- production_outputs (Migration inkl. idempotentem Backfill): eine Produktion kann mehrere Output-Produkte erzeugen (z. B. 40x50 ml + 50x5 ml) - ProductStockService bucht je Output-Produkt (idempotenter Diff, append-only); die geplante Stückzahl bucht nichts mehr, entfernte Outputs werden rückgebucht - ProductionService store/update mit outputs[] (leer = Fallback auf Planung inkl. suggestedBatchNumber — Backfill-Semantik, Alt-Aufrufer stabil) - Maske: INCI-Liste (Alternativname/Qualität/Anteil/Gramm/Regal), Chargen- Erfassung nach Rezeptur-Phasen mit Notiz + Status-Ampel, Produktionsergebnis- Repeater mit Chargen-Nr.-Vorbelegung (Präfix + ttmmjj), Planungs-Hinweis - Show: Produktionsergebnis-Karte; Index: Ergebnis-Spalte - Hinweise-Doku + Plan V6.0 §6 fortgeschrieben (nächster Schritt: AP-13) Tests: ProductionOutputTest (8 neu); Suite 201 grün, 731 Assertionen Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
83 lines
1.8 KiB
PHP
83 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Production extends Model
|
|
{
|
|
protected $fillable = [
|
|
'product_id',
|
|
'location_id',
|
|
'produced_by',
|
|
'produced_at',
|
|
'quantity',
|
|
'notes',
|
|
'mhd_warning',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'produced_at' => 'date',
|
|
'mhd_warning' => 'boolean',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Product, $this>
|
|
*/
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Location, $this>
|
|
*/
|
|
public function location(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Location::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function producedByUser(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'produced_by');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<ProductionIngredient, $this>
|
|
*/
|
|
public function productionIngredients(): HasMany
|
|
{
|
|
return $this->hasMany(ProductionIngredient::class);
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<ProductionPackaging, $this>
|
|
*/
|
|
public function productionPackagings(): HasMany
|
|
{
|
|
return $this->hasMany(ProductionPackaging::class);
|
|
}
|
|
|
|
/**
|
|
* AP-28: Produktionsergebnis-Zeilen — buchen den Produktbestand;
|
|
* `quantity` an der Produktion ist nur noch die Planung.
|
|
*
|
|
* @return HasMany<ProductionOutput, $this>
|
|
*/
|
|
public function outputs(): HasMany
|
|
{
|
|
return $this->hasMany(ProductionOutput::class)->orderBy('pos')->orderBy('id');
|
|
}
|
|
}
|