From 69337cf18b7568f0dfdb224be75de7db2e209ccb Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Fri, 16 May 2025 15:50:02 +0530 Subject: [PATCH] feat: add option to calculate ageing based on report date or today date (cherry picked from commit c67ba2d49b611f0ce852e417b03937cee8b5d55a) --- .../accounts/report/accounts_payable/accounts_payable.js | 7 +++++++ .../report/accounts_receivable/accounts_receivable.js | 7 +++++++ .../report/accounts_receivable/accounts_receivable.py | 6 ++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.js b/erpnext/accounts/report/accounts_payable/accounts_payable.js index 56550ac1fd4..7c3ced847ad 100644 --- a/erpnext/accounts/report/accounts_payable/accounts_payable.js +++ b/erpnext/accounts/report/accounts_payable/accounts_payable.js @@ -60,6 +60,13 @@ frappe.query_reports["Accounts Payable"] = { options: "Posting Date\nDue Date\nSupplier Invoice Date", default: "Due Date", }, + { + fieldname: "calculate_ageing_with", + label: __("Calculate Ageing With"), + fieldtype: "Select", + options: "Report Date\nToday Date", + default: "Report Date", + }, { fieldname: "range", label: __("Ageing Range"), diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js index 01f5a205cea..c5bfe4de0ff 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.js +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.js @@ -89,6 +89,13 @@ frappe.query_reports["Accounts Receivable"] = { options: "Posting Date\nDue Date", default: "Due Date", }, + { + fieldname: "calculate_ageing_with", + label: __("Calculate Ageing With"), + fieldtype: "Select", + options: "Report Date\nToday Date", + default: "Report Date", + }, { fieldname: "range", label: __("Ageing Range"), diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 663c1ff0a26..af15e365b25 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -47,7 +47,9 @@ class ReceivablePayableReport: self.ple = qb.DocType("Payment Ledger Entry") self.filters.report_date = getdate(self.filters.report_date or nowdate()) self.age_as_on = ( - getdate(nowdate()) if self.filters.report_date > getdate(nowdate()) else self.filters.report_date + getdate(nowdate()) + if self.filters.calculate_ageing_with == "Today Date" + else self.filters.report_date ) if not self.filters.range: @@ -784,7 +786,7 @@ class ReceivablePayableReport: self.get_ageing_data(entry_date, row) # ageing buckets should not have amounts if due date is not reached - if getdate(entry_date) > getdate(self.filters.report_date): + if getdate(entry_date) > getdate(self.age_as_on): [setattr(row, f"range{i}", 0.0) for i in self.range_numbers] row.total_due = sum(row[f"range{i}"] for i in self.range_numbers)