Skip to content

Comments

Handle reversals for new imported transactions#701

Draft
FestplattenSchnitzel wants to merge 1 commit intodevelopfrom
reversals
Draft

Handle reversals for new imported transactions#701
FestplattenSchnitzel wants to merge 1 commit intodevelopfrom
reversals

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