From 33ae0fa2f4a7fefff85198f3a1faf62be6e0e833 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 17:38:00 +0530 Subject: [PATCH] fix: correctly calculate diff amount for included taxes (#39655) fix: correctly calculate diff amount for included taxes (#39655) (cherry picked from commit 772f540bef28117c008512ead6558db801d395cd) (cherry picked from commit 350b2cdde39c2c318f286bc01c54ebdb681e8a2d) Co-authored-by: Gursheen Kaur Anand <40693548+GursheenK@users.noreply.github.com> --- .../doctype/payment_entry/payment_entry.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 66c82be596c..b89854b172a 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -874,19 +874,19 @@ class PaymentEntry(AccountsController): ) base_party_amount = flt(self.base_total_allocated_amount) + flt(base_unallocated_amount) - - if self.payment_type == "Receive": - self.difference_amount = base_party_amount - self.base_received_amount - elif self.payment_type == "Pay": - self.difference_amount = self.base_paid_amount - base_party_amount - else: - self.difference_amount = self.base_paid_amount - flt(self.base_received_amount) - - total_deductions = sum(flt(d.amount) for d in self.get("deductions")) included_taxes = self.get_included_taxes() + if self.payment_type == "Receive": + self.difference_amount = base_party_amount - self.base_received_amount + included_taxes + elif self.payment_type == "Pay": + self.difference_amount = self.base_paid_amount - base_party_amount - included_taxes + else: + self.difference_amount = self.base_paid_amount - flt(self.base_received_amount) - included_taxes + + total_deductions = sum(flt(d.amount) for d in self.get("deductions")) + self.difference_amount = flt( - self.difference_amount - total_deductions - included_taxes, self.precision("difference_amount") + self.difference_amount - total_deductions, self.precision("difference_amount") ) def get_included_taxes(self):