fix:홈택스 API 호출 시 테넌트 사업자번호 사용
- CorpNum을 파트너사 사업자번호 대신 테넌트 사업자번호로 변경 - 바로빌 회원사 정보 없을 때 명확한 에러 메시지 반환 - 에러 메시지 개선 (-10008, -60001 등) - 진단 기능에서 파트너사/테넌트 사업자번호 구분 표시 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -99,9 +99,26 @@ public function sales(Request $request): JsonResponse
|
||||
// 현재 테넌트의 바로빌 회원 정보 조회
|
||||
$tenantId = session('selected_tenant_id', self::HEADQUARTERS_TENANT_ID);
|
||||
$barobillMember = BarobillMember::where('tenant_id', $tenantId)->first();
|
||||
$userId = $barobillMember?->barobill_id ?? '';
|
||||
|
||||
if (!$barobillMember) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => '바로빌 회원사 정보가 없습니다. 테넌트 설정을 확인해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
$userId = $barobillMember->barobill_id ?? '';
|
||||
$memberCorpNum = $barobillMember->biz_no ?? '';
|
||||
|
||||
if (empty($memberCorpNum)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => '테넌트의 사업자번호가 설정되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$result = $this->callSoap('GetPeriodTaxInvoiceSalesList', [
|
||||
'CorpNum' => $memberCorpNum, // 테넌트의 사업자번호 사용
|
||||
'UserID' => $userId,
|
||||
'TaxType' => $taxType,
|
||||
'DateType' => 1, // 1:작성일 기준
|
||||
@@ -183,9 +200,26 @@ public function purchases(Request $request): JsonResponse
|
||||
// 현재 테넌트의 바로빌 회원 정보 조회
|
||||
$tenantId = session('selected_tenant_id', self::HEADQUARTERS_TENANT_ID);
|
||||
$barobillMember = BarobillMember::where('tenant_id', $tenantId)->first();
|
||||
$userId = $barobillMember?->barobill_id ?? '';
|
||||
|
||||
if (!$barobillMember) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => '바로빌 회원사 정보가 없습니다. 테넌트 설정을 확인해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
$userId = $barobillMember->barobill_id ?? '';
|
||||
$memberCorpNum = $barobillMember->biz_no ?? '';
|
||||
|
||||
if (empty($memberCorpNum)) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => '테넌트의 사업자번호가 설정되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$result = $this->callSoap('GetPeriodTaxInvoicePurchaseList', [
|
||||
'CorpNum' => $memberCorpNum, // 테넌트의 사업자번호 사용
|
||||
'UserID' => $userId,
|
||||
'TaxType' => $taxType,
|
||||
'DateType' => 1, // 1:작성일 기준
|
||||
@@ -262,9 +296,19 @@ public function getScrapRequestUrl(Request $request): JsonResponse
|
||||
try {
|
||||
$tenantId = session('selected_tenant_id', self::HEADQUARTERS_TENANT_ID);
|
||||
$barobillMember = BarobillMember::where('tenant_id', $tenantId)->first();
|
||||
$userId = $barobillMember?->barobill_id ?? '';
|
||||
|
||||
if (!$barobillMember) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => '바로빌 회원사 정보가 없습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$userId = $barobillMember->barobill_id ?? '';
|
||||
$memberCorpNum = $barobillMember->biz_no ?? '';
|
||||
|
||||
$result = $this->callSoap('GetTaxInvoiceScrapRequestURL', [
|
||||
'CorpNum' => $memberCorpNum,
|
||||
'UserID' => $userId
|
||||
]);
|
||||
|
||||
@@ -317,9 +361,19 @@ public function refreshScrap(Request $request): JsonResponse
|
||||
try {
|
||||
$tenantId = session('selected_tenant_id', self::HEADQUARTERS_TENANT_ID);
|
||||
$barobillMember = BarobillMember::where('tenant_id', $tenantId)->first();
|
||||
$userId = $barobillMember?->barobill_id ?? '';
|
||||
|
||||
if (!$barobillMember) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => '바로빌 회원사 정보가 없습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$userId = $barobillMember->barobill_id ?? '';
|
||||
$memberCorpNum = $barobillMember->biz_no ?? '';
|
||||
|
||||
$result = $this->callSoap('RefreshTaxInvoiceScrap', [
|
||||
'CorpNum' => $memberCorpNum,
|
||||
'UserID' => $userId
|
||||
]);
|
||||
|
||||
@@ -375,20 +429,23 @@ public function diagnose(Request $request): JsonResponse
|
||||
$diagnostics = [
|
||||
'config' => [
|
||||
'certKey' => !empty($this->certKey) ? substr($this->certKey, 0, 8) . '...' : '미설정',
|
||||
'corpNum' => $this->corpNum ?? '미설정',
|
||||
'partnerCorpNum' => $this->corpNum ?? '미설정', // 파트너사 사업자번호
|
||||
'isTestMode' => $this->isTestMode,
|
||||
'baseUrl' => $this->baseUrl
|
||||
],
|
||||
'member' => [
|
||||
'userId' => $userId ?: '미설정',
|
||||
'bizNo' => $memberCorpNum ?: '미설정',
|
||||
'bizNo' => $memberCorpNum ?: '미설정', // 테넌트 사업자번호 (실제 API 호출에 사용)
|
||||
'corpName' => $barobillMember?->corp_name ?? '미설정'
|
||||
],
|
||||
'tests' => []
|
||||
];
|
||||
|
||||
// 테스트 1: 홈택스 스크래핑 URL 조회 (서비스 활성화 확인용)
|
||||
$scrapUrlResult = $this->callSoap('GetTaxInvoiceScrapRequestURL', ['UserID' => $userId]);
|
||||
$scrapUrlResult = $this->callSoap('GetTaxInvoiceScrapRequestURL', [
|
||||
'CorpNum' => $memberCorpNum,
|
||||
'UserID' => $userId
|
||||
]);
|
||||
$diagnostics['tests']['scrapRequestUrl'] = [
|
||||
'method' => 'GetTaxInvoiceScrapRequestURL',
|
||||
'success' => $scrapUrlResult['success'],
|
||||
@@ -399,6 +456,7 @@ public function diagnose(Request $request): JsonResponse
|
||||
|
||||
// 테스트 2: 매출 세금계산서 조회 (기간: 최근 1개월)
|
||||
$salesResult = $this->callSoap('GetPeriodTaxInvoiceSalesList', [
|
||||
'CorpNum' => $memberCorpNum, // 테넌트 사업자번호 사용
|
||||
'UserID' => $userId,
|
||||
'TaxType' => 0,
|
||||
'DateType' => 1,
|
||||
@@ -418,7 +476,10 @@ public function diagnose(Request $request): JsonResponse
|
||||
];
|
||||
|
||||
// 테스트 3: 회원사 로그인 URL 조회 (기본 연결 확인용)
|
||||
$loginUrlResult = $this->callSoap('GetLoginURL', ['UserID' => $userId]);
|
||||
$loginUrlResult = $this->callSoap('GetLoginURL', [
|
||||
'CorpNum' => $memberCorpNum,
|
||||
'UserID' => $userId
|
||||
]);
|
||||
$diagnostics['tests']['loginUrl'] = [
|
||||
'method' => 'GetLoginURL',
|
||||
'success' => $loginUrlResult['success'],
|
||||
@@ -575,16 +636,16 @@ private function getErrorMessage(int $errorCode): string
|
||||
{
|
||||
$messages = [
|
||||
-10002 => '인증 실패 (-10002). CERTKEY가 올바르지 않거나 만료되었습니다.',
|
||||
-10008 => '등록되지 않은 사용자입니다 (-10008). 바로빌 회원사 ID를 확인해주세요.',
|
||||
-10008 => '등록되지 않은 사용자입니다 (-10008). 바로빌에 등록된 사업자번호/사용자ID를 확인해주세요.',
|
||||
-11010 => '세금계산서 조회 권한이 없습니다 (-11010). 바로빌 사이트에서 서비스 권한을 확인해주세요.',
|
||||
-24005 => 'UserID가 필요합니다 (-24005). 바로빌 회원사 ID를 설정해주세요.',
|
||||
-24006 => '조회된 데이터가 없습니다 (-24006).',
|
||||
-25005 => '조회된 데이터가 없습니다 (-25005).',
|
||||
-60001 => '등록된 홈택스 정보가 없습니다 (-60001).',
|
||||
-60002 => '홈택스 인증서가 등록되지 않았습니다 (-60002).',
|
||||
-60003 => '홈택스 수집 서비스가 활성화되지 않았습니다 (-60003).',
|
||||
-60004 => '홈택스 부서사용자 ID가 등록되지 않았습니다 (-60004).',
|
||||
-60005 => '조회된 데이터가 없습니다 (-60005).',
|
||||
-60001 => '등록된 홈택스 정보가 없습니다 (-60001). 바로빌에서 홈택스 연동 설정이 필요합니다.',
|
||||
-60002 => '홈택스 인증서가 등록되지 않았습니다 (-60002). 바로빌에서 홈택스 인증서 등록이 필요합니다.',
|
||||
-60003 => '홈택스 수집 서비스가 활성화되지 않았습니다 (-60003). 바로빌에서 서비스 신청이 필요합니다.',
|
||||
-60004 => '홈택스 부서사용자 ID가 등록되지 않았습니다 (-60004). 바로빌에서 홈택스 연동 설정이 필요합니다.',
|
||||
-60005 => '조회된 데이터가 없습니다 (-60005). 해당 기간에 세금계산서가 없습니다.',
|
||||
-60010 => '홈택스 로그인 실패 (-60010). 부서사용자 ID/비밀번호를 확인해주세요.',
|
||||
-60011 => '홈택스 데이터 수집 중입니다 (-60011). 잠시 후 다시 조회해주세요.',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user