Umsetzung der Warenwirtschafts-/Produktmanagement-Erweiterung gemaess Entwicklungsplan V4.0: - AP-00: Regressionsbasis fuer 5.1-Features (ProductPhase51Test) - AP-01: URL-Bugfixes B1/B2 (suppliers/packaging-items, breitere url-Spalten) - AP-04/04.1: iPad-taugliche, vereinheitlichte Tabellen-Aktionen - AP-05: Einstellungen "Allgemein" mit UST-Saetzen (tax_rates) und Lieferzeit-Vorlagen (delivery_times, inkl. Tage-Feld) - AP-06: Lieferanten um Bestellweg, Bestell-Mail/-URL und Lieferzeit erweitert - AP-07/07.1: INCI um Lieferanten-Mehrfachwahl, UST und Lieferzeit erweitert; Lieferanten-Detailansicht im Modal mit pflegbaren INCI-/Verpackungslisten - AP-08: Einkauf um UST-Snapshot, Netto/Brutto-Automatik und Duplizieren erweitert Entwicklungsplan aktualisiert: alle Klaerungspunkte (§5) vom Kunden beantwortet und in die jeweiligen APs eingearbeitet (AP-02/03/09/13/15), neues AP-18 (Hinweise-Doku unter Einstellungen) ergaenzt. Naechster Schritt eindeutig markiert: AP-09 (Produktion auf Hersteller-Rezeptur, kein Fallback, Warnung).
131 lines
2.9 KiB
PHP
131 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\User;
|
|
use Database\Factories\StockEntryFactory;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class StockEntry extends Model
|
|
{
|
|
/** @use HasFactory<StockEntryFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'entry_type',
|
|
'ingredient_id',
|
|
'packaging_item_id',
|
|
'supplier_id',
|
|
'location_id',
|
|
'unit',
|
|
'ordered_by',
|
|
'ordered_at',
|
|
'ordered_quantity',
|
|
'price_per_kg',
|
|
'price_per_kg_gross',
|
|
'price_total',
|
|
'tax_rate_id',
|
|
'tax_rate_percent',
|
|
'received_by',
|
|
'received_at',
|
|
'received_quantity',
|
|
'batch_number',
|
|
'best_before',
|
|
'quality_id',
|
|
'status',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'ordered_at' => 'date',
|
|
'received_at' => 'date',
|
|
'best_before' => 'date',
|
|
'ordered_quantity' => 'decimal:2',
|
|
'received_quantity' => 'decimal:2',
|
|
'price_per_kg' => 'decimal:4',
|
|
'price_per_kg_gross' => 'decimal:4',
|
|
'price_total' => 'decimal:4',
|
|
'tax_rate_percent' => '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<Supplier, $this>
|
|
*/
|
|
public function supplier(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Supplier::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Location, $this>
|
|
*/
|
|
public function location(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Location::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<TaxRate, $this>
|
|
*/
|
|
public function taxRate(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TaxRate::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<MaterialQuality, $this>
|
|
*/
|
|
public function quality(): BelongsTo
|
|
{
|
|
return $this->belongsTo(MaterialQuality::class, 'quality_id');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function orderedByUser(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'ordered_by');
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function receivedByUser(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'received_by');
|
|
}
|
|
|
|
public function isPending(): bool
|
|
{
|
|
return $this->status === 'pending';
|
|
}
|
|
|
|
public function isReceived(): bool
|
|
{
|
|
return $this->status === 'received';
|
|
}
|
|
}
|