Reduction of amount for siblings implemented
This commit is contained in:
@@ -12,6 +12,9 @@ class SetParticipationFeesCommand {
|
||||
|
||||
public function execute() : SetParticipationFeesResponse {
|
||||
$response = new SetParticipationFeesResponse();
|
||||
$this->request->event->sibling_reduction = $this->request->siblingReduction;
|
||||
$this->request->event->save();
|
||||
|
||||
$this->cleanBefore();
|
||||
|
||||
$this->request->event->participationFee1()->associate(EventParticipationFee::create([
|
||||
|
||||
@@ -12,13 +12,16 @@ class SetParticipationFeesRequest {
|
||||
public ?array $participationFeeThird;
|
||||
public ?array $participationFeeFourth;
|
||||
|
||||
public bool $siblingReduction;
|
||||
|
||||
public function __construct(Event $event, array $participationFeeFirst) {
|
||||
|
||||
public function __construct(Event $event, array $participationFeeFirst, bool $siblingReduction) {
|
||||
$this->event = $event;
|
||||
$this->participationFeeFirst = $participationFeeFirst;
|
||||
$this->participationFeeSecond = null;
|
||||
$this->participationFeeThird = null;
|
||||
$this->participationFeeFourth = null;
|
||||
$this->siblingReduction = $siblingReduction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,7 +87,8 @@ class DetailsController extends CommonController {
|
||||
'amount_solidarity' => null !== $request->input('pft_1_amount_solidarity') ? Amount::fromString($request->input('pft_1_amount_solidarity')) : null
|
||||
];
|
||||
|
||||
$participationFeeRequest = new SetParticipationFeesRequest($event, $participationFeeFirst);
|
||||
$siblingReduction = $request->input('sibling_reduction') ?? false;
|
||||
$participationFeeRequest = new SetParticipationFeesRequest($event, $participationFeeFirst, $siblingReduction);
|
||||
|
||||
if ($request->input('pft_2_active')) {
|
||||
$participationFeeRequest->participationFeeSecond = [
|
||||
|
||||
@@ -70,6 +70,8 @@ class SignupController extends CommonController {
|
||||
$event = $this->events->getById($eventId, false);
|
||||
$eventResource = $event->toResource();
|
||||
$registrationData = $request->input('registration_data');
|
||||
$siblingReduction = $registrationData['sibling'] === 'true';
|
||||
|
||||
|
||||
$arrival = \DateTime::createFromFormat('Y-m-d', $registrationData['arrival']);
|
||||
$departure = \DateTime::createFromFormat('Y-m-d', $registrationData['departure']);
|
||||
@@ -81,16 +83,17 @@ class SignupController extends CommonController {
|
||||
$registrationData['nachname'],
|
||||
$registrationData['email_1'],
|
||||
DateTime::createFromFormat('Y-m-d', $registrationData['geburtsdatum']));
|
||||
/*
|
||||
|
||||
if ($doubleCheckEventRegistrationProvider->isRegistered()) {
|
||||
return response()->json(['status' => 'exists']);
|
||||
}*/
|
||||
}
|
||||
|
||||
$amount = $eventResource->calculateAmount(
|
||||
$registrationData['participationType'],
|
||||
$registrationData['beitrag'],
|
||||
$arrival,
|
||||
$departure
|
||||
$departure,
|
||||
$siblingReduction
|
||||
);
|
||||
|
||||
$signupRequest = new SignUpRequest(
|
||||
@@ -164,12 +167,15 @@ class SignupController extends CommonController {
|
||||
public function calculateAmount(int $eventId, Request $request, bool $forDisplay = true) : JsonResponse | float {
|
||||
$event = $this->events->getById($eventId, false)->toResource();
|
||||
|
||||
$siblingReduction = $request->input('sibling') === 'true';
|
||||
|
||||
return response()->json(['amount' =>
|
||||
$event->calculateAmount(
|
||||
$request->input('participationType'),
|
||||
$request->input('beitrag'),
|
||||
\DateTime::createFromFormat('Y-m-d', $request->input('arrival')),
|
||||
\DateTime::createFromFormat('Y-m-d', $request->input('departure'))
|
||||
\DateTime::createFromFormat('Y-m-d', $request->input('departure')),
|
||||
$siblingReduction
|
||||
)->toString()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -38,9 +38,12 @@
|
||||
"pft_4_description": props.event.participationFee_4.description,
|
||||
|
||||
'maxAmount': props.event.maxAmount,
|
||||
'sibling_reduction': props.event.siblingReduction,
|
||||
|
||||
})
|
||||
|
||||
console.log(formData)
|
||||
|
||||
function validateInput() {
|
||||
var noErrors = true;
|
||||
|
||||
@@ -103,6 +106,7 @@
|
||||
pft_4_description: formData.pft_4_description,
|
||||
|
||||
maxAmount: formData.maxAmount,
|
||||
sibling_reduction: formData.sibling_reduction,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -277,7 +281,14 @@
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<td colspan="2">
|
||||
<input type="checkbox" v-model="formData.sibling_reduction" id="sibling_reduction" :checked="formData.sibling_reduction" />
|
||||
<label for="sibling_reduction">50% Preisnachlass für Geschwisterkinder gewähren</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="4" style="padding-top: 20px;">
|
||||
<input type="button" value="Speichern" @click="saveParticipationFees" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -30,6 +30,7 @@ console.log(participantData)
|
||||
telefon_2: '',
|
||||
email_2: '',
|
||||
badeerlaubnis: '-1',
|
||||
sibling: '-1',
|
||||
first_aid: '-1',
|
||||
participant_group: '',
|
||||
beitrag: 'regular',
|
||||
@@ -66,6 +67,7 @@ console.log(participantData)
|
||||
addons: selectedAddons,
|
||||
participationType: formData.participationType,
|
||||
beitrag: formData.beitrag,
|
||||
sibling: formData.sibling,
|
||||
})
|
||||
summaryAmount.value = res.data.amount
|
||||
} finally {
|
||||
|
||||
@@ -27,6 +27,11 @@ const next = () => {
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (props.event.siblingReduction && props.formData.sibling === '-1') {
|
||||
errors.sibling = 'Bitte eine Entscheidung treffen.'
|
||||
}
|
||||
|
||||
|
||||
if (!props.formData.telefon_2) {
|
||||
errors.telefon_2 = 'Bitte eine Telefonnummer angeben.'
|
||||
hasError = true
|
||||
@@ -110,6 +115,20 @@ const next = () => {
|
||||
<ErrorText :message="errors.first_aid" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="event.siblingReduction">
|
||||
<td>Ist bereits ein vollzahlendes Geschwisterkind für die Veranstaltung angemeldet:*</td>
|
||||
<td>
|
||||
<select v-model="formData.sibling">
|
||||
<option value="-1">Bitte wählen</option>
|
||||
<option value="true">Ja</option>
|
||||
<option value="false">Nein</option>
|
||||
</select><br />
|
||||
<span style="font-size: 0.8rem; color: #6b7280;">
|
||||
Ist bereits ein vollzahlendes Geschwisterkind angemeldet, reduziert sich der Teilnahmebeitrag um 50%. Der Preisnachlass wird am Ende der Anmeldung automatisch abgezogen.
|
||||
</span>
|
||||
<ErrorText :message="errors.sibling" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
|
||||
@@ -20,6 +20,7 @@ const nextStep = () => {
|
||||
const hasAddons = (props.event.addons?.length ?? 0) > 0
|
||||
emit('next', hasAddons ? 6 : 7)
|
||||
}
|
||||
console.log(props.formData, props.event)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -113,6 +114,9 @@ const nextStep = () => {
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p v-if="props.event.siblingReduction && props.formData.sibling === 'true'">
|
||||
Der Preisnachlass in Höhe von 50% wird am Ende des Anmeldeprozesses berechnet.
|
||||
</p>
|
||||
|
||||
<div class="btn-row">
|
||||
<button type="button" class="btn-secondary" @click="emit('back', 3)">← Zurück</button>
|
||||
|
||||
Reference in New Issue
Block a user