fix: Fill totals with correct amount of zeroes for empty reports
This commit is contained in:
parent
f1bd46fd57
commit
09e158d31e
@ -374,7 +374,7 @@ generateMultiBalanceReport rspec@ReportSpec{_rsReportOpts=ropts} j priceoracle u
|
||||
$ buildReportRows ropts displaynames matrix
|
||||
|
||||
-- Calculate column totals
|
||||
totalsrow = dbg5 "totalsrow" $ calculateTotalsRow ropts rows
|
||||
totalsrow = dbg5 "totalsrow" $ calculateTotalsRow ropts rows $ length colps
|
||||
|
||||
-- Sorted report rows.
|
||||
sortedrows = dbg5 "sortedrows" $ sortRows ropts j rows
|
||||
@ -501,8 +501,8 @@ sortRows ropts j
|
||||
-- | Build the report totals row.
|
||||
--
|
||||
-- Calculate the column totals. These are always the sum of column amounts.
|
||||
calculateTotalsRow :: ReportOpts -> [MultiBalanceReportRow] -> PeriodicReportRow () MixedAmount
|
||||
calculateTotalsRow ropts rows =
|
||||
calculateTotalsRow :: ReportOpts -> [MultiBalanceReportRow] -> Int -> PeriodicReportRow () MixedAmount
|
||||
calculateTotalsRow ropts rows colcount =
|
||||
PeriodicReportRow () coltotals grandtotal grandaverage
|
||||
where
|
||||
isTopRow row = flat_ ropts || not (any (`HM.member` rowMap) parents)
|
||||
@ -511,7 +511,9 @@ calculateTotalsRow ropts rows =
|
||||
|
||||
colamts = transpose . map prrAmounts $ filter isTopRow rows
|
||||
|
||||
coltotals :: [MixedAmount] = dbg5 "coltotals" $ map maSum colamts
|
||||
coltotals :: [MixedAmount] = dbg5 "coltotals" $ case colamts of
|
||||
[] -> replicate colcount nullmixedamt
|
||||
_ -> map maSum colamts
|
||||
|
||||
-- Calculate the grand total and average. These are always the sum/average
|
||||
-- of the column totals.
|
||||
|
||||
@ -19,7 +19,7 @@ Balance Sheet 2016-01-01
|
||||
Liabilities ||
|
||||
-------------++------------
|
||||
-------------++------------
|
||||
||
|
||||
|| 0
|
||||
=============++============
|
||||
Net: || 1
|
||||
|
||||
@ -42,7 +42,7 @@ Balance Sheet 2016-01-01
|
||||
Liabilities ||
|
||||
-------------++------------
|
||||
-------------++------------
|
||||
||
|
||||
|| 0
|
||||
=============++============
|
||||
Net: || 1
|
||||
|
||||
@ -171,7 +171,7 @@ Balance Sheet 2017-01-01
|
||||
Liabilities ||
|
||||
-------------++------------
|
||||
-------------++------------
|
||||
||
|
||||
|| 0
|
||||
=============++============
|
||||
Net: || 1
|
||||
|
||||
@ -193,7 +193,7 @@ Balance Sheet 2017-01-01
|
||||
Liabilities ||
|
||||
-------------++------------
|
||||
-------------++------------
|
||||
||
|
||||
|| 0
|
||||
=============++============
|
||||
Net: || 1
|
||||
|
||||
@ -215,7 +215,7 @@ Balance Sheet 2017-12-31
|
||||
Liabilities ||
|
||||
-------------++---------------------
|
||||
-------------++---------------------
|
||||
||
|
||||
|| 0 0
|
||||
=============++=====================
|
||||
Net: || $1 $1
|
||||
|
||||
@ -238,7 +238,7 @@ Balance Sheet 2016-01-31
|
||||
Liabilities ║
|
||||
─────────────╫────────────
|
||||
─────────────╫────────────
|
||||
║
|
||||
║ 0
|
||||
═════════════╬════════════
|
||||
Net: ║ 1
|
||||
|
||||
@ -276,7 +276,7 @@ Balance Sheet 2018-10-03
|
||||
Liabilities ||
|
||||
-------------------------------------++------------
|
||||
-------------------------------------++------------
|
||||
||
|
||||
|| 0
|
||||
=====================================++============
|
||||
Net: || $120
|
||||
|
||||
@ -303,7 +303,7 @@ Balance Sheet 2020-03-25
|
||||
Liabilities ||
|
||||
-------------++------------
|
||||
-------------++------------
|
||||
||
|
||||
|| 0
|
||||
=============++============
|
||||
Net: || $1
|
||||
|
||||
@ -315,7 +315,7 @@ $ hledger -f - balancesheet --tree --output-format=csv
|
||||
"assets:a","$1"
|
||||
"total","$1"
|
||||
"Liabilities",""
|
||||
"total"
|
||||
"total","0"
|
||||
"Net:","$1"
|
||||
|
||||
# ** 13. CSV output supports --drop.
|
||||
@ -326,7 +326,7 @@ $ hledger -f - balancesheet --tree --output-format=csv --drop 1
|
||||
"a","$1"
|
||||
"total","$1"
|
||||
"Liabilities",""
|
||||
"total"
|
||||
"total","0"
|
||||
"Net:","$1"
|
||||
|
||||
<
|
||||
@ -342,7 +342,7 @@ $ hledger -f - balancesheet --output-format=csv
|
||||
"assets:a","$-10000.00"
|
||||
"total","$-10000.00"
|
||||
"Liabilities",""
|
||||
"total"
|
||||
"total","0"
|
||||
"Net:","$-10000.00"
|
||||
|
||||
# ** 15. In compound reports like balancesheet, parent accounts might not have
|
||||
|
||||
@ -89,7 +89,7 @@ Cashflow Statement 2016-10
|
||||
Cash flows ||
|
||||
------------++-----
|
||||
------------++-----
|
||||
||
|
||||
|| 0
|
||||
>2
|
||||
>= 0
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ Income Statement 2014-01-01..2014-01-02
|
||||
Revenues ||
|
||||
--------------------------++------------------------
|
||||
--------------------------++------------------------
|
||||
||
|
||||
|| 0
|
||||
==========================++========================
|
||||
Expenses ||
|
||||
--------------------------++------------------------
|
||||
|
||||
@ -18,7 +18,7 @@ Income Statement 2016-01-01
|
||||
Expenses ||
|
||||
----------++------------
|
||||
----------++------------
|
||||
||
|
||||
|| 0
|
||||
==========++============
|
||||
Net: || -1
|
||||
|
||||
@ -138,7 +138,7 @@ Income Statement 2015-10
|
||||
Expenses ||
|
||||
-------------------++------------
|
||||
-------------------++------------
|
||||
||
|
||||
|| 0
|
||||
===================++============
|
||||
Net: || $10,000.00
|
||||
|
||||
@ -171,14 +171,14 @@ Income Statement 2016-10
|
||||
Revenues ||
|
||||
----------++-----
|
||||
----------++-----
|
||||
||
|
||||
|| 0
|
||||
==========++=====
|
||||
Expenses ||
|
||||
----------++-----
|
||||
----------++-----
|
||||
||
|
||||
|| 0
|
||||
==========++=====
|
||||
Net: ||
|
||||
Net: || 0
|
||||
|
||||
# ** 6. Multicolumn test
|
||||
# old (arithmetic sign):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user