Small improvements

This commit is contained in:
2026-08-05 18:08:04 +02:00
parent f8dba18854
commit 7f8417e915
12 changed files with 110 additions and 16 deletions
@@ -33,7 +33,7 @@ class CreateTenantAction
$paymentMethodDefaults = PaymentMethod::defaults();
foreach (PaymentMethod::all() as $paymentMethod) {
$defaults = $paymentMethodDefaults[$paymentMethod->slug] ?? ['name' => $paymentMethod->slug, 'description' => null];
$defaults = $paymentMethodDefaults[$paymentMethod->slug] ?? ['name' => $paymentMethod->slug, 'description' => null, 'configuration' => []];
AvailablePaymentMethod::create([
'tenant' => $tenant->slug,
@@ -41,6 +41,7 @@ class CreateTenantAction
'name' => $defaults['name'],
'description' => $defaults['description'],
'active' => true,
'configuration' => PaymentMethod::sanitizeConfiguration($paymentMethod->slug, $defaults['configuration'] ?? []),
]);
}
@@ -2,6 +2,10 @@
namespace App\Domains\Admin\Actions\UpdateTenantPayment;
use App\Models\AvailablePaymentMethod;
use App\Models\PaymentMethod;
use App\Scopes\SiteScope;
class UpdateTenantPaymentAction
{
public function __construct(private UpdateTenantPaymentRequest $request)
@@ -18,9 +22,41 @@ class UpdateTenantPaymentAction
'account_name' => $this->request->accountName,
]);
$this->syncTransferPaymentConfiguration();
$response->success = true;
$response->message = 'Bezahldaten wurden gespeichert.';
$response->message = 'IBAN-Informationen wurden gespeichert.';
return $response;
}
/**
* Übernimmt die eingegebenen IBAN-Daten direkt in die Tenant-Config der Überweisungs-Zahlungsart
* (Kontoinhaber/IBAN/BIC), damit sie nicht doppelt gepflegt werden müssen. Bestehende weitere
* Config-Werte (z.B. Symbol) bleiben erhalten. Der Ziel-Tenant kann ein verwalteter sein, daher
* ohne SiteScope explizit auf den Tenant-Slug gefiltert.
*/
private function syncTransferPaymentConfiguration(): void
{
$slug = PaymentMethod::PAYMENT_ACCOUNT_TRANSACTION;
$method = AvailablePaymentMethod::withoutGlobalScope(SiteScope::class)
->where('tenant', $this->request->tenant->slug)
->where('slug', $slug)
->first();
if ($method === null) {
return;
}
$method->configuration = PaymentMethod::sanitizeConfiguration($slug, array_merge(
$method->configuration ?? [],
[
'account_owner' => $this->request->accountName,
'iban' => $this->request->accountIban,
'bic' => $this->request->accountBic,
],
));
$method->save();
}
}