Closed mikeonly closed 6 months ago
I don't quite follow how to reproduce this, sorry, there's not enough information in the first sentence. Like, do you get the flycheck errors when editing A.journal or main.journal? Steps to reproduce would make this clearer.
Yes, sorry for not explaining it better. I get the errors when editing the A.journal.
Alright, so A.journal
does not balance locally (ie. just within that file), but when included from main.journal
it should balance? Errors when editing A.journal
would be expected in that case: flycheck
operates on buffers even when they're not saved to disk, so there'd be no way to run ledger on main.journal
so that the un-saved changes from A.journal
would be included in the overall balancing.
However, I think you can (and probably should) arrange for the individual files to balance too. IIRC I had a similar situation to you, and found that I could make everything line up nicely by using additional account names and opening balances:
For example, let's say you have a ledger file per bank account. Often you need to account for moving money between them, so the naive solution is to directly reference the account names for the other file. Instead, you can introduce a "virtual" account name. As an example:
credit-card.ledger
:
2012-05-03 5261: EXAMPLE TRANSACTION
Personal:Expenses:Groceries £10.58
Personal:Liabilities:Mastercard
2012-05-05 : PAYMENT DIRECT DEBIT FROM CURRENT ACCOUNT
Personal:Liabilities:Mastercard £1,198.43
Personal:Transfers:Mastercard
and in current-account.ledger
:
2012-05-08 (D/D) 'CREDIT CARD PAYMENT
Personal:Transfers:Mastercard £1,198.43
Personal:Assets:Bank:Current £-1,198.43
while main.ledger
includes both files:
include current-account.ledger
include credit-card.ledger
In this scheme Personal:Transfers:Mastercard
represents a flow of funds between the credit card account and other sources. All the ledger
files balance on their own, and when combined in main.ledger
the flows from the Transfers
account get balanced up against each other.
By using an opening balance account, you can usually make individual files balance internally, e.g. at the top of my credit-card.ledger
you might have:
2012-04-06 Personal Opening Balance
Personal:Liabilities:Mastercard £-176.97
Personal:Equity:Opening Balances
Thanks for the detailed clarification. Transfer accounts trick is very helpful, and I can make the opening balance work too. I would just expect a different behavior given that there is a local variable that points to the main .ledger file, but good to know that the observed error is expected. That issue is resolved as you have kindly explained your own solution, thank you.
Great, glad that helped!
Hi, I get an flycheck-ledger error for balance assertions in one of my files, let's say
A.journal
, when it is included inmain.journal
asinclude A.journal
together with some other transactions and includes that make the balance assertions inA.journal
in total correct. I am missing something I should specify to flycheck-ledger or is it not an intended functionality?Running both
hledger check --strict
andledger reg --strict
gives no errors in the command line. They are both ran against$LEDGER_FILE
which is an entrymain.journal
. I suspected that errors from flycheck-ledger would correspond to those fromledger
executable, but it is not the case.What variables should I check to fix that, or what am I missing?
Thanks. :)