chore(letter): allow for more different driving licence names in letters

This commit is contained in:
Steffen Jost 2024-07-03 16:50:38 +02:00
parent 0725a9a908
commit 073432c75b
2 changed files with 25 additions and 12 deletions

View File

@ -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

View File

@ -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.