aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJoris2019-11-07 07:59:41 +0100
committerJoris2019-11-07 07:59:41 +0100
commit4dc84dbda7ba3ea60d13e6f81eeec556974b7c72 (patch)
tree14cca21a981a55049710b85c5f81a18ce836d6b9 /common
parentf4f24158a46d8c0975f1b8813bbdbbeebad8c108 (diff)
downloadbudget-4dc84dbda7ba3ea60d13e6f81eeec556974b7c72.tar.gz
budget-4dc84dbda7ba3ea60d13e6f81eeec556974b7c72.tar.bz2
budget-4dc84dbda7ba3ea60d13e6f81eeec556974b7c72.zip
Show payment header infos
Diffstat (limited to 'common')
-rw-r--r--common/common.cabal2
-rw-r--r--common/src/Common/Model.hs2
-rw-r--r--common/src/Common/Model/ExceedingPayer.hs16
-rw-r--r--common/src/Common/Model/Payer.hs25
-rw-r--r--common/src/Common/Model/PaymentHeader.hs18
-rw-r--r--common/src/Common/Model/PaymentPage.hs4
6 files changed, 51 insertions, 16 deletions
diff --git a/common/common.cabal b/common/common.cabal
index 4a6d728..75d6cc8 100644
--- a/common/common.cabal
+++ b/common/common.cabal
@@ -59,6 +59,7 @@ Library
Common.Model.EditIncome
Common.Model.EditIncomeForm
Common.Model.EditPaymentForm
+ Common.Model.ExceedingPayer
Common.Model.Frequency
Common.Model.Income
Common.Model.IncomeHeader
@@ -67,4 +68,5 @@ Library
Common.Model.InitResult
Common.Model.Payer
Common.Model.PaymentCategory
+ Common.Model.PaymentHeader
Common.Model.PaymentPage
diff --git a/common/src/Common/Model.hs b/common/src/Common/Model.hs
index bc626d5..fdeac36 100644
--- a/common/src/Common/Model.hs
+++ b/common/src/Common/Model.hs
@@ -10,6 +10,7 @@ import Common.Model.EditIncome as X
import Common.Model.EditIncomeForm as X
import Common.Model.EditPaymentForm as X
import Common.Model.Email as X
+import Common.Model.ExceedingPayer as X
import Common.Model.Frequency as X
import Common.Model.Income as X
import Common.Model.IncomeHeader as X
@@ -19,6 +20,7 @@ import Common.Model.InitResult as X
import Common.Model.Payer as X
import Common.Model.Payment as X
import Common.Model.PaymentCategory as X
+import Common.Model.PaymentHeader as X
import Common.Model.PaymentPage as X
import Common.Model.SavedPayment as X
import Common.Model.SignInForm as X
diff --git a/common/src/Common/Model/ExceedingPayer.hs b/common/src/Common/Model/ExceedingPayer.hs
new file mode 100644
index 0000000..171b6ff
--- /dev/null
+++ b/common/src/Common/Model/ExceedingPayer.hs
@@ -0,0 +1,16 @@
+module Common.Model.ExceedingPayer
+ ( ExceedingPayer(..)
+ ) where
+
+import Data.Aeson (FromJSON, ToJSON)
+import GHC.Generics (Generic)
+
+import Common.Model.User (UserId)
+
+data ExceedingPayer = ExceedingPayer
+ { _exceedingPayer_userId :: UserId
+ , _exceedingPayer_amount :: Int
+ } deriving (Show, Generic)
+
+instance FromJSON ExceedingPayer
+instance ToJSON ExceedingPayer
diff --git a/common/src/Common/Model/Payer.hs b/common/src/Common/Model/Payer.hs
index 3c816c8..39a5788 100644
--- a/common/src/Common/Model/Payer.hs
+++ b/common/src/Common/Model/Payer.hs
@@ -1,19 +1,19 @@
module Common.Model.Payer
- ( ExceedingPayer(..)
- , getExceedingPayers
+ ( getExceedingPayers
, useIncomesFrom
, cumulativeIncomesSince
) where
-import qualified Data.List as List
-import qualified Data.Maybe as Maybe
-import Data.Time (NominalDiffTime, UTCTime (..))
-import qualified Data.Time as Time
-import Data.Time.Calendar (Day)
+import qualified Data.List as List
+import qualified Data.Maybe as Maybe
+import Data.Time (NominalDiffTime, UTCTime (..))
+import qualified Data.Time as Time
+import Data.Time.Calendar (Day)
-import Common.Model.Income (Income (..))
-import Common.Model.Payment (Payment (..))
-import Common.Model.User (User (..), UserId)
+import Common.Model.ExceedingPayer (ExceedingPayer (..))
+import Common.Model.Income (Income (..))
+import Common.Model.Payment (Payment (..))
+import Common.Model.User (User (..), UserId)
data Payer = Payer
{ _payer_userId :: UserId
@@ -29,11 +29,6 @@ data PostPaymentPayer = PostPaymentPayer
, _postPaymentPayer_ratio :: Float
}
-data ExceedingPayer = ExceedingPayer
- { _exceedingPayer_userId :: UserId
- , _exceedingPayer_amount :: Int
- } deriving (Show)
-
getExceedingPayers :: UTCTime -> [User] -> [Income] -> [Payment] -> [ExceedingPayer]
getExceedingPayers currentTime users incomes payments =
let userIds = map _user_id users
diff --git a/common/src/Common/Model/PaymentHeader.hs b/common/src/Common/Model/PaymentHeader.hs
new file mode 100644
index 0000000..a522cd8
--- /dev/null
+++ b/common/src/Common/Model/PaymentHeader.hs
@@ -0,0 +1,18 @@
+module Common.Model.PaymentHeader
+ ( PaymentHeader(..)
+ ) where
+
+import Data.Aeson (FromJSON, ToJSON)
+import Data.Map (Map)
+import GHC.Generics (Generic)
+
+import Common.Model.ExceedingPayer (ExceedingPayer)
+import Common.Model.User (UserId)
+
+data PaymentHeader = PaymentHeader
+ { _paymentHeader_exceedingPayers :: [ExceedingPayer]
+ , _paymentHeader_repartition :: Map UserId Int
+ } deriving (Show, Generic)
+
+instance FromJSON PaymentHeader
+instance ToJSON PaymentHeader
diff --git a/common/src/Common/Model/PaymentPage.hs b/common/src/Common/Model/PaymentPage.hs
index 31039c7..76c7511 100644
--- a/common/src/Common/Model/PaymentPage.hs
+++ b/common/src/Common/Model/PaymentPage.hs
@@ -7,9 +7,11 @@ import GHC.Generics (Generic)
import Common.Model.Payment (Payment)
import Common.Model.PaymentCategory (PaymentCategory)
+import Common.Model.PaymentHeader (PaymentHeader)
data PaymentPage = PaymentPage
- { _paymentPage_payments :: [Payment]
+ { _paymentPage_header :: PaymentHeader
+ , _paymentPage_payments :: [Payment]
, _paymentPage_paymentCategories :: [PaymentCategory]
, _paymentPage_totalCount :: Int
} deriving (Show, Generic)