Basic implementation of payment methods

This commit is contained in:
2026-07-28 15:50:58 +02:00
parent afc91545a9
commit 6c9281516e
39 changed files with 749 additions and 24 deletions
@@ -3,10 +3,12 @@
namespace App\Domains\Event\Actions\CreateEvent;
use App\Enumerations\EatingHabit;
use App\Models\AvailablePaymentMethod;
use App\Models\Event;
use App\Models\Tenant;
use App\RelationModels\EventEatingHabits;
use App\RelationModels\EventLocalGroups;
use App\RelationModels\EventPaymentMethods;
use Illuminate\Support\Str;
class CreateEventCommand {
@@ -41,7 +43,7 @@ class CreateEventCommand {
'account_iban' => $this->request->accountIban,
'participation_fee_type' => $this->request->participationFeeType->slug,
'pay_per_day' => $this->request->payPerDay,
'pay_direct' => $this->request->payDirect,
'pay_direct' => false,
'total_max_amount' => 0,
'support_per_person' => 0,
'support_flat' => 0,
@@ -58,6 +60,13 @@ class CreateEventCommand {
'eating_habit_id' => EatingHabit::where('slug', EatingHabit::EATING_HABIT_VEGETARIAN)->first()->id,
]);
foreach (AvailablePaymentMethod::where('active', true)->get() as $availablePaymentMethod) {
EventPaymentMethods::create([
'event_id' => $event->id,
'available_payment_method_id' => $availablePaymentMethod->id,
]);
}
if (app('tenant')->slug === 'lv') {
foreach(Tenant::where(['is_active_local_group' => true])->get() as $tenant) {
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => $tenant->id]);
@@ -19,9 +19,8 @@ class CreateEventRequest {
public string $accountOwner;
public string $accountIban;
public bool $payPerDay;
public bool $payDirect;
public function __construct(string $name, string $location, string $postalCode, string $email, DateTime $begin, DateTime $end, DateTime $earlyBirdEnd, DateTime $registrationFinalEnd, int $earlyBirdEndAmountIncrease, ParticipationFeeType $participationFeeType, string $accountOwner, string $accountIban, bool $payPerDay, bool $payDirect) {
public function __construct(string $name, string $location, string $postalCode, string $email, DateTime $begin, DateTime $end, DateTime $earlyBirdEnd, DateTime $registrationFinalEnd, int $earlyBirdEndAmountIncrease, ParticipationFeeType $participationFeeType, string $accountOwner, string $accountIban, bool $payPerDay) {
$this->name = $name;
$this->location = $location;
$this->postalCode = $postalCode;
@@ -35,6 +34,5 @@ class CreateEventRequest {
$this->accountOwner = $accountOwner;
$this->accountIban = $accountIban;
$this->payPerDay = $payPerDay;
$this->payDirect = $payDirect;
}
}
@@ -21,6 +21,8 @@ class SignUpCommand {
};
$participantAge = new Age($this->request->birthday);
$paymentMethod = $this->request->event->paymentMethods()->where('active', true)->first();
$response->participant = $this->request->event->participants()->create(
[
'tenant' => $this->request->event->tenant,
@@ -60,6 +62,7 @@ class SignUpCommand {
'notes' => $this->request->notes,
'amount' => $this->request->amount,
'payment_purpose' => $this->request->event->name . ' - Beitrag ' . $this->request->firstname . ' ' . $this->request->lastname,
'payment_method' => $paymentMethod?->slug, // available_payment_methods.slug === payment_methods.slug
'efz_status' => $participantAge->isfullAged() ? EfzStatus::EFZ_STATUS_NOT_CHECKED : EfzStatus::EFZ_STATUS_NOT_REQUIRED,
]
);
@@ -11,6 +11,12 @@ class UpdateEventCommand {
public function execute() : UpdateEventResponse {
$response = new UpdateEventResponse();
if (count($this->request->paymentMethods) === 0) {
$response->success = false;
$response->message = 'Mindestens eine Zahlungsmöglichkeit muss ausgewählt sein.';
return $response;
}
$this->request->event->name = $this->request->eventName;
$this->request->event->location = $this->request->eventLocation;
$this->request->event->postal_code = $this->request->postalCode;
@@ -26,6 +32,7 @@ class UpdateEventCommand {
$this->request->event->resetAllowedEatingHabits();
$this->request->event->resetContributingLocalGroups();
$this->request->event->resetPaymentMethods();
foreach($this->request->eatingHabits as $eatingHabit) {
$this->request->event->eatingHabits()->attach($eatingHabit);
@@ -35,6 +42,10 @@ class UpdateEventCommand {
$this->request->event->localGroups()->attach($contributingLocalGroup);
}
foreach($this->request->paymentMethods as $paymentMethod) {
$this->request->event->paymentMethods()->attach($paymentMethod);
}
$this->request->event->save();
$response->success = true;
@@ -21,8 +21,9 @@ class UpdateEventRequest {
public Amount $supportPerPerson;
public array $contributingLocalGroups;
public array $eatingHabits;
public array $paymentMethods;
public function __construct(Event $event, string $eventName, string $eventLocation, string $postalCode, string $email, DateTime $earlyBirdEnd, DateTime $registrationFinalEnd, int $alcoholicsAge, bool $sendWeeklyReports, bool $registrationAllowed, Amount $flatSupport, Amount $supportPerPerson, array $contributingLocalGroups, array $eatingHabits) {
public function __construct(Event $event, string $eventName, string $eventLocation, string $postalCode, string $email, DateTime $earlyBirdEnd, DateTime $registrationFinalEnd, int $alcoholicsAge, bool $sendWeeklyReports, bool $registrationAllowed, Amount $flatSupport, Amount $supportPerPerson, array $contributingLocalGroups, array $eatingHabits, array $paymentMethods) {
$this->event = $event;
$this->eventName = $eventName;
$this->eventLocation = $eventLocation;
@@ -37,5 +38,6 @@ class UpdateEventRequest {
$this->supportPerPerson = $supportPerPerson;
$this->contributingLocalGroups = $contributingLocalGroups;
$this->eatingHabits = $eatingHabits;
$this->paymentMethods = $paymentMethods;
}
}
@@ -4,9 +4,11 @@ namespace App\Domains\Event\Actions\UpdateEvent;
class UpdateEventResponse {
public bool $success;
public string $message;
public function __construct() {
$this->success = false;
$this->message = '';
}
}
@@ -42,6 +42,7 @@ class UpdateParticipantCommand {
$p->departure_date = DateTime::createFromFormat('Y-m-d', $this->request->departure);
$p->participation_type = $this->request->participationType;
$p->eating_habit = $this->request->eatingHabit;
$p->payment_method = $this->request->paymentMethod;
$p->allergies = $this->request->allergies;
$p->intolerances = $this->request->intolerances;
$p->medications = $this->request->medications;
@@ -25,6 +25,7 @@ class UpdateParticipantRequest {
public string $departure,
public string $participationType,
public string $eatingHabit,
public ?string $paymentMethod,
public ?string $allergies,
public ?string $intolerances,
public ?string $medications,
@@ -39,7 +39,6 @@ class CreateController extends CommonController {
$registrationFinalEnd = DateTime::createFromFormat('Y-m-d', $request->input('eventRegistrationFinalEnd'));
$participationFeeType = ParticipationFeeType::where('slug', $request->input('eventParticipationFeeType'))->first();
$payPerDay = $request->input('eventPayPerDay');
$payDirect = $request->input('eventPayDirectly');
$billingDeadline = clone $eventEnd;
$billingDeadline->modify('+6 weeks');
@@ -57,8 +56,7 @@ class CreateController extends CommonController {
$participationFeeType,
$request->input('eventAccount'),
$request->input('eventIban'),
$payPerDay,
$payDirect
$payPerDay
);
$wasSuccessful = false;
@@ -42,6 +42,7 @@ class DetailsController extends CommonController {
$contributinLocalGroups = $request->input('contributingLocalGroups');
$eatingHabits = $request->input('eatingHabits');
$paymentMethods = $request->input('paymentMethods');
$eventUpdateRequest = new UpdateEventRequest(
$event,
@@ -57,13 +58,14 @@ class DetailsController extends CommonController {
$flatSupport,
$supportPerPerson,
$contributinLocalGroups,
$eatingHabits
$eatingHabits,
$paymentMethods
);
$eventUpdateCommand = new UpdateEventCommand($eventUpdateRequest);
$response = $eventUpdateCommand->execute();
return response()->json(['status' => $response->success ? 'success' : 'error']);
return response()->json(['status' => $response->success ? 'success' : 'error', 'message' => $response->message]);
}
public function updateEventManagers(int $eventId, Request $request) : JsonResponse {
@@ -33,6 +33,7 @@ class ParticipantUpdateController extends CommonController {
departure: $request->input('departure'),
participationType: $request->input('participationType'),
eatingHabit: $request->input('eatingHabit'),
paymentMethod: $request->input('paymentMethod'),
allergies: $request->input('allergies'),
intolerances: $request->input('intolerances'),
medications: $request->input('medications'),
-9
View File
@@ -31,7 +31,6 @@
eventRegistrationFinalEnd: '',
eventAccount: props.eventAccount ? props.eventAccount : '',
eventIban: props.eventIban ? props.eventIban : '',
eventPayDirectly: true,
eventPayPerDay: props.eventPayPerDay ? props.eventPayPerDay : false,
eventParticipationFeeType: props.participationFeeType ? props.participationFeeType : 'fixed',
});
@@ -154,7 +153,6 @@
eventRegistrationFinalEnd: formData.eventRegistrationFinalEnd,
eventAccount: formData.eventAccount,
eventIban: formData.eventIban,
eventPayDirectly: formData.eventPayDirectly,
eventPayPerDay: formData.eventPayPerDay,
eventParticipationFeeType: formData.eventParticipationFeeType,
}
@@ -262,13 +260,6 @@
<ErrorText :message="errors.eventIban" /></td>
</tr>
<tr style="vertical-align: top;">
<td colspan="2" style="font-weight: bold;">
<input type="checkbox" v-model="formData.eventPayDirectly">
Teilnehmende zahlen direkt aufs Veranstaltungskonto
</td>
</tr>
<tr style="vertical-align: top;">
<td colspan="2" style="font-weight: bold;">
<input type="checkbox" v-model="formData.eventPayPerDay">
@@ -15,11 +15,13 @@
const dynmicProps = reactive({
localGroups: [],
eatingHabits:[]
eatingHabits:[],
paymentMethods: []
});
const contributingLocalGroups = ref([])
const eatingHabits = ref([]);
const paymentMethods = ref([]);
const errors = reactive({})
@@ -46,9 +48,18 @@
contributingLocalGroups.value = props.event.contributingLocalGroups?.map(t => t.id) ?? []
eatingHabits.value = props.event.eatingHabits?.map(t => t.id) ?? []
paymentMethods.value = props.event.paymentMethods?.map(t => t.id) ?? []
});
async function save() {
if (paymentMethods.value.length === 0) {
toast.error('Mindestens eine Zahlungsmöglichkeit muss ausgewählt sein.')
return
} else if(paymentMethods.value.length > 1) {
toast.error('Aktuell wird nur exakt eine Zahlungseinstellung unterstützt.')
return
}
const response = await request('/api/v1/event/details/' + props.event.id + '/common-settings', {
method: 'POST',
headers: {
@@ -68,6 +79,7 @@
supportPerson: formData.supportPerson,
contributingLocalGroups: contributingLocalGroups.value,
eatingHabits: eatingHabits.value,
paymentMethods: paymentMethods.value,
}
})
@@ -75,7 +87,7 @@
toast.success('Einstellungen wurden erfolgreich gespeichert.')
emit('close')
} else {
toast.error('Beim Speichern ist ein Fehler aufgetreten.')
toast.error(response.message ?? 'Beim Speichern ist ein Fehler aufgetreten.')
}
}
@@ -199,6 +211,17 @@
<label style="padding-left: 5px;" :for="'eatinghabit' + eatingHabit.id">{{eatingHabit.name}}</label>
</td>
</tr>
<tr>
<th style="padding-top: 40px !important;">Zahlungsmöglichkeiten</th>
</tr>
<tr v-for="paymentMethod in dynmicProps.paymentMethods">
<td>
<input type="checkbox" :id="'paymentmethod' + paymentMethod.id" :value="paymentMethod.id" v-model="paymentMethods" />
<label style="padding-left: 5px;" :for="'paymentmethod' + paymentMethod.id">{{paymentMethod.name}}</label>
</td>
</tr>
</table>
@@ -49,6 +49,7 @@ const form = reactive({
departure: '',
participationType: '',
eatingHabit: '',
paymentMethod: '',
allergies: '',
intolerances: '',
medications: '',
@@ -82,6 +83,7 @@ watch(
form.departure = participant?.departureDate ?? '';
form.participationType = participant?.participation_type ?? '';
form.eatingHabit = participant?.eating_habit ?? '';
form.paymentMethod = participant?.payment_method ?? '';
form.allergies = participant?.allergies ?? '';
form.intolerances = participant?.intolerances ?? '';
form.medications = participant?.medications ?? '';
@@ -206,7 +208,7 @@ function saveParticipant() {
<tr>
<th>Telefon</th>
<td>
<DialableTelephoneNumber v-if="!staticProps.editMode" :number="props.participant.phone_1"</DialableTelephoneNumber>
<DialableTelephoneNumber v-if="!staticProps.editMode" :number="props.participant.phone_1" />
<input v-else v-model="form.phone_1" type="text" />
</td>
</tr>
@@ -230,7 +232,7 @@ function saveParticipant() {
<tr>
<th>Ansprechperson Telefon</th>
<td>
<DialableTelephoneNumber v-if="!staticProps.editMode" :number="props.participant.phone_2"</DialableTelephoneNumber>
<DialableTelephoneNumber v-if="!staticProps.editMode" :number="props.participant.phone_2" />
<input v-else v-model="form.phone_2" type="text" />
</td>
</tr>
@@ -284,6 +286,20 @@ function saveParticipant() {
</select>
</td>
</tr>
<tr>
<th>Zahlungsmethode</th>
<td>
<span v-if="!staticProps.editMode">{{ props.participant.paymentMethod }}</span>
<select v-else v-model="form.paymentMethod">
<option
v-for="paymentMethod in staticProps.event.paymentMethods"
:value="paymentMethod.slug"
>
{{ paymentMethod.name }}
</option>
</select>
</td>
</tr>
<tr>
<th>eFZ-Status</th>
<td>