[FIX] account: bank statement reconciliation with taxes use case. The journal item for the bank should have the same amount as in the statement line except in case of already recorded payments only. Ticket 673358

This commit is contained in:
qdp-odoo
2016-04-22 15:03:58 +02:00
parent 67c7d45ea8
commit bf33c4ea0c
@@ -848,14 +848,9 @@ class AccountBankStatementLine(models.Model):
aml_dict['amount_currency'] = prorata_factor * self.amount
aml_dict['currency_id'] = statement_currency.id
# Create the move line for the statement line using the total credit/debit of the counterpart
# This leaves out the amount already reconciled and avoids rounding errors from currency conversion
st_line_amount = sum(aml_dict['credit'] - aml_dict['debit'] for aml_dict in to_create)
aml_obj.with_context(check_move_validity=False).create(self._prepare_reconciliation_move_line(move, st_line_amount))
# Create write-offs
for aml_dict in new_aml_dicts:
aml_obj.with_context(check_move_validity=False).create(aml_dict, apply_taxes=False)
aml_obj.with_context(check_move_validity=False).create(aml_dict)
# Create counterpart move lines and reconcile them
for aml_dict in counterpart_aml_dicts:
@@ -868,8 +863,14 @@ class AccountBankStatementLine(models.Model):
aml_dict['currency_id'] = counterpart_move_line.currency_id.id
aml_dict['amount_currency'] = company_currency.with_context(ctx).compute(aml_dict['debit'] - aml_dict['credit'], counterpart_move_line.currency_id)
new_aml = aml_obj.with_context(check_move_validity=False).create(aml_dict)
(new_aml | counterpart_move_line).reconcile()
# Create the move line for the statement line using the bank statement line as the remaining amount
# This leaves out the amount already reconciled and avoids rounding errors from currency conversion
st_line_amount = -sum([x.balance for x in move.line_ids])
aml_obj.with_context(check_move_validity=False).create(self._prepare_reconciliation_move_line(move, st_line_amount))
move.post()
counterpart_moves.assert_balanced()
return counterpart_moves