Skip to content

Commit

Permalink
fix: Oustanding amount en PE de So (#897) (#898)
Browse files Browse the repository at this point in the history
Co-authored-by: Francisco Roldán <[email protected]>
  • Loading branch information
github-actions[bot] and fproldan authored Jan 20, 2025
1 parent 33f10bf commit e45d317
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 e45d317

Please sign in to comment.