readability cleanups
This commit is contained in:
parent
6a61c96481
commit
9aaf489a38
@ -162,20 +162,21 @@ accountsReportItemAsText opts format (_, accountName, depth, Mixed amounts) =
|
|||||||
|
|
||||||
formatAccountsReportItem :: ReportOpts -> Maybe AccountName -> Int -> Amount -> [FormatString] -> String
|
formatAccountsReportItem :: ReportOpts -> Maybe AccountName -> Int -> Amount -> [FormatString] -> String
|
||||||
formatAccountsReportItem _ _ _ _ [] = ""
|
formatAccountsReportItem _ _ _ _ [] = ""
|
||||||
formatAccountsReportItem opts accountName depth amount (f:fs) = s ++ (formatAccountsReportItem opts accountName depth amount fs)
|
formatAccountsReportItem opts accountName depth amount (fmt:fmts) =
|
||||||
|
s ++ (formatAccountsReportItem opts accountName depth amount fs)
|
||||||
where
|
where
|
||||||
s = case f of
|
s = case fmt of
|
||||||
FormatLiteral l -> l
|
FormatLiteral l -> l
|
||||||
FormatField leftJustified min max field -> formatAccount opts accountName depth amount leftJustified min max field
|
FormatField ljust min max field -> formatField opts accountName depth amount ljust min max field
|
||||||
|
|
||||||
formatAccount :: ReportOpts -> Maybe AccountName -> Int -> Amount -> Bool -> Maybe Int -> Maybe Int -> Field -> String
|
formatField :: ReportOpts -> Maybe AccountName -> Int -> Amount -> Bool -> Maybe Int -> Maybe Int -> Field -> String
|
||||||
formatAccount opts accountName depth balance leftJustified min max field = case field of
|
formatField opts accountName depth balance ljust min max field = case field of
|
||||||
Format.Account -> formatValue leftJustified min max a
|
Format.Account -> formatValue ljust min max a
|
||||||
DepthSpacer -> case min of
|
Format.DepthSpacer -> case min of
|
||||||
Just m -> formatValue leftJustified Nothing max $ replicate (depth * m) ' '
|
Just m -> formatValue ljust Nothing max $ replicate (depth * m) ' '
|
||||||
Nothing -> formatValue leftJustified Nothing max $ replicate depth ' '
|
Nothing -> formatValue ljust Nothing max $ replicate depth ' '
|
||||||
Total -> formatValue leftJustified min max $ showAmountWithoutPrice balance
|
Format.Total -> formatValue ljust min max $ showAmountWithoutPrice balance
|
||||||
_ -> ""
|
_ -> ""
|
||||||
where
|
where
|
||||||
a = maybe "" (accountNameDrop (drop_ opts)) accountName
|
a = maybe "" (accountNameDrop (drop_ opts)) accountName
|
||||||
|
|
||||||
|
|||||||
@ -26,12 +26,11 @@ data Field =
|
|||||||
|
|
||||||
data FormatString =
|
data FormatString =
|
||||||
FormatLiteral String
|
FormatLiteral String
|
||||||
| FormatField
|
| FormatField Bool -- Left justified ?
|
||||||
Bool -- Left justified
|
(Maybe Int) -- Min width
|
||||||
(Maybe Int) -- Min width
|
(Maybe Int) -- Max width
|
||||||
(Maybe Int) -- Max width
|
Field -- Field
|
||||||
Field -- Field
|
deriving (Show, Eq)
|
||||||
deriving (Show, Eq)
|
|
||||||
|
|
||||||
formatValue :: Bool -> Maybe Int -> Maybe Int -> String -> String
|
formatValue :: Bool -> Maybe Int -> Maybe Int -> String -> String
|
||||||
formatValue leftJustified min max value = printf formatS value
|
formatValue leftJustified min max value = printf formatS value
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user