bal --budget: elide multicommodity amounts

This commit is contained in:
Simon Michael 2020-06-26 13:57:49 -07:00
parent 3b6a8b0956
commit 25c15d4bab

View File

@ -261,9 +261,10 @@ budgetReportAsText ropts@ReportOpts{..} budgetr =
Nothing -> "") Nothing -> "")
actualwidth = maximum' $ map fst amountsAndGoals actualwidth = maximum' $ map fst amountsAndGoals
budgetwidth = maximum' $ map snd amountsAndGoals budgetwidth = maximum' $ map snd amountsAndGoals
amountsAndGoals = map (\(a,g) -> (amountLength a, amountLength g)) amountsAndGoals =
. concatMap prrAmounts $ prRows budgetr map (\(a,g) -> (amountWidth a, amountWidth g)) . concatMap prrAmounts $ prRows budgetr
where amountLength = maybe 0 (length . showMixedAmountOneLineWithoutPrice False) where
amountWidth = maybe 0 (length . showMixedAmountElided False)
-- XXX lay out actual, percentage and/or goal in the single table cell for now, should probably use separate cells -- XXX lay out actual, percentage and/or goal in the single table cell for now, should probably use separate cells
showcell :: BudgetCell -> String showcell :: BudgetCell -> String
showcell (mactual, mbudget) = actualstr ++ " " ++ budgetstr showcell (mactual, mbudget) = actualstr ++ " " ++ budgetstr
@ -277,10 +278,12 @@ budgetReportAsText ropts@ReportOpts{..} budgetr =
case percentage actual budget of case percentage actual budget of
Just pct -> Just pct ->
printf ("[%"++show percentwidth++"s%% of %"++show budgetwidth++"s]") printf ("[%"++show percentwidth++"s%% of %"++show budgetwidth++"s]")
(show $ roundTo 0 pct) (showbudgetamt budget) (show $ roundTo 0 pct) (showamt' budget)
Nothing -> Nothing ->
printf ("["++replicate (percentwidth+5) ' '++"%"++show budgetwidth++"s]") printf ("["++replicate (percentwidth+5) ' '++"%"++show budgetwidth++"s]")
(showbudgetamt budget) (showamt' budget)
showamt = showMixedAmountElided color_
showamt' = showMixedAmountElided False -- XXX colored budget amounts disrupts layout
-- | Calculate the percentage of actual change to budget goal to show, if any. -- | Calculate the percentage of actual change to budget goal to show, if any.
-- If valuing at cost, both amounts are converted to cost before comparing. -- If valuing at cost, both amounts are converted to cost before comparing.
@ -296,10 +299,6 @@ budgetReportAsText ropts@ReportOpts{..} budgetr =
Nothing Nothing
where where
maybecost = if valuationTypeIsCost ropts then mixedAmountCost else id maybecost = if valuationTypeIsCost ropts then mixedAmountCost else id
showamt = showMixedAmountOneLineWithoutPrice color_
-- don't show the budget amount in color, it messes up alignment (XXX)
showbudgetamt = showMixedAmountOneLineWithoutPrice False
maybetranspose | transpose_ = \(Table rh ch vals) -> Table ch rh (transpose vals) maybetranspose | transpose_ = \(Table rh ch vals) -> Table ch rh (transpose vals)
| otherwise = id | otherwise = id