mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
fix: query voucher outstanding only when all the conditions are true.
This commit is contained in:
@@ -1869,23 +1869,25 @@ def create_payment_ledger_entry(
|
||||
|
||||
|
||||
def update_voucher_outstanding(voucher_type, voucher_no, account, party_type, party):
|
||||
if not (voucher_type in OUTSTANDING_DOCTYPES and party_type and party):
|
||||
return
|
||||
|
||||
ple = frappe.qb.DocType("Payment Ledger Entry")
|
||||
vouchers = [frappe._dict({"voucher_type": voucher_type, "voucher_no": voucher_no})]
|
||||
common_filter = []
|
||||
common_filter.append(ple.party_type == party_type)
|
||||
common_filter.append(ple.party == party)
|
||||
|
||||
if account:
|
||||
common_filter.append(ple.account == account)
|
||||
|
||||
if party_type:
|
||||
common_filter.append(ple.party_type == party_type)
|
||||
|
||||
if party:
|
||||
common_filter.append(ple.party == party)
|
||||
|
||||
ple_query = QueryPaymentLedger()
|
||||
|
||||
# on cancellation outstanding can be an empty list
|
||||
voucher_outstanding = ple_query.get_voucher_outstandings(vouchers, common_filter=common_filter)
|
||||
if voucher_type in OUTSTANDING_DOCTYPES and party_type and party and voucher_outstanding:
|
||||
if not voucher_outstanding:
|
||||
return
|
||||
|
||||
outstanding = voucher_outstanding[0]
|
||||
ref_doc = frappe.get_lazy_doc(voucher_type, voucher_no)
|
||||
outstanding_amount = flt(
|
||||
|
||||
Reference in New Issue
Block a user