diff --git a/src/Control/User.hs b/src/Control/User.hs index 4bb7285..50890fc 100644 --- a/src/Control/User.hs +++ b/src/Control/User.hs @@ -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"