refactor: show advance payments in AR/AP report
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index ad8fa5b..7329fd1 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -7,6 +7,7 @@
import frappe
from frappe import _, qb, scrub
from frappe.query_builder import Criterion
+from frappe.query_builder.functions import Date
from frappe.utils import cint, cstr, flt, getdate, nowdate
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
@@ -654,7 +655,18 @@
self.prepare_conditions()
- self.qb_selection_filter.append(self.ple.posting_date.lte(self.filters.report_date))
+ if self.filters.show_future_payments:
+ self.qb_selection_filter.append(
+ (
+ self.ple.posting_date.lte(self.filters.report_date)
+ | (
+ (self.ple.voucher_no == self.ple.against_voucher_no)
+ & (Date(self.ple.creation).lte(self.filters.report_date))
+ )
+ )
+ )
+ else:
+ self.qb_selection_filter.append(self.ple.posting_date.lte(self.filters.report_date))
ple = qb.DocType("Payment Ledger Entry")
query = (