Skip to content

Commit

Permalink
Merge pull request #899 from fproldan/diamoerp-staging
Browse files Browse the repository at this point in the history
fix: Oustanding amount en PE de So (#897) (#898)
  • Loading branch information
fproldan authored Jan 20, 2025
2 parents 394eef7 + e45d317 commit 7054d49
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions erpnext/accounts/doctype/payment_entry/payment_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,18 @@ def get_reference_details(reference_doctype, reference_name, party_account_curre
outstanding_amount = ref_doc.amount - flt(ref_doc.paid_amount)
elif reference_doctype == "Sales Commission":
outstanding_amount = ref_doc.get("outstanding_amount")
elif reference_doctype == "Sales Order":
advance_paid = frappe.db.sql(
"""
SELECT SUM(allocated_amount)
FROM `tabPayment Entry Reference`
WHERE reference_doctype = 'Sales Order'
AND reference_name = %s
AND docstatus = 1
""",
(reference_name,),
)[0][0] or 0.0
outstanding_amount = flt(total_amount) - flt(advance_paid)
else:
outstanding_amount = flt(total_amount) - flt(ref_doc.advance_paid)
else:
Expand Down

0 comments on commit 7054d49

Please sign in to comment.