I'm working on a sort of full-fledged-hledger with just ledger, and I'm trying to figure out the logic for importing journals with balance assertions. Given the following main file:
;main.journal
2024/07/30 Opening balances
Assets:Alipay ¥100
Equity:Opening Balances
And a journal (generated from a bank's CSV using ledger convert
):
;importing.journal
2024/08/02 7-11
Expenses:Unknown ¥12
Assets:Alipay ¥-12 = ¥88
With the command ledger --args-only -f main.journal -f importing.journal --sort date print
While parsing file "/home/.../importing.journal", line 4:
While parsing posting:
Assets:Alipay ¥-12 = ¥88
^^^^
Error: Balance assertion off by ¥100 (expected to see ¥-12)
Is there a way to make ledger acknowledge these assertions this way?
One solution I'm aware of is to concatenate the files, but in my use case, this makes it harder to track down errors with accounts because the line numbers don't match the lines in the files after concatenation.
And on a related note, if I stick some command directives like account and commodity declarations in another file, those declarations will affect the other files:
;init.dat
account Expenses:Groceries
account Assets:Alipay
account Equity:Opening Balances
commodity ¥
# Doesn't complain about the accounts (except for Expenses:Unknown)
ledger --strict -f init.dat -f main.journal -f importing.journal --sort date print
In addition, account aliases don't apply if there's a balance assertion in importing.journal (and that assertion fails).