Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b668c7e805 | ||
|
|
ddfaab1501 | ||
|
|
70a57d10f5 | ||
|
|
6301c342e4 | ||
|
|
025035190d | ||
|
|
651b6147bf | ||
|
|
ae13841699 | ||
|
|
91dca31c11 | ||
|
|
40d5634764 | ||
|
|
350c8dd0d0 | ||
|
|
d07980dd1f | ||
|
|
b9795f08f0 | ||
|
|
e730d6db63 | ||
|
|
a6bddf9fa5 | ||
|
|
749d8588da | ||
|
|
4bb64b0053 | ||
|
|
d23e6c3914 | ||
|
|
15690b1da9 | ||
|
|
c1c1a4f143 | ||
|
|
5beb2b1d97 | ||
|
|
efee20c16b |
+29010
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ namespace App\Domains\Admin\Controllers;
|
||||
use App\Models\AvailablePaymentMethod;
|
||||
use App\Resources\AvailablePaymentMethodResource;
|
||||
use App\Scopes\CommonController;
|
||||
use App\ValueObjects\BankStatementRuleset;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -16,6 +17,10 @@ class TenantPaymentMethodsGetController extends CommonController
|
||||
'paymentMethods' => AvailablePaymentMethod::all()
|
||||
->map(fn (AvailablePaymentMethod $method) => new AvailablePaymentMethodResource($method)->toArray($request)),
|
||||
'saveEndpoint' => '/api/v1/admin/tenant/payment-methods',
|
||||
// Der app-weite Standard für das Kontoauszug-Format. Das Formular zeigt ihn als
|
||||
// Vorbelegung an, damit erkennbar ist, wovon ein Override abweicht.
|
||||
'statementRulesetDefault' => BankStatementRuleset::default()->toArray(),
|
||||
'statementRulesetCharsets' => BankStatementRuleset::CHARSETS,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class UserDetailGetController extends CommonController
|
||||
|
||||
return response()->json([
|
||||
'user' => $userData,
|
||||
'isOwnUser' => auth()->id() === $user->id,
|
||||
'isOwnUser' => currentUser()?->id === $user->id,
|
||||
'isLvTenant' => $this->tenant->slug === 'lv',
|
||||
'userRoles' => UserRole::all()->map(fn($role) => ['slug' => $role->slug, 'name' => $role->name]),
|
||||
'localGroups' => $this->adminTenants->getActiveLocalGroups()->map(fn($t) => ['slug' => $t->slug, 'name' => $t->name]),
|
||||
|
||||
@@ -16,7 +16,7 @@ class UserToggleActiveController extends CommonController
|
||||
|
||||
$action = new ToggleUserActiveAction(new ToggleUserActiveRequest(
|
||||
user: $user,
|
||||
currentUserId: auth()->id(),
|
||||
currentUserId: currentUser()?->id,
|
||||
));
|
||||
|
||||
$response = $action->execute();
|
||||
|
||||
@@ -17,7 +17,7 @@ class UserUpdateController extends CommonController
|
||||
$action = new UpdateUserAction(new UpdateUserRequest(
|
||||
user: $user,
|
||||
data: $request->all(),
|
||||
isOwnUser: auth()->id() === $user->id,
|
||||
isOwnUser: currentUser()?->id === $user->id,
|
||||
isLvTenant: $this->tenant->slug === 'lv',
|
||||
));
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import {computed, ref} from 'vue';
|
||||
import BankRulesetEditor from "../../../../Views/Components/BankRulesetEditor.vue";
|
||||
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
||||
import TextEditor from "../../../../Views/Components/TextEditor.vue";
|
||||
import RichSelectBox from "../../../../Views/Components/RichSelectBox.vue";
|
||||
@@ -102,6 +103,10 @@ async function save() {
|
||||
<RichSelectBox v-if="option.type === 'icon'" v-model="form.configuration[option.name]"
|
||||
:options="PAYMENT_METHOD_ICONS" placeholder="Symbol wählen…"/>
|
||||
<TextEditor v-else-if="option.type === 'richtext'" v-model="form.configuration[option.name]"/>
|
||||
<BankRulesetEditor v-else-if="option.type === 'bank-ruleset'"
|
||||
v-model="form.configuration[option.name]"
|
||||
:defaults="data.statementRulesetDefault ?? {}"
|
||||
:charsets="data.statementRulesetCharsets ?? undefined"/>
|
||||
<input v-else type="text" v-model="form.configuration[option.name]" class="form-input"/>
|
||||
<span v-if="option.hint" class="option-hint">{{ option.hint }}</span>
|
||||
</td>
|
||||
|
||||
@@ -25,7 +25,7 @@ class CreateEstimateAction {
|
||||
|
||||
if ($this->request->estimateId === 0) {
|
||||
$estimate = CostUnitEstimate::create(array_merge([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'cost_unit_id' => $this->request->costUnit->id,
|
||||
'type' => $this->request->estimateType,
|
||||
'description' => $this->request->description,
|
||||
@@ -33,7 +33,7 @@ class CreateEstimateAction {
|
||||
} else {
|
||||
$estimate = CostUnitEstimate::find($this->request->estimateId);
|
||||
$estimate->update(array_merge([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'cost_unit_id' => $this->request->costUnit->id,
|
||||
'type' => $this->request->estimateType,
|
||||
'description' => $this->request->description,
|
||||
|
||||
@@ -15,7 +15,7 @@ class CreateCostUnitCommand {
|
||||
$response = new CreateCostUnitResponse();
|
||||
$costUnit = CostUnit::create([
|
||||
'name' => $this->request->name,
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'type' => $this->request->type,
|
||||
'billing_deadline' => $this->request->billingDeadline,
|
||||
'distance_allowance' => $this->request->distanceAllowance->getAmount(),
|
||||
|
||||
@@ -93,7 +93,7 @@ class ExportController extends CommonController {
|
||||
'amount' => $invoice->amount,
|
||||
'recipient_name' => $invoice->contact_bank_owner,
|
||||
'recipient_iban' => $invoice->contact_bank_iban,
|
||||
'payment_purpose' => $invoice->payment_purpose ?? 'Auslagenerstattung Rechnungsnummer ' . $invoice->invoice_number,
|
||||
'payment_purpose' => $invoice->paymentPurposeText(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,12 +89,13 @@
|
||||
<template>
|
||||
<table v-if="localData.invoices.length > 0" class="invoice-list-table">
|
||||
<tr>
|
||||
<td colspan="6">{{props.data.costUnit.name}}</td>
|
||||
<td colspan="7">{{props.data.costUnit.name}}</td>
|
||||
</tr>
|
||||
|
||||
<tr v-for="invoice in localData.invoices" :id="'invoice_' + invoice.id">
|
||||
<td>{{invoice.invoiceNumber}}</td>
|
||||
<td>{{invoice.invoiceType}}</td>
|
||||
<td>{{invoice.invoiceTypeShort}}</td>
|
||||
<td style="max-width: 250px;">{{invoice.purpose}}</td>
|
||||
<td>
|
||||
{{invoice.amount}}
|
||||
</td>
|
||||
@@ -114,7 +115,7 @@
|
||||
</tr>
|
||||
|
||||
<tr v-if="props.data.endpoint === 'approved'">
|
||||
<td colspan="5"></td>
|
||||
<td colspan="6"></td>
|
||||
<td>
|
||||
<a style="font-size: 10pt;" class="link" @click="exportPayouts()">Genehmigte Abrechnungen exportieren</a>
|
||||
</td>
|
||||
|
||||
@@ -13,7 +13,7 @@ class PersonalDataController extends CommonController
|
||||
return redirect()->intended('/login');
|
||||
}
|
||||
|
||||
$user = auth()->user();
|
||||
$user = currentUser();
|
||||
$data = $this->users->getPersonalData($user);
|
||||
|
||||
$inertiaProvider = new InertiaProvider('Dashboard/PersonalData', [
|
||||
|
||||
@@ -12,7 +12,7 @@ class StorePersonalDataController extends CommonController
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
$user = auth()->user();
|
||||
$user = currentUser();
|
||||
|
||||
$actionRequest = new UpdatePersonalDataRequest(
|
||||
user: $user,
|
||||
|
||||
@@ -33,7 +33,7 @@ function navigateTo(url) {
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
{{participation.event.postal_code}} {{participation.event.location}}<br />
|
||||
{{participation.eventAddress}}<br />
|
||||
</td>
|
||||
<td>
|
||||
<a class="link" :href="`/api/v1/event/participant/${participation.identifier}/ical`">In Kalender importieren</a>
|
||||
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\BookBankStatementPayments;
|
||||
|
||||
use App\Domains\Event\Actions\ParticipantPayment\ParticipantPaymentCommand;
|
||||
use App\Domains\Event\Actions\ParticipantPayment\ParticipantPaymentRequest;
|
||||
use App\EventPaymentModules\EventPaymentModuleRegistry;
|
||||
use App\EventPaymentModules\ReadsBankStatements;
|
||||
use App\Models\EventParticipant;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Repositories\EventParticipantRepository;
|
||||
use App\ValueObjects\Amount;
|
||||
use App\ValueObjects\BankTransaction;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* Bucht die in der Prüfansicht bestätigten Zahlungseingänge -- alle in einem Durchgang.
|
||||
*
|
||||
* Bewusst **ohne** umspannende Transaktion: Gebucht wird über {@see ParticipantPaymentCommand}, und der
|
||||
* verschickt die Zahlungsmail gleich mit. Das Projekt kennt keine Queue, die Mails gehen also synchron
|
||||
* raus; eine offene Transaktion über achtzig Mailversände wäre die schlechtere Wahl. Jede Zeile ist
|
||||
* für sich vollständig, und das Wasserzeichen schützt sie gegen eine Wiederholung.
|
||||
*/
|
||||
class BookBankStatementPaymentsCommand
|
||||
{
|
||||
public function __construct(private readonly BookBankStatementPaymentsRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): BookBankStatementPaymentsResponse
|
||||
{
|
||||
$response = new BookBankStatementPaymentsResponse();
|
||||
|
||||
if ($this->request->bookings === []) {
|
||||
$response->message = 'Es wurden keine Zahlungen zum Buchen ausgewählt.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$module = EventPaymentModuleRegistry::forSlug(PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION);
|
||||
$participants = new EventParticipantRepository();
|
||||
|
||||
foreach ($this->request->bookings as $booking) {
|
||||
$participant = $participants->findInEventByIdentifier(
|
||||
$this->request->event,
|
||||
(string) ($booking['participantIdentifier'] ?? ''),
|
||||
);
|
||||
|
||||
$transaction = $this->toTransaction($booking);
|
||||
|
||||
if ($participant === null || $transaction === null) {
|
||||
$response->failed++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Zweite Prüfung, nicht bloß Gürtel und Hosenträger: In der Prüfansicht lässt sich eine
|
||||
// Zeile von Hand einer anderen Person zuordnen, und deren Wasserzeichen hat der erste
|
||||
// Durchlauf nie gesehen.
|
||||
if ($this->isBeforeWatermark($participant, $transaction)) {
|
||||
$response->skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($module instanceof ReadsBankStatements) {
|
||||
$module->recordTransaction($participant, $transaction);
|
||||
}
|
||||
|
||||
$participant->last_payment_date = $transaction->paymentDate;
|
||||
|
||||
$this->book($participant, $transaction->amount);
|
||||
$response->booked++;
|
||||
}
|
||||
|
||||
$response->success = true;
|
||||
$response->message = $this->summaryMessage($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bucht den Betrag **zusätzlich** zum bereits Gezahlten.
|
||||
*
|
||||
* Die manuelle Erfassung setzt `amount_paid` absolut, weil dort jemand den Gesamtstand eintippt.
|
||||
* Hier kommt eine einzelne Zahlung an -- eine zweite Rate darf die erste nicht überschreiben.
|
||||
* Der {@see ParticipantPaymentCommand} speichert dabei die zuvor gesetzten Felder mit und schickt
|
||||
* die passende Mail (bezahlt / fehlt noch / überzahlt).
|
||||
*/
|
||||
private function book(EventParticipant $participant, Amount $amount): void
|
||||
{
|
||||
$total = new Amount(
|
||||
round(($participant->amount_paid?->getAmount() ?? 0.0) + $amount->getAmount(), 2),
|
||||
'Euro',
|
||||
);
|
||||
|
||||
new ParticipantPaymentCommand(new ParticipantPaymentRequest($participant, $total))->execute();
|
||||
}
|
||||
|
||||
/** @param array<string, mixed> $booking */
|
||||
private function toTransaction(array $booking): ?BankTransaction
|
||||
{
|
||||
$date = CarbonImmutable::createFromFormat('!Y-m-d', (string) ($booking['paymentDate'] ?? ''));
|
||||
$amount = $booking['amount'] ?? null;
|
||||
|
||||
if ($date === false || !is_numeric($amount) || (float) $amount <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BankTransaction(
|
||||
paymentDate: $date,
|
||||
amount: new Amount(round((float) $amount, 2), 'Euro'),
|
||||
purpose: (string) ($booking['purpose'] ?? ''),
|
||||
payerName: (string) ($booking['payerName'] ?? ''),
|
||||
payerIban: (string) ($booking['payerIban'] ?? ''),
|
||||
rowNumber: (int) ($booking['rowNumber'] ?? 0),
|
||||
);
|
||||
}
|
||||
|
||||
private function isBeforeWatermark(EventParticipant $participant, BankTransaction $transaction): bool
|
||||
{
|
||||
$watermark = $participant->last_payment_date;
|
||||
|
||||
return $watermark !== null && $transaction->paymentDate->startOfDay()->lt($watermark->startOfDay());
|
||||
}
|
||||
|
||||
private function summaryMessage(BookBankStatementPaymentsResponse $response): string
|
||||
{
|
||||
$message = sprintf('%d Zahlungen wurden gebucht.', $response->booked);
|
||||
|
||||
if ($response->skipped > 0) {
|
||||
$message .= sprintf(
|
||||
' %d wurden übersprungen, weil sie älter sind als die zuletzt erfasste Zahlung der Person.',
|
||||
$response->skipped,
|
||||
);
|
||||
}
|
||||
|
||||
if ($response->failed > 0) {
|
||||
$message .= sprintf(' %d konnten nicht zugeordnet werden.', $response->failed);
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\BookBankStatementPayments;
|
||||
|
||||
use App\Models\Event;
|
||||
|
||||
class BookBankStatementPaymentsRequest
|
||||
{
|
||||
/**
|
||||
* @param array<int, array<string, mixed>> $bookings Je Eintrag die bestätigte Zeile der Prüfansicht:
|
||||
* participantIdentifier, paymentDate, amount,
|
||||
* payerName, payerIban, purpose.
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly Event $event,
|
||||
public readonly array $bookings,
|
||||
) {
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\BookBankStatementPayments;
|
||||
|
||||
class BookBankStatementPaymentsResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
|
||||
public int $booked = 0;
|
||||
|
||||
/** Übersprungen, weil älter als die zuletzt erfasste Zahlung der Person. */
|
||||
public int $skipped = 0;
|
||||
|
||||
/** Nicht verarbeitbar (unbekannte Anmeldung, unbrauchbarer Betrag). */
|
||||
public int $failed = 0;
|
||||
}
|
||||
+2
-1
@@ -12,7 +12,8 @@ class CertificateOfConductionCheckCommand {
|
||||
public function execute() : CertificateOfConductionCheckResponse {
|
||||
$response = new CertificateOfConductionCheckResponse();
|
||||
|
||||
$localGroup = str_replace('Stamm ', '', $this->request->participant->localGroup()->first()->name);
|
||||
// Der Stamm ist optional (die Kurzanmeldung erhebt ihn nicht, in der Verwaltung kann er entfernt werden).
|
||||
$localGroup = str_replace('Stamm ', '', $this->request->participant->localGroup()->first()?->name ?? '');
|
||||
|
||||
$apiResponse = Http::acceptJson()
|
||||
->asJson()
|
||||
|
||||
@@ -28,7 +28,7 @@ class CreateEventCommand {
|
||||
}
|
||||
|
||||
|
||||
$tenant = app('tenant');
|
||||
$tenant = currentTenant();
|
||||
|
||||
// Anlage als Ganzes: der Event-Teil der Rechnungsnummer wird unter der Sperre vergeben und muss
|
||||
// im selben Zug geschrieben werden, sonst könnten zwei gleichzeitige Anlagen denselben erhalten.
|
||||
@@ -38,6 +38,8 @@ class CreateEventCommand {
|
||||
'name' => $this->request->name,
|
||||
'identifier' => Str::random(10),
|
||||
'location' => $this->request->location,
|
||||
'street' => $this->normalizeOptional($this->request->street),
|
||||
'house_number' => $this->normalizeOptional($this->request->houseNumber),
|
||||
'postal_code' => $this->request->postalCode,
|
||||
'email' => $this->request->email,
|
||||
'start_date' => $this->request->begin,
|
||||
@@ -91,12 +93,12 @@ class CreateEventCommand {
|
||||
]);
|
||||
}
|
||||
|
||||
if (app('tenant')->slug === 'lv') {
|
||||
if (currentTenant()->slug === 'lv') {
|
||||
foreach(Tenant::where(['is_active_local_group' => true])->get() as $tenant) {
|
||||
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => $tenant->id]);
|
||||
}
|
||||
} else {
|
||||
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => app('tenant')->id]);
|
||||
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => currentTenant()->id]);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +109,17 @@ class CreateEventCommand {
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Straße und Hausnummer sind optional. Ein leer gelassenes Eingabefeld liefert einen leeren String --
|
||||
* gespeichert wird dafür `null`, damit „nicht angegeben" nur eine Darstellung hat.
|
||||
*/
|
||||
private function normalizeOptional(?string $value): ?string
|
||||
{
|
||||
$value = trim((string) $value);
|
||||
|
||||
return '' === $value ? null : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event-Teil der Rechnungsnummer, z.B. `WM-V-20260701`: Tenant-Präfix, Dokumentart „V" für
|
||||
* Veranstaltung, dann ohne Trenner Jahr, Monat des Beginns und die laufende Nummer der
|
||||
|
||||
@@ -19,8 +19,10 @@ class CreateEventRequest {
|
||||
public string $accountOwner;
|
||||
public string $accountIban;
|
||||
public bool $payPerDay;
|
||||
public ?string $street;
|
||||
public ?string $houseNumber;
|
||||
|
||||
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) {
|
||||
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, ?string $street = null, ?string $houseNumber = null) {
|
||||
$this->name = $name;
|
||||
$this->location = $location;
|
||||
$this->postalCode = $postalCode;
|
||||
@@ -34,5 +36,7 @@ class CreateEventRequest {
|
||||
$this->accountOwner = $accountOwner;
|
||||
$this->accountIban = $accountIban;
|
||||
$this->payPerDay = $payPerDay;
|
||||
$this->street = $street;
|
||||
$this->houseNumber = $houseNumber;
|
||||
}
|
||||
}
|
||||
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\CreateIncomeSurplusStatement;
|
||||
|
||||
use App\Enumerations\ParticipationType;
|
||||
use App\Models\CostUnit;
|
||||
use App\Models\Event;
|
||||
use App\Providers\PdfGenerateAndDownloadProvider;
|
||||
use App\Repositories\CostUnitRepository;
|
||||
use App\ValueObjects\Amount;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Erzeugt die Einnahmen-Überschuss-Rechnung einer Veranstaltung als PDF.
|
||||
*
|
||||
* Gezeigt wird ausschließlich Geld, das geflossen ist: gezahlte Beiträge, weitere Einnahmen, was von
|
||||
* Abmeldungen einbehalten wurde, Fördermittel -- und auf der anderen Seite die erfassten Belege. Was nur
|
||||
* erwartet (offene Beiträge) oder geplant (Budgetwerte) ist, gehört in eine Einnahmen-Überschuss-Rechnung
|
||||
* nicht hinein.
|
||||
*
|
||||
* Es wird nichts gespeichert: Alle Zahlen leiten sich aus dem aktuellen Stand ab, ein erneuter Abruf
|
||||
* liefert den dann gültigen Stand.
|
||||
*/
|
||||
class CreateIncomeSurplusStatementCommand
|
||||
{
|
||||
private Event $event;
|
||||
|
||||
private CostUnitRepository $costUnits;
|
||||
|
||||
public function __construct(private readonly CreateIncomeSurplusStatementRequest $request)
|
||||
{
|
||||
$this->event = $request->event;
|
||||
$this->costUnits = new CostUnitRepository();
|
||||
}
|
||||
|
||||
public function execute(): CreateIncomeSurplusStatementResponse
|
||||
{
|
||||
$response = new CreateIncomeSurplusStatementResponse();
|
||||
|
||||
$costUnit = $this->event->costUnit()->first();
|
||||
|
||||
if (!$costUnit instanceof CostUnit) {
|
||||
$response->message = 'Der Veranstaltung ist keine Kostenstelle zugeordnet.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Der Pauschalbetrag wird vor dem Resource-Aufruf gelesen: `EventResource::calculateSupportPerPerson()`
|
||||
// multipliziert das Amount-Objekt von `support_per_person` in place. Auf `support_flat` wirkt das
|
||||
// zwar nicht, aber der gesamte Zugriff auf Beträge des Models ist danach nicht mehr vertrauenswürdig.
|
||||
$otherIncome = $this->event->support_flat->getAmount();
|
||||
|
||||
$eventData = $this->event->toResource()->toArray(new Request());
|
||||
|
||||
$income = $this->buildIncome($eventData, $otherIncome);
|
||||
$expenses = $this->buildExpenses($costUnit);
|
||||
|
||||
$result = new Amount($income['total']->getAmount() - $expenses['total']->getAmount(), 'Euro');
|
||||
|
||||
$html = view('pdfs.income-surplus-statement', [
|
||||
'event' => $this->event,
|
||||
'createdAt' => new \DateTime()->format('d.m.Y'),
|
||||
'income' => $income,
|
||||
'expenses' => $expenses,
|
||||
'result' => $result,
|
||||
'money' => self::money(...),
|
||||
])->render();
|
||||
|
||||
$response->success = true;
|
||||
$response->filename = 'EUER-' . $this->event->identifier . '.pdf';
|
||||
$response->income = $income;
|
||||
$response->expenses = $expenses;
|
||||
$response->result = $result;
|
||||
$response->pdfContent = PdfGenerateAndDownloadProvider::fromHtml($html, 'portrait');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Einnahmenseite in zwei Ober-Kategorien.
|
||||
*
|
||||
* Alle Zahlen stammen aus {@see \App\Resources\EventResource} -- derselben Quelle wie die
|
||||
* Veranstaltungsübersicht am Bildschirm. Eine eigene Rechnung daneben würde über kurz oder lang von
|
||||
* der Übersicht abweichen, und dann glaubt niemand mehr einer der beiden Zahlen.
|
||||
*
|
||||
* @param array<string, mixed> $eventData
|
||||
*
|
||||
* @return array{categories: array<int, array{name: string, total: Amount, entries: array<int, array{name: string, amount: Amount}>}>, total: Amount}
|
||||
*/
|
||||
private function buildIncome(array $eventData, float $otherIncome): array
|
||||
{
|
||||
// Beiträge aller Teilnahmearten in einer Zeile: Für die Mittelverwendung zählt, was an Beiträgen
|
||||
// hereingekommen ist, nicht von wem.
|
||||
$participationFees = new Amount(0, 'Euro');
|
||||
foreach ([
|
||||
ParticipationType::PARTICIPATION_TYPE_PARTICIPANT,
|
||||
ParticipationType::PARTICIPATION_TYPE_TEAM,
|
||||
ParticipationType::PARTICIPATION_TYPE_VOLUNTEER,
|
||||
ParticipationType::PARTICIPATION_TYPE_OTHER,
|
||||
] as $participationType) {
|
||||
$participationFees->addAmount(
|
||||
new Amount((float) $eventData['participants'][$participationType]['amount']['paid']['value'], 'Euro')
|
||||
);
|
||||
}
|
||||
|
||||
$ownFunds = [
|
||||
['name' => 'Teilnahmebeiträge', 'amount' => $participationFees],
|
||||
['name' => 'Weitere Einnahmen', 'amount' => new Amount($otherIncome, 'Euro')],
|
||||
[
|
||||
'name' => 'Einbehaltene Einnahmen aus Abmeldungen',
|
||||
'amount' => new Amount((float) $eventData['retainedFromUnregistered']['value'], 'Euro'),
|
||||
],
|
||||
];
|
||||
|
||||
$supportRate = new Amount((float) $eventData['supportPersonValue'], 'Euro');
|
||||
$funding = [
|
||||
[
|
||||
'name' => 'Fördermittel (' . self::money($supportRate) . ' € p.P./Tag)',
|
||||
'amount' => new Amount($eventData['supportPerson']['amount']->getAmount(), 'Euro'),
|
||||
],
|
||||
];
|
||||
|
||||
$categories = [
|
||||
['name' => 'Eigenmittel', 'entries' => $ownFunds, 'total' => self::sum($ownFunds)],
|
||||
['name' => 'Förderungen', 'entries' => $funding, 'total' => self::sum($funding)],
|
||||
];
|
||||
|
||||
return [
|
||||
'categories' => $categories,
|
||||
'total' => self::sum($categories),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Ausgabenseite: eine Zeile je Ausgabentyp, dazu die Belege für die Anlage.
|
||||
*
|
||||
* @return array{groups: array<int, array{name: string, sum: Amount, rows: array<int, array{number: string, date: string, purpose: string, amount: Amount}>}>, total: Amount}
|
||||
*/
|
||||
private function buildExpenses(CostUnit $costUnit): array
|
||||
{
|
||||
$groups = [];
|
||||
$total = new Amount(0, 'Euro');
|
||||
|
||||
foreach ($this->costUnits->groupExpensesByType($costUnit) as $group) {
|
||||
$rows = [];
|
||||
|
||||
foreach ($group['invoices'] as $invoice) {
|
||||
$rows[] = [
|
||||
'number' => (string) $invoice->invoice_number,
|
||||
'date' => $invoice->created_at?->format('d.m.Y') ?? '',
|
||||
// Ohne die Anmerkung: dort steht, was die Kassenwart*in beim Korrigieren notiert hat,
|
||||
// und das gehört auf den Beleg, nicht in den Zweck.
|
||||
'purpose' => $invoice->purposeText(),
|
||||
'amount' => Amount::fromString($invoice->amount),
|
||||
];
|
||||
}
|
||||
|
||||
$groups[] = [
|
||||
'name' => $group['type']->name,
|
||||
'sum' => $group['sum'],
|
||||
'rows' => $rows,
|
||||
];
|
||||
|
||||
$total->addAmount($group['sum']);
|
||||
}
|
||||
|
||||
return ['groups' => $groups, 'total' => $total];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Betrag in deutscher Schreibweise: Punkt als Tausender-, Komma als Dezimaltrennzeichen.
|
||||
*
|
||||
* Bewusst nicht {@see Amount::getFormattedAmount()}: Die Methode ersetzt nach `number_format` jeden
|
||||
* Punkt durch ein Komma und macht aus 1.487,50 damit "1,487,50". Auf einer Aufstellung, in der
|
||||
* vierstellige Beträge die Regel sind, wäre das nicht lesbar. Der Fehler steckt im Value Object und
|
||||
* wirkt überall, wo Beträge angezeigt werden -- ihn dort zu beheben ist eine eigene Änderung.
|
||||
*
|
||||
* Öffentlich, weil die Vorlage sie als Callable bekommt und weil sie für sich prüfbar sein soll.
|
||||
*/
|
||||
public static function money(Amount $amount): string
|
||||
{
|
||||
return number_format(round($amount->getAmount(), 2), 2, ',', '.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Summiert Zeilen, die je ein `amount` oder `total` tragen.
|
||||
*
|
||||
* Über ein frisches Amount-Objekt, weil `Amount::addAmount()` den Empfänger verändert -- die
|
||||
* Einzelbeträge sollen unangetastet bleiben, sie werden anschließend gedruckt.
|
||||
*
|
||||
* @param array<int, array<string, mixed>> $rows
|
||||
*/
|
||||
private static function sum(array $rows): Amount
|
||||
{
|
||||
$sum = new Amount(0, 'Euro');
|
||||
|
||||
foreach ($rows as $row) {
|
||||
/** @var Amount $amount */
|
||||
$amount = $row['amount'] ?? $row['total'];
|
||||
$sum->addAmount($amount);
|
||||
}
|
||||
|
||||
return $sum;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\CreateIncomeSurplusStatement;
|
||||
|
||||
use App\Models\Event;
|
||||
|
||||
class CreateIncomeSurplusStatementRequest
|
||||
{
|
||||
public function __construct(public readonly Event $event)
|
||||
{
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\CreateIncomeSurplusStatement;
|
||||
|
||||
use App\ValueObjects\Amount;
|
||||
|
||||
class CreateIncomeSurplusStatementResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
|
||||
public string $filename = '';
|
||||
|
||||
public string $pdfContent = '';
|
||||
|
||||
public ?string $message = null;
|
||||
|
||||
/**
|
||||
* Die Zahlen, aus denen das PDF entsteht -- Einnahmen-Kategorien, Ausgaben-Gruppen und das Ergebnis.
|
||||
*
|
||||
* Sie stehen hier, weil sie das eigentliche Ergebnis der Action sind; das PDF ist nur ihre Darstellung.
|
||||
* So lässt sich die Rechnung prüfen, ohne ein PDF zerlegen zu müssen.
|
||||
*
|
||||
* @var array{categories: array<int, array{name: string, total: Amount, entries: array<int, array{name: string, amount: Amount}>}>, total: Amount}|array{}
|
||||
*/
|
||||
public array $income = [];
|
||||
|
||||
/**
|
||||
* @var array{groups: array<int, array{name: string, sum: Amount, rows: array<int, array<string, mixed>>}>, total: Amount}|array{}
|
||||
*/
|
||||
public array $expenses = [];
|
||||
|
||||
public ?Amount $result = null;
|
||||
}
|
||||
@@ -13,18 +13,18 @@ class GenerateIcalCommand
|
||||
$participant = $this->request->participant;
|
||||
$event = $participant->event;
|
||||
|
||||
$uid = $participant->identifier . '@' . app('tenant')->slug;
|
||||
$uid = $participant->identifier . '@' . currentTenant()->slug;
|
||||
$dtStart = $event->start_date->format('Ymd');
|
||||
$dtEnd = $event->end_date->copy()->addDay()->format('Ymd');
|
||||
$now = now()->format('Ymd\THis\Z');
|
||||
$summary = $this->escapeIcal($event->name);
|
||||
$location = $this->escapeIcal(trim($event->postal_code . ' ' . $event->location));
|
||||
$location = $this->escapeIcal($event->getFullAddress());
|
||||
$description = $this->escapeIcal('Teilnahme als: ' . $participant->getOfficialName());
|
||||
|
||||
$icalContent = implode("\r\n", [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
'PRODID:-//' . app('tenant')->name . '//Veranstaltungskalender//DE',
|
||||
'PRODID:-//' . currentTenant()->name . '//Veranstaltungskalender//DE',
|
||||
'CALSCALE:GREGORIAN',
|
||||
'METHOD:PUBLISH',
|
||||
'BEGIN:VEVENT',
|
||||
|
||||
+2
-2
@@ -21,11 +21,11 @@ class GenerateIcalForDeadlineCommand {
|
||||
$icalContent = implode("\r\n", [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
'PRODID:-//' . app('tenant')->name . '//Veranstaltungskalender//DE',
|
||||
'PRODID:-//' . currentTenant()->name . '//Veranstaltungskalender//DE',
|
||||
'CALSCALE:GREGORIAN',
|
||||
'METHOD:PUBLISH',
|
||||
'BEGIN:VEVENT',
|
||||
'UID:payment-deadline-' . $event->identifier . '@' . app('tenant')->slug,
|
||||
'UID:payment-deadline-' . $event->identifier . '@' . currentTenant()->slug,
|
||||
'DTSTAMP:' . $now,
|
||||
'DTSTART;VALUE=DATE:' . $dtDate,
|
||||
'DTEND;VALUE=DATE:' . $dtDate,
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\ParseBankStatement;
|
||||
|
||||
use App\EventPaymentModules\EventPaymentModuleRegistry;
|
||||
use App\EventPaymentModules\ProvidesStatementRuleset;
|
||||
use App\EventPaymentModules\ReadsBankStatements;
|
||||
use App\Models\EventParticipant;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Providers\BankStatementParseProvider;
|
||||
use App\Repositories\EventParticipantRepository;
|
||||
use App\Support\BankStatementParseException;
|
||||
use App\ValueObjects\BankStatementRuleset;
|
||||
use App\ValueObjects\BankTransaction;
|
||||
|
||||
/**
|
||||
* Liest einen hochgeladenen Kontoauszug und schlägt je Zahlungseingang eine Anmeldung vor.
|
||||
*
|
||||
* Hier wird nichts gebucht -- das Ergebnis ist die Prüfansicht, in der die Aktionsleitung die
|
||||
* Vorschläge bestätigt, korrigiert oder verwirft. Erst der zweite Schritt schreibt.
|
||||
*
|
||||
* Der Ablauf ist zahlartneutral: Was ein verwertbarer Umsatz ist und zu wem er gehört, entscheidet
|
||||
* das Zahlungsmodul über {@see ReadsBankStatements}.
|
||||
*/
|
||||
class ParseBankStatementCommand
|
||||
{
|
||||
/** 8 MB -- ein Jahresauszug bleibt weit darunter, alles darüber ist die falsche Datei. */
|
||||
private const int MAX_BYTES = 8 * 1024 * 1024;
|
||||
|
||||
private const array ALLOWED_EXTENSIONS = ['csv', 'txt'];
|
||||
|
||||
public function __construct(private readonly ParseBankStatementRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): ParseBankStatementResponse
|
||||
{
|
||||
$response = new ParseBankStatementResponse();
|
||||
|
||||
$module = EventPaymentModuleRegistry::forSlug(PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION);
|
||||
if (!$module instanceof ReadsBankStatements) {
|
||||
$response->message = 'Für die Überweisung ist kein Kontoauszug-Import eingerichtet.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$contents = $this->readFile($response);
|
||||
if ($contents === null) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$ruleset = $module instanceof ProvidesStatementRuleset
|
||||
? $module->statementRuleset($this->request->configuration)
|
||||
: BankStatementRuleset::default();
|
||||
|
||||
try {
|
||||
$transactions = new BankStatementParseProvider()->parse($contents, $ruleset);
|
||||
} catch (BankStatementParseException $exception) {
|
||||
$response->message = $exception->getMessage();
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$candidates = new EventParticipantRepository()->getForPaymentMatching($this->request->event);
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
if (!$module->isRelevantTransaction($transaction)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$match = $module->matchTransaction($transaction, $candidates);
|
||||
|
||||
// Vor der letzten erfassten Zahlung dieser Person: schon gebucht, oder aus einem Auszug,
|
||||
// der bereits verarbeitet wurde. Gar nicht erst anzeigen.
|
||||
if ($match !== null && $this->isBeforeWatermark($match->participant, $transaction)) {
|
||||
$response->skippedOlderThanWatermark++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$response->rows[] = $transaction->toArray() + [
|
||||
'suggestedIdentifier' => $match?->participant->identifier,
|
||||
'confidence' => $match?->confidence,
|
||||
];
|
||||
}
|
||||
|
||||
$response->participants = $candidates
|
||||
->map(fn (EventParticipant $participant): array => $this->participantOption($participant))
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$response->success = true;
|
||||
$response->message = $this->summaryMessage($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function readFile(ParseBankStatementResponse $response): ?string
|
||||
{
|
||||
$file = $this->request->file;
|
||||
|
||||
if ($file === null || !$file->isValid()) {
|
||||
$response->message = 'Es wurde keine Datei hochgeladen.';
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($file->getSize() > self::MAX_BYTES) {
|
||||
$response->message = 'Die Datei ist zu groß (maximal 8 MB).';
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!in_array(strtolower($file->getClientOriginalExtension()), self::ALLOWED_EXTENSIONS, true)) {
|
||||
$response->message = 'Bitte den CSV-Export der Bank hochladen (.csv).';
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$contents = file_get_contents($file->getRealPath());
|
||||
|
||||
if ($contents === false || trim($contents) === '') {
|
||||
$response->message = 'Die Datei ließ sich nicht lesen oder ist leer.';
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
private function isBeforeWatermark(EventParticipant $participant, BankTransaction $transaction): bool
|
||||
{
|
||||
$watermark = $participant->last_payment_date;
|
||||
|
||||
// Echt kleiner, nicht kleiner-gleich: Zwei Zahlungen am selben Tag sollen beide ankommen.
|
||||
return $watermark !== null && $transaction->paymentDate->startOfDay()->lt($watermark->startOfDay());
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function participantOption(EventParticipant $participant): array
|
||||
{
|
||||
$amountLeft = clone $participant->amount;
|
||||
if ($participant->amount_paid !== null) {
|
||||
$amountLeft->subtractAmount($participant->amount_paid);
|
||||
}
|
||||
|
||||
return [
|
||||
'identifier' => $participant->identifier,
|
||||
'name' => $participant->lastname . ', ' . $participant->firstname,
|
||||
'amount' => $participant->amount?->toString(),
|
||||
'amountPaid' => $participant->amount_paid?->toString(),
|
||||
'amountOpen' => $amountLeft->toString(),
|
||||
'isSettled' => round($amountLeft->getAmount(), 2) <= 0,
|
||||
'lastPaymentDate' => $participant->last_payment_date?->format('d.m.Y'),
|
||||
// Zahlt jemand, der sich abgemeldet hat, wird die Zahlung trotzdem erfasst -- danach
|
||||
// steht aber eine Erstattung an. Die Prüfansicht weist darauf hin.
|
||||
'isSignedOff' => $participant->unregistered_at !== null,
|
||||
'signedOffAt' => $participant->unregistered_at?->format('d.m.Y'),
|
||||
];
|
||||
}
|
||||
|
||||
private function summaryMessage(ParseBankStatementResponse $response): string
|
||||
{
|
||||
if ($response->rows === []) {
|
||||
return $response->skippedOlderThanWatermark > 0
|
||||
? 'Alle Zahlungseingänge dieser Datei wurden bereits erfasst.'
|
||||
: 'In der Datei sind keine Zahlungseingänge zu dieser Aktion enthalten.';
|
||||
}
|
||||
|
||||
$assigned = count(array_filter($response->rows, static fn (array $row): bool => $row['suggestedIdentifier'] !== null));
|
||||
|
||||
$message = sprintf(
|
||||
'%d Zahlungseingänge gelesen, %d davon konnten zugeordnet werden.',
|
||||
count($response->rows),
|
||||
$assigned,
|
||||
);
|
||||
|
||||
if ($response->skippedOlderThanWatermark > 0) {
|
||||
$message .= sprintf(' %d bereits erfasste Zahlungen wurden übersprungen.', $response->skippedOlderThanWatermark);
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\ParseBankStatement;
|
||||
|
||||
use App\Models\Event;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
|
||||
class ParseBankStatementRequest
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $configuration Tenant-Konfiguration der Überweisung. Wird hereingereicht
|
||||
* statt hier geholt -- den DB-Zugriff macht der Controller
|
||||
* über das Repository.
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly Event $event,
|
||||
public readonly ?UploadedFile $file,
|
||||
public readonly array $configuration = [],
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\ParseBankStatement;
|
||||
|
||||
class ParseBankStatementResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
public string $message = '';
|
||||
|
||||
/**
|
||||
* Eine Zeile je verwertbarem Umsatz, fertig für die Prüfansicht.
|
||||
*
|
||||
* @var array<int, array<string, mixed>>
|
||||
*/
|
||||
public array $rows = [];
|
||||
|
||||
/**
|
||||
* Alle zuordenbaren Anmeldungen der Aktion für die Auswahlliste.
|
||||
*
|
||||
* @var array<int, array<string, mixed>>
|
||||
*/
|
||||
public array $participants = [];
|
||||
|
||||
/**
|
||||
* Umsätze, die vor der zuletzt erfassten Zahlung der erkannten Person liegen. Sie erscheinen gar
|
||||
* nicht erst in der Prüfansicht -- gezählt werden sie trotzdem, sonst bliebe unerklärt, warum
|
||||
* eine Datei mit 40 Zeilen nur 12 Vorschläge ergibt.
|
||||
*/
|
||||
public int $skippedOlderThanWatermark = 0;
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class SetParticipationFeesCommand {
|
||||
$this->cleanBefore();
|
||||
|
||||
$this->request->event->participationFee1()->associate(EventParticipationFee::create([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'type' => $this->request->participationFeeFirst['type'],
|
||||
'name' => $this->request->participationFeeFirst['name'],
|
||||
'description' => $this->request->participationFeeFirst['description'],
|
||||
@@ -29,7 +29,7 @@ class SetParticipationFeesCommand {
|
||||
|
||||
if ($this->request->participationFeeSecond !== null) {
|
||||
$this->request->event->participationFee2()->associate(EventParticipationFee::create([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'type' => $this->request->participationFeeSecond['type'],
|
||||
'name' => $this->request->participationFeeSecond['name'],
|
||||
'description' => $this->request->participationFeeSecond['description'],
|
||||
@@ -41,7 +41,7 @@ class SetParticipationFeesCommand {
|
||||
|
||||
if ($this->request->participationFeeThird !== null) {
|
||||
$this->request->event->participationFee3()->associate(EventParticipationFee::create([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'type' => $this->request->participationFeeThird['type'],
|
||||
'name' => $this->request->participationFeeThird['name'],
|
||||
'description' => $this->request->participationFeeThird['description'],
|
||||
@@ -53,7 +53,7 @@ class SetParticipationFeesCommand {
|
||||
|
||||
if ($this->request->participationFeeFourth !== null) {
|
||||
$this->request->event->participationFee4()->associate(EventParticipationFee::create([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'type' => $this->request->participationFeeFourth['type'],
|
||||
'name' => $this->request->participationFeeFourth['name'],
|
||||
'description' => $this->request->participationFeeFourth['description'],
|
||||
|
||||
@@ -64,7 +64,7 @@ class SetPaymentMethodsCommand
|
||||
// Bestehende Zuweisung: Config nur bei explizitem Override anpassen, sonst unverändert lassen.
|
||||
if ($override !== null) {
|
||||
$row = $existing[$slug];
|
||||
$row->configuration = PaymentMethod::sanitizeConfiguration($slug, $override);
|
||||
$row->configuration = $this->eventConfiguration($slug, $override);
|
||||
$row->save();
|
||||
}
|
||||
continue;
|
||||
@@ -75,8 +75,27 @@ class SetPaymentMethodsCommand
|
||||
EventPaymentMethods::create([
|
||||
'event_id' => $event->id,
|
||||
'slug' => $slug,
|
||||
'configuration' => PaymentMethod::sanitizeConfiguration($slug, $snapshot ?? []),
|
||||
'configuration' => $this->eventConfiguration($slug, $snapshot ?? []),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Was von einer Konfiguration am Event gespeichert wird.
|
||||
*
|
||||
* Neben dem Zuschnitt aufs Schema fallen hier die tenant-weiten Optionen heraus. Das
|
||||
* Kontoauszug-Format etwa beschreibt die Bank, nicht die Zusage an die Teilnehmenden -- eingefroren
|
||||
* ließe sich nach einem Bankwechsel für laufende Aktionen nichts mehr importieren. IBAN und
|
||||
* Kontoinhaber frieren dagegen weiterhin pro Aktion ein.
|
||||
*
|
||||
* @param array<string, mixed> $configuration
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function eventConfiguration(string $slug, array $configuration): array
|
||||
{
|
||||
return PaymentMethod::stripTenantScopedOptions(
|
||||
$slug,
|
||||
PaymentMethod::sanitizeConfiguration($slug, $configuration),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\ShortSignUp;
|
||||
|
||||
use App\Domains\Event\Actions\SignUp\SignUpCommand;
|
||||
use App\Domains\Event\Actions\SignUp\SignUpRequest;
|
||||
use App\ValueObjects\Age;
|
||||
|
||||
/**
|
||||
* Verkürzte Anmeldung: ergänzt die nicht erhobenen Pflichtangaben um Platzhalter und übergibt an die reguläre
|
||||
* Anmelde-Action. Dadurch gelten für Kurzanmeldungen dieselben Regeln wie für jede andere Anmeldung
|
||||
* (Transaktion, laufende Rechnungsnummer, eFZ-Vorbelegung, Snapshot der Teilnahmeoptionen).
|
||||
*/
|
||||
class ShortSignUpCommand {
|
||||
/** Platzhalter für Angaben, die die Kurzanmeldung nicht erhebt. */
|
||||
private const string PLACEHOLDER = 'Nicht erforderlich';
|
||||
|
||||
/**
|
||||
* Die Postleitzahl bekommt bewusst keinen Text-Platzhalter: aus ihr wird in Teilnehmerliste und CSV-Export
|
||||
* das Bundesland abgeleitet.
|
||||
*/
|
||||
private const string PLACEHOLDER_POSTCODE = '00000';
|
||||
|
||||
public function __construct(public ShortSignUpRequest $request) {
|
||||
}
|
||||
|
||||
public function execute() : ShortSignUpResponse {
|
||||
$response = new ShortSignUpResponse();
|
||||
|
||||
// Ohne konfigurierte Teilnahmegruppe gäbe es keinen gültigen `participation_type` -- sauber abbrechen,
|
||||
// statt in einen Fremdschlüssel-Fehler zu laufen.
|
||||
$participationType = $this->request->event->firstParticipationTypeSlug();
|
||||
if ($participationType === null) {
|
||||
$response->message = 'Für diese Veranstaltung ist noch keine Teilnahmegruppe hinterlegt.';
|
||||
return $response;
|
||||
}
|
||||
|
||||
$participantAge = new Age($this->request->birthday);
|
||||
|
||||
// Bei Minderjährigen ist die Kontaktperson Pflicht; der Client prüft das ebenfalls, verlassen wird sich
|
||||
// darauf nicht.
|
||||
if (!$participantAge->isfullAged()
|
||||
&& ($this->request->contactPerson === null || $this->request->contactEmail === null)) {
|
||||
$response->message = 'Für Minderjährige werden Name und E-Mail-Adresse einer Kontaktperson benötigt.';
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Stamm: bei genau einem teilnehmenden Stamm wird dieser gesetzt, bei mehreren muss gewählt werden,
|
||||
// ohne teilnehmende Stämme bleibt die Zuordnung leer.
|
||||
$localGroups = $this->request->event->localGroups;
|
||||
$localGroup = null;
|
||||
|
||||
if ($localGroups->count() === 1) {
|
||||
$localGroup = $localGroups->first();
|
||||
} elseif ($localGroups->count() > 1) {
|
||||
$localGroup = $localGroups->firstWhere('id', $this->request->localGroupId);
|
||||
|
||||
if ($localGroup === null) {
|
||||
$response->message = 'Bitte einen Stamm auswählen.';
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
$eventResource = $this->request->event->toResource();
|
||||
|
||||
// Zeitraum, Gruppe und Beitragsstufe stehen bei der Kurzanmeldung fest -- es gibt nichts zu wählen.
|
||||
$amount = $eventResource->calculateAmount(
|
||||
$participationType,
|
||||
'standard',
|
||||
$this->request->event->start_date,
|
||||
$this->request->event->end_date,
|
||||
false
|
||||
);
|
||||
|
||||
$signUpRequest = new SignUpRequest(
|
||||
event: $this->request->event,
|
||||
user_id: $this->request->user_id,
|
||||
firstname: $this->request->firstname,
|
||||
lastname: $this->request->lastname,
|
||||
nickname: $this->request->nickname,
|
||||
participationType: $participationType,
|
||||
localGroup: $localGroup,
|
||||
birthday: $this->request->birthday,
|
||||
address_1: self::PLACEHOLDER,
|
||||
address_2: null,
|
||||
postcode: self::PLACEHOLDER_POSTCODE,
|
||||
city: self::PLACEHOLDER,
|
||||
email_1: $this->request->email,
|
||||
phone_1: $this->request->phone,
|
||||
email_2: $this->request->contactEmail,
|
||||
phone_2: null,
|
||||
contact_person: $this->request->contactPerson,
|
||||
allergies: $this->request->allergies,
|
||||
intolerances: $this->request->intolerances,
|
||||
medications: null,
|
||||
tetanus_vaccination: null,
|
||||
// Kein Wert der Zuordnung -- der SignUpCommand fällt damit auf "Omnivor" zurück.
|
||||
eating_habit: '',
|
||||
swimming_permission: $this->resolveSwimmingPermission($participantAge),
|
||||
first_aid_permission: $participantAge->isfullAged() ? '-1' : ($this->request->firstAidPermission ?? '-1'),
|
||||
foto_socialmedia: $this->request->foto_socialmedia,
|
||||
foto_print: $this->request->foto_print,
|
||||
foto_webseite: $this->request->foto_webseite,
|
||||
foto_partner: $this->request->foto_partner,
|
||||
foto_intern: $this->request->foto_intern,
|
||||
arrival: $this->request->event->start_date,
|
||||
departure: $this->request->event->end_date,
|
||||
arrival_eating: 1,
|
||||
departure_eating: 2,
|
||||
notes: null,
|
||||
amount: $amount,
|
||||
paymentMethod: $this->request->paymentMethod,
|
||||
paymentOptions: $this->request->paymentOptions,
|
||||
participationOptions: $this->request->participationOptions,
|
||||
addonItems: [],
|
||||
feeType: 'standard',
|
||||
siblingReduction: false,
|
||||
);
|
||||
|
||||
$signUpResponse = new SignUpCommand($signUpRequest)->execute();
|
||||
|
||||
$response->success = $signUpResponse->success;
|
||||
$response->participant = $signUpResponse->participant;
|
||||
$response->message = $signUpResponse->message;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bei Volljährigen und wenn die Veranstaltung die Badeerlaubnis nicht abfragt, entscheidet der SignUpCommand
|
||||
* (volljährig => erteilt, nicht abgefragt => keine). Nur die getroffene Auswahl Minderjähriger wird
|
||||
* durchgereicht.
|
||||
*/
|
||||
private function resolveSwimmingPermission(Age $participantAge) : ?string
|
||||
{
|
||||
if ($participantAge->isfullAged() || !$this->request->event->swimming_permission_required) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->request->swimmingPermission;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\ShortSignUp;
|
||||
|
||||
use App\Models\Event;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* Eingabedaten der verkürzten Anmeldung -- ausschließlich das, was der Kurz-Wizard tatsächlich erhebt.
|
||||
* Alle übrigen Pflichtangaben des Teilnehmers setzt der Command auf Platzhalter.
|
||||
*/
|
||||
class ShortSignUpRequest {
|
||||
function __construct(
|
||||
public Event $event,
|
||||
public ?int $user_id,
|
||||
public string $firstname,
|
||||
public string $lastname,
|
||||
public ?string $nickname,
|
||||
public DateTime $birthday,
|
||||
public string $email,
|
||||
public string $phone,
|
||||
/**
|
||||
* Tenant-ID des Stamms. Nur gefüllt, wenn die Veranstaltung mehrere teilnehmende Stämme hat --
|
||||
* bei genau einem wird dieser gesetzt, ohne zu fragen.
|
||||
*/
|
||||
public ?int $localGroupId,
|
||||
/** Kontaktperson: nur bei Minderjährigen erhoben. */
|
||||
public ?string $contactPerson,
|
||||
public ?string $contactEmail,
|
||||
public ?string $allergies,
|
||||
public ?string $intolerances,
|
||||
/** Slug aus `first_aid_permissions`; nur bei Minderjährigen erhoben. */
|
||||
public ?string $firstAidPermission,
|
||||
/** Slug aus `swimming_permissions`; nur bei Minderjährigen und nur wenn die Veranstaltung sie abfragt. */
|
||||
public ?string $swimmingPermission,
|
||||
public bool $foto_socialmedia,
|
||||
public bool $foto_print,
|
||||
public bool $foto_webseite,
|
||||
public bool $foto_partner,
|
||||
public bool $foto_intern,
|
||||
public ?string $paymentMethod,
|
||||
public array $paymentOptions = [],
|
||||
/** Antworten auf die Teilnahmeoptionen: [ question_key => value ]. */
|
||||
public array $participationOptions = [],
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Actions\ShortSignUp;
|
||||
|
||||
use App\Models\EventParticipant;
|
||||
|
||||
class ShortSignUpResponse {
|
||||
public bool $success;
|
||||
public ?EventParticipant $participant;
|
||||
public ?string $message = null;
|
||||
|
||||
public function __construct() {
|
||||
$this->success = false;
|
||||
$this->participant = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Domains\Event\Actions\SignUp;
|
||||
|
||||
use App\Enumerations\EatingHabit;
|
||||
use App\Enumerations\EfzStatus;
|
||||
use App\Enumerations\SwimmingPermission;
|
||||
use App\EventPaymentModules\EventPaymentModuleRegistry;
|
||||
use App\ValueObjects\Age;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -59,7 +60,7 @@ class SignUpCommand {
|
||||
'participation_type' => $this->request->participationType,
|
||||
'fee_type' => $this->request->feeType,
|
||||
'sibling_reduction' => $this->request->siblingReduction,
|
||||
'local_group' => $this->request->localGroup->slug,
|
||||
'local_group' => $this->request->localGroup?->slug,
|
||||
'birthday' => $this->request->birthday,
|
||||
'address_1' => $this->request->address_1,
|
||||
'address_2' => $this->request->address_2,
|
||||
@@ -75,9 +76,7 @@ class SignUpCommand {
|
||||
'medications' => $this->request->medications,
|
||||
'tetanus_vaccination' => $this->request->tetanus_vaccination,
|
||||
'eating_habit' => $eatingHabit,
|
||||
'swimming_permission' => ($participantAge->isfullAged() || $this->request->swimming_permission === '-1')
|
||||
? 'SWIMMING_PERMISSION_ALLOWED'
|
||||
: $this->request->swimming_permission,
|
||||
'swimming_permission' => $this->resolveSwimmingPermission($participantAge),
|
||||
'first_aid_permission' => ($participantAge->isfullAged() || $this->request->first_aid_permission === '-1')
|
||||
? 'FIRST_AID_PERMISSION_ALLOWED'
|
||||
: $this->request->first_aid_permission,
|
||||
@@ -109,6 +108,26 @@ class SignUpCommand {
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Badeerlaubnis auflösen. Volljährige brauchen keine Erlaubnis. Für Minderjährige gilt die getroffene Auswahl;
|
||||
* fehlt sie -- weil die Veranstaltung die Badeerlaubnis gar nicht abfragt oder keine Wahl getroffen wurde --,
|
||||
* wird bewusst "Keine" hinterlegt und nicht etwa stillschweigend eine Erlaubnis angenommen.
|
||||
*/
|
||||
private function resolveSwimmingPermission(Age $participantAge): string
|
||||
{
|
||||
if ($participantAge->isfullAged()) {
|
||||
return SwimmingPermission::SWIMMING_PERMISSION_ALLOWED;
|
||||
}
|
||||
|
||||
if (!$this->request->event->swimming_permission_required
|
||||
|| $this->request->swimming_permission === null
|
||||
|| $this->request->swimming_permission === '-1') {
|
||||
return SwimmingPermission::SWIMMING_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
return $this->request->swimming_permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nächste laufende Nummer des Teilis innerhalb der Veranstaltung -- der letzte Block der
|
||||
* Rechnungsnummer. Die Event-Zeile wird gesperrt, damit gleichzeitige Anmeldungen derselben
|
||||
|
||||
@@ -15,7 +15,8 @@ class SignUpRequest {
|
||||
public string $lastname,
|
||||
public ?string $nickname,
|
||||
public string $participationType,
|
||||
public Tenant $localGroup,
|
||||
/** Stamm des Teilnehmers; in der Kurzanmeldung nicht erhoben und deshalb optional. */
|
||||
public ?Tenant $localGroup,
|
||||
public DateTime $birthday,
|
||||
public string $address_1,
|
||||
public ?string $address_2,
|
||||
|
||||
@@ -13,6 +13,8 @@ class UpdateEventCommand {
|
||||
|
||||
$this->request->event->name = $this->request->eventName;
|
||||
$this->request->event->location = $this->request->eventLocation;
|
||||
$this->request->event->street = $this->normalizeOptional($this->request->street);
|
||||
$this->request->event->house_number = $this->normalizeOptional($this->request->houseNumber);
|
||||
$this->request->event->postal_code = $this->request->postalCode;
|
||||
$this->request->event->email = $this->request->email;
|
||||
$this->request->event->early_bird_end = $this->request->earlyBirdEnd;
|
||||
@@ -22,6 +24,8 @@ class UpdateEventCommand {
|
||||
$this->request->event->support_flat = $this->request->flatSupport;
|
||||
$this->request->event->send_weekly_report = $this->request->sendWeeklyReports;
|
||||
$this->request->event->registration_allowed = $this->request->registrationAllowed;
|
||||
$this->request->event->short_registration = $this->request->shortRegistration;
|
||||
$this->request->event->swimming_permission_required = $this->request->swimmingPermissionRequired;
|
||||
$this->request->event->save();
|
||||
|
||||
$this->request->event->resetAllowedEatingHabits();
|
||||
@@ -40,4 +44,15 @@ class UpdateEventCommand {
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Straße und Hausnummer sind optional. Ein geleertes Eingabefeld liefert einen leeren String --
|
||||
* gespeichert wird dafür `null`, damit „nicht angegeben" nur eine Darstellung hat.
|
||||
*/
|
||||
private function normalizeOptional(?string $value): ?string
|
||||
{
|
||||
$value = trim((string) $value);
|
||||
|
||||
return '' === $value ? null : $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ class UpdateEventRequest {
|
||||
public Event $event;
|
||||
public string $eventName;
|
||||
public string $eventLocation;
|
||||
public ?string $street;
|
||||
public ?string $houseNumber;
|
||||
public string $postalCode;
|
||||
public string $email;
|
||||
public DateTime $earlyBirdEnd;
|
||||
@@ -17,16 +19,20 @@ class UpdateEventRequest {
|
||||
public int $alcoholicsAge;
|
||||
public bool $sendWeeklyReports;
|
||||
public bool $registrationAllowed;
|
||||
public bool $shortRegistration;
|
||||
public bool $swimmingPermissionRequired;
|
||||
public Amount $flatSupport;
|
||||
public Amount $supportPerPerson;
|
||||
public array $contributingLocalGroups;
|
||||
public 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)
|
||||
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, bool $shortRegistration = false, bool $swimmingPermissionRequired = true, ?string $street = null, ?string $houseNumber = null)
|
||||
{
|
||||
$this->event = $event;
|
||||
$this->eventName = $eventName;
|
||||
$this->eventLocation = $eventLocation;
|
||||
$this->street = $street;
|
||||
$this->houseNumber = $houseNumber;
|
||||
$this->postalCode = $postalCode;
|
||||
$this->email = $email;
|
||||
$this->earlyBirdEnd = $earlyBirdEnd;
|
||||
@@ -34,6 +40,8 @@ class UpdateEventRequest {
|
||||
$this->alcoholicsAge = $alcoholicsAge;
|
||||
$this->sendWeeklyReports = $sendWeeklyReports;
|
||||
$this->registrationAllowed = $registrationAllowed;
|
||||
$this->shortRegistration = $shortRegistration;
|
||||
$this->swimmingPermissionRequired = $swimmingPermissionRequired;
|
||||
$this->flatSupport = $flatSupport;
|
||||
$this->supportPerPerson = $supportPerPerson;
|
||||
$this->contributingLocalGroups = $contributingLocalGroups;
|
||||
|
||||
@@ -31,7 +31,8 @@ class UpdateParticipantCommand {
|
||||
$p->address_2 = $this->request->address_2;
|
||||
$p->postcode = $this->request->postcode;
|
||||
$p->city = $this->request->city;
|
||||
$p->local_group = $this->request->localgroup;
|
||||
// Leerer String würde als Fremdschlüssel scheitern -- kein Stamm heißt null.
|
||||
$p->local_group = $this->request->localgroup ?: null;
|
||||
$p->birthday = DateTime::createFromFormat('Y-m-d', $this->request->birthday);
|
||||
$p->email_1 = $this->request->email_1;
|
||||
$p->phone_1 = $this->request->phone_1;
|
||||
|
||||
@@ -14,7 +14,8 @@ class UpdateParticipantRequest {
|
||||
public ?string $address_2,
|
||||
public string $postcode,
|
||||
public string $city,
|
||||
public string $localgroup,
|
||||
/** Stamm-Slug; leer/null bei Anmeldungen, die keinen Stamm erfasst haben (Kurzanmeldung). */
|
||||
public ?string $localgroup,
|
||||
public string $birthday,
|
||||
public string $email_1,
|
||||
public string $phone_1,
|
||||
|
||||
@@ -17,6 +17,7 @@ class ArchivedEventsController extends CommonController
|
||||
'name' => $event->name,
|
||||
'location' => $event->location,
|
||||
'postalCode' => $event->postal_code,
|
||||
'fullAddress' => $event->getFullAddress(),
|
||||
'eventBegin' => $event->start_date->format('d.m.Y'),
|
||||
'eventEnd' => $event->end_date->format('d.m.Y'),
|
||||
];
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Controllers;
|
||||
|
||||
use App\Domains\Event\Actions\BookBankStatementPayments\BookBankStatementPaymentsCommand;
|
||||
use App\Domains\Event\Actions\BookBankStatementPayments\BookBankStatementPaymentsRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Bucht die in der Prüfansicht bestätigten Zahlungseingänge -- ein Aufruf für alle Zeilen.
|
||||
*/
|
||||
class BankStatementBookController extends CommonController
|
||||
{
|
||||
public function __invoke(int $eventId, Request $request): JsonResponse
|
||||
{
|
||||
$event = $this->events->getById($eventId);
|
||||
|
||||
if ($event === null) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Die Veranstaltung wurde nicht gefunden.']);
|
||||
}
|
||||
|
||||
$response = new BookBankStatementPaymentsCommand(new BookBankStatementPaymentsRequest(
|
||||
event: $event,
|
||||
bookings: (array) $request->input('bookings', []),
|
||||
))->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
'booked' => $response->booked,
|
||||
'skipped' => $response->skipped,
|
||||
'failed' => $response->failed,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Controllers;
|
||||
|
||||
use App\Domains\Event\Actions\ParseBankStatement\ParseBankStatementCommand;
|
||||
use App\Domains\Event\Actions\ParseBankStatement\ParseBankStatementRequest;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* Nimmt den CSV-Export der Bank entgegen und liefert die Prüfansicht zurück. Gebucht wird hier nichts.
|
||||
*/
|
||||
class BankStatementParseController extends CommonController
|
||||
{
|
||||
public function __invoke(int $eventId, Request $request): JsonResponse
|
||||
{
|
||||
$event = $this->events->getById($eventId);
|
||||
|
||||
if ($event === null) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Die Veranstaltung wurde nicht gefunden.']);
|
||||
}
|
||||
|
||||
// Das Kontoauszug-Format kommt vom Mandanten, nicht aus dem Event-Snapshot: Ein Bankwechsel
|
||||
// muss sofort auch für laufende Aktionen gelten.
|
||||
$configuration = $this->paymentMethods->tenantConfiguration(PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION);
|
||||
|
||||
$response = new ParseBankStatementCommand(new ParseBankStatementRequest(
|
||||
event: $event,
|
||||
file: $request->file('statement'),
|
||||
configuration: $configuration,
|
||||
))->execute();
|
||||
|
||||
return response()->json([
|
||||
'status' => $response->success ? 'success' : 'error',
|
||||
'message' => $response->message,
|
||||
'rows' => $response->rows,
|
||||
'participants' => $response->participants,
|
||||
'skipped' => $response->skippedOlderThanWatermark,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ use Illuminate\Http\Request;
|
||||
class CreateController extends CommonController {
|
||||
public function __invoke() {
|
||||
return new InertiaProvider('Event/Create', [
|
||||
'emailAddress' => auth()->user()->email,
|
||||
'emailAddress' => currentUserOrFail()->email,
|
||||
'eventAccount' => $this->tenant->account_name,
|
||||
'eventIban' => $this->tenant->account_iban,
|
||||
'eventPayPerDay' => $this->tenant->slug === 'lv' ? true : false,
|
||||
@@ -56,7 +56,9 @@ class CreateController extends CommonController {
|
||||
$participationFeeType,
|
||||
$request->input('eventAccount'),
|
||||
$request->input('eventIban'),
|
||||
$payPerDay
|
||||
$payPerDay,
|
||||
$request->input('eventStreet'),
|
||||
$request->input('eventHouseNumber')
|
||||
);
|
||||
|
||||
$wasSuccessful = false;
|
||||
|
||||
@@ -60,7 +60,11 @@ class DetailsController extends CommonController {
|
||||
$flatSupport,
|
||||
$supportPerPerson,
|
||||
$contributinLocalGroups,
|
||||
$eatingHabits
|
||||
$eatingHabits,
|
||||
(bool)$request->input('shortRegistration', false),
|
||||
(bool)$request->input('swimmingPermissionRequired', true),
|
||||
$request->input('street'),
|
||||
$request->input('houseNumber'),
|
||||
);
|
||||
|
||||
$eventUpdateCommand = new UpdateEventCommand($eventUpdateRequest);
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Controllers;
|
||||
|
||||
use App\Domains\Event\Actions\CreateIncomeSurplusStatement\CreateIncomeSurplusStatementCommand;
|
||||
use App\Domains\Event\Actions\CreateIncomeSurplusStatement\CreateIncomeSurplusStatementRequest;
|
||||
use App\Scopes\CommonController;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class IncomeSurplusStatementController extends CommonController
|
||||
{
|
||||
public function __invoke(string $eventId): Response
|
||||
{
|
||||
$event = $this->events->getByIdentifier($eventId);
|
||||
|
||||
if ($event === null) {
|
||||
abort(403, 'Zugriff verweigert.');
|
||||
}
|
||||
|
||||
$statementRequest = new CreateIncomeSurplusStatementRequest($event);
|
||||
$statementCommand = new CreateIncomeSurplusStatementCommand($statementRequest);
|
||||
$statementResponse = $statementCommand->execute();
|
||||
|
||||
if (!$statementResponse->success) {
|
||||
abort(422, $statementResponse->message ?? 'Die EÜR konnte nicht erstellt werden.');
|
||||
}
|
||||
|
||||
return response($statementResponse->pdfContent, 200, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'attachment; filename="' . $statementResponse->filename . '"',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class SendController extends CommonController
|
||||
}
|
||||
}
|
||||
|
||||
$user = auth()->user();
|
||||
$user = currentUser();
|
||||
$reportSubject = sprintf('Sendebericht für Nachricht mit Betreff "%s"', $subject);
|
||||
|
||||
Mail::to($user->email)->send(new ManualMailsReportMail(
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Controllers;
|
||||
|
||||
use App\Scopes\CommonController;
|
||||
use App\ValueObjects\Amount;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
/**
|
||||
* Beitrag einer Kurzanmeldung. Teilnahmegruppe, Beitragsstufe und Zeitraum stehen fest, deshalb braucht der
|
||||
* Endpunkt keine Eingaben -- und der Betrag lässt sich vom Client nicht beeinflussen.
|
||||
*
|
||||
* `amountValue` steuert im Frontend, ob der Schritt "Zahlungsart" gezeigt wird.
|
||||
*/
|
||||
class ShortCalculateAmountController extends CommonController {
|
||||
public function __invoke(int $eventId) : JsonResponse {
|
||||
$event = $this->events->getById($eventId, false);
|
||||
|
||||
$participationType = $event->firstParticipationTypeSlug();
|
||||
|
||||
$amount = $participationType === null
|
||||
? new Amount(0, 'Euro')
|
||||
: $event->toResource()->calculateAmount(
|
||||
$participationType,
|
||||
'standard',
|
||||
$event->start_date,
|
||||
$event->end_date,
|
||||
false
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'amount' => $amount->toString(),
|
||||
'amountValue' => $amount->getAmount(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Event\Controllers;
|
||||
|
||||
use App\Domains\Event\Actions\CertificateOfConductionCheck\CertificateOfConductionCheckCommand;
|
||||
use App\Domains\Event\Actions\CertificateOfConductionCheck\CertificateOfConductionCheckRequest;
|
||||
use App\Domains\Event\Actions\ShortSignUp\ShortSignUpCommand;
|
||||
use App\Domains\Event\Actions\ShortSignUp\ShortSignUpRequest;
|
||||
use App\Enumerations\FirstAidPermission;
|
||||
use App\Enumerations\SwimmingPermission;
|
||||
use App\Mail\ParticipantParticipationMails\EventSignUpSuccessfullMail;
|
||||
use App\Providers\DoubleCheckEventRegistrationProvider;
|
||||
use App\Scopes\CommonController;
|
||||
use DateTime;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
/**
|
||||
* Nimmt die verkürzte Anmeldung entgegen. Öffentlich erreichbar, deshalb werden die Eingaben hier -- anders als
|
||||
* im langen Prozess -- validiert, bevor sie die Action erreichen.
|
||||
*/
|
||||
class ShortSignupController extends CommonController {
|
||||
public function __invoke(int $eventId, Request $request) : JsonResponse {
|
||||
$event = $this->events->getById($eventId, false);
|
||||
|
||||
if (!$event->registration_allowed || new DateTime() > $event->start_date) {
|
||||
return response()->json(['status' => 'closed'], 403);
|
||||
}
|
||||
|
||||
// Die Kurzanmeldung darf nicht als Abkürzung um den langen Prozess herum benutzt werden.
|
||||
if (!$event->short_registration) {
|
||||
return response()->json(['status' => 'closed'], 403);
|
||||
}
|
||||
|
||||
$validator = Validator::make($request->all(), [
|
||||
'firstname' => 'required|string|max:255',
|
||||
'lastname' => 'required|string|max:255',
|
||||
'nickname' => 'nullable|string|max:255',
|
||||
'birthday' => 'required|date_format:Y-m-d|before:today',
|
||||
'email' => 'required|email|max:255',
|
||||
'phone' => 'required|string|max:255',
|
||||
// Gegen die teilnehmenden Stämme prüft der Command -- hier reicht die Typprüfung.
|
||||
'localGroup' => 'nullable|integer',
|
||||
'contactPerson' => 'nullable|string|max:255',
|
||||
'contactEmail' => 'nullable|email|max:255',
|
||||
'allergies' => 'nullable|string|max:255',
|
||||
'intolerances' => 'nullable|string|max:255',
|
||||
'firstAidPermission' => ['nullable', 'string', 'in:' . implode(',', FirstAidPermission::query()->pluck('slug')->toArray())],
|
||||
'swimmingPermission' => ['nullable', 'string', 'in:' . implode(',', SwimmingPermission::query()->pluck('slug')->toArray())],
|
||||
'foto' => 'array',
|
||||
'participationOptions' => 'array',
|
||||
'paymentMethod' => 'nullable|string',
|
||||
'paymentOptions' => 'array',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => $validator->errors()->first()], 422);
|
||||
}
|
||||
|
||||
$birthday = DateTime::createFromFormat('Y-m-d', $request->input('birthday'));
|
||||
|
||||
$doubleCheck = new DoubleCheckEventRegistrationProvider(
|
||||
$event,
|
||||
$request->input('firstname'),
|
||||
$request->input('lastname'),
|
||||
$request->input('email'),
|
||||
$birthday
|
||||
);
|
||||
|
||||
if ($doubleCheck->isRegistered()) {
|
||||
return response()->json(['status' => 'exists']);
|
||||
}
|
||||
|
||||
$foto = (array)$request->input('foto', []);
|
||||
|
||||
$shortSignUpRequest = new ShortSignUpRequest(
|
||||
event: $event,
|
||||
user_id: currentUser()?->id,
|
||||
firstname: $request->input('firstname'),
|
||||
lastname: $request->input('lastname'),
|
||||
nickname: $request->input('nickname'),
|
||||
birthday: $birthday,
|
||||
email: $request->input('email'),
|
||||
phone: $request->input('phone'),
|
||||
localGroupId: $request->input('localGroup') !== null ? (int)$request->input('localGroup') : null,
|
||||
contactPerson: $request->input('contactPerson') ?: null,
|
||||
contactEmail: $request->input('contactEmail') ?: null,
|
||||
allergies: $request->input('allergies') ?: null,
|
||||
intolerances: $request->input('intolerances') ?: null,
|
||||
firstAidPermission: $request->input('firstAidPermission') ?: null,
|
||||
swimmingPermission: $request->input('swimmingPermission') ?: null,
|
||||
foto_socialmedia: (bool)($foto['socialmedia'] ?? false),
|
||||
foto_print: (bool)($foto['print'] ?? false),
|
||||
foto_webseite: (bool)($foto['webseite'] ?? false),
|
||||
foto_partner: (bool)($foto['partner'] ?? false),
|
||||
foto_intern: (bool)($foto['intern'] ?? false),
|
||||
paymentMethod: $request->input('paymentMethod') ?: null,
|
||||
paymentOptions: (array)$request->input('paymentOptions', []),
|
||||
participationOptions: (array)$request->input('participationOptions', []),
|
||||
);
|
||||
|
||||
$shortSignUpResponse = new ShortSignUpCommand($shortSignUpRequest)->execute();
|
||||
|
||||
if (!$shortSignUpResponse->success) {
|
||||
return response()->json(['status' => 'error', 'message' => $shortSignUpResponse->message], 422);
|
||||
}
|
||||
|
||||
$participant = $shortSignUpResponse->participant;
|
||||
|
||||
$cocResponse = new CertificateOfConductionCheckCommand(
|
||||
new CertificateOfConductionCheckRequest($participant)
|
||||
)->execute();
|
||||
|
||||
$participant->efz_status = $cocResponse->status;
|
||||
$participant->save();
|
||||
|
||||
Mail::to($participant->email_1)->send(new EventSignUpSuccessfullMail(participant: $participant));
|
||||
|
||||
if ($participant->email_2 !== null) {
|
||||
Mail::to($participant->email_2)->send(new EventSignUpSuccessfullMail(participant: $participant));
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'participant' => $participant->toResource()->toArray($request),
|
||||
'status' => 'success',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,9 @@ class SignupController extends CommonController {
|
||||
'lastname' => '',
|
||||
];
|
||||
|
||||
if (auth()->check()) {
|
||||
$user = new UserResource(auth()->user())->toArray($request);
|
||||
$currentUser = currentUser();
|
||||
if ($currentUser !== null) {
|
||||
$user = new UserResource($currentUser)->toArray($request);
|
||||
|
||||
$participantData = [
|
||||
'id' => $user['id'],
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Domains\Event\Controllers\BankStatementBookController;
|
||||
use App\Domains\Event\Controllers\BankStatementParseController;
|
||||
use App\Domains\Event\Controllers\CreateController;
|
||||
use App\Domains\Event\Controllers\DetailsController;
|
||||
use App\Domains\Event\Controllers\EventArchiveController;
|
||||
@@ -14,6 +16,8 @@ use App\Domains\Event\Controllers\ParticipantReSignOnController;
|
||||
use App\Domains\Event\Controllers\ParticipantSignOffController;
|
||||
use App\Domains\Event\Controllers\ParticipantUpdateController;
|
||||
use App\Domains\Event\Controllers\PaymentReminderController;
|
||||
use App\Domains\Event\Controllers\ShortCalculateAmountController;
|
||||
use App\Domains\Event\Controllers\ShortSignupController;
|
||||
use App\Domains\Event\Controllers\SignupController;
|
||||
use App\Middleware\IdentifyTenant;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@@ -25,6 +29,9 @@ Route::prefix('api/v1')
|
||||
Route::post('{eventId}/calculate-amount', [SignupController::class, 'calculateAmount']);
|
||||
Route::post('{eventId}/signup', [SignupController::class, 'signUp']);
|
||||
|
||||
Route::post('{eventId}/short-calculate-amount', ShortCalculateAmountController::class);
|
||||
Route::post('{eventId}/short-signup', ShortSignupController::class);
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::post('/create', [CreateController::class, 'doCreate']);
|
||||
|
||||
@@ -48,6 +55,9 @@ Route::prefix('api/v1')
|
||||
Route::post('/payment-methods', [DetailsController::class, 'updatePaymentMethods']);
|
||||
Route::post('/participation-options', [DetailsController::class, 'updateParticipationOptions']);
|
||||
Route::post('/event-addons', [DetailsController::class, 'updateEventAddons']);
|
||||
|
||||
Route::post('/bank-statement/parse', BankStatementParseController::class);
|
||||
Route::post('/bank-statement/book', BankStatementBookController::class);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ use App\Domains\Event\Controllers\ArchivedEventsController;
|
||||
use App\Domains\Event\Controllers\AvailableEventsController;
|
||||
use App\Domains\Event\Controllers\CreateController;
|
||||
use App\Domains\Event\Controllers\DetailsController;
|
||||
use App\Domains\Event\Controllers\IncomeSurplusStatementController;
|
||||
use App\Domains\Event\Controllers\SignupController;
|
||||
use App\Middleware\IdentifyTenant;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@@ -18,6 +19,10 @@ Route::middleware(IdentifyTenant::class)->group(function () {
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
Route::get('/details/{eventId}', DetailsController::class);
|
||||
|
||||
// Vor der Wildcard darunter: Sonst greift `downloadPdfList()` und sucht ein Blade namens
|
||||
// `income-surplus-statement` mit Teilnehmendendaten, die die EÜR gar nicht braucht.
|
||||
Route::get('/details/{eventId}/pdf/income-surplus-statement', IncomeSurplusStatementController::class);
|
||||
Route::get('/details/{eventId}/pdf/{listType}', [DetailsController::class, 'downloadPdfList']);
|
||||
Route::get('/details/{eventId}/csv/{listType}', [DetailsController::class, 'downloadCsvList']);
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ async function unarchiveEvent(eventId) {
|
||||
<div>
|
||||
<h2 style="margin: 0 0 4px 0; font-size: 1.1rem; font-weight: 600;">{{ event.name }}</h2>
|
||||
<span style="color: #6b7280; font-size: 0.875rem;">
|
||||
{{ event.postalCode }} {{ event.location }}
|
||||
{{ event.fullAddress }}
|
||||
·
|
||||
{{ event.eventBegin }} – {{ event.eventEnd }}
|
||||
</span>
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
eventName: '',
|
||||
eventPostalCode: '',
|
||||
eventLocation: '',
|
||||
eventStreet: '',
|
||||
eventHouseNumber: '',
|
||||
eventEmail: props.emailAddress ? props.emailAddress : '',
|
||||
eventBegin: '',
|
||||
eventEnd: '',
|
||||
@@ -145,6 +147,8 @@
|
||||
eventName: formData.eventName,
|
||||
eventPostalCode: formData.eventPostalCode,
|
||||
eventLocation: formData.eventLocation,
|
||||
eventStreet: formData.eventStreet,
|
||||
eventHouseNumber: formData.eventHouseNumber,
|
||||
eventEmail: formData.eventEmail,
|
||||
eventBegin: formData.eventBegin,
|
||||
eventEnd: formData.eventEnd,
|
||||
@@ -195,6 +199,16 @@
|
||||
<ErrorText :message="errors.eventLocation" /></td>
|
||||
</tr>
|
||||
|
||||
<tr style="vertical-align: top;">
|
||||
<th class="width-medium pr-20 height-50">Straße (optional)</th>
|
||||
<td class="height-50"><input type="text" v-model="formData.eventStreet" class="width-half-full" /></td>
|
||||
</tr>
|
||||
|
||||
<tr style="vertical-align: top;">
|
||||
<th class="width-medium pr-20 height-50">Hausnummer (optional)</th>
|
||||
<td class="height-50"><input type="text" v-model="formData.eventHouseNumber" class="width-half-full" /></td>
|
||||
</tr>
|
||||
|
||||
<tr style="vertical-align: top;">
|
||||
<th class="width-medium pr-20 height-50">Postleitzahl des Veranstaltungsorts</th>
|
||||
<td class="height-50"><input type="text" v-model="formData.eventPostalCode" class="width-half-full" />
|
||||
|
||||
@@ -22,7 +22,7 @@ const props = defineProps({
|
||||
<div class="available-event-header">
|
||||
<div>
|
||||
<h2 class="available-event-title">{{ event.name }}</h2>
|
||||
<span class="available-event-location">{{ event.postalCode }} {{ event.location }}</span>
|
||||
<span class="available-event-location">{{ event.fullAddress }}</span>
|
||||
</div>
|
||||
<span
|
||||
v-if="event.registrationAllowed"
|
||||
@@ -47,7 +47,7 @@ const props = defineProps({
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Veranstaltungsort</th>
|
||||
<td>{{ event.postalCode }} {{ event.location }}</td>
|
||||
<td>{{ event.fullAddress }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Frühbuchen bis</th>
|
||||
|
||||
@@ -0,0 +1,635 @@
|
||||
<script setup>
|
||||
import {computed, ref} from 'vue'
|
||||
import {toast} from 'vue3-toastify'
|
||||
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
||||
import LoadingModal from "../../../../Views/Components/LoadingModal.vue";
|
||||
import Icon from "../../../../Views/Components/Icon.vue";
|
||||
import RichSelectBox from "../../../../Views/Components/RichSelectBox.vue";
|
||||
import {useAjax} from "../../../../../resources/js/components/ajaxHandler.js";
|
||||
|
||||
/**
|
||||
* Zahlungseingänge aus dem CSV-Export der Bank einbuchen.
|
||||
*
|
||||
* Zwei Schritte: Datei einlesen (der Server ordnet zu und schlägt vor), dann die Prüfansicht
|
||||
* bestätigen. Gebucht wird erst im zweiten Schritt und für alle Zeilen in einem Aufruf.
|
||||
*/
|
||||
const props = defineProps({
|
||||
event: {type: Object, required: true},
|
||||
})
|
||||
const emit = defineEmits(['close', 'booked'])
|
||||
|
||||
const {request} = useAjax()
|
||||
|
||||
const fileInput = ref(null)
|
||||
const fileName = ref('')
|
||||
const parsing = ref(false)
|
||||
const booking = ref(false)
|
||||
|
||||
const rows = ref([])
|
||||
const participants = ref([])
|
||||
// rowNumber -> identifier ('' = ignorieren)
|
||||
const assignment = ref({})
|
||||
const parsed = ref(false)
|
||||
const skipped = ref(0)
|
||||
|
||||
const assignedCount = computed(
|
||||
() => rows.value.filter(row => isAssigned(row)).length,
|
||||
)
|
||||
|
||||
const openCount = computed(() => rows.value.length - assignedCount.value)
|
||||
|
||||
const participantsByIdentifier = computed(
|
||||
() => Object.fromEntries(participants.value.map(participant => [participant.identifier, participant])),
|
||||
)
|
||||
|
||||
/**
|
||||
* Die Auswahlliste für alle Zeilen -- einmal gebaut, nicht je Zeile.
|
||||
*
|
||||
* Getrennt nach an- und abgemeldet, weil die Entscheidung unterschiedlich weit trägt: Eine Buchung
|
||||
* auf eine abgemeldete Anmeldung zieht eine Erstattung nach sich. Als Fließtext in einer Zeile ging
|
||||
* das unter, als Gruppenüberschrift steht es da.
|
||||
*/
|
||||
const participantOptions = computed(() => {
|
||||
const options = [{value: '', label: '— ignorieren —'}]
|
||||
|
||||
for (const participant of participants.value) {
|
||||
const state = participant.isSettled ? 'vollständig bezahlt' : participant.amountOpen + ' offen'
|
||||
|
||||
options.push(participant.isSignedOff
|
||||
? {
|
||||
value: participant.identifier,
|
||||
label: participant.name,
|
||||
description: 'abgemeldet am ' + participant.signedOffAt + ' · ' + state,
|
||||
group: 'Abgemeldete Teilis',
|
||||
icon: 'user-slash',
|
||||
muted: true,
|
||||
}
|
||||
: {
|
||||
value: participant.identifier,
|
||||
label: participant.name,
|
||||
description: state,
|
||||
group: 'Angemeldete Teilis',
|
||||
})
|
||||
}
|
||||
|
||||
return options
|
||||
})
|
||||
|
||||
function isAssigned(row) {
|
||||
return (assignment.value[row.rowNumber] ?? '') !== ''
|
||||
}
|
||||
|
||||
/** Der sichtbare Button klickt das versteckte Datei-Element -- wie beim Beleg-Upload der Abrechnung. */
|
||||
function chooseFile() {
|
||||
fileInput.value?.click()
|
||||
}
|
||||
|
||||
/** Auswählen und Einlesen sind ein Schritt: Ein zweiter Klick brächte nichts zu entscheiden. */
|
||||
async function onFileChosen(event) {
|
||||
const file = event.target.files?.[0] ?? null
|
||||
if (file === null) {
|
||||
return
|
||||
}
|
||||
|
||||
fileName.value = file.name
|
||||
await readStatement(file)
|
||||
}
|
||||
|
||||
async function readStatement(file) {
|
||||
parsing.value = true
|
||||
try {
|
||||
const form = new FormData()
|
||||
form.append('statement', file)
|
||||
|
||||
const response = await request(
|
||||
'/api/v1/event/details/' + props.event.id + '/bank-statement/parse',
|
||||
{method: 'POST', body: form},
|
||||
)
|
||||
|
||||
if (response?.status !== 'success') {
|
||||
toast.error(response?.message ?? 'Die Datei konnte nicht gelesen werden.')
|
||||
reset()
|
||||
return
|
||||
}
|
||||
|
||||
rows.value = response.rows ?? []
|
||||
participants.value = response.participants ?? []
|
||||
skipped.value = response.skipped ?? 0
|
||||
// Vorschläge sind vorbelegt, aber nichts ist entschieden -- gebucht wird nur, was hier
|
||||
// stehen bleibt.
|
||||
assignment.value = Object.fromEntries(
|
||||
rows.value.map(row => [row.rowNumber, row.suggestedIdentifier ?? '']),
|
||||
)
|
||||
parsed.value = true
|
||||
} finally {
|
||||
parsing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function bookPayments() {
|
||||
const bookings = rows.value
|
||||
.filter(row => isAssigned(row))
|
||||
.map(row => ({
|
||||
participantIdentifier: assignment.value[row.rowNumber],
|
||||
rowNumber: row.rowNumber,
|
||||
paymentDate: row.paymentDate,
|
||||
amount: row.amount,
|
||||
payerName: row.payerName,
|
||||
payerIban: row.payerIban,
|
||||
purpose: row.purpose,
|
||||
}))
|
||||
|
||||
if (bookings.length === 0) {
|
||||
toast.error('Es ist keine Zahlung zugeordnet.')
|
||||
return
|
||||
}
|
||||
|
||||
booking.value = true
|
||||
try {
|
||||
const response = await request(
|
||||
'/api/v1/event/details/' + props.event.id + '/bank-statement/book',
|
||||
{method: 'POST', body: {bookings}},
|
||||
)
|
||||
|
||||
if (response?.status !== 'success') {
|
||||
toast.error(response?.message ?? 'Die Zahlungen konnten nicht gebucht werden.')
|
||||
return
|
||||
}
|
||||
|
||||
toast.success(response.message)
|
||||
emit('booked')
|
||||
emit('close')
|
||||
} finally {
|
||||
booking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function reset() {
|
||||
rows.value = []
|
||||
participants.value = []
|
||||
assignment.value = {}
|
||||
parsed.value = false
|
||||
skipped.value = 0
|
||||
fileName.value = ''
|
||||
if (fileInput.value) fileInput.value.value = ''
|
||||
}
|
||||
|
||||
function assignedParticipant(row) {
|
||||
return participantsByIdentifier.value[assignment.value[row.rowNumber]] ?? null
|
||||
}
|
||||
|
||||
/** Der Zustand einer Zeile: was gebucht wird, was noch offen ist, was geprüft gehört. */
|
||||
function rowState(row) {
|
||||
if (!isAssigned(row)) {
|
||||
return row.suggestedIdentifier === null
|
||||
? {key: 'unmatched', label: 'Keine Zuordnung', icon: 'circle-question'}
|
||||
: {key: 'ignored', label: 'Ignoriert', icon: 'ban'}
|
||||
}
|
||||
|
||||
if (assignment.value[row.rowNumber] !== row.suggestedIdentifier) {
|
||||
return {key: 'manual', label: 'Von Hand', icon: 'user-pen'}
|
||||
}
|
||||
|
||||
return row.confidence === 'unsicher'
|
||||
? {key: 'uncertain', label: 'Bitte prüfen', icon: 'triangle-exclamation'}
|
||||
: {key: 'certain', label: 'Vorschlag', icon: 'check'}
|
||||
}
|
||||
|
||||
function lastPaymentOf(row) {
|
||||
return assignedParticipant(row)?.lastPaymentDate ?? null
|
||||
}
|
||||
|
||||
/** Eine Zahlung auf eine abgemeldete Anmeldung zieht eine Erstattung nach sich. */
|
||||
function signedOffOf(row) {
|
||||
const participant = assignedParticipant(row)
|
||||
|
||||
return participant?.isSignedOff === true ? participant : null
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FullScreenModal :show="true" @close="emit('close')">
|
||||
<div class="import">
|
||||
<header class="import-header">
|
||||
<h2>Zahlungseingänge einlesen</h2>
|
||||
<p class="subtitle">{{ event.name }}</p>
|
||||
</header>
|
||||
|
||||
<!-- Schritt 1: Datei wählen. Das Datei-Element bleibt versteckt, geklickt wird der Button. -->
|
||||
<div v-if="!parsed" class="dropzone">
|
||||
<Icon name="file-csv" class="dropzone-icon"/>
|
||||
<p class="dropzone-title">Kontoauszug als CSV hochladen</p>
|
||||
<p class="dropzone-note">
|
||||
Der Export wird nur gelesen und nicht gespeichert. Gebucht wird anschließend
|
||||
ausschließlich das, was ihr in der Prüfansicht bestätigt.
|
||||
</p>
|
||||
<input type="button" value="Kontoauszug auswählen" @click="chooseFile"/>
|
||||
</div>
|
||||
|
||||
<input ref="fileInput" type="file" accept=".csv,text/csv,text/plain"
|
||||
style="display: none" @change="onFileChosen"/>
|
||||
|
||||
<template v-if="parsed">
|
||||
<div class="filebar">
|
||||
<span class="filename"><Icon name="file-csv"/> {{ fileName }}</span>
|
||||
<label class="link" @click="reset">Andere Datei wählen</label>
|
||||
</div>
|
||||
|
||||
<div v-if="rows.length > 0" class="stats">
|
||||
<div class="stat stat-assigned">
|
||||
<span class="stat-value">{{ assignedCount }}</span>
|
||||
<span class="stat-label">wird gebucht</span>
|
||||
</div>
|
||||
<div class="stat" :class="{'stat-open': openCount > 0}">
|
||||
<span class="stat-value">{{ openCount }}</span>
|
||||
<span class="stat-label">nicht zugeordnet</span>
|
||||
</div>
|
||||
<div v-if="skipped > 0" class="stat">
|
||||
<span class="stat-value">{{ skipped }}</span>
|
||||
<span class="stat-label">bereits erfasst</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="rows.length === 0" class="empty">
|
||||
<Icon name="circle-check" class="empty-icon"/>
|
||||
<p>
|
||||
In dieser Datei sind keine offenen Zahlungseingänge zu dieser Aktion enthalten.
|
||||
<template v-if="skipped > 0">
|
||||
{{ skipped }} Zahlungen wurden bereits früher eingebucht.
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<table v-else class="statement-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Buchung</th>
|
||||
<th class="right">Betrag</th>
|
||||
<th>Zahler*in</th>
|
||||
<th>Verwendungszweck</th>
|
||||
<th class="assignment-column">Zuordnung</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in rows" :key="row.rowNumber" :class="'state-' + rowState(row).key">
|
||||
<td class="nowrap">{{ row.paymentDateFormatted }}</td>
|
||||
<td class="right amount">{{ row.amountFormatted }}</td>
|
||||
<td>
|
||||
<span class="payer">{{ row.payerName || '—' }}</span>
|
||||
<span v-if="row.payerIban" class="iban">{{ row.payerIban }}</span>
|
||||
</td>
|
||||
<td class="purpose">{{ row.purpose }}</td>
|
||||
<td>
|
||||
<div class="assignment">
|
||||
<RichSelectBox v-model="assignment[row.rowNumber]"
|
||||
:options="participantOptions"
|
||||
placeholder="— ignorieren —"
|
||||
filterable/>
|
||||
<span class="pill" :class="'pill-' + rowState(row).key">
|
||||
<Icon :key="rowState(row).icon" :name="rowState(row).icon"/> {{ rowState(row).label }}
|
||||
</span>
|
||||
<span v-if="signedOffOf(row)" class="pill pill-signedoff">
|
||||
<Icon name="user-slash"/> Abgemeldet
|
||||
</span>
|
||||
</div>
|
||||
<span v-if="signedOffOf(row)" class="hint hint-warning">
|
||||
Am {{ signedOffOf(row).signedOffAt }} abgemeldet — die Zahlung wird
|
||||
erfasst, danach steht eine Erstattung an.
|
||||
</span>
|
||||
<span v-if="lastPaymentOf(row)" class="hint">
|
||||
Zuletzt erfasst: {{ lastPaymentOf(row) }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<footer v-if="rows.length > 0" class="actions">
|
||||
<span class="actions-note">
|
||||
Die Teilnehmenden erhalten je Buchung die gewohnte Zahlungsmail.
|
||||
</span>
|
||||
<input type="button" class="accept-button"
|
||||
:value="assignedCount === 1 ? '1 Zahlung einbuchen' : assignedCount + ' Zahlungen einbuchen'"
|
||||
:disabled="assignedCount === 0 || booking"
|
||||
@click="bookPayments"/>
|
||||
</footer>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Beim Buchen geht je Zahlung eine Mail an die Teilnehmenden raus, und zwar synchron --
|
||||
bei achtzig Buchungen dauert der Aufruf entsprechend. -->
|
||||
<LoadingModal v-if="parsing || booking" :show="true"
|
||||
:message="booking
|
||||
? 'Die Zahlungen werden gebucht und die Teilnehmenden benachrichtigt. Das kann einen Moment dauern …'
|
||||
: 'Der Kontoauszug wird gelesen …'"/>
|
||||
</FullScreenModal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.import {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.import-header {
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
padding-bottom: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.import-header h2 {
|
||||
margin: 0;
|
||||
color: #1d4899;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin: 2px 0 0 0;
|
||||
color: #6b7280;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* ── Schritt 1: Datei wählen ───────────────────────────────────────────── */
|
||||
|
||||
.dropzone {
|
||||
border: 2px dashed #c7d2e8;
|
||||
border-radius: 10px;
|
||||
background-color: #fafbfe;
|
||||
padding: 48px 24px;
|
||||
text-align: center;
|
||||
max-width: 620px;
|
||||
margin: 40px auto;
|
||||
}
|
||||
|
||||
.dropzone-icon {
|
||||
font-size: 2.6rem;
|
||||
color: #809dd5;
|
||||
}
|
||||
|
||||
.dropzone-title {
|
||||
margin: 14px 0 6px 0;
|
||||
font-weight: bold;
|
||||
font-size: 1.05rem;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.dropzone-note {
|
||||
margin: 0 auto 22px auto;
|
||||
max-width: 440px;
|
||||
color: #6b7280;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* ── Schritt 2: Prüfansicht ────────────────────────────────────────────── */
|
||||
|
||||
.filebar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
padding: 8px 12px;
|
||||
background-color: #f9fafb;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.filename {
|
||||
color: #374151;
|
||||
font-weight: bold;
|
||||
font-size: 0.9rem;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.stat {
|
||||
flex: 1 1 130px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
padding: 10px 14px;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
display: block;
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
color: #374151;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
display: block;
|
||||
color: #6b7280;
|
||||
font-size: 0.8rem;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.stat-assigned {
|
||||
border-color: #508c4c;
|
||||
background-color: #f3faf3;
|
||||
}
|
||||
|
||||
.stat-assigned .stat-value {
|
||||
color: #2f6b2c;
|
||||
}
|
||||
|
||||
.stat-open .stat-value {
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
.empty {
|
||||
text-align: center;
|
||||
color: #6b7280;
|
||||
padding: 40px 20px;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 2rem;
|
||||
color: #508c4c;
|
||||
}
|
||||
|
||||
.statement-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.statement-table th {
|
||||
text-align: left;
|
||||
padding: 8px 10px;
|
||||
background-color: #f9fafb;
|
||||
color: #374151;
|
||||
border-bottom: 2px solid #d1d5db;
|
||||
font-size: 0.82rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.statement-table td {
|
||||
padding: 10px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
vertical-align: top;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.statement-table .right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.amount {
|
||||
white-space: nowrap;
|
||||
font-weight: bold;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.assignment-column {
|
||||
width: 360px;
|
||||
}
|
||||
|
||||
/* Zeilenfarbe sagt auf einen Blick, was passiert: grün wird gebucht, gelb will geprüft werden,
|
||||
grau bleibt liegen. */
|
||||
.state-certain td,
|
||||
.state-manual td {
|
||||
background-color: #f6fdf7;
|
||||
}
|
||||
|
||||
.state-uncertain td {
|
||||
background-color: #fffbeb;
|
||||
}
|
||||
|
||||
.state-ignored td,
|
||||
.state-unmatched td {
|
||||
background-color: #fbfbfb;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.payer {
|
||||
display: block;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.iban {
|
||||
display: block;
|
||||
color: #9ca3af;
|
||||
font-size: 0.75rem;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.purpose {
|
||||
max-width: 320px;
|
||||
word-break: break-word;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.assignment {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
|
||||
.pill {
|
||||
align-self: flex-start;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 2px 9px;
|
||||
border-radius: 11px;
|
||||
font-size: 0.72rem;
|
||||
font-weight: bold;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
.pill-certain {
|
||||
color: #2f6b2c;
|
||||
background-color: #dcfce7;
|
||||
border-color: #86c884;
|
||||
}
|
||||
|
||||
.pill-manual {
|
||||
color: #1d4899;
|
||||
background-color: #e4ecfb;
|
||||
border-color: #809dd5;
|
||||
}
|
||||
|
||||
.pill-uncertain {
|
||||
color: #92400e;
|
||||
background-color: #fef3c7;
|
||||
border-color: #d9b45c;
|
||||
}
|
||||
|
||||
.pill-ignored,
|
||||
.pill-unmatched {
|
||||
color: #6b7280;
|
||||
background-color: #f3f4f6;
|
||||
border-color: #d1d5db;
|
||||
}
|
||||
|
||||
.pill-signedoff {
|
||||
color: #9a3412;
|
||||
background-color: #ffedd5;
|
||||
border-color: #e0a06a;
|
||||
}
|
||||
|
||||
.hint {
|
||||
display: block;
|
||||
color: #9ca3af;
|
||||
font-size: 0.72rem;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.hint-warning {
|
||||
color: #9a3412;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 20px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.actions-note {
|
||||
color: #6b7280;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.actions input[disabled] {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* ── Schmale Bildschirme ───────────────────────────────────────────────── */
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.assignment-column {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.statement-table th {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.purpose {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -27,6 +27,8 @@ const emit = defineEmits(['close'])
|
||||
contributingLocalGroups: contributingLocalGroups.value,
|
||||
eventName: props.event.name,
|
||||
eventLocation: props.event.location,
|
||||
street: props.event.street ?? '',
|
||||
houseNumber: props.event.houseNumber ?? '',
|
||||
postalCode: props.event.postalCode,
|
||||
email: props.event.email,
|
||||
earlyBirdEnd: props.event.earlyBirdEnd.internal,
|
||||
@@ -35,6 +37,8 @@ const emit = defineEmits(['close'])
|
||||
eatingHabits: eatingHabits.value,
|
||||
sendWeeklyReports: props.event.sendWeeklyReports,
|
||||
registrationAllowed: props.event.registrationAllowed,
|
||||
shortRegistration: props.event.shortRegistration,
|
||||
swimmingPermissionRequired: props.event.swimmingPermissionRequired,
|
||||
flatSupport: props.event.flatSupportEdit,
|
||||
supportPerson: props.event.supportPersonIndex,
|
||||
})
|
||||
@@ -57,6 +61,8 @@ const emit = defineEmits(['close'])
|
||||
body: {
|
||||
eventName: formData.eventName,
|
||||
eventLocation: formData.eventLocation,
|
||||
street: formData.street,
|
||||
houseNumber: formData.houseNumber,
|
||||
postalCode: formData.postalCode,
|
||||
email: formData.email,
|
||||
earlyBirdEnd: formData.earlyBirdEnd,
|
||||
@@ -64,6 +70,8 @@ const emit = defineEmits(['close'])
|
||||
alcoholicsAge: formData.alcoholicsAge,
|
||||
sendWeeklyReports: formData.sendWeeklyReports,
|
||||
registrationAllowed: formData.registrationAllowed,
|
||||
shortRegistration: formData.shortRegistration,
|
||||
swimmingPermissionRequired: formData.swimmingPermissionRequired,
|
||||
flatSupport: formData.flatSupport,
|
||||
supportPerson: formData.supportPerson,
|
||||
contributingLocalGroups: contributingLocalGroups.value,
|
||||
@@ -105,6 +113,20 @@ const emit = defineEmits(['close'])
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Straße (optional)</th>
|
||||
<td>
|
||||
<input type="text" v-model="formData.street" class="width-full" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Hausnummer (optional)</th>
|
||||
<td>
|
||||
<input type="text" v-model="formData.houseNumber" class="width-full" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Postleitzahl des Veranstaltungsorts</th>
|
||||
<td>
|
||||
@@ -172,6 +194,27 @@ const emit = defineEmits(['close'])
|
||||
<label for="registrationAllowed">Veranstaltung ist für Anmeldungen geöffnet</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="checkbox" v-model="formData.shortRegistration" id="shortRegistration" />
|
||||
<label for="shortRegistration">Verkürzte Anmeldung verwenden</label><br />
|
||||
<span style="font-size: 0.8rem; color: #6b7280;">
|
||||
Fragt nur die nötigsten Daten ab (Name, Kontakt, Allergien, Foto-Erlaubnis).
|
||||
Nicht erhobene Angaben wie Anschrift und An-/Abreise werden automatisch gefüllt.
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input type="checkbox" v-model="formData.swimmingPermissionRequired" id="swimmingPermissionRequired" />
|
||||
<label for="swimmingPermissionRequired">Badeerlaubnis abfragen</label><br />
|
||||
<span style="font-size: 0.8rem; color: #6b7280;">
|
||||
Ist die Abfrage deaktiviert, wird für Minderjährige „Keine Badeerlaubnis" hinterlegt.
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import EventAddons from "./EventAddons.vue";
|
||||
import ParticipationSummary from "./ParticipationSummary.vue";
|
||||
import CommonSettings from "./CommonSettings.vue";
|
||||
import EventManagement from "./EventManagement.vue";
|
||||
import BankStatementImport from "./BankStatementImport.vue";
|
||||
import Modal from "../../../../Views/Components/Modal.vue";
|
||||
import MailCompose from "./MailCompose.vue";
|
||||
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
||||
@@ -21,6 +22,12 @@ const props = defineProps({
|
||||
|
||||
const displayData = ref('main');
|
||||
const showEventData = ref(false);
|
||||
const showBankStatement = ref(false);
|
||||
|
||||
// Nach dem Buchen stimmen die Beitragsstände der Übersicht nicht mehr -- neu laden.
|
||||
async function bankStatementBooked() {
|
||||
await showMain();
|
||||
}
|
||||
|
||||
|
||||
async function showMain() {
|
||||
@@ -106,6 +113,10 @@ async function showEventAddons() {
|
||||
<input type="button" value="Beitragsliste (PDF)" />
|
||||
</a><br/>
|
||||
|
||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/income-surplus-statement'">
|
||||
<input type="button" value="EüR (PDF)" />
|
||||
</a><br/>
|
||||
|
||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/drinking-list'">
|
||||
<input type="button" value="Getränkeliste (PDF)" />
|
||||
</a><br/>
|
||||
@@ -113,9 +124,18 @@ async function showEventAddons() {
|
||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/photo-permission-list'">
|
||||
<input type="button" value="Foto-Erlaubnis (PDF)" />
|
||||
</a><br/>
|
||||
|
||||
<input type="button" value="Zahlungseingänge einlesen" @click="showBankStatement = true" /><br/>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Liegt außerhalb der displayData-Umschaltung: Der Import ist ein Vollbild-Dialog über der
|
||||
Übersicht, keine Unter-Ansicht, und soll auch aus einer Unter-Ansicht heraus erreichbar sein. -->
|
||||
<BankStatementImport v-if="showBankStatement && dynamicProps.event"
|
||||
:event="dynamicProps.event"
|
||||
@close="showBankStatement = false"
|
||||
@booked="bankStatementBooked" />
|
||||
|
||||
<ParticipationFees v-if="displayData === 'participationFees'" :event="dynamicProps.event" @close="showMain" />
|
||||
<ParticipationOptions v-else-if="displayData === 'participationOptions'" :event="dynamicProps.event"
|
||||
@close="showMain"/>
|
||||
@@ -143,6 +163,10 @@ async function showEventAddons() {
|
||||
<input type="button" value="Beitragsliste (PDF)" />
|
||||
</a><br/>
|
||||
|
||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/income-surplus-statement'">
|
||||
<input type="button" value="EüR (PDF)" />
|
||||
</a><br/>
|
||||
|
||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/drinking-list'">
|
||||
<input type="button" value="Getränkeliste (PDF)" />
|
||||
</a><br/>
|
||||
@@ -150,6 +174,7 @@ async function showEventAddons() {
|
||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/photo-permission-list'">
|
||||
<input type="button" value="Foto-Erlaubnis (PDF)" />
|
||||
</a><br/>
|
||||
<input type="button" value="Zahlungseingänge einlesen" @click="showBankStatement = true" /><br/>
|
||||
<input type="button" @click="sendPaymentReminder" class="fix-button" value="Zahlungserinnerung senden" /><br/>
|
||||
<input type="button" class="deny-button" value="Letzte Mahnung senden" style="display: none" /><br/>
|
||||
<input type="button" value="Rundmail senden" @click="mailToGroup" /><br/>
|
||||
|
||||
@@ -233,6 +233,7 @@ function saveParticipant() {
|
||||
<td>
|
||||
<span v-if="!staticProps.editMode">{{ props.participant.localgroup }}</span>
|
||||
<select v-else v-model="form.localgroup">
|
||||
<option value="">Kein Stamm</option>
|
||||
<option v-for="group in staticProps.event.contributingLocalGroups" :key="group.id" :value="group.slug">{{ group.name }}</option>
|
||||
</select>
|
||||
</td>
|
||||
@@ -386,7 +387,17 @@ function saveParticipant() {
|
||||
Bankverbindung des Teilis
|
||||
</small>
|
||||
<small v-else-if="props.participant.refund.status === 'accepted'">
|
||||
bestätigt am {{ props.participant.refund.acceptedAt }}
|
||||
bestätigt am {{ props.participant.refund.acceptedAt }}<template
|
||||
v-if="props.participant.refund.donation"
|
||||
> – gespendet, keine Auszahlung</template>
|
||||
</small>
|
||||
|
||||
<!-- Was beim Verband geblieben ist und warum. -->
|
||||
<small v-if="props.participant.refund.hasRetention" class="retention-note">
|
||||
<br />Einbehalten: {{ props.participant.refund.retainedAmount }} –
|
||||
{{ props.participant.refund.retentionReasonLabel }}<template
|
||||
v-if="props.participant.refund.retentionReasonNote"
|
||||
> ({{ props.participant.refund.retentionReasonNote }})</template>
|
||||
</small>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -541,4 +552,8 @@ textarea {
|
||||
select {
|
||||
width: 262px;
|
||||
}
|
||||
|
||||
.retention-note {
|
||||
color: #8a6d00;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -10,6 +10,7 @@ import AmountInput from "../../../../Views/Components/AmountInput.vue";
|
||||
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
||||
import DialableTelephoneNumber from "../../../../Views/Components/DialableTelephoneNumber.vue";
|
||||
import ErrorText from "../../../../Views/Components/ErrorText.vue";
|
||||
import IbanInput from "../../../../Views/Components/IbanInput.vue";
|
||||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
@@ -47,17 +48,97 @@ const openCancelDialog = ref(false);
|
||||
const openPartialPaymentDialogSwitch = ref(false);
|
||||
const openRefundDialogSwitch = ref(false);
|
||||
|
||||
// Der Erstattungsdialog. Betrag und Grund werden hier gesetzt; die Bankverbindung erfasst der Teili
|
||||
// selbst über den Link, den die Freigabe ihm schickt.
|
||||
const refundForm = reactive({amount: '', reason: '', reasonNote: ''});
|
||||
const refundErrors = reactive({amount: '', reason: '', reasonNote: ''});
|
||||
// Der Erstattungsdialog. `captureMode` steuert den Weg: 'participant' schickt dem Teili einen Link, über
|
||||
// den er seine Bankverbindung selbst einträgt; 'management' heißt, sie liegt der Aktionsleitung bereits
|
||||
// vor -- dann wird die Erstattung sofort eingereicht.
|
||||
const refundForm = reactive({
|
||||
amount: '', reason: '', reasonNote: '',
|
||||
captureMode: 'participant', accountOwner: '', accountIban: '',
|
||||
retentionReason: '', retentionReasonNote: '',
|
||||
});
|
||||
const refundErrors = reactive({amount: '', reason: '', reasonNote: '', accountOwner: '', accountIban: ''});
|
||||
const refundReasons = ref([]);
|
||||
const retentionReasons = ref([]);
|
||||
const refundSaving = ref(false);
|
||||
const refundResending = ref(false);
|
||||
|
||||
const selectedRefundReason = computed(
|
||||
() => refundReasons.value.find(r => r.value === refundForm.reason) ?? null
|
||||
);
|
||||
|
||||
const selectedRetentionReason = computed(
|
||||
() => retentionReasons.value.find(r => r.value === refundForm.retentionReason) ?? null
|
||||
);
|
||||
|
||||
/** Was nach der Erstattung beim Verband bleibt -- die Grundlage für den Einbehaltungsblock. */
|
||||
const retainedAmount = computed(() => {
|
||||
const paid = Number(showParticipant.value?.amountPaidValue ?? 0);
|
||||
const refunded = Number((refundForm.amount ?? '').replace(',', '.'));
|
||||
|
||||
if (!Number.isFinite(refunded)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const remaining = Math.round((paid - refunded) * 100) / 100;
|
||||
|
||||
return remaining > 0.005 ? remaining : 0;
|
||||
});
|
||||
|
||||
const hasRetention = computed(() => retainedAmount.value > 0);
|
||||
|
||||
/**
|
||||
* Das Konto, das die Zahlungsart kennt -- bei der Überweisung das des Zahlungseingangs.
|
||||
*
|
||||
* Ist es da, wird es weder erfragt noch bearbeitet: Erstattet wird auf das Konto, von dem der Beitrag
|
||||
* kam, und genau das steht hier. `null`, solange nichts bekannt ist (Barzahlung, Altbestand).
|
||||
*/
|
||||
const knownRefundAccount = computed(
|
||||
() => showParticipant.value?.refundData?.available ? showParticipant.value.refundData : null
|
||||
);
|
||||
|
||||
const retainedAmountReadable = computed(
|
||||
() => retainedAmount.value.toFixed(2).replace('.', ',') + ' Euro'
|
||||
);
|
||||
|
||||
/**
|
||||
* Ob abgesendet werden kann. Der Knopf erscheint erst dann -- was noch fehlt, soll die Aktionsleitung
|
||||
* sehen, bevor sie klickt, statt danach eine Fehlermeldung zu lesen.
|
||||
*/
|
||||
const refundFormComplete = computed(() => {
|
||||
const amount = Number((refundForm.amount ?? '').replace(',', '.'));
|
||||
const paid = Number(showParticipant.value?.amountPaidValue ?? 0);
|
||||
|
||||
if (!refundForm.amount || !(amount > 0) || amount > paid + 0.005) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!refundForm.reason) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selectedRefundReason.value?.requiresNote && !refundForm.reasonNote.trim()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bleibt etwas beim Verband, muss begründet sein, warum.
|
||||
if (hasRetention.value) {
|
||||
if (!refundForm.retentionReason) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selectedRetentionReason.value?.requiresNote && !refundForm.retentionReasonNote.trim()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Beim bekannten Konto gibt es nichts einzugeben -- es steht fest.
|
||||
if (refundForm.captureMode === 'management' && !knownRefundAccount.value) {
|
||||
return refundForm.accountOwner.trim() !== '' && refundForm.accountIban.trim() !== '';
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
defineEmits(['showParticipantDetails', 'markCocExisting', 'paymentComplete'])
|
||||
|
||||
function openParticipantDetails(input) {
|
||||
@@ -317,15 +398,25 @@ async function openRefundDialog(participant) {
|
||||
refundForm.amount = participant.amountPaid?.short ?? '';
|
||||
refundForm.reason = '';
|
||||
refundForm.reasonNote = '';
|
||||
refundErrors.amount = '';
|
||||
refundErrors.reason = '';
|
||||
refundErrors.reasonNote = '';
|
||||
// Vorgabe ist der übliche Weg über den Teili.
|
||||
refundForm.captureMode = 'participant';
|
||||
refundForm.accountOwner = '';
|
||||
refundForm.accountIban = '';
|
||||
refundForm.retentionReason = '';
|
||||
refundForm.retentionReasonNote = '';
|
||||
|
||||
Object.keys(refundErrors).forEach(key => refundErrors[key] = '');
|
||||
|
||||
if (refundReasons.value.length === 0) {
|
||||
const reasons = await request('/api/v1/core/retrieve-refund-reasons', {method: 'GET'});
|
||||
refundReasons.value = reasons ?? [];
|
||||
}
|
||||
|
||||
if (retentionReasons.value.length === 0) {
|
||||
const reasons = await request('/api/v1/core/retrieve-retention-reasons', {method: 'GET'});
|
||||
retentionReasons.value = reasons ?? [];
|
||||
}
|
||||
|
||||
openRefundDialogSwitch.value = true;
|
||||
}
|
||||
|
||||
@@ -333,9 +424,7 @@ function validateRefund() {
|
||||
const amount = Number((refundForm.amount ?? '').replace(',', '.'));
|
||||
const paid = Number(showParticipant.value?.amountPaidValue ?? 0);
|
||||
|
||||
refundErrors.amount = '';
|
||||
refundErrors.reason = '';
|
||||
refundErrors.reasonNote = '';
|
||||
Object.keys(refundErrors).forEach(key => refundErrors[key] = '');
|
||||
|
||||
if (!refundForm.amount || !(amount > 0)) {
|
||||
refundErrors.amount = 'Bitte gib einen Betrag größer als 0 ein.';
|
||||
@@ -349,7 +438,19 @@ function validateRefund() {
|
||||
refundErrors.reasonNote = 'Bitte erläutere den Grund.';
|
||||
}
|
||||
|
||||
return !refundErrors.amount && !refundErrors.reason && !refundErrors.reasonNote;
|
||||
// Beim Direktweg wird sofort eingereicht -- danach gibt es keine Gelegenheit mehr zu berichtigen.
|
||||
// Ob die IBAN wirklich stimmt, prüft der Server mit Prüfziffer und länderabhängiger Länge.
|
||||
if (refundForm.captureMode === 'management' && !knownRefundAccount.value) {
|
||||
if (!refundForm.accountOwner.trim()) {
|
||||
refundErrors.accountOwner = 'Bitte gib an, wem das Konto gehört.';
|
||||
}
|
||||
|
||||
if (!refundForm.accountIban.trim()) {
|
||||
refundErrors.accountIban = 'Bitte gib die IBAN des Kontos ein.';
|
||||
}
|
||||
}
|
||||
|
||||
return Object.values(refundErrors).every(message => !message);
|
||||
}
|
||||
|
||||
async function execRefund() {
|
||||
@@ -366,13 +467,32 @@ async function execRefund() {
|
||||
amount: refundForm.amount,
|
||||
reason: refundForm.reason,
|
||||
reasonNote: refundForm.reasonNote,
|
||||
// Leer beim Weg über den Teili -- dann verschickt der Server nur den Link. Beim
|
||||
// Sofort-Einreichen mit bekanntem Konto geht dieses mit; eingegeben wurde nichts.
|
||||
accountOwner: refundForm.captureMode === 'management'
|
||||
? (knownRefundAccount.value?.accountOwner ?? refundForm.accountOwner)
|
||||
: '',
|
||||
accountIban: refundForm.captureMode === 'management'
|
||||
? (knownRefundAccount.value?.accountIban ?? refundForm.accountIban)
|
||||
: '',
|
||||
// Spende: kein Konto, trotzdem sofort eingereicht.
|
||||
donation: refundForm.captureMode === 'donation',
|
||||
// Leer bei voller Erstattung -- dann gibt es nichts zu begründen.
|
||||
retentionReason: hasRetention.value ? refundForm.retentionReason : '',
|
||||
retentionReasonNote: hasRetention.value ? refundForm.retentionReasonNote : '',
|
||||
},
|
||||
});
|
||||
|
||||
if (data?.status === 'success') {
|
||||
toast.success(data.message);
|
||||
// Reaktiv statt per getElementById: die Meta-Zeile hängt am Vorgang und wechselt mit ihm.
|
||||
// Beim Direktweg steht dort sofort "Erstattet" samt Abrechnungsnummer.
|
||||
showParticipant.value.refund = data.refund;
|
||||
// Der gezahlte Beitrag wird beim Einreichen auf 0 gesetzt -- sonst zeigte die Zeile weiter
|
||||
// den alten Stand, bis jemand neu lädt.
|
||||
if (data.refund?.status === 'accepted') {
|
||||
showParticipant.value.amountPaidValue = 0;
|
||||
}
|
||||
openRefundDialogSwitch.value = false;
|
||||
} else {
|
||||
toast.error(data?.message ?? 'Die Erstattung konnte nicht freigegeben werden.');
|
||||
@@ -395,6 +515,32 @@ async function execCancelRefund(participant) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Mail zur freigegebenen Erstattung noch einmal schicken -- ohne Rückfrage, es ändert sich nichts am
|
||||
* Vorgang. Der Guard verhindert, dass ein zweiter Klick eine zweite Mail auslöst, bevor die erste durch ist.
|
||||
*/
|
||||
async function execResendRefundMail(participant) {
|
||||
if (refundResending.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
refundResending.value = true;
|
||||
|
||||
try {
|
||||
const data = await request('/api/v1/participant-refund/' + participant.refund.token + '/resend-mail', {
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
if (data?.status === 'success') {
|
||||
toast.success(data.message);
|
||||
} else {
|
||||
toast.error(data?.message ?? 'Die Rückerstattungsmail konnte nicht versendet werden.');
|
||||
}
|
||||
} finally {
|
||||
refundResending.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadRefundDocument(participant) {
|
||||
const ok = await download('/api/v1/participant-refund/' + participant.refund.token + '/document');
|
||||
|
||||
@@ -455,6 +601,15 @@ function mailToGroup(groupKey) {
|
||||
<td class="pl-amount" :id="'participant-' + participant.identifier +'-payment'" :class="participant.amount_left_value != 0 && !participant.unregistered ? 'not-paid' : ''">
|
||||
Gezahlt: <label :id="'participant-' + participant.identifier + '-paid'">{{ participant?.amountPaid.readable }}</label> /<br />
|
||||
Gesamt: <label :id="'participant-' + participant.identifier + '-expected'">{{ participant?.amountExpected.readable }}</label>
|
||||
|
||||
<!-- Warum ein Teil des Beitrags beim Verband geblieben ist. -->
|
||||
<span v-if="participant.refund?.hasRetention" class="retention-note">
|
||||
Einbehalten: {{ participant.refund.retainedAmount }}<br />
|
||||
{{ participant.refund.retentionReasonLabel }}<template
|
||||
v-if="participant.refund.retentionReasonNote"
|
||||
> – {{ participant.refund.retentionReasonNote }}</template>
|
||||
</span>
|
||||
|
||||
<br /><br />
|
||||
<span v-if="participant.amount_left_value != 0 && !participant.unregistered" :id="'participant-' + participant.identifier + '-actions'">
|
||||
<span class="link" style="font-size:10pt;" @click="paymentComplete(participant)">Zahlung buchen</span>
|
||||
@@ -517,13 +672,17 @@ function mailToGroup(groupKey) {
|
||||
> | Beitrag erstatten</span>
|
||||
|
||||
<template v-else-if="participant.refund?.status === 'pending'">
|
||||
| <strong>Erstattung offen:</strong> {{ participant.refund.amount }},
|
||||
wartet auf Bankverbindung
|
||||
| <strong>Rückerstattung vorgemerkt:</strong> {{ participant.refund.amount }}
|
||||
am {{ participant.refund.releasedAt }}, wartet auf Bankverbindung
|
||||
<span class="link" @click="execResendRefundMail(participant)">Rückerstattungsmail erneut senden</span>
|
||||
<span class="link" style="color: #da7070;" @click="execCancelRefund(participant)">Abbrechen</span>
|
||||
</template>
|
||||
|
||||
<template v-else-if="participant.refund?.status === 'accepted'">
|
||||
| <strong>Erstattet:</strong> {{ participant.refund.amount }}
|
||||
<template v-if="participant.refund.invoiceNumber">
|
||||
· Abrechnung {{ participant.refund.invoiceNumber }}
|
||||
</template>
|
||||
<span class="link" @click="downloadRefundDocument(participant)">Beleg</span>
|
||||
</template>
|
||||
</template>
|
||||
@@ -600,8 +759,7 @@ function mailToGroup(groupKey) {
|
||||
>
|
||||
<p class="refund-intro">
|
||||
{{ showParticipant?.fullname }} hat
|
||||
<strong>{{ showParticipant?.amountPaid?.readable }}</strong> gezahlt. Nach der Freigabe erhält
|
||||
der Teili eine E-Mail und trägt seine Bankverbindung selbst ein.
|
||||
<strong>{{ showParticipant?.amountPaid?.readable }}</strong> gezahlt.
|
||||
</p>
|
||||
|
||||
<div class="refund-field">
|
||||
@@ -629,8 +787,123 @@ function mailToGroup(groupKey) {
|
||||
<ErrorText :message="refundErrors.reasonNote" />
|
||||
</div>
|
||||
|
||||
<button class="button" :disabled="refundSaving" @click="execRefund()">
|
||||
{{ refundSaving ? 'Wird freigegeben…' : 'Erstattung freigeben' }}
|
||||
<!--
|
||||
Bleibt ein Teil beim Verband, muss begründet sein, warum -- ein einbehaltener Betrag ohne
|
||||
Grund ist in der Buchhaltung nicht haltbar. Bei voller Erstattung gibt es nichts zu zeigen.
|
||||
-->
|
||||
<template v-if="hasRetention">
|
||||
<p class="refund-hint">
|
||||
<strong>{{ retainedAmountReadable }}</strong> verbleiben beim Verband.
|
||||
</p>
|
||||
|
||||
<div class="refund-field">
|
||||
<label for="refund_retention_reason">Grund der Einbehaltung</label>
|
||||
<select id="refund_retention_reason" v-model="refundForm.retentionReason" class="form-input">
|
||||
<option value="">Bitte auswählen …</option>
|
||||
<option v-for="reason in retentionReasons" :key="reason.value" :value="reason.value">
|
||||
{{ reason.label }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedRetentionReason?.requiresNote" class="refund-field">
|
||||
<label for="refund_retention_note">Erläuterung zur Einbehaltung</label>
|
||||
<textarea
|
||||
id="refund_retention_note"
|
||||
v-model="refundForm.retentionReasonNote"
|
||||
class="form-input"
|
||||
rows="3"
|
||||
></textarea>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--
|
||||
Liegt die Bankverbindung schon vor oder will der Teili spenden, entfällt der Umweg über ihn:
|
||||
die Erstattung wird sofort eingereicht. Er bekommt den Beleg trotzdem.
|
||||
-->
|
||||
<!--
|
||||
Ist das Konto aus dem Zahlungseingang bekannt, wird es weder erfragt noch bearbeitet: Es
|
||||
steht fest, dass auf genau dieses Konto zu erstatten ist. Der Teili entscheidet dann nur
|
||||
noch, ob er es haben oder spenden möchte.
|
||||
-->
|
||||
<div v-if="knownRefundAccount" class="refund-known-account">
|
||||
<strong>Konto aus dem Zahlungseingang</strong>
|
||||
<span>{{ knownRefundAccount.accountOwner }}</span>
|
||||
<span class="refund-known-account__iban">{{ knownRefundAccount.accountIban }}</span>
|
||||
<span class="refund-known-account__source">{{ knownRefundAccount.source }}</span>
|
||||
</div>
|
||||
|
||||
<div class="refund-field">
|
||||
<label class="refund-choice">
|
||||
<input type="radio" value="participant" v-model="refundForm.captureMode" />
|
||||
<template v-if="knownRefundAccount">
|
||||
Teilnehmer*in bestätigt die Erstattung oder spendet
|
||||
</template>
|
||||
<template v-else>
|
||||
Teilnehmer*in trägt die Bankverbindung selbst ein
|
||||
</template>
|
||||
</label>
|
||||
<label class="refund-choice">
|
||||
<input type="radio" value="management" v-model="refundForm.captureMode" />
|
||||
<template v-if="knownRefundAccount">
|
||||
Sofort einreichen, ohne auf die Rückmeldung zu warten
|
||||
</template>
|
||||
<template v-else>
|
||||
Bankverbindung liegt mir vor
|
||||
</template>
|
||||
</label>
|
||||
<label class="refund-choice">
|
||||
<input type="radio" value="donation" v-model="refundForm.captureMode" />
|
||||
Teilnehmer*in spendet den Betrag
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<p v-if="refundForm.captureMode === 'donation'" class="refund-hint">
|
||||
Der Betrag wird nicht ausgezahlt, sondern als Spende gebucht. Die Erstattung wird sofort
|
||||
eingereicht; der Teili erhält den Beleg per E-Mail.
|
||||
</p>
|
||||
|
||||
<!-- Bekanntes Konto: nichts einzugeben, es wird ohnehin dieses genommen. -->
|
||||
<p v-if="refundForm.captureMode === 'management' && knownRefundAccount" class="refund-hint">
|
||||
Die Erstattung wird sofort auf das oben genannte Konto eingereicht. Der Teili erhält den
|
||||
Beleg per E-Mail, wird aber nicht mehr nach einer Spende gefragt.
|
||||
</p>
|
||||
|
||||
<template v-if="refundForm.captureMode === 'management' && !knownRefundAccount">
|
||||
<div class="refund-field">
|
||||
<label for="refund_account_owner">Kontoinhaber*in</label>
|
||||
<input
|
||||
id="refund_account_owner"
|
||||
v-model="refundForm.accountOwner"
|
||||
type="text"
|
||||
class="form-input"
|
||||
/>
|
||||
<ErrorText :message="refundErrors.accountOwner" />
|
||||
</div>
|
||||
|
||||
<div class="refund-field">
|
||||
<label for="refund_account_iban">IBAN</label>
|
||||
<IbanInput id="refund_account_iban" v-model="refundForm.accountIban" class="form-input" />
|
||||
<ErrorText :message="refundErrors.accountIban" />
|
||||
</div>
|
||||
|
||||
<p class="refund-hint">
|
||||
Die Erstattung wird sofort als Abrechnung eingereicht. Der Teili erhält den Beleg per
|
||||
E-Mail und kann die Angaben prüfen.
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<!-- Erscheint erst, wenn alles ausgefüllt ist; während des Speicherns gesperrt statt weg. -->
|
||||
<button
|
||||
v-if="refundFormComplete"
|
||||
class="button"
|
||||
:disabled="refundSaving"
|
||||
@click="execRefund()"
|
||||
>
|
||||
<template v-if="refundSaving">Wird gespeichert…</template>
|
||||
<template v-else-if="refundForm.captureMode === 'management'">Erstattung einreichen</template>
|
||||
<template v-else-if="refundForm.captureMode === 'donation'">Als Spende einreichen</template>
|
||||
<template v-else>Erstattung freigeben</template>
|
||||
</button>
|
||||
</Modal>
|
||||
|
||||
@@ -653,6 +926,31 @@ function mailToGroup(groupKey) {
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
/* Anzeige, kein Feld: bewusst nicht wie ein Eingabeblock gesetzt, damit gar nicht erst der Eindruck
|
||||
entsteht, hier ließe sich etwas ändern. */
|
||||
.refund-known-account {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
background-color: #f9fafb;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.refund-known-account__iban {
|
||||
font-family: monospace;
|
||||
letter-spacing: 0.04em;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.refund-known-account__source {
|
||||
color: #6b7280;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.refund-field {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
@@ -665,10 +963,40 @@ function mailToGroup(groupKey) {
|
||||
}
|
||||
|
||||
.refund-field select,
|
||||
.refund-field textarea {
|
||||
.refund-field textarea,
|
||||
.refund-field .form-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.refund-choice {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 0.9rem;
|
||||
color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.refund-choice input {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.retention-note {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
font-size: 10pt;
|
||||
color: #ca5a0a;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.refund-hint {
|
||||
margin-bottom: 14px;
|
||||
padding: 8px 10px;
|
||||
border-left: 3px solid #f5c400;
|
||||
background-color: #fffef5;
|
||||
font-size: 0.85rem;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.participants-table {
|
||||
width: 95%;
|
||||
margin: 20px auto;
|
||||
|
||||
@@ -26,6 +26,18 @@ const paymentMethodConfigurations = reactive({})
|
||||
const showOptionsModal = ref(false)
|
||||
const optionsMethod = ref(null)
|
||||
|
||||
/**
|
||||
* Die Optionen, die pro Aktion eingefroren werden.
|
||||
*
|
||||
* Optionen mit `scope: 'tenant'` bleiben draußen: Sie gelten für den ganzen Mandanten. Das
|
||||
* Kontoauszug-Format etwa beschreibt die Bank, nicht die Zusage an die Teilnehmenden — hier
|
||||
* eingefroren ließe sich nach einem Bankwechsel für laufende Aktionen nichts mehr importieren.
|
||||
* Der Server hält sich beim Speichern an dieselbe Regel.
|
||||
*/
|
||||
function eventOptions(method) {
|
||||
return (method?.optionsSchema ?? []).filter(option => option.scope !== 'tenant')
|
||||
}
|
||||
|
||||
function openOptions(method) {
|
||||
optionsMethod.value = method
|
||||
showOptionsModal.value = true
|
||||
@@ -47,7 +59,7 @@ onMounted(async () => {
|
||||
for (const method of availablePaymentMethods.value) {
|
||||
const source = eventConfigBySlug[method.slug] ?? method.configuration ?? {}
|
||||
const config = {}
|
||||
for (const option of method.optionsSchema ?? []) {
|
||||
for (const option of eventOptions(method)) {
|
||||
config[option.name] = source[option.name] ?? ''
|
||||
}
|
||||
paymentMethodConfigurations[method.slug] = config
|
||||
@@ -358,7 +370,7 @@ onMounted(async () => {
|
||||
paymentMethod.name
|
||||
}}</label>
|
||||
<label
|
||||
v-if="paymentMethods.includes(paymentMethod.slug) && (paymentMethod.optionsSchema?.length ?? 0) > 0"
|
||||
v-if="paymentMethods.includes(paymentMethod.slug) && eventOptions(paymentMethod).length > 0"
|
||||
class="link"
|
||||
style="padding-left: 15px; font-size: 10pt;"
|
||||
@click="openOptions(paymentMethod)"
|
||||
@@ -381,7 +393,7 @@ onMounted(async () => {
|
||||
width="700px"
|
||||
@close="showOptionsModal = false"
|
||||
>
|
||||
<div v-for="option in optionsMethod?.optionsSchema ?? []" :key="option.name" class="payment-method-config-row">
|
||||
<div v-for="option in eventOptions(optionsMethod)" :key="option.name" class="payment-method-config-row">
|
||||
<label>{{ option.label }}<span v-if="option.required" class="required-marker">*</span></label>
|
||||
<RichSelectBox v-if="option.type === 'icon'"
|
||||
v-model="paymentMethodConfigurations[optionsMethod.slug][option.name]"
|
||||
|
||||
@@ -68,6 +68,17 @@ const props = defineProps({
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!--
|
||||
Beiträge, die trotz Abmeldung beim Verband geblieben sind. Eigene Zeile, weil die
|
||||
Zeilen darüber nur aktive Anmeldungen führen.
|
||||
-->
|
||||
<tr v-if="props.event.retainedFromUnregistered.value > 0">
|
||||
<th style="padding-bottom: 20px" colspan="2">Einbehalten von Abmeldungen</th>
|
||||
<td style="padding-bottom: 20px" colspan="2">
|
||||
{{ props.event.retainedFromUnregistered.readable }}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th colspan="2" style="border-width: 1px; border-top-style: solid">Gesamt</th>
|
||||
<td style="font-weight: bold; border-width: 1px; border-top-style: solid">
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
<script setup>
|
||||
import {computed} from 'vue'
|
||||
import {useShortSignupForm} from './composables/useShortSignupForm.js'
|
||||
import {
|
||||
SHORT_STEP_PERSON,
|
||||
SHORT_STEP_PARTICIPATION_OPTIONS,
|
||||
SHORT_STEP_PHOTO,
|
||||
SHORT_STEP_PAYMENT,
|
||||
SHORT_STEP_SUMMARY,
|
||||
stepVisible,
|
||||
} from './composables/shortStepFlow.js'
|
||||
import ShortStepPerson from './steps/ShortStepPerson.vue'
|
||||
import ShortStepSummary from './steps/ShortStepSummary.vue'
|
||||
import StepParticipationOptions from '../SignUpForm/steps/StepParticipationOptions.vue'
|
||||
import StepPhotoPermissions from '../SignUpForm/steps/StepPhotoPermissions.vue'
|
||||
import StepPaymentMethod from '../SignUpForm/steps/StepPaymentMethod.vue'
|
||||
import SubmitSuccess from '../SignUpForm/after-submit/SubmitSuccess.vue'
|
||||
import SubmitAlreadyExists from '../SignUpForm/after-submit/SubmitAlreadyExists.vue'
|
||||
|
||||
const props = defineProps({
|
||||
event: Object,
|
||||
participantData: Object,
|
||||
})
|
||||
|
||||
const {
|
||||
currentStep, goToStep, goNext, goBack, formData, isMinor, localGroups, needsLocalGroup,
|
||||
submit, submitting, submitResult, submitError,
|
||||
summaryLoading, summaryAmount, summaryAmountValue,
|
||||
} = useShortSignupForm(props.event, props.participantData)
|
||||
|
||||
// Die aus dem langen Prozess übernommenen Schritte emittieren ihre Zielnummer aus jenem Flow mit. Hier zählt
|
||||
// nur, dass "weiter" bzw. "zurück" gedrückt wurde -- die Reihenfolge kennt dieser Host.
|
||||
const onNext = () => goNext()
|
||||
const onBack = () => goBack()
|
||||
|
||||
const allSteps = [
|
||||
{step: SHORT_STEP_PERSON, label: 'Person'},
|
||||
{step: SHORT_STEP_PARTICIPATION_OPTIONS, label: 'Teilnahmeoptionen'},
|
||||
{step: SHORT_STEP_PHOTO, label: 'Fotoerlaubnis'},
|
||||
{step: SHORT_STEP_PAYMENT, label: 'Zahlungsart'},
|
||||
{step: SHORT_STEP_SUMMARY, label: 'Zusammenfassung'},
|
||||
]
|
||||
|
||||
// Nur die tatsächlich vorkommenden Schritte anzeigen, sonst zeigt die Leiste Schritte, die nie erscheinen.
|
||||
const steps = computed(() =>
|
||||
allSteps.filter(s => stepVisible(props.event, s.step, summaryAmountValue.value))
|
||||
)
|
||||
|
||||
const currentIndex = computed(() => steps.value.findIndex(s => s.step === currentStep.value))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- Nach Submit -->
|
||||
<SubmitSuccess
|
||||
v-if="submitResult?.status === 'success'"
|
||||
:participant="submitResult?.participant"
|
||||
:event="event"
|
||||
/>
|
||||
<SubmitAlreadyExists v-else-if="submitResult?.status === 'exists'" :event="event" />
|
||||
|
||||
<template v-else>
|
||||
<!-- Fortschrittsleiste -->
|
||||
<div class="signup-progress">
|
||||
<div class="signup-progress-pills">
|
||||
<template v-for="(s, index) in steps" :key="s.step">
|
||||
<div v-if="index > 0" class="signup-progress-separator"></div>
|
||||
<div
|
||||
class="signup-pill"
|
||||
:class="{
|
||||
'signup-pill--active': currentStep === s.step,
|
||||
'signup-pill--done': currentStep > s.step,
|
||||
'signup-pill--upcoming': currentStep < s.step,
|
||||
}"
|
||||
@click="currentStep > s.step ? goToStep(s.step) : null"
|
||||
>
|
||||
<span v-if="currentStep > s.step" class="signup-pill__check">✓</span>
|
||||
{{ s.label }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="signup-progress-bar">
|
||||
<div
|
||||
class="signup-progress-bar__fill"
|
||||
:style="{ width: (steps.length > 1 ? (currentIndex / (steps.length - 1)) * 100 : 100) + '%' }"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div class="signup-progress-mobile">
|
||||
Schritt {{ currentIndex + 1 }} von {{ steps.length }}:
|
||||
<strong>{{ steps.find(s => s.step === currentStep)?.label }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Steps -->
|
||||
<form @submit.prevent="submit">
|
||||
<ShortStepPerson
|
||||
v-if="currentStep === SHORT_STEP_PERSON"
|
||||
:formData="formData" :event="event" :isMinor="isMinor"
|
||||
:localGroups="localGroups" :needsLocalGroup="needsLocalGroup"
|
||||
@next="onNext"
|
||||
/>
|
||||
<StepParticipationOptions
|
||||
v-if="currentStep === SHORT_STEP_PARTICIPATION_OPTIONS"
|
||||
:formData="formData" :event="event"
|
||||
@next="onNext" @back="onBack"
|
||||
/>
|
||||
<StepPhotoPermissions
|
||||
v-if="currentStep === SHORT_STEP_PHOTO"
|
||||
:formData="formData" :event="event"
|
||||
@next="onNext" @back="onBack"
|
||||
/>
|
||||
<StepPaymentMethod
|
||||
v-if="currentStep === SHORT_STEP_PAYMENT"
|
||||
:formData="formData" :event="event"
|
||||
@next="onNext" @back="onBack"
|
||||
/>
|
||||
<ShortStepSummary
|
||||
v-if="currentStep === SHORT_STEP_SUMMARY"
|
||||
:formData="formData"
|
||||
:event="event"
|
||||
:isMinor="isMinor"
|
||||
:summaryAmount="summaryAmount"
|
||||
:summaryAmountValue="summaryAmountValue"
|
||||
:summaryLoading="summaryLoading"
|
||||
:submitting="submitting"
|
||||
:submitError="submitError"
|
||||
@back="onBack"
|
||||
@submit="submit"
|
||||
/>
|
||||
</form>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Unscoped und mit dem langen Anmeldeprozess geteilt. -->
|
||||
<style src="../SignUpForm/signupForm.css"></style>
|
||||
@@ -0,0 +1,37 @@
|
||||
// Schrittreihenfolge der Kurzanmeldung. Zwei Schritte sind optional: die Teilnahmeoptionen entfallen, wenn für
|
||||
// die Veranstaltung keine definiert sind, die Zahlungsart entfällt bei Betrag 0 oder wenn es ohnehin nur eine
|
||||
// Zahlungsart gibt (die wird dann vorausgewählt).
|
||||
export const SHORT_STEP_PERSON = 1
|
||||
export const SHORT_STEP_PARTICIPATION_OPTIONS = 2
|
||||
export const SHORT_STEP_PHOTO = 3
|
||||
export const SHORT_STEP_PAYMENT = 4
|
||||
export const SHORT_STEP_SUMMARY = 5
|
||||
|
||||
export function stepVisible(event, step, amountValue) {
|
||||
if (step === SHORT_STEP_PARTICIPATION_OPTIONS) {
|
||||
return (event.participationOptions?.length ?? 0) > 0
|
||||
}
|
||||
|
||||
if (step === SHORT_STEP_PAYMENT) {
|
||||
const activeMethods = (event.paymentMethods ?? []).filter(m => m.active)
|
||||
return amountValue > 0 && activeMethods.length > 1
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
export function nextVisibleFrom(event, step, amountValue) {
|
||||
let candidate = step + 1
|
||||
while (candidate < SHORT_STEP_SUMMARY && !stepVisible(event, candidate, amountValue)) {
|
||||
candidate++
|
||||
}
|
||||
return candidate
|
||||
}
|
||||
|
||||
export function prevVisibleFrom(event, step, amountValue) {
|
||||
let candidate = step - 1
|
||||
while (candidate > SHORT_STEP_PERSON && !stepVisible(event, candidate, amountValue)) {
|
||||
candidate--
|
||||
}
|
||||
return candidate
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import {computed, reactive, ref} from 'vue'
|
||||
import axios from 'axios'
|
||||
import {differenceInYears, parseISO} from 'date-fns'
|
||||
import {SHORT_STEP_PERSON, nextVisibleFrom, prevVisibleFrom} from './shortStepFlow.js'
|
||||
|
||||
export function useShortSignupForm(event, participantData) {
|
||||
const currentStep = ref(SHORT_STEP_PERSON)
|
||||
const submitting = ref(false)
|
||||
const summaryLoading = ref(false)
|
||||
const submitResult = ref(null) // null | { status: 'success'|'exists', participant: {} }
|
||||
const submitError = ref('')
|
||||
|
||||
// Gibt es nur eine Zahlungsart, wird sie vorausgewählt und der Zahlungsschritt entfällt.
|
||||
const activeMethods = (event.paymentMethods ?? []).filter(m => m.active)
|
||||
|
||||
// Bei genau einem teilnehmenden Stamm wird dieser gesetzt, ohne danach zu fragen; erst ab zwei
|
||||
// Stämmen erscheint das Auswahlfeld.
|
||||
const localGroups = event.contributingLocalGroups ?? []
|
||||
const needsLocalGroup = localGroups.length > 1
|
||||
|
||||
const formData = reactive({
|
||||
userId: participantData.id,
|
||||
vorname: participantData.firstname ?? '',
|
||||
nachname: participantData.lastname ?? '',
|
||||
pfadiname: participantData.nickname ?? '',
|
||||
geburtsdatum: participantData.birthday ?? '',
|
||||
email_1: participantData.email ?? '',
|
||||
telefon_1: participantData.phone ?? '',
|
||||
localGroup: localGroups.length === 1 ? localGroups[0].id : (participantData.localGroup ?? '-1'),
|
||||
ansprechpartner: '',
|
||||
email_2: '',
|
||||
allergien: participantData.allergies ?? '',
|
||||
intolerances: participantData.intolerances ?? '',
|
||||
first_aid: '-1',
|
||||
badeerlaubnis: '-1',
|
||||
// Antworten auf die event-spezifischen Teilnahmeoptionen: { [question.key]: option.value }
|
||||
participationOptions: {},
|
||||
foto: {socialmedia: false, print: false, webseite: false, partner: false, intern: false},
|
||||
paymentMethod: activeMethods.length === 1 ? activeMethods[0].slug : null,
|
||||
paymentOptions: {},
|
||||
summary_information_correct: false,
|
||||
summary_accept_terms: false,
|
||||
legal_accepted: false,
|
||||
payment: false,
|
||||
})
|
||||
|
||||
// Minderjährigkeit steuert Kontaktperson, Erweiterte Erste Hilfe und Badeerlaubnis. Die Grenze von 18 Jahren
|
||||
// entspricht Age::isfullAged() im Backend.
|
||||
const isMinor = computed(() => {
|
||||
if (!formData.geburtsdatum) {
|
||||
return false
|
||||
}
|
||||
return differenceInYears(new Date(), parseISO(formData.geburtsdatum)) < 18
|
||||
})
|
||||
|
||||
const summaryAmount = ref('')
|
||||
const summaryAmountValue = ref(0)
|
||||
const amountLoaded = ref(false)
|
||||
|
||||
// Der Betrag steht für die ganze Anmeldung fest (feste Teilnahmegruppe, fester Zeitraum) und wird deshalb
|
||||
// genau einmal geholt. Er entscheidet, ob der Zahlungsschritt überhaupt vorkommt.
|
||||
const ensureAmount = async () => {
|
||||
if (amountLoaded.value) {
|
||||
return
|
||||
}
|
||||
|
||||
summaryLoading.value = true
|
||||
try {
|
||||
const res = await axios.post('/api/v1/event/' + event.id + '/short-calculate-amount')
|
||||
summaryAmount.value = res.data.amount
|
||||
summaryAmountValue.value = Number(res.data.amountValue ?? 0)
|
||||
amountLoaded.value = true
|
||||
|
||||
if (summaryAmountValue.value <= 0) {
|
||||
formData.paymentMethod = null
|
||||
formData.paymentOptions = {}
|
||||
}
|
||||
} finally {
|
||||
summaryLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const goToStep = (step) => {
|
||||
currentStep.value = step
|
||||
}
|
||||
|
||||
const goNext = async () => {
|
||||
await ensureAmount()
|
||||
goToStep(nextVisibleFrom(event, currentStep.value, summaryAmountValue.value))
|
||||
}
|
||||
|
||||
const goBack = async () => {
|
||||
await ensureAmount()
|
||||
goToStep(prevVisibleFrom(event, currentStep.value, summaryAmountValue.value))
|
||||
}
|
||||
|
||||
const submit = async () => {
|
||||
if (!formData.summary_information_correct || !formData.summary_accept_terms || !formData.legal_accepted) {
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
submitError.value = ''
|
||||
try {
|
||||
const res = await axios.post('/api/v1/event/' + event.id + '/short-signup', {
|
||||
firstname: formData.vorname,
|
||||
lastname: formData.nachname,
|
||||
nickname: formData.pfadiname || null,
|
||||
birthday: formData.geburtsdatum,
|
||||
email: formData.email_1,
|
||||
phone: formData.telefon_1,
|
||||
localGroup: formData.localGroup !== '-1' ? formData.localGroup : null,
|
||||
contactPerson: isMinor.value ? formData.ansprechpartner : null,
|
||||
contactEmail: isMinor.value ? formData.email_2 : null,
|
||||
allergies: formData.allergien || null,
|
||||
intolerances: formData.intolerances || null,
|
||||
firstAidPermission: isMinor.value && formData.first_aid !== '-1' ? formData.first_aid : null,
|
||||
swimmingPermission: isMinor.value && formData.badeerlaubnis !== '-1' ? formData.badeerlaubnis : null,
|
||||
foto: formData.foto,
|
||||
participationOptions: formData.participationOptions,
|
||||
paymentMethod: formData.paymentMethod,
|
||||
paymentOptions: formData.paymentOptions,
|
||||
})
|
||||
|
||||
submitResult.value = {
|
||||
status: res.data.status,
|
||||
participant: res.data.participant,
|
||||
}
|
||||
} catch (error) {
|
||||
submitError.value = error.response?.data?.message
|
||||
?? 'Die Anmeldung konnte nicht gespeichert werden. Bitte versuche es später erneut.'
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
currentStep,
|
||||
goToStep,
|
||||
goNext,
|
||||
goBack,
|
||||
formData,
|
||||
isMinor,
|
||||
localGroups,
|
||||
needsLocalGroup,
|
||||
submit,
|
||||
submitting,
|
||||
submitResult,
|
||||
submitError,
|
||||
summaryLoading,
|
||||
summaryAmount,
|
||||
summaryAmountValue,
|
||||
ensureAmount,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
<script setup>
|
||||
import ErrorText from "../../../../../../Views/Components/ErrorText.vue";
|
||||
import {reactive} from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
formData: Object,
|
||||
event: Object,
|
||||
isMinor: Boolean,
|
||||
localGroups: {type: Array, default: () => []},
|
||||
needsLocalGroup: Boolean,
|
||||
})
|
||||
const emit = defineEmits(['next'])
|
||||
|
||||
const errors = reactive({
|
||||
vorname: '',
|
||||
nachname: '',
|
||||
geburtsdatum: '',
|
||||
localGroup: '',
|
||||
email_1: '',
|
||||
telefon_1: '',
|
||||
ansprechpartner: '',
|
||||
email_2: '',
|
||||
first_aid: '',
|
||||
badeerlaubnis: '',
|
||||
})
|
||||
|
||||
// Nur sichtbare Felder werden geprüft -- Kontaktperson und Erlaubnisse gibt es bei Volljährigen nicht.
|
||||
const next = () => {
|
||||
Object.keys(errors).forEach(key => errors[key] = '')
|
||||
|
||||
let hasError = false
|
||||
|
||||
if (!props.formData.vorname) {
|
||||
errors.vorname = 'Bitte einen Vornamen angeben.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (!props.formData.nachname) {
|
||||
errors.nachname = 'Bitte einen Nachnamen angeben.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (!props.formData.geburtsdatum) {
|
||||
errors.geburtsdatum = 'Bitte ein Geburtsdatum angeben.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (props.needsLocalGroup && (!props.formData.localGroup || props.formData.localGroup === '-1')) {
|
||||
errors.localGroup = 'Bitte einen Stamm auswählen.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (!props.formData.email_1) {
|
||||
errors.email_1 = 'Bitte eine E-Mail-Adresse angeben.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (!props.formData.telefon_1) {
|
||||
errors.telefon_1 = 'Bitte eine Telefonnummer angeben.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (props.isMinor) {
|
||||
if (!props.formData.ansprechpartner) {
|
||||
errors.ansprechpartner = 'Bitte eine Kontaktperson angeben.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (!props.formData.email_2) {
|
||||
errors.email_2 = 'Bitte eine E-Mail-Adresse der Kontaktperson angeben.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (props.formData.first_aid === '-1') {
|
||||
errors.first_aid = 'Bitte triff eine Entscheidung. Bist du dir unsicher, kontaktiere bitte die Aktionsleitung.'
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (props.event.swimmingPermissionRequired && props.formData.badeerlaubnis === '-1') {
|
||||
errors.badeerlaubnis = 'Bitte triff eine Entscheidung. Bist du dir unsicher, kontaktiere bitte die Aktionsleitung.'
|
||||
hasError = true
|
||||
}
|
||||
}
|
||||
|
||||
if (hasError) {
|
||||
return
|
||||
}
|
||||
|
||||
emit('next')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h3>Angaben zur Person</h3>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<td>Vorname:</td>
|
||||
<td>
|
||||
<input type="text" v-model="formData.vorname" />
|
||||
<ErrorText :message="errors.vorname" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Pfadiname:</td>
|
||||
<td>
|
||||
<input type="text" v-model="formData.pfadiname" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nachname:</td>
|
||||
<td>
|
||||
<input type="text" v-model="formData.nachname" />
|
||||
<ErrorText :message="errors.nachname" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Geburtsdatum:</td>
|
||||
<td>
|
||||
<input type="date" v-model="formData.geburtsdatum" />
|
||||
<ErrorText :message="errors.geburtsdatum" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="needsLocalGroup">
|
||||
<td>Stamm:</td>
|
||||
<td>
|
||||
<select v-model="formData.localGroup">
|
||||
<option value="-1">Bitte wählen</option>
|
||||
<option v-for="group in localGroups" :key="group.id" :value="group.id">{{ group.name }}</option>
|
||||
</select>
|
||||
<ErrorText :message="errors.localGroup" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>E-Mail:</td>
|
||||
<td>
|
||||
<input type="email" v-model="formData.email_1" />
|
||||
<ErrorText :message="errors.email_1" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Telefon:</td>
|
||||
<td>
|
||||
<input type="text" v-model="formData.telefon_1" />
|
||||
<ErrorText :message="errors.telefon_1" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<template v-if="isMinor">
|
||||
<tr>
|
||||
<td>Kontaktperson (Nachname, Vorname):</td>
|
||||
<td>
|
||||
<input type="text" v-model="formData.ansprechpartner" />
|
||||
<ErrorText :message="errors.ansprechpartner" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>E-Mail der Kontaktperson:</td>
|
||||
<td>
|
||||
<input type="email" v-model="formData.email_2" />
|
||||
<ErrorText :message="errors.email_2" />
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<tr>
|
||||
<td>Allergien:</td>
|
||||
<td>
|
||||
<input type="text" v-model="formData.allergien" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Unverträglichkeiten:</td>
|
||||
<td>
|
||||
<input type="text" v-model="formData.intolerances" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<template v-if="isMinor">
|
||||
<tr>
|
||||
<td>Erweiterte Erste Hilfe erlaubt:</td>
|
||||
<td>
|
||||
<select v-model="formData.first_aid">
|
||||
<option value="-1">Bitte wählen</option>
|
||||
<option
|
||||
v-for="firstAidPermission in event.firstAidPermissions"
|
||||
:key="firstAidPermission.slug"
|
||||
:value="firstAidPermission.slug">{{ firstAidPermission.name }}</option>
|
||||
</select><br />
|
||||
<span style="font-size: 0.8rem; color: #6b7280;">
|
||||
Nicht dringend-notwendige Erste-Hilfe-Maßnahmen, beinhaltet das Entfernen von Zecken und Splittern sowie das Kleben von Pflastern.
|
||||
</span>
|
||||
<ErrorText :message="errors.first_aid" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="event.swimmingPermissionRequired">
|
||||
<td>Badeerlaubnis:</td>
|
||||
<td>
|
||||
<select v-model="formData.badeerlaubnis">
|
||||
<option value="-1">Bitte wählen</option>
|
||||
<option
|
||||
v-for="swimmingPermission in event.swimmingPermissions"
|
||||
:key="swimmingPermission.slug"
|
||||
:value="swimmingPermission.slug">{{ swimmingPermission.name }}</option>
|
||||
</select>
|
||||
<ErrorText :message="errors.badeerlaubnis" />
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<tr>
|
||||
<td colspan="2" class="btn-row">
|
||||
<button type="button" class="btn-primary" @click="next">Weiter →</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,187 @@
|
||||
<script setup>
|
||||
import {computed} from "vue";
|
||||
|
||||
const PAYMENT_ACCOUNT_TRANSACTION = 'PAYMENT_ACCOUNT_TRANSACTION'
|
||||
|
||||
const props = defineProps({
|
||||
formData: Object,
|
||||
event: Object,
|
||||
isMinor: Boolean,
|
||||
summaryAmount: String,
|
||||
summaryAmountValue: {type: Number, default: 0},
|
||||
summaryLoading: Boolean,
|
||||
submitting: Boolean,
|
||||
submitError: {type: String, default: ''},
|
||||
})
|
||||
const emit = defineEmits(['back', 'submit'])
|
||||
|
||||
const selectedMethod = computed(() =>
|
||||
(props.event.paymentMethods ?? []).find(m => m.slug === props.formData.paymentMethod) ?? null
|
||||
)
|
||||
|
||||
// Die Überweisungs-Bestätigung wird nur bei Banküberweisung verlangt.
|
||||
const requiresPaymentConfirmation = computed(() =>
|
||||
props.formData.paymentMethod === PAYMENT_ACCOUNT_TRANSACTION
|
||||
)
|
||||
|
||||
// Bestätigungstext ist ein admin-konfigurierbarer Freitext ({amount}-Platzhalter), sonst Default.
|
||||
const paymentConfirmationText = computed(() => {
|
||||
const configured = selectedMethod.value?.configuration?.summary_confirmation_text
|
||||
const template = (configured && String(configured).trim() !== '')
|
||||
? configured
|
||||
: 'Ich bestätige, den Betrag von {amount} zu überweisen.'
|
||||
return template.replaceAll('{amount}', props.summaryAmount ?? '')
|
||||
})
|
||||
|
||||
// Gewählte Teilnahmeoptionen für die Zusammenfassung (Label statt Wert anzeigen).
|
||||
const selectedParticipationOptions = computed(() =>
|
||||
(props.event.participationOptions ?? []).map(question => {
|
||||
const value = props.formData.participationOptions[question.key]
|
||||
const option = (question.options ?? []).find(o => o.value === value)
|
||||
return {label: question.title || question.label, value: option?.label ?? ''}
|
||||
}).filter(entry => entry.value !== '')
|
||||
)
|
||||
|
||||
// Der Stamm steht entweder fest (genau ein teilnehmender Stamm) oder wurde auf Seite 1 gewählt.
|
||||
const localGroupName = computed(() =>
|
||||
(props.event.contributingLocalGroups ?? []).find(g => g.id === props.formData.localGroup)?.name ?? null
|
||||
)
|
||||
|
||||
const permissionName = (list, slug) =>
|
||||
(list ?? []).find(entry => entry.slug === slug)?.name ?? '—'
|
||||
|
||||
const canSubmit = computed(() =>
|
||||
props.formData.summary_information_correct
|
||||
&& props.formData.summary_accept_terms
|
||||
&& props.formData.legal_accepted
|
||||
&& (!requiresPaymentConfirmation.value || props.formData.payment)
|
||||
&& !props.submitting
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h3>Zusammenfassung</h3>
|
||||
|
||||
<div v-if="summaryLoading" style="color: #6b7280; padding: 20px 0;">Wird geladen…</div>
|
||||
<div v-else>
|
||||
<table class="form-table" style="margin-bottom: 20px;">
|
||||
<tr>
|
||||
<td>Dein Name:</td>
|
||||
<td>{{ formData.vorname }} {{ formData.nachname }}</td>
|
||||
</tr>
|
||||
<tr v-if="formData.pfadiname">
|
||||
<td>Pfadiname:</td>
|
||||
<td>{{ formData.pfadiname }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Deine E-Mail:</td>
|
||||
<td>{{ formData.email_1 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Deine Telefonnummer:</td>
|
||||
<td>{{ formData.telefon_1 }}</td>
|
||||
</tr>
|
||||
<tr v-if="localGroupName">
|
||||
<td>Stamm:</td>
|
||||
<td>{{ localGroupName }}</td>
|
||||
</tr>
|
||||
|
||||
<template v-if="isMinor">
|
||||
<tr>
|
||||
<td>Kontaktperson:</td>
|
||||
<td>{{ formData.ansprechpartner }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>E-Mail der Kontaktperson:</td>
|
||||
<td>{{ formData.email_2 }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Erweiterte Erste Hilfe:</td>
|
||||
<td>{{ permissionName(event.firstAidPermissions, formData.first_aid) }}</td>
|
||||
</tr>
|
||||
<tr v-if="event.swimmingPermissionRequired">
|
||||
<td>Badeerlaubnis:</td>
|
||||
<td>{{ permissionName(event.swimmingPermissions, formData.badeerlaubnis) }}</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<tr>
|
||||
<td>Allergien:</td>
|
||||
<td>{{ formData.allergien || 'Keine Angabe' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Unverträglichkeiten:</td>
|
||||
<td>{{ formData.intolerances || 'Keine Angabe' }}</td>
|
||||
</tr>
|
||||
|
||||
<tr v-for="option in selectedParticipationOptions" :key="option.label">
|
||||
<td>{{ option.label }}:</td>
|
||||
<td>{{ option.value }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Foto-Erlaubnis:</td>
|
||||
<td>
|
||||
<strong>Social Media:</strong> {{ formData.foto.socialmedia ? 'Ja' : 'Nein' }},
|
||||
<strong>Printmedien:</strong> {{ formData.foto.print ? 'Ja' : 'Nein' }},
|
||||
<strong>Webseite:</strong> {{ formData.foto.webseite ? 'Ja' : 'Nein' }},
|
||||
<strong>Partnerorganisationen:</strong> {{ formData.foto.partner ? 'Ja' : 'Nein' }},
|
||||
<strong>Interne Zwecke:</strong> {{ formData.foto.intern ? 'Ja' : 'Nein' }}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td>Veranstaltung:</td><td><strong>{{ event.name }}</strong></td></tr>
|
||||
<tr><td>Zeitraum:</td><td>{{ event.eventBegin }} – {{ event.eventEnd }}</td></tr>
|
||||
</table>
|
||||
|
||||
<h4 style="margin: 0 0 8px 0;">Kostenübersicht</h4>
|
||||
<table class="form-table cost-table" style="margin-bottom: 20px;">
|
||||
<tr class="cost-total">
|
||||
<td><strong>Teilnahmebeitrag:</strong></td>
|
||||
<td><strong>{{ summaryAmount }}</strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div style="display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px;">
|
||||
<label style="display: flex; gap: 10px; cursor: pointer;">
|
||||
<input type="checkbox" v-model="formData.summary_information_correct" />
|
||||
Ich bestätige, dass alle Angaben korrekt sind.
|
||||
</label>
|
||||
<label style="display: flex; gap: 10px; cursor: pointer;">
|
||||
<input type="checkbox" v-model="formData.summary_accept_terms" />
|
||||
Ich akzeptiere die Teilnahmebedingungen.
|
||||
</label>
|
||||
<label style="display: flex; gap: 10px; cursor: pointer;">
|
||||
<input type="checkbox" v-model="formData.legal_accepted" />
|
||||
Ich stimme der Datenschutzerklärung zu.
|
||||
</label>
|
||||
<label v-if="requiresPaymentConfirmation" style="display: flex; gap: 10px; cursor: pointer;">
|
||||
<input type="checkbox" v-model="formData.payment" />
|
||||
{{ paymentConfirmationText }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<p v-if="submitError" style="color: #991b1b; font-weight: 600;">{{ submitError }}</p>
|
||||
|
||||
<div class="btn-row">
|
||||
<button type="button" class="btn-secondary" @click="emit('back')">← Zurück</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="btn-primary"
|
||||
:disabled="!canSubmit"
|
||||
style="background: #059669;"
|
||||
>
|
||||
{{ submitting ? 'Wird gesendet…' : 'Jetzt anmelden ✓' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.cost-table .cost-total td {
|
||||
border-top: 1px solid #d1d5db;
|
||||
padding-top: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -122,170 +122,5 @@ const steps = [
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* ─── Progress (Step-Pills) ─── */
|
||||
.signup-progress {
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.signup-progress-pills {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.signup-progress-separator {
|
||||
flex-shrink: 0;
|
||||
width: 16px;
|
||||
height: 2px;
|
||||
background: #e5e7eb;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.signup-pill {
|
||||
padding: 5px 14px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
border: 2px solid;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.signup-pill__check { margin-right: 4px; }
|
||||
|
||||
.signup-pill--active {
|
||||
border-color: #2563eb;
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.signup-pill--done {
|
||||
border-color: #bbf7d0;
|
||||
background: #f0fdf4;
|
||||
color: #15803d;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.signup-pill--upcoming {
|
||||
border-color: #e5e7eb;
|
||||
background: #f9fafb;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.signup-progress-bar {
|
||||
margin-top: 10px;
|
||||
height: 3px;
|
||||
background: #e5e7eb;
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.signup-progress-bar__fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #2563eb, #3b82f6);
|
||||
border-radius: 2px;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.signup-progress-mobile {
|
||||
display: none;
|
||||
margin-top: 8px;
|
||||
font-size: 0.9rem;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
/* ─── Form-Table ─── */
|
||||
.form-table { width: 100%; border-collapse: collapse; }
|
||||
.form-table td { padding: 8px 12px 8px 0; vertical-align: top; }
|
||||
.form-table td:first-child { width: 220px; color: #374151; font-weight: 500; }
|
||||
.form-table input[type="text"],
|
||||
.form-table input[type="date"],
|
||||
.form-table input[type="email"],
|
||||
.form-table input[type="number"],
|
||||
.form-table select,
|
||||
.form-table textarea {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.btn-row { display: flex; gap: 10px; padding-top: 16px; flex-wrap: wrap; }
|
||||
.btn-primary {
|
||||
padding: 8px 20px;
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
.btn-secondary {
|
||||
padding: 8px 20px;
|
||||
background: #f3f4f6;
|
||||
color: #374151;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ─── Tablet ─── */
|
||||
@media (max-width: 1023px) {
|
||||
.form-table td:first-child {
|
||||
width: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Smartphone ─── */
|
||||
@media (max-width: 639px) {
|
||||
/* Pills auf Mobile: kompakter, Trennstriche ausblenden */
|
||||
.signup-progress-pills {
|
||||
display: none;
|
||||
}
|
||||
.signup-progress-mobile {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Form-Table: Label oberhalb des Feldes */
|
||||
.form-table,
|
||||
.form-table tbody,
|
||||
.form-table tr {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.form-table td {
|
||||
display: block;
|
||||
width: 100% !important;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.form-table td:first-child {
|
||||
width: 100% !important;
|
||||
font-weight: 600;
|
||||
color: #374151;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.form-table td[colspan] {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
flex-direction: column-reverse;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-primary,
|
||||
.btn-secondary {
|
||||
width: 100%;
|
||||
padding: 12px 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<!-- Unscoped und mit der Kurzanmeldung geteilt (ShortSignupForm.vue bindet dieselbe Datei ein). -->
|
||||
<style src="./signupForm.css"></style>
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
/* Geteilte Styles der Anmelde-Wizards (langer Prozess und Kurzanmeldung). */
|
||||
|
||||
/* ─── Progress (Step-Pills) ─── */
|
||||
.signup-progress {
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.signup-progress-pills {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.signup-progress-separator {
|
||||
flex-shrink: 0;
|
||||
width: 16px;
|
||||
height: 2px;
|
||||
background: #e5e7eb;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.signup-pill {
|
||||
padding: 5px 14px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
border: 2px solid;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.signup-pill__check { margin-right: 4px; }
|
||||
|
||||
.signup-pill--active {
|
||||
border-color: #2563eb;
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.signup-pill--done {
|
||||
border-color: #bbf7d0;
|
||||
background: #f0fdf4;
|
||||
color: #15803d;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.signup-pill--upcoming {
|
||||
border-color: #e5e7eb;
|
||||
background: #f9fafb;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.signup-progress-bar {
|
||||
margin-top: 10px;
|
||||
height: 3px;
|
||||
background: #e5e7eb;
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.signup-progress-bar__fill {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #2563eb, #3b82f6);
|
||||
border-radius: 2px;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.signup-progress-mobile {
|
||||
display: none;
|
||||
margin-top: 8px;
|
||||
font-size: 0.9rem;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
/* ─── Form-Table ─── */
|
||||
.form-table { width: 100%; border-collapse: collapse; }
|
||||
.form-table td { padding: 8px 12px 8px 0; vertical-align: top; }
|
||||
.form-table td:first-child { width: 220px; color: #374151; font-weight: 500; }
|
||||
.form-table input[type="text"],
|
||||
.form-table input[type="date"],
|
||||
.form-table input[type="email"],
|
||||
.form-table input[type="number"],
|
||||
.form-table select,
|
||||
.form-table textarea {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 6px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.btn-row { display: flex; gap: 10px; padding-top: 16px; flex-wrap: wrap; }
|
||||
.btn-primary {
|
||||
padding: 8px 20px;
|
||||
background: #2563eb;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
.btn-secondary {
|
||||
padding: 8px 20px;
|
||||
background: #f3f4f6;
|
||||
color: #374151;
|
||||
border: 1px solid #d1d5db;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ─── Tablet ─── */
|
||||
@media (max-width: 1023px) {
|
||||
.form-table td:first-child {
|
||||
width: 160px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Smartphone ─── */
|
||||
@media (max-width: 639px) {
|
||||
/* Pills auf Mobile: kompakter, Trennstriche ausblenden */
|
||||
.signup-progress-pills {
|
||||
display: none;
|
||||
}
|
||||
.signup-progress-mobile {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Form-Table: Label oberhalb des Feldes */
|
||||
.form-table,
|
||||
.form-table tbody,
|
||||
.form-table tr {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.form-table td {
|
||||
display: block;
|
||||
width: 100% !important;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.form-table td:first-child {
|
||||
width: 100% !important;
|
||||
font-weight: 600;
|
||||
color: #374151;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.form-table td[colspan] {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
flex-direction: column-reverse;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-primary,
|
||||
.btn-secondary {
|
||||
width: 100%;
|
||||
padding: 12px 20px;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ const next = () => {
|
||||
hasError = true
|
||||
}
|
||||
|
||||
if (props.formData.badeerlaubnis === '-1') {
|
||||
if (props.event.swimmingPermissionRequired && props.formData.badeerlaubnis === '-1') {
|
||||
errors.badeerlaubnis = 'Bitte triff eine Entscheidung. Bist du dir unsicher, kontaktiere bitte die Aktionsleitung'
|
||||
hasError = true
|
||||
}
|
||||
@@ -86,7 +86,7 @@ const next = () => {
|
||||
<ErrorText :message="errors.email_2" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-if="event.swimmingPermissionRequired">
|
||||
<td>Badeerlaubnis:</td>
|
||||
<td>
|
||||
<select v-model="formData.badeerlaubnis">
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import AppLayout from "../../../../resources/js/layouts/AppLayout.vue";
|
||||
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
||||
import SignupForm from './Partials/SignUpForm/SignupForm.vue'
|
||||
import ShortSignupForm from './Partials/ShortSignUpForm/ShortSignupForm.vue'
|
||||
import FullScreenModal from "../../../Views/Components/FullScreenModal.vue";
|
||||
import AvailableEvents from "./Partials/AvailableEvents.vue";
|
||||
import {ref} from "vue";
|
||||
@@ -37,7 +38,7 @@ function close() {
|
||||
</span>
|
||||
</div>
|
||||
<p class="signup-event-location">
|
||||
📍 {{ props.event.postalCode }} {{ props.event.location }}
|
||||
📍 {{ props.event.fullAddress }}
|
||||
</p>
|
||||
</div>
|
||||
<div v-else class="signup-header signup-header--closed">
|
||||
@@ -48,7 +49,7 @@ function close() {
|
||||
</span>
|
||||
</div>
|
||||
<p class="signup-event-location">
|
||||
📍 {{ props.event.postalCode }} {{ props.event.location }}
|
||||
📍 {{ props.event.fullAddress }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -98,8 +99,13 @@ function close() {
|
||||
<hr class="signup-divider" />
|
||||
|
||||
<div class="signup-body">
|
||||
<ShortSignupForm
|
||||
v-if="props.event.registrationAllowed && props.event.shortRegistration"
|
||||
:event="props.event"
|
||||
:participantData="props.participantData ?? {}"
|
||||
/>
|
||||
<SignupForm
|
||||
v-if="props.event.registrationAllowed"
|
||||
v-else-if="props.event.registrationAllowed"
|
||||
:event="props.event"
|
||||
:participantData="props.participantData ?? {}"
|
||||
:localGroups="props.localGroups ?? []"
|
||||
|
||||
@@ -22,7 +22,7 @@ class ChangeStatusCommand {
|
||||
switch ($this->request->status) {
|
||||
case InvoiceStatus::INVOICE_STATUS_APPROVED:
|
||||
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_APPROVED;
|
||||
$this->request->invoice->approved_by = auth()->user()->id;
|
||||
$this->request->invoice->approved_by = currentUserOrFail()->id;
|
||||
$this->request->invoice->approved_at = now();
|
||||
|
||||
if ($this->request->invoice->contact_email !== null) {
|
||||
@@ -35,7 +35,7 @@ class ChangeStatusCommand {
|
||||
|
||||
case InvoiceStatus::INVOICE_STATUS_DENIED:
|
||||
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_DENIED;
|
||||
$this->request->invoice->denied_by = auth()->user()->id;
|
||||
$this->request->invoice->denied_by = currentUserOrFail()->id;
|
||||
$this->request->invoice->denied_at = now();
|
||||
$this->request->invoice->denied_reason = $this->request->comment;
|
||||
if ($this->request->invoice->contact_email !== null) {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Domains\Invoice\Actions\CreateInvoice;
|
||||
|
||||
use App\Enumerations\InvoiceStatus;
|
||||
use App\Enumerations\InvoiceType;
|
||||
use App\Enumerations\TravelReason;
|
||||
use App\Mail\InvoiceMails\InvoiceMailsNewInvoiceMail;
|
||||
use App\Mail\InvoiceMails\InvoiceMailsSubmittedConfirmationMail;
|
||||
use App\Mail\ParticipantParticipationMails\EventSignUpSuccessfullMail;
|
||||
@@ -19,17 +21,27 @@ class CreateInvoiceCommand {
|
||||
public function execute() : CreateInvoiceResponse {
|
||||
$response = new CreateInvoiceResponse();
|
||||
|
||||
$rejection = $this->rejectTravelReason();
|
||||
if ($rejection !== null) {
|
||||
$response->message = $rejection;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
if ($this->request->accountIban === 'undefined') {
|
||||
$this->request->accountIban = null;
|
||||
}
|
||||
|
||||
$travelReason = $this->travelReason();
|
||||
|
||||
$invoice = Invoice::create([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'cost_unit_id' => $this->request->costUnit->id,
|
||||
'invoice_number' => $this->generateInvoiceNumber(),
|
||||
'status' => InvoiceStatus::INVOICE_STATUS_NEW,
|
||||
'type' => $this->request->invoiceType,
|
||||
'type_other' => $this->request->invoiceTypeExtended,
|
||||
'purpose' => $this->purpose($travelReason),
|
||||
'donation' => $this->request->isDonation,
|
||||
'user_id' => $this->request->paymentPurpose === null ? $this->request->userId : null,
|
||||
'contact_name' => $this->request->contactName,
|
||||
@@ -40,9 +52,7 @@ class CreateInvoiceCommand {
|
||||
'amount' => $this->request->totalAmount,
|
||||
'distance' => $this->request->distance,
|
||||
'travel_direction' => $this->request->travelRoute,
|
||||
'travel_reason' => $this->request->travelReason,
|
||||
'passengers' => $this->request->passengers,
|
||||
'transportation' => $this->request->transportations,
|
||||
'travel_reason' => $travelReason,
|
||||
'payment_purpose' => $this->request->paymentPurpose,
|
||||
'comment' => $this->request->notices,
|
||||
'document_filename' => $this->request->receiptFile !== null ? $this->request->receiptFile->fullPath : null,
|
||||
@@ -61,7 +71,7 @@ class CreateInvoiceCommand {
|
||||
}
|
||||
|
||||
if ($this->request->costUnit->mail_on_new) {
|
||||
$recipients = [app('tenant')->email_finance];
|
||||
$recipients = [currentTenant()->email_finance];
|
||||
|
||||
foreach ($this->request->costUnit->treasurers()->get() as $treasurer) {
|
||||
if (!in_array($treasurer->email, $recipients)) {
|
||||
@@ -81,9 +91,71 @@ class CreateInvoiceCommand {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Der Zahlungsgrund, einmal beim Anlegen festgehalten.
|
||||
*
|
||||
* Danach ist er eine eigene Angabe: Die Kassenwart*in kann ihn korrigieren, und nichts schreibt ihn
|
||||
* mehr um. Bei Fahrtkosten setzt er sich aus Reisegrund und den gefahrenen Personen zusammen, sonst
|
||||
* trägt ihn "Was wurde eingekauft". Wo nichts erfasst wird -- Beitragserstattungen -- bleibt er leer.
|
||||
*
|
||||
* Steht er schon fest, wird er übernommen: Eine Abrechnungskorrektur kopiert den Beleg, und ein von
|
||||
* Hand gesetzter Grund darf dabei nicht verloren gehen.
|
||||
*/
|
||||
private function purpose(?string $travelReason) : ?string {
|
||||
if (trim((string) $this->request->purpose) !== '') {
|
||||
return $this->request->purpose;
|
||||
}
|
||||
|
||||
$purpose = Invoice::joinPurposeParts(
|
||||
$this->request->invoiceType === InvoiceType::INVOICE_TYPE_TRAVELLING
|
||||
// Der Name des Grundes, nicht sein Schlüssel: In der Belegliste soll "Materialtransport"
|
||||
// stehen, nicht "material_transport".
|
||||
? [TravelReason::text($travelReason), $this->request->travellers]
|
||||
: [$this->request->invoiceTypeExtended]
|
||||
);
|
||||
|
||||
return $purpose === '' ? null : $purpose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Was in `travel_reason` landet: der Schlüssel des gewählten Grundes -- oder, bei "Anderer Grund",
|
||||
* der Text selbst. Der Schlüssel `other` sagt für sich nichts aus, der Text alles.
|
||||
*
|
||||
* Ein unbekannter Wert ist deshalb kein Fehler, sondern genau dieser Fall: So kommen auch
|
||||
* Bestandsbelege und Kopien durch, die ihren Freitext schon mitbringen.
|
||||
*/
|
||||
private function travelReason() : ?string {
|
||||
$reason = TravelReason::find($this->request->travelReason);
|
||||
|
||||
if ($reason === null) {
|
||||
return $this->request->travelReason;
|
||||
}
|
||||
|
||||
return $reason->requires_note
|
||||
? trim((string) $this->request->travelReasonNote)
|
||||
: $reason->slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sicherheitsnetz hinter der Oberfläche: Dort geht es erst weiter, wenn die Erläuterung steht. Über
|
||||
* einen direkten Aufruf ginge das sonst vorbei, und ein "Anderer Grund" ohne Text sagt nichts aus --
|
||||
* gespeichert würde ein leerer Reisegrund.
|
||||
*/
|
||||
private function rejectTravelReason() : ?string {
|
||||
$reason = TravelReason::find($this->request->travelReason);
|
||||
|
||||
if ($reason === null || !$reason->requires_note) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim((string) $this->request->travelReasonNote) === ''
|
||||
? 'Bitte gib an, was der Grund für die Reise war.'
|
||||
: null;
|
||||
}
|
||||
|
||||
private function generateInvoiceNumber() : string {
|
||||
$lastInvoiceNumber = Invoice::query()
|
||||
->where('tenant', app('tenant')->slug)
|
||||
->where('tenant', currentTenant()->slug)
|
||||
->whereYear('created_at', date('Y'))
|
||||
->count();
|
||||
|
||||
|
||||
@@ -16,16 +16,24 @@ class CreateInvoiceRequest {
|
||||
public ?string $invoiceTypeExtended;
|
||||
public ?string $travelRoute;
|
||||
public ?int $distance;
|
||||
public ?int $passengers;
|
||||
public ?int $transportations;
|
||||
public ?InvoiceFile $receiptFile;
|
||||
public float $totalAmount;
|
||||
public bool $isDonation;
|
||||
public ?int $userId;
|
||||
/** Der Slug eines Reisegrundes -- oder ein Freitext, wenn er von einem Bestandsbeleg stammt. */
|
||||
public ?string $travelReason;
|
||||
|
||||
/** Die Erläuterung zu "Anderer Grund"; nur bei einem Grund mit `requires_note` von Belang. */
|
||||
public ?string $travelReasonNote;
|
||||
public ?string $paymentPurpose;
|
||||
public ?string $notices;
|
||||
|
||||
/** Wer gereist ist -- Freitext aus dem Fahrtkosten-Formular, geht in den Zahlungsgrund ein. */
|
||||
public ?string $travellers;
|
||||
|
||||
/** Ein bereits feststehender Zahlungsgrund; gesetzt, gewinnt er über die Ermittlung im Command. */
|
||||
public ?string $purpose;
|
||||
|
||||
|
||||
public function __construct(
|
||||
CostUnit $costUnit,
|
||||
@@ -42,11 +50,12 @@ class CreateInvoiceRequest {
|
||||
?string $invoiceTypeExtended = null,
|
||||
?string $travelRoute = null,
|
||||
?int $distance = null,
|
||||
?int $passengers = null,
|
||||
?int $transportations,
|
||||
?string $travelReason = null,
|
||||
?string $travelReasonNote = null,
|
||||
?string $paymentPurpose = null,
|
||||
?string $notices = null,
|
||||
?string $travellers = null,
|
||||
?string $purpose = null,
|
||||
|
||||
) {
|
||||
$this->costUnit = $costUnit;
|
||||
@@ -55,8 +64,6 @@ class CreateInvoiceRequest {
|
||||
$this->invoiceTypeExtended = $invoiceTypeExtended;
|
||||
$this->travelRoute = $travelRoute;
|
||||
$this->distance = $distance;
|
||||
$this->passengers = $passengers;
|
||||
$this->transportations = $transportations;
|
||||
$this->receiptFile = $receiptFile;
|
||||
$this->contactEmail = $contactEmail;
|
||||
$this->contactPhone = $contactPhone;
|
||||
@@ -66,8 +73,11 @@ class CreateInvoiceRequest {
|
||||
$this->isDonation = $isDonation;
|
||||
$this->userId = $userId;
|
||||
$this->travelReason = $travelReason;
|
||||
$this->travelReasonNote = $travelReasonNote;
|
||||
$this->paymentPurpose = $paymentPurpose;
|
||||
$this->notices = $notices;
|
||||
$this->travellers = $travellers;
|
||||
$this->purpose = $purpose;
|
||||
|
||||
if ($accountIban === 'undefined') {
|
||||
$this->accountIban = null;
|
||||
|
||||
@@ -8,8 +8,12 @@ class CreateInvoiceResponse {
|
||||
public bool $success;
|
||||
public ?Invoice $invoice;
|
||||
|
||||
/** Warum keine Abrechnung entstanden ist -- für die Rückmeldung an die einreichende Person. */
|
||||
public ?string $message;
|
||||
|
||||
public function __construct() {
|
||||
$this->success = false;
|
||||
$this->invoice = null;
|
||||
$this->message = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +83,8 @@ class CreateInvoiceReceiptCommand {
|
||||
|
||||
$travelPartTemplate = <<<HTML
|
||||
<tr><td>Reiseweg:</td><td>%1\$s</td></tr>
|
||||
<tr><td>Grund der Reise:</td><td>%6\$s</td></tr>
|
||||
<tr><td>Grund der Reise:</td><td>%4\$s</td></tr>
|
||||
<tr><td>Gesamtlänge der Strecke:</td><td>%2\$s km x %3\$s / km</td></tr>
|
||||
<tr><td>Materialtransport:</td><td>%4\$s</td></tr>
|
||||
<tr><td>Mitfahrende im PKW:</td><td>%5\$s</td></tr>
|
||||
HTML;
|
||||
|
||||
$flatTravelPart = sprintf(
|
||||
@@ -94,8 +92,6 @@ HTML;
|
||||
$invoiceReadable['travelDirection'] ,
|
||||
$invoiceReadable['distance'],
|
||||
$invoiceReadable['distanceAllowance'],
|
||||
$invoiceReadable['transportation'],
|
||||
$invoiceReadable['passengers'],
|
||||
$invoiceReadable['travelReason'] ,
|
||||
);
|
||||
|
||||
@@ -180,7 +176,10 @@ HTML;
|
||||
$invoiceReadable['contactEmail'],
|
||||
$invoiceReadable['contactPhone'],
|
||||
$invoiceReadable['costUnitName'],
|
||||
$invoiceReadable['invoiceType'],
|
||||
// Der erfasste Zahlungsgrund, nicht der Abrechnungstyp: Der steht eine Zeile darüber schon
|
||||
// als Überschrift. Bei Fahrtkosten ist das die einzige Stelle, an der auf dem Beleg steht,
|
||||
// wer gereist ist.
|
||||
$invoiceReadable['purpose'],
|
||||
$invoiceReadable['donationText'],
|
||||
$paymentType,
|
||||
$invoiceReadable['amount'],
|
||||
|
||||
@@ -34,6 +34,17 @@ class UpdateInvoiceCommand {
|
||||
}
|
||||
|
||||
|
||||
$purpose = trim((string) $this->request->purpose);
|
||||
$purpose = $purpose === '' ? null : $purpose;
|
||||
|
||||
// Verglichen wird gegen den angezeigten Text, nicht gegen die Spalte: Das Formular ist damit
|
||||
// vorbelegt, und wer ihn unverändert abschickt, hat nichts geändert. Ein Bestandsbeleg behält so
|
||||
// seine leere Spalte und damit die Ableitung; wer das Feld leert, schaltet zurück auf automatisch.
|
||||
if (($purpose ?? '') !== $this->request->invoice->purposeText()) {
|
||||
$changes .= 'Zahlungsgrund geändert von ' . $this->request->invoice->purposeText() . ' auf ' . ($purpose ?? '--') . '.<br />';
|
||||
$this->request->invoice->purpose = $purpose;
|
||||
}
|
||||
|
||||
$this->request->invoice->comment = $this->request->comment;
|
||||
$this->request->invoice->changes = $changes;
|
||||
|
||||
|
||||
@@ -13,9 +13,11 @@ class UpdateInvoiceRequest {
|
||||
public CostUnit $costUnit;
|
||||
public Invoice $invoice;
|
||||
public Amount $amount;
|
||||
public ?string $purpose;
|
||||
|
||||
public function __construct(Invoice $invoice, ?string $comment, InvoiceType $invoiceType, CostUnit $costUnit, Amount $amount) {
|
||||
public function __construct(Invoice $invoice, ?string $comment, InvoiceType $invoiceType, CostUnit $costUnit, Amount $amount, ?string $purpose = null) {
|
||||
$this->comment = $comment;
|
||||
$this->purpose = $purpose;
|
||||
$this->invoiceType = $invoiceType;
|
||||
$this->costUnit = $costUnit;
|
||||
$this->invoice = $invoice;
|
||||
|
||||
@@ -19,7 +19,7 @@ class UploadInvoiceCommand {
|
||||
$uploadDir = sprintf(
|
||||
'%1$s%2$s/%3$s',
|
||||
WebDavProvider::INVOICE_PREFIX,
|
||||
app('tenant')->url,
|
||||
currentTenant()->url,
|
||||
$this->request->invoice->costUnit()->first()->name
|
||||
);
|
||||
|
||||
|
||||
@@ -32,25 +32,26 @@ class EditController extends CommonController{
|
||||
$receiptfile->fullPath = $invoice->document_filename;
|
||||
}
|
||||
$createInvoiceRequest = new CreateInvoiceRequest(
|
||||
$invoice->costUnit()->first(),
|
||||
$invoice->contact_name,
|
||||
$invoice->type,
|
||||
$invoice->amount,
|
||||
$receiptfile,
|
||||
$invoice->donation,
|
||||
$invoice->user_id,
|
||||
$invoice->contact_email,
|
||||
$invoice->contact_phone,
|
||||
$invoice->contact_bank_owner,
|
||||
$invoice->contact_bank_iban,
|
||||
$invoice->type_other,
|
||||
$invoice->travel_direction,
|
||||
$invoice->distance,
|
||||
$invoice->passengers,
|
||||
$invoice->transportation,
|
||||
$invoice->travel_reason,
|
||||
$invoice->payment_purpose,
|
||||
$invoice->comment,
|
||||
costUnit: $invoice->costUnit()->first(),
|
||||
contactName: $invoice->contact_name,
|
||||
invoiceType: $invoice->type,
|
||||
totalAmount: $invoice->amount,
|
||||
receiptFile: $receiptfile,
|
||||
isDonation: $invoice->donation,
|
||||
userId: $invoice->user_id,
|
||||
contactEmail: $invoice->contact_email,
|
||||
contactPhone: $invoice->contact_phone,
|
||||
accountOwner: $invoice->contact_bank_owner,
|
||||
accountIban: $invoice->contact_bank_iban,
|
||||
invoiceTypeExtended: $invoice->type_other,
|
||||
travelRoute: $invoice->travel_direction,
|
||||
distance: $invoice->distance,
|
||||
travelReason: $invoice->travel_reason,
|
||||
paymentPurpose: $invoice->payment_purpose,
|
||||
notices: $invoice->comment,
|
||||
// Die rohe Spalte, nicht purposeText(): Ein Beleg, der seinen Zahlungsgrund bisher ableitet,
|
||||
// soll das als Kopie weiter tun.
|
||||
purpose: $invoice->purpose,
|
||||
);
|
||||
|
||||
$invoiceCreationCommand = new CreateInvoiceCommand($createInvoiceRequest);
|
||||
@@ -92,7 +93,8 @@ class EditController extends CommonController{
|
||||
$modifyData['notices'],
|
||||
$invoiceType,
|
||||
$newCostUnit,
|
||||
$newAmount
|
||||
$newAmount,
|
||||
$modifyData['purpose'] ?? null
|
||||
);
|
||||
$updateInvoiceCommand = new UpdateInvoiceCommand($updateInvoiceRequest);
|
||||
$updateInvoiceCommand->execute();
|
||||
@@ -107,22 +109,22 @@ class EditController extends CommonController{
|
||||
$receiptfile->fullPath = $invoice->document_filename;
|
||||
}
|
||||
$createInvoiceRequest = new CreateInvoiceRequest(
|
||||
$invoice->costUnit()->first(),
|
||||
$invoice->contact_name,
|
||||
$invoice->type,
|
||||
$amountLeft->getAmount(),
|
||||
$receiptfile,
|
||||
$invoice->donation,
|
||||
$invoice->user_id,
|
||||
$invoice->contact_email,
|
||||
$invoice->contact_phone,
|
||||
$invoice->contact_bank_owner,
|
||||
$invoice->contact_bank_iban,
|
||||
$invoice->type_other,
|
||||
$invoice->travel_direction,
|
||||
$invoice->distance,
|
||||
$invoice->passengers,
|
||||
$invoice->transportation
|
||||
costUnit: $invoice->costUnit()->first(),
|
||||
contactName: $invoice->contact_name,
|
||||
invoiceType: $invoice->type,
|
||||
totalAmount: $amountLeft->getAmount(),
|
||||
receiptFile: $receiptfile,
|
||||
isDonation: $invoice->donation,
|
||||
userId: $invoice->user_id,
|
||||
contactEmail: $invoice->contact_email,
|
||||
contactPhone: $invoice->contact_phone,
|
||||
accountOwner: $invoice->contact_bank_owner,
|
||||
accountIban: $invoice->contact_bank_iban,
|
||||
invoiceTypeExtended: $invoice->type_other,
|
||||
travelRoute: $invoice->travel_direction,
|
||||
distance: $invoice->distance,
|
||||
travelReason: $invoice->travel_reason,
|
||||
purpose: $invoice->purpose,
|
||||
);
|
||||
|
||||
$invoiceCreationCommand = new CreateInvoiceCommand($createInvoiceRequest);
|
||||
|
||||
@@ -66,50 +66,43 @@ class SaveInvoiceController extends CommonController
|
||||
}
|
||||
|
||||
$createInvoiceRequest = new CreateInvoiceRequest(
|
||||
$costUnit,
|
||||
$request->input('name'),
|
||||
InvoiceType::INVOICE_TYPE_TRAVELLING,
|
||||
$amount,
|
||||
$uploadedFile,
|
||||
'donation' === $request->input('decision') ? true : false,
|
||||
$this->users->getCurrentUserDetails()['userId'],
|
||||
$request->input('email'),
|
||||
$request->input('telephone'),
|
||||
$request->input('accountOwner'),
|
||||
$request->input('accountIban'),
|
||||
null,
|
||||
$request->input('otherText'),
|
||||
$distance,
|
||||
$request->input('havePassengers'),
|
||||
$request->input('materialTransportation'),
|
||||
$request->input('travelReason'),
|
||||
null,
|
||||
$notices
|
||||
costUnit: $costUnit,
|
||||
contactName: $request->input('name'),
|
||||
invoiceType: InvoiceType::INVOICE_TYPE_TRAVELLING,
|
||||
totalAmount: $amount,
|
||||
receiptFile: $uploadedFile,
|
||||
isDonation: 'donation' === $request->input('decision') ? true : false,
|
||||
userId: $this->users->getCurrentUserDetails()['userId'],
|
||||
contactEmail: $request->input('email'),
|
||||
contactPhone: $request->input('telephone'),
|
||||
accountOwner: $request->input('accountOwner'),
|
||||
accountIban: $request->input('accountIban'),
|
||||
travelRoute: $request->input('otherText'),
|
||||
distance: $distance,
|
||||
travelReason: $request->input('travelReason'),
|
||||
travelReasonNote: $request->input('travelReasonNote'),
|
||||
notices: $notices,
|
||||
travellers: $request->input('travellers')
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$createInvoiceRequest = new CreateInvoiceRequest(
|
||||
$costUnit,
|
||||
$request->input('name'),
|
||||
$invoiceType,
|
||||
Amount::fromString($request->input('amount'))->getAmount(),
|
||||
$uploadedFile,
|
||||
'donation' === $request->input('decision') ? true : false,
|
||||
$this->users->getCurrentUserDetails()['userId'],
|
||||
$request->input('email'),
|
||||
$request->input('telephone'),
|
||||
$request->input('accountOwner'),
|
||||
$request->input('accountIban'),
|
||||
$request->input('otherText'),
|
||||
null,
|
||||
null,
|
||||
$request->input('havePassengers'),
|
||||
$request->input('materialTransportation'),
|
||||
null,
|
||||
$paymentPurpose,
|
||||
$notices
|
||||
costUnit: $costUnit,
|
||||
contactName: $request->input('name'),
|
||||
invoiceType: $invoiceType,
|
||||
totalAmount: Amount::fromString($request->input('amount'))->getAmount(),
|
||||
receiptFile: $uploadedFile,
|
||||
isDonation: 'donation' === $request->input('decision') ? true : false,
|
||||
userId: $this->users->getCurrentUserDetails()['userId'],
|
||||
contactEmail: $request->input('email'),
|
||||
contactPhone: $request->input('telephone'),
|
||||
accountOwner: $request->input('accountOwner'),
|
||||
accountIban: $request->input('accountIban'),
|
||||
invoiceTypeExtended: $request->input('otherText'),
|
||||
paymentPurpose: $paymentPurpose,
|
||||
notices: $notices
|
||||
);
|
||||
|
||||
break;
|
||||
@@ -128,5 +121,11 @@ class SaveInvoiceController extends CommonController
|
||||
'message' => 'Alright'
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => $response->message
|
||||
?? 'Beim Speichern ist ein Fehler aufgetreten. Bitte starte den Vorgang erneut.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,15 +37,6 @@ const props = defineProps({
|
||||
<td style="font-weight: bold">{{props.invoice.amount}}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Marterialtransport</th>
|
||||
<td>{{props.invoice.transportation}}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Hat Personen mitgenommen</th>
|
||||
<td>{{props.invoice.passengers}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</template>
|
||||
|
||||
@@ -16,11 +16,18 @@ const props = defineProps({
|
||||
|
||||
const emit = defineEmits(['submit', 'cancel'])
|
||||
|
||||
/**
|
||||
* Die Anmerkung heißt in der Resource `comment` und ist dort `'--'`, wenn keine gesetzt ist -- beides
|
||||
* muss hier stimmen, sonst startet das Feld leer und das Speichern löscht die vorhandene Anmerkung.
|
||||
*/
|
||||
const existingComment = props.newInvoice.comment
|
||||
|
||||
const formData = reactive({
|
||||
type_internal: props.newInvoice.internalType || '',
|
||||
cost_unit: props.newInvoice.costUnitId || '',
|
||||
amount: props.newInvoice.amountPlain || '',
|
||||
notices: props.newInvoice.comments || '',
|
||||
purpose: props.newInvoice.purpose || '',
|
||||
notices: !existingComment || existingComment === '--' ? '' : existingComment,
|
||||
})
|
||||
|
||||
const submitForm = () => {
|
||||
@@ -70,6 +77,13 @@ onMounted(async () => {
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Zahlungsgrund:</td>
|
||||
<td>
|
||||
<input type="text" v-model="formData.purpose" class="width-almost-full" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Anmerkungen:</td>
|
||||
<td>
|
||||
|
||||
@@ -100,6 +100,10 @@ const emit = defineEmits(["accept", "deny", "fix", "reopen"])
|
||||
<td v-else-if="props.data.externalPayment">Rechnungszahlung</td>
|
||||
<td v-else>Klassische Auszahlung</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Zahlungsgrund:</td>
|
||||
<td colspan="3">{{props.data.purpose}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Status:</td>
|
||||
<td>{{props.data.readableStatus}}</td>
|
||||
|
||||
@@ -32,15 +32,6 @@ const props = defineProps({
|
||||
<td style="font-weight: bold">{{props.invoice.amount}}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Marterialtransport</th>
|
||||
<td>{{props.invoice.transportation}}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th>Hat Personen mitgenommen</th>
|
||||
<td>{{props.invoice.passengers}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</template>
|
||||
|
||||
@@ -45,12 +45,13 @@
|
||||
<template>
|
||||
<table v-if="localData.invoices.length > 0" class="invoice-list-table">
|
||||
<tr>
|
||||
<td colspan="6">{{props.data.title}}</td>
|
||||
<td colspan="7">{{props.data.title}}</td>
|
||||
</tr>
|
||||
|
||||
<tr v-for="invoice in localData.invoices" :id="'invoice_' + invoice.id">
|
||||
<td>{{invoice.invoiceNumber}}</td>
|
||||
<td>{{invoice.invoiceType}}</td>
|
||||
<td>{{invoice.invoiceTypeShort}}</td>
|
||||
<td style="max-width: 250px;">{{invoice.purpose}}</td>
|
||||
<td>
|
||||
{{invoice.amount}}
|
||||
</td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
|
||||
import { ref, onMounted, reactive } from 'vue'
|
||||
import { ref, computed, onMounted, reactive } from 'vue'
|
||||
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
||||
import RefundData from "./refund-data.vue";
|
||||
import AmountInput from "../../../../../Views/Components/AmountInput.vue";
|
||||
@@ -38,6 +38,20 @@ onMounted(async () => {
|
||||
Object.assign(invoiceTypeCollection, data);
|
||||
});
|
||||
|
||||
/**
|
||||
* Das Beispiel im Feld "Was wurde eingekauft" kommt aus `invoice_types.purchase_example` und ist damit
|
||||
* ohne Deployment pflegbar. Ein allgemeines "z. B. Material" hilft beim Ausfüllen nicht weiter, und von
|
||||
* genau diesem Text lebt später die Zweck-Spalte der EüR-Belegliste.
|
||||
*
|
||||
* Ist am Typ nichts gepflegt, greift der allgemeine Text -- ein Feld ohne jede Hilfestellung wäre
|
||||
* schlechter als ein unscharfes Beispiel.
|
||||
*/
|
||||
const purchasePlaceholder = computed(() => {
|
||||
const selected = Object.values(invoiceTypeCollection.invoiceTypes)
|
||||
.find((type) => type.slug === invoiceType.value)
|
||||
|
||||
return selected?.purchaseExample || 'z. B. Material für die Veranstaltung'
|
||||
})
|
||||
|
||||
function handleFileChange(event) {
|
||||
if (checkFilesize('receipt')) {
|
||||
@@ -66,28 +80,36 @@ function handleFileChange(event) {
|
||||
<InfoIcon :text="'INFO_INVOICE_TYPE_' + availableInvoiceType.slug" /><br />
|
||||
</p>
|
||||
|
||||
</fieldset><br /><br />
|
||||
|
||||
<label for="invoice_type_other">
|
||||
<!--
|
||||
Pflichtangabe zu jeder Rechnung, nicht nur zu "Sonstige Kosten": Erst dieser Text sagt, wofür das
|
||||
Geld ausgegeben wurde, und füllt damit die Zweck-Spalte der EüR-Belegliste.
|
||||
|
||||
Die Schritte bauen aufeinander auf -- ohne Ausgabenart gäbe es kein passendes Beispiel für den
|
||||
Einkauf, und ein Betrag ohne Zweck ließe sich später nicht mehr zuordnen.
|
||||
-->
|
||||
<template v-if="invoiceType !== null">
|
||||
<fieldset>
|
||||
<legend><span style="font-weight: bolder;">Was wurde eingekauft</span></legend>
|
||||
<input
|
||||
type="text"
|
||||
class="width-full"
|
||||
name="kostengruppe_sonstiges"
|
||||
placeholder="Sonstige"
|
||||
for="invoice_type_other"
|
||||
id="purchase_description"
|
||||
name="purchase_description"
|
||||
:placeholder="purchasePlaceholder"
|
||||
v-model="otherText"
|
||||
@focus="invoiceType = 'other'"
|
||||
/>
|
||||
</label>
|
||||
</fieldset><br /><br />
|
||||
</template>
|
||||
|
||||
</fieldset><br /><br />
|
||||
|
||||
<fieldset>
|
||||
<fieldset v-if="invoiceType !== null && otherText.trim() !== ''">
|
||||
<legend><span style="font-weight: bolder;">Wie hoch ist der Betrag</span></legend>
|
||||
<AmountInput v-model="amount" class="width-small" id="amount" name="amount" /> Euro
|
||||
<info-icon></info-icon><br /><br />
|
||||
|
||||
<input
|
||||
v-if="amount != '' && invoiceType !== null"
|
||||
v-if="amount != ''"
|
||||
class="mareike-button"
|
||||
onclick="document.getElementById('receipt').click();"
|
||||
type="button"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
|
||||
import { ref, onMounted, reactive } from 'vue'
|
||||
import { ref, computed, onMounted, reactive } from 'vue'
|
||||
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
||||
import RefundData from "./refund-data.vue";
|
||||
import AmountInput from "../../../../../Views/Components/AmountInput.vue";
|
||||
@@ -37,6 +37,20 @@ onMounted(async () => {
|
||||
Object.assign(invoiceTypeCollection, data);
|
||||
});
|
||||
|
||||
/**
|
||||
* Das Beispiel im Feld "Was wurde eingekauft" kommt aus `invoice_types.purchase_example` und ist damit
|
||||
* ohne Deployment pflegbar. Ein allgemeines "z. B. Material" hilft beim Ausfüllen nicht weiter, und von
|
||||
* genau diesem Text lebt später die Zweck-Spalte der EüR-Belegliste.
|
||||
*
|
||||
* Ist am Typ nichts gepflegt, greift der allgemeine Text -- ein Feld ohne jede Hilfestellung wäre
|
||||
* schlechter als ein unscharfes Beispiel.
|
||||
*/
|
||||
const purchasePlaceholder = computed(() => {
|
||||
const selected = Object.values(invoiceTypeCollection.invoiceTypes)
|
||||
.find((type) => type.slug === invoiceType.value)
|
||||
|
||||
return selected?.purchaseExample || 'z. B. Material für die Veranstaltung'
|
||||
})
|
||||
|
||||
function handleFileChange(event) {
|
||||
if (checkFilesize('receipt')) {
|
||||
@@ -65,28 +79,36 @@ function handleFileChange(event) {
|
||||
<InfoIcon :text="'INFO_INVOICE_TYPE_' + availableInvoiceType.slug" /><br />
|
||||
</p>
|
||||
|
||||
</fieldset><br /><br />
|
||||
|
||||
<label for="invoice_type_other">
|
||||
<!--
|
||||
Pflichtangabe zu jeder Abrechnung, nicht nur zu "Sonstige Kosten": Erst dieser Text sagt, wofür
|
||||
das Geld ausgegeben wurde, und füllt damit die Zweck-Spalte der EüR-Belegliste.
|
||||
|
||||
Die Schritte bauen aufeinander auf -- ohne Ausgabenart gäbe es kein passendes Beispiel für den
|
||||
Einkauf, und ein Betrag ohne Zweck ließe sich später nicht mehr zuordnen.
|
||||
-->
|
||||
<template v-if="invoiceType !== null">
|
||||
<fieldset>
|
||||
<legend><span style="font-weight: bolder;">Was wurde eingekauft</span></legend>
|
||||
<input
|
||||
type="text"
|
||||
class="width-full"
|
||||
name="kostengruppe_sonstiges"
|
||||
placeholder="Sonstige"
|
||||
for="invoice_type_other"
|
||||
id="purchase_description"
|
||||
name="purchase_description"
|
||||
:placeholder="purchasePlaceholder"
|
||||
v-model="otherText"
|
||||
@focus="invoiceType = 'other'"
|
||||
/>
|
||||
</label>
|
||||
</fieldset><br /><br />
|
||||
</template>
|
||||
|
||||
</fieldset><br /><br />
|
||||
|
||||
<fieldset>
|
||||
<fieldset v-if="invoiceType !== null && otherText.trim() !== ''">
|
||||
<legend><span style="font-weight: bolder;">Wie hoch ist der Betrag</span></legend>
|
||||
<AmountInput v-model="amount" class="width-small" id="amount" name="amount" /> Euro
|
||||
<info-icon></info-icon><br /><br />
|
||||
|
||||
<input
|
||||
v-if="amount != '' && invoiceType !== null"
|
||||
v-if="amount != ''"
|
||||
class="mareike-button"
|
||||
onclick="document.getElementById('receipt').click();"
|
||||
type="button"
|
||||
|
||||
@@ -24,8 +24,6 @@ const props = defineProps({
|
||||
userTelephone: String,
|
||||
userAccountOwner: String,
|
||||
userAccountIban: String,
|
||||
havePassengers: Number,
|
||||
materialTransportation: Boolean,
|
||||
travelReason: String,
|
||||
})
|
||||
|
||||
@@ -61,8 +59,6 @@ async function sendData() {
|
||||
formData.append('accountOwner', userAccountOwner.value)
|
||||
formData.append('accountIban', userIban.value)
|
||||
formData.append('paymentPurpose', paymentPurpose.value)
|
||||
formData.append('havePassengers', props.havePassengers ? 1 : 0)
|
||||
formData.append('materialTransportation', props.materialTransportation ? 1 : 0)
|
||||
formData.append('travelReason', props.travelReason)
|
||||
|
||||
if (props.receipt) {
|
||||
|
||||
@@ -24,9 +24,9 @@ const props = defineProps({
|
||||
userTelephone: String,
|
||||
userAccountOwner: String,
|
||||
userAccountIban: String,
|
||||
havePassengers: Number,
|
||||
materialTransportation: Boolean,
|
||||
travelReason: String,
|
||||
travelReasonNote: String,
|
||||
travellers: String,
|
||||
})
|
||||
|
||||
const finalStep = ref(true)
|
||||
@@ -60,9 +60,9 @@ async function sendData() {
|
||||
formData.append('decision', decision.value)
|
||||
formData.append('accountOwner', userAccountOwner.value)
|
||||
formData.append('accountIban', userIban.value)
|
||||
formData.append('havePassengers', props.havePassengers ? 1 : 0)
|
||||
formData.append('materialTransportation', props.materialTransportation ? 1 : 0)
|
||||
formData.append('travelReason', props.travelReason)
|
||||
formData.append('travelReasonNote', props.travelReasonNote ?? '')
|
||||
formData.append('travellers', props.travellers ?? '')
|
||||
formData.append('notices', notices.value)
|
||||
|
||||
if (props.receipt) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, reactive } from 'vue'
|
||||
import { ref, computed, onMounted, reactive } from 'vue'
|
||||
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
||||
import RefundData from "./refund-data.vue";
|
||||
import NumericInput from "../../../../../Views/Components/NumericInput.vue";
|
||||
@@ -19,15 +19,44 @@ const { request } = useAjax();
|
||||
const distanceAllowance = ref(null);
|
||||
const travelDirection = ref(null);
|
||||
const travelReason = ref(null);
|
||||
const travelReasonNote = ref('');
|
||||
|
||||
const travelReasonCollection = reactive({
|
||||
travelReasons: []
|
||||
});
|
||||
|
||||
const selectedTravelReason = computed(() =>
|
||||
travelReasonCollection.travelReasons.find((reason) => reason.value === travelReason.value)
|
||||
);
|
||||
|
||||
/**
|
||||
* Ein Grund ist erst vollständig, wenn die Erläuterung steht, die er verlangt: "Anderer Grund" allein
|
||||
* sagt nichts aus. Die drei anderen Gründe bremsen den Ablauf dadurch nicht.
|
||||
*/
|
||||
const travelReasonComplete = computed(() =>
|
||||
selectedTravelReason.value !== undefined
|
||||
&& (!selectedTravelReason.value.requiresNote || travelReasonNote.value.trim() !== '')
|
||||
);
|
||||
|
||||
/**
|
||||
* Wer gereist ist, steht später als Zahlungsgrund in der Belegliste, auf der EüR und auf dem Beleg. Wer
|
||||
* den Beleg einreicht, war meist selbst dabei -- deshalb der eigene Name als Vorschlag. Ohne Login
|
||||
* bleibt das Feld leer, und es hält den Ablauf auch dann nicht auf: Ein Name ist eine Hilfe, keine
|
||||
* Bedingung.
|
||||
*/
|
||||
const travellers = ref(data.userName || '');
|
||||
const have_receipt = ref('')
|
||||
const havePassengers = ref(false);
|
||||
const materialTransportation = ref(false);
|
||||
const amount = ref(0.00);
|
||||
const invoiceType = ref(null);
|
||||
const otherText = ref('');
|
||||
const receipt = ref(null)
|
||||
const finalStep = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
const response = await fetch('/api/v1/core/retrieve-travel-reasons');
|
||||
travelReasonCollection.travelReasons = await response.json();
|
||||
});
|
||||
|
||||
async function getDistanceAllowance() {
|
||||
const tempData = await request('/api/v1/cost-unit/get-distance-allowance/' + data.eventId, {
|
||||
method: "GET",
|
||||
@@ -59,14 +88,40 @@ function handleFileChange(event) {
|
||||
|
||||
<fieldset v-if="travelDirection !== null">
|
||||
<legend><span style="font-weight: bolder;">Was war der Grund für deine Reise?</span></legend>
|
||||
|
||||
<p v-for="availableReason in travelReasonCollection.travelReasons">
|
||||
<input
|
||||
name="travel-reason"
|
||||
type="radio"
|
||||
:value="availableReason.value"
|
||||
:id="'travel_reason_' + availableReason.value"
|
||||
v-model="travelReason"
|
||||
>
|
||||
<label :for="'travel_reason_' + availableReason.value">{{ availableReason.label }}</label><br />
|
||||
</p>
|
||||
|
||||
<template v-if="selectedTravelReason?.requiresNote">
|
||||
<input
|
||||
type="text"
|
||||
class="width-full"
|
||||
name="travel-reason-note"
|
||||
placeholder="z. B. Abholung der Ausrüstung aus dem Lager"
|
||||
v-model="travelReasonNote"
|
||||
/>
|
||||
</template>
|
||||
</fieldset><br /><br />
|
||||
|
||||
<fieldset v-if="travelReasonComplete">
|
||||
<legend><span style="font-weight: bolder;">Welche Personen sind gereist?</span></legend>
|
||||
<input
|
||||
type="text"
|
||||
name="travel-reason"
|
||||
v-model="travelReason"
|
||||
name="travellers"
|
||||
placeholder="z. B. Mika, Kim und Alex"
|
||||
v-model="travellers"
|
||||
/>
|
||||
</fieldset><br /><br />
|
||||
|
||||
<fieldset v-if="travelReason !== null">
|
||||
<fieldset v-if="travelReasonComplete">
|
||||
<legend><span style="font-weight: bolder;">Bist du mit dem ÖPNV gefahren oder besitzt du einen Beleg</span></legend>
|
||||
<input type="button" style="border-radius: 0; width: 100px;" @click="have_receipt='yes'" value="Ja" />
|
||||
<input type="button" style="border-radius: 0; width: 100px;" @click="getDistanceAllowance" value="Nein" />
|
||||
@@ -93,8 +148,6 @@ function handleFileChange(event) {
|
||||
invoice-type="travelling"
|
||||
:amount="amount"
|
||||
:other-text="travelDirection"
|
||||
:materialTransportation="materialTransportation"
|
||||
:havePassengers="havePassengers"
|
||||
:userName="data.userName"
|
||||
:userEmail="data.userEmail"
|
||||
:userTelephone="data.userTelephone"
|
||||
@@ -102,6 +155,8 @@ function handleFileChange(event) {
|
||||
:userAccountOwner="data.userAccountOwner"
|
||||
:receipt="receipt"
|
||||
:travelReason="travelReason"
|
||||
:travelReasonNote="travelReasonNote"
|
||||
:travellers="travellers"
|
||||
@close="finalStep = false"
|
||||
/>
|
||||
</fieldset>
|
||||
@@ -117,22 +172,6 @@ function handleFileChange(event) {
|
||||
<span style="font-weight: normal">({{ amount }} km x {{distanceAllowance.toFixed(2).replace('.', ',')}} Euro / km = <strong>{{ (amount * distanceAllowance).toFixed(2).replace('.', ',') }} Euro</strong>)</span>
|
||||
<br /><br />
|
||||
|
||||
<input
|
||||
type="checkbox"
|
||||
name="havePassengers"
|
||||
v-model="havePassengers"
|
||||
id="havePassengers"
|
||||
/> <label style="margin-bottom: 20px;" for="havePassengers">Ich habe Personen mitgenommen</label>
|
||||
<br />
|
||||
|
||||
<input
|
||||
type="checkbox"
|
||||
name="materialTransportation"
|
||||
v-model="materialTransportation"
|
||||
id="materialTransportation"
|
||||
/> <label style="margin-bottom: 20px;" for="materialTransportation">Ich habe Material transportiert</label>
|
||||
<br /><br />
|
||||
|
||||
<input
|
||||
v-if="amount !== null && have_receipt === 'no' && amount != '0'"
|
||||
@click="finalStep = true;"
|
||||
@@ -145,14 +184,14 @@ function handleFileChange(event) {
|
||||
invoice-type="travelling"
|
||||
:amount="amount"
|
||||
:other-text="travelDirection"
|
||||
:materialTransportation="materialTransportation"
|
||||
:havePassengers="havePassengers"
|
||||
:userName="data.userName"
|
||||
:userEmail="data.userEmail"
|
||||
:userTelephone="data.userTelephone"
|
||||
:userAccountIban="data.userAccountIban"
|
||||
:userAccountOwner="data.userAccountOwner"
|
||||
:travelReason="travelReason"
|
||||
:travelReasonNote="travelReasonNote"
|
||||
:travellers="travellers"
|
||||
@close="finalStep = false"
|
||||
/>
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class CreateParticipantInvoiceCommand
|
||||
$this->participant = $request->participant;
|
||||
$this->event = $request->participant->event;
|
||||
|
||||
// Über die Relation und nicht über app('tenant'): die Rechnung hängt an der Veranstaltung,
|
||||
// Über die Relation und nicht über currentTenant(): die Rechnung hängt an der Veranstaltung,
|
||||
// nicht am gerade aktiven Mandanten. `$event->tenant` liefert das Slug-Attribut, nicht die
|
||||
// Relation -- deshalb der ausdrückliche Aufruf.
|
||||
$this->sender = $this->event->tenant()->first();
|
||||
|
||||
@@ -2,12 +2,27 @@
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Actions\AcceptRefund;
|
||||
|
||||
use App\Domains\Invoice\Actions\CreateInvoice\CreateInvoiceCommand;
|
||||
use App\Domains\Invoice\Actions\CreateInvoice\CreateInvoiceRequest;
|
||||
use App\Domains\ParticipantRefund\Actions\CreateRefundDocument\CreateRefundDocumentCommand;
|
||||
use App\Domains\ParticipantRefund\Actions\CreateRefundDocument\CreateRefundDocumentRequest;
|
||||
use App\Domains\ParticipantRefund\Actions\CreateRefundDocument\CreateRefundDocumentResponse;
|
||||
use App\Enumerations\InvoiceType;
|
||||
use App\Mail\ParticipantRefundMails\RefundAcceptedMail;
|
||||
use App\Models\CostUnit;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\ParticipantRefund;
|
||||
use App\Providers\FileWriteProvider;
|
||||
use App\Providers\UploadFileProvider;
|
||||
use App\Repositories\CostUnitRepository;
|
||||
use App\Support\Iban;
|
||||
use App\ValueObjects\Amount;
|
||||
use App\ValueObjects\InvoiceFile;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Der Teili bestätigt die Erstattung und hinterlegt seine Bankverbindung.
|
||||
@@ -46,24 +61,50 @@ class AcceptRefundCommand
|
||||
return $response;
|
||||
}
|
||||
|
||||
$owner = trim($this->request->accountOwner);
|
||||
$iban = Iban::normalize($this->request->accountIban);
|
||||
// Steht das Konto bereits am Vorgang, stammt es aus dem Zahlungseingang und wurde bei der
|
||||
// Freigabe festgeschrieben. Dann gilt es -- und die Felder aus dem Request werden verworfen.
|
||||
//
|
||||
// Das ist der eigentliche Gewinn der ganzen Übung: Der Teili tippt keine IBAN mehr ab, also
|
||||
// kann er sich weder vertippen noch lässt sich über einen direkten Aufruf dieser Route eine
|
||||
// fremde IBAN unterschieben. Erstattet wird auf das Konto, von dem gezahlt wurde, Punkt.
|
||||
$accountIsKnown = !$this->request->donation && filled($refund->account_iban);
|
||||
|
||||
$owner = $accountIsKnown ? (string) $refund->account_owner : trim($this->request->accountOwner);
|
||||
$iban = $accountIsKnown ? (string) $refund->account_iban : Iban::normalize($this->request->accountIban);
|
||||
|
||||
// Serverseitig und nicht nur im Formular: die Erklärung ist der einzige Grund, warum der Beleg
|
||||
// als Eigenbeleg etwas wert ist. Ließe sie sich mit einem direkten Aufruf übergehen, stünde auf
|
||||
// dem PDF eine Zusicherung, die niemand abgegeben hat.
|
||||
if (!$this->request->declarationAccepted) {
|
||||
//
|
||||
// Nimmt die Aktionsleitung die Angaben auf, kreuzt naturgemäß niemand etwas an. Nachvollziehbar
|
||||
// bleibt es trotzdem: `captured_by` hält fest, wer sie aufgenommen hat, und der Beleg weist es aus.
|
||||
if (!$this->request->declarationAccepted && $this->request->capturedBy === null) {
|
||||
$response->errorTypes['declaration'] = 'Bitte bestätige die Erklärung, damit wir erstatten können.';
|
||||
}
|
||||
|
||||
if ($owner === '') {
|
||||
$response->errorTypes['accountOwner'] = 'Bitte gib an, wem das Konto gehört.';
|
||||
}
|
||||
// Wer spendet, gibt kein Konto an -- alles Weitere betrifft nur die Auszahlung.
|
||||
if (!$this->request->donation) {
|
||||
// Erstattet wird ausschließlich auf das Konto, von dem der Beitrag kam. Ohne diese
|
||||
// Bestätigung ließe sich über eine Erstattung Geld auf ein fremdes Konto umleiten.
|
||||
if (!$this->request->accountDeclarationAccepted && $this->request->capturedBy === null) {
|
||||
$response->errorTypes['accountDeclaration'] = 'Bitte bestätige, dass es das Konto ist, '
|
||||
. 'von dem der Beitrag gezahlt wurde.';
|
||||
}
|
||||
|
||||
if ($iban === '') {
|
||||
$response->errorTypes['accountIban'] = 'Bitte gib die IBAN des Kontos ein.';
|
||||
} elseif (!Iban::isValid($iban)) {
|
||||
$response->errorTypes['accountIban'] = 'Diese IBAN stimmt nicht. Bitte prüfe deine Eingabe.';
|
||||
// Nur was der Teili selbst eingibt, muss geprüft werden. Das bekannte Konto hat die
|
||||
// Prüfung schon beim Import bestanden -- dort wird eine ungültige IBAN gar nicht erst
|
||||
// übernommen.
|
||||
if (!$accountIsKnown) {
|
||||
if ($owner === '') {
|
||||
$response->errorTypes['accountOwner'] = 'Bitte gib an, wem das Konto gehört.';
|
||||
}
|
||||
|
||||
if ($iban === '') {
|
||||
$response->errorTypes['accountIban'] = 'Bitte gib die IBAN des Kontos ein.';
|
||||
} elseif (!Iban::isValid($iban)) {
|
||||
$response->errorTypes['accountIban'] = 'Diese IBAN stimmt nicht. Bitte prüfe deine Eingabe.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($response->errorTypes !== []) {
|
||||
@@ -72,45 +113,226 @@ class AcceptRefundCommand
|
||||
return $response;
|
||||
}
|
||||
|
||||
$refund->account_owner = $owner;
|
||||
$refund->account_iban = $iban;
|
||||
$refund->status = ParticipantRefund::STATUS_ACCEPTED;
|
||||
$refund->accepted_at = now();
|
||||
$refund->save();
|
||||
// Ohne Kostenstelle gibt es nichts, worauf gebucht werden könnte. Lieber hier abbrechen, als den
|
||||
// Vorgang zu bestätigen und die Auszahlung stillschweigend nirgends einzureichen.
|
||||
$costUnit = $this->costUnit($refund);
|
||||
if ($costUnit === null) {
|
||||
$response->message = 'Die Erstattung kann gerade nicht bearbeitet werden. '
|
||||
. 'Bitte wende dich an die Aktionsleitung.';
|
||||
|
||||
$this->notify($refund);
|
||||
Log::error('Beitragserstattung: Veranstaltung ohne Kostenstelle, Abrechnung nicht möglich.', [
|
||||
'refund_id' => $refund->id,
|
||||
'event_id' => $refund->event_id,
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
// Der Beleg entsteht in der Transaktion, weil er den bestätigten Stand abbildet; scheitert das
|
||||
// Einreichen, soll auch kein Beleg gelten.
|
||||
$document = DB::transaction(function () use ($refund, $owner, $iban, $costUnit) {
|
||||
// Bei einer Spende bleiben die Kontofelder leer -- und zwar `null` und nicht Leerstring: Der
|
||||
// SEPA-Export unterscheidet daran, ob es etwas auszuzahlen gibt.
|
||||
$refund->account_owner = $this->request->donation ? null : $owner;
|
||||
$refund->account_iban = $this->request->donation ? null : $iban;
|
||||
$refund->captured_by = $this->request->capturedBy;
|
||||
$refund->status = ParticipantRefund::STATUS_ACCEPTED;
|
||||
$refund->accepted_at = now();
|
||||
$refund->save();
|
||||
|
||||
// Die Spende wird hier ausdrücklich mitgegeben statt am Vorgang abgelesen: Die Abrechnung,
|
||||
// die sie führt, entsteht erst weiter unten -- dieser Beleg ist ihr Anhang.
|
||||
$document = new CreateRefundDocumentCommand(new CreateRefundDocumentRequest(
|
||||
refund: $refund,
|
||||
donation: $this->request->donation,
|
||||
))->execute();
|
||||
|
||||
$invoice = $this->createInvoice($refund, $costUnit, $document);
|
||||
|
||||
// Erst jetzt, nicht früher: Beleg und Anmerkung der Abrechnung weisen den gezahlten Beitrag
|
||||
// aus und läsen sonst bereits den verrechneten Stand.
|
||||
$this->settleAmountPaid($refund);
|
||||
|
||||
$refund->invoice_id = $invoice->id;
|
||||
$refund->save();
|
||||
|
||||
return $document;
|
||||
});
|
||||
|
||||
$this->notify($refund, $document);
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Vielen Dank. Deine Angaben liegen uns vor.';
|
||||
$response->message = $this->request->donation
|
||||
? 'Vielen Dank für deine Spende.'
|
||||
: 'Vielen Dank. Deine Angaben liegen uns vor.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestätigung mit dem Beleg im Anhang, an Teili und Kontaktperson.
|
||||
* Die Kostenstelle der Veranstaltung.
|
||||
*
|
||||
* Scheitert die Belegerzeugung, geht die Mail trotzdem raus -- der Vorgang ist gespeichert, und die
|
||||
* Aktionsleitung kann den Beleg jederzeit erneut abrufen. Ein Fehler hier darf nicht dazu führen,
|
||||
* dass der Teili gar nichts hört.
|
||||
* Ohne Zugriffsprüfung, weil hier niemand angemeldet ist -- der Teili bestätigt über seinen Token.
|
||||
* Der Repository-Check greift sonst auf `currentUserOrFail()->id` zu und liefe in einen Fehler.
|
||||
*
|
||||
* Bewusst ohne Prüfung auf `allow_new`/`archived`: Eine Erstattung fällt oft erst nach dem Ende der
|
||||
* Veranstaltung an, wenn die Kostenstelle längst geschlossen ist. Sie gehört trotzdem dorthin -- und
|
||||
* der reguläre Weg über SaveInvoiceController prüft das ebenso wenig.
|
||||
*/
|
||||
private function notify(ParticipantRefund $refund): void
|
||||
private function costUnit(ParticipantRefund $refund): ?CostUnit
|
||||
{
|
||||
$document = new CreateRefundDocumentCommand(new CreateRefundDocumentRequest($refund))->execute();
|
||||
if ($refund->event->cost_unit_id === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CostUnitRepository()->getById($refund->event->cost_unit_id, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reicht die Erstattung als gewöhnliche Auslagenabrechnung ein.
|
||||
*
|
||||
* Über denselben Command wie jede von Hand erfasste Abrechnung: damit stimmen Nummernkreis, Status
|
||||
* `new`, die Bestätigungsmail an den Teili und die Benachrichtigung der Kassenwart*innen mit dem
|
||||
* überein, was die Buchhaltung kennt.
|
||||
*/
|
||||
private function createInvoice(
|
||||
ParticipantRefund $refund,
|
||||
CostUnit $costUnit,
|
||||
CreateRefundDocumentResponse $document,
|
||||
): Invoice {
|
||||
$participant = $refund->participant;
|
||||
|
||||
$invoiceRequest = new CreateInvoiceRequest(
|
||||
costUnit: $costUnit,
|
||||
// getOfficialName() und nicht getFullName(): letzteres enthält HTML für die Oberfläche.
|
||||
contactName: $participant->getOfficialName(),
|
||||
invoiceType: InvoiceType::INVOICE_TYPE_PARTICIPATION_REFUND,
|
||||
totalAmount: $refund->amount?->getAmount() ?? 0.0,
|
||||
receiptFile: $this->storeReceipt($costUnit, $document),
|
||||
// Hier landet die Entscheidung des Teilis, und nur hier: Die Abrechnung führt sie, der
|
||||
// Vorgang liest sie über ParticipantRefund::isDonation() zurück.
|
||||
isDonation: $this->request->donation,
|
||||
userId: $participant->user_id,
|
||||
contactEmail: $participant->email_1,
|
||||
contactPhone: $participant->phone_1,
|
||||
// Die Bankverbindung stammt aus dem Vorgang, nicht vom Teilnehmer: das Konto kann einem
|
||||
// Elternteil gehören.
|
||||
accountOwner: $refund->account_owner,
|
||||
accountIban: $refund->account_iban,
|
||||
|
||||
// MUSS null bleiben (nicht ''): CreateInvoiceCommand verwirft die user_id, sobald hier etwas
|
||||
// steht -- der Teili fände seine Abrechnung dann nicht unter "Meine Abrechnungen".
|
||||
paymentPurpose: null,
|
||||
notices: $this->notice($refund),
|
||||
);
|
||||
|
||||
$invoiceResponse = new CreateInvoiceCommand($invoiceRequest)->execute();
|
||||
|
||||
if (!$invoiceResponse->success || $invoiceResponse->invoice === null) {
|
||||
// Rollt die Transaktion zurück -- der Vorgang bleibt offen, der Teili kann es erneut versuchen.
|
||||
throw new RuntimeException('Die Abrechnung zur Beitragserstattung konnte nicht angelegt werden.');
|
||||
}
|
||||
|
||||
return $invoiceResponse->invoice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt den Eigenbeleg dort ab, wo auch hochgeladene Belege liegen, und verpackt ihn für die
|
||||
* Abrechnung. `CreateInvoiceCommand` speichert nur den Pfad und schreibt selbst keine Dateien.
|
||||
*/
|
||||
private function storeReceipt(CostUnit $costUnit, CreateRefundDocumentResponse $document): ?InvoiceFile
|
||||
{
|
||||
if (!$document->success) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$path = UploadFileProvider::directoryFor($costUnit) . '/' . $document->filename;
|
||||
|
||||
new FileWriteProvider($path, $document->pdfContent)->writeToFile();
|
||||
|
||||
$receipt = new InvoiceFile();
|
||||
// Beide Eigenschaften sind typisiert und ohne Vorbelegung; gespeichert wird nur `fullPath`.
|
||||
$receipt->filename = $document->filename;
|
||||
$receipt->fullPath = $path;
|
||||
|
||||
return $receipt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Anmerkung auf der Abrechnung.
|
||||
*
|
||||
* Sie nennt den gezahlten Beitrag, weil er am Teilnehmer gleich auf 0 gesetzt wird
|
||||
* ({@see self::clearAmountPaid()}) -- die Schatzmeisterei kann den Vorgang so nachvollziehen, ohne
|
||||
* den vorherigen Stand irgendwo suchen zu müssen.
|
||||
*
|
||||
* Gekürzt wird nur der vordere, freie Teil: Veranstaltungsname und Grund sind beliebig lang, der
|
||||
* Betrag darf nie abgeschnitten werden.
|
||||
*/
|
||||
private function notice(ParticipantRefund $refund): string
|
||||
{
|
||||
$paid = $refund->participant->amount_paid?->toString() ?? '0,00 Euro';
|
||||
|
||||
// Die Schatzmeisterei sieht die Abrechnung ohne den Vorgang dahinter. Dass nichts ausgezahlt
|
||||
// wird, steht zwar im Spendenkennzeichen -- warum keine Bankverbindung dabei ist, aber nur hier.
|
||||
$subject = $this->request->donation
|
||||
? 'Spende statt Rückerstattung Teilnahmebeitrag'
|
||||
: 'Rückerstattung Teilnahmebeitrag';
|
||||
|
||||
return Str::limit(sprintf(
|
||||
'%s %s – %s',
|
||||
$subject,
|
||||
$refund->event->name,
|
||||
$refund->reasonLabel()
|
||||
), 180) . sprintf(' | Gezahlter Beitrag vor Erstattung: %s', $paid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zieht den erstatteten Betrag vom gezahlten Beitrag ab.
|
||||
*
|
||||
* Danach führt `amount_paid` genau das, was beim Verband geblieben ist -- bei voller Erstattung also
|
||||
* 0, bei einer Teilerstattung den einbehaltenen Rest. Auf diesem Feld baut die Einnahmenrechnung der
|
||||
* Veranstaltung auf; es muss deshalb den tatsächlichen Bestand abbilden und nicht die Zahlung von
|
||||
* einst. Der ursprüngliche Betrag steht zur Kontrolle in der Anmerkung der Abrechnung und auf dem
|
||||
* Beleg.
|
||||
*/
|
||||
private function settleAmountPaid(ParticipantRefund $refund): void
|
||||
{
|
||||
$participant = $refund->participant;
|
||||
|
||||
$paid = $participant->amount_paid?->getAmount() ?? 0.0;
|
||||
$refunded = $refund->amount?->getAmount() ?? 0.0;
|
||||
|
||||
// `max` gegen Rundungsreste: Ein negativer gezahlter Betrag wäre in jeder Auswertung Unsinn.
|
||||
$participant->amount_paid = new Amount(max(0.0, round($paid - $refunded, 2)), 'Euro');
|
||||
$participant->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Die eigene Bestätigung mit dem Beleg im Anhang, an Teili und Kontaktperson.
|
||||
*
|
||||
* Sie kommt zusätzlich zu der, die CreateInvoiceCommand verschickt: diese trägt den Beleg, jene ist
|
||||
* die Quittung des Abrechnungssystems. Erst nach der Transaktion, damit nichts verschickt wird, was
|
||||
* anschließend zurückgerollt würde.
|
||||
*
|
||||
* Scheitert die Belegerzeugung, geht die Mail ohne Anhang raus statt gar nicht.
|
||||
*/
|
||||
private function notify(ParticipantRefund $refund, CreateRefundDocumentResponse $document): void
|
||||
{
|
||||
$pdf = $document->success ? $document->pdfContent : null;
|
||||
$filename = $document->success ? $document->filename : null;
|
||||
|
||||
$participant = $refund->participant;
|
||||
|
||||
Mail::to($participant->email_1)->send(new RefundAcceptedMail(
|
||||
participant: $participant,
|
||||
refund: $refund,
|
||||
pdfContent: $pdf,
|
||||
pdfFilename: $filename,
|
||||
));
|
||||
$recipients = [$participant->email_1];
|
||||
|
||||
if ($participant->email_2 !== null) {
|
||||
Mail::to($participant->email_2)->send(new RefundAcceptedMail(
|
||||
// `filled()` und nicht `!== null`: Der Anmeldewizard überspringt den Schritt "Kontaktperson" bei
|
||||
// Volljährigen und legt das Feld als Leerstring an -- `Mail::to('')` liefe ins Leere.
|
||||
if (filled($participant->email_2)) {
|
||||
$recipients[] = $participant->email_2;
|
||||
}
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
Mail::to($recipient)->send(new RefundAcceptedMail(
|
||||
participant: $participant,
|
||||
refund: $refund,
|
||||
pdfContent: $pdf,
|
||||
|
||||
@@ -8,10 +8,44 @@ class AcceptRefundRequest
|
||||
{
|
||||
public function __construct(
|
||||
public readonly ?ParticipantRefund $refund,
|
||||
public readonly string $accountOwner,
|
||||
public readonly string $accountIban,
|
||||
/** Ob der Teili die Erklärung auf der Seite angekreuzt hat. Ohne sie taugt der Beleg nichts. */
|
||||
/**
|
||||
* Die Eingaben des Teilis -- leer, wenn es nichts einzugeben gab.
|
||||
*
|
||||
* Das ist der Normalfall bei einer Spende (kein Konto nötig) und bei einem bereits bekannten
|
||||
* Konto: Dort steht die Bankverbindung seit der Freigabe am Vorgang, und der Command nimmt
|
||||
* ausschließlich diese.
|
||||
*/
|
||||
public readonly string $accountOwner = '',
|
||||
public readonly string $accountIban = '',
|
||||
/**
|
||||
* Ob der Teili die Erklärung auf der Seite angekreuzt hat. Ohne sie taugt der Beleg nichts.
|
||||
*
|
||||
* Im Spendenweg ist es die Verzichtserklärung, im Auszahlungsweg die Versicherung über den
|
||||
* gezahlten Beitrag -- in beiden Fällen die Erklärung, die anschließend auf dem Beleg steht.
|
||||
*/
|
||||
public readonly bool $declarationAccepted = false,
|
||||
/**
|
||||
* Ob auf die Auszahlung verzichtet und der Betrag gespendet wird.
|
||||
*
|
||||
* Wird nicht am Vorgang gespeichert: Die Entscheidung landet in der Abrechnung
|
||||
* (`invoices.donation`), von wo {@see ParticipantRefund::isDonation()} sie zurückliest. Dieses
|
||||
* Feld ist der Weg dorthin.
|
||||
*/
|
||||
public readonly bool $donation = false,
|
||||
/**
|
||||
* Nur im Auszahlungsweg: die Bestätigung, dass es das Konto der Ursprungszahlung ist.
|
||||
*
|
||||
* Getrennt von der Haupterklärung, weil sie im Spendenweg gegenstandslos ist -- dort gibt es
|
||||
* kein Konto.
|
||||
*/
|
||||
public readonly bool $accountDeclarationAccepted = false,
|
||||
/**
|
||||
* Die Aktionsleitung, wenn sie die Bankverbindung aufgenommen hat, weil sie ihr vorlag.
|
||||
*
|
||||
* Dann kreuzt niemand die Erklärung an -- sie wird stellvertretend aufgenommen, und der Beleg
|
||||
* weist genau das aus.
|
||||
*/
|
||||
public readonly ?int $capturedBy = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
+145
-7
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Actions\CreateRefundDocument;
|
||||
|
||||
use App\Enumerations\RefundAccountSource;
|
||||
use App\Models\DocumentTemplate;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventParticipant;
|
||||
@@ -27,6 +28,18 @@ class CreateRefundDocumentCommand
|
||||
/** Name des `page_texts`-Eintrags mit der Erklärung -- dieselbe Quelle wie die Bestätigungsseite. */
|
||||
public const string DECLARATION_TEXT = 'CONFIRMATION_PARTICIPANT_REFUND';
|
||||
|
||||
/** Die zweite Erklärung des Auszahlungswegs: dass es das Konto der Ursprungszahlung ist. */
|
||||
public const string ACCOUNT_DECLARATION_TEXT = 'CONFIRMATION_PARTICIPANT_REFUND_ACCOUNT';
|
||||
|
||||
/**
|
||||
* Ihre Fassung für Zahlungsarten ohne Ursprungskonto (Barzahlung): Dort gab es kein Konto, von dem
|
||||
* der Beitrag kam -- erklärt wird stattdessen, dass das angegebene auf den eigenen Namen läuft.
|
||||
*/
|
||||
public const string OWN_ACCOUNT_DECLARATION_TEXT = 'CONFIRMATION_PARTICIPANT_REFUND_ACCOUNT_OWN';
|
||||
|
||||
/** Tritt im Spendenweg an die Stelle beider anderen -- dort gibt es kein Konto. */
|
||||
public const string DONATION_DECLARATION_TEXT = 'CONFIRMATION_PARTICIPANT_REFUND_DONATION';
|
||||
|
||||
private ParticipantRefund $refund;
|
||||
|
||||
private EventParticipant $participant;
|
||||
@@ -104,14 +117,118 @@ class CreateRefundDocumentCommand
|
||||
* Fallback stünde hier ein Fatal Error auf `null` -- so steht es heute im Deckblatt-Code der
|
||||
* Auslagenerstattung, und daran soll sich der Beleg kein Beispiel nehmen.
|
||||
*/
|
||||
/**
|
||||
* Der Hinweis, warum ein Teil des Beitrags beim Verband bleibt -- leer bei voller Erstattung.
|
||||
*
|
||||
* Der Beleg wandert in die Buchhaltung und ins Archiv; dort muss die Differenz zwischen gezahltem
|
||||
* und erstattetem Betrag ohne Rückfrage erklärt sein.
|
||||
*/
|
||||
private function retentionNote(): string
|
||||
{
|
||||
if (!$this->refund->hasRetention()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$text = trim($this->refund->retentionReasonText());
|
||||
$label = $this->refund->retentionReasonLabel();
|
||||
|
||||
return $text !== '' && $text !== $label
|
||||
? sprintf('%s (%s)', $label, $text)
|
||||
: $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Vermerk, wenn die Aktionsleitung die Angaben aufgenommen hat.
|
||||
*
|
||||
* Er nennt Name und Datum, weil in diesem Fall niemand die Erklärung darüber angekreuzt hat: Wer den
|
||||
* Beleg prüft, soll erkennen, dass dort eine aufgenommene Angabe steht und keine Bestätigung des
|
||||
* Teilis selbst. Beim gewöhnlichen Weg bleibt der Platzhalter leer und der Block fällt weg.
|
||||
*/
|
||||
private function captureNote(): string
|
||||
{
|
||||
if (!$this->refund->wasCapturedByManagement()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$name = $this->refund->capturedBy()->first()?->getOfficialName();
|
||||
|
||||
return sprintf(
|
||||
'Angaben aufgenommen durch %s am %s.',
|
||||
trim((string) $name) !== '' ? $name : 'die Aktionsleitung',
|
||||
$this->refund->accepted_at?->format('d.m.Y') ?? ''
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Herkunft des Erstattungskontos, abgeleitet aus der Zahlungsart der Anmeldung.
|
||||
*
|
||||
* Der Beleg wird bei jedem Abruf neu gerendert und nicht gespeichert. Änderte jemand nachträglich
|
||||
* die Zahlungsart, zeigte ein Nachdruck die jeweils andere Kontoerklärung. Praktisch passiert das
|
||||
* nicht -- eine eigene Spalte am Vorgang wäre dafür unverhältnismäßig.
|
||||
*/
|
||||
private function accountSource(): RefundAccountSource
|
||||
{
|
||||
return $this->participant->refundData()->source;
|
||||
}
|
||||
|
||||
private function declarationText(): string
|
||||
{
|
||||
$text = PageText::where('name', self::DECLARATION_TEXT)->first()?->content;
|
||||
if ($this->request->donation) {
|
||||
return $this->pageText(
|
||||
self::DONATION_DECLARATION_TEXT,
|
||||
'Ich verzichte auf die Auszahlung des genannten Betrags und spende ihn an den Verband. '
|
||||
. 'Mir ist bewusst, dass dieser Verzicht nicht rückgängig gemacht werden kann.'
|
||||
);
|
||||
}
|
||||
|
||||
return trim((string) $text) !== ''
|
||||
? (string) $text
|
||||
: 'Ich versichere, dass ich den genannten Betrag beglichen habe und nicht anderweitig '
|
||||
. 'zurückerstattet bekomme.';
|
||||
// Beide Sätze, weil die Person beide angekreuzt hat -- der Beleg schreibt ihr nur zu, was sie
|
||||
// gelesen hat, und die Kontoerklärung ist der Grund, warum die Auszahlung zulässig ist.
|
||||
//
|
||||
// Welche der beiden Kontoerklärungen gilt, sagt die Zahlungsart: Wer bar gezahlt hat, kann
|
||||
// nicht bestätigen, dass das Konto dasselbe ist -- es gab keines.
|
||||
$accountSource = $this->accountSource();
|
||||
|
||||
return $this->pageText(
|
||||
self::DECLARATION_TEXT,
|
||||
'Ich versichere, dass ich den genannten Betrag beglichen habe und nicht anderweitig '
|
||||
. 'zurückerstattet bekomme.'
|
||||
) . '<br /><br />' . $this->pageText(
|
||||
$accountSource->accountDeclarationText(),
|
||||
$accountSource === RefundAccountSource::None
|
||||
? 'Ich bestätige, dass das angegebene Konto auf meinen Namen läuft oder ich über dieses '
|
||||
. 'Konto verfügungsberechtigt bin.'
|
||||
: 'Ich bestätige, dass das angegebene Konto dasselbe ist, von dem der Teilnahmebeitrag '
|
||||
. 'gezahlt wurde.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Seitentext mit Rückfallwert: Fehlt die Zeile in der Datenbank, soll der Beleg trotzdem
|
||||
* entstehen. Ohne den Fallback stünde hier ein Fatal Error auf `null` -- so steht es heute im
|
||||
* Deckblatt-Code der Auslagenerstattung, und daran soll sich der Beleg kein Beispiel nehmen.
|
||||
*/
|
||||
private function pageText(string $name, string $fallback): string
|
||||
{
|
||||
$text = PageText::where('name', $name)->first()?->content;
|
||||
|
||||
return trim((string) $text) !== '' ? (string) $text : $fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Einleitungssatz des Belegs, passend zum gewählten Weg.
|
||||
*
|
||||
* Als Platzhalter und nicht fest in der Vorlage, weil er sich zwischen Auszahlung und Spende
|
||||
* unterscheidet -- `{if:…}` kennt keine Verneinung, mit der eine Vorlage den einen Satz gegen den
|
||||
* anderen tauschen könnte. Ältere, bereits installierte Vorlagen tragen den festen Satz weiter; dass
|
||||
* gespendet wurde, steht dort in der Angabentabelle und in der Erklärung.
|
||||
*/
|
||||
private function introText(): string
|
||||
{
|
||||
return $this->request->donation
|
||||
? 'Ich konnte an der Veranstaltung nicht oder nur teilweise teilnehmen. Auf die Auszahlung '
|
||||
. 'des erstattungsfähigen Betrags verzichte ich und spende ihn an den Verband:'
|
||||
: 'Ich konnte an der Veranstaltung nicht oder nur teilweise teilnehmen und bitte um die '
|
||||
. 'Rückerstattung wie folgt:';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +294,12 @@ class CreateRefundDocumentCommand
|
||||
'account_owner' => (string) $refund->account_owner,
|
||||
'account_iban' => $this->formatIban((string) $refund->account_iban),
|
||||
|
||||
'retained_amount' => $this->money($refund->retained_amount?->getAmount() ?? 0.0),
|
||||
'retention_note' => $this->retentionNote(),
|
||||
|
||||
'intro_text' => $this->introText(),
|
||||
'declaration_text' => $this->declarationText(),
|
||||
'capture_note' => $this->captureNote(),
|
||||
|
||||
'details_table' => $this->renderDetails(),
|
||||
];
|
||||
@@ -219,8 +341,24 @@ class CreateRefundDocumentCommand
|
||||
$rows[] = ['Begründung', e($reasonText)];
|
||||
}
|
||||
|
||||
$rows[] = ['Kontoinhaber*in', e((string) $refund->account_owner)];
|
||||
$rows[] = ['IBAN', e($this->formatIban((string) $refund->account_iban))];
|
||||
// Nur bei einer Teilerstattung: Ohne diese Zeile bliebe die Differenz zwischen gezahltem und
|
||||
// erstattetem Betrag im Beleg unerklärt.
|
||||
if ($refund->hasRetention()) {
|
||||
$rows[] = ['Einbehalten', $this->money($refund->retained_amount?->getAmount() ?? 0.0)];
|
||||
$rows[] = ['Grund der Einbehaltung', e($this->retentionNote())];
|
||||
}
|
||||
|
||||
// Bei einer Spende gibt es keine Bankverbindung. Statt zwei leerer Zeilen steht dort, warum --
|
||||
// der Beleg wandert in die Buchhaltung, und "keine IBAN" allein sähe nach einer Lücke aus.
|
||||
if ($this->request->donation) {
|
||||
$rows[] = [
|
||||
'Auszahlung',
|
||||
'Auf die Auszahlung wird verzichtet; der Betrag verbleibt als Spende beim Verband.',
|
||||
];
|
||||
} else {
|
||||
$rows[] = ['Kontoinhaber*in', e((string) $refund->account_owner)];
|
||||
$rows[] = ['IBAN', e($this->formatIban((string) $refund->account_iban))];
|
||||
}
|
||||
|
||||
$html = '';
|
||||
foreach ($rows as [$key, $value]) {
|
||||
|
||||
+8
@@ -8,6 +8,14 @@ class CreateRefundDocumentRequest
|
||||
{
|
||||
public function __construct(
|
||||
public readonly ParticipantRefund $refund,
|
||||
/**
|
||||
* Ob der Betrag gespendet statt ausgezahlt wird.
|
||||
*
|
||||
* Ausdrücklich und nicht über {@see ParticipantRefund::isDonation()}: Beim Einreichen entsteht
|
||||
* dieser Beleg vor der Abrechnung, die die Spende führt -- er ist ihr Anhang. Wer ihn später
|
||||
* erneut zieht, liest sie dort und gibt sie hier weiter.
|
||||
*/
|
||||
public readonly bool $donation = false,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,20 @@
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Actions\ReleaseRefund;
|
||||
|
||||
use App\Domains\ParticipantRefund\Actions\AcceptRefund\AcceptRefundCommand;
|
||||
use App\Domains\ParticipantRefund\Actions\AcceptRefund\AcceptRefundRequest;
|
||||
use App\Enumerations\RefundReason;
|
||||
use App\Enumerations\RetentionReason;
|
||||
use App\EventPaymentModules\DTO\GetRefundDataResponse;
|
||||
use App\Mail\ParticipantRefundMails\RefundReleasedMail;
|
||||
use App\Models\EventParticipant;
|
||||
use App\Models\ParticipantRefund;
|
||||
use App\Repositories\ParticipantRefundRepository;
|
||||
use App\Support\Iban;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Gibt die Erstattung eines Teilnahmebeitrags frei.
|
||||
@@ -23,6 +30,8 @@ class ReleaseRefundCommand
|
||||
|
||||
private ParticipantRefundRepository $refunds;
|
||||
|
||||
private ?GetRefundDataResponse $knownRefundData = null;
|
||||
|
||||
public function __construct(private readonly ReleaseRefundRequest $request)
|
||||
{
|
||||
$this->participant = $request->participant;
|
||||
@@ -40,28 +49,103 @@ class ReleaseRefundCommand
|
||||
return $response;
|
||||
}
|
||||
|
||||
$refund = ParticipantRefund::create([
|
||||
'tenant' => $this->participant->tenant,
|
||||
'event_id' => $this->participant->event_id,
|
||||
'event_participant_id' => $this->participant->id,
|
||||
'token' => Str::random(32),
|
||||
'status' => ParticipantRefund::STATUS_PENDING,
|
||||
'amount' => $this->request->amount,
|
||||
'reason' => $this->request->reason,
|
||||
'reason_note' => $this->reasonNote(),
|
||||
'released_by' => auth()->id(),
|
||||
'released_at' => now(),
|
||||
]);
|
||||
// Liegt die Bankverbindung schon vor, entsteht in einem Zug auch die Abrechnung. Scheitert die,
|
||||
// soll keine halbe Freigabe zurückbleiben -- deshalb beides in einer Transaktion.
|
||||
$refund = DB::transaction(function (): ParticipantRefund {
|
||||
$refund = ParticipantRefund::create([
|
||||
'tenant' => $this->participant->tenant,
|
||||
'event_id' => $this->participant->event_id,
|
||||
'event_participant_id' => $this->participant->id,
|
||||
'token' => Str::random(32),
|
||||
'status' => ParticipantRefund::STATUS_PENDING,
|
||||
'amount' => $this->request->amount,
|
||||
'reason' => $this->request->reason,
|
||||
'reason_note' => $this->reasonNote(),
|
||||
// Was beim Verband bleibt, wird hier festgeschrieben: Nach dem Einreichen führt
|
||||
// `amount_paid` bereits diesen Rest, eine spätere Differenz wäre falsch.
|
||||
'retained_amount' => $this->request->retainedAmount(),
|
||||
'retention_reason' => $this->retentionReason(),
|
||||
'retention_reason_note' => $this->retentionReasonNote(),
|
||||
// Kennt die Zahlungsart das Konto, von dem der Beitrag kam, steht es von Anfang an
|
||||
// fest. Der Teili entscheidet dann nur noch: auszahlen oder spenden.
|
||||
'account_owner' => $this->knownAccountOwner(),
|
||||
'account_iban' => $this->knownAccountIban(),
|
||||
'released_by' => currentUser()?->id,
|
||||
'released_at' => now(),
|
||||
]);
|
||||
|
||||
$this->notify($refund);
|
||||
if ($this->request->submitsDirectly()) {
|
||||
$this->submitDirectly($refund);
|
||||
}
|
||||
|
||||
return $refund;
|
||||
});
|
||||
|
||||
if (!$this->request->submitsDirectly()) {
|
||||
$this->notify($refund);
|
||||
}
|
||||
|
||||
$response->success = true;
|
||||
$response->refund = $refund;
|
||||
$response->message = 'Die Erstattung wurde freigegeben. Der Teili wurde per E-Mail informiert.';
|
||||
$response->refund = $refund->fresh();
|
||||
$response->message = match (true) {
|
||||
$this->request->donation => 'Die Spende wurde eingereicht. Der Teili hat den Beleg per E-Mail erhalten.',
|
||||
$this->request->hasBankDetails() => 'Die Erstattung wurde eingereicht. Der Teili hat den Beleg per E-Mail erhalten.',
|
||||
default => 'Die Erstattung wurde freigegeben. Der Teili wurde per E-Mail informiert.',
|
||||
};
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Das Konto, das die Zahlungsart kennt -- bei der Überweisung das des Zahlungseingangs.
|
||||
*
|
||||
* Lazy und einmalig, weil der Aufruf über die Event-Relation des Teilnehmers läuft
|
||||
* ({@see EventParticipant::paymentConfiguration()}) und in einem Vorgang mehrfach gebraucht wird.
|
||||
*/
|
||||
private function knownRefundData(): GetRefundDataResponse
|
||||
{
|
||||
return $this->knownRefundData ??= $this->participant->refundData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Bei der Sofort-Einreichung und bei der Spende bleibt das Feld leer: Dort setzt der
|
||||
* {@see AcceptRefundCommand} es -- aus der Eingabe der Aktionsleitung bzw. auf `null`.
|
||||
*/
|
||||
private function knownAccountOwner(): ?string
|
||||
{
|
||||
return $this->request->submitsDirectly() ? null : ($this->knownRefundData()->accountOwner);
|
||||
}
|
||||
|
||||
private function knownAccountIban(): ?string
|
||||
{
|
||||
return $this->request->submitsDirectly() ? null : ($this->knownRefundData()->accountIban);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reicht die Erstattung sofort ein, ohne den Umweg über den Teili.
|
||||
*
|
||||
* Über denselben Command, den sonst der Bestätigungslink auslöst: Beleg, Abrechnung, das Nullstellen
|
||||
* des gezahlten Beitrags und die Mail mit dem Beleg laufen dadurch in beiden Wegen identisch ab.
|
||||
*/
|
||||
private function submitDirectly(ParticipantRefund $refund): void
|
||||
{
|
||||
$acceptResponse = new AcceptRefundCommand(new AcceptRefundRequest(
|
||||
refund: $refund,
|
||||
accountOwner: (string) $this->request->accountOwner,
|
||||
accountIban: (string) $this->request->accountIban,
|
||||
donation: $this->request->donation,
|
||||
// Niemand kreuzt hier eine Erklärung an; wer die Angaben aufgenommen hat, hält `captured_by`
|
||||
// fest, und der Beleg weist es aus.
|
||||
capturedBy: currentUser()?->id,
|
||||
))->execute();
|
||||
|
||||
if (!$acceptResponse->success) {
|
||||
// Rollt die Freigabe zurück -- die Aktionsleitung soll den Fehler sehen und nicht einen
|
||||
// Vorgang vorfinden, der nirgends eingereicht ist.
|
||||
throw new RuntimeException($acceptResponse->message ?? 'Die Erstattung konnte nicht eingereicht werden.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Gründe, aus denen eine Freigabe nicht zulässig ist.
|
||||
*
|
||||
@@ -98,6 +182,67 @@ class ReleaseRefundCommand
|
||||
return 'Für diesen Grund ist eine Erläuterung erforderlich.';
|
||||
}
|
||||
|
||||
return $this->rejectRetention() ?? $this->rejectBankDetails();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfungen zum einbehaltenen Teil.
|
||||
*
|
||||
* Sicherheitsnetz hinter der Oberfläche: Dort erscheint der Absende-Knopf erst, wenn ein Grund
|
||||
* gewählt ist. Über einen direkten Aufruf ginge das sonst vorbei, und ein einbehaltener Betrag ohne
|
||||
* Begründung ist in der Buchhaltung nicht haltbar.
|
||||
*/
|
||||
private function rejectRetention(): ?string
|
||||
{
|
||||
if (!$this->request->hasRetention()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$reason = RetentionReason::find($this->request->retentionReason);
|
||||
if ($reason === null) {
|
||||
return 'Bitte gib an, warum ein Teil des Beitrags einbehalten wird.';
|
||||
}
|
||||
|
||||
if ($reason->requires_note && trim((string) $this->request->retentionReasonNote) === '') {
|
||||
return 'Für diesen Einbehaltungsgrund ist eine Erläuterung erforderlich.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfungen, die nur den Direktweg betreffen -- die Erstattung wird dabei sofort eingereicht, es gibt
|
||||
* also keine zweite Gelegenheit, Angaben zu berichtigen.
|
||||
*/
|
||||
private function rejectBankDetails(): ?string
|
||||
{
|
||||
// Eine Spende wird nicht ausgezahlt. Kämen beide Angaben zusammen, wäre unklar, was gilt --
|
||||
// lieber nachfragen als das eine stillschweigend gegen das andere entscheiden.
|
||||
if ($this->request->donation && (filled($this->request->accountOwner) || filled($this->request->accountIban))) {
|
||||
return 'Eine Spende braucht keine Bankverbindung.';
|
||||
}
|
||||
|
||||
// Halb ausgefüllt ist keine Absicht: entweder beides oder der Weg über den Teili.
|
||||
if (!$this->request->donation
|
||||
&& filled($this->request->accountOwner) !== filled($this->request->accountIban)) {
|
||||
return 'Für die sofortige Erstattung werden Kontoinhaber*in und IBAN benötigt.';
|
||||
}
|
||||
|
||||
if (!$this->request->submitsDirectly()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->request->hasBankDetails() && !Iban::isValid((string) $this->request->accountIban)) {
|
||||
return 'Diese IBAN stimmt nicht. Bitte prüfe die Eingabe.';
|
||||
}
|
||||
|
||||
// Ohne Kostenstelle ließe sich die Abrechnung nicht anlegen -- auch die Spende braucht eine, sie
|
||||
// wird ja gebucht. Hier abfangen und nicht erst in der Transaktion, damit die Aktionsleitung eine
|
||||
// verständliche Meldung sieht.
|
||||
if ($this->participant->event->cost_unit_id === null) {
|
||||
return 'Die Veranstaltung hat keine Kostenstelle -- die Erstattung kann nicht eingereicht werden.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -113,19 +258,49 @@ class ReleaseRefundCommand
|
||||
return trim((string) $this->request->reasonNote);
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Einbehaltungsgrund -- nur, wenn tatsächlich etwas beim Verband bleibt.
|
||||
*
|
||||
* Bei voller Erstattung wird ein mitgeschickter Grund verworfen: In der Oberfläche ist das Feld dann
|
||||
* gar nicht sichtbar, und ein Wert ohne Bezug hätte in der Datenbank nichts zu suchen.
|
||||
*/
|
||||
private function retentionReason(): ?string
|
||||
{
|
||||
return $this->request->hasRetention() ? $this->request->retentionReason : null;
|
||||
}
|
||||
|
||||
/** Der Freitext dazu -- wie beim Erstattungsgrund nur bei Gründen, die ihn verlangen. */
|
||||
private function retentionReasonNote(): ?string
|
||||
{
|
||||
if (!$this->request->hasRetention()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$reason = RetentionReason::find($this->request->retentionReason);
|
||||
|
||||
if ($reason === null || !$reason->requires_note) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return trim((string) $this->request->retentionReasonNote);
|
||||
}
|
||||
|
||||
/**
|
||||
* Teili und Kontaktperson bekommen je eine eigene Mail -- dasselbe Muster wie bei der Abmeldung
|
||||
* (siehe SetParticipationStateCommand).
|
||||
*/
|
||||
private function notify(ParticipantRefund $refund): void
|
||||
{
|
||||
Mail::to($this->participant->email_1)->send(new RefundReleasedMail(
|
||||
participant: $this->participant,
|
||||
refund: $refund,
|
||||
));
|
||||
$recipients = [$this->participant->email_1];
|
||||
|
||||
if ($this->participant->email_2 !== null) {
|
||||
Mail::to($this->participant->email_2)->send(new RefundReleasedMail(
|
||||
// `filled()` und nicht `!== null`: Der Anmeldewizard überspringt den Schritt "Kontaktperson" bei
|
||||
// Volljährigen und legt das Feld als Leerstring an -- `Mail::to('')` liefe ins Leere.
|
||||
if (filled($this->participant->email_2)) {
|
||||
$recipients[] = $this->participant->email_2;
|
||||
}
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
Mail::to($recipient)->send(new RefundReleasedMail(
|
||||
participant: $this->participant,
|
||||
refund: $refund,
|
||||
));
|
||||
|
||||
@@ -12,6 +12,60 @@ class ReleaseRefundRequest
|
||||
public readonly Amount $amount,
|
||||
public readonly string $reason,
|
||||
public readonly ?string $reasonNote = null,
|
||||
/**
|
||||
* Die Bankverbindung, wenn sie der Aktionsleitung bereits vorliegt.
|
||||
*
|
||||
* Sind beide gesetzt, entfällt der Umweg über den Teili: die Erstattung wird sofort eingereicht.
|
||||
* Bleiben sie leer, läuft der übliche Weg über den Bestätigungslink.
|
||||
*/
|
||||
public readonly ?string $accountOwner = null,
|
||||
public readonly ?string $accountIban = null,
|
||||
/**
|
||||
* Warum ein Teil des Beitrags beim Verband bleibt.
|
||||
*
|
||||
* Pflicht, sobald weniger erstattet wird als gezahlt wurde: Ein einbehaltener Betrag ohne Grund
|
||||
* ist in der Buchhaltung nicht haltbar.
|
||||
*/
|
||||
public readonly ?string $retentionReason = null,
|
||||
public readonly ?string $retentionReasonNote = null,
|
||||
/**
|
||||
* Der Teili spendet den Betrag, statt ihn ausgezahlt zu bekommen.
|
||||
*
|
||||
* Dann braucht es keine Bankverbindung, und die Erstattung wird -- wie beim vorliegenden Konto --
|
||||
* sofort eingereicht. Gespeichert wird die Entscheidung in der Abrechnung, nicht am Vorgang.
|
||||
*/
|
||||
public readonly bool $donation = false,
|
||||
) {
|
||||
}
|
||||
|
||||
/** Ob die Erstattung ohne Zutun des Teilis eingereicht werden kann. */
|
||||
public function hasBankDetails(): bool
|
||||
{
|
||||
return filled($this->accountOwner) && filled($this->accountIban);
|
||||
}
|
||||
|
||||
/** Ob sofort eingereicht wird -- entweder liegt die Bankverbindung vor, oder es wird gespendet. */
|
||||
public function submitsDirectly(): bool
|
||||
{
|
||||
return $this->hasBankDetails() || $this->donation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Betrag, der beim Verband bleibt.
|
||||
*
|
||||
* Die halbe Cent-Toleranz fängt die Rundung des gespeicherten Floats ab -- ohne sie entstünden
|
||||
* Restbeträge von Bruchteilen eines Cents, die eine Begründung verlangen würden.
|
||||
*/
|
||||
public function retainedAmount(): float
|
||||
{
|
||||
$paid = $this->participant->amount_paid?->getAmount() ?? 0.0;
|
||||
$remaining = round($paid - $this->amount->getAmount(), 2);
|
||||
|
||||
return $remaining > 0.005 ? $remaining : 0.0;
|
||||
}
|
||||
|
||||
public function hasRetention(): bool
|
||||
{
|
||||
return $this->retainedAmount() > 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Actions\ResendRefundMail;
|
||||
|
||||
use App\Mail\ParticipantRefundMails\RefundReleasedMail;
|
||||
use App\Models\EventParticipant;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Schickt die Mail zu einer freigegebenen Erstattung noch einmal.
|
||||
*
|
||||
* Der häufige Fall, wenn ein Vorgang hängt: die erste Mail ist untergegangen. Am Vorgang ändert sich
|
||||
* dabei nichts -- `released_at` bleibt der Zeitpunkt der Vormerkung, der Token bleibt derselbe, der alte
|
||||
* Link funktioniert also weiter.
|
||||
*
|
||||
* Nur solange die Bankverbindung fehlt: nach der Bestätigung wäre der Link wertlos, nach dem Abbruch
|
||||
* liefe er ins Leere.
|
||||
*/
|
||||
class ResendRefundMailCommand
|
||||
{
|
||||
public function __construct(private readonly ResendRefundMailRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
public function execute(): ResendRefundMailResponse
|
||||
{
|
||||
$response = new ResendRefundMailResponse();
|
||||
$refund = $this->request->refund;
|
||||
|
||||
if (!$refund->isPending()) {
|
||||
$response->message = $refund->isAccepted()
|
||||
? 'Diese Erstattung wurde bereits bestätigt -- es gibt nichts mehr nachzureichen.'
|
||||
: 'Diese Erstattung wurde abgebrochen.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
$this->notify();
|
||||
|
||||
$response->success = true;
|
||||
$response->message = 'Die Rückerstattungsmail wurde erneut versendet.';
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Teili und Kontaktperson bekommen je eine eigene Mail -- dasselbe Muster wie bei der Freigabe
|
||||
* (siehe ReleaseRefundCommand).
|
||||
*/
|
||||
private function notify(): void
|
||||
{
|
||||
/** @var EventParticipant $participant */
|
||||
$participant = $this->request->refund->participant()->first();
|
||||
|
||||
$recipients = [$participant->email_1];
|
||||
|
||||
// `filled()` und nicht `!== null`: Der Anmeldewizard überspringt den Schritt "Kontaktperson" bei
|
||||
// Volljährigen und legt das Feld als Leerstring an -- `Mail::to('')` liefe ins Leere.
|
||||
if (filled($participant->email_2)) {
|
||||
$recipients[] = $participant->email_2;
|
||||
}
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
Mail::to($recipient)->send(new RefundReleasedMail(
|
||||
participant: $participant,
|
||||
refund: $this->request->refund,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Actions\ResendRefundMail;
|
||||
|
||||
use App\Models\ParticipantRefund;
|
||||
|
||||
class ResendRefundMailRequest
|
||||
{
|
||||
public function __construct(
|
||||
public readonly ParticipantRefund $refund,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\ParticipantRefund\Actions\ResendRefundMail;
|
||||
|
||||
class ResendRefundMailResponse
|
||||
{
|
||||
public bool $success = false;
|
||||
|
||||
public ?string $message = null;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user