Skip to content

Commit

Permalink
Merge pull request #33954 from frappe/mergify/bp/version-14-hotfix/pr…
Browse files Browse the repository at this point in the history
…-33941

fix: default due_date was wrong calculated on template "_Test Payment Term Template 1" (last day of next month) (backport #33941)
  • Loading branch information
rohitwaghchaure authored Feb 4, 2023
2 parents bccfb81 + d2836c1 commit 6df730c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion erpnext/accounts/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def get_due_date_from_template(template_name, posting_date, bill_date):
elif term.due_date_based_on == "Day(s) after the end of the invoice month":
due_date = max(due_date, add_days(get_last_day(due_date), term.credit_days))
else:
due_date = max(due_date, add_months(get_last_day(due_date), term.credit_months))
due_date = max(due_date, get_last_day(add_months(due_date, term.credit_months)))
return due_date


Expand Down
7 changes: 7 additions & 0 deletions erpnext/buying/doctype/purchase_order/test_purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from frappe.utils.data import today

from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
from erpnext.accounts.party import get_due_date_from_template
from erpnext.buying.doctype.purchase_order.purchase_order import make_inter_company_sales_order
from erpnext.buying.doctype.purchase_order.purchase_order import (
make_purchase_invoice as make_pi_from_po,
Expand Down Expand Up @@ -685,6 +686,12 @@ def test_po_for_blocked_supplier_payments_past_date(self):
else:
raise Exception

def test_default_payment_terms(self):
due_date = get_due_date_from_template(
"_Test Payment Term Template 1", "2023-02-03", None
).strftime("%Y-%m-%d")
self.assertEqual(due_date, "2023-03-31")

def test_terms_are_not_copied_if_automatically_fetch_payment_terms_is_unchecked(self):
po = create_purchase_order(do_not_save=1)
po.payment_terms_template = "_Test Payment Term Template"
Expand Down

0 comments on commit 6df730c

Please sign in to comment.