From d04d3038f5764e6eb228aea3cad7e9f3b98848ab Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 24 Mar 2022 12:56:22 +0530 Subject: [PATCH] fix: Client side changes for POS Write off amount (cherry picked from commit 2e33e748ea248acface128f759d3982635024399) # Conflicts: # erpnext/public/js/controllers/taxes_and_totals.js --- .../public/js/controllers/taxes_and_totals.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 9fec43b74e..56454c8942 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -690,7 +690,12 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { this.frm.doc.total_advance = flt(total_allocated_amount, precision("total_advance")); this.calculate_outstanding_amount(update_paid_amount); +<<<<<<< HEAD } +======= + this.calculate_write_off_amount(); + }, +>>>>>>> 2e33e748ea (fix: Client side changes for POS Write off amount) is_internal_invoice() { if (['Sales Invoice', 'Purchase Invoice'].includes(this.frm.doc.doctype)) { @@ -825,26 +830,28 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { var grand_total = this.frm.doc.rounded_total || this.frm.doc.grand_total; var base_grand_total = this.frm.doc.base_rounded_total || this.frm.doc.base_grand_total; - this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - grand_total + - this.frm.doc.write_off_amount, precision("change_amount")); + this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - grand_total, + precision("change_amount")); this.frm.doc.base_change_amount = flt(this.frm.doc.base_paid_amount - - base_grand_total + this.frm.doc.base_write_off_amount, - precision("base_change_amount")); + base_grand_total, precision("base_change_amount")); } } } +<<<<<<< HEAD calculate_write_off_amount(){ if(this.frm.doc.paid_amount > this.frm.doc.grand_total){ +======= + calculate_write_off_amount: function() { + if (this.frm.doc.write_off_outstanding_amount_automatically) { +>>>>>>> 2e33e748ea (fix: Client side changes for POS Write off amount) this.frm.doc.write_off_amount = flt(this.frm.doc.grand_total - this.frm.doc.paid_amount + this.frm.doc.change_amount, precision("write_off_amount")); - this.frm.doc.base_write_off_amount = flt(this.frm.doc.write_off_amount * this.frm.doc.conversion_rate, precision("base_write_off_amount")); - }else{ - this.frm.doc.paid_amount = 0.0; } + this.calculate_outstanding_amount(false); } };