From d1cdcf9f35eca0552d1011e6d3c11a1d2d9abee4 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Tue, 14 Oct 2025 19:54:17 +0900 Subject: (김준회) 구매혁신 No 57: ECC에서 받은 RFQ의 PR Item 매핑 관련 피드백 처리(자재명) 및 대표 PR Item 선정 로직 추가(MajorYn) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/soap/ecc/mapper/rfq-and-pr-mapper.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/soap/ecc') diff --git a/lib/soap/ecc/mapper/rfq-and-pr-mapper.ts b/lib/soap/ecc/mapper/rfq-and-pr-mapper.ts index 620cd141..0ca808ad 100644 --- a/lib/soap/ecc/mapper/rfq-and-pr-mapper.ts +++ b/lib/soap/ecc/mapper/rfq-and-pr-mapper.ts @@ -18,7 +18,6 @@ import { eq, max } from 'drizzle-orm'; import { findUserInfoByEKGRP, findProjectInfoByPSPID, - findMaterialNameByMATNR, parseSAPDateTime, } from './common-mapper-utils'; import { syncRfqPosFiles } from '@/lib/pos'; @@ -177,8 +176,8 @@ export async function mapECCRfqHeaderToRfqLast( // itemCode: 대표 PR Item의 MATNR itemCode = targetItem.MATNR || null; - // itemName: 대표 PR Item의 MATNR로 MDG에서 ZZNAME 조회 - itemName = await findMaterialNameByMATNR(targetItem.MATNR || null); + // itemName: 대표 PR Item의 TXZ01 (Short Text) + itemName = targetItem.TXZ01 || null; // prNumber: 대표 PR의 BANFN 또는 첫번째 PR의 ZREQ_FN 값 prNumber = representativeItem?.BANFN || firstItem.ZREQ_FN || null; @@ -227,7 +226,8 @@ export async function mapECCRfqHeaderToRfqLast( */ export function mapECCRfqItemToRfqPrItem( eccItem: ECCBidItem, - rfqId: number + rfqId: number, + isMajor: boolean = false ): RfqPrItemData { debugLog('ECC RFQ 아이템 매핑 시작', { anfnr: eccItem.ANFNR, @@ -259,7 +259,7 @@ export function mapECCRfqItemToRfqPrItem( specNo: null, // ECC에서 제공되지 않음 specUrl: null, // ECC에서 제공되지 않음 trackingNo: null, // ECC에서 제공되지 않음 - majorYn: false, // 기본값 false + majorYn: isMajor, // ZCON_NO_PO와 BANFN이 같은 경우 true projectDef: eccItem.PSPID || null, // 프로젝트 정의 projectSc: null, // ECC에서 제공되지 않음 projectKl: null, // ECC에서 제공되지 않음 @@ -347,7 +347,12 @@ export async function mapAndSaveECCRfqDataToRfqLast( } for (const eccItem of group.relatedItems) { - const itemData = mapECCRfqItemToRfqPrItem(eccItem, rfqId); + // ZCON_NO_PO와 BANFN이 같은 경우 majorYn을 true로 설정 + const isMajor: boolean = !!(eccItem.ZCON_NO_PO && + eccItem.ZCON_NO_PO.trim() && + eccItem.BANFN === eccItem.ZCON_NO_PO.trim()); + + const itemData = mapECCRfqItemToRfqPrItem(eccItem, rfqId, isMajor); allItemsToInsert.push(itemData); } } -- cgit v1.2.3