mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-15 21:05:10 +00:00
fix(payment term): allocate payment amount when payment term is fetched from order
(cherry picked from commit 5618859bd8)
This commit is contained in:
@@ -2328,7 +2328,7 @@ class AccountsController(TransactionBase):
|
|||||||
and automatically_fetch_payment_terms
|
and automatically_fetch_payment_terms
|
||||||
and self.linked_order_has_payment_terms(po_or_so, fieldname, doctype)
|
and self.linked_order_has_payment_terms(po_or_so, fieldname, doctype)
|
||||||
):
|
):
|
||||||
self.fetch_payment_terms_from_order(po_or_so, doctype)
|
self.fetch_payment_terms_from_order(po_or_so, doctype, grand_total, base_grand_total)
|
||||||
if self.get("payment_terms_template"):
|
if self.get("payment_terms_template"):
|
||||||
self.ignore_default_payment_terms_template = 1
|
self.ignore_default_payment_terms_template = 1
|
||||||
elif self.get("payment_terms_template"):
|
elif self.get("payment_terms_template"):
|
||||||
@@ -2372,7 +2372,7 @@ class AccountsController(TransactionBase):
|
|||||||
d.payment_amount * self.get("conversion_rate"), d.precision("base_payment_amount")
|
d.payment_amount * self.get("conversion_rate"), d.precision("base_payment_amount")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.fetch_payment_terms_from_order(po_or_so, doctype)
|
self.fetch_payment_terms_from_order(po_or_so, doctype, grand_total, base_grand_total)
|
||||||
self.ignore_default_payment_terms_template = 1
|
self.ignore_default_payment_terms_template = 1
|
||||||
|
|
||||||
def get_order_details(self):
|
def get_order_details(self):
|
||||||
@@ -2410,7 +2410,7 @@ class AccountsController(TransactionBase):
|
|||||||
def linked_order_has_payment_schedule(self, po_or_so):
|
def linked_order_has_payment_schedule(self, po_or_so):
|
||||||
return frappe.get_all("Payment Schedule", filters={"parent": po_or_so})
|
return frappe.get_all("Payment Schedule", filters={"parent": po_or_so})
|
||||||
|
|
||||||
def fetch_payment_terms_from_order(self, po_or_so, po_or_so_doctype):
|
def fetch_payment_terms_from_order(self, po_or_so, po_or_so_doctype, grand_total, base_grand_total):
|
||||||
"""
|
"""
|
||||||
Fetch Payment Terms from Purchase/Sales Order on creating a new Purchase/Sales Invoice.
|
Fetch Payment Terms from Purchase/Sales Order on creating a new Purchase/Sales Invoice.
|
||||||
"""
|
"""
|
||||||
@@ -2426,12 +2426,25 @@ class AccountsController(TransactionBase):
|
|||||||
"invoice_portion": schedule.invoice_portion,
|
"invoice_portion": schedule.invoice_portion,
|
||||||
"mode_of_payment": schedule.mode_of_payment,
|
"mode_of_payment": schedule.mode_of_payment,
|
||||||
"description": schedule.description,
|
"description": schedule.description,
|
||||||
"payment_amount": schedule.payment_amount,
|
|
||||||
"base_payment_amount": schedule.base_payment_amount,
|
|
||||||
"outstanding": schedule.outstanding,
|
|
||||||
"paid_amount": schedule.paid_amount,
|
"paid_amount": schedule.paid_amount,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if payment_schedule["invoice_portion"]:
|
||||||
|
payment_schedule["payment_amount"] = flt(
|
||||||
|
grand_total * flt(payment_schedule["invoice_portion"]) / 100,
|
||||||
|
schedule.precision("payment_amount"),
|
||||||
|
)
|
||||||
|
payment_schedule["base_payment_amount"] = flt(
|
||||||
|
base_grand_total * flt(payment_schedule["invoice_portion"]) / 100,
|
||||||
|
schedule.precision("base_payment_amount"),
|
||||||
|
)
|
||||||
|
payment_schedule["outstanding"] = payment_schedule["payment_amount"]
|
||||||
|
else:
|
||||||
|
payment_schedule["base_payment_amount"] = flt(
|
||||||
|
schedule.base_payment_amount * self.get("conversion_rate"),
|
||||||
|
schedule.precision("base_payment_amount"),
|
||||||
|
)
|
||||||
|
|
||||||
if schedule.discount_type == "Percentage":
|
if schedule.discount_type == "Percentage":
|
||||||
payment_schedule["discount_type"] = schedule.discount_type
|
payment_schedule["discount_type"] = schedule.discount_type
|
||||||
payment_schedule["discount"] = schedule.discount
|
payment_schedule["discount"] = schedule.discount
|
||||||
|
|||||||
Reference in New Issue
Block a user