Mache den Lizenzartikel zur Produktseite und leite die Seite aus dem Angebot ab
CI Feature / test (push) Failing after 3m16s
CI Feature / test (push) Failing after 3m16s
Die Produktseite ist die Seite des Artikels (/shop/{id}), den die Option als einzige
Position verkauft, oder die Paketseite. Sie wird nicht mehr einem Programm zugeordnet.
Ein Kauf braucht genau eine Position und einen Preis, sonst lässt er sich nicht aktivieren.
Module und Programme werden dadurch nicht öffentlich (Karten und /programme unverändert).
Tests: Die Tests, die eine Programmseite als Produktseite voraussetzten, prüfen jetzt die
Artikelseite; die Zuordnung „eigene Paketseite oder Programmseite“ entfällt (ADR-52).
Ein Altbestandstest sichert die Programmseite für Angebote mit mehreren Positionen.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1950dc377b
commit
08f7d0c63d
22 files changed
+544
-275
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
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;
|
||||
@@ -15,7 +16,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 +48,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 +114,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',
|
||||
@@ -215,12 +208,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,
|
||||
@@ -269,47 +257,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 +286,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 +401,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 +416,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],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user