chore(letter): implement course qualification letter (wip)

This commit is contained in:
Steffen Jost 2023-04-04 11:52:21 +00:00
parent 45daa5820e
commit a827f46f0f
7 changed files with 81 additions and 13 deletions

View File

@ -13,6 +13,7 @@ import Import
import Handler.Utils
import Handler.Utils.Csv
import Handler.Utils.Profile
-- import qualified Data.CaseInsensitive as CI
import qualified Data.Csv as Csv
@ -56,11 +57,11 @@ instance ToNamedRecord SapUserTableCsv where
-- | Removes all personalNummer which are not numbers between 10000 and 99999 (also excludes E-Accounts), which should not be returned by the query anyway (only qualfications with sap id and users with internal personnel number must be transmitted)
-- TODO: once temporary suspensions are implemented, a user must be transmitted to SAP in two rows: firstheld->suspensionFrom & suspensionTo->validTo
sapRes2csv :: [(Ex.Value (Maybe Text), Ex.Value Day, Ex.Value Day, Ex.Value (Maybe Text))] -> [SapUserTableCsv]
sapRes2csv l = [ res | (Ex.Value (Just persNo), Ex.Value firstHeld, Ex.Value validUntil, Ex.Value (Just sapId)) <- l
, let persNoAsInt = readMay persNo
, persNoAsInt >= Just (10000::Int) -- filter E-accounts for SAP export
, persNoAsInt <= Just (99999::Int) -- filter E-accounts for SAP export
, let res = SapUserTableCsv
sapRes2csv l = [ res | (Ex.Value pn@(Just persNo), Ex.Value firstHeld, Ex.Value validUntil, Ex.Value (Just sapId)) <- l
-- , let persNoAsInt = readMay =<< persNo -- also see Handler.Utils.Profile.validFraportPersonalNumber
-- , persNoAsInt >= Just (10000::Int) -- filter E-accounts for SAP export
-- , persNoAsInt <= Just (99999::Int) -- filter E-accounts for SAP export
, let res = SapUserTableCsv
{ csvSUTpersonalNummer = persNo
, csvSUTqualifikation = sapId
, csvSUTgültigVon = firstHeld
@ -68,6 +69,7 @@ sapRes2csv l = [ res | (Ex.Value (Just persNo), Ex.Value firstHeld, Ex.Value val
-- , csvSUTsupendiertBis = blocked
, csvSUTausprägung = "J"
}
, validFraportPersonalNumber pn
]
-- | Deliver all employess with a successful LDAP synch within the last 3 months

View File

@ -5,12 +5,10 @@
-- TODO: why is this Handler.Utils.Profile instead of Utils.Profile?
-- TODO: consider merging with Handler.Utils.Users?
module Handler.Utils.Profile
( checkDisplayName
, validDisplayName
, fixDisplayName
( validDisplayName, checkDisplayName, fixDisplayName
, validPostAddress
, validEmail, validEmail'
, pickValidEmail, pickValidEmail'
, validEmail, validEmail', pickValidEmail, pickValidEmail'
, validFraportPersonalNumber
) where
import Import.NoFoundation
@ -103,4 +101,11 @@ pickValidEmail' :: UserEmail -> UserEmail -> Maybe UserEmail
pickValidEmail' x y
| validEmail' x = Just x
| validEmail' y = Just y
| otherwise = Nothing
| otherwise = Nothing
validFraportPersonalNumber :: Maybe Text -> Bool
validFraportPersonalNumber Nothing = False
validFraportPersonalNumber (Just t)
| (Just pn) <- readMay t
= pn >= (10000::Int) && pn <= (99999::Int) -- used to filter for SAP export
| otherwise = False

View File

@ -15,6 +15,7 @@ module Model.Types.DateTime
import Import.NoModel
import qualified Data.Set as Set
import Data.Ratio ((%))
import qualified Data.Text as Text
-- import Data.Either.Combinators (maybeToRight, mapLeft)
@ -206,3 +207,16 @@ derivePersistFieldJSON ''Occurrences
nullaryPathPiece ''DayOfWeek camelToPathPiece
-- | Get bounds for an Occurrences
-- TODO: unfinished function, only works for a few selected cases yet
occurrencesBounds :: Occurrences -> (Maybe Day, Maybe Day)
occurrencesBounds Occurrences{occurrencesScheduled=scd} | notNull scd = (Nothing, Nothing) -- TODO: case is not yet implemented
occurrencesBounds Occurrences{occurrencesExceptions=exc} = (Set.lookupMin occDays, Set.lookupMax occDays)
where
occDays = Set.foldr getOccDays mempty exc
getOccDays :: OccurrenceException -> Set Day -> Set Day
getOccDays ExceptNoOccur{} acc = acc -- TODO: this case ignores ExceptNoOccur for now!
getOccDays ExceptOccur{exceptDay} acc = Set.insert exceptDay acc

View File

@ -128,6 +128,9 @@ makeClassyFor_ ''LmsResult
makeClassyFor_ ''UserAvs
makeClassyFor_ ''UserAvsCard
makeClassyFor_ ''UserCompany
makeLenses_ ''Company
_entityKey :: Getter (Entity record) (Key record)
-- ^ Not a `Lens'` for safety
_entityKey = to entityKey

View File

@ -47,6 +47,7 @@ import Jobs.Handler.SendNotification.Utils
import Utils.Print.Letters
import Utils.Print.RenewQualification
import Utils.Print.CourseCertificate
-- import Model.Types.Markup -- TODO-QSV: should this module be moved accordingly?

View File

@ -1,4 +1,4 @@
-- SPDX-FileCopyrightText: 2022 Steffen Jost <jost@tcs.ifi.lmu.de>
-- SPDX-FileCopyrightText: 2023 Steffen Jost <jost@tcs.ifi.lmu.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later

View File

@ -8,8 +8,51 @@ date: 11.11.1111
...
$if(is-de)$
# Teilnahmebescheinigung
## $participant$
$if(fra-number)$
### $fra-number$ $fra-department$
$endif$
$if(company)$
### $company$
$endif$
Hat
$if(course-begin)$
von $course-begin$ bis $course-end$
$endif$
an der Veranstaltung
## $course-name$
der Fahrerausbildung der Fraport AG teilgenommen.
$if(course-content)$
### Inhalte:
$course-content$
$endif$
Mit Aushändigung der Teilnahmebescheinigung wird der erfolgreiche Abschluss des Kurses bestätigt.
Dieses Zertifikat wurde maschinell erstellt.
Frankfurt am Main, $date$
Fraport College
<!-- deutsche version -->
$else$
<!-- english version -->
<!-- english version -->
# Certificate of attendance
**English version is not yet implemened.**
TODO
$endif$