Ein eigenständig vermarktetes Paket (offers.standalone_bundle) erhält /pakete/{id}
mit seinem tatsächlichen Umfang, Shop-Kachel und Suche. Die Angebotsmaske kennt
Nutzerkreis und Anzahl Trainer. Zwei Bestandstests (CartTest, Vergleich der
Rechte und Erwerbsarten) legen die Vergleichsangebote jetzt als Einzellizenz an,
weil der Nutzerkreis zum identischen Umfang gehört; ihre Aussagen bleiben.
Eine Rechnungs- oder Stripe-Bestellung lässt sich nicht mit der Testzahlung bestätigen.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Commerce;
|
|
|
|
use App\Domain\Catalog\Offer;
|
|
use App\Domain\Catalog\OfferVersion;
|
|
|
|
/**
|
|
* Eine Position des Warenkorbs mit dem Ergebnis der serverseitigen Prüfung.
|
|
*/
|
|
final class CartLine
|
|
{
|
|
public const OK = 'ok';
|
|
|
|
public const PRICE_CHANGED = 'preis_geaendert';
|
|
|
|
public const TERMS_CHANGED = 'bedingungen_geaendert';
|
|
|
|
public const WITHDRAWN = 'zurueckgezogen';
|
|
|
|
public const OWNED = 'bereits_erworben';
|
|
|
|
public const WRONG_HOLDER = 'falscher_inhaber';
|
|
|
|
public function __construct(
|
|
public readonly Offer $offer,
|
|
public readonly ?OfferVersion $version,
|
|
public readonly string $state,
|
|
public readonly int $seenPriceCents,
|
|
public readonly ?int $currentPriceCents,
|
|
public readonly ?string $note = null,
|
|
) {}
|
|
|
|
/** Geht in Summe und Bestellung ein. */
|
|
public function orderable(): bool
|
|
{
|
|
return in_array($this->state, [self::OK, self::PRICE_CHANGED, self::TERMS_CHANGED], true);
|
|
}
|
|
|
|
/** Verhindert den Abschluss, bis der Käufer die Position selbst entfernt oder den Inhaber wechselt. */
|
|
public function blocks(): bool
|
|
{
|
|
return in_array($this->state, [self::WITHDRAWN, self::WRONG_HOLDER], true);
|
|
}
|
|
|
|
public function title(): string
|
|
{
|
|
if ($this->offer->standalone_bundle && $this->version !== null) {
|
|
$bundle = app(ProductOptions::class)->bundleOf($this->version);
|
|
|
|
if ($bundle !== null) {
|
|
return (string) $bundle->name;
|
|
}
|
|
}
|
|
|
|
$composition = $this->offer->composition;
|
|
|
|
return $composition !== null
|
|
? (string) ($composition->display_title ?: $composition->designation)
|
|
: (string) $this->offer->name;
|
|
}
|
|
}
|