add: suggest one commodity at a time as default amount #383 (take 2)

This commit is contained in:
Simon Michael 2016-08-06 20:03:38 -07:00
parent 009fe6d09f
commit 87b1d26db0

View File

@ -270,7 +270,7 @@ amountAndCommentWizard EntryState{..} = do
def = case (esArgs, mhistoricalp, followedhistoricalsofar) of def = case (esArgs, mhistoricalp, followedhistoricalsofar) of
(d:_,_,_) -> d (d:_,_,_) -> d
(_,Just hp,True) -> showamt $ pamount hp (_,Just hp,True) -> showamt $ pamount hp
_ | pnum > 1 && not (isZeroMixedAmount balancingamt) -> showamt balancingamt _ | pnum > 1 && not (isZeroMixedAmount balancingamt) -> showamt balancingamtfirstcommodity
_ -> "" _ -> ""
retryMsg "A valid hledger amount is required. Eg: 1, $2, 3 EUR, \"4 red apples\"." $ retryMsg "A valid hledger amount is required. Eg: 1, $2, 3 EUR, \"4 red apples\"." $
parser parseAmountAndComment $ parser parseAmountAndComment $
@ -293,7 +293,9 @@ amountAndCommentWizard EntryState{..} = do
-- eof -- eof
return (a,c) return (a,c)
balancingamt = negate $ sum $ map pamount realps where realps = filter isReal esPostings balancingamt = negate $ sum $ map pamount realps where realps = filter isReal esPostings
showamt = showMixedAmountWithPrecision balancingamtfirstcommodity = Mixed $ take 1 $ amounts balancingamt
showamt =
showMixedAmountWithPrecision
-- what should this be ? -- what should this be ?
-- 1 maxprecision (show all decimal places or none) ? -- 1 maxprecision (show all decimal places or none) ?
-- 2 maxprecisionwithpoint (show all decimal places or .0 - avoids some but not all confusion with thousands separators) ? -- 2 maxprecisionwithpoint (show all decimal places or .0 - avoids some but not all confusion with thousands separators) ?