dev: tests: convert remaining format 1 tests to format 3 (or 2)

Mostly done with an unreleased version of shelltestrunner, plus a few manual fixups.
This commit is contained in:
Simon Michael 2023-02-16 08:05:07 -10:00
parent b6d36e9c0b
commit e9cd1df048
73 changed files with 581 additions and 903 deletions

View File

@ -2,24 +2,23 @@
# data validation
#
# 1. should prompt again for a bad date
hledger -f $$-add.j add; rm -f $$-add.j
<<<
2009/1/32
$$$ hledger -f $$-add.j add; rm -f $$-add.j
>>> /A valid hledger smart date is required/
>>>=0
>>>2 //
# 2. should accept a blank date
hledger -f $$-add.j add; rm -f $$-add.j
<<<
$$$ hledger -f $$-add.j add; rm -f $$-add.j
>>> /Date .*Description:/
>>>=0
>>>2 //
##############################################################################
# precision and commodity handling
#
# 3. simple add with no existing journal, no commodity entered
hledger -f $$-add.j add; rm -f $$-add.j
<<<
@ -28,11 +27,11 @@ a
b
.
$$$ hledger -f $$-add.j add; rm -f $$-add.j
>>> /Date.*Description.*Account 1.*Amount 1.*Account 2.*Amount 2.*Account 3.*or \. or enter to finish.*/
>>>=0
>>>2 //
# 4. default commodity with greater precision
printf 'D $1000.00\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
<<<
@ -42,11 +41,11 @@ b
.
$$$ printf 'D $1000.00\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
>>> /a +\$1000\.0/
>>>=0
>>>2 //
# 5. default commodity with less precision
printf 'D $1000.0\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
<<<
@ -56,11 +55,11 @@ b
.
$$$ printf 'D $1000.0\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
>>> /a +\$1000\.00/
>>>=0
>>>2 //
# 6. existing commodity with greater precision
printf '2010/1/1\n a $1000.00\n b\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
<<<
@ -69,11 +68,11 @@ $1000.0
b
.
$$$ printf '2010/1/1\n a $1000.00\n b\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
>>> /a +\$1000\.0/
>>>=0
>>>2 //
# 7. existing commodity with less precision
printf '2010/1/1\n a $1000.0\n b\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
<<<
@ -83,11 +82,11 @@ b
.
$$$ printf '2010/1/1\n a $1000.0\n b\n' >t$$.j; hledger -f t$$.j add >/dev/null; cat t$$.j; rm -f t$$.j
>>> /a +\$1000\.00/
>>>=0
>>>2 //
# 8. default amounts should not fail to balance due to precision
rm -f nosuch.journal; hledger -f nosuch.journal add; rm -f nosuch.journal
<<<
2010/1/1
x
@ -96,8 +95,9 @@ a
b
0.5
c
$$$ rm -f nosuch.journal; hledger -f nosuch.journal add; rm -f nosuch.journal
>>> /Amount 3 \[-0.75\]:/
>>>=0
>>>2 //
## 9. shouldn't add decimals if there aren't any
## printf '\n\na\n1\nb\n' | hledger -f /dev/null add

View File

@ -1,68 +1,61 @@
# amount layout tests, using default vertical layout
# 1. print
hledger -f - print --explicit
<<<
<
2010/1/1
a EUR 1 ; a euro
b USD 1 ; a dollar
c ; a euro and a dollar
>>>
$ hledger -f - print --explicit
2010-01-01
a EUR 1 ; a euro
b USD 1 ; a dollar
c EUR -1 ; a euro and a dollar
c USD -1 ; a euro and a dollar
>>>=0
>= 0
# 2. register
hledger -f - register
<<<
<
2010/1/1
a EUR 1 ; a euro
b USD 1 ; a dollar
c ; a euro and a dollar
>>>
$ hledger -f - register
2010-01-01 a EUR 1 EUR 1
b USD 1 EUR 1
USD 1
c EUR -1
USD -1 0
>>>=0
# 3. balance
hledger -f - balance -N
<<<
<
2010/1/1
a EUR 1 ; a euro
b USD 1 ; a dollar
c ; a euro and a dollar
>>>
$ hledger -f - balance -N
EUR 1 a
USD 1 b
EUR -1
USD -1 c
>>>=0
# 4. a single-commodity zero amount's commodity/decimal places/price is preserved, when possible
hledger -f- print --explicit --empty
<<<
<
2010/3/1 x
a $0.00 @ 3EUR
b
>>>
$ hledger -f- print --explicit --empty
2010-03-01 x
a 0 @ 3EUR
b 0
>>>=0
>= 0
# 5.
# When preserving a zero amount's commodity, we should also preserve
# the amount style, such as where to place the symbol.
# https://github.com/simonmichael/hledger/issues/230
hledger -f- balance --tree -N
<<<
<
D 1000,00€
1/1
@ -72,12 +65,11 @@ D 1000,00€
a:1 4000,58
a:D -1000,58
e -3000
>>>
$ hledger -f- balance --tree -N
3000,00€ a
4000,58€ 1
-1000,58€ D
-3000,00€ e
>>>= 0
# 5. mixed amounts with prices

View File

@ -1,21 +1,17 @@
# issue 219, --tree and --flat flags should override each other cleanly
# 1. multiple flags ending with --flat, equivalent to --flat
hledger -f balance-multicol.journal bal -MH --no-elide --no-total date:2013/1 --tree --flat
>>>
$ hledger -f balance-multicol.journal bal -MH --no-elide --no-total date:2013/1 --tree --flat
Ending balances (historical) in 2013-01:
|| 2013-01-31
=================++============
assets:checking || 10
>>>= 0
# 2. multiple flags ending with --tree, equivalent to --tree
hledger -f balance-multicol.journal bal -MH --no-elide --no-total date:2013/1 --flat --tree
>>>
$ hledger -f balance-multicol.journal bal -MH --no-elide --no-total date:2013/1 --flat --tree
Ending balances (historical) in 2013-01:
|| 2013-01-31
============++============
assets || 10
checking || 10
>>>= 0

View File

@ -1,21 +1,16 @@
# 1.
hledger -f sample.journal balance --no-total --depth 1
>>>
$ hledger -f sample.journal balance --no-total --depth 1
$-1 assets
$2 expenses
$-2 income
$1 liabilities
>>>=0
# 2. Depth 0 aggregates everything into one line
hledger -f sample.journal balance --no-total --depth 0 assets
>>>
$ hledger -f sample.journal balance --no-total --depth 0 assets
$-1 ...
>>>=0
# 3. Ditto in a multi-column balance report.
hledger -f sample.journal balance -M -e 2008/2 --depth 0 assets
>>>
$ hledger -f sample.journal balance -M -e 2008/2 --depth 0 assets
Balance changes in 2008-01:
|| Jan
@ -23,4 +18,3 @@ Balance changes in 2008-01:
... || $1
-----++-----
|| $1
>>>=0

View File

@ -14,15 +14,14 @@
# --flat shows exclusive balances
# 1.
hledger -f - balance --flat
<<<
<
1/1
(a:aa) 1
(a:aa:aaa) 1
(a:aa:bbb) 1
(b) 1
(b:bb:bbb) 1
>>>
$ hledger -f - balance --flat
1 a:aa
1 a:aa:aaa
1 a:aa:bbb
@ -30,22 +29,19 @@ hledger -f - balance --flat
1 b:bb:bbb
--------------------
5
>>>= 0
# --flat --depth shows the same accounts, but clipped and aggregated at the depth limit
# 2.
hledger -f - balance --flat --depth 2
<<<
<
1/1
(a:aa) 1
(a:aa:aaa) 1
(a:aa:bbb) 1
(b) 1
(b:bb:bbb) 1
>>>
$ hledger -f - balance --flat --depth 2
3 a:aa
1 b
1 b:bb
--------------------
5
>>>= 0

View File

@ -1,20 +1,17 @@
# multi-column balance reports
# 1. Here are the postings used in most tests below:
hledger -f balance-multicol.journal register
>>>
$ hledger -f balance-multicol.journal register
2012-12-31 (assets:checking) 10 10
2013-01-01 (assets:checking) 1 11
2013-01-15 (assets:checking) -1 10
2013-02-01 (assets:cash) 1 11
2013-02-02 (assets) 1 12
2013-03-01 (assets:checking) 1 13
>>>=0
# 2. A period balance (flow) report. --no-total also works but isn't pretty.
# Includes leading/trailing empty periods.
hledger -f balance-multicol.journal balance -p 'monthly in 2013' --no-total
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly in 2013' --no-total
Balance changes in 2013:
|| Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
@ -22,19 +19,17 @@ Balance changes in 2013:
assets || 0 1 0 0 0 0 0 0 0 0 0 0
assets:cash || 0 1 0 0 0 0 0 0 0 0 0 0
assets:checking || 0 0 1 0 0 0 0 0 0 0 0 0
>>>=0
# 3. With --empty, includes leading/trailing empty periods
#hledger -f balance-multicol.journal balance -p 'quarterly in 2013' --empty
hledger -f - balance -p 'quarterly in 2013' --empty
<<<
<
2012/12/31
(a) 10
2013/1/1
(a) 1
2013/3/1
(a) 1
>>>
$ hledger -f - balance -p 'quarterly in 2013' --empty
Balance changes in 2013:
|| 2013Q1 2013Q2 2013Q3 2013Q4
@ -42,12 +37,10 @@ Balance changes in 2013:
a || 2 0 0 0
---++--------------------------------
|| 2 0 0 0
>>>=0
# 4. A cumulative ending balance report. Column totals are the sum of
# the highest-level displayed accounts (here, assets).
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --cumulative
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --cumulative
Ending balances (cumulative) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -57,13 +50,11 @@ Ending balances (cumulative) in 2013Q1:
assets:checking || 0 0 1
-----------------++------------------------------------
|| 0 2 3
>>>=0
# 5. With the assets:cash account excluded. As with a single-column
# balance --flat report, or ledger's balance --flat, assets' balance
# includes the displayed subaccount and not the excluded one.
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --cumulative not:cash
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --cumulative not:cash
Ending balances (cumulative) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -72,11 +63,9 @@ Ending balances (cumulative) in 2013Q1:
assets:checking || 0 0 1
-----------------++------------------------------------
|| 0 1 2
>>>=0
# 6. A historical ending balance report.
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --historical
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --historical
Ending balances (historical) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -86,12 +75,10 @@ Ending balances (historical) in 2013Q1:
assets:checking || 10 10 11
-----------------++------------------------------------
|| 10 12 13
>>>=0
# 7. With top-level accounts excluded. As always, column totals are the sum of
# the highest-level displayed accounts, now assets:cash and assets:checking.
hledger -f balance-multicol.journal balance -p 'monthly from 2013' not:assets$
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' not:assets$
Balance changes in 2013Q1:
|| Jan Feb Mar
@ -100,11 +87,9 @@ Balance changes in 2013Q1:
assets:checking || 0 0 1
-----------------++---------------
|| 0 1 1
>>>=0
# 8. cumulative:
hledger -f balance-multicol.journal balance -p 'monthly from 2013' not:assets$ --cumulative
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' not:assets$ --cumulative
Ending balances (cumulative) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -113,11 +98,9 @@ Ending balances (cumulative) in 2013Q1:
assets:checking || 0 0 1
-----------------++------------------------------------
|| 0 1 2
>>>=0
# 9. historical
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --historical
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --historical
Ending balances (historical) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -127,13 +110,11 @@ Ending balances (historical) in 2013Q1:
assets:checking || 10 10 11
-----------------++------------------------------------
|| 10 12 13
>>>=0
# --depth
# 10. A flow report with depth limiting. The depth limit aggregates the three accounts as "assets".
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --depth 1
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --depth 1
Balance changes in 2013Q1:
|| Jan Feb Mar
@ -141,11 +122,9 @@ Balance changes in 2013Q1:
assets || 0 2 1
--------++---------------
|| 0 2 1
>>>=0
# 11. As above, but postings in the top-level assets account have been excluded.
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --depth 1 assets:
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --depth 1 assets:
Balance changes in 2013Q1:
|| Jan Feb Mar
@ -153,11 +132,9 @@ Balance changes in 2013Q1:
assets || 0 1 1
--------++---------------
|| 0 1 1
>>>=0
# 12. A cumulative balance report with depth limiting.
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --depth 1 --cumulative
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --depth 1 --cumulative
Ending balances (cumulative) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -165,11 +142,9 @@ Ending balances (cumulative) in 2013Q1:
assets || 0 2 3
--------++------------------------------------
|| 0 2 3
>>>=0
# 13. A historical balance report with depth limiting.
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --depth 1 --historical
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --depth 1 --historical
Ending balances (historical) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -177,11 +152,9 @@ Ending balances (historical) in 2013Q1:
assets || 10 12 13
--------++------------------------------------
|| 10 12 13
>>>=0
# 14. The three multicol balance report types again, this time with --tree
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --tree
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --tree
Balance changes in 2013Q1:
|| Jan Feb Mar
@ -191,11 +164,9 @@ Balance changes in 2013Q1:
checking || 0 0 1
------------++---------------
|| 0 2 1
>>>=0
# 15.
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --cumulative --tree
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --cumulative --tree
Ending balances (cumulative) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -205,11 +176,9 @@ Ending balances (cumulative) in 2013Q1:
checking || 0 0 1
------------++------------------------------------
|| 0 2 3
>>>=0
# 16.
hledger -f balance-multicol.journal balance -p 'monthly from 2013' --historical --tree
>>>
$ hledger -f balance-multicol.journal balance -p 'monthly from 2013' --historical --tree
Ending balances (historical) in 2013Q1:
|| 2013-01-31 2013-02-28 2013-03-31
@ -219,18 +188,16 @@ Ending balances (historical) in 2013Q1:
checking || 10 10 11
------------++------------------------------------
|| 10 12 13
>>>=0
# 17. --date2 should work
hledger -f- balance --monthly --date2
<<<
<
2014/1/1
(a) 1
2014/2/1=2014/1/31
(b) 1
>>>
$ hledger -f- balance --monthly --date2
Balance changes in 2014-01:
|| Jan
@ -239,11 +206,9 @@ Balance changes in 2014-01:
b || 1
---++-----
|| 2
>>>=0
# 18. All matched postings in the displayed intervals should be reported on.
hledger -f- balance -p 'monthly 2014/1/10-2014/2/20'
<<<
<
2014/1/5
(before) 1
@ -253,7 +218,7 @@ hledger -f- balance -p 'monthly 2014/1/10-2014/2/20'
2014/2/25
(after) 1
>>>
$ hledger -f- balance -p 'monthly 2014/1/10-2014/2/20'
Balance changes in 2014-01-01..2014-02-28:
|| Jan Feb
@ -263,4 +228,3 @@ Balance changes in 2014-01-01..2014-02-28:
within || 0 1
--------++----------
|| 1 2
>>>=0

