fix: Write off amount wrongly calculated in POS Invoice
(cherry picked from commit ee4258e42c33899fae7b7add8a676274259a40e0)
This commit is contained in:
parent
0534cf6c9c
commit
f57f4af1d9
@ -581,6 +581,7 @@ class calculate_taxes_and_totals(object):
|
||||
|
||||
if self.doc.docstatus == 0:
|
||||
self.calculate_outstanding_amount()
|
||||
self.calculate_write_off_amount()
|
||||
|
||||
def is_internal_invoice(self):
|
||||
"""
|
||||
@ -621,7 +622,6 @@ class calculate_taxes_and_totals(object):
|
||||
change_amount = 0
|
||||
|
||||
if self.doc.doctype == "Sales Invoice" and not self.doc.get('is_return'):
|
||||
self.calculate_write_off_amount()
|
||||
self.calculate_change_amount()
|
||||
change_amount = self.doc.change_amount \
|
||||
if self.doc.party_account_currency == self.doc.currency else self.doc.base_change_amount
|
||||
@ -671,19 +671,20 @@ class calculate_taxes_and_totals(object):
|
||||
and self.doc.paid_amount > grand_total and not self.doc.is_return \
|
||||
and any(d.type == "Cash" for d in self.doc.payments):
|
||||
|
||||
self.doc.change_amount = flt(self.doc.paid_amount - grand_total +
|
||||
self.doc.write_off_amount, self.doc.precision("change_amount"))
|
||||
self.doc.change_amount = flt(self.doc.paid_amount - grand_total,
|
||||
self.doc.precision("change_amount"))
|
||||
|
||||
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"))
|
||||
self.doc.base_change_amount = flt(self.doc.base_paid_amount - base_grand_total,
|
||||
self.doc.precision("base_change_amount"))
|
||||
|
||||
def calculate_write_off_amount(self):
|
||||
if flt(self.doc.change_amount) > 0:
|
||||
self.doc.write_off_amount = flt(self.doc.grand_total - self.doc.paid_amount
|
||||
+ self.doc.change_amount, self.doc.precision("write_off_amount"))
|
||||
if self.doc.write_off_outstanding_amount_automatically:
|
||||
self.doc.write_off_amount = flt(self.doc.outstanding_amount, self.doc.precision("write_off_amount"))
|
||||
self.doc.base_write_off_amount = flt(self.doc.write_off_amount * self.doc.conversion_rate,
|
||||
self.doc.precision("base_write_off_amount"))
|
||||
|
||||
self.calculate_outstanding_amount()
|
||||
|
||||
def calculate_margin(self, item):
|
||||
rate_with_margin = 0.0
|
||||
base_rate_with_margin = 0.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user