redstreet / reds-ramblings-comments

0 stars 0 forks source link

personal-finance/deduping-with-zerosum/ #10

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Deduping with Zerosum — Red's Rants

Zerosum is a Beancount plugin to match two halves of a transaction that appear across accounts or across time. The Zerosum README.md explains what it does, a...

https://reds-rants.netlify.app/personal-finance/deduping-with-zerosum/

richban commented 2 years ago

I want to migrate to per-account ledger files as well. For those scenarios how do you run the Zerosum plugin?

2010-06-07 * "Transfer to savings"
   Assets:Bank:Checking    -111 USD
   Assets:ZeroSum:Bank-Transfers

2010-06-07 * "Transfer from checking"
   Assets:Bank:Savings    111 USD
   Assets:ZeroSum:Bank-Transfers

Since now I would have to files: Assets.Bank.Checking.bc and Assets.Bank.Savings.bc. In this case I would need to invoke the plugin on the main.bc file?

redstreet commented 2 years ago

Correct: plugins work on the in-memory set of transactions that beancount has read from files. So the Zerosum doesn't care about the file it came from. Invoke it from main.bc, and it will work fine.

savingsandloan commented 2 years ago

I'm finally trying zerosum, but on the :USD cash account created in beancount_reds_importers which depending on some ofx import configurations should always be zero. This said, Shouldn't zerosum be paired with a balance assertion that checks that the zerosum account is zero and reports an error if it isn't?

Curious if perhaps the plugin should be improved to do this such that it happens automatically rather than a user writing it in manually at some arbitrary future date.

redstreet commented 2 years ago

Zerosum accounts should eventually be zero. There are many legitimate reasons why zerosum accounts may not be zero for various periods of time until then. Eg: in-flight bank transfers, rebates pending a check deposit, bought items that need to be returned. In these cases, zerosum accounts provide a confirmation of what is pending, while helping accurately reflect balances in view of the pending items.

It's simple to verify the state of zerosum accounts visually, for example by hiding zerosum accounts in fava when they are zero, meaning they show up only if not zero.

I'd be curious to hear about the case you have in mind if it doesn't fit the above. There are probably uses I haven't thought of.

savingsandloan commented 2 years ago

My particular usecase was from using the Vanguard OFX file with beancount-reds-importers (i.e. investments.py), where a Vanguard:MyAccount:USD gets created for various postings. I consider this an arbitrary scenario since I'm assuming a commodity ticker always gets created on Vanguard (including cash/money market accounts), which doesn't necessarily happen with ofx files by other institutions which may have a more generic form of handling cash.

That said, for such a case I managed to use zerosum with a balance assertion on the USD account (just set off to some far off 2099-01-01 date), and from seeing the error could figure out a rare importer issue as mentioned in https://github.com/redstreet/beancount_reds_importers/issues/15#issuecomment-1068241966 . I tend to err towards a workflow of just going through beancount errors rather than thinking about noticing if an account is hidden or shown.

redstreet commented 2 years ago

Makes sense. We could add a post_hook() method to the transaction builder, which would normally be an empty function, but could be overridden in your case to add the balance assertion you desire. If that sounds like it would address your ask, PR welcome :).