E3: Rechtstext-Versionierung in der DB (legal_documents)

Jede veroeffentlichte Fassung eines Rechtstexts ist eine Zeile mit
type/version/effective_from — alte Fassungen sind unloeschbar, zukuenftige
werden erst ab Stichtag wirksam (LegalDocument::current). Seeder legt die
fuenf aktuellen Fassungen an (AGB 0.6, Datenschutz 0.3, Richtlinien 0.1,
Meldeverfahren 0.1, Impressum 0.1). Die Unternehmer-Bestaetigung (T1neu)
referenziert jetzt die konkrete Fassung (legal_document_id am
Buchungsdatensatz, restrictOnDelete); AGB-Seite und Buchungs-Modal ziehen
Version/Stand aus der DB. config/legal.php bleibt reiner Fallback.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-07-06 09:21:52 +00:00
parent dc2b2b0d7d
commit 7510e7633e
12 changed files with 294 additions and 11 deletions

View file

@ -3,12 +3,14 @@
use App\Enums\UserPaymentOptionStatus;
use App\Models\BillingAddress;
use App\Models\BookingConfirmation;
use App\Models\LegalDocument;
use App\Models\Plan;
use App\Models\SinglePurchase;
use App\Models\User;
use App\Models\UserPaymentOption;
use App\Services\Billing\CreditWalletService;
use App\Services\Billing\StripeCheckoutService;
use Database\Seeders\LegalDocumentSeeder;
use Database\Seeders\RolesAndPermissionsSeeder;
use Livewire\Volt\Volt as LivewireVolt;
use Tests\TestCase;
@ -296,6 +298,8 @@ test('checking the entrepreneur box records a booking confirmation with the agb
/** @var TestCase $this */
// T1neu (AGB v0.6 § 1 Abs. 4): Die Pflicht-Checkbox protokolliert
// Zeitpunkt + AGB-Version — das B2B-Gate stützt sich auf diesen Nachweis.
// E3: Zusätzlich wird die konkrete Rechtstext-Fassung referenziert.
$this->seed(LegalDocumentSeeder::class);
$user = bookingsTestCustomer();
BillingAddress::factory()->create(['user_id' => $user->id]);
config()->set('billing.single_pm_stripe_price_id', 'price_test_single_pm');
@ -307,10 +311,12 @@ test('checking the entrepreneur box records a booking confirmation with the agb
->set('entrepreneurConfirmed', true);
$confirmation = BookingConfirmation::query()->sole();
$agb = LegalDocument::current(LegalDocument::TYPE_AGB);
expect($confirmation->user_id)->toBe($user->id);
expect($confirmation->booking_type)->toBe('single_pm');
expect($confirmation->agb_version)->toBe((string) config('legal.agb_version'));
expect($confirmation->legal_document_id)->toBe($agb->id);
expect($confirmation->agb_version)->toBe($agb->version);
expect($confirmation->confirmed_at)->not->toBeNull();
});