How to use account_base

4 views
Skip to first unread message

Igbanam Ogbuluijah

unread,
Jul 4, 2024, 10:46:18 AM (23 hours ago) Jul 4
to ledge...@googlegroups.com


account_base
 — from man ledger — is an expression to "Return the base account, i.e. everything after the last account delimiter ':'".

How do I use this within a ledger?

Use case: I want to record tax for sales per customer.

= ^Income
    Liabilities:Tax:$account  -0.1
    $account                   0.1

2024-07-04 * Sale
    Assets    10 USD
    Income:Customer A

This results in a Liabilities:Tax:Income:Customer A account automatically created. What I would like to end up with is Liabilities:Tax:Customer A — is this possible?

Thanks



- Igbanam

John Wiegley

unread,
Jul 4, 2024, 4:01:43 PM (17 hours ago) Jul 4
to ledge...@googlegroups.com
I think you would then use $account_base?

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 ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/CAOmRJrdYZq_mHEO5QXZQurXTLrX6X5f6bORN1TCWZui27bZ%2BOQ%40mail.gmail.com.

Igbanam Ogbuluijah

unread,
5:04 AM (4 hours ago) 5:04 AM
to Ledger
If it's meant to work this way, then there may be a bug somewhere.

With

= ^Income
    Liabilities:Tax:$account_base  -0.1

    $account                   0.1

2024-07-04 * Sale
    Assets    10 USD
    Income:Customer A


the bal query yields

              10 USD  Assets
             -11 USD  Income:Customer A
               1 USD  Liabilities:Tax:$account_base
--------------------
                   0


Wrapping it in braces — i.e $(account_base) or ($account_base) doesn't help either

Is $account_base meant to work within the ledger? If so, I could open an issue on Github and look into why it isn't working as should.


Best,
Igbanam
Reply all
Reply to author
Forward
0 new messages