aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model/Income.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Model/Income.hs')
-rw-r--r--src/server/Model/Income.hs12
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