Comments (12)
I'd also like to read record :60F: from a transaction. Thanks.
from mt940.
60F should be supported: https://github.com/WoLpH/mt940/blob/develop/mt940/tags.py#L145-L146
And 62F as well: https://github.com/WoLpH/mt940/blob/develop/mt940/tags.py#L197-L198
If it's somehow not working for you than you might have a different unrecognized format. We even have working tests for both: https://github.com/WoLpH/mt940/blob/5d277eb8db56ff958a0645a90f0e26f12ef44766/tests/jejik/generic.sta
Resulting in: https://github.com/WoLpH/mt940/blob/5d277eb8db56ff958a0645a90f0e26f12ef44766/tests/jejik/generic.yml#L4-L19
from mt940.
I think the format of the records in the MT940 file I'm using are OK. I can see the final_opening_balance
and final_closing_balance
for the last record / transaction in the parsed MT940 file but I want to get this information for each record / transaction.
For instance, if I parse the MT940 file like this:
transactions = mt940.parse('path/to/abnamro.sta')
transaction = transactions[0]
What Python code would get me the values of the :60F:
and :62F:
fields for this specific transaction?
from mt940.
Well, it's scoped to Transactions
by default but that's easily fixable with a little monkeypatch. I believe this should do the trick:
from mt940 import tags
from mt940 import models
tags.BalanceBase.scope = models.Transaction
transactions = mt940.parse('path/to/abnamro.sta')
transaction = transactions[0]
from mt940.
Thanks, I'll try it out tomorrow. Is there documentation that I missed about this?
from mt940.
from mt940.
That didn't work. Here's what I get:
>>> import mt940
>>> from mt940 import tags
>>> from mt940 import models
>>> tags.BalanceBase.scope = models.Transaction
>>> transactions = mt940.parse('/home/ben/abnamro.sta')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ben/Development/project/env/lib/python2.7/site-packages/mt940/parser.py", line 45, in parse
transactions.parse(data)
File "/home/ben/Development/project/env/lib/python2.7/site-packages/mt940/models.py", line 232, in parse
transaction.data[k] += '\n%s' % v.strip()
AttributeError: 'Balance' object has no attribute 'strip'
Any ideas? Thanks again for your help on this.
from mt940.
I've just pushed a new release to the dev which fixes this issue. The proper fix is going to take a bit more time but perhaps this already does the trick for you :)
from mt940.
Thanks, this should be fine for my needs.
From a high level, it makes sense to me that the balance information is available by default on each Transaction but it's also reasonable to just add documentation on how to do this with a monkey patch. Let me know if you prefer to monkey patch solution and I'll make a PR to add this to the docs.
I'm working on some other stuff now but I'll get back to using this soon. Thanks again for your help.
from mt940.
Ultimately it would be nice to do both, but since that will take a bit more work I think docs would be preferable for the time being.
Thanks for the help!
from mt940.
I'm just getting back to this now. It seems like record :60F: comes before record :61:. With the monkey patch applied, the opening and closing balance info isn't correct for the transaction because the transaction is created only when a :61: is found. This means the opening and closing balances can be set to the wrong transaction.
I've made a PR just for discussion but it's not correct yet. I'll make an update in a few minutes with an explanation.
from mt940.
Fixed via a898b96.
from mt940.
Related Issues (20)
- AttributeError: module 'mt940' has no attribute 'parse' HOT 5
- Transaction Reference Number is not returned by the parser HOT 5
- Missing essential documentation for Transaction fields. HOT 2
- Dropping Transaction Data? HOT 1
- First intermediate_opening_balance line missing HOT 5
- AttributeError: 'NoneType' object has no attribute 'encoding' HOT 1
- How to read closing, opening and available balances HOT 3
- Minor parsing errors
- Opening Balance HOT 4
- Parsing transactions : key 64 HOT 8
- Multiple accounts in one file HOT 7
- Parser doesn't show running balance or opening/closing balance at transaction level HOT 2
- Status and Fund code , when Currency ends with a D HOT 2
- Getting only single account data instead of multiple accounts HOT 1
- Non-numeric statement number HOT 2
- Exporting to tabular format HOT 1
- cannot run for citibank? HOT 1
- Single "account_identification" field HOT 2
- Statement line is parsed incorrectly for customer/bank reference HOT 2
- MT940 Issues parsing with :61: HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mt940.