diff --git a/Application.hs b/Application.hs
index 5356f19..394f76c 100644
--- a/Application.hs
+++ b/Application.hs
@@ -55,6 +55,7 @@ import Handler.Barcode
import Handler.Transfer
import Handler.Supplier
import Handler.SupplierActions
+import Handler.Demand
-- This line actually creates our YesodDispatch instance. It is the second half
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
diff --git a/Handler/Buy.hs b/Handler/Buy.hs
index abb1ecc..60eb5ac 100644
--- a/Handler/Buy.hs
+++ b/Handler/Buy.hs
@@ -64,8 +64,12 @@ postBuyR uId bId = do
setMessageI MsgPurchaseSuccess
redirect HomeR
True -> do
- setMessageI MsgPurchaseDebtful
- redirect HomeR
+ let level = case userBalance user - price of
+ balance
+ | balance <= -5000 -> 3
+ | balance <= -1000 -> 2
+ | otherwise -> 1
+ redirect $ DemandR level
_ -> do
setMessageI MsgErrorOccured
redirect HomeR
diff --git a/Handler/Demand.hs b/Handler/Demand.hs
new file mode 100644
index 0000000..7384281
--- /dev/null
+++ b/Handler/Demand.hs
@@ -0,0 +1,22 @@
+-- yammat - Yet Another MateMAT
+-- Copyright (C) 2015 Amedeo Molnár, Astro
+--
+-- This program is free software: you can redistribute it and/or modify
+-- it under the terms of the GNU Affero General Public License as published
+-- by the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Affero General Public License for more details.
+--
+-- You should have received a copy of the GNU Affero General Public License
+-- along with this program. If not, see
+ _{MsgPurchaseDebtful} diff --git a/yammat.cabal b/yammat.cabal index 1885355..15deda0 100644 --- a/yammat.cabal +++ b/yammat.cabal @@ -39,6 +39,7 @@ library Handler.Transfer Handler.Supplier Handler.SupplierActions + Handler.Demand if flag(dev) || flag(library-only) cpp-options: -DDEVELOPMENT -DHTTP_CLIENT