Lasse Vergaben auf Abruf und bei Registrierung nicht als Shop-Option aendern
Der Abschnitt "Im Shop verkaufen" listet alle Angebote eines Artikels. Fuer Vergaben auf Abruf oder bei Registrierung bot er "Aendern" und "Aus dem Verkauf nehmen" an; "Aendern" haette sie zum Kauf umgestellt. Jetzt zeigt der Abschnitt sie nur noch mit dem Hinweis, dass sie am Angebot bearbeitet werden, die Aktionen liefern 404, und reviseArticleOption lehnt sie ab. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3b0b4c955e
commit
657578455f
4 files changed
+44
-4
No files matched your search
@@ -195,6 +195,10 @@ public function reviseArticleOption(Offer $offer, LicenseArticle $article, Right
|
||||
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]], [
|
||||
|
||||
@@ -456,6 +456,7 @@ public function optionRows(): array
|
||||
'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'],
|
||||
@@ -582,8 +583,10 @@ 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 = 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,9 +90,13 @@
|
||||
<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">
|
||||
<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>
|
||||
@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>
|
||||
|
||||
@@ -298,6 +298,35 @@ public function test_an_option_of_another_article_cannot_be_opened_or_changed():
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
Reference in new issue
Block a user