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