Warenwirtschaft: AP-48 — Produktbestand-Buchungsgründe pflegbar, getrennt Ein/Aus
Kundenentscheid 26.08. (D-5): Eingang und Ausgang haben eigene, pflegbare Gründe-Listen statt einer festen Liste im Controller. - Neues Modell/Tabelle stock_movement_reasons (label, direction in/out, pos, active, SoftDeletes) inkl. Seed der bisherigen Gründe sinnvoll auf Ein-/Ausgang aufgeteilt. - CRUD wie DisposalReason (SettingCrudController + FormRequest + Formular mit Richtungs-Auswahl); zwei Listen (Eingangs-/Ausgangs-Gründe) auf der Seite Einstellungen → Allgemeines, „Neu anlegen" mit vorbelegter Richtung. - Produktbestand-Maske: das Grund-Dropdown wird jetzt je nach Eingang/Ausgang per JS aus den passenden, gepflegten Gründen befüllt (manualReasons entfernt). - DeletionGuard: StockMovementReason immer löschbar. Migration create_stock_movement_reasons auf Dev-/Live-DB. 4 Tests, Suite 326 grün. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e08c8dec40
commit
190713c21b
12 changed files with 381 additions and 22 deletions
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin\Inventory;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\DeliveryTime;
|
||||
use App\Models\DisposalReason;
|
||||
use App\Models\StockMovementReason;
|
||||
use App\Models\StorageRoom;
|
||||
use App\Models\StorageShelf;
|
||||
use App\Models\StorageSlot;
|
||||
|
|
@ -19,6 +20,9 @@ class GeneralSettingController extends Controller
|
|||
'taxRates' => TaxRate::query()->orderBy('pos')->orderBy('percent')->get(),
|
||||
'deliveryTimes' => DeliveryTime::query()->orderBy('pos')->orderBy('label')->get(),
|
||||
'disposalReasons' => DisposalReason::query()->orderBy('pos')->orderBy('label')->get(),
|
||||
// AP-48: Buchungsgründe Produktbestand, getrennt nach Eingang/Ausgang.
|
||||
'stockReasonsIn' => StockMovementReason::query()->where('direction', 'in')->orderBy('pos')->orderBy('label')->get(),
|
||||
'stockReasonsOut' => StockMovementReason::query()->where('direction', 'out')->orderBy('pos')->orderBy('label')->get(),
|
||||
'storageRooms' => StorageRoom::query()->orderBy('pos')->orderBy('label')->get(),
|
||||
'storageShelves' => StorageShelf::query()->orderBy('pos')->orderBy('label')->get(),
|
||||
'storageSlots' => StorageSlot::query()->orderBy('pos')->orderBy('label')->get(),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Http\Requests\Inventory\StoreProductStockMovementRequest;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductStockMovement;
|
||||
use App\Models\StockMovementReason;
|
||||
use App\Services\ProductStockService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -59,10 +60,23 @@ class ProductStockController extends Controller
|
|||
|
||||
return view('admin.inventory.product-stock.index', [
|
||||
'rows' => $rows,
|
||||
'reasons' => $this->manualReasons(),
|
||||
// AP-48: getrennte, pflegbare Buchungsgründe je Richtung.
|
||||
'reasonsIn' => $this->reasonsFor('in'),
|
||||
'reasonsOut' => $this->reasonsFor('out'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
protected function reasonsFor(string $direction): array
|
||||
{
|
||||
return StockMovementReason::query()->active()
|
||||
->where('direction', $direction)
|
||||
->orderBy('pos')->orderBy('label')
|
||||
->pluck('label')->all();
|
||||
}
|
||||
|
||||
public function storeMovement(StoreProductStockMovementRequest $request, Product $product): RedirectResponse
|
||||
{
|
||||
$data = $request->validated();
|
||||
|
|
@ -127,22 +141,6 @@ class ProductStockController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
protected function manualReasons(): array
|
||||
{
|
||||
return [
|
||||
__('Initialbestand'),
|
||||
__('Korrektur'),
|
||||
__('Inventur'),
|
||||
__('Retoure'),
|
||||
__('Testervergabe'),
|
||||
__('Verlust / Bruch'),
|
||||
__('Sonstiges'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, int>
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin\Inventory;
|
||||
|
||||
use App\Http\Requests\Inventory\StoreStockMovementReasonRequest;
|
||||
use App\Models\StockMovementReason;
|
||||
|
||||
class StockMovementReasonController extends SettingCrudController
|
||||
{
|
||||
protected function modelClass(): string
|
||||
{
|
||||
return StockMovementReason::class;
|
||||
}
|
||||
|
||||
protected function viewPrefix(): string
|
||||
{
|
||||
return 'admin.inventory.stock-movement-reasons';
|
||||
}
|
||||
|
||||
protected function redirectRoute(): string
|
||||
{
|
||||
return 'admin.inventory.general';
|
||||
}
|
||||
|
||||
protected function storeRequestClass(): string
|
||||
{
|
||||
return StoreStockMovementReasonRequest::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Neu-Formular mit vorbelegter Richtung (aus ?direction=in|out).
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function newModelAttributes(): array
|
||||
{
|
||||
$direction = in_array(request()->query('direction'), ['in', 'out'], true)
|
||||
? request()->query('direction')
|
||||
: 'in';
|
||||
|
||||
return ['active' => true, 'pos' => 0, 'direction' => $direction];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
protected function indexOrder(): array
|
||||
{
|
||||
return ['direction', 'pos', 'label'];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue