[FIX] account: aged partner balance report

bzr revid: qdp-launchpad@tinyerp.com-20100902140119-wq9s7q2kg3bh9tgp
This commit is contained in:
qdp-launchpad@tinyerp.com 2010-09-02 16:01:19 +02:00
parent c6f8df3a83
commit 53cb85f2cf
3 changed files with 19 additions and 8 deletions

View File

@ -130,17 +130,28 @@ class aged_trial_report(rml_parse.rml_parse, common_report_header):
# Each history will contain : history[1] = {'<partner_id>': <partner_debit-credit>}
history = []
for i in range(5):
args_list = (tuple(self.ACCOUNT_TYPE), tuple(partner_ids) ,self.date_from,)
dates_query = '(COALESCE(date_maturity,date)'
if form[str(i)]['start'] and form[str(i)]['stop']:
dates_query += ' BETWEEN %s AND %s)'
args_list += (form[str(i)]['start'], form[str(i)]['stop'])
elif form[str(i)]['start']:
dates_query += ' > %s)'
args_list += (form[str(i)]['start'],)
else:
dates_query += ' < %s)'
args_list += (form[str(i)]['stop'],)
self.cr.execute('SELECT partner_id, SUM(debit-credit)\
FROM account_move_line AS l, account_account\
WHERE (l.account_id = account_account.id)\
AND (account_account.type IN %s)\
AND (COALESCE(date_maturity,date) BETWEEN %s AND %s)\
AND (partner_id IN %s)\
AND ((reconcile_id IS NULL)\
OR (reconcile_id IN (SELECT recon.id FROM account_move_reconcile AS recon WHERE recon.create_date > %s )))\
AND '+ self.query + '\
AND account_account.active\
GROUP BY partner_id' , (tuple(self.ACCOUNT_TYPE), form[str(i)]['start'], form[str(i)]['stop'], tuple(partner_ids) ,self.date_from,))
AND ' + dates_query + '\
GROUP BY partner_id' , args_list)
t = self.cr.fetchall()
d = {}
for i in t:

View File

@ -168,7 +168,7 @@
<para style="P2">Partners</para>
</td>
<td>
<para style="P8">[[ data['form']['direction_selection'] == 'future' and 'Due' or 'Not due' ]] [[ formatLang(data['form']['date1'],date=True) ]]</para>
<para style="P8">[[ data['form']['direction_selection'] == 'future' and 'Due' or 'Not due' ]]</para>
</td>
<td>
<para style="P8">[[ data['form']['4']['name'] ]]</para>

View File

@ -75,18 +75,18 @@ class account_aged_trial_balance(osv.osv_memory):
for i in range(5)[::-1]:
stop = start - RelativeDateTime(days=period_length)
res[str(i)] = {
'name' : str((5-(i+1)) * period_length) + '-' + str((5-i) * period_length),
'name': (i!=0 and (str((5-(i+1)) * period_length) + '-' + str((5-i) * period_length)) or ('+'+str(4 * period_length))),
'stop': start.strftime('%Y-%m-%d'),
'start' : stop.strftime('%Y-%m-%d'),
'start': (i!=0 and stop.strftime('%Y-%m-%d') or None),
}
start = stop - RelativeDateTime(days=1)
else:
for i in range(5):
stop = start + RelativeDateTime(days=period_length)
res[str(5-(i+1))] = {
'name' : str((i) * period_length)+'-' + str((i+1) * period_length),
'name' : (i!=4 and str((i) * period_length)+'-' + str((i+1) * period_length) or ('+'+str(4 * period_length))),
'start': start.strftime('%Y-%m-%d'),
'stop': stop.strftime('%Y-%m-%d'),
'stop': (i!=4 and stop.strftime('%Y-%m-%d') or None),
}
start = stop + RelativeDateTime(days=1)
data['form'].update(res)
@ -99,4 +99,4 @@ class account_aged_trial_balance(osv.osv_memory):
account_aged_trial_balance()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: