From 87b1d26db055006950b3f1005fe23415fb742c5f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 6 Aug 2016 20:03:38 -0700 Subject: [PATCH] add: suggest one commodity at a time as default amount #383 (take 2) --- hledger/Hledger/Cli/Add.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hledger/Hledger/Cli/Add.hs b/hledger/Hledger/Cli/Add.hs index c7cad5d3c..3a0ff9f6b 100644 --- a/hledger/Hledger/Cli/Add.hs +++ b/hledger/Hledger/Cli/Add.hs @@ -270,7 +270,7 @@ amountAndCommentWizard EntryState{..} = do def = case (esArgs, mhistoricalp, followedhistoricalsofar) of (d:_,_,_) -> d (_,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\"." $ parser parseAmountAndComment $ @@ -293,7 +293,9 @@ amountAndCommentWizard EntryState{..} = do -- eof return (a,c) 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 ? -- 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) ?