Added tax support
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user