aboutsummaryrefslogtreecommitdiff
path: root/common/src/Common/Model
diff options
context:
space:
mode:
authorJoris2020-01-27 22:07:18 +0100
committerJoris2020-01-27 22:07:18 +0100
commit79e1d8b0099d61b580a499311f1714b1b7eb07b5 (patch)
treea4c35442914b3a59119ddfc1e6c2ce358ecd4758 /common/src/Common/Model
parent47c2a4d6b68c54eed5f7b45671b1ccaf8c0db200 (diff)
Show total incom by month in statistics
Diffstat (limited to 'common/src/Common/Model')
-rw-r--r--common/src/Common/Model/PaymentStats.hs10
-rw-r--r--common/src/Common/Model/Stats.hs23
2 files changed, 23 insertions, 10 deletions
diff --git a/common/src/Common/Model/PaymentStats.hs b/common/src/Common/Model/PaymentStats.hs
deleted file mode 100644
index 2dea640..0000000
--- a/common/src/Common/Model/PaymentStats.hs
+++ /dev/null
@@ -1,10 +0,0 @@
-module Common.Model.PaymentStats
- ( PaymentStats
- ) where
-
-import Data.Map (Map)
-import Data.Time.Calendar (Day)
-
-import Common.Model.Category (CategoryId)
-
-type PaymentStats = [(Day, Map CategoryId Int)]
diff --git a/common/src/Common/Model/Stats.hs b/common/src/Common/Model/Stats.hs
new file mode 100644
index 0000000..86e6ab9
--- /dev/null
+++ b/common/src/Common/Model/Stats.hs
@@ -0,0 +1,23 @@
+module Common.Model.Stats
+ ( Stats
+ , MonthStats(..)
+ ) where
+
+import Data.Aeson (FromJSON, ToJSON)
+import Data.Map (Map)
+import Data.Time.Calendar (Day)
+import GHC.Generics (Generic)
+
+import Common.Model.Category (CategoryId)
+import Common.Model.User (UserId)
+
+type Stats = [MonthStats]
+
+data MonthStats = MonthStats
+ { _monthStats_start :: Day
+ , _monthStats_paymentsByCategory :: Map CategoryId Int
+ , _monthStats_incomeByUser :: Map UserId Int
+ } deriving (Eq, Show, Generic)
+
+instance FromJSON MonthStats
+instance ToJSON MonthStats