From cd9d70d6eee69b1de8c0df2b9289c9a0ce5e1395 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 30 May 2022 18:49:17 +0530 Subject: [PATCH] refactor: show advance payments in AR/AP report --- .../accounts_receivable/accounts_receivable.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index ad8fa5ba05..7329fd1418 100755 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -7,6 +7,7 @@ from collections import OrderedDict 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 @@ class ReceivablePayableReport(object): 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 = (