284 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			284 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| # Transaction modifier adding (unbalanced) tax postings.
 | |
| # print. Auto-generated postings are inserted below the matched one.
 | |
| <
 | |
| = ^income
 | |
|   (liabilities:tax)  *.33  ; income tax
 | |
| 
 | |
| 2016/1/1 paycheck
 | |
|     income:remuneration     $-100
 | |
|     income:donations         $-15
 | |
|     assets:bank
 | |
| 
 | |
| 2016/1/1 withdraw
 | |
|     assets:cash             $20
 | |
|     assets:bank
 | |
| 
 | |
| $ hledger print -f- --auto
 | |
| 2016/01/01 paycheck
 | |
|     income:remuneration           $-100
 | |
|     (liabilities:tax)              $-33    ; income tax
 | |
|     income:donations               $-15
 | |
|     (liabilities:tax)               $-5    ; income tax
 | |
|     assets:bank
 | |
| 
 | |
| 2016/01/01 withdraw
 | |
|     assets:cash             $20
 | |
|     assets:bank
 | |
| 
 | |
| >=
 | |
| 
 | |
| # register
 | |
| $ hledger register -f- --auto
 | |
| 2016/01/01 paycheck             income:remuneration          $-100         $-100
 | |
|                                 (liabilities:tax)             $-33         $-133
 | |
|                                 income:donations              $-15         $-148
 | |
|                                 (liabilities:tax)              $-5         $-153
 | |
|                                 assets:bank                   $115          $-38
 | |
| 2016/01/01 withdraw             assets:cash                    $20          $-18
 | |
|                                 assets:bank                   $-20          $-38
 | |
| >=
 | |
| 
 | |
| # balance
 | |
| $ hledger balance -f- --auto
 | |
|                 $115  assets
 | |
|                  $95    bank
 | |
|                  $20    cash
 | |
|                $-115  income
 | |
|                 $-15    donations
 | |
|                $-100    remuneration
 | |
|                 $-38  liabilities:tax
 | |
| --------------------
 | |
|                 $-38
 | |
| >=
 | |
| 
 | |
| # Balance assertions see postings generated by transaction modifier rules.
 | |
| <
 | |
| = trigger
 | |
|   (target)   10
 | |
| 
 | |
| 2018/1/1
 | |
|   (trigger)   1
 | |
|   (target)    1    = 11  ; this assertion would not fail, auto posting will be taken into account
 | |
| 
 | |
| $ hledger register -f- --auto
 | |
| 2018/01/01                      (trigger)                        1             1
 | |
|                                 (target)                        10            11
 | |
|                                 (target)                         1            12
 | |
| >=
 | |
| 
 | |
| # Transaction modifier adding (balanced virtual) budget envelope postings.
 | |
| <
 | |
| = ^expenses:groceries
 | |
|     [budget:groceries]                           *-1
 | |
|     [assets:bank:checking]                        *1
 | |
| 
 | |
| 2018/10/7 * MARKET
 | |
|     expenses:groceries:food
 | |
|     assets:bank:checking                         $-20
 | |
| 
 | |
| $ hledger print -f- --auto
 | |
| 2018/10/07 * MARKET
 | |
|     expenses:groceries:food
 | |
|     [budget:groceries]                 $-20
 | |
|     [assets:bank:checking]              $20
 | |
|     assets:bank:checking               $-20
 | |
| 
 | |
| >=
 | |
| 
 | |
| # Rules will preserve a transaction price from the original amount.
 | |
| <
 | |
| = assets:billable:client1
 | |
|   assets:receivable:client1       *100
 | |
|   revenues:client1
 | |
| 
 | |
| 2018/1/1
 | |
|     (assets:billable:client1)         0.50h @ $90
 | |
| 
 | |
| $ hledger -f- print --auto -x
 | |
| 2018/01/01
 | |
|     (assets:billable:client1)     0.50h @ $90
 | |
