ADD negative amount lookup
This commit is contained in:
parent
4f44e37462
commit
d7117270c9
|
@ -404,7 +404,7 @@ let EntryNumGetter =
|
||||||
ConstN: a constant value
|
ConstN: a constant value
|
||||||
AmountN: the value of the 'Amount' column
|
AmountN: the value of the 'Amount' column
|
||||||
-}
|
-}
|
||||||
< LookupN : Text | ConstN : Double | AmountN >
|
< LookupN : Text | ConstN : Double | AmountN | NegAmountN >
|
||||||
|
|
||||||
let EntryTextGetter =
|
let EntryTextGetter =
|
||||||
{-
|
{-
|
||||||
|
|
|
@ -343,11 +343,13 @@ collectErrorsIO :: MonadUnliftIO m => [m a] -> m [a]
|
||||||
collectErrorsIO = mapErrorsIO id
|
collectErrorsIO = mapErrorsIO id
|
||||||
|
|
||||||
resolveValue :: TxRecord -> EntryNumGetter -> InsertExcept Double
|
resolveValue :: TxRecord -> EntryNumGetter -> InsertExcept Double
|
||||||
resolveValue r s = case s of
|
resolveValue TxRecord {trOther, trAmount} s = case s of
|
||||||
(LookupN t) -> readDouble =<< lookupErr SplitValField t (trOther r)
|
(LookupN t) -> readDouble =<< lookupErr SplitValField t trOther
|
||||||
(ConstN c) -> return c
|
(ConstN c) -> return c
|
||||||
-- TODO don't coerce to rational in trAmount
|
AmountN -> return a
|
||||||
AmountN -> return $ fromRational $ trAmount r
|
NegAmountN -> return $ negate a
|
||||||
|
where
|
||||||
|
a = fromRational trAmount
|
||||||
|
|
||||||
resolveAcnt :: TxRecord -> SplitAcnt -> InsertExcept T.Text
|
resolveAcnt :: TxRecord -> SplitAcnt -> InsertExcept T.Text
|
||||||
resolveAcnt = resolveSplitField AcntField
|
resolveAcnt = resolveSplitField AcntField
|
||||||
|
|
Loading…
Reference in New Issue