diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 30e01cfef5..f04328fd09 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -339,7 +339,7 @@ erpnext.POS = Class.extend({ } // if form is submitted & cancelled then disable all input box & buttons - if (cur_frm.doc.docstatus>=1) { + if (cur_frm.doc.docstatus>=1 && cint(cur_frm.doc.is_pos)) { me.wrapper.find('input, button').each(function () { $(this).prop('disabled', true); }); diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 8cc94f9154..1378fab51a 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -27,10 +27,11 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } // 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 ((cint(wn.defaults.get_user_defaults("is_pos"))===1 || cur_frm.doc.is_pos) && + cint(wn.defaults.get_user_defaults("fs_pos_view"))===1) { + 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" @@ -191,7 +192,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte flt(this.frm.doc.grand_total - this.frm.doc.paid_amount), precision("write_off_amount")); } - this.frm.runclientscript("write_off_amount"); + this.frm.script_manager.trigger("write_off_amount"); }, write_off_amount: function() { diff --git a/patches/patch_list.py b/patches/patch_list.py index 94e6d2bdef..f587563599 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -261,5 +261,6 @@ patch_list = [ "execute:webnotes.reload_doc('accounts', 'Print Format', 'POS Invoice') # 2013-09-02", "patches.september_2013.p01_fix_buying_amount_gl_entries", "patches.september_2013.p01_update_communication", + "patches.september_2013.p02_make_pos_view_checked_in_features_setup", "patches.september_2013.p02_fix_serial_no_status", ] \ No newline at end of file diff --git a/patches/september_2013/p02_make_pos_view_checked_in_features_setup.py b/patches/september_2013/p02_make_pos_view_checked_in_features_setup.py new file mode 100644 index 0000000000..c5e2c7bc60 --- /dev/null +++ b/patches/september_2013/p02_make_pos_view_checked_in_features_setup.py @@ -0,0 +1,11 @@ +# 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(): + webnotes.reload_doc("setup", "doctype", "features_setup") + fs = webnotes.bean("Features Setup") + fs.doc.fs_pos_view = 1 + fs.save() \ No newline at end of file diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js index 5c0c96ad56..0308dfcd25 100644 --- a/selling/doctype/sales_common/sales_common.js +++ b/selling/doctype/sales_common/sales_common.js @@ -432,14 +432,16 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ calculate_outstanding_amount: function() { // NOTE: - // write_off_amount is only for POS Invoice + // paid_amount and write_off_amount is only for POS Invoice // total_advance is only for non POS Invoice if(this.frm.doc.doctype == "Sales Invoice" && this.frm.doc.docstatus==0) { wn.model.round_floats_in(this.frm.doc, ["grand_total", "total_advance", "write_off_amount", "paid_amount"]); - var total_amount_to_pay = this.frm.doc.grand_total - this.frm.doc.write_off_amount; - this.frm.doc.outstanding_amount = flt(total_amount_to_pay - this.frm.doc.total_advance - - this.frm.doc.paid_amount, precision("outstanding_amount")); + var total_amount_to_pay = this.frm.doc.grand_total - this.frm.doc.write_off_amount - this.frm.doc.total_advance; + this.frm.doc.paid_amount = this.frm.doc.is_pos? flt(total_amount_to_pay): 0.0; + + this.frm.doc.outstanding_amount = flt(total_amount_to_pay - this.frm.doc.paid_amount, + precision("outstanding_amount")); } },