feat(WEB): 절곡품 선생산→재고적재 Phase 1 - 생산입고 기반 구축

- StockTransaction: REASON_PRODUCTION_OUTPUT 상수 및 '생산입고' 라벨 추가
- StockLot: work_order_id FK 컬럼 마이그레이션 + 모델 fillable/casts/relation 추가
- StockService: increaseFromProduction() 메서드 구현 (increaseFromReceiving 기반)
- WorkOrderService: 완료 시 sales_order_id 유무에 따라 출하/재고입고 분기
  - stockInFromProduction(): 품목별 양품 재고 입고 처리
  - shouldStockIn(): items.options 기반 입고 대상 판단

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 15:32:24 +09:00
parent ba49313ffa
commit 8be54c3b8b
5 changed files with 259 additions and 23 deletions

View File

@@ -28,6 +28,7 @@ class StockLot extends Model
'location',
'status',
'receiving_id',
'work_order_id',
'created_by',
'updated_by',
'deleted_by',
@@ -41,6 +42,7 @@ class StockLot extends Model
'available_qty' => 'decimal:3',
'stock_id' => 'integer',
'receiving_id' => 'integer',
'work_order_id' => 'integer',
];
/**
@@ -68,6 +70,14 @@ public function receiving(): BelongsTo
return $this->belongsTo(Receiving::class);
}
/**
* 작업지시 관계 (생산입고)
*/
public function workOrder(): BelongsTo
{
return $this->belongsTo(\App\Models\Production\WorkOrder::class);
}
/**
* 생성자 관계
*/

View File

@@ -48,12 +48,15 @@ class StockTransaction extends Model
public const REASON_ORDER_CANCEL = 'order_cancel';
public const REASON_PRODUCTION_OUTPUT = 'production_output';
public const REASONS = [
self::REASON_RECEIVING => '입고',
self::REASON_WORK_ORDER_INPUT => '생산투입',
self::REASON_SHIPMENT => '출하',
self::REASON_ORDER_CONFIRM => '수주확정',
self::REASON_ORDER_CANCEL => '수주취소',
self::REASON_PRODUCTION_OUTPUT => '생산입고',
];
protected $fillable = [
@@ -111,4 +114,4 @@ public function getReasonLabelAttribute(): string
{
return self::REASONS[$this->reason] ?? ($this->reason ?? '-');
}
}
}