- 修正所有模組 Controller 的 Model 引用路徑 (App\Modules\...) - 更新 ProductionOrder 與 ProductionOrderItem 模型結構以符合新版邏輯 - 修復 resources/js/utils/format.ts 在處理空值時導致 toLocaleString 崩潰的問題 - 清除全域路徑與 Controller 遷移殘留檔案
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Modules\Procurement\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Modules\Inventory\Models\Product;
|
|
|
|
class PurchaseOrderItem extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\PurchaseOrderItemFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'purchase_order_id',
|
|
'product_id',
|
|
'quantity',
|
|
'unit_price',
|
|
'subtotal',
|
|
// 驗收欄位
|
|
'received_quantity',
|
|
// 批號與效期 (驗收時填寫)
|
|
'batch_number',
|
|
'expiry_date',
|
|
];
|
|
|
|
protected $casts = [
|
|
'quantity' => 'decimal:2',
|
|
'unit_price' => 'decimal:4',
|
|
'subtotal' => 'decimal:2',
|
|
'received_quantity' => 'decimal:2',
|
|
'expiry_date' => 'date',
|
|
];
|
|
|
|
public function purchaseOrder(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(PurchaseOrder::class);
|
|
}
|
|
|
|
public function product(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
}
|