summaryrefslogtreecommitdiff
path: root/lib/soap/ecc/mapper
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-09-26 14:13:20 +0900
committerjoonhoekim <26rote@gmail.com>2025-09-26 14:13:20 +0900
commitf8fc02e175f93466cd7693eb6e549c45362e785b (patch)
tree1037ec1f9225b0a0142defd6a27c68c3e6a47009 /lib/soap/ecc/mapper
parent11bc8239ad474a8f31c1c73de51f7d0f101594df (diff)
(김준회) POS 및 구매 피드백 처리
- 요구사항 28.(0.1) 24번 행 (prItem번호 별도 표기) - pos nfs 경로에서 가져오도록 수정개발
Diffstat (limited to 'lib/soap/ecc/mapper')
-rw-r--r--lib/soap/ecc/mapper/rfq-and-pr-mapper.ts38
1 files changed, 25 insertions, 13 deletions
diff --git a/lib/soap/ecc/mapper/rfq-and-pr-mapper.ts b/lib/soap/ecc/mapper/rfq-and-pr-mapper.ts
index a517d84c..620cd141 100644
--- a/lib/soap/ecc/mapper/rfq-and-pr-mapper.ts
+++ b/lib/soap/ecc/mapper/rfq-and-pr-mapper.ts
@@ -151,25 +151,37 @@ export async function mapECCRfqHeaderToRfqLast(
const inChargeUserInfo = await findUserInfoByEKGRP(eccHeader.EKGRP || null);
const inChargeUserId = inChargeUserInfo?.userId || null;
- // 첫번째 PR Item 기반으로 projectId, itemCode, itemName 설정
+ // 대표 PR Item 기반으로 projectId, itemCode, itemName 설정 (없으면 첫번째 PR Item 사용)
let projectId: number | null = null;
let itemCode: string | null = null;
let itemName: string | null = null;
let prNumber: string | null = null;
-
+ let representativeItem: ECCBidItem | undefined;
+
if (firstItem) {
- // projectId: 첫번째 PR Item의 PSPID와 projects.code 매칭
- const projectInfo = await findProjectInfoByPSPID(firstItem.PSPID || null);
+ // 대표 PR Item 찾기 (ZCON_NO_PO와 BANFN이 같은 아이템)
+ representativeItem = eccItems.find(item =>
+ item.ANFNR === eccHeader.ANFNR &&
+ item.ZCON_NO_PO &&
+ item.ZCON_NO_PO.trim() &&
+ item.BANFN === item.ZCON_NO_PO.trim()
+ );
+
+ // 대표 PR Item이 없으면 첫번째 PR Item 사용
+ const targetItem = representativeItem || firstItem;
+
+ // projectId: 대표 PR Item의 PSPID와 projects.code 매칭
+ const projectInfo = await findProjectInfoByPSPID(targetItem.PSPID || null);
projectId = projectInfo?.id || null;
-
- // itemCode: 첫번째 PR Item의 MATKL
- itemCode = firstItem.MATKL || null;
-
- // itemName: 첫번째 PR Item의 MATNR로 MDG에서 ZZNAME 조회
- itemName = await findMaterialNameByMATNR(firstItem.MATNR || null);
-
- // prNumber: 첫번째 PR의 ZREQ_FN 값
- prNumber = firstItem.ZREQ_FN || null;
+
+ // itemCode: 대표 PR Item의 MATNR
+ itemCode = targetItem.MATNR || null;
+
+ // itemName: 대표 PR Item의 MATNR로 MDG에서 ZZNAME 조회
+ itemName = await findMaterialNameByMATNR(targetItem.MATNR || null);
+
+ // prNumber: 대표 PR의 BANFN 또는 첫번째 PR의 ZREQ_FN 값
+ prNumber = representativeItem?.BANFN || firstItem.ZREQ_FN || null;
}
// 매핑