mt940.processors module

Module Processors

This module contains pre- and post-processors for modifying tag dictionaries in MT940 processing. It provides functions for currency addition, date fix-up, transaction code extraction, transaction details parsing, and segment joining for transaction details.

mt940.processors.add_currency_pre_processor(currency, overwrite=True)[source]

Return a pre-processor that adds currency information to tag dictionaries.

Parameters:
  • currency (str) – The currency to set in the tag dictionary.

  • overwrite (bool) – Whether to overwrite existing currency information.

Returns:

A pre-processor function that adds currency information.

Return type:

PreProcessor

mt940.processors.date_fixup_pre_processor(transactions, tag, tag_dict, *args)[source]

Adjust the date in the tag dictionary if necessary.

If the day in February exceeds the maximum day in that month, adjust it to the last day of February.

Parameters:
  • transactions (models.Transactions) – The transactions object.

  • tag (tags.Tag) – The tag being processed.

  • tag_dict (dict[str, Any]) – The tag dictionary.

  • args (Any)

Returns:

The adjusted tag dictionary.

Return type:

dict[str, Any]

mt940.processors.date_cleanup_post_processor(transactions, tag, tag_dict, result)[source]

Remove date components from the result dictionary.

Removes the ‘day’, ‘month’, ‘year’, ‘entry_day’, and ‘entry_month’ keys from the result dictionary.

Parameters:
  • transactions (models.Transactions) – The transactions object.

  • tag (tags.Tag) – The tag being processed.

  • tag_dict (dict[str, Any]) – The tag dictionary.

  • result (dict[str, Any]) – The result dictionary.

Returns:

The adjusted result dictionary.

Return type:

dict[str, Any]

mt940.processors.mBank_set_transaction_code(transactions, tag, tag_dict, *args)[source]

mBank Collect uses transaction code 911 to distinguish incoming mass payments transactions, adding transaction_code may be helpful in further processing.

Parameters:
Return type:

dict[str, Any]

mt940.processors.mBank_set_iph_id(transactions, tag, tag_dict, *args)[source]

mBank Collect uses ID IPH to distinguish between virtual accounts, adding iph_id may be helpful in further processing.

Parameters:
Return type:

dict[str, Any]

mt940.processors.mBank_set_tnr(transactions, tag, tag_dict, *args)[source]

mBank Collect states TNR in transaction details as unique id for transactions, that may be used to identify the same transactions in different statement files eg. partial mt942 and full mt940 Information about TNR uniqueness has been obtained from mBank support, it lacks in mt940 mBank specification.

Parameters:
Return type:

dict[str, Any]

mt940.processors.transaction_details_post_processor(transactions, tag, tag_dict, result, space=False)[source]

Parse the extra details in some transaction formats, such as the 60-65 keys.

Parameters:
  • transactions (models.Transactions) – The transactions object.

  • tag (tags.Tag) – The tag being processed.

  • tag_dict (dict[str, Any]) – The tag dictionary.

  • result (dict[str, Any]) – The result dictionary.

  • space (bool) – Whether to include spaces between segments.

Returns:

The updated result dictionary.

Return type:

dict[str, Any]

mt940.processors.transaction_details_post_processor_with_space(transactions, tag, tag_dict, result, *, space=True)

A variant of transaction_details_post_processor that includes spaces between segments.

Parameters:
Return type:

dict[str, Any]

mt940.processors.transactions_to_transaction(*keys)[source]

Copy the global transactions details to the transaction.

Parameters:

*keys (str) – The keys to copy to the transaction.

Returns:

A post-processor function that copies specified keys.

Return type:

PostProcessor