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

Refactor parsing and formatting #122

Merged
merged 8 commits into from
Oct 3, 2024

Conversation

pinzutu
Copy link
Contributor

@pinzutu pinzutu commented Sep 26, 2024

Refactors the parsing of all_events.json and the formatting into all_transactions.csv to capture all pp events generated by tr events, especially taxes, fees, and savebacks.

In detail:
1. Removes card_failed_transaction type due to it not being relevant for PP
2. Adds INCOMING_TRANSFER_DELEGATION and events from #116 (INTEREST_PAYOUT, card_successful_oct, TAX_REFUND, benefits_saveback_execution) to event.py
3. Introduces enums and dataclasses in event.py to a. structure and facilitate type matching b. differentiate between pp_types and types that require further csv formatting
4. Introduces tax and fee parsers in event.py
5. Introduces event_formatter.py to generate multiple csv lines from certain events (saveback, taxed income, transactions with fees). Fees and taxes are added as csv columns to avoid stand-alone transactions.
6. Adds a cli option argument to dl_docs and export_transactions to chronologically sort the exported csv transactions
Additionally:

  • Changes DIVIDENDS to DIVIDEND in .po messages to respect PP's nomenclature

The all_events.json available to me parses into an accurate all_transactions.csv; however, I highly encourage everyone to test the pr on their own event logs.
I did not observe breaking changes when testing with the docker image of python 3.8

… include taxes, fees, saveback correctly

1. Removes card_failed_transaction type due to it not being relevant for PP
2. Adds INCOMING_TRANSFER_DELEGATION and from issue pytr-org#116 (card_successful_oct, TAX_REFUND, benefits_saveback_execution) to event.py
3. Introduces enums and dataclasses in event.py to a. structure and facilitate type matching b. reduce Event object's memory size c. differentiate between pp_types and types that require further csv formating.
4. Introduces hacky tax and fee parsers in event.py
5. Introduces event_formatter.py to generate multiple csv lines from certain events (saveback, taxed income, transactions with fees)
Requires extensive testing (functionality + python version)
What remains: 1. Check if still compatible with python 3.8
2. Add Fees field in csv file to avoid having to generate a new Fee-type line for each fee occurence
3. Improve parsers with more logs
…nclude tax value and no further info (KapESt, Soli, Kirche)
Adds a cli argument to dl_docs and export_transactions to chronologically sort the exported csv transactions
Removes unused imports
Various small modifications
@pinzutu pinzutu marked this pull request as ready for review September 28, 2024 11:34
Copy link
Collaborator

@Katzmann1983 Katzmann1983 left a comment

Choose a reason for hiding this comment

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

Awesome changes

@pinzutu
Copy link
Contributor Author

pinzutu commented Oct 2, 2024

Apologies for the small post-review change: I had the late realization that PP transactions have embedded taxes and fees fields. I therefore added taxes and fees columns to the csv file, which voids the need to generate stand-alone tax and fee events and trims event_formatter.py in the process.

@Katzmann1983
Copy link
Collaborator

Sorry, I was first too euphoric and then tested it a little bit more. Before your last commit, taxes and fees were positive and thus gave a wrong total sum. Also I realized, that card_failed_transaction are not handled at all. These only need to be added, if and only if the transaction is of type card_failed_transaction and of status= "executed".

…ction events with executed status to REMOVALs 3. Renames UnprocessedEventType to ConditionalEventType for more clarity
@pinzutu
Copy link
Contributor Author

pinzutu commented Oct 3, 2024

Notwithstanding PP's indifference to the sign of fees and taxes, sticking to the negative sign convention for both makes more sense indeed.
I also wrongly believed card_failed_transaction events to always be failed transactions; these now conditionally map to REMOVALs again.

@Katzmann1983 Katzmann1983 merged commit b3e70bf into pytr-org:master Oct 3, 2024
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.

2 participants