prohibited negative recharge

This commit is contained in:
nek0 2015-04-13 14:49:14 +02:00
parent f410d9e350
commit df4b740472
5 changed files with 15 additions and 6 deletions

View file

@ -45,12 +45,17 @@ postRechargeR uId = do
((res, _), _) <- runFormPost rechargeForm ((res, _), _) <- runFormPost rechargeForm
case res of case res of
FormSuccess amount -> do FormSuccess amount -> do
case amount < 0 of
False -> do
updateCashier amount ("Guthaben: " `T.append` (userIdent user)) updateCashier amount ("Guthaben: " `T.append` (userIdent user))
time <- liftIO getCurrentTime time <- liftIO getCurrentTime
secs <- return $ R.read $ formatTime defaultTimeLocale "%s" time secs <- return $ R.read $ formatTime defaultTimeLocale "%s" time
runDB $ update uId [UserBalance +=. amount, UserTimestamp =. secs] runDB $ update uId [UserBalance +=. amount, UserTimestamp =. secs]
setMessageI MsgRecharged setMessageI MsgRecharged
redirect $ HomeR redirect $ HomeR
True -> do
setMessageI MsgNegativeRecharge
redirect $ RechargeR uId
_ -> do _ -> do
setMessageI MsgRechargeError setMessageI MsgRechargeError
redirect $ HomeR redirect $ HomeR

View file

@ -80,5 +80,6 @@ SelectFile: Vyber soubor
RestoreSuccess: Databáze znovu nahrána! RestoreSuccess: Databáze znovu nahrána!
InventoryBackup: Stahnout zálohu InventoryBackup: Stahnout zálohu
RestoreFromBackup: Nahrát záĺohu RestoreFromBackup: Nahrát záĺohu
NegativeRecharge: Nelze nabít negativní obnos
Increment: ++ Increment: ++
Decrement: -- Decrement: --

View file

@ -80,5 +80,6 @@ SelectFile: Datei auswählen
RestoreSuccess: Datenbankwiederherstellung erfolgreich! RestoreSuccess: Datenbankwiederherstellung erfolgreich!
InventoryBackup: Inventarsicherung herunterladen InventoryBackup: Inventarsicherung herunterladen
RestoreFromBackup: Inventar wiederherstellen RestoreFromBackup: Inventar wiederherstellen
NegativeRecharge: Keine negativen Beträge aufladen
Increment: ++ Increment: ++
Decrement: -- Decrement: --

View file

@ -80,5 +80,6 @@ SelectFile: Select file
RestoreSuccess: Database restored successfully! RestoreSuccess: Database restored successfully!
InventoryBackup: Backup inventory InventoryBackup: Backup inventory
RestoreFromBackup: Restore from backup RestoreFromBackup: Restore from backup
NegativeRecharge: You can not recharge negative amounts
Increment: ++ Increment: ++
Decrement: -- Decrement: --

View file

@ -80,5 +80,6 @@ SelectFile: wybierz plik
RestoreSuccess: baza danych pomyślnie przywrócona! RestoreSuccess: baza danych pomyślnie przywrócona!
InventoryBackup: kopia zapasowa inwentarza InventoryBackup: kopia zapasowa inwentarza
RestoreFromBackup: przywróć z kopii zapasowej RestoreFromBackup: przywróć z kopii zapasowej
NegativeRecharge: You can not recharge negative amounts
Increment: ++ Increment: ++
Decrement: -- Decrement: --