@@ -11,6 +11,7 @@ module App.Types
11
11
newFieldPair ,
12
12
newFieldPairId ,
13
13
newTotal ,
14
+ inspectExchangeRate ,
14
15
Screen (.. ),
15
16
isQrCode ,
16
17
unQrCode ,
@@ -208,7 +209,7 @@ newFieldPairId key val = do
208
209
. # fieldOptsQrState
209
210
.~ Nothing
210
211
211
- newTotal :: Model -> [FieldPair DynamicField Identity ]
212
+ newTotal :: St Unique -> [FieldPair DynamicField Identity ]
212
213
newTotal st =
213
214
if base == 0
214
215
then mempty
@@ -219,6 +220,9 @@ newTotal st =
219
220
newFieldPairId (" Subtotal " <> quoteCur)
220
221
. DynamicFieldText
221
222
$ inspectRatioDef quote,
223
+ newFieldPairId (" Exchange rate" )
224
+ . DynamicFieldText
225
+ $ inspectExchangeRate st,
222
226
FieldPair (newTextFieldId " Fee %" )
223
227
$ uniqueToIdentity fee
224
228
& # fieldOpts
@@ -231,8 +235,8 @@ newTotal st =
231
235
$ fee
232
236
]
233
237
where
234
- fee = st ^. # modelState . # stMerchantFeePercent
235
- rate = st ^. # modelState . # stExchangeRate . # fieldOutput
238
+ fee = st ^. # stMerchantFeePercent
239
+ rate = st ^. # stExchangeRate . # fieldOutput
236
240
base =
237
241
foldl
238
242
( \ acc fps ->
@@ -243,31 +247,48 @@ newTotal st =
243
247
else acc
244
248
)
245
249
0
246
- ( st
247
- ^.. # modelState
248
- . # stAssets
249
- . each
250
- . # assetFieldPairs
250
+ ( st ^.. # stAssets . each . # assetFieldPairs
251
251
)
252
252
quote =
253
253
rate * base
254
254
baseCur =
255
255
st
256
- ^. # modelState
257
- . # stAssetCurrency
256
+ ^. # stAssetCurrency
258
257
. # currencyOutput
259
258
. # currencyInfoCode
260
259
. to Money. inspectCurrencyCode
261
260
. to toUpper
262
261
quoteCur =
263
262
st
264
- ^. # modelState
265
- . # stMerchantCurrency
263
+ ^. # stMerchantCurrency
266
264
. # currencyOutput
267
265
. # currencyInfoCode
268
266
. to Money. inspectCurrencyCode
269
267
. to toUpper
270
268
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
+
271
292
foldField :: Rational -> Field DynamicField f -> Rational
272
293
foldField acc Field {fieldType = typ, fieldOutput = out} =
273
294
case out of
0 commit comments