ADD means to scale/flip the value of a transaction
This commit is contained in:
parent
4c88151610
commit
09e03ff675
|
@ -593,6 +593,7 @@ let TxGetter =
|
|||
{ Type =
|
||||
{ tgFrom : (TxHalfGetter FromEntryGetter.Type).Type
|
||||
, tgTo : (TxHalfGetter ToEntryGetter.Type).Type
|
||||
, tgScale : Double
|
||||
, tgCurrency : EntryCurGetter
|
||||
, tgOtherEntries : List TxSubGetter.Type
|
||||
}
|
||||
|
@ -600,6 +601,7 @@ let TxGetter =
|
|||
{ tgOtherEntries = [] : List TxSubGetter.Type
|
||||
, tgFrom = TxHalfGetter
|
||||
, tgTo = TxHalfGetter
|
||||
, tgScale = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -531,6 +531,7 @@ data TxGetter = TxGetter
|
|||
, tgTo :: !(TxHalfGetter ToEntryGetter)
|
||||
, tgCurrency :: !EntryCur
|
||||
, tgOtherEntries :: ![TxSubGetter]
|
||||
, tgScale :: !Double
|
||||
}
|
||||
deriving (Eq, Generic, Hashable, Show, FromDhall)
|
||||
|
||||
|
|
|
@ -314,15 +314,16 @@ toTx
|
|||
, tgTo
|
||||
, tgCurrency
|
||||
, tgOtherEntries
|
||||
, tgScale
|
||||
}
|
||||
r@TxRecord {trAmount, trDate, trDesc} = do
|
||||
combineError curRes subRes $ \(cur, f, t) ss ->
|
||||
combineError curRes subRes $ \(cur, f, t, v) ss ->
|
||||
Tx
|
||||
{ txDate = trDate
|
||||
, txDescr = trDesc
|
||||
, txEntries =
|
||||
EntrySet
|
||||
{ esTotalValue = trAmount
|
||||
{ esTotalValue = v
|
||||
, esCurrency = cur
|
||||
, esFrom = f
|
||||
, esTo = t
|
||||
|
@ -331,10 +332,15 @@ toTx
|
|||
}
|
||||
where
|
||||
curRes = do
|
||||
m <- ask
|
||||
cur <- liftInner $ resolveCurrency r tgCurrency
|
||||
let fromRes = resolveHalfEntry resolveFromValue cur r tgFrom
|
||||
let toRes = resolveHalfEntry resolveToValue cur r tgTo
|
||||
combineError fromRes toRes (cur,,)
|
||||
let totRes =
|
||||
liftExcept $
|
||||
roundPrecisionCur cur m $
|
||||
tgScale * fromRational trAmount
|
||||
combineError3 fromRes toRes totRes (cur,,,)
|
||||
subRes = mapErrors (resolveSubGetter r) tgOtherEntries
|
||||
|
||||
resolveSubGetter
|
||||
|
|
Loading…
Reference in New Issue