diff options
Diffstat (limited to 'src/server/View')
-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 = |