mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 09:54:47 +00:00
fix: Write off amount wrongly calculated in POS Invoice
This commit is contained in:
@@ -585,6 +585,7 @@ class calculate_taxes_and_totals(object):
|
|||||||
|
|
||||||
if self.doc.docstatus == 0:
|
if self.doc.docstatus == 0:
|
||||||
self.calculate_outstanding_amount()
|
self.calculate_outstanding_amount()
|
||||||
|
self.calculate_write_off_amount()
|
||||||
|
|
||||||
def is_internal_invoice(self):
|
def is_internal_invoice(self):
|
||||||
"""
|
"""
|
||||||
@@ -625,7 +626,6 @@ class calculate_taxes_and_totals(object):
|
|||||||
change_amount = 0
|
change_amount = 0
|
||||||
|
|
||||||
if self.doc.doctype == "Sales Invoice" and not self.doc.get('is_return'):
|
if self.doc.doctype == "Sales Invoice" and not self.doc.get('is_return'):
|
||||||
self.calculate_write_off_amount()
|
|
||||||
self.calculate_change_amount()
|
self.calculate_change_amount()
|
||||||
change_amount = self.doc.change_amount \
|
change_amount = self.doc.change_amount \
|
||||||
if self.doc.party_account_currency == self.doc.currency else self.doc.base_change_amount
|
if self.doc.party_account_currency == self.doc.currency else self.doc.base_change_amount
|
||||||
@@ -675,19 +675,20 @@ class calculate_taxes_and_totals(object):
|
|||||||
and self.doc.paid_amount > grand_total and not self.doc.is_return \
|
and self.doc.paid_amount > grand_total and not self.doc.is_return \
|
||||||
and any(d.type == "Cash" for d in self.doc.payments):
|
and any(d.type == "Cash" for d in self.doc.payments):
|
||||||
|
|
||||||
self.doc.change_amount = flt(self.doc.paid_amount - 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.precision("change_amount"))
|
||||||
|
|
||||||
self.doc.base_change_amount = flt(self.doc.base_paid_amount - 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"))
|
self.doc.precision("base_change_amount"))
|
||||||
|
|
||||||
def calculate_write_off_amount(self):
|
def calculate_write_off_amount(self):
|
||||||
if flt(self.doc.change_amount) > 0:
|
if self.doc.write_off_outstanding_amount_automatically:
|
||||||
self.doc.write_off_amount = flt(self.doc.grand_total - self.doc.paid_amount
|
self.doc.write_off_amount = flt(self.doc.outstanding_amount, self.doc.precision("write_off_amount"))
|
||||||
+ self.doc.change_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.base_write_off_amount = flt(self.doc.write_off_amount * self.doc.conversion_rate,
|
||||||
self.doc.precision("base_write_off_amount"))
|
self.doc.precision("base_write_off_amount"))
|
||||||
|
|
||||||
|
self.calculate_outstanding_amount()
|
||||||
|
|
||||||
def calculate_margin(self, item):
|
def calculate_margin(self, item):
|
||||||
rate_with_margin = 0.0
|
rate_with_margin = 0.0
|
||||||
base_rate_with_margin = 0.0
|
base_rate_with_margin = 0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user