Warenwirtschaft: AP-09 bis AP-13 (Produktbestand, Set-Produkte, Ausschuss, Konzepte)

- AP-09 Produktbestand inkl. Bewegungshistorie (product_stock_movements, ProductStockService)
- AP-10 Rohstoffbestand-Ansicht je Lager (RawMaterialStockController)
- AP-11 Bestandsschwellen / Out-of-Stock-Handling fuer Produkte und Shop
- AP-12 Ausgang/Ausschuss (stock_disposals, StockDisposalController, InventoryService)
- Set-Produkte (product_set_items) inkl. Aufloesung
- Produktentwicklung & Hinweise-Verwaltung (Notices)
- AP-13 Entwicklungskonzept Shop-Bestandsabzug im Plan dokumentiert
- Feature-Tests fuer neue Module + aktualisierter Entwicklungsplan

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Kevin Adametz 2026-06-03 11:04:22 +00:00
parent 78679e0c55
commit 3ee2d756e9
63 changed files with 5968 additions and 901 deletions

View file

@ -0,0 +1,95 @@
<?php
namespace App\Http\Requests\Inventory;
use Carbon\Carbon;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
class StoreStockDisposalRequest extends FormRequest
{
public function authorize(): bool
{
return (bool) $this->user()?->isAdmin();
}
/**
* @return array<string, array<int, mixed>>
*/
public function rules(): array
{
return [
'disposal_type' => ['required', Rule::in(['ingredient', 'packaging'])],
'ingredient_id' => ['nullable', 'integer', 'exists:ingredients,id'],
'packaging_item_id' => ['nullable', 'integer', 'exists:packaging_items,id'],
'stock_entry_id' => ['nullable', 'integer', 'exists:stock_entries,id'],
'location_id' => ['required', 'integer', 'exists:locations,id'],
'quantity' => ['required', 'numeric', 'min:0.01'],
'reason' => ['required', 'string', 'max:100'],
'note' => ['nullable', 'string', 'max:255'],
'disposed_at' => ['required', 'date'],
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return [
'location_id.required' => __('Bitte einen Lagerort wählen.'),
'quantity.required' => __('Bitte eine Menge angeben.'),
'quantity.min' => __('Die Menge muss größer als 0 sein.'),
'reason.required' => __('Bitte einen Grund angeben.'),
'disposed_at.required' => __('Bitte ein Datum angeben.'),
];
}
protected function prepareForValidation(): void
{
$disposedAt = $this->input('disposed_at');
if (is_string($disposedAt) && preg_match('/^\d{2}\.\d{2}\.\d{4}$/', trim($disposedAt))) {
$disposedAt = Carbon::createFromFormat('d.m.Y', trim($disposedAt))->format('Y-m-d');
}
$this->merge([
'quantity' => reFormatNumber($this->input('quantity')),
'disposed_at' => $disposedAt,
]);
}
public function withValidator(Validator $validator): void
{
$validator->after(function (Validator $validator): void {
if ($this->input('disposal_type') === 'ingredient') {
if (empty($this->input('ingredient_id'))) {
$validator->errors()->add('ingredient_id', __('Bitte einen Rohstoff wählen.'));
}
} elseif ($this->input('disposal_type') === 'packaging') {
if (empty($this->input('packaging_item_id'))) {
$validator->errors()->add('packaging_item_id', __('Bitte einen Verpackungsartikel wählen.'));
}
}
});
}
/**
* @return array<string, mixed>
*/
public function validatedPayload(): array
{
$data = $this->validated();
if (($data['disposal_type'] ?? '') === 'ingredient') {
$data['packaging_item_id'] = null;
$data['unit'] = 'gram';
} else {
$data['ingredient_id'] = null;
$data['stock_entry_id'] = null;
$data['unit'] = 'piece';
}
return $data;
}
}