@@ -11,6 +11,7 @@ module App.Types
1111 newFieldPair ,
1212 newFieldPairId ,
1313 newTotal ,
14+ inspectExchangeRate ,
1415 Screen (.. ),
1516 isQrCode ,
1617 unQrCode ,
@@ -208,7 +209,7 @@ newFieldPairId key val = do
208209 . # fieldOptsQrState
209210 .~ Nothing
210211
211- newTotal :: Model -> [FieldPair DynamicField Identity ]
212+ newTotal :: St Unique -> [FieldPair DynamicField Identity ]
212213newTotal st =
213214 if base == 0
214215 then mempty
@@ -219,6 +220,9 @@ newTotal st =
219220 newFieldPairId (" Subtotal " <> quoteCur)
220221 . DynamicFieldText
221222 $ inspectRatioDef quote,
223+ newFieldPairId (" Exchange rate" )
224+ . DynamicFieldText
225+ $ inspectExchangeRate st,
222226 FieldPair (newTextFieldId " Fee %" )
223227 $ uniqueToIdentity fee
224228 & # fieldOpts
@@ -231,8 +235,8 @@ newTotal st =
231235 $ fee
232236 ]
233237 where
234- fee = st ^. # modelState . # stMerchantFeePercent
235- rate = st ^. # modelState . # stExchangeRate . # fieldOutput
238+ fee = st ^. # stMerchantFeePercent
239+ rate = st ^. # stExchangeRate . # fieldOutput
236240 base =
237241 foldl
238242 ( \ acc fps ->
@@ -243,31 +247,48 @@ newTotal st =
243247 else acc
244248 )
245249 0
246- ( st
247- ^.. # modelState
248- . # stAssets
249- . each
250- . # assetFieldPairs
250+ ( st ^.. # stAssets . each . # assetFieldPairs
251251 )
252252 quote =
253253 rate * base
254254 baseCur =
255255 st
256- ^. # modelState
257- . # stAssetCurrency
256+ ^. # stAssetCurrency
258257 . # currencyOutput
259258 . # currencyInfoCode
260259 . to Money. inspectCurrencyCode
261260 . to toUpper
262261 quoteCur =
263262 st
264- ^. # modelState
265- . # stMerchantCurrency
263+ ^. # stMerchantCurrency
266264 . # currencyOutput
267265 . # currencyInfoCode
268266 . to Money. inspectCurrencyCode
269267 . to toUpper
270268
269+ inspectExchangeRate :: St f -> Unicode
270+ inspectExchangeRate st =
271+ " 1 "
272+ <> toUpper
273+ ( Money. inspectCurrencyCode
274+ $ st
275+ ^. # stAssetCurrency
276+ . # currencyOutput
277+ . # currencyInfoCode
278+ )
279+ <> " \8776 "
280+ <> inspectRatioDef
281+ ( st ^. # stExchangeRate . # fieldOutput
282+ )
283+ <> " "
284+ <> toUpper
285+ ( Money. inspectCurrencyCode
286+ $ st
287+ ^. # stMerchantCurrency
288+ . # currencyOutput
289+ . # currencyInfoCode
290+ )
291+
271292foldField :: Rational -> Field DynamicField f -> Rational
272293foldField acc Field {fieldType = typ, fieldOutput = out} =
273294 case out of
0 commit comments