Teilnahmerechnungen erstellen
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
<?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>';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user