feat:바로빌 설정 페이지에 서비스 이용 옵션 체크박스 추가
- 4가지 서비스 옵션 체크박스 추가 (전자세금계산서, 계좌조회, 카드사용내역, 홈텍스매입/매출) - BarobillSetting 모델 및 BarobillSettingController 생성 - 설정 API 라우트 추가 (/api/admin/barobill/settings) - 담당자 정보 입력 필드 추가 (이름, 연락처, 이메일) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Admin\Barobill;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Barobill\BarobillSetting;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class BarobillSettingController extends Controller
|
||||
{
|
||||
/**
|
||||
* 현재 테넌트의 바로빌 설정 조회
|
||||
*/
|
||||
public function show(): JsonResponse
|
||||
{
|
||||
$tenantId = session('tenant_id', 1);
|
||||
|
||||
$setting = BarobillSetting::where('tenant_id', $tenantId)->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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user