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

Stop erroring if every transaction change is zero #49

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

AzinKhan
Copy link
Contributor

In some situations, there can be a zero-value transaction in the imported CSV files. These are usually for card checks and similar usecases. Prior to this change, the ledger tool would return the more than one account empty error in that case.

This change updates the logic to return early if the balances sum to zero. If there is any remaining balance, then the old behaviour is preserved.

In some situations, there can be a zero-value transaction in the
imported CSV files. These are usually for card checks and similar
usecases. Prior to this change, the ledger tool would return the `more
than one account empty` error in that case.

This change updates the logic to return early if the balances sum to
zero. If there is any remaining balance, then the old behaviour is
preserved.
}

if balance.IsZero() {
// If everything adds up, then all is well.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the key assumption - I don't think this will cause other issues but I'm happy to be corrected.

@AzinKhan AzinKhan marked this pull request as ready for review August 23, 2023 18:00
@AzinKhan
Copy link
Contributor Author

AzinKhan commented Aug 23, 2023

Hi @howeyc! I hope you don't mind this PR out of the blue. I was importing some of my account CSVs and found that the tool was tripping over some zeroed-out transactions (in this case a card check was appearing in the export). The obvious workaround was just to find and remove it but I think that we could potentially just allow a transaction to have all of its account changes be 0?

@howeyc
Copy link
Owner

howeyc commented Aug 23, 2023

LGTM

I think all zeros is a little odd, but I can't see any downside to allowing it. If anything they could be placeholders, or for notes, anything really. I suppose if someone finds them useful I don't have an argument against them.

I'll likely merge within a day.

@AzinKhan
Copy link
Contributor Author

Thanks!

I think all zeros is a little odd

Yeah it's definitely an edge case, but if it doesn't hurt to handle it then it's worth having it to save a bit of time here and there.

@howeyc howeyc merged commit 5a429c0 into howeyc:master Aug 23, 2023
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