work on buy message

This commit is contained in:
nek0 2021-07-02 22:53:09 +02:00
parent 4c62d65d77
commit 9bad54dcf6

View file

@ -160,9 +160,15 @@ userNotify (Just (auid, method)) boughtItems (PurchaseResult flag missing) = do
digestedDetails <- mapM
(\pd -> do
overview <- productOverviewSelectSingle (purchaseDetailProduct pd) conn
return (purchaseDetailAmount pd, productOverviewIdent overview)
return
( purchaseDetailAmount pd
, productOverviewIdent overview
, productOverviewPrice overview
)
)
boughtItems
currencyFrac <- return 2 -- TODO: Make currency fractions configurable
currencySymb <- asks rsCurrencySymbol
let messageText = mconcat $ map (<> ("\n" :: String)) $
[ printf (__ "Hello %s,") (userDetailsIdent userDetails)
, ""
@ -170,6 +176,35 @@ userNotify (Just (auid, method)) boughtItems (PurchaseResult flag missing) = do
\ Just made following purchase:")
(authOverviewComment authOV)
, ""
] ++
( map
(\(amount, ident, price) ->
printf
("%dx %s " <>
(__ "for the price of") <>
"%d %f." <>
(printf "%d" currencyFrac) <>
(printf "%s" currencySymb)
)
amount
ident
price
)
degestedDetails
)
++
[ ""
, printf (__ "For a total price of %s%s") <>
(fprint "%f." <>
(fprint "%d" currencyFrac) $
fromIntegral
(foldl (\acc (_, _, p) -> acc + p)
0
digestedDetails
) /
(10 ^ currencyFrac) -- TODO: Make currency fractions configurable
) <>
(printf "%s" currencySymb)
]
throwError $ err501
{ errBody = "userNotify: Not implemented yet"