1. 倉庫管理:新增業務類型 (Owned/External/Customer) 與車牌資訊與司機欄位。 2. 庫存管理:實作成本追蹤 (unit_cost, total_value),更新列表與撥補單顯示。 3. 採購單:新增採購日期 (order_date),調整欄位名稱與順序。 4. 前端優化:更新相關 TS Type 定義與 UI 顯示。
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Inventory\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Modules\Core\Models\User; // 跨模組核心依賴
|
|
|
|
class InventoryTransaction extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\InventoryTransactionFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'inventory_id',
|
|
'type',
|
|
'quantity',
|
|
'unit_cost',
|
|
'balance_before',
|
|
'balance_after',
|
|
'reason',
|
|
'reference_type',
|
|
'reference_id',
|
|
'user_id',
|
|
'actual_time',
|
|
];
|
|
|
|
protected $casts = [
|
|
'actual_time' => 'datetime',
|
|
'unit_cost' => 'decimal:4',
|
|
];
|
|
|
|
public function inventory(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(Inventory::class);
|
|
}
|
|
|
|
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function reference(): \Illuminate\Database\Eloquent\Relations\MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
}
|