Code Monkey home page Code Monkey logo

Comments (5)

wolph avatar wolph commented on August 15, 2024 1

You're right. For some files this is indeed not a usable situation. Option 2 is quite involved so I've opted for adding a transformer to take care of option 1. I'm still finalizing the code so the tests keep on working without issues but the current develop branch shows the new behaviour.

from mt940.

wolph avatar wolph commented on August 15, 2024 1

The new release is online. Every transaction should have the relevant transaction_reference now. If you want to add more fields you can do so using the post processors:

mt940/mt940/models.py

Lines 264 to 267 in 026859d

post_statement=[
processors.date_cleanup_post_processor,
processors.transactions_to_transaction('transaction_reference'),
],

from mt940.

wolph avatar wolph commented on August 15, 2024

There should be a transaction_reference available for a :20::

pattern = r'(?P<transaction_reference>.{0,16})'

We can see an example with this sta file here:

Which generates this data:

transaction_reference: STARTUMSE

Do you have a specific example where this is not working?

from mt940.

mmdevl avatar mmdevl commented on August 15, 2024

You can find the transaction reference as follow:

transactions = mt940.parse('test.sta')
print(transactions.data['transaction_reference'])

But for instance my bank exports several transaction references at the same time (one for each account). And with the print above you would get only the last transaction reference.

Try with this example:

:20:STARTUMSE
:25:12345678/1020304050
:28C:00000/001
:60F:C160229EUR1200,00
:61:1602300301DR6,00N024NONREF
:86:805?00ENTGELTABSCHLUSS?106666?20Pauschalen?3012345678?1122334
45566?602017-01-01T13
:12:11
:62F:C160301EUR1194,00
:20:STARTUMSE2
:25:12345678/1020304050
:28C:00000/001
:60F:C160229EUR1200,00
:61:1602300301DR6,00N024NONREF
:86:805?00ENTGELTABSCHLUSS?106666?20Pauschalen?3012345678?1122334
45566?602017-01-01T13
:12:11
:62F:C160301EUR1194,00

I think this is a bug and I see 2 solutions:

  1. add a 'transaction_reference' key to every transaction objects or
  2. group the objects by 'transaction_reference'

from mt940.

aGitForEveryone avatar aGitForEveryone commented on August 15, 2024

Amazing fix! This same issue happens when a single mt940 file contains transactions for several bank accounts. The account_identification field in transactions.data would have the value of the last tag 25. So it was impossible to track after transaction parsing what bank account the transaction belonged to.

I implemented a more complex workaround to separate the transactions per bank account. But with this post processor, it's possible to include that information in the transaction data itself. So the parsing becomes much easier.

Now don't forget that the global transactions.data gets overwritten with each new transaction, otherwise this feature doesn't work anymore.

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.