fix payment schedule discount date when no discount is applied (backport #55462) (#55568)

Co-authored-by: Vishnu Priya Baskaran <145791817+ervishnucs@users.noreply.github.com>
fix payment schedule discount date when no discount is applied (#55462)
This commit is contained in:
mergify[bot]
2026-06-03 14:10:12 +05:30
committed by GitHub
parent 20af7093ac
commit 201e62195f
2 changed files with 56 additions and 7 deletions

View File

@@ -2686,7 +2686,7 @@ class AccountsController(TransactionBase):
payment_schedule["credit_days"] = cint(schedule.credit_days)
payment_schedule["credit_months"] = cint(schedule.credit_months)
if schedule.discount_validity_based_on:
if schedule.discount_validity_based_on and flt(schedule.discount):
payment_schedule["discount_date"] = get_discount_date(schedule, posting_date)
payment_schedule["discount_validity_based_on"] = schedule.discount_validity_based_on
payment_schedule["discount_validity"] = cint(schedule.discount_validity)
@@ -2728,6 +2728,8 @@ class AccountsController(TransactionBase):
return
for d in self.get("payment_schedule"):
if not flt(d.discount):
d.discount_date = None
d.validate_from_to_dates("discount_date", "due_date")
if self.doctype in ["Sales Order", "Quotation"] and getdate(d.due_date) < getdate(
self.transaction_date
@@ -3606,12 +3608,11 @@ def get_payment_term_details(
term_details.outstanding = term_details.payment_amount
term_details.base_outstanding = term_details.base_payment_amount
if bill_date:
term_details.due_date = get_due_date(term, bill_date)
term_details.discount_date = get_discount_date(term, bill_date)
elif posting_date:
term_details.due_date = get_due_date(term, posting_date)
term_details.discount_date = get_discount_date(term, posting_date)
has_discount = flt(term.get("discount"))
date = bill_date or posting_date
if date:
term_details.due_date = get_due_date(term, date)
term_details.discount_date = get_discount_date(term, date) if has_discount else None
if getdate(term_details.due_date) < getdate(posting_date):
term_details.due_date = posting_date