diff options
author | Joris | 2016-11-13 11:58:22 +0100 |
---|---|---|
committer | Joris | 2016-11-13 11:58:22 +0100 |
commit | ede7b4fade5c396b47d386bd616e05805622b647 (patch) | |
tree | 3b9152ace8d02687151046ad2f67b625b8ccda00 /src/server/View/Mail | |
parent | 86a96decdb8892b10c5314eb916ef15a64204450 (diff) |
Show a different message on weekly report if there were no activity during the previous week
Diffstat (limited to 'src/server/View/Mail')
-rw-r--r-- | src/server/View/Mail/WeeklyReport.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/server/View/Mail/WeeklyReport.hs b/src/server/View/Mail/WeeklyReport.hs index b333891..f76fb0e 100644 --- a/src/server/View/Mail/WeeklyReport.hs +++ b/src/server/View/Mail/WeeklyReport.hs @@ -14,7 +14,7 @@ import Data.Time.Clock (UTCTime) import Data.Time.Calendar (Day, toGregorian) import Data.List (sortOn) -import Resource (Status(..), groupByStatus) +import Resource (Status(..), groupByStatus, statuses) import Database.Persist (Entity, entityVal) @@ -44,14 +44,14 @@ mail conf users payments incomes start end = body :: Conf -> [Entity User] -> Map Status [Payment] -> Map Status [Income] -> Text body conf users paymentsByStatus incomesByStatus = - T.intercalate "\n\n" . catMaybes $ - [ paymentSection Created conf users <$> M.lookup Created paymentsByStatus - , paymentSection Edited conf users <$> M.lookup Edited paymentsByStatus - , paymentSection Deleted conf users <$> M.lookup Deleted paymentsByStatus - , incomeSection Created conf users <$> M.lookup Created incomesByStatus - , incomeSection Edited conf users <$> M.lookup Edited incomesByStatus - , incomeSection Deleted conf users <$> M.lookup Deleted incomesByStatus - ] + if M.null paymentsByStatus && M.null incomesByStatus + then + getMessage K.WeeklyReportEmpty + else + T.intercalate "\n\n" . catMaybes . concat $ + [ map (\s -> paymentSection s conf users <$> M.lookup s paymentsByStatus) statuses + , map (\s -> incomeSection s conf users <$> M.lookup s incomesByStatus) statuses + ] paymentSection :: Status -> Conf -> [Entity User] -> [Payment] -> Text paymentSection status conf users payments = |