Merge pull request #12773 from rohitwaghchaure/change_amount_issue
[Fix] Incorrect change amount if enabled rounded total
This commit is contained in:
commit
ba31369764
@ -491,11 +491,13 @@ class calculate_taxes_and_totals(object):
|
||||
if self.doc.doctype == "Sales Invoice" \
|
||||
and self.doc.paid_amount > self.doc.grand_total and not self.doc.is_return \
|
||||
and any([d.type == "Cash" for d in self.doc.payments]):
|
||||
grand_total = self.doc.rounded_total or self.doc.grand_total
|
||||
base_grand_total = self.doc.base_rounded_total or self.doc.base_grand_total
|
||||
|
||||
self.doc.change_amount = flt(self.doc.paid_amount - self.doc.grand_total +
|
||||
self.doc.change_amount = flt(self.doc.paid_amount - grand_total +
|
||||
self.doc.write_off_amount, self.doc.precision("change_amount"))
|
||||
|
||||
self.doc.base_change_amount = flt(self.doc.base_paid_amount - self.doc.base_grand_total +
|
||||
self.doc.base_change_amount = flt(self.doc.base_paid_amount - base_grand_total +
|
||||
self.doc.base_write_off_amount, self.doc.precision("base_change_amount"))
|
||||
|
||||
def calculate_write_off_amount(self):
|
||||
|
@ -653,11 +653,14 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
||||
|
||||
var payment_types = $.map(this.frm.doc.payments, function(d) { return d.type; });
|
||||
if (in_list(payment_types, 'Cash')) {
|
||||
this.frm.doc.change_amount = flt(this.frm.doc.paid_amount - this.frm.doc.grand_total +
|
||||
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.base_change_amount = flt(this.frm.doc.base_paid_amount -
|
||||
this.frm.doc.base_grand_total + this.frm.doc.base_write_off_amount,
|
||||
base_grand_total + this.frm.doc.base_write_off_amount,
|
||||
precision("base_change_amount"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user