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
@@ -4,7 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Entitlement\Acquisition;
|
||||
use App\Domain\Entitlement\AcquisitionType;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
@@ -17,7 +17,10 @@
|
||||
|
||||
class Checkout
|
||||
{
|
||||
public function __construct(private readonly GrantIssuer $grants) {}
|
||||
public function __construct(
|
||||
private readonly GrantIssuer $grants,
|
||||
private readonly OfferService $offers,
|
||||
) {}
|
||||
|
||||
public function place(User $user, Offer $offer): Order
|
||||
{
|
||||
@@ -25,9 +28,9 @@ public function place(User $user, Offer $offer): Order
|
||||
throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
|
||||
}
|
||||
|
||||
$version = $offer->versions()->where('status', OfferStatus::Aktiv)->orderByDesc('number')->first();
|
||||
$version = $this->offers->currentActiveVersion($offer);
|
||||
|
||||
if ($version === null || $version->grant_kind !== 'kauf' || $version->holder_kind !== 'person') {
|
||||
if ($version->grant_kind !== 'kauf' || $version->holder_kind !== 'person') {
|
||||
throw new DomainRuleException('Dieses Angebot kann nicht als persönlicher Kauf bestellt werden.');
|
||||
}
|
||||
|
||||
@@ -35,7 +38,7 @@ public function place(User $user, Offer $offer): Order
|
||||
throw new DomainRuleException('Der Kauf braucht einen Preis an der Angebotsfassung.');
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($user, $version): Order {
|
||||
return DB::transaction(function () use ($user, $offer, $version): Order {
|
||||
$order = Order::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'party_id' => $user->party_id,
|
||||
@@ -44,6 +47,7 @@ public function place(User $user, Offer $offer): Order
|
||||
]);
|
||||
$line = $order->lines()->create([
|
||||
'offer_version_id' => $version->id,
|
||||
'offer_name' => $offer->name,
|
||||
'price_cents' => $version->price_cents,
|
||||
'term_rule' => $version->term_rule,
|
||||
'update_promise' => $version->update_promise,
|
||||
|
||||
Reference in new issue
Block a user