Event addons bookable
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Domains\Event\Controllers;
|
||||
|
||||
use App\Domains\Event\Actions\SetEventAddons\SetEventAddonsCommand;
|
||||
use App\Domains\Event\Actions\SetEventAddons\SetEventAddonsRequest;
|
||||
use App\Domains\Event\Actions\SetParticipationFees\SetParticipationFeesCommand;
|
||||
use App\Domains\Event\Actions\SetParticipationFees\SetParticipationFeesRequest;
|
||||
use App\Domains\Event\Actions\SetParticipationOptions\SetParticipationOptionsCommand;
|
||||
@@ -155,6 +157,17 @@ class DetailsController extends CommonController {
|
||||
return response()->json(['status' => $response->success ? 'success' : 'error', 'message' => $response->message]);
|
||||
}
|
||||
|
||||
public function updateEventAddons(int $eventId, Request $request): JsonResponse
|
||||
{
|
||||
$event = $this->events->getById($eventId);
|
||||
|
||||
$setRequest = new SetEventAddonsRequest($event, (array)$request->input('addons', []));
|
||||
$setCommand = new SetEventAddonsCommand($setRequest);
|
||||
$response = $setCommand->execute();
|
||||
|
||||
return response()->json(['status' => $response->success ? 'success' : 'error', 'message' => $response->message]);
|
||||
}
|
||||
|
||||
public function downloadPdfList(string $eventId, string $listType, Request $request): Response
|
||||
{
|
||||
$event = $this->events->getByIdentifier($eventId);
|
||||
|
||||
@@ -45,6 +45,7 @@ class ParticipantUpdateController extends CommonController {
|
||||
amountExpected: $request->input('amountExpected'),
|
||||
cocStatus: $request->input('cocStatus'),
|
||||
participationOptions: $request->has('participationOptions') ? (array)$request->input('participationOptions') : null,
|
||||
selectedAddons: $request->has('selectedAddons') ? (array)$request->input('selectedAddons') : null,
|
||||
);
|
||||
|
||||
$command = new UpdateParticipantCommand($updateRequest);
|
||||
|
||||
@@ -104,6 +104,11 @@ class SignupController extends CommonController {
|
||||
$siblingReduction
|
||||
);
|
||||
|
||||
// Gewählte Zusätze (Event-Addons) auflösen und auf den Gesamtbetrag aufaddieren.
|
||||
$selectedAddonKeys = array_keys(array_filter((array)$request->input('addons', []), fn($v) => (bool)$v));
|
||||
$addonResolution = $eventResource->resolveAddons($selectedAddonKeys, $arrival, $departure);
|
||||
$amount->addAmount($addonResolution['total']);
|
||||
|
||||
$signupRequest = new SignUpRequest(
|
||||
$event,
|
||||
$registrationData['userId'] ?? null,
|
||||
@@ -143,6 +148,7 @@ class SignupController extends CommonController {
|
||||
$registrationData['paymentMethod'] ?? null,
|
||||
(array)($registrationData['paymentOptions'] ?? []),
|
||||
(array)($registrationData['participationOptions'] ?? []),
|
||||
$addonResolution['items'],
|
||||
);
|
||||
|
||||
$signupCommand = new SignUpCommand($signupRequest);
|
||||
@@ -185,14 +191,22 @@ class SignupController extends CommonController {
|
||||
|
||||
$siblingReduction = $request->input('sibling') === 'true';
|
||||
|
||||
$arrival = \DateTime::createFromFormat('Y-m-d', $request->input('arrival'));
|
||||
$departure = \DateTime::createFromFormat('Y-m-d', $request->input('departure'));
|
||||
|
||||
$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')),
|
||||
$arrival,
|
||||
$departure,
|
||||
$siblingReduction
|
||||
);
|
||||
|
||||
// Gewählte Zusätze immer einrechnen -- so enthält der finale Anzeigebetrag (und der Bestätigungstext)
|
||||
// stets die Addons und der Zahlungsschritt wird nur bei Gesamt 0 € übersprungen.
|
||||
$selectedAddonKeys = array_keys(array_filter((array)$request->input('addons', []), fn($v) => (bool)$v));
|
||||
$amount->addAmount($event->resolveAddons($selectedAddonKeys, $arrival, $departure)['total']);
|
||||
|
||||
// amountValue (numerisch) steuert im Frontend das Überspringen des Zahlungsart-Schritts bei 0 €.
|
||||
return response()->json([
|
||||
'amount' => $amount->toString(),
|
||||
|
||||
Reference in New Issue
Block a user