changeset 5b45fcf631a9 in modules/account_statement_ofx:5.0
details:
https://hg.tryton.org/modules/account_statement_ofx?cmd=changeset;node=5b45fcf631a9
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 b87420281323 -r 5b45fcf631a9 account.py
--- a/account.py Tue Feb 19 21:58:26 2019 +0100
+++ b/account.py Fri Jan 10 17:01:28 2020 +0100
@@ -68,7 +68,11 @@
if not isinstance(ofx_account.statement, ofxparse.Statement):
self.raise_user_error('ofx_not_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 b87420281323 -r 5b45fcf631a9 tests/OFX.txt
--- a/tests/OFX.txt Tue Feb 19 21:58:26 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 b87420281323 -r 5b45fcf631a9 tests/scenario_account_statement_ofx.rst
--- a/tests/scenario_account_statement_ofx.rst Tue Feb 19 21:58:26 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