nice float formatting

This commit is contained in:
nek0 2015-04-07 16:30:06 +02:00
parent d41aea3bfb
commit 4506d48b50
8 changed files with 16 additions and 8 deletions

View file

@ -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)

View file

@ -2,6 +2,7 @@ module Handler.Summary where
import Import
import Data.List as L
import Handler.Common
getSummaryR :: Handler Html
getSummaryR = do

View file

@ -3,7 +3,7 @@ $doctype 5
<h3>Kauf von #{beverageIdent bev}
<p>
Preis pro Einheit: #{show ((fromIntegral (beveragePrice bev)) / 100)} #{appCurrency $ appSettings master}
Preis pro Einheit: #{formatIntCurrency (beveragePrice bev)} #{appCurrency $ appSettings master}
<form method=post enctype=#{enctype}>
^{buyWidget}

View file

@ -3,7 +3,7 @@ $doctype 5
<h3>Kauf von #{beverageIdent bev}
<p>
Preis pro Einheit: #{show ((fromIntegral (beveragePrice bev + 50)) / 100)} #{appCurrency $ appSettings master}
Preis pro Einheit: #{formatIntCurrency (beveragePrice bev + 50)} #{appCurrency $ appSettings master}
<form method=post enctype=#{enctype}>
^{buyCashWidget}

View file

@ -13,13 +13,13 @@ $if not $ L.null entries
<tr>
<td>#{formatTime defaultTimeLocale "%A %F %H:%M" $ transactionTime entry}
<td>#{transactionDescription entry}
<td>#{show ((fromIntegral (transactionAmount entry)) / 100)} #{appCurrency $ appSettings master}
<td>#{formatIntCurrency (transactionAmount entry)} #{appCurrency $ appSettings master}
<tfoot>
<tr>
<td colspan="2">Gesamtbetrag:
<td>#{show ((fromIntegral total) / 100)} #{appCurrency $ appSettings master}
<td>#{formatIntCurrency (fromIntegral total)} #{appCurrency $ appSettings master}
<p>
Kassenbestand: #{show ((fromIntegral cashBalance) / 100)} #{appCurrency $ appSettings master}
Kassenbestand: #{formatIntCurrency (fromIntegral cashBalance)} #{appCurrency $ appSettings master}
<p>
<a href=@{PayoutR}>

View file

@ -4,7 +4,7 @@ $doctype 5
Guthaben aufladen
<p>
aktuelles Guthaben: #{show ((fromIntegral $ userBalance user) / 100)}
aktuelles Guthaben: #{formatIntCurrency (userBalance user)}
<form method=post enctype=#{enctype}>
^{rechargeWidget}

View file

@ -3,7 +3,7 @@ $doctype 5
<div .header>
<ul>
<li>
aktuelles Guthaben: #{show ((fromIntegral (userBalance user)) / 100)} #{appCurrency $ appSettings master}
aktuelles Guthaben: #{formatIntCurrency (userBalance user)} #{appCurrency $ appSettings master}
<li>
<a href=@{RechargeR uId}>
Guthaben aufladen

View file

@ -16,7 +16,7 @@ $if not $ L.null bevs
<td>#{beverageIdent bev}
<td>#{beverageAmount bev}
<td>#{beverageAlertAmount bev}
<td>#{show ((fromIntegral (beveragePrice bev)) / 100)} #{appCurrency $ appSettings master}
<td>#{formatIntCurrency (beveragePrice bev)} #{appCurrency $ appSettings master}
<td><a href=@{ModifyR bId}>bearbeiten
$else
<p>keine Getränke vorhanden