simplify, remove dead code
This commit is contained in:
		
							parent
							
								
									648887b36f
								
							
						
					
					
						commit
						ebcf695240
					
				@ -45,7 +45,6 @@ import Ledger.Commodity
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
instance Show Amount where show = showAmount
 | 
					instance Show Amount where show = showAmount
 | 
				
			||||||
-- instance Show MixedAmount where show = showMixedAmount
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
instance Num Amount where
 | 
					instance Num Amount where
 | 
				
			||||||
    abs (Amount c q) = Amount c (abs q)
 | 
					    abs (Amount c q) = Amount c (abs q)
 | 
				
			||||||
@ -98,11 +97,11 @@ punctuatethousands s =
 | 
				
			|||||||
      triples [] = []
 | 
					      triples [] = []
 | 
				
			||||||
      triples l  = [take 3 l] ++ (triples $ drop 3 l)
 | 
					      triples l  = [take 3 l] ++ (triples $ drop 3 l)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Get the string representation of an amount, rounded, or showing just "0" if it's zero.
 | 
					-- -- | Get the string representation of an amount, rounded, or showing just "0" if it's zero.
 | 
				
			||||||
showAmountOrZero :: Amount -> String
 | 
					-- showAmountOrZero :: Amount -> String
 | 
				
			||||||
showAmountOrZero a
 | 
					-- showAmountOrZero a
 | 
				
			||||||
    | isZeroAmount a = "0"
 | 
					--     | isZeroAmount a = "0"
 | 
				
			||||||
    | otherwise = showAmount a
 | 
					--     | otherwise = showAmount a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Get the string representation of an amount, rounded, or showing just "0" if it's zero.
 | 
					-- | Get the string representation of an amount, rounded, or showing just "0" if it's zero.
 | 
				
			||||||
showMixedAmountOrZero :: MixedAmount -> String
 | 
					showMixedAmountOrZero :: MixedAmount -> String
 | 
				
			||||||
 | 
				
			|||||||
@ -60,10 +60,8 @@ showEntry e =
 | 
				
			|||||||
showDate = printf "%-10s"
 | 
					showDate = printf "%-10s"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
isEntryBalanced :: Entry -> Bool
 | 
					isEntryBalanced :: Entry -> Bool
 | 
				
			||||||
isEntryBalanced (Entry {etransactions=ts}) = isZeroMixedAmount sum
 | 
					isEntryBalanced (Entry {etransactions=ts}) = 
 | 
				
			||||||
    where
 | 
					    isZeroMixedAmount $ sumMixedAmounts $ map tamount $ filter isReal ts
 | 
				
			||||||
      sum = sumRawTransactions realts
 | 
					 | 
				
			||||||
      realts = filter isReal ts
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Fill in a missing balance in this entry, if we have enough
 | 
					-- | Fill in a missing balance in this entry, if we have enough
 | 
				
			||||||
-- information to do that. Excluding virtual transactions, there should be
 | 
					-- information to do that. Excluding virtual transactions, there should be
 | 
				
			||||||
@ -76,10 +74,7 @@ balanceEntry e@(Entry{etransactions=ts}) = e{etransactions=ts'}
 | 
				
			|||||||
              0 -> ts
 | 
					              0 -> ts
 | 
				
			||||||
              1 -> map balance ts
 | 
					              1 -> map balance ts
 | 
				
			||||||
              otherwise -> error $ "could not balance this entry, too many missing amounts:\n" ++ show e
 | 
					              otherwise -> error $ "could not balance this entry, too many missing amounts:\n" ++ show e
 | 
				
			||||||
      otherstotal = sumRawTransactions withamounts
 | 
					      otherstotal = sumMixedAmounts $ map tamount withamounts
 | 
				
			||||||
--       simpleotherstotal
 | 
					 | 
				
			||||||
--           | length otherstotal == 1 = head otherstotal
 | 
					 | 
				
			||||||
--           | otherwise = error $ "sorry, can't balance a mixed-commodity entry yet:\n" ++ show e
 | 
					 | 
				
			||||||
      balance t
 | 
					      balance t
 | 
				
			||||||
          | isReal t && not (hasAmount t) = t{tamount = -otherstotal}
 | 
					          | isReal t && not (hasAmount t) = t{tamount = -otherstotal}
 | 
				
			||||||
          | otherwise = t
 | 
					          | otherwise = t
 | 
				
			||||||
 | 
				
			|||||||
@ -31,6 +31,3 @@ isReal t = rttype t == RegularTransaction
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
hasAmount :: RawTransaction -> Bool
 | 
					hasAmount :: RawTransaction -> Bool
 | 
				
			||||||
hasAmount = (/= autoamt) . tamount
 | 
					hasAmount = (/= autoamt) . tamount
 | 
				
			||||||
 | 
					 | 
				
			||||||
sumRawTransactions :: [RawTransaction] -> MixedAmount
 | 
					 | 
				
			||||||
sumRawTransactions = normaliseMixedAmount . sumMixedAmounts . map tamount
 | 
					 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user