|     assets:receivable:client1    50.00h @ $90
 | |
|     revenues:client1                   $-4500
 | |
| 
 | |
| >=
 | |
| 
 | |
| # Rules can set a new commodity in the generated amounts.
 | |
| <
 | |
| = assets:billable:client1
 | |
|   assets:receivable:client1       *$100
 | |
|   revenues:client1
 | |
| 
 | |
| 2018/1/1
 | |
|     (assets:billable:client1)         0.50h
 | |
| 
 | |
| $ hledger -f- print --auto -x
 | |
| 2018/01/01
 | |
|     (assets:billable:client1)           0.50h
 | |
|     assets:receivable:client1             $50
 | |
|     revenues:client1                     $-50
 | |
| 
 | |
| >=
 | |
| 
 | |
| # And/or a new transaction price.
 | |
| <
 | |
| = assets:billable:client1
 | |
|   assets:receivable:client1       *1.00 "Client1 Hours" @ $100.00
 | |
|   revenues:client1
 | |
| 
 | |
| 2018/1/1
 | |
|     (assets:billable:client1)         0.50h @ $90
 | |
| 
 | |
| $ hledger -f- print --auto -x
 | |
| 2018/01/01
 | |
|     (assets:billable:client1)                       0.50h @ $90
 | |
|     assets:receivable:client1    0.50 "Client1 Hours" @ $100.00
 | |
|     revenues:client1                                    $-50.00
 | |
| 
 | |
| >=
 | |
| 
 | |
| # Balance assignments may not be used with accounts also affected by transaction modifier rules.
 | |
| <
 | |
| = ^expenses:foo
 | |
|     budget:available   *-1
 | |
|     assets:checking     *1
 | |
| 
 | |
| 2018/10/17 * INITIAL
 | |
|     budget:available   $100
 | |
|     equity:opening
 | |
| 
 | |
| 2018/10/17 * SOME EXPENSE
 | |
|     expenses:foo                                 $50
 | |
|     assets:checking
 | |
| 
 | |
| 2018/10/17 * ASSERT
 | |
|     budget:other
 | |
|     budget:available                              =$0
 | |
| 
 | |
| $ hledger print -f- --auto
 | |
| >2
 | |
| hledger: cannot assign amount to account 
 | |
| 
 | |
|     budget:available
 | |
| 
 | |
| because it is also included in transaction modifiers.
 | |
| 
 | |
| >=1
 | |
| 
 | |
| 
 | |
| # Issue #928:
 | |
| # Generating auto postings from a unit-priced amount.
 | |
| <
 | |
| = ^Expenses:Joint
 | |
|     Expenses:Joint                                               *-1
 | |
|     Liabilities:Joint:Bob                                       *0.5
 | |
|     Liabilities:Joint:Bill                                      *0.5
 | |
|     
 | |
| 2018/01/01
 | |
|     Expenses:Joint:Widgets                                   $100.00 @ £0.50
 | |
|     Assets:Joint:Bank                                        -£50.00
 | |
| 
 | |
| $ hledger -f- print --auto
 | |
| 2018/01/01
 | |
|     Expenses:Joint:Widgets     $100.00 @ £0.50
 | |
|     Expenses:Joint            $-100.00 @ £0.50
 | |
|     Liabilities:Joint:Bob       $50.00 @ £0.50
 | |
|     Liabilities:Joint:Bill      $50.00 @ £0.50
 | |
|     Assets:Joint:Bank                  £-50.00
 | |
| 
 | |
| >=0
 | |
| 
 | |
| # Generating auto postings from a total-priced amount.
 | |
| <
 | |
| = ^Expenses:Joint
 | |
|     Expenses:Joint                                               *-1
 | |
|     Liabilities:Joint:Bob                                       *0.5
 | |
|     Liabilities:Joint:Bill                                      *0.5
 | |
|     
 | |
