Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28e3342b1f | ||
|
|
657578455f | ||
|
|
3b0b4c955e | ||
|
|
93ae01c986 | ||
|
|
cce22ebd81 | ||
|
|
08f7d0c63d |
No files matched your search
@@ -22,7 +22,10 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
/** Komposition, deren öffentliche Seite die Produktseite dieser Lizenzoption ist. */
|
||||
/**
|
||||
* Altbestand: Programmseite, der eine Option mit mehreren Positionen früher von Hand zugeordnet wurde. Neue Optionen
|
||||
* haben genau eine Position; ihre Produktseite ergibt sich aus ihr (Artikel- oder Paketseite) und wird nicht zugeordnet.
|
||||
*/
|
||||
public function composition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Composition::class);
|
||||
|
||||
@@ -106,9 +106,7 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
|
||||
'trainer_count' => null,
|
||||
], $attributes);
|
||||
|
||||
if ($offer->standalone_bundle && (count($lines) !== 1 || ! $lines[0]['target'] instanceof BundleVersion)) {
|
||||
throw new DomainRuleException('Ein Angebot mit eigener Paketseite besteht aus genau einer Paketfassung (Katalog → Pakete). Für einen Lizenzartikel ordnest du das Angebot der Seite eines Programms zu: Das Programm muss als Programm angelegt und zur Anzeige freigegeben sein, ein Modul genügt nicht.');
|
||||
}
|
||||
$this->assertBuyable($lines, $attributes);
|
||||
|
||||
$this->assertAttributes($attributes);
|
||||
[$attributes['licence_scope'], $attributes['trainer_count']] = LicenceScope::normalise($attributes['licence_scope'], $attributes['trainer_count']);
|
||||
@@ -165,6 +163,68 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Bietet einen Lizenzartikel als Kauf an: legt die Option (Angebot) an und aktiviert ihre erste Fassung in einem
|
||||
* Schritt. Besteht eine Prüfung nicht (Stand, Preis, Rechte), bleibt kein leeres Angebot zurück.
|
||||
*
|
||||
* @param array<string, mixed> $attributes holder_kind, licence_scope, trainer_count, price_cents
|
||||
*/
|
||||
public function offerArticle(LicenseArticle $article, RightsProfileVersion $rights, array $attributes, string $name, ?string $label = null): OfferVersion
|
||||
{
|
||||
return DB::transaction(function () use ($article, $rights, $attributes, $name, $label): OfferVersion {
|
||||
$offer = $this->create($name);
|
||||
$this->setOptionLabel($offer, $label);
|
||||
|
||||
return $this->activate($offer, [['target' => $article, 'rights' => $rights]], [...$attributes, 'grant_kind' => 'kauf']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ändert eine Option eines Artikels: Die nächste Fassung wird aktiv, die bisherige bleibt gespeichert. Bedingungen,
|
||||
* die die Maske nicht zeigt (Laufzeit, Steuerklasse), bleiben die der letzten Fassung. Die Option muss den Artikel
|
||||
* als einzige Position verkaufen.
|
||||
*
|
||||
* @param array<string, mixed> $attributes holder_kind, licence_scope, trainer_count, price_cents
|
||||
*/
|
||||
public function reviseArticleOption(Offer $offer, LicenseArticle $article, RightsProfileVersion $rights, array $attributes, ?string $label = null): OfferVersion
|
||||
{
|
||||
return DB::transaction(function () use ($offer, $article, $rights, $attributes, $label): OfferVersion {
|
||||
$latest = $offer->versions()->with('lines')->orderByDesc('number')->first();
|
||||
|
||||
if ($latest === null || $latest->lines->count() !== 1 || (int) $latest->lines->first()->license_article_id !== $article->id) {
|
||||
throw new DomainRuleException('Diese Option gehört nicht zu diesem Lizenzartikel.');
|
||||
}
|
||||
|
||||
if ($latest->grant_kind !== 'kauf') {
|
||||
throw new DomainRuleException('Nur eine Option, die als Kauf angeboten wird, lässt sich so ändern. Vergaben auf Abruf oder bei Registrierung bearbeitest du am Angebot.');
|
||||
}
|
||||
|
||||
$this->setOptionLabel($offer, $label);
|
||||
|
||||
return $this->activate($offer, [['target' => $article, 'rights' => $rights]], [
|
||||
'term_rule' => $latest->term_rule,
|
||||
'tax_class' => $latest->tax_class,
|
||||
'dynamic' => (bool) $latest->dynamic,
|
||||
...$attributes,
|
||||
'grant_kind' => 'kauf',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorschlag für die Bezeichnung einer Option, wenn keine eingegeben wird: Nutzerkreis und Eignung.
|
||||
*/
|
||||
public static function defaultOptionLabel(?string $holderKind, ?string $licenceScope, mixed $trainers): string
|
||||
{
|
||||
$scope = match ($licenceScope) {
|
||||
LicenceScope::MULTI => 'Mehrfachlizenz ('.(int) $trainers.' Trainer)',
|
||||
LicenceScope::SINGLE => 'Einzellizenz',
|
||||
default => 'Lizenz',
|
||||
};
|
||||
|
||||
return $scope.' für '.($holderKind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen');
|
||||
}
|
||||
|
||||
/**
|
||||
* Zieht die Option aus dem Verkauf zurück: Die aktive Fassung wird beendet und bleibt gespeichert. Bereits
|
||||
* begründete Berechtigungen und Bestellungen ändern sich nicht; offene Warenkörbe zeigen die Position als
|
||||
@@ -183,21 +243,11 @@ public function end(Offer $offer): OfferVersion
|
||||
}
|
||||
|
||||
/**
|
||||
* Produktzuordnung der Option: Die Komposition bestimmt die öffentliche Produktseite und die Alternativgruppe,
|
||||
* die Bezeichnung benennt die Option auf dieser Seite. Beides sind keine bindenden Konditionen.
|
||||
* Die Bezeichnung der Option auf der Produktseite. Die Seite selbst wird nicht zugeordnet: Sie ist die Seite des
|
||||
* Artikels bzw. des Pakets, das die einzige Position der Fassung verkauft. Die Bezeichnung ist keine bindende Kondition.
|
||||
*/
|
||||
public function assignProduct(Offer $offer, ?int $compositionId, ?string $optionLabel, bool $ownBundlePage = false): Offer
|
||||
public function setOptionLabel(Offer $offer, ?string $optionLabel): Offer
|
||||
{
|
||||
if ($compositionId !== null) {
|
||||
Composition::query()->findOrFail($compositionId);
|
||||
}
|
||||
|
||||
if ($ownBundlePage && $compositionId !== null) {
|
||||
throw new DomainRuleException('Ein Paket hat entweder eine eigene Paketseite oder die Seite eines Programms, nicht beides.');
|
||||
}
|
||||
|
||||
$offer->composition_id = $compositionId;
|
||||
$offer->standalone_bundle = $ownBundlePage;
|
||||
$offer->option_label = filled($optionLabel) ? trim((string) $optionLabel) : null;
|
||||
$offer->save();
|
||||
|
||||
@@ -212,6 +262,29 @@ public function scopeArticleIds(OfferVersion $version): array
|
||||
return $version->resolvedScopes()->orderBy('id')->pluck('license_article_id')->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Kauf muss im Shop auffindbar und kaufbar sein, sonst lässt er sich nicht aktivieren: Er verkauft genau einen
|
||||
* Artikel oder ein Paket (das ist die Produktseite) und hat einen Preis. Mehrere Artikel gemeinsam verkauft ein
|
||||
* Paket. Vergaben bei Registrierung oder auf Abruf stehen nie im Shop und sind davon ausgenommen.
|
||||
*
|
||||
* @param list<array{target: LicenseArticle|BundleVersion, rights: RightsProfileVersion}> $lines
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
private function assertBuyable(array $lines, array $attributes): void
|
||||
{
|
||||
if (($attributes['grant_kind'] ?? null) !== 'kauf') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (count($lines) !== 1) {
|
||||
throw new DomainRuleException('Ein Kauf verkauft genau einen Artikel oder ein Paket. Mehrere Artikel gemeinsam verkaufst du als Paket (Katalog → Pakete).');
|
||||
}
|
||||
|
||||
if (! is_int($attributes['price_cents'] ?? null) || $attributes['price_cents'] <= 0) {
|
||||
throw new DomainRuleException('Ein Kauf braucht einen Preis über 0,00 €.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $attributes
|
||||
*/
|
||||
|
||||
@@ -45,10 +45,18 @@ public function blocks(): bool
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
if ($this->offer->standalone_bundle && $this->version !== null) {
|
||||
$bundle = app(ProductOptions::class)->bundleOf($this->version);
|
||||
$products = app(ProductOptions::class);
|
||||
|
||||
if ($bundle !== null) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\LicenceScope;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
|
||||
/**
|
||||
@@ -22,42 +24,99 @@ class ProductOptions
|
||||
public function __construct(private readonly OfferService $offers) {}
|
||||
|
||||
/**
|
||||
* Optionen der Produktseite eines Lizenzartikels: Angebote, deren einzige Position dieser Artikel ist.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function forComposition(Composition $composition): array
|
||||
public function forArticle(LicenseArticle $article): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (Offer::query()->where('composition_id', $composition->id)->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
|
||||
if ($version !== null) {
|
||||
$options[] = $this->describe($offer, $version);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
return $this->optionsFor('a:'.$article->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kaufbare Optionen der eigenen Produktseite eines Pakets: Angebote mit eigener Paketseite, deren aktive Fassung
|
||||
* dieses Paket verkauft.
|
||||
* Alle Optionen, die diesen Artikel als einzige Position verkaufen oder verkauften, auch beendete und solche ohne
|
||||
* Preis (Verwaltung). Die öffentliche Seite zeigt davon nur die kaufbaren (`forArticle`).
|
||||
*
|
||||
* @return list<Offer>
|
||||
*/
|
||||
public function offersOfArticle(LicenseArticle $article): array
|
||||
{
|
||||
return Offer::query()
|
||||
->whereHas('versions.lines', fn ($query) => $query->where('license_article_id', $article->id))
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->filter(fn (Offer $offer): bool => $this->groupKey($offer) === 'a:'.$article->id)
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Kaufbare Optionen der Produktseite eines Pakets: Angebote, deren einzige Position eine Fassung dieses Pakets ist.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function forBundle(Bundle $bundle): array
|
||||
{
|
||||
$options = [];
|
||||
return $this->optionsFor('b:'.$bundle->id);
|
||||
}
|
||||
|
||||
foreach (Offer::query()->where('standalone_bundle', true)->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
/**
|
||||
* Altbestand: Angebote mit mehreren Positionen, die einer Programmseite zugeordnet wurden. Neue Angebote
|
||||
* haben immer genau eine Position und damit eine Artikel- oder Paketseite.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function forComposition(Composition $composition): array
|
||||
{
|
||||
return $this->optionsFor('c:'.$composition->id);
|
||||
}
|
||||
|
||||
if ($version !== null && $this->bundleOf($version)?->id === $bundle->id) {
|
||||
$options[] = $this->describe($offer, $version);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Der Artikel, den die Fassung als einzige Position verkauft, sonst null.
|
||||
*/
|
||||
public function articleOf(OfferVersion $version): ?LicenseArticle
|
||||
{
|
||||
$version->loadMissing('lines.article');
|
||||
|
||||
return $options;
|
||||
return $version->lines->count() === 1 ? $version->lines->first()->article : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aufbau des Inhalts, den der aktuelle Stand des Artikels liefert (Rolle und Titel der Bestandteile). Ein Artikel
|
||||
* mit einem einzelnen Medium als Wurzel hat keine Struktur. Dateien und Lehrtexte kommen hier nie vor.
|
||||
*
|
||||
* @return list<StructureNode>
|
||||
*/
|
||||
public function articleStructure(LicenseArticle $article): array
|
||||
{
|
||||
$version = $article->currentRelease?->rootCompositionVersion;
|
||||
|
||||
return $version === null ? [] : app(CompositionStructureReader::class)->tree($version);
|
||||
}
|
||||
|
||||
/** Lernziel des Inhalts im aktuellen Stand des Artikels, wie es schon die öffentliche Programmseite zeigt. */
|
||||
public function articleGoal(LicenseArticle $article): ?string
|
||||
{
|
||||
$goal = $article->currentRelease?->rootCompositionVersion?->learning_goal;
|
||||
|
||||
return filled($goal) ? (string) $goal : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Artikel mit kaufbarer Option, deren Inhalt diese Komposition ist: Die Programmseite verweist auf sie.
|
||||
*
|
||||
* @return list<LicenseArticle>
|
||||
*/
|
||||
public function articlesOf(Composition $composition): array
|
||||
{
|
||||
return LicenseArticle::query()
|
||||
->whereNull('archived_at')
|
||||
->whereHas('currentRelease.rootCompositionVersion', fn ($query) => $query->where('composition_id', $composition->id))
|
||||
->orderBy('code')
|
||||
->get()
|
||||
->filter(fn (LicenseArticle $article): bool => $this->forArticle($article) !== [])
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,60 +129,135 @@ public function bundleOf(OfferVersion $version): ?Bundle
|
||||
return $version->lines->first(fn ($line): bool => $line->bundleVersion !== null)?->bundleVersion?->bundle;
|
||||
}
|
||||
|
||||
/** Gruppenschlüssel der Alternativen: Produktseite eines Programms oder eigene Paketseite. */
|
||||
/**
|
||||
* Schlüssel der Produktseite, auf der die Option angeboten wird: Artikelseite (`a:`), Paketseite (`b:`) oder, nur
|
||||
* im Altbestand mit mehreren Positionen, die Programmseite (`c:`). Die Seite ergibt sich aus der Angebotsfassung
|
||||
* und wird nirgends von Hand zugeordnet.
|
||||
*/
|
||||
public function groupKey(Offer $offer): ?string
|
||||
{
|
||||
if ($offer->composition_id !== null) {
|
||||
return 'c:'.$offer->composition_id;
|
||||
$version = $this->offers->purchasableVersion($offer) ?? $offer->versions()->orderByDesc('number')->first();
|
||||
|
||||
return $this->keyFor($offer, $version);
|
||||
}
|
||||
|
||||
private function keyFor(Offer $offer, ?OfferVersion $version): ?string
|
||||
{
|
||||
if ($version !== null && $version->lines()->count() === 1) {
|
||||
$article = $this->articleOf($version);
|
||||
|
||||
if ($article !== null) {
|
||||
return 'a:'.$article->id;
|
||||
}
|
||||
|
||||
$bundle = $this->bundleOf($version);
|
||||
|
||||
if ($bundle !== null) {
|
||||
return 'b:'.$bundle->id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($offer->standalone_bundle) {
|
||||
$version = $this->offers->purchasableVersion($offer) ?? $offer->versions()->orderByDesc('number')->first();
|
||||
$bundle = $version === null ? null : $this->bundleOf($version);
|
||||
|
||||
return $bundle === null ? null : 'b:'.$bundle->id;
|
||||
}
|
||||
|
||||
return null;
|
||||
return $offer->composition_id !== null ? 'c:'.$offer->composition_id : null;
|
||||
}
|
||||
|
||||
/** Adresse der Produktseite, auf der die Option angeboten wird, sonst null. */
|
||||
public function pageUrl(Offer $offer): ?string
|
||||
{
|
||||
if ($offer->composition_id !== null) {
|
||||
return route('public.program', $offer->composition_id);
|
||||
}
|
||||
|
||||
$key = $this->groupKey($offer);
|
||||
|
||||
return $key !== null && str_starts_with($key, 'b:') ? route('public.package', (int) substr($key, 2)) : null;
|
||||
if ($key === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$id = (int) substr($key, 2);
|
||||
|
||||
return match ($key[0]) {
|
||||
'a' => route('shop.article', $id),
|
||||
'b' => route('public.package', $id),
|
||||
default => route('public.program', $id),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Pakete mit eigener Produktseite und kaufbarer Option: Paketkennung => günstigster Preis und Zahl der Optionen.
|
||||
* Kaufbare Optionen je Produktseite: Seitenschlüssel => Angebot und Fassung in der Reihenfolge der Angebote.
|
||||
*
|
||||
* @return array<string, list<array{offer: Offer, version: OfferVersion}>>
|
||||
*/
|
||||
private function purchasable(): array
|
||||
{
|
||||
$pages = [];
|
||||
|
||||
foreach (Offer::query()->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
$key = $version === null ? null : $this->keyFor($offer, $version);
|
||||
|
||||
if ($key !== null) {
|
||||
$pages[$key][] = ['offer' => $offer, 'version' => $version];
|
||||
}
|
||||
}
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function optionsFor(string $key): array
|
||||
{
|
||||
return array_map(fn (array $row): array => $this->describe($row['offer'], $row['version']), $this->purchasable()[$key] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Günstigster Preis und Zahl der Optionen je Seite einer Art ('a', 'b' oder 'c'): Kennung => Zusammenfassung.
|
||||
*
|
||||
* @return array<int, array{from_cents: int, count: int}>
|
||||
*/
|
||||
private function summariesOf(string $kind): array
|
||||
{
|
||||
$summary = [];
|
||||
|
||||
foreach ($this->purchasable() as $key => $rows) {
|
||||
if ($key[0] !== $kind) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary[(int) substr($key, 2)] = [
|
||||
'from_cents' => min(array_map(fn (array $row): int => (int) $row['version']->price_cents, $rows)),
|
||||
'count' => count($rows),
|
||||
];
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Artikel mit kaufbarer Option: Artikelkennung => günstigster Preis und Zahl der Optionen.
|
||||
*
|
||||
* @return array<int, array{from_cents: int, count: int}>
|
||||
*/
|
||||
public function articleSummaries(): array
|
||||
{
|
||||
return $this->summariesOf('a');
|
||||
}
|
||||
|
||||
/**
|
||||
* Pakete mit kaufbarer Option: Paketkennung => günstigster Preis und Zahl der Optionen.
|
||||
*
|
||||
* @return array<int, array{from_cents: int, count: int}>
|
||||
*/
|
||||
public function bundleSummaries(): array
|
||||
{
|
||||
$summary = [];
|
||||
return $this->summariesOf('b');
|
||||
}
|
||||
|
||||
foreach (Offer::query()->where('standalone_bundle', true)->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
$bundle = $version === null ? null : $this->bundleOf($version);
|
||||
|
||||
if ($bundle === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = $summary[$bundle->id] ?? ['from_cents' => PHP_INT_MAX, 'count' => 0];
|
||||
$summary[$bundle->id] = [
|
||||
'from_cents' => min($current['from_cents'], (int) $version->price_cents),
|
||||
'count' => $current['count'] + 1,
|
||||
];
|
||||
}
|
||||
|
||||
return $summary;
|
||||
/**
|
||||
* Altbestand: Programmseiten mit kaufbaren Optionen (Angebote mit mehreren Positionen).
|
||||
*
|
||||
* @return array<int, array{from_cents: int, count: int}>
|
||||
*/
|
||||
public function summaries(): array
|
||||
{
|
||||
return $this->summariesOf('c');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,32 +292,6 @@ public function bundleContents(array $options): array
|
||||
return array_values($contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeilen für Shop-Suche und Kacheln: je Komposition die günstigste Option.
|
||||
*
|
||||
* @return array<int, array{from_cents: int, count: int}>
|
||||
*/
|
||||
public function summaries(): array
|
||||
{
|
||||
$summary = [];
|
||||
|
||||
foreach (Offer::query()->whereNotNull('composition_id')->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = $summary[$offer->composition_id] ?? ['from_cents' => PHP_INT_MAX, 'count' => 0];
|
||||
$summary[$offer->composition_id] = [
|
||||
'from_cents' => min($current['from_cents'], (int) $version->price_cents),
|
||||
'count' => $current['count'] + 1,
|
||||
];
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
|
||||
@@ -13,20 +13,32 @@
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\LicenceScope;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use App\Filament\Support\AssignsPillars;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ManagesEditorialSurface;
|
||||
use App\Filament\Support\ManagesRichFields;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -409,6 +421,204 @@ public function withdrawAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Optionen dieses Artikels im Shop: Bezeichnung, Preis, Rechte, Nutzerkreis und Zustand je Option. Gelesen wird
|
||||
* die aktive, sonst die letzte Fassung.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function optionRows(): array
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$options = app(ProductOptions::class);
|
||||
$offers = app(OfferService::class);
|
||||
$rows = [];
|
||||
|
||||
foreach ($options->offersOfArticle($article) as $offer) {
|
||||
$version = $offers->purchasableVersion($offer)
|
||||
?? $offer->versions()->where('status', OfferStatus::Aktiv)->orderByDesc('number')->first()
|
||||
?? $offer->versions()->orderByDesc('number')->first();
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$version->loadMissing('lines.rights.profile');
|
||||
$active = StatusValue::of($version->status) === OfferStatus::Aktiv->value;
|
||||
$buyable = $active && $offers->purchasableVersion($offer) !== null;
|
||||
$rows[] = [
|
||||
'offer' => $offer->id,
|
||||
'name' => $offer->optionName(),
|
||||
'price' => $version->price_cents === null ? 'kein Preis' : Money::format((int) $version->price_cents),
|
||||
'licence' => LicenceScope::label($version->licence_scope, $version->trainer_count),
|
||||
'for' => $version->holder_kind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen',
|
||||
'rights' => (string) ($version->lines->first()?->rights?->profile?->name ?? '–'),
|
||||
'number' => $version->number,
|
||||
'active' => $active,
|
||||
'kauf' => $version->grant_kind === 'kauf',
|
||||
'buyable' => $buyable,
|
||||
'zustand' => match (true) {
|
||||
$buyable => ['label' => 'Im Shop', 'ton' => 'gut'],
|
||||
$active => ['label' => CatalogLabels::vergabe($version).' · nicht im Shop', 'ton' => 'neutral'],
|
||||
default => ['label' => 'Nicht im Verkauf', 'ton' => 'leise'],
|
||||
},
|
||||
'page' => $buyable ? parse_url((string) $options->pageUrl($offer), PHP_URL_PATH) : null,
|
||||
'url' => OfferResource::getUrl('view', ['record' => $offer]),
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/** Ein Artikel lässt sich anbieten, wenn sein aktueller Stand veröffentlicht ist. */
|
||||
public function canOffer(): bool
|
||||
{
|
||||
return app(PublicationReadiness::class)->articleUsable($this->getRecord());
|
||||
}
|
||||
|
||||
/**
|
||||
* Option hinzufügen oder ändern: Rechteprofil, Preis, Nutzerkreis und Eignung. Der Artikel steht fest, es gibt keine
|
||||
* Auswahl von Artikel oder Inhalt. Mit dem Argument `offer` ändert die Aktion eine bestehende Option (nächste Fassung).
|
||||
*/
|
||||
public function optionAction(): Action
|
||||
{
|
||||
return Action::make('option')
|
||||
->modalWidth('2xl')
|
||||
->modalHeading(fn (array $arguments): string => isset($arguments['offer'])
|
||||
? 'Option „'.$this->optionOf($arguments)->optionName().'“ ändern'
|
||||
: 'Option hinzufügen: so wird der Artikel verkauft')
|
||||
->modalDescription(fn (array $arguments): string => isset($arguments['offer'])
|
||||
? 'Die Maske ist mit der letzten Fassung vorbelegt. Erst „Speichern und anbieten“ schaltet die Änderung öffentlich: Die bisherige Fassung wird beendet und bleibt gespeichert, neue Käufe nutzen die neue. Bereits begründete Berechtigungen und Bestellungen ändern sich nicht. „Abbrechen“ verwirft die Eingaben.'
|
||||
: 'Eine Option ist eine Lizenz mit Rechteprofil und Preis. Der Artikel kann mehrere Optionen haben, zum Beispiel für Privatpersonen und für Vereine. Sie erscheinen gemeinsam auf der Produktseite des Artikels. „Abbrechen“ verwirft die Eingaben.')
|
||||
->modalSubmitActionLabel('Speichern und anbieten')
|
||||
->fillForm(fn (array $arguments): array => $this->optionForm($arguments))
|
||||
->schema([
|
||||
Select::make('rights_id')->label('Rechteprofil')
|
||||
->options(fn (): array => CatalogOptions::rights())
|
||||
->required()
|
||||
->helperText('Was Käufer mit dem Artikel tun dürfen (ansehen, herunterladen, Nutzungszweck).'),
|
||||
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')->required()
|
||||
->helperText('Zum Beispiel 49,00. Ein Kauf braucht einen Preis über 0,00 €.'),
|
||||
Select::make('holder_kind')->label('Geeignet für')->options([
|
||||
'person' => 'Privatpersonen',
|
||||
'organisation' => 'Organisationen und Vereine',
|
||||
])->required()->live()
|
||||
->helperText('Wähle die Eignung passend zum Rechteprofil: Organisationslizenzen brauchen institutionelle Rechte.'),
|
||||
Select::make('licence_scope')->label('Nutzerkreis')
|
||||
->options(LicenceScope::options())
|
||||
->required()->live()
|
||||
->helperText('Wie viele Trainer die Inhalte einsetzen dürfen. Der Download bleibt beim bestellenden Konto.'),
|
||||
TextInput::make('trainer_count')->label('Anzahl Trainer')
|
||||
->numeric()->minValue(2)->maxValue(LicenceScope::MAX_TRAINERS)->integer()
|
||||
->required(fn (Get $get): bool => $get('licence_scope') === LicenceScope::MULTI)
|
||||
->visible(fn (Get $get): bool => $get('licence_scope') === LicenceScope::MULTI)
|
||||
->live(),
|
||||
TextInput::make('option_label')->label('Bezeichnung der Option')
|
||||
->maxLength(120)
|
||||
->placeholder(fn (Get $get): string => OfferService::defaultOptionLabel($get('holder_kind'), $get('licence_scope'), $get('trainer_count')))
|
||||
->helperText('So heißt die Option auf der Produktseite. Leer lassen übernimmt den grauen Vorschlag.'),
|
||||
])
|
||||
->action(function (array $data, array $arguments): void {
|
||||
$this->report(function () use ($data, $arguments): string {
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$rights = RightsProfileVersion::query()->findOrFail($data['rights_id']);
|
||||
$price = Money::parse($data['price_euro'] ?? null);
|
||||
$label = filled($data['option_label'] ?? null)
|
||||
? trim((string) $data['option_label'])
|
||||
: OfferService::defaultOptionLabel($data['holder_kind'], $data['licence_scope'], $data['trainer_count'] ?? null);
|
||||
$attributes = [
|
||||
'holder_kind' => $data['holder_kind'],
|
||||
'licence_scope' => $data['licence_scope'],
|
||||
'trainer_count' => $data['trainer_count'] ?? null,
|
||||
'price_cents' => $price,
|
||||
];
|
||||
$service = app(OfferService::class);
|
||||
|
||||
if (isset($arguments['offer'])) {
|
||||
$offer = $this->optionOf($arguments);
|
||||
$version = $service->reviseArticleOption($offer, $article, $rights, $attributes, $label);
|
||||
} else {
|
||||
$name = app(ProductOptions::class)->articleTitle($article).': '.$label;
|
||||
$version = $service->offerArticle($article, $rights, $attributes, $name, $label);
|
||||
$offer = $version->offer;
|
||||
}
|
||||
|
||||
$page = app(ProductOptions::class)->pageUrl($offer);
|
||||
|
||||
return 'Die Option „'.$offer->optionName().'“ ist als Fassung '.$version->number.' aktiv und im Shop kaufbar'
|
||||
.($page !== null ? ' unter '.parse_url($page, PHP_URL_PATH) : '').'.';
|
||||
}, 'Die Option ist aktiv.');
|
||||
$this->refreshRecord();
|
||||
});
|
||||
}
|
||||
|
||||
/** Eine Option aus dem Verkauf nehmen: nur die aktive Fassung dieser Option wird beendet. */
|
||||
public function optionEndAction(): Action
|
||||
{
|
||||
return Action::make('optionEnd')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalHeading(fn (array $arguments): string => 'Option „'.$this->optionOf($arguments)->optionName().'“ aus dem Verkauf nehmen?')
|
||||
->modalDescription('Die aktive Fassung wird beendet und bleibt gespeichert. Die Option ist danach nicht mehr kaufbar; in vorhandenen Warenkörben bleibt sie mit Hinweis sichtbar und blockiert den Abschluss, bis der Käufer sie entfernt. Bestehende Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen des Artikels bleiben kaufbar.')
|
||||
->modalSubmitActionLabel('Aus dem Verkauf nehmen')
|
||||
->action(function (array $arguments): void {
|
||||
$this->report(function () use ($arguments): string {
|
||||
$offer = $this->optionOf($arguments);
|
||||
$version = app(OfferService::class)->end($offer);
|
||||
|
||||
return 'Die Option „'.$offer->optionName().'“ ist aus dem Verkauf genommen (Fassung '.$version->number.' beendet).';
|
||||
}, 'Die Option ist aus dem Verkauf genommen.');
|
||||
$this->refreshRecord();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Option aus den Argumenten der Aktion, nur wenn sie zu diesem Artikel gehört.
|
||||
*
|
||||
* @param array<string, mixed> $arguments
|
||||
*/
|
||||
private function optionOf(array $arguments): Offer
|
||||
{
|
||||
/** @var LicenseArticle $article */
|
||||
$article = $this->getRecord();
|
||||
$offer = collect(app(ProductOptions::class)->offersOfArticle($article))->first(fn (Offer $offer): bool => $offer->id === (int) ($arguments['offer'] ?? 0)
|
||||
&& $offer->versions()->orderByDesc('number')->value('grant_kind') === 'kauf');
|
||||
|
||||
// Vergaben auf Abruf oder bei Registrierung sind keine Shop-Optionen und werden am Angebot bearbeitet.
|
||||
return $offer ?? abort(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $arguments
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function optionForm(array $arguments): array
|
||||
{
|
||||
if (! isset($arguments['offer'])) {
|
||||
$rights = array_keys(CatalogOptions::rights());
|
||||
|
||||
return [
|
||||
'holder_kind' => 'person',
|
||||
'licence_scope' => LicenceScope::SINGLE,
|
||||
'rights_id' => count($rights) === 1 ? $rights[0] : null,
|
||||
];
|
||||
}
|
||||
|
||||
$offer = $this->optionOf($arguments);
|
||||
$version = $offer->versions()->with('lines')->orderByDesc('number')->firstOrFail();
|
||||
|
||||
return [
|
||||
'rights_id' => $version->lines->first()?->rights_profile_version_id,
|
||||
'price_euro' => $version->price_cents === null ? null : number_format($version->price_cents / 100, 2, ',', ''),
|
||||
'holder_kind' => $version->holder_kind,
|
||||
'licence_scope' => $version->licence_scope,
|
||||
'trainer_count' => $version->trainer_count,
|
||||
'option_label' => $offer->option_label,
|
||||
];
|
||||
}
|
||||
|
||||
private function isFirstStand(): bool
|
||||
{
|
||||
return ! $this->getRecord()->releases()->exists();
|
||||
|
||||
@@ -24,7 +24,7 @@ class ListOffers extends ListRecords
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Ein Angebot verbindet Artikel oder eine Paketfassung mit einem Rechteprofil. Die aufgelösten Berechtigungen stehen auf der Angebotsseite.';
|
||||
return 'Ein Angebot ist eine Option zum Kauf: ein Artikel oder eine Paketfassung mit Rechteprofil und Preis. Optionen eines einzelnen Artikels legst du am Lizenzartikel an („Im Shop verkaufen“); hier stehen alle Angebote, auch die der Pakete.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace App\Filament\Resources\Offers\Pages;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenceScope;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
@@ -15,7 +15,6 @@
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Pages\Zahlungsjournal;
|
||||
@@ -48,9 +47,6 @@ class ViewOffer extends ViewRecord
|
||||
|
||||
protected static string $resource = OfferResource::class;
|
||||
|
||||
/** Wert der Auswahl „Produktseite“ für ein Paket mit eigener Seite. */
|
||||
private const OWN_BUNDLE_PAGE = '__paket';
|
||||
|
||||
public function getTitle(): string|Htmlable
|
||||
{
|
||||
return (string) $this->getRecord()->name;
|
||||
@@ -117,10 +113,6 @@ public function activateAction(): Action
|
||||
TextInput::make('option_label')->label('Bezeichnung der Option')
|
||||
->helperText('So heißt die Option auf der Produktseite, zum Beispiel „Einzellizenz für Privatpersonen“. Sie ist keine bindende Bedingung, wird aber wie die übrigen Angaben erst mit „Fassung aktivieren“ übernommen.')
|
||||
->maxLength(120),
|
||||
Select::make('composition_id')->label('Produktseite')
|
||||
->options(fn (): array => $this->productPages())
|
||||
->searchable()
|
||||
->helperText('Optionen derselben Produktseite sind Alternativen; im Warenkorb liegt nur eine davon. Die Beschreibung der Seite wird zentral an der Komposition gepflegt. Die Zuordnung wird mit „Fassung aktivieren“ übernommen.'),
|
||||
Select::make('holder_kind')->label('Geeignet für')->options([
|
||||
'person' => 'Privatpersonen',
|
||||
'organisation' => 'Organisationen und Vereine',
|
||||
@@ -143,18 +135,6 @@ public function activateAction(): Action
|
||||
])->required(),
|
||||
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')
|
||||
->helperText('Nur bei einem Kauf, zum Beispiel 49,00.'),
|
||||
Select::make('composition_version_id')->label('Programmfassung, die abgedeckt sein muss')
|
||||
->options(function (): array {
|
||||
return CompositionVersion::query()
|
||||
->where('status', 'bereit')
|
||||
->with('composition.editorialContentKind')
|
||||
->orderByDesc('id')
|
||||
->get()
|
||||
->mapWithKeys(fn (CompositionVersion $version): array => [$version->id => CatalogOptions::compositionLabel($version)])
|
||||
->all();
|
||||
})
|
||||
->searchable()
|
||||
->helperText('Wenn gewählt, lässt sich die Fassung nur aktivieren, wenn jeder Bestandteil in den Artikeln enthalten ist.'),
|
||||
Repeater::make('lines')->label('Positionen')->schema([
|
||||
Select::make('kind')->label('Ziel')->options([
|
||||
'article' => 'Lizenzartikel',
|
||||
@@ -215,12 +195,7 @@ public function activateAction(): Action
|
||||
|
||||
$service = app(OfferService::class);
|
||||
$version = DB::transaction(function () use ($service, $offer, $data, $lines, $kept, $price) {
|
||||
$service->assignProduct(
|
||||
$offer,
|
||||
filled($data['composition_id'] ?? null) && $data['composition_id'] !== self::OWN_BUNDLE_PAGE ? (int) $data['composition_id'] : null,
|
||||
$data['option_label'] ?? null,
|
||||
($data['composition_id'] ?? null) === self::OWN_BUNDLE_PAGE,
|
||||
);
|
||||
$service->setOptionLabel($offer, $data['option_label'] ?? null);
|
||||
|
||||
return $service->activate($offer, $lines, [
|
||||
...$kept,
|
||||
@@ -229,7 +204,6 @@ public function activateAction(): Action
|
||||
'trainer_count' => $data['trainer_count'] ?? null,
|
||||
'grant_kind' => $data['grant_kind'],
|
||||
'price_cents' => $price,
|
||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -269,47 +243,23 @@ public function endAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
/** „ der Produktseite „Titel““ oder leer, wenn die Option noch keiner Produktseite zugeordnet ist. */
|
||||
/** „ der Produktseite „Titel““ oder leer, wenn die Option (noch) keine Produktseite hat. */
|
||||
private function productPageSuffix(): string
|
||||
{
|
||||
$page = $this->getRecord()->composition;
|
||||
$key = app(ProductOptions::class)->groupKey($this->getRecord());
|
||||
|
||||
return $page === null ? '' : ' der Produktseite „'.($page->display_title ?: $page->designation).'“';
|
||||
}
|
||||
|
||||
/**
|
||||
* Produktseiten, die als Ziel wählbar sind: Kompositionen mit Bezeichnung und Art.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function productPages(): array
|
||||
{
|
||||
$catalog = app(PublicCatalogReader::class);
|
||||
|
||||
return [self::OWN_BUNDLE_PAGE => 'Eigene Paketseite · nur für ein Angebot aus genau einer Paketfassung (Katalog → Pakete), nicht für einen Lizenzartikel'] + Composition::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->orderBy('designation')
|
||||
->get()
|
||||
->sortBy(fn (Composition $composition): int => $catalog->shownVersion($composition) !== null ? 0 : (in_array($composition->editorialContentKind?->slug, PublicCatalogReader::PUBLIC_KINDS, true) ? 1 : 2))
|
||||
->mapWithKeys(fn (Composition $composition): array => [
|
||||
$composition->id => ($composition->display_title ?: $composition->designation)
|
||||
.' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')'
|
||||
.self::pageHint($catalog, $composition),
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
/** Sagt bei jeder Auswahl, ob die Seite im Shop auffindbar ist und was fehlt, wenn nicht. */
|
||||
private static function pageHint(PublicCatalogReader $catalog, Composition $composition): string
|
||||
{
|
||||
if ($catalog->shownVersion($composition) !== null) {
|
||||
return ' · im Shop auffindbar';
|
||||
if ($key === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return in_array($composition->editorialContentKind?->slug, PublicCatalogReader::PUBLIC_KINDS, true)
|
||||
? ' · noch nicht zur Anzeige freigegeben, im Shop nicht auffindbar'
|
||||
: ' · kein Programm, im Shop nicht auffindbar (der Shop zeigt nur Programme)';
|
||||
$id = (int) substr($key, 2);
|
||||
$title = match ($key[0]) {
|
||||
'a' => app(ProductOptions::class)->articleTitle(LicenseArticle::query()->find($id)),
|
||||
'b' => (string) Bundle::query()->whereKey($id)->value('name'),
|
||||
default => ($page = Composition::query()->find($id)) === null ? '' : (string) ($page->display_title ?: $page->designation),
|
||||
};
|
||||
|
||||
return $title === '' ? '' : ' der Produktseite „'.$title.'“';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +272,7 @@ private function formFromActive(): array
|
||||
$active = $this->activeVersion();
|
||||
/** @var Offer $offer */
|
||||
$offer = $this->getRecord();
|
||||
$option = ['option_label' => $offer->option_label, 'composition_id' => $offer->standalone_bundle ? self::OWN_BUNDLE_PAGE : $offer->composition_id];
|
||||
$option = ['option_label' => $offer->option_label];
|
||||
|
||||
if ($active === null) {
|
||||
return [...$option, 'holder_kind' => 'person', 'licence_scope' => LicenceScope::SINGLE, 'grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
|
||||
@@ -437,8 +387,8 @@ private function optionAbschnitt(Offer $offer, OfferVersion $active): array
|
||||
->map(fn (array $item): string => $item['purpose'].($item['rights'] === [] ? '' : ': '.implode(', ', $item['rights'])))
|
||||
->unique()
|
||||
->implode('; ');
|
||||
$seite = $offer->composition;
|
||||
$eigeneSeite = $offer->standalone_bundle;
|
||||
$key = app(ProductOptions::class)->groupKey($offer);
|
||||
$seite = $key === null ? null : app(ProductOptions::class)->pageUrl($offer);
|
||||
$kaufbar = app(OfferService::class)->purchasableVersion($offer) !== null;
|
||||
|
||||
return [
|
||||
@@ -452,7 +402,7 @@ private function optionAbschnitt(Offer $offer, OfferVersion $active): array
|
||||
['text' => 'Rechte: '.($rechte !== '' ? $rechte : 'keine'), 'neben' => null],
|
||||
['text' => 'Zugrunde liegender Inhalt: '.($inhalt !== '' ? $inhalt : '–'), 'neben' => null],
|
||||
['text' => 'Status: '.($kaufbar ? 'Öffentlich kaufbar' : 'Nicht als Kauf angeboten'), 'neben' => $kaufbar ? 'Aktive Fassung '.$active->number : null],
|
||||
['text' => 'Produktseite: '.($eigeneSeite ? 'eigene Paketseite mit dem Umfang des Pakets' : ($seite !== null ? ($seite->display_title ?: $seite->designation) : 'noch nicht zugeordnet')), 'neben' => $eigeneSeite || $seite !== null ? 'Option „'.$offer->optionName().'“' : 'Mit „Geänderte Fassung aktivieren“ zuordnen.'],
|
||||
['text' => 'Produktseite: '.($kaufbar && $seite !== null ? 'öffentlich unter '.parse_url($seite, PHP_URL_PATH) : 'keine, solange die Option kein Kauf mit Preis ist'), 'neben' => $kaufbar ? 'Option „'.$offer->optionName().'“; Optionen desselben Artikels sind Alternativen im Warenkorb.' : null],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\ReleaseStatus;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
@@ -35,7 +34,6 @@ class PublicationReadiness
|
||||
public function __construct(
|
||||
private readonly BundleService $bundles,
|
||||
private readonly OfferService $offers,
|
||||
private readonly PublicCatalogReader $catalog,
|
||||
) {}
|
||||
|
||||
/** Ein Artikel ist verwendbar, wenn sein aktueller Stand veröffentlicht ist. */
|
||||
@@ -157,12 +155,14 @@ public function forArticle(LicenseArticle $article): array
|
||||
'aktion' => $this->articleName($article) !== '' ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'In einem Paket oder Angebot verwenden',
|
||||
'titel' => 'Im Shop verkaufen',
|
||||
'text' => $inUse
|
||||
? 'Der Artikel ist in einem Paket oder Angebot enthalten.'
|
||||
: 'Verkauft wird der Artikel erst über ein Angebot, allein oder in einem Paket.',
|
||||
: 'Verkauft wird der Artikel über eine Option mit Rechteprofil und Preis, allein oder in einem Paket.',
|
||||
'stand' => $inUse ? 'erledigt' : 'offen',
|
||||
'aktion' => $inUse ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
||||
'aktion' => $inUse ? null : ($usable
|
||||
? ['label' => 'Option hinzufügen', 'wire' => "mountAction('option')"]
|
||||
: ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')]),
|
||||
'pflicht' => false,
|
||||
],
|
||||
]);
|
||||
@@ -227,10 +227,7 @@ public function forOffer(Offer $offer): array
|
||||
$articleIds = $hasActive ? $active->resolvedScopes()->pluck('license_article_id')->map(fn ($id): int => (int) $id)->all() : [];
|
||||
$missing = $this->unusableArticles($articleIds);
|
||||
$buyable = $hasActive && $this->offers->purchasableVersion($offer) !== null;
|
||||
$page = $offer->composition;
|
||||
$own = (bool) $offer->standalone_bundle;
|
||||
$shown = $own || ($page !== null && $this->catalog->shownVersion($page) !== null);
|
||||
$pageName = $page !== null ? (string) ($page->display_title ?: $page->designation) : '';
|
||||
$pageUrl = app(ProductOptions::class)->pageUrl($offer);
|
||||
$activate = ['label' => $hasActive ? 'Geänderte Fassung aktivieren' : 'Angebot konfigurieren', 'wire' => "mountAction('activate')"];
|
||||
|
||||
return $this->result([
|
||||
@@ -272,26 +269,15 @@ public function forOffer(Offer $offer): array
|
||||
'pflicht' => false,
|
||||
],
|
||||
[
|
||||
'titel' => 'Produktseite zuordnen',
|
||||
'text' => $own
|
||||
? 'Eigene Paketseite: Sie zeigt den Umfang des Pakets. Optionen desselben Pakets sind Alternativen im Warenkorb.'
|
||||
: ($page !== null
|
||||
? 'Zugeordnet: „'.$pageName.'“. Optionen derselben Produktseite sind Alternativen im Warenkorb.'
|
||||
: 'Der Shop zeigt ein Angebot auf der Seite eines Programms. Wähle in der Maske die Produktseite. Ein Paket (Katalog → Pakete), das für sich verkauft wird, erhält dort „Eigene Paketseite“ und zeigt seinen Umfang; ein Lizenzartikel braucht dagegen ein Programm, das unter „Programme“ angelegt und zur Anzeige freigegeben ist. Ein Modul kann keine Produktseite sein.'),
|
||||
'stand' => $own || $page !== null ? 'erledigt' : 'offen',
|
||||
'aktion' => $own || $page !== null ? null : $activate,
|
||||
],
|
||||
[
|
||||
'titel' => 'Produktseite öffentlich',
|
||||
'text' => ! $own && $page === null
|
||||
? 'Wird geprüft, sobald eine Produktseite zugeordnet ist.'
|
||||
: ($own
|
||||
? 'Die eigene Paketseite ist öffentlich, sobald die aktive Fassung ein Kauf mit Preis ist.'
|
||||
: ($shown
|
||||
? 'Das Programm ist zur Anzeige freigegeben. Das Angebot erscheint in der Shop-Suche und auf der Produktseite.'
|
||||
: 'Das Programm „'.$pageName.'“ ist nicht zur Anzeige freigegeben oder kein Programm. Das Angebot ist dort nicht auffindbar.')),
|
||||
'stand' => $shown ? 'erledigt' : 'offen',
|
||||
'aktion' => $page === null || $shown ? null : ['label' => 'Programm öffnen', 'href' => EditorialCatalog::editUrl($page)],
|
||||
'titel' => 'Produktseite im Shop',
|
||||
'text' => match (true) {
|
||||
! $hasActive => 'Die Produktseite ergibt sich aus der Fassung: Sie ist die Seite des Artikels (oder des Pakets), den die Option verkauft. Du ordnest sie nicht zu.',
|
||||
$pageUrl !== null && $buyable => 'Die Option erscheint auf der Produktseite '.parse_url($pageUrl, PHP_URL_PATH).' und im Shop. Optionen desselben Artikels sind Alternativen im Warenkorb.',
|
||||
$pageUrl !== null => 'Sobald die Option ein Kauf mit Preis ist, erscheint sie auf '.parse_url($pageUrl, PHP_URL_PATH).'.',
|
||||
default => 'Diese Fassung hat mehrere Positionen und damit keine Produktseite. Verkauft wird genau ein Artikel oder ein Paket; mehrere Artikel gemeinsam verkaufst du als Paket.',
|
||||
},
|
||||
'stand' => $buyable && $pageUrl !== null ? 'erledigt' : 'offen',
|
||||
'aktion' => $hasActive && $pageUrl === null ? $activate : null,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,13 @@ public function show(Request $request, Cart $cart, OrderHolders $holders): View
|
||||
|
||||
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||
{
|
||||
$key = app(ProductOptions::class)->groupKey($offer);
|
||||
$page = $offer->composition;
|
||||
$listed = $offer->standalone_bundle || ($page !== null && $catalog->shownVersion($page) !== null);
|
||||
$listed = match (true) {
|
||||
$key === null => false,
|
||||
$key[0] === 'c' => $page !== null && $catalog->shownVersion($page) !== null,
|
||||
default => true,
|
||||
};
|
||||
$result = $listed ? $cart->add($offer) : Cart::UNAVAILABLE;
|
||||
$back = $this->productPage($offer);
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
@@ -37,6 +39,28 @@ public function package(Bundle $bundle, ProductOptions $products, Cart $cart): V
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Produktseite eines Lizenzartikels: Titel und Beschreibung aus der Redaktion des Artikels (sonst aus seinem Inhalt),
|
||||
* der Aufbau des verkauften Inhalts und darunter die kaufbaren Lizenzoptionen. Ohne kaufbare Option gibt es sie nicht.
|
||||
*/
|
||||
public function article(LicenseArticle $article, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
abort_unless(Shop::enabled() && $article->archived_at === null, 404);
|
||||
$options = $products->forArticle($article);
|
||||
abort_if($options === [], 404);
|
||||
|
||||
return view('public.article', [
|
||||
'article' => $article,
|
||||
'title' => $products->articleTitle($article),
|
||||
'profile' => app(EditorialProfileReader::class)->read($article, 'detail'),
|
||||
'goal' => $products->articleGoal($article),
|
||||
'nodes' => $products->articleStructure($article),
|
||||
'options' => $options,
|
||||
'cart' => $cart,
|
||||
'switchTo' => session('shop.switch'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function program(Composition $composition, PublicCatalogReader $catalog, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
$version = $catalog->shownVersion($composition);
|
||||
@@ -47,6 +71,7 @@ public function program(Composition $composition, PublicCatalogReader $catalog,
|
||||
'version' => $version,
|
||||
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
||||
'options' => Shop::enabled() ? $products->forComposition($composition) : [],
|
||||
'articles' => Shop::enabled() ? $products->articlesOf($composition) : [],
|
||||
'cart' => $cart,
|
||||
'switchTo' => session('shop.switch'),
|
||||
]);
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
@@ -47,6 +49,29 @@ public function index(Request $request, ProductOptions $products, PublicCatalogR
|
||||
];
|
||||
}
|
||||
|
||||
// Lizenzartikel mit kaufbarer Option: Titel und Kurztext aus der Redaktion des Artikels (sonst seines Inhalts).
|
||||
$articleSummaries = $products->articleSummaries();
|
||||
|
||||
foreach (LicenseArticle::query()->whereIn('id', array_keys($articleSummaries))->whereNull('archived_at')->orderBy('code')->get() as $article) {
|
||||
$profile = app(EditorialProfileReader::class)->read($article, 'kachel');
|
||||
$title = $products->articleTitle($article);
|
||||
$teaser = (string) ($profile->value('teaser') ?: $profile->value('summary'));
|
||||
$haystack = mb_strtolower($title.' '.$teaser.' '.$profile->value('summary').' '.$profile->searchTerms);
|
||||
|
||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $articleSummaries[$article->id];
|
||||
$cards[] = [
|
||||
'url' => route('shop.article', $article),
|
||||
'title' => $title,
|
||||
'teaser' => $teaser,
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
// Pakete mit eigener Produktseite: gelistet mit Name und enthaltenen Artikeln.
|
||||
foreach (Bundle::query()->whereIn('id', array_keys($products->bundleSummaries()))->orderBy('name')->get() as $bundle) {
|
||||
$options = $products->forBundle($bundle);
|
||||
|
||||
@@ -87,7 +87,7 @@ public function run(): void
|
||||
$starter = $bundles->publish($bundle, [$konflikteArticle->fresh(), $grenzenArticle->fresh(), $starterArticle->fresh()]);
|
||||
$paket = $offers->create('Starterpaket: Privatlizenz');
|
||||
$offers->activate($paket, [['target' => $starter, 'rights' => $privat]], ['grant_kind' => 'kauf', 'price_cents' => 5900, 'holder_kind' => 'person', 'licence_scope' => LicenceScope::SINGLE, 'trainer_count' => 1]);
|
||||
$offers->assignProduct($paket, $starterVersion->composition_id, 'Starterpaket (zwei Programme und Einführung)');
|
||||
$offers->setOptionLabel($paket, 'Starterpaket (zwei Programme und Einführung)');
|
||||
|
||||
$tina = $this->account('Tina Trainerin', 'tina.trainerin@example.test');
|
||||
$vera = $this->account('Vera Vorstand', 'vera.vorstand@example.test');
|
||||
@@ -171,7 +171,7 @@ private function offer(OfferService $offers, string $name, string $label, Compos
|
||||
'licence_scope' => $scope,
|
||||
'trainer_count' => $trainers,
|
||||
]);
|
||||
$offers->assignProduct($offer, $version->composition_id, $label);
|
||||
$offers->setOptionLabel($offer, $label);
|
||||
|
||||
return $offer;
|
||||
}
|
||||
|
||||
@@ -762,3 +762,23 @@ ## ADR-51 – Dokumente: Kapitel als Texte, Dokumentfassung als Komposition, Tab
|
||||
**Nachtrag (24.11.2026): Logo in Kopf und Fuß.** Kopf und Fuß einer PDF-Vorlage können statt eines Bands in voller Seitenbreite ein Logo links oder rechts am Textrand tragen (`header_align`/`footer_align` = `full`, `left`, `right`; `header_logo_height`/`footer_logo_height` in Punkt, 16 bis 100, Vorgabe 40; höchstens halbe Textbreite). Dasselbe Bild kommt aus dem Medienmanager wie bisher. Die Titelseite bleibt unberührt. **Folgen:** eine additive Migration mit Vorgaben; der vorherige Programmstand kennt die Spalten nicht und zeigt jede Grafik als Band.
|
||||
|
||||
**Nachtrag (24.11.2026): Überschriftenebenen im Kapiteltext.** Ein Dokument gliedert sich vor allem durch Kapitel der ersten Ebene und Überschriften im Text. Der Editor bietet dafür `h3` bis `h6` an (Dokumenttitel `h1`, Kapitel `h2`; `h1` und `h2` aus eingefügtem Text werden `h3`). Alle Überschriften des Kapiteltexts stehen automatisch im Inhaltsverzeichnis von Seite und PDF, eingerückt nach Stufe und ohne Nummer, mit Sprungmarken `kapitel-<Nr>-u<n>` (gezählt werden die nicht leeren Überschriften auf oberster Ebene des Texts, nicht die in Tabellen) und, im PDF, mit Seitenzahl, Verweis und verschachtelten Lesezeichen (`PdfDocument::bookmark` kennt jetzt bis zu sechs Ebenen). Die Stufen sind im PDF nach Größe gestaffelt (h6 kursiv). Unter einem Unterkapitel rücken die Überschriften eine Stufe tiefer (höchstens `h6`), damit sie nie auf der Stufe des Unterkapitels stehen; ein Unterkapitel braucht man dafür nicht. **Bewusst offen:** Innerhalb eines Kapitels wird nicht geprüft, ob eine Überschrift im Text eine höhere oder gleiche Stufe wie die vorherige hat (Einzelbearbeitung). Ältere Fassungen behalten ihren Text; die gespeicherten `h3` erscheinen jetzt als `h3` statt `h4` und neu im Verzeichnis. **Folgen:** keine Migration; der Änderungsnachweis (Hash) bleibt unverändert, weil sich der gespeicherte Text nicht ändert.
|
||||
|
||||
## ADR-52 – Produktseite je Lizenzartikel: Die Seite ergibt sich aus der Angebotsfassung
|
||||
|
||||
**Status am 25.11.2026:** Umgesetzt auf `feature/shop-artikelseite`, auf `develop` und `luf-test` abzunehmen (Protokoll `docs/ux/verwaltung/abnahme/etappe-1.md`). Die Produktivfreigabe bleibt bei Lars.
|
||||
**Kontext.** Bis dahin war die Produktseite die öffentliche Seite eines **Programms**, dem ein Angebot von Hand zugeordnet wurde (`offers.composition_id`), oder die eigene Paketseite. Die Übergangsregel des `PublicCatalogReader` ließ nur Programme öffentlich zu (ADR-29, Profile je Fachobjekt noch offen). Ein Lizenzartikel aus einem Modul, einem Programm mit Modulen oder einem Medium ließ sich deshalb nicht verkaufen: Das Angebot wurde zwar aktiv, hatte aber keine Seite und stand nicht im Shop. Das widersprach der Absicht (Grundsätze: „Programme und Module“ werden verkauft; Fachkonzept: der Betreiber legt die Artikelgrenze fest, ein Artikel darf beliebig verschachtelt sein).
|
||||
**Entscheidung (Auftrag von Lars, 25.11.2026).**
|
||||
- **Im Shop ist alles ein Artikel.** Die Produktseite ist die Seite des Lizenzartikels, den die Option als **einzige Position** verkauft: `/shop/{Artikelkennung}`. Die Adresse nennt weder „programme“ noch „module“. Ein Paket (eine Paketfassung als einzige Position) behält seine Seite `/pakete/{id}`.
|
||||
- **Die Seite wird nicht zugeordnet, sondern abgeleitet.** `ProductOptions::groupKey` bestimmt sie aus der Fassung (`a:` Artikel, `b:` Paket, `c:` nur Altbestand). Alternativen im Warenkorb sind die Optionen **derselben Seite** (desselben Artikels). Keine Migration; die Spalten `composition_id` und `standalone_bundle` bleiben bestehen und werden nicht mehr beschrieben. Ein Rollback des Codes ändert daher keine Daten.
|
||||
- **Texte aus der Redaktion, sofern nicht überschrieben.** Titel, Kurzbeschreibung und Beschreibung löst der bestehende `EditorialProfileReader` auf (Abweichung für den Kontext, eigene Angabe des Artikels, sonst die fachliche Quelle des Artikelstands). Der Aufbau (Rolle und Titel der Bestandteile) und das Lernziel kommen aus dem Stand des Artikels. Dateien, Lehrtexte und Vorschaubilder der Bibliothek erscheinen nicht.
|
||||
- **Sichtbarkeit folgt dem Verkauf, nicht der Anzeigefreigabe.** Eine Artikelseite existiert, solange der Artikel eine kaufbare Option hat (aktive Fassung, Kauf, Preis) und der Shop läuft. Die Anzeigefreigabe („Mitgliederbibliothek“) hat darauf keinen Einfluss. Module und Programme werden dadurch **nicht** auf der Website öffentlich: `/programme/{id}`, die CMS-Karten und die Sichtbarkeitsregeln des `PublicCatalogReader` sind unverändert. Eine Programmseite verweist nur auf die Artikelseiten, deren Inhalt sie ist.
|
||||
- **Aktivieren nur, wenn kaufbar.** `OfferService::activate` verlangt für eine Vergabe „Kauf“ genau eine Position (ein Artikel oder eine Paketfassung) und einen Preis über 0,00 €; mehrere Artikel gemeinsam verkauft ein Paket. Vergaben „bei Registrierung“ und „auf Abruf“ stehen nie im Shop und bleiben ohne diese Einschränkung zulässig.
|
||||
- **Maske.** Die Auswahl „Produktseite“ entfällt; die Voraussetzungen zeigen die abgeleitete Seite.
|
||||
**Altbestand.** Angebote mit mehreren Positionen und einer Programmseite (früher möglich) bleiben unter `c:` auf ihrer Programmseite kaufbar, solange diese zur Anzeige freigegeben ist. Ein Angebot mit genau einer Artikelposition wechselt auf die Artikelseite, auch wenn es früher einem Programm zugeordnet war; ein früher auf einer Programmseite geführtes Paket erhält seine eigene Paketseite und erscheint im Shop als Paket.
|
||||
**Bewusst offen.** (1) Teilbesitz bei Paketen: Wer einen enthaltenen Artikel schon hat, zahlt den vollen Preis (`OwnershipCheck` kennt nur vollständige Abdeckung durch einen Erwerb). (2) Mehrere Optionen je Artikel in einem Arbeitsschritt: erledigt am 25.11.2026 (Nachtrag unten). (3) Teilen des Paketpreises auf die Artikel für den Journal-Filter „Gekauftes Angebot“.
|
||||
**Folgen.** Kein Schemawechsel. Vorhandene aktive Kaufangebote mit einer Artikelposition werden mit dem Deployment **sofort öffentlich kaufbar** und stehen im Shop, soweit der Shop läuft; wer das nicht will, nimmt sie vorher aus dem Verkauf.
|
||||
**Nachtrag 25.11.2026: Optionen am Lizenzartikel.** Der Verkauf eines Artikels wird dort gepflegt, wo der Artikel steht. Die Seite des Lizenzartikels hat den Abschnitt „Im Shop verkaufen“: Er listet die Optionen mit Preis, Nutzerkreis, Eignung, Rechten, Fassung und Zustand. „Option hinzufügen“ fragt nur Rechteprofil, Preis, Eignung, Nutzerkreis (Trainerzahl) und eine Bezeichnung ab (Vorschlag aus Nutzerkreis und Eignung); es gibt keine Auswahl von Artikel, Inhalt oder Vergabe, die Vergabe ist „Kauf“. Jede Option bleibt ein Angebot mit genau einer Position; mehrere Optionen eines Artikels erscheinen gemeinsam auf `/shop/{Artikel}` und sind Alternativen im Warenkorb.
|
||||
- `OfferService::offerArticle` legt Angebot und erste Fassung in **einer Transaktion** an: Besteht eine Prüfung nicht (Stand, Preis, Nutzerkreis), bleibt kein leeres Angebot zurück. `reviseArticleOption` aktiviert die nächste Fassung (Laufzeit und Steuerklasse der letzten Fassung bleiben) und lehnt Optionen anderer Artikel und Vergaben auf Abruf oder bei Registrierung ab; diese erscheinen im Abschnitt nur mit dem Hinweis, dass sie am Angebot bearbeitet werden.
|
||||
- Aus der Angebotsmaske entfällt „Programmfassung, die abgedeckt sein muss“; die Prüfung bleibt im Dienst (`assertCoverage`). Pakete und der Altbestand mit mehreren Positionen behalten die Angebotsmaske mit Positionen.
|
||||
- Der Dialog speichert die Redaktion des Artikels nicht mit und verwirft offene Eingaben dort nicht (CLAUDE.md, Redaktion als Arbeitsstand).
|
||||
**Quelle.** Anfrage von Lars vom 25.11.2026; ADR-29, ADR-47; `docs/prinzipien/design-prinzipien.md`; `docs/fachkonzept/produktkonfiguration-und-mitgliederbereich.md`.
|
||||
@@ -153,6 +153,14 @@ ## Annahmen und offene Punkte
|
||||
- **Gate vor Prod:** Merge-Schutz ist eine Gitea-Einstellung und gehört nicht in die Workflows.
|
||||
- **Umzug Test auf den Pi:** Werte oben in `deploy-test.yml` ändern (Label `ubuntu-latest`, Guard auf `raspberrypi5`/`aarch64`, Pfade, Port). Das Dockerfile baut auch für ARM64. Vorher Speicherlage auf dem Pi klären.
|
||||
|
||||
## Produktseiten im Shop (ADR-52, 25.11.2026)
|
||||
|
||||
- Jeder Lizenzartikel mit mindestens einer kaufbaren Option (aktive Fassung, Kauf, Preis) hat eine Produktseite unter `/shop/<Artikelkennung>` und eine Kachel im Shop. Die Seite wird aus dem Angebot abgeleitet, nicht zugeordnet. Pakete behalten `/pakete/<id>`.
|
||||
- **Mit dem Deployment ändert sich der Katalog sofort:** Aktive Kaufangebote mit einer Artikelposition, die bisher keine Produktseite hatten (zum Beispiel ein Lizenzartikel aus einem Modul), sind dann öffentlich kaufbar und gelistet, sofern der Shop läuft (Test: Testzahlung; Prod: nur mit Live-Freigabe, siehe unten). Vor dem Merge nach `main` die Angebote prüfen (Verwaltung → Angebote) und ungewollte mit „Aus dem Verkauf nehmen“ beenden. Eine Prüfung der Produktivdaten erfolgt nur lesend und mit Freigabe von Lars.
|
||||
- Keine Migration. Die Spalten `offers.composition_id` und `offers.standalone_bundle` bleiben, werden aber nicht mehr geschrieben. Ein Rollback des Codes ändert keine Daten.
|
||||
- Ein Kauf braucht genau eine Position (Artikel oder Paketfassung) und einen Preis; die Maske lehnt anderes ab.
|
||||
- Optionen eines Artikels werden am Lizenzartikel gepflegt (Abschnitt „Im Shop verkaufen“, Aktionen „Option hinzufügen“, „Ändern“, „Aus dem Verkauf nehmen“). Das ist eine reine Oberflächen- und Dienständerung ohne Migration; Pakete und Vergaben auf Abruf oder bei Registrierung bleiben in der Angebotsmaske.
|
||||
|
||||
## Verkaufsstart: Freigabe und Betrieb (Stand 24.11.2026, vorbereitet, nicht freigegeben)
|
||||
|
||||
Die Produktivfreigabe liegt bei Lars. Der Code enthält sie nicht; er erlaubt sie nur, wenn **alle** Bedingungen erfüllt sind (`App\Domain\Commerce\Shop::live()`):
|
||||
|
||||
@@ -30,6 +30,69 @@ ## Rechnungsweg aus, Zahlungen je Angebot, Zahlungshistorie mit Beleg (23.11.202
|
||||
|
||||
**Offen für die Entscheidung von Lars:** Aussteller (Name, Anschrift) und Zusatzhinweis für den Beleg (`SHOP_RECEIPT_ISSUER`, `SHOP_RECEIPT_NOTE`), Steuerangaben und Rechnungsnummer (OPEN-06, rechtliche Klärung); ob der Beleg bei einer Rechnungspflicht durch eine Rechnung ersetzt oder ergänzt wird; ob für ein gestaltetes Dokument mit Briefkopf eine PDF-Bibliothek aufgenommen wird (der jetzige Schreiber setzt bewusst keine voraus); Einschalten des Rechnungswegs (`SHOP_INVOICE=true`) erst mit vollständigem Prozess.
|
||||
|
||||
## Produktseite je Lizenzartikel (25.11.2026, auf `luf-test`)
|
||||
|
||||
**Geprüfter Stand:** Commit `cce22eb` auf `develop`; `CI Feature / test` (Branch `feature/shop-artikelseite`), `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Entscheidung und Altbestand: ADR-52, Betrieb: `DEPLOYMENT.md`, Abschnitt „Produktseiten im Shop“.
|
||||
|
||||
**Auslöser.** Ein Lizenzartikel aus einem Modul oder einem Programm mit Modulen ließ sich nicht verkaufen: Das Angebot wurde aktiv, hatte aber keine Produktseite, und die Auswahl „Produktseite“ bot nur „Eigene Paketseite“ an (das Paket verlangt eine Paketfassung). Jetzt ergibt sich die Seite aus dem Angebot: Sie ist die Seite des Artikels, den die Option als einzige Position verkauft.
|
||||
|
||||
**Tests lokal:** Die Tests laufen auf Commit `cce22eb` auf `develop` grün (Gate `CI Feature / test`, CI-Lauf `5175` für den ersten Stand rot wegen drei noch nicht angepasster Testgruppen, im Folgecommit behoben und begründet). Lokal fehlten in der `vendor`-Kopie einzelne Symbole der Texteditor-Leiste (`o-h3` bis `o-h6`, weitere Heroicons): 46 Tests der Medien-, Dokument- und Redaktionsmasken laufen lokal deshalb nicht, im CI-Gate laufen sie; keiner davon betrifft Angebote oder den Shop. Neu oder umgeschrieben: `ShopProductPageTest` (Artikelseite mit Optionen; Texte aus dem Artikel, sonst aus dem Inhalt; keine Dateien oder Lehrtexte; Programmseite verweist nur; Artikel ohne kaufbare Option hat keine Seite; unbekannter Artikel 404), `CartTest` (Alternativen sind Optionen desselben Artikels, ein anderer Artikel liegt zusätzlich im Warenkorb; Altbestand mit mehreren Positionen bleibt auf der Programmseite, solange sie freigegeben ist), `ShopVerwaltungAbnahmeTest` (Ablauf von leer bis auffindbar ohne Zuordnung; Kauf mit mehreren Positionen und Kauf ohne Preis werden abgelehnt; „Bei Registrierung“ und „Auf Abruf“ bleiben zulässig, stehen aber nicht im Shop). Die CMS-Kartentests (Module bleiben auf Karten und `/programme` privat) laufen **unverändert** grün.
|
||||
|
||||
**Geprüft im echten Browser** (Chromium über Playwright, Skripte nicht im Repository; 1280 und 390 px). Das Angebot „noch ein Test“ (bisher ohne Fassung) wurde über die Maske aktiviert, mit dem Artikel „Programm Abstand“, der aus verschachtelten Modulen besteht. Das ist der Weg, der in Produktion keine Produktseite ergab.
|
||||
|
||||
| Fall | Ergebnis | Belege |
|
||||
|---|---|---|
|
||||
| Maske „Fassung aktivieren“ | Die Auswahl „Produktseite“ gibt es nicht mehr; die Voraussetzungen führen den Schritt „Produktseite im Shop“ | [01](etappe-1/artikelseite/01-aktivieren-ohne-produktseite.jpg) |
|
||||
| Aktivieren | Meldung „Die Option ist öffentlich kaufbar und im Shop auffindbar.“, Voraussetzungen vollständig, Zeile „Produktseite: öffentlich unter /shop/4“ | [02](etappe-1/artikelseite/02-nach-aktivierung-abgeleitete-seite.jpg) |
|
||||
| Öffentliche Artikelseite | `/shop/4` antwortet 200: Titel, Lernziel, Aufbau (Module mit Unterlage und Film), darunter die Option mit Preis 15,00 €, Rechten und Nutzerkreis; der Artikel steht im Shop | [03](etappe-1/artikelseite/03-oeffentliche-artikelseite.jpg) |
|
||||
| Sperre: Kauf ohne Preis | „Ein Kauf braucht einen Preis über 0,00 €.“; Fassung 1 bleibt aktiv | [05](etappe-1/artikelseite/05-sperre-ohne-preis.jpg) |
|
||||
| Sperre: mehrere Positionen | „Ein Kauf verkauft genau einen Artikel oder ein Paket. Mehrere Artikel gemeinsam verkaufst du als Paket (Katalog → Pakete).“ | [04](etappe-1/artikelseite/04-sperre-mehrere-positionen.jpg) |
|
||||
| Shop und Seiten | Shop listet die Artikelseiten `/shop/10`, `/shop/4` und die Paketseite `/pakete/7`; bei 1280 und 390 px kein horizontaler Überlauf; „In den Warenkorb“ bleibt auf der Artikelseite, der Warenkorb nennt den Artikel mit Titel; `/shop/999999` liefert 404 | [06](etappe-1/artikelseite/06-shop-390.jpg), [07](etappe-1/artikelseite/07-artikelseite-390.jpg) |
|
||||
| Aus dem Verkauf nehmen | `/shop/4` antwortet danach 404, der Artikel verschwindet aus dem Shop, `/shop/10` und `/pakete/7` bleiben | (Skriptausgabe) |
|
||||
|
||||
Der Zustand von `luf-test` ist danach: Angebot „noch ein Test“ mit einer beendeten Fassung 1 (statt ohne Fassung); sonst unverändert.
|
||||
|
||||
**Nicht geprüft (mit Grund):**
|
||||
|
||||
1. **Alternativen im Warenkorb auf `luf-test`:** Es gibt dort nur ein Angebot je Artikel; der Wechsel zwischen zwei Optionen desselben Artikels ist durch Tests und lokal im Browser belegt (Wechselhinweis auf der Artikelseite).
|
||||
2. **Produktivdaten:** Welche Angebote auf Prod künftig sofort öffentlich kaufbar sind, ist nicht gelesen worden (nur mit Freigabe von Lars). Siehe `DEPLOYMENT.md`.
|
||||
3. **Altbestand mit mehreren Positionen und Programmseite** im Browser: durch Test belegt, auf `luf-test` gibt es keinen solchen Fall.
|
||||
4. **Der Dialog selbst** ist unverändert lang (Eignung, Nutzerkreis, Vergabe, Preis, „Programmfassung, die abgedeckt sein muss“, Positionen). Die Vereinfachung mit mehreren Optionen je Artikel (Rechteprofil mit Preis) folgt als nächster Schritt.
|
||||
|
||||
## Optionen am Lizenzartikel (25.11.2026, auf `luf-test`)
|
||||
|
||||
**Geprüfter Stand:** Commit `6575784` auf `develop`; `CI Feature / test` (Branch `feature/artikel-optionen`), `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Entscheidung: ADR-52, Nachtrag „Optionen am Lizenzartikel“.
|
||||
|
||||
**Auslöser.** Mehrere Optionen (Rechteprofil mit Preis) je Artikel ließen sich nur über je ein Angebot mit langer Maske anlegen (Auswahl von Artikel, Ziel, Programmfassung, Vergabe). Jetzt legt der Artikel seine Optionen selbst an.
|
||||
|
||||
**Tests.** `ArticleOptionsTest` (13 Tests): Der Dialog fragt nur Rechteprofil, Preis, Eignung, Nutzerkreis und Bezeichnung (keine Auswahl von Artikel, Ziel, Positionen, Paketfassung, Programmfassung, Vergabe); zwei Optionen teilen sich `/shop/{Artikel}` und sind Alternativen im Warenkorb; der Abschnitt listet Preis, Rechte und Zustand; ein Artikel ohne Stand ist nicht verkaufbar; Preis 0, negativ oder Text und Mehrfachlizenz mit einem Trainer hinterlassen **kein leeres Angebot**; Ändern aktiviert die nächste Fassung, die frühere bleibt, die andere Option bleibt unberührt; Abbrechen ändert nichts; eine Option beenden lässt die andere kaufbar, „Wieder anbieten“ funktioniert; eine Option eines anderen Artikels liefert 404 und wird vom Dienst abgelehnt; ein Angebot auf Abruf wird gelistet, aber weder geändert noch beendet noch zum Kauf umgestellt; der Dialog speichert die Redaktion nicht mit und lässt offene Eingaben stehen; die Angebotsmaske kennt „Programmfassung, die abgedeckt sein muss“ nicht mehr. Die Gesamtsuite lief lokal ohne andere Fehler als die bekannten 46 Symbolfehler der lokalen `vendor`-Kopie; das CI-Gate ist grün.
|
||||
|
||||
**Gefundener Fehler beim Abnahmelauf.** Am Artikel „Programm Abstand“ hing schon das Angebot „Testangebot Abstand“ (Vergabe Auf Abruf). Der erste Stand des Abschnitts bot dafür „Ändern“ und „Aus dem Verkauf nehmen“ an; „Ändern“ hätte es zum Kauf umgestellt. Mein Aufräumskript beendete es dabei auf `luf-test`. Behoben in `6575784` (Test oben), das Angebot danach über die Angebotsmaske wieder aktiviert (jetzt Fassung 2, Vergabe Auf Abruf, Nutzerkreis Einzellizenz statt „nicht festgelegt“; die frühere Fassung 1 ist beendet gespeichert).
|
||||
|
||||
**Geprüft im echten Browser** (Chromium über Playwright, Skripte nicht im Repository; 1280, 1440 und 390 px, Tastatur).
|
||||
|
||||
| Fall | Ergebnis | Belege |
|
||||
|---|---|---|
|
||||
| Abschnitt „Im Shop verkaufen“ | Liste der Optionen mit Preis, Nutzerkreis, Eignung, Rechten, Fassung und Zustand; beendete Option mit „Wieder anbieten“ | [01](etappe-1/optionen/01-abschnitt-vorher.jpg) |
|
||||
| Dialog „Option hinzufügen“ | Fünf Felder; per Tastatur (Enter auf dem Knopf) geöffnet, Fokus im Dialog, Escape schließt ohne Wirkung | [02](etappe-1/optionen/02-dialog-option-hinzufuegen.jpg) |
|
||||
| Beendete Option wieder anbieten | Maske vorbelegt (Preis 15,00); Meldung „ist als Fassung 2 aktiv und im Shop kaufbar unter /shop/4“ | [03](etappe-1/optionen/03-dialog-vorbelegt.jpg) |
|
||||
| Zweite Option für Vereine | Vorschlag „Mehrfachlizenz (8 Trainer) für Organisationen und Vereine“, eigene Bezeichnung übernommen, Fassung 1 aktiv | [04](etappe-1/optionen/04-dialog-zweite-option.jpg), [05](etappe-1/optionen/05-abschnitt-zwei-optionen.jpg) |
|
||||
| Öffentliche Artikelseite | Beide Optionen mit Preis, Eignung und Nutzerkreis, bei 1280 und 390 px ohne horizontalen Überlauf | [06](etappe-1/optionen/06-artikelseite-1280.jpg) |
|
||||
| Alternativen im Warenkorb | Zweite Option desselben Artikels fragt „Optionen wechseln?“; nach dem Wechsel liegt genau die gewählte Option im Warenkorb | [07](etappe-1/optionen/07-optionen-wechseln.jpg), [08](etappe-1/optionen/08-warenkorb-nach-wechsel.jpg) |
|
||||
| Schmales Fenster (390 px) | Abschnitt der Verwaltung ohne Überlauf, Aktionen umbrechen | [09](etappe-1/optionen/09-abschnitt-390.jpg) |
|
||||
| Angebot auf Abruf | „Kein Kauf im Shop. Diese Vergabe bearbeitest du am Angebot.“, keine Änderungs- oder Beenden-Aktion | [10](etappe-1/optionen/10-angebot-auf-abruf-ohne-aktionen.jpg) |
|
||||
| Aufräumen | Nur die Kauf-Option bietet „Aus dem Verkauf nehmen“ an; danach `/shop/4` 404 und aus dem Shop verschwunden | [11](etappe-1/optionen/11-abschnitt-nachher.jpg) |
|
||||
|
||||
Die Bilder 01 bis 09 stammen vom ersten Lauf vor dem Fehlerfix (dort steht „Testangebot Abstand“ noch mit „Ändern“; Bild 09 zeigt das); Bild 10 und 11 sind nach dem Fix aufgenommen.
|
||||
|
||||
**Zustand von `luf-test` danach:** Artikel „Programm Abstand“ hat die beendeten Kauf-Optionen „Einzellizenz Abstand“ (Fassung 1 und 2) und „Vereinslizenz Abstand“ (Fassung 1) sowie das Angebot „Testangebot Abstand“ (Auf Abruf, Fassung 2 aktiv); `/shop/4` antwortet 404. Es entstand ein zusätzliches Angebot („Programm Abstand: Vereinslizenz Abstand“).
|
||||
|
||||
**Nicht geprüft (mit Grund):**
|
||||
|
||||
1. **Produktivdaten:** Nicht gelesen. Lars nennt nur ein Angebot auf Prod (das fehlerhafte).
|
||||
2. **Pakete:** Optionen eines Pakets bleiben in der Angebotsmaske; ein gleichartiger Dialog am Paket ist nicht gebaut.
|
||||
3. **Teilbesitz bei Paketen und der Journal-Filter je Paket** bleiben offen (ADR-52).
|
||||
|
||||
## Zahlungsjournal: Standardansicht je Umgebung (23.11.2026, auf `luf-test`)
|
||||
|
||||
**Geprüfter Stand:** Commit `3f9e463` auf `develop`; `CI Feature / test`, `Deploy Test / test` und `Deploy Test / deploy` **success** (öffentliche Gitea-Statusabfrage). Tests lokal 714 grün, Pint auf den geänderten Dateien bestanden.
|
||||
|
||||
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 209 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 212 KiB |
|
After Width: | Height: | Size: 207 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 174 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 139 KiB |
|
After Width: | Height: | Size: 152 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 143 KiB |
|
After Width: | Height: | Size: 165 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 189 KiB |
|
After Width: | Height: | Size: 214 KiB |
|
After Width: | Height: | Size: 224 KiB |
@@ -40,6 +40,7 @@
|
||||
@include('filament.verwaltung.abgang', ['offen' => $offen])
|
||||
|
||||
<div class="vw-medien-raster">
|
||||
<div class="vw-spalte">
|
||||
<section class="vw-karte-box" aria-labelledby="artikel-redaktion">
|
||||
<div class="vw-spalte-kopf">
|
||||
<h2 id="artikel-redaktion">Präsentation des Artikels</h2>
|
||||
@@ -66,6 +67,50 @@
|
||||
<div><button type="button" class="vw-btn is-line" wire:click="openRedaktion('texte')">@include('filament.verwaltung.icon', ['name' => 'stift'])Redaktion bearbeiten</button></div>
|
||||
@endif
|
||||
</section>
|
||||
|
||||
<section class="vw-karte-box" aria-labelledby="artikel-optionen" id="optionen">
|
||||
<div class="vw-spalte-kopf">
|
||||
<h2 id="artikel-optionen">Im Shop verkaufen</h2>
|
||||
<span class="vw-feld-hilfe">Jede Option ist eine Lizenz mit Rechteprofil und Preis. Alle Optionen erscheinen auf der Produktseite dieses Artikels.</span>
|
||||
</div>
|
||||
@if (! $this->canOffer())
|
||||
<p class="vw-feld-hilfe">Zuerst den Inhalt festlegen: Ohne veröffentlichten Stand lizenziert der Artikel nichts und lässt sich nicht verkaufen.</p>
|
||||
@else
|
||||
@php($optionen = $this->optionRows())
|
||||
@if ($optionen === [])
|
||||
<div class="vw-leer">
|
||||
<strong>Noch keine Option</strong>
|
||||
<p>Lege fest, mit welchem Rechteprofil und zu welchem Preis der Artikel verkauft wird. Mehrere Optionen, etwa für Privatpersonen und für Vereine, sind möglich.</p>
|
||||
</div>
|
||||
@else
|
||||
<ul class="vw-verwendungsliste">
|
||||
@foreach ($optionen as $option)
|
||||
<li>
|
||||
<strong>{{ $option['name'] }}</strong>
|
||||
<span @class(['vw-zustand', 'is-'.$option['zustand']['ton']])>{{ $option['zustand']['label'] }}</span>
|
||||
<span class="vw-feld-hilfe">{{ $option['price'] }} · {{ $option['licence'] }} · {{ $option['for'] }} · Rechte: {{ $option['rights'] }} · Fassung {{ $option['number'] }}</span>
|
||||
<span class="vw-zeilenaktionen">
|
||||
@if ($option['kauf'])
|
||||
<button type="button" class="vw-link" wire:click="mountAction('option', { offer: {{ $option['offer'] }} })">{{ $option['active'] ? 'Ändern' : 'Wieder anbieten' }}</button>
|
||||
@if ($option['active'])
|
||||
<button type="button" class="vw-link is-quiet" wire:click="mountAction('optionEnd', { offer: {{ $option['offer'] }} })">Aus dem Verkauf nehmen</button>
|
||||
@endif
|
||||
@else
|
||||
<span class="vw-feld-hilfe">Kein Kauf im Shop. Diese Vergabe bearbeitest du am Angebot.</span>
|
||||
@endif
|
||||
@if ($option['page'])
|
||||
<a class="vw-link is-quiet" href="{{ $option['page'] }}" target="_blank" rel="noopener">Produktseite ansehen</a>
|
||||
@endif
|
||||
<a class="vw-link is-quiet" href="{{ $option['url'] }}">Angebot öffnen</a>
|
||||
</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
<div><button type="button" class="vw-btn is-line" wire:click="mountAction('option')">@include('filament.verwaltung.icon', ['name' => 'plus'])Option hinzufügen</button></div>
|
||||
@endif
|
||||
</section>
|
||||
</div>
|
||||
<aside class="vw-spalte">
|
||||
@include('filament.verwaltung.voraussetzungen', ['voraussetzungen' => $voraussetzungen])
|
||||
<section class="vw-karte-box" aria-labelledby="artikel-stand">
|
||||
|
||||
@@ -378,6 +378,7 @@
|
||||
.vw-schritt.is-erledigt .vw-schritt-text { color: var(--vw-quiet); }
|
||||
@media (max-width: 640px) { .vw-schritt { grid-template-columns: minmax(0, 1fr); } .vw-schritt .vw-btn { grid-column: 1; grid-row: auto; justify-self: start; } }
|
||||
.vw-verwendungsliste li { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; padding: 0.6rem 0; border-bottom: 1px solid var(--vw-line); }
|
||||
.vw-zeilenaktionen { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
|
||||
.vw-vorschaubild.is-gross { max-width: 40rem; }
|
||||
.vw-trennlinie { padding-top: 0.85rem; border-top: 1px solid var(--vw-line); }
|
||||
.vw-inhaltsvorschau { width: 100%; height: 34rem; border: 1px solid var(--vw-line); border-radius: var(--vw-radius); background: #fff; }
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
@extends('layouts.site')
|
||||
|
||||
@section('title', $title)
|
||||
|
||||
@section('content')
|
||||
<p><a href="{{ route('shop') }}">Shop</a></p>
|
||||
<h1>{{ $title }}</h1>
|
||||
@if ($profile->html('summary') !== '')
|
||||
<div class="lede">{!! $profile->html('summary') !!}</div>
|
||||
@elseif (filled($profile->value('teaser')))
|
||||
<p class="lede">{{ $profile->value('teaser') }}</p>
|
||||
@endif
|
||||
@if ($profile->html('description') !== '')
|
||||
<div class="shop-description">{!! $profile->html('description') !!}</div>
|
||||
@endif
|
||||
@if ($goal !== null)
|
||||
<div><strong>Lernziel:</strong> {!! \App\Domain\Catalog\FormattedText::display($goal) !!}</div>
|
||||
@endif
|
||||
@if ($nodes !== [])
|
||||
<section class="shop-package-contents" aria-labelledby="artikel-aufbau">
|
||||
<h2 id="artikel-aufbau">Das ist enthalten</h2>
|
||||
<ol class="course">
|
||||
@foreach ($nodes as $node)
|
||||
<li>
|
||||
<h3>{{ $node->role }}: {{ $node->title }}</h3>
|
||||
@if ($node->children !== [])
|
||||
<ol>
|
||||
@foreach ($node->children as $child)
|
||||
<li>{{ $child->role }}: {{ $child->title }}</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
</section>
|
||||
@endif
|
||||
@include('shop.optionen', ['options' => $options, 'cart' => $cart, 'switchTo' => $switchTo])
|
||||
@endsection
|
||||
@@ -25,5 +25,15 @@
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
@if (($articles ?? []) !== [])
|
||||
<section class="shop-options" aria-labelledby="programm-kaufen">
|
||||
<h2 id="programm-kaufen">Zum Kaufen</h2>
|
||||
<ul>
|
||||
@foreach ($articles as $article)
|
||||
<li><a href="{{ route('shop.article', $article) }}">{{ app(\App\Domain\Commerce\ProductOptions::class)->articleTitle($article) }}: Lizenzoptionen ansehen</a></li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</section>
|
||||
@endif
|
||||
@include('shop.optionen', ['options' => $options, 'cart' => $cart, 'switchTo' => $switchTo])
|
||||
@endsection
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
@section('content')
|
||||
<h1>Shop</h1>
|
||||
<p class="lede">Hier findest du kaufbare Programme und Pakete. Jede Kachel öffnet die Produktseite mit Inhalt und den verfügbaren Lizenzoptionen.</p>
|
||||
<p class="lede">Hier findest du kaufbare Produkte und Pakete. Jede Kachel öffnet die Produktseite mit Inhalt und den verfügbaren Lizenzoptionen.</p>
|
||||
|
||||
<form class="shop-search" method="get" action="{{ route('shop') }}" role="search">
|
||||
<label for="shop-suche">Shop durchsuchen</label>
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
Route::middleware(EnsureShopEnabled::class)->group(function () {
|
||||
Route::get('/shop', [ShopController::class, 'index'])->name('shop');
|
||||
Route::get('/shop/{article}', [PublicCatalogController::class, 'article'])->whereNumber('article')->name('shop.article');
|
||||
Route::get('/warenkorb', [CartController::class, 'show'])->name('cart');
|
||||
Route::post('/warenkorb/{offer}', [CartController::class, 'add'])->name('cart.add');
|
||||
Route::post('/warenkorb/{offer}/wechseln', [CartController::class, 'switch'])->name('cart.switch');
|
||||
|
||||
@@ -0,0 +1,372 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||
use App\Filament\Resources\Offers\Pages\ViewOffer;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\Support\BuildsShop;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Optionen am Lizenzartikel: Der Artikel wird direkt in seiner Maske verkauft (Rechteprofil, Preis, Nutzerkreis,
|
||||
* Eignung), mehrere Optionen je Artikel sind möglich, und eine fehlgeschlagene Prüfung hinterlässt kein leeres Angebot.
|
||||
*/
|
||||
class ArticleOptionsTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
private function keeper(): User
|
||||
{
|
||||
$keeper = User::factory()->katalogverwalter()->create();
|
||||
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $keeper;
|
||||
}
|
||||
|
||||
/** Ein Artikel mit veröffentlichtem Stand, aber ohne Angebot. */
|
||||
private function freshArticle(string $code = 'neu-optionen'): LicenseArticle
|
||||
{
|
||||
$article = app(ArticleService::class)->create($code);
|
||||
app(ArticleService::class)->publishRelease($article, $this->article('shop-grenzen')->currentRelease->rootCompositionVersion, 'Erster Stand dieses Lizenzartikels.');
|
||||
|
||||
return $article->fresh();
|
||||
}
|
||||
|
||||
private function privateRights(): RightsProfileVersion
|
||||
{
|
||||
return RightsProfileVersion::query()->whereHas('profile', fn ($query) => $query->where('name', 'Privatlizenz ehrenamtlich'))->firstOrFail();
|
||||
}
|
||||
|
||||
private function clubRights(): RightsProfileVersion
|
||||
{
|
||||
return RightsProfileVersion::query()->whereHas('profile', fn ($query) => $query->where('name', 'Vereinslizenz institutionell'))->firstOrFail();
|
||||
}
|
||||
|
||||
private function page(LicenseArticle $article)
|
||||
{
|
||||
return Livewire::actingAs($this->keeper(), 'staff')->test(ViewLicenseArticle::class, ['record' => $article->getKey()]);
|
||||
}
|
||||
|
||||
public function test_the_dialog_asks_only_for_rights_price_scope_suitability_and_label(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
|
||||
$component = $this->page($article)->mountAction('option');
|
||||
$page = $component->instance();
|
||||
$schema = (new \ReflectionMethod($page, 'getMountedActionSchema'))->invoke($page);
|
||||
$labels = collect($schema->getFlatComponents())
|
||||
->map(fn ($field): ?string => method_exists($field, 'getLabel') ? (string) $field->getLabel() : null)
|
||||
->filter()
|
||||
->values()
|
||||
->all();
|
||||
|
||||
foreach (['Rechteprofil', 'Preis in Euro', 'Geeignet für', 'Nutzerkreis', 'Bezeichnung der Option'] as $label) {
|
||||
$this->assertContains($label, $labels);
|
||||
}
|
||||
|
||||
foreach (['Artikel', 'Ziel', 'Positionen', 'Paketfassung', 'Programmfassung, die abgedeckt sein muss', 'Vergabe'] as $label) {
|
||||
$this->assertNotContains($label, $labels, 'Der Artikel steht fest, es gibt keine Auswahl von Artikel, Inhalt oder Vergabe.');
|
||||
}
|
||||
|
||||
$data = $component->get('mountedActions.0.data');
|
||||
$this->assertSame('person', $data['holder_kind']);
|
||||
$this->assertSame('einzel', $data['licence_scope']);
|
||||
}
|
||||
|
||||
public function test_an_article_gets_two_options_that_share_its_product_page_and_are_alternatives_in_the_cart(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
|
||||
$this->page($article)
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->privateRights()->id, 'price_euro' => '39,00', 'holder_kind' => 'person', 'licence_scope' => 'einzel', 'option_label' => ''])
|
||||
->callMountedAction()
|
||||
->assertHasNoActionErrors();
|
||||
|
||||
$this->page($article)
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->clubRights()->id, 'price_euro' => '149,00', 'holder_kind' => 'organisation', 'licence_scope' => 'mehrfach', 'trainer_count' => 8, 'option_label' => 'Vereinslizenz'])
|
||||
->callMountedAction()
|
||||
->assertHasNoActionErrors();
|
||||
|
||||
$offers = app(ProductOptions::class)->offersOfArticle($article);
|
||||
$this->assertCount(2, $offers);
|
||||
[$private, $club] = $offers;
|
||||
$this->assertSame('Einzellizenz für Privatpersonen', $private->optionName(), 'Ohne Eingabe gilt der Vorschlag aus Nutzerkreis und Eignung.');
|
||||
$this->assertSame('Vereinslizenz', $club->optionName());
|
||||
$this->assertStringStartsWith(app(ProductOptions::class)->articleTitle($article).': ', $private->name);
|
||||
|
||||
$privateVersion = $private->versions()->firstOrFail();
|
||||
$this->assertSame(OfferStatus::Aktiv, $privateVersion->status);
|
||||
$this->assertSame(3900, $privateVersion->price_cents);
|
||||
$this->assertSame('kauf', $privateVersion->grant_kind);
|
||||
$this->assertSame('einzel', $privateVersion->licence_scope);
|
||||
$clubVersion = $club->versions()->firstOrFail();
|
||||
$this->assertSame(14900, $clubVersion->price_cents);
|
||||
$this->assertSame('organisation', $clubVersion->holder_kind);
|
||||
$this->assertSame(8, $clubVersion->trainer_count);
|
||||
|
||||
$this->get('/shop/'.$article->id)
|
||||
->assertOk()
|
||||
->assertSee('Einzellizenz für Privatpersonen')
|
||||
->assertSee('39,00')
|
||||
->assertSee('Vereinslizenz')
|
||||
->assertSee('149,00');
|
||||
$this->get('/shop')->assertOk()->assertSee('/shop/'.$article->id, false);
|
||||
|
||||
$cart = app(Cart::class);
|
||||
$this->assertSame(Cart::ADDED, $cart->add($private));
|
||||
$this->assertSame(Cart::ALTERNATIVE, $cart->add($club), 'Zwei Optionen desselben Artikels sind Alternativen im Warenkorb.');
|
||||
$this->assertSame(1, $cart->count());
|
||||
}
|
||||
|
||||
public function test_the_article_page_lists_its_options_with_price_rights_and_state(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$this->page($article)->assertSee('Im Shop verkaufen')->assertSee('Noch keine Option')->assertSee('Option hinzufügen');
|
||||
|
||||
app(OfferService::class)->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Privat', 'Privatlizenz');
|
||||
|
||||
$this->page($article)
|
||||
->assertSee('Privatlizenz')
|
||||
->assertSee('39,00 €')
|
||||
->assertSee('Einzellizenz · 1 Trainer')
|
||||
->assertSee('Rechte: Privatlizenz ehrenamtlich')
|
||||
->assertSee('Im Shop')
|
||||
->assertSee('Produktseite ansehen')
|
||||
->assertSee('Aus dem Verkauf nehmen')
|
||||
->assertDontSee('Noch keine Option');
|
||||
}
|
||||
|
||||
public function test_an_article_without_stand_cannot_be_offered_and_the_page_says_so(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('neu-ohne-stand-optionen');
|
||||
|
||||
$this->page($article)
|
||||
->assertSee('Zuerst den Inhalt festlegen')
|
||||
->assertDontSee('Noch keine Option');
|
||||
|
||||
$before = Offer::query()->count();
|
||||
$this->page($article)
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->privateRights()->id, 'price_euro' => '39,00', 'holder_kind' => 'person', 'licence_scope' => 'einzel'])
|
||||
->callMountedAction();
|
||||
|
||||
$this->assertSame($before, Offer::query()->count(), 'Ein Artikel ohne Stand hinterlässt kein Angebot.');
|
||||
}
|
||||
|
||||
public function test_a_failed_check_leaves_no_empty_offer_behind(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$before = Offer::query()->count();
|
||||
|
||||
foreach (['0,00', '-3', 'abc'] as $price) {
|
||||
$this->page($article)
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->privateRights()->id, 'price_euro' => $price, 'holder_kind' => 'person', 'licence_scope' => 'einzel'])
|
||||
->callMountedAction();
|
||||
}
|
||||
|
||||
$this->assertSame($before, Offer::query()->count(), 'Ein Kauf ohne Preis über 0,00 € legt kein Angebot an.');
|
||||
|
||||
$service = app(OfferService::class);
|
||||
|
||||
try {
|
||||
$service->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'mehrfach', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Fehler');
|
||||
$this->fail('Eine Mehrfachlizenz mit einem Trainer wird abgelehnt.');
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertSame($before, Offer::query()->count());
|
||||
}
|
||||
|
||||
$withoutStand = app(ArticleService::class)->create('neu-ohne-stand-dienst');
|
||||
|
||||
try {
|
||||
$service->offerArticle($withoutStand, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Ohne Stand');
|
||||
$this->fail('Ein Artikel ohne Stand lässt sich nicht verkaufen.');
|
||||
} catch (DomainRuleException) {
|
||||
$this->assertSame($before, Offer::query()->count());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_changing_an_option_activates_the_next_version_and_keeps_the_others(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$service = app(OfferService::class);
|
||||
$service->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Privat', 'Privatlizenz');
|
||||
$service->offerArticle($article, $this->clubRights(), ['holder_kind' => 'organisation', 'licence_scope' => 'mehrfach', 'trainer_count' => 5, 'price_cents' => 14900], 'Neu: Verein', 'Vereinslizenz');
|
||||
[$private, $club] = app(ProductOptions::class)->offersOfArticle($article);
|
||||
|
||||
$component = $this->page($article)->mountAction('option', ['offer' => $private->id]);
|
||||
$data = $component->get('mountedActions.0.data');
|
||||
$this->assertSame('39,00', $data['price_euro'], 'Die Maske ist mit der letzten Fassung vorbelegt, der Preis steht in Euro.');
|
||||
$this->assertSame('Privatlizenz', $data['option_label']);
|
||||
$this->assertSame($this->privateRights()->id, (int) $data['rights_id']);
|
||||
|
||||
$component->fillForm(['price_euro' => '29,00'])->callMountedAction()->assertHasNoActionErrors();
|
||||
|
||||
$versions = $private->versions()->orderBy('number')->get();
|
||||
$this->assertCount(2, $versions);
|
||||
$this->assertSame(OfferStatus::Beendet, $versions[0]->status);
|
||||
$this->assertSame(3900, $versions[0]->price_cents, 'Die frühere Fassung bleibt unverändert gespeichert.');
|
||||
$this->assertSame(OfferStatus::Aktiv, $versions[1]->status);
|
||||
$this->assertSame(2900, $versions[1]->price_cents);
|
||||
$this->assertSame(1, $club->versions()->count(), 'Die andere Option bleibt unberührt.');
|
||||
$this->assertSame(14900, $club->versions()->firstOrFail()->price_cents);
|
||||
}
|
||||
|
||||
public function test_cancelling_the_dialog_changes_nothing(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
app(OfferService::class)->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Privat', 'Privatlizenz');
|
||||
[$offer] = app(ProductOptions::class)->offersOfArticle($article);
|
||||
|
||||
$this->page($article)
|
||||
->mountAction('option', ['offer' => $offer->id])
|
||||
->fillForm(['price_euro' => '1,00', 'option_label' => 'Geändert'])
|
||||
->unmountAction();
|
||||
|
||||
$this->assertSame(1, $offer->versions()->count());
|
||||
$this->assertSame(3900, $offer->versions()->firstOrFail()->price_cents);
|
||||
$this->assertSame('Privatlizenz', $offer->fresh()->option_label);
|
||||
}
|
||||
|
||||
public function test_ending_one_option_leaves_the_other_purchasable_and_it_can_be_offered_again(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$service = app(OfferService::class);
|
||||
$service->offerArticle($article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 3900], 'Neu: Privat', 'Privatlizenz');
|
||||
$service->offerArticle($article, $this->clubRights(), ['holder_kind' => 'organisation', 'licence_scope' => 'mehrfach', 'trainer_count' => 5, 'price_cents' => 14900], 'Neu: Verein', 'Vereinslizenz');
|
||||
[$private, $club] = app(ProductOptions::class)->offersOfArticle($article);
|
||||
|
||||
$this->page($article)->mountAction('optionEnd', ['offer' => $private->id])->callMountedAction();
|
||||
|
||||
$this->assertNull($service->purchasableVersion($private->fresh()));
|
||||
$this->assertNotNull($service->purchasableVersion($club->fresh()));
|
||||
$this->get('/shop/'.$article->id)->assertOk()->assertDontSee('Privatlizenz')->assertSee('Vereinslizenz');
|
||||
|
||||
$this->page($article)
|
||||
->assertSee('Nicht im Verkauf')
|
||||
->assertSee('Wieder anbieten')
|
||||
->mountAction('option', ['offer' => $private->id])
|
||||
->callMountedAction()
|
||||
->assertHasNoActionErrors();
|
||||
|
||||
$this->assertNotNull($service->purchasableVersion($private->fresh()));
|
||||
$this->assertSame(2, $private->versions()->count());
|
||||
|
||||
$this->page($article)->mountAction('optionEnd', ['offer' => $private->id])->callMountedAction();
|
||||
$this->page($article)->mountAction('optionEnd', ['offer' => $club->id])->callMountedAction();
|
||||
$this->get('/shop/'.$article->id)->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_an_option_of_another_article_cannot_be_opened_or_changed(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$foreign = $this->privateKonflikte();
|
||||
|
||||
$this->page($article)->call('mountAction', 'option', ['offer' => $foreign->id])->assertStatus(404);
|
||||
$this->page($article)->call('mountAction', 'optionEnd', ['offer' => $foreign->id])->assertStatus(404);
|
||||
$this->assertSame(1, $foreign->versions()->count());
|
||||
$this->assertNotNull(app(OfferService::class)->purchasableVersion($foreign->fresh()), 'Eine fremde Option lässt sich weder öffnen noch beenden.');
|
||||
|
||||
try {
|
||||
app(OfferService::class)->reviseArticleOption($foreign, $article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 100]);
|
||||
$this->fail('Der Dienst lehnt eine Option eines anderen Artikels ab.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertStringContainsString('gehört nicht zu diesem Lizenzartikel', $exception->getMessage());
|
||||
$this->assertSame(1, $foreign->versions()->count());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_an_offer_on_demand_is_listed_but_cannot_be_changed_or_ended_as_a_shop_option(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$service = app(OfferService::class);
|
||||
$offer = $service->create('Neu: Auf Abruf');
|
||||
$service->activate($offer, [['target' => $article, 'rights' => $this->privateRights()]], ['grant_kind' => 'auf_abruf', 'holder_kind' => 'person']);
|
||||
|
||||
$component = $this->page($article)
|
||||
->assertSee('Neu: Auf Abruf')
|
||||
->assertSee('nicht im Shop')
|
||||
->assertSee('Kein Kauf im Shop')
|
||||
->assertDontSee('Wieder anbieten');
|
||||
$this->assertStringNotContainsString('offer: '.$offer->id.' }', $component->html(), 'Für eine Vergabe auf Abruf gibt es weder „Ändern“ noch „Aus dem Verkauf nehmen“.');
|
||||
|
||||
$this->page($article)->call('mountAction', 'option', ['offer' => $offer->id])->assertStatus(404);
|
||||
$this->page($article)->call('mountAction', 'optionEnd', ['offer' => $offer->id])->assertStatus(404);
|
||||
|
||||
try {
|
||||
$service->reviseArticleOption($offer, $article, $this->privateRights(), ['holder_kind' => 'person', 'licence_scope' => 'einzel', 'trainer_count' => 1, 'price_cents' => 1000]);
|
||||
$this->fail('Eine Vergabe auf Abruf wird nicht zum Kauf umgestellt.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertStringContainsString('als Kauf angeboten', $exception->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame(1, $offer->versions()->count());
|
||||
$this->assertSame('auf_abruf', $offer->versions()->firstOrFail()->grant_kind);
|
||||
$this->assertSame(OfferStatus::Aktiv, $offer->versions()->firstOrFail()->status);
|
||||
}
|
||||
|
||||
public function test_the_dialog_neither_saves_nor_resets_open_editorial_input(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$storedTitle = $article->display_title;
|
||||
|
||||
$component = $this->page($article)->set('displayTitle', 'Noch nicht gespeichert');
|
||||
$component
|
||||
->mountAction('option')
|
||||
->fillForm(['rights_id' => $this->privateRights()->id, 'price_euro' => '39,00', 'holder_kind' => 'person', 'licence_scope' => 'einzel'])
|
||||
->callMountedAction()
|
||||
->assertHasNoActionErrors();
|
||||
|
||||
$component->assertSet('displayTitle', 'Noch nicht gespeichert');
|
||||
$this->assertSame($storedTitle, $article->fresh()->display_title, 'Die Option speichert die Redaktion nicht mit.');
|
||||
$this->assertCount(1, app(ProductOptions::class)->offersOfArticle($article));
|
||||
}
|
||||
|
||||
public function test_the_next_step_on_the_article_opens_the_option_dialog(): void
|
||||
{
|
||||
$article = $this->freshArticle();
|
||||
$steps = collect(app(PublicationReadiness::class)->forArticle($article)['schritte']);
|
||||
$step = $steps->firstWhere('titel', 'Im Shop verkaufen');
|
||||
|
||||
$this->assertNotNull($step);
|
||||
$this->assertSame("mountAction('option')", $step['aktion']['wire']);
|
||||
}
|
||||
|
||||
public function test_the_offer_dialog_no_longer_asks_for_a_program_version_to_cover(): void
|
||||
{
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewOffer::class, ['record' => $this->privateKonflikte()->getKey()])
|
||||
->mountAction('activate');
|
||||
$page = $component->instance();
|
||||
$schema = (new \ReflectionMethod($page, 'getMountedActionSchema'))->invoke($page);
|
||||
$labels = collect($schema->getFlatComponents())
|
||||
->map(fn ($field): ?string => method_exists($field, 'getLabel') ? (string) $field->getLabel() : null)
|
||||
->filter()
|
||||
->all();
|
||||
|
||||
$this->assertNotContains('Programmfassung, die abgedeckt sein muss', $labels);
|
||||
$this->assertContains('Positionen', $labels, 'Pakete und der Altbestand behalten die Positionen.');
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Commerce\Cart;
|
||||
@@ -38,7 +37,7 @@ private function standaloneOffer(string $name, int $cents, string $scope = 'einz
|
||||
$rights = app(OfferService::class)->currentActiveVersion($this->privateKonflikte())->lines()->first()->rights;
|
||||
$offers = app(OfferService::class);
|
||||
$offer = $offers->create($name);
|
||||
$offers->assignProduct($offer, null, $name, true);
|
||||
$offers->setOptionLabel($offer, $name);
|
||||
$offers->activate($offer, [['target' => $version, 'rights' => $rights]], [
|
||||
'grant_kind' => 'kauf', 'price_cents' => $cents, 'holder_kind' => 'person', 'licence_scope' => $scope, 'trainer_count' => $trainers,
|
||||
]);
|
||||
@@ -100,30 +99,14 @@ public function test_the_package_page_is_gone_without_a_purchasable_option(): vo
|
||||
$this->get(route('public.package', $this->bundle()))->assertOk();
|
||||
|
||||
app(OfferService::class)->end($offer);
|
||||
$this->get(route('public.package', $this->bundle()))->assertOk(); // Das Demo-Angebot „Starterpaket: Privatlizenz“ verkauft dasselbe Paket weiter.
|
||||
|
||||
app(OfferService::class)->end($this->offerNamed('Starterpaket: Privatlizenz'));
|
||||
|
||||
$this->get(route('public.package', $this->bundle()))->assertNotFound();
|
||||
$this->get(route('shop'))->assertDontSee(route('public.package', $this->bundle()), false);
|
||||
}
|
||||
|
||||
public function test_an_offer_with_an_own_package_page_consists_of_exactly_one_package_version(): void
|
||||
{
|
||||
$offers = app(OfferService::class);
|
||||
$offer = $offers->create('Falsch');
|
||||
$offers->assignProduct($offer, null, 'Falsch', true);
|
||||
$rights = $offers->currentActiveVersion($this->privateKonflikte())->lines()->first()->rights;
|
||||
|
||||
$this->expectException(DomainRuleException::class);
|
||||
$offers->activate($offer, [['target' => $this->article('shop-konflikte'), 'rights' => $rights]], ['grant_kind' => 'kauf', 'price_cents' => 1000]);
|
||||
}
|
||||
|
||||
public function test_a_package_has_either_an_own_page_or_a_program_page(): void
|
||||
{
|
||||
$offer = app(OfferService::class)->create('Beides');
|
||||
|
||||
$this->expectException(DomainRuleException::class);
|
||||
app(OfferService::class)->assignProduct($offer, $this->program('Konflikte im Training')->id, 'Beides', true);
|
||||
}
|
||||
|
||||
public function test_the_package_page_does_not_exist_outside_the_shop(): void
|
||||
{
|
||||
$this->standaloneOffer('Starterpaket solo', 5500);
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
use App\Domain\Commerce\CartLine;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Commerce\Order;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Domain\Commerce\StaleOverview;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Models\User;
|
||||
use App\Notifications\VerifyEmailAddress;
|
||||
use Database\Seeders\ShopDemoSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Tests\Support\BuildsShop;
|
||||
@@ -40,7 +42,7 @@ public function test_a_guest_fills_the_cart_and_the_same_option_is_one_position(
|
||||
{
|
||||
$offer = $this->privateKonflikte();
|
||||
|
||||
$this->post(route('cart.add', $offer))->assertRedirect(route('public.program', $offer->composition_id));
|
||||
$this->post(route('cart.add', $offer))->assertRedirect(app(ProductOptions::class)->pageUrl($offer));
|
||||
$this->post(route('cart.add', $offer))->assertSessionHas('status');
|
||||
|
||||
$this->assertSame(1, app(Cart::class)->count());
|
||||
@@ -75,7 +77,7 @@ public function test_alternative_options_of_one_product_page_are_replaced_only_a
|
||||
$this->assertFalse(app(Cart::class)->has($club));
|
||||
|
||||
$this->withSession(['shop.switch' => $club->id])
|
||||
->get(route('public.program', $club->composition_id))
|
||||
->get(app(ProductOptions::class)->pageUrl($club))
|
||||
->assertSee('Optionen wechseln?')
|
||||
->assertSee('Zu „Mehrfachlizenz für Vereine“ wechseln')
|
||||
->assertSee('Bei „Privatlizenz“ bleiben');
|
||||
@@ -407,18 +409,50 @@ public function test_the_checkout_says_so_when_no_holder_is_allowed(): void
|
||||
->assertDontSee('Alle Positionen sind bereits erworben');
|
||||
}
|
||||
|
||||
public function test_only_options_with_a_public_product_page_can_be_put_into_the_cart(): void
|
||||
public function test_only_purchasable_options_can_be_put_into_the_cart(): void
|
||||
{
|
||||
$this->privateGrenzen()->update(['composition_id' => null]);
|
||||
$this->post(route('cart.add', $this->privateGrenzen()))->assertSessionHasErrors('shop');
|
||||
app(OfferService::class)->end($this->privateGrenzen());
|
||||
|
||||
$this->post(route('cart.add', $this->privateGrenzen()))->assertSessionHasErrors('shop');
|
||||
$this->assertSame(0, app(Cart::class)->count());
|
||||
}
|
||||
|
||||
public function test_alternatives_are_the_options_of_one_article_and_not_those_of_different_articles(): void
|
||||
{
|
||||
$cart = app(Cart::class);
|
||||
$this->assertSame(Cart::ADDED, $cart->add($this->privateKonflikte()));
|
||||
|
||||
$this->assertSame(Cart::ALTERNATIVE, $cart->add($this->clubKonflikte()), 'Zwei Optionen desselben Artikels sind Alternativen.');
|
||||
$this->assertSame(Cart::ADDED, $cart->add($this->privateGrenzen()), 'Ein anderer Artikel liegt zusätzlich im Warenkorb.');
|
||||
$this->assertSame(2, $cart->count());
|
||||
}
|
||||
|
||||
public function test_a_legacy_offer_with_several_positions_stays_on_its_program_page_while_that_is_shown(): void
|
||||
{
|
||||
$program = $this->program('Konflikte im Training');
|
||||
$rights = app(OfferService::class)->currentActiveVersion($this->privateKonflikte())->lines()->first()->rights;
|
||||
$offer = app(OfferService::class)->create('Altbestand');
|
||||
app(OfferService::class)->activate($offer, [
|
||||
['target' => $this->article('shop-konflikte'), 'rights' => $rights],
|
||||
['target' => $this->article('shop-grenzen'), 'rights' => $rights],
|
||||
], ['grant_kind' => 'auf_abruf', 'holder_kind' => 'person']);
|
||||
// So steht ein früher als Kauf aktivierter Altbestand in der Datenbank: mehrere Positionen, Programmseite.
|
||||
DB::table('offer_versions')->where('offer_id', $offer->id)->update(['grant_kind' => 'kauf', 'price_cents' => 1000]);
|
||||
DB::table('offers')->where('id', $offer->id)->update(['composition_id' => $program->id, 'option_label' => 'Altbestand']);
|
||||
$offer = $offer->refresh();
|
||||
|
||||
$this->assertSame('c:'.$program->id, app(ProductOptions::class)->groupKey($offer));
|
||||
$this->get(route('public.program', $program))->assertOk()->assertSee('Altbestand');
|
||||
$this->post(route('cart.add', $offer))->assertSessionDoesntHaveErrors();
|
||||
$this->assertSame(1, app(Cart::class)->count());
|
||||
|
||||
app(Cart::class)->clear();
|
||||
$program->versions()->each(fn ($version) => $version->displayEvents()->create([
|
||||
'event' => CompositionVersionDisplayEvent::REVOKED,
|
||||
'actor_id' => $this->tina()->id,
|
||||
'occurred_at' => now()->addSecond(),
|
||||
]));
|
||||
$this->post(route('cart.add', $this->privateKonflikte()))->assertSessionHasErrors('shop');
|
||||
$this->post(route('cart.add', $offer))->assertSessionHasErrors('shop');
|
||||
$this->assertSame(0, app(Cart::class)->count());
|
||||
}
|
||||
|
||||
|
||||
@@ -187,6 +187,7 @@ public function test_h_a_bundle_change_does_not_change_an_activated_offer(): voi
|
||||
$offer = app(OfferService::class)->activate(
|
||||
app(OfferService::class)->create('Programmangebot'),
|
||||
[['target' => $published, 'rights' => $rights]],
|
||||
['grant_kind' => 'kauf', 'price_cents' => 1000],
|
||||
);
|
||||
|
||||
$bundles->publish($bundle, [$first, $second]);
|
||||
@@ -213,6 +214,7 @@ public function test_publication_records_impact_and_withdrawal_restores_the_prev
|
||||
app(OfferService::class)->activate(
|
||||
app(OfferService::class)->create('Blattangebot'),
|
||||
[['target' => $article, 'rights' => $rights]],
|
||||
['grant_kind' => 'kauf', 'price_cents' => 1000],
|
||||
);
|
||||
$party = Party::query()->create([
|
||||
'type' => PartyType::Person,
|
||||
@@ -265,7 +267,7 @@ public function test_each_holder_gets_an_own_acquisition_and_one_grant_per_artic
|
||||
$offer = app(OfferService::class)->create('Kostenlos');
|
||||
app(OfferService::class)->activate($offer, [
|
||||
['target' => $article, 'rights' => $rights],
|
||||
]);
|
||||
], ['grant_kind' => 'auf_abruf']);
|
||||
|
||||
$acquisitions = [];
|
||||
|
||||
|
||||
@@ -102,10 +102,10 @@ public function test_the_scope_is_not_derived_from_purpose_price_or_discount():
|
||||
|
||||
public function test_the_product_page_tells_single_and_multi_licenses_apart(): void
|
||||
{
|
||||
$page = $this->program('Konflikte im Training');
|
||||
$page = $this->article('shop-konflikte');
|
||||
$this->variant($this->privateKonflikte(), 'Ohne Angabe', ['price_cents' => 1900]);
|
||||
|
||||
$this->get(route('public.program', $page))
|
||||
$this->get(route('shop.article', $page))
|
||||
->assertOk()
|
||||
->assertSee('Nutzerkreis')
|
||||
->assertSee('Einzellizenz · 1 Trainer')
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\CartLine;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\Offers\Pages\ListOffers;
|
||||
use App\Filament\Resources\Offers\Pages\ViewOffer;
|
||||
use App\Models\User;
|
||||
@@ -40,7 +41,7 @@ public function test_the_option_page_shows_price_in_euro_suitability_rights_cont
|
||||
->assertSee('Ehrenamtlich: Film ansehen, Film herunterladen, PDF ansehen, PDF herunterladen')
|
||||
->assertSee('Zugrunde liegender Inhalt: Konflikte im Training')
|
||||
->assertSee('Status: Öffentlich kaufbar')
|
||||
->assertSee('Produktseite: Konflikte im Training')
|
||||
->assertSee('Produktseite: öffentlich unter /shop/'.$this->article('shop-konflikte')->id)
|
||||
->assertSee('Geänderte Fassung aktivieren')
|
||||
->assertSee('Aus dem Verkauf nehmen');
|
||||
|
||||
@@ -78,7 +79,7 @@ public function test_the_mask_is_prefilled_names_the_option_and_states_the_effec
|
||||
$this->assertStringContainsString('„Abbrechen“ verwirft die Eingaben', $description);
|
||||
$this->assertSame('Fassung 2 aktivieren', $action->getModalSubmitActionLabel());
|
||||
$this->assertSame('Privatlizenz', $data['option_label']);
|
||||
$this->assertSame((string) $offer->composition_id, (string) $data['composition_id']);
|
||||
$this->assertArrayNotHasKey('composition_id', $data, 'Die Produktseite wird nicht mehr zugeordnet, sie ergibt sich aus dem Artikel.');
|
||||
$this->assertSame('person', $data['holder_kind']);
|
||||
$this->assertSame('kauf', $data['grant_kind']);
|
||||
$this->assertSame('49,00', $data['price_euro'], 'Der Preis steht in Euro, nicht in Cent.');
|
||||
@@ -125,7 +126,7 @@ public function test_activating_changes_only_this_option_and_leaves_the_others_p
|
||||
$this->assertSame(1, $untouched->versions()->count());
|
||||
$this->assertNotNull(app(Cart::class)->purchasable($untouched));
|
||||
}
|
||||
$this->get(route('public.program', $offer->composition_id))
|
||||
$this->get(app(ProductOptions::class)->pageUrl($offer))
|
||||
->assertSee('39,00 €')
|
||||
->assertSee('Privatlizenz (neu)')
|
||||
->assertSee('149,00 €');
|
||||
|
||||
@@ -32,16 +32,17 @@ public function test_the_shop_lists_products_with_the_lowest_price_and_opens_the
|
||||
->assertSee('2 Lizenzoptionen')
|
||||
->assertSee('ab 29,00 €')
|
||||
->assertSee('3 Produkte');
|
||||
$page->assertSee(route('public.program', $this->program('Konflikte im Training')), false);
|
||||
$page->assertSee(route('shop.article', $this->article('shop-konflikte')), false);
|
||||
}
|
||||
|
||||
public function test_the_shop_search_filters_and_shows_an_empty_state(): void
|
||||
{
|
||||
$this->get(route('shop', ['suche' => 'Grenzen']))
|
||||
->assertOk()
|
||||
->assertSee('Grenzen setzen im Verein')
|
||||
->assertDontSee('Konflikte im Training')
|
||||
->assertSee('1 Produkt');
|
||||
->assertSee(route('shop.article', $this->article('shop-grenzen')), false)
|
||||
->assertDontSee(route('shop.article', $this->article('shop-konflikte')), false)
|
||||
->assertSee('Paket mit 3 Inhalten', false)
|
||||
->assertSee('2 Produkte');
|
||||
|
||||
$this->get(route('shop', ['suche' => 'gibt-es-nicht']))
|
||||
->assertOk()
|
||||
@@ -51,7 +52,7 @@ public function test_the_shop_search_filters_and_shows_an_empty_state(): void
|
||||
|
||||
public function test_the_product_page_shows_content_and_options_with_price_rights_and_term(): void
|
||||
{
|
||||
$response = $this->get(route('public.program', $this->program('Konflikte im Training')))->assertOk();
|
||||
$response = $this->get(route('shop.article', $this->article('shop-konflikte')))->assertOk();
|
||||
|
||||
$response->assertSee('Konflikte erkennen, benennen und gemeinsam lösen.')
|
||||
->assertSee('Film: Film Konflikte im Training')
|
||||
@@ -74,7 +75,7 @@ public function test_a_withdrawn_option_disappears_while_the_other_options_stay_
|
||||
{
|
||||
app(OfferService::class)->end($this->privateKonflikte());
|
||||
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
$this->get(route('shop.article', $this->article('shop-konflikte')))
|
||||
->assertOk()
|
||||
->assertDontSee('Privatlizenz')
|
||||
->assertSee('Mehrfachlizenz für Vereine')
|
||||
@@ -87,9 +88,9 @@ public function test_free_and_unpriced_offers_are_not_shown_as_purchasable(): vo
|
||||
$article = $this->article('shop-konflikte');
|
||||
$rights = app(OfferService::class)->createRightsProfile('Frei', 'ehrenamtlich', ['pdf' => ['ansehen']]);
|
||||
app(OfferService::class)->activate($free, [['target' => $article, 'rights' => $rights]], ['grant_kind' => 'auf_abruf']);
|
||||
app(OfferService::class)->assignProduct($free, $this->program('Konflikte im Training')->id, 'Kostenlos testen');
|
||||
app(OfferService::class)->setOptionLabel($free, 'Kostenlos testen');
|
||||
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
$this->get(route('shop.article', $this->article('shop-konflikte')))
|
||||
->assertOk()
|
||||
->assertDontSee('Kostenlos testen');
|
||||
}
|
||||
@@ -103,10 +104,12 @@ public function test_the_shop_exists_only_with_test_payment_and_never_in_product
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
$this->get(route('cart'))->assertNotFound();
|
||||
$this->post(route('cart.add', $this->privateKonflikte()))->assertNotFound();
|
||||
$this->get(route('shop.article', $this->article('shop-konflikte')))->assertNotFound();
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training')))
|
||||
->assertOk()
|
||||
->assertDontSee('Lizenzoptionen')
|
||||
->assertDontSee('In den Warenkorb');
|
||||
->assertDontSee('In den Warenkorb')
|
||||
->assertDontSee('Zum Kaufen');
|
||||
|
||||
config(['services.payment.driver' => 'test']);
|
||||
$this->app['env'] = 'production';
|
||||
@@ -114,13 +117,62 @@ public function test_the_shop_exists_only_with_test_payment_and_never_in_product
|
||||
$this->get(route('shop'))->assertNotFound();
|
||||
}
|
||||
|
||||
public function test_an_option_without_a_product_page_is_not_listed_in_the_shop(): void
|
||||
public function test_an_article_without_a_purchasable_option_has_no_page_and_is_not_listed(): void
|
||||
{
|
||||
$this->privateGrenzen()->update(['composition_id' => null]);
|
||||
$page = route('shop.article', $this->article('shop-grenzen'), false);
|
||||
$this->get($page)->assertOk();
|
||||
$this->get(route('shop'))->assertSee($page, false);
|
||||
|
||||
$this->get(route('shop'))
|
||||
->assertOk()
|
||||
->assertDontSee('Grenzen setzen im Verein')
|
||||
->assertSee('Konflikte im Training');
|
||||
app(OfferService::class)->end($this->privateGrenzen());
|
||||
|
||||
$this->get($page)->assertNotFound();
|
||||
$this->get(route('shop'))->assertOk()->assertDontSee($page, false)->assertSee('Konflikte im Training');
|
||||
}
|
||||
|
||||
public function test_the_product_page_of_an_article_takes_its_texts_from_the_article_and_otherwise_from_its_content(): void
|
||||
{
|
||||
$article = $this->article('shop-konflikte');
|
||||
|
||||
// Ohne eigene Angabe kommt die Beschreibung aus der Redaktion des Inhalts (der Komposition).
|
||||
$this->get(route('shop.article', $article))->assertOk()
|
||||
->assertSee('Ein Film, ein Arbeitsblatt und eine Anleitung für sechs Trainingseinheiten.')
|
||||
->assertSee('Konflikte erkennen, benennen und gemeinsam lösen.');
|
||||
|
||||
// Eine eigene Angabe des Artikels überschreibt sie, ohne den Inhalt zu ändern.
|
||||
$article->forceFill(['display_title' => 'Konflikte meistern', 'summary' => 'Eigene Beschreibung des Artikels.'])->save();
|
||||
$this->get(route('shop.article', $article))->assertOk()
|
||||
->assertSee('<h1>Konflikte meistern</h1>', false)
|
||||
->assertSee('Eigene Beschreibung des Artikels.')
|
||||
->assertDontSee('Ein Film, ein Arbeitsblatt und eine Anleitung für sechs Trainingseinheiten.');
|
||||
}
|
||||
|
||||
public function test_the_article_page_shows_titles_and_structure_but_no_files_or_teaching_texts(): void
|
||||
{
|
||||
$html = $this->get(route('shop.article', $this->article('shop-konflikte')))->assertOk()->getContent();
|
||||
|
||||
$this->assertStringContainsString('Film: Film Konflikte im Training', $html);
|
||||
$this->assertStringNotContainsString('inhalte/shop-konflikte', $html, 'Dateipfade gehören nicht auf die öffentliche Seite.');
|
||||
$this->assertStringNotContainsString('film.mp4', $html);
|
||||
$this->assertStringNotContainsString('Platzhalter', $html, 'Der Inhalt der Dateien erscheint nicht.');
|
||||
$this->assertStringNotContainsString('/bereich/', $html, 'Kein Verweis in die Mitgliederbibliothek.');
|
||||
}
|
||||
|
||||
public function test_the_program_page_links_to_the_article_pages_instead_of_showing_options(): void
|
||||
{
|
||||
$program = $this->program('Konflikte im Training');
|
||||
|
||||
$this->get(route('public.program', $program))->assertOk()
|
||||
->assertSee('Zum Kaufen')
|
||||
->assertSee(route('shop.article', $this->article('shop-konflikte')), false)
|
||||
->assertDontSee('Umfang und Nutzungsrechte')
|
||||
->assertDontSee('In den Warenkorb');
|
||||
}
|
||||
|
||||
public function test_a_module_is_not_public_through_the_shop_page_of_its_article_unless_it_is_sold(): void
|
||||
{
|
||||
// Ohne kaufbare Option ist ein Artikel, auch mit veröffentlichtem Stand, nirgends öffentlich.
|
||||
$article = $this->article('shop-starter');
|
||||
$this->get(route('shop.article', $article))->assertNotFound();
|
||||
$this->get(route('shop.article', 999999))->assertNotFound();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
@@ -161,28 +162,21 @@ public function test_the_offer_page_walks_from_empty_to_findable_in_the_shop():
|
||||
$offer = app(OfferService::class)->create('Neues Angebot');
|
||||
$readiness = app(PublicationReadiness::class);
|
||||
$page = fn () => Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()]);
|
||||
$article = $this->article('shop-konflikte');
|
||||
|
||||
$page()->assertSee('Bis zur Veröffentlichung')->assertSeeText('Nächster Schritt: Artikel oder Paket, Rechte, Preis und Vergabe festlegen');
|
||||
$this->assertFalse($readiness->forOffer($offer->refresh())['bereit']);
|
||||
$this->assertNull(app(ProductOptions::class)->pageUrl($offer));
|
||||
|
||||
// Aktiv, aber ohne Produktseite: nicht im Shop.
|
||||
app(OfferService::class)->activate($offer, [['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
$page()->assertSeeText('Nächster Schritt: Produktseite zuordnen');
|
||||
$this->assertSame('Produktseite zuordnen', $readiness->forOffer($offer->refresh())['naechster']['titel']);
|
||||
|
||||
// Zugeordnet, aber Programm ohne Anzeigefreigabe: nicht auffindbar.
|
||||
$hidden = $this->hiddenProgram();
|
||||
app(OfferService::class)->assignProduct($offer, $hidden->id, 'Testoption');
|
||||
$check = $readiness->forOffer($offer->refresh());
|
||||
$this->assertSame('Produktseite öffentlich', $check['naechster']['titel']);
|
||||
$this->get('/shop')->assertOk()->assertDontSee('Testoption');
|
||||
|
||||
// Öffentliche Produktseite: bereit und im Shop.
|
||||
app(OfferService::class)->assignProduct($offer, $this->program('Konflikte im Training')->id, 'Testoption');
|
||||
// Mit der aktiven Fassung hat die Option ihre Produktseite: die Seite des Artikels, ohne dass sie zugeordnet wird.
|
||||
app(OfferService::class)->activate($offer, [['target' => $article, 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
app(OfferService::class)->setOptionLabel($offer, 'Testoption');
|
||||
$check = $readiness->forOffer($offer->refresh());
|
||||
$this->assertTrue($check['bereit']);
|
||||
$page()->assertSeeText('Alle Voraussetzungen sind erfüllt.');
|
||||
$this->get(route('public.program', $this->program('Konflikte im Training'), false))->assertOk()->assertSee('Testoption')->assertSee('39,00');
|
||||
$this->assertSame(route('shop.article', $article), app(ProductOptions::class)->pageUrl($offer));
|
||||
$page()->assertSeeText('Alle Voraussetzungen sind erfüllt.')->assertSee('öffentlich unter /shop/'.$article->id);
|
||||
$this->get(route('shop.article', $article))->assertOk()->assertSee('Testoption')->assertSee('39,00');
|
||||
$this->get('/shop')->assertOk()->assertSee(route('shop.article', $article), false);
|
||||
}
|
||||
|
||||
public function test_the_bundle_page_shows_the_steps_and_the_offer_for_the_bundle(): void
|
||||
@@ -203,9 +197,13 @@ public function test_the_bundle_page_shows_the_steps_and_the_offer_for_the_bundl
|
||||
|
||||
public function test_the_bundle_offer_lists_the_scope_and_is_found_in_the_shop(): void
|
||||
{
|
||||
$starter = $this->program('Starterpaket für neue Trainer');
|
||||
$this->get('/shop')->assertOk()->assertSee('Starterpaket für neue Trainer');
|
||||
$this->get(route('public.program', $starter, false))->assertOk()->assertSee('Starterpaket (zwei Programme und Einführung)')->assertSee('59,00');
|
||||
$bundle = Bundle::query()->where('name', 'Starterpaket')->firstOrFail();
|
||||
|
||||
$this->get('/shop')->assertOk()->assertSee(route('public.package', $bundle), false)->assertSee('Paket mit 3 Inhalten');
|
||||
$this->get(route('public.package', $bundle, false))->assertOk()
|
||||
->assertSee('Starterpaket (zwei Programme und Einführung)')
|
||||
->assertSee('Starterpaket für neue Trainer')
|
||||
->assertSee('59,00');
|
||||
}
|
||||
|
||||
public function test_the_scope_names_an_article_by_its_content_and_not_by_its_code(): void
|
||||
@@ -215,12 +213,12 @@ public function test_the_scope_names_an_article_by_its_content_and_not_by_its_co
|
||||
app(ArticleService::class)->publishRelease($article, $root, 'Erster Stand dieses Lizenzartikels.');
|
||||
$offer = app(OfferService::class)->create('Namensprobe');
|
||||
app(OfferService::class)->activate($offer, [['target' => $article->refresh(), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 1500, 'holder_kind' => 'person']);
|
||||
app(OfferService::class)->assignProduct($offer, $this->program('Grenzen setzen im Verein')->id, 'Namensprobe');
|
||||
app(OfferService::class)->setOptionLabel($offer, 'Namensprobe');
|
||||
|
||||
$scope = collect(app(ProductOptions::class)->forComposition($this->program('Grenzen setzen im Verein')))->firstWhere('name', 'Namensprobe')['scope'];
|
||||
$scope = collect(app(ProductOptions::class)->forArticle($article))->firstWhere('name', 'Namensprobe')['scope'];
|
||||
|
||||
$this->assertSame('Grenzen setzen im Verein', $scope[0]['article']);
|
||||
$this->get(route('public.program', $this->program('Grenzen setzen im Verein'), false))->assertOk()->assertDontSee('nur-kennung-abnahme');
|
||||
$this->get(route('shop.article', $article))->assertOk()->assertDontSee('nur-kennung-abnahme');
|
||||
$this->assertStringContainsString('Grenzen setzen im Verein (nur-kennung-abnahme) · Stand 1', app(PublicationReadiness::class)->articleOptions()[$article->id]);
|
||||
}
|
||||
|
||||
@@ -241,39 +239,54 @@ private function rights(): RightsProfileVersion
|
||||
return RightsProfileVersion::query()->orderBy('id')->firstOrFail();
|
||||
}
|
||||
|
||||
public function test_the_product_page_choices_say_which_ones_the_shop_can_show(): void
|
||||
public function test_a_purchase_with_several_positions_is_refused_and_points_to_the_package(): void
|
||||
{
|
||||
$hidden = $this->hiddenProgram();
|
||||
$module = app(ContentService::class)->createComposition('Bündel-Modul');
|
||||
$module->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'modul')->value('id');
|
||||
$module->save();
|
||||
|
||||
$method = new \ReflectionMethod(ViewOffer::class, 'productPages');
|
||||
$choices = $method->invoke(app(ViewOffer::class));
|
||||
|
||||
$this->assertStringContainsString('nur für ein Angebot aus genau einer Paketfassung', $choices['__paket']);
|
||||
$this->assertStringContainsString('im Shop auffindbar', $choices[$this->program('Konflikte im Training')->id]);
|
||||
$this->assertStringContainsString('noch nicht zur Anzeige freigegeben', $choices[$hidden->id]);
|
||||
$this->assertStringContainsString('kein Programm', $choices[$module->id]);
|
||||
$this->assertStringContainsString('nur Programme', $choices[$module->id]);
|
||||
}
|
||||
|
||||
public function test_an_own_bundle_page_for_a_licence_article_is_refused_with_the_way_forward(): void
|
||||
{
|
||||
$offer = app(OfferService::class)->create('Bündel als Artikel');
|
||||
app(OfferService::class)->assignProduct($offer, null, null, true);
|
||||
$offer = app(OfferService::class)->create('Mehrere Artikel');
|
||||
$positions = [
|
||||
['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()],
|
||||
['target' => $this->article('shop-grenzen'), 'rights' => $this->rights()],
|
||||
];
|
||||
|
||||
try {
|
||||
app(OfferService::class)->activate($offer->refresh(), [['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
$this->fail('Ein Lizenzartikel darf keine eigene Paketseite bekommen.');
|
||||
app(OfferService::class)->activate($offer, $positions, ['grant_kind' => 'kauf', 'price_cents' => 3900, 'holder_kind' => 'person']);
|
||||
$this->fail('Ein Kauf mit mehreren Positionen hätte keine Produktseite.');
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->assertStringContainsString('Katalog → Pakete', $e->getMessage());
|
||||
$this->assertStringContainsString('Programm', $e->getMessage());
|
||||
$this->assertStringContainsString('Paket', $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame(0, $offer->versions()->count());
|
||||
}
|
||||
|
||||
public function test_a_purchase_without_a_price_cannot_be_activated(): void
|
||||
{
|
||||
$offer = app(OfferService::class)->create('Ohne Preis');
|
||||
|
||||
foreach ([null, 0] as $price) {
|
||||
try {
|
||||
app(OfferService::class)->activate($offer, [['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()]], ['grant_kind' => 'kauf', 'price_cents' => $price, 'holder_kind' => 'person']);
|
||||
$this->fail('Ein Kauf ohne Preis ist nicht kaufbar.');
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->assertStringContainsString('Preis', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertSame(0, $offer->versions()->count());
|
||||
}
|
||||
|
||||
public function test_grants_at_registration_and_on_demand_stay_possible_but_are_not_in_the_shop(): void
|
||||
{
|
||||
foreach (['bei_registrierung', 'auf_abruf'] as $kind) {
|
||||
$offer = app(OfferService::class)->create('Ohne Shop '.$kind);
|
||||
app(OfferService::class)->activate($offer, [
|
||||
['target' => $this->article('shop-konflikte'), 'rights' => $this->rights()],
|
||||
['target' => $this->article('shop-grenzen'), 'rights' => $this->rights()],
|
||||
], ['grant_kind' => $kind, 'holder_kind' => 'person']);
|
||||
|
||||
$this->assertNull(app(OfferService::class)->purchasableVersion($offer->refresh()));
|
||||
$this->assertNull(app(ProductOptions::class)->pageUrl($offer));
|
||||
}
|
||||
}
|
||||
|
||||
private function hiddenProgram(): Composition
|
||||
{
|
||||
$composition = app(ContentService::class)->createComposition('Unveröffentlichtes Programm');
|
||||
|
||||