diff options
| author | joonhoekim <26rote@gmail.com> | 2025-10-13 17:29:33 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-10-13 17:29:33 +0900 |
| commit | e84cf02a1cb4959a9d3bb5bbf37885c13a447f78 (patch) | |
| tree | cfb2817e3bd8f5ef08b4428b9e6fc619ef3884a1 /lib/soap/ecc | |
| parent | 89274bffa596ffdfc4275fb8d11cdb02ff9a2d02 (diff) | |
(김준회) SHI/벤더 PO 구현
Diffstat (limited to 'lib/soap/ecc')
| -rw-r--r-- | lib/soap/ecc/mapper/po-mapper.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/soap/ecc/mapper/po-mapper.ts b/lib/soap/ecc/mapper/po-mapper.ts index 9303cbcd..847ffdc0 100644 --- a/lib/soap/ecc/mapper/po-mapper.ts +++ b/lib/soap/ecc/mapper/po-mapper.ts @@ -14,8 +14,14 @@ import { import { eq } from 'drizzle-orm'; // ECC 데이터 타입 정의 -export type ECCPOHeader = typeof ZMM_HD.$inferInsert; +export type ECCPOHeader = typeof ZMM_HD.$inferInsert & { + notes?: ECCPONote[]; +}; export type ECCPODetail = typeof ZMM_DT.$inferInsert; +export type ECCPONote = { + ZNOTE_SER: string; + ZNOTE_TXT: string; +}; // 비즈니스 테이블 데이터 타입 정의 export type ContractData = typeof contracts.$inferInsert; @@ -108,12 +114,26 @@ export async function mapECCPOHeaderToBusiness( throw new Error(`벤더를 찾을 수 없습니다: LIFNR=${eccHeader.LIFNR}`); } + // 계약서 내용 구성 (ZMM_NOTE에서 가져옴) + let contractContent: string | null = null; + if (eccHeader.notes && eccHeader.notes.length > 0) { + // ZNOTE_SER 순번으로 정렬 후 텍스트 합치기 + const sortedNotes = eccHeader.notes.sort((a, b) => + parseInt(a.ZNOTE_SER) - parseInt(b.ZNOTE_SER) + ); + contractContent = sortedNotes + .map(note => note.ZNOTE_TXT || '') + .filter(text => text.trim() !== '') + .join('\n\n'); + } + // 매핑 - SAP ECC 필드명과 함께 주석 추가 const mappedData: ContractData = { projectId, vendorId, contractNo: eccHeader.EBELN || '', // EBELN - 구매오더번호 contractName: eccHeader.ZTITLE || eccHeader.EBELN || '', // ZTITLE - 발주제목 + contractContent, // 계약서 내용 status: eccHeader.ZPO_CNFM_STAT || 'ACTIVE', // ZPO_CNFM_STAT - 구매오더확인상태 startDate: parseDate(eccHeader.ZPO_DT || null), // ZPO_DT - 발주일자 endDate: null, // ZMM_DT에서 가져와야 함 |
