From 6117784d0e88e2b0baeafc2a0040309c8fd20410 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Thu, 25 May 2023 00:11:04 -0400 Subject: [PATCH] ENH gereralize amount lookup function --- dhall/Types.dhall | 2 +- lib/Internal/Utils.hs | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/dhall/Types.dhall b/dhall/Types.dhall index 9f00d4a..b710ab4 100644 --- a/dhall/Types.dhall +++ b/dhall/Types.dhall @@ -404,7 +404,7 @@ let EntryNumGetter = ConstN: a constant value AmountN: the value of the 'Amount' column -} - < LookupN : Text | ConstN : Double | AmountN | NegAmountN > + < LookupN : Text | ConstN : Double | AmountN : Double > let EntryTextGetter = {- diff --git a/lib/Internal/Utils.hs b/lib/Internal/Utils.hs index 7bc8421..729fe65 100644 --- a/lib/Internal/Utils.hs +++ b/lib/Internal/Utils.hs @@ -346,10 +346,7 @@ resolveValue :: TxRecord -> EntryNumGetter -> InsertExcept Double resolveValue TxRecord {trOther, trAmount} s = case s of (LookupN t) -> readDouble =<< lookupErr SplitValField t trOther (ConstN c) -> return c - AmountN -> return a - NegAmountN -> return $ negate a - where - a = fromRational trAmount + AmountN m -> return $ (* m) $ fromRational trAmount resolveAcnt :: TxRecord -> SplitAcnt -> InsertExcept T.Text resolveAcnt = resolveSplitField AcntField