- Implement OfferOptionAdminTest to validate offer option management, including price display, activation, and cancellation. - Create OrganizationPurchaseTest to ensure correct handling of organization purchases, including access control and order processing. - Add ShopProductPageTest to verify shop product listings, search functionality, and product page details. - Introduce BuildsShop trait for seeding test data related to shop functionality. - Implement MoneyTest to validate money parsing and formatting, ensuring correct handling of euro amounts.
55 lines
1.5 KiB
PHP
55 lines
1.5 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
|
|
{
|
|
$composition = $this->offer->composition;
|
|
|
|
return $composition !== null
|
|
? (string) ($composition->display_title ?: $composition->designation)
|
|
: (string) $this->offer->name;
|
|
}
|
|
}
|