diff --git a/database/migrations/2026_03_11_101502_fix_account_codes_duplicate_data.php b/database/migrations/2026_03_11_101502_fix_account_codes_duplicate_data.php new file mode 100644 index 0000000..197e599 --- /dev/null +++ b/database/migrations/2026_03_11_101502_fix_account_codes_duplicate_data.php @@ -0,0 +1,65 @@ +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']); + } +};