From ec9bcbe906ece8785c750e9fd27268fa3d0ecc34 Mon Sep 17 00:00:00 2001 From: pro Date: Thu, 22 Jan 2026 16:51:56 +0900 Subject: [PATCH] =?UTF-8?q?feat:=EB=B0=94=EB=A1=9C=EB=B9=8C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EC=9D=B4=EC=9A=A9=20=EC=98=B5=EC=85=98=20?= =?UTF-8?q?=EC=B2=B4=ED=81=AC=EB=B0=95=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 4가지 서비스 옵션 체크박스 추가 (전자세금계산서, 계좌조회, 카드사용내역, 홈텍스매입/매출) - BarobillSetting 모델 및 BarobillSettingController 생성 - 설정 API 라우트 추가 (/api/admin/barobill/settings) - 담당자 정보 입력 필드 추가 (이름, 연락처, 이메일) Co-Authored-By: Claude Opus 4.5 --- .../Barobill/BarobillSettingController.php | 114 ++++++ app/Models/Barobill/BarobillSetting.php | 69 ++++ ...d_service_options_to_barobill_settings.php | 32 ++ .../views/barobill/settings/index.blade.php | 369 ++++++++++++------ routes/api.php | 7 + 5 files changed, 475 insertions(+), 116 deletions(-) create mode 100644 app/Http/Controllers/Api/Admin/Barobill/BarobillSettingController.php create mode 100644 app/Models/Barobill/BarobillSetting.php create mode 100644 database/migrations/2026_01_22_170000_add_service_options_to_barobill_settings.php diff --git a/app/Http/Controllers/Api/Admin/Barobill/BarobillSettingController.php b/app/Http/Controllers/Api/Admin/Barobill/BarobillSettingController.php new file mode 100644 index 00000000..b6ba9231 --- /dev/null +++ b/app/Http/Controllers/Api/Admin/Barobill/BarobillSettingController.php @@ -0,0 +1,114 @@ +first(); + + if (!$setting) { + // 설정이 없으면 기본값 반환 + return response()->json([ + 'success' => true, + 'data' => [ + 'use_tax_invoice' => false, + 'use_bank_account' => false, + 'use_card_usage' => false, + 'use_hometax' => false, + ], + ]); + } + + return response()->json([ + 'success' => true, + 'data' => $setting, + ]); + } + + /** + * 바로빌 설정 저장/수정 + */ + public function store(Request $request): JsonResponse + { + $tenantId = session('tenant_id', 1); + + $validated = $request->validate([ + 'use_tax_invoice' => 'nullable|boolean', + 'use_bank_account' => 'nullable|boolean', + 'use_card_usage' => 'nullable|boolean', + 'use_hometax' => 'nullable|boolean', + 'contact_name' => 'nullable|string|max:50', + 'contact_tel' => 'nullable|string|max:20', + 'contact_id' => 'nullable|email|max:100', + ]); + + try { + $setting = BarobillSetting::updateOrCreate( + ['tenant_id' => $tenantId], + array_merge($validated, [ + 'corp_name' => $validated['corp_name'] ?? '미설정', + 'ceo_name' => $validated['ceo_name'] ?? '미설정', + 'corp_num' => $validated['corp_num'] ?? '0000000000', + ]) + ); + + return response()->json([ + 'success' => true, + 'message' => '설정이 저장되었습니다.', + 'data' => $setting, + ]); + } catch (\Exception $e) { + Log::error('바로빌 설정 저장 실패', ['error' => $e->getMessage()]); + + return response()->json([ + 'success' => false, + 'message' => '설정 저장에 실패했습니다.', + ], 500); + } + } + + /** + * 서비스 이용 여부 확인 (다른 메뉴에서 참조용) + */ + public function checkService(string $service): JsonResponse + { + $tenantId = session('tenant_id', 1); + + $setting = BarobillSetting::where('tenant_id', $tenantId)->first(); + + if (!$setting) { + return response()->json([ + 'success' => true, + 'enabled' => false, + 'message' => '바로빌 설정이 없습니다.', + ]); + } + + $enabled = match ($service) { + 'tax_invoice', 'tax-invoice' => $setting->use_tax_invoice, + 'bank_account', 'bank-account' => $setting->use_bank_account, + 'card_usage', 'card-usage' => $setting->use_card_usage, + 'hometax' => $setting->use_hometax, + default => false, + }; + + return response()->json([ + 'success' => true, + 'enabled' => $enabled, + 'service' => $service, + ]); + } +} diff --git a/app/Models/Barobill/BarobillSetting.php b/app/Models/Barobill/BarobillSetting.php new file mode 100644 index 00000000..445b4352 --- /dev/null +++ b/app/Models/Barobill/BarobillSetting.php @@ -0,0 +1,69 @@ + 'boolean', + 'auto_issue' => 'boolean', + 'use_tax_invoice' => 'boolean', + 'use_bank_account' => 'boolean', + 'use_card_usage' => 'boolean', + 'use_hometax' => 'boolean', + 'verified_at' => 'datetime', + 'created_at' => 'datetime', + 'updated_at' => 'datetime', + ]; + + /** + * 테넌트 관계 + */ + public function tenant(): BelongsTo + { + return $this->belongsTo(Tenant::class); + } + + /** + * 활성화된 서비스 목록 반환 + */ + public function getActiveServicesAttribute(): array + { + $services = []; + if ($this->use_tax_invoice) $services[] = 'tax_invoice'; + if ($this->use_bank_account) $services[] = 'bank_account'; + if ($this->use_card_usage) $services[] = 'card_usage'; + if ($this->use_hometax) $services[] = 'hometax'; + return $services; + } +} diff --git a/database/migrations/2026_01_22_170000_add_service_options_to_barobill_settings.php b/database/migrations/2026_01_22_170000_add_service_options_to_barobill_settings.php new file mode 100644 index 00000000..cc20120f --- /dev/null +++ b/database/migrations/2026_01_22_170000_add_service_options_to_barobill_settings.php @@ -0,0 +1,32 @@ +boolean('use_tax_invoice')->default(false)->after('auto_issue')->comment('전자세금계산서 이용'); + $table->boolean('use_bank_account')->default(false)->after('use_tax_invoice')->comment('계좌조회 이용'); + $table->boolean('use_card_usage')->default(false)->after('use_bank_account')->comment('카드사용내역 이용'); + $table->boolean('use_hometax')->default(false)->after('use_card_usage')->comment('홈텍스매입/매출 이용'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('barobill_settings', function (Blueprint $table) { + $table->dropColumn(['use_tax_invoice', 'use_bank_account', 'use_card_usage', 'use_hometax']); + }); + } +}; diff --git a/resources/views/barobill/settings/index.blade.php b/resources/views/barobill/settings/index.blade.php index ded94449..81e635e8 100644 --- a/resources/views/barobill/settings/index.blade.php +++ b/resources/views/barobill/settings/index.blade.php @@ -13,136 +13,273 @@ -
- -
-
-
- - - -
-
-

이메일 설정

-

세금계산서 발송 이메일 설정

-
-
-
-
- - -
-
- - -
-
-
- - -
-
-
- - - -
-
-

데이터 동기화

-

바로빌 데이터 동기화 설정

-
-
-
-
-
-

자동 동기화

-

매일 자정 자동 동기화

+
+
+ +
+
+
+ + +
-
+
+ + + + + + + + + + +
-
-
- -
-
-
- - - + +
+
+
+ + + +
+
+

담당자 정보

+

세금계산서 담당자 정보

+
-
-

API 설정

-

바로빌 API 연동 설정

+
+
+ + +
+
+ + +
+
+ + +
-
-
- - + + +
+
+
+ + + +
+
+

데이터 동기화

+

바로빌 데이터 동기화 설정

+
-
- - - - API 연결 상태: 정상 +
+
+
+

자동 동기화

+

매일 자정 자동 동기화

+
+ +
+
- -
-
-
- - - -
-
-

알림 설정

-

세금계산서 관련 알림

-
-
-
-
- 발행 완료 알림 - -
-
- 수신 알림 - -
-
- 만료 예정 알림 - -
-
+ +
+ +
-
+ - -
- -
+ +
@endsection + +@push('scripts') + +@endpush diff --git a/routes/api.php b/routes/api.php index 5f661e8f..aefccab6 100644 --- a/routes/api.php +++ b/routes/api.php @@ -100,6 +100,13 @@ Route::post('/sync', [\App\Http\Controllers\Api\Admin\Barobill\BarobillConfigController::class, 'syncCompanies'])->name('sync'); }); + // 바로빌 설정 API (회원사용) + Route::prefix('barobill/settings')->name('barobill.settings.')->group(function () { + Route::get('/', [\App\Http\Controllers\Api\Admin\Barobill\BarobillSettingController::class, 'show'])->name('show'); + Route::post('/', [\App\Http\Controllers\Api\Admin\Barobill\BarobillSettingController::class, 'store'])->name('store'); + Route::get('/check/{service}', [\App\Http\Controllers\Api\Admin\Barobill\BarobillSettingController::class, 'checkService'])->name('check'); + }); + // 바로빌 회원사 관리 API Route::prefix('barobill/members')->name('barobill.members.')->group(function () { // 통계