aboutsummaryrefslogtreecommitdiff
path: root/server/src/Persistence
diff options
context:
space:
mode:
authorJoris2019-11-07 07:59:41 +0100
committerJoris2019-11-07 07:59:41 +0100
commit4dc84dbda7ba3ea60d13e6f81eeec556974b7c72 (patch)
tree14cca21a981a55049710b85c5f81a18ce836d6b9 /server/src/Persistence
parentf4f24158a46d8c0975f1b8813bbdbbeebad8c108 (diff)
Show payment header infos
Diffstat (limited to 'server/src/Persistence')
-rw-r--r--server/src/Persistence/Payment.hs21
1 files changed, 16 insertions, 5 deletions
diff --git a/server/src/Persistence/Payment.hs b/server/src/Persistence/Payment.hs
index e01753f..7835c98 100644
--- a/server/src/Persistence/Payment.hs
+++ b/server/src/Persistence/Payment.hs
@@ -89,11 +89,14 @@ firstPunctualDay =
(Only (FrequencyField Punctual))
)
-listActive :: Query [Payment]
-listActive =
+listActive :: Frequency -> Query [Payment]
+listActive frequency =
Query (\conn -> do
map (\(Row p) -> p) <$>
- SQLite.query_ conn "SELECT * FROM payment WHERE deleted_at IS NULL"
+ SQLite.query
+ conn
+ "SELECT * FROM payment WHERE deleted_at IS NULL AND frequency = ?"
+ (Only (FrequencyField frequency))
)
listActivePage :: Int -> Int -> Query [Payment]
@@ -102,8 +105,16 @@ listActivePage page perPage =
map (\(Row p) -> p) <$>
SQLite.query
conn
- "SELECT * FROM payment WHERE deleted_at IS NULL ORDER BY date DESC LIMIT ? OFFSET ?"
- (perPage, (page - 1) * perPage)
+ (SQLite.Query $ T.intercalate " "
+ [ "SELECT *"
+ , "FROM payment"
+ , "WHERE deleted_at IS NULL AND frequency = ?"
+ , "ORDER BY date DESC"
+ , "LIMIT ?"
+ , "OFFSET ?"
+ ]
+ )
+ (FrequencyField Punctual, perPage, (page - 1) * perPage)
)
listPunctual :: Query [Payment]