1. 修復倉庫統計數據加總與樣式。 2. 修正可用庫存計算邏輯(排除不可銷售倉庫)。 3. 撥補單商品列表加入批號與效期顯示。 4. 修正撥補單儲存邏輯以支援精確批號轉移。 5. 整合 FEATURES.md 至 README.md。
46 lines
1.1 KiB
PHP
46 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',
|
|
'balance_before',
|
|
'balance_after',
|
|
'reason',
|
|
'reference_type',
|
|
'reference_id',
|
|
'user_id',
|
|
'actual_time',
|
|
];
|
|
|
|
protected $casts = [
|
|
'actual_time' => 'datetime',
|
|
];
|
|
|
|
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();
|
|
}
|
|
}
|