Skip to content

Commit

Permalink
fix: Don't add to deductions if amount is 0
Browse files Browse the repository at this point in the history
- misc: better docstring
  • Loading branch information
marination committed Mar 7, 2023
1 parent ee12313 commit f02fc8a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
},
)

Expand Down

0 comments on commit f02fc8a

Please sign in to comment.