diff options
| author | joonhoekim <26rote@gmail.com> | 2025-08-27 01:52:54 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-08-27 01:52:54 +0000 |
| commit | 818a500d9969d1c03098f612bb0b68502b6a5ae2 (patch) | |
| tree | d1b52f040972696993502dfa8a71f7bb1bc89cc2 /lib/soap/ecc | |
| parent | f61e9e9c6ea5b415d64ecb9f703a0633a5029da4 (diff) | |
(김준회) soap sender 함수 오류수정 및 벤더마스터 전송함수 리팩터링
Diffstat (limited to 'lib/soap/ecc')
| -rw-r--r-- | lib/soap/ecc/send/cancel-rfq.ts | 57 | ||||
| -rw-r--r-- | lib/soap/ecc/send/create-po.ts | 30 | ||||
| -rw-r--r-- | lib/soap/ecc/send/pcr-confirm.ts | 240 | ||||
| -rw-r--r-- | lib/soap/ecc/send/rfq-info.ts | 114 |
4 files changed, 15 insertions, 426 deletions
diff --git a/lib/soap/ecc/send/cancel-rfq.ts b/lib/soap/ecc/send/cancel-rfq.ts index b26ca38b..bcbe0c7a 100644 --- a/lib/soap/ecc/send/cancel-rfq.ts +++ b/lib/soap/ecc/send/cancel-rfq.ts @@ -21,7 +21,7 @@ export interface CancelRFQResponse { // SOAP Body Content 생성 함수 function createCancelRFQSoapBodyContent(rfqData: CancelRFQRequest): Record<string, unknown> { return { - 'ns0:MT_P2MM3016_S': { + 'p1:MT_P2MM3016_S': { // WSDL에서 사용하는 p1 접두사 적용 'T_ANFNR': rfqData.T_ANFNR } }; @@ -71,7 +71,8 @@ async function sendCancelRFQToECC(rfqData: CancelRFQRequest): Promise<SoapSendRe timeout: 30000, // RFQ 취소는 30초 타임아웃 retryCount: 3, retryDelay: 1000, - namespace: 'http://shi.samsung.co.kr/P2_MM/MMM' // ECC MM 모듈 네임스페이스 + namespace: 'http://shi.samsung.co.kr/P2_MM/MMM', // ECC MM 모듈 네임스페이스 + prefix: 'p1' // WSDL에서 사용하는 p1 접두사 }; // 로그 정보 @@ -297,54 +298,4 @@ export async function cancelTestRFQ(): Promise<{ } } -// ======================================== -// 유틸리티 함수들 -// ======================================== - -// RFQ 취소 데이터 생성 헬퍼 함수 -function createCancelRFQData(rfqNumbers: string[]): CancelRFQRequest { - return { - T_ANFNR: rfqNumbers.map(rfqNumber => ({ ANFNR: rfqNumber })) - }; -} - -// RFQ 번호 검증 함수 -function validateRFQNumber(rfqNumber: string): { isValid: boolean; error?: string } { - if (!rfqNumber || typeof rfqNumber !== 'string') { - return { isValid: false, error: 'RFQ 번호는 문자열이어야 합니다.' }; - } - - const trimmed = rfqNumber.trim(); - if (trimmed === '') { - return { isValid: false, error: 'RFQ 번호는 비어있을 수 없습니다.' }; - } - - // 기본적인 길이 검증 (10자 제한 - WSDL에서 CHAR 10으로 정의) - if (trimmed.length > 10) { - return { isValid: false, error: 'RFQ 번호는 10자를 초과할 수 없습니다.' }; - } - - return { isValid: true }; -} - -// 여러 RFQ 번호 검증 함수 -function validateRFQNumbers(rfqNumbers: string[]): { isValid: boolean; errors: string[] } { - const errors: string[] = []; - - if (!Array.isArray(rfqNumbers) || rfqNumbers.length === 0) { - errors.push('최소 1개 이상의 RFQ 번호가 필요합니다.'); - return { isValid: false, errors }; - } - - rfqNumbers.forEach((rfqNumber, index) => { - const validation = validateRFQNumber(rfqNumber); - if (!validation.isValid) { - errors.push(`RFQ[${index}]: ${validation.error}`); - } - }); - - return { - isValid: errors.length === 0, - errors - }; -}
\ No newline at end of file +// 사용하지 않는 유틸리티 함수들 삭제 (linter 오류 해결)
\ No newline at end of file diff --git a/lib/soap/ecc/send/create-po.ts b/lib/soap/ecc/send/create-po.ts index d44f091b..0d992fb3 100644 --- a/lib/soap/ecc/send/create-po.ts +++ b/lib/soap/ecc/send/create-po.ts @@ -70,7 +70,7 @@ export interface POCreateRequest { // SOAP Body Content 생성 함수 function createPOSoapBodyContent(poData: POCreateRequest): Record<string, unknown> { return { - 'ns0:MT_P2MM3015_S': { + 'p1:MT_P2MM3015_S': { // WSDL에서 사용하는 p1 접두사 적용 'T_Bidding_HEADER': poData.T_Bidding_HEADER, 'T_Bidding_ITEM': poData.T_Bidding_ITEM, 'T_PR_RETURN': poData.T_PR_RETURN, @@ -155,7 +155,8 @@ async function sendPOToECC(poData: POCreateRequest): Promise<SoapSendResult> { timeout: 60000, // PO 생성은 60초 타임아웃 retryCount: 3, retryDelay: 2000, - namespace: 'http://shi.samsung.co.kr/P2_MM/MMM' // ECC MM 모듈 네임스페이스 + namespace: 'http://shi.samsung.co.kr/P2_MM/MMM', // ECC MM 모듈 네임스페이스 + prefix: 'p1' // WSDL에서 사용하는 p1 접두사 }; // 로그 정보 @@ -392,27 +393,4 @@ export async function checkPOCreationStatus(biddingNumber: string): Promise<{ } } -// ======================================== -// 유틸리티 함수들 -// ======================================== - -// PO 데이터 생성 헬퍼 함수 -function createPOData( - headers: POHeaderData[], - items: POItemData[], - prReturns: PRReturnData[], - options?: { - extractDate?: string; - extractTime?: string; - } -): POCreateRequest { - return { - T_Bidding_HEADER: headers, - T_Bidding_ITEM: items, - T_PR_RETURN: prReturns, - EV_ERDAT: options?.extractDate || getCurrentSAPDate(), - EV_ERZET: options?.extractTime || getCurrentSAPTime() - }; -} - -// 날짜/시간 포맷 변환 함수들은 @/lib/soap/utils에서 import하여 사용 +// 사용하지 않는 유틸리티 함수들 삭제 (linter 오류 해결) diff --git a/lib/soap/ecc/send/pcr-confirm.ts b/lib/soap/ecc/send/pcr-confirm.ts index 46d1a909..72d4a574 100644 --- a/lib/soap/ecc/send/pcr-confirm.ts +++ b/lib/soap/ecc/send/pcr-confirm.ts @@ -64,7 +64,7 @@ export interface PCRConfirmResponse { // SOAP Body Content 생성 함수 function createPCRConfirmSoapBodyContent(pcrData: PCRConfirmRequest): Record<string, unknown> { return { - 'ns0:MT_P2MM3019_S': { + 'p1:MT_P2MM3019_S': { // WSDL에서 사용하는 p1 접두사 적용 'ZMM_PCR': pcrData.ZMM_PCR } }; @@ -168,7 +168,8 @@ async function sendPCRConfirmToECC(pcrData: PCRConfirmRequest): Promise<SoapSend timeout: 30000, // PCR 확인은 30초 타임아웃 retryCount: 3, retryDelay: 1000, - namespace: 'http://shi.samsung.co.kr/P2_MM/MMM' // ECC MM 모듈 네임스페이스 + namespace: 'http://shi.samsung.co.kr/P2_MM/MMM', // ECC MM 모듈 네임스페이스 + prefix: 'p1' // WSDL에서 사용하는 p1 접두사 }; // 로그 정보 @@ -447,237 +448,4 @@ export async function confirmTestPCR(): Promise<{ } } -// ======================================== -// 유틸리티 함수들 -// ======================================== - -// PCR 확인 데이터 생성 헬퍼 함수 -function createPCRConfirmData(pcrItems: Array<{ - PCR_REQ: string; - PCR_REQ_SEQ: string; - PCR_DEC_DATE: string; - EBELN: string; - EBELP: string; - PCR_STATUS: string; - WAERS?: string; - PCR_NETPR?: string; - PEINH?: string; - PCR_NETWR?: string; - REJ_CD?: string; - REJ_RSN?: string; - CONFIRM_CD?: string; - CONFIRM_RSN?: string; -}>): PCRConfirmRequest { - return { - ZMM_PCR: pcrItems - }; -} - -// PCR 요청번호 검증 함수 -function validatePCRNumber(pcrReq: string): { isValid: boolean; error?: string } { - if (!pcrReq || typeof pcrReq !== 'string') { - return { isValid: false, error: 'PCR 요청번호는 문자열이어야 합니다.' }; - } - - const trimmed = pcrReq.trim(); - if (trimmed === '') { - return { isValid: false, error: 'PCR 요청번호는 비어있을 수 없습니다.' }; - } - - // 기본적인 길이 검증 (10자 제한 - WSDL에서 CHAR 10으로 정의) - if (trimmed.length > 10) { - return { isValid: false, error: 'PCR 요청번호는 10자를 초과할 수 없습니다.' }; - } - - return { isValid: true }; -} - -// PCR 요청순번 검증 함수 -function validatePCRSequence(pcrReqSeq: string): { isValid: boolean; error?: string } { - if (!pcrReqSeq || typeof pcrReqSeq !== 'string') { - return { isValid: false, error: 'PCR 요청순번은 문자열이어야 합니다.' }; - } - - const trimmed = pcrReqSeq.trim(); - if (trimmed === '') { - return { isValid: false, error: 'PCR 요청순번은 비어있을 수 없습니다.' }; - } - - // 숫자 형식 검증 (NUMC 5자리) - if (!/^\d{1,5}$/.test(trimmed)) { - return { isValid: false, error: 'PCR 요청순번은 1-5자리 숫자여야 합니다.' }; - } - - return { isValid: true }; -} - -// PCR 결정일 검증 함수 -function validatePCRDecisionDate(pcrDecDate: string): { isValid: boolean; error?: string } { - if (!pcrDecDate || typeof pcrDecDate !== 'string') { - return { isValid: false, error: 'PCR 결정일은 문자열이어야 합니다.' }; - } - - const trimmed = pcrDecDate.trim(); - if (trimmed === '') { - return { isValid: false, error: 'PCR 결정일은 비어있을 수 없습니다.' }; - } - - // YYYYMMDD 형식 검증 - if (!/^\d{8}$/.test(trimmed)) { - return { isValid: false, error: 'PCR 결정일은 YYYYMMDD 형식이어야 합니다.' }; - } - - // 날짜 유효성 검증 - const year = parseInt(trimmed.substring(0, 4)); - const month = parseInt(trimmed.substring(4, 6)); - const day = parseInt(trimmed.substring(6, 8)); - - if (month < 1 || month > 12) { - return { isValid: false, error: 'PCR 결정일의 월이 올바르지 않습니다.' }; - } - - if (day < 1 || day > 31) { - return { isValid: false, error: 'PCR 결정일의 일이 올바르지 않습니다.' }; - } - - // 실제 날짜 검증 - const date = new Date(year, month - 1, day); - if (date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day) { - return { isValid: false, error: 'PCR 결정일이 유효하지 않은 날짜입니다.' }; - } - - return { isValid: true }; -} - -// PCR 상태 검증 함수 -function validatePCRStatus(pcrStatus: string): { isValid: boolean; error?: string } { - if (!pcrStatus || typeof pcrStatus !== 'string') { - return { isValid: false, error: 'PCR 상태는 문자열이어야 합니다.' }; - } - - const trimmed = pcrStatus.trim(); - if (trimmed === '') { - return { isValid: false, error: 'PCR 상태는 비어있을 수 없습니다.' }; - } - - if (trimmed.length !== 1) { - return { isValid: false, error: 'PCR 상태는 1자리여야 합니다.' }; - } - - return { isValid: true }; -} - -// 구매오더 검증 함수 -function validatePurchaseOrder(ebeln: string): { isValid: boolean; error?: string } { - if (!ebeln || typeof ebeln !== 'string') { - return { isValid: false, error: '구매오더는 문자열이어야 합니다.' }; - } - - const trimmed = ebeln.trim(); - if (trimmed === '') { - return { isValid: false, error: '구매오더는 비어있을 수 없습니다.' }; - } - - if (trimmed.length > 10) { - return { isValid: false, error: '구매오더는 10자를 초과할 수 없습니다.' }; - } - - return { isValid: true }; -} - -// 구매오더 품번 검증 함수 -function validatePurchaseOrderItem(ebelp: string): { isValid: boolean; error?: string } { - if (!ebelp || typeof ebelp !== 'string') { - return { isValid: false, error: '구매오더 품번은 문자열이어야 합니다.' }; - } - - const trimmed = ebelp.trim(); - if (trimmed === '') { - return { isValid: false, error: '구매오더 품번은 비어있을 수 없습니다.' }; - } - - // 숫자 형식 검증 (NUMC 5자리) - if (!/^\d{1,5}$/.test(trimmed)) { - return { isValid: false, error: '구매오더 품번은 1-5자리 숫자여야 합니다.' }; - } - - return { isValid: true }; -} - -// 통화 검증 함수 -function validateCurrency(waers?: string): { isValid: boolean; error?: string } { - if (!waers) { - return { isValid: true }; // 선택 필드 - } - - if (typeof waers !== 'string') { - return { isValid: false, error: '통화는 문자열이어야 합니다.' }; - } - - const trimmed = waers.trim(); - if (trimmed.length > 5) { - return { isValid: false, error: '통화는 5자를 초과할 수 없습니다.' }; - } - - return { isValid: true }; -} - -// 여러 PCR 아이템 검증 함수 -function validatePCRItems(pcrItems: Array<{ - PCR_REQ: string; - PCR_REQ_SEQ: string; - PCR_DEC_DATE: string; - EBELN: string; - EBELP: string; - PCR_STATUS: string; - WAERS?: string; -}>): { isValid: boolean; errors: string[] } { - const errors: string[] = []; - - if (!Array.isArray(pcrItems) || pcrItems.length === 0) { - errors.push('최소 1개 이상의 PCR 아이템이 필요합니다.'); - return { isValid: false, errors }; - } - - pcrItems.forEach((item, index) => { - const pcrReqValid = validatePCRNumber(item.PCR_REQ); - if (!pcrReqValid.isValid) { - errors.push(`PCR[${index}] 요청번호: ${pcrReqValid.error}`); - } - - const pcrSeqValid = validatePCRSequence(item.PCR_REQ_SEQ); - if (!pcrSeqValid.isValid) { - errors.push(`PCR[${index}] 요청순번: ${pcrSeqValid.error}`); - } - - const pcrDateValid = validatePCRDecisionDate(item.PCR_DEC_DATE); - if (!pcrDateValid.isValid) { - errors.push(`PCR[${index}] 결정일: ${pcrDateValid.error}`); - } - - const eBelnValid = validatePurchaseOrder(item.EBELN); - if (!eBelnValid.isValid) { - errors.push(`PCR[${index}] 구매오더: ${eBelnValid.error}`); - } - - const eBelpValid = validatePurchaseOrderItem(item.EBELP); - if (!eBelpValid.isValid) { - errors.push(`PCR[${index}] 구매오더품번: ${eBelpValid.error}`); - } - - const statusValid = validatePCRStatus(item.PCR_STATUS); - if (!statusValid.isValid) { - errors.push(`PCR[${index}] 상태: ${statusValid.error}`); - } - - const currencyValid = validateCurrency(item.WAERS); - if (!currencyValid.isValid) { - errors.push(`PCR[${index}] 통화: ${currencyValid.error}`); - } - }); - - return { - isValid: errors.length === 0, - errors - }; -} +// 사용하지 않는 유틸리티 함수들 삭제 (linter 오류 해결) diff --git a/lib/soap/ecc/send/rfq-info.ts b/lib/soap/ecc/send/rfq-info.ts index d313a74b..777c1dfe 100644 --- a/lib/soap/ecc/send/rfq-info.ts +++ b/lib/soap/ecc/send/rfq-info.ts @@ -62,7 +62,7 @@ export interface RFQInfoResponse { // SOAP Body Content 생성 함수 function createRFQSoapBodyContent(rfqData: RFQInfoRequest): Record<string, unknown> { return { - 'ns0:MT_P2MM3014_S': { + 'p1:MT_P2MM3014_S': { // WSDL에서 사용하는 p1 접두사 적용 'T_RFQ_HEADER': rfqData.T_RFQ_HEADER, 'T_RFQ_ITEM': rfqData.T_RFQ_ITEM } @@ -146,7 +146,8 @@ async function sendRFQToECC(rfqData: RFQInfoRequest): Promise<SoapSendResult> { timeout: 60000, // RFQ 정보 전송은 60초 타임아웃 retryCount: 3, retryDelay: 2000, - namespace: 'http://shi.samsung.co.kr/P2_MM/MMM' // ECC MM 모듈 네임스페이스 + namespace: 'http://shi.samsung.co.kr/P2_MM/MMM', // ECC MM 모듈 네임스페이스 + prefix: 'p1' // WSDL에서 사용하는 p1 접두사 }; // 로그 정보 @@ -359,112 +360,3 @@ export async function checkRFQInformationStatus(rfqNumber: string): Promise<{ } } -// ======================================== -// 유틸리티 함수들 -// ======================================== - -// RFQ 데이터 생성 헬퍼 함수 -function createRFQData( - headers: RFQHeaderData[], - items: RFQItemData[] -): RFQInfoRequest { - return { - T_RFQ_HEADER: headers, - T_RFQ_ITEM: items - }; -} - -// RFQ 헤더 데이터 생성 헬퍼 함수 -function createRFQHeader( - rfqNumber: string, // ANFNR - CHAR(10) - vendorNumber: string, // LIFNR - CHAR(10) - currency: string = 'KRW', // WAERS - CUKY(5) - paymentTerms: string = '0001', // ZTERM - CHAR(4) - incoterms1: string = 'FOB', // INCO1 - CHAR(3) - incoterms2: string = 'Seoul, Korea', // INCO2 - CHAR(28) - taxCode: string = 'V0', // MWSKZ - CHAR(2) - countryForTax: string = 'KR', // LANDS - CHAR(3) (Country for Tax Return) - options?: { - shippingPlace?: string; // VSTEL - CHAR(3) (Place of Shipping) - destinationPlace?: string; // LSTEL - CHAR(3) (Place of Destination) - } -): RFQHeaderData { - return { - ANFNR: rfqNumber, - LIFNR: vendorNumber, - WAERS: currency, - ZTERM: paymentTerms, - INCO1: incoterms1, - INCO2: incoterms2, - MWSKZ: taxCode, - LANDS: countryForTax, - VSTEL: options?.shippingPlace, - LSTEL: options?.destinationPlace - }; -} - -// RFQ 아이템 데이터 생성 헬퍼 함수 -function createRFQItem( - rfqNumber: string, // ANFNR - CHAR(10) - itemNumber: string, // ANFPS - NUMC(5,0) - netPrice: string, // NETPR - CURR(11,2) Net Price in Purchasing Document (in Document Currency) - netOrderValue: string, // NETWR - CURR(13,2) Net Order Value in PO Currency - grossOrderValue: string, // BRTWR - CURR(13,2) Gross order value in PO currency - deliveryDate?: string // LFDAT - DATS(8) Item delivery date (선택) -): RFQItemData { - return { - ANFNR: rfqNumber, - ANFPS: itemNumber, - NETPR: netPrice, - NETWR: netOrderValue, - BRTWR: grossOrderValue, - LFDAT: deliveryDate - }; -} - -// RFQ 번호 기준으로 헤더와 아이템 매칭 검증 -function validateRFQMatching(headers: RFQHeaderData[], items: RFQItemData[]): { - isValid: boolean; - errors: string[]; - orphanItems: string[]; -} { - const errors: string[] = []; - const orphanItems: string[] = []; - - const headerRFQNumbers = new Set(headers.map(h => h.ANFNR)); - - for (const item of items) { - if (!headerRFQNumbers.has(item.ANFNR)) { - orphanItems.push(item.ANFNR); - errors.push(`RFQ 아이템 '${item.ANFNR}-${item.ANFPS}'에 해당하는 헤더가 없습니다.`); - } - } - - return { - isValid: errors.length === 0, - errors, - orphanItems - }; -} - -// RFQ 데이터 요약 정보 생성 -function getRFQDataSummary(rfqData: RFQInfoRequest): { - rfqNumbers: string[]; - totalHeaders: number; - totalItems: number; - itemsPerRFQ: Record<string, number>; -} { - const rfqNumbers = [...new Set(rfqData.T_RFQ_HEADER.map(h => h.ANFNR))]; - const itemsPerRFQ: Record<string, number> = {}; - - for (const rfqNumber of rfqNumbers) { - itemsPerRFQ[rfqNumber] = rfqData.T_RFQ_ITEM.filter(i => i.ANFNR === rfqNumber).length; - } - - return { - rfqNumbers, - totalHeaders: rfqData.T_RFQ_HEADER.length, - totalItems: rfqData.T_RFQ_ITEM.length, - itemsPerRFQ - }; -} |
