changeset 78e18eb36cec in modules/account_statement_ofx:5.2
details: 
https://hg.tryton.org/modules/account_statement_ofx?cmd=changeset;node=78e18eb36cec
description:
        Use ofx file data for statement total_amount and start/end balance

        issue8879
        review262751002
        (grafted from 91468eba7c56e54fa23b8019031e7006d8709401)
diffstat:

 account.py                               |  6 +++++-
 tests/OFX.txt                            |  4 ++--
 tests/scenario_account_statement_ofx.rst |  4 ++++
 3 files changed, 11 insertions(+), 3 deletions(-)

diffs (47 lines):

diff -r e4a0c4a6d540 -r 78e18eb36cec account.py
--- a/account.py        Mon May 06 14:58:31 2019 +0200
+++ b/account.py        Fri Jan 10 17:01:28 2020 +0100
@@ -58,7 +58,11 @@
             raise ImportStatementError(
                 gettext('account_statement_ofx.msg_import_no_statement'))
         statement.date = ofx_account.statement.balance_date.date()
-        statement.total_amount = ofx_account.statement.balance
+        total_amount = sum(
+            t.amount for t in ofx_account.statement.transactions)
+        statement.total_amount = total_amount
+        statement.start_balance = ofx_account.statement.balance - total_amount
+        statement.end_balance = ofx_account.statement.balance
         statement.number_of_lines = len(ofx_account.statement.transactions)
         return statement
 
diff -r e4a0c4a6d540 -r 78e18eb36cec tests/OFX.txt
--- a/tests/OFX.txt     Mon May 06 14:58:31 2019 +0200
+++ b/tests/OFX.txt     Fri Jan 10 17:01:28 2020 +0100
@@ -48,11 +48,11 @@
 </STMTTRN>
 </BANKTRANLIST>
 <LEDGERBAL>
-<BALAMT>100.00
+<BALAMT>500.00
 <DTASOF>20180222
 </LEDGERBAL>
 <AVAILBAL>
-<BALAMT>100.00
+<BALAMT>500.00
 <DTASOF>20180222
 </AVAILBAL>
 </STMTRS>
diff -r e4a0c4a6d540 -r 78e18eb36cec tests/scenario_account_statement_ofx.rst
--- a/tests/scenario_account_statement_ofx.rst  Mon May 06 14:58:31 2019 +0200
+++ b/tests/scenario_account_statement_ofx.rst  Fri Jan 10 17:01:28 2020 +0100
@@ -102,6 +102,10 @@
     Decimal('100.00')
     >>> statement.number_of_lines
     1
+    >>> statement.start_balance
+    Decimal('400.00')
+    >>> statement.end_balance
+    Decimal('500.00')
     >>> len(statement.origins)
     1
     >>> origin, = statement.origins

Reply via email to