Phase 3 발주/입고/재고 관리 구현

- DB: bag_order, bag_order_item, bag_receiving, bag_inventory 테이블
- 발주: UUID v4, SHA-256 해시, LOT번호 자동생성, 봉투별 품목 관리
  - 포장단위 연동 (박스→낱장 자동 환산), 단가 연동 (금액 자동 계산)
  - 발주 현황 (기간/상태 필터), 상세 조회, 취소/삭제 (상태 변경)
- 입고: 발주건 기반 입고 처리, 박스→낱장 환산, 재고 자동 가산
- 재고: 지자체별 봉투 종류별 현재 재고 조회
- E2E 테스트 7개 전체 통과

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
javamon1174
2026-03-25 18:13:01 +09:00
parent c2840a9e34
commit d9d3ef46c1
17 changed files with 1002 additions and 12 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BagInventoryModel extends Model
{
protected $table = 'bag_inventory';
protected $primaryKey = 'bi_idx';
protected $returnType = 'object';
protected $useTimestamps = false;
protected $allowedFields = [
'bi_lg_idx', 'bi_bag_code', 'bi_bag_name', 'bi_qty', 'bi_updated_at',
];
/**
* 재고 증감 (upsert)
*/
public function adjustQty(int $lgIdx, string $bagCode, string $bagName, int $delta): void
{
$existing = $this->where('bi_lg_idx', $lgIdx)->where('bi_bag_code', $bagCode)->first();
if ($existing) {
$this->update($existing->bi_idx, [
'bi_qty' => max(0, (int) $existing->bi_qty + $delta),
'bi_updated_at' => date('Y-m-d H:i:s'),
]);
} else {
$this->insert([
'bi_lg_idx' => $lgIdx,
'bi_bag_code' => $bagCode,
'bi_bag_name' => $bagName,
'bi_qty' => max(0, $delta),
'bi_updated_at'=> date('Y-m-d H:i:s'),
]);
}
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BagOrderItemModel extends Model
{
protected $table = 'bag_order_item';
protected $primaryKey = 'boi_idx';
protected $returnType = 'object';
protected $useTimestamps = false;
protected $allowedFields = [
'boi_bo_idx', 'boi_bag_code', 'boi_bag_name',
'boi_unit_price', 'boi_qty_box', 'boi_qty_sheet', 'boi_amount',
];
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BagOrderModel extends Model
{
protected $table = 'bag_order';
protected $primaryKey = 'bo_idx';
protected $returnType = 'object';
protected $useTimestamps = false;
protected $allowedFields = [
'bo_uuid', 'bo_version', 'bo_lg_idx', 'bo_gugun_code', 'bo_dong_code',
'bo_company_idx', 'bo_agency_idx', 'bo_fee_rate', 'bo_order_date',
'bo_lot_no', 'bo_hash', 'bo_status', 'bo_orderer_idx',
'bo_regdate', 'bo_moddate',
];
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BagReceivingModel extends Model
{
protected $table = 'bag_receiving';
protected $primaryKey = 'br_idx';
protected $returnType = 'object';
protected $useTimestamps = false;
protected $allowedFields = [
'br_bo_idx', 'br_lg_idx', 'br_bag_code', 'br_bag_name',
'br_qty_box', 'br_qty_sheet', 'br_receive_date',
'br_receiver_idx', 'br_sender_name', 'br_type', 'br_regdate',
];
}