;lib: styleAmountExceptPrecision
This commit is contained in:
		
							parent
							
								
									f09111b8b9
								
							
						
					
					
						commit
						b598f30a8a
					
				@ -66,6 +66,7 @@ module Hledger.Data.Amount (
 | 
				
			|||||||
  -- ** rendering
 | 
					  -- ** rendering
 | 
				
			||||||
  amountstyle,
 | 
					  amountstyle,
 | 
				
			||||||
  styleAmount,
 | 
					  styleAmount,
 | 
				
			||||||
 | 
					  styleAmountExceptPrecision,
 | 
				
			||||||
  showAmount,
 | 
					  showAmount,
 | 
				
			||||||
  cshowAmount,
 | 
					  cshowAmount,
 | 
				
			||||||
  showAmountWithZeroCommodity,
 | 
					  showAmountWithZeroCommodity,
 | 
				
			||||||
@ -368,6 +369,13 @@ styleAmount styles a =
 | 
				
			|||||||
    Just s  -> a{astyle=s}
 | 
					    Just s  -> a{astyle=s}
 | 
				
			||||||
    Nothing -> a
 | 
					    Nothing -> a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- | Like styleAmount, but keep the number of decimal places unchanged.
 | 
				
			||||||
 | 
					styleAmountExceptPrecision :: M.Map CommoditySymbol AmountStyle -> Amount -> Amount
 | 
				
			||||||
 | 
					styleAmountExceptPrecision styles a@Amount{astyle=AmountStyle{asprecision=origp}} =
 | 
				
			||||||
 | 
					  case M.lookup (acommodity a) styles of
 | 
				
			||||||
 | 
					    Just s  -> a{astyle=s{asprecision=origp}}
 | 
				
			||||||
 | 
					    Nothing -> a
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- | Get the string representation of an amount, based on its
 | 
					-- | Get the string representation of an amount, based on its
 | 
				
			||||||
-- commodity's display settings. String representations equivalent to
 | 
					-- commodity's display settings. String representations equivalent to
 | 
				
			||||||
-- zero are converted to just \"0\". The special "missing" amount is
 | 
					-- zero are converted to just \"0\". The special "missing" amount is
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user