- ReceivingController: CRUD 및 목록 조회 API - ReceivingService: 입고 비즈니스 로직 - Receiving 모델: 다중 테넌트 지원 - FormRequest 검증 클래스 - Swagger 문서화 - receivings 테이블 마이그레이션 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
108 lines
2.3 KiB
PHP
108 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Tenants;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Receiving extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'receiving_number',
|
|
'order_no',
|
|
'order_date',
|
|
'item_id',
|
|
'item_code',
|
|
'item_name',
|
|
'specification',
|
|
'supplier',
|
|
'order_qty',
|
|
'order_unit',
|
|
'due_date',
|
|
'receiving_qty',
|
|
'receiving_date',
|
|
'lot_no',
|
|
'supplier_lot',
|
|
'receiving_location',
|
|
'receiving_manager',
|
|
'status',
|
|
'remark',
|
|
'created_by',
|
|
'updated_by',
|
|
'deleted_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'order_date' => 'date',
|
|
'due_date' => 'date',
|
|
'receiving_date' => 'date',
|
|
'order_qty' => 'decimal:2',
|
|
'receiving_qty' => 'decimal:2',
|
|
'item_id' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 상태 목록
|
|
*/
|
|
public const STATUSES = [
|
|
'order_completed' => '발주완료',
|
|
'shipping' => '배송중',
|
|
'inspection_pending' => '검사대기',
|
|
'receiving_pending' => '입고대기',
|
|
'completed' => '입고완료',
|
|
];
|
|
|
|
/**
|
|
* 품목 관계
|
|
*/
|
|
public function item(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Items\Item::class);
|
|
}
|
|
|
|
/**
|
|
* 생성자 관계
|
|
*/
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Members\User::class, 'created_by');
|
|
}
|
|
|
|
/**
|
|
* 상태 라벨
|
|
*/
|
|
public function getStatusLabelAttribute(): string
|
|
{
|
|
return self::STATUSES[$this->status] ?? $this->status;
|
|
}
|
|
|
|
/**
|
|
* 수정 가능 여부
|
|
*/
|
|
public function canEdit(): bool
|
|
{
|
|
return $this->status !== 'completed';
|
|
}
|
|
|
|
/**
|
|
* 삭제 가능 여부
|
|
*/
|
|
public function canDelete(): bool
|
|
{
|
|
return $this->status !== 'completed';
|
|
}
|
|
|
|
/**
|
|
* 입고처리 가능 여부
|
|
*/
|
|
public function canProcess(): bool
|
|
{
|
|
return in_array($this->status, ['order_completed', 'shipping', 'inspection_pending', 'receiving_pending']);
|
|
}
|
|
}
|