diff --git a/accounts/doctype/pos_setting/pos_setting.js b/accounts/doctype/pos_setting/pos_setting.js index 18f555b919..a72a96c5c0 100755 --- a/accounts/doctype/pos_setting/pos_setting.js +++ b/accounts/doctype/pos_setting/pos_setting.js @@ -49,15 +49,9 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) { } } -// ------------------ Get Print Heading ------------------------------------ -cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) { - return{ - filters:[ - ['Print Heading', 'docstatus', '!=', 2] - ] - } -} +// Expense Account +// ----------------------------- cur_frm.fields_dict["expense_account"].get_query = function(doc) { return { filters: { @@ -69,6 +63,16 @@ cur_frm.fields_dict["expense_account"].get_query = function(doc) { } } +// ------------------ Get Print Heading ------------------------------------ +cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) { + return{ + filters:[ + ['Print Heading', 'docstatus', '!=', 2] + ] + } +} + + cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) { return{ query:"controllers.queries.profile_query"} } diff --git a/accounts/doctype/pos_setting/pos_setting.py b/accounts/doctype/pos_setting/pos_setting.py index 24f45b1dab..f805518124 100755 --- a/accounts/doctype/pos_setting/pos_setting.py +++ b/accounts/doctype/pos_setting/pos_setting.py @@ -20,6 +20,7 @@ class DocType: def validate(self): self.check_for_duplicate() self.validate_expense_account() + self.validate_all_link_fields() def check_for_duplicate(self): res = webnotes.conn.sql("""select name, user from `tabPOS Setting` @@ -38,6 +39,15 @@ class DocType: and not self.doc.expense_account: msgprint(_("Expense Account is mandatory"), raise_exception=1) + def validate_all_link_fields(self): + accounts = {"Account": [self.doc.cash_bank_account, self.doc.income_account, self.doc.expense_account], \ + "Cost Center": [self.doc.cost_center], "Warehouse": [self.doc.warehouse]} + + for link_dt, dn_list in accounts.items(): + for link_dn in dn_list: + if not webnotes.conn.exists({"doctype": link_dt, "company": self.doc.company, "name": link_dn}): + msgprint(link_dn +_(" does not belong to ") + self.doc.company) + def on_update(self): webnotes.defaults.clear_default("is_pos") diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index a092e2863f..5dfe6c2911 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -292,10 +292,11 @@ erpnext.POS = Class.extend({ $.each(taxes, function(i, d) { $(repl('\ - %(description)s\ + %(description)s (%(rate)s%)\ %(tax_amount)s\ ', { description: d.description, + rate: d.rate, tax_amount: format_currency(d.tax_amount, me.frm.doc.price_list_currency) })).appendTo(".tax-table tbody"); }); @@ -429,6 +430,7 @@ erpnext.POS = Class.extend({ dialog.fields_dict.pay.input.onclick = function() { cur_frm.set_value("mode_of_payment", dialog.get_values().mode_of_payment); cur_frm.set_value("paid_amount", dialog.get_values().total_amount); + cur_frm.cscript.mode_of_payment(cur_frm.doc); cur_frm.save(); dialog.hide(); me.refresh(); diff --git a/setup/doctype/company/company.js b/setup/doctype/company/company.js index 6ae1626809..c8042710a6 100644 --- a/setup/doctype/company/company.js +++ b/setup/doctype/company/company.js @@ -36,8 +36,6 @@ cur_frm.cscript.abbr = function(doc){ } } -cur_frm.fields_dict.default_cash_account.get_query = cur_frm.fields_dict.default_bank_account.get_query; - cur_frm.fields_dict.default_bank_account.get_query = function(doc) { return{ filters:{ @@ -48,7 +46,7 @@ cur_frm.fields_dict.default_bank_account.get_query = function(doc) { } } -cur_frm.fields_dict.payables_group.get_query = cur_frm.fields_dict.receivables_group.get_query; +cur_frm.fields_dict.default_cash_account.get_query = cur_frm.fields_dict.default_bank_account.get_query; cur_frm.fields_dict.receivables_group.get_query = function(doc) { return{ @@ -59,6 +57,39 @@ cur_frm.fields_dict.receivables_group.get_query = function(doc) { } } +cur_frm.fields_dict.payables_group.get_query = cur_frm.fields_dict.receivables_group.get_query; + +cur_frm.fields_dict.default_expense_account.get_query = function(doc) { + return{ + filters:{ + 'company': doc.name, + 'group_or_ledger': "Ledger", + 'is_pl_account': "Yes", + 'debit_or_credit': "Debit" + } + } +} + +cur_frm.fields_dict.default_income_account.get_query = function(doc) { + return{ + filters:{ + 'company': doc.name, + 'group_or_ledger': "Ledger", + 'is_pl_account': "Yes", + 'debit_or_credit': "Credit" + } + } +} + +cur_frm.fields_dict.cost_center.get_query = function(doc) { + return{ + filters:{ + 'company': doc.name, + 'group_or_ledger': "Ledger", + } + } +} + if (sys_defaults.auto_inventory_accounting) { cur_frm.fields_dict["stock_in_hand_account"].get_query = function(doc) { return { diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index 66c83d6933..eeff2d1bef 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -48,7 +48,8 @@ class DocType: self.create_default_warehouses() self.create_default_web_page() - if not self.doc.cost_center: + if not webnotes.conn.get_value("Cost Center", {"group_or_ledger": "Ledger", + "company": self.doc.name}): self.create_default_cost_center() self.set_default_accounts()