Files
mareike/app/Enumerations/TaxExemptionReason.php
T
th.guentherandClaude Opus 4.8 09f9767eb7 Merge origin/dev-4.7.0: Steuer-Feature (Preismodus + DB-gestützte Befreiungsgründe)
Konflikte in den Steuer-Dateien zugunsten der weiterentwickelten lokalen Version
aufgelöst: vat_pricing_mode (Preismodus), DB-gestützte tax_exemption_reasons mit FK,
typisierte Request-DTOs, Event-Steuer-Snapshot. origin/dev-4.7.0 enthielt eine
frühere Teilmenge desselben Features.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-10 14:34:50 +02:00

67 lines
2.0 KiB
PHP

<?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
*/
class TaxExemptionReason extends CommonModel
{
public const string SMALL_BUSINESS = 'small_business';
public const string EDUCATION = 'education';
public const string YOUTH_WELFARE = 'youth_welfare';
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',
];
protected $casts = [
'requires_note' => 'boolean',
];
/**
* 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::all()
->map(static fn (self $reason): array => [
'value' => $reason->slug,
'label' => $reason->name,
'text' => $reason->requires_note ? '' : $reason->invoice_text,
])
->all();
}
}