rename amount show functions
This commit is contained in:
		
							parent
							
								
									782d05aa61
								
							
						
					
					
						commit
						aac492c746
					
				| @ -124,7 +124,7 @@ showBalanceReport opts args l = acctsstr ++ totalstr | ||||
|       acctsstr = concatMap (showAccountTreeWithBalances acctnamestoshow) $ subs treetoshow | ||||
|       totalstr = if isZeroAmount total  | ||||
|                  then ""  | ||||
|                  else printf "--------------------\n%20s\n" $ showAmountRounded total | ||||
|                  else printf "--------------------\n%20s\n" $ showAmount total | ||||
|       showingsubs = ShowSubs `elem` opts | ||||
|       pats@(apats,dpats) = parseAccountDescriptionArgs args | ||||
|       maxdepth = if null args && not showingsubs then 1 else 9999 | ||||
|  | ||||
| @ -46,12 +46,12 @@ import Ledger.Commodity | ||||
| amounttests = TestList [ | ||||
|               ] | ||||
| 
 | ||||
| instance Show Amount where show = showAmountRounded | ||||
| instance Show Amount where show = showAmount | ||||
| 
 | ||||
| -- | Get the string representation of an amount, based on its commodity's | ||||
| -- display settings. | ||||
| showAmountRounded :: Amount -> String | ||||
| showAmountRounded (Amount (Commodity {symbol=sym,side=side,spaced=spaced,precision=p}) q) | ||||
| showAmount :: Amount -> String | ||||
| showAmount (Amount (Commodity {symbol=sym,side=side,spaced=spaced,precision=p}) q) | ||||
|     | side==L = printf "%s%s%s" sym space quantity | ||||
|     | side==R = printf "%s%s%s" quantity space sym | ||||
|     where  | ||||
| @ -60,17 +60,17 @@ showAmountRounded (Amount (Commodity {symbol=sym,side=side,spaced=spaced,precisi | ||||
|       punctuatethousands = id | ||||
| 
 | ||||
| -- | Get the string representation of an amount, rounded, or showing just "0" if it's zero. | ||||
| showAmountRoundedOrZero :: Amount -> String | ||||
| showAmountRoundedOrZero a | ||||
| showAmountOrZero :: Amount -> String | ||||
| showAmountOrZero a | ||||
|     | isZeroAmount a = "0" | ||||
|     | otherwise = showAmountRounded a | ||||
|     | otherwise = showAmount a | ||||
| 
 | ||||
| -- | is this amount zero, when displayed with its given precision ? | ||||
| isZeroAmount :: Amount -> Bool | ||||
| isZeroAmount a@(Amount c _ ) = nonzerodigits == "" | ||||
|     where | ||||
|       nonzerodigits = filter (flip notElem "-+,.0") quantitystr | ||||
|       quantitystr = withoutsymbol $ showAmountRounded a | ||||
|       quantitystr = withoutsymbol $ showAmount a | ||||
|       withoutsymbol = drop (length $ symbol c) -- XXX | ||||
| 
 | ||||
| punctuatethousands :: String -> String | ||||
|  | ||||
| @ -83,7 +83,7 @@ showEntry e = | ||||
|       showtxn t = showacct t ++ "  " ++ (showamount $ tamount t) ++ (showcomment $ tcomment t) | ||||
|       showtxnnoamt t = showacct t ++ "              " ++ (showcomment $ tcomment t) | ||||
|       showacct t = "    " ++ (showaccountname $ taccount t) | ||||
|       showamount = printf "%12s" . showAmountRounded | ||||
|       showamount = printf "%12s" . showAmount | ||||
|       showaccountname s = printf "%-34s" s | ||||
|       showcomment s = if (length s) > 0 then "  ; "++s else "" | ||||
| 
 | ||||
|  | ||||
| @ -21,7 +21,7 @@ showLedgerTransaction :: RawTransaction -> String | ||||
| showLedgerTransaction t = (showaccountname $ taccount t) ++ " " ++ (showamount $ tamount t)  | ||||
|     where | ||||
|       showaccountname = printf "%-22s" . elideRight 22 | ||||
|       showamount = printf "%12s" . showAmountRoundedOrZero | ||||
|       showamount = printf "%12s" . showAmountOrZero | ||||
| 
 | ||||
| elideRight width s = | ||||
|     case length s > width of | ||||
|  | ||||
| @ -46,5 +46,5 @@ showTransactionAndBalance t b = | ||||
|     (replicate 32 ' ') ++ (showLedgerTransaction $ RawTransaction (account t) (amount t) "") ++ (showBalance b) | ||||
| 
 | ||||
| showBalance :: Amount -> String | ||||
| showBalance b = printf " %12s" (showAmountRoundedOrZero b) | ||||
| showBalance b = printf " %12s" (showAmountOrZero b) | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user