Merge lp:~openerp-dev/openobject-addons/7.0-partial-aged-balance-mat into lp:openobject-addons/7.0

Proposed by Martin Trigaux (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-partial-aged-balance-mat
Merge into: lp:openobject-addons/7.0
Diff against target: 39 lines (+16/-4)
1 file modified
account/report/account_aged_partner_balance.py (+16/-4)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-partial-aged-balance-mat
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+217778@code.launchpad.net

Description of the change

modify aged partner balance report to avoid displaying the partially reconciled entries

Way to reproduce:
- create invoice of 1000€ Jan 2014 for a partner
- create payment of 300€ in Mar 2014 for same partner

Observed:
- period 1 -> +1000
- period 2 -> -300
- total -> +700

Expected
- period 1 -> +700
- total -> +700

To post a comment you must log in.
10029. By Martin Trigaux (OpenERP)

[FIX] should not use exclude bounds

Unmerged revisions

10029. By Martin Trigaux (OpenERP)

[FIX] should not use exclude bounds

10028. By Martin Trigaux (OpenERP)

[IMP] account: when computing the aged partner balance, do not display the partial reconcilations, only display the remaining amount in the oldest period.

eg: if +1000 in period 1 and -300 in period 2, should only display +700 in period 1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/report/account_aged_partner_balance.py'
2--- account/report/account_aged_partner_balance.py 2013-06-14 21:36:02 +0000
3+++ account/report/account_aged_partner_balance.py 2014-04-30 15:28:48 +0000
4@@ -159,7 +159,7 @@
5 dates_query += ' < %s)'
6 args_list += (form[str(i)]['stop'],)
7 args_list += (self.date_from,)
8- self.cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit)
9+ self.cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit), l.reconcile_partial_id
10 FROM account_move_line AS l, account_account, account_move am
11 WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)
12 AND (am.state IN %s)
13@@ -171,11 +171,23 @@
14 AND account_account.active
15 AND ''' + dates_query + '''
16 AND (l.date <= %s)
17- GROUP BY l.partner_id''', args_list)
18+ GROUP BY l.partner_id, l.reconcile_partial_id''', args_list)
19 t = self.cr.fetchall()
20- d = {}
21+ d = dict((i[0],0) for i in t)
22 for i in t:
23- d[i[0]] = i[1]
24+ if i[2]:
25+ # in case of partial reconciliation, we want to keep the left amount in the oldest period
26+ self.cr.execute('''SELECT MIN(COALESCE(date_maturity,date)) FROM account_move_line WHERE reconcile_partial_id = %s''', (i[2],))
27+ date = self.cr.fetchall()
28+ if date and args_list[-3] <= date[0][0] <= args_list[-2]:
29+ # partial reconcilation
30+ self.cr.execute('''SELECT SUM(l.debit-l.credit)
31+ FROM account_move_line AS l
32+ WHERE l.reconcile_partial_id = %s''', (i[2],))
33+ unreconciled_amount = self.cr.fetchall()
34+ d[i[0]] += unreconciled_amount[0][0]
35+ else:
36+ d[i[0]] += i[1]
37 history.append(d)
38
39 for partner in partners: