feat(API): 부실채권, 재고, 입고 기능 개선

- BadDebt 컨트롤러/서비스 기능 확장
- StockService 재고 조회 로직 개선
- ProcessReceivingRequest 검증 규칙 수정
- Item, Order, CommonCode, Shipment 모델 업데이트
- TodayIssueObserverService 개선

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-23 21:32:23 +09:00
parent 5104a6641c
commit 09db0da43b
10 changed files with 282 additions and 73 deletions

View File

@@ -85,6 +85,14 @@ public function details()
return $this->hasOne(ItemDetail::class);
}
/**
* 재고 정보 (1:1)
*/
public function stock()
{
return $this->hasOne(\App\Models\Tenants\Stock::class);
}
/**
* 카테고리
*/
@@ -130,26 +138,29 @@ public function tags()
/**
* 특정 타입 필터
* join 시 ambiguous 에러 방지를 위해 테이블 prefix 사용
*/
public function scopeType($query, string $type)
{
return $query->where('item_type', strtoupper($type));
return $query->where('items.item_type', strtoupper($type));
}
/**
* Products 타입만 (FG, PT)
* join 시 ambiguous 에러 방지를 위해 테이블 prefix 사용
*/
public function scopeProducts($query)
{
return $query->whereIn('item_type', self::PRODUCT_TYPES);
return $query->whereIn('items.item_type', self::PRODUCT_TYPES);
}
/**
* Materials 타입만 (SM, RM, CS)
* join 시 ambiguous 에러 방지를 위해 테이블 prefix 사용
*/
public function scopeMaterials($query)
{
return $query->whereIn('item_type', self::MATERIAL_TYPES);
return $query->whereIn('items.item_type', self::MATERIAL_TYPES);
}
/**