diff --git a/Handler/Select.hs b/Handler/Select.hs index d6328fa..13a12fb 100644 --- a/Handler/Select.hs +++ b/Handler/Select.hs @@ -45,12 +45,17 @@ postRechargeR uId = do ((res, _), _) <- runFormPost rechargeForm case res of FormSuccess amount -> do - updateCashier amount ("Guthaben: " `T.append` (userIdent user)) - time <- liftIO getCurrentTime - secs <- return $ R.read $ formatTime defaultTimeLocale "%s" time - runDB $ update uId [UserBalance +=. amount, UserTimestamp =. secs] - setMessageI MsgRecharged - redirect $ HomeR + case amount < 0 of + False -> do + updateCashier amount ("Guthaben: " `T.append` (userIdent user)) + time <- liftIO getCurrentTime + secs <- return $ R.read $ formatTime defaultTimeLocale "%s" time + runDB $ update uId [UserBalance +=. amount, UserTimestamp =. secs] + setMessageI MsgRecharged + redirect $ HomeR + True -> do + setMessageI MsgNegativeRecharge + redirect $ RechargeR uId _ -> do setMessageI MsgRechargeError redirect $ HomeR diff --git a/messages/cz.msg b/messages/cz.msg index 85c0eb7..f4c0af7 100644 --- a/messages/cz.msg +++ b/messages/cz.msg @@ -80,5 +80,6 @@ SelectFile: Vyber soubor RestoreSuccess: Databáze znovu nahrána! InventoryBackup: Stahnout zálohu RestoreFromBackup: Nahrát záĺohu +NegativeRecharge: Nelze nabít negativní obnos Increment: ++ Decrement: -- diff --git a/messages/de.msg b/messages/de.msg index ecad0ce..56d081b 100644 --- a/messages/de.msg +++ b/messages/de.msg @@ -80,5 +80,6 @@ SelectFile: Datei auswählen RestoreSuccess: Datenbankwiederherstellung erfolgreich! InventoryBackup: Inventarsicherung herunterladen RestoreFromBackup: Inventar wiederherstellen +NegativeRecharge: Keine negativen Beträge aufladen Increment: ++ Decrement: -- diff --git a/messages/en.msg b/messages/en.msg index ee20a8c..c29a7e4 100644 --- a/messages/en.msg +++ b/messages/en.msg @@ -80,5 +80,6 @@ SelectFile: Select file RestoreSuccess: Database restored successfully! InventoryBackup: Backup inventory RestoreFromBackup: Restore from backup +NegativeRecharge: You can not recharge negative amounts Increment: ++ Decrement: -- diff --git a/messages/pl.msg b/messages/pl.msg index f752d9b..af80977 100644 --- a/messages/pl.msg +++ b/messages/pl.msg @@ -80,5 +80,6 @@ SelectFile: wybierz plik RestoreSuccess: baza danych pomyślnie przywrócona! InventoryBackup: kopia zapasowa inwentarza RestoreFromBackup: przywróć z kopii zapasowej +NegativeRecharge: You can not recharge negative amounts Increment: ++ Decrement: --