Handling of event addons
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enumerations;
|
||||
|
||||
use App\Scopes\CommonModel;
|
||||
|
||||
/**
|
||||
* Gründe für eine Umsatzsteuerbefreiung -- DB-gestützt (analog {@see PaymentStatus}), damit Label und
|
||||
* der auf der Rechnung verpflichtende Hinweis nach § 14 Abs. 4 Nr. 8 UStG zentral pflegbar sind.
|
||||
* Gemeinnützigkeit allein befreit nicht; die Befreiung braucht immer einen konkreten Rechtsgrund
|
||||
* (Vereins-Fälle über § 4 Nr. 22a / Nr. 25).
|
||||
*
|
||||
* @property string $slug
|
||||
* @property string $name
|
||||
* @property string $invoice_text
|
||||
* @property bool $requires_note
|
||||
* @property int $sort_order
|
||||
*/
|
||||
class TaxExemptionReason extends CommonModel
|
||||
{
|
||||
public const string USTG_19 = 'ustg_19';
|
||||
public const string USTG_4_24 = 'ustg_4_24';
|
||||
public const string USTG_4_25A = 'ustg_4_25a';
|
||||
public const string USTG_4_22A = 'ustg_4_22a';
|
||||
public const string CUSTOM = 'custom';
|
||||
|
||||
protected $table = 'tax_exemption_reasons';
|
||||
protected $primaryKey = 'slug';
|
||||
public $incrementing = false;
|
||||
protected $keyType = 'string';
|
||||
|
||||
protected $fillable = [
|
||||
'slug',
|
||||
'name',
|
||||
'invoice_text',
|
||||
'requires_note',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'requires_note' => 'boolean',
|
||||
'sort_order' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* Pflichthinweis für die Rechnung. Bei einem individuellen Grund (requires_note) wird der hinterlegte
|
||||
* Freitext des Tenants verwendet.
|
||||
*/
|
||||
public function invoiceText(?string $customNote = null): string
|
||||
{
|
||||
return $this->requires_note ? trim((string) $customNote) : $this->invoice_text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionen für das Frontend inkl. Vorschau-Text. Bei einem Freitext-Grund ist `text` leer, da der Text
|
||||
* erst aus dem Freitext des Tenants entsteht.
|
||||
*
|
||||
* @return array<int, array{value: string, label: string, text: string}>
|
||||
*/
|
||||
public static function options(): array
|
||||
{
|
||||
return self::orderBy('sort_order')->get()
|
||||
->map(static fn (self $reason): array => [
|
||||
'value' => $reason->slug,
|
||||
'label' => $reason->name,
|
||||
'text' => $reason->requires_note ? '' : $reason->invoice_text,
|
||||
])
|
||||
->all();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enumerations;
|
||||
|
||||
/**
|
||||
* Preismodus bei bestehender Umsatzsteuerpflicht: entweder ist die USt bereits im konfigurierten Beitrag
|
||||
* enthalten (Brutto/„Supermarkt") oder sie wird bei der Preisermittlung aufgeschlagen (Netto). Gespeichert
|
||||
* wird immer der finale Brutto-Beitrag; der Modus beeinflusst nur die Preisermittlung im Anmeldeprozess.
|
||||
*/
|
||||
enum VatPricingMode: string
|
||||
{
|
||||
case Inclusive = 'inclusive';
|
||||
case AddOn = 'add_on';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Inclusive => 'Inklusive – Beiträge sind Endpreise (USt enthalten)',
|
||||
self::AddOn => 'Aufschlagen – USt wird auf die Beiträge aufgeschlagen',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Optionen für das Frontend: [['value' => ..., 'label' => ...], ...].
|
||||
*
|
||||
* @return array<int, array{value: string, label: string}>
|
||||
*/
|
||||
public static function options(): array
|
||||
{
|
||||
return array_map(
|
||||
static fn (self $mode): array => [
|
||||
'value' => $mode->value,
|
||||
'label' => $mode->label(),
|
||||
],
|
||||
self::cases(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user