Thank you, John! I'm not having any success with the assertion statement
you suggested. I have modified the original example so that the
Assets:Envelopes < Assets:Bank. I expect this should throw an error, yet
it doesn't.
; define accounts for use with
; ledger bal --explicit --pedantic
commodity $
account Assets
account Assets:Bank
account Assets:Envelopes
account Assets:Bank:Checking
account Assets:Bank:Savings
account Assets:Envelopes:Rent
account Assets:Envelopes:Groceries
account Assets:Envelopes:Gasoline
account Assets:Envelopes:Vacation
account Expenses:Rent
account Expenses:Groceries
account Expenses:Gasoline
account Expenses:Vacation
account Equity:Opening
; bind expense account to corresponding envelope
= /Expenses:Groceries/
[Assets:Envelopes:Groceries] -1.0
[Assets] 1.0
= /Expenses:Rent/
[Assets:Envelopes:Rent] -1.0
[Assets] 1.0
= /Expenses:Gasoline/
[Assets:Envelopes:Gasoline] -1.0
[Assets] 1.0
= /Expenses:Vacation/
[Assets:Envelopes:Vacation] -1.0
[Assets] 1.0
; Beginning of transactions
2018/01/01 Opening balance
Assets:Bank:Checking $250.00
Assets:Bank:Savings $1000.00
Equity:Opening
2018/01/01 Transfer to envelopes
; There is $50 left to allocate
; We expect an error since Assets:Envelopes < Assets:Bank
[Assets:Envelopes:Groceries] $500
[Assets:Envelopes:Rent] $500
[Assets:Envelopes:Gasoline] $100
[Assets:Envelopes:Vacation] $100 ; Changed
[Assets]
2018-01-02 Buy groceries
Expenses:Groceries $50
Assets:Bank:Checking
2018-01-02 Pay rent
Expenses:Rent $50
Assets:Bank:Checking
2018-01-02 Buy groceries from Savings
Expenses:Groceries $100
Assets:Bank:Savings
assert account("Assets:Envelopes").amount == account("Assets:Bank").amount
I notice that
eval print(account("Assets:Envelopes").amount)
eval print(account("Assets:Bank").amount)
both return 0, so I suspect that the assert statements always evaluate as
true. I've tried other variations with the syntax with little success. I
don't see anything related in the manual. I was able to get a non-zero
result with
eval print(account("Assets").amount)
but this returns $-1200.00 which doesn't make any sense to me.
If it makes a difference, I'm running version 3.1.2-20160801 which was
installed from the Debian repos.
Thank you,
Matt
On Wed, Dec 26, 2018 at 3:01 PM John Wiegley <[email protected]> wrote:
> >>>>> "d" == dolorsitatem <[email protected]> writes:
>
> d> Ideally, Assets:Envelopes should always match Assets:Bank. There are
> three
> d> possible scenarios:
>
> I believe you can just assert in your file:
>
> assert account("Assets:Envelopes").amount == account("Assets:Bank").amount
>
> John
>
--
---
You received this message because you are subscribed to the Google Groups
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.