Conversible commodities, how to deal with that?

28 views
Skip to first unread message

Felipe Mica

unread,
Sep 11, 2021, 8:00:42 PM9/11/21
to Ledger
Hello!

What is the best way (approach) to deal with different commodities that are convertible between them?

Let's suppose I want to work with different units of the same commodity. Example: BTC and SAT (Satoshis). 1 BTC is = 100,000,000 SAT - Is there a way to tell to Ledger-CLI that these currencies are the same (or convertible between them) and if I could use both freely and get the report in only one unit?

For example:

2021-09-06 Test
    Assets:Checking
    Expenses:Food:Groceries               0.00010000 BTC

2021-09-06 Test
    Assets:Checking
    Expenses:Food:Groceries                   10,000 SAT


Both entries are exactly the same thing, but the report:

ledger -f draft.ledger balance
     -0.00010000 BTC
         -10,000 SAT  Assets:Checking
      0.00010000 BTC
          10,000 SAT  Expenses:Food:Groceries

I can do this:

commodity SAT
  note Satoshis
  format 1,000 SAT

commodity BTC
  note Bitcoin
  format 1,000.00000000 SAT

define BTC_TO_SAT=100,000,000 SAT

2021-09-06 Test
    Assets:Checking
    Expenses:Food:Groceries               (0.00010000 * BTC_TO_SAT)

2021-09-06 Test
    Assets:Checking
    Expenses:Food:Groceries                   10,000 SAT


To result in:

         -20,000 SAT  Assets:Checking
          20,000 SAT  Expenses:Food:Groceries
--------------------
                   0

But maybe there is a better way to deal with that?

Thank you.

Martin Michlmayr

unread,
Sep 11, 2021, 8:43:03 PM9/11/21
to ledge...@googlegroups.com
* Felipe Mica <mica...@gmail.com> [2021-09-11 17:00]:
> But maybe there is a better way to deal with that?

Typically you'd use "C" for that.

https://www.ledger-cli.org/3.0/doc/ledger3.html#index-C-1

C 100,000,000 SAT = 1 BTC

--
Martin Michlmayr
https://www.cyrius.com/
Reply all
Reply to author
Forward
0 new messages