Vermieterdaten, Bank, Steuerangabe, Adressen, Betriebsart und Fristen sind
Spalten von `tenants`. `App\Tenancy\TenantConfig` legt sie über
`config('fewo.*')` und `mail.from`, sobald der Mandantenkontext wechselt –
so lesen Vorlagen, Mails und der Mietvertrag weiter dieselben Schlüssel und
`resources/themes/**` bleibt unangetastet.
Die `.env` ist die Grundlinie: Rückfall, solange kein Mandant feststeht, und
Grenze für Löschfristen und Bot-Schutz (nur verschärfen, nicht lockern). Die
Flutgrenze bleibt global. Bank, Steuerangabe und eigene Dienst-Schlüssel
liegen verschlüsselt.
Die Seite System › Betrieb schreibt jetzt den Mandanten und enthält
zusätzlich Vermieterdaten, Bank und die Fristen. Tabelle `settings` und
Modell `Setting` entfallen; die Migration übernimmt die bisherigen Werte
aus `settings` und der Konfiguration in den Mandanten Stommer.
Neu: `tenant_services` (Freischaltung je Dienst mit optionalem eigenem
API-Schlüssel, nur im Betreiber-Bereich schaltbar) und `service_usages`.
Es zählt noch nichts, weil kein Dienst aufruft.
235 Feature-Tests grün. Der Umbauweg wurde zusätzlich auf einer Kopie der
lokalen Datenbank durchgespielt.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
65 lines
2.8 KiB
PHP
65 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Tenancy;
|
|
|
|
use Illuminate\Support\Facades\Crypt;
|
|
|
|
/**
|
|
* Operating data of a landlord taken from what the single-landlord installation used: the admin settings
|
|
* and config/.env. Used once by the migration and as the factory default in tests.
|
|
*/
|
|
class TenantDefaults
|
|
{
|
|
/**
|
|
* @param array<string, ?string> $settings Rows of the former `settings` table (key => value)
|
|
* @param bool $encryptBank true for raw database writes; the model's own cast encrypts otherwise
|
|
* @return array<string, mixed>
|
|
*/
|
|
public static function forLegacyLandlord(array $settings = [], bool $encryptBank = true): array
|
|
{
|
|
return [
|
|
'owner_name' => self::baseline('fewo.owner.name'),
|
|
'owner_street' => self::baseline('fewo.owner.street'),
|
|
'owner_city' => self::baseline('fewo.owner.city'),
|
|
'owner_phone' => self::baseline('fewo.owner.phone'),
|
|
'contact_email' => self::setting($settings, 'addresses.contact') ?? self::baseline('fewo.owner.email'),
|
|
'notification_emails' => self::setting($settings, 'addresses.notifications') ?? config('fewo.notification_email'),
|
|
'sender_name' => self::setting($settings, 'addresses.sender_name') ?? self::baseline('mail.from.name'),
|
|
'sender_email' => self::setting($settings, 'addresses.sender_email') ?? self::baseline('mail.from.address'),
|
|
'bank_account_holder' => self::bank(self::baseline('fewo.bank.account_holder'), $encryptBank),
|
|
'bank_iban' => self::bank(self::baseline('fewo.bank.iban'), $encryptBank),
|
|
'bank_bic' => self::bank(self::baseline('fewo.bank.bic'), $encryptBank),
|
|
'bank_name' => self::bank(self::baseline('fewo.bank.bank_name'), $encryptBank),
|
|
'operating_mode' => ($settings['operations.mode'] ?? 'test') === 'live' ? 'live' : 'test',
|
|
'test_recipient' => self::setting($settings, 'operations.test_recipient'),
|
|
'deposit_due_days' => self::baseline('fewo.deposit_due_days'),
|
|
'review_request_after_days' => self::baseline('fewo.review_request_after_days'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* The value of the installation, not the one a landlord may already have laid over the configuration.
|
|
*/
|
|
private static function baseline(string $key): mixed
|
|
{
|
|
return app(TenantConfig::class)->baselineValue($key);
|
|
}
|
|
|
|
/**
|
|
* @param array<string, ?string> $settings
|
|
*/
|
|
private static function setting(array $settings, string $key): ?string
|
|
{
|
|
return filled($settings[$key] ?? null) ? (string) $settings[$key] : null;
|
|
}
|
|
|
|
private static function bank(mixed $value, bool $encrypt): ?string
|
|
{
|
|
if (blank($value)) {
|
|
return null;
|
|
}
|
|
|
|
return $encrypt ? Crypt::encryptString((string) $value) : (string) $value;
|
|
}
|
|
}
|