From 6948b05db64dad052856c6ff0023c4affe8e24c4 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 19 Nov 2020 15:15:04 -0800 Subject: [PATCH] ;bal: budget: add tests clarifying a surprising behaviour --- hledger/test/balance/budget.test | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/hledger/test/balance/budget.test b/hledger/test/balance/budget.test index a9fe0b0d9..4d6376ac8 100644 --- a/hledger/test/balance/budget.test +++ b/hledger/test/balance/budget.test @@ -556,3 +556,41 @@ $ hledger bal -f- --budget -TA not:income -O csv "expenses:bills:c","","$50","","$50","","$50" "expenses:bills:f","$10","0","$10","0","$10","0" "Total:","$80","$370","$80","$370","$80","$370" + +# 28. You might expect this to show a budget goal in jan, feb, mar. +# But by the usual report date logic, which picks the oldest and newest +# transaction date (1/15 and 3/15) as start and end date by default, +# and since "monthly" generates transactions on the 1st, +# the january budget goal transaction is excluded. +< +~ monthly in 2020 + (expenses:food) $500 + +2020-01-15 + expenses:food $400 + assets:checking + +2020-03-15 + expenses:food $600 + assets:checking + +$ hledger -f- bal --budget -M +Budget performance in 2020Q1: + + || Jan Feb Mar +===============++============================================= + || $-400 0 $-600 + expenses:food || $400 0 [0% of $500] $600 [120% of $500] +---------------++--------------------------------------------- + || 0 0 [0% of $500] 0 [ 0% of $500] + +# 29. Specifying the report period works around it. +$ hledger -f- bal --budget -M date:2020q1 +Budget performance in 2020Q1: + + || Jan Feb Mar +===============++=========================================================== + || $-400 0 $-600 + expenses:food || $400 [80% of $500] 0 [0% of $500] $600 [120% of $500] +---------------++----------------------------------------------------------- + || 0 [ 0% of $500] 0 [0% of $500] 0 [ 0% of $500]