From f58cad6b1323d0488fc8806a3821d1376d679d30 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 17 Jan 2017 12:11:57 +0530 Subject: [PATCH] [Fix] Calculate paid amount when is pos is enabled --- .../doctype/sales_invoice/sales_invoice.json | 5 +++-- erpnext/controllers/taxes_and_totals.py | 10 ++++++---- erpnext/public/js/controllers/taxes_and_totals.js | 12 +++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index 2a0738925b..534f96521f 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -2385,7 +2385,7 @@ "in_standard_filter": 0, "label": "Sales Invoice Payment", "length": 0, - "no_copy": 0, + "no_copy": 1, "options": "Sales Invoice Payment", "permlevel": 0, "precision": "", @@ -3188,6 +3188,7 @@ "ignore_xss_filter": 0, "in_filter": 1, "in_list_view": 0, + "in_standard_filter": 0, "label": "Status", "length": 0, "no_copy": 1, @@ -4182,7 +4183,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-11-09 14:18:24.760263", + "modified": "2017-01-17 11:07:25.814402", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 2369143604..57bceeec3e 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -455,10 +455,12 @@ class calculate_taxes_and_totals(object): def calculate_paid_amount(self): paid_amount = base_paid_amount = 0.0 - for payment in self.doc.get('payments'): - payment.base_amount = flt(payment.amount * self.doc.conversion_rate) - paid_amount += payment.amount - base_paid_amount += payment.base_amount + + if self.doc.is_pos: + for payment in self.doc.get('payments'): + payment.base_amount = flt(payment.amount * self.doc.conversion_rate) + paid_amount += payment.amount + base_paid_amount += payment.base_amount self.doc.paid_amount = flt(paid_amount, self.doc.precision("paid_amount")) self.doc.base_paid_amount = flt(base_paid_amount, self.doc.precision("base_paid_amount")) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 4b14d08eda..6f55a4411a 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -588,11 +588,13 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ calculate_paid_amount: function(){ var me = this; var paid_amount = base_paid_amount = 0.0; - $.each(this.frm.doc['payments'] || [], function(index, data){ - data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount")); - paid_amount += data.amount; - base_paid_amount += data.base_amount; - }) + if(this.frm.doc.is_pos) { + $.each(this.frm.doc['payments'] || [], function(index, data){ + data.base_amount = flt(data.amount * me.frm.doc.conversion_rate, precision("base_amount")); + paid_amount += data.amount; + base_paid_amount += data.base_amount; + }) + } this.frm.doc.paid_amount = flt(paid_amount, precision("paid_amount")); this.frm.doc.base_paid_amount = flt(base_paid_amount, precision("base_paid_amount"));