Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bef494fc4c |
@@ -23,6 +23,3 @@ Homestead.json
|
|||||||
Homestead.yaml
|
Homestead.yaml
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
/docker-compose.yaml
|
/docker-compose.yaml
|
||||||
|
|
||||||
# HTML-Report von composer test:coverage
|
|
||||||
/storage/coverage
|
|
||||||
|
|||||||
-29010
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,87 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<?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,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
<?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]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?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,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
<?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 = [];
|
|
||||||
}
|
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
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)
|
||||||
@@ -17,14 +15,8 @@ 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,14 +12,6 @@ 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,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
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
|
||||||
{
|
{
|
||||||
@@ -16,23 +14,14 @@ 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->withInvoiceDetails([
|
$this->request->tenant->update([
|
||||||
'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.';
|
||||||
@@ -56,13 +45,13 @@ class UpdateTenantTaxAction
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->request->tenant->update($this->withInvoiceDetails([
|
$this->request->tenant->update([
|
||||||
'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.';
|
||||||
@@ -74,31 +63,4 @@ 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,14 +15,6 @@ 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,
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
<?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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
<?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,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
<?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),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<?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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?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"',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?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,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -15,13 +15,6 @@ 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,11 +20,6 @@ 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,11 +20,6 @@ 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,9 +23,6 @@ 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();
|
||||||
|
|||||||
@@ -13,13 +13,6 @@ 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,11 +18,6 @@ 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();
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ 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,10 +21,6 @@ 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' => currentUser()?->id === $user->id,
|
'isOwnUser' => auth()->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: currentUser()?->id,
|
currentUserId: auth()->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: currentUser()?->id === $user->id,
|
isOwnUser: auth()->id() === $user->id,
|
||||||
isLvTenant: $this->tenant->slug === 'lv',
|
isLvTenant: $this->tenant->slug === 'lv',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<?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\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;
|
||||||
@@ -39,7 +34,6 @@ 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 () {
|
||||||
@@ -66,18 +60,6 @@ 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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<?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\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;
|
||||||
@@ -9,7 +8,6 @@ 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 () {
|
||||||
@@ -18,11 +16,6 @@ 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::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);
|
||||||
|
|||||||
@@ -1,666 +0,0 @@
|
|||||||
<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>
|
|
||||||
@@ -13,17 +13,9 @@ 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 ?? '',
|
||||||
})
|
})
|
||||||
@@ -47,49 +39,16 @@ 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>
|
||||||
@@ -98,27 +57,6 @@ 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>
|
||||||
@@ -163,22 +101,6 @@ 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;
|
||||||
|
|||||||
@@ -29,15 +29,8 @@ 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')
|
||||||
|
|
||||||
@@ -72,9 +65,6 @@ 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,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -110,18 +100,6 @@ 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>
|
||||||
@@ -174,42 +152,6 @@ 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>
|
||||||
@@ -253,25 +195,6 @@ 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;
|
||||||
|
|||||||
@@ -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' => currentTenant()->slug,
|
'tenant' => app('tenant')->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' => currentTenant()->slug,
|
'tenant' => app('tenant')->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,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class CreateCostUnitCommand {
|
|||||||
$response = new CreateCostUnitResponse();
|
$response = new CreateCostUnitResponse();
|
||||||
$costUnit = CostUnit::create([
|
$costUnit = CostUnit::create([
|
||||||
'name' => $this->request->name,
|
'name' => $this->request->name,
|
||||||
'tenant' => currentTenant()->slug,
|
'tenant' => app('tenant')->slug,
|
||||||
'type' => $this->request->type,
|
'type' => $this->request->type,
|
||||||
'billing_deadline' => $this->request->billingDeadline,
|
'billing_deadline' => $this->request->billingDeadline,
|
||||||
'distance_allowance' => $this->request->distanceAllowance->getAmount(),
|
'distance_allowance' => $this->request->distanceAllowance->getAmount(),
|
||||||
|
|||||||
@@ -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->paymentPurposeText(),
|
'payment_purpose' => $invoice->payment_purpose ?? 'Auslagenerstattung Rechnungsnummer ' . $invoice->invoice_number,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
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;
|
||||||
|
|
||||||
@@ -18,10 +23,16 @@ 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,13 +89,12 @@
|
|||||||
<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="7">{{props.data.costUnit.name}}</td>
|
<td colspan="6">{{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.invoiceTypeShort}}</td>
|
<td>{{invoice.invoiceType}}</td>
|
||||||
<td style="max-width: 250px;">{{invoice.purpose}}</td>
|
|
||||||
<td>
|
<td>
|
||||||
{{invoice.amount}}
|
{{invoice.amount}}
|
||||||
</td>
|
</td>
|
||||||
@@ -115,7 +114,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr v-if="props.data.endpoint === 'approved'">
|
<tr v-if="props.data.endpoint === 'approved'">
|
||||||
<td colspan="6"></td>
|
<td colspan="5"></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 = currentUser();
|
$user = auth()->user();
|
||||||
$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 = currentUser();
|
$user = auth()->user();
|
||||||
|
|
||||||
$actionRequest = new UpdatePersonalDataRequest(
|
$actionRequest = new UpdatePersonalDataRequest(
|
||||||
user: $user,
|
user: $user,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ 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 {
|
||||||
@@ -28,13 +27,8 @@ class CreateEventCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$tenant = currentTenant();
|
$event = Event::create([
|
||||||
|
'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,
|
||||||
@@ -55,22 +49,12 @@ 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' => $tenant->tax_liable,
|
'tax_liable' => app('tenant')->tax_liable,
|
||||||
'vat_rate' => $tenant->vat_rate,
|
'vat_rate' => app('tenant')->vat_rate,
|
||||||
'vat_pricing_mode' => $tenant->vat_pricing_mode,
|
'vat_pricing_mode' => app('tenant')->vat_pricing_mode,
|
||||||
'tax_exemption_reason' => $tenant->tax_exemption_reason,
|
'tax_exemption_reason' => app('tenant')->tax_exemption_reason,
|
||||||
'tax_exemption_note' => $tenant->tax_exemption_note,
|
'tax_exemption_note' => app('tenant')->tax_exemption_note,
|
||||||
// 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([
|
||||||
@@ -91,12 +75,12 @@ class CreateEventCommand {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentTenant()->slug === 'lv') {
|
if (app('tenant')->slug === 'lv') {
|
||||||
foreach(Tenant::where(['is_active_local_group' => true])->get() as $tenant) {
|
foreach(Tenant::where(['is_active_local_group' => true])->get() as $tenant) {
|
||||||
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => $tenant->id]);
|
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => $tenant->id]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => currentTenant()->id]);
|
EventLocalGroups::create(['event_id' => $event->id, 'local_group_id' => app('tenant')->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -106,35 +90,4 @@ class CreateEventCommand {
|
|||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-205
@@ -1,205 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\Event\Actions\CreateIncomeSurplusStatement;
|
|
||||||
|
|
||||||
use App\Enumerations\ParticipationType;
|
|
||||||
use App\Models\CostUnit;
|
|
||||||
use App\Models\Event;
|
|
||||||
use App\Providers\PdfGenerateAndDownloadProvider;
|
|
||||||
use App\Repositories\CostUnitRepository;
|
|
||||||
use App\ValueObjects\Amount;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Erzeugt die Einnahmen-Überschuss-Rechnung einer Veranstaltung als PDF.
|
|
||||||
*
|
|
||||||
* Gezeigt wird ausschließlich Geld, das geflossen ist: gezahlte Beiträge, weitere Einnahmen, was von
|
|
||||||
* Abmeldungen einbehalten wurde, Fördermittel -- und auf der anderen Seite die erfassten Belege. Was nur
|
|
||||||
* erwartet (offene Beiträge) oder geplant (Budgetwerte) ist, gehört in eine Einnahmen-Überschuss-Rechnung
|
|
||||||
* nicht hinein.
|
|
||||||
*
|
|
||||||
* Es wird nichts gespeichert: Alle Zahlen leiten sich aus dem aktuellen Stand ab, ein erneuter Abruf
|
|
||||||
* liefert den dann gültigen Stand.
|
|
||||||
*/
|
|
||||||
class CreateIncomeSurplusStatementCommand
|
|
||||||
{
|
|
||||||
private Event $event;
|
|
||||||
|
|
||||||
private CostUnitRepository $costUnits;
|
|
||||||
|
|
||||||
public function __construct(private readonly CreateIncomeSurplusStatementRequest $request)
|
|
||||||
{
|
|
||||||
$this->event = $request->event;
|
|
||||||
$this->costUnits = new CostUnitRepository();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(): CreateIncomeSurplusStatementResponse
|
|
||||||
{
|
|
||||||
$response = new CreateIncomeSurplusStatementResponse();
|
|
||||||
|
|
||||||
$costUnit = $this->event->costUnit()->first();
|
|
||||||
|
|
||||||
if (!$costUnit instanceof CostUnit) {
|
|
||||||
$response->message = 'Der Veranstaltung ist keine Kostenstelle zugeordnet.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Der Pauschalbetrag wird vor dem Resource-Aufruf gelesen: `EventResource::calculateSupportPerPerson()`
|
|
||||||
// multipliziert das Amount-Objekt von `support_per_person` in place. Auf `support_flat` wirkt das
|
|
||||||
// zwar nicht, aber der gesamte Zugriff auf Beträge des Models ist danach nicht mehr vertrauenswürdig.
|
|
||||||
$otherIncome = $this->event->support_flat->getAmount();
|
|
||||||
|
|
||||||
$eventData = $this->event->toResource()->toArray(new Request());
|
|
||||||
|
|
||||||
$income = $this->buildIncome($eventData, $otherIncome);
|
|
||||||
$expenses = $this->buildExpenses($costUnit);
|
|
||||||
|
|
||||||
$result = new Amount($income['total']->getAmount() - $expenses['total']->getAmount(), 'Euro');
|
|
||||||
|
|
||||||
$html = view('pdfs.income-surplus-statement', [
|
|
||||||
'event' => $this->event,
|
|
||||||
'createdAt' => new \DateTime()->format('d.m.Y'),
|
|
||||||
'income' => $income,
|
|
||||||
'expenses' => $expenses,
|
|
||||||
'result' => $result,
|
|
||||||
'money' => self::money(...),
|
|
||||||
])->render();
|
|
||||||
|
|
||||||
$response->success = true;
|
|
||||||
$response->filename = 'EUER-' . $this->event->identifier . '.pdf';
|
|
||||||
$response->income = $income;
|
|
||||||
$response->expenses = $expenses;
|
|
||||||
$response->result = $result;
|
|
||||||
$response->pdfContent = PdfGenerateAndDownloadProvider::fromHtml($html, 'portrait');
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Einnahmenseite in zwei Ober-Kategorien.
|
|
||||||
*
|
|
||||||
* Alle Zahlen stammen aus {@see \App\Resources\EventResource} -- derselben Quelle wie die
|
|
||||||
* Veranstaltungsübersicht am Bildschirm. Eine eigene Rechnung daneben würde über kurz oder lang von
|
|
||||||
* der Übersicht abweichen, und dann glaubt niemand mehr einer der beiden Zahlen.
|
|
||||||
*
|
|
||||||
* @param array<string, mixed> $eventData
|
|
||||||
*
|
|
||||||
* @return array{categories: array<int, array{name: string, total: Amount, entries: array<int, array{name: string, amount: Amount}>}>, total: Amount}
|
|
||||||
*/
|
|
||||||
private function buildIncome(array $eventData, float $otherIncome): array
|
|
||||||
{
|
|
||||||
// Beiträge aller Teilnahmearten in einer Zeile: Für die Mittelverwendung zählt, was an Beiträgen
|
|
||||||
// hereingekommen ist, nicht von wem.
|
|
||||||
$participationFees = new Amount(0, 'Euro');
|
|
||||||
foreach ([
|
|
||||||
ParticipationType::PARTICIPATION_TYPE_PARTICIPANT,
|
|
||||||
ParticipationType::PARTICIPATION_TYPE_TEAM,
|
|
||||||
ParticipationType::PARTICIPATION_TYPE_VOLUNTEER,
|
|
||||||
ParticipationType::PARTICIPATION_TYPE_OTHER,
|
|
||||||
] as $participationType) {
|
|
||||||
$participationFees->addAmount(
|
|
||||||
new Amount((float) $eventData['participants'][$participationType]['amount']['paid']['value'], 'Euro')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$ownFunds = [
|
|
||||||
['name' => 'Teilnahmebeiträge', 'amount' => $participationFees],
|
|
||||||
['name' => 'Weitere Einnahmen', 'amount' => new Amount($otherIncome, 'Euro')],
|
|
||||||
[
|
|
||||||
'name' => 'Einbehaltene Einnahmen aus Abmeldungen',
|
|
||||||
'amount' => new Amount((float) $eventData['retainedFromUnregistered']['value'], 'Euro'),
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$supportRate = new Amount((float) $eventData['supportPersonValue'], 'Euro');
|
|
||||||
$funding = [
|
|
||||||
[
|
|
||||||
'name' => 'Fördermittel (' . self::money($supportRate) . ' € p.P./Tag)',
|
|
||||||
'amount' => new Amount($eventData['supportPerson']['amount']->getAmount(), 'Euro'),
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
$categories = [
|
|
||||||
['name' => 'Eigenmittel', 'entries' => $ownFunds, 'total' => self::sum($ownFunds)],
|
|
||||||
['name' => 'Förderungen', 'entries' => $funding, 'total' => self::sum($funding)],
|
|
||||||
];
|
|
||||||
|
|
||||||
return [
|
|
||||||
'categories' => $categories,
|
|
||||||
'total' => self::sum($categories),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Ausgabenseite: eine Zeile je Ausgabentyp, dazu die Belege für die Anlage.
|
|
||||||
*
|
|
||||||
* @return array{groups: array<int, array{name: string, sum: Amount, rows: array<int, array{number: string, date: string, purpose: string, amount: Amount}>}>, total: Amount}
|
|
||||||
*/
|
|
||||||
private function buildExpenses(CostUnit $costUnit): array
|
|
||||||
{
|
|
||||||
$groups = [];
|
|
||||||
$total = new Amount(0, 'Euro');
|
|
||||||
|
|
||||||
foreach ($this->costUnits->groupExpensesByType($costUnit) as $group) {
|
|
||||||
$rows = [];
|
|
||||||
|
|
||||||
foreach ($group['invoices'] as $invoice) {
|
|
||||||
$rows[] = [
|
|
||||||
'number' => (string) $invoice->invoice_number,
|
|
||||||
'date' => $invoice->created_at?->format('d.m.Y') ?? '',
|
|
||||||
// Ohne die Anmerkung: dort steht, was die Kassenwart*in beim Korrigieren notiert hat,
|
|
||||||
// und das gehört auf den Beleg, nicht in den Zweck.
|
|
||||||
'purpose' => $invoice->purposeText(),
|
|
||||||
'amount' => Amount::fromString($invoice->amount),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$groups[] = [
|
|
||||||
'name' => $group['type']->name,
|
|
||||||
'sum' => $group['sum'],
|
|
||||||
'rows' => $rows,
|
|
||||||
];
|
|
||||||
|
|
||||||
$total->addAmount($group['sum']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ['groups' => $groups, 'total' => $total];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ein Betrag in deutscher Schreibweise: Punkt als Tausender-, Komma als Dezimaltrennzeichen.
|
|
||||||
*
|
|
||||||
* Bewusst nicht {@see Amount::getFormattedAmount()}: Die Methode ersetzt nach `number_format` jeden
|
|
||||||
* Punkt durch ein Komma und macht aus 1.487,50 damit "1,487,50". Auf einer Aufstellung, in der
|
|
||||||
* vierstellige Beträge die Regel sind, wäre das nicht lesbar. Der Fehler steckt im Value Object und
|
|
||||||
* wirkt überall, wo Beträge angezeigt werden -- ihn dort zu beheben ist eine eigene Änderung.
|
|
||||||
*
|
|
||||||
* Öffentlich, weil die Vorlage sie als Callable bekommt und weil sie für sich prüfbar sein soll.
|
|
||||||
*/
|
|
||||||
public static function money(Amount $amount): string
|
|
||||||
{
|
|
||||||
return number_format(round($amount->getAmount(), 2), 2, ',', '.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Summiert Zeilen, die je ein `amount` oder `total` tragen.
|
|
||||||
*
|
|
||||||
* Über ein frisches Amount-Objekt, weil `Amount::addAmount()` den Empfänger verändert -- die
|
|
||||||
* Einzelbeträge sollen unangetastet bleiben, sie werden anschließend gedruckt.
|
|
||||||
*
|
|
||||||
* @param array<int, array<string, mixed>> $rows
|
|
||||||
*/
|
|
||||||
private static function sum(array $rows): Amount
|
|
||||||
{
|
|
||||||
$sum = new Amount(0, 'Euro');
|
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
/** @var Amount $amount */
|
|
||||||
$amount = $row['amount'] ?? $row['total'];
|
|
||||||
$sum->addAmount($amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\Event\Actions\CreateIncomeSurplusStatement;
|
|
||||||
|
|
||||||
use App\Models\Event;
|
|
||||||
|
|
||||||
class CreateIncomeSurplusStatementRequest
|
|
||||||
{
|
|
||||||
public function __construct(public readonly Event $event)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\Event\Actions\CreateIncomeSurplusStatement;
|
|
||||||
|
|
||||||
use App\ValueObjects\Amount;
|
|
||||||
|
|
||||||
class CreateIncomeSurplusStatementResponse
|
|
||||||
{
|
|
||||||
public bool $success = false;
|
|
||||||
|
|
||||||
public string $filename = '';
|
|
||||||
|
|
||||||
public string $pdfContent = '';
|
|
||||||
|
|
||||||
public ?string $message = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Zahlen, aus denen das PDF entsteht -- Einnahmen-Kategorien, Ausgaben-Gruppen und das Ergebnis.
|
|
||||||
*
|
|
||||||
* Sie stehen hier, weil sie das eigentliche Ergebnis der Action sind; das PDF ist nur ihre Darstellung.
|
|
||||||
* So lässt sich die Rechnung prüfen, ohne ein PDF zerlegen zu müssen.
|
|
||||||
*
|
|
||||||
* @var array{categories: array<int, array{name: string, total: Amount, entries: array<int, array{name: string, amount: Amount}>}>, total: Amount}|array{}
|
|
||||||
*/
|
|
||||||
public array $income = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array{groups: array<int, array{name: string, sum: Amount, rows: array<int, array<string, mixed>>}>, total: Amount}|array{}
|
|
||||||
*/
|
|
||||||
public array $expenses = [];
|
|
||||||
|
|
||||||
public ?Amount $result = null;
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@ class GenerateIcalCommand
|
|||||||
$participant = $this->request->participant;
|
$participant = $this->request->participant;
|
||||||
$event = $participant->event;
|
$event = $participant->event;
|
||||||
|
|
||||||
$uid = $participant->identifier . '@' . currentTenant()->slug;
|
$uid = $participant->identifier . '@' . app('tenant')->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');
|
||||||
@@ -24,7 +24,7 @@ class GenerateIcalCommand
|
|||||||
$icalContent = implode("\r\n", [
|
$icalContent = implode("\r\n", [
|
||||||
'BEGIN:VCALENDAR',
|
'BEGIN:VCALENDAR',
|
||||||
'VERSION:2.0',
|
'VERSION:2.0',
|
||||||
'PRODID:-//' . currentTenant()->name . '//Veranstaltungskalender//DE',
|
'PRODID:-//' . app('tenant')->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:-//' . currentTenant()->name . '//Veranstaltungskalender//DE',
|
'PRODID:-//' . app('tenant')->name . '//Veranstaltungskalender//DE',
|
||||||
'CALSCALE:GREGORIAN',
|
'CALSCALE:GREGORIAN',
|
||||||
'METHOD:PUBLISH',
|
'METHOD:PUBLISH',
|
||||||
'BEGIN:VEVENT',
|
'BEGIN:VEVENT',
|
||||||
'UID:payment-deadline-' . $event->identifier . '@' . currentTenant()->slug,
|
'UID:payment-deadline-' . $event->identifier . '@' . app('tenant')->slug,
|
||||||
'DTSTAMP:' . $now,
|
'DTSTAMP:' . $now,
|
||||||
'DTSTART;VALUE=DATE:' . $dtDate,
|
'DTSTART;VALUE=DATE:' . $dtDate,
|
||||||
'DTEND;VALUE=DATE:' . $dtDate,
|
'DTEND;VALUE=DATE:' . $dtDate,
|
||||||
|
|||||||
@@ -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' => currentTenant()->slug,
|
'tenant' => app('tenant')->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' => currentTenant()->slug,
|
'tenant' => app('tenant')->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' => currentTenant()->slug,
|
'tenant' => app('tenant')->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' => currentTenant()->slug,
|
'tenant' => app('tenant')->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'],
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use App\Enumerations\EatingHabit;
|
|||||||
use App\Enumerations\EfzStatus;
|
use App\Enumerations\EfzStatus;
|
||||||
use App\EventPaymentModules\EventPaymentModuleRegistry;
|
use App\EventPaymentModules\EventPaymentModuleRegistry;
|
||||||
use App\ValueObjects\Age;
|
use App\ValueObjects\Age;
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class SignUpCommand {
|
class SignUpCommand {
|
||||||
@@ -44,21 +43,15 @@ class SignUpCommand {
|
|||||||
|
|
||||||
$participantAge = new Age($this->request->birthday);
|
$participantAge = new Age($this->request->birthday);
|
||||||
|
|
||||||
// Anmeldung als Ganzes: die laufende Nummer (invoice_sequence) muss unter der Sperre vergeben und
|
$response->participant = $this->request->event->participants()->create(
|
||||||
// im selben Zug geschrieben werden, sonst könnten zwei gleichzeitige Anmeldungen dieselbe erhalten.
|
|
||||||
$response->participant = DB::transaction(function () use ($participantAge, $eatingHabit, $paymentOptions, $participationOptionRows) {
|
|
||||||
$participant = $this->request->event->participants()->create(
|
|
||||||
[
|
[
|
||||||
'tenant' => $this->request->event->tenant,
|
'tenant' => $this->request->event->tenant,
|
||||||
'user_id' => $this->request->user_id,
|
'user_id' => $this->request->user_id,
|
||||||
'identifier' => Str::random(10),
|
'identifier' => Str::random(10),
|
||||||
'invoice_sequence' => $this->nextInvoiceSequence(),
|
|
||||||
'firstname' => $this->request->firstname,
|
'firstname' => $this->request->firstname,
|
||||||
'lastname' => $this->request->lastname,
|
'lastname' => $this->request->lastname,
|
||||||
'nickname' => $this->request->nickname,
|
'nickname' => $this->request->nickname,
|
||||||
'participation_type' => $this->request->participationType,
|
'participation_type' => $this->request->participationType,
|
||||||
'fee_type' => $this->request->feeType,
|
|
||||||
'sibling_reduction' => $this->request->siblingReduction,
|
|
||||||
'local_group' => $this->request->localGroup->slug,
|
'local_group' => $this->request->localGroup->slug,
|
||||||
'birthday' => $this->request->birthday,
|
'birthday' => $this->request->birthday,
|
||||||
'address_1' => $this->request->address_1,
|
'address_1' => $this->request->address_1,
|
||||||
@@ -75,12 +68,8 @@ class SignUpCommand {
|
|||||||
'medications' => $this->request->medications,
|
'medications' => $this->request->medications,
|
||||||
'tetanus_vaccination' => $this->request->tetanus_vaccination,
|
'tetanus_vaccination' => $this->request->tetanus_vaccination,
|
||||||
'eating_habit' => $eatingHabit,
|
'eating_habit' => $eatingHabit,
|
||||||
'swimming_permission' => ($participantAge->isfullAged() || $this->request->swimming_permission === '-1')
|
'swimming_permission' => $participantAge->isfullAged() ? 'SWIMMING_PERMISSION_ALLOWED' : $this->request->swimming_permission,
|
||||||
? 'SWIMMING_PERMISSION_ALLOWED'
|
'first_aid_permission' => $participantAge->isfullAged() ? 'FIRST_AID_PERMISSION_ALLOWED' : $this->request->first_aid_permission,
|
||||||
: $this->request->swimming_permission,
|
|
||||||
'first_aid_permission' => ($participantAge->isfullAged() || $this->request->first_aid_permission === '-1')
|
|
||||||
? 'FIRST_AID_PERMISSION_ALLOWED'
|
|
||||||
: $this->request->first_aid_permission,
|
|
||||||
'foto_socialmedia' => $this->request->foto_socialmedia,
|
'foto_socialmedia' => $this->request->foto_socialmedia,
|
||||||
'foto_print' => $this->request->foto_print,
|
'foto_print' => $this->request->foto_print,
|
||||||
'foto_webseite' => $this->request->foto_webseite,
|
'foto_webseite' => $this->request->foto_webseite,
|
||||||
@@ -97,40 +86,15 @@ class SignUpCommand {
|
|||||||
'payment_options' => $paymentOptions,
|
'payment_options' => $paymentOptions,
|
||||||
'efz_status' => $participantAge->isfullAged() ? EfzStatus::EFZ_STATUS_NOT_CHECKED : EfzStatus::EFZ_STATUS_NOT_REQUIRED,
|
'efz_status' => $participantAge->isfullAged() ? EfzStatus::EFZ_STATUS_NOT_CHECKED : EfzStatus::EFZ_STATUS_NOT_REQUIRED,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->persistParticipationOptions($participant, $participationOptionRows);
|
$this->persistParticipationOptions($response->participant, $participationOptionRows);
|
||||||
$this->persistAddons($participant);
|
$this->persistAddons($response->participant);
|
||||||
|
|
||||||
return $participant;
|
|
||||||
});
|
|
||||||
|
|
||||||
$response->success = true;
|
$response->success = true;
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Nächste laufende Nummer des Teilis innerhalb der Veranstaltung -- der letzte Block der
|
|
||||||
* Rechnungsnummer. Die Event-Zeile wird gesperrt, damit gleichzeitige Anmeldungen derselben
|
|
||||||
* Veranstaltung serialisiert werden; der Aufruf erfolgt innerhalb der Anmelde-Transaktion, sodass die
|
|
||||||
* Sperre bis zum Schreiben des Teilis steht.
|
|
||||||
*
|
|
||||||
* Abgemeldete Teilis behalten ihre Nummer, gezählt wird deshalb über MAX und nicht über COUNT.
|
|
||||||
*/
|
|
||||||
private function nextInvoiceSequence(): int
|
|
||||||
{
|
|
||||||
DB::table('events')
|
|
||||||
->where('id', $this->request->event->id)
|
|
||||||
->lockForUpdate()
|
|
||||||
->first();
|
|
||||||
|
|
||||||
$highest = DB::table('event_participants')
|
|
||||||
->where('event_id', $this->request->event->id)
|
|
||||||
->max('invoice_sequence');
|
|
||||||
|
|
||||||
return (int) $highest + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Speichert die gewählten Zusätze (Event-Addons) als Snapshot-Zeilen (Titel/Preis/Betrag) für die spätere
|
* Speichert die gewählten Zusätze (Event-Addons) als Snapshot-Zeilen (Titel/Preis/Betrag) für die spätere
|
||||||
* Rechnung. Die Beträge sind bereits in der Controller-Auflösung (`resolveAddons`) berechnet, inkl. USt.
|
* Rechnung. Die Beträge sind bereits in der Controller-Auflösung (`resolveAddons`) berechnet, inkl. USt.
|
||||||
|
|||||||
@@ -50,10 +50,6 @@ class SignUpRequest {
|
|||||||
public array $participationOptions = [],
|
public array $participationOptions = [],
|
||||||
/** Aufgelöste Zusätze (Event-Addons): je Eintrag [ key, title, price, flat, days, amount ]. */
|
/** Aufgelöste Zusätze (Event-Addons): je Eintrag [ key, title, price, flat, days, amount ]. */
|
||||||
public array $addonItems = [],
|
public array $addonItems = [],
|
||||||
/** Gewählte Preisspalte: standard | reduced | solidarity. Wird für die Rechnung mitgeschrieben. */
|
|
||||||
public ?string $feeType = null,
|
|
||||||
/** Ob die 50-%-Geschwisterermäßigung in `amount` eingerechnet ist. */
|
|
||||||
public bool $siblingReduction = false,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use Illuminate\Http\Request;
|
|||||||
class CreateController extends CommonController {
|
class CreateController extends CommonController {
|
||||||
public function __invoke() {
|
public function __invoke() {
|
||||||
return new InertiaProvider('Event/Create', [
|
return new InertiaProvider('Event/Create', [
|
||||||
'emailAddress' => currentUserOrFail()->email,
|
'emailAddress' => auth()->user()->email,
|
||||||
'eventAccount' => $this->tenant->account_name,
|
'eventAccount' => $this->tenant->account_name,
|
||||||
'eventIban' => $this->tenant->account_iban,
|
'eventIban' => $this->tenant->account_iban,
|
||||||
'eventPayPerDay' => $this->tenant->slug === 'lv' ? true : false,
|
'eventPayPerDay' => $this->tenant->slug === 'lv' ? true : false,
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\Event\Controllers;
|
|
||||||
|
|
||||||
use App\Domains\Event\Actions\CreateIncomeSurplusStatement\CreateIncomeSurplusStatementCommand;
|
|
||||||
use App\Domains\Event\Actions\CreateIncomeSurplusStatement\CreateIncomeSurplusStatementRequest;
|
|
||||||
use App\Scopes\CommonController;
|
|
||||||
use Illuminate\Http\Response;
|
|
||||||
|
|
||||||
class IncomeSurplusStatementController extends CommonController
|
|
||||||
{
|
|
||||||
public function __invoke(string $eventId): Response
|
|
||||||
{
|
|
||||||
$event = $this->events->getByIdentifier($eventId);
|
|
||||||
|
|
||||||
if ($event === null) {
|
|
||||||
abort(403, 'Zugriff verweigert.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$statementRequest = new CreateIncomeSurplusStatementRequest($event);
|
|
||||||
$statementCommand = new CreateIncomeSurplusStatementCommand($statementRequest);
|
|
||||||
$statementResponse = $statementCommand->execute();
|
|
||||||
|
|
||||||
if (!$statementResponse->success) {
|
|
||||||
abort(422, $statementResponse->message ?? 'Die EÜR konnte nicht erstellt werden.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return response($statementResponse->pdfContent, 200, [
|
|
||||||
'Content-Type' => 'application/pdf',
|
|
||||||
'Content-Disposition' => 'attachment; filename="' . $statementResponse->filename . '"',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,7 +38,7 @@ class SendController extends CommonController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = currentUser();
|
$user = auth()->user();
|
||||||
$reportSubject = sprintf('Sendebericht für Nachricht mit Betreff "%s"', $subject);
|
$reportSubject = sprintf('Sendebericht für Nachricht mit Betreff "%s"', $subject);
|
||||||
|
|
||||||
Mail::to($user->email)->send(new ManualMailsReportMail(
|
Mail::to($user->email)->send(new ManualMailsReportMail(
|
||||||
|
|||||||
@@ -35,9 +35,8 @@ class SignupController extends CommonController {
|
|||||||
'lastname' => '',
|
'lastname' => '',
|
||||||
];
|
];
|
||||||
|
|
||||||
$currentUser = currentUser();
|
if (auth()->check()) {
|
||||||
if ($currentUser !== null) {
|
$user = new UserResource(auth()->user())->toArray($request);
|
||||||
$user = new UserResource($currentUser)->toArray($request);
|
|
||||||
|
|
||||||
$participantData = [
|
$participantData = [
|
||||||
'id' => $user['id'],
|
'id' => $user['id'],
|
||||||
@@ -151,8 +150,6 @@ class SignupController extends CommonController {
|
|||||||
(array)($registrationData['paymentOptions'] ?? []),
|
(array)($registrationData['paymentOptions'] ?? []),
|
||||||
(array)($registrationData['participationOptions'] ?? []),
|
(array)($registrationData['participationOptions'] ?? []),
|
||||||
$addonResolution['items'],
|
$addonResolution['items'],
|
||||||
$registrationData['beitrag'],
|
|
||||||
$siblingReduction,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$signupCommand = new SignUpCommand($signupRequest);
|
$signupCommand = new SignUpCommand($signupRequest);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ use App\Domains\Event\Controllers\ArchivedEventsController;
|
|||||||
use App\Domains\Event\Controllers\AvailableEventsController;
|
use App\Domains\Event\Controllers\AvailableEventsController;
|
||||||
use App\Domains\Event\Controllers\CreateController;
|
use App\Domains\Event\Controllers\CreateController;
|
||||||
use App\Domains\Event\Controllers\DetailsController;
|
use App\Domains\Event\Controllers\DetailsController;
|
||||||
use App\Domains\Event\Controllers\IncomeSurplusStatementController;
|
|
||||||
use App\Domains\Event\Controllers\SignupController;
|
use App\Domains\Event\Controllers\SignupController;
|
||||||
use App\Middleware\IdentifyTenant;
|
use App\Middleware\IdentifyTenant;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@@ -19,10 +18,6 @@ Route::middleware(IdentifyTenant::class)->group(function () {
|
|||||||
|
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
Route::get('/details/{eventId}', DetailsController::class);
|
Route::get('/details/{eventId}', DetailsController::class);
|
||||||
|
|
||||||
// Vor der Wildcard darunter: Sonst greift `downloadPdfList()` und sucht ein Blade namens
|
|
||||||
// `income-surplus-statement` mit Teilnehmendendaten, die die EÜR gar nicht braucht.
|
|
||||||
Route::get('/details/{eventId}/pdf/income-surplus-statement', IncomeSurplusStatementController::class);
|
|
||||||
Route::get('/details/{eventId}/pdf/{listType}', [DetailsController::class, 'downloadPdfList']);
|
Route::get('/details/{eventId}/pdf/{listType}', [DetailsController::class, 'downloadPdfList']);
|
||||||
Route::get('/details/{eventId}/csv/{listType}', [DetailsController::class, 'downloadCsvList']);
|
Route::get('/details/{eventId}/csv/{listType}', [DetailsController::class, 'downloadCsvList']);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -106,10 +106,6 @@ async function showEventAddons() {
|
|||||||
<input type="button" value="Beitragsliste (PDF)" />
|
<input type="button" value="Beitragsliste (PDF)" />
|
||||||
</a><br/>
|
</a><br/>
|
||||||
|
|
||||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/income-surplus-statement'">
|
|
||||||
<input type="button" value="EüR (PDF)" />
|
|
||||||
</a><br/>
|
|
||||||
|
|
||||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/drinking-list'">
|
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/drinking-list'">
|
||||||
<input type="button" value="Getränkeliste (PDF)" />
|
<input type="button" value="Getränkeliste (PDF)" />
|
||||||
</a><br/>
|
</a><br/>
|
||||||
@@ -147,10 +143,6 @@ async function showEventAddons() {
|
|||||||
<input type="button" value="Beitragsliste (PDF)" />
|
<input type="button" value="Beitragsliste (PDF)" />
|
||||||
</a><br/>
|
</a><br/>
|
||||||
|
|
||||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/income-surplus-statement'">
|
|
||||||
<input type="button" value="EüR (PDF)" />
|
|
||||||
</a><br/>
|
|
||||||
|
|
||||||
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/drinking-list'">
|
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/drinking-list'">
|
||||||
<input type="button" value="Getränkeliste (PDF)" />
|
<input type="button" value="Getränkeliste (PDF)" />
|
||||||
</a><br/>
|
</a><br/>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {computed, onMounted, reactive, ref, watch} from "vue";
|
import {computed, onMounted, reactive, watch} from "vue";
|
||||||
import {toast} from "vue3-toastify";
|
|
||||||
import AmountInput from "../../../../Views/Components/AmountInput.vue";
|
import AmountInput from "../../../../Views/Components/AmountInput.vue";
|
||||||
import DialableTelephoneNumber from "../../../../Views/Components/DialableTelephoneNumber.vue";
|
import DialableTelephoneNumber from "../../../../Views/Components/DialableTelephoneNumber.vue";
|
||||||
import {useAjax} from "../../../../../resources/js/components/ajaxHandler.js";
|
|
||||||
|
|
||||||
const {download} = useAjax();
|
|
||||||
|
|
||||||
const staticProps = defineProps({
|
const staticProps = defineProps({
|
||||||
editMode: Boolean,
|
editMode: Boolean,
|
||||||
@@ -150,31 +146,6 @@ function enableEditMode() {
|
|||||||
emit('editParticipant');
|
emit('editParticipant');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Rechnung über den Teilnahmebeitrag herunterladen. Sie wird bei jedem Klick neu erzeugt und trägt immer
|
|
||||||
* dieselbe, aus Veranstaltung und Position des Teilis abgeleitete Nummer.
|
|
||||||
*
|
|
||||||
* Bei einem Beitrag von 0 € gibt es nichts zu berechnen -- dann entfällt der Knopf.
|
|
||||||
*/
|
|
||||||
const creatingInvoice = ref(false)
|
|
||||||
|
|
||||||
const hasAmount = computed(() => Number(props.participant?.amountExpectedValue ?? 0) > 0)
|
|
||||||
|
|
||||||
async function downloadInvoice() {
|
|
||||||
creatingInvoice.value = true
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Der Dateiname (mit der Rechnungsnummer) kommt aus dem Content-Disposition-Header.
|
|
||||||
const ok = await download('/api/v1/participant-invoice/' + staticProps.participant.identifier)
|
|
||||||
|
|
||||||
if (!ok) {
|
|
||||||
toast.error('Die Rechnung konnte nicht erstellt werden.')
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
creatingInvoice.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveParticipant() {
|
function saveParticipant() {
|
||||||
emit('saveParticipant', { ...form });
|
emit('saveParticipant', { ...form });
|
||||||
close();
|
close();
|
||||||
@@ -377,29 +348,6 @@ function saveParticipant() {
|
|||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="props.participant.refund">
|
|
||||||
<th>Erstattung</th>
|
|
||||||
<td>
|
|
||||||
{{ props.participant.refund.amount }} – {{ props.participant.refund.reasonLabel }}<br />
|
|
||||||
<small v-if="props.participant.refund.status === 'pending'">
|
|
||||||
freigegeben am {{ props.participant.refund.releasedAt }}, wartet auf die
|
|
||||||
Bankverbindung des Teilis
|
|
||||||
</small>
|
|
||||||
<small v-else-if="props.participant.refund.status === 'accepted'">
|
|
||||||
bestätigt am {{ props.participant.refund.acceptedAt }}<template
|
|
||||||
v-if="props.participant.refund.donation"
|
|
||||||
> – gespendet, keine Auszahlung</template>
|
|
||||||
</small>
|
|
||||||
|
|
||||||
<!-- Was beim Verband geblieben ist und warum. -->
|
|
||||||
<small v-if="props.participant.refund.hasRetention" class="retention-note">
|
|
||||||
<br />Einbehalten: {{ props.participant.refund.retainedAmount }} –
|
|
||||||
{{ props.participant.refund.retentionReasonLabel }}<template
|
|
||||||
v-if="props.participant.refund.retentionReasonNote"
|
|
||||||
> ({{ props.participant.refund.retentionReasonNote }})</template>
|
|
||||||
</small>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -509,12 +457,6 @@ function saveParticipant() {
|
|||||||
|
|
||||||
<button v-if="!props.participant.unregistered" class="button" @click="paymentComplete(props.participant)">Zahlung vollständig</button>
|
<button v-if="!props.participant.unregistered" class="button" @click="paymentComplete(props.participant)">Zahlung vollständig</button>
|
||||||
<button v-if="!props.participant.unregistered" class="button" @click="markCocExisting(props.participant)">eFZ liegt vor</button>
|
<button v-if="!props.participant.unregistered" class="button" @click="markCocExisting(props.participant)">eFZ liegt vor</button>
|
||||||
<button
|
|
||||||
v-if="!props.participant.unregistered && hasAmount"
|
|
||||||
class="button"
|
|
||||||
:disabled="creatingInvoice"
|
|
||||||
@click="downloadInvoice"
|
|
||||||
>{{ creatingInvoice ? 'Wird erstellt…' : 'Rechnung erstellen' }}</button>
|
|
||||||
<button v-if="!props.participant.unregistered" class="button" @click="cancelParticipation(props.participant)">Abmelden</button>
|
<button v-if="!props.participant.unregistered" class="button" @click="cancelParticipation(props.participant)">Abmelden</button>
|
||||||
<button class="button" @click="close">Schließen</button>
|
<button class="button" @click="close">Schließen</button>
|
||||||
|
|
||||||
@@ -551,8 +493,4 @@ textarea {
|
|||||||
select {
|
select {
|
||||||
width: 262px;
|
width: 262px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.retention-note {
|
|
||||||
color: #8a6d00;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import {format} from "date-fns";
|
|||||||
import AmountInput from "../../../../Views/Components/AmountInput.vue";
|
import AmountInput from "../../../../Views/Components/AmountInput.vue";
|
||||||
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
|
||||||
import DialableTelephoneNumber from "../../../../Views/Components/DialableTelephoneNumber.vue";
|
import DialableTelephoneNumber from "../../../../Views/Components/DialableTelephoneNumber.vue";
|
||||||
import ErrorText from "../../../../Views/Components/ErrorText.vue";
|
|
||||||
import IbanInput from "../../../../Views/Components/IbanInput.vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
@@ -31,7 +29,7 @@ const props = defineProps({
|
|||||||
|
|
||||||
const today = format(new Date(), "yyyy-MM-dd");
|
const today = format(new Date(), "yyyy-MM-dd");
|
||||||
|
|
||||||
const { request, download } = useAjax();
|
const { request } = useAjax();
|
||||||
|
|
||||||
const searchTerms = reactive({});
|
const searchTerms = reactive({});
|
||||||
const selectedStatuses = reactive({});
|
const selectedStatuses = reactive({});
|
||||||
@@ -46,87 +44,6 @@ const mailCompose = ref(false);
|
|||||||
|
|
||||||
const openCancelDialog = ref(false);
|
const openCancelDialog = ref(false);
|
||||||
const openPartialPaymentDialogSwitch = ref(false);
|
const openPartialPaymentDialogSwitch = ref(false);
|
||||||
const openRefundDialogSwitch = ref(false);
|
|
||||||
|
|
||||||
// Der Erstattungsdialog. `captureMode` steuert den Weg: 'participant' schickt dem Teili einen Link, über
|
|
||||||
// den er seine Bankverbindung selbst einträgt; 'management' heißt, sie liegt der Aktionsleitung bereits
|
|
||||||
// vor -- dann wird die Erstattung sofort eingereicht.
|
|
||||||
const refundForm = reactive({
|
|
||||||
amount: '', reason: '', reasonNote: '',
|
|
||||||
captureMode: 'participant', accountOwner: '', accountIban: '',
|
|
||||||
retentionReason: '', retentionReasonNote: '',
|
|
||||||
});
|
|
||||||
const refundErrors = reactive({amount: '', reason: '', reasonNote: '', accountOwner: '', accountIban: ''});
|
|
||||||
const refundReasons = ref([]);
|
|
||||||
const retentionReasons = ref([]);
|
|
||||||
const refundSaving = ref(false);
|
|
||||||
const refundResending = ref(false);
|
|
||||||
|
|
||||||
const selectedRefundReason = computed(
|
|
||||||
() => refundReasons.value.find(r => r.value === refundForm.reason) ?? null
|
|
||||||
);
|
|
||||||
|
|
||||||
const selectedRetentionReason = computed(
|
|
||||||
() => retentionReasons.value.find(r => r.value === refundForm.retentionReason) ?? null
|
|
||||||
);
|
|
||||||
|
|
||||||
/** Was nach der Erstattung beim Verband bleibt -- die Grundlage für den Einbehaltungsblock. */
|
|
||||||
const retainedAmount = computed(() => {
|
|
||||||
const paid = Number(showParticipant.value?.amountPaidValue ?? 0);
|
|
||||||
const refunded = Number((refundForm.amount ?? '').replace(',', '.'));
|
|
||||||
|
|
||||||
if (!Number.isFinite(refunded)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const remaining = Math.round((paid - refunded) * 100) / 100;
|
|
||||||
|
|
||||||
return remaining > 0.005 ? remaining : 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
const hasRetention = computed(() => retainedAmount.value > 0);
|
|
||||||
|
|
||||||
const retainedAmountReadable = computed(
|
|
||||||
() => retainedAmount.value.toFixed(2).replace('.', ',') + ' Euro'
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ob abgesendet werden kann. Der Knopf erscheint erst dann -- was noch fehlt, soll die Aktionsleitung
|
|
||||||
* sehen, bevor sie klickt, statt danach eine Fehlermeldung zu lesen.
|
|
||||||
*/
|
|
||||||
const refundFormComplete = computed(() => {
|
|
||||||
const amount = Number((refundForm.amount ?? '').replace(',', '.'));
|
|
||||||
const paid = Number(showParticipant.value?.amountPaidValue ?? 0);
|
|
||||||
|
|
||||||
if (!refundForm.amount || !(amount > 0) || amount > paid + 0.005) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!refundForm.reason) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedRefundReason.value?.requiresNote && !refundForm.reasonNote.trim()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bleibt etwas beim Verband, muss begründet sein, warum.
|
|
||||||
if (hasRetention.value) {
|
|
||||||
if (!refundForm.retentionReason) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedRetentionReason.value?.requiresNote && !refundForm.retentionReasonNote.trim()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (refundForm.captureMode === 'management') {
|
|
||||||
return refundForm.accountOwner.trim() !== '' && refundForm.accountIban.trim() !== '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
defineEmits(['showParticipantDetails', 'markCocExisting', 'paymentComplete'])
|
defineEmits(['showParticipantDetails', 'markCocExisting', 'paymentComplete'])
|
||||||
|
|
||||||
@@ -375,164 +292,6 @@ async function execPartialPayment() {
|
|||||||
openPartialPaymentDialogSwitch.value = false;
|
openPartialPaymentDialogSwitch.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Erstattung freigeben.
|
|
||||||
*
|
|
||||||
* Der Betrag ist mit dem vor, was der Teili gezahlt hat -- das ist der Regelfall; Abzüge trägt die
|
|
||||||
* Aktionsleitung von Hand ein.
|
|
||||||
*/
|
|
||||||
async function openRefundDialog(participant) {
|
|
||||||
showParticipant.value = participant;
|
|
||||||
|
|
||||||
refundForm.amount = participant.amountPaid?.short ?? '';
|
|
||||||
refundForm.reason = '';
|
|
||||||
refundForm.reasonNote = '';
|
|
||||||
// Vorgabe ist der übliche Weg über den Teili.
|
|
||||||
refundForm.captureMode = 'participant';
|
|
||||||
refundForm.accountOwner = '';
|
|
||||||
refundForm.accountIban = '';
|
|
||||||
refundForm.retentionReason = '';
|
|
||||||
refundForm.retentionReasonNote = '';
|
|
||||||
|
|
||||||
Object.keys(refundErrors).forEach(key => refundErrors[key] = '');
|
|
||||||
|
|
||||||
if (refundReasons.value.length === 0) {
|
|
||||||
const reasons = await request('/api/v1/core/retrieve-refund-reasons', {method: 'GET'});
|
|
||||||
refundReasons.value = reasons ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retentionReasons.value.length === 0) {
|
|
||||||
const reasons = await request('/api/v1/core/retrieve-retention-reasons', {method: 'GET'});
|
|
||||||
retentionReasons.value = reasons ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
openRefundDialogSwitch.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function validateRefund() {
|
|
||||||
const amount = Number((refundForm.amount ?? '').replace(',', '.'));
|
|
||||||
const paid = Number(showParticipant.value?.amountPaidValue ?? 0);
|
|
||||||
|
|
||||||
Object.keys(refundErrors).forEach(key => refundErrors[key] = '');
|
|
||||||
|
|
||||||
if (!refundForm.amount || !(amount > 0)) {
|
|
||||||
refundErrors.amount = 'Bitte gib einen Betrag größer als 0 ein.';
|
|
||||||
} else if (amount > paid + 0.005) {
|
|
||||||
refundErrors.amount = 'Mehr als der gezahlte Beitrag kann nicht erstattet werden.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!refundForm.reason) {
|
|
||||||
refundErrors.reason = 'Bitte wähle einen Grund aus.';
|
|
||||||
} else if (selectedRefundReason.value?.requiresNote && !refundForm.reasonNote.trim()) {
|
|
||||||
refundErrors.reasonNote = 'Bitte erläutere den Grund.';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Beim Direktweg wird sofort eingereicht -- danach gibt es keine Gelegenheit mehr zu berichtigen.
|
|
||||||
// Ob die IBAN wirklich stimmt, prüft der Server mit Prüfziffer und länderabhängiger Länge.
|
|
||||||
if (refundForm.captureMode === 'management') {
|
|
||||||
if (!refundForm.accountOwner.trim()) {
|
|
||||||
refundErrors.accountOwner = 'Bitte gib an, wem das Konto gehört.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!refundForm.accountIban.trim()) {
|
|
||||||
refundErrors.accountIban = 'Bitte gib die IBAN des Kontos ein.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Object.values(refundErrors).every(message => !message);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function execRefund() {
|
|
||||||
if (!validateRefund() || refundSaving.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
refundSaving.value = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const data = await request('/api/v1/participant-refund/' + showParticipant.value.identifier + '/release', {
|
|
||||||
method: "POST",
|
|
||||||
body: {
|
|
||||||
amount: refundForm.amount,
|
|
||||||
reason: refundForm.reason,
|
|
||||||
reasonNote: refundForm.reasonNote,
|
|
||||||
// Leer beim Weg über den Teili -- dann verschickt der Server nur den Link.
|
|
||||||
accountOwner: refundForm.captureMode === 'management' ? refundForm.accountOwner : '',
|
|
||||||
accountIban: refundForm.captureMode === 'management' ? refundForm.accountIban : '',
|
|
||||||
// Spende: kein Konto, trotzdem sofort eingereicht.
|
|
||||||
donation: refundForm.captureMode === 'donation',
|
|
||||||
// Leer bei voller Erstattung -- dann gibt es nichts zu begründen.
|
|
||||||
retentionReason: hasRetention.value ? refundForm.retentionReason : '',
|
|
||||||
retentionReasonNote: hasRetention.value ? refundForm.retentionReasonNote : '',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (data?.status === 'success') {
|
|
||||||
toast.success(data.message);
|
|
||||||
// Reaktiv statt per getElementById: die Meta-Zeile hängt am Vorgang und wechselt mit ihm.
|
|
||||||
// Beim Direktweg steht dort sofort "Erstattet" samt Abrechnungsnummer.
|
|
||||||
showParticipant.value.refund = data.refund;
|
|
||||||
// Der gezahlte Beitrag wird beim Einreichen auf 0 gesetzt -- sonst zeigte die Zeile weiter
|
|
||||||
// den alten Stand, bis jemand neu lädt.
|
|
||||||
if (data.refund?.status === 'accepted') {
|
|
||||||
showParticipant.value.amountPaidValue = 0;
|
|
||||||
}
|
|
||||||
openRefundDialogSwitch.value = false;
|
|
||||||
} else {
|
|
||||||
toast.error(data?.message ?? 'Die Erstattung konnte nicht freigegeben werden.');
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
refundSaving.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function execCancelRefund(participant) {
|
|
||||||
const data = await request('/api/v1/participant-refund/' + participant.refund.token + '/cancel', {
|
|
||||||
method: "POST",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (data?.status === 'success') {
|
|
||||||
toast.success(data.message);
|
|
||||||
participant.refund = null;
|
|
||||||
} else {
|
|
||||||
toast.error(data?.message ?? 'Die Erstattung konnte nicht abgebrochen werden.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Mail zur freigegebenen Erstattung noch einmal schicken -- ohne Rückfrage, es ändert sich nichts am
|
|
||||||
* Vorgang. Der Guard verhindert, dass ein zweiter Klick eine zweite Mail auslöst, bevor die erste durch ist.
|
|
||||||
*/
|
|
||||||
async function execResendRefundMail(participant) {
|
|
||||||
if (refundResending.value) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
refundResending.value = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const data = await request('/api/v1/participant-refund/' + participant.refund.token + '/resend-mail', {
|
|
||||||
method: "POST",
|
|
||||||
});
|
|
||||||
|
|
||||||
if (data?.status === 'success') {
|
|
||||||
toast.success(data.message);
|
|
||||||
} else {
|
|
||||||
toast.error(data?.message ?? 'Die Rückerstattungsmail konnte nicht versendet werden.');
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
refundResending.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function downloadRefundDocument(participant) {
|
|
||||||
const ok = await download('/api/v1/participant-refund/' + participant.refund.token + '/document');
|
|
||||||
|
|
||||||
if (!ok) {
|
|
||||||
toast.error('Der Beleg konnte nicht erstellt werden.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const mailToType = ref('')
|
const mailToType = ref('')
|
||||||
const recipientIdentifier = ref('')
|
const recipientIdentifier = ref('')
|
||||||
|
|
||||||
@@ -585,15 +344,6 @@ function mailToGroup(groupKey) {
|
|||||||
<td class="pl-amount" :id="'participant-' + participant.identifier +'-payment'" :class="participant.amount_left_value != 0 && !participant.unregistered ? 'not-paid' : ''">
|
<td class="pl-amount" :id="'participant-' + participant.identifier +'-payment'" :class="participant.amount_left_value != 0 && !participant.unregistered ? 'not-paid' : ''">
|
||||||
Gezahlt: <label :id="'participant-' + participant.identifier + '-paid'">{{ participant?.amountPaid.readable }}</label> /<br />
|
Gezahlt: <label :id="'participant-' + participant.identifier + '-paid'">{{ participant?.amountPaid.readable }}</label> /<br />
|
||||||
Gesamt: <label :id="'participant-' + participant.identifier + '-expected'">{{ participant?.amountExpected.readable }}</label>
|
Gesamt: <label :id="'participant-' + participant.identifier + '-expected'">{{ participant?.amountExpected.readable }}</label>
|
||||||
|
|
||||||
<!-- Warum ein Teil des Beitrags beim Verband geblieben ist. -->
|
|
||||||
<span v-if="participant.refund?.hasRetention" class="retention-note">
|
|
||||||
Einbehalten: {{ participant.refund.retainedAmount }}<br />
|
|
||||||
{{ participant.refund.retentionReasonLabel }}<template
|
|
||||||
v-if="participant.refund.retentionReasonNote"
|
|
||||||
> – {{ participant.refund.retentionReasonNote }}</template>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
<span v-if="participant.amount_left_value != 0 && !participant.unregistered" :id="'participant-' + participant.identifier + '-actions'">
|
<span v-if="participant.amount_left_value != 0 && !participant.unregistered" :id="'participant-' + participant.identifier + '-actions'">
|
||||||
<span class="link" style="font-size:10pt;" @click="paymentComplete(participant)">Zahlung buchen</span>
|
<span class="link" style="font-size:10pt;" @click="paymentComplete(participant)">Zahlung buchen</span>
|
||||||
@@ -645,31 +395,6 @@ function mailToGroup(groupKey) {
|
|||||||
<span class="link">E-Mail senden</span> |
|
<span class="link">E-Mail senden</span> |
|
||||||
<span @click="openCancelParticipationDialog(participant)" v-if="!participant.unregistered" class="link" style="color: #da7070;">Abmelden</span>
|
<span @click="openCancelParticipationDialog(participant)" v-if="!participant.unregistered" class="link" style="color: #da7070;">Abmelden</span>
|
||||||
<span v-else class="link" @click="execResignonParticipant(participant)" style="color: #3cb62e;">Wieder anmelden</span>
|
<span v-else class="link" @click="execResignonParticipant(participant)" style="color: #3cb62e;">Wieder anmelden</span>
|
||||||
|
|
||||||
<!-- Erstattung: erst der Einstieg, danach der Zustand des Vorgangs. -->
|
|
||||||
<template v-if="participant.unregistered">
|
|
||||||
<span
|
|
||||||
v-if="!participant.refund && Number(participant.amountPaidValue ?? 0) > 0"
|
|
||||||
class="link"
|
|
||||||
style="color: #da7070;"
|
|
||||||
@click="openRefundDialog(participant)"
|
|
||||||
> | Beitrag erstatten</span>
|
|
||||||
|
|
||||||
<template v-else-if="participant.refund?.status === 'pending'">
|
|
||||||
| <strong>Rückerstattung vorgemerkt:</strong> {{ participant.refund.amount }}
|
|
||||||
am {{ participant.refund.releasedAt }}, wartet auf Bankverbindung
|
|
||||||
<span class="link" @click="execResendRefundMail(participant)">Rückerstattungsmail erneut senden</span>
|
|
||||||
<span class="link" style="color: #da7070;" @click="execCancelRefund(participant)">Abbrechen</span>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-else-if="participant.refund?.status === 'accepted'">
|
|
||||||
| <strong>Erstattet:</strong> {{ participant.refund.amount }}
|
|
||||||
<template v-if="participant.refund.invoiceNumber">
|
|
||||||
· Abrechnung {{ participant.refund.invoiceNumber }}
|
|
||||||
</template>
|
|
||||||
<span class="link" @click="downloadRefundDocument(participant)">Beleg</span>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
||||||
@@ -735,134 +460,6 @@ function mailToGroup(groupKey) {
|
|||||||
<button class="button" @click="execPartialPayment()">Teilbetrag buchen</button>
|
<button class="button" @click="execPartialPayment()">Teilbetrag buchen</button>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<Modal
|
|
||||||
:show="openRefundDialogSwitch"
|
|
||||||
title="Beitrag erstatten"
|
|
||||||
width="480px"
|
|
||||||
@close="openRefundDialogSwitch = false"
|
|
||||||
>
|
|
||||||
<p class="refund-intro">
|
|
||||||
{{ showParticipant?.fullname }} hat
|
|
||||||
<strong>{{ showParticipant?.amountPaid?.readable }}</strong> gezahlt.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="refund-field">
|
|
||||||
<label for="refund_amount">Zu erstattender Betrag</label>
|
|
||||||
<div>
|
|
||||||
<AmountInput id="refund_amount" v-model="refundForm.amount" style="width: 100px !important;" /> Euro
|
|
||||||
</div>
|
|
||||||
<ErrorText :message="refundErrors.amount" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="refund-field">
|
|
||||||
<label for="refund_reason">Grund</label>
|
|
||||||
<select id="refund_reason" v-model="refundForm.reason" class="form-input">
|
|
||||||
<option value="">Bitte auswählen …</option>
|
|
||||||
<option v-for="reason in refundReasons" :key="reason.value" :value="reason.value">
|
|
||||||
{{ reason.label }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<ErrorText :message="refundErrors.reason" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="selectedRefundReason?.requiresNote" class="refund-field">
|
|
||||||
<label for="refund_reason_note">Erläuterung</label>
|
|
||||||
<textarea id="refund_reason_note" v-model="refundForm.reasonNote" class="form-input" rows="3"></textarea>
|
|
||||||
<ErrorText :message="refundErrors.reasonNote" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Bleibt ein Teil beim Verband, muss begründet sein, warum -- ein einbehaltener Betrag ohne
|
|
||||||
Grund ist in der Buchhaltung nicht haltbar. Bei voller Erstattung gibt es nichts zu zeigen.
|
|
||||||
-->
|
|
||||||
<template v-if="hasRetention">
|
|
||||||
<p class="refund-hint">
|
|
||||||
<strong>{{ retainedAmountReadable }}</strong> verbleiben beim Verband.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="refund-field">
|
|
||||||
<label for="refund_retention_reason">Grund der Einbehaltung</label>
|
|
||||||
<select id="refund_retention_reason" v-model="refundForm.retentionReason" class="form-input">
|
|
||||||
<option value="">Bitte auswählen …</option>
|
|
||||||
<option v-for="reason in retentionReasons" :key="reason.value" :value="reason.value">
|
|
||||||
{{ reason.label }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-if="selectedRetentionReason?.requiresNote" class="refund-field">
|
|
||||||
<label for="refund_retention_note">Erläuterung zur Einbehaltung</label>
|
|
||||||
<textarea
|
|
||||||
id="refund_retention_note"
|
|
||||||
v-model="refundForm.retentionReasonNote"
|
|
||||||
class="form-input"
|
|
||||||
rows="3"
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
Liegt die Bankverbindung schon vor oder will der Teili spenden, entfällt der Umweg über ihn:
|
|
||||||
die Erstattung wird sofort eingereicht. Er bekommt den Beleg trotzdem.
|
|
||||||
-->
|
|
||||||
<div class="refund-field">
|
|
||||||
<label class="refund-choice">
|
|
||||||
<input type="radio" value="participant" v-model="refundForm.captureMode" />
|
|
||||||
Teilnehmer*in trägt die Bankverbindung selbst ein
|
|
||||||
</label>
|
|
||||||
<label class="refund-choice">
|
|
||||||
<input type="radio" value="management" v-model="refundForm.captureMode" />
|
|
||||||
Bankverbindung liegt mir vor
|
|
||||||
</label>
|
|
||||||
<label class="refund-choice">
|
|
||||||
<input type="radio" value="donation" v-model="refundForm.captureMode" />
|
|
||||||
Teilnehmer*in spendet den Betrag
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p v-if="refundForm.captureMode === 'donation'" class="refund-hint">
|
|
||||||
Der Betrag wird nicht ausgezahlt, sondern als Spende gebucht. Die Erstattung wird sofort
|
|
||||||
eingereicht; der Teili erhält den Beleg per E-Mail.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<template v-if="refundForm.captureMode === 'management'">
|
|
||||||
<div class="refund-field">
|
|
||||||
<label for="refund_account_owner">Kontoinhaber*in</label>
|
|
||||||
<input
|
|
||||||
id="refund_account_owner"
|
|
||||||
v-model="refundForm.accountOwner"
|
|
||||||
type="text"
|
|
||||||
class="form-input"
|
|
||||||
/>
|
|
||||||
<ErrorText :message="refundErrors.accountOwner" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="refund-field">
|
|
||||||
<label for="refund_account_iban">IBAN</label>
|
|
||||||
<IbanInput id="refund_account_iban" v-model="refundForm.accountIban" class="form-input" />
|
|
||||||
<ErrorText :message="refundErrors.accountIban" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="refund-hint">
|
|
||||||
Die Erstattung wird sofort als Abrechnung eingereicht. Der Teili erhält den Beleg per
|
|
||||||
E-Mail und kann die Angaben prüfen.
|
|
||||||
</p>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<!-- Erscheint erst, wenn alles ausgefüllt ist; während des Speicherns gesperrt statt weg. -->
|
|
||||||
<button
|
|
||||||
v-if="refundFormComplete"
|
|
||||||
class="button"
|
|
||||||
:disabled="refundSaving"
|
|
||||||
@click="execRefund()"
|
|
||||||
>
|
|
||||||
<template v-if="refundSaving">Wird gespeichert…</template>
|
|
||||||
<template v-else-if="refundForm.captureMode === 'management'">Erstattung einreichen</template>
|
|
||||||
<template v-else-if="refundForm.captureMode === 'donation'">Als Spende einreichen</template>
|
|
||||||
<template v-else>Erstattung freigeben</template>
|
|
||||||
</button>
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<FullScreenModal
|
<FullScreenModal
|
||||||
:show="mailCompose"
|
:show="mailCompose"
|
||||||
title="E-Mail senden"
|
title="E-Mail senden"
|
||||||
@@ -876,58 +473,6 @@ function mailToGroup(groupKey) {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.refund-intro {
|
|
||||||
margin-bottom: 16px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
color: #4b5563;
|
|
||||||
}
|
|
||||||
|
|
||||||
.refund-field {
|
|
||||||
margin-bottom: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.refund-field label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
color: #4b5563;
|
|
||||||
}
|
|
||||||
|
|
||||||
.refund-field select,
|
|
||||||
.refund-field textarea,
|
|
||||||
.refund-field .form-input {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.refund-choice {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 6px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
color: #1a1a1a;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.refund-choice input {
|
|
||||||
margin-right: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.retention-note {
|
|
||||||
display: block;
|
|
||||||
margin-top: 6px;
|
|
||||||
font-size: 10pt;
|
|
||||||
color: #ca5a0a;
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.refund-hint {
|
|
||||||
margin-bottom: 14px;
|
|
||||||
padding: 8px 10px;
|
|
||||||
border-left: 3px solid #f5c400;
|
|
||||||
background-color: #fffef5;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
color: #4b5563;
|
|
||||||
}
|
|
||||||
|
|
||||||
.participants-table {
|
.participants-table {
|
||||||
width: 95%;
|
width: 95%;
|
||||||
margin: 20px auto;
|
margin: 20px auto;
|
||||||
|
|||||||
@@ -68,17 +68,6 @@ const props = defineProps({
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!--
|
|
||||||
Beiträge, die trotz Abmeldung beim Verband geblieben sind. Eigene Zeile, weil die
|
|
||||||
Zeilen darüber nur aktive Anmeldungen führen.
|
|
||||||
-->
|
|
||||||
<tr v-if="props.event.retainedFromUnregistered.value > 0">
|
|
||||||
<th style="padding-bottom: 20px" colspan="2">Einbehalten von Abmeldungen</th>
|
|
||||||
<td style="padding-bottom: 20px" colspan="2">
|
|
||||||
{{ props.event.retainedFromUnregistered.readable }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" style="border-width: 1px; border-top-style: solid">Gesamt</th>
|
<th colspan="2" style="border-width: 1px; border-top-style: solid">Gesamt</th>
|
||||||
<td style="font-weight: bold; border-width: 1px; border-top-style: solid">
|
<td style="font-weight: bold; border-width: 1px; border-top-style: solid">
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ChangeStatusCommand {
|
|||||||
switch ($this->request->status) {
|
switch ($this->request->status) {
|
||||||
case InvoiceStatus::INVOICE_STATUS_APPROVED:
|
case InvoiceStatus::INVOICE_STATUS_APPROVED:
|
||||||
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_APPROVED;
|
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_APPROVED;
|
||||||
$this->request->invoice->approved_by = currentUserOrFail()->id;
|
$this->request->invoice->approved_by = auth()->user()->id;
|
||||||
$this->request->invoice->approved_at = now();
|
$this->request->invoice->approved_at = now();
|
||||||
|
|
||||||
if ($this->request->invoice->contact_email !== null) {
|
if ($this->request->invoice->contact_email !== null) {
|
||||||
@@ -35,7 +35,7 @@ class ChangeStatusCommand {
|
|||||||
|
|
||||||
case InvoiceStatus::INVOICE_STATUS_DENIED:
|
case InvoiceStatus::INVOICE_STATUS_DENIED:
|
||||||
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_DENIED;
|
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_DENIED;
|
||||||
$this->request->invoice->denied_by = currentUserOrFail()->id;
|
$this->request->invoice->denied_by = auth()->user()->id;
|
||||||
$this->request->invoice->denied_at = now();
|
$this->request->invoice->denied_at = now();
|
||||||
$this->request->invoice->denied_reason = $this->request->comment;
|
$this->request->invoice->denied_reason = $this->request->comment;
|
||||||
if ($this->request->invoice->contact_email !== null) {
|
if ($this->request->invoice->contact_email !== null) {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
namespace App\Domains\Invoice\Actions\CreateInvoice;
|
namespace App\Domains\Invoice\Actions\CreateInvoice;
|
||||||
|
|
||||||
use App\Enumerations\InvoiceStatus;
|
use App\Enumerations\InvoiceStatus;
|
||||||
use App\Enumerations\InvoiceType;
|
|
||||||
use App\Enumerations\TravelReason;
|
|
||||||
use App\Mail\InvoiceMails\InvoiceMailsNewInvoiceMail;
|
use App\Mail\InvoiceMails\InvoiceMailsNewInvoiceMail;
|
||||||
use App\Mail\InvoiceMails\InvoiceMailsSubmittedConfirmationMail;
|
use App\Mail\InvoiceMails\InvoiceMailsSubmittedConfirmationMail;
|
||||||
use App\Mail\ParticipantParticipationMails\EventSignUpSuccessfullMail;
|
use App\Mail\ParticipantParticipationMails\EventSignUpSuccessfullMail;
|
||||||
@@ -21,27 +19,17 @@ class CreateInvoiceCommand {
|
|||||||
public function execute() : CreateInvoiceResponse {
|
public function execute() : CreateInvoiceResponse {
|
||||||
$response = new CreateInvoiceResponse();
|
$response = new CreateInvoiceResponse();
|
||||||
|
|
||||||
$rejection = $this->rejectTravelReason();
|
|
||||||
if ($rejection !== null) {
|
|
||||||
$response->message = $rejection;
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->request->accountIban === 'undefined') {
|
if ($this->request->accountIban === 'undefined') {
|
||||||
$this->request->accountIban = null;
|
$this->request->accountIban = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$travelReason = $this->travelReason();
|
|
||||||
|
|
||||||
$invoice = Invoice::create([
|
$invoice = Invoice::create([
|
||||||
'tenant' => currentTenant()->slug,
|
'tenant' => app('tenant')->slug,
|
||||||
'cost_unit_id' => $this->request->costUnit->id,
|
'cost_unit_id' => $this->request->costUnit->id,
|
||||||
'invoice_number' => $this->generateInvoiceNumber(),
|
'invoice_number' => $this->generateInvoiceNumber(),
|
||||||
'status' => InvoiceStatus::INVOICE_STATUS_NEW,
|
'status' => InvoiceStatus::INVOICE_STATUS_NEW,
|
||||||
'type' => $this->request->invoiceType,
|
'type' => $this->request->invoiceType,
|
||||||
'type_other' => $this->request->invoiceTypeExtended,
|
'type_other' => $this->request->invoiceTypeExtended,
|
||||||
'purpose' => $this->purpose($travelReason),
|
|
||||||
'donation' => $this->request->isDonation,
|
'donation' => $this->request->isDonation,
|
||||||
'user_id' => $this->request->paymentPurpose === null ? $this->request->userId : null,
|
'user_id' => $this->request->paymentPurpose === null ? $this->request->userId : null,
|
||||||
'contact_name' => $this->request->contactName,
|
'contact_name' => $this->request->contactName,
|
||||||
@@ -52,7 +40,9 @@ class CreateInvoiceCommand {
|
|||||||
'amount' => $this->request->totalAmount,
|
'amount' => $this->request->totalAmount,
|
||||||
'distance' => $this->request->distance,
|
'distance' => $this->request->distance,
|
||||||
'travel_direction' => $this->request->travelRoute,
|
'travel_direction' => $this->request->travelRoute,
|
||||||
'travel_reason' => $travelReason,
|
'travel_reason' => $this->request->travelReason,
|
||||||
|
'passengers' => $this->request->passengers,
|
||||||
|
'transportation' => $this->request->transportations,
|
||||||
'payment_purpose' => $this->request->paymentPurpose,
|
'payment_purpose' => $this->request->paymentPurpose,
|
||||||
'comment' => $this->request->notices,
|
'comment' => $this->request->notices,
|
||||||
'document_filename' => $this->request->receiptFile !== null ? $this->request->receiptFile->fullPath : null,
|
'document_filename' => $this->request->receiptFile !== null ? $this->request->receiptFile->fullPath : null,
|
||||||
@@ -71,7 +61,7 @@ class CreateInvoiceCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->request->costUnit->mail_on_new) {
|
if ($this->request->costUnit->mail_on_new) {
|
||||||
$recipients = [currentTenant()->email_finance];
|
$recipients = [app('tenant')->email_finance];
|
||||||
|
|
||||||
foreach ($this->request->costUnit->treasurers()->get() as $treasurer) {
|
foreach ($this->request->costUnit->treasurers()->get() as $treasurer) {
|
||||||
if (!in_array($treasurer->email, $recipients)) {
|
if (!in_array($treasurer->email, $recipients)) {
|
||||||
@@ -91,71 +81,9 @@ class CreateInvoiceCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der Zahlungsgrund, einmal beim Anlegen festgehalten.
|
|
||||||
*
|
|
||||||
* Danach ist er eine eigene Angabe: Die Kassenwart*in kann ihn korrigieren, und nichts schreibt ihn
|
|
||||||
* mehr um. Bei Fahrtkosten setzt er sich aus Reisegrund und den gefahrenen Personen zusammen, sonst
|
|
||||||
* trägt ihn "Was wurde eingekauft". Wo nichts erfasst wird -- Beitragserstattungen -- bleibt er leer.
|
|
||||||
*
|
|
||||||
* Steht er schon fest, wird er übernommen: Eine Abrechnungskorrektur kopiert den Beleg, und ein von
|
|
||||||
* Hand gesetzter Grund darf dabei nicht verloren gehen.
|
|
||||||
*/
|
|
||||||
private function purpose(?string $travelReason) : ?string {
|
|
||||||
if (trim((string) $this->request->purpose) !== '') {
|
|
||||||
return $this->request->purpose;
|
|
||||||
}
|
|
||||||
|
|
||||||
$purpose = Invoice::joinPurposeParts(
|
|
||||||
$this->request->invoiceType === InvoiceType::INVOICE_TYPE_TRAVELLING
|
|
||||||
// Der Name des Grundes, nicht sein Schlüssel: In der Belegliste soll "Materialtransport"
|
|
||||||
// stehen, nicht "material_transport".
|
|
||||||
? [TravelReason::text($travelReason), $this->request->travellers]
|
|
||||||
: [$this->request->invoiceTypeExtended]
|
|
||||||
);
|
|
||||||
|
|
||||||
return $purpose === '' ? null : $purpose;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Was in `travel_reason` landet: der Schlüssel des gewählten Grundes -- oder, bei "Anderer Grund",
|
|
||||||
* der Text selbst. Der Schlüssel `other` sagt für sich nichts aus, der Text alles.
|
|
||||||
*
|
|
||||||
* Ein unbekannter Wert ist deshalb kein Fehler, sondern genau dieser Fall: So kommen auch
|
|
||||||
* Bestandsbelege und Kopien durch, die ihren Freitext schon mitbringen.
|
|
||||||
*/
|
|
||||||
private function travelReason() : ?string {
|
|
||||||
$reason = TravelReason::find($this->request->travelReason);
|
|
||||||
|
|
||||||
if ($reason === null) {
|
|
||||||
return $this->request->travelReason;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $reason->requires_note
|
|
||||||
? trim((string) $this->request->travelReasonNote)
|
|
||||||
: $reason->slug;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sicherheitsnetz hinter der Oberfläche: Dort geht es erst weiter, wenn die Erläuterung steht. Über
|
|
||||||
* einen direkten Aufruf ginge das sonst vorbei, und ein "Anderer Grund" ohne Text sagt nichts aus --
|
|
||||||
* gespeichert würde ein leerer Reisegrund.
|
|
||||||
*/
|
|
||||||
private function rejectTravelReason() : ?string {
|
|
||||||
$reason = TravelReason::find($this->request->travelReason);
|
|
||||||
|
|
||||||
if ($reason === null || !$reason->requires_note) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim((string) $this->request->travelReasonNote) === ''
|
|
||||||
? 'Bitte gib an, was der Grund für die Reise war.'
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function generateInvoiceNumber() : string {
|
private function generateInvoiceNumber() : string {
|
||||||
$lastInvoiceNumber = Invoice::query()
|
$lastInvoiceNumber = Invoice::query()
|
||||||
->where('tenant', currentTenant()->slug)
|
->where('tenant', app('tenant')->slug)
|
||||||
->whereYear('created_at', date('Y'))
|
->whereYear('created_at', date('Y'))
|
||||||
->count();
|
->count();
|
||||||
|
|
||||||
|
|||||||
@@ -16,24 +16,16 @@ class CreateInvoiceRequest {
|
|||||||
public ?string $invoiceTypeExtended;
|
public ?string $invoiceTypeExtended;
|
||||||
public ?string $travelRoute;
|
public ?string $travelRoute;
|
||||||
public ?int $distance;
|
public ?int $distance;
|
||||||
|
public ?int $passengers;
|
||||||
|
public ?int $transportations;
|
||||||
public ?InvoiceFile $receiptFile;
|
public ?InvoiceFile $receiptFile;
|
||||||
public float $totalAmount;
|
public float $totalAmount;
|
||||||
public bool $isDonation;
|
public bool $isDonation;
|
||||||
public ?int $userId;
|
public ?int $userId;
|
||||||
/** Der Slug eines Reisegrundes -- oder ein Freitext, wenn er von einem Bestandsbeleg stammt. */
|
|
||||||
public ?string $travelReason;
|
public ?string $travelReason;
|
||||||
|
|
||||||
/** Die Erläuterung zu "Anderer Grund"; nur bei einem Grund mit `requires_note` von Belang. */
|
|
||||||
public ?string $travelReasonNote;
|
|
||||||
public ?string $paymentPurpose;
|
public ?string $paymentPurpose;
|
||||||
public ?string $notices;
|
public ?string $notices;
|
||||||
|
|
||||||
/** Wer gereist ist -- Freitext aus dem Fahrtkosten-Formular, geht in den Zahlungsgrund ein. */
|
|
||||||
public ?string $travellers;
|
|
||||||
|
|
||||||
/** Ein bereits feststehender Zahlungsgrund; gesetzt, gewinnt er über die Ermittlung im Command. */
|
|
||||||
public ?string $purpose;
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
CostUnit $costUnit,
|
CostUnit $costUnit,
|
||||||
@@ -50,12 +42,11 @@ class CreateInvoiceRequest {
|
|||||||
?string $invoiceTypeExtended = null,
|
?string $invoiceTypeExtended = null,
|
||||||
?string $travelRoute = null,
|
?string $travelRoute = null,
|
||||||
?int $distance = null,
|
?int $distance = null,
|
||||||
|
?int $passengers = null,
|
||||||
|
?int $transportations,
|
||||||
?string $travelReason = null,
|
?string $travelReason = null,
|
||||||
?string $travelReasonNote = null,
|
|
||||||
?string $paymentPurpose = null,
|
?string $paymentPurpose = null,
|
||||||
?string $notices = null,
|
?string $notices = null,
|
||||||
?string $travellers = null,
|
|
||||||
?string $purpose = null,
|
|
||||||
|
|
||||||
) {
|
) {
|
||||||
$this->costUnit = $costUnit;
|
$this->costUnit = $costUnit;
|
||||||
@@ -64,6 +55,8 @@ class CreateInvoiceRequest {
|
|||||||
$this->invoiceTypeExtended = $invoiceTypeExtended;
|
$this->invoiceTypeExtended = $invoiceTypeExtended;
|
||||||
$this->travelRoute = $travelRoute;
|
$this->travelRoute = $travelRoute;
|
||||||
$this->distance = $distance;
|
$this->distance = $distance;
|
||||||
|
$this->passengers = $passengers;
|
||||||
|
$this->transportations = $transportations;
|
||||||
$this->receiptFile = $receiptFile;
|
$this->receiptFile = $receiptFile;
|
||||||
$this->contactEmail = $contactEmail;
|
$this->contactEmail = $contactEmail;
|
||||||
$this->contactPhone = $contactPhone;
|
$this->contactPhone = $contactPhone;
|
||||||
@@ -73,11 +66,8 @@ class CreateInvoiceRequest {
|
|||||||
$this->isDonation = $isDonation;
|
$this->isDonation = $isDonation;
|
||||||
$this->userId = $userId;
|
$this->userId = $userId;
|
||||||
$this->travelReason = $travelReason;
|
$this->travelReason = $travelReason;
|
||||||
$this->travelReasonNote = $travelReasonNote;
|
|
||||||
$this->paymentPurpose = $paymentPurpose;
|
$this->paymentPurpose = $paymentPurpose;
|
||||||
$this->notices = $notices;
|
$this->notices = $notices;
|
||||||
$this->travellers = $travellers;
|
|
||||||
$this->purpose = $purpose;
|
|
||||||
|
|
||||||
if ($accountIban === 'undefined') {
|
if ($accountIban === 'undefined') {
|
||||||
$this->accountIban = null;
|
$this->accountIban = null;
|
||||||
|
|||||||
@@ -8,12 +8,8 @@ class CreateInvoiceResponse {
|
|||||||
public bool $success;
|
public bool $success;
|
||||||
public ?Invoice $invoice;
|
public ?Invoice $invoice;
|
||||||
|
|
||||||
/** Warum keine Abrechnung entstanden ist -- für die Rückmeldung an die einreichende Person. */
|
|
||||||
public ?string $message;
|
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->success = false;
|
$this->success = false;
|
||||||
$this->invoice = null;
|
$this->invoice = null;
|
||||||
$this->message = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,8 +83,10 @@ class CreateInvoiceReceiptCommand {
|
|||||||
|
|
||||||
$travelPartTemplate = <<<HTML
|
$travelPartTemplate = <<<HTML
|
||||||
<tr><td>Reiseweg:</td><td>%1\$s</td></tr>
|
<tr><td>Reiseweg:</td><td>%1\$s</td></tr>
|
||||||
<tr><td>Grund der Reise:</td><td>%4\$s</td></tr>
|
<tr><td>Grund der Reise:</td><td>%6\$s</td></tr>
|
||||||
<tr><td>Gesamtlänge der Strecke:</td><td>%2\$s km x %3\$s / km</td></tr>
|
<tr><td>Gesamtlänge der Strecke:</td><td>%2\$s km x %3\$s / km</td></tr>
|
||||||
|
<tr><td>Materialtransport:</td><td>%4\$s</td></tr>
|
||||||
|
<tr><td>Mitfahrende im PKW:</td><td>%5\$s</td></tr>
|
||||||
HTML;
|
HTML;
|
||||||
|
|
||||||
$flatTravelPart = sprintf(
|
$flatTravelPart = sprintf(
|
||||||
@@ -92,6 +94,8 @@ HTML;
|
|||||||
$invoiceReadable['travelDirection'] ,
|
$invoiceReadable['travelDirection'] ,
|
||||||
$invoiceReadable['distance'],
|
$invoiceReadable['distance'],
|
||||||
$invoiceReadable['distanceAllowance'],
|
$invoiceReadable['distanceAllowance'],
|
||||||
|
$invoiceReadable['transportation'],
|
||||||
|
$invoiceReadable['passengers'],
|
||||||
$invoiceReadable['travelReason'] ,
|
$invoiceReadable['travelReason'] ,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -176,10 +180,7 @@ HTML;
|
|||||||
$invoiceReadable['contactEmail'],
|
$invoiceReadable['contactEmail'],
|
||||||
$invoiceReadable['contactPhone'],
|
$invoiceReadable['contactPhone'],
|
||||||
$invoiceReadable['costUnitName'],
|
$invoiceReadable['costUnitName'],
|
||||||
// Der erfasste Zahlungsgrund, nicht der Abrechnungstyp: Der steht eine Zeile darüber schon
|
$invoiceReadable['invoiceType'],
|
||||||
// als Überschrift. Bei Fahrtkosten ist das die einzige Stelle, an der auf dem Beleg steht,
|
|
||||||
// wer gereist ist.
|
|
||||||
$invoiceReadable['purpose'],
|
|
||||||
$invoiceReadable['donationText'],
|
$invoiceReadable['donationText'],
|
||||||
$paymentType,
|
$paymentType,
|
||||||
$invoiceReadable['amount'],
|
$invoiceReadable['amount'],
|
||||||
|
|||||||
@@ -34,17 +34,6 @@ class UpdateInvoiceCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$purpose = trim((string) $this->request->purpose);
|
|
||||||
$purpose = $purpose === '' ? null : $purpose;
|
|
||||||
|
|
||||||
// Verglichen wird gegen den angezeigten Text, nicht gegen die Spalte: Das Formular ist damit
|
|
||||||
// vorbelegt, und wer ihn unverändert abschickt, hat nichts geändert. Ein Bestandsbeleg behält so
|
|
||||||
// seine leere Spalte und damit die Ableitung; wer das Feld leert, schaltet zurück auf automatisch.
|
|
||||||
if (($purpose ?? '') !== $this->request->invoice->purposeText()) {
|
|
||||||
$changes .= 'Zahlungsgrund geändert von ' . $this->request->invoice->purposeText() . ' auf ' . ($purpose ?? '--') . '.<br />';
|
|
||||||
$this->request->invoice->purpose = $purpose;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->request->invoice->comment = $this->request->comment;
|
$this->request->invoice->comment = $this->request->comment;
|
||||||
$this->request->invoice->changes = $changes;
|
$this->request->invoice->changes = $changes;
|
||||||
|
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ class UpdateInvoiceRequest {
|
|||||||
public CostUnit $costUnit;
|
public CostUnit $costUnit;
|
||||||
public Invoice $invoice;
|
public Invoice $invoice;
|
||||||
public Amount $amount;
|
public Amount $amount;
|
||||||
public ?string $purpose;
|
|
||||||
|
|
||||||
public function __construct(Invoice $invoice, ?string $comment, InvoiceType $invoiceType, CostUnit $costUnit, Amount $amount, ?string $purpose = null) {
|
public function __construct(Invoice $invoice, ?string $comment, InvoiceType $invoiceType, CostUnit $costUnit, Amount $amount) {
|
||||||
$this->comment = $comment;
|
$this->comment = $comment;
|
||||||
$this->purpose = $purpose;
|
|
||||||
$this->invoiceType = $invoiceType;
|
$this->invoiceType = $invoiceType;
|
||||||
$this->costUnit = $costUnit;
|
$this->costUnit = $costUnit;
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class UploadInvoiceCommand {
|
|||||||
$uploadDir = sprintf(
|
$uploadDir = sprintf(
|
||||||
'%1$s%2$s/%3$s',
|
'%1$s%2$s/%3$s',
|
||||||
WebDavProvider::INVOICE_PREFIX,
|
WebDavProvider::INVOICE_PREFIX,
|
||||||
currentTenant()->url,
|
app('tenant')->url,
|
||||||
$this->request->invoice->costUnit()->first()->name
|
$this->request->invoice->costUnit()->first()->name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -32,26 +32,25 @@ class EditController extends CommonController{
|
|||||||
$receiptfile->fullPath = $invoice->document_filename;
|
$receiptfile->fullPath = $invoice->document_filename;
|
||||||
}
|
}
|
||||||
$createInvoiceRequest = new CreateInvoiceRequest(
|
$createInvoiceRequest = new CreateInvoiceRequest(
|
||||||
costUnit: $invoice->costUnit()->first(),
|
$invoice->costUnit()->first(),
|
||||||
contactName: $invoice->contact_name,
|
$invoice->contact_name,
|
||||||
invoiceType: $invoice->type,
|
$invoice->type,
|
||||||
totalAmount: $invoice->amount,
|
$invoice->amount,
|
||||||
receiptFile: $receiptfile,
|
$receiptfile,
|
||||||
isDonation: $invoice->donation,
|
$invoice->donation,
|
||||||
userId: $invoice->user_id,
|
$invoice->user_id,
|
||||||
contactEmail: $invoice->contact_email,
|
$invoice->contact_email,
|
||||||
contactPhone: $invoice->contact_phone,
|
$invoice->contact_phone,
|
||||||
accountOwner: $invoice->contact_bank_owner,
|
$invoice->contact_bank_owner,
|
||||||
accountIban: $invoice->contact_bank_iban,
|
$invoice->contact_bank_iban,
|
||||||
invoiceTypeExtended: $invoice->type_other,
|
$invoice->type_other,
|
||||||
travelRoute: $invoice->travel_direction,
|
$invoice->travel_direction,
|
||||||
distance: $invoice->distance,
|
$invoice->distance,
|
||||||
travelReason: $invoice->travel_reason,
|
$invoice->passengers,
|
||||||
paymentPurpose: $invoice->payment_purpose,
|
$invoice->transportation,
|
||||||
notices: $invoice->comment,
|
$invoice->travel_reason,
|
||||||
// Die rohe Spalte, nicht purposeText(): Ein Beleg, der seinen Zahlungsgrund bisher ableitet,
|
$invoice->payment_purpose,
|
||||||
// soll das als Kopie weiter tun.
|
$invoice->comment,
|
||||||
purpose: $invoice->purpose,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$invoiceCreationCommand = new CreateInvoiceCommand($createInvoiceRequest);
|
$invoiceCreationCommand = new CreateInvoiceCommand($createInvoiceRequest);
|
||||||
@@ -93,8 +92,7 @@ class EditController extends CommonController{
|
|||||||
$modifyData['notices'],
|
$modifyData['notices'],
|
||||||
$invoiceType,
|
$invoiceType,
|
||||||
$newCostUnit,
|
$newCostUnit,
|
||||||
$newAmount,
|
$newAmount
|
||||||
$modifyData['purpose'] ?? null
|
|
||||||
);
|
);
|
||||||
$updateInvoiceCommand = new UpdateInvoiceCommand($updateInvoiceRequest);
|
$updateInvoiceCommand = new UpdateInvoiceCommand($updateInvoiceRequest);
|
||||||
$updateInvoiceCommand->execute();
|
$updateInvoiceCommand->execute();
|
||||||
@@ -109,22 +107,22 @@ class EditController extends CommonController{
|
|||||||
$receiptfile->fullPath = $invoice->document_filename;
|
$receiptfile->fullPath = $invoice->document_filename;
|
||||||
}
|
}
|
||||||
$createInvoiceRequest = new CreateInvoiceRequest(
|
$createInvoiceRequest = new CreateInvoiceRequest(
|
||||||
costUnit: $invoice->costUnit()->first(),
|
$invoice->costUnit()->first(),
|
||||||
contactName: $invoice->contact_name,
|
$invoice->contact_name,
|
||||||
invoiceType: $invoice->type,
|
$invoice->type,
|
||||||
totalAmount: $amountLeft->getAmount(),
|
$amountLeft->getAmount(),
|
||||||
receiptFile: $receiptfile,
|
$receiptfile,
|
||||||
isDonation: $invoice->donation,
|
$invoice->donation,
|
||||||
userId: $invoice->user_id,
|
$invoice->user_id,
|
||||||
contactEmail: $invoice->contact_email,
|
$invoice->contact_email,
|
||||||
contactPhone: $invoice->contact_phone,
|
$invoice->contact_phone,
|
||||||
accountOwner: $invoice->contact_bank_owner,
|
$invoice->contact_bank_owner,
|
||||||
accountIban: $invoice->contact_bank_iban,
|
$invoice->contact_bank_iban,
|
||||||
invoiceTypeExtended: $invoice->type_other,
|
$invoice->type_other,
|
||||||
travelRoute: $invoice->travel_direction,
|
$invoice->travel_direction,
|
||||||
distance: $invoice->distance,
|
$invoice->distance,
|
||||||
travelReason: $invoice->travel_reason,
|
$invoice->passengers,
|
||||||
purpose: $invoice->purpose,
|
$invoice->transportation
|
||||||
);
|
);
|
||||||
|
|
||||||
$invoiceCreationCommand = new CreateInvoiceCommand($createInvoiceRequest);
|
$invoiceCreationCommand = new CreateInvoiceCommand($createInvoiceRequest);
|
||||||
|
|||||||
@@ -66,43 +66,50 @@ class SaveInvoiceController extends CommonController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$createInvoiceRequest = new CreateInvoiceRequest(
|
$createInvoiceRequest = new CreateInvoiceRequest(
|
||||||
costUnit: $costUnit,
|
$costUnit,
|
||||||
contactName: $request->input('name'),
|
$request->input('name'),
|
||||||
invoiceType: InvoiceType::INVOICE_TYPE_TRAVELLING,
|
InvoiceType::INVOICE_TYPE_TRAVELLING,
|
||||||
totalAmount: $amount,
|
$amount,
|
||||||
receiptFile: $uploadedFile,
|
$uploadedFile,
|
||||||
isDonation: 'donation' === $request->input('decision') ? true : false,
|
'donation' === $request->input('decision') ? true : false,
|
||||||
userId: $this->users->getCurrentUserDetails()['userId'],
|
$this->users->getCurrentUserDetails()['userId'],
|
||||||
contactEmail: $request->input('email'),
|
$request->input('email'),
|
||||||
contactPhone: $request->input('telephone'),
|
$request->input('telephone'),
|
||||||
accountOwner: $request->input('accountOwner'),
|
$request->input('accountOwner'),
|
||||||
accountIban: $request->input('accountIban'),
|
$request->input('accountIban'),
|
||||||
travelRoute: $request->input('otherText'),
|
null,
|
||||||
distance: $distance,
|
$request->input('otherText'),
|
||||||
travelReason: $request->input('travelReason'),
|
$distance,
|
||||||
travelReasonNote: $request->input('travelReasonNote'),
|
$request->input('havePassengers'),
|
||||||
notices: $notices,
|
$request->input('materialTransportation'),
|
||||||
travellers: $request->input('travellers')
|
$request->input('travelReason'),
|
||||||
|
null,
|
||||||
|
$notices
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$createInvoiceRequest = new CreateInvoiceRequest(
|
$createInvoiceRequest = new CreateInvoiceRequest(
|
||||||
costUnit: $costUnit,
|
$costUnit,
|
||||||
contactName: $request->input('name'),
|
$request->input('name'),
|
||||||
invoiceType: $invoiceType,
|
$invoiceType,
|
||||||
totalAmount: Amount::fromString($request->input('amount'))->getAmount(),
|
Amount::fromString($request->input('amount'))->getAmount(),
|
||||||
receiptFile: $uploadedFile,
|
$uploadedFile,
|
||||||
isDonation: 'donation' === $request->input('decision') ? true : false,
|
'donation' === $request->input('decision') ? true : false,
|
||||||
userId: $this->users->getCurrentUserDetails()['userId'],
|
$this->users->getCurrentUserDetails()['userId'],
|
||||||
contactEmail: $request->input('email'),
|
$request->input('email'),
|
||||||
contactPhone: $request->input('telephone'),
|
$request->input('telephone'),
|
||||||
accountOwner: $request->input('accountOwner'),
|
$request->input('accountOwner'),
|
||||||
accountIban: $request->input('accountIban'),
|
$request->input('accountIban'),
|
||||||
invoiceTypeExtended: $request->input('otherText'),
|
$request->input('otherText'),
|
||||||
paymentPurpose: $paymentPurpose,
|
null,
|
||||||
notices: $notices
|
null,
|
||||||
|
$request->input('havePassengers'),
|
||||||
|
$request->input('materialTransportation'),
|
||||||
|
null,
|
||||||
|
$paymentPurpose,
|
||||||
|
$notices
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -121,11 +128,5 @@ class SaveInvoiceController extends CommonController
|
|||||||
'message' => 'Alright'
|
'message' => 'Alright'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json([
|
|
||||||
'status' => 'error',
|
|
||||||
'message' => $response->message
|
|
||||||
?? 'Beim Speichern ist ein Fehler aufgetreten. Bitte starte den Vorgang erneut.'
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,15 @@ const props = defineProps({
|
|||||||
<td style="font-weight: bold">{{props.invoice.amount}}</td>
|
<td style="font-weight: bold">{{props.invoice.amount}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>Marterialtransport</th>
|
||||||
|
<td>{{props.invoice.transportation}}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>Hat Personen mitgenommen</th>
|
||||||
|
<td>{{props.invoice.passengers}}</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -16,18 +16,11 @@ const props = defineProps({
|
|||||||
|
|
||||||
const emit = defineEmits(['submit', 'cancel'])
|
const emit = defineEmits(['submit', 'cancel'])
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Anmerkung heißt in der Resource `comment` und ist dort `'--'`, wenn keine gesetzt ist -- beides
|
|
||||||
* muss hier stimmen, sonst startet das Feld leer und das Speichern löscht die vorhandene Anmerkung.
|
|
||||||
*/
|
|
||||||
const existingComment = props.newInvoice.comment
|
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
type_internal: props.newInvoice.internalType || '',
|
type_internal: props.newInvoice.internalType || '',
|
||||||
cost_unit: props.newInvoice.costUnitId || '',
|
cost_unit: props.newInvoice.costUnitId || '',
|
||||||
amount: props.newInvoice.amountPlain || '',
|
amount: props.newInvoice.amountPlain || '',
|
||||||
purpose: props.newInvoice.purpose || '',
|
notices: props.newInvoice.comments || '',
|
||||||
notices: !existingComment || existingComment === '--' ? '' : existingComment,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const submitForm = () => {
|
const submitForm = () => {
|
||||||
@@ -77,13 +70,6 @@ onMounted(async () => {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>Zahlungsgrund:</td>
|
|
||||||
<td>
|
|
||||||
<input type="text" v-model="formData.purpose" class="width-almost-full" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Anmerkungen:</td>
|
<td>Anmerkungen:</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -100,10 +100,6 @@ const emit = defineEmits(["accept", "deny", "fix", "reopen"])
|
|||||||
<td v-else-if="props.data.externalPayment">Rechnungszahlung</td>
|
<td v-else-if="props.data.externalPayment">Rechnungszahlung</td>
|
||||||
<td v-else>Klassische Auszahlung</td>
|
<td v-else>Klassische Auszahlung</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>Zahlungsgrund:</td>
|
|
||||||
<td colspan="3">{{props.data.purpose}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Status:</td>
|
<td>Status:</td>
|
||||||
<td>{{props.data.readableStatus}}</td>
|
<td>{{props.data.readableStatus}}</td>
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ const props = defineProps({
|
|||||||
<td style="font-weight: bold">{{props.invoice.amount}}</td>
|
<td style="font-weight: bold">{{props.invoice.amount}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>Marterialtransport</th>
|
||||||
|
<td>{{props.invoice.transportation}}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<th>Hat Personen mitgenommen</th>
|
||||||
|
<td>{{props.invoice.passengers}}</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -45,13 +45,12 @@
|
|||||||
<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="7">{{props.data.title}}</td>
|
<td colspan="6">{{props.data.title}}</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.invoiceTypeShort}}</td>
|
<td>{{invoice.invoiceType}}</td>
|
||||||
<td style="max-width: 250px;">{{invoice.purpose}}</td>
|
|
||||||
<td>
|
<td>
|
||||||
{{invoice.amount}}
|
{{invoice.amount}}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import { ref, computed, onMounted, reactive } from 'vue'
|
import { ref, onMounted, reactive } from 'vue'
|
||||||
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
||||||
import RefundData from "./refund-data.vue";
|
import RefundData from "./refund-data.vue";
|
||||||
import AmountInput from "../../../../../Views/Components/AmountInput.vue";
|
import AmountInput from "../../../../../Views/Components/AmountInput.vue";
|
||||||
@@ -38,20 +38,6 @@ onMounted(async () => {
|
|||||||
Object.assign(invoiceTypeCollection, data);
|
Object.assign(invoiceTypeCollection, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Das Beispiel im Feld "Was wurde eingekauft" kommt aus `invoice_types.purchase_example` und ist damit
|
|
||||||
* ohne Deployment pflegbar. Ein allgemeines "z. B. Material" hilft beim Ausfüllen nicht weiter, und von
|
|
||||||
* genau diesem Text lebt später die Zweck-Spalte der EüR-Belegliste.
|
|
||||||
*
|
|
||||||
* Ist am Typ nichts gepflegt, greift der allgemeine Text -- ein Feld ohne jede Hilfestellung wäre
|
|
||||||
* schlechter als ein unscharfes Beispiel.
|
|
||||||
*/
|
|
||||||
const purchasePlaceholder = computed(() => {
|
|
||||||
const selected = Object.values(invoiceTypeCollection.invoiceTypes)
|
|
||||||
.find((type) => type.slug === invoiceType.value)
|
|
||||||
|
|
||||||
return selected?.purchaseExample || 'z. B. Material für die Veranstaltung'
|
|
||||||
})
|
|
||||||
|
|
||||||
function handleFileChange(event) {
|
function handleFileChange(event) {
|
||||||
if (checkFilesize('receipt')) {
|
if (checkFilesize('receipt')) {
|
||||||
@@ -80,36 +66,28 @@ function handleFileChange(event) {
|
|||||||
<InfoIcon :text="'INFO_INVOICE_TYPE_' + availableInvoiceType.slug" /><br />
|
<InfoIcon :text="'INFO_INVOICE_TYPE_' + availableInvoiceType.slug" /><br />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</fieldset><br /><br />
|
|
||||||
|
|
||||||
<!--
|
<label for="invoice_type_other">
|
||||||
Pflichtangabe zu jeder Rechnung, nicht nur zu "Sonstige Kosten": Erst dieser Text sagt, wofür das
|
|
||||||
Geld ausgegeben wurde, und füllt damit die Zweck-Spalte der EüR-Belegliste.
|
|
||||||
|
|
||||||
Die Schritte bauen aufeinander auf -- ohne Ausgabenart gäbe es kein passendes Beispiel für den
|
|
||||||
Einkauf, und ein Betrag ohne Zweck ließe sich später nicht mehr zuordnen.
|
|
||||||
-->
|
|
||||||
<template v-if="invoiceType !== null">
|
|
||||||
<fieldset>
|
|
||||||
<legend><span style="font-weight: bolder;">Was wurde eingekauft</span></legend>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="width-full"
|
class="width-full"
|
||||||
id="purchase_description"
|
name="kostengruppe_sonstiges"
|
||||||
name="purchase_description"
|
placeholder="Sonstige"
|
||||||
:placeholder="purchasePlaceholder"
|
for="invoice_type_other"
|
||||||
v-model="otherText"
|
v-model="otherText"
|
||||||
|
@focus="invoiceType = 'other'"
|
||||||
/>
|
/>
|
||||||
</fieldset><br /><br />
|
</label>
|
||||||
</template>
|
|
||||||
|
|
||||||
<fieldset v-if="invoiceType !== null && otherText.trim() !== ''">
|
</fieldset><br /><br />
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
<legend><span style="font-weight: bolder;">Wie hoch ist der Betrag</span></legend>
|
<legend><span style="font-weight: bolder;">Wie hoch ist der Betrag</span></legend>
|
||||||
<AmountInput v-model="amount" class="width-small" id="amount" name="amount" /> Euro
|
<AmountInput v-model="amount" class="width-small" id="amount" name="amount" /> Euro
|
||||||
<info-icon></info-icon><br /><br />
|
<info-icon></info-icon><br /><br />
|
||||||
|
|
||||||
<input
|
<input
|
||||||
v-if="amount != ''"
|
v-if="amount != '' && invoiceType !== null"
|
||||||
class="mareike-button"
|
class="mareike-button"
|
||||||
onclick="document.getElementById('receipt').click();"
|
onclick="document.getElementById('receipt').click();"
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
|
||||||
import { ref, computed, onMounted, reactive } from 'vue'
|
import { ref, onMounted, reactive } from 'vue'
|
||||||
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
||||||
import RefundData from "./refund-data.vue";
|
import RefundData from "./refund-data.vue";
|
||||||
import AmountInput from "../../../../../Views/Components/AmountInput.vue";
|
import AmountInput from "../../../../../Views/Components/AmountInput.vue";
|
||||||
@@ -37,20 +37,6 @@ onMounted(async () => {
|
|||||||
Object.assign(invoiceTypeCollection, data);
|
Object.assign(invoiceTypeCollection, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* Das Beispiel im Feld "Was wurde eingekauft" kommt aus `invoice_types.purchase_example` und ist damit
|
|
||||||
* ohne Deployment pflegbar. Ein allgemeines "z. B. Material" hilft beim Ausfüllen nicht weiter, und von
|
|
||||||
* genau diesem Text lebt später die Zweck-Spalte der EüR-Belegliste.
|
|
||||||
*
|
|
||||||
* Ist am Typ nichts gepflegt, greift der allgemeine Text -- ein Feld ohne jede Hilfestellung wäre
|
|
||||||
* schlechter als ein unscharfes Beispiel.
|
|
||||||
*/
|
|
||||||
const purchasePlaceholder = computed(() => {
|
|
||||||
const selected = Object.values(invoiceTypeCollection.invoiceTypes)
|
|
||||||
.find((type) => type.slug === invoiceType.value)
|
|
||||||
|
|
||||||
return selected?.purchaseExample || 'z. B. Material für die Veranstaltung'
|
|
||||||
})
|
|
||||||
|
|
||||||
function handleFileChange(event) {
|
function handleFileChange(event) {
|
||||||
if (checkFilesize('receipt')) {
|
if (checkFilesize('receipt')) {
|
||||||
@@ -79,36 +65,28 @@ function handleFileChange(event) {
|
|||||||
<InfoIcon :text="'INFO_INVOICE_TYPE_' + availableInvoiceType.slug" /><br />
|
<InfoIcon :text="'INFO_INVOICE_TYPE_' + availableInvoiceType.slug" /><br />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</fieldset><br /><br />
|
|
||||||
|
|
||||||
<!--
|
<label for="invoice_type_other">
|
||||||
Pflichtangabe zu jeder Abrechnung, nicht nur zu "Sonstige Kosten": Erst dieser Text sagt, wofür
|
|
||||||
das Geld ausgegeben wurde, und füllt damit die Zweck-Spalte der EüR-Belegliste.
|
|
||||||
|
|
||||||
Die Schritte bauen aufeinander auf -- ohne Ausgabenart gäbe es kein passendes Beispiel für den
|
|
||||||
Einkauf, und ein Betrag ohne Zweck ließe sich später nicht mehr zuordnen.
|
|
||||||
-->
|
|
||||||
<template v-if="invoiceType !== null">
|
|
||||||
<fieldset>
|
|
||||||
<legend><span style="font-weight: bolder;">Was wurde eingekauft</span></legend>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
class="width-full"
|
class="width-full"
|
||||||
id="purchase_description"
|
name="kostengruppe_sonstiges"
|
||||||
name="purchase_description"
|
placeholder="Sonstige"
|
||||||
:placeholder="purchasePlaceholder"
|
for="invoice_type_other"
|
||||||
v-model="otherText"
|
v-model="otherText"
|
||||||
|
@focus="invoiceType = 'other'"
|
||||||
/>
|
/>
|
||||||
</fieldset><br /><br />
|
</label>
|
||||||
</template>
|
|
||||||
|
|
||||||
<fieldset v-if="invoiceType !== null && otherText.trim() !== ''">
|
</fieldset><br /><br />
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
<legend><span style="font-weight: bolder;">Wie hoch ist der Betrag</span></legend>
|
<legend><span style="font-weight: bolder;">Wie hoch ist der Betrag</span></legend>
|
||||||
<AmountInput v-model="amount" class="width-small" id="amount" name="amount" /> Euro
|
<AmountInput v-model="amount" class="width-small" id="amount" name="amount" /> Euro
|
||||||
<info-icon></info-icon><br /><br />
|
<info-icon></info-icon><br /><br />
|
||||||
|
|
||||||
<input
|
<input
|
||||||
v-if="amount != ''"
|
v-if="amount != '' && invoiceType !== null"
|
||||||
class="mareike-button"
|
class="mareike-button"
|
||||||
onclick="document.getElementById('receipt').click();"
|
onclick="document.getElementById('receipt').click();"
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ const props = defineProps({
|
|||||||
userTelephone: String,
|
userTelephone: String,
|
||||||
userAccountOwner: String,
|
userAccountOwner: String,
|
||||||
userAccountIban: String,
|
userAccountIban: String,
|
||||||
|
havePassengers: Number,
|
||||||
|
materialTransportation: Boolean,
|
||||||
travelReason: String,
|
travelReason: String,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -59,6 +61,8 @@ async function sendData() {
|
|||||||
formData.append('accountOwner', userAccountOwner.value)
|
formData.append('accountOwner', userAccountOwner.value)
|
||||||
formData.append('accountIban', userIban.value)
|
formData.append('accountIban', userIban.value)
|
||||||
formData.append('paymentPurpose', paymentPurpose.value)
|
formData.append('paymentPurpose', paymentPurpose.value)
|
||||||
|
formData.append('havePassengers', props.havePassengers ? 1 : 0)
|
||||||
|
formData.append('materialTransportation', props.materialTransportation ? 1 : 0)
|
||||||
formData.append('travelReason', props.travelReason)
|
formData.append('travelReason', props.travelReason)
|
||||||
|
|
||||||
if (props.receipt) {
|
if (props.receipt) {
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ const props = defineProps({
|
|||||||
userTelephone: String,
|
userTelephone: String,
|
||||||
userAccountOwner: String,
|
userAccountOwner: String,
|
||||||
userAccountIban: String,
|
userAccountIban: String,
|
||||||
|
havePassengers: Number,
|
||||||
|
materialTransportation: Boolean,
|
||||||
travelReason: String,
|
travelReason: String,
|
||||||
travelReasonNote: String,
|
|
||||||
travellers: String,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const finalStep = ref(true)
|
const finalStep = ref(true)
|
||||||
@@ -60,9 +60,9 @@ async function sendData() {
|
|||||||
formData.append('decision', decision.value)
|
formData.append('decision', decision.value)
|
||||||
formData.append('accountOwner', userAccountOwner.value)
|
formData.append('accountOwner', userAccountOwner.value)
|
||||||
formData.append('accountIban', userIban.value)
|
formData.append('accountIban', userIban.value)
|
||||||
|
formData.append('havePassengers', props.havePassengers ? 1 : 0)
|
||||||
|
formData.append('materialTransportation', props.materialTransportation ? 1 : 0)
|
||||||
formData.append('travelReason', props.travelReason)
|
formData.append('travelReason', props.travelReason)
|
||||||
formData.append('travelReasonNote', props.travelReasonNote ?? '')
|
|
||||||
formData.append('travellers', props.travellers ?? '')
|
|
||||||
formData.append('notices', notices.value)
|
formData.append('notices', notices.value)
|
||||||
|
|
||||||
if (props.receipt) {
|
if (props.receipt) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onMounted, reactive } from 'vue'
|
import { ref, onMounted, reactive } from 'vue'
|
||||||
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
import {checkFilesize} from "../../../../../../resources/js/components/InvoiceUploadChecks.js";
|
||||||
import RefundData from "./refund-data.vue";
|
import RefundData from "./refund-data.vue";
|
||||||
import NumericInput from "../../../../../Views/Components/NumericInput.vue";
|
import NumericInput from "../../../../../Views/Components/NumericInput.vue";
|
||||||
@@ -19,44 +19,15 @@ const { request } = useAjax();
|
|||||||
const distanceAllowance = ref(null);
|
const distanceAllowance = ref(null);
|
||||||
const travelDirection = ref(null);
|
const travelDirection = ref(null);
|
||||||
const travelReason = ref(null);
|
const travelReason = ref(null);
|
||||||
const travelReasonNote = ref('');
|
|
||||||
|
|
||||||
const travelReasonCollection = reactive({
|
|
||||||
travelReasons: []
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectedTravelReason = computed(() =>
|
|
||||||
travelReasonCollection.travelReasons.find((reason) => reason.value === travelReason.value)
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ein Grund ist erst vollständig, wenn die Erläuterung steht, die er verlangt: "Anderer Grund" allein
|
|
||||||
* sagt nichts aus. Die drei anderen Gründe bremsen den Ablauf dadurch nicht.
|
|
||||||
*/
|
|
||||||
const travelReasonComplete = computed(() =>
|
|
||||||
selectedTravelReason.value !== undefined
|
|
||||||
&& (!selectedTravelReason.value.requiresNote || travelReasonNote.value.trim() !== '')
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wer gereist ist, steht später als Zahlungsgrund in der Belegliste, auf der EüR und auf dem Beleg. Wer
|
|
||||||
* den Beleg einreicht, war meist selbst dabei -- deshalb der eigene Name als Vorschlag. Ohne Login
|
|
||||||
* bleibt das Feld leer, und es hält den Ablauf auch dann nicht auf: Ein Name ist eine Hilfe, keine
|
|
||||||
* Bedingung.
|
|
||||||
*/
|
|
||||||
const travellers = ref(data.userName || '');
|
|
||||||
const have_receipt = ref('')
|
const have_receipt = ref('')
|
||||||
|
const havePassengers = ref(false);
|
||||||
|
const materialTransportation = ref(false);
|
||||||
const amount = ref(0.00);
|
const amount = ref(0.00);
|
||||||
const invoiceType = ref(null);
|
const invoiceType = ref(null);
|
||||||
const otherText = ref('');
|
const otherText = ref('');
|
||||||
const receipt = ref(null)
|
const receipt = ref(null)
|
||||||
const finalStep = ref(false)
|
const finalStep = ref(false)
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const response = await fetch('/api/v1/core/retrieve-travel-reasons');
|
|
||||||
travelReasonCollection.travelReasons = await response.json();
|
|
||||||
});
|
|
||||||
|
|
||||||
async function getDistanceAllowance() {
|
async function getDistanceAllowance() {
|
||||||
const tempData = await request('/api/v1/cost-unit/get-distance-allowance/' + data.eventId, {
|
const tempData = await request('/api/v1/cost-unit/get-distance-allowance/' + data.eventId, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@@ -88,40 +59,14 @@ function handleFileChange(event) {
|
|||||||
|
|
||||||
<fieldset v-if="travelDirection !== null">
|
<fieldset v-if="travelDirection !== null">
|
||||||
<legend><span style="font-weight: bolder;">Was war der Grund für deine Reise?</span></legend>
|
<legend><span style="font-weight: bolder;">Was war der Grund für deine Reise?</span></legend>
|
||||||
|
|
||||||
<p v-for="availableReason in travelReasonCollection.travelReasons">
|
|
||||||
<input
|
|
||||||
name="travel-reason"
|
|
||||||
type="radio"
|
|
||||||
:value="availableReason.value"
|
|
||||||
:id="'travel_reason_' + availableReason.value"
|
|
||||||
v-model="travelReason"
|
|
||||||
>
|
|
||||||
<label :for="'travel_reason_' + availableReason.value">{{ availableReason.label }}</label><br />
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<template v-if="selectedTravelReason?.requiresNote">
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
class="width-full"
|
|
||||||
name="travel-reason-note"
|
|
||||||
placeholder="z. B. Abholung der Ausrüstung aus dem Lager"
|
|
||||||
v-model="travelReasonNote"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</fieldset><br /><br />
|
|
||||||
|
|
||||||
<fieldset v-if="travelReasonComplete">
|
|
||||||
<legend><span style="font-weight: bolder;">Welche Personen sind gereist?</span></legend>
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="travellers"
|
name="travel-reason"
|
||||||
placeholder="z. B. Mika, Kim und Alex"
|
v-model="travelReason"
|
||||||
v-model="travellers"
|
|
||||||
/>
|
/>
|
||||||
</fieldset><br /><br />
|
</fieldset><br /><br />
|
||||||
|
|
||||||
<fieldset v-if="travelReasonComplete">
|
<fieldset v-if="travelReason !== null">
|
||||||
<legend><span style="font-weight: bolder;">Bist du mit dem ÖPNV gefahren oder besitzt du einen Beleg</span></legend>
|
<legend><span style="font-weight: bolder;">Bist du mit dem ÖPNV gefahren oder besitzt du einen Beleg</span></legend>
|
||||||
<input type="button" style="border-radius: 0; width: 100px;" @click="have_receipt='yes'" value="Ja" />
|
<input type="button" style="border-radius: 0; width: 100px;" @click="have_receipt='yes'" value="Ja" />
|
||||||
<input type="button" style="border-radius: 0; width: 100px;" @click="getDistanceAllowance" value="Nein" />
|
<input type="button" style="border-radius: 0; width: 100px;" @click="getDistanceAllowance" value="Nein" />
|
||||||
@@ -148,6 +93,8 @@ function handleFileChange(event) {
|
|||||||
invoice-type="travelling"
|
invoice-type="travelling"
|
||||||
:amount="amount"
|
:amount="amount"
|
||||||
:other-text="travelDirection"
|
:other-text="travelDirection"
|
||||||
|
:materialTransportation="materialTransportation"
|
||||||
|
:havePassengers="havePassengers"
|
||||||
:userName="data.userName"
|
:userName="data.userName"
|
||||||
:userEmail="data.userEmail"
|
:userEmail="data.userEmail"
|
||||||
:userTelephone="data.userTelephone"
|
:userTelephone="data.userTelephone"
|
||||||
@@ -155,8 +102,6 @@ function handleFileChange(event) {
|
|||||||
:userAccountOwner="data.userAccountOwner"
|
:userAccountOwner="data.userAccountOwner"
|
||||||
:receipt="receipt"
|
:receipt="receipt"
|
||||||
:travelReason="travelReason"
|
:travelReason="travelReason"
|
||||||
:travelReasonNote="travelReasonNote"
|
|
||||||
:travellers="travellers"
|
|
||||||
@close="finalStep = false"
|
@close="finalStep = false"
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
@@ -172,6 +117,22 @@ function handleFileChange(event) {
|
|||||||
<span style="font-weight: normal">({{ amount }} km x {{distanceAllowance.toFixed(2).replace('.', ',')}} Euro / km = <strong>{{ (amount * distanceAllowance).toFixed(2).replace('.', ',') }} Euro</strong>)</span>
|
<span style="font-weight: normal">({{ amount }} km x {{distanceAllowance.toFixed(2).replace('.', ',')}} Euro / km = <strong>{{ (amount * distanceAllowance).toFixed(2).replace('.', ',') }} Euro</strong>)</span>
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="havePassengers"
|
||||||
|
v-model="havePassengers"
|
||||||
|
id="havePassengers"
|
||||||
|
/> <label style="margin-bottom: 20px;" for="havePassengers">Ich habe Personen mitgenommen</label>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
name="materialTransportation"
|
||||||
|
v-model="materialTransportation"
|
||||||
|
id="materialTransportation"
|
||||||
|
/> <label style="margin-bottom: 20px;" for="materialTransportation">Ich habe Material transportiert</label>
|
||||||
|
<br /><br />
|
||||||
|
|
||||||
<input
|
<input
|
||||||
v-if="amount !== null && have_receipt === 'no' && amount != '0'"
|
v-if="amount !== null && have_receipt === 'no' && amount != '0'"
|
||||||
@click="finalStep = true;"
|
@click="finalStep = true;"
|
||||||
@@ -184,14 +145,14 @@ function handleFileChange(event) {
|
|||||||
invoice-type="travelling"
|
invoice-type="travelling"
|
||||||
:amount="amount"
|
:amount="amount"
|
||||||
:other-text="travelDirection"
|
:other-text="travelDirection"
|
||||||
|
:materialTransportation="materialTransportation"
|
||||||
|
:havePassengers="havePassengers"
|
||||||
:userName="data.userName"
|
:userName="data.userName"
|
||||||
:userEmail="data.userEmail"
|
:userEmail="data.userEmail"
|
||||||
:userTelephone="data.userTelephone"
|
:userTelephone="data.userTelephone"
|
||||||
:userAccountIban="data.userAccountIban"
|
:userAccountIban="data.userAccountIban"
|
||||||
:userAccountOwner="data.userAccountOwner"
|
:userAccountOwner="data.userAccountOwner"
|
||||||
:travelReason="travelReason"
|
:travelReason="travelReason"
|
||||||
:travelReasonNote="travelReasonNote"
|
|
||||||
:travellers="travellers"
|
|
||||||
@close="finalStep = false"
|
@close="finalStep = false"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
-418
@@ -1,418 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantInvoice\Actions\CreateParticipantInvoice;
|
|
||||||
|
|
||||||
use App\Enumerations\TaxExemptionReason;
|
|
||||||
use App\EventPaymentModules\DTO\CreateInvoiceRequest;
|
|
||||||
use App\Models\DocumentTemplate;
|
|
||||||
use App\Models\Event;
|
|
||||||
use App\Models\EventParticipant;
|
|
||||||
use App\Models\Tenant;
|
|
||||||
use App\Providers\DocumentTemplateRenderProvider;
|
|
||||||
use App\Providers\PdfGenerateAndDownloadProvider;
|
|
||||||
use App\RelationModels\EventParticipationFee;
|
|
||||||
use App\Support\DateRange;
|
|
||||||
use App\ValueObjects\Amount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Erzeugt die Rechnung über den Teilnahmebeitrag als PDF.
|
|
||||||
*
|
|
||||||
* Es wird nichts gespeichert: die Rechnungsnummer ergibt sich deterministisch aus Veranstaltung und
|
|
||||||
* Position des Teilis, der Inhalt aus dessen aktuellem Stand. Ein erneuter Abruf liefert unter derselben
|
|
||||||
* Nummer den dann gültigen Stand.
|
|
||||||
*/
|
|
||||||
class CreateParticipantInvoiceCommand
|
|
||||||
{
|
|
||||||
private EventParticipant $participant;
|
|
||||||
|
|
||||||
private Event $event;
|
|
||||||
|
|
||||||
/** Der Rechnungssteller. Gehört zum Mandanten, nicht zur Veranstaltung -- siehe buildTokens(). */
|
|
||||||
private ?Tenant $sender;
|
|
||||||
|
|
||||||
public function __construct(private readonly CreateParticipantInvoiceRequest $request)
|
|
||||||
{
|
|
||||||
$this->participant = $request->participant;
|
|
||||||
$this->event = $request->participant->event;
|
|
||||||
|
|
||||||
// Über die Relation und nicht über currentTenant(): die Rechnung hängt an der Veranstaltung,
|
|
||||||
// nicht am gerade aktiven Mandanten. `$event->tenant` liefert das Slug-Attribut, nicht die
|
|
||||||
// Relation -- deshalb der ausdrückliche Aufruf.
|
|
||||||
$this->sender = $this->event->tenant()->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(): CreateParticipantInvoiceResponse
|
|
||||||
{
|
|
||||||
$response = new CreateParticipantInvoiceResponse();
|
|
||||||
|
|
||||||
if ($this->event->invoice_key === null || $this->participant->invoice_sequence === null) {
|
|
||||||
$response->message = 'Für diese Anmeldung lässt sich keine Rechnungsnummer bilden.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
$invoiceNumber = sprintf(
|
|
||||||
'%s-%s',
|
|
||||||
$this->event->invoice_key,
|
|
||||||
str_pad((string) $this->participant->invoice_sequence, 4, '0', STR_PAD_LEFT)
|
|
||||||
);
|
|
||||||
|
|
||||||
$lines = $this->buildLines();
|
|
||||||
$gross = round($this->participant->amount?->getAmount() ?? 0.0, 2);
|
|
||||||
|
|
||||||
$html = new DocumentTemplateRenderProvider(DocumentTemplate::TYPE_PARTICIPANT_INVOICE)
|
|
||||||
->render($this->buildTokens($invoiceNumber, $lines, $gross));
|
|
||||||
|
|
||||||
$response->success = true;
|
|
||||||
$response->invoiceNumber = $invoiceNumber;
|
|
||||||
$response->filename = 'Rechnung-' . $invoiceNumber . '.pdf';
|
|
||||||
$response->pdfContent = PdfGenerateAndDownloadProvider::fromHtml($html, 'portrait');
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Rechnungspositionen.
|
|
||||||
*
|
|
||||||
* Der Beitragsanteil wird nicht neu berechnet, sondern aus dem gespeicherten Gesamtbetrag abgeleitet:
|
|
||||||
* `amount` ist Beitrag + Zusätze (siehe SignupController), die Zusätze liegen als Snapshot-Zeilen vor.
|
|
||||||
* Damit stimmt die Rechnung immer mit dem überein, was der Teili tatsächlich zahlen soll -- unabhängig
|
|
||||||
* davon, ob die Beiträge der Veranstaltung inzwischen geändert wurden oder der Early-Bird-Stichtag
|
|
||||||
* verstrichen ist.
|
|
||||||
*
|
|
||||||
* @return array<int, array{description: string, quantity: ?float, unit: string, unitPrice: ?float, amount: float}>
|
|
||||||
*/
|
|
||||||
private function buildLines(): array
|
|
||||||
{
|
|
||||||
$addons = $this->participant->selectedAddons;
|
|
||||||
|
|
||||||
$addonTotal = 0.0;
|
|
||||||
foreach ($addons as $addon) {
|
|
||||||
$addonTotal += $addon->amount?->getAmount() ?? 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$fee = round(($this->participant->amount?->getAmount() ?? 0.0) - $addonTotal, 2);
|
|
||||||
$days = $this->attendanceDays();
|
|
||||||
|
|
||||||
// Die Preiskette in EventResource::calculateAmount() besteht nur aus Multiplikationen; der Faktor
|
|
||||||
// 0,5 der Geschwisterermäßigung wirkt damit auf den gesamten Endbetrag. Der Listenpreis ist also
|
|
||||||
// exakt das Doppelte des gespeicherten Beitragsanteils, der Rabatt genau dieser Anteil.
|
|
||||||
$listed = $this->participant->sibling_reduction ? round($fee * 2, 2) : $fee;
|
|
||||||
|
|
||||||
$lines = [$this->line(
|
|
||||||
$this->feeDescription(),
|
|
||||||
$listed,
|
|
||||||
$this->event->pay_per_day ? $days : 1
|
|
||||||
)];
|
|
||||||
|
|
||||||
if ($this->participant->sibling_reduction) {
|
|
||||||
$lines[] = [
|
|
||||||
'description' => 'Geschwisterermäßigung 50 %',
|
|
||||||
'quantity' => null,
|
|
||||||
'unit' => '',
|
|
||||||
'unitPrice' => null,
|
|
||||||
'amount' => -$fee,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($addons as $addon) {
|
|
||||||
$lines[] = $this->line(
|
|
||||||
(string) $addon->title,
|
|
||||||
$addon->amount?->getAmount() ?? 0.0,
|
|
||||||
$addon->flat ? 1 : (int) $addon->days
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Eine Position mit Mengenaufteilung -- aber nur, wenn sie aufgeht.
|
|
||||||
*
|
|
||||||
* Der Endbetrag ist gerundet gespeichert; bei krummen Tagessätzen (etwa nach einem
|
|
||||||
* Early-Bird-Aufschlag) ergäbe Menge × gerundeter Einzelpreis einen anderen Wert als der Betrag der
|
|
||||||
* Zeile. Eine Rechnung, deren Positionen sich nicht nachrechnen lassen, ist unbrauchbar -- in dem
|
|
||||||
* Fall entfällt die Aufteilung und die Position steht als Gesamtbetrag da.
|
|
||||||
*
|
|
||||||
* @return array{description: string, quantity: ?float, unit: string, unitPrice: ?float, amount: float}
|
|
||||||
*/
|
|
||||||
private function line(string $description, float $amount, int $quantity): array
|
|
||||||
{
|
|
||||||
$amount = round($amount, 2);
|
|
||||||
|
|
||||||
if ($quantity > 1) {
|
|
||||||
$unitPrice = round($amount / $quantity, 2);
|
|
||||||
|
|
||||||
if (abs($unitPrice * $quantity - $amount) < 0.005) {
|
|
||||||
return [
|
|
||||||
'description' => $description,
|
|
||||||
'quantity' => (float) $quantity,
|
|
||||||
'unit' => 'Tage',
|
|
||||||
'unitPrice' => $unitPrice,
|
|
||||||
'amount' => $amount,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'description' => $description,
|
|
||||||
'quantity' => 1.0,
|
|
||||||
'unit' => '',
|
|
||||||
'unitPrice' => $amount,
|
|
||||||
'amount' => $amount,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bezeichnung der Beitragsposition. Der Gruppenname stammt aus dem am Event hinterlegten Beitrag,
|
|
||||||
* dessen `type` der Teilnahmeart entspricht -- dieselbe Auflösung wie in EventResource.
|
|
||||||
*/
|
|
||||||
private function feeDescription(): string
|
|
||||||
{
|
|
||||||
$group = $this->participationFee()?->name;
|
|
||||||
|
|
||||||
$description = $group !== null && trim($group) !== ''
|
|
||||||
? sprintf('Teilnahme %s in Gruppe %s', $this->event->name, $group)
|
|
||||||
: sprintf('Teilnahme %s', $this->event->name);
|
|
||||||
|
|
||||||
$feeTypeLabel = match ($this->participant->fee_type) {
|
|
||||||
'standard' => 'Standardbeitrag',
|
|
||||||
'reduced' => 'Reduzierter Beitrag',
|
|
||||||
'solidarity' => 'Solidaritätsbeitrag',
|
|
||||||
// Altanmeldungen vor Einführung von `fee_type` -- dann bleibt der Zusatz weg.
|
|
||||||
default => null,
|
|
||||||
};
|
|
||||||
|
|
||||||
return $feeTypeLabel === null
|
|
||||||
? $description
|
|
||||||
: sprintf('%s (%s)', $description, $feeTypeLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function participationFee(): ?EventParticipationFee
|
|
||||||
{
|
|
||||||
return collect([
|
|
||||||
$this->event->participationFee1,
|
|
||||||
$this->event->participationFee2,
|
|
||||||
$this->event->participationFee3,
|
|
||||||
$this->event->participationFee4,
|
|
||||||
])
|
|
||||||
->filter(fn(?EventParticipationFee $fee) => $fee !== null)
|
|
||||||
->first(fn(EventParticipationFee $fee) => $fee->type === $this->participant->participation_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function attendanceDays(): int
|
|
||||||
{
|
|
||||||
$arrival = $this->participant->arrival_date;
|
|
||||||
$departure = $this->participant->departure_date;
|
|
||||||
|
|
||||||
if ($arrival === null || $departure === null) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DateRange::inclusiveDays($arrival, $departure);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Umsatzsteuer aus dem Brutto herausrechnen. Gespeichert ist immer der finale Brutto-Betrag -- beim
|
|
||||||
* Preismodus `add_on` wurde die USt bereits bei der Anmeldung aufgeschlagen, bei `inclusive` war sie
|
|
||||||
* von Anfang an enthalten. Für die Rechnung ist die Rechnung deshalb in beiden Fällen dieselbe, der
|
|
||||||
* Preismodus spielt hier keine Rolle mehr.
|
|
||||||
*
|
|
||||||
* @return array{net: float, vat: float}
|
|
||||||
*/
|
|
||||||
private function splitVat(float $gross): array
|
|
||||||
{
|
|
||||||
if (!$this->event->tax_liable || $this->event->vat_rate <= 0) {
|
|
||||||
return ['net' => $gross, 'vat' => 0.0];
|
|
||||||
}
|
|
||||||
|
|
||||||
$vat = round($gross * $this->event->vat_rate / (100 + $this->event->vat_rate), 2);
|
|
||||||
|
|
||||||
return ['net' => round($gross - $vat, 2), 'vat' => $vat];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der je Zahlungsart variierende Schlusssatz, bezogen auf den noch offenen Betrag.
|
|
||||||
*/
|
|
||||||
private function closingStatement(): string
|
|
||||||
{
|
|
||||||
$module = $this->participant->paymentModule();
|
|
||||||
if ($module === null) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$open = new Amount($this->participant->amount?->getAmount() ?? 0.0, 'Euro');
|
|
||||||
if ($this->participant->amount_paid !== null) {
|
|
||||||
$open->subtractAmount($this->participant->amount_paid);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $module->createInvoice(new CreateInvoiceRequest(
|
|
||||||
$this->event,
|
|
||||||
$this->participant,
|
|
||||||
$open,
|
|
||||||
$this->participant->paymentConfiguration(),
|
|
||||||
));
|
|
||||||
|
|
||||||
return (string) ($result->closingStatement ?? '');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Leistungszeitraum: bei eintägigen Veranstaltungen nur ein Datum, sonst der Zeitraum.
|
|
||||||
*/
|
|
||||||
private function servicePeriod(): string
|
|
||||||
{
|
|
||||||
$start = $this->event->start_date;
|
|
||||||
$end = $this->event->end_date;
|
|
||||||
|
|
||||||
if ($start === null) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($end === null || $start->isSameDay($end)) {
|
|
||||||
return $start->format('d.m.Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf('%s – %s', $start->format('d.m.Y'), $end->format('d.m.Y'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<int, array<string, mixed>> $lines
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
private function buildTokens(string $invoiceNumber, array $lines, float $gross): array
|
|
||||||
{
|
|
||||||
$participant = $this->participant;
|
|
||||||
$sender = $this->sender;
|
|
||||||
|
|
||||||
return [
|
|
||||||
'document_title' => 'Rechnung ' . $invoiceNumber,
|
|
||||||
|
|
||||||
'invoice_number' => $invoiceNumber,
|
|
||||||
// Rechnungsdatum ist das Anmeldedatum, Leistungsdatum der Veranstaltungszeitraum.
|
|
||||||
'invoice_date' => $participant->created_at?->format('d.m.Y') ?? '',
|
|
||||||
'service_period' => $this->servicePeriod(),
|
|
||||||
|
|
||||||
// Der Rechnungssteller wird live vom Mandanten gelesen, nicht auf der Veranstaltung
|
|
||||||
// eingefroren: eine Korrektur an Name oder Anschrift soll auch auf bestehende
|
|
||||||
// Veranstaltungen wirken. Eingefroren bleibt nur, was den Preis erklärt (Steuergrundlage)
|
|
||||||
// und die Nummer (invoice_key).
|
|
||||||
'sender_name' => $sender?->invoiceSenderName() ?? '',
|
|
||||||
'sender_address_1' => (string) $sender?->address_1,
|
|
||||||
'sender_address_2' => (string) $sender?->address_2,
|
|
||||||
'sender_address_3' => (string) $sender?->address_3,
|
|
||||||
'sender_postcode' => (string) $sender?->postcode,
|
|
||||||
'sender_city' => (string) $sender?->city,
|
|
||||||
'sender_email' => (string) $sender?->email,
|
|
||||||
'sender_phone' => (string) $sender?->phone,
|
|
||||||
'sender_tax_number' => (string) $sender?->tax_number,
|
|
||||||
'sender_vat_id' => (string) $sender?->vat_id,
|
|
||||||
|
|
||||||
'recipient_name' => $participant->getOfficialName(),
|
|
||||||
'recipient_address_1' => (string) $participant->address_1,
|
|
||||||
'recipient_address_2' => (string) $participant->address_2,
|
|
||||||
'recipient_postcode' => (string) $participant->postcode,
|
|
||||||
'recipient_city' => (string) $participant->city,
|
|
||||||
|
|
||||||
'positions_table' => $this->renderPositions($lines),
|
|
||||||
'summary_table' => $this->renderSummary($gross),
|
|
||||||
'closing_statement' => $this->closingStatement(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param array<int, array<string, mixed>> $lines */
|
|
||||||
private function renderPositions(array $lines): string
|
|
||||||
{
|
|
||||||
$rows = '';
|
|
||||||
foreach ($lines as $index => $line) {
|
|
||||||
$quantity = $line['quantity'] === null
|
|
||||||
? ''
|
|
||||||
: trim($this->quantity((float) $line['quantity']) . ' ' . $line['unit']);
|
|
||||||
|
|
||||||
$rows .= sprintf(
|
|
||||||
'<tr><td>%d</td><td>%s</td><td class="r">%s</td><td class="r">%s</td><td class="r">%s</td></tr>',
|
|
||||||
$index + 1,
|
|
||||||
e((string) $line['description']),
|
|
||||||
e($quantity),
|
|
||||||
$line['unitPrice'] === null ? '' : $this->money((float) $line['unitPrice']),
|
|
||||||
$this->money((float) $line['amount']),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<table class="pos-table">'
|
|
||||||
. '<thead><tr>'
|
|
||||||
. '<th style="width:8%;">Nr.</th>'
|
|
||||||
. '<th style="width:44%;">Bezeichnung</th>'
|
|
||||||
. '<th style="width:12%;" class="r">Menge</th>'
|
|
||||||
. '<th style="width:18%;" class="r">Einzelpreis</th>'
|
|
||||||
. '<th style="width:18%;" class="r">Gesamt</th>'
|
|
||||||
. '</tr></thead>'
|
|
||||||
. '<tbody>' . $rows . '</tbody>'
|
|
||||||
. '</table>';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Summenblock. Bei Steuerpflicht wird die USt aus dem Brutto ausgewiesen, sonst steht statt der
|
|
||||||
* USt-Zeile der Pflichthinweis nach § 14 Abs. 4 Nr. 8 UStG.
|
|
||||||
*/
|
|
||||||
private function renderSummary(float $gross): string
|
|
||||||
{
|
|
||||||
$rows = '';
|
|
||||||
|
|
||||||
if ($this->event->tax_liable && $this->event->vat_rate > 0) {
|
|
||||||
$split = $this->splitVat($gross);
|
|
||||||
|
|
||||||
$rows .= sprintf(
|
|
||||||
'<tr><td class="sum-key">Nettobetrag</td><td class="sum-val">%s</td></tr>',
|
|
||||||
$this->money($split['net'])
|
|
||||||
);
|
|
||||||
$rows .= sprintf(
|
|
||||||
'<tr class="sum-line"><td class="sum-key">enthaltene USt. %d %%</td><td class="sum-val">%s</td></tr>',
|
|
||||||
$this->event->vat_rate,
|
|
||||||
$this->money($split['vat'])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$rows .= sprintf(
|
|
||||||
'<tr class="sum-total"><td class="sum-key">Gesamtbetrag</td><td class="sum-val">%s</td></tr>',
|
|
||||||
$this->money($gross)
|
|
||||||
);
|
|
||||||
|
|
||||||
$table = '<table class="sum-outer"><tr><td class="sum-spacer"></td><td>'
|
|
||||||
. '<table class="sum-inner">' . $rows . '</table>'
|
|
||||||
. '</td></tr></table>';
|
|
||||||
|
|
||||||
return $table . $this->taxExemptionNote();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pflichthinweis auf den Grund der Steuerbefreiung, aus dem Event-Snapshot. */
|
|
||||||
private function taxExemptionNote(): string
|
|
||||||
{
|
|
||||||
if ($this->event->tax_liable) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$reason = $this->event->tax_exemption_reason !== null
|
|
||||||
? TaxExemptionReason::find($this->event->tax_exemption_reason)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
$text = $reason?->invoiceText($this->event->tax_exemption_note);
|
|
||||||
if ($text === null || trim($text) === '') {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<div class="tax-note">' . e($text) . '</div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
private function money(float $value): string
|
|
||||||
{
|
|
||||||
return new Amount($value, 'Euro')->getFormattedAmount() . ' €';
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Mengen ohne Nachkommastellen, solange sie ganzzahlig sind ("3 Tage", nicht "3,00 Tage"). */
|
|
||||||
private function quantity(float $value): string
|
|
||||||
{
|
|
||||||
return abs($value - round($value)) < 0.005
|
|
||||||
? (string) (int) round($value)
|
|
||||||
: number_format($value, 2, ',', '.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantInvoice\Actions\CreateParticipantInvoice;
|
|
||||||
|
|
||||||
use App\Models\EventParticipant;
|
|
||||||
|
|
||||||
class CreateParticipantInvoiceRequest
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
public readonly EventParticipant $participant,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantInvoice\Actions\CreateParticipantInvoice;
|
|
||||||
|
|
||||||
class CreateParticipantInvoiceResponse
|
|
||||||
{
|
|
||||||
public bool $success = false;
|
|
||||||
|
|
||||||
public string $invoiceNumber = '';
|
|
||||||
|
|
||||||
public string $filename = '';
|
|
||||||
|
|
||||||
public string $pdfContent = '';
|
|
||||||
|
|
||||||
public ?string $message = null;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantInvoice\Controllers;
|
|
||||||
|
|
||||||
use App\Domains\ParticipantInvoice\Actions\CreateParticipantInvoice\CreateParticipantInvoiceCommand;
|
|
||||||
use App\Domains\ParticipantInvoice\Actions\CreateParticipantInvoice\CreateParticipantInvoiceRequest;
|
|
||||||
use App\Scopes\CommonController;
|
|
||||||
use Illuminate\Http\Response;
|
|
||||||
|
|
||||||
class CreateParticipantInvoiceController extends CommonController
|
|
||||||
{
|
|
||||||
public function __invoke(string $participantIdentifier): Response
|
|
||||||
{
|
|
||||||
$participant = $this->eventParticipants->getByIdentifier($participantIdentifier, $this->events);
|
|
||||||
|
|
||||||
if ($participant === null) {
|
|
||||||
abort(403, 'Zugriff verweigert.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$invoiceRequest = new CreateParticipantInvoiceRequest($participant);
|
|
||||||
$invoiceCommand = new CreateParticipantInvoiceCommand($invoiceRequest);
|
|
||||||
$invoiceResponse = $invoiceCommand->execute();
|
|
||||||
|
|
||||||
if (!$invoiceResponse->success) {
|
|
||||||
abort(422, $invoiceResponse->message ?? 'Die Rechnung konnte nicht erstellt werden.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return response($invoiceResponse->pdfContent, 200, [
|
|
||||||
'Content-Type' => 'application/pdf',
|
|
||||||
'Content-Disposition' => 'attachment; filename="' . $invoiceResponse->filename . '"',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantInvoice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Katalog der Platzhalter, die in der Rechnungsvorlage zur Verfügung stehen.
|
|
||||||
*
|
|
||||||
* Dient zwei Zwecken: der Platzhalter-Liste in der Vorlagen-Verwaltung und den Beispieldaten für die
|
|
||||||
* Vorschau. Die echten Werte setzt
|
|
||||||
* {@see \App\Domains\ParticipantInvoice\Actions\CreateParticipantInvoice\CreateParticipantInvoiceCommand}
|
|
||||||
* zusammen -- dass beide Seiten dieselben Namen kennen, sichert ein Test ab.
|
|
||||||
*/
|
|
||||||
final class ParticipantInvoiceTokens
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Platzhalter nach Gruppen, je Eintrag Name, Beschreibung und Beispielwert.
|
|
||||||
*
|
|
||||||
* @return array<string, array{label: string, tokens: array<string, array{description: string, sample: string}>}>
|
|
||||||
*/
|
|
||||||
public static function groups(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'document' => [
|
|
||||||
'label' => 'Dokument',
|
|
||||||
'tokens' => [
|
|
||||||
'document_title' => ['description' => 'Titel des PDF-Dokuments', 'sample' => 'Rechnung WM-V-20260701-0005'],
|
|
||||||
'invoice_number' => ['description' => 'Rechnungsnummer', 'sample' => 'WM-V-20260701-0005'],
|
|
||||||
'invoice_date' => ['description' => 'Rechnungsdatum (= Anmeldedatum)', 'sample' => '03.02.2026'],
|
|
||||||
'service_period' => ['description' => 'Leistungszeitraum der Veranstaltung', 'sample' => '16.07.2026 – 20.07.2026'],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'sender' => [
|
|
||||||
'label' => 'Absender',
|
|
||||||
'tokens' => [
|
|
||||||
'sender_name' => ['description' => 'Rechnungs-Absender (Standard: Name des Mandanten)', 'sample' => 'BdP Landesverband Sachsen e.V.'],
|
|
||||||
'sender_address_1' => ['description' => 'Straße und Hausnummer', 'sample' => 'Musterweg 1'],
|
|
||||||
'sender_address_2' => ['description' => 'Adresszusatz, z. B. „c/o …"', 'sample' => 'c/o Mustermensch'],
|
|
||||||
'sender_address_3' => ['description' => 'Weiterer Adresszusatz', 'sample' => ''],
|
|
||||||
'sender_postcode' => ['description' => 'Postleitzahl', 'sample' => '01623'],
|
|
||||||
'sender_city' => ['description' => 'Ort', 'sample' => 'Lommatzsch'],
|
|
||||||
'sender_email' => ['description' => 'E-Mail-Adresse', 'sample' => 'kontakt@example.com'],
|
|
||||||
'sender_phone' => ['description' => 'Telefonnummer', 'sample' => '0351 1234567'],
|
|
||||||
'sender_tax_number' => ['description' => 'Steuernummer', 'sample' => '201/123/45678'],
|
|
||||||
'sender_vat_id' => ['description' => 'USt-IdNr.', 'sample' => ''],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'recipient' => [
|
|
||||||
'label' => 'Empfänger',
|
|
||||||
'tokens' => [
|
|
||||||
'recipient_name' => ['description' => 'Name der teilnehmenden Person', 'sample' => 'Mika Muster'],
|
|
||||||
'recipient_address_1' => ['description' => 'Straße und Hausnummer', 'sample' => 'Beispielstraße 3'],
|
|
||||||
'recipient_address_2' => ['description' => 'Adresszusatz', 'sample' => ''],
|
|
||||||
'recipient_postcode' => ['description' => 'Postleitzahl', 'sample' => '11111'],
|
|
||||||
'recipient_city' => ['description' => 'Ort', 'sample' => 'Beispielstadt'],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'body' => [
|
|
||||||
'label' => 'Rechnungsinhalt (generiert)',
|
|
||||||
'tokens' => [
|
|
||||||
'positions_table' => ['description' => 'Positionstabelle', 'sample' => self::samplePositions()],
|
|
||||||
'summary_table' => ['description' => 'Summenblock inkl. USt bzw. Befreiungshinweis', 'sample' => self::sampleSummary()],
|
|
||||||
'closing_statement' => ['description' => 'Zahlungshinweis der gewählten Zahlungsart', 'sample' => 'Bitte überweise 300,00 Euro bis zum 01.07.2026 auf folgendes Konto:<br />IBAN: DE00 0000 0000 0000 0000 00'],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Beispielwerte für die Vorschau.
|
|
||||||
*
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function sample(): array
|
|
||||||
{
|
|
||||||
$sample = [];
|
|
||||||
|
|
||||||
foreach (self::groups() as $group) {
|
|
||||||
foreach ($group['tokens'] as $name => $token) {
|
|
||||||
$sample[$name] = $token['sample'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $sample;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @return array<int, string> */
|
|
||||||
public static function names(): array
|
|
||||||
{
|
|
||||||
return array_keys(self::sample());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function samplePositions(): string
|
|
||||||
{
|
|
||||||
return '<table class="pos-table">'
|
|
||||||
. '<thead><tr>'
|
|
||||||
. '<th style="width:8%;">Nr.</th><th style="width:44%;">Bezeichnung</th>'
|
|
||||||
. '<th style="width:12%;" class="r">Menge</th><th style="width:18%;" class="r">Einzelpreis</th>'
|
|
||||||
. '<th style="width:18%;" class="r">Gesamt</th>'
|
|
||||||
. '</tr></thead><tbody>'
|
|
||||||
. '<tr><td>1</td><td>Teilnahme Sommerlager in Gruppe Sippe (Standardbeitrag)</td>'
|
|
||||||
. '<td class="r">5 Tage</td><td class="r">60,00 €</td><td class="r">300,00 €</td></tr>'
|
|
||||||
. '</tbody></table>';
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function sampleSummary(): string
|
|
||||||
{
|
|
||||||
return '<table class="sum-outer"><tr><td class="sum-spacer"></td><td>'
|
|
||||||
. '<table class="sum-inner">'
|
|
||||||
. '<tr class="sum-total"><td class="sum-key">Gesamtbetrag</td><td class="sum-val">300,00 €</td></tr>'
|
|
||||||
. '</table></td></tr></table>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use App\Domains\ParticipantInvoice\Controllers\CreateParticipantInvoiceController;
|
|
||||||
use App\Middleware\IdentifyTenant;
|
|
||||||
use Illuminate\Support\Facades\Route;
|
|
||||||
|
|
||||||
Route::prefix('api/v1')
|
|
||||||
->group(function () {
|
|
||||||
Route::middleware(IdentifyTenant::class)->group(function () {
|
|
||||||
Route::middleware(['auth'])->group(function () {
|
|
||||||
Route::get('participant-invoice/{participantIdentifier}', CreateParticipantInvoiceController::class);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,330 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\AcceptRefund;
|
|
||||||
|
|
||||||
use App\Domains\Invoice\Actions\CreateInvoice\CreateInvoiceCommand;
|
|
||||||
use App\Domains\Invoice\Actions\CreateInvoice\CreateInvoiceRequest;
|
|
||||||
use App\Domains\ParticipantRefund\Actions\CreateRefundDocument\CreateRefundDocumentCommand;
|
|
||||||
use App\Domains\ParticipantRefund\Actions\CreateRefundDocument\CreateRefundDocumentRequest;
|
|
||||||
use App\Domains\ParticipantRefund\Actions\CreateRefundDocument\CreateRefundDocumentResponse;
|
|
||||||
use App\Enumerations\InvoiceType;
|
|
||||||
use App\Mail\ParticipantRefundMails\RefundAcceptedMail;
|
|
||||||
use App\Models\CostUnit;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
use App\Providers\FileWriteProvider;
|
|
||||||
use App\Providers\UploadFileProvider;
|
|
||||||
use App\Repositories\CostUnitRepository;
|
|
||||||
use App\Support\Iban;
|
|
||||||
use App\ValueObjects\Amount;
|
|
||||||
use App\ValueObjects\InvoiceFile;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use RuntimeException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der Teili bestätigt die Erstattung und hinterlegt seine Bankverbindung.
|
|
||||||
*
|
|
||||||
* Läuft ohne Login -- der Token aus der Mail ist die Autorisierung, dasselbe Modell wie bei
|
|
||||||
* /print-girocode/{identifier}. Betrag und Grund stehen fest und werden hier nicht angefasst: sie kommen
|
|
||||||
* aus der Freigabe der Aktionsleitung.
|
|
||||||
*
|
|
||||||
* Danach ist der Vorgang festgeschrieben; der Beleg geht mit der Bestätigungsmail raus.
|
|
||||||
*/
|
|
||||||
class AcceptRefundCommand
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Wortlaut für jeden Fall, in dem der Link nicht (mehr) zu einem offenen Vorgang führt.
|
|
||||||
*
|
|
||||||
* Bewusst ein und derselbe Text für „Token unbekannt" und „abgebrochen": eine abgebrochene Freigabe
|
|
||||||
* soll sich verhalten, als hätte es sie nie gegeben.
|
|
||||||
*/
|
|
||||||
public const string NO_OPEN_REFUND = 'Zu deiner Anmeldung liegt keine freigegebene Rückerstattung vor. '
|
|
||||||
. 'Bitte wende dich an die Aktionsleitung.';
|
|
||||||
|
|
||||||
public function __construct(private readonly AcceptRefundRequest $request)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(): AcceptRefundResponse
|
|
||||||
{
|
|
||||||
$response = new AcceptRefundResponse();
|
|
||||||
$refund = $this->request->refund;
|
|
||||||
|
|
||||||
if ($refund === null || !$refund->isPending()) {
|
|
||||||
$response->message = $refund?->isAccepted() === true
|
|
||||||
? 'Deine Angaben liegen uns bereits vor.'
|
|
||||||
: self::NO_OPEN_REFUND;
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
$owner = trim($this->request->accountOwner);
|
|
||||||
$iban = Iban::normalize($this->request->accountIban);
|
|
||||||
|
|
||||||
// Serverseitig und nicht nur im Formular: die Erklärung ist der einzige Grund, warum der Beleg
|
|
||||||
// als Eigenbeleg etwas wert ist. Ließe sie sich mit einem direkten Aufruf übergehen, stünde auf
|
|
||||||
// dem PDF eine Zusicherung, die niemand abgegeben hat.
|
|
||||||
//
|
|
||||||
// Nimmt die Aktionsleitung die Angaben auf, kreuzt naturgemäß niemand etwas an. Nachvollziehbar
|
|
||||||
// bleibt es trotzdem: `captured_by` hält fest, wer sie aufgenommen hat, und der Beleg weist es aus.
|
|
||||||
if (!$this->request->declarationAccepted && $this->request->capturedBy === null) {
|
|
||||||
$response->errorTypes['declaration'] = 'Bitte bestätige die Erklärung, damit wir erstatten können.';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wer spendet, gibt kein Konto an -- alles Weitere betrifft nur die Auszahlung.
|
|
||||||
if (!$this->request->donation) {
|
|
||||||
// Erstattet wird ausschließlich auf das Konto, von dem der Beitrag kam. Ohne diese
|
|
||||||
// Bestätigung ließe sich über eine Erstattung Geld auf ein fremdes Konto umleiten.
|
|
||||||
if (!$this->request->accountDeclarationAccepted && $this->request->capturedBy === null) {
|
|
||||||
$response->errorTypes['accountDeclaration'] = 'Bitte bestätige, dass es das Konto ist, '
|
|
||||||
. 'von dem der Beitrag gezahlt wurde.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($owner === '') {
|
|
||||||
$response->errorTypes['accountOwner'] = 'Bitte gib an, wem das Konto gehört.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($iban === '') {
|
|
||||||
$response->errorTypes['accountIban'] = 'Bitte gib die IBAN des Kontos ein.';
|
|
||||||
} elseif (!Iban::isValid($iban)) {
|
|
||||||
$response->errorTypes['accountIban'] = 'Diese IBAN stimmt nicht. Bitte prüfe deine Eingabe.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($response->errorTypes !== []) {
|
|
||||||
$response->message = 'Bitte prüfe deine Angaben.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ohne Kostenstelle gibt es nichts, worauf gebucht werden könnte. Lieber hier abbrechen, als den
|
|
||||||
// Vorgang zu bestätigen und die Auszahlung stillschweigend nirgends einzureichen.
|
|
||||||
$costUnit = $this->costUnit($refund);
|
|
||||||
if ($costUnit === null) {
|
|
||||||
$response->message = 'Die Erstattung kann gerade nicht bearbeitet werden. '
|
|
||||||
. 'Bitte wende dich an die Aktionsleitung.';
|
|
||||||
|
|
||||||
Log::error('Beitragserstattung: Veranstaltung ohne Kostenstelle, Abrechnung nicht möglich.', [
|
|
||||||
'refund_id' => $refund->id,
|
|
||||||
'event_id' => $refund->event_id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Der Beleg entsteht in der Transaktion, weil er den bestätigten Stand abbildet; scheitert das
|
|
||||||
// Einreichen, soll auch kein Beleg gelten.
|
|
||||||
$document = DB::transaction(function () use ($refund, $owner, $iban, $costUnit) {
|
|
||||||
// Bei einer Spende bleiben die Kontofelder leer -- und zwar `null` und nicht Leerstring: Der
|
|
||||||
// SEPA-Export unterscheidet daran, ob es etwas auszuzahlen gibt.
|
|
||||||
$refund->account_owner = $this->request->donation ? null : $owner;
|
|
||||||
$refund->account_iban = $this->request->donation ? null : $iban;
|
|
||||||
$refund->captured_by = $this->request->capturedBy;
|
|
||||||
$refund->status = ParticipantRefund::STATUS_ACCEPTED;
|
|
||||||
$refund->accepted_at = now();
|
|
||||||
$refund->save();
|
|
||||||
|
|
||||||
// Die Spende wird hier ausdrücklich mitgegeben statt am Vorgang abgelesen: Die Abrechnung,
|
|
||||||
// die sie führt, entsteht erst weiter unten -- dieser Beleg ist ihr Anhang.
|
|
||||||
$document = new CreateRefundDocumentCommand(new CreateRefundDocumentRequest(
|
|
||||||
refund: $refund,
|
|
||||||
donation: $this->request->donation,
|
|
||||||
))->execute();
|
|
||||||
|
|
||||||
$invoice = $this->createInvoice($refund, $costUnit, $document);
|
|
||||||
|
|
||||||
// Erst jetzt, nicht früher: Beleg und Anmerkung der Abrechnung weisen den gezahlten Beitrag
|
|
||||||
// aus und läsen sonst bereits den verrechneten Stand.
|
|
||||||
$this->settleAmountPaid($refund);
|
|
||||||
|
|
||||||
$refund->invoice_id = $invoice->id;
|
|
||||||
$refund->save();
|
|
||||||
|
|
||||||
return $document;
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->notify($refund, $document);
|
|
||||||
|
|
||||||
$response->success = true;
|
|
||||||
$response->message = $this->request->donation
|
|
||||||
? 'Vielen Dank für deine Spende.'
|
|
||||||
: 'Vielen Dank. Deine Angaben liegen uns vor.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Kostenstelle der Veranstaltung.
|
|
||||||
*
|
|
||||||
* Ohne Zugriffsprüfung, weil hier niemand angemeldet ist -- der Teili bestätigt über seinen Token.
|
|
||||||
* Der Repository-Check greift sonst auf `currentUserOrFail()->id` zu und liefe in einen Fehler.
|
|
||||||
*
|
|
||||||
* Bewusst ohne Prüfung auf `allow_new`/`archived`: Eine Erstattung fällt oft erst nach dem Ende der
|
|
||||||
* Veranstaltung an, wenn die Kostenstelle längst geschlossen ist. Sie gehört trotzdem dorthin -- und
|
|
||||||
* der reguläre Weg über SaveInvoiceController prüft das ebenso wenig.
|
|
||||||
*/
|
|
||||||
private function costUnit(ParticipantRefund $refund): ?CostUnit
|
|
||||||
{
|
|
||||||
if ($refund->event->cost_unit_id === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CostUnitRepository()->getById($refund->event->cost_unit_id, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reicht die Erstattung als gewöhnliche Auslagenabrechnung ein.
|
|
||||||
*
|
|
||||||
* Über denselben Command wie jede von Hand erfasste Abrechnung: damit stimmen Nummernkreis, Status
|
|
||||||
* `new`, die Bestätigungsmail an den Teili und die Benachrichtigung der Kassenwart*innen mit dem
|
|
||||||
* überein, was die Buchhaltung kennt.
|
|
||||||
*/
|
|
||||||
private function createInvoice(
|
|
||||||
ParticipantRefund $refund,
|
|
||||||
CostUnit $costUnit,
|
|
||||||
CreateRefundDocumentResponse $document,
|
|
||||||
): Invoice {
|
|
||||||
$participant = $refund->participant;
|
|
||||||
|
|
||||||
$invoiceRequest = new CreateInvoiceRequest(
|
|
||||||
costUnit: $costUnit,
|
|
||||||
// getOfficialName() und nicht getFullName(): letzteres enthält HTML für die Oberfläche.
|
|
||||||
contactName: $participant->getOfficialName(),
|
|
||||||
invoiceType: InvoiceType::INVOICE_TYPE_PARTICIPATION_REFUND,
|
|
||||||
totalAmount: $refund->amount?->getAmount() ?? 0.0,
|
|
||||||
receiptFile: $this->storeReceipt($costUnit, $document),
|
|
||||||
// Hier landet die Entscheidung des Teilis, und nur hier: Die Abrechnung führt sie, der
|
|
||||||
// Vorgang liest sie über ParticipantRefund::isDonation() zurück.
|
|
||||||
isDonation: $this->request->donation,
|
|
||||||
userId: $participant->user_id,
|
|
||||||
contactEmail: $participant->email_1,
|
|
||||||
contactPhone: $participant->phone_1,
|
|
||||||
// Die Bankverbindung stammt aus dem Vorgang, nicht vom Teilnehmer: das Konto kann einem
|
|
||||||
// Elternteil gehören.
|
|
||||||
accountOwner: $refund->account_owner,
|
|
||||||
accountIban: $refund->account_iban,
|
|
||||||
|
|
||||||
// MUSS null bleiben (nicht ''): CreateInvoiceCommand verwirft die user_id, sobald hier etwas
|
|
||||||
// steht -- der Teili fände seine Abrechnung dann nicht unter "Meine Abrechnungen".
|
|
||||||
paymentPurpose: null,
|
|
||||||
notices: $this->notice($refund),
|
|
||||||
);
|
|
||||||
|
|
||||||
$invoiceResponse = new CreateInvoiceCommand($invoiceRequest)->execute();
|
|
||||||
|
|
||||||
if (!$invoiceResponse->success || $invoiceResponse->invoice === null) {
|
|
||||||
// Rollt die Transaktion zurück -- der Vorgang bleibt offen, der Teili kann es erneut versuchen.
|
|
||||||
throw new RuntimeException('Die Abrechnung zur Beitragserstattung konnte nicht angelegt werden.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $invoiceResponse->invoice;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Legt den Eigenbeleg dort ab, wo auch hochgeladene Belege liegen, und verpackt ihn für die
|
|
||||||
* Abrechnung. `CreateInvoiceCommand` speichert nur den Pfad und schreibt selbst keine Dateien.
|
|
||||||
*/
|
|
||||||
private function storeReceipt(CostUnit $costUnit, CreateRefundDocumentResponse $document): ?InvoiceFile
|
|
||||||
{
|
|
||||||
if (!$document->success) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path = UploadFileProvider::directoryFor($costUnit) . '/' . $document->filename;
|
|
||||||
|
|
||||||
new FileWriteProvider($path, $document->pdfContent)->writeToFile();
|
|
||||||
|
|
||||||
$receipt = new InvoiceFile();
|
|
||||||
// Beide Eigenschaften sind typisiert und ohne Vorbelegung; gespeichert wird nur `fullPath`.
|
|
||||||
$receipt->filename = $document->filename;
|
|
||||||
$receipt->fullPath = $path;
|
|
||||||
|
|
||||||
return $receipt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Die Anmerkung auf der Abrechnung.
|
|
||||||
*
|
|
||||||
* Sie nennt den gezahlten Beitrag, weil er am Teilnehmer gleich auf 0 gesetzt wird
|
|
||||||
* ({@see self::clearAmountPaid()}) -- die Schatzmeisterei kann den Vorgang so nachvollziehen, ohne
|
|
||||||
* den vorherigen Stand irgendwo suchen zu müssen.
|
|
||||||
*
|
|
||||||
* Gekürzt wird nur der vordere, freie Teil: Veranstaltungsname und Grund sind beliebig lang, der
|
|
||||||
* Betrag darf nie abgeschnitten werden.
|
|
||||||
*/
|
|
||||||
private function notice(ParticipantRefund $refund): string
|
|
||||||
{
|
|
||||||
$paid = $refund->participant->amount_paid?->toString() ?? '0,00 Euro';
|
|
||||||
|
|
||||||
// Die Schatzmeisterei sieht die Abrechnung ohne den Vorgang dahinter. Dass nichts ausgezahlt
|
|
||||||
// wird, steht zwar im Spendenkennzeichen -- warum keine Bankverbindung dabei ist, aber nur hier.
|
|
||||||
$subject = $this->request->donation
|
|
||||||
? 'Spende statt Rückerstattung Teilnahmebeitrag'
|
|
||||||
: 'Rückerstattung Teilnahmebeitrag';
|
|
||||||
|
|
||||||
return Str::limit(sprintf(
|
|
||||||
'%s %s – %s',
|
|
||||||
$subject,
|
|
||||||
$refund->event->name,
|
|
||||||
$refund->reasonLabel()
|
|
||||||
), 180) . sprintf(' | Gezahlter Beitrag vor Erstattung: %s', $paid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Zieht den erstatteten Betrag vom gezahlten Beitrag ab.
|
|
||||||
*
|
|
||||||
* Danach führt `amount_paid` genau das, was beim Verband geblieben ist -- bei voller Erstattung also
|
|
||||||
* 0, bei einer Teilerstattung den einbehaltenen Rest. Auf diesem Feld baut die Einnahmenrechnung der
|
|
||||||
* Veranstaltung auf; es muss deshalb den tatsächlichen Bestand abbilden und nicht die Zahlung von
|
|
||||||
* einst. Der ursprüngliche Betrag steht zur Kontrolle in der Anmerkung der Abrechnung und auf dem
|
|
||||||
* Beleg.
|
|
||||||
*/
|
|
||||||
private function settleAmountPaid(ParticipantRefund $refund): void
|
|
||||||
{
|
|
||||||
$participant = $refund->participant;
|
|
||||||
|
|
||||||
$paid = $participant->amount_paid?->getAmount() ?? 0.0;
|
|
||||||
$refunded = $refund->amount?->getAmount() ?? 0.0;
|
|
||||||
|
|
||||||
// `max` gegen Rundungsreste: Ein negativer gezahlter Betrag wäre in jeder Auswertung Unsinn.
|
|
||||||
$participant->amount_paid = new Amount(max(0.0, round($paid - $refunded, 2)), 'Euro');
|
|
||||||
$participant->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Die eigene Bestätigung mit dem Beleg im Anhang, an Teili und Kontaktperson.
|
|
||||||
*
|
|
||||||
* Sie kommt zusätzlich zu der, die CreateInvoiceCommand verschickt: diese trägt den Beleg, jene ist
|
|
||||||
* die Quittung des Abrechnungssystems. Erst nach der Transaktion, damit nichts verschickt wird, was
|
|
||||||
* anschließend zurückgerollt würde.
|
|
||||||
*
|
|
||||||
* Scheitert die Belegerzeugung, geht die Mail ohne Anhang raus statt gar nicht.
|
|
||||||
*/
|
|
||||||
private function notify(ParticipantRefund $refund, CreateRefundDocumentResponse $document): void
|
|
||||||
{
|
|
||||||
$pdf = $document->success ? $document->pdfContent : null;
|
|
||||||
$filename = $document->success ? $document->filename : null;
|
|
||||||
|
|
||||||
$participant = $refund->participant;
|
|
||||||
|
|
||||||
$recipients = [$participant->email_1];
|
|
||||||
|
|
||||||
// `filled()` und nicht `!== null`: Der Anmeldewizard überspringt den Schritt "Kontaktperson" bei
|
|
||||||
// Volljährigen und legt das Feld als Leerstring an -- `Mail::to('')` liefe ins Leere.
|
|
||||||
if (filled($participant->email_2)) {
|
|
||||||
$recipients[] = $participant->email_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($recipients as $recipient) {
|
|
||||||
Mail::to($recipient)->send(new RefundAcceptedMail(
|
|
||||||
participant: $participant,
|
|
||||||
refund: $refund,
|
|
||||||
pdfContent: $pdf,
|
|
||||||
pdfFilename: $filename,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\AcceptRefund;
|
|
||||||
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
|
|
||||||
class AcceptRefundRequest
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
public readonly ?ParticipantRefund $refund,
|
|
||||||
public readonly string $accountOwner,
|
|
||||||
public readonly string $accountIban,
|
|
||||||
/**
|
|
||||||
* Ob der Teili die Erklärung auf der Seite angekreuzt hat. Ohne sie taugt der Beleg nichts.
|
|
||||||
*
|
|
||||||
* Im Spendenweg ist es die Verzichtserklärung, im Auszahlungsweg die Versicherung über den
|
|
||||||
* gezahlten Beitrag -- in beiden Fällen die Erklärung, die anschließend auf dem Beleg steht.
|
|
||||||
*/
|
|
||||||
public readonly bool $declarationAccepted = false,
|
|
||||||
/**
|
|
||||||
* Ob auf die Auszahlung verzichtet und der Betrag gespendet wird.
|
|
||||||
*
|
|
||||||
* Wird nicht am Vorgang gespeichert: Die Entscheidung landet in der Abrechnung
|
|
||||||
* (`invoices.donation`), von wo {@see ParticipantRefund::isDonation()} sie zurückliest. Dieses
|
|
||||||
* Feld ist der Weg dorthin.
|
|
||||||
*/
|
|
||||||
public readonly bool $donation = false,
|
|
||||||
/**
|
|
||||||
* Nur im Auszahlungsweg: die Bestätigung, dass es das Konto der Ursprungszahlung ist.
|
|
||||||
*
|
|
||||||
* Getrennt von der Haupterklärung, weil sie im Spendenweg gegenstandslos ist -- dort gibt es
|
|
||||||
* kein Konto.
|
|
||||||
*/
|
|
||||||
public readonly bool $accountDeclarationAccepted = false,
|
|
||||||
/**
|
|
||||||
* Die Aktionsleitung, wenn sie die Bankverbindung aufgenommen hat, weil sie ihr vorlag.
|
|
||||||
*
|
|
||||||
* Dann kreuzt niemand die Erklärung an -- sie wird stellvertretend aufgenommen, und der Beleg
|
|
||||||
* weist genau das aus.
|
|
||||||
*/
|
|
||||||
public readonly ?int $capturedBy = null,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\AcceptRefund;
|
|
||||||
|
|
||||||
class AcceptRefundResponse
|
|
||||||
{
|
|
||||||
public bool $success = false;
|
|
||||||
|
|
||||||
public ?string $message = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Feldbezogene Fehler für das Formular. Schlüssel sind die Feldnamen des Frontends.
|
|
||||||
*
|
|
||||||
* @var array<string, string>
|
|
||||||
*/
|
|
||||||
public array $errorTypes = [];
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\CancelRefund;
|
|
||||||
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bricht eine freigegebene, aber noch nicht bestätigte Erstattung ab.
|
|
||||||
*
|
|
||||||
* Danach läuft der Link des Teilis ins Leere und die Anmeldung sieht aus wie vor der Freigabe. Bewusst
|
|
||||||
* ohne Mail: der Teili soll nicht über etwas informiert werden, das für ihn nie stattgefunden hat --
|
|
||||||
* die Aktionsleitung klärt das im Zweifel direkt.
|
|
||||||
*
|
|
||||||
* Ein bereits bestätigter Vorgang ist unantastbar: dazu gibt es einen Beleg, und der Teili hat seine
|
|
||||||
* Bankverbindung im Vertrauen darauf herausgegeben.
|
|
||||||
*/
|
|
||||||
class CancelRefundCommand
|
|
||||||
{
|
|
||||||
public function __construct(private readonly CancelRefundRequest $request)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(): CancelRefundResponse
|
|
||||||
{
|
|
||||||
$response = new CancelRefundResponse();
|
|
||||||
$refund = $this->request->refund;
|
|
||||||
|
|
||||||
if (!$refund->isPending()) {
|
|
||||||
$response->message = $refund->isAccepted()
|
|
||||||
? 'Diese Erstattung wurde bereits bestätigt und kann nicht mehr abgebrochen werden.'
|
|
||||||
: 'Diese Erstattung wurde bereits abgebrochen.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
$refund->status = ParticipantRefund::STATUS_CANCELLED;
|
|
||||||
$refund->cancelled_at = now();
|
|
||||||
$refund->save();
|
|
||||||
|
|
||||||
$response->success = true;
|
|
||||||
$response->message = 'Die Erstattung wurde abgebrochen.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\CancelRefund;
|
|
||||||
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
|
|
||||||
class CancelRefundRequest
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
public readonly ParticipantRefund $refund,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\CancelRefund;
|
|
||||||
|
|
||||||
class CancelRefundResponse
|
|
||||||
{
|
|
||||||
public bool $success = false;
|
|
||||||
|
|
||||||
public ?string $message = null;
|
|
||||||
}
|
|
||||||
-358
@@ -1,358 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\CreateRefundDocument;
|
|
||||||
|
|
||||||
use App\Models\DocumentTemplate;
|
|
||||||
use App\Models\Event;
|
|
||||||
use App\Models\EventParticipant;
|
|
||||||
use App\Models\PageText;
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
use App\Models\Tenant;
|
|
||||||
use App\Providers\DocumentTemplateRenderProvider;
|
|
||||||
use App\Providers\PdfGenerateAndDownloadProvider;
|
|
||||||
use App\ValueObjects\Amount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Erzeugt den Beleg über die erstattete Teilnahmegebühr als PDF.
|
|
||||||
*
|
|
||||||
* Wie bei der Teilnahmerechnung wird nichts gespeichert: die Belegnummer leitet sich aus Veranstaltung
|
|
||||||
* und Position des Teilis ab, der Inhalt aus dem Erstattungsvorgang. Da ein bestätigter Vorgang nicht
|
|
||||||
* mehr verändert wird, liefert ein erneuter Abruf denselben Beleg.
|
|
||||||
*
|
|
||||||
* Keine Umsatzsteuer: eine Erstattung ist keine Rechnung. Ausgewiesen wird der Betrag, den der Teili
|
|
||||||
* zurückbekommt. Eine Stornorechnung mit USt-Ausweis wäre eine eigene Dokumentart.
|
|
||||||
*/
|
|
||||||
class CreateRefundDocumentCommand
|
|
||||||
{
|
|
||||||
/** Name des `page_texts`-Eintrags mit der Erklärung -- dieselbe Quelle wie die Bestätigungsseite. */
|
|
||||||
public const string DECLARATION_TEXT = 'CONFIRMATION_PARTICIPANT_REFUND';
|
|
||||||
|
|
||||||
/** Die zweite Erklärung des Auszahlungswegs: dass es das Konto der Ursprungszahlung ist. */
|
|
||||||
public const string ACCOUNT_DECLARATION_TEXT = 'CONFIRMATION_PARTICIPANT_REFUND_ACCOUNT';
|
|
||||||
|
|
||||||
/** Tritt im Spendenweg an die Stelle beider anderen -- dort gibt es kein Konto. */
|
|
||||||
public const string DONATION_DECLARATION_TEXT = 'CONFIRMATION_PARTICIPANT_REFUND_DONATION';
|
|
||||||
|
|
||||||
private ParticipantRefund $refund;
|
|
||||||
|
|
||||||
private EventParticipant $participant;
|
|
||||||
|
|
||||||
private Event $event;
|
|
||||||
|
|
||||||
/** Der Aussteller. Gehört zum Mandanten der Veranstaltung, nicht zum gerade aktiven. */
|
|
||||||
private ?Tenant $sender;
|
|
||||||
|
|
||||||
public function __construct(private readonly CreateRefundDocumentRequest $request)
|
|
||||||
{
|
|
||||||
$this->refund = $request->refund;
|
|
||||||
$this->participant = $request->refund->participant;
|
|
||||||
$this->event = $request->refund->event;
|
|
||||||
|
|
||||||
// Wie in CreateParticipantInvoiceCommand: `$event->tenant` liefert das Slug-Attribut, nicht die
|
|
||||||
// Relation. Der Aussteller wird live gelesen, damit eine Korrektur an Name oder Anschrift auch
|
|
||||||
// auf bestehende Veranstaltungen wirkt.
|
|
||||||
$this->sender = $this->event->tenant()->first();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(): CreateRefundDocumentResponse
|
|
||||||
{
|
|
||||||
$response = new CreateRefundDocumentResponse();
|
|
||||||
|
|
||||||
if ($this->event->invoice_key === null || $this->participant->invoice_sequence === null) {
|
|
||||||
$response->message = 'Für diese Anmeldung lässt sich keine Belegnummer bilden.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->refund->isAccepted()) {
|
|
||||||
$response->message = 'Der Beleg entsteht erst, wenn die Erstattung bestätigt wurde.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
$documentNumber = $this->documentNumber();
|
|
||||||
|
|
||||||
$html = new DocumentTemplateRenderProvider(DocumentTemplate::TYPE_PARTICIPANT_REFUND)
|
|
||||||
->render($this->buildTokens($documentNumber));
|
|
||||||
|
|
||||||
$response->success = true;
|
|
||||||
$response->documentNumber = $documentNumber;
|
|
||||||
$response->filename = 'Rueckerstattung-' . $documentNumber . '.pdf';
|
|
||||||
$response->pdfContent = PdfGenerateAndDownloadProvider::fromHtml($html, 'portrait');
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dieselbe Nummer wie die Rechnung, mit angehängtem `-R`. Kein zweiter Nummernkreis: der Beleg
|
|
||||||
* gehört zu genau einer Anmeldung, und so ist auf einen Blick erkennbar, zu welcher Rechnung.
|
|
||||||
*/
|
|
||||||
private function documentNumber(): string
|
|
||||||
{
|
|
||||||
return $this->invoiceNumber() . '-R';
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Die Nummer der Teilnahmerechnung -- der Beleg weist sie aus, damit die Zahlung auffindbar ist. */
|
|
||||||
private function invoiceNumber(): string
|
|
||||||
{
|
|
||||||
return sprintf(
|
|
||||||
'%s-%s',
|
|
||||||
$this->event->invoice_key,
|
|
||||||
str_pad((string) $this->participant->invoice_sequence, 4, '0', STR_PAD_LEFT)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der Erklärungssatz aus `page_texts` -- derselbe, den der Teili auf der Bestätigungsseite gelesen
|
|
||||||
* und angekreuzt hat.
|
|
||||||
*
|
|
||||||
* Mit Rückfallwert: fehlt die Zeile in der Datenbank, soll der Beleg trotzdem entstehen. Ohne den
|
|
||||||
* Fallback stünde hier ein Fatal Error auf `null` -- so steht es heute im Deckblatt-Code der
|
|
||||||
* Auslagenerstattung, und daran soll sich der Beleg kein Beispiel nehmen.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Der Hinweis, warum ein Teil des Beitrags beim Verband bleibt -- leer bei voller Erstattung.
|
|
||||||
*
|
|
||||||
* Der Beleg wandert in die Buchhaltung und ins Archiv; dort muss die Differenz zwischen gezahltem
|
|
||||||
* und erstattetem Betrag ohne Rückfrage erklärt sein.
|
|
||||||
*/
|
|
||||||
private function retentionNote(): string
|
|
||||||
{
|
|
||||||
if (!$this->refund->hasRetention()) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = trim($this->refund->retentionReasonText());
|
|
||||||
$label = $this->refund->retentionReasonLabel();
|
|
||||||
|
|
||||||
return $text !== '' && $text !== $label
|
|
||||||
? sprintf('%s (%s)', $label, $text)
|
|
||||||
: $label;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der Vermerk, wenn die Aktionsleitung die Angaben aufgenommen hat.
|
|
||||||
*
|
|
||||||
* Er nennt Name und Datum, weil in diesem Fall niemand die Erklärung darüber angekreuzt hat: Wer den
|
|
||||||
* Beleg prüft, soll erkennen, dass dort eine aufgenommene Angabe steht und keine Bestätigung des
|
|
||||||
* Teilis selbst. Beim gewöhnlichen Weg bleibt der Platzhalter leer und der Block fällt weg.
|
|
||||||
*/
|
|
||||||
private function captureNote(): string
|
|
||||||
{
|
|
||||||
if (!$this->refund->wasCapturedByManagement()) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$name = $this->refund->capturedBy()->first()?->getOfficialName();
|
|
||||||
|
|
||||||
return sprintf(
|
|
||||||
'Angaben aufgenommen durch %s am %s.',
|
|
||||||
trim((string) $name) !== '' ? $name : 'die Aktionsleitung',
|
|
||||||
$this->refund->accepted_at?->format('d.m.Y') ?? ''
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function declarationText(): string
|
|
||||||
{
|
|
||||||
if ($this->request->donation) {
|
|
||||||
return $this->pageText(
|
|
||||||
self::DONATION_DECLARATION_TEXT,
|
|
||||||
'Ich verzichte auf die Auszahlung des genannten Betrags und spende ihn an den Verband. '
|
|
||||||
. 'Mir ist bewusst, dass dieser Verzicht nicht rückgängig gemacht werden kann.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Beide Sätze, weil die Person beide angekreuzt hat -- der Beleg schreibt ihr nur zu, was sie
|
|
||||||
// gelesen hat, und die Kontoerklärung ist der Grund, warum die Auszahlung zulässig ist.
|
|
||||||
return $this->pageText(
|
|
||||||
self::DECLARATION_TEXT,
|
|
||||||
'Ich versichere, dass ich den genannten Betrag beglichen habe und nicht anderweitig '
|
|
||||||
. 'zurückerstattet bekomme.'
|
|
||||||
) . '<br /><br />' . $this->pageText(
|
|
||||||
self::ACCOUNT_DECLARATION_TEXT,
|
|
||||||
'Ich bestätige, dass das angegebene Konto dasselbe ist, von dem der Teilnahmebeitrag '
|
|
||||||
. 'gezahlt wurde.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ein Seitentext mit Rückfallwert: Fehlt die Zeile in der Datenbank, soll der Beleg trotzdem
|
|
||||||
* entstehen. Ohne den Fallback stünde hier ein Fatal Error auf `null` -- so steht es heute im
|
|
||||||
* Deckblatt-Code der Auslagenerstattung, und daran soll sich der Beleg kein Beispiel nehmen.
|
|
||||||
*/
|
|
||||||
private function pageText(string $name, string $fallback): string
|
|
||||||
{
|
|
||||||
$text = PageText::where('name', $name)->first()?->content;
|
|
||||||
|
|
||||||
return trim((string) $text) !== '' ? (string) $text : $fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der Einleitungssatz des Belegs, passend zum gewählten Weg.
|
|
||||||
*
|
|
||||||
* Als Platzhalter und nicht fest in der Vorlage, weil er sich zwischen Auszahlung und Spende
|
|
||||||
* unterscheidet -- `{if:…}` kennt keine Verneinung, mit der eine Vorlage den einen Satz gegen den
|
|
||||||
* anderen tauschen könnte. Ältere, bereits installierte Vorlagen tragen den festen Satz weiter; dass
|
|
||||||
* gespendet wurde, steht dort in der Angabentabelle und in der Erklärung.
|
|
||||||
*/
|
|
||||||
private function introText(): string
|
|
||||||
{
|
|
||||||
return $this->request->donation
|
|
||||||
? 'Ich konnte an der Veranstaltung nicht oder nur teilweise teilnehmen. Auf die Auszahlung '
|
|
||||||
. 'des erstattungsfähigen Betrags verzichte ich und spende ihn an den Verband:'
|
|
||||||
: 'Ich konnte an der Veranstaltung nicht oder nur teilweise teilnehmen und bitte um die '
|
|
||||||
. 'Rückerstattung wie folgt:';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Leistungszeitraum: bei eintägigen Veranstaltungen nur ein Datum, sonst der Zeitraum.
|
|
||||||
*/
|
|
||||||
private function servicePeriod(): string
|
|
||||||
{
|
|
||||||
$start = $this->event->start_date;
|
|
||||||
$end = $this->event->end_date;
|
|
||||||
|
|
||||||
if ($start === null) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($end === null || $start->isSameDay($end)) {
|
|
||||||
return $start->format('d.m.Y');
|
|
||||||
}
|
|
||||||
|
|
||||||
return sprintf('%s – %s', $start->format('d.m.Y'), $end->format('d.m.Y'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
private function buildTokens(string $documentNumber): array
|
|
||||||
{
|
|
||||||
$participant = $this->participant;
|
|
||||||
$sender = $this->sender;
|
|
||||||
$refund = $this->refund;
|
|
||||||
|
|
||||||
return [
|
|
||||||
'document_title' => 'Rückerstattung ' . $documentNumber,
|
|
||||||
|
|
||||||
'document_number' => $documentNumber,
|
|
||||||
// Belegdatum ist der Tag, an dem der Teili bestätigt hat -- da stand der Vorgang fest.
|
|
||||||
'document_date' => $refund->accepted_at?->format('d.m.Y') ?? '',
|
|
||||||
'event_name' => (string) $this->event->name,
|
|
||||||
'service_period' => $this->servicePeriod(),
|
|
||||||
'unregistered_at' => $participant->unregistered_at?->format('d.m.Y') ?? '',
|
|
||||||
|
|
||||||
'sender_name' => $sender?->invoiceSenderName() ?? '',
|
|
||||||
'sender_address_1' => (string) $sender?->address_1,
|
|
||||||
'sender_address_2' => (string) $sender?->address_2,
|
|
||||||
'sender_address_3' => (string) $sender?->address_3,
|
|
||||||
'sender_postcode' => (string) $sender?->postcode,
|
|
||||||
'sender_city' => (string) $sender?->city,
|
|
||||||
'sender_email' => (string) $sender?->email,
|
|
||||||
'sender_phone' => (string) $sender?->phone,
|
|
||||||
'sender_tax_number' => (string) $sender?->tax_number,
|
|
||||||
'sender_vat_id' => (string) $sender?->vat_id,
|
|
||||||
|
|
||||||
'recipient_name' => $participant->getOfficialName(),
|
|
||||||
'recipient_address_1' => (string) $participant->address_1,
|
|
||||||
'recipient_address_2' => (string) $participant->address_2,
|
|
||||||
'recipient_postcode' => (string) $participant->postcode,
|
|
||||||
'recipient_city' => (string) $participant->city,
|
|
||||||
|
|
||||||
'paid_amount' => $this->money($participant->amount_paid?->getAmount() ?? 0.0),
|
|
||||||
'invoice_number' => $this->invoiceNumber(),
|
|
||||||
'refund_amount' => $this->money($refund->amount?->getAmount() ?? 0.0),
|
|
||||||
'refund_reason' => $refund->reasonLabel(),
|
|
||||||
'refund_reason_text' => $refund->reasonText(),
|
|
||||||
'account_owner' => (string) $refund->account_owner,
|
|
||||||
'account_iban' => $this->formatIban((string) $refund->account_iban),
|
|
||||||
|
|
||||||
'retained_amount' => $this->money($refund->retained_amount?->getAmount() ?? 0.0),
|
|
||||||
'retention_note' => $this->retentionNote(),
|
|
||||||
|
|
||||||
'intro_text' => $this->introText(),
|
|
||||||
'declaration_text' => $this->declarationText(),
|
|
||||||
'capture_note' => $this->captureNote(),
|
|
||||||
|
|
||||||
'details_table' => $this->renderDetails(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der generierte Block: wer erklärt, worauf sich die Erstattung bezieht, warum, und auf welches
|
|
||||||
* Konto sie geht.
|
|
||||||
*
|
|
||||||
* Alles, was die Person erklärt, steht in dieser einen Tabelle -- auch die Begründung, die früher als
|
|
||||||
* Fließtext darunter hing. Was daneben steht (Anschrift im Briefkopf, Veranstaltung im Betreff),
|
|
||||||
* beschreibt den Vorgang, gehört aber nicht zur Erklärung selbst.
|
|
||||||
*/
|
|
||||||
private function renderDetails(): string
|
|
||||||
{
|
|
||||||
$refund = $this->refund;
|
|
||||||
$participant = $this->participant;
|
|
||||||
|
|
||||||
$rows = [
|
|
||||||
// Der Name steht voran: die Tabelle trägt alles, was die Person erklärt, und die Anschrift
|
|
||||||
// allein im Briefkopf würde den Bezug lösen, sobald der Beleg als Anlage hinter einem
|
|
||||||
// Deckblatt liegt. Kontoinhaber*in weiter unten kann eine andere Person sein -- etwa ein
|
|
||||||
// Elternteil.
|
|
||||||
['Name', e($participant->getOfficialName())],
|
|
||||||
|
|
||||||
// Der gezahlte Beitrag ist die Bezugsgröße. Ohne ihn lässt sich bei einer Teilerstattung
|
|
||||||
// nicht erkennen, warum nur ein Teil zurückgeht -- und die Zusicherung „ich habe den Betrag
|
|
||||||
// beglichen" bliebe unbelegt, obwohl mareike ihn kennt.
|
|
||||||
['Gezahlter Teilnahmebeitrag', $this->money($participant->amount_paid?->getAmount() ?? 0.0)],
|
|
||||||
['Rechnung', e($this->invoiceNumber())],
|
|
||||||
['Erstattungsbetrag', $this->money($refund->amount?->getAmount() ?? 0.0)],
|
|
||||||
['Grund', e($refund->reasonLabel())],
|
|
||||||
];
|
|
||||||
|
|
||||||
// Bei einem Freitext-Grund ist die Begründung der Text der Aktionsleitung, sonst der des
|
|
||||||
// Katalogs. Fehlt beides, entfällt die Zeile -- eine Beschriftung ohne Wert sieht nach Fehler aus.
|
|
||||||
$reasonText = trim($refund->reasonText());
|
|
||||||
if ($reasonText !== '') {
|
|
||||||
$rows[] = ['Begründung', e($reasonText)];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nur bei einer Teilerstattung: Ohne diese Zeile bliebe die Differenz zwischen gezahltem und
|
|
||||||
// erstattetem Betrag im Beleg unerklärt.
|
|
||||||
if ($refund->hasRetention()) {
|
|
||||||
$rows[] = ['Einbehalten', $this->money($refund->retained_amount?->getAmount() ?? 0.0)];
|
|
||||||
$rows[] = ['Grund der Einbehaltung', e($this->retentionNote())];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bei einer Spende gibt es keine Bankverbindung. Statt zwei leerer Zeilen steht dort, warum --
|
|
||||||
// der Beleg wandert in die Buchhaltung, und "keine IBAN" allein sähe nach einer Lücke aus.
|
|
||||||
if ($this->request->donation) {
|
|
||||||
$rows[] = [
|
|
||||||
'Auszahlung',
|
|
||||||
'Auf die Auszahlung wird verzichtet; der Betrag verbleibt als Spende beim Verband.',
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$rows[] = ['Kontoinhaber*in', e((string) $refund->account_owner)];
|
|
||||||
$rows[] = ['IBAN', e($this->formatIban((string) $refund->account_iban))];
|
|
||||||
}
|
|
||||||
|
|
||||||
$html = '';
|
|
||||||
foreach ($rows as [$key, $value]) {
|
|
||||||
$html .= sprintf(
|
|
||||||
'<tr><td class="detail-key">%s</td><td class="detail-val">%s</td></tr>',
|
|
||||||
e($key),
|
|
||||||
$value
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<table class="detail-table">' . $html . '</table>';
|
|
||||||
}
|
|
||||||
|
|
||||||
/** IBAN in Vierergruppen -- so steht sie auf jedem Beleg und lässt sich abtippen. */
|
|
||||||
private function formatIban(string $iban): string
|
|
||||||
{
|
|
||||||
return trim(chunk_split($iban, 4, ' '));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function money(float $value): string
|
|
||||||
{
|
|
||||||
return new Amount($value, 'Euro')->getFormattedAmount() . ' €';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\CreateRefundDocument;
|
|
||||||
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
|
|
||||||
class CreateRefundDocumentRequest
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
public readonly ParticipantRefund $refund,
|
|
||||||
/**
|
|
||||||
* Ob der Betrag gespendet statt ausgezahlt wird.
|
|
||||||
*
|
|
||||||
* Ausdrücklich und nicht über {@see ParticipantRefund::isDonation()}: Beim Einreichen entsteht
|
|
||||||
* dieser Beleg vor der Abrechnung, die die Spende führt -- er ist ihr Anhang. Wer ihn später
|
|
||||||
* erneut zieht, liest sie dort und gibt sie hier weiter.
|
|
||||||
*/
|
|
||||||
public readonly bool $donation = false,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\CreateRefundDocument;
|
|
||||||
|
|
||||||
class CreateRefundDocumentResponse
|
|
||||||
{
|
|
||||||
public bool $success = false;
|
|
||||||
|
|
||||||
public string $documentNumber = '';
|
|
||||||
|
|
||||||
public string $filename = '';
|
|
||||||
|
|
||||||
public string $pdfContent = '';
|
|
||||||
|
|
||||||
public ?string $message = null;
|
|
||||||
}
|
|
||||||
@@ -1,277 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\ReleaseRefund;
|
|
||||||
|
|
||||||
use App\Domains\ParticipantRefund\Actions\AcceptRefund\AcceptRefundCommand;
|
|
||||||
use App\Domains\ParticipantRefund\Actions\AcceptRefund\AcceptRefundRequest;
|
|
||||||
use App\Enumerations\RefundReason;
|
|
||||||
use App\Enumerations\RetentionReason;
|
|
||||||
use App\Mail\ParticipantRefundMails\RefundReleasedMail;
|
|
||||||
use App\Models\EventParticipant;
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
use App\Repositories\ParticipantRefundRepository;
|
|
||||||
use App\Support\Iban;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
use RuntimeException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gibt die Erstattung eines Teilnahmebeitrags frei.
|
|
||||||
*
|
|
||||||
* Der Vorgang entsteht hier nur als Absichtserklärung: Betrag und Grund stehen fest, die Bankverbindung
|
|
||||||
* fehlt noch. Der Teili ergänzt sie über den Link in der Mail. `amount_paid` bleibt unangetastet --
|
|
||||||
* gezahlt hat er bis zur Auszahlung weiterhin, was er gezahlt hat.
|
|
||||||
*/
|
|
||||||
class ReleaseRefundCommand
|
|
||||||
{
|
|
||||||
private EventParticipant $participant;
|
|
||||||
|
|
||||||
private ParticipantRefundRepository $refunds;
|
|
||||||
|
|
||||||
public function __construct(private readonly ReleaseRefundRequest $request)
|
|
||||||
{
|
|
||||||
$this->participant = $request->participant;
|
|
||||||
$this->refunds = new ParticipantRefundRepository();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(): ReleaseRefundResponse
|
|
||||||
{
|
|
||||||
$response = new ReleaseRefundResponse();
|
|
||||||
|
|
||||||
$rejection = $this->reject();
|
|
||||||
if ($rejection !== null) {
|
|
||||||
$response->message = $rejection;
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Liegt die Bankverbindung schon vor, entsteht in einem Zug auch die Abrechnung. Scheitert die,
|
|
||||||
// soll keine halbe Freigabe zurückbleiben -- deshalb beides in einer Transaktion.
|
|
||||||
$refund = DB::transaction(function (): ParticipantRefund {
|
|
||||||
$refund = ParticipantRefund::create([
|
|
||||||
'tenant' => $this->participant->tenant,
|
|
||||||
'event_id' => $this->participant->event_id,
|
|
||||||
'event_participant_id' => $this->participant->id,
|
|
||||||
'token' => Str::random(32),
|
|
||||||
'status' => ParticipantRefund::STATUS_PENDING,
|
|
||||||
'amount' => $this->request->amount,
|
|
||||||
'reason' => $this->request->reason,
|
|
||||||
'reason_note' => $this->reasonNote(),
|
|
||||||
// Was beim Verband bleibt, wird hier festgeschrieben: Nach dem Einreichen führt
|
|
||||||
// `amount_paid` bereits diesen Rest, eine spätere Differenz wäre falsch.
|
|
||||||
'retained_amount' => $this->request->retainedAmount(),
|
|
||||||
'retention_reason' => $this->retentionReason(),
|
|
||||||
'retention_reason_note' => $this->retentionReasonNote(),
|
|
||||||
'released_by' => currentUser()?->id,
|
|
||||||
'released_at' => now(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ($this->request->submitsDirectly()) {
|
|
||||||
$this->submitDirectly($refund);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $refund;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!$this->request->submitsDirectly()) {
|
|
||||||
$this->notify($refund);
|
|
||||||
}
|
|
||||||
|
|
||||||
$response->success = true;
|
|
||||||
$response->refund = $refund->fresh();
|
|
||||||
$response->message = match (true) {
|
|
||||||
$this->request->donation => 'Die Spende wurde eingereicht. Der Teili hat den Beleg per E-Mail erhalten.',
|
|
||||||
$this->request->hasBankDetails() => 'Die Erstattung wurde eingereicht. Der Teili hat den Beleg per E-Mail erhalten.',
|
|
||||||
default => 'Die Erstattung wurde freigegeben. Der Teili wurde per E-Mail informiert.',
|
|
||||||
};
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reicht die Erstattung sofort ein, ohne den Umweg über den Teili.
|
|
||||||
*
|
|
||||||
* Über denselben Command, den sonst der Bestätigungslink auslöst: Beleg, Abrechnung, das Nullstellen
|
|
||||||
* des gezahlten Beitrags und die Mail mit dem Beleg laufen dadurch in beiden Wegen identisch ab.
|
|
||||||
*/
|
|
||||||
private function submitDirectly(ParticipantRefund $refund): void
|
|
||||||
{
|
|
||||||
$acceptResponse = new AcceptRefundCommand(new AcceptRefundRequest(
|
|
||||||
refund: $refund,
|
|
||||||
accountOwner: (string) $this->request->accountOwner,
|
|
||||||
accountIban: (string) $this->request->accountIban,
|
|
||||||
donation: $this->request->donation,
|
|
||||||
// Niemand kreuzt hier eine Erklärung an; wer die Angaben aufgenommen hat, hält `captured_by`
|
|
||||||
// fest, und der Beleg weist es aus.
|
|
||||||
capturedBy: currentUser()?->id,
|
|
||||||
))->execute();
|
|
||||||
|
|
||||||
if (!$acceptResponse->success) {
|
|
||||||
// Rollt die Freigabe zurück -- die Aktionsleitung soll den Fehler sehen und nicht einen
|
|
||||||
// Vorgang vorfinden, der nirgends eingereicht ist.
|
|
||||||
throw new RuntimeException($acceptResponse->message ?? 'Die Erstattung konnte nicht eingereicht werden.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Alle Gründe, aus denen eine Freigabe nicht zulässig ist.
|
|
||||||
*
|
|
||||||
* @return string|null Meldung, oder null wenn nichts dagegen spricht.
|
|
||||||
*/
|
|
||||||
private function reject(): ?string
|
|
||||||
{
|
|
||||||
if ($this->participant->unregistered_at === null) {
|
|
||||||
return 'Eine Erstattung ist nur für abgemeldete Teilis möglich.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->refunds->openFor($this->participant) !== null) {
|
|
||||||
return 'Für diese Anmeldung läuft bereits eine Erstattung.';
|
|
||||||
}
|
|
||||||
|
|
||||||
$amount = $this->request->amount->getAmount();
|
|
||||||
if ($amount <= 0) {
|
|
||||||
return 'Der Erstattungsbetrag muss größer als 0 sein.';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mehr zurückgeben als eingegangen ist wäre keine Erstattung mehr. Die halbe Cent-Toleranz
|
|
||||||
// fängt die Rundung des gespeicherten Floats ab.
|
|
||||||
$paid = $this->participant->amount_paid?->getAmount() ?? 0.0;
|
|
||||||
if ($amount > $paid + 0.005) {
|
|
||||||
return 'Der Erstattungsbetrag darf den gezahlten Beitrag nicht übersteigen.';
|
|
||||||
}
|
|
||||||
|
|
||||||
$reason = RefundReason::find($this->request->reason);
|
|
||||||
if ($reason === null) {
|
|
||||||
return 'Bitte wähle einen Erstattungsgrund aus.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($reason->requires_note && trim((string) $this->request->reasonNote) === '') {
|
|
||||||
return 'Für diesen Grund ist eine Erläuterung erforderlich.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->rejectRetention() ?? $this->rejectBankDetails();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüfungen zum einbehaltenen Teil.
|
|
||||||
*
|
|
||||||
* Sicherheitsnetz hinter der Oberfläche: Dort erscheint der Absende-Knopf erst, wenn ein Grund
|
|
||||||
* gewählt ist. Über einen direkten Aufruf ginge das sonst vorbei, und ein einbehaltener Betrag ohne
|
|
||||||
* Begründung ist in der Buchhaltung nicht haltbar.
|
|
||||||
*/
|
|
||||||
private function rejectRetention(): ?string
|
|
||||||
{
|
|
||||||
if (!$this->request->hasRetention()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$reason = RetentionReason::find($this->request->retentionReason);
|
|
||||||
if ($reason === null) {
|
|
||||||
return 'Bitte gib an, warum ein Teil des Beitrags einbehalten wird.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($reason->requires_note && trim((string) $this->request->retentionReasonNote) === '') {
|
|
||||||
return 'Für diesen Einbehaltungsgrund ist eine Erläuterung erforderlich.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prüfungen, die nur den Direktweg betreffen -- die Erstattung wird dabei sofort eingereicht, es gibt
|
|
||||||
* also keine zweite Gelegenheit, Angaben zu berichtigen.
|
|
||||||
*/
|
|
||||||
private function rejectBankDetails(): ?string
|
|
||||||
{
|
|
||||||
// Eine Spende wird nicht ausgezahlt. Kämen beide Angaben zusammen, wäre unklar, was gilt --
|
|
||||||
// lieber nachfragen als das eine stillschweigend gegen das andere entscheiden.
|
|
||||||
if ($this->request->donation && (filled($this->request->accountOwner) || filled($this->request->accountIban))) {
|
|
||||||
return 'Eine Spende braucht keine Bankverbindung.';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Halb ausgefüllt ist keine Absicht: entweder beides oder der Weg über den Teili.
|
|
||||||
if (!$this->request->donation
|
|
||||||
&& filled($this->request->accountOwner) !== filled($this->request->accountIban)) {
|
|
||||||
return 'Für die sofortige Erstattung werden Kontoinhaber*in und IBAN benötigt.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$this->request->submitsDirectly()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->request->hasBankDetails() && !Iban::isValid((string) $this->request->accountIban)) {
|
|
||||||
return 'Diese IBAN stimmt nicht. Bitte prüfe die Eingabe.';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ohne Kostenstelle ließe sich die Abrechnung nicht anlegen -- auch die Spende braucht eine, sie
|
|
||||||
// wird ja gebucht. Hier abfangen und nicht erst in der Transaktion, damit die Aktionsleitung eine
|
|
||||||
// verständliche Meldung sieht.
|
|
||||||
if ($this->participant->event->cost_unit_id === null) {
|
|
||||||
return 'Die Veranstaltung hat keine Kostenstelle -- die Erstattung kann nicht eingereicht werden.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Der Freitext gehört nur zu Gründen, die ihn verlangen -- sonst stünde er ungenutzt in der DB. */
|
|
||||||
private function reasonNote(): ?string
|
|
||||||
{
|
|
||||||
$reason = RefundReason::find($this->request->reason);
|
|
||||||
|
|
||||||
if ($reason === null || !$reason->requires_note) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim((string) $this->request->reasonNote);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der Einbehaltungsgrund -- nur, wenn tatsächlich etwas beim Verband bleibt.
|
|
||||||
*
|
|
||||||
* Bei voller Erstattung wird ein mitgeschickter Grund verworfen: In der Oberfläche ist das Feld dann
|
|
||||||
* gar nicht sichtbar, und ein Wert ohne Bezug hätte in der Datenbank nichts zu suchen.
|
|
||||||
*/
|
|
||||||
private function retentionReason(): ?string
|
|
||||||
{
|
|
||||||
return $this->request->hasRetention() ? $this->request->retentionReason : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Der Freitext dazu -- wie beim Erstattungsgrund nur bei Gründen, die ihn verlangen. */
|
|
||||||
private function retentionReasonNote(): ?string
|
|
||||||
{
|
|
||||||
if (!$this->request->hasRetention()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$reason = RetentionReason::find($this->request->retentionReason);
|
|
||||||
|
|
||||||
if ($reason === null || !$reason->requires_note) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return trim((string) $this->request->retentionReasonNote);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Teili und Kontaktperson bekommen je eine eigene Mail -- dasselbe Muster wie bei der Abmeldung
|
|
||||||
* (siehe SetParticipationStateCommand).
|
|
||||||
*/
|
|
||||||
private function notify(ParticipantRefund $refund): void
|
|
||||||
{
|
|
||||||
$recipients = [$this->participant->email_1];
|
|
||||||
|
|
||||||
// `filled()` und nicht `!== null`: Der Anmeldewizard überspringt den Schritt "Kontaktperson" bei
|
|
||||||
// Volljährigen und legt das Feld als Leerstring an -- `Mail::to('')` liefe ins Leere.
|
|
||||||
if (filled($this->participant->email_2)) {
|
|
||||||
$recipients[] = $this->participant->email_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($recipients as $recipient) {
|
|
||||||
Mail::to($recipient)->send(new RefundReleasedMail(
|
|
||||||
participant: $this->participant,
|
|
||||||
refund: $refund,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\ReleaseRefund;
|
|
||||||
|
|
||||||
use App\Models\EventParticipant;
|
|
||||||
use App\ValueObjects\Amount;
|
|
||||||
|
|
||||||
class ReleaseRefundRequest
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
public readonly EventParticipant $participant,
|
|
||||||
public readonly Amount $amount,
|
|
||||||
public readonly string $reason,
|
|
||||||
public readonly ?string $reasonNote = null,
|
|
||||||
/**
|
|
||||||
* Die Bankverbindung, wenn sie der Aktionsleitung bereits vorliegt.
|
|
||||||
*
|
|
||||||
* Sind beide gesetzt, entfällt der Umweg über den Teili: die Erstattung wird sofort eingereicht.
|
|
||||||
* Bleiben sie leer, läuft der übliche Weg über den Bestätigungslink.
|
|
||||||
*/
|
|
||||||
public readonly ?string $accountOwner = null,
|
|
||||||
public readonly ?string $accountIban = null,
|
|
||||||
/**
|
|
||||||
* Warum ein Teil des Beitrags beim Verband bleibt.
|
|
||||||
*
|
|
||||||
* Pflicht, sobald weniger erstattet wird als gezahlt wurde: Ein einbehaltener Betrag ohne Grund
|
|
||||||
* ist in der Buchhaltung nicht haltbar.
|
|
||||||
*/
|
|
||||||
public readonly ?string $retentionReason = null,
|
|
||||||
public readonly ?string $retentionReasonNote = null,
|
|
||||||
/**
|
|
||||||
* Der Teili spendet den Betrag, statt ihn ausgezahlt zu bekommen.
|
|
||||||
*
|
|
||||||
* Dann braucht es keine Bankverbindung, und die Erstattung wird -- wie beim vorliegenden Konto --
|
|
||||||
* sofort eingereicht. Gespeichert wird die Entscheidung in der Abrechnung, nicht am Vorgang.
|
|
||||||
*/
|
|
||||||
public readonly bool $donation = false,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Ob die Erstattung ohne Zutun des Teilis eingereicht werden kann. */
|
|
||||||
public function hasBankDetails(): bool
|
|
||||||
{
|
|
||||||
return filled($this->accountOwner) && filled($this->accountIban);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Ob sofort eingereicht wird -- entweder liegt die Bankverbindung vor, oder es wird gespendet. */
|
|
||||||
public function submitsDirectly(): bool
|
|
||||||
{
|
|
||||||
return $this->hasBankDetails() || $this->donation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Der Betrag, der beim Verband bleibt.
|
|
||||||
*
|
|
||||||
* Die halbe Cent-Toleranz fängt die Rundung des gespeicherten Floats ab -- ohne sie entstünden
|
|
||||||
* Restbeträge von Bruchteilen eines Cents, die eine Begründung verlangen würden.
|
|
||||||
*/
|
|
||||||
public function retainedAmount(): float
|
|
||||||
{
|
|
||||||
$paid = $this->participant->amount_paid?->getAmount() ?? 0.0;
|
|
||||||
$remaining = round($paid - $this->amount->getAmount(), 2);
|
|
||||||
|
|
||||||
return $remaining > 0.005 ? $remaining : 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hasRetention(): bool
|
|
||||||
{
|
|
||||||
return $this->retainedAmount() > 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\ReleaseRefund;
|
|
||||||
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
|
|
||||||
class ReleaseRefundResponse
|
|
||||||
{
|
|
||||||
public bool $success = false;
|
|
||||||
|
|
||||||
public ?ParticipantRefund $refund = null;
|
|
||||||
|
|
||||||
public ?string $message = null;
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\ResendRefundMail;
|
|
||||||
|
|
||||||
use App\Mail\ParticipantRefundMails\RefundReleasedMail;
|
|
||||||
use App\Models\EventParticipant;
|
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Schickt die Mail zu einer freigegebenen Erstattung noch einmal.
|
|
||||||
*
|
|
||||||
* Der häufige Fall, wenn ein Vorgang hängt: die erste Mail ist untergegangen. Am Vorgang ändert sich
|
|
||||||
* dabei nichts -- `released_at` bleibt der Zeitpunkt der Vormerkung, der Token bleibt derselbe, der alte
|
|
||||||
* Link funktioniert also weiter.
|
|
||||||
*
|
|
||||||
* Nur solange die Bankverbindung fehlt: nach der Bestätigung wäre der Link wertlos, nach dem Abbruch
|
|
||||||
* liefe er ins Leere.
|
|
||||||
*/
|
|
||||||
class ResendRefundMailCommand
|
|
||||||
{
|
|
||||||
public function __construct(private readonly ResendRefundMailRequest $request)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public function execute(): ResendRefundMailResponse
|
|
||||||
{
|
|
||||||
$response = new ResendRefundMailResponse();
|
|
||||||
$refund = $this->request->refund;
|
|
||||||
|
|
||||||
if (!$refund->isPending()) {
|
|
||||||
$response->message = $refund->isAccepted()
|
|
||||||
? 'Diese Erstattung wurde bereits bestätigt -- es gibt nichts mehr nachzureichen.'
|
|
||||||
: 'Diese Erstattung wurde abgebrochen.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->notify();
|
|
||||||
|
|
||||||
$response->success = true;
|
|
||||||
$response->message = 'Die Rückerstattungsmail wurde erneut versendet.';
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Teili und Kontaktperson bekommen je eine eigene Mail -- dasselbe Muster wie bei der Freigabe
|
|
||||||
* (siehe ReleaseRefundCommand).
|
|
||||||
*/
|
|
||||||
private function notify(): void
|
|
||||||
{
|
|
||||||
/** @var EventParticipant $participant */
|
|
||||||
$participant = $this->request->refund->participant()->first();
|
|
||||||
|
|
||||||
$recipients = [$participant->email_1];
|
|
||||||
|
|
||||||
// `filled()` und nicht `!== null`: Der Anmeldewizard überspringt den Schritt "Kontaktperson" bei
|
|
||||||
// Volljährigen und legt das Feld als Leerstring an -- `Mail::to('')` liefe ins Leere.
|
|
||||||
if (filled($participant->email_2)) {
|
|
||||||
$recipients[] = $participant->email_2;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($recipients as $recipient) {
|
|
||||||
Mail::to($recipient)->send(new RefundReleasedMail(
|
|
||||||
participant: $participant,
|
|
||||||
refund: $this->request->refund,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Domains\ParticipantRefund\Actions\ResendRefundMail;
|
|
||||||
|
|
||||||
use App\Models\ParticipantRefund;
|
|
||||||
|
|
||||||
class ResendRefundMailRequest
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
public readonly ParticipantRefund $refund,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user