diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-11 08:44:22 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-11 08:44:22 +0000 |
| commit | d76ab1855ec68432a1b362c5d922af7235658d10 (patch) | |
| tree | e85c266c3667bcb2ce060823bce66218ae88a5a5 /lib/vendor-candidates | |
| parent | da6606ef891d8498a4479cadb82e270e52b19166 (diff) | |
(임수민) 구매 피드백 수정사항들
PO 금액 표시, RFQ 품목 컬럼 추가, 스크롤 시 헤더 고정, 납기일과 SAP 한국시간, 히스토리 수정
Diffstat (limited to 'lib/vendor-candidates')
| -rw-r--r-- | lib/vendor-candidates/service.ts | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/lib/vendor-candidates/service.ts b/lib/vendor-candidates/service.ts index bfeb3090..2b6421f5 100644 --- a/lib/vendor-candidates/service.ts +++ b/lib/vendor-candidates/service.ts @@ -252,20 +252,41 @@ export async function updateVendorCandidate(input: UpdateVendorCandidateSchema, .returning(); // 로그 작성 - const statusChanged = - updateData.status && + const statusChanged = + updateData.status !== undefined && existingCandidate.status !== updateData.status; - await tx.insert(vendorCandidateLogs).values({ - vendorCandidateId: id, - userId: userId, - action: statusChanged ? "status_change" : "update", - oldStatus: statusChanged ? existingCandidate.status : undefined, - newStatus: statusChanged ? updateData.status : undefined, - comment: statusChanged - ? `Status changed from ${existingCandidate.status} to ${updateData.status}` - : `Updated vendor candidate: ${existingCandidate.companyName}` - }); + // 상태가 변경된 경우에만 상태 변경 로그 기록 + if (statusChanged) { + await tx.insert(vendorCandidateLogs).values({ + vendorCandidateId: id, + userId: userId, + action: "status_change", + oldStatus: existingCandidate.status, + newStatus: updateData.status, + comment: `Status changed from ${existingCandidate.status} to ${updateData.status}` + }); + } + + // 상태가 변경되지 않았지만 다른 필드가 변경된 경우에만 일반 업데이트 로그 기록 + // (실제로 변경된 필드가 있는지 확인하는 로직은 복잡하므로, 상태 변경이 아닌 경우에만 로그 기록) + // 참고: 모든 필드가 동일한 경우도 있지만, 사용자가 저장 버튼을 눌렀다는 것은 변경 의도가 있다는 의미 + if (!statusChanged) { + // 다른 필드 변경 여부를 간단히 확인 (실제로는 더 정교한 비교가 필요할 수 있음) + const hasOtherChanges = Object.keys(updateData).some(key => { + if (key === 'status' || key === 'updatedAt') return false; + return (existingCandidate as any)[key] !== (updateData as any)[key]; + }); + + if (hasOtherChanges) { + await tx.insert(vendorCandidateLogs).values({ + vendorCandidateId: id, + userId: userId, + action: "update", + comment: `Updated vendor candidate: ${existingCandidate.companyName}` + }); + } + } |
