fix: [account-codes] 계정과목 중복 데이터 정리 마이그레이션
- 비표준 코드(5자리 KIS 중복, 1-2자리 카테고리 헤더) 비활성화 - 홈택스 분개 코드 수정: 135→117, 251→201, 255→208
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* 계정과목 중복 데이터 정리 및 홈택스 분개 코드 수정
|
||||
*
|
||||
* 문제: 5자리 KIS 코드가 5회씩 중복 등록 (2386개), 1-2자리 카테고리 헤더 포함
|
||||
* → 드롭다운에 2549개 표시 (정상: 163개)
|
||||
*
|
||||
* 홈택스 분개 기본 코드 불일치:
|
||||
* - 135(미존재) → 117(부가세대급금)
|
||||
* - 251(장기차입금) → 201(외상매입금)
|
||||
* - 255(장기미지급금) → 208(부가세예수금)
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// 1. 3자리가 아닌 코드 비활성화 (5자리 KIS 중복, 1-2자리 카테고리 헤더)
|
||||
$deactivated = DB::table('account_codes')
|
||||
->where('is_active', true)
|
||||
->whereRaw('LENGTH(code) != 3')
|
||||
->update(['is_active' => false]);
|
||||
|
||||
// 2. 홈택스 분개에서 잘못된 코드 수정
|
||||
$fixed135 = DB::table('hometax_invoice_journals')
|
||||
->where('account_code', '135')
|
||||
->update(['account_code' => '117', 'account_name' => '부가세대급금']);
|
||||
|
||||
$fixed251 = DB::table('hometax_invoice_journals')
|
||||
->where('account_code', '251')
|
||||
->where('account_name', '외상매입금')
|
||||
->update(['account_code' => '201']);
|
||||
|
||||
$fixed255 = DB::table('hometax_invoice_journals')
|
||||
->where('account_code', '255')
|
||||
->where('account_name', '부가세예수금')
|
||||
->update(['account_code' => '208']);
|
||||
|
||||
Log::info('[Migration] 계정과목 정리 완료', [
|
||||
'deactivated_codes' => $deactivated,
|
||||
'fixed_135_to_117' => $fixed135,
|
||||
'fixed_251_to_201' => $fixed251,
|
||||
'fixed_255_to_208' => $fixed255,
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// 비활성화된 비표준 코드 복원
|
||||
DB::table('account_codes')
|
||||
->where('is_active', false)
|
||||
->whereRaw('LENGTH(code) != 3')
|
||||
->update(['is_active' => true]);
|
||||
|
||||
// 분개 코드 원복
|
||||
DB::table('hometax_invoice_journals')
|
||||
->where('account_code', '117')
|
||||
->where('account_name', '부가세대급금')
|
||||
->update(['account_code' => '135']);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user