diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-27 09:43:55 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-11-27 09:43:55 +0000 |
| commit | daabc02e9ae54f216ada77aa826b349f37c3281a (patch) | |
| tree | 74c6f94e0c66ee31dfeac2f355c5156431cd42e3 /lib/bidding/pre-quote | |
| parent | 5870b73785715d1585531e655c06d8c068eb64ac (diff) | |
(최겸) 구매 입찰 피드백 반영(80%완)
Diffstat (limited to 'lib/bidding/pre-quote')
| -rw-r--r-- | lib/bidding/pre-quote/service.ts | 87 |
1 files changed, 58 insertions, 29 deletions
diff --git a/lib/bidding/pre-quote/service.ts b/lib/bidding/pre-quote/service.ts index 1dd06b3c..0f938b24 100644 --- a/lib/bidding/pre-quote/service.ts +++ b/lib/bidding/pre-quote/service.ts @@ -840,37 +840,66 @@ export async function setPreQuoteParticipation( }
// PR 아이템 조회 (입찰에 포함된 품목들)
-export async function getPrItemsForBidding(biddingId: number) {
+export async function getPrItemsForBidding(biddingId: number, companyId?: number) {
try {
- const prItems = await db
- .select({
- id: prItemsForBidding.id,
- biddingId: prItemsForBidding.biddingId,
- itemNumber: prItemsForBidding.itemNumber,
- projectId: prItemsForBidding.projectId,
- projectInfo: prItemsForBidding.projectInfo,
- itemInfo: prItemsForBidding.itemInfo,
- shi: prItemsForBidding.shi,
- materialGroupNumber: prItemsForBidding.materialGroupNumber,
- materialGroupInfo: prItemsForBidding.materialGroupInfo,
- materialNumber: prItemsForBidding.materialNumber,
- materialInfo: prItemsForBidding.materialInfo,
- requestedDeliveryDate: prItemsForBidding.requestedDeliveryDate,
- annualUnitPrice: prItemsForBidding.annualUnitPrice,
- currency: prItemsForBidding.currency,
- quantity: prItemsForBidding.quantity,
- quantityUnit: prItemsForBidding.quantityUnit,
- totalWeight: prItemsForBidding.totalWeight,
- weightUnit: prItemsForBidding.weightUnit,
- priceUnit: prItemsForBidding.priceUnit,
- purchaseUnit: prItemsForBidding.purchaseUnit,
- materialWeight: prItemsForBidding.materialWeight,
- prNumber: prItemsForBidding.prNumber,
- hasSpecDocument: prItemsForBidding.hasSpecDocument,
- })
- .from(prItemsForBidding)
- .where(eq(prItemsForBidding.biddingId, biddingId))
+ const selectFields: any = {
+ id: prItemsForBidding.id,
+ biddingId: prItemsForBidding.biddingId,
+ itemNumber: prItemsForBidding.itemNumber,
+ projectId: prItemsForBidding.projectId,
+ projectInfo: prItemsForBidding.projectInfo,
+ itemInfo: prItemsForBidding.itemInfo,
+ shi: prItemsForBidding.shi,
+ materialGroupNumber: prItemsForBidding.materialGroupNumber,
+ materialGroupInfo: prItemsForBidding.materialGroupInfo,
+ materialNumber: prItemsForBidding.materialNumber,
+ materialInfo: prItemsForBidding.materialInfo,
+ requestedDeliveryDate: prItemsForBidding.requestedDeliveryDate,
+ annualUnitPrice: prItemsForBidding.annualUnitPrice,
+ currency: prItemsForBidding.currency,
+ quantity: prItemsForBidding.quantity,
+ quantityUnit: prItemsForBidding.quantityUnit,
+ totalWeight: prItemsForBidding.totalWeight,
+ weightUnit: prItemsForBidding.weightUnit,
+ priceUnit: prItemsForBidding.priceUnit,
+ purchaseUnit: prItemsForBidding.purchaseUnit,
+ materialWeight: prItemsForBidding.materialWeight,
+ targetUnitPrice: prItemsForBidding.targetUnitPrice,
+ targetAmount: prItemsForBidding.targetAmount,
+ targetCurrency: prItemsForBidding.targetCurrency,
+ budgetAmount: prItemsForBidding.budgetAmount,
+ budgetCurrency: prItemsForBidding.budgetCurrency,
+ actualAmount: prItemsForBidding.actualAmount,
+ actualCurrency: prItemsForBidding.actualCurrency,
+ prNumber: prItemsForBidding.prNumber,
+ hasSpecDocument: prItemsForBidding.hasSpecDocument,
+ specification: prItemsForBidding.specification,
+ }
+
+ if (companyId) {
+ selectFields.bidUnitPrice = companyPrItemBids.bidUnitPrice
+ selectFields.bidAmount = companyPrItemBids.bidAmount
+ selectFields.proposedDeliveryDate = companyPrItemBids.proposedDeliveryDate
+ selectFields.technicalSpecification = companyPrItemBids.technicalSpecification
+ }
+
+ let query = db.select(selectFields).from(prItemsForBidding)
+
+ if (companyId) {
+ query = query
+ .leftJoin(biddingCompanies, and(
+ eq(biddingCompanies.biddingId, biddingId),
+ eq(biddingCompanies.companyId, companyId)
+ ))
+ .leftJoin(companyPrItemBids, and(
+ eq(companyPrItemBids.prItemId, prItemsForBidding.id),
+ eq(companyPrItemBids.biddingCompanyId, biddingCompanies.id)
+ )) as any
+ }
+
+ 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)
|
