- 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>
87 lines
1.8 KiB
PHP
87 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class StockDisposal extends Model
|
|
{
|
|
protected $fillable = [
|
|
'disposal_type',
|
|
'ingredient_id',
|
|
'packaging_item_id',
|
|
'stock_entry_id',
|
|
'location_id',
|
|
'quantity',
|
|
'unit',
|
|
'reason',
|
|
'note',
|
|
'user_id',
|
|
'disposed_at',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'disposed_at' => 'date',
|
|
'quantity' => 'decimal:2',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Ingredient, $this>
|
|
*/
|
|
public function ingredient(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Ingredient::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<PackagingItem, $this>
|
|
*/
|
|
public function packagingItem(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PackagingItem::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<StockEntry, $this>
|
|
*/
|
|
public function stockEntry(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StockEntry::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Location, $this>
|
|
*/
|
|
public function location(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Location::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function isIngredient(): bool
|
|
{
|
|
return $this->disposal_type === 'ingredient';
|
|
}
|
|
|
|
public function articleName(): string
|
|
{
|
|
return $this->isIngredient()
|
|
? ($this->ingredient?->name ?? '—')
|
|
: ($this->packagingItem?->name ?? '—');
|
|
}
|
|
}
|