On Thu, 8 Jun 2023 at 18:53, Alexis <[email protected]> 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.

-- 

--- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAP_d_8W_G-iTxw1XykVCdcpuabu2wQ%3DQZaitAfmx%2BZRR9x6x0w%40mail.gmail.com.

Reply via email to