parent
							
								
									cd0c76eb4a
								
							
						
					
					
						commit
						166951dc69
					
				| @ -388,7 +388,9 @@ generateMultiBalanceReport rspec@ReportSpec{rsOpts=ropts} j valuation colspans c | ||||
|     displaynames = dbg'' "displaynames" $ displayedAccounts rspec accumvalued | ||||
| 
 | ||||
|     -- All the rows of the report. | ||||
|     rows = dbg'' "rows" $ buildReportRows ropts displaynames accumvalued | ||||
|     rows = dbg'' "rows" | ||||
|              . (if invert_ ropts then map (fmap negate) else id)  -- Negate amounts if applicable | ||||
|              $ buildReportRows ropts displaynames accumvalued | ||||
| 
 | ||||
|     -- Calculate column totals | ||||
|     totalsrow = dbg' "totalsrow" $ calculateTotalsRow ropts rows | ||||
| @ -396,8 +398,8 @@ generateMultiBalanceReport rspec@ReportSpec{rsOpts=ropts} j valuation colspans c | ||||
|     -- Sorted report rows. | ||||
|     sortedrows = dbg' "sortedrows" $ sortRows ropts j rows | ||||
| 
 | ||||
|     -- Postprocess the report, negating balances and taking percentages if needed | ||||
|     report = postprocessReport ropts $ PeriodicReport colspans sortedrows totalsrow | ||||
|     -- Take percentages if needed | ||||
|     report = reportPercent ropts $ PeriodicReport colspans sortedrows totalsrow | ||||
| 
 | ||||
| -- | Build the report rows. | ||||
| -- | ||||
| @ -528,15 +530,11 @@ calculateTotalsRow ropts rows = | ||||
|         _            -> lastDef 0 coltotals | ||||
|     grandaverage = averageMixedAmounts coltotals | ||||
| 
 | ||||
| -- | Map the report rows to percentages and negate if needed | ||||
| postprocessReport :: ReportOpts -> MultiBalanceReport -> MultiBalanceReport | ||||
| postprocessReport ropts = maybePercent . maybeInvert | ||||
|   where | ||||
|     maybeInvert  = if invert_  ropts then fmap negate else id | ||||
|     maybePercent = if percent_ ropts then prPercent   else id | ||||
| 
 | ||||
|     prPercent (PeriodicReport spans rows totalrow) = | ||||
|         PeriodicReport spans (map percentRow rows) (percentRow totalrow) | ||||
| -- | Map the report rows to percentages if needed | ||||
| reportPercent :: ReportOpts -> MultiBalanceReport -> MultiBalanceReport | ||||
| reportPercent ropts report@(PeriodicReport spans rows totalrow) | ||||
|   | percent_ ropts = PeriodicReport spans (map percentRow rows) (percentRow totalrow) | ||||
|   | otherwise      = report | ||||
|   where | ||||
|     percentRow (PeriodicReportRow name rowvals rowtotal rowavg) = | ||||
|       PeriodicReportRow name | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user