Paket 1: eine aktive Angebotsfassung und Bestellbezeichnung
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8cd382c357
commit
7820bececb
13 files changed
+529
-25
No files matched your search
@@ -34,11 +34,24 @@ protected function casts(): array
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::updating(function (OfferVersion $version): void {
|
||||
if (in_array(StatusValue::of($version->getOriginal('status')), [
|
||||
OfferStatus::Aktiv->value,
|
||||
OfferStatus::Beendet->value,
|
||||
], true)) {
|
||||
throw new DomainRuleException('Eine aktivierte Angebotsfassung ist unveränderlich.');
|
||||
$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.');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user