mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
fix: Back update discounted amount in Invoice based on discount type
- Discount value was always trated as a percentage on back updation
This commit is contained in:
@@ -424,15 +424,28 @@ class PaymentEntry(AccountsController):
|
|||||||
payment_schedule = frappe.get_all(
|
payment_schedule = frappe.get_all(
|
||||||
"Payment Schedule",
|
"Payment Schedule",
|
||||||
filters={"parent": ref.reference_name},
|
filters={"parent": ref.reference_name},
|
||||||
fields=["paid_amount", "payment_amount", "payment_term", "discount", "outstanding"],
|
fields=[
|
||||||
|
"paid_amount",
|
||||||
|
"payment_amount",
|
||||||
|
"payment_term",
|
||||||
|
"discount",
|
||||||
|
"outstanding",
|
||||||
|
"discount_type",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
for term in payment_schedule:
|
for term in payment_schedule:
|
||||||
invoice_key = (term.payment_term, ref.reference_name)
|
invoice_key = (term.payment_term, ref.reference_name)
|
||||||
invoice_paid_amount_map.setdefault(invoice_key, {})
|
invoice_paid_amount_map.setdefault(invoice_key, {})
|
||||||
invoice_paid_amount_map[invoice_key]["outstanding"] = term.outstanding
|
invoice_paid_amount_map[invoice_key]["outstanding"] = term.outstanding
|
||||||
invoice_paid_amount_map[invoice_key]["discounted_amt"] = ref.total_amount * (
|
if not (term.discount_type and term.discount):
|
||||||
term.discount / 100
|
continue
|
||||||
)
|
|
||||||
|
if term.discount_type == "Percentage":
|
||||||
|
invoice_paid_amount_map[invoice_key]["discounted_amt"] = ref.total_amount * (
|
||||||
|
term.discount / 100
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
invoice_paid_amount_map[invoice_key]["discounted_amt"] = term.discount
|
||||||
|
|
||||||
for idx, (key, allocated_amount) in enumerate(invoice_payment_amount_map.items(), 1):
|
for idx, (key, allocated_amount) in enumerate(invoice_payment_amount_map.items(), 1):
|
||||||
if not invoice_paid_amount_map.get(key):
|
if not invoice_paid_amount_map.get(key):
|
||||||
|
|||||||
Reference in New Issue
Block a user