refactor: 검사 테이블 통합 및 출하 대시보드 수정
## 변경 사항 ### 검사 시스템 통합 - 레거시 검사 모델 삭제 (MaterialInspection, MaterialInspectionItem, MaterialReceipt) - 통합 검사 모델 추가 (Inspection.php) - IQC/PQC/FQC 지원 - 품목 입고 모델 추가 (ItemReceipt.php) - PricingService에서 ItemReceipt 참조로 변경 ### 출하 대시보드 수정 - ShipmentService stats() 프론트엔드 호환 필드 추가 - today_shipment_count, scheduled_count, shipping_count, urgent_count ### 마이그레이션 - inspections 테이블 생성 (IQC/PQC/FQC 통합) - item_receipts로 테이블명 변경 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
113
app/Models/Items/ItemReceipt.php
Normal file
113
app/Models/Items/ItemReceipt.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Items;
|
||||
|
||||
use App\Models\Scopes\BelongsToTenant;
|
||||
use App\Models\Tenants\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* 품목 입고 모델
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $item_id 품목 ID
|
||||
* @property int $tenant_id 테넌트 ID
|
||||
* @property string $receipt_date 입고일
|
||||
* @property string $lot_number LOT번호
|
||||
* @property float $received_qty 입고수량
|
||||
* @property string $unit 단위
|
||||
* @property string|null $supplier_name 공급업체명
|
||||
* @property string|null $manufacturer_name 제조업체명
|
||||
* @property float|null $purchase_price_excl_vat 매입단가(부가세 제외)
|
||||
* @property float|null $weight_kg 중량(kg)
|
||||
* @property string $status_code 상태코드
|
||||
* @property string $is_inspection 검사여부 (Y/N)
|
||||
* @property string|null $inspection_date 검사일
|
||||
* @property string|null $remarks 비고
|
||||
*
|
||||
* @mixin IdeHelperItemReceipt
|
||||
*/
|
||||
class ItemReceipt extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'item_receipts';
|
||||
|
||||
protected $fillable = [
|
||||
'item_id',
|
||||
'tenant_id',
|
||||
'receipt_date',
|
||||
'lot_number',
|
||||
'received_qty',
|
||||
'unit',
|
||||
'supplier_name',
|
||||
'manufacturer_name',
|
||||
'purchase_price_excl_vat',
|
||||
'weight_kg',
|
||||
'status_code',
|
||||
'is_inspection',
|
||||
'inspection_date',
|
||||
'remarks',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'receipt_date' => 'date',
|
||||
'inspection_date' => 'date',
|
||||
'received_qty' => 'decimal:2',
|
||||
'purchase_price_excl_vat' => 'decimal:2',
|
||||
'weight_kg' => 'decimal:2',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::addGlobalScope(new BelongsToTenant);
|
||||
}
|
||||
|
||||
// ===== Relationships =====
|
||||
|
||||
/**
|
||||
* 품목
|
||||
*/
|
||||
public function item()
|
||||
{
|
||||
return $this->belongsTo(Item::class, 'item_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 생성자
|
||||
*/
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
// ===== Scopes =====
|
||||
|
||||
/**
|
||||
* 특정 품목의 입고 내역
|
||||
*/
|
||||
public function scopeForItem($query, int $itemId)
|
||||
{
|
||||
return $query->where('item_id', $itemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 일자 이전 입고
|
||||
*/
|
||||
public function scopeBeforeDate($query, string $date)
|
||||
{
|
||||
return $query->where('receipt_date', '<=', $date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 단가가 있는 입고만
|
||||
*/
|
||||
public function scopeWithPrice($query)
|
||||
{
|
||||
return $query->whereNotNull('purchase_price_excl_vat')
|
||||
->where('purchase_price_excl_vat', '>', 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user