Merge pull request #10062 from rohitwaghchaure/set_defualt_mode_payment

[enhance] Provision to set default mode of payment for the POS in POS profile
This commit is contained in:
Nabin Hait 2017-07-28 21:10:05 +05:30 committed by GitHub
commit e09b507b6c
15 changed files with 170 additions and 9 deletions

View File

@ -14,6 +14,7 @@ class POSProfile(Document):
self.check_for_duplicate() self.check_for_duplicate()
self.validate_all_link_fields() self.validate_all_link_fields()
self.validate_duplicate_groups() self.validate_duplicate_groups()
self.check_default_payment()
def check_for_duplicate(self): def check_for_duplicate(self):
res = frappe.db.sql("""select name, user from `tabPOS Profile` res = frappe.db.sql("""select name, user from `tabPOS Profile`
@ -48,6 +49,15 @@ class POSProfile(Document):
if len(customer_groups) != len(set(customer_groups)): if len(customer_groups) != len(set(customer_groups)):
frappe.throw(_("Duplicate customer group found in the cutomer group table"), title = "Duplicate Customer Group") frappe.throw(_("Duplicate customer group found in the cutomer group table"), title = "Duplicate Customer Group")
def check_default_payment(self):
if self.payments:
default_mode_of_payment = [d.default for d in self.payments if d.default]
if not default_mode_of_payment:
frappe.throw(_("Set default mode of payment"))
if len(default_mode_of_payment) > 1:
frappe.throw(_("Multiple default mode of payment is not allowed"))
def before_save(self): def before_save(self):
set_account_for_mode_of_payment(self) set_account_for_mode_of_payment(self)

View File

@ -31,6 +31,8 @@ class TestPOSProfile(unittest.TestCase):
frappe.db.sql("delete from `tabPOS Profile`") frappe.db.sql("delete from `tabPOS Profile`")
def make_pos_profile(): def make_pos_profile():
frappe.db.sql("delete from `tabPOS Profile`")
pos_profile = frappe.get_doc({ pos_profile = frappe.get_doc({
"company": "_Test Company", "company": "_Test Company",
"cost_center": "_Test Cost Center - _TC", "cost_center": "_Test Cost Center - _TC",

View File

@ -1,5 +1,6 @@
{ {
"allow_copy": 0, "allow_copy": 0,
"allow_guest_to_view": 0,
"allow_import": 0, "allow_import": 0,
"allow_rename": 0, "allow_rename": 0,
"beta": 0, "beta": 0,
@ -11,16 +12,51 @@
"editable_grid": 1, "editable_grid": 1,
"fields": [ "fields": [
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"depends_on": "eval:parent.doctype == 'POS Profile'",
"fieldname": "default",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Default",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "mode_of_payment", "fieldname": "mode_of_payment",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Mode of Payment", "label": "Mode of Payment",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -30,6 +66,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
@ -37,9 +74,11 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"default": "0.0", "default": "0.0",
"depends_on": "eval:parent.doctype == 'Sales Invoice'", "depends_on": "eval:parent.doctype == 'Sales Invoice'",
"fieldname": "amount", "fieldname": "amount",
@ -48,7 +87,9 @@
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 0,
"label": "Amount", "label": "Amount",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -58,6 +99,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 1, "reqd": 1,
"search_index": 0, "search_index": 0,
@ -65,16 +107,20 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "column_break_3", "fieldname": "column_break_3",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"permlevel": 0, "permlevel": 0,
@ -82,6 +128,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -89,16 +136,20 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "account", "fieldname": "account",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Account", "label": "Account",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -108,6 +159,7 @@
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -115,16 +167,20 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "type", "fieldname": "type",
"fieldtype": "Read Only", "fieldtype": "Read Only",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Type", "label": "Type",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
@ -134,6 +190,7 @@
"print_hide": 0, "print_hide": 0,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -141,16 +198,20 @@
"unique": 0 "unique": 0
}, },
{ {
"allow_bulk_edit": 0,
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0,
"fieldname": "base_amount", "fieldname": "base_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
"in_filter": 0, "in_filter": 0,
"in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 0,
"label": "Base Amount (Company Currency)", "label": "Base Amount (Company Currency)",
"length": 0, "length": 0,
"no_copy": 1, "no_copy": 1,
@ -160,6 +221,7 @@
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 1, "read_only": 1,
"remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 0,
"search_index": 0, "search_index": 0,
@ -167,17 +229,17 @@
"unique": 0 "unique": 0
} }
], ],
"has_web_view": 0,
"hide_heading": 0, "hide_heading": 0,
"hide_toolbar": 0, "hide_toolbar": 0,
"idx": 0, "idx": 0,
"image_view": 0, "image_view": 0,
"in_create": 0, "in_create": 0,
"in_dialog": 0,
"is_submittable": 0, "is_submittable": 0,
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-07-11 03:28:07.779228", "modified": "2017-07-24 17:25:03.765856",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Sales Invoice Payment", "name": "Sales Invoice Payment",
@ -187,7 +249,9 @@
"quick_entry": 1, "quick_entry": 1,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"track_changes": 0,
"track_seen": 0 "track_seen": 0
} }

View File

@ -0,0 +1,60 @@
QUnit.test("test:POS Profile", function(assert) {
assert.expect(1);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("POS Profile", [
{naming_series: "SINV"},
{company: "_Test Company"},
{country: "India"},
{currency: "INR"},
{write_off_account: "Write Off - _TC"},
{write_off_cost_center: "Main - _TC"},
{payments: [
[
{"default": 1},
{"mode_of_payment": "Cash"}
]]
}
]);
},
() => cur_frm.save(),
() => frappe.timeout(2),
() => {
assert.equal(cur_frm.doc.payments[0].default, 1, "Default mode of payment tested");
},
() => done()
]);
});
QUnit.test("test:Sales Invoice", function(assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => {
return frappe.tests.make("Sales Invoice", [
{customer: "_Test Customer 2"},
{company: "_Test Company"},
{is_pos: 1},
{posting_date: frappe.datetime.get_today()},
{due_date: frappe.datetime.get_today()},
{items: [
[
{"item_code": "_Test Item"},
{"qty": 5}
]]
}
]);
},
() => frappe.timeout(2),
() => cur_frm.save(),
() => frappe.timeout(2),
() => {
assert.equal(cur_frm.doc.payments[0].default, 1, "Default mode of payment tested");
assert.equal(cur_frm.doc.payments[0].mode_of_payment, "Cash", "Default mode of payment tested");
},
() => done()
]);
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

