redstreet / reds-ramblings-comments

0 stars 0 forks source link

personal-finance/automating-balance-assertions/ #6

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Automating Balance Assertions — Red's Rants

Balance assertions allow you to verify that Beancount’s computed balance for an account is the same as the balance provided by the banking institution. Auto-...

https://reds-rants.netlify.app/personal-finance/automating-balance-assertions/

redstreet commented 2 years ago

Works like a charm! I'm still missing the balance assertions tho. Should I make the balance assertions based on the Started Date (max) and State == Completed? Since I can have PENDING transactions that don't have any balance yet:

CARD_PAYMENT | Current | 12/5/21 9:32 |   | Iz *Cooffe | -150 | 0 | DKK | PENDING |  
-- | -- | -- | -- | -- | -- | -- | -- | -- | --
CARD_PAYMENT | Current | 12/4/21 11:39 | 12/5/21 10:20 | Misc | -25 | 0 | DKK | COMPLETED | 1276.57
CARD_PAYMENT | Current | 12/4/21 13:03 | 12/5/21 10:20 | Iz * Coffee Aps | -79 | 0 | DKK | COMPLETED | 1197.57
CARD_PAYMENT | Current | 12/5/21 11:14 |   | Iz *Coffee | -30 | 0 | DKK | PENDING |  
TOPUP | Current | 12/5/21 11:47 | 12/5/21 11:48 | Top-Up by *0225 | 1680 | 0 | DKK | COMPLETED | 2877.57

Originally posted by @richban in this article.

redstreet commented 2 years ago

@richban, yes, that's what I would do. Set this variable to true in your importer's init. Then, implement this method in your importer to do exactly what you said (find the balance of the last completed transaction).

The article above should help you figure out the date.

richban commented 2 years ago

Thank you this definitely helped! I have managed to implement it. Next up is Deduping 🙂

dc-bond commented 7 months ago

The balance date in my QFX file is 2023-11-29. The last transaction date in my file is 2023-11-28.

When I set the balance_assertion_date_type to anything other than "last_transaction" (e.g. set it to smart, ofx_date, today, etc.), the balance assertion date generated is 2023-11-30. When I set it to last_transaction the date generated is 2023-11-29.

This doesn't seem to make sense. Why doesn't ofx_date generate a date of 2023-11-29? Why doesn't last_transaction generate a date of 2023-11-28? Does this have something to do with the fact I'm using a QFX file instead of an OFX file? Should I just switch to try using CSV files instead?

I set the key in my importer config as follows:

CONFIG = [

apply_hooks(quicksilverXXXX.Importer({
    'account_number'  : 'XXXX',
    'main_account'    : 'Liabilities:CapitalOne:Quicksilver',
    'balance_assertion_date_type' : 'ofx_date',
    }), [PredictPostings()]),
redstreet commented 7 months ago

Balance entries as defined by Beancount run at the beginning of the day before other transactions. So for any day where you want to check the balance at the end of the day the balance assertion has to be made on the next date.

Therefore balance assertions are always one day later than you might expect. Does this help clarify?

dc-bond commented 7 months ago

Okay that makes sense now thanks! Essentially its like saying "my bank statement says my balance is $10 on 11:59:59pm of 11/29, and my beancount ledger balance assertion says my balance is $10 on 12:00:00am of 11/30" - meaning any additional transactions occurring on 11/30 would be placed after the balance assertion maintaining a correct accounting.

redstreet commented 7 months ago

That's exactly right!