refactor: 하드코딩된 validation을 common_codes 기반으로 변경
- item_type_code: 기존 PRODUCT,MATERIAL 고정값 → common_codes 조회 - margin_rate: max:100 제한 제거 (100% 초과 마진 허용) - client_type: 매입/매출/매입매출 common_codes로 이동 - bad_debt_progress: 협의중/소송중/회수완료/대손처리 common_codes로 이동 - product_category: 스크린/스틸 common_codes로 이동 - 마이그레이션 추가: client_type, bad_debt_progress, product_category 코드 그룹 수정 파일: - PriceStoreRequest, PriceUpdateRequest - ClientStoreRequest, ClientUpdateRequest - QuoteStoreRequest, QuoteUpdateRequest 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$now = now();
|
||||
|
||||
// client_type 코드 그룹
|
||||
$clientTypes = [
|
||||
['code' => 'PURCHASE', 'name' => '매입', 'sort_order' => 1],
|
||||
['code' => 'SALES', 'name' => '매출', 'sort_order' => 2],
|
||||
['code' => 'BOTH', 'name' => '매입매출', 'sort_order' => 3],
|
||||
];
|
||||
|
||||
foreach ($clientTypes as $item) {
|
||||
DB::table('common_codes')->updateOrInsert(
|
||||
['code_group' => 'client_type', 'code' => $item['code']],
|
||||
[
|
||||
'code_group' => 'client_type',
|
||||
'code' => $item['code'],
|
||||
'name' => $item['name'],
|
||||
'sort_order' => $item['sort_order'],
|
||||
'is_active' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// bad_debt_progress 코드 그룹 (악성채권 진행상태)
|
||||
$badDebtProgress = [
|
||||
['code' => 'NEGOTIATING', 'name' => '협의중', 'sort_order' => 1],
|
||||
['code' => 'LITIGATION', 'name' => '소송중', 'sort_order' => 2],
|
||||
['code' => 'RECOVERED', 'name' => '회수완료', 'sort_order' => 3],
|
||||
['code' => 'WRITTEN_OFF', 'name' => '대손처리', 'sort_order' => 4],
|
||||
];
|
||||
|
||||
foreach ($badDebtProgress as $item) {
|
||||
DB::table('common_codes')->updateOrInsert(
|
||||
['code_group' => 'bad_debt_progress', 'code' => $item['code']],
|
||||
[
|
||||
'code_group' => 'bad_debt_progress',
|
||||
'code' => $item['code'],
|
||||
'name' => $item['name'],
|
||||
'sort_order' => $item['sort_order'],
|
||||
'is_active' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// product_category 코드 그룹 (견적 제품 카테고리)
|
||||
$productCategories = [
|
||||
['code' => 'SCREEN', 'name' => '스크린', 'sort_order' => 1],
|
||||
['code' => 'STEEL', 'name' => '스틸', 'sort_order' => 2],
|
||||
];
|
||||
|
||||
foreach ($productCategories as $item) {
|
||||
DB::table('common_codes')->updateOrInsert(
|
||||
['code_group' => 'product_category', 'code' => $item['code']],
|
||||
[
|
||||
'code_group' => 'product_category',
|
||||
'code' => $item['code'],
|
||||
'name' => $item['name'],
|
||||
'sort_order' => $item['sort_order'],
|
||||
'is_active' => true,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
DB::table('common_codes')->where('code_group', 'client_type')->delete();
|
||||
DB::table('common_codes')->where('code_group', 'bad_debt_progress')->delete();
|
||||
DB::table('common_codes')->where('code_group', 'product_category')->delete();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user