Paket 1: eine aktive Angebotsfassung und Bestellbezeichnung
Deploy Test / test (push) Failing after 10s
Deploy Test / deploy (push) Skipped

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-16 06:54:43 +01:00
1 parent 8cd382c357
commit 7820bececb
13 files changed
+529 -25

No files matched your search

+21
View File
@@ -8,6 +8,20 @@ class OfferService
{
public function __construct(private readonly BundleService $bundles) {}
public function currentActiveVersion(Offer $offer): OfferVersion
{
$version = $offer->versions()
->where('status', OfferStatus::Aktiv)
->orderByDesc('number')
->first();
if ($version === null) {
throw new DomainRuleException('Das Angebot hat keine aktive Fassung.');
}
return $version;
}
/**
* @param array<string, mixed> $capabilities
* @param array<string, mixed> $options
@@ -77,6 +91,13 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
$scope = $this->scopeFor($lines);
return DB::transaction(function () use ($offer, $lines, $attributes, $scope): OfferVersion {
$offer = Offer::query()->lockForUpdate()->findOrFail($offer->id);
OfferVersion::query()
->where('offer_id', $offer->id)
->where('status', OfferStatus::Aktiv)
->update(['status' => OfferStatus::Beendet->value]);
$version = $offer->versions()->create([
'number' => ((int) $offer->versions()->max('number')) + 1,
'status' => OfferStatus::Entwurf,