Warenwirtschaft: AP-37 — Rohstoffbestand „Enthalten in" nicht mehr doppelt
Jedes Produkt trägt einen Rohstoff i. d. R. in zwei product_ingredients-Zeilen (recipe_type manufacturer + product); die belongsToMany-Relation Ingredient::products lieferte das Produkt dadurch doppelt in der „Enthalten in"-Box. In RawMaterialStockController::show() die Produktliste nach ID dedupliziert (setRelation), wovon auch der abgeleitete Produktbestand profitiert. Reine Anzeige-Korrektur, Pivot-Daten unangetastet. Test ergänzt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5c5078bf64
commit
00be848604
2 changed files with 34 additions and 0 deletions
|
|
@ -435,3 +435,31 @@ test('detailansicht zeigt alternativnamen und lagerort', function () {
|
|||
$response->assertSee('Phospholipon 80 H');
|
||||
$response->assertSee('Raum 1 | Regal 3 | O');
|
||||
});
|
||||
|
||||
test('AP-37: enthalten-in listet ein produkt trotz doppelter rezeptzeilen nur einmal', function () {
|
||||
$user = ap10MakeUser(1);
|
||||
$ing = ap10MakeIngredient('AP37-Rohstoff');
|
||||
$product = Product::query()->create(['name' => 'AP37-Zaubercreme-Unikat', 'title' => 'AP37-Zaubercreme-Unikat', 'active' => true]);
|
||||
|
||||
// Realfall: jedes Produkt trägt den Rohstoff in ZWEI product_ingredients-Zeilen
|
||||
// (Hersteller- und Produktrezeptur). Die „Enthalten in"-Liste darf ihn dennoch
|
||||
// nur einmal zeigen.
|
||||
foreach (['manufacturer', 'product'] as $type) {
|
||||
ProductIngredient::query()->create([
|
||||
'product_id' => $product->id,
|
||||
'ingredient_id' => $ing->id,
|
||||
'pos' => 0,
|
||||
'gram' => 10,
|
||||
'factor' => 1.0,
|
||||
'recipe_type' => $type,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->actingAs($user, 'user');
|
||||
|
||||
$html = $this->get(route('admin.inventory.raw-material-stock.show', $ing))
|
||||
->assertSuccessful()
|
||||
->getContent();
|
||||
|
||||
expect(substr_count($html, 'AP37-Zaubercreme-Unikat'))->toBe(1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue