CI Feature / test (push) Failing after 3m16s
Die Produktseite ist die Seite des Artikels (/shop/{id}), den die Option als einzige
Position verkauft, oder die Paketseite. Sie wird nicht mehr einem Programm zugeordnet.
Ein Kauf braucht genau eine Position und einen Preis, sonst lässt er sich nicht aktivieren.
Module und Programme werden dadurch nicht öffentlich (Karten und /programme unverändert).
Tests: Die Tests, die eine Programmseite als Produktseite voraussetzten, prüfen jetzt die
Artikelseite; die Zuordnung „eigene Paketseite oder Programmseite“ entfällt (ADR-52).
Ein Altbestandstest sichert die Programmseite für Angebote mit mehreren Positionen.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
71 lines
1.9 KiB
PHP
71 lines
1.9 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
|
|
{
|
|
$products = app(ProductOptions::class);
|
|
|
|
if ($this->version !== null) {
|
|
$article = $products->articleOf($this->version);
|
|
|
|
if ($article !== null) {
|
|
return $products->articleTitle($article);
|
|
}
|
|
|
|
$bundle = $products->bundleOf($this->version);
|
|
|
|
if ($bundle !== null && $this->version->lines->count() === 1) {
|
|
return (string) $bundle->name;
|
|
}
|
|
}
|
|
|
|
$composition = $this->offer->composition;
|
|
|
|
return $composition !== null
|
|
? (string) ($composition->display_title ?: $composition->designation)
|
|
: (string) $this->offer->name;
|
|
}
|
|
}
|