diff options
Diffstat (limited to 'src/server/Model/Income.hs')
-rw-r--r-- | src/server/Model/Income.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/server/Model/Income.hs b/src/server/Model/Income.hs index 70b9149..2177617 100644 --- a/src/server/Model/Income.hs +++ b/src/server/Model/Income.hs @@ -1,5 +1,5 @@ module Model.Income - ( getIncome + ( getJsonIncome , getFirstIncome , getIncomes , setIncome @@ -12,13 +12,15 @@ import Control.Monad.IO.Class (liftIO) import Database.Persist import Model.Database +import qualified Model.Json.Income as Json -getIncome :: UserId -> Persist (Maybe Income) -getIncome userId = - fmap entityVal <$> selectFirst [IncomeUserId ==. userId] [Desc IncomeCreation] +getJsonIncome :: Entity Income -> Json.Income +getJsonIncome incomeEntity = + Json.Income (entityKey incomeEntity) (incomeUserId income) (incomeCreation income) (incomeAmount income) + where income = entityVal incomeEntity -getIncomes :: Persist [Income] -getIncomes = map entityVal <$> selectList [] [] +getIncomes :: Persist [Entity Income] +getIncomes = selectList [] [] getFirstIncome :: UserId -> Persist (Maybe Income) getFirstIncome userId = |