aboutsummaryrefslogtreecommitdiff
path: root/server/src/Persistence/Payment.hs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/Persistence/Payment.hs')
-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]