add: refactor, note default precision issue
This commit is contained in:
parent
21ef771a1d
commit
5eeadad160
@ -131,10 +131,16 @@ getPostings st enteredps = do
|
|||||||
| n > 1 = Just balancingamountstr
|
| n > 1 = Just balancingamountstr
|
||||||
| otherwise = Nothing
|
| otherwise = Nothing
|
||||||
where
|
where
|
||||||
-- force a decimal point in the output in case there's a
|
historicalamountstr = showMixedAmountWithPrecision p $ pamount $ fromJust bestmatch'
|
||||||
-- digit group separator that would be mistaken for one
|
balancingamountstr = showMixedAmountWithPrecision p $ negate $ sum $ map pamount enteredrealps
|
||||||
historicalamountstr = showMixedAmountWithPrecision maxprecisionwithpoint $ pamount $ fromJust bestmatch'
|
-- what should this be ?
|
||||||
balancingamountstr = showMixedAmountWithPrecision maxprecisionwithpoint $ negate $ sum $ map pamount enteredrealps
|
-- 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) ?
|
||||||
|
-- 3 canonical precision for this commodity in the journal ?
|
||||||
|
-- 4 maximum precision entered so far in this transaction ?
|
||||||
|
-- 5 3 or 4, whichever would show the most decimal places ?
|
||||||
|
-- I think 1 or 4, whichever would show the most decimal places
|
||||||
|
p = maxprecisionwithpoint
|
||||||
amountstr <- runInteractionDefault $ askFor (printf "amount %d" n) defaultamountstr validateamount
|
amountstr <- runInteractionDefault $ askFor (printf "amount %d" n) defaultamountstr validateamount
|
||||||
let amount = fromparse $ runParser (someamount <|> return missingamt) ctx "" amountstr
|
let amount = fromparse $ runParser (someamount <|> return missingamt) ctx "" amountstr
|
||||||
amount' = fromparse $ runParser (someamount <|> return missingamt) nullctx "" amountstr
|
amount' = fromparse $ runParser (someamount <|> return missingamt) nullctx "" amountstr
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user