diff --git a/account_partner_aged_statement_webkit/report/partner_aged_statement.mako b/account_partner_aged_statement_webkit/report/partner_aged_statement.mako index b3a580e9..f50e5bed 100644 --- a/account_partner_aged_statement_webkit/report/partner_aged_statement.mako +++ b/account_partner_aged_statement_webkit/report/partner_aged_statement.mako @@ -58,8 +58,7 @@ %if get_balance(partner, company): - - + @@ -69,8 +68,7 @@ %for l in get_balance(partner, company): - - + @@ -83,10 +81,10 @@ %endif

-
${_('List of Due Invoices')}
- %if getLines30(partner, company): + + %if getLinesCurrent(partner, company): +
${_('List of current invoices')}

-
${_('0-30')}
${_('Not Due')}${_('0-30')}${_('Current')} ${_('30-60')} ${_('60-90')} ${_('90-120')}
${ l['not_due'] }${ l['30'] }${ l['current'] } ${ l['3060'] } ${ l['6090'] } ${ l['90120'] }
@@ -98,7 +96,7 @@ - %for line in getLines30(partner, company): + %for line in getLinesCurrent(partner, company): @@ -109,9 +107,13 @@ - %endfor ## for line in getLines30(partner, company) + %endfor ## for line in getLinesCurrent(partner, company)
${_('Date')}${_('Total')} ${_('Currency')}
${ formatLang(line['date_original'], date=True) } ${ line['name'] }${ formatLang(line['amount_unreconciled']) } ${ line['currency_name'] }
- %endif ## if getLines30(partner, company) +
+
+ %endif ## if getLinesCurrent(partner, company) + +
${_('List of overdue invoices')}
%if getLines3060(partner, company):
${_('30-60')}
diff --git a/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py b/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py index 73a7c638..2f34eed7 100644 --- a/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py +++ b/account_partner_aged_statement_webkit/report/partner_aged_statement_report.py @@ -47,7 +47,7 @@ class PartnerAgedTrialReport(aged_trial_report): self._partners = self.localcontext["active_ids"] self.localcontext.update({ 'message': self._message, - 'getLines30': self._lines_get_30, + 'getLinesCurrent': self._lines_get_current, 'getLines3060': self._lines_get_30_60, 'getLines60': self._lines_get_60, 'show_message': True, @@ -87,7 +87,7 @@ class PartnerAgedTrialReport(aged_trial_report): res = {} for currency_name, lines in grouped_movelines: res[currency_name] = { - 'not_due': 0, + 'current': 0, '30': 0, '3060': 0, '6090': 0, @@ -101,22 +101,22 @@ class PartnerAgedTrialReport(aged_trial_report): for line in lines: amount = line['amount_unreconciled'] - if line['date_due'] > today or not line['date_due']: - current_dict['not_due'] += amount + if ( + not line['date_original'] or + line['date_original'] >= date_30 + ): + current_dict['current'] += amount - elif line['date_due'] > date_30: - current_dict['30'] += amount - - elif line['date_due'] > date_60: + elif line['date_original'] > date_60: current_dict['3060'] += amount - elif line['date_due'] > date_90: + elif line['date_original'] > date_90: current_dict['6090'] += amount - elif line['date_due'] > date_120: + elif line['date_original'] > date_120: current_dict['90120'] += amount - elif line['date_due']: + else: current_dict['120'] += amount current_dict['total'] += amount @@ -157,7 +157,7 @@ class PartnerAgedTrialReport(aged_trial_report): invoices = inv_obj.browse(cr, uid, invoice_ids, context=context) - return [ + res = sorted([ { 'date_due': inv.date_due or '', 'date_original': inv.date_invoice or '', @@ -169,19 +169,22 @@ class PartnerAgedTrialReport(aged_trial_report): 'ref': inv.reference or '', 'id': inv.id, } for inv in invoices - ] + ], key=lambda inv: inv['date_original']) - def _lines_get_30(self, partner, company): + res.reverse() + + return res + + def _lines_get_current(self, partner, company): today = self.today stop = today - relativedelta(days=30) - - today = today.strftime(DEFAULT_SERVER_DATE_FORMAT) stop = stop.strftime(DEFAULT_SERVER_DATE_FORMAT) movelines = self._get_current_invoice_lines(partner, company, today) movelines = [ line for line in movelines - if not line['date_due'] or stop < line['date_due'] <= today + if not line['date_original'] or + line['date_original'] >= stop ] return movelines @@ -197,7 +200,8 @@ class PartnerAgedTrialReport(aged_trial_report): movelines = self._get_current_invoice_lines(partner, company, today) movelines = [ line for line in movelines - if line['date_due'] and stop < line['date_due'] <= start + if line['date_original'] and + stop < line['date_original'] <= start ] return movelines @@ -211,7 +215,8 @@ class PartnerAgedTrialReport(aged_trial_report): movelines = self._get_current_invoice_lines(partner, company, today) movelines = [ line for line in movelines - if line['date_due'] and line['date_due'] <= start + if line['date_original'] and + line['date_original'] <= start ] return movelines diff --git a/account_partner_aged_statement_webkit/tests/test_aged_statement.py b/account_partner_aged_statement_webkit/tests/test_aged_statement.py index b9bd4cf6..b74459eb 100644 --- a/account_partner_aged_statement_webkit/tests/test_aged_statement.py +++ b/account_partner_aged_statement_webkit/tests/test_aged_statement.py @@ -133,7 +133,7 @@ class test_aged_statement(common.TransactionCase): balance = self.report._get_balance(self.partner, self.company) self.assertEqual(len(balance), 1) - self.assertEqual(balance[0]['30'], 400) + self.assertEqual(balance[0]['current'], 400) self.assertEqual(balance[0]['3060'], 150) self.assertEqual(balance[0]['6090'], 200) self.assertEqual(balance[0]['90120'], 250) @@ -148,27 +148,22 @@ class test_aged_statement(common.TransactionCase): self.assertEqual( line['amount_unreconciled'], vals['amount_unreconciled']) - def test_line_get_30(self): - lines = sorted( - self.report._lines_get_30(self.partner, self.company), - key=lambda l: l['date_original']) + def test_line_get_current(self): + lines = self.report._lines_get_current(self.partner, self.company) self.compare_vals(lines[0], { - 'date_original': self.date1, - 'amount_original': 100, - 'amount_unreconciled': 100, - }) - - self.compare_vals(lines[1], { 'date_original': self.today, 'amount_original': 300, 'amount_unreconciled': 300, }) + self.compare_vals(lines[1], { + 'date_original': self.date1, + 'amount_original': 100, + 'amount_unreconciled': 100, + }) def test_line_get_30_60(self): - lines = sorted( - self.report._lines_get_30_60(self.partner, self.company), - key=lambda l: l['date_original']) + lines = self.report._lines_get_30_60(self.partner, self.company) self.compare_vals(lines[0], { 'date_original': self.date2,