;dev: cli: ledger tests: snapshot of ledger regress tests' data

This commit is contained in:
Simon Michael 2022-12-18 00:35:15 -10:00
parent caffb22320
commit 5cc0080776
213 changed files with 7220 additions and 0 deletions

View File

@ -0,0 +1,25 @@
2005/01/03 * Pay Credit card
Liabilities:CredCard $1,000.00 ; Electronic/ACH Debit
Assets:Current:Checking ; Electronic/ACH Debit
(Virtualaccount) $1,000.00
2006/01/03 Gift shop
Expenses:Gifts $46.50
* Liabilities:CredCard
2006/01/03 Bike shop
Expenses:Misc $199.00
* Liabilities:CredCard
(testvirtual) $184.72
2006/01/04 Store
Expenses:Misc $49.95
* Liabilities:CredCard
comment
test equity -e 2006
2005/01/03 Opening Balances
Assets:Current:Checking $-1,000.00
Liabilities:CredCard $1,000.00
(Virtualaccount) $1,000.00
end test

View File

@ -0,0 +1,16 @@
bucket Assets:Checking
2011/04/25 Tom's Used Cars
Auto $ 5,500.00
; :nobudget:
A Assets:Checking
2011/04/27 Book Store
Books $20.00
comment
test reg
11-Apr-25 Tom's Used Cars Auto $ 5,500.00 $ 5,500.00
Assets:Checking $ -5,500.00 0
11-Apr-27 Book Store Books $ 20.00 $ 20.00
Assets:Checking $ -20.00 0
end test

View File

@ -0,0 +1,17 @@
2009/04/04 CS Club Sign
Expenses:School:CS Club:Home Depot:4" Brush 2 @ $3.97
Liabilities:Mastercard
2009/04/04 CS Club Sign
Expenses:School:CS Club:Home Depot:4" Brush (2 * $3.97)
Liabilities:Mastercard
comment
test reg
09-Apr-04 CS Club Sign Ex:Sc:CS:Home:4" Brush 2 2
Liabilities:Mastercard $-7.94 2
$-7.94
09-Apr-04 CS Club Sign Ex:Sc:CS:Home:4" Brush $7.94 2
Liabilities:Mastercard $-7.94 2
$-7.94
end test

View File

@ -0,0 +1,12 @@
; Test for invalid option embedded in journal
--foo
comment
test bal -> 1
__ERROR__
While parsing file "$FILE", line 4:
Error: Illegal option --foo
end test

View File

@ -0,0 +1,12 @@
2007/02/02 RD VMMXX
Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00
Income:Dividends:Vanguard:VMMXX $-0.35
comment
test bal
0.350 VMMXX Assets:Investments:Vanguard:VMMXX
$-0.35 Income:Dividends:Vanguard:VMMXX
--------------------
$-0.35
0.350 VMMXX
end test

View File

@ -0,0 +1,3 @@
date,posted,amount,
12/12/2011,12/13/2011,$10,
12/12/2011,,$20,

View File

@ -0,0 +1,10 @@
comment
test -f /dev/null --input-date-format '%m/%d/%Y' convert test/regress/0DDDEBC0.dat
2011/12/12=2011/12/13 *
Expenses:Unknown $10
Equity:Unknown
2011/12/12 *
Expenses:Unknown $20
Equity:Unknown
end test

View File

@ -0,0 +1,81 @@
account
alias
apply
assert
bucket
check
commodity
def
define
apply account foo
end
expr
eval
include
!include
import
payee
tag
comment
foo bar
end comment
value
comment
test source -> 17
__ERROR__
While parsing file "$FILE", line 2:
Error: Directive 'account' requires an argument
While parsing file "$FILE", line 4:
Error: Directive 'alias' requires an argument
While parsing file "$FILE", line 6:
Error: Directive 'apply' requires an argument
While parsing file "$FILE", line 8:
Error: Directive 'assert' requires an argument
While parsing file "$FILE", line 10:
Error: Directive 'bucket' requires an argument
While parsing file "$FILE", line 12:
Error: Directive 'check' requires an argument
While parsing file "$FILE", line 14:
Error: Directive 'commodity' requires an argument
While parsing file "$FILE", line 16:
Error: Directive 'def' requires an argument
While parsing file "$FILE", line 18:
Error: Directive 'define' requires an argument
While parsing file "$FILE", line 23:
Error: Directive 'expr' requires an argument
While parsing file "$FILE", line 25:
Error: Directive 'eval' requires an argument
While parsing file "$FILE", line 27:
Error: Directive 'include' requires an argument
While parsing file "$FILE", line 29:
Error: Directive 'include' requires an argument
While parsing file "$FILE", line 31:
Error: Directive 'import' requires an argument
While parsing file "$FILE", line 33:
Error: Directive 'payee' requires an argument
While parsing file "$FILE", line 35:
Error: Directive 'tag' requires an argument
While parsing file "$FILE", line 41:
Error: Directive 'value' requires an argument
end test

View File

@ -0,0 +1,19 @@
Y2014
04/13 Bank
Expenses:Loan $400
Assets:Cash
05/13 Bug 1038 Test
Expenses:Some:Account $500
Assets:Cash
06/13 Landlord
Expenses:Rent $600
Assets:Cash
comment
test reg --now 2014-05-14 -p 'this month'
14-May-13 Bug 1038 Test Expenses:Some:Account $500 $500
Assets:Cash $-500 0
end test

View File

@ -0,0 +1,19 @@
year 2014
04/13 Bank
Expenses:Loan $400
Assets:Cash
05/13 Bug 1038 Test
Expenses:Some:Account $500
Assets:Cash
06/13 Landlord
Expenses:Rent $600
Assets:Cash
comment
test reg --now 2014-05-14 -p 'this month'
14-May-13 Bug 1038 Test Expenses:Some:Account $500 $500
Assets:Cash $-500 0
end test

View File

@ -0,0 +1,21 @@
apply year 2014
04/13 Bank
Expenses:Loan $400
Assets:Cash
05/13 Bug 1038 Test
Expenses:Some:Account $500
Assets:Cash
06/13 Landlord
Expenses:Rent $600
Assets:Cash
end apply
comment
test reg --now 2014-05-14 -p 'this month'
14-May-13 Bug 1038 Test Expenses:Some:Account $500 $500
Assets:Cash $-500 0
end test

View File

@ -0,0 +1,36 @@
2014-05-01 * Test 1
A 1.00 GBP (@) 1.23 EUR
B -1.23 EUR
2014-05-02 * Test 2
A 1.00 GBP (@@) 1.23 EUR
B -1.23 EUR
2014-05-03 * Test 3
A 1.00 GBP @ 1.23 EUR
B -1.23 EUR
2014-05-04 * Test 4
A 1.00 GBP @@ 1.23 EUR
B -1.23 EUR
comment
test print
2014/05/01 * Test 1
A 1.00 GBP (@) 1.23 EUR
B -1.23 EUR
2014/05/02 * Test 2
A 1.00 GBP (@@) 1.23 EUR
B -1.23 EUR
2014/05/03 * Test 3
A 1.00 GBP @ 1.23 EUR
B -1.23 EUR
2014/05/04 * Test 4
A 1.00 GBP @@ 1.23 EUR
B -1.23 EUR
end test

View File

@ -0,0 +1,40 @@
D $1000.00
D £1000.00
D €1000.00
D 1000.00 EUR
2014-06-05 * Test
A 2 EUR @$1.37
C
2014-06-05 * Test
A 2 EUR @@£1.62
C
2014-06-05 * Test
A 2 EUR (@)€1.00
C
2014-06-05 * Test
A 2 EUR (@@)€2.00
C
comment
test bal
8.00 EUR A
$-2.74
£-1.62
€-4.00 C
--------------------
$-2.74
8.00 EUR
£-1.62
€-4.00
end test
test pricedb
P 2014/06/05 00:00:00 EUR $1.37
P 2014/06/05 00:00:00 EUR £0.81
end test

View File

@ -0,0 +1,27 @@
2011-01-01 * Opening balance
Assets:Broker 250.00 GBP = 250.00 GBP
Equity:Opening balance -250.00 GBP
2011-02-01 * Buy 1 AAA for 10.00 GBP
Assets:Broker 1 AAA = 1 AAA
Assets:Broker -10.00 GBP
2011-03-01 * Buy 1 AAA for 10.00 GBP
Assets:Broker 1 AAA = 2 AAA
Assets:Broker -10.00 GBP
2011-04-01 * Buy 1 BBB for 15.00 GBP
Assets:Broker 1 BBB = 1 BBB
Assets:Broker -15.00 GBP
comment
test bal
2 AAA
1 BBB
215.00 GBP Assets:Broker
-250.00 GBP Equity:Opening balance
--------------------
2 AAA
1 BBB
-35.00 GBP
end test

View File

@ -0,0 +1,12 @@
2014/04/03 www.amazon.fr
Dépense:Loisir:Ordi:Matériel 101,50 € ; disque dur portable 2,5" 2000 Go
Dépense:Maison:Service:Poste
* Passif:Crédit:BanqueAccord -171,63 €
comment
test --now=2014/06/27 emacs
(("$sourcepath/test/regress/1057.test" 1 (21308 60112 0) nil "www.amazon.fr"
(2 "Dépense:Loisir:Ordi:Matériel" "101,50 €" nil " disque dur portable 2,5\" 2000 Go")
(3 "Dépense:Maison:Service:Poste" "70,13 €" nil)
(4 "Passif:Crédit:BanqueAccord" "-171,63 €" t)))
end test

View File

@ -0,0 +1,32 @@
--input-date-format %d/%m/%y
--date-format %d/%m/%y
1/1/14 * Test
A $10
B
12/1/14 * Test
A $20
B
comment
test --input-date-format %d/%m/%y reg --begin 2/1/13
01/01/14 Test A $10 $10
B $-10 0
12/01/14 Test A $20 $20
B $-20 0
end test
test --input-date-format %d/%m/%y reg --begin 1/1/14
01/01/14 Test A $10 $10
B $-10 0
12/01/14 Test A $20 $20
B $-20 0
end test
test --input-date-format %d/%m/%y reg --begin 2/1/14
12/01/14 Test A $20 $20
B $-20 0
end test

View File

@ -0,0 +1,162 @@
--input-date-format %Y-%m-%d
--date-format %Y-%m-%d
2011-06-01 * Jun 2011
A $10
B
2011-07-01 * Jul 2011
A $10
B
2011-08-01 * Aug 2011
A $10
B
2012-06-01 * Jun 2012
A $10
B
2012-07-01 * Jul 2012
A $10
B
2012-08-01 * Aug 2012
A $10
B
2013-06-01 * Jun 2013
A $10
B
2013-07-01 * Jul 2013
A $10
B
2013-08-01 * Aug 2013
A $10
B
2014-06-01 * Jun 2014
A $10
B
2014-07-01 * Jul 2014
A $10
B
2014-08-01 * Aug 2014
A $10
B
2015-06-01 * Jun 2015
A $10
B
2015-07-01 * Jul 2015
A $10
B
2015-08-01 * Aug 2015
A $10
B
comment
test --now 2012-02-03 reg -p "from june to july"
2012-06-01 Jun 2012 A $10 $10
B $-10 0
end test
test --now 2013-02-03 reg -p "from june to july"
2013-06-01 Jun 2013 A $10 $10
B $-10 0
end test
test --now 2014-02-03 reg -p "from june to july"
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test
test --now 2014-10-02 reg -p "from june to july"
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test
test --now 2012-02-03 reg -p "from june to july 2014"
2012-06-01 Jun 2012 A $10 $10
B $-10 0
2012-07-01 Jul 2012 A $10 $10
B $-10 0
2012-08-01 Aug 2012 A $10 $10
B $-10 0
2013-06-01 Jun 2013 A $10 $10
B $-10 0
2013-07-01 Jul 2013 A $10 $10
B $-10 0
2013-08-01 Aug 2013 A $10 $10
B $-10 0
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test
test --now 2013-10-02 reg -p "from june to july 2014"
2013-06-01 Jun 2013 A $10 $10
B $-10 0
2013-07-01 Jul 2013 A $10 $10
B $-10 0
2013-08-01 Aug 2013 A $10 $10
B $-10 0
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test
test --now 2014-01-02 reg -p "from june to july 2014"
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test
test --now 2014-10-02 reg -p "from june to july 2014"
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test
test --now 2012-02-03 reg -p "from june 2012 to july 2014"
2012-06-01 Jun 2012 A $10 $10
B $-10 0
2012-07-01 Jul 2012 A $10 $10
B $-10 0
2012-08-01 Aug 2012 A $10 $10
B $-10 0
2013-06-01 Jun 2013 A $10 $10
B $-10 0
2013-07-01 Jul 2013 A $10 $10
B $-10 0
2013-08-01 Aug 2013 A $10 $10
B $-10 0
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test
test --now 2012-02-03 reg -p "from june 2013 to july 2014"
2013-06-01 Jun 2013 A $10 $10
B $-10 0
2013-07-01 Jul 2013 A $10 $10
B $-10 0
2013-08-01 Aug 2013 A $10 $10
B $-10 0
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test
test --now 2015-02-03 reg -p "from june 2013 to july 2014"
2013-06-01 Jun 2013 A $10 $10
B $-10 0
2013-07-01 Jul 2013 A $10 $10
B $-10 0
2013-08-01 Aug 2013 A $10 $10
B $-10 0
2014-06-01 Jun 2014 A $10 $10
B $-10 0
end test

View File

@ -0,0 +1,38 @@
; Test for: ./ledger -f doc/sample.dat -E bal liab' shows the Assets account
= /^Expenses:Books/
(Liabilities:Taxes) -0.10
~ Monthly
Assets:Bank:Checking $500.00
Income:Salary
2004/05/01 * Checking balance
Assets:Bank:Checking $1,000.00
Equity:Opening Balances
2004/05/01 * Investment balance
Assets:Brokerage 50 AAPL @ $30.00
Equity:Opening Balances
2004/05/14 * Pay day
Assets:Bank:Checking $500.00
Income:Salary
2004/05/27 Book Store
Expenses:Books $20.00
Liabilities:MasterCard
2004/05/27 (100) Credit card company
Liabilities:MasterCard $20.00
Assets:Bank:Checking
comment
test -E bal liabilities
$-2.00 Liabilities
0 MasterCard
$-2.00 Taxes
--------------------
$-2.00
end test

View File

@ -0,0 +1,9 @@
2015/01/15 * Grocery Store
Assets:Cash ¤ -5,00
Expenses:Food
comment
test -i /dev/null reg
15-Jan-15 Grocery Store Assets:Cash ¤ -5,00 ¤ -5,00
Expenses:Food ¤ 5,00 0
end test

View File

@ -0,0 +1,12 @@
2015/01/20 Payee
Assets:Cash ¤ 12,34
Expenses:Food
comment
test -F "»%(trim(' Trimmed '))«\n" reg expenses
»Trimmed«
end test
test -F "»%(trim('Trimmed'))«\n" reg expenses
»Trimmed«
end test

View File

@ -0,0 +1,16 @@
; Test that automated transactions are added to accounts soon enough
; for assertions to work.
= expr account =~ /^Assets/
(Foo) 1
2018-06-09 Something
Assets $100
Equity
2018-06-09 Assert amount added by automated transaction
[Foo] = $100
comment
test bal Foo
$100 Foo
end test

View File

@ -0,0 +1,17 @@
1994/09/02=1994/08/25 * Joe
Actif:Courant:BnpCc 126,00 F
Actif:Remboursement:Autre -126,00 F = 0,00 F
1994/10/20=1994/08/25 * (3551465) Bill
Actif:Remboursement:Autre 126,00 F
Actif:Courant:BnpCc
comment
test bal -> 1
__ERROR__
While parsing file "$FILE", line 3:
While parsing posting:
Actif:Remboursement:Autre -126,00 F = 0,00 F
^^^^^^
Error: Balance assertion off by 126,00 F (expected to see -126,00 F)
end test

View File

@ -0,0 +1,13 @@
2000/01/01 Pre-transaction balance
A $5.00 = $0.00
B
comment
test bal -> 1
__ERROR__
While parsing file "$FILE", line 2:
While parsing posting:
A $5.00 = $0.00
^^^^^
Error: Balance assertion off by $-5.00 (expected to see $5.00)
end test

View File

@ -0,0 +1,11 @@
2000/01/01 Post-transaction balance
A $5.00 = $5.00
B
comment
test bal
$5.00 A
$-5.00 B
--------------------
0
end test

View File

@ -0,0 +1,30 @@
2003/09/13 a payee ; sat
A $100.00
B
2003/09/14 a payee ; mon
A $100.00
B
2004/10/15 a payee ; fri
A $50.00
B
2004/10/19 a payee ; tue
A $50.00
B
;sun first day of month
comment
test reg -p "every 12 months from 2001/04/01"
03-Apr-01 - 04-Mar-31 A $200.00 $200.00
B $-200.00 0
04-Apr-01 - 05-Mar-31 A $100.00 $100.00
B $-100.00 0
end test
test reg -p 'every 12 months'
03-Sep-01 - 04-Aug-31 A $200.00 $200.00
B $-200.00 0
04-Sep-01 - 05-Aug-31 A $100.00 $100.00
B $-100.00 0
end test

View File

@ -0,0 +1,24 @@
2016-01-01 Employer
Me -5400s
Them 5400s
2016-01-01 Employer
Me -3600s
Them 3600s
2016-01-02 Employer
Me -1800s
Them 1800s
2016-01-02 Employer
Me -30s
Them 30s
comment
test reg --time-colon
16-Jan-01 Employer Me -1:30h -1:30h
Them 1:30h 0
16-Jan-01 Employer Me -1:00h -1:00h
Them 1:00h 0
16-Jan-02 Employer Me -30:0m -30:0m
Them 30:0m 0
16-Jan-02 Employer Me -30s -30s
Them 30s 0
end test

View File

@ -0,0 +1,13 @@
=
2000/01/01 Test
A $1.00
B
comment
test bal -> 1
__ERROR__
While parsing file "$FILE", line 1:
While parsing automated transaction:
> =
Error: Expected predicate after '='
end test

View File

@ -0,0 +1,18 @@
2000/01/01 Test
A $1.00
B
============
2000/01/02 Test
A $1.00
B
comment
test bal -> 1
__ERROR__
While parsing file "$FILE", line 5:
While parsing automated transaction:
> ============
Error: Expected predicate after '='
end test

View File

@ -0,0 +1,20 @@
2006/08/17 * Au Bon Bec
Dépense:Alimentation:Restaurant 100,00 €
Passif:Crédit:Banque
2006/08/20 * Retrait
Dépense:Liquide 60,00 €
Passif:Crédit:Banque -60,00 €
Passif:Crédit:Banque 60,00 € = -100,00 €
Actif:Courant:Cc -60,00 €
comment
test bal
-60,00 € Actif:Courant:Cc
160,00 € Dépense
100,00 € Alimentation:Restaurant
60,00 € Liquide
-100,00 € Passif:Crédit:Banque
--------------------
0
end test

View File

@ -0,0 +1,19 @@
2001/01/01 * Balance
Actif:Courant:Cc 10000,00 F = 10000,00 F
Equity
2002/01/11 * Passage à l'euro
Actif:Courant:Cc -10000,00 F = 0,00 F
Actif:Courant:Cc 1524,49 € = 1524,49 €
Revenu:Devise 10000,00 F
Revenu:Devise -1524,49 €
comment
test bal
1524,49 € Actif:Courant:Cc
-10000,00 F Equity
10000,00 F
-1524,49 € Revenu:Devise
--------------------
0
end test

View File

@ -0,0 +1,37 @@
2000/01/01 Multiple posts
A $5.00
B $7.20
C $-114.99
D
2000/01/02 Many assertions
A $2.00
A $3.00 = $10.00
B $0.80 = $8.00
C $-0.01 = $-115.00
B $1.00
C $1
C $4 = $-110
D
2000/01/03 Incremental
A $1.00 = $11.00
A $1.00 = $12.00
A $1.00 = $13.00
D
2000/01/04 Assignment
A $2
A = $25
D $-10
D $-2
comment
test bal
$25.00 A
$9.00 B
$-110.00 C
$76.00 D
--------------------
0
end test

View File

@ -0,0 +1,33 @@
2000/01/01 Multiple commodities
A $5.00
A 32 F
B $-12
C
2000/01/02 Assertions
A $1 = $6
A 1 F = 33 F
A $1 = $7
A 1 F = 34 F
B 3 F = 3 F
B $12 = $0
B 1 F = 4 F
C
2000/01/03 Assignments
A = $0
A -4 F = 30 F
B $-7 = $-7
B = 0 F
C $14
C 8 F
comment
test bal
30 F A
$-7.00 B
$7.00
-30 F C
--------------------
0
end test

View File

@ -0,0 +1,37 @@
2013/12/01 * Initial State
Crédit:Viseca:MasterCard P1 -618.50 CHF
Crédit:Viseca:MasterCard P2 -52.10 CHF
Equity:Opening Balances
2013/12/15 * Buy Some Chocolate
Dépenses:Nourriture 19.00 EUR ; #1
Crédit:Viseca:MasterCard P1
2013/12/15 * Buy Some Chocolate
Crédit:Viseca:MasterCard P1 18.00 EUR ; #2
Recettes:Erreurs
2013/12/23 * Facture Viseca
Crédit:Viseca:MasterCard P2 52.10 CHF = 0 ; #3
Crédit:Viseca:MasterCard P1 618.50 CHF = 0 CHF ; #4
Dépenses:Frais:Gestion Comptes 1.50 CHF
Crédit:Viseca -672.10 CHF
2014/01/03 * Facture Viseca
Crédit:Viseca 672.10 CHF = 0
Actif:Comptes:CP courant
comment
test bal
-672.10 CHF Actif:Comptes:CP courant
-1.00 EUR Crédit:Viseca
-1.00 EUR MasterCard P1
1.50 CHF
19.00 EUR Dépenses
1.50 CHF Frais:Gestion Comptes
19.00 EUR Nourriture
670.60 CHF Equity:Opening Balances
-18.00 EUR Recettes:Erreurs
--------------------
0
end test

View File

@ -0,0 +1,8 @@
--fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
comment
test reg -> 1
__ERROR__
While parsing file "$FILE", line 1:
Error: Illegal option --fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
end test

View File

@ -0,0 +1,10 @@
2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
comment
test reg -> 1
__ERROR__
While parsing file "$FILE", line 1:
While parsing transaction:
> 2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Error: Invalid date: 2000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
end test

View File

@ -0,0 +1,28 @@
@alias OLD1 = NEW1
2012-01-01 Something
OLD1 $10.00
Other
!alias OLD2 = NEW2
2012-01-01 Something
OLD2 $10.00
Other
account NEW3
alias OLD3
2012-01-01 Something
OLD3 $10.00
Other
comment
test bal
$10.00 NEW1
$10.00 NEW2
$10.00 NEW3
$-30.00 Other
--------------------
0
end test

View File

@ -0,0 +1,29 @@
Y2008
01/30 A
Bank 130
Income
02/01 B
Bank 140
Income
02/20 C
Bank 150
Income
03/01 D
Bank 160
Income
comment
test reg
08-Jan-30 A Bank 130 130
Income -130 0
08-Feb-01 B Bank 140 140
Income -140 0
08-Feb-20 C Bank 150 150
Income -150 0
08-Mar-01 D Bank 160 160
Income -160 0
end test

View File

@ -0,0 +1,19 @@
D 1000.00 GBP
;P 2011-01-01 EUR 0.8604 GBP
P 2011-02-01 EUR 0.8576 GBP
2011-01-31 * AdSense earnings
Assets:Receivable:AdSense 11.00 EUR
Income:AdSense
2011-02-28 * AdSense earnings
Assets:Receivable:AdSense 10.00 EUR
Income:AdSense
comment
test reg income:adse -X GBP -H
11-Jan-31 AdSense earnings Income:AdSense -11.00 EUR -11.00 EUR
11-Feb-28 Commodities revalued <Revalued> -9.43 GBP -9.43 GBP
11-Feb-28 AdSense earnings Income:AdSense -8.58 GBP -18.01 GBP
end test

View File

@ -0,0 +1,13 @@
2010-04-02 Opening balance
Assets:A 14.75 EUR
Assets:B 2.84 GBP
Equity:Opening balance
comment
test reg
10-Apr-02 Opening balance Assets:A 14.75 EUR 14.75 EUR
Assets:B 2.84 GBP 14.75 EUR
2.84 GBP
Equity:Opening balance -14.75 EUR 2.84 GBP
Equity:Opening balance -2.84 GBP 0
end test

View File

@ -0,0 +1,16 @@
; Test for: Confusing error message with ledger v3 with invalid input
2008/03/03
A (2 FOO @ 10.00 EUR) = 20.00 EUR
B
comment
test bal -> 1
__ERROR__
While parsing file "$FILE", line 4:
While parsing posting:
A (2 FOO @ 10.00 EUR) = 20.00 EUR
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Invalid char '@'
end test

View File

@ -0,0 +1,29 @@
comment
test period every 1000 years from 1 Sep 2011 to 30 May 2012 --now=2018-06-10
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 1000
TOK_YEARS: years
TOK_SINCE: since
TOK_INT: 1
TOK_A_MONTH: Sep
TOK_INT: 2011
TOK_UNTIL: until
TOK_INT: 30
TOK_A_MONTH: May
TOK_INT: 2012
END_REACHED: <EOF>
--- Before stabilization ---
range: from day 1 to day 30
duration: 1000 years
--- After stabilization ---
range: from day 1 to day 30
start: 18-Jan-01
finish: 18-Jan-30
duration: 1000 years
--- Sample dates in range (max. 20) ---
1: 18-Jan-01 -- 18-Jan-29
end test

View File

@ -0,0 +1,18 @@
tag Foo
assert value =~ /^Bar$/
2019/01/01 * Payee
;; Foo: Bar
Income:Foo $-1
Assets:Cash $1
2019/01/01 * Another Payee
Assets:Cash $-1
Expenses:Baz $1
comment
test bal
$1 Expenses:Baz
$-1 Income:Foo
--------------------
0
end test

View File

@ -0,0 +1,12 @@
P 2018-10-31 MultifundosPlus R$0
2017-05-03 * Test
Assets:A 1 AAA @ R$ 3000
Assets:B
comment
test reg assets:a -V --now 2018-12-31
17-May-03 Test Assets:A R$3000 R$3000
end test

View File

@ -0,0 +1,13 @@
2003/12/20 Organic Co-op
Expenses:Food:Groceries $ 37.50 ; ] [=2004/01/01]
Assets:Cash $-37.50
comment
test bal
$ -37.50 Assets:Cash
$ 37.50 Expenses:Food:Groceries
--------------------
0
end test

View File

@ -0,0 +1,6 @@
2017/3/17 deferred posting
<deferred posting>
comment
test reg
end test

View File

@ -0,0 +1,13 @@
2018-01-02 * Account name starting with semicolon
* ;A 10.00 EUR
B
comment
test reg -> 1
__ERROR__
While parsing file "$FILE", line 2:
While parsing posting:
* ;A 10.00 EUR
Error: Posting has no account
end test

View File

@ -0,0 +1,21 @@
2017-02-28 * Test
Assets:A 10.00 EUR
Assets:B -10.00 EUR
2017-03-30 * Test
Assets:A 10.00 EUR
Assets:B -10.00 EUR
2018-03-30 * Test
Assets:A 10.00 EUR
Assets:B -10.00 EUR
comment
test reg --input-date-format %F
17-Feb-28 Test Assets:A 10.00 EUR 10.00 EUR
Assets:B -10.00 EUR 0
17-Mar-30 Test Assets:A 10.00 EUR 10.00 EUR
Assets:B -10.00 EUR 0
18-Mar-30 Test Assets:A 10.00 EUR 10.00 EUR
Assets:B -10.00 EUR 0
end test

View File

@ -0,0 +1,22 @@
; Test for: The bal report does not honor -r (ledger bal simon
; would show all accounts, rather than just simon and the related
; account).
2011/10/26 trader joe's
simon $-50
alice $-50
expenses:food:groceries
comment
test bal -r simon
$-50 alice
$100 expenses:food:groceries
--------------------
$50
end test
test reg -r simon
11-Oct-26 trader joe's alice $-50 $-50
expense:food:groceries $100 $50
end test

View File

@ -0,0 +1,22 @@
= /Expenses:Transportation/ and not expr "has_tag(/NOTAX/)"
Expenses:Tax 0.2
$account -0.2
2020-05-06 * Test
Expenses:Transportation 200.00 EUR
Assets:Bank -200.00 EUR
2020-05-06 * Test
; :NOTAX:
Expenses:Transportation 300.00 EUR
Assets:Bank -300.00 EUR
comment
test bal
-500.00 EUR Assets:Bank
500.00 EUR Expenses
40.00 EUR Tax
460.00 EUR Transportation
--------------------
0
end test

View File

@ -0,0 +1,22 @@
= ^Expenses and expr "any(account =~ /^A:Assets/ and R)"
[A:Assets:Split] (amount / 2)
[B:Assets:Split] (-amount / 2)
= ^Expenses and expr "any(account =~ /^B:Assets/ and R)"
[B:Assets:Split] (amount / 2)
[A:Assets:Split] (-amount / 2)
2020-05-08 * Test
Expenses:Transportation 200.00 EUR
A:Assets:Checking
comment
test bal
-100.00 EUR A:Assets
-200.00 EUR Checking
100.00 EUR Split
-100.00 EUR B:Assets:Split
200.00 EUR Expenses:Transportation
--------------------
0
end test

View File

@ -0,0 +1,32 @@
2020-05-18 Test
Assets:foo 10.00 EUR
Assets:bar -10.00 EUR
comment
test bal
0 Assets
-10.00 EUR bar
10.00 EUR foo
--------------------
0
end test
test bal --invert
0 Assets
10.00 EUR bar
-10.00 EUR foo
--------------------
0
end test
test reg --format="%(account) %10(amount) %10(amount_expr) %10(total) %10(display_amount) %10(display_total)\n"
Assets:foo 10.00 EUR 10.00 EUR 10.00 EUR 10.00 EUR 10.00 EUR
Assets:bar -10.00 EUR -10.00 EUR 0 -10.00 EUR 0
end test
test reg --format="%(account) %10(amount) %10(amount_expr) %10(total) %10(display_amount) %10(display_total)\n" --invert
Assets:foo 10.00 EUR -10.00 EUR -10.00 EUR -10.00 EUR -10.00 EUR
Assets:bar -10.00 EUR 10.00 EUR 0 10.00 EUR 0
end test

View File

@ -0,0 +1,29 @@
2018/01/01 * Opening Balance
Assets:Checking $1000.00
Equity:Opening Balances -$1000.00
2018/01/01 * Budget
[Assets:Budget:Rent] $100.00
[Assets:Budget:Emergency] $200.00
[Assets:Checking] -$300.00
2018/01/01 * Budget
[Assets:Budget:Rent] = $100.00
[Assets:Budget:Emergency] = $400.00
[Assets:Bank] -$500.00
comment
test bal Assets -> 1
__ERROR__
While parsing file "$FILE", line 13:
While balancing transaction from "$FILE", lines 10-13:
> 2018/01/01 * Budget
> [Assets:Budget:Rent] = $100.00
> [Assets:Budget:Emergency] = $400.00
> [Assets:Bank] -$500.00
Unbalanced remainder is:
$-300.00
Amount to balance against:
$200.00
Error: Transaction does not balance
end test

View File

@ -0,0 +1,29 @@
2018/01/01 * Opening Balance
Assets:Checking $1000.00
Equity:Opening Balances -$1000.00
2018/01/01 * Budget
[Assets:Budget:Rent] $100.00
[Assets:Budget:Emergency] $200.00
[Assets:Checking] -$300.00
2018/01/01 * Budget
[Assets:Budget:Rent] $0 = $100.00
[Assets:Budget:Emergency] = $400.00
[Assets:Bank] -$500.00
comment
test bal Assets -> 1
__ERROR__
While parsing file "$FILE", line 13:
While balancing transaction from "$FILE", lines 10-13:
> 2018/01/01 * Budget
> [Assets:Budget:Rent] $0 = $100.00
> [Assets:Budget:Emergency] = $400.00
> [Assets:Bank] -$500.00
Unbalanced remainder is:
$-300.00
Amount to balance against:
$200.00
Error: Transaction does not balance
end test

View File

@ -0,0 +1,29 @@
2018/01/01 * Opening Balance
Assets:Checking $1000.00
Equity:Opening Balances -$1000.00
2018/01/01 * Budget
Assets:Budget:Rent $100.00
Assets:Budget:Emergency $200.00
Assets:Checking -$300.00
2018/01/01 * Budget
Assets:Budget:Rent = $100.00
Assets:Budget:Emergency = $400.00
Assets:Bank -$500.00
comment
test bal Assets -> 1
__ERROR__
While parsing file "$FILE", line 13:
While balancing transaction from "$FILE", lines 10-13:
> 2018/01/01 * Budget
> Assets:Budget:Rent = $100.00
> Assets:Budget:Emergency = $400.00
> Assets:Bank -$500.00
Unbalanced remainder is:
$-300.00
Amount to balance against:
$200.00
Error: Transaction does not balance
end test

View File

@ -0,0 +1,29 @@
2018/01/01 * Opening Balance
Assets:Checking $1000.00
Equity:Opening Balances -$1000.00
2018/01/01 * Budget
Assets:Budget:Rent $100.00
Assets:Budget:Emergency $200.00
Assets:Checking -$300.00
2018/01/01 * Budget
Assets:Budget:Rent $0
Assets:Budget:Emergency = $400.00
Assets:Bank -$500.00
comment
test bal Assets -> 1
__ERROR__
While parsing file "$FILE", line 13:
While balancing transaction from "$FILE", lines 10-13:
> 2018/01/01 * Budget
> Assets:Budget:Rent $0
> Assets:Budget:Emergency = $400.00
> Assets:Bank -$500.00
Unbalanced remainder is:
$-300.00
Amount to balance against:
$200.00
Error: Transaction does not balance
end test

View File

@ -0,0 +1,18 @@
2020-10-30 * Set up liability
Expenses:Test 310.56 EUR
Liabilities:Foo -310.56 EUR
2020-10-30 * Pay liability
Assets:Bank -416.30 AUD @ 0.746 EUR
Liabilities:Foo
2020-10-30 * Put another commodity into the account so the account is always displayed
Expenses:Test 10.00 GBP
Liabilities:Foo
comment
test bal Liabilities:Foo
-10.00 GBP Liabilities:Foo
end test

View File

@ -0,0 +1,15 @@
2021-01-02 Same commodity, different values
Assets -1 Stock {100 USD} [2021-01-01]
Assets 1 Stock {100 EUR} [2021-01-01]
Equity
comment
test bal --lots
1 Stock {EUR100} [2021/01/01]
-1 Stock {USD100} [2021/01/01] Assets
-1 Stock {EUR100} [2021/01/01]
1 Stock {USD100} [2021/01/01] Equity
--------------------
0
end test

View File

@ -0,0 +1,14 @@
2012/02/22 * Testing invalid amount
Assets:Cash $1,00.00
Equity:Opening Balances
comment
test bal -> 1
__ERROR__
While parsing file "$FILE", line 2:
While parsing posting:
Assets:Cash $1,00.00
^^^^^^^^
Error: Incorrect use of thousand-mark comma
end test

View File

@ -0,0 +1,26 @@
2009/01/01 sample
Assets:Super:ARF $1000.00
Assets:Super:CSS $1000.00
Assets:Super:CSS:Contributions $1000.00
Income:Opening Balances
2009/02/01 sample
Assets:Super:ARF $1000.00
Assets:Super:CSS $1000.00
Assets:Super:CSS:Contributions $1000.00
Income:Opening Balances
2009/03/01 sample
Assets:Super:ARF $1000.00
Assets:Super:CSS $1000.00
Assets:Super:CSS:Contributions $1000.00
Income:Opening Balances
comment
test equity assets
2009/03/01 Opening Balances
Assets:Super:ARF $3000.00
Assets:Super:CSS $3000.00
Assets:Super:CSS:Contributions $3000.00
Equity:Opening Balances $-9000.00
end test

View File

@ -0,0 +1,176 @@
D 1.200,40 €
1999/11/01 * Achat
Actif:SSB 125 STK
Actif:SSB -1672,42 $
1999/11/04 * Vente
Actif:SSB -125 STK
Dépense:SSB:Commissions 55,07 $
Actif:SSB 1821,54 $
2001/05/01 * Vente
Actif:SSEA -188,7974 STK @ 14,200 $
Dépense:SSEA:Commissions 19,60 $
Actif:SSEA 2661,32 $
2001/12/21 * Achat
Actif:LPG 7,34316 AMD @ 200,340 €
Actif:LPG -1471,13 €
2002/12/31 * Réinv. des dividendes
Actif:LPG 0,03032 AMD @ 135,060 €
Revenu:Dividende:AMD -4,10 €
2003/12/31 * Réinv. des dividendes
Actif:LPG 0,02356 AMD @ 147,830 €
Revenu:Dividende:AMD -3,48 €
2004/02/17 * Vente
Actif:LPG -7,39704 AMD @ 148,860 €
Actif:LPG 1101,12 €
2005/12/31 * Réinv. des dividendes
Actif:LPG 0,87704 LAPD @ 22,680 €
Revenu:Dividende:LAPD -19,89 €
2006/06/30 * Achat
Actif:CPE 54,7328 PM @ 33,200 €
Actif:CPE -1817,13 €
2006/06/30 * Achat
Actif:CPE 13,8913 PM @ 33,200 €
Actif:CPE -461,19 €
2007/04/01 Achat
Actif:SV 0,2087 CE @ 622,900 €
Actif:BC -130,00 €
2007/12/27 Vente
Actif:SV -0,2086 EA @ 183,800 €
Actif:SV 38,34 €
2008/01/01 Achat
Actif:SV 0,1757 CE @ 739,900 €
Actif:BC -130,00 €
2008/02/01 Achat
Actif:SV 3,1863 EA @ 163,200 €
Actif:BC -520,00 €
2008/05/01 Achat
Actif:SV 0,2599 CE @ 654,100 €
Actif:BC -170,00 €
2008/10/30 Vente
Actif:SV -0,0405 CD @ 155,800 €
Actif:SV 6,31 €
2008/12/31 Vente
Actif:SV -0,0357 MFE @ 259,100 €
Actif:SV 9,25 €
2009/06/29 Vente
Actif:SV -0,0786 CD @ 155,600 €
Actif:SV 12,23 €
2009/07/30 Vente
Actif:SV -0,0417 MFE @ 321,100 €
Actif:SV 13,39 €
2009/08/01 Achat
Actif:SV 1,0204 MFE @ 333,200 €
Actif:BC -340,00 €
2009/09/29 Vente
Actif:SV -0,0415 MFE @ 358,800 €
Actif:SV 14,89 €
comment
test print
1999/11/01 * Achat
Actif:SSB 125,0000 STK
Actif:SSB -1672,42 $
1999/11/04 * Vente
Actif:SSB -125,0000 STK
Dépense:SSB:Commissions 55,07 $
Actif:SSB 1821,54 $
2001/05/01 * Vente
Actif:SSEA -188,7974 STK @ 14,20 $
Dépense:SSEA:Commissions 19,60 $
Actif:SSEA 2661,32 $
2001/12/21 * Achat
Actif:LPG 7,34316 AMD @ 200,34 €
Actif:LPG -1.471,13 €
2002/12/31 * Réinv. des dividendes
Actif:LPG 0,03032 AMD @ 135,06 €
Revenu:Dividende:AMD -4,10 €
2003/12/31 * Réinv. des dividendes
Actif:LPG 0,02356 AMD @ 147,83 €
Revenu:Dividende:AMD -3,48 €
2004/02/17 * Vente
Actif:LPG -7,39704 AMD @ 148,86 €
Actif:LPG 1.101,12 €
2005/12/31 * Réinv. des dividendes
Actif:LPG 0,87704 LAPD @ 22,68 €
Revenu:Dividende:LAPD -19,89 €
2006/06/30 * Achat
Actif:CPE 54,7328 PM @ 33,20 €
Actif:CPE -1.817,13 €
2006/06/30 * Achat
Actif:CPE 13,8913 PM @ 33,20 €
Actif:CPE -461,19 €
2007/04/01 Achat
Actif:SV 0,2087 CE @ 622,90 €
Actif:BC -130,00 €
2007/12/27 Vente
Actif:SV -0,2086 EA @ 183,80 €
Actif:SV 38,34 €
2008/01/01 Achat
Actif:SV 0,1757 CE @ 739,90 €
Actif:BC -130,00 €
2008/02/01 Achat
Actif:SV 3,1863 EA @ 163,20 €
Actif:BC -520,00 €
2008/05/01 Achat
Actif:SV 0,2599 CE @ 654,10 €
Actif:BC -170,00 €
2008/10/30 Vente
Actif:SV -0,0405 CD @ 155,80 €
Actif:SV 6,31 €
2008/12/31 Vente
Actif:SV -0,0357 MFE @ 259,10 €
Actif:SV 9,25 €
2009/06/29 Vente
Actif:SV -0,0786 CD @ 155,60 €
Actif:SV 12,23 €
2009/07/30 Vente
Actif:SV -0,0417 MFE @ 321,10 €
Actif:SV 13,39 €
2009/08/01 Achat
Actif:SV 1,0204 MFE @ 333,20 €
Actif:BC -340,00 €
2009/09/29 Vente
Actif:SV -0,0415 MFE @ 358,80 €
Actif:SV 14,89 €
end test

View File

@ -0,0 +1,58 @@
; -*- ledger -*-
D 1000,00 PLN
N $
N h
N PLN
N zł
C 1,00 PLN = 1,00
2010-05-19 * ŁUKASZ STELMACH
Assets:Checking:Konto24 GBP 200,00 GBP @ 4,8799 PLN ; fikimiki
Assets:Checking:Konto<30 -975,98 PLN
2010-05-19 * ŁUKASZ STELMACH
Assets:Checking:Konto24 GBP 200,00 GBP @ 4,8799 PLN ; fikimiki
Assets:Checking:Konto<30 -975,98 PLN
2010-05-19 * ŁUKASZ STELMACH
Assets:Checking:Konto<30 -975,98 PLN @ 0,204922 GBP
Assets:Checking:Konto24 GBP 200,00 GBP ; fikimiki
2010-05-19 * ŁUKASZ STELMACH
Assets:Checking:Konto<30 -975,98 PLN @ 0,204922 GBP
Assets:Checking:Konto24 GBP 200,00 GBP ; fikimiki
2010-05-19 * ŁUKASZ STELMACH
Assets:Checking:Konto24 GBP 200,00 GBP @ 4,8799 PLN ; fikimiki
Assets:Checking:Konto<30 -975,98 PLN
2010-05-19 * ŁUKASZ STELMACH
Assets:Checking:Konto24 GBP 200,00 GBP @ 4,8799 PLN ; fikimiki
Assets:Checking:Konto<30 -975,98 PLN
comment
test reg
10-May-19 ŁUKASZ STELMACH As:Checkin:Konto24 GBP 200,00 GBP 200,00 GBP
Asse:Checking:Konto<30 -975.98 -975.98
200,00 GBP
10-May-19 ŁUKASZ STELMACH As:Checkin:Konto24 GBP 200,00 GBP -975.98
400,00 GBP
Asse:Checking:Konto<30 -975.98 -1951.96
400,00 GBP
10-May-19 ŁUKASZ STELMACH Asse:Checking:Konto<30 -975.98 -2927.94
400,00 GBP
As:Checkin:Konto24 GBP 200,00 GBP -2927.94
600,00 GBP
10-May-19 ŁUKASZ STELMACH Asse:Checking:Konto<30 -975.98 -3903.92
600,00 GBP
As:Checkin:Konto24 GBP 200,00 GBP -3903.92
800,00 GBP
10-May-19 ŁUKASZ STELMACH As:Checkin:Konto24 GBP 200,00 GBP -3903.92
1000,00 GBP
Asse:Checking:Konto<30 -975.98 -4879.9
1000,00 GBP
10-May-19 ŁUKASZ STELMACH As:Checkin:Konto24 GBP 200,00 GBP -4879.9
1200,00 GBP
Asse:Checking:Konto<30 -975.98 -5855.88
1200,00 GBP
end test

View File

@ -0,0 +1,13 @@
2021/4/1 Was Already Working
Expenses:Something (3 - 1)
Assets:Cash
2021/4/2 Now Fixed
Expenses:Something (3-1)
Assets:Cash
comment
test reg exp
21-Apr-01 Was Already Working Expenses:Something 2 2
21-Apr-02 Now Fixed Expenses:Something 2 4
end test

View File

@ -0,0 +1,13 @@
C 1 "" = 1 $
2021-01-01 Test
A $10
B
comment
test bal
10 A
-10 B
--------------------
0
end test

View File

@ -0,0 +1,9 @@
2021/1/2 Test
A $1.00
B
comment
test -p 'last %^@' bal -> 1
__ERROR__
Error: Invalid char '%'
end test

View File

@ -0,0 +1,12 @@
2021/1/2 Test
A $1.00
B
comment
test --limit 'date>=[2020/12/31' register A -> 1
__ERROR__
While parsing value expression:
(date>=[2020/12/31)&((account =~ /A/))
Error: Missing ']'
end test

View File

@ -0,0 +1,17 @@
P 2021-01-01 EUR 1.15 USD
2021-01-01 Test 1
A 100 USD
B
2021-01-01 Test 2
A 100 EUR
B
comment
test -X USD --sort display_amount reg
21-Jan-01 Test 2 B -115 USD -115 USD
21-Jan-01 Test 1 B -100 USD -215 USD
A 100 USD -115 USD
21-Jan-01 Test 2 A 115 USD 0
end test

View File

@ -0,0 +1,24 @@
2021/11/22 Entry
Assets:Foo 100 FOO (Note) {$43.44}
Income:Bar
2021/11/22 Entry
Assets:Foo 100 FOO (Misc) {$45.44} = 200 FOO
Income:Bar
2021/11/22 Entry
Assets:Foo $100
Income:Bar
2021/11/22 Balance Check
Assets:Foo 0 FOO = 200 FOO
comment
test reg
21-Nov-22 Entry Assets:Foo 100 FOO 100 FOO
Income:Bar -100 FOO 0
21-Nov-22 Entry Assets:Foo 100 FOO 100 FOO
Income:Bar -100 FOO 0
21-Nov-22 Entry Assets:Foo $100 $100
Income:Bar $-100 0
end test

View File

@ -0,0 +1,793 @@
/*
* Copyright (c) 2003-2012, John Wiegley. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of New Artisans LLC nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @defgroup math Mathematical objects
*/
/**
* @file amount.h
* @author John Wiegley
*
* @ingroup math
*
* @brief Basic type for handling commoditized math: amount_t
*
* An amount is the most basic numerical type in Ledger, and relies on
* commodity.h to represent commoditized amounts, which allows Ledger to
* handle mathematical expressions involving disparate commodities.
*
* Amounts can be of virtually infinite size and precision. When
* division or multiplication is performed, the precision is
* automatically expanded to include as many extra digits as necessary
* to avoid losing information.
*/
#ifndef _AMOUNT_H
#define _AMOUNT_H
#include "utils.h"
#include "times.h"
#include "flags.h"
namespace ledger {
class commodity_t;
struct annotation_t;
struct keep_details_t;
DECLARE_EXCEPTION(amount_error, std::runtime_error);
enum parse_flags_enum_t {
PARSE_DEFAULT = 0x00,
PARSE_PARTIAL = 0x01,
PARSE_SINGLE = 0x02,
PARSE_NO_MIGRATE = 0x04,
PARSE_NO_REDUCE = 0x08,
PARSE_NO_ASSIGN = 0x10,
PARSE_NO_ANNOT = 0x20,
PARSE_OP_CONTEXT = 0x40,
PARSE_SOFT_FAIL = 0x80
};
typedef basic_flags_t<parse_flags_enum_t, uint_least8_t> parse_flags_t;
/**
* @brief Encapsulate infinite-precision commoditized amounts
*
* Used to represent commoditized infinite-precision numbers, and
* uncommoditized, plain numbers. In the commoditized case, commodities
* keep track of how they are used, and are always displayed back to the
* user after the same fashion. For uncommoditized numbers, no display
* truncation is ever done. In both cases, internal precision is always
* kept to an excessive degree.
*/
class amount_t
: public ordered_field_operators<amount_t,
ordered_field_operators<amount_t, double,
ordered_field_operators<amount_t, unsigned long,
ordered_field_operators<amount_t, long> > > >
{
public:
/** Ready the amount subsystem for use.
@note Normally called by session_t::initialize(). */
static void initialize();
/** Shutdown the amount subsystem and free all resources.
@note Normally called by session_t::shutdown(). */
static void shutdown();
static bool is_initialized;
/** The amount's decimal precision. */
typedef uint_least16_t precision_t;
/** Number of places of precision by which values are extended to
avoid losing precision during division and multiplication. */
static const std::size_t extend_by_digits = 6U;
/** If amounts should be streamed using to_fullstring() rather than
to_string(), so that complete precision is always displayed no matter
what the precision of an individual commodity may be. */
static bool stream_fullstrings;
protected:
void _copy(const amount_t& amt);
void _dup();
void _clear();
void _release();
struct bigint_t;
bigint_t * quantity;
commodity_t * commodity_;
public:
/** @name Constructors
@{ */
/** Creates a value for which is_null() is true, and which has no
value or commodity. If used in a value expression it evaluates to
zero, and its commodity equals \c commodity_t::null_commodity. */
amount_t() : quantity(NULL), commodity_(NULL) {
TRACE_CTOR(amount_t, "");
}
/** Convert a double to an amount. As much precision as possible is
decoded from the binary floating point number. */
amount_t(const double val);
/** Convert an unsigned long to an amount. It's precision is zero. */
amount_t(const unsigned long val);
/** Convert a long to an amount. It's precision is zero, and the sign
is preserved. */
amount_t(const long val);
/** Parse a string as an (optionally commoditized) amount. If no
commodity is present, the resulting commodity is \c
commodity_t::null_commodity. The number may be of infinite
precision. */
explicit amount_t(const string& val) : quantity(NULL) {
parse(val);
TRACE_CTOR(amount_t, "const string&");
}
/** Parse a pointer to a C string as an (optionally commoditized)
amount. If no commodity is present, the resulting commodity is \c
commodity_t::null_commodity. The number may be of infinite
precision. */
explicit amount_t(const char * val) : quantity(NULL) {
assert(val);
parse(val);
TRACE_CTOR(amount_t, "const char *");
}
/*@}*/
/** Create an amount whose display precision is never truncated, even
if the amount uses a commodity (which normally causes "round on
streaming" to occur). This function is mostly used by debugging
code and unit tests. This is the proper way to specify \c
$100.005, where display of the extra digit precision is required.
If a regular constructor were used, the amount would stream as \c
$100.01, even though its internal value equals \c $100.005. */
static amount_t exact(const string& value);
/** Release the reference count held for the underlying \c
amount_t::bigint_t object. */
~amount_t() {
TRACE_DTOR(amount_t);
if (quantity)
_release();
}
/** @name Assignment and copy
@{*/
/** Copy an amount object. Copies are very efficient, using a
copy-on-write model. Until the copy is changed, it refers to the
same memory used by the original via reference counting. The \c
amount_t::bigint_t class in amount.cc maintains the reference. */
amount_t(const amount_t& amt) : quantity(NULL) {
if (amt.quantity)
_copy(amt);
else
commodity_ = NULL;
TRACE_CTOR(amount_t, "copy");
}
/** Copy an amount object, applying the given commodity annotation
details afterward. This is equivalent to doing a normal copy
(@see amount_t(const amount_t&)) and then calling
amount_t::annotate(). */
amount_t(const amount_t& amt, const annotation_t& details) : quantity(NULL) {
assert(amt.quantity);
_copy(amt);
annotate(details);
TRACE_CTOR(amount_t, "const amount_t&, const annotation_t&");
}
/** Assign an amount object. This is like copying if the amount was
null beforehand, otherwise the previous value's reference is must
be freed. */
amount_t& operator=(const amount_t& amt);
amount_t& operator=(const double val) {
return *this = amount_t(val);
}
amount_t& operator=(const unsigned long val) {
return *this = amount_t(val);
}
amount_t& operator=(const long val) {
return *this = amount_t(val);
}
/* Assign a string to an amount. This causes the contents of the
string to be parsed, look for a commoditized or uncommoditized
amount specifier. */
amount_t& operator=(const string& str) {
return *this = amount_t(str);
}
amount_t& operator=(const char * str) {
assert(str);
return *this = amount_t(str);
}
/*@}*/
/** @name Comparison
@{ */
/** Compare two amounts, returning a number less than zero if \p amt
is greater, exactly zero if they are equal, and greater than zero
if \p amt is less. This method is used to implement all of the
other comparison methods.*/
int compare(const amount_t& amt) const;
/** Test two amounts for equality. First the commodity pointers are
quickly tested, then the multi-precision values themselves must be
compared. */
bool operator==(const amount_t& amt) const;
template <typename T>
bool operator==(const T& val) const {
return compare(val) == 0;
}
template <typename T>
bool operator<(const T& amt) const {
return compare(amt) < 0;
}
template <typename T>
bool operator>(const T& amt) const {
return compare(amt) > 0;
}
/*@}*/
/** @name Binary arithmetic
*/
/*@{*/
amount_t& operator+=(const amount_t& amt);
amount_t& operator-=(const amount_t& amt);
amount_t& operator*=(const amount_t& amt) {
return multiply(amt);
}
amount_t& multiply(const amount_t& amt, bool ignore_commodity = false);
/** Divide two amounts while extending the precision to preserve the
accuracy of the result. For example, if \c 10 is divided by \c 3,
the result ends up having a precision of \link
amount_t::extend_by_digits \endlink place to avoid losing internal
resolution. */
amount_t& operator/=(const amount_t& amt);
/*@}*/
/** @name Unary arithmetic
@{ */
/** Return an amount's internal precision. To find the precision it
should be displayed at -- assuming it was not created using
amount_t::exact() -- use the following expression instead:
@code
amount.commodity().precision()
@endcode */
precision_t precision() const;
bool keep_precision() const;
void set_keep_precision(const bool keep = true) const;
precision_t display_precision() const;
/** Returns the negated value of an amount.
@see operator-()
*/
amount_t negated() const {
amount_t temp(*this);
temp.in_place_negate();
return temp;
}
void in_place_negate();
amount_t operator-() const {
return negated();
}
/** Returns the absolute value of an amount. Equivalent to:
@code
(x < * 0) ? - x : x
@endcode
*/
amount_t abs() const {
if (sign() < 0)
return negated();
return *this;
}
amount_t inverted() const {
amount_t temp(*this);
temp.in_place_invert();
return temp;
}
void in_place_invert();
/** Yields an amount whose display precision when output is truncated
to the display precision of its commodity. This is normally the
default state of an amount, but if one has become unrounded, this
sets the "keep precision" state back to false.
@see set_keep_precision */
amount_t rounded() const {
amount_t temp(*this);
temp.in_place_round();
return temp;
}
void in_place_round();
/** Yields an amount which has lost all of its extra precision, beyond what
the display precision of the commodity would have printed. */
amount_t truncated() const {
amount_t temp(*this);
temp.in_place_truncate();
return temp;
}
void in_place_truncate();
/** Yields an amount which has lost all of its extra precision, beyond what
the display precision of the commodity would have printed. */
amount_t floored() const {
amount_t temp(*this);
temp.in_place_floor();
return temp;
}
void in_place_floor();
/** Yields an amount which has lost all of its extra precision, beyond what
the display precision of the commodity would have printed. */
amount_t ceilinged() const {
amount_t temp(*this);
temp.in_place_ceiling();
return temp;
}
void in_place_ceiling();
/** Yields an amount whose display precision is never truncated, even
though its commodity normally displays only rounded values. */
amount_t unrounded() const {
amount_t temp(*this);
temp.in_place_unround();
return temp;
}
void in_place_unround();
/** reduces a value to its most basic commodity form, for amounts that
utilize "scaling commodities". For example, an amount of \c 1h
after reduction will be \c 3600s.
*/
amount_t reduced() const {
amount_t temp(*this);
temp.in_place_reduce();
return temp;
}
void in_place_reduce();
/** unreduce(), if used with a "scaling commodity", yields the most
compact form greater than one. That is, \c 3599s will unreduce to
\c 59.98m, while \c 3601 unreduces to \c 1h.
*/
amount_t unreduced() const {
amount_t temp(*this);
temp.in_place_unreduce();
return temp;
}
void in_place_unreduce();
/** Returns the historical value for an amount -- the default moment
returns the most recently known price -- based on the price history
for the given commodity (or determined automatically, if none is
provided). For example, if the amount were <tt>10 AAPL</tt>, and
on Apr 10, 2000 each share of \c AAPL was worth \c $10, then
calling value() for that moment in time would yield the amount \c
$100.00.
*/
optional<amount_t>
value(const datetime_t& moment = datetime_t(),
const commodity_t * in_terms_of = NULL) const;
optional<amount_t> price() const;
/*@}*/
/** @name Truth tests
*/
/*@{*/
/** Truth tests. An amount may be truth test in several ways:
sign() returns an integer less than, greater than, or equal to
zero depending on whether the amount is negative, zero, or
greater than zero. Note that this function tests the actual
value of the amount -- using its internal precision -- and not
the display value. To test its display value, use:
`round().sign()'.
is_nonzero(), or operator bool, returns true if an amount's
display value is not zero.
is_zero() returns true if an amount's display value is zero.
Thus, $0.0001 is considered zero if the current display precision
for dollars is two decimal places.
is_realzero() returns true if an amount's actual value is zero.
Thus, $0.0001 is never considered realzero.
is_null() returns true if an amount has no value and no
commodity. This only occurs if an uninitialized amount has never
been assigned a value.
*/
int sign() const;
operator bool() const {
return is_nonzero();
}
bool is_nonzero() const {
return ! is_zero();
}
bool is_zero() const;
bool is_realzero() const {
return sign() == 0;
}
bool is_null() const {
if (! quantity) {
assert(! commodity_);
return true;
}
return false;
}
/*@}*/
/** @name Conversion
*/
/*@{*/
/** Conversion methods. An amount may be converted to the same types
it can be constructed from -- with the exception of unsigned
long. Implicit conversions are not allowed in C++ (though they
are in Python), rather the following conversion methods must be
called explicitly:
to_double([bool]) returns an amount as a double. If the optional
boolean argument is true (the default), an exception is thrown if
the conversion would lose information.
to_long([bool]) returns an amount as a long integer. If the
optional boolean argument is true (the default), an exception is
thrown if the conversion would lose information.
fits_in_long() returns true if to_long() would not lose
precision.
to_string() returns an amount'ss "display value" as a string --
after rounding the value according to the commodity's default
precision. It is equivalent to: `round().to_fullstring()'.
to_fullstring() returns an amount's "internal value" as a string,
without any rounding.
quantity_string() returns an amount's "display value", but
without any commodity. Note that this is different from
`number().to_string()', because in that case the commodity has
been stripped and the full, internal precision of the amount
would be displayed.
*/
double to_double() const;
long to_long() const;
bool fits_in_long() const;
operator string() const {
return to_string();
}
string to_string() const;
string to_fullstring() const;
string quantity_string() const;
/*@}*/
/** @name Commodity methods
*/
/*@{*/
/** The following methods relate to an
amount's commodity:
commodity() returns an amount's commodity. If the amount has no
commodity, the value returned is the `null_commodity'.
has_commodity() returns true if the amount has a commodity.
set_commodity(commodity_t) sets an amount's commodity to the
given value. Note that this merely sets the current amount to
that commodity, it does not "observe" the amount for possible
changes in the maximum display precision of the commodity, the
way that `parse' does.
clear_commodity() sets an amount's commodity to null, such that
has_commodity() afterwards returns false.
number() returns a commodity-less version of an amount. This is
useful for accessing just the numeric portion of an amount.
*/
commodity_t * commodity_ptr() const;
commodity_t& commodity() const {
return *commodity_ptr();
}
bool has_commodity() const;
void set_commodity(commodity_t& comm) {
if (! quantity)
*this = 0L;
commodity_ = &comm;
}
amount_t with_commodity(const commodity_t& comm) const {
if (commodity_ == &comm) {
return *this;
} else {
amount_t tmp(*this);
tmp.set_commodity(const_cast<commodity_t&>(comm));
return tmp;
}
}
void clear_commodity() {
commodity_ = NULL;
}
amount_t number() const {
if (! has_commodity())
return *this;
amount_t temp(*this);
temp.clear_commodity();
return temp;
}
/*@}*/
/** @name Commodity annotations
*/
/*@{*/
/** An amount's commodity may be annotated with special details, such as the
price it was purchased for, when it was acquired, or an arbitrary note,
identifying perhaps the lot number of an item.
annotate_commodity(amount_t price, [datetime_t date, string tag])
sets the annotations for the current amount's commodity. Only
the price argument is required, although it can be passed as
`none' if no price is desired.
commodity_annotated() returns true if an amount's commodity has
any annotation details associated with it.
annotation_details() returns all of the details of an annotated
commodity's annotations. The structure returns will evaluate as
boolean false if there are no details.
strip_annotations() returns an amount whose commodity's annotations have
been stripped.
*/
void annotate(const annotation_t& details);
bool has_annotation() const;
annotation_t& annotation();
const annotation_t& annotation() const {
return const_cast<amount_t&>(*this).annotation();
}
/** If the lot price is considered whenever working with commoditized
values.
Let's say a user adds two values of the following form:
@code
10 AAPL + 10 AAPL {$20}
@endcode
This expression adds ten shares of Apple stock with another ten
shares that were purchased for \c $20 a share. If \c keep_price
is false, the result of this expression is an amount equal to
<tt>20 AAPL</tt>. If \c keep_price is \c true the expression
yields an exception for adding amounts with different commodities.
In that case, a \link balance_t \endlink object must be used to
store the combined sum. */
amount_t strip_annotations(const keep_details_t& what_to_keep) const;
/*@}*/
/** @name Parsing
*/
/*@{*/
/** The `flags' argument of both parsing may be one or more of the
following:
PARSE_NO_MIGRATE means to not pay attention to the way an
amount is used. Ordinarily, if an amount were $100.001, for
example, it would cause the default display precision for $ to be
"widened" to three decimal places. If PARSE_NO_MIGRATE is
used, the commodity's default display precision is not changed.
PARSE_NO_REDUCE means not to call in_place_reduce() on the
resulting amount after it is parsed.
These parsing methods observe the amounts they parse (unless
PARSE_NO_MIGRATE is true), and set the display details of
the corresponding commodity accordingly. This way, amounts do
not require commodities to be pre-defined in any way, but merely
displays them back to the user in the same fashion as it saw them
used.
There is also a static convenience method called
`parse_conversion' which can be used to define a relationship
between scaling commodity values. For example, Ledger uses it to
define the relationships among various time values:
@code
amount_t::parse_conversion("1.0m", "60s"); // a minute is 60 seconds
amount_t::parse_conversion("1.0h", "60m"); // an hour is 60 minutes
@endcode
The method parse() is used to parse an amount from an input stream
or a string. A global operator>>() is also defined which simply
calls parse on the input stream. The parse() method has two forms:
parse(istream, flags_t) parses an amount from the given input
stream.
parse(string, flags_t) parses an amount from the given string.
parse(string, flags_t) also parses an amount from a string.
*/
bool parse(std::istream& in,
const parse_flags_t& flags = PARSE_DEFAULT);
bool parse(const string& str,
const parse_flags_t& flags = PARSE_DEFAULT) {
std::istringstream stream(str);
bool result = parse(stream, flags);
return result;
}
static void parse_conversion(const string& larger_str,
const string& smaller_str);
/*@}*/
/** @name Printing
*/
/*@{*/
/** An amount may be output to a stream using the `print' method. There is
also a global operator<< defined which simply calls print for an amount
on the given stream. There is one form of the print method, which takes
one required argument and two arguments with default values:
print(ostream, bool omit_commodity = false, bool full_precision = false)
prints an amounts to the given output stream, using its commodity's
default display characteristics. If `omit_commodity' is true, the
commodity will not be displayed, only the amount (although the
commodity's display precision is still used). If `full_precision' is
true, the full internal precision of the amount is displayed, regardless
of its commodity's display precision.
*/
#define AMOUNT_PRINT_NO_FLAGS 0x00
#define AMOUNT_PRINT_RIGHT_JUSTIFY 0x01
#define AMOUNT_PRINT_COLORIZE 0x02
#define AMOUNT_PRINT_NO_COMPUTED_ANNOTATIONS 0x04
#define AMOUNT_PRINT_ELIDE_COMMODITY_QUOTES 0x08
void print(std::ostream& out,
const uint_least8_t flags = AMOUNT_PRINT_NO_FLAGS) const;
/*@}*/
/** @name Debugging
*/
/*@{*/
/** There are two methods defined to help with debugging:
dump(ostream) dumps an amount to an output stream. There is
little different from print(), it simply surrounds the display
value with a marker, for example "AMOUNT($1.00)". This code is
used by other dumping code elsewhere in Ledger.
valid() returns true if an amount is valid. This ensures that if
an amount has a commodity, it has a valid value pointer, for
example, even if that pointer simply points to a zero value.
*/
void dump(std::ostream& out) const {
out << "AMOUNT(";
print(out);
out << ")";
}
bool valid() const;
#if HAVE_BOOST_SERIALIZATION
private:
/** Serialization. */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /* version */);
#endif // HAVE_BOOST_SERIALIZATION
/*@}*/
};
inline amount_t amount_t::exact(const string& value) {
amount_t temp;
temp.parse(value, PARSE_NO_MIGRATE);
return temp;
}
inline string amount_t::to_string() const {
std::ostringstream bufstream;
print(bufstream);
return bufstream.str();
}
inline string amount_t::to_fullstring() const {
std::ostringstream bufstream;
unrounded().print(bufstream);
return bufstream.str();
}
inline string amount_t::quantity_string() const {
std::ostringstream bufstream;
number().print(bufstream);
return bufstream.str();
}
inline std::ostream& operator<<(std::ostream& out, const amount_t& amt) {
if (amount_t::stream_fullstrings)
amt.unrounded().print(out);
else
amt.print(out);
return out;
}
inline std::istream& operator>>(std::istream& in, amount_t& amt) {
amt.parse(in);
return in;
}
void put_amount(property_tree::ptree& pt, const amount_t& amt,
bool wrap = true, bool commodity_details = false);
} // namespace ledger
#endif // _AMOUNT_H

View File

@ -0,0 +1,62 @@
comment
test -f test/regress/25A099C9.dat reg -> 29
__ERROR__
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 1:
Error: Directive '/*' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 32:
Error: Directive '/**' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 36:
Error: Directive '/**' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 66:
Error: No quantity specified for amount
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 69:
Error: Unexpected whitespace at beginning of line
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 78:
Error: Directive '};' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 82:
Error: Directive '/**' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 93:
Error: Unexpected whitespace at beginning of line
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 97:
Error: Directive '{' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 98:
Error: Directive 'public:' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 120:
Error: Directive 'protected:' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 131:
Error: Directive 'public:' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 711:
Error: Unexpected whitespace at beginning of line
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 740:
Error: Directive 'private:' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 749:
Error: Unexpected whitespace at beginning of line
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 750:
Error: Directive '};' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 752:
Error: Invalid date/time: line amount_t amoun
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 756:
Error: Directive '}' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 758:
Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 762:
Error: Directive '}' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 764:
Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 768:
Error: Directive '}' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 770:
Error: Invalid date/time: line string amount_
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 774:
Error: Directive '}' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 776:
Error: Invalid date/time: line std::ostream&
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 782:
Error: Directive '}' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 783:
Error: Invalid date/time: line std::istream&
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 786:
Error: Directive '}' requires an argument
While parsing file "$sourcepath/test/regress/25A099C9.dat", line 789:
Error: Unexpected whitespace at beginning of line
end test

View File

@ -0,0 +1,14 @@
2012-01-01 * Buy AAA
A 1 AAA @ 1.00 EUR
B -1.00 EUR
2012-02-01 * Buy AAA
A 1 AAA @ 2.00 EUR
B -2.00 EUR
comment
test --anon pricedb --format "%(date) %(amount)\n"
2012/01/01 1.00 A
2012/02/01 2.00 A
end test

View File

@ -0,0 +1,20 @@
D 1,000.00 USD
2007-12-31 * Start of year / Opening balances.
Account1 1000 EUR @ 1.6 USD
Account2 -1000 EUR @ 1.5 USD
comment
test bal -> 1
__ERROR__
While parsing file "$FILE", line 5:
While balancing transaction from "$FILE", lines 3-5:
> 2007-12-31 * Start of year / Opening balances.
> Account1 1000 EUR @ 1.6 USD
> Account2 -1000 EUR @ 1.5 USD
Unbalanced remainder is:
100.00 USD
Amount to balance against:
1,600.00 USD
Error: Transaction does not balance
end test

View File

@ -0,0 +1,28 @@
;budgets care about start dates
~ every 14 days from 2010/02/23
Expenses:Bills:Housecleaning $85.00
Assets:Bank:Checking
;before Sun aug 01 2010
;now is Mon jun 21 2010
;a Tuesday?
;
comment
test reg --budget --now=2010/06/13
10-Feb-23 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Feb-23 Budget transaction Assets:Bank:Checking $85.00 0
10-Mar-09 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Mar-09 Budget transaction Assets:Bank:Checking $85.00 0
10-Mar-23 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Mar-23 Budget transaction Assets:Bank:Checking $85.00 0
10-Apr-06 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Apr-06 Budget transaction Assets:Bank:Checking $85.00 0
10-Apr-20 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Apr-20 Budget transaction Assets:Bank:Checking $85.00 0
10-May-04 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-May-04 Budget transaction Assets:Bank:Checking $85.00 0
10-May-18 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-May-18 Budget transaction Assets:Bank:Checking $85.00 0
10-Jun-01 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Jun-01 Budget transaction Assets:Bank:Checking $85.00 0
end test

View File

@ -0,0 +1,30 @@
;budgets care about start dates
~ every 2 weeks from 2010/02/23
Expenses:Bills:Housecleaning $85.00
Assets:Bank:Checking
;before Sun aug 01 2010
;now is Mon jun 21 2010
;a Tuesday?
;
comment
test reg --budget --now=2010/06/13
10-Feb-23 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Feb-23 Budget transaction Assets:Bank:Checking $85.00 0
10-Feb-28 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Feb-28 Budget transaction Assets:Bank:Checking $85.00 0
10-Mar-14 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Mar-14 Budget transaction Assets:Bank:Checking $85.00 0
10-Mar-28 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Mar-28 Budget transaction Assets:Bank:Checking $85.00 0
10-Apr-11 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Apr-11 Budget transaction Assets:Bank:Checking $85.00 0
10-Apr-25 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Apr-25 Budget transaction Assets:Bank:Checking $85.00 0
10-May-09 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-May-09 Budget transaction Assets:Bank:Checking $85.00 0
10-May-23 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-May-23 Budget transaction Assets:Bank:Checking $85.00 0
10-Jun-06 Budget transaction Ex:Bills:Housecleaning $-85.00 $-85.00
10-Jun-06 Budget transaction Assets:Bank:Checking $85.00 0
end test

View File

@ -0,0 +1,18 @@
;does not care about start date
~ every 14 days from 2010/02/23
Expenses:Bills:Housecleaning $85.00
Assets:Bank:Checking
;before Sun aug 01 2010
;now is Mon jun 21 2010
;a Tuesday?
;forecasts period start is now first forecast transaction is now + 1 'tomorrow'
comment
test reg --forecast 'date <[2010/08/01]' --now=2010/06/13
10-Jun-27 Forecast transaction Ex:Bills:Housecleaning $85.00 $85.00
10-Jun-27 Forecast transaction Assets:Bank:Checking $-85.00 0
10-Jul-11 Forecast transaction Ex:Bills:Housecleaning $85.00 $85.00
10-Jul-11 Forecast transaction Assets:Bank:Checking $-85.00 0
10-Jul-25 Forecast transaction Ex:Bills:Housecleaning $85.00 $85.00
10-Jul-25 Forecast transaction Assets:Bank:Checking $-85.00 0
end test

View File

@ -0,0 +1,17 @@
;Tuesday
~ every 2 weeks from 2010/02/23
Expenses:Bills:Housecleaning $85.00
Assets:Bank:Checking
;before Sun aug 01 2010
;now is Mon jun 21 2010
;a Sunday
comment
test reg --forecast 'date <[2010/08/01]' --now=2010/06/21
10-Jun-27 Forecast transaction Ex:Bills:Housecleaning $85.00 $85.00
10-Jun-27 Forecast transaction Assets:Bank:Checking $-85.00 0
10-Jul-11 Forecast transaction Ex:Bills:Housecleaning $85.00 $85.00
10-Jul-11 Forecast transaction Assets:Bank:Checking $-85.00 0
10-Jul-25 Forecast transaction Ex:Bills:Housecleaning $85.00 $85.00
10-Jul-25 Forecast transaction Assets:Bank:Checking $-85.00 0
end test

View File

@ -0,0 +1,444 @@
;period days should not be aligned
comment
test period 'every 14 days from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 14
TOK_DAYS: days
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 14 days
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 14 days
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Oct-16
2: 11-Oct-17 -- 11-Oct-30
3: 11-Oct-31 -- 11-Nov-13
4: 11-Nov-14 -- 11-Nov-27
5: 11-Nov-28 -- 11-Dec-11
6: 11-Dec-12 -- 11-Dec-25
7: 11-Dec-26 -- 12-Jan-08
8: 12-Jan-09 -- 12-Jan-22
9: 12-Jan-23 -- 12-Feb-05
10: 12-Feb-06 -- 12-Feb-19
11: 12-Feb-20 -- 12-Mar-04
12: 12-Mar-05 -- 12-Mar-18
13: 12-Mar-19 -- 12-Apr-01
14: 12-Apr-02 -- 12-Apr-15
15: 12-Apr-16 -- 12-Apr-29
16: 12-Apr-30 -- 12-May-13
17: 12-May-14 -- 12-May-27
18: 12-May-28 -- 12-Jun-10
19: 12-Jun-11 -- 12-Jun-24
20: 12-Jun-25 -- 12-Jul-08
end test
;ensure weeks behave as before
test period 'every 1 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 1
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 1 week
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 1 week
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Oct-08
2: 11-Oct-09 -- 11-Oct-15
3: 11-Oct-16 -- 11-Oct-22
4: 11-Oct-23 -- 11-Oct-29
5: 11-Oct-30 -- 11-Nov-05
6: 11-Nov-06 -- 11-Nov-12
7: 11-Nov-13 -- 11-Nov-19
8: 11-Nov-20 -- 11-Nov-26
9: 11-Nov-27 -- 11-Dec-03
10: 11-Dec-04 -- 11-Dec-10
11: 11-Dec-11 -- 11-Dec-17
12: 11-Dec-18 -- 11-Dec-24
13: 11-Dec-25 -- 11-Dec-31
14: 12-Jan-01 -- 12-Jan-07
15: 12-Jan-08 -- 12-Jan-14
16: 12-Jan-15 -- 12-Jan-21
17: 12-Jan-22 -- 12-Jan-28
18: 12-Jan-29 -- 12-Feb-04
19: 12-Feb-05 -- 12-Feb-11
20: 12-Feb-12 -- 12-Feb-18
end test
test period 'every 2 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 2
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 2 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 2 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Oct-08
2: 11-Oct-09 -- 11-Oct-22
3: 11-Oct-23 -- 11-Nov-05
4: 11-Nov-06 -- 11-Nov-19
5: 11-Nov-20 -- 11-Dec-03
6: 11-Dec-04 -- 11-Dec-17
7: 11-Dec-18 -- 11-Dec-31
8: 12-Jan-01 -- 12-Jan-14
9: 12-Jan-15 -- 12-Jan-28
10: 12-Jan-29 -- 12-Feb-11
11: 12-Feb-12 -- 12-Feb-25
12: 12-Feb-26 -- 12-Mar-10
13: 12-Mar-11 -- 12-Mar-24
14: 12-Mar-25 -- 12-Apr-07
15: 12-Apr-08 -- 12-Apr-21
16: 12-Apr-22 -- 12-May-05
17: 12-May-06 -- 12-May-19
18: 12-May-20 -- 12-Jun-02
19: 12-Jun-03 -- 12-Jun-16
20: 12-Jun-17 -- 12-Jun-30
end test
test period 'every 3 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 3
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 3 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 3 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Oct-22
2: 11-Oct-23 -- 11-Nov-12
3: 11-Nov-13 -- 11-Dec-03
4: 11-Dec-04 -- 11-Dec-24
5: 11-Dec-25 -- 12-Jan-14
6: 12-Jan-15 -- 12-Feb-04
7: 12-Feb-05 -- 12-Feb-25
8: 12-Feb-26 -- 12-Mar-17
9: 12-Mar-18 -- 12-Apr-07
10: 12-Apr-08 -- 12-Apr-28
11: 12-Apr-29 -- 12-May-19
12: 12-May-20 -- 12-Jun-09
13: 12-Jun-10 -- 12-Jun-30
14: 12-Jul-01 -- 12-Jul-21
15: 12-Jul-22 -- 12-Aug-11
16: 12-Aug-12 -- 12-Sep-01
17: 12-Sep-02 -- 12-Sep-22
18: 12-Sep-23 -- 12-Oct-13
19: 12-Oct-14 -- 12-Nov-03
20: 12-Nov-04 -- 12-Nov-24
end test
test period 'every 4 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 4
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 4 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 4 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Oct-22
2: 11-Oct-23 -- 11-Nov-19
3: 11-Nov-20 -- 11-Dec-17
4: 11-Dec-18 -- 12-Jan-14
5: 12-Jan-15 -- 12-Feb-11
6: 12-Feb-12 -- 12-Mar-10
7: 12-Mar-11 -- 12-Apr-07
8: 12-Apr-08 -- 12-May-05
9: 12-May-06 -- 12-Jun-02
10: 12-Jun-03 -- 12-Jun-30
11: 12-Jul-01 -- 12-Jul-28
12: 12-Jul-29 -- 12-Aug-25
13: 12-Aug-26 -- 12-Sep-22
14: 12-Sep-23 -- 12-Oct-20
15: 12-Oct-21 -- 12-Nov-17
16: 12-Nov-18 -- 12-Dec-15
17: 12-Dec-16 -- 13-Jan-12
18: 13-Jan-13 -- 13-Feb-09
19: 13-Feb-10 -- 13-Mar-09
20: 13-Mar-10 -- 13-Apr-06
end test
test period 'every 5 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 5
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 5 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 5 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Oct-22
2: 11-Oct-23 -- 11-Nov-26
3: 11-Nov-27 -- 11-Dec-31
4: 12-Jan-01 -- 12-Feb-04
5: 12-Feb-05 -- 12-Mar-10
6: 12-Mar-11 -- 12-Apr-14
7: 12-Apr-15 -- 12-May-19
8: 12-May-20 -- 12-Jun-23
9: 12-Jun-24 -- 12-Jul-28
10: 12-Jul-29 -- 12-Sep-01
11: 12-Sep-02 -- 12-Oct-06
12: 12-Oct-07 -- 12-Nov-10
13: 12-Nov-11 -- 12-Dec-15
14: 12-Dec-16 -- 13-Jan-19
15: 13-Jan-20 -- 13-Feb-23
16: 13-Feb-24 -- 13-Mar-30
17: 13-Mar-31 -- 13-May-04
18: 13-May-05 -- 13-Jun-08
19: 13-Jun-09 -- 13-Jul-13
20: 13-Jul-14 -- 13-Aug-17
end test
test period 'every 6 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 6
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 6 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 6 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Oct-22
2: 11-Oct-23 -- 11-Dec-03
3: 11-Dec-04 -- 12-Jan-14
4: 12-Jan-15 -- 12-Feb-25
5: 12-Feb-26 -- 12-Apr-07
6: 12-Apr-08 -- 12-May-19
7: 12-May-20 -- 12-Jun-30
8: 12-Jul-01 -- 12-Aug-11
9: 12-Aug-12 -- 12-Sep-22
10: 12-Sep-23 -- 12-Nov-03
11: 12-Nov-04 -- 12-Dec-15
12: 12-Dec-16 -- 13-Jan-26
13: 13-Jan-27 -- 13-Mar-09
14: 13-Mar-10 -- 13-Apr-20
15: 13-Apr-21 -- 13-Jun-01
16: 13-Jun-02 -- 13-Jul-13
17: 13-Jul-14 -- 13-Aug-24
18: 13-Aug-25 -- 13-Oct-05
19: 13-Oct-06 -- 13-Nov-16
20: 13-Nov-17 -- 13-Dec-28
end test
test period 'every 7 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 7
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 7 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 7 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Nov-12
2: 11-Nov-13 -- 11-Dec-31
3: 12-Jan-01 -- 12-Feb-18
4: 12-Feb-19 -- 12-Apr-07
5: 12-Apr-08 -- 12-May-26
6: 12-May-27 -- 12-Jul-14
7: 12-Jul-15 -- 12-Sep-01
8: 12-Sep-02 -- 12-Oct-20
9: 12-Oct-21 -- 12-Dec-08
10: 12-Dec-09 -- 13-Jan-26
11: 13-Jan-27 -- 13-Mar-16
12: 13-Mar-17 -- 13-May-04
13: 13-May-05 -- 13-Jun-22
14: 13-Jun-23 -- 13-Aug-10
15: 13-Aug-11 -- 13-Sep-28
16: 13-Sep-29 -- 13-Nov-16
17: 13-Nov-17 -- 14-Jan-04
18: 14-Jan-05 -- 14-Feb-22
19: 14-Feb-23 -- 14-Apr-12
20: 14-Apr-13 -- 14-May-31
end test
test period 'every 8 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 8
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 8 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 8 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Nov-19
2: 11-Nov-20 -- 12-Jan-14
3: 12-Jan-15 -- 12-Mar-10
4: 12-Mar-11 -- 12-May-05
5: 12-May-06 -- 12-Jun-30
6: 12-Jul-01 -- 12-Aug-25
7: 12-Aug-26 -- 12-Oct-20
8: 12-Oct-21 -- 12-Dec-15
9: 12-Dec-16 -- 13-Feb-09
10: 13-Feb-10 -- 13-Apr-06
11: 13-Apr-07 -- 13-Jun-01
12: 13-Jun-02 -- 13-Jul-27
13: 13-Jul-28 -- 13-Sep-21
14: 13-Sep-22 -- 13-Nov-16
15: 13-Nov-17 -- 14-Jan-11
16: 14-Jan-12 -- 14-Mar-08
17: 14-Mar-09 -- 14-May-03
18: 14-May-04 -- 14-Jun-28
19: 14-Jun-29 -- 14-Aug-23
20: 14-Aug-24 -- 14-Oct-18
end test
test period 'every 9 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 9
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 9 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 9 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Nov-12
2: 11-Nov-13 -- 12-Jan-14
3: 12-Jan-15 -- 12-Mar-17
4: 12-Mar-18 -- 12-May-19
5: 12-May-20 -- 12-Jul-21
6: 12-Jul-22 -- 12-Sep-22
7: 12-Sep-23 -- 12-Nov-24
8: 12-Nov-25 -- 13-Jan-26
9: 13-Jan-27 -- 13-Mar-30
10: 13-Mar-31 -- 13-Jun-01
11: 13-Jun-02 -- 13-Aug-03
12: 13-Aug-04 -- 13-Oct-05
13: 13-Oct-06 -- 13-Dec-07
14: 13-Dec-08 -- 14-Feb-08
15: 14-Feb-09 -- 14-Apr-12
16: 14-Apr-13 -- 14-Jun-14
17: 14-Jun-15 -- 14-Aug-16
18: 14-Aug-17 -- 14-Oct-18
19: 14-Oct-19 -- 14-Dec-20
20: 14-Dec-21 -- 15-Feb-21
end test
test period 'every 10 weeks from 2011/10/03'
--- Period expression tokens ---
TOK_EVERY: every
TOK_INT: 10
TOK_WEEKS: weeks
TOK_SINCE: since
TOK_DATE: year 2011 month Oct day 3
END_REACHED: <EOF>
--- Before stabilization ---
range: from year 2011 month Oct day 3
duration: 10 weeks
--- After stabilization ---
range: from year 2011 month Oct day 3
start: 11-Oct-03
duration: 10 weeks
--- Sample dates in range (max. 20) ---
1: 11-Oct-03 -- 11-Oct-22
2: 11-Oct-23 -- 11-Dec-31
3: 12-Jan-01 -- 12-Mar-10
4: 12-Mar-11 -- 12-May-19
5: 12-May-20 -- 12-Jul-28
6: 12-Jul-29 -- 12-Oct-06
7: 12-Oct-07 -- 12-Dec-15
8: 12-Dec-16 -- 13-Feb-23
9: 13-Feb-24 -- 13-May-04
10: 13-May-05 -- 13-Jul-13
11: 13-Jul-14 -- 13-Sep-21
12: 13-Sep-22 -- 13-Nov-30
13: 13-Dec-01 -- 14-Feb-08
14: 14-Feb-09 -- 14-Apr-19
15: 14-Apr-20 -- 14-Jun-28
16: 14-Jun-29 -- 14-Sep-06
17: 14-Sep-07 -- 14-Nov-15
18: 14-Nov-16 -- 15-Jan-24
19: 15-Jan-25 -- 15-Apr-04
20: 15-Apr-05 -- 15-Jun-13
end test

View File

@ -0,0 +1,8 @@
2004/05/27 Book Store
Expenses:Books 20 BOOK @ $10
Liabilities:MasterCard $-200.00
comment
test bal --sort total --flat -X '$' not '(Income|Liabilities)'
$200.00 Expenses:Books
end test

View File

@ -0,0 +1,37 @@
2009-01-01 * Jan 09
Assets:Current 100.00 EUR
Income:Salary
2009-02-01 * Feb 09
Assets:Current 100.00 EUR
Income:Salary
2009-03-01 * Mar 09
Assets:Current 100.00 EUR
Income:Salary
2010-01-01 * Jan 10
Assets:Current 100.00 EUR
Income:Salary
2010-02-01 * Feb 10
Assets:Current 100.00 EUR
Income:Salary
comment
test reg -p "until Feb 2009"
09-Jan-01 Jan 09 Assets:Current 100.00 EUR 100.00 EUR
Income:Salary -100.00 EUR 0
end test
test reg -p "until February 2009"
09-Jan-01 Jan 09 Assets:Current 100.00 EUR 100.00 EUR
Income:Salary -100.00 EUR 0
end test
test reg -p "in Feb 2009"
09-Feb-01 Feb 09 Assets:Current 100.00 EUR 100.00 EUR
Income:Salary -100.00 EUR 0
end test

View File

@ -0,0 +1,30 @@
--input-date-format %Y:%m:%d
D 1000.00 GBP
2014:05:12 * Test
Assets:Investments 100 AA {2.00 GBP} [2014:01:01] @@ 200.00 GBP
Equity:Opening balance
comment
test bal Assets:Investments --lots --date-format %Y.%m.%d
100 AA {2.00 GBP} [2014.01.01] Assets:Investments
end test
test bal Assets:Investments --lots --date-format %Y/%m/%d
100 AA {2.00 GBP} [2014/01/01] Assets:Investments
end test
test bal Assets:Investments --lots --date-format %Y:%m:%d
100 AA {2.00 GBP} [2014:01:01] Assets:Investments
end test
test bal Assets:Investments --lots --date-format %Y-%m-%d
100 AA {2.00 GBP} [2014-01-01] Assets:Investments
end test
test bal Assets:Investments --lots --date-format %y-%b-%d
100 AA {2.00 GBP} [14-Jan-01] Assets:Investments
end test

View File

@ -0,0 +1,24 @@
; Test for: --sort d not working with -p
2009-01-01 Opening Balances
Assets:Checking 100.00 EUR
Equity:Opening Balances
2009-03-01 Test
Expenses:Phone 10.00 EUR
Assets:Checking
2009-02-01 Test
Expenses:Phone 10.00 EUR
Assets:Checking
comment
test --sort d -p "until 2010" reg
09-Jan-01 Opening Balances Assets:Checking 100.00 EUR 100.00 EUR
Equit:Opening Balances -100.00 EUR 0
09-Feb-01 Test Expenses:Phone 10.00 EUR 10.00 EUR
Assets:Checking -10.00 EUR 0
09-Mar-01 Test Expenses:Phone 10.00 EUR 10.00 EUR
Assets:Checking -10.00 EUR 0
end test

View File

@ -0,0 +1,12 @@
i 2007/03/01 23:00:00 A
o 2007/03/02 01:00:00
i 2007/03/11 23:00:00 B
o 2007/03/12 01:00:00
comment
test bal
2.00h A
2.00h B
--------------------
4.00h
end test

View File

@ -0,0 +1,75 @@
N $
P 2010/09/28 20:43:24 E $3.700
P 2010/09/28 20:43:25 A $5.230
P 2010/09/28 20:43:26 D $34.020
P 2010/09/28 20:43:27 C $12.370
P 2010/09/28 20:43:28 F $39.700
P 2010/09/28 20:43:29 B $39.430
P 2010/09/29 13:50:15 E $3.720
P 2010/09/29 13:50:15 A $5.240
P 2010/09/29 13:50:17 D $33.920
P 2010/09/29 13:50:18 C $12.310 P 2010/09/29 13:50:18 F $39.670
P 2010/09/29 13:50:19 B $39.830
2010/04/04 * Opening Balance
Assets:Sub1 100 A @ $0.01
Equity:Opening Balances
2010/04/04 * Opening Balance
Assets:Sub1 100 B @ $32.27
Equity:Opening Balances
2010/04/04 * Opening Balance
Assets:Sub1 100 C @ $11.30
Equity:Opening Balances
2010/04/04 * Opening Balance
Assets:Sub1 100 D @ $20.30
Equity:Opening Balances
2010/04/04 * Opening Balance
Assets:Sub1:Leftovers $6.79
Equity:Opening Balances
2010/04/04 * Opening Balance
Assets:Sub1 11 D
Equity:Opening Balances
2010/04/04 * Opening Balance
Assets:Sub1 100 E @ $2.97
Equity:Opening Balances
2010/05/18=2010/05/21 * FOO
Assets:Sub1 200 F @ $27.190
Expenses:Qux $29.95
Assets:Sub2
2010/07/02 * BAR
Income:D -$169.65
Assets:Sub2 $32.50
Assets:Sub1 6 D @ $22.64
Assets:Sub1:Leftovers
comment
test bal -X \$ sub1
$18026.74 Assets:Sub1
$8.10 Leftovers
--------------------
$18026.74
end test
test reg -X \$ sub1 --now=2012/03/14
10-Apr-04 Opening Balance Assets:Sub1 $1.00 $1.00
10-Apr-04 Opening Balance Assets:Sub1 $3227.00 $3228.00
10-Apr-04 Opening Balance Assets:Sub1 $1130.00 $4358.00
10-Apr-04 Opening Balance Assets:Sub1 $2030.00 $6388.00
10-Apr-04 Opening Balance Assets:Sub1:Leftovers $6.79 $6394.79
10-Apr-04 Opening Balance Assets:Sub1 $223.30 $6618.09
10-Apr-04 Opening Balance Assets:Sub1 $297.00 $6915.09
10-May-18 FOO Assets:Sub1 $5438.00 $12353.09
10-Jul-02 Commodities revalued <Revalued> $259.74 $12612.83
10-Jul-02 BAR Assets:Sub1 $135.84 $12748.67
Assets:Sub1:Leftovers $1.31 $12749.98
10-Sep-29 Commodities revalued <Revalued> $5251.46 $18001.44
12-Mar-14 Commodities revalued <Revalued> $25.30 $18026.74
end test

View File

@ -0,0 +1,26 @@
P 2008/01/01 $ €1
2008/01/11 LIAT
Expenses:Travel:Airfare $40.00
Liabilities:MasterCard
2008/02/05 CTX
Expenses:Travel:Auto €240.38
Liabilities:MasterCard
comment
test bal --exchange=€
€280.38 Expenses:Travel
€40.00 Airfare
€240.38 Auto
€-280.38 Liabilities:MasterCard
--------------------
0
end test
test bal --exchange=€ --percent
100.00% Expenses:Travel
14.27% Airfare
85.73% Auto
100.00% Liabilities:MasterCard
end test

View File

@ -0,0 +1,12 @@
2008/01/01 one
test:a 1
test:b
comment
test bal
0 test
1 a
-1 b
--------------------
0
end test

View File

@ -0,0 +1,93 @@
2008/01/11 LIAT
Expenses:Travel:Airfare 40,00 €
Liabilities:MasterCard
2008/01/14 cheaptickets.com
Expenses:Travel:Airfare 182,19 €
Liabilities:MasterCard
2008/02/05 CTX
Expenses:Travel:Auto 240,38 €
Liabilities:MasterCard
2008/02/05 UNITED
Expenses:Travel:Airfare 238,80 €
Liabilities:MasterCard
2008/02/05 UNITED
Expenses:Travel:Airfare 238,80 €
Liabilities:MasterCard
2008/02/22 BUDGET RENT-A-CAR
Expenses:Travel:Auto 40,59 €
Liabilities:MasterCard
2008/03/16 IBERIA
Expenses:Travel:Airfare 1231,60 €
Liabilities:MasterCard
2008/03/16 IBERIA
Expenses:Travel:Airfare 1231,60 €
Liabilities:MasterCard
2008/04/03 AMERICAN
Expenses:Travel:Airfare 155,86 €
Liabilities:MasterCard
2008/04/03 AMERICAN
Expenses:Travel:Airfare 155,86 €
Liabilities:MasterCard
2008/04/30 UNITED
Expenses:Travel:Airfare 437,21 €
Liabilities:MasterCard
2008/04/30 UNITED
Expenses:Travel:Airfare 437,21 €
Liabilities:MasterCard
2008/08/08 BCIS I-131 FILING FEE-
Expenses:Travel:Passport 170,00 €
Liabilities:MasterCard
2008/09/06 AMERICAN
Expenses:Travel:Airfare 912,60 €
Liabilities:MasterCard
2008/09/06 AMERICAN
Expenses:Travel:Airfare 912,60 €
Liabilities:MasterCard
2008/09/22 AGNT FEE
Expenses:Travel:Airfare 70,00 €
Liabilities:MasterCard
2008/09/22 DELTA
Expenses:Travel:Airfare 806,20 €
Liabilities:MasterCard
2008/09/22 DELTA
Expenses:Travel:Airfare 806,20 €
Liabilities:MasterCard
2008/09/22 LIAT 1974 LIMITED
Expenses:Travel:Airfare 418,34 €
Liabilities:MasterCard
2008/12/26 U.S. Department of State
Expenses:Travel:Passport 127,00 €
Assets:Checking
2008/12/26 U.S. Department of State
Expenses:Travel:Passport 127,00 €
Assets:Checking
comment
test --decimal-comma --percent balance
100.00% Assets:Checking
100.00% Expenses:Travel
92.15% Airfare
3.13% Auto
4.72% Passport
100.00% Liabilities:MasterCard
end test

View File

@ -0,0 +1,10 @@
15.03.2006 Exxon
Expenses:Auto:Gas 10,00 €
Liabilities:MasterCard -10,00 €
test --input-date-format '%d.%m.%Y' reg
06-Mar-15 Exxon Expenses:Auto:Gas 10,00 € 10,00 €
Liabilities:MasterCard -10,00 € 0
end test

View File

@ -0,0 +1,17 @@
--input-date-format %d.%m
Y2010
03.01 * Foo
A 10.00 EUR
B
05.02 * Bar
A 20.00 EUR
B
test reg A
10-Jan-03 Foo A 10.00 EUR 10.00 EUR
10-Feb-05 Bar A 20.00 EUR 30.00 EUR
end test

View File

@ -0,0 +1,4 @@
2012-03-17 Payee
Expenses:Food $20
Assets:Cash

View File

@ -0,0 +1,6 @@
from __future__ import print_function
import ledger
for post in ledger.read_journal("test/regress/4D9288AE.dat").query("^expenses:"):
print(post.cost)

View File

@ -0,0 +1,4 @@
comment
test python test/regress/4D9288AE.py
None
end test

View File

@ -0,0 +1,5 @@
comment
test cleared --file test/input/parsing.dat --cleared-format "%-30(account) %15(get_at(total_expr, 0)) %15(get_at(total_expr, 1))\n%/"
Assets $30 0
Income $-30 0
end test

View File

@ -0,0 +1,30 @@
D $1,000.00
; payroll taxes
= /^Payroll/
Liabilities:Taxes:CFICA 0.062
Liabilities:Taxes:CMED 0.0145
$account:EFICA -0.062
$account:EMED -0.0145
; Hourly rates for each employee, as commodity prices.
P 2010/01/01 EONE $15.00
; Payroll transactions
2010/05/18 Payroll from May 2nd to May 15th for Employee1
Assets:Checking 20 EONE
Payroll:Employee1
comment
test bal -V
$300.00 Assets:Checking
$-22.95 Liabilities:Taxes
$-18.60 CFICA
$-4.35 CMED
$-277.05 Payroll:Employee1
$18.60 EFICA
$4.35 EMED
--------------------
0
end test

View File

@ -0,0 +1,27 @@
2018/01/01 * Opening Balance
Assets:Checking $100.00
Equity:Opening Balances
2018/01/01 * Budget
[Assets:Checking] -$100.00
[Assets:Budget:Food:Groceries] $20.00
[Assets:Budget:Food:Restaurants] $80.00
2018/01/02 * Assertion
[Assets:Checking] = $0.00
2018/01/02 * Assertion
Assets:Checking = $100.00
comment
test bal Assets
$100.00 Assets:Budget:Food
$20.00 Groceries
$80.00 Restaurants
--------------------
$100.00
end test
test bal Assets -R
$100.00 Assets:Checking
end test

View File

@ -0,0 +1,23 @@
2018/01/01 * Opening Balance
Assets:Checking $100.00
Equity:Opening Balances
2018/01/01 * Budget
[Assets:Checking] -$100.00
[Assets:Budget:Food:Groceries] $20.00
[Assets:Budget:Food:Restaurants] $80.00
2018/01/02 * Buy Groceries
[Assets:Budget:Food:Groceries] -$20 = $0
[Assets:Checking] $20
Assets:Checking -$20 = $80
Expenses:Food:Groceries $20
comment
test bal Assets
$80.00 Assets:Budget:Food:Restaurants
end test
test bal Assets -R
$80.00 Assets:Checking
end test

View File

@ -0,0 +1,25 @@
2018/01/01 * Opening Balance
Assets:Checking $100.00
Equity:Opening Balances
2018/01/01 * Budget
[Assets:Checking] -$100.00
[Assets:Budget:Food:Groceries] $20.00
[Assets:Budget:Food:Restaurants] $80.00
2018/01/02 * Budget Groceries
[Assets:Budget:Food:Groceries] -$20 = $0
[Assets:Checking] $20
2018/01/02 * Buy Groceries
Assets:Checking -$20 = $80
Expenses:Food:Groceries $20
comment
test bal Assets
$80.00 Assets:Budget:Food:Restaurants
end test
test bal Assets -R
$80.00 Assets:Checking
end test

View File

@ -0,0 +1,33 @@
2018/01/01 * Opening Balance
Assets:Checking $100.00
Equity:Opening Balances
2018/01/01 * Budget
[Assets:Checking] = 0
[Assets:Budget:Food:Groceries] $20.00
[Assets:Budget:Food:Restaurants] $80.00
2018/01/02 * Groceries
Assets:Checking = $80.00
Expenses:Groceries
comment
test bal
$80.00 Assets
$100.00 Budget:Food
$20.00 Groceries
$80.00 Restaurants
$-20.00 Checking
$-100.00 Equity:Opening Balances
$20.00 Expenses:Groceries
--------------------
0
end test
test bal -R
$80.00 Assets:Checking
$-100.00 Equity:Opening Balances
$20.00 Expenses:Groceries
--------------------
0
end test

View File

@ -0,0 +1,74 @@
; this file contains spaces after the payee and tag values. Ledger
; should ignore the trailing spaces for the purposes of determining
; unique values
;
; bug 584 and 550 reported trailing spaces being considered
; significant in payee and tag values.
;
; running
; ledger -f test/spaces.dat payees
; yielded two distinct payees, because utils.h/next_element() didn't
; handle a single space followed by a null correctly.
;
; running
; ledger -f test/spaces.dat reg --group-by "tag('test')"
; yielded four groups.
2011/11/28 * test
; no space after payee or tag value
Expenses:misc $1 ; test: spaces
Assets:checking
2011/11/28 * test
; single space after payee and tag value
Expenses:misc $2 ; test: spaces
Assets:checking
2011/11/28 test
; two spaces after payee and tag value
Expenses:misc $4 ; test: spaces
Assets:checking
2011/11/28 test
; three spaces after payee and tag value
Expenses:misc $8 ; test: spaces
Assets:checking
2011/11/28 testcommodity
; COM commodity has no space after
Expenses:misc 1 COM
Assets:checking
2011/11/28 testcommodity
; COM commodity has one space after
Expenses:misc 1 COM
Assets:checking
2011/11/28 testcommodity
; COM commodity has two spaces after
Expenses:misc 1 COM
Assets:checking
2011/11/28 testcommodity
; COM commodity has three spaces after
Expenses:misc 1 COM
Assets:checking
comment
test payees
test
testcommodity
end test
test reg --group-by "tag('test')"
spaces
11-Nov-28 test Expenses:misc $1 $1
11-Nov-28 test Expenses:misc $2 $3
11-Nov-28 test Expenses:misc $4 $7
11-Nov-28 test Expenses:misc $8 $15
end test
test commodities
$
COM
end test

View File

@ -0,0 +1,21 @@
# Test for missing arguments
apply account
apply tag
apply fixed
apply rate
apply year
comment
test -f - bal -> 5
__ERROR__
While parsing file "", line 2:
Error: Directive 'apply account' requires an argument
While parsing file "", line 3:
Error: Directive 'apply tag' requires an argument
While parsing file "", line 4:
Error: Directive 'apply fixed' requires an argument
While parsing file "", line 5:
Error: Directive 'apply rate' requires an argument
While parsing file "", line 6:
Error: Directive 'apply year' requires an argument
end test

View File

@ -0,0 +1,25 @@
2008/01/01 * previous balances
liabilities:credit cards:discover 4462 $-1094.38
equity:opening balances
2008/01/18 * DISCOVER FEES
liabilities:credit cards:discover 4462:interest $-36.59
assets:bank:wells fargo:checking
2008/01/18 * DISCOVER FEES
liabilities:credit cards:discover 4462:fee $-39
liabilities:credit cards:discover 4462:interest $-28.17
assets:bank:wells fargo:checking
2008/03/01 * discover card payment
liabilities:credit cards:discover 4462 $1198.14
assets:bank:wells fargo:checking
comment
test bal discover
0 liabilities:credit cards:discover 4462
$-39.00 fee
$-64.76 interest
--------------------
0
end test

View File

@ -0,0 +1,18 @@
D 1000.00 USD
2010-01-07 * Put money in
Assets:A -20.00 EUR
Equity:Opening balances
2010-01-11 * Purchase
Assets:A 20.00 EUR @@ 25.00 USD
Expenses:B
comment
test bal
20.00 EUR Equity:Opening balances
-25.00 USD Expenses:B
--------------------
20.00 EUR
-25.00 USD
end test

Some files were not shown because too many files have changed in this diff Show More