summaryrefslogtreecommitdiff
path: root/lib/po/vendor-table/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/po/vendor-table/service.ts')
-rw-r--r--lib/po/vendor-table/service.ts127
1 files changed, 107 insertions, 20 deletions
diff --git a/lib/po/vendor-table/service.ts b/lib/po/vendor-table/service.ts
index 224dd2f1..bc4a693b 100644
--- a/lib/po/vendor-table/service.ts
+++ b/lib/po/vendor-table/service.ts
@@ -366,14 +366,60 @@ export async function getVendorPOItems(contractId: number): Promise<VendorPOItem
id: contractItems.id,
contractId: contractItems.contractId,
itemId: contractItems.itemId,
+ itemNo: contractItems.itemNo, // EBELP - 구매오더품목번호 (품번)
+ prNo: contractItems.prNo, // BANFN - 구매요청번호 (PR번호)
+ prItemNo: contractItems.prItemNo, // BNFPO - 구매요청품목번호 (PR 품번)
+ materialGroup: contractItems.materialGroup, // MATKL - 자재그룹
+ weight: contractItems.weight, // NTGEW - 순중량
+ weightUnit: contractItems.weightUnit, // GEWEI - 중량단위
+ totalWeight: contractItems.totalWeight, // BRGEW - 총중량
description: contractItems.description,
quantity: contractItems.quantity,
- unitPrice: contractItems.unitPrice,
+ unitPrice: contractItems.unitPrice, // NETPR - 구매단가
+
+ // 가격 관련 추가 필드
+ PEINH: contractItems.PEINH, // 가격단위값
+ BPRME: contractItems.BPRME, // 구매단가단위
+ ZNETPR: contractItems.ZNETPR, // 발주단가
+ ZREF_NETPR: contractItems.ZREF_NETPR, // 참조단가
+
taxRate: contractItems.taxRate,
taxAmount: contractItems.taxAmount,
+ taxType: contractItems.taxType, // MWSKZ - 매출부가가치세코드
totalLineAmount: contractItems.totalLineAmount,
remark: contractItems.remark,
+ // SAP ECC 추가 필드들
+ ZPO_UNIT: contractItems.ZPO_UNIT, // 구매오더수량단위
+ NETWR: contractItems.NETWR, // 오더정가 (최종 정가)
+ BRTWR: contractItems.BRTWR, // 오더총액 (기본 총액)
+ ZPDT_EXDS_AMT: contractItems.ZPDT_EXDS_AMT, // 할인/할증금액
+
+ // 위치 정보
+ WERKS: contractItems.WERKS, // 플랜트코드
+ LGORT: contractItems.LGORT, // 저장위치
+
+ // RFQ 추적
+ ANFNR: contractItems.ANFNR, // RFQ번호
+ ANFPS: contractItems.ANFPS, // RFQ품목번호
+
+ // 자재 추적
+ ZPO_LOT_NO: contractItems.ZPO_LOT_NO, // Steel Material Marking No
+
+ // 볼륨 정보
+ VOLUM: contractItems.VOLUM, // 볼륨
+ VOLEH: contractItems.VOLEH, // 볼륨단위
+
+ // 날짜 정보
+ ZPO_DLV_DT: contractItems.ZPO_DLV_DT, // PO납기일자
+ ZPLN_ST_DT: contractItems.ZPLN_ST_DT, // 예정시작일자
+ ZPLN_ED_DT: contractItems.ZPLN_ED_DT, // 예정종료일자
+ LFDAT: contractItems.LFDAT, // PR Delivery Date
+ ZRCV_DT: contractItems.ZRCV_DT, // 구매접수일자
+
+ // 기타
+ ZCON_IND: contractItems.ZCON_IND, // 시리즈구분
+
// contracts 테이블 필드들
contractNo: contracts.contractNo,
@@ -393,33 +439,74 @@ export async function getVendorPOItems(contractId: number): Promise<VendorPOItem
.orderBy(contractItems.id);
// VendorPOItem 타입으로 변환
+ // SAP에서 제공하지 않는 데이터는 임의로 만들지 않고 그대로 표시 (FE에서 '-' 처리)
const vendorPOItems: VendorPOItem[] = rawItems.map(row => ({
contractNo: row.contractNo || '',
- itemNo: row.itemCode || 'AUTO-ITEM', // mock 데이터용
- prNo: `PR-${new Date().getFullYear()}-${String(row.id).padStart(4, '0')}`, // mock 데이터용
- materialGroup: row.packageCode || 'Unknown Group',
- priceStandard: 'FOB', // mock 데이터용 기본값
+ itemNo: row.itemNo || '', // EBELP - 구매오더품목번호 (품번)
+ prNo: row.prNo || '', // BANFN - 구매요청번호 (PR번호)
+ prItemNo: row.prItemNo || '', // BNFPO - 구매요청품목번호 (PR 품번)
+ materialGroup: row.materialGroup || '', // MATKL - 자재그룹
+ priceStandard: '', // SAP에서 제공되지 않음 - FE에서 '-' 처리
materialNo: row.itemCode || '',
itemDescription: row.itemName || '',
materialSpec: row.description || '',
- fittingNo: undefined, // contract_items에 없는 필드
- cert: undefined, // contract_items에 없는 필드
+ fittingNo: undefined, // SAP에서 제공되지 않음
+ cert: undefined, // SAP에서 제공되지 않음
material: row.gradeMaterial || undefined,
specification: row.description || '',
- quantity: row.quantity || 1,
- quantityUnit: row.unitOfMeasure || 'EA',
- weight: undefined, // contract_items에 없는 필드
- weightUnit: undefined, // contract_items에 없는 필드
- totalWeight: undefined, // contract_items에 없는 필드
- unitPrice: row.unitPrice ? Number(row.unitPrice) : 0,
- priceUnit: 'KRW', // 기본값
- priceUnitValue: '원/EA', // 기본값
- contractAmount: row.totalLineAmount ? Number(row.totalLineAmount) : 0,
- adjustmentAmount: undefined, // contract_items에 없는 필드
- deliveryDate: new Date().toISOString().split('T')[0], // 기본값 (오늘 날짜)
- vatType: row.taxRate && Number(row.taxRate) > 0 ? '과세' : '면세',
+ quantity: row.quantity ?? 0, // null/undefined면 0, 0이면 0 표시
+ quantityUnit: row.ZPO_UNIT || row.unitOfMeasure || '', // SAP 단위 우선, 없으면 items 테이블 단위
+ ZPO_UNIT: row.ZPO_UNIT || undefined, // SAP 구매오더수량단위
+ weight: row.weight ? Number(row.weight) : undefined, // NTGEW - 순중량
+ weightUnit: row.weightUnit || undefined, // GEWEI - 중량단위
+ totalWeight: row.totalWeight ? Number(row.totalWeight) : undefined, // BRGEW - 총중량
+ unitPrice: row.unitPrice ? Number(row.unitPrice) : 0, // NETPR - 구매단가
+
+ // 가격 관련 추가 필드
+ PEINH: row.PEINH ?? undefined, // 가격단위값
+ BPRME: row.BPRME || undefined, // 구매단가단위
+ ZNETPR: row.ZNETPR ? Number(row.ZNETPR) : undefined, // 발주단가
+ ZREF_NETPR: row.ZREF_NETPR ? Number(row.ZREF_NETPR) : undefined, // 참조단가
+
+ priceUnit: row.BPRME || '', // BPRME을 priceUnit으로 사용
+ priceUnitValue: row.PEINH ? String(row.PEINH) : '', // PEINH를 priceUnitValue로 사용
+ contractAmount: row.NETWR ? Number(row.NETWR) : (row.totalLineAmount ? Number(row.totalLineAmount) : 0), // NETWR 우선, 없으면 totalLineAmount
+ adjustmentAmount: row.ZPDT_EXDS_AMT ? Number(row.ZPDT_EXDS_AMT) : undefined, // SAP 조정금액
+
+ // SAP ECC 금액 필드
+ NETWR: row.NETWR ? Number(row.NETWR) : undefined, // 오더정가 (최종 정가)
+ BRTWR: row.BRTWR ? Number(row.BRTWR) : undefined, // 오더총액 (기본 총액)
+ ZPDT_EXDS_AMT: row.ZPDT_EXDS_AMT ? Number(row.ZPDT_EXDS_AMT) : undefined, // 할인/할증금액
+
+ // 위치 정보
+ WERKS: row.WERKS || undefined, // 플랜트코드
+ LGORT: row.LGORT || undefined, // 저장위치
+
+ // RFQ 추적
+ ANFNR: row.ANFNR || undefined, // RFQ번호
+ ANFPS: row.ANFPS || undefined, // RFQ품목번호
+
+ // 자재 추적
+ ZPO_LOT_NO: row.ZPO_LOT_NO || undefined, // Steel Material Marking No
+
+ // 볼륨 정보
+ VOLUM: row.VOLUM ? Number(row.VOLUM) : undefined, // 볼륨
+ VOLEH: row.VOLEH || undefined, // 볼륨단위
+
+ deliveryDate: row.ZPO_DLV_DT || '', // SAP 납기일자, 없으면 빈 문자열 (FE에서 '-' 처리)
+ ZPO_DLV_DT: row.ZPO_DLV_DT || undefined, // SAP PO납기일자
+ ZPLN_ST_DT: row.ZPLN_ST_DT || undefined, // SAP 예정시작일자
+ ZPLN_ED_DT: row.ZPLN_ED_DT || undefined, // SAP 예정종료일자
+ LFDAT: row.LFDAT || undefined, // PR Delivery Date
+ ZRCV_DT: row.ZRCV_DT || undefined, // 구매접수일자
+
+ // 기타
+ ZCON_IND: row.ZCON_IND || undefined, // 시리즈구분 (SS 등)
+
+ vatType: row.taxType || '', // MWSKZ - 매출부가가치세코드 (V1, V2 등)
steelSpec: row.steelType || undefined,
- prManager: 'AUTO-MANAGER', // mock 데이터용 기본값
+ prManager: '', // SAP에서 제공되지 않음 - FE에서 '-' 처리
+ remark: row.remark || undefined,
}));
return vendorPOItems;