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
=== modified file 'account/report/account_aged_partner_balance.py'
--- account/report/account_aged_partner_balance.py 2013-06-14 21:36:02 +0000
+++ account/report/account_aged_partner_balance.py 2014-04-30 15:28:48 +0000
@@ -159,7 +159,7 @@
159 dates_query += ' < %s)'159 dates_query += ' < %s)'
160 args_list += (form[str(i)]['stop'],)160 args_list += (form[str(i)]['stop'],)
161 args_list += (self.date_from,)161 args_list += (self.date_from,)
162 self.cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit)162 self.cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit), l.reconcile_partial_id
163 FROM account_move_line AS l, account_account, account_move am 163 FROM account_move_line AS l, account_account, account_move am
164 WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)164 WHERE (l.account_id = account_account.id) AND (l.move_id=am.id)
165 AND (am.state IN %s)165 AND (am.state IN %s)
@@ -171,11 +171,23 @@
171 AND account_account.active171 AND account_account.active
172 AND ''' + dates_query + '''172 AND ''' + dates_query + '''
173 AND (l.date <= %s)173 AND (l.date <= %s)
174 GROUP BY l.partner_id''', args_list)174 GROUP BY l.partner_id, l.reconcile_partial_id''', args_list)
175 t = self.cr.fetchall()175 t = self.cr.fetchall()
176 d = {}176 d = dict((i[0],0) for i in t)
177 for i in t:177 for i in t:
178 d[i[0]] = i[1]178 if i[2]:
179 # in case of partial reconciliation, we want to keep the left amount in the oldest period
180 self.cr.execute('''SELECT MIN(COALESCE(date_maturity,date)) FROM account_move_line WHERE reconcile_partial_id = %s''', (i[2],))
181 date = self.cr.fetchall()
182 if date and args_list[-3] <= date[0][0] <= args_list[-2]:
183 # partial reconcilation
184 self.cr.execute('''SELECT SUM(l.debit-l.credit)
185 FROM account_move_line AS l
186 WHERE l.reconcile_partial_id = %s''', (i[2],))
187 unreconciled_amount = self.cr.fetchall()
188 d[i[0]] += unreconciled_amount[0][0]
189 else:
190 d[i[0]] += i[1]
179 history.append(d)191 history.append(d)
180192
181 for partner in partners:193 for partner in partners: