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 () { // 통계