Domäne: Rabattcodes mit Geltungsbereich (Warenkorb oder gewählte Ziele) und Einlösungsberechtigung (allgemein oder freigeschaltete Konten) unabhängig voneinander; Prüfung bei Eingabe, in jeder Übersicht und unter Sperre vor Bestellabschluss (Prüfsumme der Übersicht enthält den Rabatt). Rabatt je Position, Zwischensumme und Zahlbetrag in der Bestellung; Stripe erhält den Preis nach Rabatt. Nutzerkreis (Einzel-/Mehrfachlizenz, Trainerzahl) an der Angebotsfassung, kopiert in Bestellposition und Erwerb, Teil der Prüfung "Bereits erworben". OfferService::activate lehnt Angebote ohne veröffentlichten Artikelstand ab. Kasse: Zustimmungen als Pflichtangabe mit Nachweis, "Zahlungspflichtig bestellen", Rechnungsweg für Organisationen, Erstattung über Stripe, Widerruf erklären. Produktivfreigabe SHOP_LIVE_RELEASE standardmäßig aus. Bestandstests geändert (fachlich überholt, Assertions nicht abgeschwächt): die Schaltfläche heißt "Zahlungspflichtig bestellen" (§ 312j BGB), die Summe heißt "Zu zahlen", der Vereinshinweis steht als Rollenliste; Bestellungen über die Kasse senden jetzt die Zustimmungen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
76 lines
2.0 KiB
PHP
76 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class OfferVersion extends Model
|
|
{
|
|
protected $fillable = [
|
|
'offer_id',
|
|
'number',
|
|
'status',
|
|
'price_cents',
|
|
'tax_class',
|
|
'term_rule',
|
|
'update_promise',
|
|
'dynamic',
|
|
'grant_kind',
|
|
'holder_kind',
|
|
'licence_scope',
|
|
'trainer_count',
|
|
'activated_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'status' => OfferStatus::class,
|
|
'dynamic' => 'boolean',
|
|
'activated_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
protected static function booted(): void
|
|
{
|
|
static::updating(function (OfferVersion $version): void {
|
|
$original = StatusValue::of($version->getOriginal('status'));
|
|
$next = StatusValue::of($version->status);
|
|
|
|
if ($original === OfferStatus::Beendet->value) {
|
|
throw new DomainRuleException('Eine beendete Angebotsfassung ist unveränderlich.');
|
|
}
|
|
|
|
if ($original === OfferStatus::Aktiv->value) {
|
|
if ($next !== OfferStatus::Beendet->value) {
|
|
throw new DomainRuleException('Eine aktive Angebotsfassung lässt sich nur durch Beendigung schließen.');
|
|
}
|
|
|
|
$dirty = $version->getDirty();
|
|
unset($dirty['status'], $dirty['updated_at']);
|
|
|
|
if ($dirty !== []) {
|
|
throw new DomainRuleException('Eine aktive Angebotsfassung lässt sich nur durch Beendigung schließen.');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
public function offer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Offer::class);
|
|
}
|
|
|
|
public function lines(): HasMany
|
|
{
|
|
return $this->hasMany(OfferLine::class)->orderBy('position');
|
|
}
|
|
|
|
public function resolvedScopes(): HasMany
|
|
{
|
|
return $this->hasMany(ResolvedScope::class);
|
|
}
|
|
}
|