Merge branch 'feature/shop-verwaltung-abnahme' into develop
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
da7ebca999
11 files changed
+677
-15
No files matched your search
@@ -11,6 +11,7 @@
|
||||
use App\Filament\Resources\Bundles\BundleResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
@@ -90,7 +91,8 @@ public function publishAction(): Action
|
||||
->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' veröffentlichen')
|
||||
->fillForm(fn (): array => $this->formFromPublished())
|
||||
->schema([
|
||||
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => CatalogOptions::articles()),
|
||||
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => app(PublicationReadiness::class)->articleOptions())
|
||||
->helperText('Artikel ohne Stand lassen sich aufnehmen, aber erst verkaufen, wenn sie einen Inhalt haben.'),
|
||||
CheckboxList::make('bundles')->label('Enthaltene Pakete')
|
||||
->options(function (): array {
|
||||
$options = CatalogOptions::bundles();
|
||||
@@ -115,7 +117,12 @@ public function publishAction(): Action
|
||||
|
||||
$version = app(BundleService::class)->publish($bundle, $items);
|
||||
|
||||
return 'Fassung '.$version->number.' ist veröffentlicht.';
|
||||
$bundle->unsetRelations();
|
||||
$readiness = app(PublicationReadiness::class)->forBundle($bundle->refresh());
|
||||
|
||||
return 'Fassung '.$version->number.' ist veröffentlicht.'.($readiness['naechster'] !== null
|
||||
? ' Nächster Schritt: '.$readiness['naechster']['titel'].'.'
|
||||
: '');
|
||||
}, 'Die Paketfassung ist veröffentlicht.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
@@ -164,6 +171,7 @@ private function paketDaten(): array
|
||||
'art' => 'primary',
|
||||
]],
|
||||
],
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forBundle($bundle),
|
||||
'haupt' => [
|
||||
[
|
||||
'titel' => 'Bestandteile',
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ListLicenseArticles;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -57,6 +58,7 @@ public static function infolist(Schema $schema): Schema
|
||||
->viewData(fn (LicenseArticle $record): array => [
|
||||
'stand' => app(CatalogReading::class)->articleStand($record),
|
||||
'kontext' => app(CatalogReading::class)->articleContext($record),
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forArticle($record),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
|
||||
@@ -330,12 +330,28 @@ protected function getHeaderActions(): array
|
||||
public function releaseAction(): Action
|
||||
{
|
||||
return Action::make('release')
|
||||
->label('Stand veröffentlichen')
|
||||
->label(fn (): string => $this->isFirstStand() ? 'Inhalt festlegen' : 'Neuen Stand veröffentlichen')
|
||||
->modalHeading(fn (): string => $this->isFirstStand() ? 'Inhalt festlegen: ersten Stand veröffentlichen' : 'Neuen Stand veröffentlichen')
|
||||
->modalDescription(fn (): string => $this->isFirstStand()
|
||||
? 'Der Stand legt fest, welche Inhalte dieser Lizenzartikel lizenziert: der gewählte Inhalt samt allem, was er enthält. Er ist danach unveränderlich. Pakete und Angebote können den Artikel danach verwenden; verkauft wird er erst über ein Angebot.'
|
||||
: 'Ein neuer Stand ersetzt den aktuellen für künftige Ausgaben. Bestehende Käufer erhalten ihn im Rahmen ihrer Lizenz; frühere Stände bleiben gespeichert.')
|
||||
->modalSubmitActionLabel('Stand veröffentlichen')
|
||||
->fillForm(fn (): array => $this->isFirstStand() ? ['classification' => 'Erster Stand dieses Lizenzartikels.'] : [])
|
||||
->schema([
|
||||
Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||
Textarea::make('classification')->label('Einordnung')->required()
|
||||
->helperText('Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||
TextInput::make('change_note')->label('Änderungshinweis'),
|
||||
Select::make('root')->label('Freigegebener Inhalt')
|
||||
->options(fn (): array => CatalogOptions::assignmentTargets())
|
||||
->searchable()
|
||||
->required()
|
||||
->helperText(fn (): string => CatalogOptions::assignmentTargets() === []
|
||||
? 'Es gibt noch keinen freigegebenen Inhalt. Gib zuerst ein Medium, Modul oder Programm frei.'
|
||||
: 'Medien, Module und Programme mit freigegebener Fassung. Bei Modulen und Programmen gehört alles Enthaltene zum Stand.'),
|
||||
Textarea::make('classification')->label('Einordnung')
|
||||
->required(fn (): bool => ! $this->isFirstStand())
|
||||
->helperText(fn (): string => $this->isFirstStand()
|
||||
? 'Beim ersten Stand genügt der vorgegebene Text.'
|
||||
: 'Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||
TextInput::make('change_note')->label('Änderungshinweis')
|
||||
->visible(fn (): bool => ! $this->isFirstStand()),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
@@ -348,7 +364,7 @@ public function releaseAction(): Action
|
||||
$release = app(ArticleService::class)->publishRelease(
|
||||
$article,
|
||||
$root,
|
||||
$data['classification'],
|
||||
(string) ($data['classification'] ?? 'Erster Stand dieses Lizenzartikels.'),
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
$report = $release->impact_report ?? [];
|
||||
@@ -383,6 +399,11 @@ public function withdrawAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
private function isFirstStand(): bool
|
||||
{
|
||||
return ! $this->getRecord()->releases()->exists();
|
||||
}
|
||||
|
||||
private function refreshRecord(): void
|
||||
{
|
||||
$this->getRecord()->unsetRelations();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Offers\Pages;
|
||||
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
@@ -13,11 +14,13 @@
|
||||
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\Resources\Offers\OfferResource;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -141,9 +144,12 @@ public function activateAction(): Action
|
||||
'article' => 'Lizenzartikel',
|
||||
'bundle' => 'Paketfassung',
|
||||
])->required()->live(),
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => app(PublicationReadiness::class)->articleOptions())
|
||||
->searchable()
|
||||
->helperText('Nur Artikel mit veröffentlichtem Stand lassen sich verkaufen. Artikel ohne Stand sind gekennzeichnet.')
|
||||
->visible(fn (Get $get): bool => $get('kind') === 'article'),
|
||||
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => CatalogOptions::bundleVersions())
|
||||
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => app(PublicationReadiness::class)->bundleVersionOptions())
|
||||
->searchable()
|
||||
->visible(fn (Get $get): bool => $get('kind') === 'bundle'),
|
||||
Select::make('rights_id')->label('Rechte')->options(fn (): array => CatalogOptions::rights())->required(),
|
||||
])->minItems(1)->addActionLabel('Position hinzufügen'),
|
||||
@@ -164,6 +170,20 @@ public function activateAction(): Action
|
||||
];
|
||||
}
|
||||
|
||||
// Voraussetzung: Jeder Artikel der Positionen hat einen veröffentlichten Stand, sonst erhielten Käufer nichts.
|
||||
$articleIds = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$target = $line['target'];
|
||||
array_push($articleIds, ...($target instanceof BundleVersion ? app(BundleService::class)->articleIds($target) : [$target->id]));
|
||||
}
|
||||
|
||||
$unusable = app(PublicationReadiness::class)->unusableArticles($articleIds);
|
||||
|
||||
if ($unusable !== []) {
|
||||
throw new DomainRuleException(app(PublicationReadiness::class)->unusableMessage($unusable, 'das Angebot aktivierst'));
|
||||
}
|
||||
|
||||
// Bedingungen, die die Maske nicht zeigt, bleiben bei einer Änderung die der aktiven Fassung.
|
||||
$active = $this->activeVersion();
|
||||
$kept = $active === null ? [] : [
|
||||
@@ -194,7 +214,12 @@ public function activateAction(): Action
|
||||
]);
|
||||
});
|
||||
|
||||
return 'Fassung '.$version->number.' ist aktiv. Die Option ist in dieser Fassung öffentlich kaufbar.';
|
||||
$offer->unsetRelations();
|
||||
$readiness = app(PublicationReadiness::class)->forOffer($offer->refresh());
|
||||
|
||||
return 'Fassung '.$version->number.' ist aktiv.'.($readiness['bereit']
|
||||
? ' Die Option ist öffentlich kaufbar und im Shop auffindbar.'
|
||||
: ' Noch nicht im Shop kaufbar. Nächster Schritt: '.$readiness['naechster']['titel'].'.');
|
||||
}, 'Die Angebotsfassung ist aktiv.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
@@ -240,14 +265,18 @@ private function productPageSuffix(): string
|
||||
*/
|
||||
private function productPages(): array
|
||||
{
|
||||
$catalog = app(PublicCatalogReader::class);
|
||||
|
||||
return Composition::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->orderBy('designation')
|
||||
->get()
|
||||
->sortBy(fn (Composition $composition): int => $catalog->shownVersion($composition) !== null ? 0 : 1)
|
||||
->mapWithKeys(fn (Composition $composition): array => [
|
||||
$composition->id => ($composition->display_title ?: $composition->designation)
|
||||
.' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')',
|
||||
.' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')'
|
||||
.($catalog->shownVersion($composition) !== null ? ' · im Shop auffindbar' : ' · nicht öffentlich, im Shop nicht auffindbar'),
|
||||
])
|
||||
->all();
|
||||
}
|
||||
@@ -320,6 +349,7 @@ private function angebotDaten(): array
|
||||
]] : []),
|
||||
],
|
||||
],
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forOffer($offer),
|
||||
'haupt' => [
|
||||
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
|
||||
[
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleStatus;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
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\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Voraussetzungen bis zur Veröffentlichung für Lizenzartikel, Paket und Angebot in einer gemeinsamen Form
|
||||
* (Verwaltungsstandard 14, Abschnitt 9: eine Komponente für gleiche Aufgaben). Die Klasse liest nur; sie ändert keine
|
||||
* fachliche Regel. Jeder Schritt nennt, was fehlt, und bietet den Weg dorthin an.
|
||||
*
|
||||
* Schritt: ['titel', 'text', 'stand' => erledigt|offen|optional, 'aktion' => ['label', 'wire'|'href']|null]
|
||||
* Ergebnis: ['schritte', 'bereit' (alle Pflichtschritte erledigt), 'naechster' (Text des ersten offenen Pflichtschritts)].
|
||||
*/
|
||||
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. */
|
||||
public function articleUsable(LicenseArticle $article): bool
|
||||
{
|
||||
$release = $article->currentRelease;
|
||||
|
||||
return $release instanceof ArticleRelease && StatusValue::of($release->status) === ReleaseStatus::Veroeffentlicht->value;
|
||||
}
|
||||
|
||||
/** Anzeige in Auswahllisten: Name, Kennung und Stand statt der bloßen Kennung. */
|
||||
public function articleLabel(LicenseArticle $article): string
|
||||
{
|
||||
$title = trim((string) ($article->display_title ?: $article->working_title));
|
||||
$name = $title !== '' ? $title.' ('.$article->code.')' : (string) $article->code;
|
||||
$release = $article->currentRelease;
|
||||
|
||||
if ($this->articleUsable($article)) {
|
||||
return $name.' · Stand '.$release->number;
|
||||
}
|
||||
|
||||
return $name.' · '.($release === null ? 'noch ohne Stand, nicht verwendbar' : 'Stand gesperrt, nicht verwendbar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function articleOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (LicenseArticle::query()->with('currentRelease')->orderBy('code')->get() as $article) {
|
||||
$options[$article->id] = $this->articleLabel($article);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Veröffentlichte Paketfassungen mit ihren Artikeln, damit die Auswahl zeigt, was verkauft wird.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function bundleVersionOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (BundleVersion::query()->where('status', BundleStatus::Veroeffentlicht)->with('bundle')->orderBy('id')->get() as $version) {
|
||||
try {
|
||||
$codes = LicenseArticle::query()->whereIn('id', $this->bundles->articleIds($version))->orderBy('code')->pluck('code')->all();
|
||||
} catch (DomainRuleException) {
|
||||
$codes = [];
|
||||
}
|
||||
|
||||
$options[$version->id] = $version->bundle->name.' · Fassung '.$version->number.' ('.($codes === [] ? 'ohne Artikel' : implode(', ', $codes)).')';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Artikel einer Auswahl, die keinen verwendbaren Stand haben.
|
||||
*
|
||||
* @param list<int> $articleIds
|
||||
* @return list<LicenseArticle>
|
||||
*/
|
||||
public function unusableArticles(array $articleIds): array
|
||||
{
|
||||
return LicenseArticle::query()->with('currentRelease')->whereIn('id', array_unique($articleIds))->orderBy('code')->get()
|
||||
->reject(fn (LicenseArticle $article): bool => $this->articleUsable($article))
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<LicenseArticle> $articles
|
||||
*/
|
||||
public function unusableMessage(array $articles, string $zweck): string
|
||||
{
|
||||
$namen = implode(', ', array_map(fn (LicenseArticle $article): string => '„'.($article->display_title ?: $article->working_title ?: $article->code).'“ ('.$article->code.')', $articles));
|
||||
|
||||
return (count($articles) === 1 ? 'Der Lizenzartikel ' : 'Die Lizenzartikel ').$namen
|
||||
.(count($articles) === 1 ? ' hat' : ' haben')
|
||||
.' noch keinen veröffentlichten Stand und vergibt'.(count($articles) === 1 ? '' : ' keine').' keine Inhalte. '
|
||||
.'Lege zuerst am Artikel mit „Inhalt festlegen“ den Inhalt fest, bevor du '.$zweck.'.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forArticle(LicenseArticle $article): array
|
||||
{
|
||||
$article->loadMissing('currentRelease');
|
||||
$usable = $this->articleUsable($article);
|
||||
$release = $article->currentRelease;
|
||||
$inUse = $this->articleInUse($article);
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Inhalt festlegen',
|
||||
'text' => $usable
|
||||
? 'Stand '.$release->number.' ist veröffentlicht und bestimmt, welche Inhalte der Artikel lizenziert.'
|
||||
: 'Der Artikel lizenziert noch nichts. Wähle den freigegebenen Inhalt (Medium, Modul oder Programm), den er umfassen soll.',
|
||||
'stand' => $usable ? 'erledigt' : 'offen',
|
||||
'aktion' => $usable ? null : ['label' => 'Inhalt festlegen', 'wire' => "mountAction('release')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'Name und Beschreibung',
|
||||
'text' => filled($article->display_title)
|
||||
? 'Der Name „'.$article->display_title.'“ erscheint in Paketen, Angeboten und der Bibliothek.'
|
||||
: 'Ohne eigenen Namen erscheint die Kennung „'.$article->code.'“. Name, Teaser und Beschreibung pflegst du in der Redaktion.',
|
||||
'stand' => filled($article->display_title) ? 'erledigt' : 'optional',
|
||||
'aktion' => filled($article->display_title) ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'In einem Paket oder Angebot verwenden',
|
||||
'text' => $inUse
|
||||
? 'Der Artikel ist in einem Paket oder Angebot enthalten.'
|
||||
: 'Verkauft wird der Artikel erst über ein Angebot, allein oder in einem Paket.',
|
||||
'stand' => $inUse ? 'erledigt' : 'offen',
|
||||
'aktion' => $inUse ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
||||
'pflicht' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forBundle(Bundle $bundle): array
|
||||
{
|
||||
$published = $bundle->versions()->where('status', BundleStatus::Veroeffentlicht)->orderByDesc('number')->first();
|
||||
$missing = [];
|
||||
|
||||
if ($published instanceof BundleVersion) {
|
||||
try {
|
||||
$missing = $this->unusableArticles($this->bundles->articleIds($published));
|
||||
} catch (DomainRuleException) {
|
||||
$missing = [];
|
||||
}
|
||||
}
|
||||
|
||||
$offered = $published instanceof BundleVersion && $this->bundleOffered($bundle);
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Bestandteile festlegen',
|
||||
'text' => $published instanceof BundleVersion
|
||||
? 'Fassung '.$published->number.' ist veröffentlicht und unveränderlich.'
|
||||
: 'Wähle die Lizenzartikel und Pakete, die zusammen verkauft werden, und veröffentliche die Fassung.',
|
||||
'stand' => $published instanceof BundleVersion ? 'erledigt' : 'offen',
|
||||
'aktion' => $published instanceof BundleVersion ? null : ['label' => 'Bestandteile festlegen', 'wire' => "mountAction('publish')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'Jeder enthaltene Artikel hat einen Inhalt',
|
||||
'text' => ! $published instanceof BundleVersion
|
||||
? 'Wird geprüft, sobald die Bestandteile feststehen.'
|
||||
: ($missing === []
|
||||
? 'Alle enthaltenen Artikel haben einen veröffentlichten Stand.'
|
||||
: 'Ohne Stand und damit ohne Inhalt: '.implode(', ', array_map(fn (LicenseArticle $article): string => (string) $article->code, $missing)).'. Ein Angebot lässt sich erst aktivieren, wenn jeder Artikel einen Stand hat.'),
|
||||
'stand' => $published instanceof BundleVersion && $missing === [] ? 'erledigt' : 'offen',
|
||||
'aktion' => $missing === [] ? null : ['label' => 'Artikel „'.$missing[0]->code.'“ öffnen', 'href' => LicenseArticleResource::getUrl('view', ['record' => $missing[0]])],
|
||||
],
|
||||
[
|
||||
'titel' => 'Angebot mit Preis und Rechten',
|
||||
'text' => $offered
|
||||
? 'Ein aktives Angebot verkauft dieses Paket.'
|
||||
: 'Verkauft wird das Paket erst über ein Angebot. Dort wählst du die Paketfassung, die Rechte und den Preis.',
|
||||
'stand' => $offered ? 'erledigt' : 'offen',
|
||||
'aktion' => $offered ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
||||
'pflicht' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forOffer(Offer $offer): array
|
||||
{
|
||||
$active = $offer->versions()->where('status', 'aktiv')->orderByDesc('number')->first();
|
||||
$hasActive = $active instanceof OfferVersion;
|
||||
$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;
|
||||
$shown = $page !== null && $this->catalog->shownVersion($page) !== null;
|
||||
$pageName = $page !== null ? (string) ($page->display_title ?: $page->designation) : '';
|
||||
$activate = ['label' => $hasActive ? 'Geänderte Fassung aktivieren' : 'Angebot konfigurieren', 'wire' => "mountAction('activate')"];
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Artikel oder Paket, Rechte, Preis und Vergabe festlegen',
|
||||
'text' => $hasActive
|
||||
? 'Fassung '.$active->number.' ist aktiv.'
|
||||
: 'Wähle, was verkauft wird (Lizenzartikel oder Paketfassung), welche Nutzungsrechte dazugehören, für wen es gilt und was es kostet. Erst „Fassung aktivieren“ macht das Angebot gültig.',
|
||||
'stand' => $hasActive ? 'erledigt' : 'offen',
|
||||
'aktion' => $hasActive ? null : $activate,
|
||||
],
|
||||
[
|
||||
'titel' => 'Inhalt vorhanden',
|
||||
'text' => ! $hasActive
|
||||
? 'Wird geprüft, sobald die Fassung aktiv ist.'
|
||||
: ($missing === []
|
||||
? 'Jeder enthaltene Lizenzartikel hat einen veröffentlichten Stand.'
|
||||
: 'Ohne Stand und damit ohne Inhalt: '.implode(', ', array_map(fn (LicenseArticle $article): string => (string) $article->code, $missing)).'. Käufer würden nichts erhalten.'),
|
||||
'stand' => $hasActive && $missing === [] ? 'erledigt' : 'offen',
|
||||
'aktion' => $missing === [] ? null : ['label' => 'Artikel „'.$missing[0]->code.'“ öffnen', 'href' => LicenseArticleResource::getUrl('view', ['record' => $missing[0]])],
|
||||
],
|
||||
[
|
||||
'titel' => 'Als Kauf mit Preis angeboten',
|
||||
'text' => $buyable
|
||||
? 'Die aktive Fassung ist ein Kauf zu '.Money::format((int) $active->price_cents).'.'
|
||||
: ($hasActive ? 'Die aktive Fassung ist kein Kauf mit Preis (Vergabe: '.CatalogLabels::vergabe($active).'). Im Shop erscheinen nur Käufe.' : 'Wird mit der Fassung festgelegt.'),
|
||||
'stand' => $buyable ? 'erledigt' : 'offen',
|
||||
'aktion' => $buyable ? null : ($hasActive ? $activate : null),
|
||||
],
|
||||
[
|
||||
'titel' => 'Produktseite zuordnen',
|
||||
'text' => $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 braucht eine eigene Produktseite, sonst ist es Alternative zu den Einzelangeboten dieser Seite.',
|
||||
'stand' => $page !== null ? 'erledigt' : 'offen',
|
||||
'aktion' => $page !== null ? null : $activate,
|
||||
],
|
||||
[
|
||||
'titel' => 'Produktseite öffentlich',
|
||||
'text' => $page === null
|
||||
? 'Wird geprüft, sobald eine Produktseite zugeordnet 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)],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $schritte
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function result(array $schritte): array
|
||||
{
|
||||
$schritte = array_map(fn (array $schritt): array => ['pflicht' => true, 'aktion' => null, ...$schritt], $schritte);
|
||||
$naechster = null;
|
||||
|
||||
foreach ($schritte as $schritt) {
|
||||
if ($schritt['pflicht'] && $schritt['stand'] === 'offen') {
|
||||
$naechster = $schritt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'schritte' => $schritte,
|
||||
'bereit' => $naechster === null,
|
||||
'naechster' => $naechster,
|
||||
];
|
||||
}
|
||||
|
||||
private function articleInUse(LicenseArticle $article): bool
|
||||
{
|
||||
return DB::table('offer_lines')->where('license_article_id', $article->id)->exists()
|
||||
|| DB::table('bundle_items')->where('license_article_id', $article->id)->exists();
|
||||
}
|
||||
|
||||
private function bundleOffered(Bundle $bundle): bool
|
||||
{
|
||||
return DB::table('offer_lines')
|
||||
->join('offer_versions', 'offer_versions.id', '=', 'offer_lines.offer_version_id')
|
||||
->join('bundle_versions', 'bundle_versions.id', '=', 'offer_lines.bundle_version_id')
|
||||
->where('bundle_versions.bundle_id', $bundle->id)
|
||||
->where('offer_versions.status', 'aktiv')
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
Begleitinformation rechts. Parameter:
|
||||
kopf Parameter für filament.verwaltung.kopf
|
||||
haupt Liste ['titel', 'zusatz' => kleiner Titelzusatz, 'hilfe', 'zeilen' => [['text', 'neben']], 'leer' => ['titel', 'text']]
|
||||
voraussetzungen optional: Ergebnis von PublicationReadiness, erscheint als „Bis zur Veröffentlichung“ über den Abschnitten
|
||||
seite Liste ['titel', 'zeilen' => [['text', 'zustand' => ['label', 'ton'], 'neben']], 'hilfe', 'leer' => Text]
|
||||
--}}
|
||||
<div class="vw">
|
||||
@@ -10,6 +11,9 @@
|
||||
|
||||
<div class="vw-medien-raster vw-katalogobjekt">
|
||||
<div class="vw-medien-haupt">
|
||||
@if (! empty($voraussetzungen))
|
||||
@include('filament.verwaltung.voraussetzungen', ['voraussetzungen' => $voraussetzungen])
|
||||
@endif
|
||||
@foreach ($haupt as $abschnitt)
|
||||
<section class="vw-katalog-abschnitt" aria-labelledby="abschnitt-{{ $loop->index }}">
|
||||
<h2 id="abschnitt-{{ $loop->index }}" class="vw-abschnitt-titel">{{ $abschnitt['titel'] }}@if (filled($abschnitt['zusatz'] ?? null)) <span class="vw-rolle-zahl">· {{ $abschnitt['zusatz'] }}</span>@endif</h2>
|
||||
|
||||
@@ -9,11 +9,15 @@
|
||||
$titel = $this->redaktionTitel();
|
||||
$offen = $this->redaktionOffen();
|
||||
$aktionen = [];
|
||||
$ohneStand = ! $artikel->current_release_id;
|
||||
if ($ohneStand) {
|
||||
$aktionen[] = ['label' => 'Inhalt festlegen', 'wire' => "mountAction('release')", 'art' => 'primary'];
|
||||
}
|
||||
if ($this->canEditEditorial()) {
|
||||
$aktionen[] = ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')", 'art' => 'line', 'icon' => 'stift'];
|
||||
$aktionen[] = ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')", 'art' => $ohneStand ? 'line' : 'line', 'icon' => 'stift'];
|
||||
}
|
||||
$mehr = [
|
||||
['label' => 'Stand veröffentlichen', 'wire' => "mountAction('release')", 'hinweis' => 'Neuer Artikelstand aus einer freigegebenen Fassung.'],
|
||||
['label' => $ohneStand ? 'Inhalt festlegen' : 'Neuen Stand veröffentlichen', 'wire' => "mountAction('release')", 'hinweis' => $ohneStand ? 'Freigegebenen Inhalt wählen, den der Artikel lizenziert.' : 'Neuer Artikelstand aus einer freigegebenen Fassung.'],
|
||||
['label' => 'Stand zurückziehen', 'wire' => "mountAction('withdraw')", 'hinweis' => 'Rechtlich notwendiger Rückzug mit Begründung.', 'gefahr' => true],
|
||||
];
|
||||
@endphp
|
||||
@@ -63,6 +67,7 @@
|
||||
@endif
|
||||
</section>
|
||||
<aside class="vw-spalte">
|
||||
@include('filament.verwaltung.voraussetzungen', ['voraussetzungen' => $voraussetzungen])
|
||||
<section class="vw-karte-box" aria-labelledby="artikel-stand">
|
||||
<h2 id="artikel-stand">Aktueller Stand</h2>
|
||||
<ul style="margin: 0; padding-left: 1.1rem; display: grid; gap: 0.25rem;">
|
||||
|
||||
@@ -332,6 +332,13 @@
|
||||
.vw-katalog-abschnitt + .vw-katalog-abschnitt { margin-top: 1.25rem; }
|
||||
.vw-verwendung h3 { font-size: 1.05rem; margin-top: 0.5rem; }
|
||||
.vw-verwendungsliste { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--vw-line); }
|
||||
.vw-schritte { counter-reset: schritt; }
|
||||
.vw-schritt { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.2rem 1rem; align-items: start; }
|
||||
.vw-schritt-kopf { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; grid-column: 1; }
|
||||
.vw-schritt-text { grid-column: 1; max-width: 60rem; }
|
||||
.vw-schritt .vw-btn { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
|
||||
.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-vorschaubild.is-gross { max-width: 40rem; }
|
||||
.vw-trennlinie { padding-top: 0.85rem; border-top: 1px solid var(--vw-line); }
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
{{--
|
||||
Gemeinsamer Baustein „Bis zur Veröffentlichung“ für Lizenzartikel, Paket und Angebot. Der Zustand steht als Text
|
||||
und Symbol, nie allein als Farbe. Parameter:
|
||||
voraussetzungen Ergebnis von App\Filament\Support\PublicationReadiness (schritte, bereit, naechster)
|
||||
abschnittTitel Abschnittstitel (Standard: Bis zur Veröffentlichung)
|
||||
--}}
|
||||
@php
|
||||
$abschnittTitel = $abschnittTitel ?? 'Bis zur Veröffentlichung';
|
||||
$schritte = $voraussetzungen['schritte'] ?? [];
|
||||
$naechster = $voraussetzungen['naechster'] ?? null;
|
||||
@endphp
|
||||
<section class="vw-katalog-abschnitt vw-voraussetzungen" aria-labelledby="voraussetzungen-titel">
|
||||
<h2 id="voraussetzungen-titel" class="vw-abschnitt-titel">{{ $abschnittTitel }}</h2>
|
||||
@if ($naechster)
|
||||
<p class="vw-feld-hilfe"><strong>Nächster Schritt:</strong> {{ $naechster['titel'] }}.</p>
|
||||
@else
|
||||
<p class="vw-feld-hilfe"><strong>Alle Voraussetzungen sind erfüllt.</strong></p>
|
||||
@endif
|
||||
<ol class="vw-verwendungsliste vw-schritte">
|
||||
@foreach ($schritte as $schritt)
|
||||
@php
|
||||
$erledigt = $schritt['stand'] === 'erledigt';
|
||||
$optional = ! ($schritt['pflicht'] ?? true) || $schritt['stand'] === 'optional';
|
||||
$marke = $erledigt ? 'Erledigt' : ($optional ? 'Empfohlen' : 'Offen');
|
||||
@endphp
|
||||
<li @class(['vw-schritt', 'is-erledigt' => $erledigt])>
|
||||
<span class="vw-schritt-kopf">
|
||||
@include('filament.verwaltung.icon', ['name' => $erledigt ? 'ok' : ($optional ? 'info' : 'achtung')])
|
||||
<strong>{{ $schritt['titel'] }}</strong>
|
||||
<span @class(['vw-zustand', 'is-gut' => $erledigt, 'is-offen' => ! $erledigt && ! $optional])>{{ $marke }}</span>
|
||||
</span>
|
||||
<span class="vw-feld-hilfe vw-schritt-text">{{ $schritt['text'] }}</span>
|
||||
@if (! empty($schritt['aktion']))
|
||||
@if (! empty($schritt['aktion']['href']))
|
||||
<a class="vw-btn is-small {{ $erledigt ? '' : 'is-line' }}" href="{{ $schritt['aktion']['href'] }}">{{ $schritt['aktion']['label'] }}</a>
|
||||
@else
|
||||
<button type="button" class="vw-btn is-small is-line" wire:click="{{ $schritt['aktion']['wire'] }}">{{ $schritt['aktion']['label'] }}</button>
|
||||
@endif
|
||||
@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
</section>
|
||||
@@ -114,12 +114,13 @@ public function test_a_second_ordering_member_of_the_same_club_gets_nothing_from
|
||||
|
||||
public function test_membership_boundaries_decide_the_club_access(): void
|
||||
{
|
||||
// Feste Uhrzeit vor der Bestellung, damit die Berechtigung nicht erst nach dem Testzeitpunkt beginnt.
|
||||
$this->travelTo(now()->startOfDay()->addHours(12));
|
||||
$vera = $this->vera();
|
||||
app(Checkout::class)->confirmTestPayment($this->orderOf($vera, [$this->clubKonflikte()]), 'test-verein');
|
||||
[$article, $release, $film] = $this->parts();
|
||||
$membership = fn () => Membership::query()->where(['user_id' => $vera->id, 'party_id' => $this->club()->id]);
|
||||
$allowed = fn (): bool => app(DecideAccess::class)($vera, $article, $release, $film, 'laden')->allowed;
|
||||
$this->travelTo(now()->startOfDay()->addHours(12));
|
||||
|
||||
$membership()->update(['valid_until' => today()]);
|
||||
$this->assertTrue($allowed(), 'Der letzte Tag gilt noch.');
|
||||
|
||||
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Filament\Resources\Bundles\Pages\ViewBundle;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Etappe 1, Nachbesserung der Shop-Verwaltung: Aus „Name angelegt“ führt die Oberfläche bis zum kaufbaren Angebot.
|
||||
* Geprüft werden die gemeinsame Anzeige der Voraussetzungen (Artikel, Paket, Angebot), der verständliche Dialog für den
|
||||
* ersten Artikelstand, die gekennzeichnete Auswahl und die Absicherung gegen Artikel ohne Inhalt.
|
||||
*/
|
||||
class ShopVerwaltungAbnahmeTest extends TestCase
|
||||
{
|
||||
use BuildsShop;
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedShop();
|
||||
}
|
||||
|
||||
public function test_an_article_without_stand_names_the_next_step_and_offers_the_content_as_main_action(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('neu-ohne-stand');
|
||||
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
||||
->assertSee('Bis zur Veröffentlichung')
|
||||
->assertSeeText('Nächster Schritt:')
|
||||
->assertSee('Inhalt festlegen')
|
||||
->assertSee('Der Artikel lizenziert noch nichts');
|
||||
|
||||
$this->assertStringContainsString('wire:click="mountAction('release')"', $component->html());
|
||||
$this->assertStringContainsString('vw-btn is-primary', (string) preg_replace('/\s+/', ' ', explode('Weitere Aktionen', $component->html())[0]), 'Der Einstieg steht als Hauptaktion im Kopf, nicht nur im Menü.');
|
||||
}
|
||||
|
||||
public function test_the_first_stand_dialog_is_plain_prefilled_and_publishes(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('neu-erster-stand');
|
||||
$root = 'composition:'.$this->article('shop-grenzen')->currentRelease->root_composition_version_id;
|
||||
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
||||
->mountAction('release');
|
||||
$action = $component->instance()->getMountedAction();
|
||||
|
||||
$this->assertSame('Inhalt festlegen: ersten Stand veröffentlichen', $action->getModalHeading());
|
||||
$this->assertSame('Stand veröffentlichen', $action->getModalSubmitActionLabel());
|
||||
$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();
|
||||
$this->assertContains('Freigegebener Inhalt', $labels);
|
||||
$this->assertNotContains('Wurzel', $labels);
|
||||
$this->assertSame('Erster Stand dieses Lizenzartikels.', $component->get('mountedActions.0.data.classification'));
|
||||
|
||||
$component->fillForm(['root' => $root])->callMountedAction()->assertHasNoActionErrors();
|
||||
|
||||
$article->refresh();
|
||||
$this->assertNotNull($article->current_release_id);
|
||||
$this->assertSame('Erster Stand dieses Lizenzartikels.', $article->currentRelease->classification_note);
|
||||
$this->assertTrue(app(PublicationReadiness::class)->forArticle($article)['schritte'][0]['stand'] === 'erledigt');
|
||||
}
|
||||
|
||||
public function test_a_later_stand_still_asks_for_the_classification(): void
|
||||
{
|
||||
$article = $this->article('shop-grenzen');
|
||||
|
||||
$component = Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
||||
->mountAction('release');
|
||||
|
||||
$this->assertSame('Neuen Stand veröffentlichen', $component->instance()->getMountedAction()->getModalHeading());
|
||||
$component->fillForm(['root' => 'composition:'.$article->currentRelease->root_composition_version_id, 'classification' => ''])
|
||||
->callMountedAction()
|
||||
->assertHasActionErrors(['classification' => 'required']);
|
||||
}
|
||||
|
||||
public function test_pickers_name_articles_with_title_and_stand_and_mark_those_without_content(): void
|
||||
{
|
||||
app(ArticleService::class)->create('leer-ohne-stand');
|
||||
$options = app(PublicationReadiness::class)->articleOptions();
|
||||
|
||||
$leer = collect($options)->first(fn (string $label): bool => str_contains($label, 'leer-ohne-stand'));
|
||||
$this->assertSame('leer-ohne-stand · noch ohne Stand, nicht verwendbar', $leer);
|
||||
$this->assertStringContainsString('· Stand 1', (string) collect($options)->first(fn (string $label): bool => str_contains($label, 'shop-konflikte')));
|
||||
$this->assertStringContainsString('shop-konflikte', implode(' ', app(PublicationReadiness::class)->bundleVersionOptions()));
|
||||
}
|
||||
|
||||
public function test_an_offer_for_an_article_without_stand_cannot_be_activated(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('angebot-ohne-stand');
|
||||
$offer = app(OfferService::class)->create('Angebot ohne Inhalt');
|
||||
|
||||
Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewOffer::class, ['record' => $offer->getKey()])
|
||||
->mountAction('activate')
|
||||
->fillForm([
|
||||
'holder_kind' => 'person',
|
||||
'grant_kind' => 'kauf',
|
||||
'price_euro' => '19,00',
|
||||
'lines' => [['kind' => 'article', 'article_id' => $article->id, 'rights_id' => $this->rights()->id]],
|
||||
])
|
||||
->callMountedAction()
|
||||
->assertNotified('Der Lizenzartikel „angebot-ohne-stand“ (angebot-ohne-stand) hat noch keinen veröffentlichten Stand und vergibt keine Inhalte. Lege zuerst am Artikel mit „Inhalt festlegen“ den Inhalt fest, bevor du das Angebot aktivierst.');
|
||||
|
||||
$this->assertSame(0, $offer->versions()->count(), 'Es entsteht keine Angebotsfassung.');
|
||||
}
|
||||
|
||||
public function test_an_offer_for_a_bundle_with_an_article_without_stand_cannot_be_activated(): void
|
||||
{
|
||||
$article = app(ArticleService::class)->create('paket-ohne-stand');
|
||||
$bundle = app(BundleService::class)->create('Paket mit leerem Artikel');
|
||||
$version = app(BundleService::class)->publish($bundle, [$article, $this->article('shop-konflikte')]);
|
||||
$offer = app(OfferService::class)->create('Paketangebot ohne Inhalt');
|
||||
|
||||
Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewOffer::class, ['record' => $offer->getKey()])
|
||||
->mountAction('activate')
|
||||
->fillForm([
|
||||
'holder_kind' => 'person',
|
||||
'grant_kind' => 'kauf',
|
||||
'price_euro' => '19,00',
|
||||
'lines' => [['kind' => 'bundle', 'bundle_version_id' => $version->id, 'rights_id' => $this->rights()->id]],
|
||||
])
|
||||
->callMountedAction();
|
||||
|
||||
$this->assertSame(0, $offer->versions()->count());
|
||||
|
||||
$check = app(PublicationReadiness::class)->forBundle($bundle->refresh());
|
||||
$this->assertFalse($check['bereit']);
|
||||
$this->assertSame('Jeder enthaltene Artikel hat einen Inhalt', $check['naechster']['titel']);
|
||||
$this->assertStringContainsString('paket-ohne-stand', $check['naechster']['text']);
|
||||
}
|
||||
|
||||
public function test_the_offer_page_walks_from_empty_to_findable_in_the_shop(): void
|
||||
{
|
||||
$offer = app(OfferService::class)->create('Neues Angebot');
|
||||
$readiness = app(PublicationReadiness::class);
|
||||
$page = fn () => Livewire::actingAs($this->keeper(), 'staff')->test(ViewOffer::class, ['record' => $offer->getKey()]);
|
||||
|
||||
$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']);
|
||||
|
||||
// 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');
|
||||
$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');
|
||||
}
|
||||
|
||||
public function test_the_bundle_page_shows_the_steps_and_the_offer_for_the_bundle(): void
|
||||
{
|
||||
$bundle = app(BundleService::class)->create('Frisches Paket');
|
||||
|
||||
Livewire::actingAs($this->keeper(), 'staff')
|
||||
->test(ViewBundle::class, ['record' => $bundle->getKey()])
|
||||
->assertSee('Bis zur Veröffentlichung')
|
||||
->assertSeeText('Nächster Schritt: Bestandteile festlegen');
|
||||
|
||||
app(BundleService::class)->publish($bundle, [$this->article('shop-konflikte'), $this->article('shop-grenzen')]);
|
||||
$check = app(PublicationReadiness::class)->forBundle($bundle->refresh());
|
||||
$this->assertTrue($check['bereit'], 'Pflichtschritte erfüllt; das Angebot ist eine Empfehlung.');
|
||||
$this->assertSame('offen', $check['schritte'][2]['stand']);
|
||||
$this->assertFalse($check['schritte'][2]['pflicht']);
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
private function rights(): RightsProfileVersion
|
||||
{
|
||||
return RightsProfileVersion::query()->orderBy('id')->firstOrFail();
|
||||
}
|
||||
|
||||
private function hiddenProgram(): Composition
|
||||
{
|
||||
$composition = app(ContentService::class)->createComposition('Unveröffentlichtes Programm');
|
||||
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$composition->save();
|
||||
|
||||
return $composition;
|
||||
}
|
||||
|
||||
private function keeper(): User
|
||||
{
|
||||
$keeper = User::factory()->katalogverwalter()->create();
|
||||
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $keeper;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user