[FIX] account: aged partner balance, advance partial payment

Partners totals were not correct if the partner paid partially an invoice in advance
For an invoice of 20.000 in the future, with a payment made in advance of 5000
The column not due must contains 20.000, as the amount is not yet due
One of the column 1-30, 30-60, ... (accordingly on when the payment was made). must contains -5000
The total should be 15.000
This commit is contained in:
Denis Ledoux 2014-12-17 13:57:34 +01:00
parent 998db2c61f
commit 43cf6d51d2
1 changed files with 4 additions and 1 deletions

View File

@ -188,9 +188,12 @@ class aged_trial_report(report_sxw.rml_parse, common_report_header):
partial = date and date[0][0] <= form[str(i)]['stop']
if partial:
# partial reconcilation
limit_date = 'COALESCE(l.date_maturity,l.date) %s %%s' % '<=' if self.direction_selection == 'past' else '>='
self.cr.execute('''SELECT SUM(l.debit-l.credit)
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],))
WHERE l.move_id = am.id AND am.state in %s
AND l.reconcile_partial_id = %s
AND ''' + limit_date, (tuple(move_state), partner_info[2], self.date_from))
unreconciled_amount = self.cr.fetchall()
partners_amount[partner_info[0]] += unreconciled_amount[0][0]
else: