Code Monkey home page Code Monkey logo

Comments (12)

benkonrath avatar benkonrath commented on September 5, 2024

I'd also like to read record :60F: from a transaction. Thanks.

from mt940.

wolph avatar wolph commented on September 5, 2024

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.

benkonrath avatar benkonrath commented on September 5, 2024

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.

wolph avatar wolph commented on September 5, 2024

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.

benkonrath avatar benkonrath commented on September 5, 2024

Thanks, I'll try it out tomorrow. Is there documentation that I missed about this?

from mt940.

wolph avatar wolph commented on September 5, 2024

from mt940.

benkonrath avatar benkonrath commented on September 5, 2024

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.

wolph avatar wolph commented on September 5, 2024

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.

benkonrath avatar benkonrath commented on September 5, 2024

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.

wolph avatar wolph commented on September 5, 2024

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.

benkonrath avatar benkonrath commented on September 5, 2024

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.

benkonrath avatar benkonrath commented on September 5, 2024

Fixed via a898b96.

from mt940.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.