Compare commits
15
Commits
8c8d655336
...
5f69c9daa5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f69c9daa5 | ||
|
|
36955a1e98 | ||
|
|
736128476b | ||
|
|
8e4afc0813 | ||
|
|
e5fa63b7e8 | ||
|
|
84df3a94d9 | ||
|
|
2c381ee741 | ||
|
|
dc86e715cb | ||
|
|
5f2252af71 | ||
|
|
455456b6bc | ||
|
|
045fdea923 | ||
|
|
8ff13614d2 | ||
|
|
331c88c38e | ||
|
|
c31d086356 | ||
|
|
dde36ccba2 |
No files matched your search
@@ -54,6 +54,10 @@ APP_NEWSLETTER_CONFIRMATION_TTL_HOURS=1
|
||||
# (override in .env.local/production secrets as usual).
|
||||
ACCOMMODATION_OFFER_LINK_SECRET=abf8ec28cc2162d9121d35d6f8cbf7c29728cdacce0303e22e1bac854501728a
|
||||
|
||||
ACCOMMODATION_TERMS_AT=
|
||||
ACCOMMODATION_TERMS_CH=
|
||||
ACCOMMODATION_TERMS_IT=
|
||||
|
||||
BPN_CONNECT_BASE_URL=https://bpn-connect.ep-reisen.app
|
||||
BPN_CONNECT_API_KEY=
|
||||
|
||||
@@ -84,7 +88,7 @@ APP_TRAVEL_SNAPSHOT_RETENTION_BUFFER_DAYS=14
|
||||
# Emails
|
||||
APP_DEFAULT_EMAIL_FROM=[email protected]
|
||||
APP_DEFAULT_EMAIL_TO=[email protected]
|
||||
ACCOMMODATION_INQUIRY_EMAIL=info@ep-reisen.de
|
||||
ACCOMMODATION_INQUIRY_EMAIL=gruppen@ep-reisen.de
|
||||
|
||||
# Global common defaults
|
||||
APP_SEASON_WINTER_FROM=2026-10-01
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
|
||||
/**
|
||||
* Unchecks conflicting additional services as soon as one is selected, so the user sees the
|
||||
* result immediately instead of waiting for the debounced htmx refresh. The server resolves
|
||||
* the same conflicts again and stays the source of truth.
|
||||
*/
|
||||
export default class extends Controller {
|
||||
|
||||
static targets = [ 'input' ]
|
||||
|
||||
select(event) {
|
||||
const input = event.target
|
||||
|
||||
if (!input.checked) {
|
||||
return
|
||||
}
|
||||
|
||||
const group = input.dataset.exclusionGroup
|
||||
|
||||
if (!group) {
|
||||
return
|
||||
}
|
||||
|
||||
const exclusive = '1' === input.dataset.exclusive
|
||||
|
||||
this.inputTargets
|
||||
.filter(other => other !== input)
|
||||
.filter(other => other.dataset.exclusionGroup === group)
|
||||
.filter(other => exclusive || '1' === other.dataset.exclusive)
|
||||
.forEach(other => { other.checked = false })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { Controller } from '@hotwired/stimulus'
|
||||
import Sortable from 'sortablejs'
|
||||
|
||||
export default class extends Controller {
|
||||
|
||||
static targets = [ 'list', 'item', 'handle', 'positionField', 'positionLabel', 'status' ]
|
||||
|
||||
static values = {
|
||||
url: String,
|
||||
}
|
||||
|
||||
connect() {
|
||||
this.abortController = null
|
||||
|
||||
// The sortable container may be nested (e.g. a tbody) when the controller element also
|
||||
// has to wrap elements that must not be dragged, like the status message.
|
||||
new Sortable(this.hasListTarget ? this.listTarget : this.element, {
|
||||
draggable: '[data-sortable-target="item"]',
|
||||
handle: '[data-sortable-target="handle"]',
|
||||
sort: true,
|
||||
fallbackOnBody: true,
|
||||
onEnd: e => {
|
||||
this.updateOrdering()
|
||||
this.persist()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
this.abortController?.abort()
|
||||
}
|
||||
|
||||
updateOrdering() {
|
||||
this.positionFieldTargets.forEach((field, index) => {
|
||||
field.value = index + 1
|
||||
})
|
||||
this.positionLabelTargets.forEach((label, index) => {
|
||||
label.innerText = index + 1
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the new order to the server. Only active when a url value is present, so the
|
||||
* controller stays usable for plain form ordering.
|
||||
*/
|
||||
persist() {
|
||||
if (!this.hasUrlValue || this.urlValue === '') {
|
||||
return
|
||||
}
|
||||
|
||||
// A drag while the previous request is still running makes that request obsolete.
|
||||
this.abortController?.abort()
|
||||
this.abortController = new AbortController()
|
||||
|
||||
const ids = this.itemTargets
|
||||
.map(item => Number(item.dataset.sortableId))
|
||||
.filter(id => Number.isInteger(id) && id > 0)
|
||||
|
||||
this.setStatus('speichert …')
|
||||
|
||||
fetch(this.urlValue, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
signal: this.abortController.signal,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ ids }),
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Unexpected response ${response.status}`)
|
||||
}
|
||||
this.setStatus('Reihenfolge gespeichert')
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.name === 'AbortError') {
|
||||
return
|
||||
}
|
||||
console.error('Failed to persist ordering', error)
|
||||
this.setStatus('Speichern fehlgeschlagen')
|
||||
})
|
||||
}
|
||||
|
||||
setStatus(message) {
|
||||
this.statusTargets.forEach(status => {
|
||||
status.innerText = message
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 700 490" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g>
|
||||
<g>
|
||||
<defs>
|
||||
<mask id="Mask">
|
||||
|
||||
<g transform="matrix(0.00288044,8.84736e-05,8.84736e-05,-0.00288044,-0.5862,0.835135)"><image id="_Image2" width="700px" height="490px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArwAAAHqCAAAAADD7sLoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGsElEQVR4nO3dQW7bRgBA0SHTm/VGvWCPVQRIqy4cSVHkBKRlmvzWewsDjClybPxMZiJZnk4Dmua9BwBvJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXrD/2HsDDTt8+5j7Tp7jFytv8u90o3kE/3r//XHzqfP4wzXdH03Q+msYY8/lofDn/0TT9eDRP46WC6f4xrxxdHvzaCTe3H/PN7W9PuB3MK1/O/Wiv15tuTvjVaOfx/dR5GuOfvxZ/b/dg2UCWeMkSL1niPZiVm7Zp3WOWnflBG8eH9Tds7+kt5Sw78737upy5xYXHZX93bGZessRLlnjJsub92YrlKfsy85IlXrLES5Z4f2/nBbD19+/YsP3ayucg3v3Zq+2eMll34cMy85IlXrLES9bTrXlXLE+3HcPCU8fuoz0uMy9Z4iVLvGSJd6m918n73v6Qnm7D9iZHKGeLTd4Rvq4HmHnJEi9Z4iXrmde8B3jhy3aLziOMYWtm3t35b4y3Ei9Z4iVLvGQ984ZtjOSrtoJD3oiZlyzxkiVesp59zXuxyZuQLj917ZtMbXLh2krazLulVg2t0Q7xEiZessRLlg3b1rbZCTLMvISJlyzxkiXeBx3hZyE2u+bBF+E2bHcO8JPjOz/dV3nhmpmXLPGSJV6ynmXNu/KXTG/3+6i38Kzv92vm/TjbRvNpklxOvGSJl6xnWfOepjHGaXz/cLr8G/vfOP+aivNqcJrHuK4Nbz/38nd9/vHo+rnp/jHXS033J9xe4XqZMcZ8c/TQ+F45GsvGN43xdfk3eA/PEu9Ls2O85MqnYNlAlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVesv4HAfsUn4ytnvgAAAAASUVORK5CYII="/>
|
||||
</g>
|
||||
</mask>
|
||||
</defs>
|
||||
<g mask="url(#Mask)">
|
||||
<path d="M194.119,305.842C276.606,300.464 338.37,307.962 339.484,308.146C443.176,325.422 503.557,327.571 540.702,324.728L540.867,319.638C514.426,320.951 478.688,316.871 434.918,311.559C400.804,307.419 306.697,277.408 195.03,276.09L194.119,305.842Z" style="fill:url(#_Linear1);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<path d="M197.896,191.813L263.503,143.048L280.105,147.93L308,116.748L343.653,164.795L368.768,174.295L433.766,244.544L364.027,189.537L348.682,194.693L311.065,147L294.029,164.035L268.834,159.229L238.564,191.454L239.319,171.647L197.896,191.813Z" style="fill:rgb(25,64,80);fill-rule:nonzero;"/>
|
||||
<path d="M38.408,306.474C32.18,326.891 27.643,336.159 27.643,336.159C142.218,243.379 280.978,259.659 329.465,268.035C309.049,261.755 276.356,253.993 236.312,252.714C233.474,252.619 230.617,252.577 227.737,252.577C164.07,252.577 90.101,274.674 38.408,306.474Z" style="fill:url(#_Linear3);fill-rule:nonzero;"/>
|
||||
<path d="M602.405,251.387C598.632,265.755 587.357,277.441 568.9,286.133C545.646,297.083 503.477,293.225 446.803,275.075C503.429,297.055 546.732,303.825 570.113,294.462C588.056,287.276 599.307,277.049 603.538,264.06C606.541,254.838 605.79,245.126 603.793,236.74C604.062,241.537 603.698,246.481 602.405,251.387Z" style="fill:url(#_Linear4);fill-rule:nonzero;"/>
|
||||
<path d="M605.397,211.094L598.994,215.409C599.174,215.674 617.073,242.823 609.679,268.117C605.51,282.372 593.852,293.765 575.037,301.985C550.593,312.652 506.299,307.123 446.929,285.984C401.072,269.647 362.435,249.627 362.114,249.457C360.612,248.668 215.374,173.608 69.773,226.274C77.162,248.414 43.719,292.66 43.719,292.66C200.142,196.079 356.618,273.877 358.332,274.656C497.597,337.936 553.312,328.53 581.212,316.131C655.404,283.16 606.303,212.439 605.397,211.094" style="fill:rgb(17,142,206);fill-rule:nonzero;"/>
|
||||
<path d="M600.278,217.512L606.147,212.228L600.581,202.639L578.087,165.139L562.014,162.674L523.519,106.019L514.326,111.057L492.375,98.148L455.456,140.096L390.467,39.17C390.467,39.17 377.747,37.716 367.194,35.266C356.622,32.81 330.597,14.462 330.597,14.462L227.896,119.816L206.63,102.138L79.887,212.658L205.945,124.457L222.915,143.594L339.412,39.199L361.863,104.782L369.352,79.049L419.68,129.184L437.972,178.766L453.331,174.016L458.28,217.927L509.42,132.182L532.48,143.533L563.393,178.941L577.921,181.66L595.665,210.07L600.278,217.512Z" style="fill:rgb(25,64,80);fill-rule:nonzero;"/>
|
||||
<path d="M598.991,215.408C599.175,215.672 617.07,242.822 609.681,268.116C605.511,282.37 593.854,293.764 575.038,301.984C551.165,312.4 508.335,307.334 451.085,287.418L450.377,310.289C524.455,332.854 560.505,325.328 581.209,316.13C655.4,283.159 606.305,212.438 605.398,211.092L598.991,215.408Z" style="fill:url(#_Linear5);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g transform="matrix(141.308,0,0,141.308,702.346,466.324)">
|
||||
</g>
|
||||
<text x="-0.827px" y="466.324px" style="font-family:'BebasNeue-Regular', 'Bebas Neue', sans-serif;font-size:141.308px;fill:rgb(30,28,26);">A<tspan x="55.719px 104.212px 158.639px 185.652px 245.873px 297.051px 346.956px 403.22px 457.224px 507.27px 558.589px 585.602px 642.008px " y="466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px ">LPINEVACATION</tspan></text>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(346.842,10.6534,-10.6534,346.842,194.415,296.129)"><stop offset="0" style="stop-color:rgb(188,187,186);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(86,85,83);stop-opacity:1"/></linearGradient>
|
||||
<linearGradient id="_Linear3" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(301.821,0,0,301.821,27.6449,294.368)"><stop offset="0" style="stop-color:rgb(56,165,72);stop-opacity:1"/><stop offset="0.04" style="stop-color:rgb(56,165,72);stop-opacity:1"/><stop offset="0.91" style="stop-color:rgb(163,198,57);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(163,198,57);stop-opacity:1"/></linearGradient>
|
||||
<linearGradient id="_Linear4" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(158.742,0,0,158.742,446.802,267.649)"><stop offset="0" style="stop-color:rgb(56,165,72);stop-opacity:1"/><stop offset="0.04" style="stop-color:rgb(56,165,72);stop-opacity:1"/><stop offset="0.91" style="stop-color:rgb(163,198,57);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(163,198,57);stop-opacity:1"/></linearGradient>
|
||||
<linearGradient id="_Linear5" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(170.152,5.22629,-5.22629,170.152,451.782,264.535)"><stop offset="0" style="stop-color:rgb(17,142,206);stop-opacity:1"/><stop offset="0.04" style="stop-color:rgb(17,142,206);stop-opacity:1"/><stop offset="0.91" style="stop-color:rgb(24,64,80);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(24,64,80);stop-opacity:1"/></linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 700 490" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g>
|
||||
<g>
|
||||
<defs>
|
||||
<mask id="Mask">
|
||||
|
||||
<g transform="matrix(0.00288044,8.84736e-05,8.84736e-05,-0.00288044,-0.5862,0.835135)"><image id="_Image2" width="700px" height="490px" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArwAAAHqCAAAAADD7sLoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGsElEQVR4nO3dQW7bRgBA0SHTm/VGvWCPVQRIqy4cSVHkBKRlmvzWewsDjClybPxMZiJZnk4Dmua9BwBvJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXrD/2HsDDTt8+5j7Tp7jFytv8u90o3kE/3r//XHzqfP4wzXdH03Q+msYY8/lofDn/0TT9eDRP46WC6f4xrxxdHvzaCTe3H/PN7W9PuB3MK1/O/Wiv15tuTvjVaOfx/dR5GuOfvxZ/b/dg2UCWeMkSL1niPZiVm7Zp3WOWnflBG8eH9Tds7+kt5Sw78737upy5xYXHZX93bGZessRLlnjJsub92YrlKfsy85IlXrLES5Z4f2/nBbD19+/YsP3ayucg3v3Zq+2eMll34cMy85IlXrLES9bTrXlXLE+3HcPCU8fuoz0uMy9Z4iVLvGSJd6m918n73v6Qnm7D9iZHKGeLTd4Rvq4HmHnJEi9Z4iXrmde8B3jhy3aLziOMYWtm3t35b4y3Ei9Z4iVLvGQ984ZtjOSrtoJD3oiZlyzxkiVesp59zXuxyZuQLj917ZtMbXLh2krazLulVg2t0Q7xEiZessRLlg3b1rbZCTLMvISJlyzxkiXeBx3hZyE2u+bBF+E2bHcO8JPjOz/dV3nhmpmXLPGSJV6ynmXNu/KXTG/3+6i38Kzv92vm/TjbRvNpklxOvGSJl6xnWfOepjHGaXz/cLr8G/vfOP+aivNqcJrHuK4Nbz/38nd9/vHo+rnp/jHXS033J9xe4XqZMcZ8c/TQ+F45GsvGN43xdfk3eA/PEu9Ls2O85MqnYNlAlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGSJlyzxkiVesv4HAfsUn4ytnvgAAAAASUVORK5CYII="/>
|
||||
</g>
|
||||
</mask>
|
||||
</defs>
|
||||
<g mask="url(#Mask)">
|
||||
<path d="M194.119,305.842C276.606,300.464 338.37,307.962 339.484,308.146C443.176,325.422 503.557,327.571 540.702,324.728L540.867,319.638C514.426,320.951 478.688,316.871 434.918,311.559C400.804,307.419 306.697,277.408 195.03,276.09L194.119,305.842Z" style="fill:url(#_Linear1);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<path d="M197.896,191.813L263.503,143.048L280.105,147.93L308,116.748L343.653,164.795L368.768,174.295L433.766,244.544L364.027,189.537L348.682,194.693L311.065,147L294.029,164.035L268.834,159.229L238.564,191.454L239.319,171.647L197.896,191.813Z" style="fill:rgb(25,64,80);fill-rule:nonzero;"/>
|
||||
<path d="M38.408,306.474C32.18,326.891 27.643,336.159 27.643,336.159C142.218,243.379 280.978,259.659 329.465,268.035C309.049,261.755 276.356,253.993 236.312,252.714C233.474,252.619 230.617,252.577 227.737,252.577C164.07,252.577 90.101,274.674 38.408,306.474Z" style="fill:url(#_Linear3);fill-rule:nonzero;"/>
|
||||
<path d="M602.405,251.387C598.632,265.755 587.357,277.441 568.9,286.133C545.646,297.083 503.477,293.225 446.803,275.075C503.429,297.055 546.732,303.825 570.113,294.462C588.056,287.276 599.307,277.049 603.538,264.06C606.541,254.838 605.79,245.126 603.793,236.74C604.062,241.537 603.698,246.481 602.405,251.387Z" style="fill:url(#_Linear4);fill-rule:nonzero;"/>
|
||||
<path d="M605.397,211.094L598.994,215.409C599.174,215.674 617.073,242.823 609.679,268.117C605.51,282.372 593.852,293.765 575.037,301.985C550.593,312.652 506.299,307.123 446.929,285.984C401.072,269.647 362.435,249.627 362.114,249.457C360.612,248.668 215.374,173.608 69.773,226.274C77.162,248.414 43.719,292.66 43.719,292.66C200.142,196.079 356.618,273.877 358.332,274.656C497.597,337.936 553.312,328.53 581.212,316.131C655.404,283.16 606.303,212.439 605.397,211.094" style="fill:rgb(17,142,206);fill-rule:nonzero;"/>
|
||||
<path d="M600.278,217.512L606.147,212.228L600.581,202.639L578.087,165.139L562.014,162.674L523.519,106.019L514.326,111.057L492.375,98.148L455.456,140.096L390.467,39.17C390.467,39.17 377.747,37.716 367.194,35.266C356.622,32.81 330.597,14.462 330.597,14.462L227.896,119.816L206.63,102.138L79.887,212.658L205.945,124.457L222.915,143.594L339.412,39.199L361.863,104.782L369.352,79.049L419.68,129.184L437.972,178.766L453.331,174.016L458.28,217.927L509.42,132.182L532.48,143.533L563.393,178.941L577.921,181.66L595.665,210.07L600.278,217.512Z" style="fill:rgb(25,64,80);fill-rule:nonzero;"/>
|
||||
<path d="M598.991,215.408C599.175,215.672 617.07,242.822 609.681,268.116C605.511,282.37 593.854,293.764 575.038,301.984C551.165,312.4 508.335,307.334 451.085,287.418L450.377,310.289C524.455,332.854 560.505,325.328 581.209,316.13C655.4,283.159 606.305,212.438 605.398,211.092L598.991,215.408Z" style="fill:url(#_Linear5);fill-rule:nonzero;"/>
|
||||
</g>
|
||||
<g transform="matrix(141.308,0,0,141.308,674.94,466.324)">
|
||||
</g>
|
||||
<text x="24.191px" y="466.324px" style="font-family:'BebasNeue-Regular', 'Bebas Neue', sans-serif;font-size:141.308px;fill:rgb(30,28,26);">C<tspan x="78.195px 126.687px 164.157px 215.476px 237.967px 288.721px 345.126px 401.814px 458.644px 485.657px 538.106px 589.425px 616.438px " y="466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px 466.324px ">LLT Touristik</tspan></text>
|
||||
</g>
|
||||
<defs>
|
||||
<linearGradient id="_Linear1" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(346.842,10.6534,-10.6534,346.842,194.415,296.129)"><stop offset="0" style="stop-color:rgb(188,187,186);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(86,85,83);stop-opacity:1"/></linearGradient>
|
||||
<linearGradient id="_Linear3" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(301.821,0,0,301.821,27.6449,294.368)"><stop offset="0" style="stop-color:rgb(56,165,72);stop-opacity:1"/><stop offset="0.04" style="stop-color:rgb(56,165,72);stop-opacity:1"/><stop offset="0.91" style="stop-color:rgb(163,198,57);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(163,198,57);stop-opacity:1"/></linearGradient>
|
||||
<linearGradient id="_Linear4" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(158.742,0,0,158.742,446.802,267.649)"><stop offset="0" style="stop-color:rgb(56,165,72);stop-opacity:1"/><stop offset="0.04" style="stop-color:rgb(56,165,72);stop-opacity:1"/><stop offset="0.91" style="stop-color:rgb(163,198,57);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(163,198,57);stop-opacity:1"/></linearGradient>
|
||||
<linearGradient id="_Linear5" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(170.152,5.22629,-5.22629,170.152,451.782,264.535)"><stop offset="0" style="stop-color:rgb(17,142,206);stop-opacity:1"/><stop offset="0.04" style="stop-color:rgb(17,142,206);stop-opacity:1"/><stop offset="0.91" style="stop-color:rgb(24,64,80);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(24,64,80);stop-opacity:1"/></linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
Generated
+10
-10
@@ -11962,11 +11962,11 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "2.2.7",
|
||||
"version": "2.2.8",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/692db47b9dddb0487934e5236e77d48594aef921",
|
||||
"reference": "692db47b9dddb0487934e5236e77d48594aef921",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/e285254e60f33c21902efef4a926ca0987c06804",
|
||||
"reference": "e285254e60f33c21902efef4a926ca0987c06804",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -12022,7 +12022,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-07-29T17:39:32+00:00"
|
||||
"time": "2026-08-04T22:21:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-doctrine",
|
||||
@@ -13117,16 +13117,16 @@
|
||||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
"version": "2.6.0",
|
||||
"version": "2.6.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rectorphp/rector.git",
|
||||
"reference": "24ef17c06737a6272806c5cca32b860449efe1ba"
|
||||
"reference": "b8e68f058bca43e01a2e1caa51ef022d6551ed95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/24ef17c06737a6272806c5cca32b860449efe1ba",
|
||||
"reference": "24ef17c06737a6272806c5cca32b860449efe1ba",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/b8e68f058bca43e01a2e1caa51ef022d6551ed95",
|
||||
"reference": "b8e68f058bca43e01a2e1caa51ef022d6551ed95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -13165,7 +13165,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rectorphp/rector/issues",
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.6.0"
|
||||
"source": "https://github.com/rectorphp/rector/tree/2.6.1"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -13173,7 +13173,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-08-03T09:01:59+00:00"
|
||||
"time": "2026-08-03T17:30:34+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
||||
@@ -265,7 +265,14 @@ services:
|
||||
|
||||
App\Service\AccommodationBookingService:
|
||||
arguments:
|
||||
$officeEmail: '%accommodation_inquiry_email%'
|
||||
$accommodationEmail: '%accommodation_inquiry_email%'
|
||||
|
||||
App\Service\AccommodationTermsUrlProvider:
|
||||
arguments:
|
||||
$config:
|
||||
AT: '%env(ACCOMMODATION_TERMS_AT)%'
|
||||
CH: '%env(ACCOMMODATION_TERMS_CH)%'
|
||||
IT: '%env(ACCOMMODATION_TERMS_IT)%'
|
||||
|
||||
App\Service\GroupsPriceCalculator:
|
||||
arguments:
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
# Body Dimensions Transition Plan (Stakeholder Draft)
|
||||
|
||||
> **STATUS (verified 2026-07-15): NOT IMPLEMENTED.** `src/Form/BodyDimensionsType.php` still declares `height`, `shoeSize`, and `weight` as `IntegerType` fields, and `src/Validator/Constraints/ParticipantValidator.php` has no regex/legacy-format handling — only numeric range checks. This plan has not been acted on.
|
||||
|
||||
## Goal
|
||||
|
||||
Prevent edit-form failures for existing bookings while we transition from legacy body-dimension values to a better long-term field model.
|
||||
|
||||
This plan introduces a temporary compatibility phase and keeps sunsetting manual and straightforward.
|
||||
|
||||
## Current Problem
|
||||
|
||||
- Existing bookings may contain legacy values such as `-148`, `149-157`, or `195+`.
|
||||
- Integer-only form fields can fail when these legacy strings are loaded.
|
||||
- Result: participant edit forms can crash before submit.
|
||||
|
||||
## Proposed Transition Strategy
|
||||
|
||||
Use **text input fields** for body dimensions during transition, with explicit server-side format validation.
|
||||
|
||||
### Key Decisions
|
||||
|
||||
- No gating by booking create date.
|
||||
- One unified behavior for all bookings.
|
||||
- Accept both legacy and numeric formats during transition.
|
||||
- Keep manual sunsetting later (no automated migration switch).
|
||||
|
||||
## Functional Scope
|
||||
|
||||
Affected fields:
|
||||
|
||||
- `height`
|
||||
- `weight`
|
||||
- `shoeSize`
|
||||
|
||||
Affected components:
|
||||
|
||||
- `src/Form/BodyDimensionsType.php`
|
||||
- `src/Validator/Constraints/ParticipantValidator.php`
|
||||
- `src/Form/BookingParticipantType.php` (option passthrough already in place)
|
||||
- `config/services.yaml` (ranges remain as validation/config source)
|
||||
|
||||
## Validation Rules During Transition
|
||||
|
||||
### Accepted formats
|
||||
|
||||
- Numeric value: `^\d+$` (e.g. `176`)
|
||||
- Legacy lower/open/range tokens:
|
||||
- `^-\d+$` (e.g. `-148`)
|
||||
- `^\d+\+$` (e.g. `195+`)
|
||||
- `^\d+\s*-\s*\d+$` (e.g. `149-157`)
|
||||
|
||||
### Requiredness
|
||||
|
||||
- Keep existing rule: body dimensions required when rentals are selected.
|
||||
|
||||
### Range checks
|
||||
|
||||
- Keep current numeric range checks based on `body_dimension_ranges`.
|
||||
- Apply range checks only to plain numeric values in transition phase.
|
||||
|
||||
## UX/Behavior Expectations
|
||||
|
||||
- Existing legacy values render without form initialization errors.
|
||||
- New numeric entries are accepted and validated.
|
||||
- Invalid free text (e.g. `abc`, `17x`) shows clear validation errors.
|
||||
- HTMX refresh behavior remains unchanged.
|
||||
|
||||
## Implementation Steps
|
||||
|
||||
1. **Form type change**
|
||||
- In `BodyDimensionsType`, replace integer fields with text fields for all three body dimensions.
|
||||
- Keep labels/help text; keep placeholders based on configured ranges.
|
||||
|
||||
2. **Validator extension**
|
||||
- Add format validation for all three fields in `ParticipantValidator`.
|
||||
- Keep existing required-when-rentals logic.
|
||||
- Keep existing range validation for numeric values.
|
||||
|
||||
3. **Message tuning**
|
||||
- Add one clear message for invalid format.
|
||||
- Retain existing range message for numeric out-of-range values.
|
||||
|
||||
4. **Testing and QA**
|
||||
- Validate old bookings with legacy values open/edit successfully.
|
||||
- Validate numeric path (valid and invalid range).
|
||||
- Validate invalid format handling.
|
||||
- Validate rental-required behavior.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- No 500 error when editing participants with legacy body-dimension values.
|
||||
- Legacy values can be loaded and submitted in transition phase.
|
||||
- Numeric values are accepted and range-validated.
|
||||
- Invalid text is rejected with a user-facing validation message.
|
||||
- Existing participant edit/refresh flows continue to work.
|
||||
|
||||
## Risks and Mitigations
|
||||
|
||||
- **Risk:** Free-text field semantics are less strict than integer fields.
|
||||
- **Mitigation:** strict server-side regex + range checks.
|
||||
|
||||
- **Risk:** Inconsistent data representations during transition.
|
||||
- **Mitigation:** explicit acceptance policy and manual sunset plan.
|
||||
|
||||
## Effort Estimate
|
||||
|
||||
- Implementation: 0.5 day
|
||||
- Validation/message tuning: 0.25 day
|
||||
- QA/manual testing: 0.5 day
|
||||
- **Total:** ~1 to 1.5 days
|
||||
|
||||
## Manual Sunset Plan (Later)
|
||||
|
||||
When stakeholders approve end of transition:
|
||||
|
||||
1. Replace text fields with final semantic field type(s).
|
||||
2. Remove legacy format acceptance from validator.
|
||||
3. Keep only final numeric/range validation behavior.
|
||||
4. Remove transition-specific tests and copy.
|
||||
|
||||
Expected cleanup effort: ~0.25 to 0.5 day.
|
||||
@@ -1,196 +0,0 @@
|
||||
# Booking Flow Reference
|
||||
|
||||
Last updated: 2026-07-15
|
||||
|
||||
This document traces the booking create and edit flows from controller entry point through to session/DTO state. It is intended as orientation for developers unfamiliar with the flow, not as a substitute for reading the code.
|
||||
|
||||
---
|
||||
|
||||
## Shared Concepts
|
||||
|
||||
### `BookingDto`
|
||||
|
||||
The central data object for both flows. Holds room selections, participants, payment method, and travel reference. Lives in the HTTP session between requests. Has two modes: `MODE_CREATE` and `MODE_EDIT`.
|
||||
|
||||
### `BookingSessionManager`
|
||||
|
||||
Owns all reads and writes to session-stored `BookingDto` instances. Also manages the baseline room snapshot used for change detection in the create flow.
|
||||
|
||||
### `BookingCreateContextFactory`
|
||||
|
||||
Assembles the view model (`BookingCreateContext`) passed to create-flow templates. Handles room grouping (by-pax vs. by-room) and wires summary sidebar data.
|
||||
|
||||
---
|
||||
|
||||
## Create Flow
|
||||
|
||||
```
|
||||
Step 1 (room selection)
|
||||
→ Step 2 (participants)
|
||||
→ Step 2 sub-form (per-participant, HTMX)
|
||||
→ Step 3 (payment + API pre-validation)
|
||||
→ Step 4 (confirmation + final submission)
|
||||
→ Success
|
||||
```
|
||||
|
||||
### Entry / Bootstrap
|
||||
|
||||
`AbstractBookingCreateController::loadBookingCreateDto()` is called by every step controller and delegates to `BookingSessionManager::getOrCreateBookingCreateDto()`. If no DTO exists in session, `BookingConfigurator::startFreshBooking()` loads travel data and initialises a fresh `BookingDto`.
|
||||
|
||||
### Step 1 — Room Selection
|
||||
|
||||
**Controller:** `Create/Step1Controller`
|
||||
**Route:** `GET|POST /bookings/create/rooms`
|
||||
|
||||
1. Load or create DTO via `getOrCreateBookingCreateDto()`
|
||||
2. `BookingSessionManager::getOrCreateBaselineSnapshot()` — saves the current room selection as a comparison point for change detection
|
||||
3. Render `BookingCreateStep1Type` form
|
||||
4. On submit:
|
||||
- If room selection changed from baseline: `BookingDto::resetParticipantAssignments()` — clears stale assignments
|
||||
- `BookingConfigurator::updateBookingStatusFromRoomSelection()` — may switch booking to inquiry mode if capacity constraints require it
|
||||
- `BookingSessionManager::saveBookingDto()`, advance `currentStep` to 2
|
||||
- `BookingSessionManager::clearBaselineSnapshot()`
|
||||
- Redirect to Step 2
|
||||
|
||||
HTMX refresh (`/bookings/create/refresh`): processes the form without validation and returns updated room selection + summary sidebar blocks.
|
||||
|
||||
### Step 2 — Participants (Card Overview)
|
||||
|
||||
**Controller:** `Create/Step2Controller`
|
||||
**Route:** `GET|POST /bookings/create/participants`
|
||||
|
||||
1. Load DTO from session (or redirect to Step 1 if missing)
|
||||
2. `TravelDataProvider::enrichWithFreshAvailabilities()` — refreshes room availability
|
||||
3. `ensureCorrectNumberOfParticipants()` — syncs the `BookingDto::participants` array length with the room selections (e.g., 2× double room → 4 participants). Preserves existing participant data for slots that still exist.
|
||||
4. `ParticipantDataPrefiller::shouldPrefillApplicant()` + `prefillApplicantFromUser()` — prefills participant[0] from user profile on first visit
|
||||
5. `RoomAssigner::validateAndResetInvalidAssignments()` — clears any room assignments that no longer match the current room selection (handles back-navigation from Step 2 → Step 1 → Step 2)
|
||||
6. `RoomAssigner::assignRoomsIfNeeded()` — auto-assigns participants to rooms
|
||||
7. `BookingConfigurator::preselectDefaultServices()` — selects mandatory and auto-book services for all participants
|
||||
8. `BookingConfigurator::applyCreateBookingStatusRules()` — re-evaluates booking status (book / inquiry / not-bookable)
|
||||
9. `BookingSessionManager::saveBookingDto()`
|
||||
10. On form submit (all participants valid): advance to Step 3, redirect
|
||||
|
||||
### Step 2 — Individual Participant Form (HTMX)
|
||||
|
||||
**Controller:** `Create/Step2ParticipantController`
|
||||
**Routes:** `GET|POST /bookings/create/participants/{index}` and `/participants/{index}/refresh`
|
||||
|
||||
Each participant card lazy-loads its form via HTMX. The controller:
|
||||
|
||||
1. Verifies the participant slot exists
|
||||
2. Refreshes availability
|
||||
3. Handles dummy data fill (`ParticipantDataPrefiller::isDummyDataFillRequested()` / `fillDummyParticipant()`)
|
||||
4. On submit: re-applies status rules, saves to session, redirects to card overview
|
||||
5. `ParticipantFormSupport` is used for form creation options and notification draining
|
||||
|
||||
### Step 3 — Payment + API Pre-Validation
|
||||
|
||||
**Controller:** `Create/Step3Controller`
|
||||
**Route:** `GET|POST /bookings/create/payment`
|
||||
|
||||
1. Load DTO from session
|
||||
2. `BookingConfigurator::applyCreateBookingStatusRules()`
|
||||
3. On submit:
|
||||
- `ApiClient::createBookingInquiry()` — submits booking to API for validation without committing it
|
||||
- If inquiry fails with "nicht möglich" + "Anfrage" in message: auto-switch to inquiry mode, advance to Step 4
|
||||
- If inquiry fails otherwise: show error, stay on step
|
||||
- Price verification: `BookingPriceCalculator::calculateGrandTotal()` is compared against the API response total (accounting for promotional/goodwill voucher discounts and API-applied group discounts). Mismatch triggers `BookingPriceMismatchAnalyzer` for detailed logging.
|
||||
- On success: advance `currentStep` to 4, redirect
|
||||
|
||||
### Step 4 — Confirmation + Final Submission
|
||||
|
||||
**Controller:** `Create/Step4Controller`
|
||||
**Route:** `GET|POST /bookings/create/confirmation`
|
||||
|
||||
1. Load DTO from session
|
||||
2. Newsletter subscription check for opt-in display
|
||||
3. On submit:
|
||||
- `BookingConfigurator::applyCreateBookingStatusRules()`
|
||||
- `ApiClient::createBooking()` — final booking submission (already validated in Step 3)
|
||||
- Newsletter double-opt-in if selected
|
||||
- On success: store booking number + total in flash (for analytics), clear travel data cache, `BookingSessionManager::clearBookingDto()`, redirect to success page
|
||||
|
||||
---
|
||||
|
||||
## Edit Flow
|
||||
|
||||
```
|
||||
Entry (start)
|
||||
→ Load (session or API + draft restore)
|
||||
→ Participant sub-forms (HTMX, per-participant)
|
||||
→ Submission
|
||||
```
|
||||
|
||||
### Entry
|
||||
|
||||
**Controller:** `Edit/IndexController::start()`
|
||||
**Route:** `GET /bookings/{id}/edit/start`
|
||||
|
||||
Clears any existing session DTO for edit mode and invalidates the API booking cache, then redirects to the edit page. This ensures a clean load from API on every intentional re-entry.
|
||||
|
||||
### Load
|
||||
|
||||
**Controller:** `Edit/IndexController::index()`
|
||||
**Route:** `GET|POST /bookings/{id}/edit`
|
||||
|
||||
Loading is delegated entirely to `BookingEditDataLoader::loadFormData()`:
|
||||
|
||||
**If session DTO exists and matches the requested booking ID:**
|
||||
- `TravelDataProvider::enrichWithFreshAvailabilities()` — refreshes room availability
|
||||
- `TravelDataProvider::getMutabilityData()` + `patchMutability()` — applies cached mutability state to DTO
|
||||
|
||||
**If no session DTO (first load or after `start`):**
|
||||
|
||||
`initializeFromApi()`:
|
||||
1. `fetchBookingData()` — `ApiClient::getBooking()` with 5-minute cache (tagged by user ID for bulk invalidation)
|
||||
2. `TravelDataProvider::getTravelData()` — loads travel data (XML or snapshot)
|
||||
3. `TravelDataProvider::getAvailabilityData(forceRefresh: true)` + `patchAvailabilities()` — force-refreshes availability at edit start, populates cache for subsequent loads within the session
|
||||
4. `TravelDataProvider::getMutabilityData(cached: true)` + `patchMutability()` — applies which service categories are currently editable
|
||||
5. `BookingDataProcessor::createBookingDtoFromBooking()` — hydrates `BookingDto` from API booking entity
|
||||
6. Agency code resolved via `AgencyLoader` (used by field state conditions)
|
||||
7. `BookingChangeTracker::generateFingerprint()` — sets `originalFingerprint` on DTO **before** draft is applied, so dirty detection compares against original API data
|
||||
8. `BookingEditDraftManager::findDraft()` + `applyDraftToDto()` — if draft exists, merges user edits on top of fresh API data. Sets `draftWasRestored = true` if successful.
|
||||
9. `BookingSessionManager::saveBookingDto()`
|
||||
|
||||
Back in the controller: shows "draft restored" flash if applicable, fetches booking data for surcharge/status display, renders the card overview with `BookingEditContextFactory::createOverviewContext()`.
|
||||
|
||||
### Individual Participant Form (HTMX)
|
||||
|
||||
**Controller:** `Edit/ParticipantController`
|
||||
**Routes:** `GET|POST /bookings/{id}/edit/participants/{index}` and `/{index}/refresh`
|
||||
|
||||
Per-participant forms are lazy-loaded, matching the create flow pattern.
|
||||
|
||||
1. `BookingEditContextFactory::prepareBookingDto()` — refreshes availabilities on the DTO travel object
|
||||
2. `ParticipantFormSupport` — form creation, notification draining
|
||||
3. On submit: `BookingSessionManager::saveBookingDto()` + `BookingEditDraftManager::saveDraft()` — persists participant edits to both session and draft
|
||||
|
||||
### Submission
|
||||
|
||||
**Service:** `BookingEditSubmitter::handleSubmission()`
|
||||
Called from `Edit/IndexController` on valid form submit.
|
||||
|
||||
1. Invalidate API cache, fetch fresh booking data
|
||||
2. Force-refresh mutability data (`TravelDataProvider::getMutabilityData(forceRefresh: true)`) and patch DTO travel
|
||||
3. `BookingEditSubmitGuard::reconcileImmutableCategories()` — reverts any DTO fields that have become immutable since the session was loaded. Shows flash if anything was reverted.
|
||||
4. `ApiClient::updateBooking()` — submit
|
||||
5. On success: invalidate cache again, `BookingSessionManager::clearBookingDto()`, `BookingEditDraftManager::deleteDraft()`
|
||||
|
||||
### Other Edit Routes
|
||||
|
||||
| Route | Action |
|
||||
|-------|--------|
|
||||
| `GET /bookings/{id}/edit/reload` | Shows confirmation modal |
|
||||
| `POST /bookings/{id}/edit/reload` | Clears session + **deletes draft**, reloads from API |
|
||||
| `GET /bookings/{id}/edit/cancel` | Clears session, **preserves draft**, redirects to booking list |
|
||||
|
||||
The distinction between reload and cancel is intentional: cancel keeps the draft so the user can return to their changes later; reload discards everything.
|
||||
|
||||
---
|
||||
|
||||
## Key Invariants
|
||||
|
||||
- `currentStep` on the DTO gates forward navigation in create mode; controllers redirect to the current step if a higher step is requested directly.
|
||||
- The original fingerprint is set before draft application in edit mode. Dirty detection (`BookingChangeTracker::isDirty()`) always compares the live session DTO against the original API state, not against the draft.
|
||||
- Mutability is always patched from fresh or cached data before rendering. The DTO travel object is the authoritative source of which fields are editable at render time.
|
||||
- Drafts survive cancel but not reload, and are deleted on successful submission.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260804120000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add exclusion group and exclusive flag to additional services';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// The default only backfills existing rows; it is dropped again so the column matches the mapping.
|
||||
$this->addSql('ALTER TABLE additional_service ADD exclusion_group VARCHAR(128) DEFAULT NULL, ADD is_exclusive TINYINT(1) DEFAULT 0 NOT NULL');
|
||||
$this->addSql('ALTER TABLE additional_service ALTER COLUMN is_exclusive DROP DEFAULT');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE additional_service DROP exclusion_group, DROP is_exclusive');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260804140000 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add manual ordering position to additional services';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// The default only backfills existing rows; it is dropped again so the column matches the mapping.
|
||||
$this->addSql('ALTER TABLE additional_service ADD position INT DEFAULT 0 NOT NULL');
|
||||
$this->addSql('ALTER TABLE additional_service ALTER COLUMN position DROP DEFAULT');
|
||||
|
||||
// Seed the positions with the ordering the admin overview used before, so nothing changes
|
||||
// visually until someone actually drags a row.
|
||||
$this->addSql('
|
||||
UPDATE additional_service s
|
||||
JOIN (
|
||||
SELECT id, ROW_NUMBER() OVER (
|
||||
PARTITION BY accommodation_id
|
||||
ORDER BY date_from ASC, (price <> 0) ASC, label ASC
|
||||
) AS rn
|
||||
FROM additional_service
|
||||
) o ON o.id = s.id
|
||||
SET s.position = o.rn
|
||||
');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE additional_service DROP position');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260804152215 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Make accommodation booking contact fields nullable (filled on the edit page after creation)';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE accommodation_booking CHANGE first_name first_name VARCHAR(100) DEFAULT NULL, CHANGE last_name last_name VARCHAR(100) DEFAULT NULL, CHANGE email email VARCHAR(255) DEFAULT NULL, CHANGE group_name group_name VARCHAR(255) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE accommodation_booking CHANGE group_name group_name VARCHAR(255) NOT NULL, CHANGE first_name first_name VARCHAR(100) NOT NULL, CHANGE last_name last_name VARCHAR(100) NOT NULL, CHANGE email email VARCHAR(255) NOT NULL');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260804153855 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Replace the accommodation booking is_inquiry flag with a four-value status';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE accommodation_booking ADD status VARCHAR(20) DEFAULT NULL');
|
||||
$this->addSql("UPDATE accommodation_booking SET status = IF(is_inquiry = 1, 'inquiry', 'booking')");
|
||||
$this->addSql('ALTER TABLE accommodation_booking CHANGE status status VARCHAR(20) NOT NULL');
|
||||
$this->addSql('ALTER TABLE accommodation_booking DROP is_inquiry');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE accommodation_booking ADD is_inquiry TINYINT(1) DEFAULT NULL');
|
||||
$this->addSql("UPDATE accommodation_booking SET is_inquiry = IF(status = 'inquiry', 1, 0)");
|
||||
$this->addSql('ALTER TABLE accommodation_booking CHANGE is_inquiry is_inquiry TINYINT(1) NOT NULL');
|
||||
$this->addSql('ALTER TABLE accommodation_booking DROP status');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20260805102251 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Add country to accommodation, defaulting existing rows to DE';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// Added with a default so existing rows backfill to DE, then dropped again to match the mapping
|
||||
$this->addSql("ALTER TABLE accommodation ADD country VARCHAR(2) DEFAULT 'DE' NOT NULL");
|
||||
$this->addSql('ALTER TABLE accommodation ALTER country DROP DEFAULT');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE accommodation DROP country');
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace App\BusProNet\DataProcessor;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\BusProNet\Utility\DirectionMapper;
|
||||
use App\BusProNet\XmlLoader\AgencyLoader;
|
||||
@@ -301,8 +302,8 @@ class BookingDataProcessor
|
||||
*/
|
||||
public function createUpdateRequestPayload(?BookingDto $formData): array
|
||||
{
|
||||
// Apply bulk insurance if enabled (modifies DTO in place)
|
||||
$this->applyBulkInsuranceIfActive($formData);
|
||||
// Apply bulk or family insurance if applicable (modifies DTO in place)
|
||||
$this->applyApplicantInsuranceToParticipants($formData);
|
||||
|
||||
$bookingData = $formData->booking;
|
||||
$travelData = $formData->travel;
|
||||
@@ -362,33 +363,131 @@ class BookingDataProcessor
|
||||
*/
|
||||
public function createBookingRequestPayload(BookingDto $bookingDto, string $bookingType): array
|
||||
{
|
||||
// Apply bulk insurance if enabled (modifies DTO in place)
|
||||
$this->applyBulkInsuranceIfActive($bookingDto);
|
||||
// Re-validate each participant's insurance against current eligibility (price tier,
|
||||
// family constraint, etc.) before submission - selections can go stale between the
|
||||
// moment they were chosen and final submission, since users can freely revisit
|
||||
// earlier steps and change composition/services without ever re-opening the
|
||||
// insurance field. Must run before the applicant-to-dependents propagation below,
|
||||
// so that propagation is based on an already-corrected applicant selection.
|
||||
$this->reconcileInsuranceEligibility($bookingDto);
|
||||
|
||||
// Apply bulk or family insurance if applicable (modifies DTO in place)
|
||||
$this->applyApplicantInsuranceToParticipants($bookingDto);
|
||||
|
||||
return $this->payloadBuilder->buildCreatePayload($bookingDto, $bookingType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies bulk insurance assignment if the applicant has enabled it.
|
||||
* Re-validates every participant's currently selected insurance against present-day
|
||||
* eligibility (price tier, family constraint, age, travel/booking dates, duration) and
|
||||
* corrects any selection that's gone stale.
|
||||
*
|
||||
* When bulk insurance is active (applicant's bulkInsuranceBooking = true), this method
|
||||
* assigns the applicant's insurance TYPE to all dependent participants with automatic
|
||||
* price tier adjustment based on each participant's total cost.
|
||||
* Insurance eligibility is normally re-checked when a participant's own card is
|
||||
* resubmitted (see ParticipantInsuranceFieldHandler::processField()), but nothing forces
|
||||
* that to happen again if the user changes composition or services on an earlier step
|
||||
* after insurance was already chosen, then jumps straight to submission. Left unchecked,
|
||||
* a stale insurance ID (e.g. a family-tariff price tier that no longer matches the
|
||||
* current total booking price) would reach the BPN API and be rejected as a mismatch.
|
||||
*
|
||||
* IMPORTANT: In edit mode, bulk insurance only applies to participants who:
|
||||
* Mirrors the reassign-or-clear logic already established in
|
||||
* ParticipantInsuranceFieldHandler for the resubmission case, applied here across all
|
||||
* participants right before the payload is built.
|
||||
*/
|
||||
private function reconcileInsuranceEligibility(BookingDto $bookingDto): bool
|
||||
{
|
||||
$selectableInsurances = $this->insuranceService->getSelectableInsurances($bookingDto->travel);
|
||||
$changed = false;
|
||||
|
||||
foreach ($bookingDto->getParticipants() as $index => $participant) {
|
||||
$currentInsurance = $participant->insurance;
|
||||
if (null === $currentInsurance || $currentInsurance->isNoInsurance()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$travelPrice = $this->priceCalculatorService->resolveInsuranceTravelPrice($bookingDto, $index, $currentInsurance);
|
||||
$eligibleInsurances = $this->insuranceService->getEligibleInsurances($selectableInsurances, $participant, $bookingDto, $travelPrice);
|
||||
|
||||
if ($this->isInsuranceInList($currentInsurance, $eligibleInsurances)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$reassignedInsurance = $this->insuranceService->reassignInsuranceForPriceChange(
|
||||
$selectableInsurances,
|
||||
$currentInsurance,
|
||||
$participant,
|
||||
$bookingDto,
|
||||
$travelPrice
|
||||
);
|
||||
|
||||
if (null !== $reassignedInsurance) {
|
||||
$participant->addNotification(
|
||||
'warning',
|
||||
sprintf('Versicherung vor der Übermittlung automatisch angepasst: %s', $reassignedInsurance->label)
|
||||
);
|
||||
} else {
|
||||
$participant->addNotification(
|
||||
'warning',
|
||||
'Die gewählte Versicherung ist für diese Buchung nicht mehr verfügbar und wurde entfernt. Bitte erneut auswählen.'
|
||||
);
|
||||
}
|
||||
|
||||
$participant->insurance = $reassignedInsurance;
|
||||
$changed = true;
|
||||
}
|
||||
|
||||
return $changed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a specific insurance exists in a list of insurances (by id).
|
||||
*
|
||||
* @param array<Insurance> $insuranceList
|
||||
*/
|
||||
private function isInsuranceInList(Insurance $targetInsurance, array $insuranceList): bool
|
||||
{
|
||||
foreach ($insuranceList as $insurance) {
|
||||
if ($insurance->id === $targetInsurance->id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the applicant's insurance to other participants if their selection requires it.
|
||||
*
|
||||
* Runs when either:
|
||||
* - Bulk insurance is active (applicant's bulkInsuranceBooking = true): assigns the
|
||||
* applicant's insurance TYPE to all dependent participants with automatic price tier
|
||||
* adjustment based on each participant's individual cost.
|
||||
* - The applicant selected a family insurance: family insurance covers the whole family
|
||||
* under a single policy, so dependents must never hold their own insurance, regardless
|
||||
* of whether the bulk checkbox was checked.
|
||||
*
|
||||
* IMPORTANT: In edit mode, non-family bulk insurance only applies to participants who:
|
||||
* 1. Currently have NO insurance assigned (insurance === null)
|
||||
* 2. OR whose insurance was already assigned via previous bulk operation
|
||||
*
|
||||
* This prevents overriding individually selected insurances that are locked.
|
||||
* This prevents overriding individually selected insurances that are locked. Family
|
||||
* insurance is exempt from this protection: dependents can never legitimately hold
|
||||
* their own policy alongside it, so their insurance is always cleared, in edit mode too.
|
||||
*
|
||||
* @param BookingDto $bookingDto The booking DTO (create or edit flow)
|
||||
*/
|
||||
private function applyBulkInsuranceIfActive(BookingDto $bookingDto): void
|
||||
private function applyApplicantInsuranceToParticipants(BookingDto $bookingDto): void
|
||||
{
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
|
||||
// Check if bulk insurance is enabled and applicant has selected an insurance
|
||||
if (null === $applicant || false === $applicant->bulkInsuranceBooking || null === $applicant->insurance) {
|
||||
if (null === $applicant || null === $applicant->insurance) {
|
||||
return;
|
||||
}
|
||||
|
||||
$isFamilyInsurance = true === $applicant->insurance->familyInsurance;
|
||||
|
||||
// Check if bulk insurance is enabled OR the applicant's selection is a family
|
||||
// insurance (which always applies to dependents, independent of the bulk checkbox)
|
||||
if (false === $applicant->bulkInsuranceBooking && false === $isFamilyInsurance) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -409,10 +508,11 @@ class BookingDataProcessor
|
||||
$participantPrices
|
||||
);
|
||||
|
||||
// Apply assignments to dependent participants (skip applicant at index 0)
|
||||
// Apply assignments to all participants; for non-family insurance skip the applicant
|
||||
// (they already hold the insurance they selected themselves)
|
||||
foreach ($assignments as $index => $insurance) {
|
||||
if (0 === $index) {
|
||||
continue; // Skip applicant
|
||||
if (0 === $index && false === $isFamilyInsurance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$participant = $bookingDto->getParticipant($index);
|
||||
@@ -420,9 +520,10 @@ class BookingDataProcessor
|
||||
continue;
|
||||
}
|
||||
|
||||
// In edit mode: only apply bulk insurance if participant has no insurance
|
||||
// This respects the rule that once assigned, insurance cannot be changed
|
||||
if (BookingDto::MODE_EDIT === $bookingDto->getMode() && null !== $participant->insurance) {
|
||||
// In edit mode: non-family bulk assignment must not overwrite an individually
|
||||
// locked insurance. Family insurance always overrides, since dependents can
|
||||
// never legitimately keep their own policy alongside it.
|
||||
if (BookingDto::MODE_EDIT === $bookingDto->getMode() && false === $isFamilyInsurance && null !== $participant->insurance) {
|
||||
continue; // Skip participants with existing insurance assignment
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Service\CmsDataProvider;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
@@ -57,8 +58,8 @@ class EditController extends AbstractController
|
||||
$boardServices = $accommodation->getBoardServices()->toArray();
|
||||
usort($boardServices, $this->compareServices(...));
|
||||
|
||||
// Additional services are ordered manually, see #[ORM\OrderBy] on the association.
|
||||
$additionalServices = $accommodation->getAdditionalServices()->toArray();
|
||||
usort($additionalServices, $this->compareServices(...));
|
||||
|
||||
return $this->render('admin/accommodation/edit.html.twig', [
|
||||
'accommodation' => $accommodation,
|
||||
@@ -69,10 +70,59 @@ class EditController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives the additional service ids in their new order and renumbers the positions.
|
||||
*
|
||||
* Ids are only accepted when they belong to the given accommodation; services missing from the
|
||||
* payload (e.g. created in another tab in the meantime) are appended in their previous order.
|
||||
*/
|
||||
#[Route('/admin/accommodation/{id}/additional-services/order', name: 'app_admin_accommodation_additionalservices_order', methods: ['POST'])]
|
||||
public function orderAdditionalServices(Accommodation $accommodation, Request $request): Response
|
||||
{
|
||||
try {
|
||||
$payload = json_decode($request->getContent(), true, 512, \JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException) {
|
||||
return new JsonResponse(['error' => 'Malformed payload'], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
if (!\is_array($payload) || !\is_array($payload['ids'] ?? null)) {
|
||||
return new JsonResponse(['error' => 'Malformed payload'], Response::HTTP_BAD_REQUEST);
|
||||
}
|
||||
|
||||
/** @var array<int, AdditionalService> $remaining */
|
||||
$remaining = [];
|
||||
|
||||
foreach ($accommodation->getAdditionalServices() as $additionalService) {
|
||||
$remaining[$additionalService->getId()] = $additionalService;
|
||||
}
|
||||
|
||||
$position = 0;
|
||||
|
||||
foreach ($payload['ids'] as $id) {
|
||||
$id = \is_numeric($id) ? (int) $id : null;
|
||||
|
||||
if (null === $id || !isset($remaining[$id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$remaining[$id]->setPosition(++$position);
|
||||
unset($remaining[$id]);
|
||||
}
|
||||
|
||||
// Whatever was not part of the payload keeps its relative order behind the sorted ones.
|
||||
foreach ($remaining as $additionalService) {
|
||||
$additionalService->setPosition(++$position);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
return new JsonResponse(['status' => 'ok']);
|
||||
}
|
||||
|
||||
/**
|
||||
* DateFrom ascending, then free (price 0) before paid, then alphabetically by label.
|
||||
*/
|
||||
private function compareServices(BoardService|AdditionalService $a, BoardService|AdditionalService $b): int
|
||||
private function compareServices(BoardService $a, BoardService $b): int
|
||||
{
|
||||
$aFree = 0 === $a->getPrice() ? 0 : 1;
|
||||
$bFree = 0 === $b->getPrice() ? 0 : 1;
|
||||
|
||||
@@ -5,7 +5,9 @@ declare(strict_types=1);
|
||||
namespace App\Controller\Admin\AccommodationBooking;
|
||||
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Form\Admin\Groups\AccommodationBookingType;
|
||||
use App\Entity\User;
|
||||
use App\Form\Admin\Groups\AccommodationBookingCreateType;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -30,8 +32,16 @@ class CreateController extends AbstractController
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
|
||||
$form = $this->createForm(AccommodationBookingType::class, $booking, [
|
||||
'with_accommodation' => true,
|
||||
// Whoever creates a booking in the backoffice looks after it until someone else is
|
||||
// assigned in the edit form. The route is behind ROLE_GROUPS_MANAGER, so the creator
|
||||
// is always eligible as Betreuer.
|
||||
$user = $this->getUser();
|
||||
if ($user instanceof User) {
|
||||
$booking->setManagedBy($user);
|
||||
}
|
||||
|
||||
$form = $this->createForm(AccommodationBookingCreateType::class, $booking, [
|
||||
'hx_post' => $request->getRequestUri(),
|
||||
]);
|
||||
$form->handleRequest($request);
|
||||
|
||||
@@ -40,20 +50,18 @@ class CreateController extends AbstractController
|
||||
$this->entityManager->persist($booking);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->bookingService->issueAccessLinkForDirectBooking($booking);
|
||||
$this->bookingService->sendCustomerConfirmationEmail($booking);
|
||||
|
||||
$this->addFlash('success', 'Die Buchung wurde erstellt');
|
||||
|
||||
$this->logger->info('Created accommodation booking', [
|
||||
'id' => $booking->getId(),
|
||||
'groupName' => $booking->getGroupName(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_admin_accommodationbooking_edit', ['id' => $booking->getId()]);
|
||||
return new HxRedirectResponse(
|
||||
$this->generateUrl('app_admin_accommodationbooking_edit', ['id' => $booking->getId()])
|
||||
);
|
||||
}
|
||||
|
||||
return $this->render('admin/accommodation_booking/create.html.twig', [
|
||||
return $this->render('admin/accommodation_booking/modal_create.html.twig', [
|
||||
'form' => $form,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,11 @@ namespace App\Controller\Admin\AccommodationBooking;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Entity\Groups\BoardService;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Form\Admin\Groups\AccommodationBookingType;
|
||||
use App\Repository\Groups\AdditionalServiceRepository;
|
||||
use App\Repository\Groups\BoardServiceRepository;
|
||||
use App\Repository\UserRepository;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -27,6 +29,7 @@ class EditController extends AbstractController
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly BoardServiceRepository $boardServiceRepo,
|
||||
private readonly AdditionalServiceRepository $additionalServiceRepo,
|
||||
private readonly UserRepository $userRepo,
|
||||
private readonly AccommodationBookingService $bookingService,
|
||||
) {
|
||||
}
|
||||
@@ -68,14 +71,28 @@ class EditController extends AbstractController
|
||||
));
|
||||
}
|
||||
|
||||
// ROLE_ADMIN inherits ROLE_GROUPS_ADMIN, so this single check covers both.
|
||||
$assignableManagers = [];
|
||||
if ($this->isGranted('ROLE_GROUPS_ADMIN')) {
|
||||
$assignableManagers = $this->userRepo->findGroupsStaff();
|
||||
|
||||
// A user assigned earlier may have lost the role since — keep them in the choices
|
||||
// so the field can render the current value instead of failing to transform it.
|
||||
$currentManager = $booking->getManagedBy();
|
||||
if (null !== $currentManager && !in_array($currentManager, $assignableManagers, true)) {
|
||||
$assignableManagers[] = $currentManager;
|
||||
}
|
||||
}
|
||||
|
||||
$form = $this->createForm(AccommodationBookingType::class, $booking, [
|
||||
'max_adolescent_age' => $accommodation?->getMaxAdolescentAge() ?? 0,
|
||||
'board_services' => $boardServices,
|
||||
'additional_services' => $additionalServices,
|
||||
'current_board_service' => $currentBoardService,
|
||||
'current_additional_services' => $currentAdditionalServices,
|
||||
'assignable_managers' => $assignableManagers,
|
||||
]);
|
||||
$wasInquiry = $booking->isInquiry();
|
||||
$previousStatus = $booking->getStatus();
|
||||
|
||||
$form->handleRequest($request);
|
||||
|
||||
@@ -110,8 +127,11 @@ class EditController extends AbstractController
|
||||
$this->entityManager->persist($booking);
|
||||
$this->entityManager->flush();
|
||||
|
||||
if ($wasInquiry && !$booking->isInquiry()) {
|
||||
$this->bookingService->issueAccessLinkForDirectBooking($booking);
|
||||
// Entering Anfrage or Buchung is what the customer needs to hear about: the offer
|
||||
// becomes viewable, or the booking is confirmed. Entwurf and Absage stay silent.
|
||||
$notifiableStatuses = [AccommodationBookingStatus::Inquiry, AccommodationBookingStatus::Booking];
|
||||
if ($previousStatus !== $booking->getStatus() && in_array($booking->getStatus(), $notifiableStatuses, true)) {
|
||||
$this->bookingService->issueAccessLink($booking);
|
||||
$this->bookingService->sendCustomerConfirmationEmail($booking);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,9 @@ class IndexController extends AbstractController
|
||||
$qb = $this
|
||||
->bookingRepository
|
||||
->createQueryBuilder('booking')
|
||||
->select('booking', 'managed_by')
|
||||
->leftJoin('booking.accommodation', 'accommodation')
|
||||
->leftJoin('booking.managedBy', 'managed_by')
|
||||
->addSelect('accommodation')
|
||||
->where('booking.dateTo >= :today')
|
||||
->setParameter('today', $today)
|
||||
|
||||
@@ -6,12 +6,14 @@ namespace App\Controller\Api;
|
||||
|
||||
use App\BpnConnect\ContingentsClient;
|
||||
use App\BpnConnect\Exception\BpnConnectException;
|
||||
use App\BpnConnect\Model\ContingentStatus;
|
||||
use App\Entity\Groups\AccommodationPrice;
|
||||
use App\Enum\Groups\PriceType;
|
||||
use App\Model\ContingentCalendarQuery;
|
||||
use App\Model\ContingentPricesQuery;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
use App\Repository\Groups\AccommodationRepository;
|
||||
use App\Service\AccommodationPriceCoverage;
|
||||
use App\Service\PriceTimelineBuilder;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -34,6 +36,7 @@ class ContingentController extends AbstractController
|
||||
private readonly AccommodationPriceRepository $priceRepository,
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly PriceTimelineBuilder $priceTimelineBuilder,
|
||||
private readonly AccommodationPriceCoverage $priceCoverage,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
@@ -96,8 +99,10 @@ class ContingentController extends AbstractController
|
||||
|
||||
$currency = $accommodation->getCurrency();
|
||||
|
||||
$covered = $this->priceCoverage->coveredDatesFor($prices, $dateFrom, $dateTo);
|
||||
|
||||
$data = array_map(
|
||||
fn ($entry) => $this->enrichEntry($entry->date, $entry->status->value, $prices, $currency),
|
||||
fn ($entry) => $this->enrichEntry($entry->date, $entry->status->value, $prices, $covered, $currency),
|
||||
$calendar->data,
|
||||
);
|
||||
|
||||
@@ -106,13 +111,19 @@ class ContingentController extends AbstractController
|
||||
|
||||
/**
|
||||
* @param AccommodationPrice[] $prices
|
||||
* @param array<string, true> $covered
|
||||
*
|
||||
* @return array{date: string, status: string, type: string|null, pricePerNight: float|null, defaultPricePerNight: float|null, priceAdditionalPerson: float|null, defaultPriceAdditionalPerson: float|null, includedPax: int|null, minNights: int|null}
|
||||
*/
|
||||
private function enrichEntry(string $date, string $status, array $prices, string $currency): array
|
||||
private function enrichEntry(string $date, string $status, array $prices, array $covered, string $currency): array
|
||||
{
|
||||
$day = (new \DateTimeImmutable($date))->setTime(0, 0);
|
||||
|
||||
// A day without a price is not sold, no matter what the contingent says.
|
||||
if (!isset($covered[$day->format('Y-m-d')])) {
|
||||
$status = ContingentStatus::Blocked->value;
|
||||
}
|
||||
|
||||
// dateFrom and dateTo are both inclusive (last night, not checkout day)
|
||||
$candidates = array_filter(
|
||||
$prices,
|
||||
|
||||
@@ -19,6 +19,7 @@ use App\Service\BookingCreateContextFactory;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\BookingPriceMismatchAnalyzer;
|
||||
use App\Service\BookingSessionManager;
|
||||
use App\Service\ParticipantFormSupport;
|
||||
use App\Service\RoomPricingCalculator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -40,6 +41,7 @@ class Step3Controller extends AbstractBookingCreateController
|
||||
private readonly BookingPriceCalculator $priceCalculator,
|
||||
private readonly BookingPriceMismatchAnalyzer $priceMismatchDiagnostics,
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly ParticipantFormSupport $participantFormSupportService,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
@@ -76,6 +78,12 @@ class Step3Controller extends AbstractBookingCreateController
|
||||
// Validate booking data with API by submitting an inquiry booking
|
||||
$inquiryResponse = $this->apiClient->createBookingInquiry($bookingCreateDto);
|
||||
|
||||
// Surface any insurance corrections made during payload building (e.g. a
|
||||
// stale price tier reassigned/cleared right before submission)
|
||||
foreach ($this->participantFormSupportService->collectAndClearNotifications($bookingCreateDto) as $notification) {
|
||||
$this->addFlash($notification['type'], $notification['message']);
|
||||
}
|
||||
|
||||
if ($inquiryResponse instanceof Notification) {
|
||||
$this->handleApiError(
|
||||
$this->logger,
|
||||
|
||||
@@ -20,6 +20,7 @@ use App\Service\BookingConfigurator;
|
||||
use App\Service\BookingCreateContextFactory;
|
||||
use App\Service\BookingSessionManager;
|
||||
use App\Service\NewsletterManager;
|
||||
use App\Service\ParticipantFormSupport;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -41,6 +42,7 @@ class Step4Controller extends AbstractBookingCreateController
|
||||
private readonly ApiClient $apiClient,
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly NewsletterManager $doubleOptInService,
|
||||
private readonly ParticipantFormSupport $participantFormSupportService,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
@@ -78,6 +80,12 @@ class Step4Controller extends AbstractBookingCreateController
|
||||
// Submit final booking (already validated in Step 3)
|
||||
$bookingResponse = $this->apiClient->createBooking($bookingCreateDto);
|
||||
|
||||
// Surface any insurance corrections made during payload building (e.g. a
|
||||
// stale price tier reassigned/cleared right before submission)
|
||||
foreach ($this->participantFormSupportService->collectAndClearNotifications($bookingCreateDto) as $notification) {
|
||||
$this->addFlash($notification['type'], $notification['message']);
|
||||
}
|
||||
|
||||
if ($bookingResponse instanceof Notification) {
|
||||
$this->handleApiError(
|
||||
$this->logger,
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Repository\Groups\AccommodationBookingRepository;
|
||||
use App\Service\AccommodationBookingBreakdownCalculator;
|
||||
use App\Service\AccommodationBookingLinkSigner;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationTermsUrlProvider;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -27,6 +28,7 @@ class OfferController extends AbstractController
|
||||
private readonly AccommodationBookingLinkSigner $linkSigner,
|
||||
private readonly AccommodationBookingBreakdownCalculator $breakdownCalculator,
|
||||
private readonly AccommodationBookingService $bookingService,
|
||||
private readonly AccommodationTermsUrlProvider $termsUrlProvider,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -44,6 +46,10 @@ class OfferController extends AbstractController
|
||||
return $this->render('groups/booking/offer_unavailable.html.twig');
|
||||
}
|
||||
|
||||
if (!$this->isCustomerVisible($booking)) {
|
||||
return $this->render('groups/booking/offer_unavailable.html.twig');
|
||||
}
|
||||
|
||||
$this->linkSigner->authorizeSession($request, $booking);
|
||||
|
||||
return new RedirectResponse($this->generateUrl('app_groups_booking_offer_view', ['uuid' => $uuid]));
|
||||
@@ -58,6 +64,10 @@ class OfferController extends AbstractController
|
||||
return $this->render('groups/booking/offer_unavailable.html.twig');
|
||||
}
|
||||
|
||||
if (!$this->isCustomerVisible($booking)) {
|
||||
return $this->render('groups/booking/offer_unavailable.html.twig');
|
||||
}
|
||||
|
||||
$accommodation = $booking->getAccommodation() ?? throw $this->createNotFoundException('Booking has no accommodation.');
|
||||
$priceBreakdown = $this->breakdownCalculator->compute($booking);
|
||||
|
||||
@@ -88,7 +98,7 @@ class OfferController extends AbstractController
|
||||
}
|
||||
|
||||
$confirmationForm = $this->createForm(OfferAcceptConfirmationType::class, null, [
|
||||
'terms_url' => $this->getParameter('terms_and_conditions_url'),
|
||||
'terms_url' => $this->termsUrlProvider->forAccommodation($booking->getAccommodation()),
|
||||
]);
|
||||
$confirmationForm->handleRequest($request);
|
||||
|
||||
@@ -105,6 +115,15 @@ class OfferController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A draft is not ready to be shown, and a discarded booking must not be viewable
|
||||
* any more — in both cases the link behaves as if it had expired.
|
||||
*/
|
||||
private function isCustomerVisible(AccommodationBooking $booking): bool
|
||||
{
|
||||
return !$booking->isDraft() && !$booking->isDiscarded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the browser to a full reload of the (non-modal) offer page — this is
|
||||
* triggered from an htmx-loaded modal, so a plain render/redirect here would
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Htmx\HxTrait;
|
||||
use App\Model\AccommodationBookingContext;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationPriceCoverage;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use App\Service\CalendarGridBuilder;
|
||||
use App\Service\GroupsPriceCalculator;
|
||||
@@ -38,6 +39,7 @@ class Step1Controller extends AbstractAccommodationController
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly CalendarGridBuilder $calendarGridBuilder,
|
||||
private readonly GroupsPriceCalculator $priceCalculator,
|
||||
private readonly AccommodationPriceCoverage $priceCoverage,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -225,9 +227,12 @@ class Step1Controller extends AbstractAccommodationController
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches contingent + price data and returns a map of date → ['status', 'minNights'].
|
||||
* Fetches contingent + price data and returns a map of date → ['status', 'minNights']
|
||||
* covering every day of the requested range.
|
||||
*
|
||||
* Returns an empty array on API failure; the template treats missing dates as blocked.
|
||||
* A day is only available when the contingent allows it *and* an AccommodationPrice
|
||||
* covers it. On API failure the contingent imposes no restriction and price coverage
|
||||
* alone decides.
|
||||
*
|
||||
* @return array<string, array{status: string, minNights: int}>
|
||||
*/
|
||||
@@ -238,6 +243,7 @@ class Step1Controller extends AbstractAccommodationController
|
||||
string $dateFromStr,
|
||||
string $dateToStr,
|
||||
): array {
|
||||
$calendar = null;
|
||||
try {
|
||||
$cacheKey = sprintf('contingents_calendar_%s_%s_%s', $hotelCode, $dateFromStr, $dateToStr);
|
||||
$calendar = $this->cache->get(
|
||||
@@ -249,23 +255,38 @@ class Step1Controller extends AbstractAccommodationController
|
||||
},
|
||||
);
|
||||
} catch (BpnConnectException|\Psr\Cache\InvalidArgumentException) {
|
||||
return [];
|
||||
// Fall through with $calendar === null — price coverage still applies
|
||||
}
|
||||
|
||||
$contingentStatus = [];
|
||||
if (null !== $calendar) {
|
||||
foreach ($calendar->data as $entry) {
|
||||
$contingentStatus[(new \DateTimeImmutable($entry->date))->format('Y-m-d')] = $entry->status;
|
||||
}
|
||||
}
|
||||
|
||||
$prices = $this->priceRepository->findByHotelCodeAndDateRange($hotelCode, $dateFrom, $dateTo);
|
||||
$covered = $this->priceCoverage->coveredDatesFor($prices, $dateFrom, $dateTo);
|
||||
|
||||
$start = $dateFrom->setTime(0, 0);
|
||||
$end = $dateTo->setTime(0, 0);
|
||||
|
||||
$availableDates = [];
|
||||
foreach ($calendar->data as $entry) {
|
||||
if (ContingentStatus::Ok === $entry->status) {
|
||||
$availableDates[$entry->date] = true;
|
||||
for ($day = $start; $day <= $end; $day = $day->modify('+1 day')) {
|
||||
$date = $day->format('Y-m-d');
|
||||
// Days the contingent API does not mention are unrestricted
|
||||
$status = $contingentStatus[$date] ?? ContingentStatus::Ok;
|
||||
|
||||
if (ContingentStatus::Ok === $status && isset($covered[$date])) {
|
||||
$availableDates[$date] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$enriched = [];
|
||||
foreach ($calendar->data as $entry) {
|
||||
$isAvailable = ContingentStatus::Ok === $entry->status;
|
||||
$prevDate = (new \DateTimeImmutable($entry->date))->modify('-1 day')->format('Y-m-d');
|
||||
$prevAvailable = isset($availableDates[$prevDate]);
|
||||
for ($day = $start; $day <= $end; $day = $day->modify('+1 day')) {
|
||||
$date = $day->format('Y-m-d');
|
||||
$isAvailable = isset($availableDates[$date]);
|
||||
$prevAvailable = isset($availableDates[$day->modify('-1 day')->format('Y-m-d')]);
|
||||
|
||||
$status = match (true) {
|
||||
$isAvailable && $prevAvailable => 'ok',
|
||||
@@ -274,14 +295,13 @@ class Step1Controller extends AbstractAccommodationController
|
||||
default => 'blocked',
|
||||
};
|
||||
|
||||
$day = (new \DateTimeImmutable($entry->date))->setTime(0, 0);
|
||||
$candidates = array_values(array_filter(
|
||||
$prices,
|
||||
fn(AccommodationPrice $p): bool => $p->getDateFrom() <= $day && $p->getDateTo() >= $day,
|
||||
fn (AccommodationPrice $p): bool => $p->getDateFrom() <= $day && $p->getDateTo() >= $day,
|
||||
));
|
||||
$winner = $this->priceTimelineBuilder->resolveWinner($candidates);
|
||||
|
||||
$enriched[$entry->date] = [
|
||||
$enriched[$date] = [
|
||||
'status' => $status,
|
||||
'minNights' => $winner?->getMinNights() ?? 0,
|
||||
];
|
||||
|
||||
@@ -72,7 +72,7 @@ class Step2Controller extends AbstractAccommodationController
|
||||
|
||||
return $this->htmxOobResponse(
|
||||
'groups/booking/step_2.html.twig',
|
||||
['accommodation_form', 'accommodation_summary'],
|
||||
['booking_form', 'accommodation_summary'],
|
||||
['dto' => $dto, 'ctx' => $ctx, 'form' => $form->createView()],
|
||||
);
|
||||
}
|
||||
@@ -92,6 +92,7 @@ class Step2Controller extends AbstractAccommodationController
|
||||
$form = $this->createForm(AccommodationStep2Type::class, $dto, [
|
||||
'board_service_choices' => $this->buildServiceChoices($services['boardServices']),
|
||||
'additional_service_choices' => $this->buildServiceChoices($services['additionalServices']),
|
||||
'additional_services' => $services['additionalServices'],
|
||||
'max_adolescent_age' => (int) $accommodation->getMaxAdolescentAge(),
|
||||
'validation_groups' => $validate ? ['step_2'] : false,
|
||||
]);
|
||||
|
||||
@@ -15,6 +15,7 @@ use App\Htmx\HxTrait;
|
||||
use App\Model\AccommodationBookingContext;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use App\Service\AccommodationTermsUrlProvider;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
@@ -26,6 +27,7 @@ class Step4Controller extends AbstractAccommodationController
|
||||
public function __construct(
|
||||
private readonly AccommodationBookingService $bookingService,
|
||||
private readonly AccommodationSessionManager $sessionManager,
|
||||
private readonly AccommodationTermsUrlProvider $termsUrlProvider,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -94,7 +96,7 @@ class Step4Controller extends AbstractAccommodationController
|
||||
$accommodation = $this->loadAccommodationOrFail($dto);
|
||||
|
||||
$confirmationForm = $this->createForm(AccommodationBookingConfirmationType::class, $dto, [
|
||||
'terms_url' => $this->getParameter('terms_and_conditions_url'),
|
||||
'terms_url' => $this->termsUrlProvider->forAccommodation($accommodation),
|
||||
]);
|
||||
$confirmationForm->handleRequest($request);
|
||||
|
||||
@@ -151,7 +153,7 @@ class Step4Controller extends AbstractAccommodationController
|
||||
{
|
||||
$prices = $this->bookingService->loadPrices($dto, $accommodation);
|
||||
$booking = $this->bookingService->finalizeBooking($dto, $accommodation, $prices, $services);
|
||||
$this->addFlash('groups_booking_result', $booking->isInquiry() ? 'inquiry' : 'booking');
|
||||
$this->addFlash('groups_booking_result', $booking->getStatus()->value);
|
||||
$this->sessionManager->clear($request);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use App\Entity\BlameableEntity;
|
||||
use App\Entity\BlameableEntityInterface;
|
||||
use App\Entity\TimestampableEntity;
|
||||
use App\Entity\TimestampableEntityInterface;
|
||||
use App\Enum\Groups\AccommodationCountry;
|
||||
use App\Repository\Groups\AccommodationRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
@@ -52,7 +53,7 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
|
||||
* @var Collection<int, AdditionalService>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: AdditionalService::class, mappedBy: 'accommodation', cascade: ['all'])]
|
||||
#[ORM\OrderBy(['dateFrom' => 'ASC', 'label' => 'ASC'])]
|
||||
#[ORM\OrderBy(['position' => 'ASC', 'dateFrom' => 'ASC', 'id' => 'ASC'])]
|
||||
private Collection $additionalServices;
|
||||
|
||||
#[ORM\Column]
|
||||
@@ -64,6 +65,10 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
|
||||
#[Assert\Choice(choices: ['EUR', 'CHF'], message: 'invalid')]
|
||||
private ?string $currency = 'EUR';
|
||||
|
||||
#[ORM\Column(length: 2, enumType: AccommodationCountry::class)]
|
||||
#[Assert\NotNull(message: 'required')]
|
||||
private ?AccommodationCountry $country = AccommodationCountry::Germany;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->accommodationPrices = new ArrayCollection();
|
||||
@@ -171,6 +176,18 @@ class Accommodation implements BlameableEntityInterface, TimestampableEntityInte
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCountry(): ?AccommodationCountry
|
||||
{
|
||||
return $this->country;
|
||||
}
|
||||
|
||||
public function setCountry(AccommodationCountry $country): self
|
||||
{
|
||||
$this->country = $country;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, BoardService>
|
||||
*/
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Entity\BlameableEntityInterface;
|
||||
use App\Entity\TimestampableEntity;
|
||||
use App\Entity\TimestampableEntityInterface;
|
||||
use App\Entity\User;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Enum\Groups\AdditionalServiceType;
|
||||
use App\Repository\Groups\AccommodationBookingRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
@@ -75,8 +76,8 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
|
||||
private ?int $pricingVersion = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $isInquiry = false;
|
||||
#[ORM\Column(length: 20, enumType: AccommodationBookingStatus::class)]
|
||||
private AccommodationBookingStatus $status = AccommodationBookingStatus::Draft;
|
||||
|
||||
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $accessLinkIssuedAt = null;
|
||||
@@ -84,19 +85,24 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
|
||||
private ?\DateTimeImmutable $acceptedAt = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Assert\NotBlank(groups: ['edit'])]
|
||||
private ?string $groupName = null;
|
||||
|
||||
#[ORM\Column(length: 10, nullable: true)]
|
||||
private ?string $salutation = null;
|
||||
|
||||
#[ORM\Column(length: 100)]
|
||||
#[ORM\Column(length: 100, nullable: true)]
|
||||
#[Assert\NotBlank(groups: ['edit'])]
|
||||
private ?string $firstName = null;
|
||||
|
||||
#[ORM\Column(length: 100)]
|
||||
#[ORM\Column(length: 100, nullable: true)]
|
||||
#[Assert\NotBlank(groups: ['edit'])]
|
||||
private ?string $lastName = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
#[Assert\NotBlank(groups: ['edit'])]
|
||||
#[Assert\Email(groups: ['edit'])]
|
||||
private ?string $email = null;
|
||||
|
||||
#[ORM\Column(length: 50, nullable: true)]
|
||||
@@ -330,18 +336,38 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->pricingVersion;
|
||||
}
|
||||
|
||||
public function isInquiry(): bool
|
||||
public function getStatus(): AccommodationBookingStatus
|
||||
{
|
||||
return $this->isInquiry;
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
public function setIsInquiry(bool $isInquiry): self
|
||||
public function setStatus(AccommodationBookingStatus $status): self
|
||||
{
|
||||
$this->isInquiry = $isInquiry;
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isDraft(): bool
|
||||
{
|
||||
return AccommodationBookingStatus::Draft === $this->status;
|
||||
}
|
||||
|
||||
public function isInquiry(): bool
|
||||
{
|
||||
return AccommodationBookingStatus::Inquiry === $this->status;
|
||||
}
|
||||
|
||||
public function isBooking(): bool
|
||||
{
|
||||
return AccommodationBookingStatus::Booking === $this->status;
|
||||
}
|
||||
|
||||
public function isDiscarded(): bool
|
||||
{
|
||||
return AccommodationBookingStatus::Discarded === $this->status;
|
||||
}
|
||||
|
||||
public function getAccessLinkIssuedAt(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->accessLinkIssuedAt;
|
||||
@@ -371,7 +397,7 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->groupName;
|
||||
}
|
||||
|
||||
public function setGroupName(string $groupName): self
|
||||
public function setGroupName(?string $groupName): self
|
||||
{
|
||||
$this->groupName = $groupName;
|
||||
|
||||
@@ -395,7 +421,7 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->firstName;
|
||||
}
|
||||
|
||||
public function setFirstName(string $firstName): self
|
||||
public function setFirstName(?string $firstName): self
|
||||
{
|
||||
$this->firstName = $firstName;
|
||||
|
||||
@@ -407,7 +433,7 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->lastName;
|
||||
}
|
||||
|
||||
public function setLastName(string $lastName): self
|
||||
public function setLastName(?string $lastName): self
|
||||
{
|
||||
$this->lastName = $lastName;
|
||||
|
||||
@@ -419,7 +445,7 @@ class AccommodationBooking implements BlameableEntityInterface, TimestampableEnt
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): self
|
||||
public function setEmail(?string $email): self
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
|
||||
@@ -53,6 +53,18 @@ class AdditionalService implements BlameableEntityInterface, TimestampableEntity
|
||||
#[ORM\Column(length: 128, nullable: true)]
|
||||
private ?string $selectionGroup = null;
|
||||
|
||||
#[ORM\Column(length: 128, nullable: true)]
|
||||
private ?string $exclusionGroup = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private bool $isExclusive = false;
|
||||
|
||||
/**
|
||||
* Manual presentation order within the accommodation, maintained by drag & drop in the admin.
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private int $position = 0;
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
@@ -158,4 +170,40 @@ class AdditionalService implements BlameableEntityInterface, TimestampableEntity
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getExclusionGroup(): ?string
|
||||
{
|
||||
return $this->exclusionGroup;
|
||||
}
|
||||
|
||||
public function setExclusionGroup(?string $exclusionGroup): self
|
||||
{
|
||||
$this->exclusionGroup = $exclusionGroup;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isExclusive(): bool
|
||||
{
|
||||
return $this->isExclusive;
|
||||
}
|
||||
|
||||
public function setIsExclusive(bool $isExclusive): self
|
||||
{
|
||||
$this->isExclusive = $isExclusive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPosition(): int
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
public function setPosition(int $position): self
|
||||
{
|
||||
$this->position = $position;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enum\Groups;
|
||||
|
||||
enum AccommodationBookingStatus: string
|
||||
{
|
||||
case Draft = 'draft';
|
||||
case Inquiry = 'inquiry';
|
||||
case Booking = 'booking';
|
||||
case Discarded = 'discarded';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Draft => 'Entwurf',
|
||||
self::Inquiry => 'Anfrage',
|
||||
self::Booking => 'Buchung',
|
||||
self::Discarded => 'Absage',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enum\Groups;
|
||||
|
||||
enum AccommodationCountry: string
|
||||
{
|
||||
case Germany = 'DE';
|
||||
case Austria = 'AT';
|
||||
case Switzerland = 'CH';
|
||||
case Italy = 'IT';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'enum.accommodation_country.'.$this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logo of the legal entity operating this country's accommodations, shown in the
|
||||
* header of the public booking and offer pages. Null falls back to the logo of the
|
||||
* request host — Germany has no dedicated entity.
|
||||
*/
|
||||
public function logo(): ?string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Austria => 'logo_cllt.svg',
|
||||
self::Switzerland => 'logo_alpinevacation.svg',
|
||||
self::Italy => 'logo_ep.svg',
|
||||
self::Germany => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Service\AdditionalServiceExclusionResolver;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
@@ -18,6 +20,11 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
*/
|
||||
class AccommodationStep2Type extends AbstractType
|
||||
{
|
||||
public function __construct(
|
||||
private readonly AdditionalServiceExclusionResolver $exclusionResolver,
|
||||
) {
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
@@ -51,7 +58,9 @@ class AccommodationStep2Type extends AbstractType
|
||||
])
|
||||
;
|
||||
|
||||
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void {
|
||||
$availableServices = $options['additional_services'];
|
||||
|
||||
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($availableServices): void {
|
||||
$data = $event->getData();
|
||||
|
||||
if (!is_array($data)) {
|
||||
@@ -64,6 +73,14 @@ class AccommodationStep2Type extends AbstractType
|
||||
}
|
||||
}
|
||||
|
||||
$dto = $event->getForm()->getData();
|
||||
|
||||
$data['selectedAdditionalServiceIds'] = $this->exclusionResolver->resolve(
|
||||
$availableServices,
|
||||
array_map('intval', (array) ($data['selectedAdditionalServiceIds'] ?? [])),
|
||||
$dto instanceof AccommodationBookingDto ? $dto->selectedAdditionalServiceIds : [],
|
||||
);
|
||||
|
||||
$event->setData($data);
|
||||
});
|
||||
}
|
||||
@@ -75,8 +92,10 @@ class AccommodationStep2Type extends AbstractType
|
||||
'validation_groups' => ['step_2'],
|
||||
'board_service_choices' => [],
|
||||
'additional_service_choices' => [],
|
||||
'additional_services' => [],
|
||||
'max_adolescent_age' => 0,
|
||||
]);
|
||||
$resolver->setAllowedTypes('max_adolescent_age', 'int');
|
||||
$resolver->setAllowedTypes('additional_services', AdditionalService::class . '[]');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Admin\Groups;
|
||||
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* Lean form for creating a booking. The available board and additional services can only be
|
||||
* resolved once accommodation and date range are known, so they are offered on the edit page.
|
||||
*
|
||||
* @extends AbstractType<AccommodationBooking>
|
||||
*/
|
||||
class AccommodationBookingCreateType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('accommodation', EntityType::class, [
|
||||
'class' => Accommodation::class,
|
||||
'choice_label' => 'name',
|
||||
'label' => 'Gruppenhaus',
|
||||
])
|
||||
->add('dateFrom', DateType::class, [
|
||||
'label' => 'Anreise',
|
||||
'widget' => 'single_text',
|
||||
])
|
||||
->add('dateTo', DateType::class, [
|
||||
'label' => 'Abreise',
|
||||
'widget' => 'single_text',
|
||||
])
|
||||
->add('paxCount', IntegerType::class, [
|
||||
'label' => 'Anzahl Personen',
|
||||
])
|
||||
->add('minorsCount', IntegerType::class, [
|
||||
'label' => 'davon Kinder (0–3 Jahre)',
|
||||
])
|
||||
->add('childrenCount', IntegerType::class, [
|
||||
'label' => 'davon Kinder',
|
||||
])
|
||||
->add('status', EnumType::class, [
|
||||
'label' => 'Status',
|
||||
'class' => AccommodationBookingStatus::class,
|
||||
'choices' => [
|
||||
AccommodationBookingStatus::Draft,
|
||||
AccommodationBookingStatus::Inquiry,
|
||||
AccommodationBookingStatus::Booking,
|
||||
],
|
||||
'choice_label' => fn (AccommodationBookingStatus $status) => $status->label(),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => AccommodationBooking::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -4,20 +4,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Admin\Groups;
|
||||
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Entity\Groups\BoardService;
|
||||
use App\Entity\User;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Range;
|
||||
|
||||
@@ -26,17 +28,13 @@ class AccommodationBookingType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
if ($options['with_accommodation']) {
|
||||
$builder->add('accommodation', EntityType::class, [
|
||||
'class' => Accommodation::class,
|
||||
'choice_label' => 'name',
|
||||
'label' => 'Gruppenhaus',
|
||||
]);
|
||||
}
|
||||
|
||||
// The contact fields carry no HTML5 `required` attribute: a draft must be saveable
|
||||
// while still empty. They are enforced server-side by the `edit` validation group
|
||||
// as soon as the booking leaves Entwurf — see configureOptions().
|
||||
$builder
|
||||
->add('groupName', TextType::class, [
|
||||
'label' => 'Gruppenname',
|
||||
'required' => false,
|
||||
])
|
||||
->add('salutation', ChoiceType::class, [
|
||||
'label' => 'Anrede',
|
||||
@@ -50,12 +48,15 @@ class AccommodationBookingType extends AbstractType
|
||||
])
|
||||
->add('firstName', TextType::class, [
|
||||
'label' => 'Vorname',
|
||||
'required' => false,
|
||||
])
|
||||
->add('lastName', TextType::class, [
|
||||
'label' => 'Nachname',
|
||||
'required' => false,
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'label' => 'E-Mail',
|
||||
'required' => false,
|
||||
])
|
||||
->add('phone', TextType::class, [
|
||||
'label' => 'Telefon',
|
||||
@@ -121,10 +122,25 @@ class AccommodationBookingType extends AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('isInquiry', CheckboxType::class, [
|
||||
'label' => 'Anfrage (nicht bindend)',
|
||||
// Assigning a manager is reserved for the groups admins; the controller leaves the
|
||||
// choices empty for everyone else, so the field never enters the form tree and a
|
||||
// plain manager cannot set it by hand-crafting the request either.
|
||||
if (!empty($options['assignable_managers'])) {
|
||||
$builder->add('managedBy', EntityType::class, [
|
||||
'class' => User::class,
|
||||
'required' => false,
|
||||
'choices' => $options['assignable_managers'],
|
||||
'choice_label' => 'email',
|
||||
'placeholder' => 'keine Zuordnung',
|
||||
'label' => 'Bearbeiter:in',
|
||||
]);
|
||||
}
|
||||
|
||||
$builder
|
||||
->add('status', EnumType::class, [
|
||||
'label' => 'Status',
|
||||
'class' => AccommodationBookingStatus::class,
|
||||
'choice_label' => fn (AccommodationBookingStatus $status) => $status->label(),
|
||||
])
|
||||
->add('accommodationDiscount', IntegerType::class, [
|
||||
'label' => 'Rabatt Unterkunft (%)',
|
||||
@@ -158,18 +174,30 @@ class AccommodationBookingType extends AbstractType
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => AccommodationBooking::class,
|
||||
'with_accommodation' => false,
|
||||
// Entwurf is a scratch record the office fills in over time, and an Absage is
|
||||
// never going anywhere — neither needs complete contact data. The groups are
|
||||
// resolved after binding, so promoting a draft to Anfrage or Buchung enforces
|
||||
// the contact data in the very same save.
|
||||
'validation_groups' => static function (FormInterface $form): array {
|
||||
/** @var AccommodationBooking $booking */
|
||||
$booking = $form->getData();
|
||||
|
||||
return $booking->isDraft() || $booking->isDiscarded()
|
||||
? ['Default']
|
||||
: ['Default', 'edit'];
|
||||
},
|
||||
'max_adolescent_age' => 0,
|
||||
'board_services' => [],
|
||||
'additional_services' => [],
|
||||
'current_board_service' => null,
|
||||
'current_additional_services' => [],
|
||||
'assignable_managers' => [],
|
||||
]);
|
||||
$resolver->setAllowedTypes('with_accommodation', 'bool');
|
||||
$resolver->setAllowedTypes('max_adolescent_age', 'int');
|
||||
$resolver->setAllowedTypes('board_services', 'array');
|
||||
$resolver->setAllowedTypes('additional_services', 'array');
|
||||
$resolver->setAllowedTypes('current_board_service', ['null', BoardService::class]);
|
||||
$resolver->setAllowedTypes('current_additional_services', 'array');
|
||||
$resolver->setAllowedTypes('assignable_managers', 'array');
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Form\Admin\Groups;
|
||||
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Enum\Groups\AccommodationCountry;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -38,6 +40,11 @@ class AccommodationType extends AbstractType
|
||||
'CHF' => 'CHF',
|
||||
],
|
||||
])
|
||||
->add('country', EnumType::class, [
|
||||
'label' => 'Land',
|
||||
'class' => AccommodationCountry::class,
|
||||
'choice_label' => fn (AccommodationCountry $country): string => $country->label(),
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Form\Admin\Groups;
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Enum\Groups\AdditionalServiceType as AdditionalServiceTypeEnum;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||
@@ -46,6 +47,15 @@ class AdditionalServiceType extends AbstractType
|
||||
'required' => false,
|
||||
'disabled' => true,
|
||||
])
|
||||
->add('exclusionGroup', TextType::class, [
|
||||
'label' => 'Ausschlussgruppe',
|
||||
'required' => false,
|
||||
'help' => 'Leistungen mit derselben Ausschlussgruppe können sich gegenseitig abwählen.',
|
||||
])
|
||||
->add('isExclusive', CheckboxType::class, [
|
||||
'label' => 'Schließt andere Leistungen dieser Gruppe aus',
|
||||
'required' => false,
|
||||
])
|
||||
->add('dateFrom', DateType::class, [
|
||||
'label' => 'Datum von',
|
||||
'html5' => true,
|
||||
|
||||
@@ -70,6 +70,21 @@ class BookingDto
|
||||
*/
|
||||
public ?string $originalFingerprint = null;
|
||||
|
||||
/**
|
||||
* Whether the applicant has already been notified that family insurance became
|
||||
* available after they picked a non-family insurance while dependents were incomplete.
|
||||
* Prevents re-showing the same hint on every subsequent participant card submission.
|
||||
*/
|
||||
public bool $familyInsuranceHintShown = false;
|
||||
|
||||
/**
|
||||
* Whether the applicant's current insurance choice was made while family insurance
|
||||
* was not yet eligible (i.e. before all dependents' dates of birth were known).
|
||||
* Set at selection time; used to distinguish "family insurance just became
|
||||
* available" from "it was available all along and the applicant chose otherwise".
|
||||
*/
|
||||
public bool $applicantInsuranceChosenWhileFamilyIneligible = false;
|
||||
|
||||
public function __construct(public Travel $travel, public int $hotelId)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ class ParticipantEditDto
|
||||
* Validates that insurance is selected when required.
|
||||
*
|
||||
* Insurance is required for all participants in create mode, EXCEPT for dependent
|
||||
* participants when the applicant has enabled bulk insurance booking. In that case,
|
||||
* the insurance field is hidden and will be automatically assigned by the bulk
|
||||
* insurance handler.
|
||||
* participants when the applicant has enabled bulk insurance booking, or when the
|
||||
* applicant has a family insurance selected. In both cases, the insurance field is
|
||||
* hidden and coverage is derived from the applicant instead.
|
||||
*
|
||||
* In edit submissions, this validation is skipped entirely because insurance
|
||||
* data is readonly and preserved as-is from the BPN API.
|
||||
@@ -90,6 +90,10 @@ class ParticipantEditDto
|
||||
if (true === $applicant?->bulkInsuranceBooking) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (null !== $applicant?->insurance && true === $applicant->insurance->familyInsurance) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $this->participant->insurance) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service\Condition;
|
||||
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Contract\FieldConditionInterface;
|
||||
|
||||
/**
|
||||
* True for dependent participants when the applicant has a family insurance selected.
|
||||
*
|
||||
* Family insurance covers the whole family under a single policy on the applicant, so
|
||||
* dependents must not be offered their own insurance selection while it's active.
|
||||
*/
|
||||
class FamilyInsuranceActiveCondition implements FieldConditionInterface
|
||||
{
|
||||
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
|
||||
{
|
||||
if (0 === $participantIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
|
||||
return null !== $applicant
|
||||
&& null !== $applicant->insurance
|
||||
&& true === $applicant->insurance->familyInsurance;
|
||||
}
|
||||
|
||||
public function getDependentFields(): array
|
||||
{
|
||||
return ['insurance'];
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Applicant has a family insurance selected';
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ use App\Form\Service\Condition\BookingEligibilityCondition;
|
||||
use App\Form\Service\Condition\BulkInsuranceBookingCondition;
|
||||
use App\Form\Service\Condition\CompositeCondition;
|
||||
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
|
||||
use App\Form\Service\Condition\FamilyInsuranceActiveCondition;
|
||||
use App\Form\Service\Condition\FieldValueCondition;
|
||||
use App\Form\Service\Condition\FinalBookingOnlyCondition;
|
||||
use App\Form\Service\Condition\FirstParticipantCondition;
|
||||
@@ -221,11 +222,13 @@ class CreateFieldStateProvider extends AbstractFieldStateProvider
|
||||
),
|
||||
];
|
||||
|
||||
// Hide insurance field until date of birth is provided OR when bulk insurance booking is active OR when participant is ineligible
|
||||
// Hide insurance field until date of birth is provided OR when bulk insurance booking is active
|
||||
// OR when the applicant has a family insurance active (it already covers dependents) OR when participant is ineligible
|
||||
$this->fieldStateConditions['insurance'] = [
|
||||
'hidden' => CompositeCondition::or(
|
||||
CompositeCondition::not($dateOfBirthProvidedCondition),
|
||||
$bulkInsuranceBookingCondition,
|
||||
new FamilyInsuranceActiveCondition(),
|
||||
$bookingEligibilityCondition
|
||||
),
|
||||
];
|
||||
|
||||
@@ -1159,15 +1159,17 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
||||
// Get selectable (non-complementary) insurances with caching
|
||||
$selectableInsurances = $this->insuranceService->getSelectableInsurances($bookingDto->travel);
|
||||
|
||||
// Calculate travel price for eligibility filtering
|
||||
$travelPrice = $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($bookingDto, $participantIndex);
|
||||
// Family insurances are priced by the total booking price rather than the individual
|
||||
// participant's price - InsuranceManager applies the correct basis per insurance type
|
||||
$individualPrice = $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($bookingDto, $participantIndex);
|
||||
$totalBookingPrice = $this->priceCalculatorService->calculateTotalBookingPriceExcludingInsurance($bookingDto);
|
||||
|
||||
// Filter based on eligibility criteria for this participant
|
||||
$eligibleInsurances = $this->insuranceService->getEligibleInsurances(
|
||||
$eligibleInsurances = $this->insuranceService->getEligibleInsurancesForParticipant(
|
||||
$selectableInsurances,
|
||||
$participant,
|
||||
$bookingDto,
|
||||
$travelPrice
|
||||
$individualPrice,
|
||||
$totalBookingPrice
|
||||
);
|
||||
|
||||
// Inject synthetic "no insurance" option at the top of the list
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\InsuranceManager;
|
||||
@@ -124,6 +125,19 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
|
||||
* @param int $participantIndex The index of the participant being processed
|
||||
*/
|
||||
public function processField(array $submittedData, BookingDto $bookingDto, int $participantIndex): void
|
||||
{
|
||||
$this->applyInsuranceSelection($submittedData, $bookingDto, $participantIndex);
|
||||
|
||||
// Runs after the selection above is fully resolved, so a submission that itself
|
||||
// switches the applicant to family insurance doesn't trigger a stale "please
|
||||
// recheck" notification about the choice it just made.
|
||||
$this->notifyApplicantIfFamilyInsuranceNewlyAvailable($bookingDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $submittedData The submitted participant form data
|
||||
*/
|
||||
private function applyInsuranceSelection(array $submittedData, BookingDto $bookingDto, int $participantIndex): void
|
||||
{
|
||||
$participant = $bookingDto->getParticipant($participantIndex);
|
||||
if (null === $participant) {
|
||||
@@ -136,9 +150,6 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
|
||||
// Get selectable (non-complementary) insurances with caching
|
||||
$selectableInsurances = $this->insuranceService->getSelectableInsurances($bookingDto->travel);
|
||||
|
||||
// Calculate travel price for eligibility checks
|
||||
$travelPrice = $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($bookingDto, $participantIndex);
|
||||
|
||||
// Determine if this is a new user selection or just form resubmission
|
||||
$isNewSelection = null !== $selectedInsuranceId
|
||||
&& (null === $currentInsurance || !$this->isSameInsurance($selectedInsuranceId, $currentInsurance));
|
||||
@@ -155,12 +166,16 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
|
||||
$noInsurance->price = 0.0;
|
||||
$participant->insurance = $noInsurance;
|
||||
|
||||
$this->recordFamilyIneligibilityAtSelectionTime($bookingDto, $participantIndex, $noInsurance);
|
||||
|
||||
return; // Skip all other processing for "no insurance"
|
||||
}
|
||||
|
||||
$selectedInsurance = $this->findInsuranceById($selectableInsurances, $selectedInsuranceId);
|
||||
|
||||
if (null !== $selectedInsurance) {
|
||||
$travelPrice = $this->priceCalculatorService->resolveInsuranceTravelPrice($bookingDto, $participantIndex, $selectedInsurance);
|
||||
|
||||
$eligibleInsurances = $this->insuranceService->getEligibleInsurances($selectableInsurances, $participant, $bookingDto, $travelPrice);
|
||||
$isSelectedInsuranceEligible = $this->isInsuranceInList($selectedInsurance, $eligibleInsurances);
|
||||
|
||||
@@ -189,15 +204,22 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
|
||||
// Insurance not found - clear selection
|
||||
$participant->insurance = null;
|
||||
}
|
||||
|
||||
$this->recordFamilyIneligibilityAtSelectionTime($bookingDto, $participantIndex, $participant->insurance);
|
||||
}
|
||||
|
||||
// Handle form resubmission with existing insurance (automatic reassignment check)
|
||||
if (null !== $currentInsurance && null !== $selectedInsuranceId) {
|
||||
// Only applies when the selection didn't just change above - otherwise this would
|
||||
// re-validate the now-stale $currentInsurance and could overwrite the fresh selection
|
||||
// the block above already made in this same request.
|
||||
if (!$isNewSelection && null !== $currentInsurance && null !== $selectedInsuranceId) {
|
||||
// Preserve "no insurance" selection during resubmission
|
||||
if ($currentInsurance->isNoInsurance()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$travelPrice = $this->priceCalculatorService->resolveInsuranceTravelPrice($bookingDto, $participantIndex, $currentInsurance);
|
||||
|
||||
// Check if current insurance is still eligible with updated participant data
|
||||
$eligibleInsurances = $this->insuranceService->getEligibleInsurances($selectableInsurances, $participant, $bookingDto, $travelPrice);
|
||||
$isCurrentInsuranceStillEligible = $this->isInsuranceInList($currentInsurance, $eligibleInsurances);
|
||||
@@ -259,6 +281,95 @@ class ParticipantInsuranceFieldHandler extends AbstractParticipantFieldHandler
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Records whether the applicant's insurance choice was made while family insurance
|
||||
* was NOT yet eligible, so the notification below can tell "just became available"
|
||||
* apart from "was available all along and the applicant chose non-family anyway".
|
||||
*
|
||||
* Only called when the applicant (index 0) makes a genuine new selection - not on
|
||||
* mere resubmission/price-tier reassignment of an already-standing choice.
|
||||
*/
|
||||
private function recordFamilyIneligibilityAtSelectionTime(BookingDto $bookingDto, int $participantIndex, ?Insurance $insurance): void
|
||||
{
|
||||
if (0 !== $participantIndex || null === $insurance || true === $insurance->familyInsurance) {
|
||||
return;
|
||||
}
|
||||
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
if (null === $applicant) {
|
||||
return;
|
||||
}
|
||||
|
||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible = !$this->hasEligibleFamilyInsurance($bookingDto, $applicant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a family insurance is actually eligible right now - not just whether
|
||||
* the participant composition qualifies as a family booking, but whether a selectable
|
||||
* family insurance product actually matches the current total booking price.
|
||||
*
|
||||
* Used by both the selection-time recording above and the notification below, so they
|
||||
* can never disagree on what "family insurance is eligible" means.
|
||||
*/
|
||||
private function hasEligibleFamilyInsurance(BookingDto $bookingDto, ParticipantDto $applicant): bool
|
||||
{
|
||||
if (!$bookingDto->isFamilyBooking()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$selectableInsurances = $this->insuranceService->getSelectableInsurances($bookingDto->travel);
|
||||
$familyInsurances = array_values(array_filter($selectableInsurances, static fn (Insurance $i) => true === $i->familyInsurance));
|
||||
|
||||
if ([] === $familyInsurances) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$totalPrice = $this->priceCalculatorService->calculateTotalBookingPriceExcludingInsurance($bookingDto);
|
||||
|
||||
return [] !== $this->insuranceService->getEligibleInsurances($familyInsurances, $applicant, $bookingDto, $totalPrice);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the applicant when family insurance becomes available after the fact.
|
||||
*
|
||||
* Participants are entered one card at a time, in any order, so the applicant is
|
||||
* likely to pick a non-family insurance before any dependent's date of birth makes
|
||||
* the booking eligible for family insurance. Once that happens, nothing prompts the
|
||||
* applicant to revisit their earlier choice. This surfaces a one-time hint via the
|
||||
* existing notification/toast pipeline (App\Form\Model\ParticipantDto::addNotification()),
|
||||
* mirroring the cross-participant side effect already used by
|
||||
* ParticipantAssignedRoomFieldHandler::resolveRoomCapacityConflict() for room conflicts.
|
||||
*
|
||||
* Requires `applicantInsuranceChosenWhileFamilyIneligible` to be true - i.e. the
|
||||
* choice was actually made before family insurance was possible - not just that
|
||||
* family insurance happens to be eligible now (it may have been all along).
|
||||
*/
|
||||
private function notifyApplicantIfFamilyInsuranceNewlyAvailable(BookingDto $bookingDto): void
|
||||
{
|
||||
if ($bookingDto->familyInsuranceHintShown) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$bookingDto->applicantInsuranceChosenWhileFamilyIneligible) {
|
||||
return;
|
||||
}
|
||||
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
if (null === $applicant || null === $applicant->insurance || true === $applicant->insurance->familyInsurance) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->hasEligibleFamilyInsurance($bookingDto, $applicant)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$applicant->addNotification(
|
||||
'info',
|
||||
'Für eure Konstellation ist auch eine Familienversicherung verfügbar und kann über die anmeldende Person gebucht werden.'
|
||||
);
|
||||
$bookingDto->familyInsuranceHintShown = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds an insurance by ID from the available insurances array.
|
||||
*
|
||||
|
||||
@@ -88,7 +88,7 @@ final readonly class AccommodationBookingApiResponse
|
||||
public function __construct(AccommodationBooking $booking, ?array $priceBreakdown)
|
||||
{
|
||||
$this->uuid = $booking->getUuid();
|
||||
$this->status = $booking->isInquiry() ? 'inquiry' : 'booking';
|
||||
$this->status = $booking->getStatus()->value;
|
||||
$this->dateFrom = $booking->getDateFrom();
|
||||
$this->dateTo = $booking->getDateTo();
|
||||
$this->nights = $booking->getNights();
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Repository\Groups;
|
||||
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
@@ -20,4 +21,16 @@ class AdditionalServiceRepository extends ServiceEntityRepository
|
||||
{
|
||||
parent::__construct($registry, AdditionalService::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional services are ordered manually in the admin; dateFrom and id only break ties
|
||||
* between records that share a position (newly created or duplicated ones).
|
||||
*/
|
||||
protected function applyOrdering(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder
|
||||
->orderBy('s.position', 'ASC')
|
||||
->addOrderBy('s.dateFrom', 'ASC')
|
||||
->addOrderBy('s.id', 'ASC');
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace App\Repository\Groups;
|
||||
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
/**
|
||||
* @template T of object
|
||||
@@ -26,16 +27,26 @@ trait FindsByAccommodationAndDateRangeTrait
|
||||
\DateTimeImmutable $dateFrom,
|
||||
\DateTimeImmutable $dateTo,
|
||||
): array {
|
||||
return $this->createQueryBuilder('s')
|
||||
$queryBuilder = $this->createQueryBuilder('s')
|
||||
->where('s.accommodation = :accommodation')
|
||||
->andWhere('s.dateFrom <= :dateTo')
|
||||
->andWhere('s.dateTo >= :dateFrom')
|
||||
->setParameter('accommodation', $accommodation)
|
||||
->setParameter('dateFrom', $dateFrom)
|
||||
->setParameter('dateTo', $dateTo)
|
||||
->setParameter('dateTo', $dateTo);
|
||||
|
||||
$this->applyOrdering($queryBuilder);
|
||||
|
||||
return $queryBuilder->getQuery()->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordering applied to the query above; override to sort by something else.
|
||||
*/
|
||||
protected function applyOrdering(QueryBuilder $queryBuilder): void
|
||||
{
|
||||
$queryBuilder
|
||||
->orderBy('s.dateFrom', 'ASC')
|
||||
->addOrderBy('s.label', 'ASC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
->addOrderBy('s.label', 'ASC');
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,22 @@ class UserRepository extends ServiceEntityRepository
|
||||
{
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Users who can look after a group booking. The roles are a JSON array column and no
|
||||
* JSON_CONTAINS is registered, so the needles carry their quotes to stay anchored to
|
||||
* whole array entries. Only the literal roles count — a plain ROLE_ADMIN is not offered.
|
||||
*
|
||||
* @return User[]
|
||||
*/
|
||||
public function findGroupsStaff(): array
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->andWhere('u.roles LIKE :groupsAdmin OR u.roles LIKE :groupsManager')
|
||||
->setParameter('groupsAdmin', '%"ROLE_GROUPS_ADMIN"%')
|
||||
->setParameter('groupsManager', '%"ROLE_GROUPS_MANAGER"%')
|
||||
->orderBy('u.email', 'ASC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Entity\Groups\AccommodationPrice;
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Entity\Groups\BoardService;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Model\AccommodationBookingQueryParams;
|
||||
use App\Model\CmsHotelData;
|
||||
@@ -37,7 +38,7 @@ class AccommodationBookingService
|
||||
private readonly CmsDataProvider $cmsDataProvider,
|
||||
private readonly AccommodationBookingLinkSigner $linkSigner,
|
||||
private readonly AccommodationBookingBreakdownCalculator $breakdownCalculator,
|
||||
private readonly string $officeEmail,
|
||||
private readonly string $accommodationEmail,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -156,11 +157,9 @@ class AccommodationBookingService
|
||||
}
|
||||
}
|
||||
|
||||
// Additional services keep the repository order (manual position), which also makes the
|
||||
// groups appear in the order of their lowest-positioned member.
|
||||
$boardServices = $this->sortServicesByPriceThenLabel($boardServices);
|
||||
$ungrouped = $this->sortServicesByPriceThenLabel($ungrouped);
|
||||
foreach ($grouped as $groupName => $groupServices) {
|
||||
$grouped[$groupName] = $this->sortServicesByPriceThenLabel($groupServices);
|
||||
}
|
||||
|
||||
return [
|
||||
'boardServices' => $boardServices,
|
||||
@@ -171,17 +170,15 @@ class AccommodationBookingService
|
||||
}
|
||||
|
||||
/**
|
||||
* Free services (price 0) first, then alphabetically; each group sorted alphabetically.
|
||||
* Free services (price 0) first, then alphabetically.
|
||||
*
|
||||
* @template T of BoardService|AdditionalService
|
||||
* @param BoardService[] $services
|
||||
*
|
||||
* @param T[] $services
|
||||
*
|
||||
* @return T[]
|
||||
* @return BoardService[]
|
||||
*/
|
||||
private function sortServicesByPriceThenLabel(array $services): array
|
||||
{
|
||||
usort($services, static function (BoardService|AdditionalService $a, BoardService|AdditionalService $b): int {
|
||||
usort($services, static function (BoardService $a, BoardService $b): int {
|
||||
$aFree = 0 === $a->getPrice() ? 0 : 1;
|
||||
$bFree = 0 === $b->getPrice() ? 0 : 1;
|
||||
|
||||
@@ -268,7 +265,11 @@ class AccommodationBookingService
|
||||
$booking->setPaxCount($dto->paxCount);
|
||||
$booking->setMinorsCount($dto->minorsCount);
|
||||
$booking->setChildrenCount($dto->childrenCount);
|
||||
$booking->setIsInquiry($dto->forceInquiry || $this->computeInquiryStatus($dto, $prices)->isInquiry);
|
||||
$booking->setStatus(
|
||||
$dto->forceInquiry || $this->computeInquiryStatus($dto, $prices)->isInquiry
|
||||
? AccommodationBookingStatus::Inquiry
|
||||
: AccommodationBookingStatus::Booking
|
||||
);
|
||||
|
||||
// Freeze board service as scalar fields (no FK)
|
||||
if (null !== $dto->selectedBoardServiceId) {
|
||||
@@ -369,6 +370,30 @@ class AccommodationBookingService
|
||||
|
||||
public function sendNotificationEmail(AccommodationBooking $booking): void
|
||||
{
|
||||
$this->sendBookingEmail(
|
||||
$booking,
|
||||
$this->accommodationEmail,
|
||||
sprintf(
|
||||
'Neue Unterkunfts%s: %s',
|
||||
$booking->isInquiry() ? 'anfrage' : 'buchung',
|
||||
$booking->getAccommodation()?->getName(),
|
||||
),
|
||||
'email/accommodation_booking.html.twig',
|
||||
'Failed to send accommodation booking notification email',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* All accommodation mail is sent from the group desk address so customer replies
|
||||
* land there rather than in the general inbox.
|
||||
*/
|
||||
private function sendBookingEmail(
|
||||
AccommodationBooking $booking,
|
||||
string $to,
|
||||
string $subject,
|
||||
string $template,
|
||||
string $errorMessage,
|
||||
): void {
|
||||
try {
|
||||
$this->mailer->createAndSendEmail(
|
||||
[
|
||||
@@ -376,18 +401,15 @@ class AccommodationBookingService
|
||||
'accessLink' => $this->accessLinkOrNull($booking),
|
||||
],
|
||||
[
|
||||
'to' => $this->officeEmail,
|
||||
'subject' => sprintf(
|
||||
'Neue Unterkunfts%s: %s',
|
||||
$booking->isInquiry() ? 'anfrage' : 'buchung',
|
||||
$booking->getAccommodation()?->getName(),
|
||||
),
|
||||
'template' => 'email/accommodation_booking.html.twig',
|
||||
'from' => $this->accommodationEmail,
|
||||
'to' => $to,
|
||||
'subject' => $subject,
|
||||
'template' => $template,
|
||||
'attachments' => [],
|
||||
],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to send accommodation booking notification email', [
|
||||
$this->logger->error($errorMessage, [
|
||||
'booking_id' => $booking->getId(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
@@ -395,13 +417,13 @@ class AccommodationBookingService
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accessLinkIssuedAt for a direct (non-inquiry) booking if it doesn't have one yet.
|
||||
* Sets accessLinkIssuedAt if the booking doesn't have one yet, whatever its status.
|
||||
* No email side effect — the confirmation email is always sent separately via
|
||||
* sendCustomerConfirmationEmail(), regardless of whether a link exists.
|
||||
*/
|
||||
public function issueAccessLinkForDirectBooking(AccommodationBooking $booking): void
|
||||
public function issueAccessLink(AccommodationBooking $booking): void
|
||||
{
|
||||
if ($booking->isInquiry() || null !== $booking->getAccessLinkIssuedAt()) {
|
||||
if (null !== $booking->getAccessLinkIssuedAt()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -409,33 +431,42 @@ class AccommodationBookingService
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Issues the access link only for a confirmed booking. Inquiries from the public flow
|
||||
* deliberately get no link — the office prepares the offer first and issues the link
|
||||
* when it switches the booking to Anfrage.
|
||||
*/
|
||||
public function issueAccessLinkForDirectBooking(AccommodationBooking $booking): void
|
||||
{
|
||||
if (!$booking->isBooking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->issueAccessLink($booking);
|
||||
}
|
||||
|
||||
/**
|
||||
* Always sends a confirmation email to the customer, whether or not an access link
|
||||
* exists yet — the template renders differently depending on accessLink being present.
|
||||
* exists yet — the template renders differently depending on accessLink being present,
|
||||
* so the subject has to follow the same distinction.
|
||||
*/
|
||||
public function sendCustomerConfirmationEmail(AccommodationBooking $booking): void
|
||||
{
|
||||
try {
|
||||
$this->mailer->createAndSendEmail(
|
||||
[
|
||||
'booking' => $booking,
|
||||
'accessLink' => $this->accessLinkOrNull($booking),
|
||||
],
|
||||
[
|
||||
'to' => $booking->getEmail(),
|
||||
'subject' => $booking->isInquiry()
|
||||
? 'Deine Anfrage ist bei uns eingegangen'
|
||||
: 'Deine Buchung ist bestätigt',
|
||||
'template' => 'email/accommodation_booking_customer.html.twig',
|
||||
'attachments' => [],
|
||||
],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to send accommodation booking customer confirmation email', [
|
||||
'booking_id' => $booking->getId(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
if (!$booking->isInquiry()) {
|
||||
$subject = 'Deine Buchung ist bestätigt';
|
||||
} elseif (null !== $booking->getAccessLinkIssuedAt()) {
|
||||
$subject = 'Dein Angebot ist bereit';
|
||||
} else {
|
||||
$subject = 'Deine Anfrage ist bei uns eingegangen';
|
||||
}
|
||||
|
||||
$this->sendBookingEmail(
|
||||
$booking,
|
||||
$booking->getEmail(),
|
||||
$subject,
|
||||
'email/accommodation_booking_customer.html.twig',
|
||||
'Failed to send accommodation booking customer confirmation email',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -459,7 +490,7 @@ class AccommodationBookingService
|
||||
return;
|
||||
}
|
||||
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
$booking->setAcceptedAt(new \DateTimeImmutable());
|
||||
$this->entityManager->flush();
|
||||
|
||||
@@ -469,48 +500,24 @@ class AccommodationBookingService
|
||||
|
||||
public function sendOfferAcceptedNotificationEmail(AccommodationBooking $booking): void
|
||||
{
|
||||
try {
|
||||
$this->mailer->createAndSendEmail(
|
||||
[
|
||||
'booking' => $booking,
|
||||
'accessLink' => $this->accessLinkOrNull($booking),
|
||||
],
|
||||
[
|
||||
'to' => $this->officeEmail,
|
||||
'subject' => sprintf('Angebot angenommen: %s', $booking->getAccommodation()?->getName()),
|
||||
'template' => 'email/offer_accepted.html.twig',
|
||||
'attachments' => [],
|
||||
],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to send offer accepted notification email', [
|
||||
'booking_id' => $booking->getId(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
$this->sendBookingEmail(
|
||||
$booking,
|
||||
$this->accommodationEmail,
|
||||
sprintf('Angebot angenommen: %s', $booking->getAccommodation()?->getName()),
|
||||
'email/offer_accepted.html.twig',
|
||||
'Failed to send offer accepted notification email',
|
||||
);
|
||||
}
|
||||
|
||||
public function sendOfferAcceptedCustomerEmail(AccommodationBooking $booking): void
|
||||
{
|
||||
try {
|
||||
$this->mailer->createAndSendEmail(
|
||||
[
|
||||
'booking' => $booking,
|
||||
'accessLink' => $this->accessLinkOrNull($booking),
|
||||
],
|
||||
[
|
||||
'to' => $booking->getEmail(),
|
||||
'subject' => 'Deine Buchung ist bestätigt',
|
||||
'template' => 'email/offer_accepted_customer.html.twig',
|
||||
'attachments' => [],
|
||||
],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to send offer accepted customer email', [
|
||||
'booking_id' => $booking->getId(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
$this->sendBookingEmail(
|
||||
$booking,
|
||||
$booking->getEmail(),
|
||||
'Deine Buchung ist bestätigt',
|
||||
'email/offer_accepted_customer.html.twig',
|
||||
'Failed to send offer accepted customer email',
|
||||
);
|
||||
}
|
||||
|
||||
private function accessLinkOrNull(AccommodationBooking $booking): ?string
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Groups\AccommodationPrice;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
|
||||
/**
|
||||
* Determines which days of a date range are covered by an AccommodationPrice.
|
||||
*
|
||||
* A day without a covering price is not sold and must not be offered as available,
|
||||
* regardless of what the external contingent calendar reports.
|
||||
*/
|
||||
final readonly class AccommodationPriceCoverage
|
||||
{
|
||||
public function __construct(
|
||||
private AccommodationPriceRepository $priceRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, true> keyed by Y-m-d, only covered days present
|
||||
*/
|
||||
public function coveredDates(string $hotelCode, \DateTimeImmutable $dateFrom, \DateTimeImmutable $dateTo): array
|
||||
{
|
||||
return $this->coveredDatesFor(
|
||||
$this->priceRepository->findByHotelCodeAndDateRange($hotelCode, $dateFrom, $dateTo),
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccommodationPrice[] $prices
|
||||
*
|
||||
* @return array<string, true> keyed by Y-m-d, only covered days present
|
||||
*/
|
||||
public function coveredDatesFor(array $prices, \DateTimeImmutable $dateFrom, \DateTimeImmutable $dateTo): array
|
||||
{
|
||||
$start = $dateFrom->setTime(0, 0);
|
||||
$end = $dateTo->setTime(0, 0);
|
||||
|
||||
$covered = [];
|
||||
|
||||
// dateFrom and dateTo are both inclusive (last night, not checkout day)
|
||||
for ($day = $start; $day <= $end; $day = $day->modify('+1 day')) {
|
||||
foreach ($prices as $price) {
|
||||
if ($price->getDateFrom() <= $day && $price->getDateTo() >= $day) {
|
||||
$covered[$day->format('Y-m-d')] = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $covered;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* Resolves the terms and conditions a booking is concluded under.
|
||||
*
|
||||
* Which legal entity operates an accommodation depends on the country it is located in,
|
||||
* and each entity has its own AGB document. Countries without a dedicated entity — and
|
||||
* any country whose document is not configured in this environment — fall back to the
|
||||
* general E&P terms.
|
||||
*/
|
||||
class AccommodationTermsUrlProvider
|
||||
{
|
||||
/** @var array<string, string> country code → terms document URL */
|
||||
private array $termsUrls;
|
||||
|
||||
/**
|
||||
* @param array<string, string> $config
|
||||
*/
|
||||
public function __construct(
|
||||
array $config,
|
||||
private readonly string $termsAndConditionsUrl,
|
||||
) {
|
||||
$this->termsUrls = $this->resolveConfig($config);
|
||||
}
|
||||
|
||||
public function forAccommodation(?Accommodation $accommodation): string
|
||||
{
|
||||
$country = $accommodation?->getCountry();
|
||||
$url = null !== $country ? ($this->termsUrls[$country->value] ?? '') : '';
|
||||
|
||||
return '' !== $url ? $url : $this->termsAndConditionsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $config
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function resolveConfig(array $config): array
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
$resolver->setRequired(['AT', 'CH', 'IT']);
|
||||
$resolver->setAllowedTypes('AT', 'string');
|
||||
$resolver->setAllowedTypes('CH', 'string');
|
||||
$resolver->setAllowedTypes('IT', 'string');
|
||||
|
||||
return $resolver->resolve($config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
|
||||
/**
|
||||
* Resolves mutually exclusive additional services.
|
||||
*
|
||||
* Services sharing an exclusion group interact as soon as at least one of the two involved
|
||||
* services is flagged as exclusive: selecting the exclusive one clears all other members of
|
||||
* the group, selecting any other member clears the exclusive ones. Members that are not
|
||||
* exclusive can be combined freely.
|
||||
*
|
||||
* Conflicts are resolved in favour of the newest selection, determined by diffing the
|
||||
* submitted ids against the previously stored ones.
|
||||
*/
|
||||
class AdditionalServiceExclusionResolver
|
||||
{
|
||||
/**
|
||||
* @param AdditionalService[] $availableServices
|
||||
* @param array<array-key, int> $submittedIds keys are preserved, grouped radios submit under their group name
|
||||
* @param array<array-key, int> $previousIds
|
||||
*
|
||||
* @return array<array-key, int>
|
||||
*/
|
||||
public function resolve(array $availableServices, array $submittedIds, array $previousIds): array
|
||||
{
|
||||
$rules = $this->buildRules($availableServices);
|
||||
|
||||
if ([] === $rules) {
|
||||
return $submittedIds;
|
||||
}
|
||||
|
||||
$added = array_values(array_diff($submittedIds, $previousIds));
|
||||
|
||||
foreach ($added as $addedId) {
|
||||
if (!isset($rules[$addedId])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$submittedIds = array_filter(
|
||||
$submittedIds,
|
||||
fn(int $id) => !$this->conflicts($rules, $addedId, $id),
|
||||
);
|
||||
}
|
||||
|
||||
return $submittedIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, array{group: string, exclusive: bool}> $rules
|
||||
*/
|
||||
private function conflicts(array $rules, int $a, int $b): bool
|
||||
{
|
||||
if ($a === $b || !isset($rules[$b])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($rules[$a]['group'] !== $rules[$b]['group']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $rules[$a]['exclusive'] || $rules[$b]['exclusive'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AdditionalService[] $availableServices
|
||||
*
|
||||
* @return array<int, array{group: string, exclusive: bool}>
|
||||
*/
|
||||
private function buildRules(array $availableServices): array
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
foreach ($availableServices as $service) {
|
||||
$group = $service->getExclusionGroup();
|
||||
$id = $service->getId();
|
||||
|
||||
if (null === $id || null === $group || '' === $group) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rules[$id] = ['group' => $group, 'exclusive' => $service->isExclusive()];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\Form\Model\BookingDto;
|
||||
|
||||
/**
|
||||
@@ -76,6 +77,22 @@ class BookingPriceCalculator
|
||||
return $this->participantPricingCalculator->calculateAllParticipantIndividualPrices($bookingDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates total booking price across all participants, excluding insurance.
|
||||
*
|
||||
* Used for family insurance price-tier determination, where the tier is based on
|
||||
* the combined trip cost rather than any single participant's price.
|
||||
*/
|
||||
public function calculateTotalBookingPriceExcludingInsurance(BookingDto $bookingDto): float
|
||||
{
|
||||
$total = 0.0;
|
||||
foreach ($bookingDto->getParticipants() as $index => $participant) {
|
||||
$total += $this->calculateIndividualParticipantPriceExcludingInsurance($bookingDto, $index);
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the total price for an individual participant excluding insurance.
|
||||
*
|
||||
@@ -95,4 +112,22 @@ class BookingPriceCalculator
|
||||
$participantIndex
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the travel price to use for insurance eligibility checks.
|
||||
*
|
||||
* Family insurances are always evaluated against the total booking price (all
|
||||
* participants combined); everything else uses the individual participant's price.
|
||||
* Non-applicant participants can never hold a family insurance (InsuranceManager
|
||||
* restricts family insurances to the applicant), so this does not need to know
|
||||
* whether $participantIndex is the applicant.
|
||||
*/
|
||||
public function resolveInsuranceTravelPrice(BookingDto $bookingDto, int $participantIndex, Insurance $insurance): float
|
||||
{
|
||||
if (true === $insurance->familyInsurance) {
|
||||
return $this->calculateTotalBookingPriceExcludingInsurance($bookingDto);
|
||||
}
|
||||
|
||||
return $this->calculateIndividualParticipantPriceExcludingInsurance($bookingDto, $participantIndex);
|
||||
}
|
||||
}
|
||||
@@ -107,6 +107,42 @@ class InsuranceManager
|
||||
})();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns eligible insurances for a participant, pricing family and non-family
|
||||
* insurances on the correct basis.
|
||||
*
|
||||
* Family insurances must be priced by the total booking price, not the individual
|
||||
* participant's price - this splits the given insurances by type and evaluates
|
||||
* each group against the appropriate price before merging the results back together.
|
||||
*
|
||||
* @param array<Insurance> $insurances Available insurances to filter
|
||||
* @param ParticipantDto $participant The participant to match insurances for
|
||||
* @param BookingDto $booking The booking context for additional criteria
|
||||
* @param float $individualPrice The participant's individual travel price (excluding insurance)
|
||||
* @param float $totalBookingPrice The total booking price across all participants (excluding insurance)
|
||||
*
|
||||
* @return array<Insurance> Filtered array of eligible insurances, sorted by price
|
||||
*/
|
||||
public function getEligibleInsurancesForParticipant(
|
||||
array $insurances,
|
||||
ParticipantDto $participant,
|
||||
BookingDto $booking,
|
||||
float $individualPrice,
|
||||
float $totalBookingPrice,
|
||||
): array {
|
||||
$nonFamilyInsurances = array_values(array_filter($insurances, static fn (Insurance $i) => false === $i->familyInsurance));
|
||||
$familyInsurances = array_values(array_filter($insurances, static fn (Insurance $i) => true === $i->familyInsurance));
|
||||
|
||||
$eligibleInsurances = $this->getEligibleInsurances($nonFamilyInsurances, $participant, $booking, $individualPrice);
|
||||
|
||||
if (!empty($familyInsurances)) {
|
||||
$eligibleFamilyInsurances = $this->getEligibleInsurances($familyInsurances, $participant, $booking, $totalBookingPrice);
|
||||
$eligibleInsurances = $this->sortByPrice(array_merge($eligibleInsurances, $eligibleFamilyInsurances));
|
||||
}
|
||||
|
||||
return $eligibleInsurances;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-reassigns an insurance to the same type with appropriate price tier.
|
||||
*
|
||||
@@ -159,12 +195,28 @@ class InsuranceManager
|
||||
BookingDto $booking,
|
||||
array $participantPrices,
|
||||
): array {
|
||||
$assignments = [];
|
||||
|
||||
// Group insurances of the same type
|
||||
$sameTypeInsurances = $this->filterByType($availableInsurances, $selectedInsurance);
|
||||
|
||||
// Assign appropriate insurance to each participant
|
||||
// Family insurance: assign to applicant only, priced by total booking price
|
||||
if (true === $selectedInsurance->familyInsurance) {
|
||||
$totalPrice = array_sum($participantPrices);
|
||||
$applicant = $booking->getParticipant(0);
|
||||
$eligibleInsurances = null !== $applicant
|
||||
? $this->getEligibleInsurances($sameTypeInsurances, $applicant, $booking, $totalPrice)
|
||||
: [];
|
||||
$tieredInsurance = !empty($eligibleInsurances) ? array_values($eligibleInsurances)[0] : null;
|
||||
|
||||
$assignments = [];
|
||||
foreach ($booking->getParticipants() as $index => $participant) {
|
||||
$assignments[$index] = 0 === $index ? $tieredInsurance : null;
|
||||
}
|
||||
|
||||
return $assignments;
|
||||
}
|
||||
|
||||
// Non-family insurance: assign to each participant with their individual price tier
|
||||
$assignments = [];
|
||||
foreach ($booking->getParticipants() as $index => $participant) {
|
||||
$travelPrice = $participantPrices[$index] ?? 0.0;
|
||||
$eligibleInsurances = $this->getEligibleInsurances($sameTypeInsurances, $participant, $booking, $travelPrice);
|
||||
@@ -242,7 +294,7 @@ class InsuranceManager
|
||||
int $travelDurationDays,
|
||||
): bool {
|
||||
// Family insurance constraints
|
||||
if (false === $this->checkFamilyInsuranceConstraints($insurance, $booking)) {
|
||||
if (false === $this->checkFamilyInsuranceConstraints($insurance, $participant, $booking)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -274,23 +326,15 @@ class InsuranceManager
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkFamilyInsuranceConstraints(Insurance $insurance, BookingDto $booking): bool
|
||||
private function checkFamilyInsuranceConstraints(Insurance $insurance, ParticipantDto $participant, BookingDto $booking): bool
|
||||
{
|
||||
// Family booking detection only available in create mode
|
||||
if (BookingDto::MODE_EDIT === $booking->getMode()) {
|
||||
return true; // Skip family constraints for edit mode
|
||||
}
|
||||
|
||||
$isFamilyBooking = $booking->isFamilyBooking();
|
||||
|
||||
// If it's a family insurance, it should only be available for family bookings
|
||||
if (true === $insurance->familyInsurance && false === $isFamilyBooking) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it's not a family insurance, it should only be available for non-family bookings
|
||||
if (false === $insurance->familyInsurance && true === $isFamilyBooking) {
|
||||
return false;
|
||||
if (true === $insurance->familyInsurance) {
|
||||
if (false === $booking->isFamilyBooking()) {
|
||||
return false; // Family insurance only available for family bookings
|
||||
}
|
||||
if (0 !== $participant->index) {
|
||||
return false; // Family insurance only assignable to the applicant
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -10,6 +10,7 @@ use App\BpnConnect\Model\ContingentStatus;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Model\CalendarDay;
|
||||
use App\Model\CalendarMonth;
|
||||
use App\Service\AccommodationPriceCoverage;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Psr\Cache\InvalidArgumentException;
|
||||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
|
||||
@@ -45,6 +46,7 @@ class Calendar
|
||||
public function __construct(
|
||||
private readonly ContingentsClient $contingentsClient,
|
||||
private readonly CacheInterface $cache,
|
||||
private readonly AccommodationPriceCoverage $priceCoverage,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -119,6 +121,18 @@ class Calendar
|
||||
}
|
||||
}
|
||||
|
||||
// A day without a price is not sold, no matter what the contingent says.
|
||||
$rangeStart = new \DateTimeImmutable($dateFrom);
|
||||
$rangeEnd = new \DateTimeImmutable($dateTo);
|
||||
$covered = $this->priceCoverage->coveredDates($hotelCode, $rangeStart, $rangeEnd);
|
||||
|
||||
for ($day = $rangeStart->setTime(0, 0); $day <= $rangeEnd->setTime(0, 0); $day = $day->modify('+1 day')) {
|
||||
$key = $day->format('Y-m-d');
|
||||
if (!isset($covered[$key])) {
|
||||
$blocked[$key] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $blocked;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,3 +28,13 @@
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endif %}
|
||||
{% if app.session.flashBag.peek('warning')|length > 0 %}
|
||||
{% embed '_partials/_modal.html.twig' with { 'level': 'warning', 'modal': true } %}
|
||||
{% block title %}
|
||||
Hinweis
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{% include '_partials/_alert.html.twig' with { level: 'warning', messages: app.flashes('warning') } %}
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endif %}
|
||||
@@ -1,6 +1,10 @@
|
||||
<div class="flex items-center justify-between">
|
||||
<a href="{{ path('app_account') }}" title="zu meinem Account">
|
||||
{% if booking_theme() == 'sbw' %}
|
||||
{# The operating entity depends on where the accommodation is, so its logo wins over the host's #}
|
||||
{% set country_logo = accommodation|default(null) and accommodation.country ? accommodation.country.logo : null %}
|
||||
{% if country_logo %}
|
||||
<img src="{{ asset('build/images/' ~ country_logo) }}" alt="" class="h-14 my-1 w-auto">
|
||||
{% elseif booking_theme() == 'sbw' %}
|
||||
<img src="{{ asset('build/images/logo_sbw.svg') }}" alt="" class="h-10 my-2 w-auto">
|
||||
{% elseif booking_theme() == 'ser' %}
|
||||
<img src="{{ asset('build/images/logo_ser.svg') }}" alt="" class="h-10 my-2 w-auto">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<div class="fixed inset-0 w-full h-full z-50" {{ stimulus_controller('modal') }} {{ stimulus_action('modal', 'close', 'modal-close@window') }}>
|
||||
<div class="absolute inset-0 backdrop-blur-sm" {{ stimulus_action('modal', 'close', 'click') }}></div>
|
||||
<div class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 px-4 w-full max-w-3xl">
|
||||
<div class="{{ html_classes('relative py-4 rounded-md', { 'bg-red-500': level == 'error', 'bg-green-500': level == 'success', 'bg-primary-light': level == 'info' }) }}">
|
||||
<div class="{{ html_classes('relative py-4 rounded-md', { 'bg-red-500': level == 'error', 'bg-green-500': level == 'success', 'bg-yellow-500': level == 'warning', 'bg-primary-light': level == 'info' }) }}">
|
||||
<div class="flex justify-between pb-4 px-4">
|
||||
<div class="text-2xl font-medium text-white">
|
||||
<div class="{{ html_classes('text-2xl font-medium', { 'text-gray-800': level == 'warning', 'text-white': level != 'warning' }) }}">
|
||||
{% block title %}{% endblock %}
|
||||
</div>
|
||||
<button type="button"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
{{ form_row(form.cmsCode) }}
|
||||
{{ form_row(form.maxAdolescentAge) }}
|
||||
{{ form_row(form.currency) }}
|
||||
{{ form_row(form.country) }}
|
||||
</div>
|
||||
{% if cmsData is not null and cmsData.name is not null %}
|
||||
<div class="space-y-4">
|
||||
@@ -233,15 +234,21 @@
|
||||
|
||||
<hr class="my-8">
|
||||
|
||||
<section id="additional-services">
|
||||
<section id="additional-services" {{ stimulus_controller('sortable', {
|
||||
url: path('app_admin_accommodation_additionalservices_order', { id: accommodation.id })
|
||||
}) }}>
|
||||
<h2 class="text-xl font-bold">
|
||||
Optionale Zusatzleistungen
|
||||
</h2>
|
||||
<p class="text-sm text-gray-500 mb-2">
|
||||
Die Reihenfolge wird per Drag & Drop festgelegt und gilt auch für das Buchungsformular.
|
||||
</p>
|
||||
<div class="data-table-wrapper mb-4">
|
||||
<div class="data-table-wrapper__inner text-sm">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-8"></th>
|
||||
<th>
|
||||
Datums-Bereich
|
||||
</th>
|
||||
@@ -257,9 +264,12 @@
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody {{ stimulus_target('sortable', 'list') }}>
|
||||
{% for service in additionalServices %}
|
||||
<tr>
|
||||
<tr {{ stimulus_target('sortable', 'item') }} data-sortable-id="{{ service.id }}">
|
||||
<td class="cursor-grab text-gray-400" {{ stimulus_target('sortable', 'handle') }}>
|
||||
{{ icon('draggable', 'w-4 h-4') }}
|
||||
</td>
|
||||
<td>
|
||||
{{ service.dateFrom | date('d.m.Y') }} - {{ service.dateTo | date('d.m.Y') }}
|
||||
</td>
|
||||
@@ -288,7 +298,7 @@
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
<td colspan="6" class="text-center">
|
||||
Keine Daten
|
||||
</td>
|
||||
</tr>
|
||||
@@ -297,7 +307,8 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-sm text-gray-500" {{ stimulus_target('sortable', 'status') }}></span>
|
||||
<a href="{{ path('app_admin_additionalservice_create', { 'id': accommodation.id }) }}" class="button button--primary button--small">
|
||||
neu
|
||||
</a>
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
{{ form_start(form) }}
|
||||
<div class="grid lg:grid-cols-2 gap-y-4 lg:gap-x-8">
|
||||
{{ form_row(form.name) }}
|
||||
{{ form_row(form.calendarCode) }}
|
||||
{{ form_row(form.maxAdolescentAge) }}
|
||||
{{ form_row(form.currency) }}
|
||||
{{ form_row(form.country) }}
|
||||
{{ form_row(form.calendarCode) }}
|
||||
{{ form_row(form.cmsCode) }}
|
||||
{{ form_row(form.maxAdolescentAge) }}
|
||||
</div>
|
||||
<div class="flex justify-end pt-8">
|
||||
<button type="submit" class="button button--primary button--small">
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
{% extends 'layout_admin.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<twig:page:heading>Neue Buchung</twig:page:heading>
|
||||
|
||||
{% form_theme form 'forms_admin.html.twig' %}
|
||||
|
||||
{{ form_start(form) }}
|
||||
<div class="grid lg:grid-cols-2 gap-y-4 lg:gap-x-8">
|
||||
<div class="lg:col-span-2">
|
||||
{{ form_row(form.accommodation) }}
|
||||
</div>
|
||||
|
||||
<h2 class="lg:col-span-2 text-base font-bold pt-2">Kontaktdaten</h2>
|
||||
{{ form_row(form.groupName) }}
|
||||
{{ form_row(form.salutation) }}
|
||||
{{ form_row(form.firstName) }}
|
||||
{{ form_row(form.lastName) }}
|
||||
{{ form_row(form.email) }}
|
||||
{{ form_row(form.phone) }}
|
||||
{{ form_row(form.street) }}
|
||||
{{ form_row(form.zip) }}
|
||||
{{ form_row(form.city) }}
|
||||
|
||||
<h2 class="lg:col-span-2 text-base font-bold pt-2">Reisedaten</h2>
|
||||
{{ form_row(form.dateFrom) }}
|
||||
{{ form_row(form.dateTo) }}
|
||||
{{ form_row(form.paxCount) }}
|
||||
{{ form_row(form.minorsCount) }}
|
||||
{{ form_row(form.childrenCount) }}
|
||||
|
||||
<h2 class="lg:col-span-2 text-base font-bold pt-2">Status & Rabatt</h2>
|
||||
<div class="lg:col-span-2">
|
||||
{{ form_row(form.isInquiry) }}
|
||||
</div>
|
||||
{{ form_row(form.accommodationDiscount) }}
|
||||
{{ form_row(form.boardServiceDiscount) }}
|
||||
{{ form_row(form.additionalServicesDiscount) }}
|
||||
<div class="lg:col-span-2">
|
||||
{{ form_row(form.remarks) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-between pt-8">
|
||||
<a href="{{ path('app_admin_accommodationbooking') }}" class="button button--secondary button--small">
|
||||
zurück
|
||||
</a>
|
||||
<button type="submit" class="button button--primary button--small">
|
||||
speichern
|
||||
</button>
|
||||
</div>
|
||||
{{ form_rest(form) }}
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
@@ -40,13 +40,18 @@
|
||||
|
||||
<h2 class="lg:col-span-2 text-base font-bold pt-2">Status & Rabatt</h2>
|
||||
<div class="lg:col-span-2">
|
||||
{{ form_row(form.isInquiry) }}
|
||||
{{ form_row(form.status) }}
|
||||
</div>
|
||||
{% if booking.acceptedAt is not null %}
|
||||
<p class="lg:col-span-2 text-xs text-gray-500">
|
||||
Angenommen am {{ booking.acceptedAt | date('d.m.Y, H:i') }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if form.managedBy is defined %}
|
||||
<div class="lg:col-span-2">
|
||||
{{ form_row(form.managedBy) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{{ form_row(form.accommodationDiscount) }}
|
||||
{{ form_row(form.boardServiceDiscount) }}
|
||||
{{ form_row(form.additionalServicesDiscount) }}
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
<th>
|
||||
Personen
|
||||
</th>
|
||||
<th>
|
||||
Betreuer:in
|
||||
</th>
|
||||
<th>
|
||||
Status
|
||||
</th>
|
||||
@@ -50,12 +53,15 @@
|
||||
{{ booking.paxCount }}
|
||||
</td>
|
||||
<td>
|
||||
{% if booking.isInquiry %}
|
||||
Anfrage
|
||||
{% if booking.managedBy is not null %}
|
||||
{{ booking.managedBy.email }}
|
||||
{% else %}
|
||||
Buchung
|
||||
keine Zuordnung
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{{ booking.status.label }}
|
||||
</td>
|
||||
<td>
|
||||
{% set discounts = [] %}
|
||||
{% if booking.accommodationDiscount is not null %}
|
||||
@@ -93,8 +99,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<a href="{{ path('app_admin_accommodationbooking_create') }}" class="button button--primary button--small">
|
||||
<button type="button"
|
||||
hx-get="{{ path('app_admin_accommodationbooking_create') }}"
|
||||
hx-target="body"
|
||||
hx-swap="beforeend"
|
||||
class="button button--primary button--small">
|
||||
neu
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,29 @@
|
||||
{% extends 'htmx_modal_admin.html.twig' %}
|
||||
{% form_theme form 'forms_admin.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="text-xl font-bold pb-4">
|
||||
Neue Buchung
|
||||
</div>
|
||||
{{ form_start(form) }}
|
||||
<div class="grid lg:grid-cols-2 gap-y-4 lg:gap-x-8">
|
||||
<div class="lg:col-span-2">
|
||||
{{ form_row(form.accommodation) }}
|
||||
</div>
|
||||
{{ form_row(form.dateFrom) }}
|
||||
{{ form_row(form.dateTo) }}
|
||||
{{ form_row(form.paxCount) }}
|
||||
{{ form_row(form.minorsCount) }}
|
||||
{{ form_row(form.childrenCount) }}
|
||||
<div class="lg:col-span-2">
|
||||
{{ form_row(form.status) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end pt-8">
|
||||
<button type="submit" class="button button--primary button--small">
|
||||
speichern
|
||||
</button>
|
||||
</div>
|
||||
{{ form_rest(form) }}
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
<twig:page:heading>
|
||||
{% if booking.isInquiry %}Anfrage{% else %}Buchung{% endif %}
|
||||
{{ booking.status.label }}
|
||||
{{ booking.groupName }}
|
||||
</twig:page:heading>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<dd>{{ booking.childrenCount }}</dd>
|
||||
{% endif %}
|
||||
<dt class="font-medium">Status</dt>
|
||||
<dd>{% if booking.isInquiry %}Anfrage{% else %}Buchung{% endif %}</dd>
|
||||
<dd>{{ booking.status.label }}</dd>
|
||||
{% if booking.acceptedAt is not null %}
|
||||
<dt class="font-medium">Angenommen am</dt>
|
||||
<dd>{{ booking.acceptedAt | date('d.m.Y, H:i') }}</dd>
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
</div>
|
||||
{{ form_row(form.price) }}
|
||||
{{ form_row(form.selectionGroup) }}
|
||||
{{ form_row(form.exclusionGroup) }}
|
||||
<div class="lg:col-span-2">
|
||||
{{ form_row(form.isExclusive) }}
|
||||
</div>
|
||||
{{ form_row(form.dateFrom) }}
|
||||
{{ form_row(form.dateTo) }}
|
||||
</div>
|
||||
|
||||
@@ -493,9 +493,15 @@
|
||||
|
||||
{# Insurance field OR assigned insurance display for dependent participants (create mode) #}
|
||||
{% else %}
|
||||
{% set showBulkInsurance = participantIndex > 0 and bookingDto.participants[0].bulkInsuranceBooking %}
|
||||
{# Dependents get the applicant's read-only insurance display instead of their own choice
|
||||
when bulk insurance booking is active, or when the applicant selected a family
|
||||
insurance (which always covers the whole family, regardless of the bulk checkbox) #}
|
||||
{% set showApplicantInsurance = participantIndex > 0 and (
|
||||
bookingDto.participants[0].bulkInsuranceBooking
|
||||
or (bookingDto.participants[0].insurance and bookingDto.participants[0].insurance.familyInsurance)
|
||||
) %}
|
||||
|
||||
{% if showBulkInsurance %}
|
||||
{% if showApplicantInsurance %}
|
||||
{% set applicantInsurance = bookingDto.participants[0].insurance %}
|
||||
<div class="pb-4">
|
||||
<fieldset class="border border-primary-bg">
|
||||
|
||||
@@ -33,174 +33,22 @@
|
||||
{# Main form #}
|
||||
{% block accommodation_form %}
|
||||
<div id="accommodation-form"
|
||||
class="flex-1 order-2 lg:order-1 lg:col-span-3 bg-white flex flex-col min-h-0"
|
||||
{% if htmx_oob_swap is defined and htmx_oob_swap %}hx-swap-oob="true"{% endif %}>
|
||||
|
||||
{% include '_partials/_flashes.html.twig' %}
|
||||
class="flex-1 order-2 lg:order-1 lg:col-span-3 bg-white flex flex-col min-h-0">
|
||||
|
||||
{# Pagination - desktop only (fixed above scrollable content) #}
|
||||
<div class="hidden lg:block shrink-0">
|
||||
{% include 'groups/booking/_pagination.html.twig' with { 'current_step': 2 } %}
|
||||
</div>
|
||||
|
||||
<div id="participant-form"
|
||||
{# The scroll container itself must survive the htmx refresh — only its contents
|
||||
are swapped, so assets/loading.js can restore the scroll position. #}
|
||||
<div id="booking-form"
|
||||
class="flex-1 overflow-y-auto px-4 lg:px-8 py-8"
|
||||
hx-post="{{ path('app_groups_booking_step_2_refresh') }}"
|
||||
hx-trigger="change delay:300ms"
|
||||
hx-swap="none">
|
||||
|
||||
{# Validation errors #}
|
||||
{% from '_partials/_validation_errors.html.twig' import validation_alert %}
|
||||
{{ validation_alert(form) }}
|
||||
|
||||
{% if dto.isInquiry %}
|
||||
{% include '_partials/_alert.html.twig' with {
|
||||
level: 'warning',
|
||||
title: 'Diese Buchung wird als unverbindliche Anfrage behandelt',
|
||||
messages: dto.inquiryReasons
|
||||
} %}
|
||||
{% endif %}
|
||||
|
||||
{# Pax counts #}
|
||||
<h2 class="pb-4">
|
||||
Personenanzahl und gewünschte Leistungen
|
||||
</h2>
|
||||
|
||||
<div class="grid lg:grid-cols-3 lg:gap-x-8">
|
||||
{{ form_row(form.paxCount) }}
|
||||
{{ form_row(form.minorsCount) }}
|
||||
{{ form_row(form.childrenCount) }}
|
||||
</div>
|
||||
|
||||
{# Board services — rendered manually so price is formatted in Twig #}
|
||||
{% do form.selectedBoardServiceId.setRendered %}
|
||||
{% if ctx.boardServices is not empty %}
|
||||
<div class="pb-4">
|
||||
<fieldset class="border border-primary-bg">
|
||||
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">
|
||||
Verpflegungsleistungen
|
||||
</legend>
|
||||
<table class="w-full table-fixed border-collapse">
|
||||
{% for service in ctx.boardServices %}
|
||||
<tr>
|
||||
<td class="border border-primary-bg p-2 align-top">
|
||||
<label for="board_service_{{ service.id }}" class="cursor-pointer">{{ service.label }}</label>
|
||||
{% if service.description %}
|
||||
<div {{ stimulus_controller('tooltip') }}>
|
||||
<button type="button" data-tooltip-target="trigger" class="text-sm text-primary-light">Details</button>
|
||||
<template data-tooltip-target="template">
|
||||
<div class="text-sm">{{ service.description|nl2br }}</div>
|
||||
</template>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
||||
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
|
||||
{% if service.price != 0 %}
|
||||
<div class="text-xs text-gray-500">pro Person und Nacht</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
||||
<input type="radio"
|
||||
id="board_service_{{ service.id }}"
|
||||
name="{{ form.selectedBoardServiceId.vars.full_name }}"
|
||||
value="{{ service.id }}"
|
||||
{% if dto.selectedBoardServiceId == service.id %}checked{% endif %}
|
||||
class="form-radio">
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# Additional services — rendered manually to support checkbox/radio mix #}
|
||||
{% do form.selectedAdditionalServiceIds.setRendered %}
|
||||
{% set selectedAdditionalServiceBaseName = form.selectedAdditionalServiceIds.vars.full_name|replace({'[]': ''}) %}
|
||||
|
||||
{% if ctx.ungroupedAdditionalServices is not empty or ctx.groupedAdditionalServices is not empty %}
|
||||
|
||||
{# Ungrouped → checkboxes #}
|
||||
{% if ctx.ungroupedAdditionalServices is not empty %}
|
||||
<div class="pb-4">
|
||||
<fieldset class="border border-primary-bg">
|
||||
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">
|
||||
Optionale Zusatzleistungen
|
||||
</legend>
|
||||
<table class="w-full table-fixed border-collapse">
|
||||
{% for service in ctx.ungroupedAdditionalServices %}
|
||||
<tr>
|
||||
<td class="border border-primary-bg p-2 align-top">
|
||||
<label for="add_service_{{ service.id }}" class="cursor-pointer">{{ service.label }}</label>
|
||||
{% if service.description %}
|
||||
<div {{ stimulus_controller('tooltip') }}>
|
||||
<button type="button" data-tooltip-target="trigger" class="text-sm text-primary-light">Details</button>
|
||||
<template data-tooltip-target="template">
|
||||
<div class="text-sm">{{ service.description|nl2br }}</div>
|
||||
</template>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
||||
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
|
||||
<div class="text-xs text-gray-500">{{ service.type.label | trans }}</div>
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
||||
<input type="checkbox"
|
||||
id="add_service_{{ service.id }}"
|
||||
name="{{ form.selectedAdditionalServiceIds.vars.full_name }}"
|
||||
value="{{ service.id }}"
|
||||
{% if service.id in dto.selectedAdditionalServiceIds %}checked{% endif %}
|
||||
class="form-checkbox">
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# Grouped → radio buttons per group, one fieldset per group #}
|
||||
{% for groupName, services in ctx.groupedAdditionalServices %}
|
||||
<div class="pb-4">
|
||||
<fieldset class="border border-primary-bg">
|
||||
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">{{ groupName }}</legend>
|
||||
<table class="w-full table-fixed border-collapse">
|
||||
{% for service in services %}
|
||||
<tr>
|
||||
<td class="border border-primary-bg p-2 align-top">
|
||||
<label for="add_service_{{ service.id }}" class="cursor-pointer">{{ service.label }}</label>
|
||||
{% if service.description %}
|
||||
<div {{ stimulus_controller('tooltip') }}>
|
||||
<button type="button" data-tooltip-target="trigger" class="text-sm text-primary-light">Details</button>
|
||||
<template data-tooltip-target="template">
|
||||
<div class="text-sm">{{ service.description|nl2br }}</div>
|
||||
</template>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
||||
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
|
||||
<div class="text-xs text-gray-500">{{ service.type.label | trans }}</div>
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
||||
<input type="radio"
|
||||
id="add_service_{{ service.id }}"
|
||||
name="{{ selectedAdditionalServiceBaseName }}[{{ groupName|e('html_attr') }}]"
|
||||
value="{{ service.id }}"
|
||||
{% if service.id in dto.selectedAdditionalServiceIds %}checked{% endif %}
|
||||
class="form-radio">
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
hx-target="#booking-form"
|
||||
hx-swap="innerHTML">
|
||||
{{ block('booking_form') }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -221,3 +69,179 @@
|
||||
{{ form_rest(form) }}
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
|
||||
{# Swapped into #booking-form on every htmx refresh #}
|
||||
{% block booking_form %}
|
||||
|
||||
{# Flash messages - must be inside the swapped region to be displayed #}
|
||||
{% include '_partials/_flashes.html.twig' %}
|
||||
|
||||
{# Validation errors #}
|
||||
{% from '_partials/_validation_errors.html.twig' import validation_alert %}
|
||||
{{ validation_alert(form) }}
|
||||
|
||||
{% if dto.isInquiry %}
|
||||
{% include '_partials/_alert.html.twig' with {
|
||||
level: 'warning',
|
||||
title: 'Diese Buchung wird als unverbindliche Anfrage behandelt',
|
||||
messages: dto.inquiryReasons
|
||||
} %}
|
||||
{% endif %}
|
||||
|
||||
{# Pax counts #}
|
||||
<h2 class="pb-4">
|
||||
Personenanzahl und gewünschte Leistungen
|
||||
</h2>
|
||||
|
||||
<div class="grid lg:grid-cols-3 lg:gap-x-8">
|
||||
{{ form_row(form.paxCount) }}
|
||||
{{ form_row(form.minorsCount) }}
|
||||
{{ form_row(form.childrenCount) }}
|
||||
</div>
|
||||
|
||||
{# Board services — rendered manually so price is formatted in Twig #}
|
||||
{% do form.selectedBoardServiceId.setRendered %}
|
||||
{% if ctx.boardServices is not empty %}
|
||||
<div class="pb-4">
|
||||
<fieldset class="border border-primary-bg">
|
||||
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">
|
||||
Verpflegungsleistungen
|
||||
</legend>
|
||||
<table class="w-full table-fixed border-collapse">
|
||||
{% for service in ctx.boardServices %}
|
||||
<tr>
|
||||
<td class="border border-primary-bg p-2 align-top">
|
||||
<label for="board_service_{{ service.id }}" class="cursor-pointer">{{ service.label }}</label>
|
||||
{% if service.description %}
|
||||
<div {{ stimulus_controller('tooltip') }}>
|
||||
<button type="button" data-tooltip-target="trigger" class="text-sm text-primary-light">Details</button>
|
||||
<template data-tooltip-target="template">
|
||||
<div class="text-sm">{{ service.description|nl2br }}</div>
|
||||
</template>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
||||
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
|
||||
{% if service.price != 0 %}
|
||||
<div class="text-xs text-gray-500">pro Person und Nacht</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
||||
<input type="radio"
|
||||
id="board_service_{{ service.id }}"
|
||||
name="{{ form.selectedBoardServiceId.vars.full_name }}"
|
||||
value="{{ service.id }}"
|
||||
{% if dto.selectedBoardServiceId == service.id %}checked{% endif %}
|
||||
class="form-radio">
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# Additional services — rendered manually to support checkbox/radio mix #}
|
||||
{% do form.selectedAdditionalServiceIds.setRendered %}
|
||||
{% set selectedAdditionalServiceBaseName = form.selectedAdditionalServiceIds.vars.full_name|replace({'[]': ''}) %}
|
||||
|
||||
{% if ctx.ungroupedAdditionalServices is not empty or ctx.groupedAdditionalServices is not empty %}
|
||||
|
||||
{# Wraps every fieldset so mutually exclusive services can be unchecked across fieldsets.
|
||||
Purely for instant feedback — the server resolves the same conflicts on submit. #}
|
||||
<div {{ stimulus_controller('service-exclusion') }} {{ stimulus_action('service-exclusion', 'select', 'change') }}>
|
||||
|
||||
{# Ungrouped → checkboxes #}
|
||||
{% if ctx.ungroupedAdditionalServices is not empty %}
|
||||
<div class="pb-4">
|
||||
<fieldset class="border border-primary-bg">
|
||||
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">
|
||||
Optionale Zusatzleistungen
|
||||
</legend>
|
||||
<table class="w-full table-fixed border-collapse">
|
||||
{% for service in ctx.ungroupedAdditionalServices %}
|
||||
<tr>
|
||||
<td class="border border-primary-bg p-2 align-top">
|
||||
<label for="add_service_{{ service.id }}" class="cursor-pointer">{{ service.label }}</label>
|
||||
{% if service.description %}
|
||||
<div {{ stimulus_controller('tooltip') }}>
|
||||
<button type="button" data-tooltip-target="trigger" class="text-sm text-primary-light">Details</button>
|
||||
<template data-tooltip-target="template">
|
||||
<div class="text-sm">{{ service.description|nl2br }}</div>
|
||||
</template>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
||||
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
|
||||
<div class="text-xs text-gray-500">{{ service.type.label | trans }}</div>
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
||||
<input type="checkbox"
|
||||
id="add_service_{{ service.id }}"
|
||||
name="{{ form.selectedAdditionalServiceIds.vars.full_name }}"
|
||||
value="{{ service.id }}"
|
||||
{% if service.id in dto.selectedAdditionalServiceIds %}checked{% endif %}
|
||||
{% if service.exclusionGroup %}
|
||||
{{ stimulus_target('service-exclusion', 'input') }}
|
||||
data-exclusion-group="{{ service.exclusionGroup }}"
|
||||
data-exclusive="{{ service.isExclusive ? '1' : '0' }}"
|
||||
{% endif %}
|
||||
class="form-checkbox">
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{# Grouped → radio buttons per group, one fieldset per group #}
|
||||
{% for groupName, services in ctx.groupedAdditionalServices %}
|
||||
<div class="pb-4">
|
||||
<fieldset class="border border-primary-bg">
|
||||
<legend class="w-full bg-primary-bg p-2 font-semibold uppercase">{{ groupName }}</legend>
|
||||
<table class="w-full table-fixed border-collapse">
|
||||
{% for service in services %}
|
||||
<tr>
|
||||
<td class="border border-primary-bg p-2 align-top">
|
||||
<label for="add_service_{{ service.id }}" class="cursor-pointer">{{ service.label }}</label>
|
||||
{% if service.description %}
|
||||
<div {{ stimulus_controller('tooltip') }}>
|
||||
<button type="button" data-tooltip-target="trigger" class="text-sm text-primary-light">Details</button>
|
||||
<template data-tooltip-target="template">
|
||||
<div class="text-sm">{{ service.description|nl2br }}</div>
|
||||
</template>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-32 text-right">
|
||||
<div>{% if service.price == 0 %}inkl.{% else %}{{ (service.price / 100)|format_currency(ctx.accommodation.currency) }}{% endif %}</div>
|
||||
<div class="text-xs text-gray-500">{{ service.type.label | trans }}</div>
|
||||
</td>
|
||||
<td class="border border-primary-bg p-2 align-top w-12 text-center">
|
||||
<input type="radio"
|
||||
id="add_service_{{ service.id }}"
|
||||
name="{{ selectedAdditionalServiceBaseName }}[{{ groupName|e('html_attr') }}]"
|
||||
value="{{ service.id }}"
|
||||
{% if service.id in dto.selectedAdditionalServiceIds %}checked{% endif %}
|
||||
{% if service.exclusionGroup %}
|
||||
data-service-exclusion-target="input"
|
||||
data-exclusion-group="{{ service.exclusionGroup }}"
|
||||
data-exclusive="{{ service.isExclusive ? '1' : '0' }}"
|
||||
{% endif %}
|
||||
class="form-radio">
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -36,7 +36,7 @@
|
||||
{% include 'groups/booking/_pagination.html.twig' with { 'current_step': 3 } %}
|
||||
</div>
|
||||
|
||||
<div id="participant-form" class="flex-1 overflow-y-auto px-4 lg:px-8 py-8">
|
||||
<div id="booking-form" class="flex-1 overflow-y-auto px-4 lg:px-8 py-8">
|
||||
<h2 class="pb-4">
|
||||
Persönliche Daten
|
||||
</h2>
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
<div class="max-w-screen-xl h-dvh ml-auto flex flex-col overflow-hidden bg-inner">
|
||||
<div class="shrink-0 z-20 py-2 px-4 bg-white shadow-md">
|
||||
{% block header %}
|
||||
{% include '_partials/_header.html.twig' %}
|
||||
{% include '_partials/_header.html.twig' with {
|
||||
accommodation: ctx is defined ? ctx.accommodation : null
|
||||
} %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div class="flex-1 flex flex-col min-h-0 overflow-y-auto md:overflow-hidden relative z-10">
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
<div class="max-w-screen-xl h-dvh ml-auto flex flex-col overflow-hidden bg-inner">
|
||||
<div class="shrink-0 z-20 py-2 px-4 bg-white shadow-md">
|
||||
{% block header %}
|
||||
{% include '_partials/_header.html.twig' %}
|
||||
{% include '_partials/_header.html.twig' with {
|
||||
accommodation: ctx is defined ? ctx.accommodation : null
|
||||
} %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div class="flex-1 flex flex-col min-h-0 relative z-10">
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\BusProNet\Model\Address;
|
||||
use App\BusProNet\Model\BankAccount;
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Communication;
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\BusProNet\Model\Pickup;
|
||||
use App\BusProNet\Model\Room;
|
||||
@@ -822,4 +823,257 @@ class BookingDataProcessorTest extends TestCase
|
||||
|
||||
return $participant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: family insurance covers the whole family under a single policy on the
|
||||
* applicant, so dependents must never keep their own insurance selection - even when
|
||||
* the applicant never checked the "book for everyone" (bulkInsuranceBooking) box.
|
||||
*/
|
||||
public function testFamilyInsuranceClearsDependentInsuranceWithoutBulkCheckbox(): void
|
||||
{
|
||||
$familyInsurance = new Insurance();
|
||||
$familyInsurance->id = 'family-1';
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$applicant = $this->createMockParticipantDto(0, 'F');
|
||||
$applicant->bulkInsuranceBooking = false;
|
||||
$applicant->insurance = $familyInsurance;
|
||||
|
||||
$dependentInsurance = new Insurance();
|
||||
$dependentInsurance->id = 'dependent-own-1';
|
||||
$dependentInsurance->familyInsurance = false;
|
||||
|
||||
$dependent = $this->createMockParticipantDto(1, 'F');
|
||||
$dependent->insurance = $dependentInsurance;
|
||||
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
// Both insurances must already look eligible, otherwise the submit-time
|
||||
// reconciliation step (added for stale-insurance re-validation) would clear
|
||||
// them before propagation even runs - this test is only about propagation.
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([$familyInsurance, $dependentInsurance]);
|
||||
$insuranceService->method('getEligibleInsurances')->willReturnCallback(
|
||||
fn (array $insurances) => $insurances
|
||||
);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([
|
||||
0 => $familyInsurance,
|
||||
1 => null,
|
||||
]);
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(0.0);
|
||||
|
||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||
|
||||
$processor = new BookingDataProcessor(
|
||||
$insuranceService,
|
||||
$priceCalculatorService,
|
||||
new ServiceMappingCollector(),
|
||||
new ParticipantServiceProcessor(new NullLogger()),
|
||||
$payloadBuilder,
|
||||
new PersonalDataSynchronizer(),
|
||||
);
|
||||
|
||||
$processor->createBookingRequestPayload($bookingDto, 'ANFRAGE');
|
||||
|
||||
$this->assertSame($familyInsurance, $bookingDto->participants[0]->insurance);
|
||||
$this->assertNull($bookingDto->participants[1]->insurance, 'Dependent must lose their own insurance once the applicant selects family insurance');
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: the edit-mode guard that protects an individually-locked non-family
|
||||
* insurance from being overwritten must not also block clearing a dependent's
|
||||
* pre-existing insurance when the applicant switches to family insurance.
|
||||
*/
|
||||
public function testFamilyInsuranceClearsDependentInsuranceInEditMode(): void
|
||||
{
|
||||
$familyInsurance = new Insurance();
|
||||
$familyInsurance->id = 'family-1';
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$formData = $this->createCompleteFormData();
|
||||
|
||||
$applicant = $formData->participants[0];
|
||||
$applicant->bulkInsuranceBooking = false;
|
||||
$applicant->insurance = $familyInsurance;
|
||||
|
||||
$dependentInsurance = new Insurance();
|
||||
$dependentInsurance->id = 'dependent-own-1';
|
||||
$dependentInsurance->familyInsurance = false;
|
||||
|
||||
$dependent = $formData->participants[1];
|
||||
$dependent->insurance = $dependentInsurance;
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([]);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([
|
||||
0 => $familyInsurance,
|
||||
1 => null,
|
||||
]);
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
|
||||
$processor = new BookingDataProcessor(
|
||||
$insuranceService,
|
||||
$priceCalculatorService,
|
||||
new ServiceMappingCollector(),
|
||||
new ParticipantServiceProcessor(new NullLogger()),
|
||||
new BookingPayloadBuilder(new ServiceMappingCollector()),
|
||||
new PersonalDataSynchronizer(),
|
||||
);
|
||||
|
||||
$processor->createUpdateRequestPayload($formData);
|
||||
|
||||
$this->assertSame($familyInsurance, $formData->participants[0]->insurance);
|
||||
$this->assertNull($formData->participants[1]->insurance, 'Dependent must lose their pre-existing individual insurance in edit mode once the applicant selects family insurance');
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: an insurance selected earlier can go stale by submission time (e.g. its
|
||||
* price tier no longer matches the current total, because the user added services on an
|
||||
* earlier step after choosing insurance and jumped straight to submission without
|
||||
* revisiting the insurance field). createBookingRequestPayload() must re-validate and
|
||||
* reassign to the correct tier right before the payload is built, so a stale ID never
|
||||
* reaches the BPN API.
|
||||
*/
|
||||
public function testCreateBookingRequestPayloadReassignsStaleInsuranceToCurrentPriceTier(): void
|
||||
{
|
||||
$staleInsurance = new Insurance();
|
||||
$staleInsurance->id = 'tier-low';
|
||||
$staleInsurance->familyInsurance = false;
|
||||
|
||||
$correctTierInsurance = new Insurance();
|
||||
$correctTierInsurance->id = 'tier-high';
|
||||
$correctTierInsurance->familyInsurance = false;
|
||||
|
||||
$applicant = $this->createMockParticipantDto(0, 'F');
|
||||
$applicant->insurance = $staleInsurance;
|
||||
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->participants = [$applicant];
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([$staleInsurance, $correctTierInsurance]);
|
||||
// Only the higher tier is eligible at the current (updated) price.
|
||||
$insuranceService->method('getEligibleInsurances')->willReturn([$correctTierInsurance]);
|
||||
$insuranceService->method('reassignInsuranceForPriceChange')->willReturn($correctTierInsurance);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => $correctTierInsurance]);
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(2600.0);
|
||||
|
||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||
|
||||
$processor = new BookingDataProcessor(
|
||||
$insuranceService,
|
||||
$priceCalculatorService,
|
||||
new ServiceMappingCollector(),
|
||||
new ParticipantServiceProcessor(new NullLogger()),
|
||||
$payloadBuilder,
|
||||
new PersonalDataSynchronizer(),
|
||||
);
|
||||
|
||||
$processor->createBookingRequestPayload($bookingDto, 'ANFRAGE');
|
||||
|
||||
$this->assertSame($correctTierInsurance, $applicant->insurance);
|
||||
$this->assertCount(1, $applicant->notifications);
|
||||
$this->assertSame('warning', array_values($applicant->notifications)[0]['type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: when a stale insurance has no eligible replacement at all (e.g. the total
|
||||
* price now falls outside every tier of that type), it must be cleared rather than
|
||||
* silently left in place and submitted anyway.
|
||||
*/
|
||||
public function testCreateBookingRequestPayloadClearsStaleInsuranceWithoutEligibleReplacement(): void
|
||||
{
|
||||
$staleInsurance = new Insurance();
|
||||
$staleInsurance->id = 'tier-low';
|
||||
$staleInsurance->familyInsurance = false;
|
||||
|
||||
$applicant = $this->createMockParticipantDto(0, 'F');
|
||||
$applicant->insurance = $staleInsurance;
|
||||
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->participants = [$applicant];
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([$staleInsurance]);
|
||||
$insuranceService->method('getEligibleInsurances')->willReturn([]);
|
||||
$insuranceService->method('reassignInsuranceForPriceChange')->willReturn(null);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => null]);
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(9999.0);
|
||||
|
||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||
|
||||
$processor = new BookingDataProcessor(
|
||||
$insuranceService,
|
||||
$priceCalculatorService,
|
||||
new ServiceMappingCollector(),
|
||||
new ParticipantServiceProcessor(new NullLogger()),
|
||||
$payloadBuilder,
|
||||
new PersonalDataSynchronizer(),
|
||||
);
|
||||
|
||||
$processor->createBookingRequestPayload($bookingDto, 'ANFRAGE');
|
||||
|
||||
$this->assertNull($applicant->insurance);
|
||||
$this->assertCount(1, $applicant->notifications);
|
||||
$this->assertSame('warning', array_values($applicant->notifications)[0]['type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Regression: an insurance that's still eligible at submission time must be left
|
||||
* untouched - the reconciliation step must not fire (or notify) on the common,
|
||||
* unremarkable case where nothing has gone stale.
|
||||
*/
|
||||
public function testCreateBookingRequestPayloadLeavesStillEligibleInsuranceUntouched(): void
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->id = 'tier-1';
|
||||
$insurance->familyInsurance = false;
|
||||
|
||||
$applicant = $this->createMockParticipantDto(0, 'F');
|
||||
$applicant->insurance = $insurance;
|
||||
|
||||
$bookingDto = new BookingDto($this->createMockTravel(), 1);
|
||||
$bookingDto->participants = [$applicant];
|
||||
|
||||
$insuranceService = $this->createMock(InsuranceManager::class);
|
||||
$insuranceService->method('getSelectableInsurances')->willReturn([$insurance]);
|
||||
$insuranceService->method('getEligibleInsurances')->willReturn([$insurance]);
|
||||
$insuranceService->method('batchAssignInsuranceToParticipants')->willReturn([0 => $insurance]);
|
||||
|
||||
$priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')->willReturn(0.0);
|
||||
$priceCalculatorService->method('resolveInsuranceTravelPrice')->willReturn(500.0);
|
||||
|
||||
$payloadBuilder = $this->createMock(BookingPayloadBuilder::class);
|
||||
$payloadBuilder->method('buildCreatePayload')->willReturn([]);
|
||||
|
||||
$processor = new BookingDataProcessor(
|
||||
$insuranceService,
|
||||
$priceCalculatorService,
|
||||
new ServiceMappingCollector(),
|
||||
new ParticipantServiceProcessor(new NullLogger()),
|
||||
$payloadBuilder,
|
||||
new PersonalDataSynchronizer(),
|
||||
);
|
||||
|
||||
$processor->createBookingRequestPayload($bookingDto, 'ANFRAGE');
|
||||
|
||||
$this->assertSame($insurance, $applicant->insurance);
|
||||
$this->assertCount(0, $applicant->notifications);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use App\Entity\Groups\Accommodation;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationPriceCoverage;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use App\Service\CalendarGridBuilder;
|
||||
use App\Service\GroupsPriceCalculator;
|
||||
@@ -105,15 +106,18 @@ class Step1ControllerTest extends TestCase
|
||||
AccommodationBookingService $bookingService,
|
||||
AccommodationSessionManager $sessionManager,
|
||||
): TestableAccommodationStep1Controller {
|
||||
$priceRepository = $this->createMock(AccommodationPriceRepository::class);
|
||||
|
||||
return new TestableAccommodationStep1Controller(
|
||||
$bookingService,
|
||||
$sessionManager,
|
||||
$this->createMock(ContingentsClient::class),
|
||||
$this->createMock(AccommodationPriceRepository::class),
|
||||
$priceRepository,
|
||||
new PriceTimelineBuilder(),
|
||||
$this->createMock(CacheInterface::class),
|
||||
new CalendarGridBuilder(),
|
||||
new GroupsPriceCalculator(new PriceTimelineBuilder(), ['runningCostsEur' => 0, 'runningCostsChf' => 0, 'undersubscription30Eur' => 0, 'undersubscription30Chf' => 0, 'undersubscription40Eur' => 0, 'undersubscription40Chf' => 0]),
|
||||
new AccommodationPriceCoverage($priceRepository),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -129,6 +133,7 @@ final class TestableAccommodationStep1Controller extends Step1Controller
|
||||
CacheInterface $cache,
|
||||
CalendarGridBuilder $calendarGridBuilder,
|
||||
GroupsPriceCalculator $priceCalculator,
|
||||
AccommodationPriceCoverage $priceCoverage,
|
||||
) {
|
||||
parent::__construct(
|
||||
$bookingService,
|
||||
@@ -139,6 +144,7 @@ final class TestableAccommodationStep1Controller extends Step1Controller
|
||||
$cache,
|
||||
$calendarGridBuilder,
|
||||
$priceCalculator,
|
||||
$priceCoverage,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Admin\AccommodationBooking;
|
||||
|
||||
use App\Controller\Admin\AccommodationBooking\CreateController;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Entity\User;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
/**
|
||||
* Covers the Betreuer default only — the form itself is exercised through
|
||||
* AccommodationBookingCreateType.
|
||||
*/
|
||||
class CreateControllerTest extends TestCase
|
||||
{
|
||||
public function testTheCreatingUserBecomesTheBetreuer(): void
|
||||
{
|
||||
$user = new User('[email protected]');
|
||||
|
||||
$controller = $this->buildController($user);
|
||||
$controller->index(Request::create('/admin/accommodation-booking/create'));
|
||||
|
||||
self::assertSame($user, $controller->capturedBooking?->getManagedBy());
|
||||
}
|
||||
|
||||
private function buildController(?UserInterface $user): TestableCreateController
|
||||
{
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturn($form);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
return new TestableCreateController(
|
||||
$this->createMock(EntityManagerInterface::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createMock(AccommodationBookingService::class),
|
||||
$form,
|
||||
$user,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final class TestableCreateController extends CreateController
|
||||
{
|
||||
public ?AccommodationBooking $capturedBooking = null;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $entityManager,
|
||||
LoggerInterface $logger,
|
||||
AccommodationBookingService $bookingService,
|
||||
private readonly FormInterface $form,
|
||||
private readonly ?UserInterface $user,
|
||||
) {
|
||||
parent::__construct($entityManager, $logger, $bookingService);
|
||||
}
|
||||
|
||||
protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface
|
||||
{
|
||||
if ($data instanceof AccommodationBooking) {
|
||||
$this->capturedBooking = $data;
|
||||
}
|
||||
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
protected function getUser(): ?UserInterface
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function render(string $view, array $parameters = [], ?Response $response = null): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Admin\AccommodationBooking;
|
||||
|
||||
use App\Controller\Admin\AccommodationBooking\EditController;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Entity\User;
|
||||
use App\Repository\Groups\AdditionalServiceRepository;
|
||||
use App\Repository\Groups\BoardServiceRepository;
|
||||
use App\Repository\UserRepository;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Covers the status transition side effects only — the service and form behaviour
|
||||
* they build on is tested in AccommodationBookingServiceTest.
|
||||
*/
|
||||
class EditControllerTest extends TestCase
|
||||
{
|
||||
public function testTransitionToInquiryIssuesAccessLinkAndSendsCustomerEmail(): void
|
||||
{
|
||||
$bookingService = $this->assertNotified(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$this->submitStatusChange(AccommodationBookingStatus::Draft, AccommodationBookingStatus::Inquiry, $bookingService);
|
||||
}
|
||||
|
||||
public function testTransitionToBookingIssuesAccessLinkAndSendsCustomerEmail(): void
|
||||
{
|
||||
$bookingService = $this->assertNotified(AccommodationBookingStatus::Booking);
|
||||
|
||||
$this->submitStatusChange(AccommodationBookingStatus::Draft, AccommodationBookingStatus::Booking, $bookingService);
|
||||
}
|
||||
|
||||
public function testTransitionToDiscardedSendsNothing(): void
|
||||
{
|
||||
$bookingService = $this->assertNotNotified();
|
||||
|
||||
$this->submitStatusChange(AccommodationBookingStatus::Inquiry, AccommodationBookingStatus::Discarded, $bookingService);
|
||||
}
|
||||
|
||||
public function testSavingWithoutStatusChangeSendsNothing(): void
|
||||
{
|
||||
$bookingService = $this->assertNotNotified();
|
||||
|
||||
$this->submitStatusChange(AccommodationBookingStatus::Booking, AccommodationBookingStatus::Booking, $bookingService);
|
||||
}
|
||||
|
||||
private function assertNotified(AccommodationBookingStatus $expected): AccommodationBookingService
|
||||
{
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::once())->method('refreshPriceSnapshot');
|
||||
$bookingService
|
||||
->expects(self::once())
|
||||
->method('issueAccessLink')
|
||||
->with(self::callback(static fn (AccommodationBooking $booking) => $expected === $booking->getStatus()));
|
||||
$bookingService->expects(self::once())->method('sendCustomerConfirmationEmail');
|
||||
|
||||
return $bookingService;
|
||||
}
|
||||
|
||||
private function assertNotNotified(): AccommodationBookingService
|
||||
{
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->expects(self::once())->method('refreshPriceSnapshot');
|
||||
$bookingService->expects(self::never())->method('issueAccessLink');
|
||||
$bookingService->expects(self::never())->method('sendCustomerConfirmationEmail');
|
||||
|
||||
return $bookingService;
|
||||
}
|
||||
|
||||
private function submitStatusChange(
|
||||
AccommodationBookingStatus $from,
|
||||
AccommodationBookingStatus $to,
|
||||
AccommodationBookingService $bookingService,
|
||||
): void {
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus($from);
|
||||
|
||||
// The form is what moves the entity to its new status during handleRequest().
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturnCallback(static function () use ($booking, $to, $form) {
|
||||
$booking->setStatus($to);
|
||||
|
||||
return $form;
|
||||
});
|
||||
$form->method('isSubmitted')->willReturn(true);
|
||||
$form->method('isValid')->willReturn(true);
|
||||
$form->method('has')->willReturn(false);
|
||||
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::once())->method('flush');
|
||||
|
||||
$controller = new TestableEditController(
|
||||
$entityManager,
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createMock(BoardServiceRepository::class),
|
||||
$this->createMock(AdditionalServiceRepository::class),
|
||||
$this->createMock(UserRepository::class),
|
||||
$bookingService,
|
||||
$form,
|
||||
);
|
||||
|
||||
$response = $controller->index($booking, Request::create('/admin/accommodation-booking/1/edit', 'POST'));
|
||||
|
||||
self::assertSame(Response::HTTP_FOUND, $response->getStatusCode());
|
||||
}
|
||||
|
||||
public function testManagerWithoutAdminRoleGetsNoBetreuerChoices(): void
|
||||
{
|
||||
$userRepo = $this->createMock(UserRepository::class);
|
||||
$userRepo->expects(self::never())->method('findGroupsStaff');
|
||||
|
||||
$controller = $this->buildController($userRepo, granted: false);
|
||||
$controller->index(new AccommodationBooking(), Request::create('/admin/accommodation-booking/1/edit'));
|
||||
|
||||
self::assertSame([], $controller->capturedOptions['assignable_managers']);
|
||||
}
|
||||
|
||||
public function testAdminGetsTheGroupsStaffAsBetreuerChoices(): void
|
||||
{
|
||||
$staff = [new User('[email protected]')];
|
||||
$userRepo = $this->createMock(UserRepository::class);
|
||||
$userRepo->method('findGroupsStaff')->willReturn($staff);
|
||||
|
||||
$controller = $this->buildController($userRepo, granted: true);
|
||||
$controller->index(new AccommodationBooking(), Request::create('/admin/accommodation-booking/1/edit'));
|
||||
|
||||
self::assertSame($staff, $controller->capturedOptions['assignable_managers']);
|
||||
}
|
||||
|
||||
public function testAnAssignedUserWhoLostTheRoleStaysSelectable(): void
|
||||
{
|
||||
$formerManager = new User('[email protected]');
|
||||
$staff = [new User('[email protected]')];
|
||||
|
||||
$userRepo = $this->createMock(UserRepository::class);
|
||||
$userRepo->method('findGroupsStaff')->willReturn($staff);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setManagedBy($formerManager);
|
||||
|
||||
$controller = $this->buildController($userRepo, granted: true);
|
||||
$controller->index($booking, Request::create('/admin/accommodation-booking/1/edit'));
|
||||
|
||||
self::assertSame([$staff[0], $formerManager], $controller->capturedOptions['assignable_managers']);
|
||||
}
|
||||
|
||||
private function buildController(UserRepository $userRepo, bool $granted): TestableEditController
|
||||
{
|
||||
// An unsubmitted form: index() falls through to render() and only the options
|
||||
// handed to createForm() are of interest here.
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form->method('handleRequest')->willReturn($form);
|
||||
$form->method('isSubmitted')->willReturn(false);
|
||||
|
||||
return new TestableEditController(
|
||||
$this->createMock(EntityManagerInterface::class),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
$this->createMock(BoardServiceRepository::class),
|
||||
$this->createMock(AdditionalServiceRepository::class),
|
||||
$userRepo,
|
||||
$this->createMock(AccommodationBookingService::class),
|
||||
$form,
|
||||
$granted,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final class TestableEditController extends EditController
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
public array $capturedOptions = [];
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $entityManager,
|
||||
LoggerInterface $logger,
|
||||
BoardServiceRepository $boardServiceRepo,
|
||||
AdditionalServiceRepository $additionalServiceRepo,
|
||||
UserRepository $userRepo,
|
||||
AccommodationBookingService $bookingService,
|
||||
private readonly FormInterface $form,
|
||||
private readonly bool $granted = false,
|
||||
) {
|
||||
parent::__construct($entityManager, $logger, $boardServiceRepo, $additionalServiceRepo, $userRepo, $bookingService);
|
||||
}
|
||||
|
||||
protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface
|
||||
{
|
||||
$this->capturedOptions = $options;
|
||||
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
protected function isGranted(mixed $attribute, mixed $subject = null): bool
|
||||
{
|
||||
return $this->granted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function render(string $view, array $parameters = [], ?Response $response = null): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
|
||||
protected function addFlash(string $type, mixed $message): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
protected function generateUrl(string $route, array $parameters = [], int $referenceType = 1): string
|
||||
{
|
||||
return '/'.$route.'?'.http_build_query($parameters);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace App\Tests\Controller\Api;
|
||||
use App\Controller\Api\AccommodationBookingController;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Repository\Groups\AccommodationBookingRepository;
|
||||
use App\Service\AccommodationBookingBreakdownCalculator;
|
||||
use App\Service\AccommodationBookingService;
|
||||
@@ -54,7 +55,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
$booking->setAccommodationDiscount(10);
|
||||
$booking->setBoardServiceDiscount(20);
|
||||
$booking->setAdditionalServicesDiscount(30);
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
$booking->setAcceptedAt(new \DateTimeImmutable('2026-07-15T10:00:00+00:00'));
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
@@ -143,7 +144,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
$booking->setFirstName('Tom');
|
||||
$booking->setLastName('Beispiel');
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository
|
||||
@@ -194,7 +195,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
$booking->setFirstName('Tom');
|
||||
$booking->setLastName('Beispiel');
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository
|
||||
@@ -212,7 +213,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
->method('acceptBooking')
|
||||
->with($booking)
|
||||
->willReturnCallback(static function (AccommodationBooking $b): void {
|
||||
$b->setIsInquiry(false);
|
||||
$b->setStatus(AccommodationBookingStatus::Booking);
|
||||
$b->setAcceptedAt(new \DateTimeImmutable());
|
||||
});
|
||||
|
||||
@@ -223,7 +224,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
|
||||
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
|
||||
self::assertSame('booking', $payload['status']);
|
||||
self::assertFalse($booking->isInquiry());
|
||||
self::assertSame(AccommodationBookingStatus::Booking, $booking->getStatus());
|
||||
self::assertNotNull($booking->getAcceptedAt());
|
||||
self::assertSame($booking->getAcceptedAt()->format(\DATE_ATOM), $payload['acceptedAt']);
|
||||
}
|
||||
@@ -239,7 +240,7 @@ class AccommodationBookingControllerTest extends TestCase
|
||||
$booking->setFirstName('Tom');
|
||||
$booking->setLastName('Beispiel');
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
$booking->setAcceptedAt($acceptedAt);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
|
||||
@@ -9,22 +9,56 @@ use App\Controller\Api\ContingentController;
|
||||
use App\Entity\Groups\AccommodationPrice;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
use App\Repository\Groups\AccommodationRepository;
|
||||
use App\Service\AccommodationPriceCoverage;
|
||||
use App\Service\PriceTimelineBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
||||
class ContingentControllerTest extends TestCase
|
||||
{
|
||||
public function testEnrichEntryIncludesPricingMetadata(): void
|
||||
{
|
||||
$controller = new ContingentController(
|
||||
$controller = $this->createController();
|
||||
$price = $this->createPrice();
|
||||
|
||||
$result = $this->enrichEntry($controller, '2026-07-06', 'available', [$price], ['2026-07-06' => true]);
|
||||
|
||||
self::assertSame('available', $result['status']);
|
||||
self::assertSame(4, $result['includedPax']);
|
||||
self::assertSame(3, $result['minNights']);
|
||||
self::assertSame(123.45, $result['pricePerNight']);
|
||||
self::assertSame('EUR', $result['currency']);
|
||||
}
|
||||
|
||||
public function testEnrichEntryBlocksDayWithoutPrice(): void
|
||||
{
|
||||
$controller = $this->createController();
|
||||
$price = $this->createPrice();
|
||||
|
||||
$result = $this->enrichEntry($controller, '2026-08-01', 'OK', [$price], ['2026-07-06' => true]);
|
||||
|
||||
self::assertSame('BLOCKED', $result['status']);
|
||||
self::assertNull($result['pricePerNight']);
|
||||
self::assertNull($result['includedPax']);
|
||||
self::assertNull($result['minNights']);
|
||||
}
|
||||
|
||||
private function createController(): ContingentController
|
||||
{
|
||||
return new ContingentController(
|
||||
$this->createMock(ContingentsClient::class),
|
||||
$this->createMock(AccommodationRepository::class),
|
||||
$this->createMock(AccommodationPriceRepository::class),
|
||||
$this->createMock(CacheInterface::class),
|
||||
new PriceTimelineBuilder(),
|
||||
new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class)),
|
||||
$this->createMock(LoggerInterface::class),
|
||||
);
|
||||
}
|
||||
|
||||
private function createPrice(): AccommodationPrice
|
||||
{
|
||||
$price = new AccommodationPrice();
|
||||
$price->setDateFrom(new \DateTimeImmutable('2026-07-01'));
|
||||
$price->setDateTo(new \DateTimeImmutable('2026-07-31'));
|
||||
@@ -33,13 +67,24 @@ class ContingentControllerTest extends TestCase
|
||||
$price->setPriceAdditionalPerson(1500);
|
||||
$price->setMinNights(3);
|
||||
|
||||
return $price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccommodationPrice[] $prices
|
||||
* @param array<string, true> $covered
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function enrichEntry(
|
||||
ContingentController $controller,
|
||||
string $date,
|
||||
string $status,
|
||||
array $prices,
|
||||
array $covered,
|
||||
): array {
|
||||
$method = new \ReflectionMethod($controller, 'enrichEntry');
|
||||
|
||||
$result = $method->invoke($controller, '2026-07-06', 'available', [$price], 'EUR');
|
||||
|
||||
self::assertSame(4, $result['includedPax']);
|
||||
self::assertSame(3, $result['minNights']);
|
||||
self::assertSame(123.45, $result['pricePerNight']);
|
||||
self::assertSame('EUR', $result['currency']);
|
||||
return $method->invoke($controller, $date, $status, $prices, $covered, 'EUR');
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,12 @@ namespace App\Tests\Controller\Groups;
|
||||
use App\Controller\Groups\OfferController;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Repository\Groups\AccommodationBookingRepository;
|
||||
use App\Service\AccommodationBookingBreakdownCalculator;
|
||||
use App\Service\AccommodationBookingLinkSigner;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationTermsUrlProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
@@ -24,6 +26,7 @@ class OfferControllerTest extends TestCase
|
||||
public function testAccessAuthorizesSessionAndRedirectsToView(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository->method('findOneBy')->with(['uuid' => $booking->getUuid()])->willReturn($booking);
|
||||
@@ -90,10 +93,65 @@ class OfferControllerTest extends TestCase
|
||||
self::assertSame('groups/booking/offer_unavailable.html.twig', $controller->renderedView);
|
||||
}
|
||||
|
||||
public function testAccessRendersUnavailableForDraft(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus(AccommodationBookingStatus::Draft);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||
|
||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||
$linkSigner->method('isValidLinkRequest')->willReturn(true);
|
||||
$linkSigner->expects(self::never())->method('authorizeSession');
|
||||
|
||||
$controller = new TestableOfferController(
|
||||
$bookingRepository,
|
||||
$linkSigner,
|
||||
$this->createMock(AccommodationBookingBreakdownCalculator::class),
|
||||
$this->createMock(AccommodationBookingService::class),
|
||||
);
|
||||
|
||||
$response = $controller->access($booking->getUuid(), Request::create('/groups/booking/offer/'.$booking->getUuid()));
|
||||
|
||||
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
|
||||
self::assertSame('groups/booking/offer_unavailable.html.twig', $controller->renderedView);
|
||||
}
|
||||
|
||||
public function testViewRendersUnavailableForDiscardedBooking(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus(AccommodationBookingStatus::Discarded);
|
||||
$booking->setAccommodation(new Accommodation());
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||
|
||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||
$linkSigner->method('isSessionAuthorized')->willReturn(true);
|
||||
|
||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator->expects(self::never())->method('compute');
|
||||
|
||||
$controller = new TestableOfferController(
|
||||
$bookingRepository,
|
||||
$linkSigner,
|
||||
$breakdownCalculator,
|
||||
$this->createMock(AccommodationBookingService::class),
|
||||
);
|
||||
|
||||
$request = Request::create('/groups/booking/offer/'.$booking->getUuid().'/view');
|
||||
$request->setSession(new Session(new MockArraySessionStorage()));
|
||||
$response = $controller->view($booking->getUuid(), $request);
|
||||
|
||||
self::assertSame(Response::HTTP_OK, $response->getStatusCode());
|
||||
self::assertSame('groups/booking/offer_unavailable.html.twig', $controller->renderedView);
|
||||
}
|
||||
|
||||
public function testViewRendersOfferWhenSessionAuthorized(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
$booking->setAccommodation(new Accommodation());
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
@@ -149,7 +207,7 @@ class OfferControllerTest extends TestCase
|
||||
public function testConfirmGetRendersModalWithFreshForm(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository->method('findOneBy')->with(['uuid' => $booking->getUuid()])->willReturn($booking);
|
||||
@@ -180,7 +238,7 @@ class OfferControllerTest extends TestCase
|
||||
public function testConfirmPostValidAcceptsBookingAndRedirects(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||
@@ -215,7 +273,7 @@ class OfferControllerTest extends TestCase
|
||||
public function testConfirmPostValidViaHtmxReturnsHxRedirect(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||
@@ -250,7 +308,7 @@ class OfferControllerTest extends TestCase
|
||||
public function testConfirmPostInvalidReRendersModalWithoutAccepting(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||
@@ -284,7 +342,7 @@ class OfferControllerTest extends TestCase
|
||||
public function testConfirmRedirectsWhenAlreadyAccepted(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
|
||||
$bookingRepository = $this->createMock(AccommodationBookingRepository::class);
|
||||
$bookingRepository->method('findOneBy')->willReturn($booking);
|
||||
@@ -361,7 +419,13 @@ final class TestableOfferController extends OfferController
|
||||
AccommodationBookingService $bookingService,
|
||||
private readonly ?FormInterface $confirmationForm = null,
|
||||
) {
|
||||
parent::__construct($bookingRepository, $linkSigner, $breakdownCalculator, $bookingService);
|
||||
parent::__construct(
|
||||
$bookingRepository,
|
||||
$linkSigner,
|
||||
$breakdownCalculator,
|
||||
$bookingService,
|
||||
new AccommodationTermsUrlProvider(['AT' => '', 'CH' => '', 'IT' => ''], 'https://example.test/agb/'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function createForm(string $type, mixed $data = null, array $options = []): FormInterface
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Controller\Groups;
|
||||
|
||||
use App\BpnConnect\ContingentsClient;
|
||||
use App\BpnConnect\Model\ContingentCalendarEntry;
|
||||
use App\BpnConnect\Model\ContingentCalendarMeta;
|
||||
use App\BpnConnect\Model\ContingentCalendarResponse;
|
||||
use App\BpnConnect\Model\ContingentStatus;
|
||||
use App\Controller\Groups\Step1Controller;
|
||||
use App\Entity\Groups\AccommodationPrice;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationPriceCoverage;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use App\Service\CalendarGridBuilder;
|
||||
use App\Service\GroupsPriceCalculator;
|
||||
use App\Service\PriceTimelineBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Contracts\Cache\CacheInterface;
|
||||
|
||||
class Step1CalendarDataTest extends TestCase
|
||||
{
|
||||
public function testDaysWithoutPriceAreBlockedEvenWhenContingentIsOk(): void
|
||||
{
|
||||
// Contingent says OK for the whole week, prices only cover 03.–05.
|
||||
$price = new AccommodationPrice();
|
||||
$price->setDateFrom(new \DateTimeImmutable('2026-06-03'));
|
||||
$price->setDateTo(new \DateTimeImmutable('2026-06-05'));
|
||||
$price->setMinNights(2);
|
||||
|
||||
$enriched = $this->buildEnrichedDayData(
|
||||
$this->calendarResponse([
|
||||
'2026-06-01' => ContingentStatus::Ok,
|
||||
'2026-06-02' => ContingentStatus::Ok,
|
||||
'2026-06-03' => ContingentStatus::Ok,
|
||||
'2026-06-04' => ContingentStatus::Ok,
|
||||
'2026-06-05' => ContingentStatus::Ok,
|
||||
'2026-06-06' => ContingentStatus::Ok,
|
||||
'2026-06-07' => ContingentStatus::Ok,
|
||||
]),
|
||||
[$price],
|
||||
'2026-06-01',
|
||||
'2026-06-07',
|
||||
);
|
||||
|
||||
self::assertSame('blocked', $enriched['2026-06-01']['status']);
|
||||
self::assertSame('blocked', $enriched['2026-06-02']['status']);
|
||||
// First priced night — arrival only
|
||||
self::assertSame('blocked-to-ok', $enriched['2026-06-03']['status']);
|
||||
self::assertSame('ok', $enriched['2026-06-04']['status']);
|
||||
self::assertSame('ok', $enriched['2026-06-05']['status']);
|
||||
// Day after the last priced night — still valid as checkout
|
||||
self::assertSame('checkout-only', $enriched['2026-06-06']['status']);
|
||||
self::assertSame('blocked', $enriched['2026-06-07']['status']);
|
||||
|
||||
self::assertSame(2, $enriched['2026-06-04']['minNights']);
|
||||
self::assertSame(0, $enriched['2026-06-07']['minNights']);
|
||||
}
|
||||
|
||||
public function testBlockedContingentWinsOverExistingPrice(): void
|
||||
{
|
||||
$price = new AccommodationPrice();
|
||||
$price->setDateFrom(new \DateTimeImmutable('2026-06-01'));
|
||||
$price->setDateTo(new \DateTimeImmutable('2026-06-03'));
|
||||
$price->setMinNights(1);
|
||||
|
||||
$enriched = $this->buildEnrichedDayData(
|
||||
$this->calendarResponse([
|
||||
'2026-06-01' => ContingentStatus::Ok,
|
||||
'2026-06-02' => ContingentStatus::Blocked,
|
||||
'2026-06-03' => ContingentStatus::Ok,
|
||||
]),
|
||||
[$price],
|
||||
'2026-06-01',
|
||||
'2026-06-03',
|
||||
);
|
||||
|
||||
self::assertSame('blocked-to-ok', $enriched['2026-06-01']['status']);
|
||||
self::assertSame('checkout-only', $enriched['2026-06-02']['status']);
|
||||
self::assertSame('blocked-to-ok', $enriched['2026-06-03']['status']);
|
||||
}
|
||||
|
||||
public function testPriceCoverageStillAppliesWhenContingentApiIsUnavailable(): void
|
||||
{
|
||||
$price = new AccommodationPrice();
|
||||
$price->setDateFrom(new \DateTimeImmutable('2026-06-01'));
|
||||
$price->setDateTo(new \DateTimeImmutable('2026-06-02'));
|
||||
$price->setMinNights(1);
|
||||
|
||||
$enriched = $this->buildEnrichedDayData(null, [$price], '2026-06-01', '2026-06-03');
|
||||
|
||||
self::assertSame('blocked-to-ok', $enriched['2026-06-01']['status']);
|
||||
self::assertSame('ok', $enriched['2026-06-02']['status']);
|
||||
self::assertSame('checkout-only', $enriched['2026-06-03']['status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, ContingentStatus> $statuses
|
||||
*/
|
||||
private function calendarResponse(array $statuses): ContingentCalendarResponse
|
||||
{
|
||||
$entries = [];
|
||||
foreach ($statuses as $date => $status) {
|
||||
$entries[] = new ContingentCalendarEntry(date: $date, status: $status);
|
||||
}
|
||||
|
||||
return new ContingentCalendarResponse(
|
||||
new ContingentCalendarMeta('', '', 'days', 'HOTEL', 1, count($entries)),
|
||||
$entries,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccommodationPrice[] $prices
|
||||
*
|
||||
* @return array<string, array{status: string, minNights: int}>
|
||||
*/
|
||||
private function buildEnrichedDayData(
|
||||
?ContingentCalendarResponse $calendar,
|
||||
array $prices,
|
||||
string $dateFrom,
|
||||
string $dateTo,
|
||||
): array {
|
||||
$cache = $this->createMock(CacheInterface::class);
|
||||
if (null === $calendar) {
|
||||
$cache->method('get')->willThrowException(new \App\BpnConnect\Exception\BpnConnectException('down'));
|
||||
} else {
|
||||
$cache->method('get')->willReturn($calendar);
|
||||
}
|
||||
|
||||
$priceRepository = $this->createMock(AccommodationPriceRepository::class);
|
||||
$priceRepository->method('findByHotelCodeAndDateRange')->willReturn($prices);
|
||||
|
||||
$controller = new Step1Controller(
|
||||
$this->createMock(AccommodationBookingService::class),
|
||||
$this->createMock(AccommodationSessionManager::class),
|
||||
$this->createMock(ContingentsClient::class),
|
||||
$priceRepository,
|
||||
new PriceTimelineBuilder(),
|
||||
$cache,
|
||||
$this->createMock(CalendarGridBuilder::class),
|
||||
$this->createMock(GroupsPriceCalculator::class),
|
||||
new AccommodationPriceCoverage($priceRepository),
|
||||
);
|
||||
|
||||
$method = new \ReflectionMethod($controller, 'buildEnrichedDayData');
|
||||
|
||||
return $method->invoke(
|
||||
$controller,
|
||||
'HOTEL',
|
||||
new \DateTimeImmutable($dateFrom),
|
||||
new \DateTimeImmutable($dateTo),
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,11 @@ namespace App\Tests\Controller\Groups;
|
||||
use App\Controller\Groups\Step4Controller;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Service\AccommodationBookingService;
|
||||
use App\Service\AccommodationSessionManager;
|
||||
use App\Service\AccommodationTermsUrlProvider;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
@@ -100,7 +102,7 @@ class Step4ControllerTest extends TestCase
|
||||
->setCalendarCode('HOTEL')
|
||||
->setMaxAdolescentAge(17);
|
||||
|
||||
$booking = (new AccommodationBooking())->setIsInquiry(true);
|
||||
$booking = (new AccommodationBooking())->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
|
||||
@@ -273,7 +275,7 @@ class Step4ControllerTest extends TestCase
|
||||
->setCalendarCode('HOTEL')
|
||||
->setMaxAdolescentAge(17);
|
||||
|
||||
$booking = (new AccommodationBooking())->setIsInquiry(false);
|
||||
$booking = (new AccommodationBooking())->setStatus(AccommodationBookingStatus::Booking);
|
||||
|
||||
$bookingService = $this->createMock(AccommodationBookingService::class);
|
||||
$bookingService->method('loadAccommodation')->with(1)->willReturn($accommodation);
|
||||
@@ -352,7 +354,11 @@ final class TestableStep4Controller extends Step4Controller
|
||||
AccommodationSessionManager $sessionManager,
|
||||
private readonly FormInterface $form,
|
||||
) {
|
||||
parent::__construct($bookingService, $sessionManager);
|
||||
parent::__construct(
|
||||
$bookingService,
|
||||
$sessionManager,
|
||||
new AccommodationTermsUrlProvider(['AT' => '', 'CH' => '', 'IT' => ''], 'https://example.test/agb/'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,20 +4,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form;
|
||||
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Form\AccommodationStep2Type;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Service\AdditionalServiceExclusionResolver;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\Forms;
|
||||
|
||||
class AccommodationStep2TypeTest extends TestCase
|
||||
{
|
||||
public function testChildrenLabelIsBuiltFromMaxAdolescentAgeOption(): void
|
||||
{
|
||||
$form = Forms::createFormFactoryBuilder()
|
||||
->getFormFactory()
|
||||
->create(AccommodationStep2Type::class, new AccommodationBookingDto(), [
|
||||
'max_adolescent_age' => 15,
|
||||
]);
|
||||
$form = $this->createForm(new AccommodationBookingDto(), [
|
||||
'max_adolescent_age' => 15,
|
||||
]);
|
||||
|
||||
self::assertSame(
|
||||
'davon Kinder (4–15 Jahre)',
|
||||
@@ -28,9 +29,7 @@ class AccommodationStep2TypeTest extends TestCase
|
||||
public function testBlankOptionalChildCountersAreNormalizedToZero(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$form = Forms::createFormFactoryBuilder()
|
||||
->getFormFactory()
|
||||
->create(AccommodationStep2Type::class, $dto);
|
||||
$form = $this->createForm($dto);
|
||||
|
||||
$form->submit([
|
||||
'paxCount' => '2',
|
||||
@@ -48,14 +47,12 @@ class AccommodationStep2TypeTest extends TestCase
|
||||
public function testGroupedAdditionalServiceValuesCanSubmitUnderSelectionGroupKeys(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$form = Forms::createFormFactoryBuilder()
|
||||
->getFormFactory()
|
||||
->create(AccommodationStep2Type::class, $dto, [
|
||||
'additional_service_choices' => [
|
||||
'Ski service' => 101,
|
||||
'Board service' => 202,
|
||||
],
|
||||
]);
|
||||
$form = $this->createForm($dto, [
|
||||
'additional_service_choices' => [
|
||||
'Ski service' => 101,
|
||||
'Board service' => 202,
|
||||
],
|
||||
]);
|
||||
|
||||
$form->submit([
|
||||
'paxCount' => '2',
|
||||
@@ -71,4 +68,87 @@ class AccommodationStep2TypeTest extends TestCase
|
||||
self::assertTrue($form->isSynchronized());
|
||||
self::assertSame([101, 202], array_values($dto->selectedAdditionalServiceIds));
|
||||
}
|
||||
|
||||
public function testNewlySelectedExclusiveServiceClearsItsConflicts(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$dto->selectedAdditionalServiceIds = [11, 12];
|
||||
|
||||
$form = $this->createForm($dto, [
|
||||
'additional_service_choices' => [
|
||||
'Keller' => 11,
|
||||
'1. OG' => 12,
|
||||
'Komplett' => 13,
|
||||
],
|
||||
'additional_services' => [
|
||||
$this->service(11, 'Reinigung', false),
|
||||
$this->service(12, 'Reinigung', false),
|
||||
$this->service(13, 'Reinigung', true),
|
||||
],
|
||||
]);
|
||||
|
||||
$form->submit([
|
||||
'paxCount' => '2',
|
||||
'minorsCount' => '0',
|
||||
'childrenCount' => '0',
|
||||
'selectedBoardServiceId' => '',
|
||||
'selectedAdditionalServiceIds' => ['11', '12', '13'],
|
||||
]);
|
||||
|
||||
self::assertTrue($form->isSynchronized());
|
||||
self::assertSame([13], array_values($dto->selectedAdditionalServiceIds));
|
||||
}
|
||||
|
||||
public function testNewlySelectedRegularServiceClearsTheExclusiveOne(): void
|
||||
{
|
||||
$dto = new AccommodationBookingDto();
|
||||
$dto->selectedAdditionalServiceIds = [13];
|
||||
|
||||
$form = $this->createForm($dto, [
|
||||
'additional_service_choices' => [
|
||||
'Keller' => 11,
|
||||
'Komplett' => 13,
|
||||
],
|
||||
'additional_services' => [
|
||||
$this->service(11, 'Reinigung', false),
|
||||
$this->service(13, 'Reinigung', true),
|
||||
],
|
||||
]);
|
||||
|
||||
$form->submit([
|
||||
'paxCount' => '2',
|
||||
'minorsCount' => '0',
|
||||
'childrenCount' => '0',
|
||||
'selectedBoardServiceId' => '',
|
||||
'selectedAdditionalServiceIds' => ['13', '11'],
|
||||
]);
|
||||
|
||||
self::assertTrue($form->isSynchronized());
|
||||
self::assertSame([11], array_values($dto->selectedAdditionalServiceIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @return FormInterface<AccommodationBookingDto>
|
||||
*/
|
||||
private function createForm(AccommodationBookingDto $dto, array $options = []): FormInterface
|
||||
{
|
||||
return Forms::createFormFactoryBuilder()
|
||||
->addType(new AccommodationStep2Type(new AdditionalServiceExclusionResolver()))
|
||||
->getFormFactory()
|
||||
->create(AccommodationStep2Type::class, $dto, $options);
|
||||
}
|
||||
|
||||
private function service(int $id, ?string $exclusionGroup, bool $isExclusive): AdditionalService
|
||||
{
|
||||
$service = new AdditionalService();
|
||||
$service->setExclusionGroup($exclusionGroup);
|
||||
$service->setIsExclusive($isExclusive);
|
||||
|
||||
$property = new \ReflectionProperty(AdditionalService::class, 'id');
|
||||
$property->setValue($service, $id);
|
||||
|
||||
return $service;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Admin\Groups;
|
||||
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Form\Admin\Groups\AccommodationBookingType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Email;
|
||||
use Symfony\Component\Validator\Constraints\EmailValidator;
|
||||
use Symfony\Component\Validator\ConstraintValidatorFactory;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
|
||||
class AccommodationBookingTypeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider statusesWithoutMandatoryFields
|
||||
*/
|
||||
public function testDraftAndDiscardedAreValidatedWithoutTheEditGroup(AccommodationBookingStatus $status): void
|
||||
{
|
||||
self::assertSame(['Default'], $this->resolveValidationGroups($status));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider customerFacingStatuses
|
||||
*/
|
||||
public function testCustomerFacingStatusesAddTheEditGroup(AccommodationBookingStatus $status): void
|
||||
{
|
||||
self::assertSame(['Default', 'edit'], $this->resolveValidationGroups($status));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable<string, array{AccommodationBookingStatus}>
|
||||
*/
|
||||
public static function statusesWithoutMandatoryFields(): iterable
|
||||
{
|
||||
yield 'draft' => [AccommodationBookingStatus::Draft];
|
||||
yield 'discarded' => [AccommodationBookingStatus::Discarded];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return iterable<string, array{AccommodationBookingStatus}>
|
||||
*/
|
||||
public static function customerFacingStatuses(): iterable
|
||||
{
|
||||
yield 'inquiry' => [AccommodationBookingStatus::Inquiry];
|
||||
yield 'booking' => [AccommodationBookingStatus::Booking];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider statusesWithoutMandatoryFields
|
||||
*/
|
||||
public function testEmptyContactDataPassesValidation(AccommodationBookingStatus $status): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus($status);
|
||||
|
||||
$violations = $this->validate($booking, $this->resolveValidationGroups($status));
|
||||
|
||||
self::assertCount(0, $violations);
|
||||
}
|
||||
|
||||
public function testPromotedBookingRequiresContactData(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$violations = $this->validate($booking, ['Default', 'edit']);
|
||||
|
||||
$properties = array_map(static fn ($violation) => $violation->getPropertyPath(), iterator_to_array($violations));
|
||||
sort($properties);
|
||||
|
||||
self::assertSame(['email', 'firstName', 'groupName', 'lastName'], $properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolveValidationGroups(AccommodationBookingStatus $status): array
|
||||
{
|
||||
$resolver = new OptionsResolver();
|
||||
(new AccommodationBookingType())->configureOptions($resolver);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus($status);
|
||||
|
||||
$form = $this->createMock(FormInterface::class);
|
||||
$form->method('getData')->willReturn($booking);
|
||||
|
||||
return ($resolver->resolve()['validation_groups'])($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $groups
|
||||
*/
|
||||
private function validate(AccommodationBooking $booking, array $groups): \Symfony\Component\Validator\ConstraintViolationListInterface
|
||||
{
|
||||
// The app configures email_validation_mode: html5 globally (config/packages/validator.yaml);
|
||||
// the standalone builder would otherwise fall back to the deprecated "loose" mode.
|
||||
$validatorFactory = new ConstraintValidatorFactory([
|
||||
EmailValidator::class => new EmailValidator(Email::VALIDATION_MODE_HTML5),
|
||||
]);
|
||||
|
||||
return Validation::createValidatorBuilder()
|
||||
->enableAttributeMapping()
|
||||
->setConstraintValidatorFactory($validatorFactory)
|
||||
->getValidator()
|
||||
->validate($booking, null, $groups);
|
||||
}
|
||||
}
|
||||
@@ -728,6 +728,54 @@ class ParticipantEditDtoTest extends TestCase
|
||||
$this->assertCount(1, $insuranceViolations);
|
||||
}
|
||||
|
||||
public function testDependentWithoutInsurancePassesWhenApplicantHasFamilyInsurance(): void
|
||||
{
|
||||
$applicant = $this->createAdultParticipant('[email protected]');
|
||||
$applicant->insurance = $this->createMockInsurance(familyInsurance: true);
|
||||
|
||||
$dependent = $this->createAdultParticipant('[email protected]');
|
||||
$dependent->insurance = null;
|
||||
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([$applicant, $dependent]);
|
||||
|
||||
$wrapper = new ParticipantEditDto(
|
||||
participant: $bookingDto->participants[1],
|
||||
bookingContext: $bookingDto,
|
||||
);
|
||||
|
||||
$violations = $this->validator->validate($wrapper, null, ['strict_required']);
|
||||
$insuranceViolations = array_filter(
|
||||
iterator_to_array($violations),
|
||||
fn ($v) => 'participant.insurance' === $v->getPropertyPath()
|
||||
);
|
||||
|
||||
$this->assertCount(0, $insuranceViolations);
|
||||
}
|
||||
|
||||
public function testDependentWithoutInsuranceFailsWhenApplicantHasNonFamilyInsurance(): void
|
||||
{
|
||||
$applicant = $this->createAdultParticipant('[email protected]');
|
||||
$applicant->insurance = $this->createMockInsurance(familyInsurance: false);
|
||||
|
||||
$dependent = $this->createAdultParticipant('[email protected]');
|
||||
$dependent->insurance = null;
|
||||
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([$applicant, $dependent]);
|
||||
|
||||
$wrapper = new ParticipantEditDto(
|
||||
participant: $bookingDto->participants[1],
|
||||
bookingContext: $bookingDto,
|
||||
);
|
||||
|
||||
$violations = $this->validator->validate($wrapper, null, ['strict_required']);
|
||||
$insuranceViolations = array_filter(
|
||||
iterator_to_array($violations),
|
||||
fn ($v) => 'participant.insurance' === $v->getPropertyPath()
|
||||
);
|
||||
|
||||
$this->assertCount(1, $insuranceViolations);
|
||||
}
|
||||
|
||||
private function createBookingDtoWithParticipants(array $participants): BookingDto
|
||||
{
|
||||
$travel = new Travel();
|
||||
@@ -821,12 +869,13 @@ class ParticipantEditDtoTest extends TestCase
|
||||
return $service;
|
||||
}
|
||||
|
||||
private function createMockInsurance(): Insurance
|
||||
private function createMockInsurance(bool $familyInsurance = false): Insurance
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->id = '1';
|
||||
$insurance->label = 'Test Insurance';
|
||||
$insurance->price = 10.0;
|
||||
$insurance->familyInsurance = $familyInsurance;
|
||||
|
||||
return $insurance;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Service\Condition;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\Condition\FamilyInsuranceActiveCondition;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FamilyInsuranceActiveConditionTest extends TestCase
|
||||
{
|
||||
private FamilyInsuranceActiveCondition $condition;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->condition = new FamilyInsuranceActiveCondition();
|
||||
}
|
||||
|
||||
public function testAlwaysFalseForApplicant(): void
|
||||
{
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->insurance = $this->createFamilyInsurance();
|
||||
|
||||
$bookingDto = new BookingDto(new Travel(), 1);
|
||||
$bookingDto->participants = [$applicant];
|
||||
|
||||
$result = $this->condition->evaluate($bookingDto, 0, []);
|
||||
|
||||
$this->assertFalse($result, 'Applicant is never affected by their own family insurance selection');
|
||||
}
|
||||
|
||||
public function testTrueForDependentWhenApplicantHasFamilyInsurance(): void
|
||||
{
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->insurance = $this->createFamilyInsurance();
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
|
||||
$bookingDto = new BookingDto(new Travel(), 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$result = $this->condition->evaluate($bookingDto, 1, []);
|
||||
|
||||
$this->assertTrue($result, 'Dependent insurance field must be hidden when applicant has family insurance');
|
||||
}
|
||||
|
||||
public function testFalseForDependentWhenApplicantHasNonFamilyInsurance(): void
|
||||
{
|
||||
$nonFamilyInsurance = new Insurance();
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->insurance = $nonFamilyInsurance;
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
|
||||
$bookingDto = new BookingDto(new Travel(), 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$result = $this->condition->evaluate($bookingDto, 1, []);
|
||||
|
||||
$this->assertFalse($result, 'Dependent should keep their own insurance choice for non-family insurance');
|
||||
}
|
||||
|
||||
public function testFalseForDependentWhenApplicantHasNoInsurance(): void
|
||||
{
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
|
||||
$bookingDto = new BookingDto(new Travel(), 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$result = $this->condition->evaluate($bookingDto, 1, []);
|
||||
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testGetDependentFieldsReturnsInsurance(): void
|
||||
{
|
||||
$result = $this->condition->getDependentFields();
|
||||
|
||||
$this->assertSame(['insurance'], $result);
|
||||
}
|
||||
|
||||
public function testGetDescriptionReturnsString(): void
|
||||
{
|
||||
$result = $this->condition->getDescription();
|
||||
|
||||
$this->assertIsString($result);
|
||||
$this->assertStringContainsString('family insurance', $result);
|
||||
}
|
||||
|
||||
private function createFamilyInsurance(): Insurance
|
||||
{
|
||||
$insurance = new Insurance();
|
||||
$insurance->familyInsurance = true;
|
||||
|
||||
return $insurance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\CreateFieldStateProvider;
|
||||
use App\Service\ParticipantEligibilityChecker;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Integration-level coverage for cross-participant field-state re-evaluation: proves the
|
||||
* dependent's 'insurance' field state actually flips when the applicant's insurance
|
||||
* selection changes, wiring FamilyInsuranceActiveCondition through the real
|
||||
* CreateFieldStateProvider composition rather than testing the condition in isolation.
|
||||
*/
|
||||
class CreateFieldStateProviderTest extends TestCase
|
||||
{
|
||||
private CreateFieldStateProvider $provider;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->provider = new CreateFieldStateProvider(new ParticipantEligibilityChecker());
|
||||
}
|
||||
|
||||
public function testDependentInsuranceFieldHidesWhenApplicantSelectsFamilyInsuranceThenReappearsAfterSwitch(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+30 days');
|
||||
$travel->dateTo = new \DateTimeImmutable('+37 days');
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
// Baby age (0-2 years at travel date) is always eligible regardless of skipass availability
|
||||
$applicant->dateOfBirth = $travel->dateFrom->modify('-1 year');
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
$dependent->dateOfBirth = $travel->dateFrom->modify('-1 year');
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$this->assertTrue(
|
||||
$this->provider->shouldIncludeField('insurance', $bookingDto, 1),
|
||||
'Dependent should see their own insurance field before the applicant selects family insurance'
|
||||
);
|
||||
|
||||
$familyInsurance = new Insurance();
|
||||
$familyInsurance->familyInsurance = true;
|
||||
$applicant->insurance = $familyInsurance;
|
||||
|
||||
$this->assertFalse(
|
||||
$this->provider->shouldIncludeField('insurance', $bookingDto, 1),
|
||||
'Dependent insurance field must be hidden once the applicant selects family insurance'
|
||||
);
|
||||
|
||||
$nonFamilyInsurance = new Insurance();
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
$applicant->insurance = $nonFamilyInsurance;
|
||||
|
||||
$this->assertTrue(
|
||||
$this->provider->shouldIncludeField('insurance', $bookingDto, 1),
|
||||
'Dependent insurance field must reappear once the applicant switches away from family insurance'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantFieldOptionsProvider;
|
||||
use App\Service\BookingPriceCalculator;
|
||||
use App\Service\InsuranceManager;
|
||||
use App\Service\ServiceAvailabilityCalculator;
|
||||
use App\Service\ServiceLabelFormatter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* Regression tests for the family-insurance choices-list bug: the applicant selects a
|
||||
* family insurance, it's correctly reassigned to the total-price tier on submit, but
|
||||
* the re-rendered form showed no selection because the choices list was still filtered
|
||||
* by the applicant's individual price instead of the total booking price.
|
||||
*/
|
||||
class ParticipantFieldOptionsProviderInsuranceTest extends TestCase
|
||||
{
|
||||
private ParticipantFieldOptionsProvider $provider;
|
||||
private BookingPriceCalculator $priceCalculatorService;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$serviceAvailabilityCalculator = $this->createMock(ServiceAvailabilityCalculator::class);
|
||||
// InsuranceManager is stateless - use the real implementation so actual
|
||||
// eligibility/price-tier filtering runs, not a stubbed-out mock.
|
||||
$insuranceService = new InsuranceManager();
|
||||
$this->priceCalculatorService = $this->createMock(BookingPriceCalculator::class);
|
||||
$serviceLabelFormatter = new ServiceLabelFormatter();
|
||||
$translator = $this->createMock(TranslatorInterface::class);
|
||||
$translator->method('trans')->willReturnCallback(fn (string $message) => $message);
|
||||
|
||||
$this->provider = new ParticipantFieldOptionsProvider(
|
||||
$serviceAvailabilityCalculator,
|
||||
$insuranceService,
|
||||
$this->priceCalculatorService,
|
||||
$serviceLabelFormatter,
|
||||
$translator
|
||||
);
|
||||
}
|
||||
|
||||
public function testFamilyInsuranceCorrectTierAppearsInApplicantChoicesUsingTotalPrice(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2025-08-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2025-08-08');
|
||||
|
||||
// Low tier only matches the applicant's individual price (300), not the total (450)
|
||||
$lowTierFamilyInsurance = new Insurance();
|
||||
$lowTierFamilyInsurance->id = '1';
|
||||
$lowTierFamilyInsurance->label = 'Reise-Rücktritt Familie';
|
||||
$lowTierFamilyInsurance->familyInsurance = true;
|
||||
$lowTierFamilyInsurance->travelPriceFrom = 0.0;
|
||||
$lowTierFamilyInsurance->travelPriceTo = 400.0;
|
||||
|
||||
// Correct tier matches the total booking price (450), not the applicant's individual price (300)
|
||||
$correctTierFamilyInsurance = new Insurance();
|
||||
$correctTierFamilyInsurance->id = '2';
|
||||
$correctTierFamilyInsurance->label = 'Reise-Rücktritt Familie';
|
||||
$correctTierFamilyInsurance->familyInsurance = true;
|
||||
$correctTierFamilyInsurance->travelPriceFrom = 400.01;
|
||||
$correctTierFamilyInsurance->travelPriceTo = 600.0;
|
||||
|
||||
$travel->insurances = [$lowTierFamilyInsurance, $correctTierFamilyInsurance];
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
|
||||
$child = new ParticipantDto();
|
||||
$child->index = 1;
|
||||
$child->dateOfBirth = new \DateTimeImmutable('2015-01-01');
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $child];
|
||||
|
||||
$this->priceCalculatorService
|
||||
->method('calculateIndividualParticipantPriceExcludingInsurance')
|
||||
->willReturn(300.0);
|
||||
$this->priceCalculatorService
|
||||
->method('calculateTotalBookingPriceExcludingInsurance')
|
||||
->willReturn(450.0);
|
||||
|
||||
$options = $this->provider->getFieldOptions('insurance', $bookingDto, 0);
|
||||
|
||||
$choiceIds = array_map(fn (Insurance $insurance) => $insurance->id, $options['choices']);
|
||||
|
||||
$this->assertContains('2', $choiceIds, 'Family insurance tier matching the total booking price must be selectable');
|
||||
$this->assertNotContains('1', $choiceIds, 'Family insurance tier that only matches the individual price must not be selectable');
|
||||
}
|
||||
|
||||
public function testFamilyInsuranceNeverAppearsInDependentChoices(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2025-08-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2025-08-08');
|
||||
|
||||
$familyInsurance = new Insurance();
|
||||
$familyInsurance->id = '1';
|
||||
$familyInsurance->label = 'Reise-Rücktritt Familie';
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$travel->insurances = [$familyInsurance];
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
|
||||
$child = new ParticipantDto();
|
||||
$child->index = 1;
|
||||
$child->dateOfBirth = new \DateTimeImmutable('2015-01-01');
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $child];
|
||||
|
||||
$this->priceCalculatorService
|
||||
->method('calculateIndividualParticipantPriceExcludingInsurance')
|
||||
->willReturn(0.0);
|
||||
$this->priceCalculatorService
|
||||
->method('calculateTotalBookingPriceExcludingInsurance')
|
||||
->willReturn(450.0);
|
||||
|
||||
$options = $this->provider->getFieldOptions('insurance', $bookingDto, 1);
|
||||
|
||||
$choiceIds = array_map(fn (Insurance $insurance) => $insurance->id, $options['choices']);
|
||||
|
||||
$this->assertNotContains('1', $choiceIds, 'Family insurance must never be selectable for a non-applicant participant');
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
||||
// Mock price calculator to return a default price
|
||||
$this->priceCalculatorService->method('calculateIndividualParticipantPriceExcludingInsurance')
|
||||
->willReturn(500.0);
|
||||
$this->priceCalculatorService->method('resolveInsuranceTravelPrice')
|
||||
->willReturn(500.0);
|
||||
|
||||
$this->handler = new ParticipantInsuranceFieldHandler($this->insuranceService, $this->priceCalculatorService);
|
||||
}
|
||||
@@ -196,6 +198,36 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
||||
$this->assertNull($participant->insurance);
|
||||
}
|
||||
|
||||
public function testProcessFieldSwitchingToNewInsuranceIsNotOverwrittenByStaleResubmissionCheck(): void
|
||||
{
|
||||
// Regression: switching from one already-selected insurance to a different one must
|
||||
// not be re-validated (and potentially overwritten) against the OLD, now-stale
|
||||
// insurance by the "form resubmission" block afterward.
|
||||
$oldInsurance = $this->createInsurance('1');
|
||||
$newInsurance = $this->createInsurance('2');
|
||||
|
||||
$participant = new ParticipantDto();
|
||||
$participant->insurance = $oldInsurance;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->insurances = [$oldInsurance, $newInsurance];
|
||||
|
||||
$bookingDto = $this->createMockBookingDto();
|
||||
$bookingDto->method('getParticipant')->with(0)->willReturn($participant);
|
||||
$bookingDto->travel = $travel;
|
||||
|
||||
// Only the NEW insurance is ever eligible - the old one would fail re-validation
|
||||
// if the (buggy) resubmission block ran a second time after this new selection.
|
||||
$this->insuranceService
|
||||
->expects($this->once())
|
||||
->method('getEligibleInsurances')
|
||||
->willReturn([$newInsurance]);
|
||||
|
||||
$this->handler->processField(['insurance' => '2'], $bookingDto, 0);
|
||||
|
||||
$this->assertSame($newInsurance, $participant->insurance);
|
||||
}
|
||||
|
||||
public function testProcessFieldWorksWithStringAndIntegerIds(): void
|
||||
{
|
||||
$insurance = $this->createInsurance(123); // Integer ID
|
||||
@@ -247,6 +279,250 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
||||
$this->assertNull($participant->insurance);
|
||||
}
|
||||
|
||||
public function testProcessFieldNotifiesApplicantWhenFamilyInsuranceNewlyAvailable(): void
|
||||
{
|
||||
$bookingDto = $this->createFamilyBookingDtoWithNonFamilyApplicantInsurance();
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
|
||||
$this->priceCalculatorService->method('calculateTotalBookingPriceExcludingInsurance')->willReturn(500.0);
|
||||
$this->insuranceService->method('getEligibleInsurances')->willReturn([$this->createInsurance('2', 'Reise-Rücktritt Familie')]);
|
||||
|
||||
// Dependent's own card is submitted (e.g. just their date of birth) - no insurance selection
|
||||
$this->handler->processField([], $bookingDto, 1);
|
||||
|
||||
$this->assertNotEmpty($applicant->notifications, 'Applicant should be notified that family insurance is now available');
|
||||
$this->assertTrue($bookingDto->familyInsuranceHintShown);
|
||||
}
|
||||
|
||||
public function testProcessFieldRecordsIneligibilityWhenApplicantSelectsInsuranceBeforeFamilyEligible(): void
|
||||
{
|
||||
$nonFamilyInsurance = $this->createInsurance('1');
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2025-08-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2025-08-08');
|
||||
$travel->insurances = [$nonFamilyInsurance];
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
|
||||
// No dependents yet - not (and cannot be) a family booking at selection time
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant];
|
||||
|
||||
$this->insuranceService->method('getEligibleInsurances')->willReturn([$nonFamilyInsurance]);
|
||||
|
||||
$this->handler->processField(['insurance' => '1'], $bookingDto, 0);
|
||||
|
||||
$this->assertTrue(
|
||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
||||
'Choosing non-family insurance while ineligible must be recorded so a later hint is justified'
|
||||
);
|
||||
}
|
||||
|
||||
public function testProcessFieldDoesNotRecordIneligibilityWhenApplicantSelectsInsuranceWhileAlreadyFamilyEligible(): void
|
||||
{
|
||||
$nonFamilyInsurance = $this->createInsurance('1');
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
|
||||
$familyInsurance = $this->createInsurance('2');
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2025-08-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2025-08-08');
|
||||
$travel->insurances = [$nonFamilyInsurance, $familyInsurance];
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
|
||||
$child = new ParticipantDto();
|
||||
$child->index = 1;
|
||||
$child->dateOfBirth = new \DateTimeImmutable('2015-01-01');
|
||||
|
||||
// Dependent's date of birth is already known, and a family insurance product is
|
||||
// actually eligible at the current price - family insurance was genuinely
|
||||
// available at the moment the applicant deliberately chose a non-family insurance.
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $child];
|
||||
|
||||
$this->priceCalculatorService->method('calculateTotalBookingPriceExcludingInsurance')->willReturn(500.0);
|
||||
$this->insuranceService->method('getEligibleInsurances')->willReturnCallback(
|
||||
fn (array $insurances) => $insurances
|
||||
);
|
||||
|
||||
$this->handler->processField(['insurance' => '1'], $bookingDto, 0);
|
||||
|
||||
$this->assertFalse(
|
||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
||||
'Must not claim family insurance "just became available" when it was already eligible at selection time'
|
||||
);
|
||||
}
|
||||
|
||||
public function testProcessFieldRecordsIneligibilityWhenFamilyCompositionExistsButNoPriceTierMatches(): void
|
||||
{
|
||||
// Regression: family composition (adult + child) alone isn't enough - a family
|
||||
// insurance product must actually match the current total price for it to count
|
||||
// as "eligible". If it doesn't, the applicant's choice was genuinely made while
|
||||
// family insurance was NOT selectable, even though isFamilyBooking() is already true.
|
||||
$nonFamilyInsurance = $this->createInsurance('1');
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
|
||||
$familyInsurance = $this->createInsurance('2');
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2025-08-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2025-08-08');
|
||||
$travel->insurances = [$nonFamilyInsurance, $familyInsurance];
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
|
||||
$child = new ParticipantDto();
|
||||
$child->index = 1;
|
||||
$child->dateOfBirth = new \DateTimeImmutable('2015-01-01');
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $child];
|
||||
|
||||
$this->priceCalculatorService->method('calculateTotalBookingPriceExcludingInsurance')->willReturn(500.0);
|
||||
$this->insuranceService->method('getEligibleInsurances')->willReturnCallback(
|
||||
// No family insurance matches the current price tier, even though the
|
||||
// participant composition already qualifies as a family booking.
|
||||
fn (array $insurances) => array_values(array_filter($insurances, fn ($i) => false === $i->familyInsurance))
|
||||
);
|
||||
|
||||
$this->handler->processField(['insurance' => '1'], $bookingDto, 0);
|
||||
|
||||
$this->assertTrue(
|
||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible,
|
||||
'Family composition alone must not count as eligible - no family insurance actually matched the price'
|
||||
);
|
||||
}
|
||||
|
||||
public function testProcessFieldDoesNotNotifyWhenApplicantSwitchesToFamilyInsuranceInSameSubmission(): void
|
||||
{
|
||||
$familyInsurance = $this->createInsurance('2');
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$nonFamilyInsurance = $this->createInsurance('1');
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2025-08-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2025-08-08');
|
||||
$travel->insurances = [$nonFamilyInsurance, $familyInsurance];
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
$applicant->insurance = $nonFamilyInsurance;
|
||||
|
||||
$child = new ParticipantDto();
|
||||
$child->index = 1;
|
||||
$child->dateOfBirth = new \DateTimeImmutable('2015-01-01');
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $child];
|
||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible = true;
|
||||
|
||||
$this->insuranceService->method('getEligibleInsurances')->willReturn([$familyInsurance]);
|
||||
|
||||
// Applicant's own submission switches them to family insurance in this same request
|
||||
$this->handler->processField(['insurance' => '2'], $bookingDto, 0);
|
||||
|
||||
$this->assertSame($familyInsurance, $applicant->insurance);
|
||||
$this->assertEmpty($applicant->notifications, 'Must not show a stale "please recheck" hint for a choice this submission already made');
|
||||
}
|
||||
|
||||
public function testProcessFieldDoesNotNotifyWhenHintAlreadyShown(): void
|
||||
{
|
||||
$bookingDto = $this->createFamilyBookingDtoWithNonFamilyApplicantInsurance();
|
||||
$bookingDto->familyInsuranceHintShown = true;
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
|
||||
$this->priceCalculatorService->method('calculateTotalBookingPriceExcludingInsurance')->willReturn(500.0);
|
||||
$this->insuranceService->method('getEligibleInsurances')->willReturn([$this->createInsurance('2')]);
|
||||
|
||||
$this->handler->processField([], $bookingDto, 1);
|
||||
|
||||
$this->assertEmpty($applicant->notifications, 'Hint must not repeat once already shown');
|
||||
}
|
||||
|
||||
public function testProcessFieldDoesNotNotifyWhenApplicantHasNoInsurance(): void
|
||||
{
|
||||
$bookingDto = $this->createFamilyBookingDtoWithNonFamilyApplicantInsurance();
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
$applicant->insurance = null;
|
||||
|
||||
$this->handler->processField([], $bookingDto, 1);
|
||||
|
||||
$this->assertEmpty($applicant->notifications, 'Nothing to alert about when applicant has not chosen insurance yet');
|
||||
$this->assertFalse($bookingDto->familyInsuranceHintShown);
|
||||
}
|
||||
|
||||
public function testProcessFieldDoesNotNotifyWhenApplicantAlreadyHasFamilyInsurance(): void
|
||||
{
|
||||
$bookingDto = $this->createFamilyBookingDtoWithNonFamilyApplicantInsurance();
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
$familyInsurance = $this->createInsurance('2');
|
||||
$familyInsurance->familyInsurance = true;
|
||||
$applicant->insurance = $familyInsurance;
|
||||
|
||||
$this->handler->processField([], $bookingDto, 1);
|
||||
|
||||
$this->assertEmpty($applicant->notifications, 'Nothing to alert about when applicant already has family insurance');
|
||||
$this->assertFalse($bookingDto->familyInsuranceHintShown);
|
||||
}
|
||||
|
||||
public function testProcessFieldDoesNotNotifyWhenNoEligibleFamilyInsuranceExists(): void
|
||||
{
|
||||
$bookingDto = $this->createFamilyBookingDtoWithNonFamilyApplicantInsurance();
|
||||
$applicant = $bookingDto->getParticipant(0);
|
||||
|
||||
$this->priceCalculatorService->method('calculateTotalBookingPriceExcludingInsurance')->willReturn(500.0);
|
||||
$this->insuranceService->method('getEligibleInsurances')->willReturn([]); // No eligible family insurance
|
||||
|
||||
$this->handler->processField([], $bookingDto, 1);
|
||||
|
||||
$this->assertEmpty($applicant->notifications, 'Nothing to alert about when no family insurance is actually eligible');
|
||||
$this->assertFalse($bookingDto->familyInsuranceHintShown);
|
||||
}
|
||||
|
||||
private function createFamilyBookingDtoWithNonFamilyApplicantInsurance(): BookingDto
|
||||
{
|
||||
$nonFamilyInsurance = $this->createInsurance('1');
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
|
||||
$familyInsurance = $this->createInsurance('2');
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('2025-08-01');
|
||||
$travel->dateTo = new \DateTimeImmutable('2025-08-08');
|
||||
$travel->insurances = [$nonFamilyInsurance, $familyInsurance];
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->dateOfBirth = new \DateTimeImmutable('1990-06-15');
|
||||
$applicant->insurance = $nonFamilyInsurance;
|
||||
|
||||
$child = new ParticipantDto();
|
||||
$child->index = 1;
|
||||
$child->dateOfBirth = new \DateTimeImmutable('2015-01-01');
|
||||
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $child];
|
||||
$bookingDto->applicantInsuranceChosenWhileFamilyIneligible = true;
|
||||
|
||||
return $bookingDto;
|
||||
}
|
||||
|
||||
public function testGetFieldStateModificationsReturnsEmptyArray(): void
|
||||
{
|
||||
$bookingDto = $this->createMockBookingDto();
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Email\Mailer;
|
||||
use App\Entity\Groups\Accommodation;
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Entity\Groups\AccommodationPrice;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Model\AccommodationBookingQueryParams;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
use App\Repository\Groups\AccommodationRepository;
|
||||
@@ -65,7 +66,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
|
||||
$service->issueAccessLinkForDirectBooking($booking);
|
||||
|
||||
@@ -80,7 +81,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$service->issueAccessLinkForDirectBooking($booking);
|
||||
|
||||
@@ -95,7 +96,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
$issuedAt = new \DateTimeImmutable('2026-01-01');
|
||||
$booking->setAccessLinkIssuedAt($issuedAt);
|
||||
|
||||
@@ -104,11 +105,70 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
self::assertSame($issuedAt, $booking->getAccessLinkIssuedAt());
|
||||
}
|
||||
|
||||
public function testIssueAccessLinkSetsTimestampRegardlessOfStatus(): void
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::once())->method('flush');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$service->issueAccessLink($booking);
|
||||
|
||||
self::assertNotNull($booking->getAccessLinkIssuedAt());
|
||||
}
|
||||
|
||||
public function testIssueAccessLinkNoOpsWhenAlreadySet(): void
|
||||
{
|
||||
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$entityManager->expects(self::never())->method('flush');
|
||||
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
$issuedAt = new \DateTimeImmutable('2026-01-01');
|
||||
$booking->setAccessLinkIssuedAt($issuedAt);
|
||||
|
||||
$service->issueAccessLink($booking);
|
||||
|
||||
self::assertSame($issuedAt, $booking->getAccessLinkIssuedAt());
|
||||
}
|
||||
|
||||
public function testSendCustomerConfirmationEmailUsesOfferSubjectForInquiryWithLink(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
$booking->setAccessLinkIssuedAt(new \DateTimeImmutable());
|
||||
|
||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||
$linkSigner->method('sign')->willReturn('https://example.com/offer/signed-link');
|
||||
|
||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator->method('compute')->willReturn(null);
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer
|
||||
->expects(self::once())
|
||||
->method('createAndSendEmail')
|
||||
->with(
|
||||
self::anything(),
|
||||
self::callback(static fn (array $options) => 'Dein Angebot ist bereit' === $options['subject']),
|
||||
);
|
||||
|
||||
$service = $this->createServiceWithAccommodation(mailer: $mailer, linkSigner: $linkSigner, breakdownCalculator: $breakdownCalculator);
|
||||
|
||||
$service->sendCustomerConfirmationEmail($booking);
|
||||
}
|
||||
|
||||
public function testSendCustomerConfirmationEmailAlwaysSendsWithLinkWhenIssued(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
$booking->setAccessLinkIssuedAt(new \DateTimeImmutable());
|
||||
|
||||
$linkSigner = $this->createMock(AccommodationBookingLinkSigner::class);
|
||||
@@ -124,6 +184,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
->with(
|
||||
self::callback(static fn (array $context) => 'https://example.com/offer/signed-link' === $context['accessLink']),
|
||||
self::callback(static fn (array $options) => '[email protected]' === $options['to']
|
||||
&& '[email protected]' === $options['from']
|
||||
&& 'email/accommodation_booking_customer.html.twig' === $options['template']),
|
||||
);
|
||||
|
||||
@@ -136,7 +197,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator->method('compute')->willReturn(null);
|
||||
@@ -159,7 +220,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
|
||||
$breakdownCalculator = $this->createMock(AccommodationBookingBreakdownCalculator::class);
|
||||
$breakdownCalculator->method('compute')->willReturn(null);
|
||||
@@ -179,7 +240,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
$previousIssuedAt = new \DateTimeImmutable('2026-01-01');
|
||||
$booking->setAccessLinkIssuedAt($previousIssuedAt);
|
||||
|
||||
@@ -209,7 +270,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
$entityManager->expects(self::once())->method('flush');
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(true);
|
||||
$booking->setStatus(AccommodationBookingStatus::Inquiry);
|
||||
$booking->setEmail('[email protected]');
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
@@ -219,6 +280,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
->with(
|
||||
self::anything(),
|
||||
self::callback(static fn (array $options) => in_array($options['to'], ['[email protected]', '[email protected]'], true)
|
||||
&& '[email protected]' === $options['from']
|
||||
&& in_array($options['template'], ['email/offer_accepted.html.twig', 'email/offer_accepted_customer.html.twig'], true)),
|
||||
);
|
||||
|
||||
@@ -226,7 +288,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
|
||||
$service->acceptBooking($booking);
|
||||
|
||||
self::assertFalse($booking->isInquiry());
|
||||
self::assertSame(AccommodationBookingStatus::Booking, $booking->getStatus());
|
||||
self::assertNotNull($booking->getAcceptedAt());
|
||||
}
|
||||
|
||||
@@ -241,7 +303,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
$service = $this->createServiceWithAccommodation(entityManager: $entityManager, mailer: $mailer);
|
||||
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
|
||||
$service->acceptBooking($booking);
|
||||
|
||||
@@ -251,7 +313,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
public function testSendOfferAcceptedNotificationEmailLogsAndSwallowsMailerFailures(): void
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
||||
@@ -268,7 +330,7 @@ class AccommodationBookingServiceTest extends TestCase
|
||||
{
|
||||
$booking = new AccommodationBooking();
|
||||
$booking->setEmail('[email protected]');
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
|
||||
$mailer = $this->createMock(Mailer::class);
|
||||
$mailer->method('createAndSendEmail')->willThrowException(new \RuntimeException('SMTP down'));
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\Entity\Groups\AccommodationPrice;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
use App\Service\AccommodationPriceCoverage;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AccommodationPriceCoverageTest extends TestCase
|
||||
{
|
||||
public function testCoversOnlyDaysWithinPricePeriod(): void
|
||||
{
|
||||
$coverage = new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class));
|
||||
|
||||
$covered = $coverage->coveredDatesFor(
|
||||
[$this->price('2026-06-01', '2026-06-09')],
|
||||
new \DateTimeImmutable('2026-06-01'),
|
||||
new \DateTimeImmutable('2026-06-12'),
|
||||
);
|
||||
|
||||
// dateTo is the last night, so 2026-06-09 is still covered
|
||||
self::assertSame([
|
||||
'2026-06-01', '2026-06-02', '2026-06-03', '2026-06-04', '2026-06-05',
|
||||
'2026-06-06', '2026-06-07', '2026-06-08', '2026-06-09',
|
||||
], array_keys($covered));
|
||||
}
|
||||
|
||||
public function testGapBetweenPricePeriodsStaysUncovered(): void
|
||||
{
|
||||
$coverage = new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class));
|
||||
|
||||
$covered = $coverage->coveredDatesFor(
|
||||
[$this->price('2026-06-01', '2026-06-02'), $this->price('2026-06-05', '2026-06-06')],
|
||||
new \DateTimeImmutable('2026-06-01'),
|
||||
new \DateTimeImmutable('2026-06-06'),
|
||||
);
|
||||
|
||||
self::assertSame(
|
||||
['2026-06-01', '2026-06-02', '2026-06-05', '2026-06-06'],
|
||||
array_keys($covered),
|
||||
);
|
||||
}
|
||||
|
||||
public function testNoPricesMeansNoCoverage(): void
|
||||
{
|
||||
$coverage = new AccommodationPriceCoverage($this->createMock(AccommodationPriceRepository::class));
|
||||
|
||||
$covered = $coverage->coveredDatesFor(
|
||||
[],
|
||||
new \DateTimeImmutable('2026-06-01'),
|
||||
new \DateTimeImmutable('2026-06-03'),
|
||||
);
|
||||
|
||||
self::assertSame([], $covered);
|
||||
}
|
||||
|
||||
private function price(string $from, string $to): AccommodationPrice
|
||||
{
|
||||
$price = new AccommodationPrice();
|
||||
$price->setDateFrom(new \DateTimeImmutable($from));
|
||||
$price->setDateTo(new \DateTimeImmutable($to));
|
||||
|
||||
return $price;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Service\AdditionalServiceExclusionResolver;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AdditionalServiceExclusionResolverTest extends TestCase
|
||||
{
|
||||
private const int BASEMENT = 1;
|
||||
private const int FIRST_FLOOR = 2;
|
||||
private const int SECOND_FLOOR = 3;
|
||||
private const int FULL = 4;
|
||||
private const int BREAKFAST = 5;
|
||||
|
||||
public function testSelectingTheExclusiveServiceClearsTheOtherGroupMembers(): void
|
||||
{
|
||||
$resolved = $this->resolve(
|
||||
[self::BASEMENT, self::FIRST_FLOOR, self::FULL],
|
||||
[self::BASEMENT, self::FIRST_FLOOR],
|
||||
);
|
||||
|
||||
self::assertSame([self::FULL], array_values($resolved));
|
||||
}
|
||||
|
||||
public function testSelectingANonExclusiveServiceClearsOnlyTheExclusiveOne(): void
|
||||
{
|
||||
$resolved = $this->resolve(
|
||||
[self::FULL, self::BASEMENT],
|
||||
[self::FULL],
|
||||
);
|
||||
|
||||
self::assertSame([self::BASEMENT], array_values($resolved));
|
||||
}
|
||||
|
||||
public function testNonExclusiveGroupMembersCanBeCombined(): void
|
||||
{
|
||||
$resolved = $this->resolve(
|
||||
[self::BASEMENT, self::FIRST_FLOOR, self::SECOND_FLOOR],
|
||||
[self::BASEMENT],
|
||||
);
|
||||
|
||||
self::assertSame(
|
||||
[self::BASEMENT, self::FIRST_FLOOR, self::SECOND_FLOOR],
|
||||
array_values($resolved),
|
||||
);
|
||||
}
|
||||
|
||||
public function testServicesWithoutAnExclusionGroupAreNeverCleared(): void
|
||||
{
|
||||
$resolved = $this->resolve(
|
||||
[self::BREAKFAST, self::BASEMENT, self::FULL],
|
||||
[self::BREAKFAST, self::BASEMENT],
|
||||
);
|
||||
|
||||
self::assertSame([self::BREAKFAST, self::FULL], array_values($resolved));
|
||||
}
|
||||
|
||||
public function testUnchangedSelectionIsLeftAlone(): void
|
||||
{
|
||||
$resolved = $this->resolve(
|
||||
[self::BASEMENT, self::FULL],
|
||||
[self::BASEMENT, self::FULL],
|
||||
);
|
||||
|
||||
self::assertSame([self::BASEMENT, self::FULL], array_values($resolved));
|
||||
}
|
||||
|
||||
public function testSubmittedArrayKeysArePreserved(): void
|
||||
{
|
||||
$resolver = new AdditionalServiceExclusionResolver();
|
||||
|
||||
$resolved = $resolver->resolve(
|
||||
$this->services(),
|
||||
['Reinigung' => self::FULL, 'Verpflegung' => self::BREAKFAST, 0 => self::BASEMENT],
|
||||
[self::BASEMENT],
|
||||
);
|
||||
|
||||
self::assertSame(
|
||||
['Reinigung' => self::FULL, 'Verpflegung' => self::BREAKFAST],
|
||||
$resolved,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $submittedIds
|
||||
* @param list<int> $previousIds
|
||||
*
|
||||
* @return array<array-key, int>
|
||||
*/
|
||||
private function resolve(array $submittedIds, array $previousIds): array
|
||||
{
|
||||
return (new AdditionalServiceExclusionResolver())->resolve(
|
||||
$this->services(),
|
||||
$submittedIds,
|
||||
$previousIds,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AdditionalService[]
|
||||
*/
|
||||
private function services(): array
|
||||
{
|
||||
return [
|
||||
$this->service(self::BASEMENT, 'Reinigung', false),
|
||||
$this->service(self::FIRST_FLOOR, 'Reinigung', false),
|
||||
$this->service(self::SECOND_FLOOR, 'Reinigung', false),
|
||||
$this->service(self::FULL, 'Reinigung', true),
|
||||
$this->service(self::BREAKFAST, null, false),
|
||||
];
|
||||
}
|
||||
|
||||
private function service(int $id, ?string $exclusionGroup, bool $isExclusive): AdditionalService
|
||||
{
|
||||
$service = new AdditionalService();
|
||||
$service->setExclusionGroup($exclusionGroup);
|
||||
$service->setIsExclusive($isExclusive);
|
||||
|
||||
$property = new \ReflectionProperty(AdditionalService::class, 'id');
|
||||
$property->setValue($service, $id);
|
||||
|
||||
return $service;
|
||||
}
|
||||
}
|
||||
@@ -252,4 +252,86 @@ class BookingPriceCalculatorTest extends TestCase
|
||||
'calculateServiceTotal() must agree with the display breakdown on bulk-insurance bookings'
|
||||
);
|
||||
}
|
||||
|
||||
public function testResolveInsuranceTravelPriceUsesIndividualPriceForNonFamilyInsurance(): void
|
||||
{
|
||||
$skiPass = new Service();
|
||||
$skiPass->price = 50.0;
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->skiPass = $skiPass;
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$nonFamilyInsurance = new Insurance();
|
||||
$nonFamilyInsurance->familyInsurance = false;
|
||||
|
||||
$result = $this->service->resolveInsuranceTravelPrice($bookingDto, 0, $nonFamilyInsurance);
|
||||
|
||||
$this->assertEquals(50.0, $result);
|
||||
}
|
||||
|
||||
public function testResolveInsuranceTravelPriceUsesTotalPriceForFamilyInsuranceOnApplicant(): void
|
||||
{
|
||||
$applicantSkiPass = new Service();
|
||||
$applicantSkiPass->price = 50.0;
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->skiPass = $applicantSkiPass;
|
||||
|
||||
$dependentSkiPass = new Service();
|
||||
$dependentSkiPass->price = 30.0;
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
$dependent->skiPass = $dependentSkiPass;
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$familyInsurance = new Insurance();
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$result = $this->service->resolveInsuranceTravelPrice($bookingDto, 0, $familyInsurance);
|
||||
|
||||
$this->assertEquals(80.0, $result);
|
||||
}
|
||||
|
||||
public function testResolveInsuranceTravelPriceUsesTotalPriceForFamilyInsuranceRegardlessOfParticipantIndex(): void
|
||||
{
|
||||
// Family insurances are restricted to the applicant by InsuranceManager's eligibility
|
||||
// constraints, not by this method - it always resolves the total price for them.
|
||||
$applicantSkiPass = new Service();
|
||||
$applicantSkiPass->price = 50.0;
|
||||
|
||||
$applicant = new ParticipantDto();
|
||||
$applicant->index = 0;
|
||||
$applicant->skiPass = $applicantSkiPass;
|
||||
|
||||
$dependentSkiPass = new Service();
|
||||
$dependentSkiPass->price = 30.0;
|
||||
|
||||
$dependent = new ParticipantDto();
|
||||
$dependent->index = 1;
|
||||
$dependent->skiPass = $dependentSkiPass;
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$applicant, $dependent];
|
||||
|
||||
$familyInsurance = new Insurance();
|
||||
$familyInsurance->familyInsurance = true;
|
||||
|
||||
$result = $this->service->resolveInsuranceTravelPrice($bookingDto, 1, $familyInsurance);
|
||||
|
||||
$this->assertEquals(80.0, $result);
|
||||
}
|
||||
}
|
||||
@@ -425,6 +425,148 @@ class InsuranceManagerTest extends TestCase
|
||||
$this->assertNotNull($result[1]);
|
||||
}
|
||||
|
||||
public function testBatchAssignFamilyInsuranceToApplicantOnly(): void
|
||||
{
|
||||
$booking = $this->createFamilyBooking('2024-08-01', '2024-08-08');
|
||||
|
||||
// Tier matched by total price (300 + 0 = 300, fits 250–400 tier)
|
||||
$lowTierInsurance = $this->createInsurance([
|
||||
'id' => '1',
|
||||
'package' => false,
|
||||
'subType' => 'FAM',
|
||||
'familyInsurance' => true,
|
||||
'travelPriceFrom' => 0.0,
|
||||
'travelPriceTo' => 249.99,
|
||||
]);
|
||||
$correctTierInsurance = $this->createInsurance([
|
||||
'id' => '2',
|
||||
'package' => false,
|
||||
'subType' => 'FAM',
|
||||
'familyInsurance' => true,
|
||||
'travelPriceFrom' => 250.0,
|
||||
'travelPriceTo' => 400.0,
|
||||
]);
|
||||
|
||||
$availableInsurances = [$lowTierInsurance, $correctTierInsurance];
|
||||
// Individual prices: applicant 300, child 0 → total 300
|
||||
$participantPrices = [0 => 300.0, 1 => 0.0];
|
||||
|
||||
$result = $this->service->batchAssignInsuranceToParticipants(
|
||||
$availableInsurances,
|
||||
$correctTierInsurance,
|
||||
$booking,
|
||||
$participantPrices
|
||||
);
|
||||
|
||||
$this->assertCount(2, $result);
|
||||
$this->assertSame($correctTierInsurance, $result[0], 'Applicant should get tier matching total price');
|
||||
$this->assertNull($result[1], 'Non-applicant participants must be cleared for family insurance');
|
||||
}
|
||||
|
||||
public function testFamilyInsuranceIneligibleForNonApplicant(): void
|
||||
{
|
||||
$booking = $this->createFamilyBooking('2024-08-01', '2024-08-08');
|
||||
|
||||
$nonApplicant = $this->createParticipant('2015-01-01'); // child
|
||||
$nonApplicant->index = 1;
|
||||
|
||||
$familyInsurance = $this->createInsurance(['familyInsurance' => true]);
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$familyInsurance], $nonApplicant, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result, 'Family insurance must not be eligible for non-applicant participants');
|
||||
}
|
||||
|
||||
public function testNonFamilyInsuranceEligibleForFamilyBooking(): void
|
||||
{
|
||||
$booking = $this->createFamilyBooking('2024-08-01', '2024-08-08');
|
||||
|
||||
$adult = $this->createParticipant('1990-06-15');
|
||||
$adult->index = 0;
|
||||
$child = $this->createParticipant('2015-01-01');
|
||||
$child->index = 1;
|
||||
|
||||
$nonFamilyInsurance = $this->createInsurance(['familyInsurance' => false]);
|
||||
|
||||
$adultResult = $this->service->getEligibleInsurances([$nonFamilyInsurance], $adult, $booking, 500.0);
|
||||
$childResult = $this->service->getEligibleInsurances([$nonFamilyInsurance], $child, $booking, 500.0);
|
||||
|
||||
$this->assertNotEmpty($adultResult, 'Non-family insurance must be available in family bookings for adults');
|
||||
$this->assertNotEmpty($childResult, 'Non-family insurance must be available in family bookings for children');
|
||||
}
|
||||
|
||||
public function testFamilyInsuranceIneligibleForNonFamilyBooking(): void
|
||||
{
|
||||
// Two adults, no children — not a family booking
|
||||
$booking = $this->createBooking('2024-08-01', '2024-08-08');
|
||||
$adult1 = $this->createParticipant('1990-06-15');
|
||||
$adult1->index = 0;
|
||||
$adult2 = $this->createParticipant('1985-03-10');
|
||||
$adult2->index = 1;
|
||||
$booking->participants = [$adult1, $adult2];
|
||||
|
||||
$familyInsurance = $this->createInsurance(['familyInsurance' => true]);
|
||||
|
||||
$result = $this->service->getEligibleInsurances([$familyInsurance], $adult1, $booking, 500.0);
|
||||
|
||||
$this->assertEmpty($result, 'Family insurance must not be eligible when booking is not a family booking');
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesForParticipantUsesTotalPriceForFamilyInsurance(): void
|
||||
{
|
||||
$booking = $this->createFamilyBooking('2024-08-01', '2024-08-08');
|
||||
$applicant = $booking->participants[0];
|
||||
|
||||
// Only matches the total booking price (450), not the individual price (300)
|
||||
$familyInsurance = $this->createInsurance([
|
||||
'familyInsurance' => true,
|
||||
'travelPriceFrom' => 400.01,
|
||||
'travelPriceTo' => 600.0,
|
||||
]);
|
||||
|
||||
$nonFamilyInsurance = $this->createInsurance([
|
||||
'familyInsurance' => false,
|
||||
'travelPriceFrom' => 0.0,
|
||||
'travelPriceTo' => 350.0,
|
||||
]);
|
||||
|
||||
$result = $this->service->getEligibleInsurancesForParticipant(
|
||||
[$familyInsurance, $nonFamilyInsurance],
|
||||
$applicant,
|
||||
$booking,
|
||||
300.0,
|
||||
450.0
|
||||
);
|
||||
|
||||
$ids = array_map(fn (Insurance $insurance) => spl_object_id($insurance), $result);
|
||||
|
||||
$this->assertContains(spl_object_id($familyInsurance), $ids, 'Family insurance must be evaluated against the total booking price');
|
||||
$this->assertContains(spl_object_id($nonFamilyInsurance), $ids, 'Non-family insurance must be evaluated against the individual price');
|
||||
}
|
||||
|
||||
public function testGetEligibleInsurancesForParticipantSkipsFamilyPricingWhenNoneAvailable(): void
|
||||
{
|
||||
$booking = $this->createFamilyBooking('2024-08-01', '2024-08-08');
|
||||
$applicant = $booking->participants[0];
|
||||
|
||||
$nonFamilyInsurance = $this->createInsurance([
|
||||
'familyInsurance' => false,
|
||||
'travelPriceFrom' => 0.0,
|
||||
'travelPriceTo' => 350.0,
|
||||
]);
|
||||
|
||||
$result = $this->service->getEligibleInsurancesForParticipant(
|
||||
[$nonFamilyInsurance],
|
||||
$applicant,
|
||||
$booking,
|
||||
300.0,
|
||||
450.0
|
||||
);
|
||||
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertSame($nonFamilyInsurance, $result[0]);
|
||||
}
|
||||
|
||||
private function createParticipant(string $dateOfBirth): ParticipantDto
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
@@ -442,6 +584,20 @@ class InsuranceManagerTest extends TestCase
|
||||
return $booking;
|
||||
}
|
||||
|
||||
private function createFamilyBooking(string $travelDateFrom, string $travelDateTo): BookingDto
|
||||
{
|
||||
$booking = $this->createBooking($travelDateFrom, $travelDateTo);
|
||||
|
||||
$adult = $this->createParticipant('1990-06-15'); // 34 years old
|
||||
$adult->index = 0;
|
||||
$child = $this->createParticipant('2015-01-01'); // 9 years old
|
||||
$child->index = 1;
|
||||
|
||||
$booking->participants = [$adult, $child];
|
||||
|
||||
return $booking;
|
||||
}
|
||||
|
||||
private function createTravel(string $dateFrom, string $dateTo): Travel
|
||||
{
|
||||
$travel = new Travel();
|
||||
|
||||
@@ -14,6 +14,11 @@ service:
|
||||
separator: ' und '
|
||||
|
||||
enum:
|
||||
accommodation_country:
|
||||
DE: Deutschland
|
||||
AT: Österreich
|
||||
CH: Schweiz
|
||||
IT: Italien
|
||||
additional_service:
|
||||
flat: pauschal
|
||||
per_person: pro Person
|
||||
|
||||
Reference in new issue
Block a user