From 805f09a3fe02ccf5afb3185fcbe5c86e17156747 Mon Sep 17 00:00:00 2001 From: AravindPranera Date: Thu, 26 Apr 2018 18:02:37 +0530 Subject: [PATCH] Accounts receivable aging based on supplier due date (#13801) --- .../report/accounts_payable/accounts_payable.js | 2 +- .../accounts_receivable/accounts_receivable.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.js b/erpnext/accounts/report/accounts_payable/accounts_payable.js index 63ef83263c..e95b0f3adb 100644 --- a/erpnext/accounts/report/accounts_payable/accounts_payable.js +++ b/erpnext/accounts/report/accounts_payable/accounts_payable.js @@ -32,7 +32,7 @@ frappe.query_reports["Accounts Payable"] = { "fieldname":"ageing_based_on", "label": __("Ageing Based On"), "fieldtype": "Select", - "options": 'Posting Date\nDue Date', + "options": 'Posting Date\nDue Date\nSupplier Invoice Date', "default": "Posting Date" }, { diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 61096837f5..fc730ed19b 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -151,6 +151,7 @@ class ReceivablePayableReport(object): # get due date due_date = voucher_details.get(gle.voucher_no, {}).get("due_date", "") + bill_date = voucher_details.get(gle.voucher_no, {}).get("bill_date", "") row += [gle.voucher_type, gle.voucher_no, due_date] @@ -167,15 +168,25 @@ class ReceivablePayableReport(object): row += [invoiced_amount, paid_amt, credit_note_amount, outstanding_amount] # ageing data - entry_date = due_date if self.filters.ageing_based_on == "Due Date" else gle.posting_date + if self.filters.ageing_based_on == "Due Date": + entry_date = due_date + elif self.filters.ageing_based_on == "Supplier Invoice Date": + entry_date = bill_date + else: + entry_date = gle.posting_date row += get_ageing_data(cint(self.filters.range1), cint(self.filters.range2), cint(self.filters.range3), self.age_as_on, entry_date, outstanding_amount) + # issue 6371-Ageing buckets should not have amounts if due date is not reached if self.filters.ageing_based_on == "Due Date" \ and getdate(due_date) > getdate(self.filters.report_date): row[-1]=row[-2]=row[-3]=row[-4]=0 + if self.filters.ageing_based_on == "Supplier Invoice Date" \ + and getdate(bill_date) > getdate(self.filters.report_date): + row[-1]=row[-2]=row[-3]=row[-4]=0 + if self.filters.get(scrub(args.get("party_type"))): row.append(gle.account_currency) else: