summaryrefslogtreecommitdiff
path: root/lib/soap/ecc/mapper
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-10-14 19:54:17 +0900
committerjoonhoekim <26rote@gmail.com>2025-10-14 19:54:17 +0900
commitd1cdcf9f35eca0552d1011e6d3c11a1d2d9abee4 (patch)
tree692c270d73c300f74d93470ca1fdf43e22c80c53 /lib/soap/ecc/mapper
parent2ce5f9dfbb69f0898c42ab862db5ad142fa24943 (diff)
(김준회) 구매혁신 No 57: ECC에서 받은 RFQ의 PR Item 매핑 관련 피드백 처리(자재명) 및 대표 PR Item 선정 로직 추가(MajorYn)
Diffstat (limited to 'lib/soap/ecc/mapper')
-rw-r--r--lib/soap/ecc/mapper/rfq-and-pr-mapper.ts17
1 files changed, 11 insertions, 6 deletions
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);
}
}