hlint-clean BalanceReport, MultiBalanceReport
This commit is contained in:
		
							parent
							
								
									bd5c7669d1
								
							
						
					
					
						commit
						67a76b297a
					
				| @ -1,4 +1,4 @@ | |||||||
| {-# LANGUAGE RecordWildCards, DeriveDataTypeable, FlexibleInstances, ScopedTypeVariables, OverloadedStrings #-} | {-# LANGUAGE FlexibleInstances, ScopedTypeVariables, OverloadedStrings #-} | ||||||
| {-| | {-| | ||||||
| 
 | 
 | ||||||
| Balance report, used by the balance command. | Balance report, used by the balance command. | ||||||
| @ -127,7 +127,7 @@ balanceReportItem opts q a | |||||||
|     name | queryDepth q > 0 = aname a |     name | queryDepth q > 0 = aname a | ||||||
|          | otherwise        = "..." |          | otherwise        = "..." | ||||||
|     elidedname = accountNameFromComponents (adjacentboringparentnames ++ [accountLeafName name]) |     elidedname = accountNameFromComponents (adjacentboringparentnames ++ [accountLeafName name]) | ||||||
|     adjacentboringparentnames = reverse $ map (accountLeafName.aname) $ takeWhile aboring $ parents |     adjacentboringparentnames = reverse $ map (accountLeafName.aname) $ takeWhile aboring parents | ||||||
|     indent = length $ filter (not.aboring) parents |     indent = length $ filter (not.aboring) parents | ||||||
|     -- parents exclude the tree's root node |     -- parents exclude the tree's root node | ||||||
|     parents = case parentAccounts a of [] -> [] |     parents = case parentAccounts a of [] -> [] | ||||||
| @ -147,7 +147,7 @@ balanceReportValue :: Journal -> Day -> BalanceReport -> BalanceReport | |||||||
| balanceReportValue j d r = r' | balanceReportValue j d r = r' | ||||||
|   where |   where | ||||||
|     (items,total) = r |     (items,total) = r | ||||||
|     r' = dbg8 "balanceReportValue" $ |     r' = dbg8 "balanceReportValue" | ||||||
|          ([(n, mixedAmountValue j d a) |(n,a) <- items], mixedAmountValue j d total) |          ([(n, mixedAmountValue j d a) |(n,a) <- items], mixedAmountValue j d total) | ||||||
| 
 | 
 | ||||||
| mixedAmountValue :: Journal -> Day -> MixedAmount -> MixedAmount | mixedAmountValue :: Journal -> Day -> MixedAmount -> MixedAmount | ||||||
| @ -385,27 +385,28 @@ tests_balanceReport = | |||||||
| -} | -} | ||||||
|  ] |  ] | ||||||
| 
 | 
 | ||||||
