From f02fc8acf0d50fcc178b713a1385595a40cb19f0 Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 7 Mar 2023 12:12:45 +0530 Subject: [PATCH] fix: Don't add to deductions if amount is 0 - misc: better docstring --- erpnext/accounts/doctype/payment_entry/payment_entry.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 6e612eeee742..f927b1b887d0 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -1941,7 +1941,7 @@ def apply_early_payment_discount(paid_amount, received_amount, doc): def set_early_payment_discount_loss(pe, doc, valid_discounts, discount_amount): - """Split early bird discount deductions into Income Loss & Tax Loss.""" + """Split early payment discount into Income Loss & Tax Loss.""" if not (discount_amount and valid_discounts): return discount_amount @@ -2013,12 +2013,16 @@ def add_tax_discount_loss(pe, doc, total_discount_percenatage) -> float: for account, loss in tax_discount_loss.items(): total_tax_loss += loss + amount = flt(loss * doc.get("conversion_rate", 1), precision) + if amount == 0.0: + continue + pe.append( "deductions", { "account": account, "cost_center": pe.cost_center or frappe.get_cached_value("Company", pe.company, "cost_center"), - "amount": flt(loss * doc.get("conversion_rate", 1), precision), + "amount": amount, }, )