lib: fix alignment in budget report
This commit is contained in:
parent
d094138910
commit
92e7370f1f
@ -262,18 +262,24 @@ budgetReportSpan (PeriodicReport (spans, _, _)) = DateSpan (spanStart $ head spa
|
|||||||
|
|
||||||
-- | Render a budget report as plain text suitable for console output.
|
-- | Render a budget report as plain text suitable for console output.
|
||||||
budgetReportAsText :: ReportOpts -> BudgetReport -> String
|
budgetReportAsText :: ReportOpts -> BudgetReport -> String
|
||||||
budgetReportAsText ropts budgetr =
|
budgetReportAsText ropts budgetr@(PeriodicReport ( _, rows, _)) =
|
||||||
printf "Budget performance in %s:\n\n" (showDateSpan $ budgetReportSpan budgetr)
|
printf "Budget performance in %s:\n\n" (showDateSpan $ budgetReportSpan budgetr)
|
||||||
++
|
++
|
||||||
tableAsText ropts showcell (budgetReportAsTable ropts budgetr)
|
tableAsText ropts showcell (budgetReportAsTable ropts budgetr)
|
||||||
where
|
where
|
||||||
|
actualwidth =
|
||||||
|
maximum [ maybe 0 (length . showMixedAmountOneLineWithoutPrice) amt
|
||||||
|
| (_, _, _, amtandgoals, _, _) <- rows
|
||||||
|
, (amt, _) <- amtandgoals ]
|
||||||
|
budgetwidth =
|
||||||
|
maximum [ maybe 0 (length . showMixedAmountOneLineWithoutPrice) goal
|
||||||
|
| (_, _, _, amtandgoals, _, _) <- rows
|
||||||
|
, (_, goal) <- amtandgoals ]
|
||||||
-- 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 :: (Maybe Change, Maybe BudgetGoal) -> String
|
showcell :: (Maybe Change, Maybe BudgetGoal) -> String
|
||||||
showcell (mactual, mbudget) = actualstr ++ " " ++ budgetstr
|
showcell (mactual, mbudget) = actualstr ++ " " ++ budgetstr
|
||||||
where
|
where
|
||||||
actualwidth = 7
|
|
||||||
percentwidth = 4
|
percentwidth = 4
|
||||||
budgetwidth = 5
|
|
||||||
actual = fromMaybe 0 mactual
|
actual = fromMaybe 0 mactual
|
||||||
actualstr = printf ("%"++show actualwidth++"s") (showamt actual)
|
actualstr = printf ("%"++show actualwidth++"s") (showamt actual)
|
||||||
budgetstr = case mbudget of
|
budgetstr = case mbudget of
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user