mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-28 04:46:31 +03:00
167 lines
4.3 KiB
Plaintext
167 lines
4.3 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
|
|
|