Reduction of amount for siblings implemented

This commit is contained in:
2026-04-25 22:31:38 +02:00
parent 8348f677a5
commit 21be212129
11 changed files with 68 additions and 8 deletions

View File

@@ -12,6 +12,9 @@ class SetParticipationFeesCommand {
public function execute() : SetParticipationFeesResponse { public function execute() : SetParticipationFeesResponse {
$response = new SetParticipationFeesResponse(); $response = new SetParticipationFeesResponse();
$this->request->event->sibling_reduction = $this->request->siblingReduction;
$this->request->event->save();
$this->cleanBefore(); $this->cleanBefore();
$this->request->event->participationFee1()->associate(EventParticipationFee::create([ $this->request->event->participationFee1()->associate(EventParticipationFee::create([

View File

@@ -12,13 +12,16 @@ class SetParticipationFeesRequest {
public ?array $participationFeeThird; public ?array $participationFeeThird;
public ?array $participationFeeFourth; 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->event = $event;
$this->participationFeeFirst = $participationFeeFirst; $this->participationFeeFirst = $participationFeeFirst;
$this->participationFeeSecond = null; $this->participationFeeSecond = null;
$this->participationFeeThird = null; $this->participationFeeThird = null;
$this->participationFeeFourth = null; $this->participationFeeFourth = null;
$this->siblingReduction = $siblingReduction;
} }
} }

View File

@@ -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 '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')) { if ($request->input('pft_2_active')) {
$participationFeeRequest->participationFeeSecond = [ $participationFeeRequest->participationFeeSecond = [

View File

@@ -70,6 +70,8 @@ class SignupController extends CommonController {
$event = $this->events->getById($eventId, false); $event = $this->events->getById($eventId, false);
$eventResource = $event->toResource(); $eventResource = $event->toResource();
$registrationData = $request->input('registration_data'); $registrationData = $request->input('registration_data');
$siblingReduction = $registrationData['sibling'] === 'true';
$arrival = \DateTime::createFromFormat('Y-m-d', $registrationData['arrival']); $arrival = \DateTime::createFromFormat('Y-m-d', $registrationData['arrival']);
$departure = \DateTime::createFromFormat('Y-m-d', $registrationData['departure']); $departure = \DateTime::createFromFormat('Y-m-d', $registrationData['departure']);
@@ -81,16 +83,17 @@ class SignupController extends CommonController {
$registrationData['nachname'], $registrationData['nachname'],
$registrationData['email_1'], $registrationData['email_1'],
DateTime::createFromFormat('Y-m-d', $registrationData['geburtsdatum'])); DateTime::createFromFormat('Y-m-d', $registrationData['geburtsdatum']));
/*
if ($doubleCheckEventRegistrationProvider->isRegistered()) { if ($doubleCheckEventRegistrationProvider->isRegistered()) {
return response()->json(['status' => 'exists']); return response()->json(['status' => 'exists']);
}*/ }
$amount = $eventResource->calculateAmount( $amount = $eventResource->calculateAmount(
$registrationData['participationType'], $registrationData['participationType'],
$registrationData['beitrag'], $registrationData['beitrag'],
$arrival, $arrival,
$departure $departure,
$siblingReduction
); );
$signupRequest = new SignUpRequest( $signupRequest = new SignUpRequest(
@@ -164,12 +167,15 @@ class SignupController extends CommonController {
public function calculateAmount(int $eventId, Request $request, bool $forDisplay = true) : JsonResponse | float { public function calculateAmount(int $eventId, Request $request, bool $forDisplay = true) : JsonResponse | float {
$event = $this->events->getById($eventId, false)->toResource(); $event = $this->events->getById($eventId, false)->toResource();
$siblingReduction = $request->input('sibling') === 'true';
return response()->json(['amount' => return response()->json(['amount' =>
$event->calculateAmount( $event->calculateAmount(
$request->input('participationType'), $request->input('participationType'),
$request->input('beitrag'), $request->input('beitrag'),
\DateTime::createFromFormat('Y-m-d', $request->input('arrival')), \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() )->toString()
]); ]);
} }

View File

@@ -38,9 +38,12 @@
"pft_4_description": props.event.participationFee_4.description, "pft_4_description": props.event.participationFee_4.description,
'maxAmount': props.event.maxAmount, 'maxAmount': props.event.maxAmount,
'sibling_reduction': props.event.siblingReduction,
}) })
console.log(formData)
function validateInput() { function validateInput() {
var noErrors = true; var noErrors = true;
@@ -103,6 +106,7 @@
pft_4_description: formData.pft_4_description, pft_4_description: formData.pft_4_description,
maxAmount: formData.maxAmount, maxAmount: formData.maxAmount,
sibling_reduction: formData.sibling_reduction,
} }
}) })
@@ -277,7 +281,14 @@
</tr> </tr>
<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" /> <input type="button" value="Speichern" @click="saveParticipationFees" />
</td> </td>
</tr> </tr>

View File

@@ -30,6 +30,7 @@ console.log(participantData)
telefon_2: '', telefon_2: '',
email_2: '', email_2: '',
badeerlaubnis: '-1', badeerlaubnis: '-1',
sibling: '-1',
first_aid: '-1', first_aid: '-1',
participant_group: '', participant_group: '',
beitrag: 'regular', beitrag: 'regular',
@@ -66,6 +67,7 @@ console.log(participantData)
addons: selectedAddons, addons: selectedAddons,
participationType: formData.participationType, participationType: formData.participationType,
beitrag: formData.beitrag, beitrag: formData.beitrag,
sibling: formData.sibling,
}) })
summaryAmount.value = res.data.amount summaryAmount.value = res.data.amount
} finally { } finally {

View File

@@ -27,6 +27,11 @@ const next = () => {
hasError = true hasError = true
} }
if (props.event.siblingReduction && props.formData.sibling === '-1') {
errors.sibling = 'Bitte eine Entscheidung treffen.'
}
if (!props.formData.telefon_2) { if (!props.formData.telefon_2) {
errors.telefon_2 = 'Bitte eine Telefonnummer angeben.' errors.telefon_2 = 'Bitte eine Telefonnummer angeben.'
hasError = true hasError = true
@@ -110,6 +115,20 @@ const next = () => {
<ErrorText :message="errors.first_aid" /> <ErrorText :message="errors.first_aid" />
</td> </td>
</tr> </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> <tr>
<td></td> <td></td>
<td> <td>

View File

@@ -20,6 +20,7 @@ const nextStep = () => {
const hasAddons = (props.event.addons?.length ?? 0) > 0 const hasAddons = (props.event.addons?.length ?? 0) > 0
emit('next', hasAddons ? 6 : 7) emit('next', hasAddons ? 6 : 7)
} }
console.log(props.formData, props.event)
</script> </script>
<template> <template>
@@ -113,6 +114,9 @@ const nextStep = () => {
</td> </td>
</tr> </tr>
</table> </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"> <div class="btn-row">
<button type="button" class="btn-secondary" @click="emit('back', 3)"> Zurück</button> <button type="button" class="btn-secondary" @click="emit('back', 3)"> Zurück</button>

View File

@@ -37,6 +37,7 @@ use Illuminate\Http\Resources\Json\JsonResource;
* @property string $registration_link * @property string $registration_link
* @property boolean $pay_per_day * @property boolean $pay_per_day
* @property boolean $pay_direct * @property boolean $pay_direct
* @property boolean $sibling_reduction
* @property boolean $send_weekly_report * @property boolean $send_weekly_report
* @property int $participation_fee_1 * @property int $participation_fee_1
* @property int $participation_fee_2 * @property int $participation_fee_2
@@ -73,6 +74,7 @@ class Event extends InstancedModel
'registration_link', 'registration_link',
'pay_per_day', 'pay_per_day',
'pay_direct', 'pay_direct',
'sibling_reduction',
'send_weekly_report', 'send_weekly_report',
'participation_fee_1', 'participation_fee_1',
'participation_fee_2', 'participation_fee_2',
@@ -104,6 +106,8 @@ class Event extends InstancedModel
'support_per_person' => AmountCast::class, 'support_per_person' => AmountCast::class,
'support_flat' => AmountCast::class, 'support_flat' => AmountCast::class,
'total_max_amount' => AmountCast::class, 'total_max_amount' => AmountCast::class,
'sibling_reduction' => 'boolean',
]; ];
public function tenant(): BelongsTo public function tenant(): BelongsTo

View File

@@ -74,6 +74,7 @@ class EventResource extends JsonResource{
$returnArray['nameShort'] = substr($returnArray['nameShort'], 8, 13) . '...'; $returnArray['nameShort'] = substr($returnArray['nameShort'], 8, 13) . '...';
} }
$returnArray['siblingReduction'] = $this->event->sibling_reduction ?? true;
$returnArray['costUnit'] = new CostUnitResource($this->event->costUnit()->first())->toArray(true); $returnArray['costUnit'] = new CostUnitResource($this->event->costUnit()->first())->toArray(true);
$returnArray['solidarityPayment'] = $this->event->participation_fee_type === ParticipationFeeType::PARTICIPATION_FEE_TYPE_SOLIDARITY; $returnArray['solidarityPayment'] = $this->event->participation_fee_type === ParticipationFeeType::PARTICIPATION_FEE_TYPE_SOLIDARITY;
$returnArray['payPerDay'] = $this->event->pay_per_day; $returnArray['payPerDay'] = $this->event->pay_per_day;
@@ -301,7 +302,8 @@ class EventResource extends JsonResource{
string $participationType, string $participationType,
string $feeType, string $feeType,
DateTime $arrival, DateTime $arrival,
DateTime $departure DateTime $departure,
bool $hasSibling
) : Amount { ) : Amount {
$fee = collect([ $fee = collect([
$this->event->participationFee1, $this->event->participationFee1,
@@ -324,6 +326,10 @@ class EventResource extends JsonResource{
$basicFee = $basicFee->multiply($days); $basicFee = $basicFee->multiply($days);
} }
if ($hasSibling && $this->event->sibling_reduction) {
$basicFee = $basicFee->multiply(0.5);
}
return $basicFee; return $basicFee;
} }
} }

View File

@@ -59,6 +59,7 @@ return new class extends Migration {
$table->string('registration_link')->nullable(); $table->string('registration_link')->nullable();
$table->boolean('pay_per_day'); $table->boolean('pay_per_day');
$table->boolean('pay_direct'); $table->boolean('pay_direct');
$table->boolean('sibling_reduction')->default(false);
$table->boolean('send_weekly_report')->default(true); $table->boolean('send_weekly_report')->default(true);
$table->foreignId('participation_fee_1')->nullable()->constrained('event_participation_fees', 'id')->nullOnDelete()->cascadeOnUpdate(); $table->foreignId('participation_fee_1')->nullable()->constrained('event_participation_fees', 'id')->nullOnDelete()->cascadeOnUpdate();
$table->foreignId('participation_fee_2')->nullable()->constrained('event_participation_fees', 'id')->nullOnDelete()->cascadeOnUpdate(); $table->foreignId('participation_fee_2')->nullable()->constrained('event_participation_fees', 'id')->nullOnDelete()->cascadeOnUpdate();