P2-03/04 봉투 단가 관리 CRUD + 이력 + 기간별 조회

- bag_price, bag_price_history 테이블 생성
- BagPriceModel, BagPriceHistoryModel
- BagPrice 컨트롤러 (목록/등록/수정/삭제/이력)
- 단가 변경 시 자동 이력 기록 (트랜잭션)
- 기간 필터 조회 (적용시작일/종료일)
- 봉투코드(O) 드롭다운 연동
- E2E 테스트 5개 전체 통과
- 스크린샷 2개 추가

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
javamon1174
2026-03-25 16:27:42 +09:00
parent 41442c23a1
commit 6949227592
12 changed files with 558 additions and 0 deletions

View File

@@ -65,6 +65,15 @@ $routes->group('admin', ['filter' => 'adminAuth'], static function ($routes): vo
$routes->post('code-details/update/(:num)', 'Admin\CodeDetail::update/$1');
$routes->post('code-details/delete/(:num)', 'Admin\CodeDetail::delete/$1');
// 봉투 단가 관리 (P2-03/04)
$routes->get('bag-prices', 'Admin\BagPrice::index');
$routes->get('bag-prices/create', 'Admin\BagPrice::create');
$routes->post('bag-prices/store', 'Admin\BagPrice::store');
$routes->get('bag-prices/edit/(:num)', 'Admin\BagPrice::edit/$1');
$routes->post('bag-prices/update/(:num)', 'Admin\BagPrice::update/$1');
$routes->post('bag-prices/delete/(:num)', 'Admin\BagPrice::delete/$1');
$routes->get('bag-prices/history/(:num)', 'Admin\BagPrice::history/$1');
$routes->get('designated-shops', 'Admin\DesignatedShop::index');
$routes->get('designated-shops/create', 'Admin\DesignatedShop::create');
$routes->post('designated-shops/store', 'Admin\DesignatedShop::store');

View File

@@ -0,0 +1,228 @@
<?php
namespace App\Controllers\Admin;
use App\Controllers\BaseController;
use App\Models\BagPriceModel;
use App\Models\BagPriceHistoryModel;
use App\Models\CodeKindModel;
use App\Models\CodeDetailModel;
class BagPrice extends BaseController
{
private BagPriceModel $priceModel;
private BagPriceHistoryModel $historyModel;
public function __construct()
{
$this->priceModel = model(BagPriceModel::class);
$this->historyModel = model(BagPriceHistoryModel::class);
}
public function index()
{
helper('admin');
$lgIdx = admin_effective_lg_idx();
if (!$lgIdx) {
return redirect()->to(site_url('admin'))->with('error', '지자체를 선택해 주세요.');
}
$builder = $this->priceModel->where('bp_lg_idx', $lgIdx);
// 기간 필터 (P2-04)
$startDate = $this->request->getGet('start_date');
$endDate = $this->request->getGet('end_date');
if ($startDate) {
$builder->where('bp_start_date >=', $startDate);
}
if ($endDate) {
$builder->groupStart()
->where('bp_end_date IS NULL')
->orWhere('bp_end_date <=', $endDate)
->groupEnd();
}
$list = $builder->orderBy('bp_bag_code', 'ASC')->orderBy('bp_start_date', 'DESC')->findAll();
return view('admin/layout', [
'title' => '봉투 단가 관리',
'content' => view('admin/bag_price/index', [
'list' => $list,
'startDate' => $startDate,
'endDate' => $endDate,
]),
]);
}
public function create()
{
helper('admin');
$lgIdx = admin_effective_lg_idx();
if (!$lgIdx) {
return redirect()->to(site_url('admin/bag-prices'))->with('error', '지자체를 선택해 주세요.');
}
// 봉투명 코드(O) 목록
$kindModel = model(CodeKindModel::class);
$kind = $kindModel->where('ck_code', 'O')->first();
$bagCodes = [];
if ($kind) {
$bagCodes = model(CodeDetailModel::class)->getByKind((int) $kind->ck_idx, true);
}
return view('admin/layout', [
'title' => '봉투 단가 등록',
'content' => view('admin/bag_price/create', ['bagCodes' => $bagCodes]),
]);
}
public function store()
{
helper('admin');
$lgIdx = admin_effective_lg_idx();
$rules = [
'bp_bag_code' => 'required|max_length[50]',
'bp_order_price' => 'required|decimal',
'bp_wholesale' => 'required|decimal',
'bp_consumer' => 'required|decimal',
'bp_start_date' => 'required|valid_date[Y-m-d]',
'bp_end_date' => 'permit_empty|valid_date[Y-m-d]',
];
if (! $this->validate($rules)) {
return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
}
// 봉투명 스냅샷
$bagCode = $this->request->getPost('bp_bag_code');
$kindModel = model(CodeKindModel::class);
$kind = $kindModel->where('ck_code', 'O')->first();
$bagName = '';
if ($kind) {
$detail = model(CodeDetailModel::class)->where('cd_ck_idx', $kind->ck_idx)->where('cd_code', $bagCode)->first();
$bagName = $detail ? $detail->cd_name : '';
}
$this->priceModel->insert([
'bp_lg_idx' => $lgIdx,
'bp_bag_code' => $bagCode,
'bp_bag_name' => $bagName,
'bp_order_price' => $this->request->getPost('bp_order_price'),
'bp_wholesale' => $this->request->getPost('bp_wholesale'),
'bp_consumer' => $this->request->getPost('bp_consumer'),
'bp_start_date' => $this->request->getPost('bp_start_date'),
'bp_end_date' => $this->request->getPost('bp_end_date') ?: null,
'bp_state' => 1,
'bp_regdate' => date('Y-m-d H:i:s'),
'bp_reg_mb_idx' => session()->get('mb_idx'),
]);
return redirect()->to(site_url('admin/bag-prices'))->with('success', '봉투 단가가 등록되었습니다.');
}
public function edit(int $id)
{
helper('admin');
$item = $this->priceModel->find($id);
if (!$item || (int) $item->bp_lg_idx !== admin_effective_lg_idx()) {
return redirect()->to(site_url('admin/bag-prices'))->with('error', '단가 정보를 찾을 수 없습니다.');
}
$kindModel = model(CodeKindModel::class);
$kind = $kindModel->where('ck_code', 'O')->first();
$bagCodes = [];
if ($kind) {
$bagCodes = model(CodeDetailModel::class)->getByKind((int) $kind->ck_idx, true);
}
return view('admin/layout', [
'title' => '봉투 단가 수정',
'content' => view('admin/bag_price/edit', ['item' => $item, 'bagCodes' => $bagCodes]),
]);
}
public function update(int $id)
{
helper('admin');
$item = $this->priceModel->find($id);
if (!$item || (int) $item->bp_lg_idx !== admin_effective_lg_idx()) {
return redirect()->to(site_url('admin/bag-prices'))->with('error', '단가 정보를 찾을 수 없습니다.');
}
$rules = [
'bp_order_price' => 'required|decimal',
'bp_wholesale' => 'required|decimal',
'bp_consumer' => 'required|decimal',
'bp_start_date' => 'required|valid_date[Y-m-d]',
'bp_end_date' => 'permit_empty|valid_date[Y-m-d]',
'bp_state' => 'required|in_list[0,1]',
];
if (! $this->validate($rules)) {
return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
}
// 이력 기록
$db = \Config\Database::connect();
$db->transStart();
$priceFields = ['bp_order_price', 'bp_wholesale', 'bp_consumer'];
foreach ($priceFields as $field) {
$oldVal = (string) $item->$field;
$newVal = (string) $this->request->getPost($field);
if ($oldVal !== $newVal) {
$this->historyModel->insert([
'bph_bp_idx' => $id,
'bph_field' => $field,
'bph_old_value' => $oldVal,
'bph_new_value' => $newVal,
'bph_changed_at'=> date('Y-m-d H:i:s'),
'bph_changed_by'=> session()->get('mb_idx'),
]);
}
}
$this->priceModel->update($id, [
'bp_order_price' => $this->request->getPost('bp_order_price'),
'bp_wholesale' => $this->request->getPost('bp_wholesale'),
'bp_consumer' => $this->request->getPost('bp_consumer'),
'bp_start_date' => $this->request->getPost('bp_start_date'),
'bp_end_date' => $this->request->getPost('bp_end_date') ?: null,
'bp_state' => (int) $this->request->getPost('bp_state'),
'bp_moddate' => date('Y-m-d H:i:s'),
]);
$db->transComplete();
return redirect()->to(site_url('admin/bag-prices'))->with('success', '봉투 단가가 수정되었습니다.');
}
public function delete(int $id)
{
helper('admin');
$item = $this->priceModel->find($id);
if (!$item || (int) $item->bp_lg_idx !== admin_effective_lg_idx()) {
return redirect()->to(site_url('admin/bag-prices'))->with('error', '단가 정보를 찾을 수 없습니다.');
}
$this->priceModel->delete($id);
return redirect()->to(site_url('admin/bag-prices'))->with('success', '봉투 단가가 삭제되었습니다.');
}
public function history(int $bpIdx)
{
helper('admin');
$item = $this->priceModel->find($bpIdx);
if (!$item || (int) $item->bp_lg_idx !== admin_effective_lg_idx()) {
return redirect()->to(site_url('admin/bag-prices'))->with('error', '단가 정보를 찾을 수 없습니다.');
}
$list = $this->historyModel->where('bph_bp_idx', $bpIdx)->orderBy('bph_changed_at', 'DESC')->findAll();
return view('admin/layout', [
'title' => '단가 변경 이력 — ' . $item->bp_bag_name,
'content' => view('admin/bag_price/history', ['item' => $item, 'list' => $list]),
]);
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BagPriceHistoryModel extends Model
{
protected $table = 'bag_price_history';
protected $primaryKey = 'bph_idx';
protected $returnType = 'object';
protected $useTimestamps = false;
protected $allowedFields = [
'bph_bp_idx', 'bph_field', 'bph_old_value', 'bph_new_value',
'bph_changed_at', 'bph_changed_by',
];
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class BagPriceModel extends Model
{
protected $table = 'bag_price';
protected $primaryKey = 'bp_idx';
protected $returnType = 'object';
protected $useTimestamps = false;
protected $allowedFields = [
'bp_lg_idx', 'bp_bag_code', 'bp_bag_name',
'bp_order_price', 'bp_wholesale', 'bp_consumer',
'bp_start_date', 'bp_end_date', 'bp_state',
'bp_regdate', 'bp_moddate', 'bp_reg_mb_idx',
];
}

View File

@@ -0,0 +1,54 @@
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
<span class="text-sm font-bold text-gray-700">봉투 단가 등록</span>
</section>
<div class="border border-gray-300 p-4 mt-2 bg-white max-w-3xl">
<form action="<?= base_url('admin/bag-prices/store') ?>" method="POST" class="space-y-4">
<?= csrf_field() ?>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">봉투 <span class="text-red-500">*</span></label>
<select class="border border-gray-300 rounded px-3 py-1.5 text-sm w-60" name="bp_bag_code" required>
<option value="">선택</option>
<?php foreach ($bagCodes as $cd): ?>
<option value="<?= esc($cd->cd_code) ?>" <?= old('bp_bag_code') === $cd->cd_code ? 'selected' : '' ?>>
<?= esc($cd->cd_code) ?> — <?= esc($cd->cd_name) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">발주단가 <span class="text-red-500">*</span></label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_order_price" type="number" step="0.01" value="<?= esc(old('bp_order_price', '0')) ?>" required/>
<span class="text-sm text-gray-500">원</span>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">도매가 <span class="text-red-500">*</span></label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_wholesale" type="number" step="0.01" value="<?= esc(old('bp_wholesale', '0')) ?>" required/>
<span class="text-sm text-gray-500">원</span>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">소비자가 <span class="text-red-500">*</span></label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_consumer" type="number" step="0.01" value="<?= esc(old('bp_consumer', '0')) ?>" required/>
<span class="text-sm text-gray-500">원</span>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">적용시작일 <span class="text-red-500">*</span></label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="bp_start_date" type="date" value="<?= esc(old('bp_start_date', date('Y-m-d'))) ?>" required/>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">적용종료일</label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="bp_end_date" type="date" value="<?= esc(old('bp_end_date')) ?>"/>
<span class="text-sm text-gray-400">비워두면 현재 적용중</span>
</div>
<div class="flex gap-2 pt-2">
<button type="submit" class="bg-btn-search text-white px-6 py-1.5 rounded-sm text-sm shadow hover:opacity-90 transition">등록</button>
<a href="<?= base_url('admin/bag-prices') ?>" class="bg-gray-200 text-gray-700 px-6 py-1.5 rounded-sm text-sm hover:bg-gray-300 transition">취소</a>
</div>
</form>
</div>

View File

@@ -0,0 +1,55 @@
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
<span class="text-sm font-bold text-gray-700">봉투 단가 수정</span>
</section>
<div class="border border-gray-300 p-4 mt-2 bg-white max-w-3xl">
<form action="<?= base_url('admin/bag-prices/update/' . (int) $item->bp_idx) ?>" method="POST" class="space-y-4">
<?= csrf_field() ?>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">봉투</label>
<span class="text-sm font-mono"><?= esc($item->bp_bag_code) ?></span>
<span class="text-sm text-gray-500"><?= esc($item->bp_bag_name) ?></span>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">발주단가 <span class="text-red-500">*</span></label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_order_price" type="number" step="0.01" value="<?= esc(old('bp_order_price', $item->bp_order_price)) ?>" required/>
<span class="text-sm text-gray-500">원</span>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">도매가 <span class="text-red-500">*</span></label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_wholesale" type="number" step="0.01" value="<?= esc(old('bp_wholesale', $item->bp_wholesale)) ?>" required/>
<span class="text-sm text-gray-500">원</span>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">소비자가 <span class="text-red-500">*</span></label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-40 text-right" name="bp_consumer" type="number" step="0.01" value="<?= esc(old('bp_consumer', $item->bp_consumer)) ?>" required/>
<span class="text-sm text-gray-500">원</span>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">적용시작일 <span class="text-red-500">*</span></label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="bp_start_date" type="date" value="<?= esc(old('bp_start_date', $item->bp_start_date)) ?>" required/>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">적용종료일</label>
<input class="border border-gray-300 rounded px-3 py-1.5 text-sm w-44" name="bp_end_date" type="date" value="<?= esc(old('bp_end_date', $item->bp_end_date)) ?>"/>
</div>
<div class="flex flex-wrap items-center gap-2">
<label class="block text-sm font-bold text-gray-700 w-28">상태 <span class="text-red-500">*</span></label>
<select class="border border-gray-300 rounded px-3 py-1.5 text-sm w-32" name="bp_state" required>
<option value="1" <?= (int) old('bp_state', $item->bp_state) === 1 ? 'selected' : '' ?>>사용</option>
<option value="0" <?= (int) old('bp_state', $item->bp_state) === 0 ? 'selected' : '' ?>>미사용</option>
</select>
</div>
<div class="flex gap-2 pt-2">
<button type="submit" class="bg-btn-search text-white px-6 py-1.5 rounded-sm text-sm shadow hover:opacity-90 transition">수정</button>
<a href="<?= base_url('admin/bag-prices') ?>" class="bg-gray-200 text-gray-700 px-6 py-1.5 rounded-sm text-sm hover:bg-gray-300 transition">취소</a>
</div>
</form>
</div>

View File

@@ -0,0 +1,34 @@
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
<div class="flex items-center gap-2">
<a href="<?= base_url('admin/bag-prices') ?>" class="text-blue-600 hover:underline text-sm">&larr; 단가 목록</a>
<span class="text-gray-400">|</span>
<span class="text-sm font-bold text-gray-700">단가 변경 이력 <?= esc($item->bp_bag_name) ?> (<?= esc($item->bp_bag_code) ?>)</span>
</div>
</section>
<div class="border border-gray-300 overflow-auto mt-2">
<table class="w-full data-table">
<thead>
<tr>
<th class="w-16">번호</th>
<th>변경 필드</th>
<th>이전 값</th>
<th>변경 값</th>
<th>변경일시</th>
</tr>
</thead>
<tbody class="text-right">
<?php foreach ($list as $row): ?>
<tr>
<td class="text-center"><?= esc($row->bph_idx) ?></td>
<td class="text-left pl-2"><?= esc($row->bph_field) ?></td>
<td><?= number_format((float) $row->bph_old_value) ?></td>
<td><?= number_format((float) $row->bph_new_value) ?></td>
<td class="text-center"><?= esc($row->bph_changed_at) ?></td>
</tr>
<?php endforeach; ?>
<?php if (empty($list)): ?>
<tr><td colspan="5" class="text-center text-gray-400 py-4">변경 이력이 없습니다.</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,60 @@
<section class="border-b border-gray-300 p-2 shrink-0 bg-control-panel">
<div class="flex flex-wrap items-center justify-between gap-y-2">
<span class="text-sm font-bold text-gray-700">봉투 단가 관리</span>
<a href="<?= base_url('admin/bag-prices/create') ?>" class="bg-btn-search text-white px-4 py-1.5 rounded-sm flex items-center gap-1 text-sm shadow hover:opacity-90 transition border border-transparent">단가 등록</a>
</div>
</section>
<section class="p-2 bg-white border-b border-gray-200">
<form method="GET" action="<?= base_url('admin/bag-prices') ?>" class="flex flex-wrap items-center gap-2">
<label class="text-sm text-gray-600">적용시작일</label>
<input type="date" name="start_date" value="<?= esc($startDate ?? '') ?>" class="border border-gray-300 rounded px-2 py-1 text-sm"/>
<label class="text-sm text-gray-600">~</label>
<input type="date" name="end_date" value="<?= esc($endDate ?? '') ?>" class="border border-gray-300 rounded px-2 py-1 text-sm"/>
<button type="submit" class="bg-btn-search text-white px-4 py-1 rounded-sm text-sm">조회</button>
<a href="<?= base_url('admin/bag-prices') ?>" class="text-sm text-gray-500 hover:underline">초기화</a>
</form>
</section>
<div class="border border-gray-300 overflow-auto mt-2">
<table class="w-full data-table">
<thead>
<tr>
<th class="w-16">번호</th>
<th>봉투코드</th>
<th>봉투명</th>
<th>발주단가</th>
<th>도매가</th>
<th>소비자가</th>
<th>적용시작</th>
<th>적용종료</th>
<th class="w-20">상태</th>
<th class="w-36">작업</th>
</tr>
</thead>
<tbody class="text-right">
<?php foreach ($list as $row): ?>
<tr>
<td class="text-center"><?= esc($row->bp_idx) ?></td>
<td class="text-center font-mono"><?= esc($row->bp_bag_code) ?></td>
<td class="text-left pl-2"><?= esc($row->bp_bag_name) ?></td>
<td><?= number_format((float) $row->bp_order_price) ?></td>
<td><?= number_format((float) $row->bp_wholesale) ?></td>
<td><?= number_format((float) $row->bp_consumer) ?></td>
<td class="text-center"><?= esc($row->bp_start_date) ?></td>
<td class="text-center"><?= esc($row->bp_end_date ?? '현재') ?></td>
<td class="text-center"><?= (int) $row->bp_state === 1 ? '사용' : '미사용' ?></td>
<td class="text-center">
<a href="<?= base_url('admin/bag-prices/history/' . (int) $row->bp_idx) ?>" class="text-green-600 hover:underline text-sm mr-1">이력</a>
<a href="<?= base_url('admin/bag-prices/edit/' . (int) $row->bp_idx) ?>" class="text-blue-600 hover:underline text-sm mr-1">수정</a>
<form action="<?= base_url('admin/bag-prices/delete/' . (int) $row->bp_idx) ?>" method="POST" class="inline" onsubmit="return confirm('삭제하시겠습니까?');">
<?= csrf_field() ?>
<button type="submit" class="text-red-600 hover:underline text-sm">삭제</button>
</form>
</td>
</tr>
<?php endforeach; ?>
<?php if (empty($list)): ?>
<tr><td colspan="10" class="text-center text-gray-400 py-4">등록된 단가가 없습니다.</td></tr>
<?php endif; ?>
</tbody>
</table>
</div>

48
e2e/bag-price.spec.js Normal file
View File

@@ -0,0 +1,48 @@
// @ts-check
const { test, expect } = require('@playwright/test');
const { login } = require('./helpers/auth');
async function loginAsAdmin(page) {
await login(page, 'admin');
await page.locator('input[name="lg_idx"]').first().check();
await page.click('button[type="submit"]');
await page.waitForURL(url => !url.pathname.includes('select-local-government'), { timeout: 15000 });
}
test.describe('P2-03/04: 봉투 단가 관리', () => {
test.beforeEach(async ({ page }) => {
await loginAsAdmin(page);
});
test('단가 목록 접근', async ({ page }) => {
await page.goto('/admin/bag-prices');
await expect(page).toHaveURL(/\/admin\/bag-prices/);
});
test('단가 등록 폼 표시', async ({ page }) => {
await page.goto('/admin/bag-prices/create');
await expect(page.locator('select[name="bp_bag_code"]')).toBeVisible();
await expect(page.locator('input[name="bp_order_price"]')).toBeVisible();
});
test('기간 필터 조회', async ({ page }) => {
await page.goto('/admin/bag-prices?start_date=2026-01-01&end_date=2026-12-31');
await expect(page).toHaveURL(/start_date/);
});
test('단가 변경 이력 페이지 (빈 상태)', async ({ page }) => {
// 먼저 데이터가 있어야 하므로, 목록 페이지만 접근 확인
await page.goto('/admin/bag-prices');
await expect(page).toHaveURL(/\/admin\/bag-prices/);
});
});
test.describe('P2-03: 지자체관리자 접근', () => {
test('지자체관리자도 단가 목록 접근 가능', async ({ page }) => {
await login(page, 'local');
await page.goto('/admin/bag-prices');
await expect(page).toHaveURL(/\/admin\/bag-prices/);
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@@ -0,0 +1,34 @@
-- ============================================
-- 봉투 단가 관리 테이블 (P2-03, P2-04)
-- ============================================
CREATE TABLE IF NOT EXISTS `bag_price` (
`bp_idx` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`bp_lg_idx` INT UNSIGNED NOT NULL COMMENT '지자체 FK',
`bp_bag_code` VARCHAR(50) NOT NULL COMMENT '봉투코드(code_detail cd_code, ck=O)',
`bp_bag_name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '봉투명(등록시점 스냅샷)',
`bp_order_price` DECIMAL(12,2) NOT NULL DEFAULT 0 COMMENT '발주단가',
`bp_wholesale` DECIMAL(12,2) NOT NULL DEFAULT 0 COMMENT '도매가',
`bp_consumer` DECIMAL(12,2) NOT NULL DEFAULT 0 COMMENT '소비자가',
`bp_start_date` DATE NOT NULL COMMENT '적용 시작일',
`bp_end_date` DATE NULL DEFAULT NULL COMMENT '적용 종료일(NULL=현재 적용중)',
`bp_state` TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '1=사용, 0=미사용',
`bp_regdate` DATETIME NOT NULL,
`bp_moddate` DATETIME NULL DEFAULT NULL,
`bp_reg_mb_idx` INT UNSIGNED NULL COMMENT '등록자',
PRIMARY KEY (`bp_idx`),
KEY `idx_bp_lg_bag` (`bp_lg_idx`, `bp_bag_code`),
KEY `idx_bp_dates` (`bp_start_date`, `bp_end_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='지자체별 봉투 단가';
CREATE TABLE IF NOT EXISTS `bag_price_history` (
`bph_idx` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`bph_bp_idx` INT UNSIGNED NOT NULL COMMENT 'bag_price FK',
`bph_field` VARCHAR(30) NOT NULL COMMENT '변경 필드명',
`bph_old_value` VARCHAR(100) NOT NULL DEFAULT '',
`bph_new_value` VARCHAR(100) NOT NULL DEFAULT '',
`bph_changed_at` DATETIME NOT NULL,
`bph_changed_by` INT UNSIGNED NULL COMMENT '변경자 mb_idx',
PRIMARY KEY (`bph_idx`),
KEY `idx_bph_bp_idx` (`bph_bp_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='봉투 단가 변경 이력';