| 2018/01/01
 | |
|     Expenses:Joint:Widgets                                   $100.00 @@ £50
 | |
|     Assets:Joint:Bank                                        -£50.00
 | |
| 
 | |
| $ hledger -f- print --auto
 | |
| 2018/01/01
 | |
|     Expenses:Joint:Widgets     $100.00 @@ £50
 | |
|     Expenses:Joint            $-100.00 @@ £50
 | |
|     Liabilities:Joint:Bob       $50.00 @@ £25
 | |
|     Liabilities:Joint:Bill      $50.00 @@ £25
 | |
|     Assets:Joint:Bank                 £-50.00
 | |
| 
 | |
| >=0
 | |
| # alternate approach: convert to unit prices
 | |
| #2018/01/01
 | |
| #    Expenses:Joint:Widgets     $100.00 @@ £50
 | |
| #    Expenses:Joint            $-100.00 @ £0.5
 | |
| #    Liabilities:Joint:Bob       $50.00 @ £0.5
 | |
| #    Liabilities:Joint:Bill      $50.00 @ £0.5
 | |
| #    Assets:Joint:Bank                 £-50.00
 | |
| 
 | |
| # Generating auto postings from an implicitly-priced amount. Should work like the above.
 | |
| <
 | |
| = ^Expenses:Joint
 | |
|     Expenses:Joint                                               *-1
 | |
|     Liabilities:Joint:Bob                                       *0.5
 | |
|     Liabilities:Joint:Bill                                      *0.5
 | |
| 
 | |
| 2018/01/01
 | |
|     Expenses:Joint:Widgets                                   $100.00
 | |
|     Assets:Joint:Bank                                        -£50.00
 | |
| 
 | |
| $ hledger -f- print --auto
 | |
| 2018/01/01
 | |
|     Expenses:Joint:Widgets            $100.00
 | |
|     Expenses:Joint            $-100.00 @@ £50
 | |
|     Liabilities:Joint:Bob       $50.00 @@ £25
 | |
|     Liabilities:Joint:Bill      $50.00 @@ £25
 | |
|     Assets:Joint:Bank                 £-50.00
 | |
| 
 | |
| >=0
 | |
| 
 | |
| #
 | |
| 
 | |
| 
 | |
| ## Transaction modifiers affect forecast transactions (#959)
 | |
| <
 | |
| = ^income
 | |
|   (liabilities:tax)  *.33  ; income tax
 | |
| 
 | |
| ~ monthly from 2016-01   paycheck
 | |
|     income:remuneration     $-100
 | |
|     income:donations         $-15
 | |
|     assets:bank
 | |
| 
 | |
| 2016/1/3 withdraw
 | |
|     assets:cash             $20
 | |
|     assets:bank
 | |
| 
 | |
| $ hledger print -f- --auto --forecast -b 2016-01 -e 2016-03
 | |
| 2016/01/03 withdraw
 | |
|     assets:cash             $20
 | |
|     assets:bank
 | |
| 
 | |
| 2016/02/01 paycheck
 | |
|     ; recur: monthly from 2016-01
 | |
|     income:remuneration           $-100
 | |
|     (liabilities:tax)              $-33    ; income tax
 | |
|     income:donations               $-15
 | |
|     (liabilities:tax)               $-5    ; income tax
 | |
|     assets:bank
 | |
| 
 | |
| >=
 | |
| 
 | |
| # and they don't force --auto on
 | |
| $ hledger print -f- --forecast -b 2016-01 -e 2016-03
 | |
| 2016/01/03 withdraw
 | |
|     assets:cash             $20
 | |
|     assets:bank
 | |
| 
 | |
| 2016/02/01 paycheck
 | |
|     ; recur: monthly from 2016-01
 | |
|     income:remuneration           $-100
 | |
|     income:donations               $-15
 | |
|     assets:bank
 | |
| 
 | |
| >=
 |