fix: 경동 BOM 계산 수정 및 품목-공정 매핑
- KyungdongFormulaHandler: product_type 자동 추론(item_category 기반), 철재 주자재 EGI코일로 변경, 조인트바 steel 공통 지원 - FormulaEvaluatorService: FG item_category에서 product_type 자동 판별 - MapItemsToProcesses: 경동 품목-공정 매핑 커맨드 정비 - KyungdongItemMasterSeeder: BOM child_item_id code 기반 재매핑 - ItemsBomController: ghost ID 유효성 검증 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,22 @@ public function store(int $id, Request $request)
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
$item = $this->getItem($id);
|
||||
$inputItems = $request->input('items', []);
|
||||
$tenantId = app('tenant_id');
|
||||
|
||||
// child_item_id 존재 검증
|
||||
$childIds = collect($inputItems)->pluck('child_item_id')->filter()->unique()->values()->toArray();
|
||||
if (! empty($childIds)) {
|
||||
$validIds = Item::where('tenant_id', $tenantId)
|
||||
->whereIn('id', $childIds)
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
$invalidIds = array_diff($childIds, $validIds);
|
||||
if (! empty($invalidIds)) {
|
||||
throw new \InvalidArgumentException(
|
||||
__('error.bom.invalid_child_items', ['ids' => implode(', ', $invalidIds)])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$existingBom = $item->bom ?? [];
|
||||
$existingMap = collect($existingBom)->keyBy('child_item_id')->toArray();
|
||||
@@ -273,6 +289,22 @@ public function replace(int $id, Request $request)
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
$item = $this->getItem($id);
|
||||
$inputItems = $request->input('items', []);
|
||||
$tenantId = app('tenant_id');
|
||||
|
||||
// child_item_id 존재 검증
|
||||
$childIds = collect($inputItems)->pluck('child_item_id')->filter()->unique()->values()->toArray();
|
||||
if (! empty($childIds)) {
|
||||
$validIds = Item::where('tenant_id', $tenantId)
|
||||
->whereIn('id', $childIds)
|
||||
->pluck('id')
|
||||
->toArray();
|
||||
$invalidIds = array_diff($childIds, $validIds);
|
||||
if (! empty($invalidIds)) {
|
||||
throw new \InvalidArgumentException(
|
||||
__('error.bom.invalid_child_items', ['ids' => implode(', ', $invalidIds)])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$newBom = [];
|
||||
foreach ($inputItems as $inputItem) {
|
||||
|
||||
Reference in New Issue
Block a user