Handling of event addons

This commit is contained in:
2026-08-12 17:18:45 +02:00
parent 085299336e
commit 6e4e6b645c
74 changed files with 3072 additions and 95 deletions
@@ -0,0 +1,66 @@
<?php
namespace App\Domains\Admin\Actions\UpdateTenantTax;
use App\Enumerations\VatPricingMode;
class UpdateTenantTaxAction
{
public function __construct(private UpdateTenantTaxRequest $request)
{
}
public function execute(): UpdateTenantTaxResponse
{
$response = new UpdateTenantTaxResponse();
if ($this->request->taxLiable) {
$this->request->tenant->update([
'tax_liable' => true,
'vat_rate' => $this->clampVatRate($this->request->vatRate),
'vat_pricing_mode' => $this->request->vatPricingMode->value,
'tax_exemption_reason' => null,
'tax_exemption_note' => null,
]);
$response->success = true;
$response->message = 'Steuerinformationen wurden gespeichert.';
return $response;
}
$reason = $this->request->exemptionReason;
if ($reason === null) {
$response->message = 'Bitte einen gültigen Befreiungsgrund auswählen.';
return $response;
}
$note = trim((string)$this->request->exemptionNote);
if ($reason->requires_note && $note === '') {
$response->message = 'Bitte einen Text für den Befreiungsgrund angeben.';
return $response;
}
$this->request->tenant->update([
'tax_liable' => false,
'vat_rate' => 0,
'vat_pricing_mode' => VatPricingMode::Inclusive->value,
'tax_exemption_reason' => $reason->slug,
'tax_exemption_note' => $reason->requires_note ? $note : null,
]);
$response->success = true;
$response->message = 'Steuerinformationen wurden gespeichert.';
return $response;
}
private function clampVatRate(int $vatRate): int
{
return max(0, min(100, $vatRate));
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Domains\Admin\Actions\UpdateTenantTax;
use App\Enumerations\TaxExemptionReason;
use App\Enumerations\VatPricingMode;
use App\Models\Tenant;
class UpdateTenantTaxRequest
{
public function __construct(
public Tenant $tenant,
public bool $taxLiable,
public int $vatRate,
public ?TaxExemptionReason $exemptionReason,
public ?string $exemptionNote,
public VatPricingMode $vatPricingMode,
)
{
}
}
@@ -0,0 +1,9 @@
<?php
namespace App\Domains\Admin\Actions\UpdateTenantTax;
class UpdateTenantTaxResponse
{
public bool $success = false;
public string $message = '';
}