aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model/Json
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Model/Json')
-rw-r--r--src/server/Model/Json/Category.hs10
-rw-r--r--src/server/Model/Json/CreatePayment.hs7
-rw-r--r--src/server/Model/Json/EditCategory.hs5
-rw-r--r--src/server/Model/Json/EditIncome.hs2
-rw-r--r--src/server/Model/Json/EditPayment.hs8
-rw-r--r--src/server/Model/Json/Income.hs11
-rw-r--r--src/server/Model/Json/Init.hs11
-rw-r--r--src/server/Model/Json/Payment.hs22
-rw-r--r--src/server/Model/Json/PaymentCategory.hs10
-rw-r--r--src/server/Model/Json/User.hs10
10 files changed, 62 insertions, 34 deletions
diff --git a/src/server/Model/Json/Category.hs b/src/server/Model/Json/Category.hs
index daad4c2..8b5e527 100644
--- a/src/server/Model/Json/Category.hs
+++ b/src/server/Model/Json/Category.hs
@@ -2,14 +2,15 @@
module Model.Json.Category
( Category(..)
+ , fromCategory
) where
-import GHC.Generics
-
import Data.Aeson
import Data.Text (Text)
+import GHC.Generics
-import Model.Database (CategoryId)
+import Model.Category (CategoryId)
+import qualified Model.Category as M
data Category = Category
{ id :: CategoryId
@@ -18,3 +19,6 @@ data Category = Category
} deriving (Show, Generic)
instance ToJSON Category
+
+fromCategory :: M.Category -> Category
+fromCategory category = Category (M.id category) (M.name category) (M.color category)
diff --git a/src/server/Model/Json/CreatePayment.hs b/src/server/Model/Json/CreatePayment.hs
index 5bc6b47..6ab3a5b 100644
--- a/src/server/Model/Json/CreatePayment.hs
+++ b/src/server/Model/Json/CreatePayment.hs
@@ -4,13 +4,12 @@ module Model.Json.CreatePayment
( CreatePayment(..)
) where
-import GHC.Generics
-
import Data.Aeson
-import Data.Time.Calendar (Day)
import Data.Text (Text)
+import Data.Time.Calendar (Day)
+import GHC.Generics
-import Model.Database (CategoryId)
+import Model.Category (CategoryId)
import Model.Frequency (Frequency)
data CreatePayment = CreatePayment
diff --git a/src/server/Model/Json/EditCategory.hs b/src/server/Model/Json/EditCategory.hs
index bda3418..a10ce39 100644
--- a/src/server/Model/Json/EditCategory.hs
+++ b/src/server/Model/Json/EditCategory.hs
@@ -4,12 +4,11 @@ module Model.Json.EditCategory
( EditCategory(..)
) where
-import GHC.Generics
-
import Data.Aeson
import Data.Text (Text)
+import GHC.Generics
-import Model.Database (CategoryId)
+import Model.Category (CategoryId)
data EditCategory = EditCategory
{ id :: CategoryId
diff --git a/src/server/Model/Json/EditIncome.hs b/src/server/Model/Json/EditIncome.hs
index be3c7dc..9b29379 100644
--- a/src/server/Model/Json/EditIncome.hs
+++ b/src/server/Model/Json/EditIncome.hs
@@ -9,7 +9,7 @@ import GHC.Generics
import Data.Aeson
import Data.Time.Calendar (Day)
-import Model.Database (IncomeId)
+import Model.Income (IncomeId)
data EditIncome = EditIncome
{ id :: IncomeId
diff --git a/src/server/Model/Json/EditPayment.hs b/src/server/Model/Json/EditPayment.hs
index 35f44e5..b7d4d7d 100644
--- a/src/server/Model/Json/EditPayment.hs
+++ b/src/server/Model/Json/EditPayment.hs
@@ -4,14 +4,14 @@ module Model.Json.EditPayment
( EditPayment(..)
) where
-import GHC.Generics
-
import Data.Aeson
-import Data.Time.Calendar (Day)
import Data.Text (Text)
+import Data.Time.Calendar (Day)
+import GHC.Generics
+import Model.Category (CategoryId)
import Model.Frequency (Frequency)
-import Model.Database (PaymentId, CategoryId)
+import Model.Payment (PaymentId)
data EditPayment = EditPayment
{ id :: PaymentId
diff --git a/src/server/Model/Json/Income.hs b/src/server/Model/Json/Income.hs
index bb1ac97..7e23a84 100644
--- a/src/server/Model/Json/Income.hs
+++ b/src/server/Model/Json/Income.hs
@@ -2,14 +2,16 @@
module Model.Json.Income
( Income(..)
+ , fromIncome
) where
-import GHC.Generics
-
import Data.Aeson
import Data.Time.Calendar (Day)
+import GHC.Generics
-import Model.Database (IncomeId, UserId)
+import Model.Income (IncomeId)
+import Model.User (UserId)
+import qualified Model.Income as M
data Income = Income
{ id :: IncomeId
@@ -19,3 +21,6 @@ data Income = Income
} deriving (Show, Generic)
instance ToJSON Income
+
+fromIncome :: M.Income -> Income
+fromIncome income = Income (M.id income) (M.userId income) (M.date income) (M.amount income)
diff --git a/src/server/Model/Json/Init.hs b/src/server/Model/Json/Init.hs
index b9f7f40..530c3b7 100644
--- a/src/server/Model/Json/Init.hs
+++ b/src/server/Model/Json/Init.hs
@@ -5,17 +5,16 @@ module Model.Json.Init
, InitResult(..)
) where
-import GHC.Generics
-
import Data.Aeson
+import GHC.Generics
-import Model.Database (UserId)
-import Model.Json.User (User)
-import Model.Json.Payment (Payment)
-import Model.Json.Income (Income)
import Model.Json.Category (Category)
+import Model.Json.Income (Income)
+import Model.Json.Payment (Payment)
import Model.Json.PaymentCategory (PaymentCategory)
+import Model.Json.User (User)
import Model.Message.Key (Key)
+import Model.User (UserId)
data Init = Init
{ users :: [User]
diff --git a/src/server/Model/Json/Payment.hs b/src/server/Model/Json/Payment.hs
index 04c6de8..e406c0f 100644
--- a/src/server/Model/Json/Payment.hs
+++ b/src/server/Model/Json/Payment.hs
@@ -2,16 +2,19 @@
module Model.Json.Payment
( Payment(..)
+ , fromPayment
) where
-import GHC.Generics
-
-import Data.Text (Text)
import Data.Aeson
+import Data.Text (Text)
import Data.Time.Calendar (Day)
+import GHC.Generics
+import Prelude hiding (id)
-import Model.Database (PaymentId, UserId)
import Model.Frequency
+import Model.Payment (PaymentId)
+import Model.User (UserId)
+import qualified Model.Payment as M
data Payment = Payment
{ id :: PaymentId
@@ -24,3 +27,14 @@ data Payment = Payment
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
+ }
diff --git a/src/server/Model/Json/PaymentCategory.hs b/src/server/Model/Json/PaymentCategory.hs
index edd4388..fd97674 100644
--- a/src/server/Model/Json/PaymentCategory.hs
+++ b/src/server/Model/Json/PaymentCategory.hs
@@ -2,14 +2,15 @@
module Model.Json.PaymentCategory
( PaymentCategory(..)
+ , fromPaymentCategory
) where
-import GHC.Generics
-
import Data.Aeson
import Data.Text (Text)
+import GHC.Generics
-import Model.Database (CategoryId)
+import Model.Category (CategoryId)
+import qualified Model.PaymentCategory as M
data PaymentCategory = PaymentCategory
{ name :: Text
@@ -17,3 +18,6 @@ data PaymentCategory = PaymentCategory
} deriving (Show, Generic)
instance ToJSON PaymentCategory
+
+fromPaymentCategory :: M.PaymentCategory -> PaymentCategory
+fromPaymentCategory pc = PaymentCategory (M.name pc) (M.category pc)
diff --git a/src/server/Model/Json/User.hs b/src/server/Model/Json/User.hs
index ebc347b..c289fe0 100644
--- a/src/server/Model/Json/User.hs
+++ b/src/server/Model/Json/User.hs
@@ -2,14 +2,15 @@
module Model.Json.User
( User(..)
+ , fromUser
) where
-import GHC.Generics
-
import Data.Aeson
import Data.Text (Text)
+import GHC.Generics
-import Model.Database (UserId)
+import Model.User (UserId)
+import qualified Model.User as M
data User = User
{ id :: UserId
@@ -19,3 +20,6 @@ data User = User
instance FromJSON User
instance ToJSON User
+
+fromUser :: M.User -> User
+fromUser user = User (M.id user) (M.name user) (M.email user)