From 3990104e9bf24b5e64b172771d4e5317e0ed7340 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 7 Nov 2013 21:04:01 +0530 Subject: [PATCH] [minor] [refactor] Accounts Receivable --- .../accounts_receivable.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/accounts/report/accounts_receivable/accounts_receivable.py b/accounts/report/accounts_receivable/accounts_receivable.py index 18fd35cef7b..02a9a5e6b2c 100644 --- a/accounts/report/accounts_receivable/accounts_receivable.py +++ b/accounts/report/accounts_receivable/accounts_receivable.py @@ -43,7 +43,7 @@ class AccountsReceivableReport(object): outstanding_amount] entry_date = due_date if self.filters.ageing_based_on=="Due Date" \ else gle.posting_date - row += self.get_age(entry_date, outstanding_amount) + row += get_age(self.age_as_on, entry_date, outstanding_amount) data.append(row) return data @@ -69,24 +69,6 @@ class AccountsReceivableReport(object): return flt(gle.debit) - flt(gle.credit) - payment_received - def get_age(self, entry_date, oustanding_amount): - # [0-30, 30-60, 60-90, 90-above] - outstanding_range = [0.0, 0.0, 0.0, 0.0] - if not (self.age_as_on and entry_date): - return [0] + outstanding_range - - age = (self.age_as_on - getdate(entry_date)).days or 0 - index = None - for i, days in enumerate([30, 60, 90]): - if age <= days: - index = i - break - - if index is None: index = 3 - outstanding_range[index] = oustanding_amount - - return [age] + outstanding_range - def get_customer(self, account): return self.get_account_map().get(account).get("customer_name") or "" @@ -157,4 +139,22 @@ class AccountsReceivableReport(object): .get(against_voucher, []) def execute(filters=None): - return AccountsReceivableReport(filters).run() \ No newline at end of file + return AccountsReceivableReport(filters).run() + +def get_ageing_data(age_as_on, entry_date, oustanding_amount): + # [0-30, 30-60, 60-90, 90-above] + outstanding_range = [0.0, 0.0, 0.0, 0.0] + if not (self.age_as_on and entry_date): + return [0] + outstanding_range + + age = (self.age_as_on - getdate(entry_date)).days or 0 + index = None + for i, days in enumerate([30, 60, 90]): + if age <= days: + index = i + break + + if index is None: index = 3 + outstanding_range[index] = oustanding_amount + + return [age] + outstanding_range \ No newline at end of file