mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-16 13:25:10 +00:00
fix: calculate due date based on payment term (#46416)
(cherry picked from commit 9e808c832f)
This commit is contained in:
committed by
Mergify
parent
27105501fb
commit
9e7a5bb1bb
@@ -498,7 +498,13 @@ class SalesInvoice(SellingController):
|
|||||||
"Account", self.debit_to, "account_currency", cache=True
|
"Account", self.debit_to, "account_currency", cache=True
|
||||||
)
|
)
|
||||||
if not self.due_date and self.customer:
|
if not self.due_date and self.customer:
|
||||||
self.due_date = get_due_date(self.posting_date, "Customer", self.customer, self.company)
|
self.due_date = get_due_date(
|
||||||
|
self.posting_date,
|
||||||
|
"Customer",
|
||||||
|
self.customer,
|
||||||
|
self.company,
|
||||||
|
template_name=self.payment_terms_template,
|
||||||
|
)
|
||||||
|
|
||||||
super().set_missing_values(for_validate)
|
super().set_missing_values(for_validate)
|
||||||
|
|
||||||
|
|||||||
@@ -552,12 +552,13 @@ def validate_party_accounts(doc):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_due_date(posting_date, party_type, party, company=None, bill_date=None):
|
def get_due_date(posting_date, party_type, party, company=None, bill_date=None, template_name=None):
|
||||||
"""Get due date from `Payment Terms Template`"""
|
"""Get due date from `Payment Terms Template`"""
|
||||||
due_date = None
|
due_date = None
|
||||||
if (bill_date or posting_date) and party:
|
if (bill_date or posting_date) and party:
|
||||||
due_date = bill_date or posting_date
|
due_date = bill_date or posting_date
|
||||||
template_name = get_payment_terms_template(party, party_type, company)
|
if not template_name:
|
||||||
|
template_name = get_payment_terms_template(party, party_type, company)
|
||||||
|
|
||||||
if template_name:
|
if template_name:
|
||||||
due_date = get_due_date_from_template(template_name, posting_date, bill_date).strftime("%Y-%m-%d")
|
due_date = get_due_date_from_template(template_name, posting_date, bill_date).strftime("%Y-%m-%d")
|
||||||
|
|||||||
Reference in New Issue
Block a user