From 54106807e4be07c7815ba2188759e70749a36877 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 13 Mar 2014 17:26:41 +0530 Subject: [PATCH] Set paid amount to zero if not pos --- erpnext/selling/sales_common.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 12aca892d6f..74b9bb92282 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -403,15 +403,14 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ // 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) { - if(this.frm.doc.paid_amount==null) { - frappe.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.total_advance; - this.frm.doc.paid_amount = this.frm.doc.is_pos ? flt (total_amount_to_pay) : 0.0; - this.frm.set_value("outstanding_amount", flt(total_amount_to_pay - - this.frm.doc.paid_amount, precision("outstanding_amount"))); - } + frappe.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.total_advance; + this.frm.doc.paid_amount = (this.frm.doc.is_pos && !this.frm.doc.paid_amount) ? + flt(total_amount_to_pay): 0.0; + this.frm.set_value("outstanding_amount", flt(total_amount_to_pay + - this.frm.doc.paid_amount, precision("outstanding_amount"))); } },