diff options
author | Joris | 2016-06-12 23:54:17 +0200 |
---|---|---|
committer | Joris | 2016-06-12 23:54:17 +0200 |
commit | 6a0c5087f716ed6c876a666db6573491bfd3e094 (patch) | |
tree | bf439109143c7a1749c2661fc8b805b83a993027 /src/server/Model/Income.hs | |
parent | 38896af4281d2e191cbde15836a23e4c0274fff6 (diff) |
Design income form
Diffstat (limited to 'src/server/Model/Income.hs')
-rw-r--r-- | src/server/Model/Income.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/server/Model/Income.hs b/src/server/Model/Income.hs index c0cac45..119a44f 100644 --- a/src/server/Model/Income.hs +++ b/src/server/Model/Income.hs @@ -5,7 +5,8 @@ module Model.Income , deleteOwnIncome ) where -import Data.Time.Clock (UTCTime, getCurrentTime) +import Data.Time.Clock (getCurrentTime) +import Data.Time.Calendar (Day) import Control.Monad.IO.Class (liftIO) @@ -16,15 +17,16 @@ import qualified Model.Json.Income as Json getJsonIncome :: Entity Income -> Json.Income getJsonIncome incomeEntity = - Json.Income (entityKey incomeEntity) (incomeUserId income) (incomeCreation income) (incomeAmount income) + Json.Income (entityKey incomeEntity) (incomeUserId income) (incomeDate income) (incomeAmount income) where income = entityVal incomeEntity getIncomes :: Persist [Entity Income] getIncomes = selectList [IncomeDeletedAt ==. Nothing] [] -addIncome :: UserId -> UTCTime -> Int -> Persist IncomeId -addIncome userId creation amount = do - insert (Income userId creation amount Nothing) +addIncome :: UserId -> Day -> Int -> Persist IncomeId +addIncome userId day amount = do + now <- liftIO getCurrentTime + insert (Income userId day amount now Nothing) deleteOwnIncome :: Entity User -> IncomeId -> Persist Bool deleteOwnIncome user incomeId = do |