View File

@ -1,17 +1,14 @@
#!/usr/bin/env shelltest
# 1. Single column percent
hledger -f sample.journal balance expenses -% --tree
>>>
$ hledger -f sample.journal balance expenses -% --tree
100.0 % expenses
50.0 % food
50.0 % supplies
--------------------
100.0 %
>>>= 0
# 2. Multi column percent
hledger -f sample.journal balance expenses -% -p quarterly
>>>
$ hledger -f sample.journal balance expenses -% -p quarterly
Balance changes in 2008:
|| 2008Q1 2008Q2 2008Q3 2008Q4
@ -20,11 +17,9 @@ Balance changes in 2008:
expenses:supplies || 0 50.0 % 0 0
-------------------++---------------------------------
|| 0 100.0 % 0 0
>>>= 0
# 3. In a balanced ledger everything should sum up to zero, therefore all percentages should be zero.
hledger -f sample.journal balance -% -p quarterly
>>>
$ hledger -f sample.journal balance -% -p quarterly
Balance changes in 2008:
|| 2008Q1 2008Q2 2008Q3 2008Q4
@ -39,4 +34,3 @@ Balance changes in 2008:
liabilities:debts || 0 0 0 0
----------------------++--------------------------------
|| 0 0 0 0
>>>= 0

View File

@ -1,12 +1,10 @@
#
hledger -f- balance
<<<
<
1/1
a 1.00
b -1
>>>
$ hledger -f- balance
1.00 a
-1.00 b
--------------------
0
>>>=0

View File

@ -1,6 +1,5 @@
# 1. Uses Unicode tables when given --pretty=yes
hledger -f balance-multicol.journal balance --pretty=yes -M
>>>
$ hledger -f balance-multicol.journal balance --pretty=yes -M
Balance changes in 2012-12-01..2013-03-31:
║ 2012-12 2013-01 2013-02 2013-03
@ -10,11 +9,9 @@ Balance changes in 2012-12-01..2013-03-31:
assets:checking ║ 10 0 0 1
─────────────────╫────────────────────────────────────
║ 10 0 2 1
>>>=0
# 2. Uses Unicode tables when given --pretty
hledger -f balance-multicol.journal balance --pretty -M
>>>
$ hledger -f balance-multicol.journal balance --pretty -M
Balance changes in 2012-12-01..2013-03-31:
║ 2012-12 2013-01 2013-02 2013-03
@ -24,11 +21,9 @@ Balance changes in 2012-12-01..2013-03-31:
assets:checking ║ 10 0 0 1
─────────────────╫────────────────────────────────────
║ 10 0 2 1
>>>=0
# 3. Uses ASCII tables when given --pretty=no
hledger -f balance-multicol.journal balance --pretty=no -M
>>>
$ hledger -f balance-multicol.journal balance --pretty=no -M
Balance changes in 2012-12-01..2013-03-31:
|| 2012-12 2013-01 2013-02 2013-03
@ -38,11 +33,9 @@ Balance changes in 2012-12-01..2013-03-31:
assets:checking || 10 0 0 1
-----------------++------------------------------------
|| 10 0 2 1
>>>=0
# 4. Still accepts the legacy --pretty-tables for now
hledger -f balance-multicol.journal balance --pretty-tables -M
>>>
$ hledger -f balance-multicol.journal balance --pretty-tables -M
Balance changes in 2012-12-01..2013-03-31:
║ 2012-12 2013-01 2013-02 2013-03
@ -52,4 +45,3 @@ Balance changes in 2012-12-01..2013-03-31:
assets:checking ║ 10 0 0 1
─────────────────╫────────────────────────────────────
║ 10 0 2 1
>>>=0

View File

@ -1,5 +1,4 @@
hledger -f balance-multicol.journal balance -M -A --transpose
>>>
$ hledger -f balance-multicol.journal balance -M -A --transpose
Balance changes in 2012-12-01..2013-03-31:
|| assets assets:cash assets:checking |
@ -9,21 +8,17 @@ Balance changes in 2012-12-01..2013-03-31:
2013-02 || 1 1 0 | 2
2013-03 || 0 0 1 | 1
Average || 0 0 3 | 3
>>>=0
hledger -f balance-multicol.journal balance -M -A -O csv --transpose
>>>
$ hledger -f balance-multicol.journal balance -M -A -O csv --transpose
"account","assets","assets:cash","assets:checking","total"
"2012-12","0","0","10","10"
"2013-01","0","0","0","0"
"2013-02","1","1","0","2"
"2013-03","0","0","1","1"
"average","0","0","3","3"
>>>=0
hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget
<<<
<
2016/12/01
expenses:food $10
assets:cash
@ -52,7 +47,7 @@ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget
expenses:food $10
expenses:leisure $15
assets:cash
>>>
$ hledger bal -D -b 2016-12-01 -e 2016-12-04 -f - --budget
Budget performance in 2016-12-01..2016-12-03:
|| 2016-12-01 2016-12-02 2016-12-03
@ -63,4 +58,3 @@ Budget performance in 2016-12-01..2016-12-03:
expenses:leisure || 0 [ 0% of $15] $5 [33% of $15] 0 [ 0% of $15]
------------------++--------------------------------------------------------------
|| 0 [ 0] 0 [ 0] 0 [ 0]
>>>=0

View File

@ -1,12 +1,8 @@
# commands should generally autocreate an empty journal when missing, see also add*.test
# $$ used for safe concurrent test running, may be a bash-ism
hledger register -f no-such-file-$$; rm -f no-such-file-$$
>>>
>>>2 /journal file.*not found/
>>>=0
$ hledger register -f no-such-file-$$; rm -f no-such-file-$$
>2 /journal file.*not found/
hledger balance --no-total -f no-such-file-$$; rm -f no-such-file-$$
>>>
>>>2 /journal file.*not found/
>>>=0
$ hledger balance --no-total -f no-such-file-$$; rm -f no-such-file-$$
>2 /journal file.*not found/

View File

@ -1,5 +1,5 @@
$$$ hledger check accounts -f accounts.j
>>>2 /hledger: Error: .*accounts.j:4:
$ hledger check accounts -f accounts.j
>2 /hledger: Error: .*accounts.j:4:
\| 2022-01-01
4 \| \(a\) 1
\| \^
@ -12,4 +12,4 @@ account a
account a ; type:A ; \(L,E,R,X,C,V\)
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f assertions.j
>>>2 /hledger: Error: .*assertions.j:4:8:
$ hledger check -f assertions.j
>2 /hledger: Error: .*assertions.j:4:8:
\| 2022-01-01
4 \| a 0 = 1
\| \^\^\^
@ -12,4 +12,4 @@ but the calculated balance is: 0
a difference of: 1
Consider viewing t/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f balanced.j
>>>2 /hledger: Error: .*balanced.j:3-4:
$ hledger check -f balanced.j
>2 /hledger: Error: .*balanced.j:3-4:
3 \| 2022-01-01
\| a 1
@ -7,4 +7,4 @@ This transaction is unbalanced.
The real postings' sum should be 0 but is: 1
Consider adjusting this entry's amounts, or adding missing postings.
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check balancednoautoconversion -f balancednoautoconversion.j
>>>2 /hledger: Error: .*balancednoautoconversion.j:6-8:
$ hledger check balancednoautoconversion -f balancednoautoconversion.j
>2 /hledger: Error: .*balancednoautoconversion.j:6-8:
6 \| 2022-01-01
\| a 1 A
\| b -1 B
@ -8,4 +8,4 @@ This multi-commodity transaction is unbalanced.
Automatic commodity conversion is not enabled.
The real postings' sum should be 0 but is: 1 A, -1 B
Consider adjusting this entry's/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check commodities -f commodities.j
>>>2 /hledger: Error: .*commodities.j:6:
$ hledger check commodities -f commodities.j
>2 /hledger: Error: .*commodities.j:6:
\| 2022-01-01
6 \| \(a\) A 1
\| \^\^\^
@ -12,4 +12,4 @@ commodity A1000.00
commodity 1.000,00 A
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f csvamountonenonzero.csv
>>>2 /hledger: Error: in CSV rules:
$ hledger check -f csvamountonenonzero.csv
>2 /hledger: Error: in CSV rules:
While processing CSV record: "2022-01-03","1","2"
while calculating amount for posting 1
rule "amount-in %2" assigned value "1"
@ -7,4 +7,4 @@ rule "amount-out %3" assigned value "2"
Multiple non-zero amounts were assigned for an amount field.
Please ensure just one non-zero amount i/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f csvamountparse.csv
>>>2 /hledger: Error: error: could not parse "badamount" as an amount
$ hledger check -f csvamountparse.csv
>2 /hledger: Error: error: could not parse "badamount" as an amount
CSV record: "2022-01-03","badamount"
the amount rule is: %2
the date rule is: %1
@ -12,4 +12,4 @@ unexpected end of input
expecting '\+', '-', or number
you may need to change your am/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f csvbalanceparse.csv
>>>2 /hledger: Error: error: could not parse "badbalance" as balance1 amount
$ hledger check -f csvbalanceparse.csv
>2 /hledger: Error: error: could not parse "badbalance" as balance1 amount
CSV record: "2022-01-03","badbalance"
the balance rule is: %2
the date rule is: %1
@ -13,4 +13,4 @@ expecting '\+', '-', or number
/
>>>= 1
>= 1

