# * --pivot option

# ** 1. check pivot with print
<
2016/02/16 Test Transaction
    Account1                                   2 EUR
    Account2                                  -2 EUR
    ; TAG: value
$ hledger -f- --pivot TAG print
2016-02-16 Test Transaction
                    2 EUR
    value          -2 EUR
    ; TAG: value

>= 0

# ** 2. check pivot with bal
<
2016/02/16 Member Fee Payment John Doe
    assets:bank account                                   2 EUR
    income:member fees                                  -2 EUR
      ; member: John Doe
$ hledger -f- --pivot member bal --no-total
               2 EUR  
              -2 EUR  John Doe

# ** 3. check with another example
<
2016/02/16 Donation Freifunk
    assets:bank account                                   2 EUR
    income:donations                                  -2 EUR
      ; budget: Freifunk
$ hledger -f- --pivot budget bal --no-total
               2 EUR  
              -2 EUR  Freifunk

# ** 4. query on account will find either effective name or original one
<
2016/02/16 Test Transaction
    Account1                                   2 EUR
    ; TAG: fun
    Account2                                  -1 EUR
    ; TAG: value
    Account2                                  -1 EUR
    ; TAG: hidden
$ hledger -f- --pivot TAG reg '^Account2$' '^fun$' not:hidden
2016-02-16 Test Transaction     fun                          2 EUR         2 EUR
                                value                       -1 EUR         1 EUR

# ** 5. We should be able to query on original account names
<
2017/1/1 prepay
    assets           $1500  ; expenses:a
    assets            $100  ; expenses:b
    assets              $5  ; expenses:c
    liabilities     $-1605
$ hledger -f- --pivot expenses reg not:liabilities
2017-01-01 prepay               a                            $1500         $1500
                                b                             $100         $1600
                                c                               $5         $1605

# ** 6. pivot for implicit tag desc (technical sample)
<
2016/02/16 Freifunk
    assets:bank account                                   2 EUR  ; date:03/01
    income:donations                                  -2 EUR
$ hledger -f- --pivot desc reg -M
2016-02   Freifunk                                          -2 EUR        -2 EUR
2016-03   Freifunk                                           2 EUR             0

# ** 7. pivot for implicit tag code (technical sample)
<
2016/02/16 (Freifunk) Donation Freifunk
    assets:bank account                                   2 EUR  ; date:03/01
    income:donations                                  -2 EUR
$ hledger -f- --pivot code reg -M
2016-02   Freifunk                                          -2 EUR        -2 EUR
2016-03   Freifunk                                           2 EUR             0

# ** 8. use of pivot with code-based budgeting
<
2016/02/16 (Freifunk) Donation Freifunk
    assets:bank account                                   2 EUR
    income:donations                                  -2 EUR
$ hledger -f- --pivot code reg ^income
2016-02-16 Donation Freifunk    Freifunk                    -2 EUR        -2 EUR

# ** 9. get expenses balance by payee
<
2016/02/16 (1138) Auchan | buy a food for tomorrow morning
    assets:bank account
    expense:snacks                      2 EUR
    expense:grocery                    20 EUR

2016/02/16 StarBars
    assets:bank account
    expense:coffee                     5 EUR
$ hledger -f- --pivot payee bal --no-total --flat ^expense
              22 EUR  Auchan
               5 EUR  StarBars

# ** 10. get daily expenses by payee
<
2016/02/16 (1138) Auchan
    assets:bank account
    expense:snacks                      2 EUR
    expense:grocery                    20 EUR

2016/02/16 StarBars
    assets:bank account
    expense:coffee                     5 EUR

2016/02/17 (1139) Auchan
    assets:bank account
    expense:grocery                    30 EUR
$ hledger -f- --pivot payee reg -D ^expense
2016-02-16   Auchan                                         22 EUR        22 EUR
             StarBars                                        5 EUR        27 EUR
2016-02-17   Auchan                                         30 EUR        57 EUR
# ** 11. pivot on multiple tags
<
2023-01-01 compound purchase
        expenses  10 ; project: job1, kind: equipment
        expenses  20 ; project: job2, kind: equipment
        expenses  25 ; project: job2, kind: fee
        assets
$ hledger -f- --pivot acct:kind:project bal ^expense -N
                  10  expenses:equipment:job1
                  20  expenses:equipment:job2
                  25  expenses:fee:job2
