Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d511dbdd66 | ||
|
|
9e9ea0cfd5 | ||
|
|
bcebe2ebed | ||
|
|
a43fd9cedf | ||
|
|
a5e4e55df5 | ||
|
|
c4ca101594 | ||
|
|
985c9ce07e | ||
|
|
790e8e1dbc | ||
|
|
ef6284d5cc | ||
|
|
328825293a | ||
|
|
4e981c140b | ||
|
|
8940cb275b | ||
|
|
b668c7e805 | ||
|
|
ddfaab1501 | ||
|
|
70a57d10f5 | ||
|
|
6301c342e4 | ||
|
|
025035190d | ||
|
|
651b6147bf | ||
|
|
ae13841699 | ||
|
|
91dca31c11 | ||
|
|
40d5634764 | ||
|
|
350c8dd0d0 | ||
|
|
d07980dd1f | ||
|
|
b9795f08f0 | ||
|
|
e730d6db63 | ||
|
|
a6bddf9fa5 | ||
|
|
749d8588da | ||
|
|
4bb64b0053 | ||
|
|
d23e6c3914 | ||
|
|
15690b1da9 | ||
|
|
c1c1a4f143 | ||
|
|
5beb2b1d97 | ||
|
|
efee20c16b | ||
|
|
b01288b5e0 | ||
|
|
6a183d6498 | ||
|
|
9c4c28e566 | ||
|
|
a61344395a |
No files matched your search
@@ -23,3 +23,6 @@ Homestead.json
|
|||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
/docker-compose.yaml
|
/docker-compose.yaml
|
||||||
|
|
||||||
|
# HTML-Report von composer test:coverage
|
||||||
|
/storage/coverage
|
||||||
@@ -16,6 +16,32 @@ Routing, Mails) stehen in `.ai/conventions.md` und werden hier eingebunden — *
|
|||||||
- [Zahlungsmodule](app/EventPaymentModules/CLAUDE.md) — interface-gesteuerte Zahlungsarten (Optionen, Config,
|
- [Zahlungsmodule](app/EventPaymentModules/CLAUDE.md) — interface-gesteuerte Zahlungsarten (Optionen, Config,
|
||||||
Anmelde-Zusammenfassung, GiroCode/Fähigkeits-Interfaces, neues Modul hinzufügen).
|
Anmelde-Zusammenfassung, GiroCode/Fähigkeits-Interfaces, neues Modul hinzufügen).
|
||||||
|
|
||||||
|
## Local Group / Parent Group (Stamm / Bund)
|
||||||
|
|
||||||
|
Technisch heißt es **Local Group** (Mandant/Tenant) und **Parent Group** (übergeordnete Gruppe); „Stamm"/„Bund" sind nur
|
||||||
|
UI-Bezeichnungen.
|
||||||
|
|
||||||
|
- **ParentGroup** (`App\Models\ParentGroup`, Tabelle `parent_groups`, app-weit): `tenants.parent_group_id` ist Pflicht
|
||||||
|
(n:1). `is_fallback` markiert „Ohne Zuordnung" — `Tenant::booted()` setzt sie, wenn nichts angegeben ist; sie ist nie
|
||||||
|
löschbar. Andere nur, solange weder Tenant noch Anmeldung sie nutzt (`AdminParentGroupRepository::isInUse()`).
|
||||||
|
Verwaltung LV-only unter `/admin/parent-groups`; Zuordnung am Tenant im Tab „Allgemeines" und bei der Anlage.
|
||||||
|
- **Event**: `participant_group_type` (Enum `App\Enumerations\ParticipantGroupType`: `local_group` | `parent_group`),
|
||||||
|
gewählt bei der Anlage, in den Einstellungen änderbar nur ohne Anmeldungen. **Einzige Quelle für die Auswahl**:
|
||||||
|
`Event::participantGroupOptions()` — teilnehmende Stämme oder deren Bünde (distinct). Gespeichert wird
|
||||||
|
`event_participants.local_group` (Slug) **oder** `event_participants.parent_group_id`.
|
||||||
|
- **Anzeige**: `EventParticipant::participantGroupName()` → Resource-Feld `participantGroup`; `EventResource` liefert
|
||||||
|
`participantGroupType`, `participantGroupLabel`, `participantGroupOptions` (`{id, name, value}`).
|
||||||
|
- **Bezeichnungen** in `global_settings` (Model `GlobalSetting`, Repository `GlobalSettingRepository`, im Container
|
||||||
|
`scoped` — immer über `app(...)` beziehen), Singular + Plural je Ebene, gepflegt von Hauptadmins unter
|
||||||
|
`/admin/settings`. Gelesen über `ParticipantGroupType::label()/pluralLabel()/labels()`. Texte ohne Artikel formulieren
|
||||||
|
(„Bitte bei „{label}" eine Auswahl treffen."), weil der Artikel vom Wort abhängt.
|
||||||
|
|
||||||
|
## eFZ-Prüfung pro Veranstaltung
|
||||||
|
|
||||||
|
`events.coc_check_required` (Default `true`, Checkbox in `CommonSettings.vue`, Resource-Feld `cocCheckRequired`). Ist
|
||||||
|
sie aus, liefert `CertificateOfConductionCheckCommand` ohne API-Aufruf `not_required`, und `SignUpCommand` belegt
|
||||||
|
`efz_status` mit `not_required` vor. Wirkt nur auf neue Anmeldungen, bestehende Status bleiben.
|
||||||
|
|
||||||
## Umsatzsteuer / Steuerinformationen
|
## Umsatzsteuer / Steuerinformationen
|
||||||
|
|
||||||
Rechtlich korrekter Begriff ist **Umsatzsteuer (USt)**, nicht MwSt. Ziel: tagesbasierte Anmelde-Rechnungen („Teilnahme
|
Rechtlich korrekter Begriff ist **Umsatzsteuer (USt)**, nicht MwSt. Ziel: tagesbasierte Anmelde-Rechnungen („Teilnahme
|
||||||
|
|||||||
+29010
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\CreateParentGroup;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipantGroupType;
|
||||||
|
use App\Models\ParentGroup;
|
||||||
|
|
||||||
|
class CreateParentGroupAction
|
||||||
|
{
|
||||||
|
public function __construct(private CreateParentGroupRequest $request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(): CreateParentGroupResponse
|
||||||
|
{
|
||||||
|
$response = new CreateParentGroupResponse();
|
||||||
|
|
||||||
|
$name = trim($this->request->name);
|
||||||
|
|
||||||
|
if ($name === '') {
|
||||||
|
$response->message = 'Bitte einen Namen angeben.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->parentGroup = ParentGroup::create([
|
||||||
|
'name' => $name,
|
||||||
|
'is_fallback' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->success = true;
|
||||||
|
$response->message = sprintf('%s „%s" wurde angelegt.', ParticipantGroupType::ParentGroup->label(), $name);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\CreateParentGroup;
|
||||||
|
|
||||||
|
class CreateParentGroupRequest
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public string $name,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\CreateParentGroup;
|
||||||
|
|
||||||
|
use App\Models\ParentGroup;
|
||||||
|
|
||||||
|
class CreateParentGroupResponse
|
||||||
|
{
|
||||||
|
public bool $success = false;
|
||||||
|
public string $message = '';
|
||||||
|
public ?ParentGroup $parentGroup = null;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domains\Admin\Actions\CreateTenant;
|
namespace App\Domains\Admin\Actions\CreateTenant;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipantGroupType;
|
||||||
use App\Models\AvailablePaymentMethod;
|
use App\Models\AvailablePaymentMethod;
|
||||||
use App\Models\PaymentMethod;
|
use App\Models\PaymentMethod;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
@@ -16,10 +17,17 @@ class CreateTenantAction
|
|||||||
{
|
{
|
||||||
$response = new CreateTenantResponse();
|
$response = new CreateTenantResponse();
|
||||||
|
|
||||||
|
if ($this->request->parentGroup === null) {
|
||||||
|
$response->message = sprintf('Bitte bei „%s" eine Auswahl treffen.', ParticipantGroupType::ParentGroup->label());
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
$tenant = Tenant::create([
|
$tenant = Tenant::create([
|
||||||
'name' => $this->request->name,
|
'name' => $this->request->name,
|
||||||
'slug' => $this->request->slug,
|
'slug' => $this->request->slug,
|
||||||
'url' => $this->request->url,
|
'url' => $this->request->url,
|
||||||
|
'parent_group_id' => $this->request->parentGroup->id,
|
||||||
'email' => '',
|
'email' => '',
|
||||||
'email_finance' => '',
|
'email_finance' => '',
|
||||||
'account_name' => '',
|
'account_name' => '',
|
||||||
@@ -34,19 +42,23 @@ class CreateTenantAction
|
|||||||
$paymentMethodDefaults = PaymentMethod::defaults();
|
$paymentMethodDefaults = PaymentMethod::defaults();
|
||||||
foreach (PaymentMethod::all() as $paymentMethod) {
|
foreach (PaymentMethod::all() as $paymentMethod) {
|
||||||
$defaults = $paymentMethodDefaults[$paymentMethod->slug] ?? ['name' => $paymentMethod->slug, 'description' => null, 'configuration' => []];
|
$defaults = $paymentMethodDefaults[$paymentMethod->slug] ?? ['name' => $paymentMethod->slug, 'description' => null, 'configuration' => []];
|
||||||
|
$configuration = PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $defaults['configuration'] ?? []);
|
||||||
|
|
||||||
|
// Aktiv nur, was schon vollständig konfiguriert ist -- derselbe Maßstab wie beim Aktivieren
|
||||||
|
// von Hand. Ein neuer Stamm hat noch keine Bankdaten; seine Zahlungsarten schaltet er frei,
|
||||||
|
// sobald sie gepflegt sind.
|
||||||
AvailablePaymentMethod::create([
|
AvailablePaymentMethod::create([
|
||||||
'tenant' => $tenant->slug,
|
'tenant' => $tenant->slug,
|
||||||
'slug' => $paymentMethod->slug,
|
'slug' => $paymentMethod->slug,
|
||||||
'name' => $defaults['name'],
|
'name' => $defaults['name'],
|
||||||
'description' => $defaults['description'],
|
'description' => $defaults['description'],
|
||||||
'active' => true,
|
'active' => PaymentMethod::isConfigurationComplete($paymentMethod->slug, $configuration),
|
||||||
'configuration' => PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $defaults['configuration'] ?? []),
|
'configuration' => $configuration,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
$response->message = 'Stamm wurde angelegt.';
|
$response->message = sprintf('%s wurde angelegt.', ParticipantGroupType::LocalGroup->label());
|
||||||
$response->slug = $tenant->slug;
|
$response->slug = $tenant->slug;
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|||||||
@@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Domains\Admin\Actions\CreateTenant;
|
namespace App\Domains\Admin\Actions\CreateTenant;
|
||||||
|
|
||||||
|
use App\Models\ParentGroup;
|
||||||
|
|
||||||
class CreateTenantRequest
|
class CreateTenantRequest
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $name,
|
public string $name,
|
||||||
public string $slug,
|
public string $slug,
|
||||||
public string $url,
|
public string $url,
|
||||||
|
/** Pflicht; null heißt, die übermittelte ID war unbekannt. */
|
||||||
|
public ?ParentGroup $parentGroup,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\DeleteParentGroup;
|
||||||
|
|
||||||
|
class DeleteParentGroupAction
|
||||||
|
{
|
||||||
|
public function __construct(private DeleteParentGroupRequest $request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(): DeleteParentGroupResponse
|
||||||
|
{
|
||||||
|
$response = new DeleteParentGroupResponse();
|
||||||
|
|
||||||
|
// Die Fallback-Gruppe nimmt Mandanten ohne Zuordnung auf und muss deshalb bestehen bleiben.
|
||||||
|
if ($this->request->parentGroup->is_fallback) {
|
||||||
|
$response->message = sprintf('„%s" kann nicht gelöscht werden.', $this->request->parentGroup->name);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->request->inUse) {
|
||||||
|
$response->message = sprintf(
|
||||||
|
'„%s" ist noch zugeordnet und kann deshalb nicht gelöscht werden.',
|
||||||
|
$this->request->parentGroup->name,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->request->parentGroup->delete();
|
||||||
|
|
||||||
|
$response->success = true;
|
||||||
|
$response->message = sprintf('„%s" wurde gelöscht.', $this->request->parentGroup->name);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\DeleteParentGroup;
|
||||||
|
|
||||||
|
use App\Models\ParentGroup;
|
||||||
|
|
||||||
|
class DeleteParentGroupRequest
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public ParentGroup $parentGroup,
|
||||||
|
/** Ob die Gruppe noch von einem Mandanten oder einer Anmeldung verwendet wird. */
|
||||||
|
public bool $inUse,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\DeleteParentGroup;
|
||||||
|
|
||||||
|
class DeleteParentGroupResponse
|
||||||
|
{
|
||||||
|
public bool $success = false;
|
||||||
|
public string $message = '';
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\RenameParentGroup;
|
||||||
|
|
||||||
|
class RenameParentGroupAction
|
||||||
|
{
|
||||||
|
public function __construct(private RenameParentGroupRequest $request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(): RenameParentGroupResponse
|
||||||
|
{
|
||||||
|
$response = new RenameParentGroupResponse();
|
||||||
|
|
||||||
|
$name = trim($this->request->name);
|
||||||
|
|
||||||
|
if ($name === '') {
|
||||||
|
$response->message = 'Bitte einen Namen angeben.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Umbenennen ist jederzeit möglich: Mandanten und Anmeldungen verweisen über die ID.
|
||||||
|
$this->request->parentGroup->update(['name' => $name]);
|
||||||
|
|
||||||
|
$response->success = true;
|
||||||
|
$response->message = 'Der Name wurde gespeichert.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\RenameParentGroup;
|
||||||
|
|
||||||
|
use App\Models\ParentGroup;
|
||||||
|
|
||||||
|
class RenameParentGroupRequest
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public ParentGroup $parentGroup,
|
||||||
|
public string $name,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\RenameParentGroup;
|
||||||
|
|
||||||
|
class RenameParentGroupResponse
|
||||||
|
{
|
||||||
|
public bool $success = false;
|
||||||
|
public string $message = '';
|
||||||
|
}
|
||||||
+7
-2
@@ -20,10 +20,15 @@ class UpdateAvailablePaymentMethodAction
|
|||||||
// Nur bekannte Options-Keys übernehmen -- das Options-Schema des Zahlungsmoduls ist die Autorität.
|
// Nur bekannte Options-Keys übernehmen -- das Options-Schema des Zahlungsmoduls ist die Autorität.
|
||||||
$configuration = PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $this->request->configuration);
|
$configuration = PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $this->request->configuration);
|
||||||
|
|
||||||
// Guard: Aktivierung nur erlaubt, wenn alle Pflicht-Optionen befüllt sind.
|
// Guard: Aktivierung nur erlaubt, wenn alle Pflicht-Optionen befüllt und gültig sind. Inaktiv
|
||||||
|
// gespeichert werden darf auch eine unfertige Konfiguration -- als Entwurf.
|
||||||
if ($this->request->active && !PaymentMethod::isConfigurationComplete($paymentMethod->slug, $configuration)) {
|
if ($this->request->active && !PaymentMethod::isConfigurationComplete($paymentMethod->slug, $configuration)) {
|
||||||
|
$errors = PaymentMethod::configurationErrors($paymentMethod->slug, $configuration);
|
||||||
|
|
||||||
$response->success = false;
|
$response->success = false;
|
||||||
$response->message = 'Bitte zuerst alle Pflichtfelder ausfüllen, bevor die Zahlungsmethode aktiviert wird.';
|
$response->message = $errors !== []
|
||||||
|
? implode(' ', $errors) . ' Die Zahlungsmethode kann so nicht aktiviert werden.'
|
||||||
|
: 'Bitte zuerst alle Pflichtfelder ausfüllen, bevor die Zahlungsmethode aktiviert wird.';
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateDocumentAsset;
|
||||||
|
|
||||||
|
use App\Models\DocumentAsset;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt ein Bild für die Dokumentvorlagen an oder ersetzt es.
|
||||||
|
*
|
||||||
|
* Gespeichert wird der base64-Payload in der Datenbank -- so überlebt das Bild ein Release (das als
|
||||||
|
* `git checkout` alles unter `public/` überschreibt) und wandert mit jedem Dump mit.
|
||||||
|
*/
|
||||||
|
class UpdateDocumentAssetAction
|
||||||
|
{
|
||||||
|
/** Über 2 MB wird die Vorlage träge und das PDF unnötig groß. */
|
||||||
|
private const int MAX_BYTES = 2 * 1024 * 1024;
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
private const array ALLOWED_MIME_TYPES = [
|
||||||
|
'image/png' => 'png',
|
||||||
|
'image/jpeg' => 'jpg',
|
||||||
|
'image/gif' => 'gif',
|
||||||
|
'image/svg+xml' => 'svg',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct(private readonly UpdateDocumentAssetRequest $request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(): UpdateDocumentAssetResponse
|
||||||
|
{
|
||||||
|
$response = new UpdateDocumentAssetResponse();
|
||||||
|
|
||||||
|
$name = $this->normalizeName($this->request->name);
|
||||||
|
|
||||||
|
if ($name === null) {
|
||||||
|
$response->message = 'Bitte einen Namen aus Kleinbuchstaben, Ziffern, Bindestrich oder Unterstrich angeben.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$asset = DocumentAsset::where('name', $name)->first();
|
||||||
|
$file = $this->request->file;
|
||||||
|
|
||||||
|
if ($file === null && $asset === null) {
|
||||||
|
$response->message = 'Für ein neues Bild wird eine Datei benötigt.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes = ['name' => $name, 'label' => $this->request->label];
|
||||||
|
|
||||||
|
if ($file !== null) {
|
||||||
|
if (!array_key_exists($file->getMimeType(), self::ALLOWED_MIME_TYPES)) {
|
||||||
|
$response->message = 'Nur PNG, JPEG, GIF oder SVG sind zulässig.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($file->getSize() > self::MAX_BYTES) {
|
||||||
|
$response->message = 'Das Bild darf höchstens 2 MB groß sein.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributes['mime'] = $file->getMimeType();
|
||||||
|
$attributes['data'] = base64_encode(file_get_contents($file->getRealPath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->asset = $asset === null
|
||||||
|
? DocumentAsset::create($attributes)
|
||||||
|
: tap($asset)->update($attributes);
|
||||||
|
|
||||||
|
$response->success = true;
|
||||||
|
$response->message = 'Das Bild wurde gespeichert.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Namen sind Slugs, damit `{asset:name}` eindeutig erkennbar bleibt. */
|
||||||
|
private function normalizeName(string $name): ?string
|
||||||
|
{
|
||||||
|
$name = strtolower(trim($name));
|
||||||
|
|
||||||
|
return preg_match('/^[a-z0-9_-]+$/', $name) === 1 ? $name : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateDocumentAsset;
|
||||||
|
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
|
||||||
|
class UpdateDocumentAssetRequest
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
/** Slug, unter dem das Bild in der Vorlage als `{asset:name}` referenziert wird. */
|
||||||
|
public readonly string $name,
|
||||||
|
public readonly ?string $label = null,
|
||||||
|
public readonly ?UploadedFile $file = null,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateDocumentAsset;
|
||||||
|
|
||||||
|
use App\Models\DocumentAsset;
|
||||||
|
|
||||||
|
class UpdateDocumentAssetResponse
|
||||||
|
{
|
||||||
|
public bool $success = false;
|
||||||
|
|
||||||
|
public ?string $message = null;
|
||||||
|
|
||||||
|
public ?DocumentAsset $asset = null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateDocumentTemplate;
|
||||||
|
|
||||||
|
use App\Models\DocumentTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speichert die Blockinhalte einer Dokumentvorlage.
|
||||||
|
*
|
||||||
|
* Es werden nur bereits angelegte, als editierbar markierte Blöcke geschrieben. Neue Blöcke entstehen
|
||||||
|
* nicht über das Formular -- welche Blöcke eine Dokumentart hat, gibt die Vorlage vor (das Layout
|
||||||
|
* verweist mit `{block:...}` auf sie).
|
||||||
|
*/
|
||||||
|
class UpdateDocumentTemplateAction
|
||||||
|
{
|
||||||
|
public function __construct(private readonly UpdateDocumentTemplateRequest $request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(): UpdateDocumentTemplateResponse
|
||||||
|
{
|
||||||
|
$response = new UpdateDocumentTemplateResponse();
|
||||||
|
|
||||||
|
$existing = DocumentTemplate::forType($this->request->documentType);
|
||||||
|
|
||||||
|
// Erst prüfen, dann schreiben -- sonst bliebe bei einem Fehler ein halb gespeicherter Stand übrig.
|
||||||
|
$rejection = $this->rejectBareAssetInStyle();
|
||||||
|
if ($rejection !== null) {
|
||||||
|
$response->message = $rejection;
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->request->blocks as $block => $content) {
|
||||||
|
$template = $existing->get($block);
|
||||||
|
|
||||||
|
if ($template === null || !$template->editable) {
|
||||||
|
$response->skipped[] = $block;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template->update(['content' => (string) $content]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->success = true;
|
||||||
|
$response->message = $response->skipped === []
|
||||||
|
? 'Die Vorlage wurde gespeichert.'
|
||||||
|
: 'Die Vorlage wurde gespeichert; nicht editierbare Blöcke blieben unverändert.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Bild-Platzhalter, der im CSS nicht in `url(...)` steht, expandiert zu einem Data-URI, das
|
||||||
|
* dompdf nicht auslagern kann -- der Parser läuft dann minutenlang und der FPM-Worker stirbt am
|
||||||
|
* Zeitlimit (502). Solches CSS wird gar nicht erst gespeichert.
|
||||||
|
*
|
||||||
|
* @return string|null Fehlermeldung, oder null wenn nichts zu beanstanden ist.
|
||||||
|
*/
|
||||||
|
private function rejectBareAssetInStyle(): ?string
|
||||||
|
{
|
||||||
|
$style = $this->request->blocks[DocumentTemplate::BLOCK_STYLE] ?? null;
|
||||||
|
|
||||||
|
if ($style === null || preg_match('/(?<![("\'])\{asset:([a-z0-9_-]+)}/i', (string) $style, $match) !== 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'Im CSS-Block steht der Bild-Platzhalter {asset:%1$s} direkt im Text. Dort gehört er in url("{asset:%1$s}").',
|
||||||
|
$match[1]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateDocumentTemplate;
|
||||||
|
|
||||||
|
class UpdateDocumentTemplateRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $blocks Blockinhalte, adressiert über den Block-Slug.
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
public readonly string $documentType,
|
||||||
|
public readonly array $blocks,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateDocumentTemplate;
|
||||||
|
|
||||||
|
class UpdateDocumentTemplateResponse
|
||||||
|
{
|
||||||
|
public bool $success = false;
|
||||||
|
|
||||||
|
public ?string $message = null;
|
||||||
|
|
||||||
|
/** @var array<int, string> Blöcke, die nicht gespeichert wurden (unbekannt oder nicht editierbar). */
|
||||||
|
public array $skipped = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateGlobalSettings;
|
||||||
|
|
||||||
|
use App\Models\GlobalSetting;
|
||||||
|
|
||||||
|
class UpdateGlobalSettingsAction
|
||||||
|
{
|
||||||
|
public function __construct(private UpdateGlobalSettingsRequest $request)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(): UpdateGlobalSettingsResponse
|
||||||
|
{
|
||||||
|
$response = new UpdateGlobalSettingsResponse();
|
||||||
|
|
||||||
|
$values = [
|
||||||
|
GlobalSetting::LOCAL_GROUP_LABEL => trim($this->request->localGroupLabel),
|
||||||
|
GlobalSetting::LOCAL_GROUP_LABEL_PLURAL => trim($this->request->localGroupLabelPlural),
|
||||||
|
GlobalSetting::PARENT_GROUP_LABEL => trim($this->request->parentGroupLabel),
|
||||||
|
GlobalSetting::PARENT_GROUP_LABEL_PLURAL => trim($this->request->parentGroupLabelPlural),
|
||||||
|
];
|
||||||
|
|
||||||
|
// Eine leere Bezeichnung ließe Überschriften und Auswahlfelder ohne Beschriftung zurück.
|
||||||
|
if (in_array('', $values, true)) {
|
||||||
|
$response->message = 'Bitte alle Bezeichnungen ausfüllen.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->request->globalSettings->setMany($values);
|
||||||
|
|
||||||
|
$response->success = true;
|
||||||
|
$response->message = 'Einstellungen wurden gespeichert.';
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateGlobalSettings;
|
||||||
|
|
||||||
|
use App\Repositories\GlobalSettingRepository;
|
||||||
|
|
||||||
|
class UpdateGlobalSettingsRequest
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public GlobalSettingRepository $globalSettings,
|
||||||
|
public string $localGroupLabel,
|
||||||
|
public string $localGroupLabelPlural,
|
||||||
|
public string $parentGroupLabel,
|
||||||
|
public string $parentGroupLabelPlural,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Actions\UpdateGlobalSettings;
|
||||||
|
|
||||||
|
class UpdateGlobalSettingsResponse
|
||||||
|
{
|
||||||
|
public bool $success = false;
|
||||||
|
public string $message = '';
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Domains\Admin\Actions\UpdateTenantContact;
|
namespace App\Domains\Admin\Actions\UpdateTenantContact;
|
||||||
|
|
||||||
|
use App\Support\Text;
|
||||||
|
|
||||||
class UpdateTenantContactAction
|
class UpdateTenantContactAction
|
||||||
{
|
{
|
||||||
public function __construct(private UpdateTenantContactRequest $request)
|
public function __construct(private UpdateTenantContactRequest $request)
|
||||||
@@ -15,8 +17,14 @@ class UpdateTenantContactAction
|
|||||||
$this->request->tenant->update([
|
$this->request->tenant->update([
|
||||||
'email' => $this->request->email,
|
'email' => $this->request->email,
|
||||||
'email_finance' => $this->request->emailFinance,
|
'email_finance' => $this->request->emailFinance,
|
||||||
|
'invoice_sender_name' => Text::nullIfBlank($this->request->invoiceSenderName),
|
||||||
|
// Leergelassene optionale Felder als NULL, damit sie im Briefkopf sauber wegfallen.
|
||||||
|
'address_1' => Text::nullIfBlank($this->request->address1),
|
||||||
|
'address_2' => Text::nullIfBlank($this->request->address2),
|
||||||
|
'address_3' => Text::nullIfBlank($this->request->address3),
|
||||||
'postcode' => $this->request->postcode,
|
'postcode' => $this->request->postcode,
|
||||||
'city' => $this->request->city,
|
'city' => $this->request->city,
|
||||||
|
'phone' => Text::nullIfBlank($this->request->phone),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ class UpdateTenantContactRequest
|
|||||||
public string $emailFinance,
|
public string $emailFinance,
|
||||||
public string $postcode,
|
public string $postcode,
|
||||||
public string $city,
|
public string $city,
|
||||||
|
/** Bezeichnung des Rechnungsstellers; leer bedeutet "Name des Mandanten verwenden". */
|
||||||
|
public ?string $invoiceSenderName = null,
|
||||||
|
/** Straße und Hausnummer -- Pflichtangabe auf Rechnungen nach § 14 Abs. 4 UStG. */
|
||||||
|
public ?string $address1 = null,
|
||||||
|
/** Optionale Zusatzzeile, z.B. "c/o ...". */
|
||||||
|
public ?string $address2 = null,
|
||||||
|
public ?string $address3 = null,
|
||||||
|
public ?string $phone = null,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Domains\Admin\Actions\UpdateTenantGeneral;
|
namespace App\Domains\Admin\Actions\UpdateTenantGeneral;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipantGroupType;
|
||||||
|
|
||||||
class UpdateTenantGeneralAction
|
class UpdateTenantGeneralAction
|
||||||
{
|
{
|
||||||
public function __construct(private UpdateTenantGeneralRequest $request)
|
public function __construct(private UpdateTenantGeneralRequest $request)
|
||||||
@@ -12,10 +14,17 @@ class UpdateTenantGeneralAction
|
|||||||
{
|
{
|
||||||
$response = new UpdateTenantGeneralResponse();
|
$response = new UpdateTenantGeneralResponse();
|
||||||
|
|
||||||
|
if ($this->request->parentGroup === null) {
|
||||||
|
$response->message = sprintf('Bitte bei „%s" eine Auswahl treffen.', ParticipantGroupType::ParentGroup->label());
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
$this->request->tenant->update([
|
$this->request->tenant->update([
|
||||||
'name' => $this->request->name,
|
'name' => $this->request->name,
|
||||||
'slug' => $this->request->slug,
|
'slug' => $this->request->slug,
|
||||||
'url' => $this->request->url,
|
'url' => $this->request->url,
|
||||||
|
'parent_group_id' => $this->request->parentGroup->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domains\Admin\Actions\UpdateTenantGeneral;
|
namespace App\Domains\Admin\Actions\UpdateTenantGeneral;
|
||||||
|
|
||||||
|
use App\Models\ParentGroup;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
|
|
||||||
class UpdateTenantGeneralRequest
|
class UpdateTenantGeneralRequest
|
||||||
@@ -11,6 +12,8 @@ class UpdateTenantGeneralRequest
|
|||||||
public string $name,
|
public string $name,
|
||||||
public string $slug,
|
public string $slug,
|
||||||
public string $url,
|
public string $url,
|
||||||
|
/** Pflicht; null heißt, die übermittelte ID war unbekannt. */
|
||||||
|
public ?ParentGroup $parentGroup,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,12 @@ use App\Scopes\SiteScope;
|
|||||||
|
|
||||||
class UpdateTenantPaymentAction
|
class UpdateTenantPaymentAction
|
||||||
{
|
{
|
||||||
|
/** Zahlungsarten, deren Konto das Konto des Stammes ist (Überweisung: Ziel, Lastschrift: Gläubiger). */
|
||||||
|
private const array BANK_ACCOUNT_SLUGS = [
|
||||||
|
PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION,
|
||||||
|
PaymentMethod::PAYMENT_SEPA_DIRECT_DEBIT,
|
||||||
|
];
|
||||||
|
|
||||||
public function __construct(private UpdateTenantPaymentRequest $request)
|
public function __construct(private UpdateTenantPaymentRequest $request)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -22,7 +28,9 @@ class UpdateTenantPaymentAction
|
|||||||
'account_name' => $this->request->accountName,
|
'account_name' => $this->request->accountName,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->syncTransferPaymentConfiguration();
|
foreach (self::BANK_ACCOUNT_SLUGS as $slug) {
|
||||||
|
$this->syncPaymentConfiguration($slug);
|
||||||
|
}
|
||||||
|
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
$response->message = 'IBAN-Informationen wurden gespeichert.';
|
$response->message = 'IBAN-Informationen wurden gespeichert.';
|
||||||
@@ -31,15 +39,13 @@ class UpdateTenantPaymentAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Übernimmt die eingegebenen IBAN-Daten direkt in die Tenant-Config der Überweisungs-Zahlungsart
|
* Übernimmt die eingegebenen IBAN-Daten direkt in die Tenant-Config der Zahlungsart
|
||||||
* (Kontoinhaber/IBAN/BIC), damit sie nicht doppelt gepflegt werden müssen. Bestehende weitere
|
* (Kontoinhaber/IBAN/BIC), damit sie nicht doppelt gepflegt werden müssen. Bestehende weitere
|
||||||
* Config-Werte (z.B. Symbol) bleiben erhalten. Der Ziel-Tenant kann ein verwalteter sein, daher
|
* Config-Werte (z.B. Symbol, Gläubiger-ID) bleiben erhalten. Der Ziel-Tenant kann ein verwalteter
|
||||||
* ohne SiteScope explizit auf den Tenant-Slug gefiltert.
|
* sein, daher ohne SiteScope explizit auf den Tenant-Slug gefiltert.
|
||||||
*/
|
*/
|
||||||
private function syncTransferPaymentConfiguration(): void
|
private function syncPaymentConfiguration(string $slug): void
|
||||||
{
|
{
|
||||||
$slug = PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION;
|
|
||||||
|
|
||||||
$method = AvailablePaymentMethod::withoutGlobalScope(SiteScope::class)
|
$method = AvailablePaymentMethod::withoutGlobalScope(SiteScope::class)
|
||||||
->where('tenant', $this->request->tenant->slug)
|
->where('tenant', $this->request->tenant->slug)
|
||||||
->where('slug', $slug)
|
->where('slug', $slug)
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace App\Domains\Admin\Actions\UpdateTenantTax;
|
namespace App\Domains\Admin\Actions\UpdateTenantTax;
|
||||||
|
|
||||||
use App\Enumerations\VatPricingMode;
|
use App\Enumerations\VatPricingMode;
|
||||||
|
use App\Models\Tenant;
|
||||||
|
use App\Support\Text;
|
||||||
|
|
||||||
class UpdateTenantTaxAction
|
class UpdateTenantTaxAction
|
||||||
{
|
{
|
||||||
@@ -14,14 +16,23 @@ class UpdateTenantTaxAction
|
|||||||
{
|
{
|
||||||
$response = new UpdateTenantTaxResponse();
|
$response = new UpdateTenantTaxResponse();
|
||||||
|
|
||||||
|
// Präfixe sind großgeschrieben; null heißt "nicht mitgeschickt" und damit "unverändert".
|
||||||
|
$prefix = Text::nullIfBlank(strtoupper((string) $this->request->invoicePrefix));
|
||||||
|
|
||||||
|
if ($prefix !== null && $this->prefixTakenByAnotherTenant($prefix)) {
|
||||||
|
$response->message = sprintf('Das Rechnungs-Präfix "%s" wird bereits von einem anderen Mandanten genutzt.', $prefix);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->request->taxLiable) {
|
if ($this->request->taxLiable) {
|
||||||
$this->request->tenant->update([
|
$this->request->tenant->update($this->withInvoiceDetails([
|
||||||
'tax_liable' => true,
|
'tax_liable' => true,
|
||||||
'vat_rate' => $this->clampVatRate($this->request->vatRate),
|
'vat_rate' => $this->clampVatRate($this->request->vatRate),
|
||||||
'vat_pricing_mode' => $this->request->vatPricingMode->value,
|
'vat_pricing_mode' => $this->request->vatPricingMode->value,
|
||||||
'tax_exemption_reason' => null,
|
'tax_exemption_reason' => null,
|
||||||
'tax_exemption_note' => null,
|
'tax_exemption_note' => null,
|
||||||
]);
|
], $prefix));
|
||||||
|
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
$response->message = 'Steuerinformationen wurden gespeichert.';
|
$response->message = 'Steuerinformationen wurden gespeichert.';
|
||||||
@@ -45,13 +56,13 @@ class UpdateTenantTaxAction
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->request->tenant->update([
|
$this->request->tenant->update($this->withInvoiceDetails([
|
||||||
'tax_liable' => false,
|
'tax_liable' => false,
|
||||||
'vat_rate' => 0,
|
'vat_rate' => 0,
|
||||||
'vat_pricing_mode' => VatPricingMode::Inclusive->value,
|
'vat_pricing_mode' => VatPricingMode::Inclusive->value,
|
||||||
'tax_exemption_reason' => $reason->slug,
|
'tax_exemption_reason' => $reason->slug,
|
||||||
'tax_exemption_note' => $reason->requires_note ? $note : null,
|
'tax_exemption_note' => $reason->requires_note ? $note : null,
|
||||||
]);
|
], $prefix));
|
||||||
|
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
$response->message = 'Steuerinformationen wurden gespeichert.';
|
$response->message = 'Steuerinformationen wurden gespeichert.';
|
||||||
@@ -63,4 +74,31 @@ class UpdateTenantTaxAction
|
|||||||
{
|
{
|
||||||
return max(0, min(100, $vatRate));
|
return max(0, min(100, $vatRate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ergänzt die Rechnungsstellerangaben. Sie gelten unabhängig davon, ob Steuerpflicht besteht -- eine
|
||||||
|
* Steuernummer gehört auch auf eine steuerfreie Rechnung.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $attributes
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function withInvoiceDetails(array $attributes, ?string $prefix): array
|
||||||
|
{
|
||||||
|
$attributes['tax_number'] = Text::nullIfBlank($this->request->taxNumber);
|
||||||
|
$attributes['vat_id'] = Text::nullIfBlank($this->request->vatId);
|
||||||
|
|
||||||
|
// Nicht mitgeschickt heißt "unverändert", nicht "leeren".
|
||||||
|
if ($prefix !== null) {
|
||||||
|
$attributes['invoice_prefix'] = $prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function prefixTakenByAnotherTenant(string $prefix): bool
|
||||||
|
{
|
||||||
|
return Tenant::where('invoice_prefix', $prefix)
|
||||||
|
->where('id', '!=', $this->request->tenant->id)
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,14 @@ class UpdateTenantTaxRequest
|
|||||||
public ?TaxExemptionReason $exemptionReason,
|
public ?TaxExemptionReason $exemptionReason,
|
||||||
public ?string $exemptionNote,
|
public ?string $exemptionNote,
|
||||||
public VatPricingMode $vatPricingMode,
|
public VatPricingMode $vatPricingMode,
|
||||||
|
/** Steuernummer bzw. USt-IdNr. -- Pflichtangabe auf Rechnungen (§ 14 Abs. 4 Nr. 2 UStG). */
|
||||||
|
public ?string $taxNumber = null,
|
||||||
|
public ?string $vatId = null,
|
||||||
|
/**
|
||||||
|
* Erster Block der Rechnungsnummer. `null` heißt "unverändert lassen" -- im Self-Service wird das
|
||||||
|
* Feld gar nicht erst mitgeschickt, damit ein bestehender Nummernkreis nicht bricht.
|
||||||
|
*/
|
||||||
|
public ?string $invoicePrefix = null,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Models\DocumentAsset;
|
||||||
|
use App\Models\DocumentTemplate;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class DocumentAssetDeleteController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(string $name): JsonResponse
|
||||||
|
{
|
||||||
|
$asset = DocumentAsset::where('name', $name)->first();
|
||||||
|
|
||||||
|
// Durchweg 200 mit Status im Body -- wie die übrigen Admin-Endpunkte, damit der Grund im Frontend
|
||||||
|
// ankommt (der Ajax-Helfer verwirft den Body bei Fehler-Statuscodes).
|
||||||
|
if ($asset === null) {
|
||||||
|
return response()->json(['status' => 'error', 'message' => 'Das Bild existiert nicht.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ein noch referenziertes Bild zu löschen würde stillschweigend eine Lücke in jede künftige
|
||||||
|
// Rechnung reißen -- der Platzhalter löst dann zu einem Leerstring auf.
|
||||||
|
if ($this->isReferenced($asset->name)) {
|
||||||
|
return response()->json([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => sprintf('Das Bild wird noch als {asset:%s} in der Vorlage verwendet.', $asset->name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$asset->delete();
|
||||||
|
|
||||||
|
return response()->json(['status' => 'success', 'message' => 'Das Bild wurde gelöscht.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isReferenced(string $name): bool
|
||||||
|
{
|
||||||
|
return DocumentTemplate::query()
|
||||||
|
->where('content', 'like', '%{asset:' . $name . '}%')
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Admin\Actions\UpdateDocumentAsset\UpdateDocumentAssetAction;
|
||||||
|
use App\Domains\Admin\Actions\UpdateDocumentAsset\UpdateDocumentAssetRequest;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class DocumentAssetUpdateController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$action = new UpdateDocumentAssetAction(new UpdateDocumentAssetRequest(
|
||||||
|
name: (string) $request->input('name'),
|
||||||
|
label: $request->input('label'),
|
||||||
|
file: $request->file('file'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = $action->execute();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => $response->success ? 'success' : 'error',
|
||||||
|
'message' => $response->message,
|
||||||
|
'token' => $response->asset !== null ? '{asset:' . $response->asset->name . '}' : null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Models\DocumentAsset;
|
||||||
|
use App\Models\DocumentTemplate;
|
||||||
|
use App\Models\DocumentTypeCatalog;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class DocumentTemplatesGetController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$documentType = (string) $request->input('type', DocumentTypeCatalog::default());
|
||||||
|
|
||||||
|
if (!DocumentTypeCatalog::has($documentType)) {
|
||||||
|
abort(422, 'Unbekannte Dokumentart.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$blocks = DocumentTemplate::forType($documentType)
|
||||||
|
->values()
|
||||||
|
->map(fn(DocumentTemplate $block): array => [
|
||||||
|
'block' => $block->block,
|
||||||
|
'label' => DocumentTypeCatalog::blockLabel($documentType, $block->block),
|
||||||
|
'content' => (string) $block->content,
|
||||||
|
'editable' => $block->editable,
|
||||||
|
'source' => in_array($block->block, DocumentTypeCatalog::SOURCE_BLOCKS, true),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'documentType' => $documentType,
|
||||||
|
'documentTypes' => DocumentTypeCatalog::options(),
|
||||||
|
'blocks' => $blocks,
|
||||||
|
// Die Bilder gelten für alle Dokumentarten -- sie hängen nicht am Typ.
|
||||||
|
'assets' => DocumentAsset::orderBy('name')->get()->map(fn(DocumentAsset $asset): array => [
|
||||||
|
'name' => $asset->name,
|
||||||
|
'label' => $asset->label,
|
||||||
|
'mime' => $asset->mime,
|
||||||
|
'token' => '{asset:' . $asset->name . '}',
|
||||||
|
'preview' => $asset->toDataUri(),
|
||||||
|
]),
|
||||||
|
'tokenGroups' => DocumentTypeCatalog::tokenGroups($documentType),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Providers\InertiaProvider;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Inertia\Response;
|
||||||
|
|
||||||
|
class DocumentTemplatesPageController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(): Response
|
||||||
|
{
|
||||||
|
return new InertiaProvider('Admin/DocumentTemplates', [])->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Models\DocumentTypeCatalog;
|
||||||
|
use App\Providers\DocumentTemplateRenderProvider;
|
||||||
|
use App\Providers\PdfGenerateAndDownloadProvider;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rendert die Vorlage mit Beispieldaten, ohne sie zu speichern -- damit niemand blind HTML editiert.
|
||||||
|
*/
|
||||||
|
class DocumentTemplatesPreviewController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): Response
|
||||||
|
{
|
||||||
|
$documentType = (string) $request->input('type', DocumentTypeCatalog::default());
|
||||||
|
|
||||||
|
if (!DocumentTypeCatalog::has($documentType)) {
|
||||||
|
abort(422, 'Unbekannte Dokumentart.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = new DocumentTemplateRenderProvider(
|
||||||
|
$documentType,
|
||||||
|
(array) $request->input('blocks', []),
|
||||||
|
)->render(DocumentTypeCatalog::sampleTokens($documentType));
|
||||||
|
|
||||||
|
return response(PdfGenerateAndDownloadProvider::fromHtml($html, 'portrait'), 200, [
|
||||||
|
'Content-Type' => 'application/pdf',
|
||||||
|
'Content-Disposition' => 'inline; filename="vorschau.pdf"',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Admin\Actions\UpdateDocumentTemplate\UpdateDocumentTemplateAction;
|
||||||
|
use App\Domains\Admin\Actions\UpdateDocumentTemplate\UpdateDocumentTemplateRequest;
|
||||||
|
use App\Models\DocumentTypeCatalog;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class DocumentTemplatesUpdateController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$documentType = (string) $request->input('type', DocumentTypeCatalog::default());
|
||||||
|
|
||||||
|
// Die Dokumentart bestimmt, welche Zeilen geschrieben werden -- ungeprüft weitergereicht wäre
|
||||||
|
// sie ein Weg, in beliebige Vorlagen zu schreiben.
|
||||||
|
if (!DocumentTypeCatalog::has($documentType)) {
|
||||||
|
abort(422, 'Unbekannte Dokumentart.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$action = new UpdateDocumentTemplateAction(new UpdateDocumentTemplateRequest(
|
||||||
|
documentType: $documentType,
|
||||||
|
blocks: (array) $request->input('blocks', []),
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = $action->execute();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => $response->success ? 'success' : 'error',
|
||||||
|
'message' => $response->message,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipantGroupType;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class GlobalSettingsGetController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
return response()->json([
|
||||||
|
'groupLabels' => ParticipantGroupType::labels(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Providers\InertiaProvider;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Inertia\Response;
|
||||||
|
|
||||||
|
class GlobalSettingsPageController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): Response
|
||||||
|
{
|
||||||
|
return new InertiaProvider('Admin/GlobalSettings', [])->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Admin\Actions\UpdateGlobalSettings\UpdateGlobalSettingsAction;
|
||||||
|
use App\Domains\Admin\Actions\UpdateGlobalSettings\UpdateGlobalSettingsRequest;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class GlobalSettingsUpdateController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$response = new UpdateGlobalSettingsAction(new UpdateGlobalSettingsRequest(
|
||||||
|
globalSettings: $this->globalSettings,
|
||||||
|
localGroupLabel: (string) $request->input('localGroup'),
|
||||||
|
localGroupLabelPlural: (string) $request->input('localGroupPlural'),
|
||||||
|
parentGroupLabel: (string) $request->input('parentGroup'),
|
||||||
|
parentGroupLabelPlural: (string) $request->input('parentGroupPlural'),
|
||||||
|
))->execute();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => $response->success ? 'success' : 'error',
|
||||||
|
'message' => $response->message,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,13 @@ class ManagedTenantContactGetController extends CommonController
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'email' => $tenant->email,
|
'email' => $tenant->email,
|
||||||
'email_finance' => $tenant->email_finance,
|
'email_finance' => $tenant->email_finance,
|
||||||
|
'invoice_sender_name' => $tenant->invoice_sender_name,
|
||||||
|
// Als Platzhalter im Formular: so heisst der Absender, solange nichts eingetragen ist.
|
||||||
|
'name' => $tenant->name,
|
||||||
|
'phone' => $tenant->phone,
|
||||||
|
'address_1' => $tenant->address_1,
|
||||||
|
'address_2' => $tenant->address_2,
|
||||||
|
'address_3' => $tenant->address_3,
|
||||||
'postcode' => $tenant->postcode,
|
'postcode' => $tenant->postcode,
|
||||||
'city' => $tenant->city,
|
'city' => $tenant->city,
|
||||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/contact',
|
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/contact',
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ class ManagedTenantContactUpdateController extends CommonController
|
|||||||
emailFinance: $request->input('email_finance'),
|
emailFinance: $request->input('email_finance'),
|
||||||
postcode: $request->input('postcode'),
|
postcode: $request->input('postcode'),
|
||||||
city: $request->input('city'),
|
city: $request->input('city'),
|
||||||
|
invoiceSenderName: $request->input('invoice_sender_name'),
|
||||||
|
address1: $request->input('address_1'),
|
||||||
|
address2: $request->input('address_2'),
|
||||||
|
address3: $request->input('address_3'),
|
||||||
|
phone: $request->input('phone'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $action->execute();
|
$response = $action->execute();
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ class ManagedTenantTaxGetController extends CommonController
|
|||||||
'tax_exemption_reason' => $tenant->tax_exemption_reason,
|
'tax_exemption_reason' => $tenant->tax_exemption_reason,
|
||||||
'tax_exemption_note' => $tenant->tax_exemption_note,
|
'tax_exemption_note' => $tenant->tax_exemption_note,
|
||||||
'vat_pricing_mode' => $tenant->vat_pricing_mode,
|
'vat_pricing_mode' => $tenant->vat_pricing_mode,
|
||||||
|
'tax_number' => $tenant->tax_number,
|
||||||
|
'vat_id' => $tenant->vat_id,
|
||||||
|
'invoice_prefix' => $tenant->invoice_prefix,
|
||||||
|
// In der Mandanten-Verwaltung ist der Nummernkreis änderbar.
|
||||||
|
'can_edit_invoice_prefix' => true,
|
||||||
'exemption_reasons' => TaxExemptionReason::options(),
|
'exemption_reasons' => TaxExemptionReason::options(),
|
||||||
'pricing_modes' => VatPricingMode::options(),
|
'pricing_modes' => VatPricingMode::options(),
|
||||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/tax',
|
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/tax',
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ class ManagedTenantTaxUpdateController extends CommonController
|
|||||||
exemptionReason: TaxExemptionReason::where('slug', $request->input('tax_exemption_reason'))->first(),
|
exemptionReason: TaxExemptionReason::where('slug', $request->input('tax_exemption_reason'))->first(),
|
||||||
exemptionNote: $request->input('tax_exemption_note'),
|
exemptionNote: $request->input('tax_exemption_note'),
|
||||||
vatPricingMode: VatPricingMode::tryFrom((string) $request->input('vat_pricing_mode', 'inclusive')) ?? VatPricingMode::Inclusive,
|
vatPricingMode: VatPricingMode::tryFrom((string) $request->input('vat_pricing_mode', 'inclusive')) ?? VatPricingMode::Inclusive,
|
||||||
|
taxNumber: $request->input('tax_number'),
|
||||||
|
vatId: $request->input('vat_id'),
|
||||||
|
invoicePrefix: $request->input('invoice_prefix'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $action->execute();
|
$response = $action->execute();
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Admin\Actions\CreateParentGroup\CreateParentGroupAction;
|
||||||
|
use App\Domains\Admin\Actions\CreateParentGroup\CreateParentGroupRequest;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ParentGroupCreateController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$response = new CreateParentGroupAction(new CreateParentGroupRequest(
|
||||||
|
name: (string) $request->input('name'),
|
||||||
|
))->execute();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => $response->success ? 'success' : 'error',
|
||||||
|
'message' => $response->message,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Admin\Actions\DeleteParentGroup\DeleteParentGroupAction;
|
||||||
|
use App\Domains\Admin\Actions\DeleteParentGroup\DeleteParentGroupRequest;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ParentGroupDeleteController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(int $id, Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$parentGroup = $this->adminParentGroups->findById($id);
|
||||||
|
|
||||||
|
if ($parentGroup === null) {
|
||||||
|
return response()->json(['status' => 'error', 'message' => 'Eintrag nicht gefunden.'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = new DeleteParentGroupAction(new DeleteParentGroupRequest(
|
||||||
|
parentGroup: $parentGroup,
|
||||||
|
inUse: $this->adminParentGroups->isInUse($parentGroup),
|
||||||
|
))->execute();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => $response->success ? 'success' : 'error',
|
||||||
|
'message' => $response->message,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ParentGroupListApiController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$parentGroups = $this->adminParentGroups->all()->map(fn ($parentGroup) => [
|
||||||
|
'id' => $parentGroup->id,
|
||||||
|
'name' => $parentGroup->name,
|
||||||
|
'isFallback' => $parentGroup->is_fallback,
|
||||||
|
'tenantCount' => $parentGroup->tenants_count,
|
||||||
|
'deletable' => !$parentGroup->is_fallback && !$this->adminParentGroups->isInUse($parentGroup),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json(['parentGroups' => $parentGroups]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipantGroupType;
|
||||||
|
use App\Providers\InertiaProvider;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Inertia\Response;
|
||||||
|
|
||||||
|
class ParentGroupListPageController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request): Response
|
||||||
|
{
|
||||||
|
return new InertiaProvider('Admin/ParentGroupList', [
|
||||||
|
'groupLabels' => ParticipantGroupType::labels(),
|
||||||
|
])->render();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Domains\Admin\Actions\RenameParentGroup\RenameParentGroupAction;
|
||||||
|
use App\Domains\Admin\Actions\RenameParentGroup\RenameParentGroupRequest;
|
||||||
|
use App\Scopes\CommonController;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ParentGroupUpdateController extends CommonController
|
||||||
|
{
|
||||||
|
public function __invoke(int $id, Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$parentGroup = $this->adminParentGroups->findById($id);
|
||||||
|
|
||||||
|
if ($parentGroup === null) {
|
||||||
|
return response()->json(['status' => 'error', 'message' => 'Eintrag nicht gefunden.'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = new RenameParentGroupAction(new RenameParentGroupRequest(
|
||||||
|
parentGroup: $parentGroup,
|
||||||
|
name: (string) $request->input('name'),
|
||||||
|
))->execute();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status' => $response->success ? 'success' : 'error',
|
||||||
|
'message' => $response->message,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,13 @@ class TenantContactGetController extends CommonController
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'email' => $this->tenant->email,
|
'email' => $this->tenant->email,
|
||||||
'email_finance' => $this->tenant->email_finance,
|
'email_finance' => $this->tenant->email_finance,
|
||||||
|
'invoice_sender_name' => $this->tenant->invoice_sender_name,
|
||||||
|
// Als Platzhalter im Formular: so heisst der Absender, solange nichts eingetragen ist.
|
||||||
|
'name' => $this->tenant->name,
|
||||||
|
'phone' => $this->tenant->phone,
|
||||||
|
'address_1' => $this->tenant->address_1,
|
||||||
|
'address_2' => $this->tenant->address_2,
|
||||||
|
'address_3' => $this->tenant->address_3,
|
||||||
'postcode' => $this->tenant->postcode,
|
'postcode' => $this->tenant->postcode,
|
||||||
'city' => $this->tenant->city,
|
'city' => $this->tenant->city,
|
||||||
'saveEndpoint' => '/api/v1/admin/tenant/contact',
|
'saveEndpoint' => '/api/v1/admin/tenant/contact',
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ class TenantContactUpdateController extends CommonController
|
|||||||
emailFinance: $request->input('email_finance'),
|
emailFinance: $request->input('email_finance'),
|
||||||
postcode: $request->input('postcode'),
|
postcode: $request->input('postcode'),
|
||||||
city: $request->input('city'),
|
city: $request->input('city'),
|
||||||
|
invoiceSenderName: $request->input('invoice_sender_name'),
|
||||||
|
address1: $request->input('address_1'),
|
||||||
|
address2: $request->input('address_2'),
|
||||||
|
address3: $request->input('address_3'),
|
||||||
|
phone: $request->input('phone'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $action->execute();
|
$response = $action->execute();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class TenantCreateController extends CommonController
|
|||||||
name: $request->input('name'),
|
name: $request->input('name'),
|
||||||
slug: $request->input('slug'),
|
slug: $request->input('slug'),
|
||||||
url: $request->input('url'),
|
url: $request->input('url'),
|
||||||
|
parentGroup: $this->adminParentGroups->findById((int) $request->input('parent_group_id')),
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $action->execute();
|
$response = $action->execute();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domains\Admin\Controllers;
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipantGroupType;
|
||||||
use App\Scopes\CommonController;
|
use App\Scopes\CommonController;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -17,6 +18,12 @@ class TenantGeneralGetController extends CommonController
|
|||||||
'slug' => $tenant->slug,
|
'slug' => $tenant->slug,
|
||||||
'url' => $tenant->url,
|
'url' => $tenant->url,
|
||||||
'is_active_local_group' => $tenant->is_active_local_group,
|
'is_active_local_group' => $tenant->is_active_local_group,
|
||||||
|
'parent_group_id' => $tenant->parent_group_id,
|
||||||
|
'parentGroups' => $this->adminParentGroups->all()->map(fn ($parentGroup) => [
|
||||||
|
'id' => $parentGroup->id,
|
||||||
|
'name' => $parentGroup->name,
|
||||||
|
]),
|
||||||
|
'parentGroupLabel' => ParticipantGroupType::ParentGroup->label(),
|
||||||
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/general',
|
'saveEndpoint' => '/api/v1/admin/tenants/' . $slug . '/general',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class TenantGeneralUpdateController extends CommonController
|
|||||||
name: $request->input('name'),
|
name: $request->input('name'),
|
||||||
slug: $request->input('slug'),
|
slug: $request->input('slug'),
|
||||||
url: $request->input('url'),
|
url: $request->input('url'),
|
||||||
|
parentGroup: $this->adminParentGroups->findById((int) $request->input('parent_group_id')),
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $action->execute();
|
$response = $action->execute();
|
||||||
|
|||||||
@@ -18,9 +18,17 @@ class TenantListApiController extends CommonController
|
|||||||
'slug' => $tenant->slug,
|
'slug' => $tenant->slug,
|
||||||
'url' => $tenant->url,
|
'url' => $tenant->url,
|
||||||
'is_active_local_group' => $tenant->is_active_local_group,
|
'is_active_local_group' => $tenant->is_active_local_group,
|
||||||
|
'parentGroup' => $tenant->parentGroup?->name,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
return response()->json(['tenants' => $mapped]);
|
// Auswahl für das Anlage-Formular (Pflichtangabe).
|
||||||
|
$parentGroups = $this->adminParentGroups->all()->map(fn ($parentGroup) => [
|
||||||
|
'id' => $parentGroup->id,
|
||||||
|
'name' => $parentGroup->name,
|
||||||
|
'isFallback' => $parentGroup->is_fallback,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return response()->json(['tenants' => $mapped, 'parentGroups' => $parentGroups]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domains\Admin\Controllers;
|
namespace App\Domains\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipantGroupType;
|
||||||
use App\Providers\InertiaProvider;
|
use App\Providers\InertiaProvider;
|
||||||
use App\Scopes\CommonController;
|
use App\Scopes\CommonController;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -11,7 +12,9 @@ class TenantListPageController extends CommonController
|
|||||||
{
|
{
|
||||||
public function __invoke(Request $request): Response
|
public function __invoke(Request $request): Response
|
||||||
{
|
{
|
||||||
$inertiaProvider = new InertiaProvider('Admin/TenantList', []);
|
$inertiaProvider = new InertiaProvider('Admin/TenantList', [
|
||||||
|
'groupLabels' => ParticipantGroupType::labels(),
|
||||||
|
]);
|
||||||
return $inertiaProvider->render();
|
return $inertiaProvider->render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ namespace App\Domains\Admin\Controllers;
|
|||||||
use App\Models\AvailablePaymentMethod;
|
use App\Models\AvailablePaymentMethod;
|
||||||
use App\Resources\AvailablePaymentMethodResource;
|
use App\Resources\AvailablePaymentMethodResource;
|
||||||
use App\Scopes\CommonController;
|
use App\Scopes\CommonController;
|
||||||
|
use App\ValueObjects\BankStatementRuleset;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
@@ -16,6 +17,10 @@ class TenantPaymentMethodsGetController extends CommonController
|
|||||||
'paymentMethods' => AvailablePaymentMethod::all()
|
'paymentMethods' => AvailablePaymentMethod::all()
|
||||||
->map(fn (AvailablePaymentMethod $method) => new AvailablePaymentMethodResource($method)->toArray($request)),
|
->map(fn (AvailablePaymentMethod $method) => new AvailablePaymentMethodResource($method)->toArray($request)),
|
||||||
'saveEndpoint' => '/api/v1/admin/tenant/payment-methods',
|
'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,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,11 @@ class TenantTaxGetController extends CommonController
|
|||||||
'tax_exemption_reason' => $this->tenant->tax_exemption_reason,
|
'tax_exemption_reason' => $this->tenant->tax_exemption_reason,
|
||||||
'tax_exemption_note' => $this->tenant->tax_exemption_note,
|
'tax_exemption_note' => $this->tenant->tax_exemption_note,
|
||||||
'vat_pricing_mode' => $this->tenant->vat_pricing_mode,
|
'vat_pricing_mode' => $this->tenant->vat_pricing_mode,
|
||||||
|
'tax_number' => $this->tenant->tax_number,
|
||||||
|
'vat_id' => $this->tenant->vat_id,
|
||||||
|
'invoice_prefix' => $this->tenant->invoice_prefix,
|
||||||
|
// Im Self-Service nicht änderbar: das Präfix bestimmt den Nummernkreis.
|
||||||
|
'can_edit_invoice_prefix' => false,
|
||||||
'exemption_reasons' => TaxExemptionReason::options(),
|
'exemption_reasons' => TaxExemptionReason::options(),
|
||||||
'pricing_modes' => VatPricingMode::options(),
|
'pricing_modes' => VatPricingMode::options(),
|
||||||
'saveEndpoint' => '/api/v1/admin/tenant/tax',
|
'saveEndpoint' => '/api/v1/admin/tenant/tax',
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ class TenantTaxUpdateController extends CommonController
|
|||||||
exemptionReason: TaxExemptionReason::where('slug', $request->input('tax_exemption_reason'))->first(),
|
exemptionReason: TaxExemptionReason::where('slug', $request->input('tax_exemption_reason'))->first(),
|
||||||
exemptionNote: $request->input('tax_exemption_note'),
|
exemptionNote: $request->input('tax_exemption_note'),
|
||||||
vatPricingMode: VatPricingMode::tryFrom((string) $request->input('vat_pricing_mode', 'inclusive')) ?? VatPricingMode::Inclusive,
|
vatPricingMode: VatPricingMode::tryFrom((string) $request->input('vat_pricing_mode', 'inclusive')) ?? VatPricingMode::Inclusive,
|
||||||
|
taxNumber: $request->input('tax_number'),
|
||||||
|
vatId: $request->input('vat_id'),
|
||||||
|
// invoice_prefix wird hier bewusst nicht durchgereicht -- der Nummernkreis ist nur in der
|
||||||
|
// Mandanten-Verwaltung änderbar.
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $action->execute();
|
$response = $action->execute();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class UserDetailGetController extends CommonController
|
|||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'user' => $userData,
|
'user' => $userData,
|
||||||
'isOwnUser' => auth()->id() === $user->id,
|
'isOwnUser' => currentUser()?->id === $user->id,
|
||||||
'isLvTenant' => $this->tenant->slug === 'lv',
|
'isLvTenant' => $this->tenant->slug === 'lv',
|
||||||
'userRoles' => UserRole::all()->map(fn($role) => ['slug' => $role->slug, 'name' => $role->name]),
|
'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]),
|
'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(
|
$action = new ToggleUserActiveAction(new ToggleUserActiveRequest(
|
||||||
user: $user,
|
user: $user,
|
||||||
currentUserId: auth()->id(),
|
currentUserId: currentUser()?->id,
|
||||||
));
|
));
|
||||||
|
|
||||||
$response = $action->execute();
|
$response = $action->execute();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class UserUpdateController extends CommonController
|
|||||||
$action = new UpdateUserAction(new UpdateUserRequest(
|
$action = new UpdateUserAction(new UpdateUserRequest(
|
||||||
user: $user,
|
user: $user,
|
||||||
data: $request->all(),
|
data: $request->all(),
|
||||||
isOwnUser: auth()->id() === $user->id,
|
isOwnUser: currentUser()?->id === $user->id,
|
||||||
isLvTenant: $this->tenant->slug === 'lv',
|
isLvTenant: $this->tenant->slug === 'lv',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Admin\Repositories;
|
||||||
|
|
||||||
|
use App\Models\ParentGroup;
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
|
||||||
|
class AdminParentGroupRepository
|
||||||
|
{
|
||||||
|
/** Alle Parent Groups, alphabetisch mit „Ohne Zuordnung" am Ende, mit der Zahl zugeordneter Mandanten. */
|
||||||
|
public function all(): Collection
|
||||||
|
{
|
||||||
|
return ParentGroup::withCount('tenants')
|
||||||
|
->ordered()
|
||||||
|
->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findById(int $id): ?ParentGroup
|
||||||
|
{
|
||||||
|
return ParentGroup::find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ob die Parent Group noch verwendet wird -- von einem Mandanten oder von einer Anmeldung. Anmeldungen sind
|
||||||
|
* mandantengebunden; gezählt wird hier bewusst über alle Mandanten hinweg.
|
||||||
|
*/
|
||||||
|
public function isInUse(ParentGroup $parentGroup): bool
|
||||||
|
{
|
||||||
|
return $parentGroup->tenants()->exists()
|
||||||
|
|| $parentGroup->eventParticipants()->withoutGlobalScopes()->exists();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Domains\Admin\Controllers\DocumentAssetDeleteController;
|
||||||
|
use App\Domains\Admin\Controllers\DocumentAssetUpdateController;
|
||||||
|
use App\Domains\Admin\Controllers\DocumentTemplatesGetController;
|
||||||
|
use App\Domains\Admin\Controllers\DocumentTemplatesPreviewController;
|
||||||
|
use App\Domains\Admin\Controllers\DocumentTemplatesUpdateController;
|
||||||
|
use App\Domains\Admin\Controllers\GlobalSettingsGetController;
|
||||||
|
use App\Domains\Admin\Controllers\GlobalSettingsUpdateController;
|
||||||
use App\Domains\Admin\Controllers\ManagedTenantContactGetController;
|
use App\Domains\Admin\Controllers\ManagedTenantContactGetController;
|
||||||
use App\Domains\Admin\Controllers\ManagedTenantContactUpdateController;
|
use App\Domains\Admin\Controllers\ManagedTenantContactUpdateController;
|
||||||
use App\Domains\Admin\Controllers\ManagedTenantGdprGetController;
|
use App\Domains\Admin\Controllers\ManagedTenantGdprGetController;
|
||||||
@@ -10,6 +17,10 @@ use App\Domains\Admin\Controllers\ManagedTenantPaymentGetController;
|
|||||||
use App\Domains\Admin\Controllers\ManagedTenantPaymentUpdateController;
|
use App\Domains\Admin\Controllers\ManagedTenantPaymentUpdateController;
|
||||||
use App\Domains\Admin\Controllers\ManagedTenantTaxGetController;
|
use App\Domains\Admin\Controllers\ManagedTenantTaxGetController;
|
||||||
use App\Domains\Admin\Controllers\ManagedTenantTaxUpdateController;
|
use App\Domains\Admin\Controllers\ManagedTenantTaxUpdateController;
|
||||||
|
use App\Domains\Admin\Controllers\ParentGroupCreateController;
|
||||||
|
use App\Domains\Admin\Controllers\ParentGroupDeleteController;
|
||||||
|
use App\Domains\Admin\Controllers\ParentGroupListApiController;
|
||||||
|
use App\Domains\Admin\Controllers\ParentGroupUpdateController;
|
||||||
use App\Domains\Admin\Controllers\TenantContactGetController;
|
use App\Domains\Admin\Controllers\TenantContactGetController;
|
||||||
use App\Domains\Admin\Controllers\TenantContactUpdateController;
|
use App\Domains\Admin\Controllers\TenantContactUpdateController;
|
||||||
use App\Domains\Admin\Controllers\TenantCreateController;
|
use App\Domains\Admin\Controllers\TenantCreateController;
|
||||||
@@ -34,6 +45,7 @@ use App\Domains\Admin\Controllers\UserUpdateController;
|
|||||||
use App\Middleware\AdminRoleMiddleware;
|
use App\Middleware\AdminRoleMiddleware;
|
||||||
use App\Middleware\IdentifyTenant;
|
use App\Middleware\IdentifyTenant;
|
||||||
use App\Middleware\LvOnlyMiddleware;
|
use App\Middleware\LvOnlyMiddleware;
|
||||||
|
use App\Middleware\MainAdminRoleMiddleware;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->group(function () {
|
Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->group(function () {
|
||||||
@@ -60,6 +72,24 @@ Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->
|
|||||||
Route::post('/{id}/reset-password', UserResetPasswordController::class);
|
Route::post('/{id}/reset-password', UserResetPasswordController::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Dokumentvorlagen gelten app-weit für alle Mandanten -- deshalb nur für Hauptadministrator*innen,
|
||||||
|
// AdminRoleMiddleware allein ließe auch Gruppenleitungen durch.
|
||||||
|
Route::middleware(MainAdminRoleMiddleware::class)->group(function () {
|
||||||
|
Route::prefix('api/v1/admin/document-templates')->group(function () {
|
||||||
|
Route::get('/', DocumentTemplatesGetController::class);
|
||||||
|
Route::post('/', DocumentTemplatesUpdateController::class);
|
||||||
|
Route::post('/preview', DocumentTemplatesPreviewController::class);
|
||||||
|
Route::post('/assets', DocumentAssetUpdateController::class);
|
||||||
|
Route::delete('/assets/{name}', DocumentAssetDeleteController::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Bezeichnungen der Gruppen-Ebenen gelten ebenfalls app-weit.
|
||||||
|
Route::prefix('api/v1/admin/settings')->group(function () {
|
||||||
|
Route::get('/', GlobalSettingsGetController::class);
|
||||||
|
Route::post('/', GlobalSettingsUpdateController::class);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
Route::middleware(LvOnlyMiddleware::class)->group(function () {
|
Route::middleware(LvOnlyMiddleware::class)->group(function () {
|
||||||
Route::prefix('api/v1/admin/tenants')->group(function () {
|
Route::prefix('api/v1/admin/tenants')->group(function () {
|
||||||
Route::get('/list', TenantListApiController::class);
|
Route::get('/list', TenantListApiController::class);
|
||||||
@@ -79,5 +109,12 @@ Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->
|
|||||||
Route::post('/tax', ManagedTenantTaxUpdateController::class);
|
Route::post('/tax', ManagedTenantTaxUpdateController::class);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::prefix('api/v1/admin/parent-groups')->group(function () {
|
||||||
|
Route::get('/list', ParentGroupListApiController::class);
|
||||||
|
Route::post('/create', ParentGroupCreateController::class);
|
||||||
|
Route::post('/{id}', ParentGroupUpdateController::class)->whereNumber('id');
|
||||||
|
Route::delete('/{id}', ParentGroupDeleteController::class)->whereNumber('id');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Domains\Admin\Controllers\AdminDashboardController;
|
use App\Domains\Admin\Controllers\AdminDashboardController;
|
||||||
|
use App\Domains\Admin\Controllers\DocumentTemplatesPageController;
|
||||||
|
use App\Domains\Admin\Controllers\GlobalSettingsPageController;
|
||||||
|
use App\Domains\Admin\Controllers\ParentGroupListPageController;
|
||||||
use App\Domains\Admin\Controllers\TenantEditPageController;
|
use App\Domains\Admin\Controllers\TenantEditPageController;
|
||||||
use App\Domains\Admin\Controllers\TenantListPageController;
|
use App\Domains\Admin\Controllers\TenantListPageController;
|
||||||
use App\Domains\Admin\Controllers\TenantPageController;
|
use App\Domains\Admin\Controllers\TenantPageController;
|
||||||
@@ -8,6 +11,7 @@ use App\Domains\Admin\Controllers\UserListPageController;
|
|||||||
use App\Middleware\AdminRoleMiddleware;
|
use App\Middleware\AdminRoleMiddleware;
|
||||||
use App\Middleware\IdentifyTenant;
|
use App\Middleware\IdentifyTenant;
|
||||||
use App\Middleware\LvOnlyMiddleware;
|
use App\Middleware\LvOnlyMiddleware;
|
||||||
|
use App\Middleware\MainAdminRoleMiddleware;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->group(function () {
|
Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->group(function () {
|
||||||
@@ -16,9 +20,16 @@ Route::middleware([IdentifyTenant::class, 'auth', AdminRoleMiddleware::class])->
|
|||||||
Route::get('/tenant', TenantPageController::class);
|
Route::get('/tenant', TenantPageController::class);
|
||||||
Route::get('/users', UserListPageController::class);
|
Route::get('/users', UserListPageController::class);
|
||||||
|
|
||||||
|
// App-weit gültige Dokumentvorlagen -- nur für Hauptadministrator*innen.
|
||||||
|
Route::middleware(MainAdminRoleMiddleware::class)->group(function () {
|
||||||
|
Route::get('/document-templates', DocumentTemplatesPageController::class);
|
||||||
|
Route::get('/settings', GlobalSettingsPageController::class);
|
||||||
|
});
|
||||||
|
|
||||||
Route::middleware(LvOnlyMiddleware::class)->group(function () {
|
Route::middleware(LvOnlyMiddleware::class)->group(function () {
|
||||||
Route::get('/tenants', TenantListPageController::class);
|
Route::get('/tenants', TenantListPageController::class);
|
||||||
Route::get('/tenants/{slug}', TenantEditPageController::class);
|
Route::get('/tenants/{slug}', TenantEditPageController::class);
|
||||||
|
Route::get('/parent-groups', ParentGroupListPageController::class);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,666 @@
|
|||||||
|
<script setup>
|
||||||
|
import {computed, onMounted, ref} from 'vue'
|
||||||
|
import {toast} from 'vue3-toastify'
|
||||||
|
import AdminAppLayout from '../../../../resources/js/layouts/AdminAppLayout.vue'
|
||||||
|
import ShadowedBox from '../../../Views/Components/ShadowedBox.vue'
|
||||||
|
import TextEditor from '../../../Views/Components/TextEditor.vue'
|
||||||
|
import {useAjax} from '../../../../resources/js/components/ajaxHandler.js'
|
||||||
|
|
||||||
|
const {request} = useAjax()
|
||||||
|
|
||||||
|
const blocks = ref([])
|
||||||
|
const assets = ref([])
|
||||||
|
const tokenGroups = ref({})
|
||||||
|
|
||||||
|
// Die Vorlagen sind nach Dokumentart getrennt; der Umschalter lädt jeweils deren Blöcke neu.
|
||||||
|
const documentType = ref(null)
|
||||||
|
const documentTypes = ref([])
|
||||||
|
|
||||||
|
const activeBlock = ref(null)
|
||||||
|
const saving = ref(false)
|
||||||
|
|
||||||
|
// Die Vorschau ist ein PDF, das aus den aktuellen -- auch ungespeicherten -- Blockinhalten entsteht.
|
||||||
|
const previewUrl = ref(null)
|
||||||
|
const previewLoading = ref(false)
|
||||||
|
|
||||||
|
const newAsset = ref({name: '', label: '', file: null})
|
||||||
|
const assetInput = ref(null)
|
||||||
|
|
||||||
|
const current = computed(() => blocks.value.find(b => b.block === activeBlock.value) ?? null)
|
||||||
|
|
||||||
|
/** Beim Blockwechsel die gemerkte Einfügemarke verwerfen -- sie gehört zum vorigen Text. */
|
||||||
|
function selectBlock(block) {
|
||||||
|
activeBlock.value = block
|
||||||
|
caret.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load)
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
const query = documentType.value ? '?type=' + encodeURIComponent(documentType.value) : ''
|
||||||
|
const data = await request('/api/v1/admin/document-templates' + query, {method: 'GET'})
|
||||||
|
if (!data) {
|
||||||
|
toast.error('Die Vorlage konnte nicht geladen werden.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
documentType.value = data.documentType
|
||||||
|
documentTypes.value = data.documentTypes ?? []
|
||||||
|
blocks.value = data.blocks ?? []
|
||||||
|
assets.value = data.assets ?? []
|
||||||
|
tokenGroups.value = data.tokenGroups ?? {}
|
||||||
|
activeBlock.value = blocks.value.find(b => b.editable)?.block ?? blocks.value[0]?.block ?? null
|
||||||
|
|
||||||
|
await refreshPreview()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Beim Wechsel der Dokumentart alles neu holen -- Blöcke und Platzhalter sind je Art andere. */
|
||||||
|
async function selectDocumentType(type) {
|
||||||
|
if (type === documentType.value) return
|
||||||
|
|
||||||
|
documentType.value = type
|
||||||
|
caret.value = null
|
||||||
|
await load()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Nur editierbare Blöcke werden gesendet; der generierte Rechnungsinhalt bleibt unverändert. */
|
||||||
|
function editableBlocks() {
|
||||||
|
return Object.fromEntries(
|
||||||
|
blocks.value.filter(b => b.editable).map(b => [b.block, b.content ?? ''])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
saving.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await request('/api/v1/admin/document-templates', {
|
||||||
|
method: 'POST',
|
||||||
|
body: {type: documentType.value, blocks: editableBlocks()},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response?.status === 'success') {
|
||||||
|
toast.success(response.message)
|
||||||
|
} else {
|
||||||
|
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
saving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshPreview() {
|
||||||
|
previewLoading.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/v1/admin/document-templates/preview', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content ?? '',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({type: documentType.value, blocks: editableBlocks()}),
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
toast.error('Die Vorschau konnte nicht erzeugt werden.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previewUrl.value) {
|
||||||
|
URL.revokeObjectURL(previewUrl.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
previewUrl.value = URL.createObjectURL(await response.blob())
|
||||||
|
} finally {
|
||||||
|
previewLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platzhalter an der Einfügemarke ergänzen. Im WYSIWYG-Editor übernimmt das TinyMCE selbst, im
|
||||||
|
* Quelltext-Editor wird an der zuletzt bekannten Cursorposition eingesetzt.
|
||||||
|
*/
|
||||||
|
function insertToken(token) {
|
||||||
|
const block = current.value
|
||||||
|
if (!block) return
|
||||||
|
|
||||||
|
const placeholder = wrapForBlock('{' + token + '}', token, block)
|
||||||
|
|
||||||
|
if (block.source) {
|
||||||
|
insertIntoTextarea(placeholder)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const editor = window.tinymce?.activeEditor
|
||||||
|
if (editor) {
|
||||||
|
editor.execCommand('mceInsertContent', false, placeholder)
|
||||||
|
} else {
|
||||||
|
block.content = (block.content ?? '') + placeholder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Bild-Platzhalter allein ist nirgends sinnvoll: er expandiert zum nackten Data-URI, das dann als
|
||||||
|
* Zeichenkette im Dokument steht. Er braucht immer eine Hülle — im CSS url("..."), sonst ein <img>.
|
||||||
|
*
|
||||||
|
* Im CSS ist das zusätzlich eine Frage der Funktionsfähigkeit: ein Data-URI ausserhalb von url()
|
||||||
|
* kann dompdf nicht verarbeiten und läuft ins Zeitlimit.
|
||||||
|
*/
|
||||||
|
function wrapForBlock(placeholder, token, block) {
|
||||||
|
if (!token.startsWith('asset:')) {
|
||||||
|
return placeholder
|
||||||
|
}
|
||||||
|
|
||||||
|
return block.block === 'style'
|
||||||
|
? `url("${placeholder}")`
|
||||||
|
: `<img src="${placeholder}" alt="" />`
|
||||||
|
}
|
||||||
|
|
||||||
|
const sourceArea = ref(null)
|
||||||
|
// Zuletzt bekannte Einfügemarke im Quelltext-Feld. Ohne das würde ein Klick in der weit darunter
|
||||||
|
// liegenden Platzhalter- oder Bilder-Liste an unvorhersehbarer Stelle einfügen.
|
||||||
|
const caret = ref(null)
|
||||||
|
|
||||||
|
function rememberCaret() {
|
||||||
|
const area = sourceArea.value
|
||||||
|
if (!area) return
|
||||||
|
|
||||||
|
caret.value = {start: area.selectionStart, end: area.selectionEnd}
|
||||||
|
}
|
||||||
|
|
||||||
|
function insertIntoTextarea(text) {
|
||||||
|
const block = current.value
|
||||||
|
if (!block) return
|
||||||
|
|
||||||
|
const content = block.content ?? ''
|
||||||
|
const position = caret.value
|
||||||
|
|
||||||
|
if (position === null) {
|
||||||
|
block.content = content + text
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
block.content = content.slice(0, position.start) + text + content.slice(position.end)
|
||||||
|
caret.value = {start: position.start + text.length, end: position.start + text.length}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function uploadAsset() {
|
||||||
|
const form = new FormData()
|
||||||
|
form.append('name', newAsset.value.name)
|
||||||
|
form.append('label', newAsset.value.label ?? '')
|
||||||
|
if (newAsset.value.file) {
|
||||||
|
form.append('file', newAsset.value.file)
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await request('/api/v1/admin/document-templates/assets', {
|
||||||
|
method: 'POST',
|
||||||
|
body: form,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (result?.status === 'success') {
|
||||||
|
toast.success(result.message)
|
||||||
|
newAsset.value = {name: '', label: '', file: null}
|
||||||
|
if (assetInput.value) assetInput.value.value = ''
|
||||||
|
await load()
|
||||||
|
} else {
|
||||||
|
toast.error(result?.message ?? 'Fehler beim Hochladen')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteAsset(name) {
|
||||||
|
if (!confirm(`Das Bild „${name}" wirklich löschen?`)) return
|
||||||
|
|
||||||
|
const result = await request('/api/v1/admin/document-templates/assets/' + name, {method: 'DELETE'})
|
||||||
|
|
||||||
|
if (result?.status === 'success') {
|
||||||
|
toast.success(result.message)
|
||||||
|
await load()
|
||||||
|
} else {
|
||||||
|
// Ein noch in der Vorlage referenziertes Bild lehnt der Server ab.
|
||||||
|
toast.error(result?.message ?? 'Das Bild konnte nicht gelöscht werden.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyToken(token) {
|
||||||
|
navigator.clipboard?.writeText(token)
|
||||||
|
toast.success(`${token} kopiert`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFileChosen(event) {
|
||||||
|
newAsset.value.file = event.target.files?.[0] ?? null
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<AdminAppLayout title="Dokumentvorlagen">
|
||||||
|
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px;">
|
||||||
|
<p class="intro">
|
||||||
|
Die Vorlagen gelten für <strong>alle Mandanten</strong>; die eingesetzten Werte kommen je
|
||||||
|
Dokument aus dem jeweiligen Mandanten. Sie liegen in der Datenbank und werden von einem
|
||||||
|
Update nicht überschrieben.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="type-switch">
|
||||||
|
<label for="document-type">Dokumentart</label>
|
||||||
|
<select
|
||||||
|
id="document-type"
|
||||||
|
class="form-input"
|
||||||
|
:value="documentType"
|
||||||
|
@change="selectDocumentType($event.target.value)"
|
||||||
|
>
|
||||||
|
<option v-for="type in documentTypes" :key="type.value" :value="type.value">
|
||||||
|
{{ type.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="layout">
|
||||||
|
<!-- ── Blöcke und Editor ── -->
|
||||||
|
<div class="editor-column">
|
||||||
|
<div class="block-tabs">
|
||||||
|
<button
|
||||||
|
v-for="block in blocks"
|
||||||
|
:key="block.block"
|
||||||
|
class="block-tab"
|
||||||
|
:class="{active: block.block === activeBlock, readonly: !block.editable}"
|
||||||
|
@click="selectBlock(block.block)"
|
||||||
|
>
|
||||||
|
{{ block.label }}
|
||||||
|
<span v-if="!block.editable" class="badge">generiert</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="current" class="editor-panel">
|
||||||
|
<p v-if="!current.editable" class="notice">
|
||||||
|
Dieser Block wird beim Erzeugen des Dokuments aus den Daten der Anmeldung
|
||||||
|
zusammengesetzt und lässt sich nicht bearbeiten.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p v-else-if="current.source" class="notice">
|
||||||
|
Enthält den Seitenaufbau bzw. die Gestaltung und wird deshalb im Quelltext
|
||||||
|
bearbeitet. Für Adresse, Logo oder Fußnote ist das nicht nötig.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<textarea
|
||||||
|
v-if="current.source || !current.editable"
|
||||||
|
ref="sourceArea"
|
||||||
|
v-model="current.content"
|
||||||
|
class="source-editor"
|
||||||
|
:readonly="!current.editable"
|
||||||
|
spellcheck="false"
|
||||||
|
rows="24"
|
||||||
|
@click="rememberCaret"
|
||||||
|
@keyup="rememberCaret"
|
||||||
|
@blur="rememberCaret"
|
||||||
|
></textarea>
|
||||||
|
|
||||||
|
<!-- convert-urls aus: sonst schreibt TinyMCE {asset:...} in einem src um. -->
|
||||||
|
<TextEditor v-else v-model="current.content" :convert-urls="false" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="actions">
|
||||||
|
<button class="btn-save" :disabled="saving" @click="save">
|
||||||
|
{{ saving ? 'Wird gespeichert…' : 'Speichern' }}
|
||||||
|
</button>
|
||||||
|
<button class="btn-secondary" :disabled="previewLoading" @click="refreshPreview">
|
||||||
|
{{ previewLoading ? 'Wird erzeugt…' : 'Vorschau aktualisieren' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ── Platzhalter ── -->
|
||||||
|
<div class="tokens">
|
||||||
|
<h3>Platzhalter</h3>
|
||||||
|
<p class="tokens-hint">
|
||||||
|
Klicken fügt den Platzhalter an der Einfügemarke ein — in
|
||||||
|
<strong>{{ current?.label ?? '—' }}</strong>. Mit
|
||||||
|
<code>{if:name}…{/if:name}</code> lässt sich ein Abschnitt weglassen, solange
|
||||||
|
der Platzhalter leer ist.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div v-for="(group, key) in tokenGroups" :key="key" class="token-group">
|
||||||
|
<h4>{{ group.label }}</h4>
|
||||||
|
<button
|
||||||
|
v-for="(token, name) in group.tokens"
|
||||||
|
:key="name"
|
||||||
|
class="token"
|
||||||
|
:title="token.description"
|
||||||
|
@click="insertToken(name)"
|
||||||
|
>{{ '{' + name + '}' }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ── Bilder ── -->
|
||||||
|
<div class="assets">
|
||||||
|
<h3>Bilder</h3>
|
||||||
|
<p class="tokens-hint">
|
||||||
|
Liegen in der Datenbank, damit ein Update sie nicht überschreibt. „Einfügen"
|
||||||
|
schreibt in <strong>{{ current?.label ?? '—' }}</strong><template
|
||||||
|
v-if="current?.block === 'style'"> — im CSS als
|
||||||
|
<code>url("…")</code>, anders kann dompdf ein Bild dort nicht verarbeiten</template>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table class="asset-table">
|
||||||
|
<tr v-for="asset in assets" :key="asset.name">
|
||||||
|
<td class="asset-preview"><img :src="asset.preview" :alt="asset.name" /></td>
|
||||||
|
<td>
|
||||||
|
<strong>{{ asset.name }}</strong>
|
||||||
|
<span v-if="asset.label" class="asset-label">{{ asset.label }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code class="token-code" @click="copyToken(asset.token)">{{ asset.token }}</code>
|
||||||
|
</td>
|
||||||
|
<td class="asset-actions">
|
||||||
|
<button class="btn-link" @click="insertToken('asset:' + asset.name)">Einfügen</button>
|
||||||
|
<button class="btn-link danger" @click="deleteAsset(asset.name)">Löschen</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="asset-upload">
|
||||||
|
<input v-model="newAsset.name" type="text" placeholder="Name, z. B. logo" class="form-input" />
|
||||||
|
<input v-model="newAsset.label" type="text" placeholder="Beschreibung (optional)" class="form-input" />
|
||||||
|
<input ref="assetInput" type="file" accept="image/*" @change="onFileChosen" />
|
||||||
|
<button class="btn-secondary" :disabled="!newAsset.name" @click="uploadAsset">
|
||||||
|
Hochladen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ── Vorschau ── -->
|
||||||
|
<div class="preview-column">
|
||||||
|
<h3>Vorschau</h3>
|
||||||
|
<p class="tokens-hint">Mit Beispieldaten, ohne zu speichern.</p>
|
||||||
|
<iframe v-if="previewUrl" :src="previewUrl" class="preview-frame"></iframe>
|
||||||
|
<p v-else class="notice">Noch keine Vorschau erzeugt.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</shadowed-box>
|
||||||
|
</AdminAppLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.intro {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-left: 3px solid #f5c400;
|
||||||
|
background-color: #fffef5;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #4b5563;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-switch {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-switch label {
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: #4b5563;
|
||||||
|
}
|
||||||
|
|
||||||
|
.type-switch select {
|
||||||
|
width: auto;
|
||||||
|
min-width: 220px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layout {
|
||||||
|
display: flex;
|
||||||
|
gap: 24px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-column {
|
||||||
|
flex: 1 1 60%;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-column {
|
||||||
|
flex: 1 1 40%;
|
||||||
|
min-width: 320px;
|
||||||
|
position: sticky;
|
||||||
|
top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-tabs {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-tab {
|
||||||
|
padding: 6px 12px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 6px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-tab.active {
|
||||||
|
background-color: #1d4899;
|
||||||
|
border-color: #1d4899;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-tab.readonly {
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
margin-left: 6px;
|
||||||
|
padding: 1px 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background-color: #e5e7eb;
|
||||||
|
color: #4b5563;
|
||||||
|
font-size: 0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-tab.active .badge {
|
||||||
|
background-color: rgba(255, 255, 255, 0.25);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-panel {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notice {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-editor {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
box-sizing: border-box;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-editor[readonly] {
|
||||||
|
background-color: #f9fafb;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save, .btn-secondary {
|
||||||
|
padding: 8px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save {
|
||||||
|
background-color: #16a34a;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save:hover:not(:disabled) {
|
||||||
|
background-color: #15803d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
background-color: #e5e7eb;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover:not(:disabled) {
|
||||||
|
background-color: #d1d5db;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save:disabled, .btn-secondary:disabled {
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tokens, .assets {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tokens h3, .assets h3, .preview-column h3 {
|
||||||
|
margin-bottom: 6px;
|
||||||
|
font-size: 1rem;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tokens-hint {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tokens-hint code, .token-code {
|
||||||
|
padding: 1px 4px;
|
||||||
|
background-color: #f3f4f6;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-size: 0.95em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.token-group {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.token-group h4 {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: normal;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.token {
|
||||||
|
margin: 0 4px 4px 0;
|
||||||
|
padding: 3px 8px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: #f9fafb;
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
.token:hover {
|
||||||
|
background-color: #eef2ff;
|
||||||
|
border-color: #1d4899;
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-table td {
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-bottom: 1px solid #e5e7eb;
|
||||||
|
vertical-align: middle;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-preview img {
|
||||||
|
max-width: 60px;
|
||||||
|
max-height: 40px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.token-code {
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: 'DejaVu Sans Mono', Menlo, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-actions {
|
||||||
|
text-align: right;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-link {
|
||||||
|
padding: 2px 6px;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #1d4899;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-link.danger {
|
||||||
|
color: #b91c1c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-upload {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input {
|
||||||
|
padding: 6px 10px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-frame {
|
||||||
|
width: 100%;
|
||||||
|
height: 780px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 6px;
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1100px) {
|
||||||
|
.layout {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preview-column {
|
||||||
|
position: static;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
import AdminAppLayout from "../../../../resources/js/layouts/AdminAppLayout.vue";
|
||||||
|
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
||||||
|
import { useAjax } from "../../../../resources/js/components/ajaxHandler.js";
|
||||||
|
import { toast } from "vue3-toastify";
|
||||||
|
|
||||||
|
const { request } = useAjax()
|
||||||
|
|
||||||
|
const form = ref({
|
||||||
|
localGroup: '',
|
||||||
|
localGroupPlural: '',
|
||||||
|
parentGroup: '',
|
||||||
|
parentGroupPlural: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const response = await request('/api/v1/admin/settings')
|
||||||
|
Object.assign(form.value, response?.groupLabels ?? {})
|
||||||
|
})
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
const response = await request('/api/v1/admin/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
body: form.value,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response && response.status === 'success') {
|
||||||
|
toast.success(response.message)
|
||||||
|
} else {
|
||||||
|
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<AdminAppLayout title="Einstellungen">
|
||||||
|
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
||||||
|
<h3>Bezeichnungen der Gruppen</h3>
|
||||||
|
<p class="hint">
|
||||||
|
Gelten für alle Mandanten: in Anmeldungen, Teilnehmendenlisten, Exporten und in der Verwaltung.
|
||||||
|
</p>
|
||||||
|
<table class="data-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>Einzahl</th>
|
||||||
|
<th>Mehrzahl</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Gruppe (Mandant)</th>
|
||||||
|
<td><input type="text" v-model="form.localGroup" class="form-input" placeholder="z. B. Stamm" /></td>
|
||||||
|
<td><input type="text" v-model="form.localGroupPlural" class="form-input" placeholder="z. B. Stämme" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Übergeordnete Gruppe</th>
|
||||||
|
<td><input type="text" v-model="form.parentGroup" class="form-input" placeholder="z. B. Bund" /></td>
|
||||||
|
<td><input type="text" v-model="form.parentGroupPlural" class="form-input" placeholder="z. B. Bünde" /></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<button class="btn-save" @click="save">Speichern</button>
|
||||||
|
</shadowed-box>
|
||||||
|
</AdminAppLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.hint {
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-table th {
|
||||||
|
text-align: left;
|
||||||
|
padding: 8px 12px;
|
||||||
|
color: #374151;
|
||||||
|
border-bottom: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-table td {
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-bottom: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save {
|
||||||
|
margin-top: 15px;
|
||||||
|
padding: 8px 20px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
background-color: #16a34a;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save:hover {
|
||||||
|
background-color: #15803d;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
import AdminAppLayout from "../../../../resources/js/layouts/AdminAppLayout.vue";
|
||||||
|
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
||||||
|
import { useAjax } from "../../../../resources/js/components/ajaxHandler.js";
|
||||||
|
import { toast } from "vue3-toastify";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
groupLabels: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({ localGroupPlural: 'Stämme', parentGroup: 'Bund', parentGroupPlural: 'Bünde' }),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const { request } = useAjax()
|
||||||
|
|
||||||
|
const parentGroups = ref([])
|
||||||
|
const newName = ref('')
|
||||||
|
const showCreate = ref(false)
|
||||||
|
// ID des Eintrags, der gerade umbenannt wird, samt Entwurf des neuen Namens.
|
||||||
|
const editingId = ref(null)
|
||||||
|
const editName = ref('')
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadParentGroups()
|
||||||
|
})
|
||||||
|
|
||||||
|
async function loadParentGroups() {
|
||||||
|
const response = await request('/api/v1/admin/parent-groups/list')
|
||||||
|
parentGroups.value = response?.parentGroups ?? []
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createParentGroup() {
|
||||||
|
const response = await request('/api/v1/admin/parent-groups/create', {
|
||||||
|
method: 'POST',
|
||||||
|
body: { name: newName.value },
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response && response.status === 'success') {
|
||||||
|
toast.success(response.message)
|
||||||
|
newName.value = ''
|
||||||
|
showCreate.value = false
|
||||||
|
await loadParentGroups()
|
||||||
|
} else {
|
||||||
|
toast.error(response?.message ?? 'Fehler beim Anlegen')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function startEditing(parentGroup) {
|
||||||
|
editingId.value = parentGroup.id
|
||||||
|
editName.value = parentGroup.name
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveName(parentGroup) {
|
||||||
|
const response = await request('/api/v1/admin/parent-groups/' + parentGroup.id, {
|
||||||
|
method: 'POST',
|
||||||
|
body: { name: editName.value },
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response && response.status === 'success') {
|
||||||
|
toast.success(response.message)
|
||||||
|
editingId.value = null
|
||||||
|
await loadParentGroups()
|
||||||
|
} else {
|
||||||
|
toast.error(response?.message ?? 'Fehler beim Speichern')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteParentGroup(parentGroup) {
|
||||||
|
if (!confirm('„' + parentGroup.name + '" wirklich löschen?')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await request('/api/v1/admin/parent-groups/' + parentGroup.id, {
|
||||||
|
method: 'DELETE',
|
||||||
|
})
|
||||||
|
|
||||||
|
if (response && response.status === 'success') {
|
||||||
|
toast.success(response.message)
|
||||||
|
await loadParentGroups()
|
||||||
|
} else {
|
||||||
|
toast.error(response?.message ?? 'Fehler beim Löschen')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<AdminAppLayout :title="props.groupLabels.parentGroupPlural">
|
||||||
|
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
||||||
|
<table class="parent-group-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Zugeordnete {{ props.groupLabels.localGroupPlural }}</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="parentGroup in parentGroups" :key="parentGroup.id">
|
||||||
|
<td>
|
||||||
|
<input v-if="editingId === parentGroup.id" type="text" v-model="editName" class="form-input"
|
||||||
|
@keyup.enter="saveName(parentGroup)" />
|
||||||
|
<span v-else>{{ parentGroup.name }}</span>
|
||||||
|
</td>
|
||||||
|
<td>{{ parentGroup.tenantCount }}</td>
|
||||||
|
<td class="actions">
|
||||||
|
<template v-if="editingId === parentGroup.id">
|
||||||
|
<button class="btn-save" @click="saveName(parentGroup)">Speichern</button>
|
||||||
|
<button class="btn-cancel" @click="editingId = null">Abbrechen</button>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<button class="btn-edit" @click="startEditing(parentGroup)">Umbenennen</button>
|
||||||
|
<button v-if="parentGroup.deletable" class="btn-delete" @click="deleteParentGroup(parentGroup)">Löschen</button>
|
||||||
|
</template>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p class="hint">
|
||||||
|
Löschen ist nur möglich, solange keine {{ props.groupLabels.localGroupPlural }} und keine Anmeldungen
|
||||||
|
zugeordnet sind. „Ohne Zuordnung" bleibt immer bestehen.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div style="margin-top: 20px;">
|
||||||
|
<button v-if="!showCreate" class="btn-create" @click="showCreate = true">Neuen Eintrag anlegen</button>
|
||||||
|
|
||||||
|
<div v-if="showCreate" class="create-form">
|
||||||
|
<h3>Neuen Eintrag anlegen ({{ props.groupLabels.parentGroup }})</h3>
|
||||||
|
<input type="text" v-model="newName" class="form-input" placeholder="Name"
|
||||||
|
@keyup.enter="createParentGroup" />
|
||||||
|
<div class="btn-group">
|
||||||
|
<button class="btn-save" @click="createParentGroup">Anlegen</button>
|
||||||
|
<button class="btn-cancel" @click="showCreate = false">Abbrechen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</shadowed-box>
|
||||||
|
</AdminAppLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.parent-group-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.parent-group-table thead th {
|
||||||
|
text-align: left;
|
||||||
|
padding: 10px 16px;
|
||||||
|
background-color: #f9fafb;
|
||||||
|
color: #374151;
|
||||||
|
font-weight: bold;
|
||||||
|
border-bottom: 2px solid #d1d5db;
|
||||||
|
}
|
||||||
|
|
||||||
|
.parent-group-table tbody td {
|
||||||
|
padding: 10px 16px;
|
||||||
|
border-bottom: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hint {
|
||||||
|
margin-top: 12px;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.create-form {
|
||||||
|
margin-top: 15px;
|
||||||
|
padding: 20px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: #f9fafb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.create-form h3 {
|
||||||
|
margin: 0 0 15px 0;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 6px 10px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-group {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-create, .btn-save, .btn-cancel, .btn-edit, .btn-delete {
|
||||||
|
padding: 6px 16px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-create, .btn-edit {
|
||||||
|
background-color: #1d4899;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-create:hover, .btn-edit:hover {
|
||||||
|
background-color: #163a7a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save {
|
||||||
|
background-color: #16a34a;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-save:hover {
|
||||||
|
background-color: #15803d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-cancel {
|
||||||
|
background-color: #e5e7eb;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-cancel:hover {
|
||||||
|
background-color: #d1d5db;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-delete {
|
||||||
|
background-color: #dc2626;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-delete:hover {
|
||||||
|
background-color: #b91c1c;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -13,9 +13,17 @@ const props = defineProps({
|
|||||||
const { request } = useAjax()
|
const { request } = useAjax()
|
||||||
|
|
||||||
const editing = ref(false)
|
const editing = ref(false)
|
||||||
|
// Solange kein eigener Absender eingetragen ist, steht auf der Rechnung der Name des Mandanten.
|
||||||
|
const senderFallback = props.data.name ?? ''
|
||||||
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
|
invoice_sender_name: props.data.invoice_sender_name ?? '',
|
||||||
email: props.data.email ?? '',
|
email: props.data.email ?? '',
|
||||||
email_finance: props.data.email_finance ?? '',
|
email_finance: props.data.email_finance ?? '',
|
||||||
|
phone: props.data.phone ?? '',
|
||||||
|
address_1: props.data.address_1 ?? '',
|
||||||
|
address_2: props.data.address_2 ?? '',
|
||||||
|
address_3: props.data.address_3 ?? '',
|
||||||
postcode: props.data.postcode ?? '',
|
postcode: props.data.postcode ?? '',
|
||||||
city: props.data.city ?? '',
|
city: props.data.city ?? '',
|
||||||
})
|
})
|
||||||
@@ -39,16 +47,49 @@ async function save() {
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="!editing">
|
<div v-if="!editing">
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
|
<tr>
|
||||||
|
<th>Rechnungs-Absender:</th>
|
||||||
|
<td>
|
||||||
|
{{ form.invoice_sender_name || senderFallback }}
|
||||||
|
<span v-if="!form.invoice_sender_name" class="field-hint">
|
||||||
|
Name des Mandanten, da nichts Eigenes hinterlegt ist
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr><th>Email:</th><td>{{ form.email }}</td></tr>
|
<tr><th>Email:</th><td>{{ form.email }}</td></tr>
|
||||||
<tr><th>Email Schatzmeister*in:</th><td>{{ form.email_finance }}</td></tr>
|
<tr><th>Email Schatzmeister*in:</th><td>{{ form.email_finance }}</td></tr>
|
||||||
|
<tr><th>Telefon:</th><td>{{ form.phone || '—' }}</td></tr>
|
||||||
|
<tr><th>Straße & Hausnummer:</th><td>{{ form.address_1 || '—' }}</td></tr>
|
||||||
|
<tr><th>Adresszusatz:</th><td>{{ form.address_2 || '—' }}</td></tr>
|
||||||
|
<tr><th>Weiterer Zusatz:</th><td>{{ form.address_3 || '—' }}</td></tr>
|
||||||
<tr><th>Postleitzahl:</th><td>{{ form.postcode }}</td></tr>
|
<tr><th>Postleitzahl:</th><td>{{ form.postcode }}</td></tr>
|
||||||
<tr><th>Ort:</th><td>{{ form.city }}</td></tr>
|
<tr><th>Ort:</th><td>{{ form.city }}</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<p v-if="!form.address_1" class="hint">
|
||||||
|
Ohne Straße & Hausnummer ist die Anschrift auf Rechnungen unvollständig
|
||||||
|
(§ 14 Abs. 4 UStG).
|
||||||
|
</p>
|
||||||
<button class="btn-edit" @click="editing = true">Bearbeiten</button>
|
<button class="btn-edit" @click="editing = true">Bearbeiten</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
|
<tr>
|
||||||
|
<th>Rechnungs-Absender:</th>
|
||||||
|
<td>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="form.invoice_sender_name"
|
||||||
|
class="form-input"
|
||||||
|
:placeholder="senderFallback"
|
||||||
|
/>
|
||||||
|
<span class="field-hint">
|
||||||
|
Vollständige Bezeichnung mit Rechtsform, wie sie auf der Rechnung stehen soll.
|
||||||
|
Leer lassen, um den Namen des Mandanten zu verwenden.
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Email:</th>
|
<th>Email:</th>
|
||||||
<td><input type="email" v-model="form.email" class="form-input" /></td>
|
<td><input type="email" v-model="form.email" class="form-input" /></td>
|
||||||
@@ -57,6 +98,27 @@ async function save() {
|
|||||||
<th>Email Schatzmeister*in:</th>
|
<th>Email Schatzmeister*in:</th>
|
||||||
<td><input type="email" v-model="form.email_finance" class="form-input" /></td>
|
<td><input type="email" v-model="form.email_finance" class="form-input" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Telefon:</th>
|
||||||
|
<td><input type="text" v-model="form.phone" class="form-input" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Straße & Hausnummer:</th>
|
||||||
|
<td>
|
||||||
|
<input type="text" v-model="form.address_1" class="form-input" />
|
||||||
|
<span class="field-hint">Pflichtangabe für Rechnungen (§ 14 Abs. 4 UStG)</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Adresszusatz:</th>
|
||||||
|
<td>
|
||||||
|
<input type="text" v-model="form.address_2" class="form-input" placeholder="z. B. c/o Mustermensch" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Weiterer Zusatz:</th>
|
||||||
|
<td><input type="text" v-model="form.address_3" class="form-input" /></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Postleitzahl:</th>
|
<th>Postleitzahl:</th>
|
||||||
<td><input type="text" v-model="form.postcode" class="form-input" /></td>
|
<td><input type="text" v-model="form.postcode" class="form-input" /></td>
|
||||||
@@ -101,6 +163,22 @@ async function save() {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.field-hint {
|
||||||
|
display: block;
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hint {
|
||||||
|
margin-top: 12px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-left: 3px solid #f5c400;
|
||||||
|
background-color: #fffef5;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
color: #4b5563;
|
||||||
|
}
|
||||||
|
|
||||||
.btn-edit, .btn-save, .btn-cancel {
|
.btn-edit, .btn-save, .btn-cancel {
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
padding: 8px 20px;
|
padding: 8px 20px;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
|
import { useAjax } from "../../../../../resources/js/components/ajaxHandler.js";
|
||||||
import { toast } from "vue3-toastify";
|
import { toast } from "vue3-toastify";
|
||||||
|
|
||||||
@@ -17,8 +17,16 @@ const form = ref({
|
|||||||
name: props.data.name ?? '',
|
name: props.data.name ?? '',
|
||||||
slug: props.data.slug ?? '',
|
slug: props.data.slug ?? '',
|
||||||
url: props.data.url ?? '',
|
url: props.data.url ?? '',
|
||||||
|
parent_group_id: props.data.parent_group_id ?? null,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Übergeordnete Gruppe (z. B. „Bund") -- Pflichtangabe, Auswahl aus der LV-seitig gepflegten Liste.
|
||||||
|
const parentGroups = props.data.parentGroups ?? []
|
||||||
|
const parentGroupLabel = props.data.parentGroupLabel ?? 'Bund'
|
||||||
|
const parentGroupName = computed(() =>
|
||||||
|
parentGroups.find(g => g.id === form.value.parent_group_id)?.name ?? '—'
|
||||||
|
)
|
||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
const saveUrl = props.data.saveEndpoint ?? '/api/v1/admin/tenants/' + props.data.slug + '/general'
|
const saveUrl = props.data.saveEndpoint ?? '/api/v1/admin/tenants/' + props.data.slug + '/general'
|
||||||
const response = await request(saveUrl, {
|
const response = await request(saveUrl, {
|
||||||
@@ -39,6 +47,7 @@ async function save() {
|
|||||||
<div v-if="!editing">
|
<div v-if="!editing">
|
||||||
<table class="data-table">
|
<table class="data-table">
|
||||||
<tr><th>Name:</th><td>{{ form.name }}</td></tr>
|
<tr><th>Name:</th><td>{{ form.name }}</td></tr>
|
||||||
|
<tr><th>{{ parentGroupLabel }}:</th><td>{{ parentGroupName }}</td></tr>
|
||||||
<tr><th>Slug:</th><td>{{ form.slug }}</td></tr>
|
<tr><th>Slug:</th><td>{{ form.slug }}</td></tr>
|
||||||
<tr><th>URL:</th><td>{{ form.url }}</td></tr>
|
<tr><th>URL:</th><td>{{ form.url }}</td></tr>
|
||||||
<tr><th>Status:</th><td>
|
<tr><th>Status:</th><td>
|
||||||
@@ -54,6 +63,14 @@ async function save() {
|
|||||||
<th>Name:</th>
|
<th>Name:</th>
|
||||||
<td><input type="text" v-model="form.name" class="form-input" /></td>
|
<td><input type="text" v-model="form.name" class="form-input" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>{{ parentGroupLabel }}:</th>
|
||||||
|
<td>
|
||||||
|
<select v-model="form.parent_group_id" class="form-input">
|
||||||
|
<option v-for="group in parentGroups" :key="group.id" :value="group.id">{{ group.name }}</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Slug:</th>
|
<th>Slug:</th>
|
||||||
<td><input type="text" v-model="form.slug" class="form-input" /></td>
|
<td><input type="text" v-model="form.slug" class="form-input" /></td>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {computed, ref} from 'vue';
|
import {computed, ref} from 'vue';
|
||||||
|
import BankRulesetEditor from "../../../../Views/Components/BankRulesetEditor.vue";
|
||||||
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
||||||
import TextEditor from "../../../../Views/Components/TextEditor.vue";
|
import TextEditor from "../../../../Views/Components/TextEditor.vue";
|
||||||
import RichSelectBox from "../../../../Views/Components/RichSelectBox.vue";
|
import RichSelectBox from "../../../../Views/Components/RichSelectBox.vue";
|
||||||
@@ -102,6 +103,12 @@ async function save() {
|
|||||||
<RichSelectBox v-if="option.type === 'icon'" v-model="form.configuration[option.name]"
|
<RichSelectBox v-if="option.type === 'icon'" v-model="form.configuration[option.name]"
|
||||||
:options="PAYMENT_METHOD_ICONS" placeholder="Symbol wählen…"/>
|
:options="PAYMENT_METHOD_ICONS" placeholder="Symbol wählen…"/>
|
||||||
<TextEditor v-else-if="option.type === 'richtext'" v-model="form.configuration[option.name]"/>
|
<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-if="option.type === 'number'" type="number" step="1"
|
||||||
|
v-model="form.configuration[option.name]" class="form-input"/>
|
||||||
<input v-else type="text" v-model="form.configuration[option.name]" class="form-input"/>
|
<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>
|
<span v-if="option.hint" class="option-hint">{{ option.hint }}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -29,8 +29,15 @@ const form = ref({
|
|||||||
tax_exemption_reason: props.data.tax_exemption_reason ?? '',
|
tax_exemption_reason: props.data.tax_exemption_reason ?? '',
|
||||||
tax_exemption_note: props.data.tax_exemption_note ?? '',
|
tax_exemption_note: props.data.tax_exemption_note ?? '',
|
||||||
vat_pricing_mode: props.data.vat_pricing_mode ?? 'inclusive',
|
vat_pricing_mode: props.data.vat_pricing_mode ?? 'inclusive',
|
||||||
|
tax_number: props.data.tax_number ?? '',
|
||||||
|
vat_id: props.data.vat_id ?? '',
|
||||||
|
invoice_prefix: props.data.invoice_prefix ?? '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Das Präfix bestimmt den Nummernkreis und darf sich nachträglich nicht ändern -- sonst gehörten bereits
|
||||||
|
// herausgegebene Rechnungen plötzlich zu einer anderen Nummer. Nur in der verwalteten Ansicht editierbar.
|
||||||
|
const canEditPrefix = computed(() => props.data.can_edit_invoice_prefix === true)
|
||||||
|
|
||||||
const isLiable = computed(() => form.value.tax_liable === '1')
|
const isLiable = computed(() => form.value.tax_liable === '1')
|
||||||
const isCustomReason = computed(() => form.value.tax_exemption_reason === 'custom')
|
const isCustomReason = computed(() => form.value.tax_exemption_reason === 'custom')
|
||||||
|
|
||||||
@@ -65,6 +72,9 @@ async function save() {
|
|||||||
tax_exemption_reason: isLiable.value ? null : form.value.tax_exemption_reason,
|
tax_exemption_reason: isLiable.value ? null : form.value.tax_exemption_reason,
|
||||||
tax_exemption_note: form.value.tax_exemption_note,
|
tax_exemption_note: form.value.tax_exemption_note,
|
||||||
vat_pricing_mode: form.value.vat_pricing_mode,
|
vat_pricing_mode: form.value.vat_pricing_mode,
|
||||||
|
tax_number: form.value.tax_number,
|
||||||
|
vat_id: form.value.vat_id,
|
||||||
|
invoice_prefix: canEditPrefix.value ? form.value.invoice_prefix : undefined,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -100,6 +110,18 @@ async function save() {
|
|||||||
<th>Rechnungshinweis</th>
|
<th>Rechnungshinweis</th>
|
||||||
<td>{{ invoiceHint }}</td>
|
<td>{{ invoiceHint }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Steuernummer</th>
|
||||||
|
<td>{{ form.tax_number || '—' }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>USt-IdNr.</th>
|
||||||
|
<td>{{ form.vat_id || '—' }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Rechnungs-Präfix</th>
|
||||||
|
<td>{{ form.invoice_prefix || '—' }}</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<button class="btn-edit" @click="editing = true">Bearbeiten</button>
|
<button class="btn-edit" @click="editing = true">Bearbeiten</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -152,6 +174,42 @@ async function save() {
|
|||||||
<th>Rechnungshinweis</th>
|
<th>Rechnungshinweis</th>
|
||||||
<td class="hint-preview">{{ invoiceHint }}</td>
|
<td class="hint-preview">{{ invoiceHint }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>Steuernummer</th>
|
||||||
|
<td>
|
||||||
|
<input type="text" v-model="form.tax_number" class="form-input" />
|
||||||
|
<span class="field-hint">
|
||||||
|
Pflichtangabe auf Rechnungen — alternativ die USt-IdNr. (§ 14 Abs. 4 Nr. 2 UStG)
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>USt-IdNr.</th>
|
||||||
|
<td><input type="text" v-model="form.vat_id" class="form-input" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Rechnungs-Präfix</th>
|
||||||
|
<td>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="form.invoice_prefix"
|
||||||
|
class="form-input"
|
||||||
|
:disabled="!canEditPrefix"
|
||||||
|
/>
|
||||||
|
<span class="field-hint">
|
||||||
|
Erster Block der Rechnungsnummer, z. B. <code>WM</code> in
|
||||||
|
<code>WM-V-20260701-0005</code>.
|
||||||
|
<template v-if="canEditPrefix">
|
||||||
|
Eine Änderung wirkt nur auf künftige Veranstaltungen; bereits angelegte behalten
|
||||||
|
ihre Nummer.
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
Änderbar nur in der Mandanten-Verwaltung.
|
||||||
|
</template>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<button class="btn-save" @click="save">Speichern</button>
|
<button class="btn-save" @click="save">Speichern</button>
|
||||||
@@ -195,6 +253,25 @@ async function save() {
|
|||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.field-hint {
|
||||||
|
display: block;
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-hint code {
|
||||||
|
padding: 1px 4px;
|
||||||
|
background-color: #f3f4f6;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-size: 0.95em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input:disabled {
|
||||||
|
background-color: #f3f4f6;
|
||||||
|
color: #6b7280;
|
||||||
|
}
|
||||||
|
|
||||||
.btn-edit, .btn-save, .btn-cancel {
|
.btn-edit, .btn-save, .btn-cancel {
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
padding: 8px 20px;
|
padding: 8px 20px;
|
||||||
|
|||||||
@@ -5,6 +5,13 @@ import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
|
|||||||
import { useAjax } from "../../../../resources/js/components/ajaxHandler.js";
|
import { useAjax } from "../../../../resources/js/components/ajaxHandler.js";
|
||||||
import { toast } from "vue3-toastify";
|
import { toast } from "vue3-toastify";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
groupLabels: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({ localGroup: 'Stamm', localGroupPlural: 'Stämme', parentGroup: 'Bund' }),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const { request } = useAjax()
|
const { request } = useAjax()
|
||||||
|
|
||||||
function openTenant(slug) {
|
function openTenant(slug) {
|
||||||
@@ -12,12 +19,16 @@ function openTenant(slug) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const tenants = ref([])
|
const tenants = ref([])
|
||||||
|
const parentGroups = ref([])
|
||||||
const showCreate = ref(false)
|
const showCreate = ref(false)
|
||||||
const createForm = ref({
|
const emptyForm = () => ({
|
||||||
name: '',
|
name: '',
|
||||||
slug: '',
|
slug: '',
|
||||||
url: '',
|
url: '',
|
||||||
|
// Pflichtangabe; vorbelegt mit „Ohne Zuordnung", sobald die Liste geladen ist.
|
||||||
|
parent_group_id: parentGroups.value.find(g => g.isFallback)?.id ?? null,
|
||||||
})
|
})
|
||||||
|
const createForm = ref(emptyForm())
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await loadTenants()
|
await loadTenants()
|
||||||
@@ -33,6 +44,11 @@ async function loadTenants() {
|
|||||||
})
|
})
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
tenants.value = data.tenants
|
tenants.value = data.tenants
|
||||||
|
parentGroups.value = data.parentGroups ?? []
|
||||||
|
|
||||||
|
if (createForm.value.parent_group_id === null) {
|
||||||
|
createForm.value.parent_group_id = parentGroups.value.find(g => g.isFallback)?.id ?? null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createTenant() {
|
async function createTenant() {
|
||||||
@@ -44,7 +60,7 @@ async function createTenant() {
|
|||||||
if (response && response.status === 'success') {
|
if (response && response.status === 'success') {
|
||||||
toast.success(response.message)
|
toast.success(response.message)
|
||||||
showCreate.value = false
|
showCreate.value = false
|
||||||
createForm.value = { name: '', slug: '', url: '' }
|
createForm.value = emptyForm()
|
||||||
await loadTenants()
|
await loadTenants()
|
||||||
} else {
|
} else {
|
||||||
toast.error(response?.message ?? 'Fehler beim Anlegen')
|
toast.error(response?.message ?? 'Fehler beim Anlegen')
|
||||||
@@ -53,12 +69,13 @@ async function createTenant() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AdminAppLayout title="Stämme">
|
<AdminAppLayout :title="props.groupLabels.localGroupPlural">
|
||||||
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
|
||||||
<table class="tenant-table">
|
<table class="tenant-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
<th>{{ props.groupLabels.parentGroup }}</th>
|
||||||
<th>Slug</th>
|
<th>Slug</th>
|
||||||
<th>URL</th>
|
<th>URL</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
@@ -67,6 +84,7 @@ async function createTenant() {
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="tenant in tenants" :key="tenant.slug" class="tenant-row" @click="openTenant(tenant.slug)">
|
<tr v-for="tenant in tenants" :key="tenant.slug" class="tenant-row" @click="openTenant(tenant.slug)">
|
||||||
<td>{{ tenant.name }}</td>
|
<td>{{ tenant.name }}</td>
|
||||||
|
<td>{{ tenant.parentGroup ?? '—' }}</td>
|
||||||
<td>{{ tenant.slug }}</td>
|
<td>{{ tenant.slug }}</td>
|
||||||
<td>{{ tenant.url }}</td>
|
<td>{{ tenant.url }}</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -79,15 +97,23 @@ async function createTenant() {
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div style="margin-top: 20px;">
|
<div style="margin-top: 20px;">
|
||||||
<button v-if="!showCreate" class="btn-create" @click="showCreate = true">Neuen Stamm anlegen</button>
|
<button v-if="!showCreate" class="btn-create" @click="showCreate = true">Neuen Eintrag anlegen ({{ props.groupLabels.localGroup }})</button>
|
||||||
|
|
||||||
<div v-if="showCreate" class="create-form">
|
<div v-if="showCreate" class="create-form">
|
||||||
<h3>Neuen Stamm anlegen</h3>
|
<h3>Neuen Eintrag anlegen ({{ props.groupLabels.localGroup }})</h3>
|
||||||
<table class="form-table">
|
<table class="form-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<td><input type="text" v-model="createForm.name" class="form-input" /></td>
|
<td><input type="text" v-model="createForm.name" class="form-input" /></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>{{ props.groupLabels.parentGroup }}</th>
|
||||||
|
<td>
|
||||||
|
<select v-model="createForm.parent_group_id" class="form-input">
|
||||||
|
<option v-for="group in parentGroups" :key="group.id" :value="group.id">{{ group.name }}</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Slug</th>
|
<th>Slug</th>
|
||||||
<td><input type="text" v-model="createForm.slug" class="form-input" /></td>
|
<td><input type="text" v-model="createForm.slug" class="form-input" /></td>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class CreateEstimateAction {
|
|||||||
|
|
||||||
if ($this->request->estimateId === 0) {
|
if ($this->request->estimateId === 0) {
|
||||||
$estimate = CostUnitEstimate::create(array_merge([
|
$estimate = CostUnitEstimate::create(array_merge([
|
||||||
'tenant' => app('tenant')->slug,
|
'tenant' => currentTenant()->slug,
|
||||||
'cost_unit_id' => $this->request->costUnit->id,
|
'cost_unit_id' => $this->request->costUnit->id,
|
||||||
'type' => $this->request->estimateType,
|
'type' => $this->request->estimateType,
|
||||||
'description' => $this->request->description,
|
'description' => $this->request->description,
|
||||||
@@ -33,7 +33,7 @@ class CreateEstimateAction {
|
|||||||
} else {
|
} else {
|
||||||
$estimate = CostUnitEstimate::find($this->request->estimateId);
|
$estimate = CostUnitEstimate::find($this->request->estimateId);
|
||||||
$estimate->update(array_merge([
|
$estimate->update(array_merge([
|
||||||
'tenant' => app('tenant')->slug,
|
'tenant' => currentTenant()->slug,
|
||||||
'cost_unit_id' => $this->request->costUnit->id,
|
'cost_unit_id' => $this->request->costUnit->id,
|
||||||
'type' => $this->request->estimateType,
|
'type' => $this->request->estimateType,
|
||||||
'description' => $this->request->description,
|
'description' => $this->request->description,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class ChangeCostUnitDetailsCommand {
|
|||||||
|
|
||||||
$this->request->costUnit->distance_allowance = $this->request->distanceAllowance->getAmount();
|
$this->request->costUnit->distance_allowance = $this->request->distanceAllowance->getAmount();
|
||||||
$this->request->costUnit->mail_on_new = $this->request->mailOnNew;
|
$this->request->costUnit->mail_on_new = $this->request->mailOnNew;
|
||||||
$this->request->costUnit->billing_deadline = $this->request->billingDeadline;
|
$this->request->costUnit->billing_deadline = $this->request->billingDeadline?->format('Y-m-d');
|
||||||
|
|
||||||
$response->success = $this->request->costUnit->save();
|
$response->success = $this->request->costUnit->save();
|
||||||
return $response;
|
return $response;
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ class CreateCostUnitCommand {
|
|||||||
$response = new CreateCostUnitResponse();
|
$response = new CreateCostUnitResponse();
|
||||||
$costUnit = CostUnit::create([
|
$costUnit = CostUnit::create([
|
||||||
'name' => $this->request->name,
|
'name' => $this->request->name,
|
||||||
'tenant' => app('tenant')->slug,
|
'tenant' => currentTenant()->slug,
|
||||||
'type' => $this->request->type,
|
'type' => $this->request->type,
|
||||||
'billing_deadline' => $this->request->billingDeadline,
|
'billing_deadline' => $this->request->billingDeadline?->format('Y-m-d'),
|
||||||
'distance_allowance' => $this->request->distanceAllowance->getAmount(),
|
'distance_allowance' => $this->request->distanceAllowance->getAmount(),
|
||||||
'mail_on_new' => $this->request->mailOnNew,
|
'mail_on_new' => $this->request->mailOnNew,
|
||||||
'allow_new' => true,
|
'allow_new' => true,
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ class EditController extends CommonController{
|
|||||||
|
|
||||||
$saveParams = $request->get('formData');
|
$saveParams = $request->get('formData');
|
||||||
$distanceAllowance = Amount::fromString($saveParams['distanceAllowance']);
|
$distanceAllowance = Amount::fromString($saveParams['distanceAllowance']);
|
||||||
$billingDeadline = isset($saveParams['billingDeadline']) ? \DateTime::createFromFormat('Y-m-d', $saveParams['billingDeadline']) : null;
|
$rawBillingDeadline = $saveParams['billingDeadline'] ?? null;
|
||||||
|
$billingDeadline = !empty($rawBillingDeadline)
|
||||||
|
? (\DateTime::createFromFormat('!Y-m-d', $rawBillingDeadline) ?: null)
|
||||||
|
: null;
|
||||||
|
|
||||||
$request = new ChangeCostUnitDetailsRequest($costUnit, $distanceAllowance, $saveParams['mailOnNew'], $billingDeadline);
|
$request = new ChangeCostUnitDetailsRequest($costUnit, $distanceAllowance, $saveParams['mailOnNew'], $billingDeadline);
|
||||||
$command = new ChangeCostUnitDetailsCommand($request);
|
$command = new ChangeCostUnitDetailsCommand($request);
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class ExportController extends CommonController {
|
|||||||
'amount' => $invoice->amount,
|
'amount' => $invoice->amount,
|
||||||
'recipient_name' => $invoice->contact_bank_owner,
|
'recipient_name' => $invoice->contact_bank_owner,
|
||||||
'recipient_iban' => $invoice->contact_bank_iban,
|
'recipient_iban' => $invoice->contact_bank_iban,
|
||||||
'payment_purpose' => $invoice->payment_purpose ?? 'Auslagenerstattung Rechnungsnummer ' . $invoice->invoice_number,
|
'payment_purpose' => $invoice->paymentPurposeText(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
use App\Domains\CostUnit\Controllers\CreateController;
|
use App\Domains\CostUnit\Controllers\CreateController;
|
||||||
use App\Domains\CostUnit\Controllers\ListController;
|
use App\Domains\CostUnit\Controllers\ListController;
|
||||||
use App\Domains\CostUnit\Controllers\OpenController;
|
use App\Domains\CostUnit\Controllers\OpenController;
|
||||||
use App\Domains\UserManagement\Controllers\EmailVerificationController;
|
|
||||||
use App\Domains\UserManagement\Controllers\LoginController;
|
|
||||||
use App\Domains\UserManagement\Controllers\LogOutController;
|
|
||||||
use App\Domains\UserManagement\Controllers\RegistrationController;
|
|
||||||
use App\Domains\UserManagement\Controllers\ResetPasswordController;
|
|
||||||
use App\Middleware\IdentifyTenant;
|
use App\Middleware\IdentifyTenant;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
@@ -23,16 +18,10 @@ Route::middleware(IdentifyTenant::class)->group(function () {
|
|||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
Route::get('/register', [RegistrationController::class, 'loginForm']);
|
|
||||||
Route::get('/register/verifyEmail', [EmailVerificationController::class, 'verifyEmailForm']);
|
|
||||||
|
|
||||||
Route::get('/reset-password', [ResetPasswordController::class, 'resetPasswordForm']);
|
|
||||||
|
|
||||||
route::get('/logout', LogOutController::class);
|
|
||||||
route::post('/login', [LoginController::class, 'doLogin']);
|
|
||||||
route::get('/login', [LoginController::class, 'loginForm']);
|
|
||||||
|
|
||||||
|
|
||||||
|
// Anmeldung, Registrierung und Passwort-Reset gehören zur Domain UserManagement und sind dort
|
||||||
|
// definiert. Die Duplikate hier überschrieben die dortigen Routen -- unter anderem die benannte
|
||||||
|
// Route `login`, auf die Laravels `auth`-Middleware Gäste umleitet.
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,12 +89,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<table v-if="localData.invoices.length > 0" class="invoice-list-table">
|
<table v-if="localData.invoices.length > 0" class="invoice-list-table">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6">{{props.data.costUnit.name}}</td>
|
<td colspan="7">{{props.data.costUnit.name}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr v-for="invoice in localData.invoices" :id="'invoice_' + invoice.id">
|
<tr v-for="invoice in localData.invoices" :id="'invoice_' + invoice.id">
|
||||||
<td>{{invoice.invoiceNumber}}</td>
|
<td>{{invoice.invoiceNumber}}</td>
|
||||||
<td>{{invoice.invoiceType}}</td>
|
<td>{{invoice.invoiceTypeShort}}</td>
|
||||||
|
<td style="max-width: 250px;">{{invoice.purpose}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{invoice.amount}}
|
{{invoice.amount}}
|
||||||
</td>
|
</td>
|
||||||
@@ -114,7 +115,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr v-if="props.data.endpoint === 'approved'">
|
<tr v-if="props.data.endpoint === 'approved'">
|
||||||
<td colspan="5"></td>
|
<td colspan="6"></td>
|
||||||
<td>
|
<td>
|
||||||
<a style="font-size: 10pt;" class="link" @click="exportPayouts()">Genehmigte Abrechnungen exportieren</a>
|
<a style="font-size: 10pt;" class="link" @click="exportPayouts()">Genehmigte Abrechnungen exportieren</a>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class PersonalDataController extends CommonController
|
|||||||
return redirect()->intended('/login');
|
return redirect()->intended('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = auth()->user();
|
$user = currentUser();
|
||||||
$data = $this->users->getPersonalData($user);
|
$data = $this->users->getPersonalData($user);
|
||||||
|
|
||||||
$inertiaProvider = new InertiaProvider('Dashboard/PersonalData', [
|
$inertiaProvider = new InertiaProvider('Dashboard/PersonalData', [
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class StorePersonalDataController extends CommonController
|
|||||||
{
|
{
|
||||||
public function __invoke(Request $request): JsonResponse
|
public function __invoke(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = currentUser();
|
||||||
|
|
||||||
$actionRequest = new UpdatePersonalDataRequest(
|
$actionRequest = new UpdatePersonalDataRequest(
|
||||||
user: $user,
|
user: $user,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function navigateTo(url) {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{participation.event.postal_code}} {{participation.event.location}}<br />
|
{{participation.eventAddress}}<br />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="link" :href="`/api/v1/event/participant/${participation.identifier}/ical`">In Kalender importieren</a>
|
<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;
|
||||||
|
}
|
||||||
+8
-1
@@ -12,7 +12,14 @@ class CertificateOfConductionCheckCommand {
|
|||||||
public function execute() : CertificateOfConductionCheckResponse {
|
public function execute() : CertificateOfConductionCheckResponse {
|
||||||
$response = new CertificateOfConductionCheckResponse();
|
$response = new CertificateOfConductionCheckResponse();
|
||||||
|
|
||||||
$localGroup = str_replace('Stamm ', '', $this->request->participant->localGroup()->first()->name);
|
// Verlangt die Veranstaltung kein eFZ, entfällt die Prüfung -- ohne Aufruf der Prüf-API.
|
||||||
|
if (!$this->request->participant->event()->first()?->coc_check_required) {
|
||||||
|
$response->status = EfzStatus::EFZ_STATUS_NOT_REQUIRED;
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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()
|
$apiResponse = Http::acceptJson()
|
||||||
->asJson()
|
->asJson()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use App\Models\Tenant;
|
|||||||
use App\RelationModels\EventEatingHabits;
|
use App\RelationModels\EventEatingHabits;
|
||||||
use App\RelationModels\EventLocalGroups;
|
use App\RelationModels\EventLocalGroups;
|
||||||
use App\RelationModels\EventPaymentMethods;
|
use App\RelationModels\EventPaymentMethods;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class CreateEventCommand {
|
class CreateEventCommand {
|
||||||
@@ -27,11 +28,18 @@ class CreateEventCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$event = Event::create([
|
$tenant = currentTenant();
|
||||||
'tenant' => app('tenant')->slug,
|
|
||||||
|
// 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.
|
||||||
|
$event = DB::transaction(function () use ($tenant): Event {
|
||||||
|
$event = Event::create([
|
||||||
|
'tenant' => $tenant->slug,
|
||||||
'name' => $this->request->name,
|
'name' => $this->request->name,
|
||||||
'identifier' => Str::random(10),
|
'identifier' => Str::random(10),
|
||||||
'location' => $this->request->location,
|
'location' => $this->request->location,
|
||||||
|
'street' => $this->normalizeOptional($this->request->street),
|
||||||
|
'house_number' => $this->normalizeOptional($this->request->houseNumber),
|
||||||
'postal_code' => $this->request->postalCode,
|
'postal_code' => $this->request->postalCode,
|
||||||
'email' => $this->request->email,
|
'email' => $this->request->email,
|
||||||
'start_date' => $this->request->begin,
|
'start_date' => $this->request->begin,
|
||||||
@@ -49,12 +57,23 @@ class CreateEventCommand {
|
|||||||
'support_flat' => 0,
|
'support_flat' => 0,
|
||||||
// Umsatzsteuerliche Grundlage bei Anlage einfrieren (unveränderlich), damit Preisermittlung und
|
// Umsatzsteuerliche Grundlage bei Anlage einfrieren (unveränderlich), damit Preisermittlung und
|
||||||
// spätere Rechnungen von späteren Tenant-Änderungen unberührt bleiben.
|
// spätere Rechnungen von späteren Tenant-Änderungen unberührt bleiben.
|
||||||
'tax_liable' => app('tenant')->tax_liable,
|
'tax_liable' => $tenant->tax_liable,
|
||||||
'vat_rate' => app('tenant')->vat_rate,
|
'vat_rate' => $tenant->vat_rate,
|
||||||
'vat_pricing_mode' => app('tenant')->vat_pricing_mode,
|
'vat_pricing_mode' => $tenant->vat_pricing_mode,
|
||||||
'tax_exemption_reason' => app('tenant')->tax_exemption_reason,
|
'tax_exemption_reason' => $tenant->tax_exemption_reason,
|
||||||
'tax_exemption_note' => app('tenant')->tax_exemption_note,
|
'tax_exemption_note' => $tenant->tax_exemption_note,
|
||||||
]);
|
'participant_group_type' => $this->request->participantGroupType->value,
|
||||||
|
// Den Event-Teil der Rechnungsnummer einfrieren: Tenant-Präfix und Startdatum sind später
|
||||||
|
// änderbar, eine herausgegebene Rechnung würde sonst zu einer anderen Nummer gehören.
|
||||||
|
//
|
||||||
|
// Der Rechnungssteller wird bewusst NICHT mitkopiert -- er ist der Mandant und wird beim
|
||||||
|
// Erzeugen der Rechnung von dort gelesen, damit eine Korrektur an Name oder Anschrift auch
|
||||||
|
// auf bestehende Veranstaltungen wirkt.
|
||||||
|
'invoice_key' => $this->nextInvoiceKey($tenant),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $event;
|
||||||
|
});
|
||||||
|
|
||||||
if ($event !== null) {
|
if ($event !== null) {
|
||||||
EventEatingHabits::create([
|
EventEatingHabits::create([
|
||||||
@@ -75,12 +94,12 @@ class CreateEventCommand {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app('tenant')->slug === 'lv') {
|
if (currentTenant()->slug === 'lv') {
|
||||||
foreach(Tenant::where(['is_active_local_group' => true])->get() as $tenant) {
|
foreach(Tenant::where(['is_active_local_group' => true])->get() as $tenant) {
|
||||||
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => $tenant->id]);
|
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => $tenant->id]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => app('tenant')->id]);
|
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => currentTenant()->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -90,4 +109,46 @@ class CreateEventCommand {
|
|||||||
|
|
||||||
return $response;
|
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
|
||||||
|
* Veranstaltungen dieses Tenants in diesem Monat.
|
||||||
|
*
|
||||||
|
* Gezählt wird über die bereits vergebenen Schlüssel desselben Monats. Die Sperre auf der
|
||||||
|
* Tenant-Zeile serialisiert gleichzeitige Anlagen; der Aufruf erfolgt innerhalb der
|
||||||
|
* Anlage-Transaktion, sodass die Sperre bis zum Schreiben des Events steht.
|
||||||
|
*/
|
||||||
|
private function nextInvoiceKey(Tenant $tenant): string
|
||||||
|
{
|
||||||
|
// Jahr und Monat ohne Trenner; die laufende Nummer haengt unmittelbar daran. Alle drei Teile
|
||||||
|
// haben feste Laenge, der Schluessel bleibt dadurch eindeutig zerlegbar.
|
||||||
|
$month = $this->request->begin->format('Ym');
|
||||||
|
$prefix = sprintf('%s-V-%s', $tenant->invoice_prefix ?? strtoupper($tenant->slug), $month);
|
||||||
|
|
||||||
|
DB::table('tenants')->where('id', $tenant->id)->lockForUpdate()->first();
|
||||||
|
|
||||||
|
$used = DB::table('events')
|
||||||
|
->where('tenant', $tenant->slug)
|
||||||
|
->where('invoice_key', 'like', $prefix . '%')
|
||||||
|
->pluck('invoice_key');
|
||||||
|
|
||||||
|
$highest = 0;
|
||||||
|
foreach ($used as $key) {
|
||||||
|
$highest = max($highest, (int) substr((string) $key, strlen($prefix)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $prefix . str_pad((string) ($highest + 1), 2, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domains\Event\Actions\CreateEvent;
|
namespace App\Domains\Event\Actions\CreateEvent;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipantGroupType;
|
||||||
use App\Enumerations\ParticipationFeeType;
|
use App\Enumerations\ParticipationFeeType;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
@@ -19,8 +20,13 @@ class CreateEventRequest {
|
|||||||
public string $accountOwner;
|
public string $accountOwner;
|
||||||
public string $accountIban;
|
public string $accountIban;
|
||||||
public bool $payPerDay;
|
public bool $payPerDay;
|
||||||
|
public ?string $street;
|
||||||
|
public ?string $houseNumber;
|
||||||
|
/** Wonach bei der Anmeldung gefragt wird: Local Group oder Parent Group. */
|
||||||
|
public ParticipantGroupType $participantGroupType;
|
||||||
|
|
||||||
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, ParticipantGroupType $participantGroupType = ParticipantGroupType::LocalGroup) {
|
||||||
|
$this->participantGroupType = $participantGroupType;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->location = $location;
|
$this->location = $location;
|
||||||
$this->postalCode = $postalCode;
|
$this->postalCode = $postalCode;
|
||||||
@@ -34,5 +40,7 @@ class CreateEventRequest {
|
|||||||
$this->accountOwner = $accountOwner;
|
$this->accountOwner = $accountOwner;
|
||||||
$this->accountIban = $accountIban;
|
$this->accountIban = $accountIban;
|
||||||
$this->payPerDay = $payPerDay;
|
$this->payPerDay = $payPerDay;
|
||||||
|
$this->street = $street;
|
||||||
|
$this->houseNumber = $houseNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+233
@@ -0,0 +1,233 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domains\Event\Actions\CreateIncomeSurplusStatement;
|
||||||
|
|
||||||
|
use App\Enumerations\ParticipationType;
|
||||||
|
use App\Models\CostUnit;
|
||||||
|
use App\Models\Event;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
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());
|
||||||
|
|
||||||
|
$expenses = $this->buildExpenses($costUnit);
|
||||||
|
$donations = $this->buildExpenses($costUnit, donationsOnly: true);
|
||||||
|
$income = $this->buildIncome($eventData, $otherIncome, $donations['total']);
|
||||||
|
|
||||||
|
$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,
|
||||||
|
'donations' => $donations,
|
||||||
|
'result' => $result,
|
||||||
|
'money' => self::money(...),
|
||||||
|
])->render();
|
||||||
|
|
||||||
|
$response->success = true;
|
||||||
|
$response->filename = 'EUER-' . $this->event->identifier . '.pdf';
|
||||||
|
$response->income = $income;
|
||||||
|
$response->expenses = $expenses;
|
||||||
|
$response->donations = $donations;
|
||||||
|
$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, Amount $donations): 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'),
|
||||||
|
],
|
||||||
|
// Gespendete Auslagen: als Ausgabe ihres Typs gebucht, hier die Gegenbuchung.
|
||||||
|
['name' => 'Spenden', 'amount' => $donations],
|
||||||
|
];
|
||||||
|
|
||||||
|
$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.
|
||||||
|
*
|
||||||
|
* Mit `$donationsOnly` nur die gespendeten Auslagen in derselben Gliederung -- für die Anlage „Spenden"
|
||||||
|
* und die Summe unter den Förderungen.
|
||||||
|
*
|
||||||
|
* @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, bool $donationsOnly = false): array
|
||||||
|
{
|
||||||
|
$groups = [];
|
||||||
|
$total = new Amount(0, 'Euro');
|
||||||
|
|
||||||
|
foreach ($this->costUnits->groupExpensesByType($costUnit, $donationsOnly) 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' => self::purpose($invoice),
|
||||||
|
'amount' => Amount::fromString($invoice->amount),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$groups[] = [
|
||||||
|
'name' => $group['type']->name,
|
||||||
|
'sum' => $group['sum'],
|
||||||
|
'rows' => $rows,
|
||||||
|
];
|
||||||
|
|
||||||
|
$total->addAmount($group['sum']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['groups' => $groups, 'total' => $total];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der Zweck eines Belegs für die Anlage.
|
||||||
|
*
|
||||||
|
* Erfasster oder abgeleiteter Zahlungsgrund wie in der Beleg-Übersicht. Nur wenn es keinen gibt --
|
||||||
|
* ältere Abrechnungen ohne jede Zweckangabe --, steht dort ersatzweise, wem was erstattet wurde. Bewusst
|
||||||
|
* hier und nicht in {@see Invoice::purposeText()}: Dort würde der Ersatztext als erfasster Zahlungsgrund
|
||||||
|
* erscheinen und beim Korrigieren als Änderung protokolliert.
|
||||||
|
*/
|
||||||
|
private static function purpose(Invoice $invoice): string
|
||||||
|
{
|
||||||
|
$purpose = $invoice->purposeText();
|
||||||
|
|
||||||
|
if (trim($purpose) !== '') {
|
||||||
|
return $purpose;
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim('Auslagenerstattung ' . $invoice->contact_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
<?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 = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die gespendeten Auslagen, gegliedert wie die Ausgaben -- die Gegenbuchung zur Zeile „Spenden".
|
||||||
|
*
|
||||||
|
* @var array{groups: array<int, array{name: string, sum: Amount, rows: array<int, array<string, mixed>>}>, total: Amount}|array{}
|
||||||
|
*/
|
||||||
|
public array $donations = [];
|
||||||
|
|
||||||
|
public ?Amount $result = null;
|
||||||
|
}
|
||||||
@@ -13,18 +13,18 @@ class GenerateIcalCommand
|
|||||||
$participant = $this->request->participant;
|
$participant = $this->request->participant;
|
||||||
$event = $participant->event;
|
$event = $participant->event;
|
||||||
|
|
||||||
$uid = $participant->identifier . '@' . app('tenant')->slug;
|
$uid = $participant->identifier . '@' . currentTenant()->slug;
|
||||||
$dtStart = $event->start_date->format('Ymd');
|
$dtStart = $event->start_date->format('Ymd');
|
||||||
$dtEnd = $event->end_date->copy()->addDay()->format('Ymd');
|
$dtEnd = $event->end_date->copy()->addDay()->format('Ymd');
|
||||||
$now = now()->format('Ymd\THis\Z');
|
$now = now()->format('Ymd\THis\Z');
|
||||||
$summary = $this->escapeIcal($event->name);
|
$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());
|
$description = $this->escapeIcal('Teilnahme als: ' . $participant->getOfficialName());
|
||||||
|
|
||||||
$icalContent = implode("\r\n", [
|
$icalContent = implode("\r\n", [
|
||||||
'BEGIN:VCALENDAR',
|
'BEGIN:VCALENDAR',
|
||||||
'VERSION:2.0',
|
'VERSION:2.0',
|
||||||
'PRODID:-//' . app('tenant')->name . '//Veranstaltungskalender//DE',
|
'PRODID:-//' . currentTenant()->name . '//Veranstaltungskalender//DE',
|
||||||
'CALSCALE:GREGORIAN',
|
'CALSCALE:GREGORIAN',
|
||||||
'METHOD:PUBLISH',
|
'METHOD:PUBLISH',
|
||||||
'BEGIN:VEVENT',
|
'BEGIN:VEVENT',
|
||||||
|
|||||||
+2
-2
@@ -21,11 +21,11 @@ class GenerateIcalForDeadlineCommand {
|
|||||||
$icalContent = implode("\r\n", [
|
$icalContent = implode("\r\n", [
|
||||||
'BEGIN:VCALENDAR',
|
'BEGIN:VCALENDAR',
|
||||||
'VERSION:2.0',
|
'VERSION:2.0',
|
||||||
'PRODID:-//' . app('tenant')->name . '//Veranstaltungskalender//DE',
|
'PRODID:-//' . currentTenant()->name . '//Veranstaltungskalender//DE',
|
||||||
'CALSCALE:GREGORIAN',
|
'CALSCALE:GREGORIAN',
|
||||||
'METHOD:PUBLISH',
|
'METHOD:PUBLISH',
|
||||||
'BEGIN:VEVENT',
|
'BEGIN:VEVENT',
|
||||||
'UID:payment-deadline-' . $event->identifier . '@' . app('tenant')->slug,
|
'UID:payment-deadline-' . $event->identifier . '@' . currentTenant()->slug,
|
||||||
'DTSTAMP:' . $now,
|
'DTSTAMP:' . $now,
|
||||||
'DTSTART;VALUE=DATE:' . $dtDate,
|
'DTSTART;VALUE=DATE:' . $dtDate,
|
||||||
'DTEND;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->cleanBefore();
|
||||||
|
|
||||||
$this->request->event->participationFee1()->associate(EventParticipationFee::create([
|
$this->request->event->participationFee1()->associate(EventParticipationFee::create([
|
||||||
'tenant' => app('tenant')->slug,
|
'tenant' => currentTenant()->slug,
|
||||||
'type' => $this->request->participationFeeFirst['type'],
|
'type' => $this->request->participationFeeFirst['type'],
|
||||||
'name' => $this->request->participationFeeFirst['name'],
|
'name' => $this->request->participationFeeFirst['name'],
|
||||||
'description' => $this->request->participationFeeFirst['description'],
|
'description' => $this->request->participationFeeFirst['description'],
|
||||||
@@ -29,7 +29,7 @@ class SetParticipationFeesCommand {
|
|||||||
|
|
||||||
if ($this->request->participationFeeSecond !== null) {
|
if ($this->request->participationFeeSecond !== null) {
|
||||||
$this->request->event->participationFee2()->associate(EventParticipationFee::create([
|
$this->request->event->participationFee2()->associate(EventParticipationFee::create([
|
||||||
'tenant' => app('tenant')->slug,
|
'tenant' => currentTenant()->slug,
|
||||||
'type' => $this->request->participationFeeSecond['type'],
|
'type' => $this->request->participationFeeSecond['type'],
|
||||||
'name' => $this->request->participationFeeSecond['name'],
|
'name' => $this->request->participationFeeSecond['name'],
|
||||||
'description' => $this->request->participationFeeSecond['description'],
|
'description' => $this->request->participationFeeSecond['description'],
|
||||||
@@ -41,7 +41,7 @@ class SetParticipationFeesCommand {
|
|||||||
|
|
||||||
if ($this->request->participationFeeThird !== null) {
|
if ($this->request->participationFeeThird !== null) {
|
||||||
$this->request->event->participationFee3()->associate(EventParticipationFee::create([
|
$this->request->event->participationFee3()->associate(EventParticipationFee::create([
|
||||||
'tenant' => app('tenant')->slug,
|
'tenant' => currentTenant()->slug,
|
||||||
'type' => $this->request->participationFeeThird['type'],
|
'type' => $this->request->participationFeeThird['type'],
|
||||||
'name' => $this->request->participationFeeThird['name'],
|
'name' => $this->request->participationFeeThird['name'],
|
||||||
'description' => $this->request->participationFeeThird['description'],
|
'description' => $this->request->participationFeeThird['description'],
|
||||||
@@ -53,7 +53,7 @@ class SetParticipationFeesCommand {
|
|||||||
|
|
||||||
if ($this->request->participationFeeFourth !== null) {
|
if ($this->request->participationFeeFourth !== null) {
|
||||||
$this->request->event->participationFee4()->associate(EventParticipationFee::create([
|
$this->request->event->participationFee4()->associate(EventParticipationFee::create([
|
||||||
'tenant' => app('tenant')->slug,
|
'tenant' => currentTenant()->slug,
|
||||||
'type' => $this->request->participationFeeFourth['type'],
|
'type' => $this->request->participationFeeFourth['type'],
|
||||||
'name' => $this->request->participationFeeFourth['name'],
|
'name' => $this->request->participationFeeFourth['name'],
|
||||||
'description' => $this->request->participationFeeFourth['description'],
|
'description' => $this->request->participationFeeFourth['description'],
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Domains\Event\Actions\SetPaymentMethods;
|
namespace App\Domains\Event\Actions\SetPaymentMethods;
|
||||||
|
|
||||||
|
use App\EventPaymentModules\EventPaymentModuleRegistry;
|
||||||
use App\Models\AvailablePaymentMethod;
|
use App\Models\AvailablePaymentMethod;
|
||||||
use App\Models\PaymentMethod;
|
use App\Models\PaymentMethod;
|
||||||
use App\RelationModels\EventPaymentMethods;
|
use App\RelationModels\EventPaymentMethods;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class SetPaymentMethodsCommand
|
class SetPaymentMethodsCommand
|
||||||
{
|
{
|
||||||
@@ -25,7 +27,22 @@ class SetPaymentMethodsCommand
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->syncPaymentMethods();
|
$existing = EventPaymentMethods::where('event_id', $this->request->event->id)->get()->keyBy('slug');
|
||||||
|
$configurations = $this->configurationsToWrite($existing);
|
||||||
|
|
||||||
|
// Erst prüfen, dann schreiben: Eine Zahlungsart, die am Event unvollständig konfiguriert wäre,
|
||||||
|
// ließe sich bei der Anmeldung wählen, ohne dass die Angaben für die Zahlung vorliegen.
|
||||||
|
$incomplete = $this->incompleteNames($configurations);
|
||||||
|
if ($incomplete !== []) {
|
||||||
|
$response->success = false;
|
||||||
|
$response->message = sprintf(
|
||||||
|
'Die Konfiguration von „%s" ist unvollständig oder ungültig.',
|
||||||
|
implode('", „', $incomplete),
|
||||||
|
);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->syncPaymentMethods($existing, $configurations);
|
||||||
|
|
||||||
$this->request->event->save();
|
$this->request->event->save();
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
@@ -34,49 +51,107 @@ class SetPaymentMethodsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Differenzieller Sync der Zahlungsmethoden mit Snapshot-Copy-Semantik:
|
* Die Configs, die geschrieben werden (Snapshot-Copy-Semantik):
|
||||||
* - entfernte Methoden werden gelöscht,
|
|
||||||
* - neue Methoden erhalten einen Snapshot der Tenant-Config (oder eines expliziten Overrides),
|
* - neue Methoden erhalten einen Snapshot der Tenant-Config (oder eines expliziten Overrides),
|
||||||
* - bestehende Methoden behalten ihre pro-Event-Config, sofern kein Override übergeben wird.
|
* - bestehende Methoden behalten ihre pro-Event-Config, sofern kein Override übergeben wird --
|
||||||
|
* sie tauchen hier dann nicht auf.
|
||||||
|
*
|
||||||
|
* @param Collection<string, EventPaymentMethods> $existing
|
||||||
|
* @return array<string, array<string, mixed>> slug => Config
|
||||||
*/
|
*/
|
||||||
private function syncPaymentMethods(): void
|
private function configurationsToWrite(Collection $existing): array
|
||||||
{
|
{
|
||||||
$event = $this->request->event;
|
|
||||||
$desiredSlugs = $this->request->paymentMethods;
|
$desiredSlugs = $this->request->paymentMethods;
|
||||||
$overrides = $this->request->paymentMethodConfigurations;
|
$overrides = $this->request->paymentMethodConfigurations;
|
||||||
|
|
||||||
$existing = EventPaymentMethods::where('event_id', $event->id)->get()->keyBy('slug');
|
|
||||||
|
|
||||||
// Nicht mehr gewünschte Methoden entfernen.
|
|
||||||
foreach ($existing as $slug => $row) {
|
|
||||||
if (!in_array($slug, $desiredSlugs, true)) {
|
|
||||||
$row->delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tenant-Instanzen (für Snapshot-Kopie neuer Methoden) laden.
|
// Tenant-Instanzen (für Snapshot-Kopie neuer Methoden) laden.
|
||||||
$tenantMethods = AvailablePaymentMethod::whereIn('slug', $desiredSlugs)->get()->keyBy('slug');
|
$tenantMethods = AvailablePaymentMethod::whereIn('slug', $desiredSlugs)->get()->keyBy('slug');
|
||||||
|
|
||||||
|
$configurations = [];
|
||||||
foreach ($desiredSlugs as $slug) {
|
foreach ($desiredSlugs as $slug) {
|
||||||
$override = $overrides[$slug] ?? null;
|
$override = $overrides[$slug] ?? null;
|
||||||
|
|
||||||
if (isset($existing[$slug])) {
|
if (isset($existing[$slug]) && $override === null) {
|
||||||
// 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->save();
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Neue Zuweisung: expliziter Override oder Snapshot der Tenant-Config.
|
|
||||||
$snapshot = $override ?? ($tenantMethods[$slug]->configuration ?? []);
|
$snapshot = $override ?? ($tenantMethods[$slug]->configuration ?? []);
|
||||||
|
$configurations[$slug] = $this->eventConfiguration($slug, $snapshot ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $configurations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Namen der Zahlungsarten, deren Config nicht vollständig oder nicht gültig ist.
|
||||||
|
*
|
||||||
|
* Geprüft wird auf der Event-Config, also ohne die tenant-weiten Optionen -- die sind ohnehin nie
|
||||||
|
* Pflicht, weil sie am Event gar nicht liegen.
|
||||||
|
*
|
||||||
|
* @param array<string, array<string, mixed>> $configurations
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
private function incompleteNames(array $configurations): array
|
||||||
|
{
|
||||||
|
$names = [];
|
||||||
|
foreach ($configurations as $slug => $configuration) {
|
||||||
|
if (!PaymentMethod::isConfigurationComplete($slug, $configuration)) {
|
||||||
|
$names[] = EventPaymentModuleRegistry::forSlug($slug)?->defaultName() ?? $slug;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Differenzieller Sync: entfernte Methoden werden gelöscht, die vorbereiteten Configs geschrieben.
|
||||||
|
*
|
||||||
|
* @param Collection<string, EventPaymentMethods> $existing
|
||||||
|
* @param array<string, array<string, mixed>> $configurations
|
||||||
|
*/
|
||||||
|
private function syncPaymentMethods(Collection $existing, array $configurations): void
|
||||||
|
{
|
||||||
|
$event = $this->request->event;
|
||||||
|
|
||||||
|
// Nicht mehr gewünschte Methoden entfernen.
|
||||||
|
foreach ($existing as $slug => $row) {
|
||||||
|
if (!in_array($slug, $this->request->paymentMethods, true)) {
|
||||||
|
$row->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($configurations as $slug => $configuration) {
|
||||||
|
if (isset($existing[$slug])) {
|
||||||
|
$row = $existing[$slug];
|
||||||
|
$row->configuration = $configuration;
|
||||||
|
$row->save();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
EventPaymentMethods::create([
|
EventPaymentMethods::create([
|
||||||
'event_id' => $event->id,
|
'event_id' => $event->id,
|
||||||
'slug' => $slug,
|
'slug' => $slug,
|
||||||
'configuration' => PaymentMethod::sanitizeConfiguration($slug, $snapshot ?? []),
|
'configuration' => $configuration,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loaded 100 of 381 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user