View File

@ -15,7 +15,7 @@ POS Invoices created in the offline mode will be saved locally in the browser. I
In ERPNext all Sales and Purchase transactions, like Sales Invoice, Quotation, Sales Order, Purchase Order etc. can be edited via the POS. There two steps to Setup POS: In ERPNext all Sales and Purchase transactions, like Sales Invoice, Quotation, Sales Order, Purchase Order etc. can be edited via the POS. There two steps to Setup POS:
1. Enable POS View via (Setup > Customize > Feature Setup) 1. Enable POS View via (Setup > Customize > Feature Setup)
2. Create a [POS Setting]({{docs_base_url}}/user/manual/en/setting-up/pos-setting.html) record 2. Create a [POS Profile]({{docs_base_url}}/user/manual/en/setting-up/pos-setting.html) record
#### Different sections of the POS #### Different sections of the POS

View File

@ -1,4 +1,4 @@
# Point of Sale Setting # Point of Sale Profile
POS includes advanced features to cater to different functionality, such as POS includes advanced features to cater to different functionality, such as
inventory management, CRM, financials, warehousing, etc., all built into the inventory management, CRM, financials, warehousing, etc., all built into the
@ -10,11 +10,17 @@ If you are in retail operations, you want your Point of Sale to be as quick
and efficient as possible. To do this, you can create a POS Setting for a user and efficient as possible. To do this, you can create a POS Setting for a user
from: from:
> Accounts > Setup > Point-of-Sale Setting > Accounts > Setup > Point-of-Sale Profile
Set default values as defined. Set default values as defined.
<img class="screenshot" alt="POS Setting" src="{{docs_base_url}}/assets/img/pos-setting/pos-setting.png"> <img class="screenshot" alt="POS Setting" src="{{docs_base_url}}/assets/img/pos-setting/pos_profile.png">
To set the default mode of payment, enabled the option default in the mode of payments table
<img class="screenshot" alt="POS Setting" src="{{docs_base_url}}/assets/img/pos-setting/default_mop.png">
User can sale the particular products to the particular customers from the POS by adding item groups, customer groups in the POS Profile.
<img class="screenshot" alt="POS Setting" src="{{docs_base_url}}/assets/img/pos-setting/item_customer_group.png">
> Important : If you specify a particular User, the POS setting will be > Important : If you specify a particular User, the POS setting will be
applied only to that User. If the User option is left blank, the setting will applied only to that User. If the User option is left blank, the setting will

