"John Wiegley" <
jo...@newartisans.com> writes:
> >>>>> Ben Finney <
ben+l...@benfinney.id.au> writes:
>
> > How can I enter [the account balance] at a specific point in time in
> > the Ledger input, such that Ledger can verify them when processing
> > the data?
>
> You can use a single line balance assertion:
>
> 2006/01/17 Confirm balance at this point
> [Liabilities:MasterCard] = $-1,731.72
Thank you. That works in this simple case:
=====
$ cat ./lorem.ledger
2015-01-01 * Opening balance
Assets:Bank:Savings $ 1000
Equity:Balances
2015-01-04 * Balance brought forward
[Assets:Bank:Savings] = $ 999999
2015-01-04 * Cheese
Expenses:Groceries $ 17
Assets:Bank:Savings
$ ledger -f ./lorem.ledger bal
While parsing file "./lorem.ledger", line 10:
While balancing transaction from "./lorem.ledger", lines 9-10:
> 2015-01-04 * Balance brought forward
> [Assets:Bank:Savings] = $ 999999
Unbalanced remainder is:
$ 998999
Amount to balance against:
$ 998999
Error: Transaction does not balance
=====
But the assertion doesn't work when I have a “default” account set:
=====
$ cat ./lorem.ledger
account Assets:Bank:Lorem Ipsum:Everyday Savings
alias Assets:Bank:Savings
default
2015-01-01 * Opening balance
Assets:Bank:Savings $ 1000
Equity:Balances
2015-01-04 * Balance brought forward
[Assets:Bank:Savings] = $ 999999
2015-01-04 * Cheese
Expenses:Groceries $ 17
Assets:Bank:Savings
$ ledger -f ./lorem.ledger bal
$ 983 Assets:Bank:Lorem Ipsum:Everyday Savings
$ -1000 Equity:Balances
$ 17 Expenses:Groceries
--------------------
0
=====
With the default account set, Ledger fills in what is needed to make the
assertion pass. This results in nonsense transactions:
=====
$ ledger ./lorem.ledger reg
2015-01-01 Opening balance ..:Lo:Everyday Savings $ 1000 $ 1000
Equity:Balances $ -1000 0
2015-01-04 Balance brought fo.. ..Lo:Everyday Savings] $ 998999 $ 998999
..:Lo:Everyday Savings $ -998999 0
2015-01-04 Cheese Expenses:Groceries $ 17 $ 17
..:Lo:Everyday Savings $ -17 0
=====
So, how can I make Ledger both create the needed postings on a default
account (as normal for the “default”); *and* make falsifiable assertions
about the balance at a specific timestamop?
--
\ “Any fool can write code that a computer can understand. Good |
`\ programmers write code that humans can understand.” —Martin |
_o__) Fowler, _Refactoring_, 2000 |
Ben Finney