diff --git a/Handler/Common.hs b/Handler/Common.hs index 91fb2f8..0d653a2 100644 --- a/Handler/Common.hs +++ b/Handler/Common.hs @@ -8,6 +8,7 @@ import qualified Data.Text.Read as R import Yesod.Form.Functions import Text.Shakespeare.Text import Network.Mail.Mime +import Text.Printf import Import -- These handlers embed files in the executable at compile time to avoid a @@ -120,3 +121,9 @@ prependZero t0 = if T.null t1 else t1 where t1 = T.dropWhile ((==) ' ') t0 + +formatFloat :: Double -> Text +formatFloat = T.pack . (printf "%.2f") + +formatIntCurrency :: Int -> Text +formatIntCurrency x = formatFloat $ ((fromIntegral x) / 100) diff --git a/Handler/Summary.hs b/Handler/Summary.hs index 8ddee2b..2a08b9a 100644 --- a/Handler/Summary.hs +++ b/Handler/Summary.hs @@ -2,6 +2,7 @@ module Handler.Summary where import Import import Data.List as L +import Handler.Common getSummaryR :: Handler Html getSummaryR = do diff --git a/templates/buy.hamlet b/templates/buy.hamlet index 288a787..0f3e570 100644 --- a/templates/buy.hamlet +++ b/templates/buy.hamlet @@ -3,7 +3,7 @@ $doctype 5
- Preis pro Einheit: #{show ((fromIntegral (beveragePrice bev)) / 100)} #{appCurrency $ appSettings master} + Preis pro Einheit: #{formatIntCurrency (beveragePrice bev)} #{appCurrency $ appSettings master}