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
@@ -2,6 +2,8 @@
namespace App\Domains\Admin\Actions\CreateTenant; namespace App\Domains\Admin\Actions\CreateTenant;
use App\Models\AvailablePaymentMethod;
use App\Models\PaymentMethod;
use App\Models\Tenant; use App\Models\Tenant;
class CreateTenantAction class CreateTenantAction
@@ -29,6 +31,18 @@ class CreateTenantAction
'has_active_instance' => true, 'has_active_instance' => true,
]); ]);
foreach (PaymentMethod::all() as $paymentMethod) {
$defaults = PaymentMethod::DEFAULTS[$paymentMethod->slug] ?? ['name' => $paymentMethod->slug, 'description' => null];
AvailablePaymentMethod::create([
'tenant' => $tenant->slug,
'slug' => $paymentMethod->slug,
'name' => $defaults['name'],
'description' => $defaults['description'],
'active' => true,
]);
}
$response->success = true; $response->success = true;
$response->message = 'Stamm wurde angelegt.'; $response->message = 'Stamm wurde angelegt.';
$response->slug = $tenant->slug; $response->slug = $tenant->slug;
@@ -0,0 +1,32 @@
<?php
namespace App\Domains\Admin\Actions\RemovePaymentMethodUsage;
use App\Mail\EventReportMails\PaymentMethodsExhaustedMail;
use App\Models\AvailablePaymentMethod;
use Illuminate\Support\Facades\Mail;
class RemovePaymentMethodUsageAction
{
public function execute(AvailablePaymentMethod $availablePaymentMethod): void
{
foreach ($availablePaymentMethod->events()->get() as $event) {
$event->paymentMethods()->detach($availablePaymentMethod->id);
$remainingActive = $event->paymentMethods()->where('active', true)->count();
if ($remainingActive === 0 && $event->registration_allowed) {
$event->registration_allowed = false;
$event->save();
$recipients = $event->eventManagers;
if ($event->costUnit !== null) {
$recipients = $recipients->merge($event->costUnit->treasurers);
}
foreach ($recipients->unique('id') as $recipient) {
Mail::to($recipient->email)->send(new PaymentMethodsExhaustedMail($event));
}
}
}
}
}
@@ -0,0 +1,33 @@
<?php
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
use App\Domains\Admin\Actions\RemovePaymentMethodUsage\RemovePaymentMethodUsageAction;
class UpdateAvailablePaymentMethodAction
{
public function __construct(private UpdateAvailablePaymentMethodRequest $request)
{
}
public function execute(): UpdateAvailablePaymentMethodResponse
{
$response = new UpdateAvailablePaymentMethodResponse();
$wasActive = $this->request->availablePaymentMethod->active;
$this->request->availablePaymentMethod->update([
'name' => $this->request->name,
'description' => $this->request->description,
'active' => $this->request->active,
]);
if ($wasActive && !$this->request->active) {
(new RemovePaymentMethodUsageAction())->execute($this->request->availablePaymentMethod);
}
$response->success = true;
$response->message = 'Zahlungsmethode wurde gespeichert.';
return $response;
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
use App\Models\AvailablePaymentMethod;
class UpdateAvailablePaymentMethodRequest
{
public function __construct(
public AvailablePaymentMethod $availablePaymentMethod,
public string $name,
public ?string $description,
public bool $active,
) {
}
}
@@ -0,0 +1,9 @@
<?php
namespace App\Domains\Admin\Actions\UpdateAvailablePaymentMethod;
class UpdateAvailablePaymentMethodResponse
{
public bool $success = false;
public string $message = '';
}
@@ -0,0 +1,19 @@
<?php
namespace App\Domains\Admin\Controllers;
use App\Models\AvailablePaymentMethod;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class TenantPaymentMethodsGetController extends CommonController
{
public function __invoke(Request $request): JsonResponse
{
return response()->json([
'paymentMethods' => AvailablePaymentMethod::all(),
'saveEndpoint' => '/api/v1/admin/tenant/payment-methods',
]);
}
}
@@ -0,0 +1,32 @@
<?php
namespace App\Domains\Admin\Controllers;
use App\Domains\Admin\Actions\UpdateAvailablePaymentMethod\UpdateAvailablePaymentMethodAction;
use App\Domains\Admin\Actions\UpdateAvailablePaymentMethod\UpdateAvailablePaymentMethodRequest;
use App\Models\AvailablePaymentMethod;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class TenantPaymentMethodsUpdateController extends CommonController
{
public function __invoke(int $id, Request $request): JsonResponse
{
$availablePaymentMethod = AvailablePaymentMethod::findOrFail($id);
$action = new UpdateAvailablePaymentMethodAction(new UpdateAvailablePaymentMethodRequest(
availablePaymentMethod: $availablePaymentMethod,
name: $request->input('name'),
description: $request->input('description'),
active: (bool) $request->input('active'),
));
$response = $action->execute();
return response()->json([
'status' => $response->success ? 'success' : 'error',
'message' => $response->message,
]);
}
}
+4
View File
@@ -25,6 +25,8 @@ use App\Domains\Admin\Controllers\TenantImpressUpdateController;
use App\Domains\Admin\Controllers\TenantListApiController; use App\Domains\Admin\Controllers\TenantListApiController;
use App\Domains\Admin\Controllers\TenantPaymentGetController; use App\Domains\Admin\Controllers\TenantPaymentGetController;
use App\Domains\Admin\Controllers\TenantPaymentUpdateController; use App\Domains\Admin\Controllers\TenantPaymentUpdateController;
use App\Domains\Admin\Controllers\TenantPaymentMethodsGetController;
use App\Domains\Admin\Controllers\TenantPaymentMethodsUpdateController;
use App\Middleware\AdminRoleMiddleware; use App\Middleware\AdminRoleMiddleware;
use App\Middleware\IdentifyTenant; use App\Middleware\IdentifyTenant;
use App\Middleware\LvOnlyMiddleware; use App\Middleware\LvOnlyMiddleware;
@@ -36,6 +38,8 @@ Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->
Route::post('/contact', TenantContactUpdateController::class); Route::post('/contact', TenantContactUpdateController::class);
Route::get('/payment', TenantPaymentGetController::class); Route::get('/payment', TenantPaymentGetController::class);
Route::post('/payment', TenantPaymentUpdateController::class); Route::post('/payment', TenantPaymentUpdateController::class);
Route::get('/payment-methods', TenantPaymentMethodsGetController::class);
Route::post('/payment-methods/{id}', TenantPaymentMethodsUpdateController::class);
Route::get('/impress', TenantImpressGetController::class); Route::get('/impress', TenantImpressGetController::class);
Route::post('/impress', TenantImpressUpdateController::class); Route::post('/impress', TenantImpressUpdateController::class);
Route::get('/gdpr', TenantGdprGetController::class); Route::get('/gdpr', TenantGdprGetController::class);
@@ -0,0 +1,212 @@
<script setup>
import { ref } from 'vue';
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
import { toast } from "vue3-toastify";
const props = defineProps({
data: {
type: Object,
default: () => ({})
},
})
const { request } = useAjax()
const paymentMethods = ref(props.data.paymentMethods ?? [])
const editing = ref(null)
const form = ref({ name: '', description: '', active: true })
function edit(paymentMethod) {
editing.value = paymentMethod
form.value = {
name: paymentMethod.name,
description: paymentMethod.description ?? '',
active: paymentMethod.active,
}
}
function close() {
editing.value = null
}
async function save() {
const response = await request('/api/v1/admin/tenant/payment-methods/' + editing.value.id, {
method: 'POST',
body: form.value,
})
if (response && response.status === 'success') {
toast.success(response.message)
Object.assign(editing.value, form.value)
close()
} else {
toast.error(response?.message ?? 'Fehler beim Speichern')
}
}
</script>
<template>
<table class="payment-method-table">
<thead>
<tr>
<th>Name</th>
<th>Slug</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="paymentMethod in paymentMethods" :key="paymentMethod.id">
<td>{{ paymentMethod.name }}</td>
<td>{{ paymentMethod.slug }}</td>
<td>
<span :class="paymentMethod.active ? 'badge-active' : 'badge-inactive'">
{{ paymentMethod.active ? 'Aktiv' : 'Inaktiv' }}
</span>
</td>
<td>
<button class="btn-edit" @click="edit(paymentMethod)">Bearbeiten</button>
</td>
</tr>
</tbody>
</table>
<FullScreenModal :show="editing !== null" @close="close">
<template v-if="editing">
<h2>Zahlungsweg bearbeiten</h2>
<table class="data-table">
<tr><th>Name:</th><td><input type="text" v-model="form.name" class="form-input" /></td></tr>
<tr><th>Slug:</th><td>{{ editing.slug }}</td></tr>
<tr><th>Beschreibung:</th><td><textarea v-model="form.description" class="form-input"></textarea></td></tr>
<tr><th>Aktiv:</th><td><input type="checkbox" v-model="form.active" /></td></tr>
</table>
<div class="btn-group">
<button class="btn-save" @click="save">Speichern</button>
<button class="btn-cancel" @click="close">Abbrechen</button>
</div>
</template>
</FullScreenModal>
</template>
<style scoped>
.payment-method-table {
width: 100%;
border-collapse: collapse;
border: 1px solid #d1d5db;
border-radius: 8px;
overflow: hidden;
}
.payment-method-table thead th {
text-align: left;
padding: 10px 16px;
background-color: #f9fafb;
color: #374151;
font-weight: bold;
border-bottom: 2px solid #d1d5db;
}
.payment-method-table tbody td {
padding: 10px 16px;
border-bottom: 1px solid #e5e7eb;
}
.badge-active {
display: inline-block;
padding: 3px 12px;
border-radius: 12px;
font-size: 0.85rem;
font-weight: bold;
color: #166534;
background-color: #dcfce7;
border: 1px solid #22c55e;
}
.badge-inactive {
display: inline-block;
padding: 3px 12px;
border-radius: 12px;
font-size: 0.85rem;
font-weight: bold;
color: #991b1b;
background-color: #fee2e2;
border: 1px solid #ef4444;
}
.btn-edit {
padding: 6px 16px;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
font-size: 0.9rem;
background-color: #1d4899;
color: #ffffff;
}
.btn-edit:hover {
background-color: #163a7a;
}
.data-table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
.data-table th {
text-align: left;
padding: 8px 12px;
width: 200px;
color: #374151;
border-bottom: 1px solid #e5e7eb;
}
.data-table td {
padding: 8px 12px;
border-bottom: 1px solid #e5e7eb;
}
.form-input {
width: 100%;
padding: 6px 10px;
border: 1px solid #d1d5db;
border-radius: 6px;
font-size: 0.95rem;
box-sizing: border-box;
}
.btn-group {
display: flex;
gap: 10px;
margin-top: 15px;
}
.btn-save, .btn-cancel {
padding: 8px 20px;
border: none;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
font-size: 0.9rem;
}
.btn-save {
background-color: #16a34a;
color: #ffffff;
}
.btn-save:hover {
background-color: #15803d;
}
.btn-cancel {
background-color: #e5e7eb;
color: #374151;
}
.btn-cancel:hover {
background-color: #d1d5db;
}
</style>
+6
View File
@@ -6,6 +6,7 @@ import TenantContact from "./Partials/TenantContact.vue";
import TenantPayment from "./Partials/TenantPayment.vue"; import TenantPayment from "./Partials/TenantPayment.vue";
import TenantImpress from "./Partials/TenantImpress.vue"; import TenantImpress from "./Partials/TenantImpress.vue";
import TenantGdpr from "./Partials/TenantGdpr.vue"; import TenantGdpr from "./Partials/TenantGdpr.vue";
import TenantPaymentMethods from "./Partials/TenantPaymentMethods.vue";
const props = defineProps({ const props = defineProps({
tenant: Object, tenant: Object,
@@ -22,6 +23,11 @@ const tabs = [
component: TenantPayment, component: TenantPayment,
endpoint: '/api/v1/admin/tenant/payment', endpoint: '/api/v1/admin/tenant/payment',
}, },
{
title: 'Zahlungswege',
component: TenantPaymentMethods,
endpoint: '/api/v1/admin/tenant/payment-methods',
},
{ {
title: 'Impressum', title: 'Impressum',
component: TenantImpress, component: TenantImpress,
@@ -3,10 +3,12 @@
namespace App\Domains\Event\Actions\CreateEvent; namespace App\Domains\Event\Actions\CreateEvent;
use App\Enumerations\EatingHabit; use App\Enumerations\EatingHabit;
use App\Models\AvailablePaymentMethod;
use App\Models\Event; use App\Models\Event;
use App\Models\Tenant; use App\Models\Tenant;
use App\RelationModels\EventEatingHabits; use App\RelationModels\EventEatingHabits;
use App\RelationModels\EventLocalGroups; use App\RelationModels\EventLocalGroups;
use App\RelationModels\EventPaymentMethods;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class CreateEventCommand { class CreateEventCommand {
@@ -41,7 +43,7 @@ class CreateEventCommand {
'account_iban' => $this->request->accountIban, 'account_iban' => $this->request->accountIban,
'participation_fee_type' => $this->request->participationFeeType->slug, 'participation_fee_type' => $this->request->participationFeeType->slug,
'pay_per_day' => $this->request->payPerDay, 'pay_per_day' => $this->request->payPerDay,
'pay_direct' => $this->request->payDirect, 'pay_direct' => false,
'total_max_amount' => 0, 'total_max_amount' => 0,
'support_per_person' => 0, 'support_per_person' => 0,
'support_flat' => 0, 'support_flat' => 0,
@@ -58,6 +60,13 @@ class CreateEventCommand {
'eating_habit_id' => EatingHabit::where('slug', EatingHabit::EATING_HABIT_VEGETARIAN)->first()->id, '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') { if (app('tenant')->slug === 'lv') {
foreach(Tenant::where(['is_active_local_group' => true])->get() as $tenant) { foreach(Tenant::where(['is_active_local_group' => true])->get() as $tenant) {
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => $tenant->id]); EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => $tenant->id]);
@@ -19,9 +19,8 @@ class CreateEventRequest {
public string $accountOwner; public string $accountOwner;
public string $accountIban; public string $accountIban;
public bool $payPerDay; 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->name = $name;
$this->location = $location; $this->location = $location;
$this->postalCode = $postalCode; $this->postalCode = $postalCode;
@@ -35,6 +34,5 @@ class CreateEventRequest {
$this->accountOwner = $accountOwner; $this->accountOwner = $accountOwner;
$this->accountIban = $accountIban; $this->accountIban = $accountIban;
$this->payPerDay = $payPerDay; $this->payPerDay = $payPerDay;
$this->payDirect = $payDirect;
} }
} }
@@ -21,6 +21,8 @@ class SignUpCommand {
}; };
$participantAge = new Age($this->request->birthday); $participantAge = new Age($this->request->birthday);
$paymentMethod = $this->request->event->paymentMethods()->where('active', true)->first();
$response->participant = $this->request->event->participants()->create( $response->participant = $this->request->event->participants()->create(
[ [
'tenant' => $this->request->event->tenant, 'tenant' => $this->request->event->tenant,
@@ -60,6 +62,7 @@ class SignUpCommand {
'notes' => $this->request->notes, 'notes' => $this->request->notes,
'amount' => $this->request->amount, 'amount' => $this->request->amount,
'payment_purpose' => $this->request->event->name . ' - Beitrag ' . $this->request->firstname . ' ' . $this->request->lastname, '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, 'efz_status' => $participantAge->isfullAged() ? EfzStatus::EFZ_STATUS_NOT_CHECKED : EfzStatus::EFZ_STATUS_NOT_REQUIRED,
] ]
); );
@@ -11,6 +11,12 @@ class UpdateEventCommand {
public function execute() : UpdateEventResponse { public function execute() : UpdateEventResponse {
$response = new 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->name = $this->request->eventName;
$this->request->event->location = $this->request->eventLocation; $this->request->event->location = $this->request->eventLocation;
$this->request->event->postal_code = $this->request->postalCode; $this->request->event->postal_code = $this->request->postalCode;
@@ -26,6 +32,7 @@ class UpdateEventCommand {
$this->request->event->resetAllowedEatingHabits(); $this->request->event->resetAllowedEatingHabits();
$this->request->event->resetContributingLocalGroups(); $this->request->event->resetContributingLocalGroups();
$this->request->event->resetPaymentMethods();
foreach($this->request->eatingHabits as $eatingHabit) { foreach($this->request->eatingHabits as $eatingHabit) {
$this->request->event->eatingHabits()->attach($eatingHabit); $this->request->event->eatingHabits()->attach($eatingHabit);
@@ -35,6 +42,10 @@ class UpdateEventCommand {
$this->request->event->localGroups()->attach($contributingLocalGroup); $this->request->event->localGroups()->attach($contributingLocalGroup);
} }
foreach($this->request->paymentMethods as $paymentMethod) {
$this->request->event->paymentMethods()->attach($paymentMethod);
}
$this->request->event->save(); $this->request->event->save();
$response->success = true; $response->success = true;
@@ -21,8 +21,9 @@ class UpdateEventRequest {
public Amount $supportPerPerson; public Amount $supportPerPerson;
public array $contributingLocalGroups; public array $contributingLocalGroups;
public array $eatingHabits; 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->event = $event;
$this->eventName = $eventName; $this->eventName = $eventName;
$this->eventLocation = $eventLocation; $this->eventLocation = $eventLocation;
@@ -37,5 +38,6 @@ class UpdateEventRequest {
$this->supportPerPerson = $supportPerPerson; $this->supportPerPerson = $supportPerPerson;
$this->contributingLocalGroups = $contributingLocalGroups; $this->contributingLocalGroups = $contributingLocalGroups;
$this->eatingHabits = $eatingHabits; $this->eatingHabits = $eatingHabits;
$this->paymentMethods = $paymentMethods;
} }
} }
@@ -4,9 +4,11 @@ namespace App\Domains\Event\Actions\UpdateEvent;
class UpdateEventResponse { class UpdateEventResponse {
public bool $success; public bool $success;
public string $message;
public function __construct() { public function __construct() {
$this->success = false; $this->success = false;
$this->message = '';
} }
} }
@@ -42,6 +42,7 @@ class UpdateParticipantCommand {
$p->departure_date = DateTime::createFromFormat('Y-m-d', $this->request->departure); $p->departure_date = DateTime::createFromFormat('Y-m-d', $this->request->departure);
$p->participation_type = $this->request->participationType; $p->participation_type = $this->request->participationType;
$p->eating_habit = $this->request->eatingHabit; $p->eating_habit = $this->request->eatingHabit;
$p->payment_method = $this->request->paymentMethod;
$p->allergies = $this->request->allergies; $p->allergies = $this->request->allergies;
$p->intolerances = $this->request->intolerances; $p->intolerances = $this->request->intolerances;
$p->medications = $this->request->medications; $p->medications = $this->request->medications;
@@ -25,6 +25,7 @@ class UpdateParticipantRequest {
public string $departure, public string $departure,
public string $participationType, public string $participationType,
public string $eatingHabit, public string $eatingHabit,
public ?string $paymentMethod,
public ?string $allergies, public ?string $allergies,
public ?string $intolerances, public ?string $intolerances,
public ?string $medications, public ?string $medications,
@@ -39,7 +39,6 @@ class CreateController extends CommonController {
$registrationFinalEnd = DateTime::createFromFormat('Y-m-d', $request->input('eventRegistrationFinalEnd')); $registrationFinalEnd = DateTime::createFromFormat('Y-m-d', $request->input('eventRegistrationFinalEnd'));
$participationFeeType = ParticipationFeeType::where('slug', $request->input('eventParticipationFeeType'))->first(); $participationFeeType = ParticipationFeeType::where('slug', $request->input('eventParticipationFeeType'))->first();
$payPerDay = $request->input('eventPayPerDay'); $payPerDay = $request->input('eventPayPerDay');
$payDirect = $request->input('eventPayDirectly');
$billingDeadline = clone $eventEnd; $billingDeadline = clone $eventEnd;
$billingDeadline->modify('+6 weeks'); $billingDeadline->modify('+6 weeks');
@@ -57,8 +56,7 @@ class CreateController extends CommonController {
$participationFeeType, $participationFeeType,
$request->input('eventAccount'), $request->input('eventAccount'),
$request->input('eventIban'), $request->input('eventIban'),
$payPerDay, $payPerDay
$payDirect
); );
$wasSuccessful = false; $wasSuccessful = false;
@@ -42,6 +42,7 @@ class DetailsController extends CommonController {
$contributinLocalGroups = $request->input('contributingLocalGroups'); $contributinLocalGroups = $request->input('contributingLocalGroups');
$eatingHabits = $request->input('eatingHabits'); $eatingHabits = $request->input('eatingHabits');
$paymentMethods = $request->input('paymentMethods');
$eventUpdateRequest = new UpdateEventRequest( $eventUpdateRequest = new UpdateEventRequest(
$event, $event,
@@ -57,13 +58,14 @@ class DetailsController extends CommonController {
$flatSupport, $flatSupport,
$supportPerPerson, $supportPerPerson,
$contributinLocalGroups, $contributinLocalGroups,
$eatingHabits $eatingHabits,
$paymentMethods
); );
$eventUpdateCommand = new UpdateEventCommand($eventUpdateRequest); $eventUpdateCommand = new UpdateEventCommand($eventUpdateRequest);
$response = $eventUpdateCommand->execute(); $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 { public function updateEventManagers(int $eventId, Request $request) : JsonResponse {
@@ -33,6 +33,7 @@ class ParticipantUpdateController extends CommonController {
departure: $request->input('departure'), departure: $request->input('departure'),
participationType: $request->input('participationType'), participationType: $request->input('participationType'),
eatingHabit: $request->input('eatingHabit'), eatingHabit: $request->input('eatingHabit'),
paymentMethod: $request->input('paymentMethod'),
allergies: $request->input('allergies'), allergies: $request->input('allergies'),
intolerances: $request->input('intolerances'), intolerances: $request->input('intolerances'),
medications: $request->input('medications'), medications: $request->input('medications'),
-9
View File
@@ -31,7 +31,6 @@
eventRegistrationFinalEnd: '', eventRegistrationFinalEnd: '',
eventAccount: props.eventAccount ? props.eventAccount : '', eventAccount: props.eventAccount ? props.eventAccount : '',
eventIban: props.eventIban ? props.eventIban : '', eventIban: props.eventIban ? props.eventIban : '',
eventPayDirectly: true,
eventPayPerDay: props.eventPayPerDay ? props.eventPayPerDay : false, eventPayPerDay: props.eventPayPerDay ? props.eventPayPerDay : false,
eventParticipationFeeType: props.participationFeeType ? props.participationFeeType : 'fixed', eventParticipationFeeType: props.participationFeeType ? props.participationFeeType : 'fixed',
}); });
@@ -154,7 +153,6 @@
eventRegistrationFinalEnd: formData.eventRegistrationFinalEnd, eventRegistrationFinalEnd: formData.eventRegistrationFinalEnd,
eventAccount: formData.eventAccount, eventAccount: formData.eventAccount,
eventIban: formData.eventIban, eventIban: formData.eventIban,
eventPayDirectly: formData.eventPayDirectly,
eventPayPerDay: formData.eventPayPerDay, eventPayPerDay: formData.eventPayPerDay,
eventParticipationFeeType: formData.eventParticipationFeeType, eventParticipationFeeType: formData.eventParticipationFeeType,
} }
@@ -262,13 +260,6 @@
<ErrorText :message="errors.eventIban" /></td> <ErrorText :message="errors.eventIban" /></td>
</tr> </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;"> <tr style="vertical-align: top;">
<td colspan="2" style="font-weight: bold;"> <td colspan="2" style="font-weight: bold;">
<input type="checkbox" v-model="formData.eventPayPerDay"> <input type="checkbox" v-model="formData.eventPayPerDay">
@@ -15,11 +15,13 @@
const dynmicProps = reactive({ const dynmicProps = reactive({
localGroups: [], localGroups: [],
eatingHabits:[] eatingHabits:[],
paymentMethods: []
}); });
const contributingLocalGroups = ref([]) const contributingLocalGroups = ref([])
const eatingHabits = ref([]); const eatingHabits = ref([]);
const paymentMethods = ref([]);
const errors = reactive({}) const errors = reactive({})
@@ -46,9 +48,18 @@
contributingLocalGroups.value = props.event.contributingLocalGroups?.map(t => t.id) ?? [] contributingLocalGroups.value = props.event.contributingLocalGroups?.map(t => t.id) ?? []
eatingHabits.value = props.event.eatingHabits?.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() { 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', { const response = await request('/api/v1/event/details/' + props.event.id + '/common-settings', {
method: 'POST', method: 'POST',
headers: { headers: {
@@ -68,6 +79,7 @@
supportPerson: formData.supportPerson, supportPerson: formData.supportPerson,
contributingLocalGroups: contributingLocalGroups.value, contributingLocalGroups: contributingLocalGroups.value,
eatingHabits: eatingHabits.value, eatingHabits: eatingHabits.value,
paymentMethods: paymentMethods.value,
} }
}) })
@@ -75,7 +87,7 @@
toast.success('Einstellungen wurden erfolgreich gespeichert.') toast.success('Einstellungen wurden erfolgreich gespeichert.')
emit('close') emit('close')
} else { } 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> <label style="padding-left: 5px;" :for="'eatinghabit' + eatingHabit.id">{{eatingHabit.name}}</label>
</td> </td>
</tr> </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> </table>
@@ -49,6 +49,7 @@ const form = reactive({
departure: '', departure: '',
participationType: '', participationType: '',
eatingHabit: '', eatingHabit: '',
paymentMethod: '',
allergies: '', allergies: '',
intolerances: '', intolerances: '',
medications: '', medications: '',
@@ -82,6 +83,7 @@ watch(
form.departure = participant?.departureDate ?? ''; form.departure = participant?.departureDate ?? '';
form.participationType = participant?.participation_type ?? ''; form.participationType = participant?.participation_type ?? '';
form.eatingHabit = participant?.eating_habit ?? ''; form.eatingHabit = participant?.eating_habit ?? '';
form.paymentMethod = participant?.payment_method ?? '';
form.allergies = participant?.allergies ?? ''; form.allergies = participant?.allergies ?? '';
form.intolerances = participant?.intolerances ?? ''; form.intolerances = participant?.intolerances ?? '';
form.medications = participant?.medications ?? ''; form.medications = participant?.medications ?? '';
@@ -206,7 +208,7 @@ function saveParticipant() {
<tr> <tr>
<th>Telefon</th> <th>Telefon</th>
<td> <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" /> <input v-else v-model="form.phone_1" type="text" />
</td> </td>
</tr> </tr>
@@ -230,7 +232,7 @@ function saveParticipant() {
<tr> <tr>
<th>Ansprechperson Telefon</th> <th>Ansprechperson Telefon</th>
<td> <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" /> <input v-else v-model="form.phone_2" type="text" />
</td> </td>
</tr> </tr>
@@ -284,6 +286,20 @@ function saveParticipant() {
</select> </select>
</td> </td>
</tr> </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> <tr>
<th>eFZ-Status</th> <th>eFZ-Status</th>
<td> <td>
+7
View File
@@ -14,6 +14,7 @@ use App\Enumerations\ParticipationType;
use App\Enumerations\SwimmingPermission; use App\Enumerations\SwimmingPermission;
use App\Enumerations\UserRole; use App\Enumerations\UserRole;
use App\Models\CronTask; use App\Models\CronTask;
use App\Models\PaymentMethod;
use App\Models\Tenant; use App\Models\Tenant;
class ProductionDataSeeder { class ProductionDataSeeder {
@@ -28,6 +29,12 @@ class ProductionDataSeeder {
$this->installParticipationFeeTypes(); $this->installParticipationFeeTypes();
$this->installParticipationTypes(); $this->installParticipationTypes();
$this->installEfzStatus(); $this->installEfzStatus();
$this->installPaymentMethods();
}
private function installPaymentMethods() {
PaymentMethod::create(['slug' => PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION]);
PaymentMethod::create(['slug' => PaymentMethod::PAYMENT_NOT_DEFINED]);
} }
private function installEfzStatus() { private function installEfzStatus() {
@@ -0,0 +1,46 @@
<?php
namespace App\Mail\EventReportMails;
use App\Models\Event;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
class PaymentMethodsExhaustedMail extends Mailable
{
public function __construct(
private Event $event,
)
{
//
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
$subject = sprintf(
'Anmeldung deaktiviert keine Zahlungsmethode verfügbar für %1$s',
$this->event->name
);
return new Envelope(
subject: $subject,
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'emails.events.payment_methods_exhausted',
with: [
'eventTitle' => $this->event->name,
],
);
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
namespace App\Models;
use App\Scopes\InstancedModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
/**
* @property int $id
* @property string $tenant
* @property string $slug
* @property string $name
* @property ?string $description
* @property bool $active
*/
class AvailablePaymentMethod extends InstancedModel
{
protected $table = 'available_payment_methods';
protected $fillable = [
'tenant',
'slug',
'name',
'description',
'active',
];
protected $casts = [
'active' => 'boolean',
];
public function paymentMethod(): BelongsTo
{
return $this->belongsTo(PaymentMethod::class, 'slug', 'slug');
}
public function events(): BelongsToMany
{
return $this->belongsToMany(Event::class, 'event_payment_methods')->withTimestamps();
}
}
+9
View File
@@ -153,6 +153,10 @@ class Event extends InstancedModel
return $this->belongsToMany(EatingHabit::class, 'event_allowed_eating_habits', 'event_id', 'eating_habit_id'); return $this->belongsToMany(EatingHabit::class, 'event_allowed_eating_habits', 'event_id', 'eating_habit_id');
} }
public function paymentMethods() : BelongsToMany {
return $this->belongsToMany(AvailablePaymentMethod::class, 'event_payment_methods', 'event_id', 'available_payment_method_id')->withTimestamps();
}
public function resetContributingLocalGroups() { public function resetContributingLocalGroups() {
$this->localGroups()->detach(); $this->localGroups()->detach();
$this->save(); $this->save();
@@ -163,6 +167,11 @@ class Event extends InstancedModel
$this->save(); $this->save();
} }
public function resetPaymentMethods() {
$this->paymentMethods()->detach();
$this->save();
}
public function resetMangers() { public function resetMangers() {
$this->eventManagers()->detach(); $this->eventManagers()->detach();
$this->save(); $this->save();
+6
View File
@@ -64,6 +64,7 @@ class EventParticipant extends InstancedModel
'amount', 'amount',
'amount_paid', 'amount_paid',
'payment_purpose', 'payment_purpose',
'payment_method',
'efz_status', 'efz_status',
'unregistered_at', 'unregistered_at',
]; ];
@@ -126,6 +127,11 @@ class EventParticipant extends InstancedModel
return $this->belongsTo(EatingHabit::class, 'eating_habits', 'slug'); return $this->belongsTo(EatingHabit::class, 'eating_habits', 'slug');
} }
public function paymentMethod()
{
return $this->belongsTo(\App\Models\PaymentMethod::class, 'payment_method', 'slug');
}
public function firstAidPermission() public function firstAidPermission()
{ {
return $this->belongsTo(FirstAidPermission::class, 'first_aid_permission', 'slug'); return $this->belongsTo(FirstAidPermission::class, 'first_aid_permission', 'slug');
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use App\Scopes\CommonModel;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
/**
* @property string $id
* @property string $slug
*/
class PaymentMethod extends CommonModel
{
use HasUuids;
public $incrementing = false;
protected $keyType = 'string';
public const string PAYMENT_ACCOUNT_TRANSACTION = 'PAYMENT_ACCOUNT_TRANSACTION';
public const string PAYMENT_NOT_DEFINED = 'PAYMENT_NOT_DEFINED';
public const array DEFAULTS = [
self::PAYMENT_ACCOUNT_TRANSACTION => ['name' => 'Überweisung auf Veranstaltungskonto', 'description' => null],
self::PAYMENT_NOT_DEFINED => ['name' => 'Sonstiges (Barzahlung, Zahlung vor Ort)', 'description' => null],
];
protected $fillable = [
'slug',
];
}
+2
View File
@@ -5,6 +5,7 @@ namespace App\Providers;
use App\Enumerations\EatingHabit; use App\Enumerations\EatingHabit;
use App\Enumerations\InvoiceType; use App\Enumerations\InvoiceType;
use App\Enumerations\UserRole; use App\Enumerations\UserRole;
use App\Models\AvailablePaymentMethod;
use App\Models\Tenant; use App\Models\Tenant;
use App\Models\User; use App\Models\User;
use App\Repositories\EventRepository; use App\Repositories\EventRepository;
@@ -187,6 +188,7 @@ class GlobalDataProvider {
[ [
'localGroups' => Tenant::where(['is_active_local_group' => true])->get(), 'localGroups' => Tenant::where(['is_active_local_group' => true])->get(),
'eatingHabits' => EatingHabit::all(), 'eatingHabits' => EatingHabit::all(),
'paymentMethods' => AvailablePaymentMethod::where('active', true)->get(),
]); ]);
} }
@@ -0,0 +1,11 @@
<?php
namespace App\RelationModels;
use App\Scopes\CommonModel;
class EventPaymentMethods extends CommonModel
{
protected $table = 'event_payment_methods';
protected $fillable = ['event_id', 'available_payment_method_id'];
}
@@ -0,0 +1,24 @@
<?php
namespace App\Resources;
use App\Models\AvailablePaymentMethod;
use Illuminate\Http\Resources\Json\JsonResource;
class AvailablePaymentMethodResource extends JsonResource {
private AvailablePaymentMethod $availablePaymentMethod;
public function __construct(AvailablePaymentMethod $availablePaymentMethod) {
$this->availablePaymentMethod = $availablePaymentMethod;
}
public function toArray($request) : array {
return [
'id' => $this->availablePaymentMethod->id,
'slug' => $this->availablePaymentMethod->slug,
'name' => $this->availablePaymentMethod->name,
'description' => $this->availablePaymentMethod->description,
'active' => $this->availablePaymentMethod->active,
];
}
}
+8 -1
View File
@@ -5,7 +5,9 @@ namespace App\Resources;
use App\Enumerations\EatingHabit; use App\Enumerations\EatingHabit;
use App\Enumerations\EfzStatus; use App\Enumerations\EfzStatus;
use App\Enumerations\ParticipationType; use App\Enumerations\ParticipationType;
use App\Models\AvailablePaymentMethod;
use App\Models\EventParticipant; use App\Models\EventParticipant;
use App\Models\PaymentMethod;
use App\ValueObjects\Age; use App\ValueObjects\Age;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
@@ -52,7 +54,9 @@ class EventParticipantResource extends JsonResource
'tetanusVaccinationEdit' => $this->resource->tetanus_vaccination?->format('Y-m-d') ?? null, 'tetanusVaccinationEdit' => $this->resource->tetanus_vaccination?->format('Y-m-d') ?? null,
'presenceDays' => ['real' => $presenceDays, 'support' => $presenceDaysSupport], 'presenceDays' => ['real' => $presenceDays, 'support' => $presenceDaysSupport],
'participationType' => ParticipationType::where(['slug' => $this->resource->participation_type])->first()->name, 'participationType' => ParticipationType::where(['slug' => $this->resource->participation_type])->first()->name,
'needs_payment' => $this->resource->amount->getAmount() > 0 && $event->pay_direct && $this->resource->amount_paid?->getAmount() < $this->resource->amount->getAmount(), 'needs_payment' => $this->resource->amount->getAmount() > 0
&& $this->resource->payment_method === PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION
&& $this->resource->amount_paid?->getAmount() < $this->resource->amount->getAmount(),
'nicename' => $this->resource->getNicename(), 'nicename' => $this->resource->getNicename(),
'arrival' => $this->resource->arrival_date->format('d.m.Y'), 'arrival' => $this->resource->arrival_date->format('d.m.Y'),
'departure' => $this->resource->departure_date->format('d.m.Y'), 'departure' => $this->resource->departure_date->format('d.m.Y'),
@@ -68,6 +72,9 @@ class EventParticipantResource extends JsonResource
'localGroupState' => null !== $this->resource->localGroup()->first()?->postcode ? config('postCode.map.' . $this->resource->postcode) : '--', 'localGroupState' => null !== $this->resource->localGroup()->first()?->postcode ? config('postCode.map.' . $this->resource->postcode) : '--',
'birthday' => $this->resource->birthday->format('d.m.Y'), 'birthday' => $this->resource->birthday->format('d.m.Y'),
'eatingHabit' => EatingHabit::where('slug', $this->resource->eating_habit)->first()->name, 'eatingHabit' => EatingHabit::where('slug', $this->resource->eating_habit)->first()->name,
'paymentMethod' => $this->resource->payment_method !== null
? AvailablePaymentMethod::withoutGlobalScopes()->where('tenant', $this->resource->tenant)->where('slug', $this->resource->payment_method)->first()?->name ?? $this->resource->payment_method
: null,
'cocColor' => match ($this->resource->efz_status) { 'cocColor' => match ($this->resource->efz_status) {
EfzStatus::EFZ_STATUS_CHECKED_VALID => 'bg-green', EfzStatus::EFZ_STATUS_CHECKED_VALID => 'bg-green',
EfzStatus::EFZ_STATUS_NOT_REQUIRED => 'bg-green', EfzStatus::EFZ_STATUS_NOT_REQUIRED => 'bg-green',
+3
View File
@@ -134,6 +134,9 @@ class EventResource extends JsonResource{
$returnArray['eatingHabits'] = $this->event->eatingHabits()->get()->map( $returnArray['eatingHabits'] = $this->event->eatingHabits()->get()->map(
fn($eatingHabit) => new EatingHabitResource($eatingHabit))->toArray(); fn($eatingHabit) => new EatingHabitResource($eatingHabit))->toArray();
$returnArray['paymentMethods'] = $this->event->paymentMethods()->get()->map(
fn($paymentMethod) => new AvailablePaymentMethodResource($paymentMethod))->toArray();
$returnArray['participationTypes'] = []; $returnArray['participationTypes'] = [];
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('payment_methods', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('slug')->unique();
$table->timestamps();
});
Schema::create('available_payment_methods', function (Blueprint $table) {
$table->id();
$table->string('tenant');
$table->string('slug');
$table->string('name');
$table->string('description')->nullable();
$table->boolean('active')->default(true);
$table->timestamps();
$table->foreign('tenant')->references('slug')->on('tenants')->restrictOnDelete()->cascadeOnUpdate();
$table->foreign('slug')->references('slug')->on('payment_methods')->restrictOnDelete()->cascadeOnUpdate();
$table->unique(['tenant', 'slug']);
});
}
public function down(): void
{
Schema::dropIfExists('available_payment_methods');
Schema::dropIfExists('payment_methods');
}
};
@@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('event_payment_methods', function (Blueprint $table) {
$table->id();
$table->foreignId('event_id')->constrained('events', 'id')->restrictOnDelete()->cascadeOnUpdate();
$table->foreignId('available_payment_method_id')->constrained('available_payment_methods', 'id')->restrictOnDelete()->cascadeOnUpdate();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('event_payment_methods');
}
};
@@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('event_participants', function (Blueprint $table) {
$table->string('payment_method')->nullable()->after('payment_purpose');
$table->foreign('payment_method')->references('slug')->on('payment_methods')->restrictOnDelete()->cascadeOnUpdate();
});
}
public function down(): void
{
Schema::table('event_participants', function (Blueprint $table) {
$table->dropForeign(['payment_method']);
$table->dropColumn('payment_method');
});
}
};
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<body>
<p>
Für die Veranstaltung "{{ $eventTitle }}" wurde die letzte aktive Zahlungsmöglichkeit deaktiviert.
</p>
<p>
Die Anmeldung für diese Veranstaltung wurde deshalb automatisch deaktiviert, da aktuell keine
Zahlungsmöglichkeit mehr zur Verfügung steht.
</p>
<p>
Bitte aktiviert mindestens eine Zahlungsmöglichkeit für diese Veranstaltung, um die Anmeldung wieder
zu ermöglichen.
</p>
</body>
</html>