From b35134fb9a64ab4cfdf9ce78e8fe7fcc75b716c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 16 Aug 2012 14:54:26 +0200 Subject: [PATCH] Fix sign of the amount to pay on line issue2746 review464003 --- statement.py | 4 +++- tests/scenario_account_statement.rst | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/statement.py b/statement.py index 4fccb10a22..aa814b41e8 100644 --- a/statement.py +++ b/statement.py @@ -262,7 +262,9 @@ class Statement(Workflow, ModelSQL, ModelView): else: res['lines']['update'].append({ 'id': line['id'], - 'amount': amount_to_pay, + 'amount': (amount_to_pay + if line['amount'] >= 0 + else -amount_to_pay), }) res['lines'].setdefault('add', []) vals = line.copy() diff --git a/tests/scenario_account_statement.rst b/tests/scenario_account_statement.rst index f459c027cc..96160c9982 100644 --- a/tests/scenario_account_statement.rst +++ b/tests/scenario_account_statement.rst @@ -265,11 +265,16 @@ Paid 50 to supplier:: >>> statement_line = StatementLine() >>> statement.lines.append(statement_line) >>> statement_line.date = today - >>> statement_line.amount = Decimal('-50') + >>> statement_line.amount = Decimal('-60') >>> statement_line.party = supplier >>> statement_line.account == payable True >>> statement_line.invoice = supplier_invoice + >>> statement_line.amount == Decimal('-50') + True + >>> statement_line = statement.lines.pop() + >>> statement_line.amount == Decimal('-10') + True >>> statement.save()