From 073432c75b73218b08c10bc6346ebeb20ad0b026 Mon Sep 17 00:00:00 2001 From: Steffen Date: Wed, 3 Jul 2024 16:50:38 +0200 Subject: [PATCH] chore(letter): allow for more different driving licence names in letters --- src/Utils/Print/RenewQualification.hs | 35 ++++++++++++++++++--------- templates/letter/fraport_renewal.md | 2 +- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/Utils/Print/RenewQualification.hs b/src/Utils/Print/RenewQualification.hs index 068cffa29..c8e935a8f 100644 --- a/src/Utils/Print/RenewQualification.hs +++ b/src/Utils/Print/RenewQualification.hs @@ -56,23 +56,36 @@ defaultNotice renewAuto l qualName qualShort newExpire , "(Kontaktieren Sie uns bitte, um zukünftige Briefe von uns in deutscher Sprache zu erhalten.)" ] +isAnyDrivingLicence :: Text -> Maybe Text +-- isAnyDrivingLicence = firstJust (Text.stripSuffix "führerschein") . Text.words . Text.replace "-" " " . Text.replace "+" "" +isAnyDrivingLicence = firstJust (Text.stripSuffix "führerschein") . Text.words . Text.map anyNonAlphaToBlank + +anyNonAlphaToBlank :: Char -> Char +anyNonAlphaToBlank c + | Char.isAlpha c + = c + | otherwise = ' ' + qualificationText :: Lang -> Text -> Text -> (Text, Text, Text) -- (qarea, qformal, qlicence) i.e. (Rollfeld, Rollfeldfahrberechtigung, Rollfeldführerschein) translated -qualificationText l qName@(Text.stripSuffix "führerschein" -> Just qPrefix) qShort - | isDe l - = (qPrefix, [st|Fahrberechtigung „#{qShort}“|], qName) - | qShort == "F" - = ("apron", [st|driving licence "#{qShort}"|], "apron driving licence") - | qShort == "R" - = ("maneuvering area", [st|driving licence "#{qShort}"|], "maneuvering area driving licence") - | otherwise - = (qPrefix, qPrefix <> " driving licence", qName) qualificationText l _qName "GSS" | isDe l = ("Gabelstapler", "Fahrberechtigung Gabelstapler", "Gabelstaplerführerschein") | otherwise - = ("Forklift", "forklift driving licence", "forklift driving licence") -qualificationText _l qName qShort + = ("forklift", "forklift driving licence", "forklift driving licence") +qualificationText l qName@(isAnyDrivingLicence -> Just qPrefix) qShort + | isDe l + = (qPrefix, [st|Fahrberechtigung „#{qShort}“|], qName) + | qShort == "F" + = ("apron", [st|driving licence "#{qShort}"|], "apron driving licence") + | Text.isPrefixOf "R" qShort + = ("maneuvering area", [st|driving licence "#{qShort}"|], "maneuvering area driving licence") + | otherwise + = (qPrefix, qPrefix <> " driving licence", qName) +qualificationText l qName qShort + | isDe l = (qShort, [st|Fahrberechtigung „#{qShort}“|], qName) + | otherwise + = (qShort, [st|driving licence "#{qShort}"|], qName) data LetterRenewQualification = LetterRenewQualification diff --git a/templates/letter/fraport_renewal.md b/templates/letter/fraport_renewal.md index 6166c9e2d..a27d3a5eb 100644 --- a/templates/letter/fraport_renewal.md +++ b/templates/letter/fraport_renewal.md @@ -128,7 +128,7 @@ we require by **$expiry$**, that the $if(practical)$ theorectical and practical $endif$ -airport-specific recurrent training at Fraport AG, +airport-specific $qarea$ recurrent training at Fraport AG, according to European Union Regulation No. 139/2014, has been completed.