Browse Source

Base the report on the invoice date instead of due date

pull/9/head
dufresnedavid 10 years ago
committed by Maxime Chambreuil
parent
commit
5691db1b95
  1. 22
      account_partner_aged_statement_webkit/report/partner_aged_statement.mako
  2. 43
      account_partner_aged_statement_webkit/report/partner_aged_statement_report.py
  3. 23
      account_partner_aged_statement_webkit/tests/test_aged_statement.py

22
account_partner_aged_statement_webkit/report/partner_aged_statement.mako

@ -58,8 +58,7 @@
%if get_balance(partner, company):
<table class="basic_table" style="width: 100%;">
<tr>
<th>${_('Not Due')}</th>
<th>${_('0-30')}</th>
<th>${_('Current')}</th>
<th>${_('30-60')}</th>
<th>${_('60-90')}</th>
<th>${_('90-120')}</th>
@ -69,8 +68,7 @@
</tr>
%for l in get_balance(partner, company):
<tr>
<td>${ l['not_due'] }</td>
<td>${ l['30'] }</td>
<td>${ l['current'] }</td>
<td>${ l['3060'] }</td>
<td>${ l['6090'] }</td>
<td>${ l['90120'] }</td>
@ -83,10 +81,10 @@
%endif
<br/>
<br/>
<div class="title">${_('List of Due Invoices')}</div>
%if getLines30(partner, company):
%if getLinesCurrent(partner, company):
<div class="title">${_('List of current invoices')}</div>
<br/>
<div class="total">${_('0-30')}</div>
<table class="basic_table" style="width: 100%;">
<tr>
<th>${_('Date')}</th>
@ -98,7 +96,7 @@
<th>${_('Total')}</th>
<th>${_('Currency')}</th>
</tr>
%for line in getLines30(partner, company):
%for line in getLinesCurrent(partner, company):
<tr>
<td>${ formatLang(line['date_original'], date=True) }</td>
<td>${ line['name'] }</td>
@ -109,9 +107,13 @@
<td style="text-align: right;">${ formatLang(line['amount_unreconciled']) }</td>
<td>${ line['currency_name'] }</td>
</tr>
%endfor ## for line in getLines30(partner, company)
%endfor ## for line in getLinesCurrent(partner, company)
</table>
%endif ## if getLines30(partner, company)
<br/>
<br/>
%endif ## if getLinesCurrent(partner, company)
<div class="title">${_('List of overdue invoices')}</div>
%if getLines3060(partner, company):
<br/>
<div class="total">${_('30-60')}</div>

43
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

23
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,

Loading…
Cancel
Save