Formulas with variables in transaction legs

102 views
Skip to first unread message

Dan Schultz

unread,
Mar 15, 2022, 7:59:44 PM3/15/22
to Beancount
Hello all,

This project and community is excellent, thank you so much for it!

I'm entering some transactions for a small business where each invoice results in a "gross income tax" liability due to a regional business tax.   In my specific case this is 0.4%.

I know I can write the formula directly e.g.:

2018-06-13 * "My Client" "invoice" ^2018-06-13-invoice-1 #MyProject
  Assets:AccountsReceivable                 1000.00 USD
  Income:Services:MyClient                   -1000.00 USD
  Expenses:Taxes:BusinessPrivilege     (1000.00 * 0.004) USD
  Liabilities:Taxes:BusinessPrivilege    -(1000.00 * 0.004) USD

I was wondering if there is any ability to define variables and reference those variables in transactions.

First: could I define the business privilege tax in a global event variable and reference that?

Second: could I even define that net billable "1000.00" in a transaction level metadata field that can be referenced in multiple places?

I also appreciate maybe the most explicit thing would be to simply do the calculation by hand as part of the entry, and so variable based stuff would be too complex and unpredictable, but wanted to ask just in case!

Best,
 - Dan


Tino Didriksen

unread,
Jun 4, 2024, 9:25:45 AMJun 4
to Beancount
Was a solution ever found/made for this? Plugin or otherwise?

I would also very much like some way to back-reference numbers. I've got transactions like:

2024-01-02 * "Bs betaling MODSTRØM DANMARK A/S"
Assets:Nordea:Tino:Primary -1036.65 DKK
Liabilities:TDC:VAT:Y2024 (-1036.65 * 0.3 * 0.2 * -1) DKK
Liabilities:TDC:B-Tax:Y2024 (-1036.65 * 0.3 * 0.8 * -1) DKK
Expenses:Housing:Power

and it is a bit silly to repeat the number on every line. I would like to instead write something akin to:

2024-01-02 * "Bs betaling MODSTRØM DANMARK A/S"
Assets:Nordea:Tino:Primary -1036.65 DKK
Liabilities:TDC:VAT:Y2024 (\1 * 0.3 * 0.2 * -1) DKK
Liabilities:TDC:B-Tax:Y2024 (\1 * 0.3 * 0.8 * -1) DKK
Expenses:Housing:Power

where \1 inserts the result of the first line, here just a flat number, but similarly \2 should be the result of the second line's calculation. Should be simple to implement, so if it doesn't exist I might take a stab at a plugin.

-- Tino Didriksen

Martin Blais

unread,
Jun 4, 2024, 9:24:27 PMJun 4
to bean...@googlegroups.com
Not that I'm aware of


--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/fb0e1d6e-ce9e-42c8-990f-7c85afbf0ab7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages