On Thu, 8 Jun 2023 at 18:53, Alexis <
surr...@gmail.com> wrote:
> I know of two options to reduce the duplication of the amount value:>
> 1. Using transaction typed metadata
>
> 2023/06/06 McDonalds
> ; amount_spent:: $23.98
> Expenses:Food:Restaurants (tag("amount_spent"))
> Liabilities:Apple Card (-tag("amount_spent"))
> Income:Credit Card Rewards (-(tag("amount_spent")) * 0.02)
> Assets:Apple Cash
>
> See
https://ledger-cli.org/doc/ledger3.html#Typed-metadata
One might try to combine typed metadata with automated transactions:
= Liabilities:Apple Card
Assets:Apple Cash (-tag("cashback"))
Income:Credit Card Rewards (tag("cashback"))
2023-06-06 McDonalds
; cashback:: 0.02
Expenses:Food:Restaurants $23.98
Liabilities:Apple Card
$ ledger bal -f test_cashback.ledger
$0.48 Assets:Apple Cash
$23.98 Expenses:Food:Restaurants
$-0.48 Income:Credit Card Rewards
$-23.98 Liabilities:Apple Card
--------------------
0
I do not know off the bat how to apply a default 0.02 value if the tag
is not present, but that is probably possible.