| Right samplejournal2 = journalBalanceTransactions $ | Right samplejournal2 = | ||||||
|          nulljournal |   journalBalanceTransactions | ||||||
|          {jtxns = [ |     nulljournal{ | ||||||
|            txnTieKnot $ Transaction { |       jtxns = [ | ||||||
|              tindex=0, |         txnTieKnot Transaction{ | ||||||
|              tsourcepos=nullsourcepos, |           tindex=0, | ||||||
|              tdate=parsedate "2008/01/01", |           tsourcepos=nullsourcepos, | ||||||
|              tdate2=Just $ parsedate "2009/01/01", |           tdate=parsedate "2008/01/01", | ||||||
|              tstatus=Uncleared, |           tdate2=Just $ parsedate "2009/01/01", | ||||||
|              tcode="", |           tstatus=Uncleared, | ||||||
|              tdescription="income", |           tcode="", | ||||||
|              tcomment="", |           tdescription="income", | ||||||
|              ttags=[], |           tcomment="", | ||||||
|              tpostings= |           ttags=[], | ||||||
|                  [posting {paccount="assets:bank:checking", pamount=Mixed [usd 1]} |           tpostings= | ||||||
|                  ,posting {paccount="income:salary", pamount=missingmixedamt} |             [posting {paccount="assets:bank:checking", pamount=Mixed [usd 1]} | ||||||
|                  ], |             ,posting {paccount="income:salary", pamount=missingmixedamt} | ||||||
|              tpreceding_comment_lines="" |             ], | ||||||
|            } |           tpreceding_comment_lines="" | ||||||
|           ] |         } | ||||||
|          } |       ] | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| -- tests_isInterestingIndented = [ | -- tests_isInterestingIndented = [ | ||||||
| --   "isInterestingIndented" ~: do | --   "isInterestingIndented" ~: do | ||||||
| @ -416,5 +417,5 @@ Right samplejournal2 = journalBalanceTransactions $ | |||||||
| --  ] | --  ] | ||||||
| 
 | 
 | ||||||
| tests_Hledger_Reports_BalanceReport :: Test | tests_Hledger_Reports_BalanceReport :: Test | ||||||
| tests_Hledger_Reports_BalanceReport = TestList $ | tests_Hledger_Reports_BalanceReport = TestList | ||||||
|     tests_balanceReport |   tests_balanceReport | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| {-# LANGUAGE RecordWildCards, DeriveDataTypeable, FlexibleInstances, ScopedTypeVariables #-} | {-# LANGUAGE FlexibleInstances, ScopedTypeVariables #-} | ||||||
| {-| | {-| | ||||||
| 
 | 
 | ||||||
| Multi-column balance reports, used by the balance command. | Multi-column balance reports, used by the balance command. | ||||||
| @ -100,12 +100,12 @@ multiBalanceReport opts q j = MultiBalanceReport (displayspans, items, totalsrow | |||||||
|       displayspans = dbg1 "displayspans" $ splitSpan (interval_ opts) displayspan |       displayspans = dbg1 "displayspans" $ splitSpan (interval_ opts) displayspan | ||||||
|         where |         where | ||||||
|           displayspan |           displayspan | ||||||
|             | empty_ opts = dbg1 "displayspan (-E)" $ reportspan                                -- all the requested intervals |             | empty_ opts = dbg1 "displayspan (-E)" reportspan                                -- all the requested intervals | ||||||
|             | otherwise   = dbg1 "displayspan"      $ requestedspan `spanIntersect` matchedspan -- exclude leading/trailing empty intervals |             | otherwise   = dbg1 "displayspan"      $ requestedspan `spanIntersect` matchedspan -- exclude leading/trailing empty intervals | ||||||
|           matchedspan = dbg1 "matchedspan" $ postingsDateSpan' (whichDateFromOpts opts) ps |           matchedspan = dbg1 "matchedspan" $ postingsDateSpan' (whichDateFromOpts opts) ps | ||||||
| 
 | 
 | ||||||
|       psPerSpan :: [[Posting]] = |       psPerSpan :: [[Posting]] = | ||||||
|           dbg1 "psPerSpan" $ |           dbg1 "psPerSpan" | ||||||
|           [filter (isPostingInDateSpan' (whichDateFromOpts opts) s) ps | s <- displayspans] |           [filter (isPostingInDateSpan' (whichDateFromOpts opts) s) ps | s <- displayspans] | ||||||
| 
 | 
 | ||||||
|       postedAcctBalChangesPerSpan :: [[(ClippedAccountName, MixedAmount)]] = |       postedAcctBalChangesPerSpan :: [[(ClippedAccountName, MixedAmount)]] = | ||||||
| @ -141,17 +141,17 @@ multiBalanceReport opts q j = MultiBalanceReport (displayspans, items, totalsrow | |||||||
|           if empty_ opts then nub $ sort $ startAccts ++ postedAccts else postedAccts |           if empty_ opts then nub $ sort $ startAccts ++ postedAccts else postedAccts | ||||||
| 
 | 
 | ||||||
|       acctBalChangesPerSpan :: [[(ClippedAccountName, MixedAmount)]] = |       acctBalChangesPerSpan :: [[(ClippedAccountName, MixedAmount)]] = | ||||||
|           dbg1 "acctBalChangesPerSpan" $ |           dbg1 "acctBalChangesPerSpan" | ||||||
|           [sortBy (comparing fst) $ unionBy (\(a,_) (a',_) -> a == a') postedacctbals zeroes |           [sortBy (comparing fst) $ unionBy (\(a,_) (a',_) -> a == a') postedacctbals zeroes | ||||||
|            | postedacctbals <- postedAcctBalChangesPerSpan] |            | postedacctbals <- postedAcctBalChangesPerSpan] | ||||||
|           where zeroes = [(a, nullmixedamt) | a <- displayedAccts] |           where zeroes = [(a, nullmixedamt) | a <- displayedAccts] | ||||||
| 
 | 
 | ||||||
|       acctBalChanges :: [(ClippedAccountName, [MixedAmount])] = |       acctBalChanges :: [(ClippedAccountName, [MixedAmount])] = | ||||||
|           dbg1 "acctBalChanges" $ |           dbg1 "acctBalChanges" | ||||||
|           [(a, map snd abs) | abs@((a,_):_) <- transpose acctBalChangesPerSpan] -- never null, or used when null... |           [(a, map snd abs) | abs@((a,_):_) <- transpose acctBalChangesPerSpan] -- never null, or used when null... | ||||||
| 
 | 
 | ||||||
|       items :: [MultiBalanceReportRow] = |       items :: [MultiBalanceReportRow] = | ||||||
|           dbg1 "items" $ |           dbg1 "items" | ||||||
|           [((a, accountLeafName a, accountNameLevel a), displayedBals, rowtot, rowavg) |           [((a, accountLeafName a, accountNameLevel a), displayedBals, rowtot, rowavg) | ||||||
|            | (a,changes) <- acctBalChanges |            | (a,changes) <- acctBalChanges | ||||||
|            , let displayedBals = case balancetype_ opts of |            , let displayedBals = case balancetype_ opts of | ||||||
| @ -169,11 +169,11 @@ multiBalanceReport opts q j = MultiBalanceReport (displayspans, items, totalsrow | |||||||
|           where |           where | ||||||
|             balsbycol = transpose [bs | ((a,_,_),bs,_,_) <- items, not (tree_ opts) || a `elem` highestlevelaccts] |             balsbycol = transpose [bs | ((a,_,_),bs,_,_) <- items, not (tree_ opts) || a `elem` highestlevelaccts] | ||||||
|             highestlevelaccts     = |             highestlevelaccts     = | ||||||
|                 dbg1 "highestlevelaccts" $ |                 dbg1 "highestlevelaccts" | ||||||
|                 [a | a <- displayedAccts, not $ any (`elem` displayedAccts) $ init $ expandAccountName a] |                 [a | a <- displayedAccts, not $ any (`elem` displayedAccts) $ init $ expandAccountName a] | ||||||
| 
 | 
 | ||||||
|       totalsrow :: MultiBalanceTotalsRow = |       totalsrow :: MultiBalanceTotalsRow = | ||||||
|           dbg1 "totalsrow" $ |           dbg1 "totalsrow" | ||||||
|           (totals, sum totals, averageMixedAmounts totals) |           (totals, sum totals, averageMixedAmounts totals) | ||||||
| 
 | 
 | ||||||
|       dbg1 s = let p = "multiBalanceReport" in Hledger.Utils.dbg1 (p++" "++s)  -- add prefix in this function's debug output |       dbg1 s = let p = "multiBalanceReport" in Hledger.Utils.dbg1 (p++" "++s)  -- add prefix in this function's debug output | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user