View File

@ -1,9 +1,9 @@
$$$ hledger check -f csvbalancetypeparse.csv
>>>2 /hledger: Error: balance-type "badtype" is invalid. Use =, ==, =\* or ==\*.
$ hledger check -f csvbalancetypeparse.csv
>2 /hledger: Error: balance-type "badtype" is invalid. Use =, ==, =\* or ==\*.
CSV record: "2022-01-01","1"
the balance rule is: %2
the date rule is: %1
/
>>>= 1
>= 1

View File

@ -1,8 +1,8 @@
$$$ hledger check -f csvdateparse.csv
>>>2 /hledger: Error: error: could not parse "baddate" as a date using date format "%Y-%m-%d"
$ hledger check -f csvdateparse.csv
>2 /hledger: Error: error: could not parse "baddate" as a date using date format "%Y-%m-%d"
CSV record: "baddate","b"
the date rule is: %1
the date-format is: %Y-%m-%d
you may need to change your date rule, change your date-format rule, or change your skip rule
for m\/d\/y or d\/m\/y dates, use date-f/
>>>= 1
>= 1

View File

@ -1,6 +1,6 @@
$$$ hledger check -f csvdaterule.csv
>>>2 /hledger: Error: offset=0:
$ hledger check -f csvdaterule.csv
>2 /hledger: Error: offset=0:
Please specify \(at top level\) the date field. Eg: date %1
/
>>>= 1
>= 1

View File

@ -1,4 +1,4 @@
$$$ hledger check -f csvdecimalmarkparse.csv
>>>2 /hledger: Error: decimal-mark's argument should be "." or "," \(not "badmark"\)
$ hledger check -f csvdecimalmarkparse.csv
>2 /hledger: Error: decimal-mark's argument should be "." or "," \(not "badmark"\)
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f csvifblocknonempty.csv
>>>2 /hledger: Error: .*csvifblocknonempty.csv.rules:2:1:
$ hledger check -f csvifblocknonempty.csv
>2 /hledger: Error: .*csvifblocknonempty.csv.rules:2:1:
\|
2 \| if foo
\| \^
@ -7,4 +7,4 @@ start of conditional block found, but no assignment rules afterward
\(assignment rules in a conditional block should be indented\)
/
>>>= 1
>= 1

View File

@ -1,8 +1,8 @@
$$$ hledger check -f csviftablefieldnames.csv
>>>2 /hledger: Error: .*csviftablefieldnames.csv.rules:2:9:
$ hledger check -f csviftablefieldnames.csv
>2 /hledger: Error: .*csviftablefieldnames.csv.rules:2:9:
\|
2 \| if,date,nosuchfield,description
\| \^\^\^\^\^\^\^\^\^\^\^\^
unexpected "nosuchfield,"
expecting "account1", "account10", "account11", "account12", "account13", "account14", "account15", "account16", "account17", "account18", "/
>>>= 1
>= 1

View File

@ -1,9 +1,9 @@
$$$ hledger check -f csviftablenonempty.csv
>>>2 /hledger: Error: .*csviftablenonempty.csv.rules:2:1:
$ hledger check -f csviftablenonempty.csv
>2 /hledger: Error: .*csviftablenonempty.csv.rules:2:1:
\|
2 \| if,date,description,comment
\| \^
start of conditional table found, but no assignment rules afterward
/
>>>= 1
>= 1

View File

@ -1,9 +1,9 @@
$$$ hledger check -f csviftablevaluecount.csv
>>>2 /hledger: Error: .*csviftablevaluecount.csv.rules:4:1:
$ hledger check -f csviftablevaluecount.csv
>2 /hledger: Error: .*csviftablevaluecount.csv.rules:4:1:
\|
4 \| one,val1
\| \^
line of conditional table should have 2 values, but this one has only 1
/
>>>= 1
>= 1

View File

@ -1,4 +1,4 @@
$$$ hledger check -f csvnoinclude.j
>>>2 /hledger: Error: sorry, CSV files can't be included yet
$ hledger check -f csvnoinclude.j
>2 /hledger: Error: sorry, CSV files can't be included yet
/
>>>= 1
>= 1

View File

@ -1,4 +1,4 @@
$$$ hledger check -f csvskipvalue.csv
>>>2 /hledger: Error: could not parse skip value: "badval"
$ hledger check -f csvskipvalue.csv
>2 /hledger: Error: could not parse skip value: "badval"
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger print -f csvstatusparse.csv
>>>2 /hledger: Error: error: could not parse "badstatus" as a cleared status \(should be \*, ! or empty\)
$ hledger print -f csvstatusparse.csv
>2 /hledger: Error: error: could not parse "badstatus" as a cleared status \(should be \*, ! or empty\)
the parse error is: 1:1:
\|
1 \| badstatus
@ -9,4 +9,4 @@ expecting '!', '\*', or end of input
/
>>>= 1
>= 1

View File

@ -1,4 +1,4 @@
$$$ sh csvstdinrules.sh
>>>2 /hledger: Error: please use --rules-file when reading CSV from stdin
$ sh csvstdinrules.sh
>2 /hledger: Error: please use --rules-file when reading CSV from stdin
/
>>>= 1
>= 1

View File

