From 522a1f4c2a844d4e7e044c631f3bacce2f68aa9b Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 16 Apr 2009 05:45:06 +0000 Subject: [PATCH] when adding, the balancing amount is a more useful default --- AddCommand.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AddCommand.hs b/AddCommand.hs index cf1bf45bc..8605e67bf 100644 --- a/AddCommand.hs +++ b/AddCommand.hs @@ -112,7 +112,8 @@ getPostings bestmatchps enteredps = do where Just ps = bestmatchps defaultaccount = maybe Nothing (Just . paccount) bestmatch validateaccount = Just $ \s -> not $ null s - defaultamount = maybe Nothing (Just . show . pamount) bestmatch + defaultamount | n==1 = maybe Nothing (Just . show . pamount) bestmatch -- previously used amount + | otherwise = Just $ show $ negate $ sum $ map pamount enteredps -- balancing amount validateamount = Just $ \s -> (null s && (not $ null enteredps)) || (isRight $ parse (someamount>>many spacenonewline>>eof) "" s)