Files
sam-api/database/seeders/NumberingRuleSeeder.php
권혁성 78851ec04a feat: 테넌트별 채번 규칙 시스템 구현
- numbering_rules 테이블: JSON 패턴 기반 채번 규칙 저장 (tenant별)
- numbering_sequences 테이블: MySQL UPSERT 기반 atomic 시퀀스 관리
- NumberingService: generate/preview/nextSequence 핵심 서비스
- QuoteNumberService: NumberingService 우선, 폴백 QT{YYYYMMDD}{NNNN}
- OrderService: NumberingService 우선 (pair_code 지원), 폴백 ORD{YYYYMMDD}{NNNN}
- StoreOrderRequest: pair_code 필드 추가
- NumberingRuleSeeder: tenant_id=287 견적(KD-PR)/수주(KD-{pairCode}) 규칙

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 09:50:52 +09:00

58 lines
2.1 KiB
PHP

<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class NumberingRuleSeeder extends Seeder
{
public function run(): void
{
$tenantId = 287;
// 견적번호 규칙: KD-PR-{YYMMDD}-{NN}
DB::table('numbering_rules')->updateOrInsert(
['tenant_id' => $tenantId, 'document_type' => 'quote'],
[
'rule_name' => '5130 견적번호',
'pattern' => json_encode([
['type' => 'static', 'value' => 'KD'],
['type' => 'separator', 'value' => '-'],
['type' => 'static', 'value' => 'PR'],
['type' => 'separator', 'value' => '-'],
['type' => 'date', 'format' => 'ymd'],
['type' => 'separator', 'value' => '-'],
['type' => 'sequence'],
]),
'reset_period' => 'daily',
'sequence_padding' => 2,
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
]
);
// 수주 로트번호 규칙: KD-{pairCode}-{YYMMDD}-{NN}
DB::table('numbering_rules')->updateOrInsert(
['tenant_id' => $tenantId, 'document_type' => 'order'],
[
'rule_name' => '5130 수주 로트번호',
'pattern' => json_encode([
['type' => 'static', 'value' => 'KD'],
['type' => 'separator', 'value' => '-'],
['type' => 'param', 'key' => 'pair_code', 'default' => 'SS'],
['type' => 'separator', 'value' => '-'],
['type' => 'date', 'format' => 'ymd'],
['type' => 'separator', 'value' => '-'],
['type' => 'sequence'],
]),
'reset_period' => 'daily',
'sequence_padding' => 2,
'is_active' => true,
'created_at' => now(),
'updated_at' => now(),
]
);
}
}