From d1f1768611a73541f5d63b6735f64d194466825b Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 4 Dec 2025 12:42:23 +0000 Subject: (최겸) 구매 입찰 견적 히스토리, 응찰품목조회 table 개발 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/bidding/pre-quote/service.ts | 44 ++++++++++++---------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) (limited to 'lib/bidding/pre-quote/service.ts') diff --git a/lib/bidding/pre-quote/service.ts b/lib/bidding/pre-quote/service.ts index 08cb0e2c..e1152abe 100644 --- a/lib/bidding/pre-quote/service.ts +++ b/lib/bidding/pre-quote/service.ts @@ -49,16 +49,6 @@ interface UpdateBiddingCompanyInput { isAttendingMeeting?: boolean } -interface PrItemQuotation { - prItemId: number - bidUnitPrice: number - bidAmount: number - proposedDeliveryDate?: string - technicalSpecification?: string -} - - - // 사전견적용 업체 추가 - biddingCompanies와 company_condition_responses 레코드 생성 export async function createBiddingCompany(input: CreateBiddingCompanyInput) { try { @@ -201,16 +191,6 @@ export async function deleteBiddingCompany(id: number) { } -// 선택된 업체들에게 사전견적 초대 발송 -interface CompanyWithContacts { - id: number - companyId: number - companyName: string - selectedMainEmail: string - additionalEmails: string[] -} - - // PR 아이템 조회 (입찰에 포함된 품목들) export async function getPrItemsForBidding(biddingId: number, companyId?: number) { try { @@ -253,12 +233,11 @@ export async function getPrItemsForBidding(biddingId: number, companyId?: number selectFields.bidAmount = companyPrItemBids.bidAmount selectFields.proposedDeliveryDate = companyPrItemBids.proposedDeliveryDate selectFields.technicalSpecification = companyPrItemBids.technicalSpecification - } + selectFields.currency = companyPrItemBids.currency - let query = db.select(selectFields).from(prItemsForBidding) - - if (companyId) { - query = query + return await db + .select(selectFields) + .from(prItemsForBidding) .leftJoin(biddingCompanies, and( eq(biddingCompanies.biddingId, biddingId), eq(biddingCompanies.companyId, companyId) @@ -266,13 +245,16 @@ export async function getPrItemsForBidding(biddingId: number, companyId?: number .leftJoin(companyPrItemBids, and( eq(companyPrItemBids.prItemId, prItemsForBidding.id), eq(companyPrItemBids.biddingCompanyId, biddingCompanies.id) - )) as any + )) + .where(eq(prItemsForBidding.biddingId, biddingId)) + .orderBy(prItemsForBidding.id) + } else { + return await db + .select(selectFields) + .from(prItemsForBidding) + .where(eq(prItemsForBidding.biddingId, biddingId)) + .orderBy(prItemsForBidding.id) } - - query = query.where(eq(prItemsForBidding.biddingId, biddingId)).orderBy(prItemsForBidding.id) as any - - const prItems = await query - return prItems } catch (error) { console.error('Failed to get PR items for bidding:', error) return [] -- cgit v1.2.3