feat: add option to calculate ageing based on report date or today date

(cherry picked from commit c67ba2d49b)
This commit is contained in:
l0gesh29
2025-05-16 15:50:02 +05:30
committed by Mergify
parent b773b494a0
commit 69337cf18b
3 changed files with 18 additions and 2 deletions

View File

@@ -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"),

View File

@@ -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"),

View File

@@ -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)