summaryrefslogtreecommitdiff
path: root/lib/soap/ecc/mapper/bidding-and-pr-mapper.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/soap/ecc/mapper/bidding-and-pr-mapper.ts')
-rw-r--r--lib/soap/ecc/mapper/bidding-and-pr-mapper.ts22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/soap/ecc/mapper/bidding-and-pr-mapper.ts b/lib/soap/ecc/mapper/bidding-and-pr-mapper.ts
index 9bdd238d..4cdaf90d 100644
--- a/lib/soap/ecc/mapper/bidding-and-pr-mapper.ts
+++ b/lib/soap/ecc/mapper/bidding-and-pr-mapper.ts
@@ -32,6 +32,7 @@ import {
parseSAPDateToString,
findSpecificationByMATNR,
} from './common-mapper-utils';
+import { updateBiddingAmounts } from '@/lib/bidding/service';
// Note: POS 파일은 온디맨드 방식으로 다운로드됩니다.
// 자동 동기화 관련 import는 제거되었습니다.
@@ -255,11 +256,14 @@ export async function mapECCBiddingHeaderToBidding(
// prNumber: 대표 PR의 BANFN 또는 타겟 PR의 ZREQ_FN 값
prNumber = representativeItem?.BANFN || targetItem.ZREQ_FN || null;
}
+
+ // 원입찰번호(originalBiddingNumber)에 생성된 biddingNumber에서 '-'로 split해서 앞부분을 사용
+ const originalBiddingNumber = biddingNumber ? biddingNumber.split('-')[0] : (eccHeader.ANFNR || null);
// 매핑
const mappedData: BiddingData = {
biddingNumber, // 생성된 Bidding 코드
- originalBiddingNumber: eccHeader.ANFNR || null, // 원입찰번호
+ originalBiddingNumber, // 원입찰번호에 생성된 biddingnumber split 결과 사용
revision: 0, // 기본 리비전 0 (I/F 해서 가져온 건 보낸 적 없으므로 0 고정)
projectName, // 타겟 PR Item의 PSPID로 찾은 프로젝트 이름
itemName, // 타겟 PR Item 정보로 조회한 자재명/내역
@@ -278,7 +282,6 @@ export async function mapECCBiddingHeaderToBidding(
biddingRegistrationDate: new Date().toISOString(), // 입찰등록일 I/F 시점 등록(1120 이시원 프로 요청)
submissionStartDate: null,
submissionEndDate: null,
- evaluationDate: null,
// 사양설명회
hasSpecificationMeeting: false, // 기본값 처리하고, 입찰관리상세에서 사용자가 관리
@@ -293,6 +296,7 @@ export async function mapECCBiddingHeaderToBidding(
// PR 정보
prNumber, // 첫번째 PR의 ZREQ_FN 값
hasPrDocument: false, // PR문서는 POS를 말하는 것으로 보임.
+ plant: eccHeader.WERKS || null, // 플랜트 코드(WERKS)
// 상태 및 설정
status: 'bidding_generated', // 입찰생성 상태
@@ -497,6 +501,20 @@ export async function mapAndSaveECCBiddingData(
};
});
+ // 새로 생성된 Bidding들에 대해 금액 집계 업데이트 (PR 아이템의 금액 정보를 Bidding 헤더에 반영)
+ if (result.insertedBiddings && result.insertedBiddings.length > 0) {
+ debugLog('Bidding 금액 집계 업데이트 시작', { count: result.insertedBiddings.length });
+ await Promise.all(
+ result.insertedBiddings.map(async (bidding) => {
+ try {
+ await updateBiddingAmounts(bidding.id);
+ } catch (err) {
+ debugError(`Bidding ${bidding.biddingNumber} 금액 업데이트 실패`, err);
+ }
+ })
+ );
+ }
+
debugSuccess('ECC Bidding 데이터 일괄 처리 완료', {
processedCount: result.processedCount,
});