summaryrefslogtreecommitdiff
path: root/lib/vendor-document-list/enhanced-document-service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-document-list/enhanced-document-service.ts')
-rw-r--r--lib/vendor-document-list/enhanced-document-service.ts11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/vendor-document-list/enhanced-document-service.ts b/lib/vendor-document-list/enhanced-document-service.ts
index 28fad74b..d2cec15d 100644
--- a/lib/vendor-document-list/enhanced-document-service.ts
+++ b/lib/vendor-document-list/enhanced-document-service.ts
@@ -1027,11 +1027,11 @@ export async function getDocumentDetails(documentId: number) {
// 2. 해당 벤더의 모든 계약 ID들 조회
const vendorContracts = await db
- .select({ projectId: contracts.projectId })
+ .select({ projectId: contracts.projectId, contractId:contracts.id })
.from(contracts)
.where(eq(contracts.vendorId, companyId))
- const contractIds = vendorContracts.map(c => c.projectId)
+ const contractIds = vendorContracts.map(c => c.contractId)
if (contractIds.length === 0) {
return { data: [], pageCount: 0, total: 0, drawingKind: null, vendorInfo: null }
@@ -1057,7 +1057,7 @@ export async function getDocumentDetails(documentId: number) {
// 5. 최종 WHERE 조건 (계약 ID들로 필터링)
const finalWhere = and(
- inArray(simplifiedDocumentsView.projectId, contractIds),
+ inArray(simplifiedDocumentsView.contractId, contractIds),
advancedWhere,
globalWhere,
)
@@ -1099,9 +1099,8 @@ export async function getDocumentDetails(documentId: number) {
vendorName: vendors.vendorName,
vendorCode: vendors.vendorCode,
})
- .from(contracts)
- .leftJoin(vendors, eq(contracts.vendorId, vendors.id))
- .where(eq(contracts.projectId, contractIds[0]))
+ .from(vendors)
+ .where(eq(vendors.id, companyId))
.limit(1)
return { data, total, drawingKind, vendorInfo }