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

Date for balance statement could be wrong #187

Open
rapiz1 opened this issue Jan 7, 2025 · 1 comment
Open

Date for balance statement could be wrong #187

rapiz1 opened this issue Jan 7, 2025 · 1 comment

Comments

@rapiz1
Copy link
Contributor

rapiz1 commented Jan 7, 2025

We assume transactions are sorted and find the first date by using the date from the first transaction

def post_process_transactions(self, transactions) -> list[Transaction]:
previous_month_balances = self.get_prev_month_balances()
if previous_month_balances:
first_transaction_date = next(iter(transactions)).date
for prev_month_balance in previous_month_balances:
groupdict = TransactionGroupDict(**prev_month_balance.groupdict())
groupdict.transaction_date = first_transaction_date
prev_month_transaction = Transaction(**groupdict)
transactions.insert(0, prev_month_transaction)
return transactions

But it's not always sorted by date in the raw statement. For example, UOB puts CRedit before debit. So the previous balance statement can have a wrong date. What's worse is that at this point we haven't parsed the date yet so we can't sort.

I have a patch to solve it but it unfortunately requires a bigger change and move the post processing of previous balance statement into Pipeline.transform

@benjamin-awd
Copy link
Owner

We assume transactions are sorted and find the first date by using the date from the first transaction

Yes unfortunately monopoly currently has a very inelegant way of finding the statement date 😢

Do you have an example of how the UOB statement would fail? I think the UOB credit/debit statements I used don't have this particular ordering issue.

I have a patch to solve it but it unfortunately requires a bigger change and move the post processing of previous balance statement into Pipeline.transform

This is fine by me. It probably makes more sense for post-processing to happen in the transformation layer anyway

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

No branches or pull requests

2 participants