diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-12 19:46:54 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-12 19:46:54 +0900 |
| commit | 78454bb1c87b08e9a9d49cbaf5c093c39e675157 (patch) | |
| tree | 6e17a2d32acdfb290b2fd814228a9f7977f4bc4c /lib/soap | |
| parent | 8642ee064ddf96f1db2b948b4cc8bbbd6cfee820 (diff) | |
(김준회) MDG 벤더 송신: TAXTYPE 및 TAXNUM 매핑 변경
Diffstat (limited to 'lib/soap')
| -rw-r--r-- | lib/soap/mdg/send/vendor-master/send-single-vendor.ts | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/lib/soap/mdg/send/vendor-master/send-single-vendor.ts b/lib/soap/mdg/send/vendor-master/send-single-vendor.ts index bf040b36..0eceac8a 100644 --- a/lib/soap/mdg/send/vendor-master/send-single-vendor.ts +++ b/lib/soap/mdg/send/vendor-master/send-single-vendor.ts @@ -167,6 +167,44 @@ function mapVendorToMDGFormat( const phoneStr = vendor.phone?.trim() || '' const isMobile = phoneStr.startsWith('+8210') ? '1' : '0' + // === 세금 정보 처리 (분기 로직) === + let taxType = 'KR1' // 기본값 + let taxNum = '' + + if (vendor.taxId) { + // 분기1: 사업자등록번호가 있는 경우 + taxType = 'KR2' + taxNum = vendor.taxId.replace(/-/g, '') + debugLog(`💳 [Tax Info] 사업자등록번호 사용: ${taxNum}`) + } else if (vendor.corporateRegistrationNumber) { + // 분기2: 법인등록번호가 있는 경우 + taxType = 'KR1' + taxNum = vendor.corporateRegistrationNumber.replace(/-/g, '') + debugLog(`💳 [Tax Info] 법인등록번호 사용: ${taxNum}`) + } else if (vendor.representativeBirth) { + // 분기3: 대표자생년월일이 있는 경우 (YYMMDD0000000 형식) + taxType = 'KR1' + // representativeBirth 포맷 처리 (YYYYMMDD 또는 YYMMDD 형식으로 가정) + const birthStr = vendor.representativeBirth.replace(/[-\s]/g, '') // 하이픈, 공백 제거 + let yymmdd = '' + + if (birthStr.length === 8) { + // YYYYMMDD 형식인 경우 -> YYMMDD로 변환 + yymmdd = birthStr.substring(2, 8) + } else if (birthStr.length === 6) { + // YYMMDD 형식인 경우 + yymmdd = birthStr + } else { + debugError(`⚠️ [Tax Info] 대표자생년월일 형식 오류: ${vendor.representativeBirth}`) + yymmdd = birthStr.padEnd(6, '0').substring(0, 6) // 6자리로 맞춤 + } + + taxNum = `${yymmdd}0000000` + debugLog(`💳 [Tax Info] 대표자생년월일 사용: ${taxNum} (원본: ${vendor.representativeBirth})`) + } else { + debugError(`⚠️ [Tax Info] 세금 정보를 찾을 수 없음 (taxId, corporateRegistrationNumber, representativeBirth 모두 없음)`) + } + // 기본 매핑 (신규 벤더) const mapping: Record<string, string> = { // === 필수 필드 (고정값) === @@ -193,9 +231,9 @@ function mapVendorToMDGFormat( ADDRNO: '', // 빈 문자열 (보내면 안됨) NATION: '', // 빈 문자열 (보내면 안됨) COUNTRY: vendor.country || 'KR', // 국가코드 (기본값 KR) - POST_CODE1: vendor.postalCode || '00000', // 우편번호 (없으면 00000) - CITY1: vendor.addressDetail || '상세주소 정보가 없습니다', // 상세주소 (없으면 fallback) - STREET: vendor.address || '주소 정보가 없습니다', // 기본주소 (없으면 fallback) + POST_CODE1: vendor.postalCode || '', // 우편번호 (없으면 빈 문자열) + CITY1: vendor.addressDetail || '', // 상세주소 (없으면 빈 문자열) + STREET: vendor.address || '', // 기본주소 (없으면 빈 문자열) // === 연락처 정보 === TEL_NUMBER: vendor.phone || '', // 전화번호 @@ -203,10 +241,10 @@ function mapVendorToMDGFormat( URI_ADDR: vendor.website || '', // 홈페이지 주소 SMTP_ADDR: vendor.representativeEmail || '', // 대표자 이메일 - // === 세금 정보 === - TAXTYPE: 'KR2', // 고정값 (한국) - TAXNUM: vendor.taxId?.replace(/-/g, '') || '', // 사업자번호 (하이픈 제거) - BP_TX_TYP: 'KR2', // 고정값 (한국) + // === 세금 정보 (분기 처리) === + TAXTYPE: taxType, // KR1 또는 KR2 + TAXNUM: taxNum, // 사업자번호/법인등록번호/대표자생년월일 + BP_TX_TYP: taxType, // TAXTYPE과 동일 STCD3: vendor.corporateRegistrationNumber?.replace(/-/g, '') || '', // 법인등록번호 (하이픈 제거) // === 기업 정보 === |
