From 1f0b8606d6fd16e9ac64158507cdeb554c4b1115 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 23 Aug 2013 18:22:32 +0530 Subject: [PATCH 1/6] [pos][minor] --- accounts/doctype/sales_invoice/pos.js | 29 ++++++++++++------- .../doctype/sales_invoice/sales_invoice.js | 2 -- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 126b88745c..1c21fbefb6 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -160,10 +160,13 @@ erpnext.POS = Class.extend({ parent: this.wrapper.find(".barcode-area") }); this.barcode.make_input(); - this.barcode.$input.on("change", function() { - me.add_item_thru_barcode(); + this.barcode.$input.on("keypress", function() { + setTimeout(function() { me.barcode_timeout(); }, 1000); }); }, + barcode_timeout: function() { + me.add_item_thru_barcode(); + }, make_item_list: function() { var me = this; wn.call({ @@ -178,7 +181,7 @@ erpnext.POS = Class.extend({ me.wrapper.find(".item-list").empty(); $.each(r.message, function(index, obj) { if (obj.image) - image = ""; + image = ''; else image = '
'; @@ -230,7 +233,6 @@ erpnext.POS = Class.extend({ var child = wn.model.add_child(me.frm.doc, "Sales Invoice Item", "entries"); child.item_code = item_code; me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name); - //me.refresh(); } }, update_qty: function(item_code, qty) { @@ -262,7 +264,7 @@ erpnext.POS = Class.extend({ %(item_code)s%(item_name)s\ \ - %(rate)s
%(amount)s\ + %(amount)s
%(rate)s\ ', { item_code: d.item_code, @@ -297,14 +299,18 @@ erpnext.POS = Class.extend({ this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export, cur_frm.doc.price_list_currency)); + $("input.qty").on("focus", function() { + $(this).select(); + }); + // append quantity to the respective item after change from input box $("input.qty").on("change", function() { var item_code = $(this).closest("tr")[0].id; me.update_qty(item_code, $(this).val()); }); - // on td click highlight the respective row - $("td").on("click", function() { + // on td click toggle the highlighting of row + $("#cart tbody tr td").on("click", function() { var row = $(this).closest("tr"); if (row.attr("data-selected") == "false") { row.attr("class", "warning"); @@ -319,22 +325,25 @@ erpnext.POS = Class.extend({ }); me.refresh_delete_btn(); + cur_frm.pos.barcode.$input.focus(); }, refresh_delete_btn: function() { $(".delete-items").toggle($(".item-cart .warning").length ? true : false); }, add_item_thru_barcode: function() { var me = this; + clearTimeout(); wn.call({ method: 'accounts.doctype.sales_invoice.pos.get_item_from_barcode', args: {barcode: this.barcode.$input.val()}, callback: function(r) { if (r.message) { me.add_to_cart(r.message[0].name); - me.refresh(); } else msgprint(wn._("Invalid Barcode")); + + me.refresh(); } }); }, @@ -348,9 +357,6 @@ erpnext.POS = Class.extend({ selected_items.push(row.attr("id")); } } - - if (!selected_items[0]) - msgprint(wn._("Please select any item to remove it")); var child = wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries", "Sales Invoice"); @@ -362,6 +368,7 @@ erpnext.POS = Class.extend({ } }); cur_frm.fields_dict["entries"].grid.refresh(); + cur_frm.script_manager.trigger("calculate_taxes_and_totals"); me.refresh(); }, make_payment: function() { diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 5d11ecbecb..e2eeeac309 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -97,8 +97,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte if (cint(sys_defaults.fs_pos_view)===1) cur_frm.cscript.pos_btn(); - setTimeout(function() { cur_frm.$pos_btn.click(); }, 1000); - } else { // hide shown pos for submitted records if(cur_frm.pos_active) cur_frm.cscript.toggle_pos(false); From d2714310edabc1461ef9ffc57774d2544cdd9ea2 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 28 Aug 2013 19:35:22 +0530 Subject: [PATCH 2/6] [pos][minor] barcode clear timeout done --- accounts/doctype/sales_invoice/pos.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 0bae8a30d3..1a9fb12424 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -160,8 +160,10 @@ erpnext.POS = Class.extend({ parent: this.wrapper.find(".barcode-area") }); this.barcode.make_input(); - this.barcode.$input.on("change", function() { - setTimeout(me.add_item_thru_barcode(), 1000); + this.barcode.$input.on("keypress", function() { + if(me.barcode_timeout) + clearTimeout(me.barcode_timeout); + me.barcode_timeout = setTimeout(function() { me.add_item_thru_barcode(); }, 1000); }); }, make_item_list: function() { @@ -233,19 +235,23 @@ erpnext.POS = Class.extend({ me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name); } }, - update_qty: function(item_code, qty) { + update_qty: function(item_code, qty, textbox_qty) { var me = this; $.each(wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries", "Sales Invoice"), function(i, d) { if (d.item_code == item_code) { - if (qty == 1) - d.qty += 1; - else + if (textbox_qty) { + if (qty == 0 && d.item_code == item_code) + wn.model.clear_doc(d.doctype, d.name); d.qty = qty; + } + else + d.qty += 1; me.frm.cscript.qty(me.frm.doc, d.doctype, d.name); } }); + me.frm.dirty(); me.refresh(); }, refresh: function() { @@ -288,7 +294,7 @@ erpnext.POS = Class.extend({ ', { description: d.description, tax_amount: format_currency(d.tax_amount, me.frm.doc.price_list_currency) - })).appendTo(".tax-table tbody") + })).appendTo(".tax-table tbody"); }); // set totals @@ -304,7 +310,7 @@ erpnext.POS = Class.extend({ // append quantity to the respective item after change from input box $("input.qty").on("change", function() { var item_code = $(this).closest("tr")[0].id; - me.update_qty(item_code, $(this).val()); + me.update_qty(item_code, $(this).val(), true); }); // on td click toggle the highlighting of row @@ -330,6 +336,7 @@ erpnext.POS = Class.extend({ }, add_item_thru_barcode: function() { var me = this; + me.barcode_timeout = null; wn.call({ method: 'accounts.doctype.sales_invoice.pos.get_item_from_barcode', args: {barcode: this.barcode.$input.val()}, @@ -367,6 +374,7 @@ erpnext.POS = Class.extend({ }); cur_frm.fields_dict["entries"].grid.refresh(); cur_frm.script_manager.trigger("calculate_taxes_and_totals"); + me.frm.dirty(); me.refresh(); }, make_payment: function() { From cf0b6d579fc7b3960ba6c14b34a35bd2fe616573 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Thu, 29 Aug 2013 19:21:03 +0530 Subject: [PATCH 3/6] [pos] POS Invoice print format done --- accounts/Print Format/POS Invoice/POS Invoice.txt | 4 ++-- accounts/doctype/sales_invoice/pos.js | 2 +- accounts/doctype/sales_invoice/sales_invoice.js | 5 +---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/accounts/Print Format/POS Invoice/POS Invoice.txt b/accounts/Print Format/POS Invoice/POS Invoice.txt index 672c107b84..2d48fff430 100644 --- a/accounts/Print Format/POS Invoice/POS Invoice.txt +++ b/accounts/Print Format/POS Invoice/POS Invoice.txt @@ -2,14 +2,14 @@ { "creation": "2011-12-21 11:08:55", "docstatus": 0, - "modified": "2013-08-16 16:15:46", + "modified": "2013-08-29 17:40:19", "modified_by": "Administrator", "owner": "Administrator" }, { "doc_type": "Sales Invoice", "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n\n \n \n\n\n \n\n
NO: DATE:
M/s
\n\n
\n\n
\n\n

\n\n \n \n \n \n
For
 
Signatory
\n\n\n", + "html": "\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n
RECEIPT NO: DATE:
M/s
\n\n
\n\n\n", "module": "Accounts", "name": "__common__", "print_format_type": "Client", diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 1a9fb12424..6ef48112af 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -181,7 +181,7 @@ erpnext.POS = Class.extend({ $.each(r.message, function(index, obj) { if (obj.image) image = ''; + style="border:1px solid #eee;height:140px;width:100%;">'; else image = '
'; diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 85550c48a8..5cfc27105d 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -26,7 +26,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } } - if(this.frm.doc.is_pos && this.frm.doc.docstatus===0) { + if(this.frm.doc.is_pos) { cur_frm.cscript.toggle_pos(true); } }, @@ -93,9 +93,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } }); }); - } else { - // hide shown pos for submitted records - if(cur_frm.pos_active) cur_frm.cscript.toggle_pos(false); } if(cint(sys_defaults.fs_pos_view)===1) From 12425ce85e96904e09a9db596106fa93db439a8a Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 2 Sep 2013 18:48:39 +0530 Subject: [PATCH 4/6] [pos] [minor] pos completed --- .../Print Format/POS Invoice/POS Invoice.txt | 4 +- accounts/doctype/pos_setting/pos_setting.py | 18 ++++- accounts/doctype/sales_invoice/pos.js | 77 +++++++++++-------- accounts/doctype/sales_invoice/pos.py | 1 + .../doctype/sales_invoice/sales_invoice.js | 20 +++-- .../doctype/sales_invoice/sales_invoice.txt | 3 +- patches/patch_list.py | 2 + patches/september_2013/__init__.py | 1 + .../p01_add_user_defaults_from_pos_setting.py | 13 ++++ 9 files changed, 96 insertions(+), 43 deletions(-) create mode 100644 patches/september_2013/__init__.py create mode 100644 patches/september_2013/p01_add_user_defaults_from_pos_setting.py diff --git a/accounts/Print Format/POS Invoice/POS Invoice.txt b/accounts/Print Format/POS Invoice/POS Invoice.txt index 2d48fff430..ebf25e4253 100644 --- a/accounts/Print Format/POS Invoice/POS Invoice.txt +++ b/accounts/Print Format/POS Invoice/POS Invoice.txt @@ -2,14 +2,14 @@ { "creation": "2011-12-21 11:08:55", "docstatus": 0, - "modified": "2013-08-29 17:40:19", + "modified": "2013-08-30 12:46:21", "modified_by": "Administrator", "owner": "Administrator" }, { "doc_type": "Sales Invoice", "doctype": "Print Format", - "html": "\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n
RECEIPT NO: DATE:
M/s
\n\n
\n\n\n", + "html": "\n\n\n\n\n\n\n\n\n \n \n \n \n \n \n \n
RECEIPT NO: DATE:
M/s
\n\n
\n\n\n", "module": "Accounts", "name": "__common__", "print_format_type": "Client", diff --git a/accounts/doctype/pos_setting/pos_setting.py b/accounts/doctype/pos_setting/pos_setting.py index 73f5ed6e72..b794c668a0 100755 --- a/accounts/doctype/pos_setting/pos_setting.py +++ b/accounts/doctype/pos_setting/pos_setting.py @@ -7,7 +7,7 @@ from webnotes import msgprint, _ from webnotes.utils import cint class DocType: - def __init__(self,doc,doclist=[]): + def __init__(self,doc,doclist): self.doc, self.doclist = doc,doclist def get_series(self): @@ -18,6 +18,7 @@ class DocType: return series and series[0] or '' def validate(self): + self.prev_user = webnotes.conn.get_value("POS Setting", self.doc.name, "user") self.check_for_duplicate() self.validate_expense_account() @@ -36,4 +37,17 @@ class DocType: def validate_expense_account(self): if cint(webnotes.defaults.get_global_default("auto_inventory_accounting")) \ and not self.doc.expense_account: - msgprint(_("Expense Account is mandatory"), raise_exception=1) \ No newline at end of file + msgprint(_("Expense Account is mandatory"), raise_exception=1) + + def on_update(self): + webnotes.defaults.clear_default("is_pos") + + pos_view_users = webnotes.conn.sql_list("""select user from `tabPOS Setting`""") + for user in pos_view_users: + if user: + webnotes.defaults.set_user_default("is_pos", 1, user) + else: + webnotes.defaults.set_global_default("is_pos", 1) + + def on_trash(self): + self.on_update() \ No newline at end of file diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 6ef48112af..a092e2863f 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -199,13 +199,16 @@ erpnext.POS = Class.extend({ })).appendTo($wrap); }); - $("div.pos-item").on("click", function() { - if(!cur_frm.doc.customer) { - msgprint("Please select customer first."); - return; - } - me.add_to_cart($(this).attr("data-item_code")); - }); + // if form is local then allow this function + if (cur_frm.doc.docstatus===0) { + $("div.pos-item").on("click", function() { + if(!cur_frm.doc.customer) { + msgprint("Please select customer first."); + return; + } + me.add_to_cart($(this).attr("data-item_code")); + }); + } } }); }, @@ -303,33 +306,45 @@ erpnext.POS = Class.extend({ this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export, cur_frm.doc.price_list_currency)); - $("input.qty").on("focus", function() { - $(this).select(); - }); + // if form is local then only run all these functions + if (cur_frm.doc.docstatus===0) { + $("input.qty").on("focus", function() { + $(this).select(); + }); - // append quantity to the respective item after change from input box - $("input.qty").on("change", function() { - var item_code = $(this).closest("tr")[0].id; - me.update_qty(item_code, $(this).val(), true); - }); + // append quantity to the respective item after change from input box + $("input.qty").on("change", function() { + var item_code = $(this).closest("tr")[0].id; + me.update_qty(item_code, $(this).val(), true); + }); + + // on td click toggle the highlighting of row + $("#cart tbody tr td").on("click", function() { + var row = $(this).closest("tr"); + if (row.attr("data-selected") == "false") { + row.attr("class", "warning"); + row.attr("data-selected", "true"); + } + else { + row.prop("class", null); + row.attr("data-selected", "false"); + } + me.refresh_delete_btn(); + + }); - // on td click toggle the highlighting of row - $("#cart tbody tr td").on("click", function() { - var row = $(this).closest("tr"); - if (row.attr("data-selected") == "false") { - row.attr("class", "warning"); - row.attr("data-selected", "true"); - } - else { - row.prop("class", null); - row.attr("data-selected", "false"); - } me.refresh_delete_btn(); - - }); - - me.refresh_delete_btn(); - cur_frm.pos.barcode.$input.focus(); + cur_frm.pos.barcode.$input.focus(); + } + + // if form is submitted & cancelled then disable all input box & buttons + if (cur_frm.doc.docstatus>=1) { + me.wrapper.find('input, button').each(function () { + $(this).prop('disabled', true); + }); + $(".delete-items").hide(); + $(".make-payment").hide(); + } }, refresh_delete_btn: function() { $(".delete-items").toggle($(".item-cart .warning").length ? true : false); diff --git a/accounts/doctype/sales_invoice/pos.py b/accounts/doctype/sales_invoice/pos.py index 2f2ad6a36c..1b867cb8db 100644 --- a/accounts/doctype/sales_invoice/pos.py +++ b/accounts/doctype/sales_invoice/pos.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import webnotes +from webnotes import msgprint @webnotes.whitelist() def get_items(price_list, item=None, item_group=None): diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 5cfc27105d..20df233bfe 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -26,9 +26,18 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } } - if(this.frm.doc.is_pos) { + // toggle to pos view if is_pos is 1 in user_defaults + if (cint(wn.defaults.get_user_defaults("is_pos"))===1 || cur_frm.doc.is_pos) { + this.frm.set_value("is_pos", 1); + this.is_pos(); cur_frm.cscript.toggle_pos(true); } + + // if document is POS then change default print format to "POS Invoice" + if(cur_frm.doc.is_pos && cur_frm.doc.docstatus===1) { + locals.DocType[cur_frm.doctype].default_print_format = "POS Invoice"; + cur_frm.setup_print(); + } }, refresh: function(doc, dt, dn) { @@ -94,7 +103,8 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte }); }); } - + + // Show POS button only if it enabled from features setup if(cint(sys_defaults.fs_pos_view)===1) cur_frm.cscript.pos_btn(); }, @@ -115,13 +125,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte cur_frm.cscript.toggle_pos(); cur_frm.cscript.pos_btn(); }, icon); - }, - toggle_pos: function(show) { - // if(cint(sys_defaults.fs_pos_view)===0) return; - // if(!(this.frm.doc.is_pos && this.frm.doc.docstatus===0)) return; - + toggle_pos: function(show) { if (!this.frm.doc.selling_price_list) msgprint(wn._("Please select Price List")) else { diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt index dbdf42fd3e..ca2b4b243f 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.txt +++ b/accounts/doctype/sales_invoice/sales_invoice.txt @@ -2,13 +2,14 @@ { "creation": "2013-05-24 19:29:05", "docstatus": 0, - "modified": "2013-08-09 14:45:42", + "modified": "2013-09-01 05:26:13", "modified_by": "Administrator", "owner": "Administrator" }, { "allow_attach": 1, "autoname": "naming_series:", + "default_print_format": "Standard", "doctype": "DocType", "document_type": "Transaction", "icon": "icon-file-text", diff --git a/patches/patch_list.py b/patches/patch_list.py index 1d382a56bd..dd95e2dfd7 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -257,4 +257,6 @@ patch_list = [ "execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-08-16", "patches.august_2013.p06_fix_sle_against_stock_entry", "execute:webnotes.bean('Style Settings').save() #2013-08-20", + "patches.september_2013.p01_add_user_defaults_from_pos_setting", + "execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-09-02", ] \ No newline at end of file diff --git a/patches/september_2013/__init__.py b/patches/september_2013/__init__.py new file mode 100644 index 0000000000..baffc48825 --- /dev/null +++ b/patches/september_2013/__init__.py @@ -0,0 +1 @@ +from __future__ import unicode_literals diff --git a/patches/september_2013/p01_add_user_defaults_from_pos_setting.py b/patches/september_2013/p01_add_user_defaults_from_pos_setting.py new file mode 100644 index 0000000000..f3a9344464 --- /dev/null +++ b/patches/september_2013/p01_add_user_defaults_from_pos_setting.py @@ -0,0 +1,13 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + pos_view_users = webnotes.conn.sql_list("""select user from `tabPOS Setting`""") + for user in pos_view_users: + if user: + webnotes.defaults.set_user_default("is_pos", 1, user) + else: + webnotes.defaults.set_global_default("is_pos", 1) \ No newline at end of file From 45af0a18b65f8c8a34c3d0bf88f38f4294a8adbf Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 2 Sep 2013 19:05:55 +0530 Subject: [PATCH 5/6] [pos] [minor] pos setting fix --- accounts/doctype/pos_setting/pos_setting.py | 1 - 1 file changed, 1 deletion(-) diff --git a/accounts/doctype/pos_setting/pos_setting.py b/accounts/doctype/pos_setting/pos_setting.py index b794c668a0..24f45b1dab 100755 --- a/accounts/doctype/pos_setting/pos_setting.py +++ b/accounts/doctype/pos_setting/pos_setting.py @@ -18,7 +18,6 @@ class DocType: return series and series[0] or '' def validate(self): - self.prev_user = webnotes.conn.get_value("POS Setting", self.doc.name, "user") self.check_for_duplicate() self.validate_expense_account() From 734b2aab5c6890778b4028f0ba56a0268ddf9ab8 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 4 Sep 2013 18:48:08 +0530 Subject: [PATCH 6/6] [fix] pos setting link fields validate to specific company --- accounts/doctype/pos_setting/pos_setting.js | 20 ++++++----- accounts/doctype/pos_setting/pos_setting.py | 10 ++++++ accounts/doctype/sales_invoice/pos.js | 4 ++- setup/doctype/company/company.js | 37 +++++++++++++++++++-- setup/doctype/company/company.py | 3 +- 5 files changed, 61 insertions(+), 13 deletions(-) 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()