fix: balance: Balance reports should consider date: queries when calculating
report span with --date2. (#1745)
This commit is contained in:
parent
41bde20095
commit
7597e525a3
@ -479,7 +479,7 @@ queryTermDateSpan _ = Nothing
|
||||
queryDateSpan :: Bool -> Query -> DateSpan
|
||||
queryDateSpan secondary (Or qs) = spansUnion $ map (queryDateSpan secondary) qs
|
||||
queryDateSpan secondary (And qs) = spansIntersect $ map (queryDateSpan secondary) qs
|
||||
queryDateSpan False (Date span) = span
|
||||
queryDateSpan _ (Date span) = span
|
||||
queryDateSpan True (Date2 span) = span
|
||||
queryDateSpan _ _ = nulldatespan
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
hledger -f - balance -p 'in 2009' --date2 -N
|
||||
<<<
|
||||
<
|
||||
2009/1/1 x
|
||||
a 1
|
||||
b
|
||||
@ -7,7 +6,23 @@ hledger -f - balance -p 'in 2009' --date2 -N
|
||||
2009/1/1=2010/1/1 x
|
||||
a 10
|
||||
b
|
||||
>>>
|
||||
|
||||
# 1. --date2 ignores postings with secondary dates outside the range
|
||||
$ hledger -f - balance -p 'in 2009' --date2 -N
|
||||
1 a
|
||||
-1 b
|
||||
>>>=0
|
||||
|
||||
# 2. Above but with date: queries
|
||||
$ hledger -f - balance date:2009 --date2 -N
|
||||
1 a
|
||||
-1 b
|
||||
|
||||
# 3. --date2 sees postings with secondary dates inside the range
|
||||
$ hledger -f - balance -p 'in 2010' --date2 -N
|
||||
10 a
|
||||
-10 b
|
||||
|
||||
# 4. Above but with date: queries
|
||||
$ hledger -f - balance date:2010 --date2 -N
|
||||
10 a
|
||||
-10 b
|
||||
|
||||
@ -28,16 +28,20 @@ hledger -f- register -p 2014/1/2 --date2
|
||||
2014-01-02 (a) 1 1
|
||||
>>>=0
|
||||
|
||||
# 3. --date2 causes date: to match the secondary date
|
||||
# 3. --date2 causes date: to match the secondary date (or the primary date, if there is no secondary)
|
||||
hledger -f- register date:2014/1/2 --date2
|
||||
<<<
|
||||
2014/1/1=1/2
|
||||
(a) 1
|
||||
|
||||
2014/1/3
|
||||
2014/1/2
|
||||
(b) 1
|
||||
|
||||
2014/1/2=1/3
|
||||
(C) 1
|
||||
>>>
|
||||
2014-01-02 (a) 1 1
|
||||
2014-01-02 (b) 1 2
|
||||
>>>=0
|
||||
|
||||
# 4. date2: matches the secondary date (but does not necessarily display it)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user