View File

@ -427,3 +427,4 @@ erpnext.patches.v8_1.set_delivery_date_in_so_item
erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs
erpnext.patches.v8_5.remove_quotations_route_in_sidebar erpnext.patches.v8_5.remove_quotations_route_in_sidebar
erpnext.patches.v8_5.update_existing_data_in_project_type erpnext.patches.v8_5.update_existing_data_in_project_type
erpnext.patches.v8_5.set_default_mode_of_payment

View File

@ -0,0 +1,17 @@
# Copyright (c) 2017, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doctype("POS Profile")
frappe.reload_doctype("Sales Invoice Payment")
frappe.db.sql("""
update
`tabSales Invoice Payment`
set `tabSales Invoice Payment`.default = 1
where
`tabSales Invoice Payment`.parenttype = 'POS Profile'
and `tabSales Invoice Payment`.idx=1""")

View File

@ -584,7 +584,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
var payment_status = true; var payment_status = true;
if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){ if(this.frm.doc.is_pos && (update_paid_amount===undefined || update_paid_amount)){
$.each(this.frm.doc['payments'] || [], function(index, data){ $.each(this.frm.doc['payments'] || [], function(index, data){
if(data.type == "Cash" && payment_status && total_amount_to_pay > 0) { if(data.default && payment_status && total_amount_to_pay > 0) {
data.base_amount = flt(total_amount_to_pay, precision("base_amount")); data.base_amount = flt(total_amount_to_pay, precision("base_amount"));
data.amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount")); data.amount = flt(total_amount_to_pay / me.frm.doc.conversion_rate, precision("amount"));
payment_status = false; payment_status = false;

View File

@ -17,6 +17,6 @@
</div> </div>
<div class="pos-list-row"> <div class="pos-list-row">
<div class="cell">{{ __("Amount") }}:</div> <div class="cell">{{ __("Amount") }}:</div>
<input type="tel" class="form-control cell pos-amount" value="{%= amount %}"/> <input type="tel" class="form-control cell pos-amount" disabled value="{%= amount %}"/>
</div> </div>
</div> </div>

View File

@ -31,4 +31,5 @@ erpnext/schools/doctype/student_batch_name/test_student_batch_name.js
erpnext/schools/doctype/student_category/test_student_category.js erpnext/schools/doctype/student_category/test_student_category.js
erpnext/schools/doctype/room/test_room.js erpnext/schools/doctype/room/test_room.js
erpnext/schools/doctype/instructor/test_instructor.js erpnext/schools/doctype/instructor/test_instructor.js
erpnext/accounts/page/pos/test_pos.js
erpnext/selling/doctype/product_bundle/test_product_bundle.js erpnext/selling/doctype/product_bundle/test_product_bundle.js