Merge branch 'Preorder/change-custom-notification' into 'master'

only efh buildings based on building type

See merge request fronk/thetool!1469
This commit is contained in:
Luca Haid
2025-06-17 12:35:10 +00:00

View File

@@ -28,12 +28,15 @@ SELECT
FROM Preorder p
INNER JOIN Preordercampaign pc ON p.preordercampaign_id = pc.id
INNER JOIN PreordercampaignStatusnotificationMailtemplate pcsmt ON pc.id = pcsmt.preordercampaign_id
INNER JOIN `" . ADDRESSDB_DBNAME . "`.Hausnummer hn ON p.adb_wohneinheit_id = hn.id
INNER JOIN Preorderstatus ps_current ON p.status_id = ps_current.id
INNER JOIN first_status_300_plus fs ON p.id = fs.preorder_id
LEFT JOIN PreorderStatusnotificationLog psnl ON p.id = psnl.preorder_id AND psnl.email_type = '300-custom'
WHERE p.type = 'order'
AND ps_current.code >= 300
AND ps_current.code < 500
AND hn.id IS NOT NULL
AND hn.tool_building_type = 1 -- Only consider residential buildings
AND pcsmt.notification_type = 'logical'
AND JSON_EXTRACT(pcsmt.logical_config, '$.type') = '300-custom'
AND psnl.id IS NULL -- No existing '300-custom' notification