-
-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reading transaction closing balance (record :62F:) #18
Comments
I'd also like to read record :60F: from a transaction. Thanks. |
60F should be supported: https://github.com/WoLpH/mt940/blob/develop/mt940/tags.py#L145-L146 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 |
I think the format of the records in the MT940 file I'm using are OK. I can see the For instance, if I parse the MT940 file like this:
What Python code would get me the values of the |
Well, it's scoped to
|
Thanks, I'll try it out tomorrow. Is there documentation that I missed about this? |
I honestly wasn't expecting this to be needed so no, it's not documented.
It's more of a view the source thing in this case.
Perhaps I should change the default scope for the balance or add it to both
scopes by default. I'll have to think about it for a bit.
|
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. |
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 :) |
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. |
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! |
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. |
Fixed via a898b96. |
Is it possible to access the transaction closing balance (record :62F:)? I don't see this in transaction.data? I've read through the docs but I'm still not sure how to get this piece of information. I did find
mt940.models.Balance
for parsing this information but I'm not sure how to use this to get the information in record :62F:. Thanks for your help.The text was updated successfully, but these errors were encountered: