From fc3a71bc46cc2748fc4c5737de9f6ceba878e574 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 29 Mar 2018 16:36:31 +0100 Subject: [PATCH] budget: more tests --- tests/budget/budget.test | 125 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/tests/budget/budget.test b/tests/budget/budget.test index dba99773d..4a6caec1a 100644 --- a/tests/budget/budget.test +++ b/tests/budget/budget.test @@ -103,3 +103,128 @@ Balance changes in 2016/12/01-2016/12/03: expenses:leisure || 0 [ 0% of $15] $5 [ 33% of $15] 0 [ 0% of $15] -----------------------++--------------------------------------------------------------------------------------- || $-15, £10 $-21.0, 20 CAD 0 + +< +~ daily + (a) 10 + +~weekly + (b) 100 + +~weekly + (c) 1000 + +2018/1/1 + (a) 1 + (b) 1 + (c) 1 + +2018/1/3 + (a) 1 + (b) 1 + (c) 1 + +# 4. --budget uses only periodic transactions of the specified interval. +# No interval - same as a regular balance report. +$ hledger -f- bal --budget + 2 a + 2 b + 2 c +-------------------- + 6 + +# 5. With -D it selects the daily budget. +# The budget is unbounded, so extends through the report period. +$ hledger -f- bal --budget -D +Balance changes in 2018/01/01-2018/01/03: + + || 2018/01/01 2018/01/02 2018/01/03 +===++============================================================================== + a || 1 [ 10% of 10] 0 [ 0% of 10] 1 [ 10% of 10] + b || 1 0 1 + c || 1 0 1 +---++------------------------------------------------------------------------------ + || 3 0 3 + +# 6. And with -W it selects the weekly budget, defined by all weekly periodic transactions. +$ hledger -f- bal --budget -W +Balance changes in 2018/01/01w01: + + || 2018/01/01w01 +===++========================== + a || 2 + b || 2 [ 2% of 100] + c || 2 [ 0% of 1000] +---++-------------------------- + || 6 + +# 7. A bounded two day budget. The end date is exclusive as usual. +< +~ daily from 2018/1/2 to 2018/1/4 + (a) 1 + +2018/1/1 + (a) 1 + (b) 1 + +2018/1/2 + (a) 1 + (b) 1 + +2018/1/3 + (a) 1 + (b) 1 + +2018/1/4 + (a) 1 + (b) 1 + +$ hledger -f- bal --budget -D +Balance changes in 2018/01/01-2018/01/04: + + || 2018/01/01 2018/01/02 2018/01/03 2018/01/04 +================++======================================================================================================== + :b || 1 1 1 1 + a || 1 1 [ 100% of 1] 1 [ 100% of 1] 1 +----------------++-------------------------------------------------------------------------------------------------------- + || 2 2 2 2 + +# 8. Multiple bounded budgets. +< +~ daily from 2018/1/1 to 2018/1/3 + (a) 1 + +~ daily from 2018/1/3 to 2018/1/5 + (a) 10 + +2018/1/1 + (a) 1 + +2018/1/2 + (a) 1 + +2018/1/3 + (a) 1 + +2018/1/4 + (a) 1 + +$ hledger -f- bal --budget -D +Balance changes in 2018/01/01-2018/01/04: + + || 2018/01/01 2018/01/02 2018/01/03 2018/01/04 +===++======================================================================================================== + a || 1 [ 100% of 1] 1 [ 100% of 1] 1 [ 10% of 10] 1 [ 10% of 10] +---++-------------------------------------------------------------------------------------------------------- + || 1 1 1 1 + +# 9. A "from A to B" budget should not be included in a report beginning on B. +$ hledger -f- bal --budget -D -b 2018/1/3 +Balance changes in 2018/01/03-2018/01/04: + + || 2018/01/03 2018/01/04 +===++==================================================== + a || 1 [ 10% of 10] 1 [ 10% of 10] +---++---------------------------------------------------- + || 1 1 +