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>
|
||||
|
||||
@@ -37,6 +37,7 @@ use Illuminate\Http\Resources\Json\JsonResource;
|
||||
* @property string $registration_link
|
||||
* @property boolean $pay_per_day
|
||||
* @property boolean $pay_direct
|
||||
* @property boolean $sibling_reduction
|
||||
* @property boolean $send_weekly_report
|
||||
* @property int $participation_fee_1
|
||||
* @property int $participation_fee_2
|
||||
@@ -73,6 +74,7 @@ class Event extends InstancedModel
|
||||
'registration_link',
|
||||
'pay_per_day',
|
||||
'pay_direct',
|
||||
'sibling_reduction',
|
||||
'send_weekly_report',
|
||||
'participation_fee_1',
|
||||
'participation_fee_2',
|
||||
@@ -104,6 +106,8 @@ class Event extends InstancedModel
|
||||
'support_per_person' => AmountCast::class,
|
||||
'support_flat' => AmountCast::class,
|
||||
'total_max_amount' => AmountCast::class,
|
||||
|
||||
'sibling_reduction' => 'boolean',
|
||||
];
|
||||
|
||||
public function tenant(): BelongsTo
|
||||
|
||||
@@ -74,6 +74,7 @@ class EventResource extends JsonResource{
|
||||
$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['solidarityPayment'] = $this->event->participation_fee_type === ParticipationFeeType::PARTICIPATION_FEE_TYPE_SOLIDARITY;
|
||||
$returnArray['payPerDay'] = $this->event->pay_per_day;
|
||||
@@ -301,7 +302,8 @@ class EventResource extends JsonResource{
|
||||
string $participationType,
|
||||
string $feeType,
|
||||
DateTime $arrival,
|
||||
DateTime $departure
|
||||
DateTime $departure,
|
||||
bool $hasSibling
|
||||
) : Amount {
|
||||
$fee = collect([
|
||||
$this->event->participationFee1,
|
||||
@@ -324,6 +326,10 @@ class EventResource extends JsonResource{
|
||||
$basicFee = $basicFee->multiply($days);
|
||||
}
|
||||
|
||||
if ($hasSibling && $this->event->sibling_reduction) {
|
||||
$basicFee = $basicFee->multiply(0.5);
|
||||
}
|
||||
|
||||
return $basicFee;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ return new class extends Migration {
|
||||
$table->string('registration_link')->nullable();
|
||||
$table->boolean('pay_per_day');
|
||||
$table->boolean('pay_direct');
|
||||
$table->boolean('sibling_reduction')->default(false);
|
||||
$table->boolean('send_weekly_report')->default(true);
|
||||
$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();
|
||||
|
||||
Reference in New Issue
Block a user