Skip to content
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

Handle reversals for new imported transactions #701

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

FestplattenSchnitzel
Copy link
Member

@FestplattenSchnitzel FestplattenSchnitzel commented Feb 27, 2024

Closes #700

@FestplattenSchnitzel
Copy link
Member Author

Setting to draft b/c we should definitely add a test.

Comment on lines +224 to +229
amount = transaction.data["amount"].amount

# Reversal ("Storno")
if "R" in transaction.data.get("status", ""):
amount = -amount

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing that inline, we should provide an intermediate function which turns a MT940Transaction into a BankAccountActivity. For that, it needs from transaction.data the following fields:

  • applicant_iban
  • applicant_bin
  • applicant_name
  • purpose
  • end_to_end_reference
  • amount
  • guessed_entry_date
  • date

This should be a pure function

def activiity_from_transaction_data(
    transaction_data: TDataTypedDict,
    bank_account_id: int
) -> BankAccountActivity: ...

where TDataTypedDict captures the aforementioned keys as a TypedDict.
We can then use a fixed mt940 dump of test data to check whether all the cases are handled properly without even having to touch the DB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle credit reversals in bank account activities
2 participants