diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py index 56c9ff07e26..f42583cb34c 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.py @@ -172,22 +172,22 @@ class PaymentReconciliation(Document): query = ( qb.from_(gl) .select( - gl.voucher_type.as_("reference_type"), - gl.voucher_no.as_("reference_name"), + gl.against_voucher_type.as_("reference_type"), + gl.against_voucher.as_("reference_name"), (Sum(dr_or_cr) - Sum(reconciled_dr_or_cr)).as_("amount"), gl.posting_date, gl.account_currency.as_("currency"), ) .where( - (gl.voucher_type == voucher_type) - & (gl.voucher_no.isin(sub_query)) + (gl.against_voucher.isin(sub_query)) + & (gl.against_voucher_type == voucher_type) & (gl.is_cancelled == 0) & (gl.account == self.receivable_payable_account) & (gl.party_type == self.party_type) & (gl.party == self.party) ) .where(Criterion.all(conditions)) - .groupby(gl.voucher_no) + .groupby(gl.against_voucher) .having(qb.Field("amount") > 0) ) dr_cr_notes = query.run(as_dict=True)