aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model/Json/Payment.hs
blob: e406c0f41061d21eda3c507a5fc2e50992787ec6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{-# LANGUAGE DeriveGeneric #-}

module Model.Json.Payment
  ( Payment(..)
  , fromPayment
  ) where

import Data.Aeson
import Data.Text (Text)
import Data.Time.Calendar (Day)
import GHC.Generics
import Prelude hiding (id)

import Model.Frequency
import Model.Payment (PaymentId)
import Model.User (UserId)
import qualified Model.Payment as M

data Payment = Payment
  { id :: PaymentId
  , date :: Day
  , name :: Text
  , cost :: Int
  , userId :: UserId
  , frequency :: Frequency
  } deriving (Show, Generic)

instance FromJSON Payment
instance ToJSON Payment

fromPayment :: M.Payment -> Payment
fromPayment payment =
  Payment
    { id = M.id payment
    , date = M.date payment
    , name = M.name payment
    , cost = M.cost payment
    , userId = M.userId payment
    , frequency = M.frequency payment
    }