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

@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 선생산 완료 시 재고 입고를 위해 stock_lots에 work_order_id FK 추가
* - 구매입고: receiving_id 참조
* - 생산입고: work_order_id 참조
*/
public function up(): void
{
Schema::table('stock_lots', function (Blueprint $table) {
$table->unsignedBigInteger('work_order_id')
->nullable()
->after('receiving_id')
->comment('생산입고 시 작업지시 참조');
$table->foreign('work_order_id')
->references('id')
->on('work_orders')
->nullOnDelete();
});
}
public function down(): void
{
Schema::table('stock_lots', function (Blueprint $table) {
$table->dropForeign(['work_order_id']);
$table->dropColumn('work_order_id');
});
}
};