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

        issue8879
        review262751002
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 e29a9955c89d -r 91468eba7c56 account.py
--- a/account.py        Wed Dec 04 11:09:35 2019 +0100
+++ 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 e29a9955c89d -r 91468eba7c56 tests/OFX.txt
--- a/tests/OFX.txt     Wed Dec 04 11:09:35 2019 +0100
+++ 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 e29a9955c89d -r 91468eba7c56 tests/scenario_account_statement_ofx.rst
--- a/tests/scenario_account_statement_ofx.rst  Wed Dec 04 11:09:35 2019 +0100
+++ 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