diff options
Diffstat (limited to 'lib/rfq-last')
| -rw-r--r-- | lib/rfq-last/contract-actions.ts | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/lib/rfq-last/contract-actions.ts b/lib/rfq-last/contract-actions.ts index c09b296b..f28d7af9 100644 --- a/lib/rfq-last/contract-actions.ts +++ b/lib/rfq-last/contract-actions.ts @@ -111,41 +111,41 @@ export async function createPO(params: CreatePOParams) { quotationItems.map(item => [item.rfqPrItemId, item]) ); - // 4. 필수 필드 검증 + // 4. 필수 필드 검증 (경고만 출력, 전송은 계속 진행) if (!vendorData.vendorCode) { - throw new Error(`벤더 코드가 없습니다. (Vendor ID: ${vendorData.id})`); + console.warn(`⚠️ 벤더 코드가 없습니다. (Vendor ID: ${vendorData.id}) - 빈 값으로 전송합니다.`); } - const vendorCode = vendorData.vendorCode; // 타입 좁히기 + const vendorCode = vendorData.vendorCode || ''; // 빈 값으로 기본값 설정 if (!detailData.paymentTermsCode) { - throw new Error("지급조건(Payment Terms)이 설정되지 않았습니다."); + console.warn("⚠️ 지급조건(Payment Terms)이 설정되지 않았습니다. - 빈 값으로 전송합니다."); } - const paymentTermsCode = detailData.paymentTermsCode; // 타입 좁히기 + const paymentTermsCode = detailData.paymentTermsCode || ''; // 빈 값으로 기본값 설정 if (!detailData.incotermsCode) { - throw new Error("인코텀즈(Incoterms)가 설정되지 않았습니다."); + console.warn("⚠️ 인코텀즈(Incoterms)가 설정되지 않았습니다. - 빈 값으로 전송합니다."); } - const incotermsCode = detailData.incotermsCode; // 타입 좁히기 + const incotermsCode = detailData.incotermsCode || ''; // 빈 값으로 기본값 설정 if (!detailData.incotermsDetail) { - throw new Error("인코텀즈 상세 정보(INCO2)가 설정되지 않았습니다."); + console.warn("⚠️ 인코텀즈 상세 정보(INCO2)가 설정되지 않았습니다. - 빈 값으로 전송합니다."); } - const incotermsDetail = detailData.incotermsDetail; // 타입 좁히기 + const incotermsDetail = detailData.incotermsDetail || ''; // 빈 값으로 기본값 설정 if (!detailData.taxCode) { - throw new Error("세금코드(Tax Code)가 설정되지 않았습니다."); + console.warn("⚠️ 세금코드(Tax Code)가 설정되지 않았습니다. - 빈 값으로 전송합니다."); } - const taxCode = detailData.taxCode; // 타입 좁히기 + const taxCode = detailData.taxCode || ''; // 빈 값으로 기본값 설정 if (!detailData.currency && !params.currency) { - throw new Error("통화(Currency)가 설정되지 않았습니다."); + console.warn("⚠️ 통화(Currency)가 설정되지 않았습니다. - KRW로 기본 설정합니다."); } - const currency = detailData.currency || params.currency!; // 타입 좁히기 + const currency = detailData.currency || params.currency || 'KRW'; // KRW를 기본값으로 설정 // ANFNR: rfqsLast.ANFNR 우선, 없으면 rfqCode 사용 (ITB, 일반견적은 ANFNR 없으므로..) - const anfnr = rfqData.ANFNR || rfqData.rfqCode; + const anfnr = rfqData.ANFNR || rfqData.rfqCode || ''; if (!anfnr) { - throw new Error("RFQ 번호(ANFNR 또는 rfqCode)가 없습니다."); + console.warn("⚠️ RFQ 번호(ANFNR 또는 rfqCode)가 없습니다. - 빈 값으로 전송합니다."); } // 5. PO 데이터 구성 @@ -175,23 +175,23 @@ export async function createPO(params: CreatePOParams) { }], T_Bidding_ITEM: prItems.map((item, index) => { if (!item.uom) { - throw new Error(`PR 아이템 ${index + 1}번의 단위(UOM)가 없습니다.`); + console.warn(`⚠️ PR 아이템 ${index + 1}번의 단위(UOM)가 없습니다. - 빈 값으로 전송합니다.`); } // 견적 아이템에서 실제 가격 정보 가져오기 const quoteItem = quotationItemMap.get(item.id); if (!quoteItem) { - throw new Error(`PR 아이템 ${item.id}에 대한 견적 정보를 찾을 수 없습니다.`); + console.warn(`⚠️ PR 아이템 ${item.id}에 대한 견적 정보를 찾을 수 없습니다. - 기본값으로 전송합니다.`); } // 가격 계산: SAP은 소수점을 포함한 문자열 형태로 받음 - const unitPrice = quoteItem.unitPrice || 0; - const quantity = quoteItem.quantity || item.quantity || 0; - const totalPrice = quoteItem.totalPrice || (unitPrice * quantity); + const unitPrice = quoteItem?.unitPrice || 0; + const quantity = quoteItem?.quantity || item.quantity || 0; + const totalPrice = quoteItem?.totalPrice || (unitPrice * quantity); // 납기일 계산 (우선순위: 견적 납기일 > PR 납기일 > 현재일자) let deliveryDate = getCurrentSAPDate(); - if (quoteItem.vendorDeliveryDate) { + if (quoteItem?.vendorDeliveryDate) { deliveryDate = new Date(quoteItem.vendorDeliveryDate).toISOString().split('T')[0].replace(/-/g, ''); } else if (item.deliveryDate) { deliveryDate = new Date(item.deliveryDate).toISOString().split('T')[0].replace(/-/g, ''); @@ -204,7 +204,7 @@ export async function createPO(params: CreatePOParams) { LIFNR: vendorCode, NETPR: unitPrice.toFixed(2), // 단가 (소수점 2자리) PEINH: '1', // 가격 단위: 1 (표준값, 1단위당 가격) - BPRME: item.uom, + BPRME: item.uom || '', NETWR: totalPrice.toFixed(2), // 순액 (세금 제외) BRTWR: totalPrice.toFixed(2), // 총액: SAP이 taxCode(MWSKZ)로 세금 계산하도록 순액과 동일하게 전송 LFDAT: deliveryDate, |
