[FIX] account: accurate amount total due with partial reconcile
This is related to rev.db98434e85rev.abe5c803a0forgot some partial reconciliations when the date domain was other than BETWEEN (for instance, <= stop date or >= start date, alone, not between) Besides, the rev.abe5c803a0did not care about account move being posted or not. rev.db98434e85took several times the same partially reconciled moves lines
This commit is contained in:
@@ -153,10 +153,10 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header):
|
||||
dates_query += ' BETWEEN %s AND %s)'
|
||||
args_list += (form[str(i)]['start'], form[str(i)]['stop'])
|
||||
elif form[str(i)]['start']:
|
||||
dates_query += ' > %s)'
|
||||
dates_query += ' >= %s)'
|
||||
args_list += (form[str(i)]['start'],)
|
||||
else:
|
||||
dates_query += ' < %s)'
|
||||
dates_query += ' <= %s)'
|
||||
args_list += (form[str(i)]['stop'],)
|
||||
args_list += (self.date_from,)
|
||||
self.cr.execute('''SELECT l.partner_id, SUM(l.debit-l.credit), l.reconcile_partial_id
|
||||
@@ -175,20 +175,25 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header):
|
||||
partners_partial = self.cr.fetchall()
|
||||
partners_amount = dict((i[0],0) for i in partners_partial)
|
||||
for partner_info in partners_partial:
|
||||
partial = False
|
||||
if partner_info[2]:
|
||||
# in case of partial reconciliation, we want to keep the left amount in the oldest period
|
||||
self.cr.execute('''SELECT MIN(COALESCE(date_maturity,date)) FROM account_move_line WHERE reconcile_partial_id = %s''', (partner_info[2],))
|
||||
date = self.cr.fetchall()
|
||||
if date and args_list[-3] <= date[0][0] <= args_list[-2]:
|
||||
partial = False
|
||||
if 'BETWEEN' in dates_query:
|
||||
partial = date and args_list[-3] <= date[0][0] <= args_list[-2]
|
||||
elif '>=' in dates_query:
|
||||
partial = date and date[0][0] >= form[str(i)]['start']
|
||||
else:
|
||||
partial = date and date[0][0] <= form[str(i)]['stop']
|
||||
if partial:
|
||||
# partial reconcilation
|
||||
partial = True
|
||||
self.cr.execute('''SELECT SUM(l.debit-l.credit)
|
||||
FROM account_move_line AS l
|
||||
WHERE l.reconcile_partial_id = %s''', (partner_info[2],))
|
||||
FROM account_move_line AS l, account_move AS am
|
||||
WHERE l.move_id = am.id AND am.state in %s AND l.reconcile_partial_id = %s''', (tuple(move_state), partner_info[2],))
|
||||
unreconciled_amount = self.cr.fetchall()
|
||||
partners_amount[partner_info[0]] += unreconciled_amount[0][0]
|
||||
if not partial:
|
||||
else:
|
||||
partners_amount[partner_info[0]] += partner_info[1]
|
||||
history.append(partners_amount)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user