@ -1,4 +1,4 @@
$$$ hledger check -f csvtwofields.csv
>>>2 /hledger: Error: CSV record \["b"\] has less than two fields
$ hledger check -f csvtwofields.csv
>2 /hledger: Error: CSV record \["b"\] has less than two fields
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check ordereddates -f ordereddates.j
>>>2 /hledger: Error: .*ordereddates.j:10:
$ hledger check ordereddates -f ordereddates.j
>2 /hledger: Error: .*ordereddates.j:10:
7 \| 2022-01-02 p
\| \(a\) 1
@ -10,4 +10,4 @@ $$$ hledger check ordereddates -f ordereddates.j
Ordered dates checking is enabled, and this transaction's
date \(2022-01-01\) is out of order with the previous transaction.
Consider/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f parseable-dates.j
>>>2 /hledger: Error: .*parseable-dates.j:3:1:
$ hledger check -f parseable-dates.j
>2 /hledger: Error: .*parseable-dates.j:3:1:
\|
3 \| 2022\/1\/32
\| \^\^\^\^\^\^\^\^\^
@ -7,4 +7,4 @@ $$$ hledger check -f parseable-dates.j
This date is invalid, please correct it: 2022\/1\/32
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f parseable-regexps.j
>>>2 /hledger: Error: .*parseable-regexps.j:3:8:
$ hledger check -f parseable-regexps.j
>2 /hledger: Error: .*parseable-regexps.j:3:8:
\|
3 \| alias \/\(\/ = a
\| \^
@ -8,4 +8,4 @@ This regular expression is malformed, please correct it:
\(
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f parseable.j
>>>2 /hledger: Error: .*parseable.j:3:2:
$ hledger check -f parseable.j
>2 /hledger: Error: .*parseable.j:3:2:
\|
3 \| 1
\| \^
@ -7,4 +7,4 @@ unexpected newline
expecting date separator or digit
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check payees -f payees.j
>>>2 /hledger: Error: .*payees.j:6:
$ hledger check payees -f payees.j
>2 /hledger: Error: .*payees.j:6:
6 \| 2022-01-01 p
\| \^
\| \(a\) A 1
@ -11,4 +11,4 @@ Consider adding a payee directive. Examples:
payee p
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check recentassertions -f recentassertions.j
>>>2 /hledger: Error: .*recentassertions.j:5:8:
$ hledger check recentassertions -f recentassertions.j
>2 /hledger: Error: .*recentassertions.j:5:8:
\| 2022-01-01 \*
5 \| a 0 = 0
\| \^\^\^
@ -8,4 +8,4 @@ The recentassertions check is enabled, so accounts with balance assertions must
have a balance assertion no more than 7 days before their latest posting date.
In account a,
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f tcclockouttime.timeclock
>>>2 /hledger: Error: .*tcclockouttime.timeclock:5:1:
$ hledger check -f tcclockouttime.timeclock
>2 /hledger: Error: .*tcclockouttime.timeclock:5:1:
\| i 2022-01-01 00:01:00
5 \| o 2022-01-01 00:00:00
\| \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^
@ -7,4 +7,4 @@ $$$ hledger check -f tcclockouttime.timeclock
This clockout time \(2022-01-01 00:00:00\) is earlier than the previous clockin.
Please adjust it to be later than 2022-01-01 00:01:00.
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check -f tcorderedactions.timeclock
>>>2 /hledger: Error: .*tcorderedactions.timeclock:8:1:
$ hledger check -f tcorderedactions.timeclock
>2 /hledger: Error: .*tcorderedactions.timeclock:8:1:
8 \| i 2022-01-01 00:01:00
\| \^
@ -7,4 +7,4 @@ Expected a timeclock o entry but got i.
Only one session may be clocked in at a time.
Please alternate i and o, beginning with i.
/
>>>= 1
>= 1

View File

@ -1,5 +1,5 @@
$$$ hledger check uniqueleafnames -f uniqueleafnames.j
>>>2 /hledger: Error: .*uniqueleafnames.j:12:
$ hledger check uniqueleafnames -f uniqueleafnames.j
>2 /hledger: Error: .*uniqueleafnames.j:12:
\| 2022-01-01 p
9 \| \(a:c\) 1
...
@ -10,4 +10,4 @@ $$$ hledger check uniqueleafnames -f uniqueleafnames.j
Checking for unique account leaf names is enabled, and
account leaf name "c" is not unique.
It appears in these account names, which a/
>>>= 1
>= 1

View File

@ -1,17 +1,13 @@
hledger -f - register τράπ
<<<
<
2009-01-01 проверка
τράπεζα 10 руб
नकद
>>>
$ hledger -f - register τράπ
2009-01-01 проверка τράπεζα 10 руб 10 руб
>>>=0
hledger -f - balance -N " ét"
<<<
<
2020-09-19 Test
assets:a ét 5
assets:b
>>>
$ hledger -f - balance -N " ét"
5 assets:a ét
>>>=0

View File

@ -1,11 +1,9 @@
hledger -f - balance
<<<
<
2009-01-01 проверка
τράπεζα 10 руб
नकद
>>>
$ hledger -f - balance
10 руб τράπεζα
-10 руб नकद
--------------------
0
>>>=0

View File

@ -1,12 +1,10 @@
hledger -f - register desc:аура
<<<
<
2009-01-01 аура (cyrillic letters)
bank 10
cash
2010-01-01 aypa (roman letters)
bank 20
cash
>>>
$ hledger -f - register desc:аура
2009-01-01 аура (cyrillic le.. bank 10 10
cash -10 0
>>>=0

View File

@ -1,7 +1,7 @@
hledger -f - balance
<<<
<
2009-01-01 broken entry
дебит 1
кредит -2
>>>2 /дебит/
>>>= 1
$ hledger -f - balance
>2 /дебит/
>= 1

View File

@ -1,11 +1,10 @@
hledger -f - print
<<<
<
2009-01-01 проверка
счёт:первый 1
счёт:второй
>>>
$ hledger -f - print
2009-01-01 проверка
счёт:первый 1
счёт:второй
>>>=0
>= 0

View File

@ -1,9 +1,7 @@
hledger -f - register
<<<
<
2009-01-01 проверка
τράπεζα 10 руб
नकद
>>>
$ hledger -f - register
2009-01-01 проверка τράπεζα 10 руб 10 руб
नकद -10 руб 0
>>>=0

View File

@ -5,8 +5,7 @@
# XXX how to test hledger-ui ?
# 1.
hledger -f - print
<<<
<
2000-01-01 transaction 1
㐀 㐃㐃1 @ 2 㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂
㐀:㐁 ;㐃㐃-1
@ -18,7 +17,7 @@ hledger -f - print
2000-01-03 transaction 3
㐀:㐁:㐂:㐃:㐄 1
㐀 -1
>>>
$ hledger -f - print
2000-01-01 transaction 1
㐀 㐃㐃1 @ 2 㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂
㐀:㐁 ; 㐃㐃-1
@ -31,36 +30,28 @@ hledger -f - print
㐀:㐁:㐂:㐃:㐄 1
㐀 -1
>>>2
>>>=0
>= 0
# 2.
hledger -f chinese.journal register --width 80
>>>
$ hledger -f chinese.journal register --width 80
2000-01-01 transaction 1 㐀 1 A 1 A
㐀:㐁 -1 A 0
2000-01-02 transaction 2 㐀:㐁:㐂 1 A 1 A
㐀:㐁:㐂:㐃 -1 A 0
2000-01-03 transaction 3 㐀:㐁:㐂:㐃:㐄 1 A 1 A
㐀 -1 A 0
>>>2
>>>=0
# 3.
hledger -f chinese.journal balance --tree
>>>
$ hledger -f chinese.journal balance --tree
0 㐀:㐁
1 A 㐂
0 㐃
1 A 㐄
--------------------
0
>>>2
>>>=0
# 4.
hledger -f chinese.journal balance -Y
>>>
$ hledger -f chinese.journal balance -Y
Balance changes in 2000:
|| 2000
@ -71,8 +62,6 @@ Balance changes in 2000:
㐀:㐁:㐂:㐃:㐄 || 1 A
----------------++------
|| 0
>>>2
>>>=0
# 5.

View File

@ -1,10 +1,9 @@
# 1. Simple statement works
hledger -f - incomestatement
<<<
<
2016/1/1
income 1
b
>>>
$ hledger -f - incomestatement
Income Statement 2016-01-01
|| 2016-01-01
@ -21,12 +20,9 @@ Income Statement 2016-01-01
||
==========++============
Net: || -1
>>>2
>>>= 0
# 2. Period reporting works for a specific year
hledger -f - incomestatement -b 2016 -e 2017
<<<
<
2015/10/10 Client A | Invoice #1
assets:receivables $10,000.00
revenue:clients:A -$10,000.00
@ -46,7 +42,7 @@ hledger -f - incomestatement -b 2016 -e 2017
2016/03/01 Deposit | Invoice #2
assets:checking $10.00
assets:receivables -$10.00
>>>
$ hledger -f - incomestatement -b 2016 -e 2017
Income Statement 2016
|| 2016
@ -64,12 +60,9 @@ Income Statement 2016
|| $50.00
===================++=========
Net: || $-40.00
>>>2
>>>= 0
# 3. Period reporting works for two years
hledger -f - incomestatement -b 2015 -e 2017
<<<
<
2015/10/10 Client A | Invoice #1
assets:receivables $10,000.00
revenue:clients:A -$10,000.00
@ -89,7 +82,7 @@ hledger -f - incomestatement -b 2015 -e 2017
2016/03/01 Deposit | Invoice #2
assets:checking $10.00
assets:receivables -$10.00
>>>
$ hledger -f - incomestatement -b 2015 -e 2017
Income Statement 2015-01-01..2016-12-31
|| 2015-01-01..2016-12-31
@ -108,12 +101,9 @@ Income Statement 2015-01-01..2016-12-31
|| $50.00
===================++========================
Net: || $9,960.00
>>>2
>>>= 0
# 4. Period reporting works for one month
hledger -f - incomestatement -b 2015/10 -e 2015/11
<<<
<
2015/10/10 Client A | Invoice #1
assets:receivables $10,000.00
revenue:clients:A -$10,000.00
@ -133,7 +123,7 @@ hledger -f - incomestatement -b 2015/10 -e 2015/11
2016/03/01 Deposit | Invoice #2
assets:checking $10.00
assets:receivables -$10.00
>>>
$ hledger -f - incomestatement -b 2015/10 -e 2015/11
Income Statement 2015-10
|| Oct
@ -150,12 +140,9 @@ Income Statement 2015-10
||
===================++============
Net: || $10,000.00
>>>2
>>>= 0
# 5. Period reporting works for one month in another year
hledger -f - incomestatement -b 2016/10 -e 2016/11
<<<
<
2015/10/10 Client A | Invoice #1
assets:receivables $10,000.00
revenue:clients:A -$10,000.00
@ -175,7 +162,7 @@ hledger -f - incomestatement -b 2016/10 -e 2016/11
2016/03/01 Deposit | Invoice #2
assets:checking $10.00
assets:receivables -$10.00
>>>
$ hledger -f - incomestatement -b 2016/10 -e 2016/11
Income Statement 2016-10
|| Oct
@ -191,8 +178,6 @@ Income Statement 2016-10
||
==========++=====
Net: ||
>>>2
>>>= 0
# 6. Multicolumn test
# old (arithmetic sign):
@ -216,8 +201,7 @@ Income Statement 2016-10
# ===================++==============================================================================================================================
# Total || $-1 0 0 0 0 $1 0 0 0 0 0 0 0 0
#
hledger -f sample.journal incomestatement -p 'monthly in 2008' -AT
>>>
$ hledger -f sample.journal incomestatement -p 'monthly in 2008' -AT
Income Statement 2008
|| Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Total Average
@ -237,7 +221,6 @@ Income Statement 2008
|| 0 0 0 0 0 $2 0 0 0 0 0 0 $2 0
===================++==============================================================================
Net: || $1 0 0 0 0 $-1 0 0 0 0 0 0 0 0
>>>= 0
# 7. Multicolumn test (historical)
# old (arithmetic sign):
@ -261,8 +244,7 @@ Income Statement 2008
# ===================++================================================================================================================================================
# Total || $-1 $-1 $-1 $-1 $-1 0 0 0 0 0 0 0
#
hledger -f sample.journal incomestatement -p 'monthly in 2008' --historical
>>>
$ hledger -f sample.journal incomestatement -p 'monthly in 2008' --historical
Income Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
|| 2008-01-31 2008-02-29 2008-03-31 2008-04-30 2008-05-31 2008-06-30 2008-07-31 2008-08-31 2008-09-30 2008-10-31 2008-11-30 2008-12-31
@ -282,11 +264,9 @@ Income Statement 2008-01-31..2008-12-31 (Historical Ending Balances)
|| 0 0 0 0 0 $2 $2 $2 $2 $2 $2 $2
===================++================================================================================================================================================
Net: || $1 $1 $1 $1 $1 0 0 0 0 0 0 0
>>>= 0
# 8. Percentage test
hledger -f sample.journal incomestatement -p 'quarterly 2008' -T --average -% --no-total
>>>
$ hledger -f sample.journal incomestatement -p 'quarterly 2008' -T --average -% --no-total
Income Statement 2008
|| 2008Q1 2008Q2 2008Q3 2008Q4 Total Average
@ -300,17 +280,15 @@ Income Statement 2008
-------------------++----------------------------------------------------
expenses:food || 0 50.0 % 0 0 50.0 % 50.0 %
expenses:supplies || 0 50.0 % 0 0 50.0 % 50.0 %
>>>= 0
# 9. With --declared, declared leaf accounts are included, and in the right place.
hledger -f - incomestatement -N -E --declared
<<<
<
account revenues
account revenues:aa
account revenues:ab
account revenues:ac:aca
account expenses
>>>
$ hledger -f - incomestatement -N -E --declared
Income Statement ..
|| ..
@ -324,4 +302,3 @@ Income Statement ..
Expenses ||
-----------------++----
expenses || 0
>>>= 0

View File

@ -1,17 +1,17 @@
# 1. accept a blank description
hledger -f- print
<<<
<
2010/1/1
a 1
b
>>>=0
$ hledger -f- print
> //
# 2. same, but no separator space after the date
hledger -f- print
<<<
<
2010/1/1
a 1
b
>>>=0
$ hledger -f- print
> //

View File

@ -3,8 +3,7 @@
# 1. several comment characters allowed for file characters;
# print shows in-transaction & posting comments;
# comment line is preserved, starting column is not.
hledger -f - print
<<<
<
; file comments, ignored
# file comment using a hash
* file comment using a star (org node)
@ -22,7 +21,7 @@ hledger -f - print
; file comment right after the transaction, ignored
; trailing file comment, ignored
>>>
$ hledger -f - print
2009-01-01 x ; transaction same line comment
; transaction new line comment
a 1 ; posting 1 same line comment
@ -30,36 +29,32 @@ hledger -f - print
a
; posting 2 new line comment
>>>2
>>>=0
>= 0
# 2. transaction comments must use ;
hledger -f - print
<<<
<
2017/1/1 this # and * are not ; the comment
>>>
$ hledger -f - print
2017-01-01 this # and * are not ; the comment
>>>2
>>>=0
>= 0
# 3. posting comments must use ;
hledger -f - print
<<<
<
2017/1/1
a 0 # hash & star not allowed for posting comments
>>>=1
$ hledger -f - print
> //
>2 //
>= 1
# 4. register does not show comments
hledger -f - register
<<<
<
2010/1/1 x
a 1 ; comment
b
>>>
$ hledger -f - register
2010-01-01 x a 1 1
b -1 0
>>>2
>>>=0

View File

@ -1,44 +1,43 @@
# invalid dates should be rejected
# 1. valid month and day, but flipped
hledger -f- print
<<<
<
2010/31/12 x
a 1
b
>>>2 /date is invalid/
>>>= 1
$ hledger -f- print
>2 /date is invalid/
>= 1
# 2. too-large day
hledger -f- print
<<<
<
2010/12/32 x
a 1
b
>>>2 /date is invalid/
>>>= 1
$ hledger -f- print
>2 /date is invalid/
>= 1
# 3. 29th feb on leap year should be ok
hledger -f- print
<<<
<
2000/2/29 x
a 1
b
>>>
$ hledger -f- print
2000-02-29 x
a 1
b
>>>= 0
>= 0
# 4. 29th feb on non-leap year should fail
hledger -f- print
<<<
<
2001/2/29 x
a 1
b
>>>2 /date is invalid/
>>>= 1
$ hledger -f- print
>2 /date is invalid/
>= 1
# 5. dates must be followed by whitespace or newline
hledger -f- print
<<<
<
2015/9/6*
a 0
>>>2 /unexpected '*'/
>>>= 1
$ hledger -f- print
>2 /unexpected '*'/
>= 1

View File

@ -1,6 +1,5 @@
# 1. nested includes in subdirectories
mkdir -p b/c/d ; printf '2010/1/1\n (D) 1\n' >b/c/d/d.journal ; printf '2010/1/1\n (C) 1\ninclude d/d.journal\n' >b/c/c.journal ; printf '2010/1/1\n (B) 1\ninclude c/c.journal\n' >b/b.journal ; printf '2010/1/1\n (A) 1\ninclude b/b.journal\n' >a.journal ; hledger -f a.journal print; rm -rf a.journal bG
>>>
$ mkdir -p b/c/d ; printf '2010/1/1\n (D) 1\n' >b/c/d/d.journal ; printf '2010/1/1\n (C) 1\ninclude d/d.journal\n' >b/c/c.journal ; printf '2010/1/1\n (B) 1\ninclude c/c.journal\n' >b/b.journal ; printf '2010/1/1\n (A) 1\ninclude b/b.journal\n' >a.journal ; hledger -f a.journal print; rm -rf a.journal bG
2010-01-01
(A) 1
@ -13,18 +12,16 @@
2010-01-01
(D) 1
>>>2
>>>=0
>= 0
# 2. including other formats
hledger -f - print
<<<
<
2016/1/1
(x) 1
include a.timeclock
include b.timedot
>>>
$ hledger -f - print
2016-01-01
(x) 1.00
@ -34,69 +31,61 @@ include b.timedot
2016-01-01 *
(b.bb) 1.00
>>>=0
>=
# 3. include glob patterns
printf '2018/01/01\n (A) 1\n' >ab.journal; printf '2018/01/01\n (B) 1' >bb.journal; hledger -f - print; rm -f ab.journal bb.journal
<<<
<
include *b.journal
>>>
$ printf '2018/01/01\n (A) 1\n' >ab.journal; printf '2018/01/01\n (B) 1' >bb.journal; hledger -f - print; rm -f ab.journal bb.journal
2018-01-01
(A) 1
2018-01-01
(B) 1
>>>=0
>=
# 4. include invalid glob patterns
hledger -f - print
<<<
<
include [.journal
>>>=1
$ hledger -f - print
>2 //
>= 1
# 5. include nonexsitant file
hledger -f - print
<<<
<
include doesnotexist.journal
>>>=1
$ hledger -f - print
>2 //
>= 1
# 6. include relative to home
printf '2018/01/01\n (A) 1\n' >included.journal; HOME="$PWD" hledger -f - print; rm -rf included.journal
<<<
<
include ~/included.journal
>>>
$ printf '2018/01/01\n (A) 1\n' >included.journal; HOME="$PWD" hledger -f - print; rm -rf included.journal
2018-01-01
(A) 1
>>>2
>>>=0
>= 0
# The next tests require hard coded file names, so are not concurrent-safe.
# They use different file names so a single concurrent shelltest invocation will be fine.
# 7. test that order of include files is maintained
printf 'include _b\n' >_a; touch _b; hledger -f _a stats | grep _ | sed -e 's%.*/%%'; rm -rf _a _b
>>>
$ printf 'include _b\n' >_a; touch _b; hledger -f _a stats | grep _ | sed -e 's%.*/%%'; rm -rf _a _b
_a
_b
>>>2
>>>=0
# 8. and with --auto code path
printf 'include _d\n=\n' >_c; touch _d; hledger -f _c stats --auto | grep _ | sed -e 's%.*/%%'; rm -rf _c _d
>>>
$ printf 'include _d\n=\n' >_c; touch _d; hledger -f _c stats --auto | grep _ | sed -e 's%.*/%%'; rm -rf _c _d
_c
_d
>>>2
>>>=0
# 9. include using old !include directive
printf '2018/01/01\n (A) 1\n' >f.journal; hledger -f - print; rm -f f.journal
<<<
<
!include f.journal
>>>
$ printf '2018/01/01\n (A) 1\n' >f.journal; hledger -f - print; rm -f f.journal
2018-01-01
(A) 1
>>>=0
>=

View File

@ -1,236 +1,203 @@
# 1. Simple case
hledger bal -f - --no-total
<<<
<
2017/1/1
a 1,000.00 EUR
b -1,000.00 EUR
>>>
$ hledger bal -f - --no-total
1,000.00 EUR a
-1,000.00 EUR b
>>>2
>>>=0
# 2. No digits before decimal sep
hledger bal -f - --no-total
<<<
<
2017/1/1
a .01 EUR
b
>>>
$ hledger bal -f - --no-total
0.01 EUR a
-0.01 EUR b
>>>2
>>>=0
# 3. No digits after decimal sep
hledger bal -f - --no-total
<<<
<
2017/1/1
a 1. EUR
b
>>>
$ hledger bal -f - --no-total
1 EUR a
-1 EUR b
>>>2
>>>=0
# 4. No digits at all
hledger bal -f -
<<<
<
2017/1/1
a . EUR
b
>>>
>>>=1
$ hledger bal -f -
>2 //
>= 1
# 5. Space between digits groups
hledger bal -f - --no-total
<<<
<
2017/1/1
a 1 000.00 EUR
b -1 000.00 EUR
>>>
$ hledger bal -f - --no-total
1 000.00 EUR a
-1 000.00 EUR b
>>>2
>>>=0
# 6. Space between digits groups in commodity directive
hledger bal -f - --no-total
<<<
<
commodity 1 000.00 EUR
2017/1/1
a 1,000.00 EUR
b -1,000.00 EUR
>>>
$ hledger bal -f - --no-total
1 000.00 EUR a
-1 000.00 EUR b
>>>2
>>>=0
# 7. Default commodity
hledger bal -f -
<<<
<
D 1,000.00 EUR
2017/1/1
a 1,000
b -1,000 EUR
>>>
$ hledger bal -f -
1,000.00 EUR a
-1,000.00 EUR b
--------------------
0
>>>2
>>>=0
# 8. Omitted decimals
hledger bal -f -
<<<
<
2017/1/1
a 1,000 EUR
b -1,000.00 EUR
>>>
>>>=1
$ hledger bal -f -
>2 //
>= 1
# 9. Omitted decimals with commodity hint
hledger bal -f -
<<<
<
commodity 1,000.00 EUR
2017/1/1
a 1,000 EUR
b -1,000.00 EUR
>>>
$ hledger bal -f -
1,000.00 EUR a
-1,000.00 EUR b
--------------------
0
>>>2
>>>=0
# 10. Omitted decimals with commodity hint and symbol on left
hledger bal -f -
<<<
<
commodity €1,000.00
2017/1/1
a €1,000
b €-1,000.00
>>>
$ hledger bal -f -
€1,000.00 a
€-1,000.00 b
--------------------
0
>>>2
>>>=0
# 11. Commodity directive requires a decimal separator
hledger bal -f -
<<<
<
commodity 1000 EUR
>>>2 /Please include a decimal point or decimal comma/
>>>=1
$ hledger bal -f -
> //
>2 /Please include a decimal point or decimal comma/
>= 1
# 12. Commodity directive with zero precision
hledger bal -f -
<<<
<
commodity 100. EUR
2017/1/1
a 1,000 EUR
b -1,000.00 EUR
>>>
$ hledger bal -f -
1000 EUR a
-1000 EUR b
--------------------
0
>>>2
>>>=0
# 13. Big prices
hledger bal -f - --no-total
<<<
<
2017/1/1
a -1 BTC @ 24,840 UAH
b 24,840.00 UAH
>>>
>>>=1
$ hledger bal -f - --no-total
>2 //
>= 1
# 14. Big prices with commodity hint
hledger bal -f - --no-total
<<<
<
commodity ₴1,000.00
2017/1/1
a -1 BTC @ ₴24,840
b ₴24,840.00
>>>
$ hledger bal -f - --no-total
-1 BTC a
₴24,840.00 b
>>>2
>>>=0
# 15. adjacent punctuation chars
hledger bal -f -
<<<
<
2017/1/1
a 1,,0,,0.0 EUR
b -1..0..0,0 EUR
>>>
>>>=1
$ hledger bal -f -
>2 //
>= 1
# 16. adjacent punctuation chars of different types
hledger bal -f -
<<<
<
2017/1/1
a 1,0,.0 EUR
b -1.0.,0 EUR
>>>
>>>=1
$ hledger bal -f -
>2 //
>= 1
# 17. separator chars vary
hledger bal -f -
<<<
<
2017/1/1
a 1.0,0.0,0 EUR
b -1,0.0,0.0 EUR
>>>
>>>=1
$ hledger bal -f -
>2 //
>= 1
# 18. number begins with a decimal char
hledger bal -f -
<<<
<
2017/1/1
a .1 EUR
b -.1 EUR
>>>
$ hledger bal -f -
0.1 EUR a
-0.1 EUR b
--------------------
0
>>>2
>>>=0
# 19. number begins with a separator char
hledger bal -f -
<<<
<
2017/1/1
a ,100.0 EUR
b -,100.0 EUR
>>>
>>>=1
$ hledger bal -f -
>2 //
>= 1
# 20. long numbers in multi balance reports
hledger bal -YN -f -
<<<
<
2021-01-01
(a) -0.12345678901234567890123456 EUR
>>>
$ hledger bal -YN -f -
Balance changes in 2021:
|| 2021
===++===================================
a || -0.12345678901234567890123456 EUR
>>>=0

View File

@ -1,33 +1,31 @@
# Tests for parentheses and brackets in account names
# 1. Parentheses in the middle of an account name are ignored.
hledger -f - print
<<<
<
2009-01-01 x
a 2
b (b) b -1
c
>>>
$ hledger -f - print
2009-01-01 x
a 2
b (b) b -1
c
>>>=0
>= 0
# 2. Nested parentheses are removed and the outer brackets are used as the type.
hledger -f- print
<<<
<
2023-01-01
[([(a)])] 1
[(b:bb)] 1
[b:[bbb]]
>>>
$ hledger -f- print
2023-01-01
[a] 1
[b:bb] 1
[b:[bbb]]
>>>=0
>= 0

View File

@ -1,6 +1,5 @@
# can we parse this sample journal from c++ ledger source
hledger -f- stats
<<<
<
; -*- ledger -*-
N $
@ -55,4 +54,6 @@ end tag
; :MyTag:
Assets:Bank:Checking
; :AnotherTag:
>>>= 0
$ hledger -f- stats
> //

View File

@ -1,17 +1,15 @@
# 1. posting dates can be set with a tag. Also the year can be
# inferred from the transaction. If there are multiple tags, the first
# is used. Date separators /-. are allowed.
hledger -f- register
<<<
<
2000/1/2
a 0 ; date: 3/4, date: 4-5, date:6.7
>>> /^2000-03-04/
>>>=0
$ hledger -f- register
> /^2000-03-04/
# 2. If the date: or date2: tags do not have a valid simple date
# value, there should be a corresponding error at the right position
hledger -f- register
<<<
<
comment
Journal comment to prevent this being parsed as a timedot file
end comment
@ -23,23 +21,22 @@ end comment
b 0
; date: 3.32
>>>2 /10:16/
>>>=1
$ hledger -f- register
>2 /10:16/
>= 1
# 3. Ledger's bracketed date syntax is also supported: `[DATE]`,
# `[DATE=DATE2]` or `[=DATE2]`. This is equivalent to using `date:` or
# `date2:` tags.
hledger -f- register --date2
<<<
<
2000/1/2
a 0 ; [=3-4]
>>> /^2000-03-04/
>>>=0
$ hledger -f- register --date2
> /^2000-03-04/
# 4. Date parsing and error reporting activates for square brackets
# containing only `0123456789/-.=` characters.
hledger -f- register
<<<
<
comment
Journal comment to prevent this being parsed as a timedot file
end comment
@ -50,5 +47,6 @@ end comment
2000/1/2
b 0 ; [1/1=1/2/3/4] bad second date, should error
>>>2 /-:9:21/
>>>=1
$ hledger -f- register
>2 /-:9:21/
>= 1

View File

@ -2,67 +2,61 @@
#
# 1. original test case, this should balance since price precisions do
# not affect the canonical display precisions used for display and balancing
hledger -f - print
<<<
<
2010/1/1 x
A 55.3653 C @ 30.92189512 D
A -1712 D
>>>
$ hledger -f - print
2010-01-01 x
A 55.3653 C @ 30.92189512 D
A -1712 D
>>>=0
>= 0
# 2. here the price should be printed with its original precision, not
# the canonical display precision. And the inferred amount should be printed
# with the canonical precision (2 digits, inferred from the first posting).
hledger -f - print --explicit
<<<
<
2010/1/1
a $0.00
a 1C @ $1.0049
a
>>>
$ hledger -f - print --explicit
2010-01-01
a 0
a 1C @ $1.0049
a $-1.0049
>>>=0
>= 0
# 3. with $'s display precision at 3 or more, this txn should not balance.
# The error message shows the difference with full precision.
hledger -f - balance --no-total --cost --empty
<<<
<
2010/1/1
a 1C @ $1.0049
a $-1.000
>>>2 /should be 0 but is: \$0.0049/
>>>= 1
$ hledger -f - balance --no-total --cost --empty
>2 /should be 0 but is: \$0.0049/
>= 1
# 4. with $'s display precision at 2 or less, this txn should balance
hledger -f - balance --no-total --cost --empty
<<<
<
2010/1/1
a 1C @ $1.0049
a $-1.00
>>>
$ hledger -f - balance --no-total --cost --empty
0 a
>>>=0
# 5. avamk's 2011/1/19 example
hledger -f - balance --cost
<<<
<
2001/01/01 * ACME fund
assets:investment:ACME 203.890 ACME @ $16.02
equity:opening balances
>>>
$ hledger -f - balance --cost
$3266.32 assets:investment:ACME
$-3266.32 equity:opening balances
--------------------
0
>>>=0
# hledger 0.14pre: precision=2, presumably from price
# $3266.32 assets:investment:ACME
@ -81,18 +75,16 @@ hledger -f - balance --cost
# 0
## 6. with a default commodity..
hledger -f - balance --cost
<<<
<
D $1000.0
2001/01/01 * ACME fund
assets:investment:ACME 203.890 ACME @ $16.02
equity:opening balances
>>>
$ hledger -f - balance --cost
$3266.3 assets:investment:ACME
$-3266.3 equity:opening balances
--------------------
0
>>>=0
### hledger 0.14pre: precision=2, presumably from price, ignores D
### $3266.32 assets:investment:ACME
### $-3266.32 equity:opening balances
@ -115,33 +107,31 @@ D $1000.0
# the max precisions of the commodities being converted (#262).
# Here the (irrational) price should be displayed with just precision 4
# (C's precision 2 + D's precision 2).
hledger -f- print --explicit
<<<
<
2015/1/1
c C 10.00
c C 11.00
d D -320.00
>>>
$ hledger -f- print --explicit
2015-01-01
c C 10.00 @ D 15.2381
c C 11.00 @ D 15.2381
d D -320.00
>>>=0
>= 0
## 8. Here the price should be displayed with precision 7
# (E's precision 4 + F's precision 3).
hledger -f- print --explicit
<<<
<
2015/1/1
e E 10.0000
e E 11
f F -320.000
>>>
$ hledger -f- print --explicit
2015-01-01
e E 10.0000 @ F 15.2380952
e E 11.0000 @ F 15.2380952
f F -320.000
>>>=0
>= 0

View File

@ -1,17 +1,14 @@
# just check
hledger -f - bal --no-total
<<<
<
D $1,000.00
2018/1/1
(a) 2.3
>>>
$ hledger -f - bal --no-total
$2.30 a
>>>=0
# some basic cases with commodity
hledger -f - bal --no-total
<<<
<
commodity $1,000.00000000
2018/1/1
@ -19,16 +16,14 @@ commodity $1,000.00000000
b $31415926e-7
c $1E+3
d
>>>
$ hledger -f - bal --no-total
$105.00000000 a
$3.14159260 b
$1,000.00000000 c
$-1,108.14159260 d
>>>=0
# some basic cases with commodity
hledger -f - print --explicit
<<<
<
commodity $1,000.00000000
2018/1/1
@ -36,48 +31,43 @@ commodity $1,000.00000000
b $31415926e-7
c $1E+3
d
>>>
$ hledger -f - print --explicit
2018-01-01
a $105.00000000
b $3.14159260
c $1,000.00000000
d $-1,108.14159260
>>>=0
#
>=
# some basic cases
hledger -f - bal --no-total
<<<
<
2018/1/1
a 1.05e2
b 31415926e-7
c 1E+3
d
>>>
$ hledger -f - bal --no-total
105.0000000 a
3.1415926 b
1000.0000000 c
-1108.1415926 d
>>>2
>>>=0
# we still should recognize commodities with e
hledger -f - bal --no-total
<<<
<
2018/1/1
(a) 1.00005e
(a) 2.00003E
>>>
$ hledger -f - bal --no-total
2.00003E
1.00005e a
>>>=0
hledger -f - reg
<<<
<
2018/1/1
(a) 1,000.5e-1
>>>
>>>=1
$ hledger -f - reg
>2 //
>= 1
# different digit group separator chars before and after decimal point, not supported
# 2018/1/4

View File

@ -1,8 +1,7 @@
## parsing
# 1. transactions and postings have status marks which are nothing, ! or *
hledger -fstatus.journal print
>>>
$ hledger -fstatus.journal print
2017-01-01 unmarked
(a) 1
(b) 1
@ -15,94 +14,82 @@ hledger -fstatus.journal print
(a) 1
* (b) 1
>>>=0
>= 0
# 2. other characters will be considered part of the description
hledger -f- print desc:%
<<<
<
2017/01/01 %
>>>
$ hledger -f- print desc:%
2017-01-01 %
>>>=0
>= 0
## matching with flags
# 3. --cleared matches * only
hledger -fstatus.journal print --cleared
>>>
$ hledger -fstatus.journal print --cleared
2017-01-03 * cleared
(a) 1
* (b) 1
>>>=0
>= 0
# 4. --pending matches ! only
hledger -fstatus.journal print --pending
>>>
$ hledger -fstatus.journal print --pending
2017-01-02 ! pending
(a) 1
! (b) 1
>>>=0
>= 0
# 5. --unmarked matches no status mark only
hledger -fstatus.journal print --unmarked
>>>
$ hledger -fstatus.journal print --unmarked
2017-01-01 unmarked
(a) 1
(b) 1
>>>=0
>= 0
# 6. these flags can be combined
hledger -fstatus.journal register --unmarked --pending
>>>
$ hledger -fstatus.journal register --unmarked --pending
2017-01-01 unmarked (a) 1 1
(b) 1 2
2017-01-02 pending (a) 1 3
(b) 1 4
>>>= 0
# 7. these flags work with other commands
hledger -fstatus.journal balance -N --unmarked
>>>
$ hledger -fstatus.journal balance -N --unmarked
1 a
1 b
>>>=0
## matching with status: query
# 8. status:* matches * only
hledger -fstatus.journal print status:*
>>>
$ hledger -fstatus.journal print status:*
2017-01-03 * cleared
(a) 1
* (b) 1
>>>=0
>= 0
# 9. status:! matches ! only
hledger -fstatus.journal print status:!
>>>
$ hledger -fstatus.journal print status:!
2017-01-02 ! pending
(a) 1
! (b) 1
>>>=0
>= 0
# 10. status: matches unmarked only
hledger -fstatus.journal print status:
>>>
$ hledger -fstatus.journal print status:
2017-01-01 unmarked
(a) 1
(b) 1
>>>=0
>= 0
# 11. multiple status: queries are OR'd
hledger -fstatus.journal print status: status:!
>>>
$ hledger -fstatus.journal print status: status:!
2017-01-01 unmarked
(a) 1
(b) 1
@ -111,5 +98,5 @@ hledger -fstatus.journal print status: status:!
(a) 1
! (b) 1
>>>= 0
>= 0

View File

@ -1,42 +1,42 @@
# 1. virtual posting shouldn't affect balance
hledger -f- print
<<<
<
2009/1/1 x
(virtual) 100
a 1
b
>>>=0
#
$ hledger -f- print
> //
# 2. balanced virtual postings should be required to balance (themselves)
hledger -f- print
<<<
<
2010/1/1 x
[balanced virtual] 10
a 1
b
>>>= !0
#
$ hledger -f- print
>2 //
>= 1
# 3. balanced virtual postings should be required to balance (themselves)
hledger -f- print
<<<
<
2010/1/1 x
[balanced virtual] 10
[balanced virtual] -10
a 1
b
>>>=0
#
$ hledger -f- print
> //
# 4. a virtual posting with implicit amount should be handled correctly
hledger -f- print
<<<
<
2010/1/1 x
[a] 10
[b]
>>>=0
#
$ hledger -f- print
> //
# 5. real and balanced virtual postings are balanced separately, and multiple blank virtuals are ok
hledger -f- balance --tree
<<<
<
2010/1/1 x
a 1
b
@ -44,12 +44,10 @@ hledger -f- balance --tree
[f]
(c)
(d)
>>>
$ hledger -f- balance --tree
1 a
-1 b
10 e
-10 f
--------------------
0
>>>2
>>>=0

View File

@ -1,47 +1,41 @@
# --pivot tests
# 1. check pivot with print
hledger -f- --pivot TAG 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
>= 0
# 2. check pivot with bal
hledger -f- --pivot member bal --no-total
<<<
<
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
>>>=0
# 3. check with another example
hledger -f- --pivot budget bal --no-total
<<<
<
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
>>>=0
# 4. query on account will find either effective name or original one
hledger -f- --pivot TAG reg '^Account2$' '^fun$' not:hidden
<<<
<
2016/02/16 Test Transaction
Account1 2 EUR
; TAG: fun
@ -49,60 +43,50 @@ hledger -f- --pivot TAG reg '^Account2$' '^fun$' not:hidden
; 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
>>>=0
# 5. We should be able to query on original account names
hledger -f- --pivot expenses reg not:liabilities
<<<
<
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
>>>=0
# 6. pivot for implicit tag desc (technical sample)
hledger -f- --pivot description reg -M
<<<
<
2016/02/16 Freifunk
assets:bank account 2 EUR ; date:03/01
income:donations -2 EUR
>>>
$ hledger -f- --pivot description reg -M
2016-02 Freifunk -2 EUR -2 EUR
2016-03 Freifunk 2 EUR 0
>>>=0
# 7. pivot for implicit tag code (technical sample)
hledger -f- --pivot code reg -M
<<<
<
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
>>>=0
# 8. use of pivot with code-based budgeting
hledger -f- --pivot code reg ^income
<<<
<
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
>>>=0
# 9. get expenses balance by description/payee
hledger -f- --pivot payee bal --no-total --flat ^expense
<<<
<
2016/02/16 (1138) Auchan | buy a food for tomorrow morning
assets:bank account
expense:snacks 2 EUR
@ -111,14 +95,12 @@ hledger -f- --pivot payee bal --no-total --flat ^expense
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
>>>=0
# 10. get daily expenses by description/payee
hledger -f- --pivot payee reg -D ^expense
<<<
<
2016/02/16 (1138) Auchan
assets:bank account
expense:snacks 2 EUR
@ -131,8 +113,7 @@ hledger -f- --pivot payee reg -D ^expense
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
>>>=0

View File

@ -1,37 +1,33 @@
# 1. print shows both primary and secondary dates. The second's year defaults to the first's.
hledger -f - print
<<<
<
2000/1/1=3/3
(a) 1
2000/1/2=2/2
(b) 1
>>>
$ hledger -f - print
2000-01-01=2000-03-03
(a) 1
2000-01-02=2000-02-02
(b) 1
>>>2
>>>= 0
>= 0
# 2. With --date2, the secondary date is used for sorting.
hledger -f - print --date2
<<<
<
2000/1/1=3/3
(a) 1
2000/1/2=2/2
(b) 1
>>>
$ hledger -f - print --date2
2000-01-02=2000-02-02
(b) 1
2000-01-01=2000-03-03
(a) 1
>>>2
>>>= 0
>= 0

View File

@ -1,121 +1,104 @@
# Tests of --explicit option effect
# 1. implicit transaction balance w/o --explict
hledger -f - print
<<<
<
2017/1/1
expenses $5
assets
>>>
$ hledger -f - print
2017-01-01
expenses $5
assets
>>>2
>>>=0
>= 0
# 2. implicit transaction balance w/ --explict
hledger -f - print --explicit
<<<
<
2017/1/1
expenses $5
assets
>>>
$ hledger -f - print --explicit
2017-01-01
expenses $5
assets $-5
>>>2
>>>=0
>= 0
# 3. implicit commodity price w/o --explict
hledger -f - print
<<<
<
2017/1/1
expenses 4 EUR
assets $-5
>>>
$ hledger -f - print
2017-01-01
expenses 4 EUR
assets $-5
>>>2
>>>=0
>= 0
# 4. implicit commodity price w/ --explict
hledger -f - print --explicit
<<<
<
2017/1/1
expenses 4 EUR
assets $-5
>>>
$ hledger -f - print --explicit
2017-01-01
expenses 4 EUR @@ $5
assets $-5
>>>2
>>>=0
>= 0
# 5. implicit account balance w/o --explict
hledger -f - print
<<<
<
2017/1/1
assets = $100
equity
>>>
$ hledger -f - print
2017-01-01
assets = $100
equity
>>>2
>>>=0
>= 0
# 6. implicit account balance w/ --explict
hledger -f - print --explicit
<<<
<
2017/1/1
assets = $100
equity
>>>
$ hledger -f - print --explicit
2017-01-01
assets $100 = $100
equity $-100
>>>2
>>>=0
>= 0
# 7. default commodity always applied because print do not issue appropriate directive
hledger -f - print
<<<
<
D 1000.00 EUR
2017/1/1
expenses 100
assets
>>>
$ hledger -f - print
2017-01-01
expenses 100.00 EUR
assets
>>>2
>>>=0
>= 0
# 8. option --explicit implies effect of --empty
hledger -f - print --explicit
<<<
<
2017/1/1
assets $0
equity
>>>
$ hledger -f - print --explicit
2017-01-01
assets 0
equity 0
>>>2
>>>=0
>= 0
# 9. Auto postings are always explicit
hledger -f - print --auto
<<<
<
= a
c *-0.453
d
@ -123,12 +106,11 @@ hledger -f - print --auto
2021-09-01
a 1000 EUR
b
>>>
$ hledger -f - print --auto
2021-09-01 ; modified:
a 1000 EUR
c -453 EUR ; generated-posting: = a
d 453 EUR ; generated-posting: = a
b
>>>2
>>>=0
>= 0

View File

@ -1,11 +1,10 @@
hledger -f - print
<<<
<
2009/1/1 x
aaaaabbbbbcccccdddddeeeeefffffggggghhhhh 1
b
>>>
$ hledger -f - print
2009-01-01 x
aaaaabbbbbcccccdddddeeeeefffffggggghhhhh 1
b
>>>=0
>= 0

View File

@ -1,8 +1,6 @@
# print with negative account pattern should exclude transactions containing a matched posting
hledger -f- print not:a
<<<
<
2010/1/1 x
a 1
b -1
>>>
>>>=0
$ hledger -f- print not:a

View File

@ -1,5 +1,4 @@
hledger -f - print desc:x
<<<
<
2009/1/1 x
a 1
b
@ -8,9 +7,9 @@ hledger -f - print desc:x
a 1
b
>>>
$ hledger -f - print desc:x
2009-01-01 x
a 1
b
>>>=0
>= 0

View File

@ -6,31 +6,26 @@
# date2:D matches the secondary date
# 1. --date2 causes the secondary date to be displayed
hledger -f - register --date2
<<<
<
2009/1/1=2010/1/1 x
a 1
b
>>>
$ hledger -f - register --date2
2010-01-01 x a 1 1
b -1 0
>>>=0
# 2. --date2 causes -b/-e/-p to match the secondary date
hledger -f- register -p 2014/1/2 --date2
<<<
<
2014/1/1=1/2
(a) 1
2014/1/3
(b) 1
>>>
$ hledger -f- register -p 2014/1/2 --date2
2014-01-02 (a) 1 1
>>>=0
# 3. --date2 causes date: to match the secondary date (or the primary date, if there is no secondary)
hledger -f- register date:2014/1/2 --date2
<<<
<
2014/1/1=1/2
(a) 1
@ -39,55 +34,46 @@ hledger -f- register date:2014/1/2 --date2
2014/1/2=1/3
(C) 1
>>>
$ hledger -f- register date:2014/1/2 --date2
2014-01-02 (a) 1 1
2014-01-02 (b) 1 2
>>>=0
# 4. date2: matches the secondary date (but does not necessarily display it)
hledger -f- register date2:2014/1/2
<<<
<
2014/1/1=1/2
(a) 1
2014/1/3
(b) 1
>>>
$ hledger -f- register date2:2014/1/2
2014-01-01 (a) 1 1
>>>=0
# 5. date2: plus --date2 both matches and displays the secondary date
hledger -f- register date2:2014/1/2 --date2
<<<
<
2014/1/1=1/2
(a) 1
2014/1/3
(b) 1
>>>
$ hledger -f- register date2:2014/1/2 --date2
2014-01-02 (a) 1 1
>>>=0
# 6. date2: matching is not affected by --date2
hledger -f- register date2:2014/1/1 --date2
<<<
<
2014/1/1=1/2
(a) 1
2014/1/3
(b) 1
>>>
>>>=0
$ hledger -f- register date2:2014/1/1 --date2
# 7. with --date2, the secondary date is used for sorting
hledger -f- register --date2
<<<
<
2014/1/1=2/2
(a) 1
2014/1/3=2/1
(b) 1
>>>
$ hledger -f- register --date2
2014-02-01 (b) 1 1
2014-02-02 (a) 1 2
>>>=0

View File

@ -1,16 +1,13 @@
# 1. register --depth N matches postings as usual but clips account names to N
hledger -f - register aa --depth 1
<<<
<
2010/1/1 x
a:aa:aaa 1
b
>>>
$ hledger -f - register aa --depth 1
2010-01-01 x a 1 1
>>>=0
# 2. separate postings remain separate
hledger -f - register aa --depth 2
<<<
<
2010/1/1 x
a:aa 1
b:bb:bbb
@ -22,15 +19,13 @@ hledger -f - register aa --depth 2
2010/1/2 z
a:aa 1
b:bb:bbb
>>>
$ hledger -f - register aa --depth 2
2010-01-01 x a:aa 1 1
2010-01-01 y a:aa 1 2
2010-01-02 z a:aa 1 3
>>>=0
# 3. with a reporting interval, all postings are aggregated under each (clipped) account
hledger -f - register aa --depth 1 --daily
<<<
<
2010/1/1 x
a:aa 1
b:bb:bbb
@ -42,24 +37,19 @@ hledger -f - register aa --depth 1 --daily
2010/1/2 z
a:aa 1
b:bb:bbb
>>>
$ hledger -f - register aa --depth 1 --daily
2010-01-01 a 2 2
2010-01-02 a 1 3
>>>=0
# 4. with --cleared
hledger -f - register a --depth 1 --cleared
<<<
<
2012/1/1 *
(a:aa) 1
>>>
$ hledger -f - register a --depth 1 --cleared
2012-01-01 (a) 1 1
>>>2
>>>=0
# 5. depth 0 aggregates everything into a single line
hledger -f - register --depth 0 --daily a b
<<<
<
2010/1/1 x
a:aa 1
b:bb 2
@ -74,8 +64,7 @@ hledger -f - register --depth 0 --daily a b
a:aa 1
b:bb 2
c:cc
>>>
$ hledger -f - register --depth 0 --daily a b
2010-01-01 ... 6 6
2010-01-02 ... 3 9
>>>=0

View File

@ -1,5 +1,4 @@
hledger -f- register date:2014/4
<<<
<
2014/3/30
(a) 1
@ -9,7 +8,5 @@ hledger -f- register date:2014/4
2014/3/31
(a) 1
>>>
$ hledger -f- register date:2014/4
2014-04-01 (a) 1 1
>>>2
>>>= 0

View File

@ -1,7 +1,6 @@
# 1. Add proportional income tax (from documentation)
hledger rewrite -f- ^income --add-posting '(liabilities:tax) *.33 ; income tax'
<<<
<
2016/1/1 paycheck
income:remuneration $-100
income:donations $-15
@ -10,7 +9,7 @@ hledger rewrite -f- ^income --add-posting '(liabilities:tax) *.33 ; income tax
2016/1/1 withdraw
assets:cash $20
assets:bank
>>>
$ hledger rewrite -f- ^income --add-posting '(liabilities:tax) *.33 ; income tax'
2016-01-01 paycheck ; modified:
income:remuneration $-100
(liabilities:tax) $-33 ; income tax, generated-posting: = ^income
@ -22,13 +21,11 @@ hledger rewrite -f- ^income --add-posting '(liabilities:tax) *.33 ; income tax
assets:cash $20
assets:bank
>>>2
>>>=0
>= 0
# 2. Duplicate posting for budgeting (from documentation).
# It uses same date as the matched posting.
hledger rewrite -f- expenses:gifts --add-posting '(budget:gifts) *-1'
<<<
<
2016/1/1 withdraw
assets:cash $20
assets:bank
@ -36,7 +33,7 @@ hledger rewrite -f- expenses:gifts --add-posting '(budget:gifts) *-1'
2016/1/1 gift
assets:cash $-15
expenses:gifts ; [1/2]
>>>
$ hledger rewrite -f- expenses:gifts --add-posting '(budget:gifts) *-1'
2016-01-01 withdraw
assets:cash $20
assets:bank
@ -46,12 +43,10 @@ hledger rewrite -f- expenses:gifts --add-posting '(budget:gifts) *-1'
expenses:gifts ; [1/2]
(budget:gifts) $-15 ; [2016-01-02], generated-posting: = expenses:gifts
>>>2
>>>=0
>= 0
# 3. Add postings in another commodity
hledger rewrite -f-
<<<
<
2017/04/24 * 09:00-09:25
(assets:unbilled:client1) 0.42h
@ -67,7 +62,7 @@ hledger rewrite -f-
= ^assets:unbilled:client2
(assets:to bill:client2) *150.00 CAD
>>>
$ hledger rewrite -f-
2017-04-24 * 09:00-09:25 ; modified:
(assets:unbilled:client1) 0.42h
(assets:to bill:client1) 42.00 CAD ; generated-posting: = ^assets:unbilled:client1
@ -80,13 +75,11 @@ hledger rewrite -f-
(assets:unbilled:client2) 1.54h
(assets:to bill:client2) 231.00 CAD ; generated-posting: = ^assets:unbilled:client2
>>>2
>>>=0
>= 0
# 4. Add postings with prices
hledger rewrite -f- -B
<<<
<
2017/04/24 * 09:00-09:25
(assets:unbilled:client1) 0.42h
@ -104,7 +97,7 @@ hledger rewrite -f- -B
= ^assets:unbilled:client2
assets:to bill:client2 *1.00 hours @ $150.00
income:consulting:client2
>>>
$ hledger rewrite -f- -B
2017-04-24 * 09:00-09:25 ; modified:
(assets:unbilled:client1) 0.42h
assets:to bill:client1 $42.00 ; generated-posting: = ^assets:unbilled:client1
@ -120,13 +113,11 @@ hledger rewrite -f- -B
assets:to bill:client2 $231.00 ; generated-posting: = ^assets:unbilled:client2
income:consulting:client2 ; generated-posting: = ^assets:unbilled:client2
>>>2
>>>=0
>= 0
# 5. Add absolute bank processing fee
# XXX is "and" really processed here ?
hledger rewrite -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' --add-posting 'assets:bank $-5'
<<<
<
2016/1/1 withdraw
assets:cash $20
assets:bank
@ -139,7 +130,7 @@ hledger rewrite -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' -
# 2016/1/31 paycheck
# income:remuneration $-100
# assets:bank
>>>
$ hledger rewrite -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' --add-posting 'assets:bank $-5'
2016-01-01 withdraw ; modified:
assets:cash $20
assets:bank
@ -152,12 +143,10 @@ hledger rewrite -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' -
expenses:fee $5 ; generated-posting: = assets:bank and "amt:<0"
assets:bank $-5 ; generated-posting: = assets:bank and "amt:<0"
>>>2
>>>=0
>= 0
# 6. Rewrite rule within journal
hledger rewrite -f- date:2017/1 --add-posting 'Here comes Santa $0'
<<<
<
= ^assets:bank$ date:2017/1 amt:<0
assets:bank *0.008
expenses:fee *-0.008 ; cash withdraw fee
@ -188,7 +177,7 @@ hledger rewrite -f- date:2017/1 --add-posting 'Here comes Santa $0'
; but relative order matters to refer-rewritten transactions
= ^expenses not:housing not:grocery not:food
(budget:misc) *-1
>>>
$ hledger rewrite -f- date:2017/1 --add-posting 'Here comes Santa $0'
2016-12-31 ; modified:
expenses:housing $600.00
(budget:housing) $-600.00 ; generated-posting: = ^expenses:housing
@ -220,12 +209,10 @@ hledger rewrite -f- date:2017/1 --add-posting 'Here comes Santa $0'
assets:cash $100.00
assets:bank
>>>2
>>>=0
>= 0
# 7. Rewrite using diff output
hledger rewrite --diff -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' --add-posting 'assets:bank $-5'
<<<
<
2016/01/01 withdraw
assets:cash $20
assets:bank
@ -233,7 +220,7 @@ hledger rewrite --diff -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee
2016/01/02 withdraw
assets:cash
assets:bank $-30
>>>
$ hledger rewrite --diff -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' --add-posting 'assets:bank $-5'
--- -
+++ -
@@ -1,3 +1,5 @@
@ -250,5 +237,3 @@ hledger rewrite --diff -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee
assets:bank $-30
+ expenses:fee $5 ; generated-posting: = assets:bank and "amt:<0"
+ assets:bank $-5 ; generated-posting: = assets:bank and "amt:<0"
>>>2
>>>=0

View File

@ -1,6 +1,5 @@
# 1. investment that does not grow has no return
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
<<<
<
2017-01-01 investment
assets:cash -$100
investment
@ -8,18 +7,17 @@ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
2017-06-01 investment
assets:cash -$100
investment
>>>
$ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++=======+=======+
| 1 || 2017-01-01 | 2017-12-31 || 0 | $200 | $200 | 0 || 0.00% | 0.00% |
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
>>>=0
>= 0
# 2. Growth by 12% from single investment transaction should show 12% IRR and 12% TWR
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
<<<
<
2017-01-01 investment
assets:cash -$100
investment
@ -27,18 +25,17 @@ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
2017-12-31 investment valuation
investment = $112
pnl
>>>
$ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++========+========+
| 1 || 2017-01-01 | 2017-12-31 || 0 | $100 | $112 | $12 || 12.00% | 12.00% |
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
>>>=0
>= 0
# 3. Same as (2), but grow by 1% per month
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
<<<
<
2017-01-01 investment
assets:cash -$100
investment
@ -91,18 +88,17 @@ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
investment = $112
pnl
>>>
$ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++========+========+
| 1 || 2017-01-01 | 2017-12-31 || 0 | $100 | $112 | $12 || 12.00% | 12.00% |
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
>>>=0
>= 0
# 4. When $100 invested over 12 month + $100 invested over 6 month yield $220, that's 10% TWR, but 12.73% IRR
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
<<<
<
2017-01-01 investment
assets:cash -$100
investment
@ -114,18 +110,17 @@ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
2017-12-31 investment valuation
investment = $220
pnl
>>>
$ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++========+========+
| 1 || 2017-01-01 | 2017-12-31 || 0 | $200 | $220 | $20 || 12.72% | 10.00% |
+---++------------+------------++---------------+----------+-------------+-----++--------+--------+
>>>=0
>= 0
# 5. When $100 invested over 12 month + $100 invested over 6 month yield $20, that's -90% TWR, but -95.73% IRR
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
<<<
<
2017-01-01 investment
assets:cash -$100
investment
@ -137,18 +132,17 @@ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
2017-12-31 investment valuation
investment = $20
pnl
>>>
$ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Y
+---++------------+------------++---------------+----------+-------------+-------++---------+---------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=======++=========+=========+
| 1 || 2017-01-01 | 2017-12-31 || 0 | $200 | $20 | $-180 || -95.73% | -90.00% |
+---++------------+------------++---------------+----------+-------------+-------++---------+---------+
>>>=0
>= 0
# 6. Check that deposits/withdrawals and profit/loss are reflected in the right periods
hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Q
<<<
<
2017-01-01 investment
assets:cash -$100
investment
@ -168,7 +162,7 @@ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Q
2017-12-31 investment valuation
investment = $155
pnl
>>>
$ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Q
+---++------------+------------++---------------+----------+-------------+-----++---------+---------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++=========+=========+
@ -178,11 +172,10 @@ hledger -f- roi --inv investment --pnl pnl -b 2017 -e 2018 -Q
| 4 || 2017-10-01 | 2017-12-31 || $210 | $-50 | $155 | $-5 || -11.83% | -11.82% |
+---++------------+------------++---------------+----------+-------------+-----++---------+---------+
>>>=0
>= 0
# 7. Check that reporting for the part of the total history of investment works
hledger -f- roi --inv investment --pnl pnl -b 2017-06 -e 2018
<<<
<
2017-01-01 investment
assets:cash -$100
investment
@ -202,33 +195,31 @@ hledger -f- roi --inv investment --pnl pnl -b 2017-06 -e 2018
2017-12-31 investment valuation
investment = $155
pnl
>>>
$ hledger -f- roi --inv investment --pnl pnl -b 2017-06 -e 2018
+---++------------+------------++---------------+----------+-------------+-----++-------+--------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++=======+========+
| 1 || 2017-06-01 | 2017-12-31 || $100 | $50 | $155 | $5 || 5.24% | 11.45% |
+---++------------+------------++---------------+----------+-------------+-----++-------+--------+
>>>=0
>= 0
# 8. Dont fail where there is no rate-of-return
hledger -f- roi -p 2019-11
<<<
<
2019/11/01 Example
Assets:Checking 1
Income:Salary -1
>>>
$ hledger -f- roi -p 2019-11
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++=======+=======+
| 1 || 2019-11-01 | 2019-11-30 || 0 | 0 | 0 | 0 || 0.00% | 0.00% |
+---++------------+------------++---------------+----------+-------------+-----++-------+-------+
>>>=0
>= 0
# 9. Fail with a nice error message when commodity can't be valued
hledger -f- roi -p 2019-11 --inv Investment --pnl PnL
<<<
<
2019/11/01 Example
Assets:Checking -100 A
Investment 10 B
@ -237,15 +228,15 @@ hledger -f- roi -p 2019-11 --inv Investment --pnl PnL
Investment -10 B @@ 100 A
Assets:Checking 101 A
Unrealized PnL
>>>2
$ hledger -f- roi -p 2019-11 --inv Investment --pnl PnL
>2
hledger: Error: Amounts could not be converted to a single cost basis: ["10 B","-10 B @@ 100 A"]
Consider using --value to force all costs to be in a single commodity.
For example, "--cost --value=end,<commodity> --infer-market-prices", where commodity is the one that was used to pay for the investment.
>>>=1
>= 1
# 10. Forcing valuation via --value
hledger -f- roi -p 2019-11 --inv Investment --pnl PnL --cost --value=then,A --infer-market-prices
<<<
<
2019/11/01 Example
Assets:Checking -100 A
Investment 10 B
@ -254,18 +245,17 @@ hledger -f- roi -p 2019-11 --inv Investment --pnl PnL --cost --value=then,A --in
Investment -10 B @@ 100 A
Assets:Checking 101 A
Unrealized PnL
>>>
$ hledger -f- roi -p 2019-11 --inv Investment --pnl PnL --cost --value=then,A --infer-market-prices
+---++------------+------------++---------------+----------+-------------+-----++----------+--------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++==========+========+
| 1 || 2019-11-01 | 2019-11-30 || 0 | -1 A | 0 | 1 A || 3678.34% | 12.87% |
+---++------------+------------++---------------+----------+-------------+-----++----------+--------+
>>>=0
>= 0
# 11. Use "then" prices. 10000/76.20 = 131.23, 11000/73.88=148.89
hledger -f - roi --inv assets:investment --pnl income:investment --value=then,'$'
<<<
<
P 2020-12-01 $ 76.20
P 2021-01-01 $ 73.88
@ -276,18 +266,17 @@ P 2021-01-01 $ 73.88
2021-01-02 get profit
assets:investment =11000
income:investment
>>>
$ hledger -f - roi --inv assets:investment --pnl income:investment --value=then,'$'
+---++------------+------------++---------------+----------+-------------+-----++---------+---------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++=========+=========+
| 1 || 2020-12-02 | 2021-01-02 || 0 | $131 | $149 | $18 || 321.99% | 321.81% |
+---++------------+------------++---------------+----------+-------------+-----++---------+---------+
>>>=0
>= 0
# 12. Use "end" prices. 10000/73.88=135.35
hledger -f - roi --inv assets:investment --pnl income:investment --value=end,'$'
<<<
<
P 2020-12-01 $ 76.20
P 2021-01-01 $ 73.88
@ -298,18 +287,17 @@ P 2021-01-01 $ 73.88
2021-01-02 get profit
assets:investment =11000
income:investment
>>>
$ hledger -f - roi --inv assets:investment --pnl income:investment --value=end,'$'
+---++------------+------------++---------------+----------+-------------+-----++---------+---------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=====++=========+=========+
| 1 || 2020-12-02 | 2021-01-02 || 0 | $135 | $149 | $14 || 196.58% | 196.58% |
+---++------------+------------++---------------+----------+-------------+-----++---------+---------+
>>>=0
>= 0
# 13. Several PnL transactions on a single date are aggregated together
hledger -f - roi --inv saving --pnl dividend
<<<
<
2010-01-01 A1
savingA 100.00 €
checking
@ -337,18 +325,17 @@ hledger -f - roi --inv saving --pnl dividend
2012-03-29 B3
saving -100.00 €
checking
>>>
$ hledger -f - roi --inv saving --pnl dividend
+---++------------+------------++---------------+----------+-------------+---------++-------+-------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+=========++=======+=======+
| 1 || 2010-01-01 | 2012-03-29 || 0 | -16.00 € | 0 | 16.00 € || 3.52% | 3.49% |
+---++------------+------------++---------------+----------+-------------+---------++-------+-------+
>>>=0
>= 0
# 14. Should support begin date before first transaction where first transaction has pnl
hledger -f - roi --inv stocks --pnl expenses --value=then,€ -Y
<<<
<
P 2022-07-31 A € 1
2022-08-01 Purchase
@ -358,11 +345,11 @@ P 2022-07-31 A € 1
P 2022-08-02 A € 2
>>>
$ hledger -f - roi --inv stocks --pnl expenses --value=then,€ -Y
+---++------------+------------++---------------+----------+-------------+------++---------+--------+
| || Begin | End || Value (begin) | Cashflow | Value (end) | PnL || IRR | TWR |
+===++============+============++===============+==========+=============+======++=========+========+
| 1 || 2022-01-01 | 2022-12-31 || 0 | € 101 | € 200 | € 99 || 410.31% | 98.02% |
+---++------------+------------++---------------+----------+-------------+------++---------+--------+
>>>=0
>= 0

View File

@ -1,14 +1,10 @@
# 1. empty file
hledger -f- stats
<<<
>>> /Accounts.* 0 \(depth 0\)/
>>>=0
$ hledger -f- stats
> /Accounts.* 0 \(depth 0\)/
# 2. included files should be listed in parse order
touch a.j b.j; hledger -f- stats; rm -f a.j b.j
<<<
<
include a.j
include b.j
>>> /Included files *: *\.\/a\.j/
>>>2
>>>=0
$ touch a.j b.j; hledger -f- stats; rm -f a.j b.j
> /Included files *: *\.\/a\.j/