diff --git a/src/components/quotes/QuoteCalculationReport.tsx b/src/components/quotes/QuoteCalculationReport.tsx index 53e32063..fb105832 100644 --- a/src/components/quotes/QuoteCalculationReport.tsx +++ b/src/components/quotes/QuoteCalculationReport.tsx @@ -5,9 +5,12 @@ */ import { QuoteFormData } from "./QuoteRegistration"; +import type { BomMaterial } from "./types"; +import type { CompanyFormData } from "@/components/settings/CompanyInfoManagement/types"; interface QuoteCalculationReportProps { quote: QuoteFormData; + companyInfo?: CompanyFormData | null; documentType?: "견적산출내역서" | "견적서"; showDetailedBreakdown?: boolean; showMaterialList?: boolean; @@ -15,6 +18,7 @@ interface QuoteCalculationReportProps { export function QuoteCalculationReport({ quote, + companyInfo, documentType = "견적산출내역서", showDetailedBreakdown = true, showMaterialList = true @@ -30,19 +34,26 @@ export function QuoteCalculationReport({ return `${date.getFullYear()}년 ${String(date.getMonth() + 1).padStart(2, '0')}월 ${String(date.getDate()).padStart(2, '0')}일`; }; - // 총 금액 계산 + // 총 금액 계산 (totalAmount > unitPrice * quantity > inspectionFee 우선순위) const totalAmount = quote.items?.reduce((sum, item) => { - return sum + (item.inspectionFee || 0) * (item.quantity || 1); + const itemTotal = item.totalAmount || + (item.unitPrice || 0) * (item.quantity || 1) || + (item.inspectionFee || 0) * (item.quantity || 1); + return sum + itemTotal; }, 0) || 0; - // 소요자재 내역 생성 (샘플 데이터) - const materialItems = quote.items?.map((item, index) => ({ + // 소요자재 내역 - BOM 자재 목록 (quote.bomMaterials)에서 가져옴 + // bomMaterials가 없으면 빈 배열 (BOM 계산 데이터 없음) + const materialItems = (quote.bomMaterials || []).map((material, index) => ({ no: index + 1, - name: item.productName || '가이드레일', - spec: `${item.openWidth || 0}×${item.openHeight || 0}mm`, - quantity: item.quantity || 1, - unit: 'SET' - })) || []; + itemCode: material.itemCode || '-', + name: material.itemName || '-', + spec: material.specification || '-', + quantity: Math.floor(material.quantity || 1), + unit: material.unit || 'EA', + unitPrice: material.unitPrice || 0, + totalPrice: material.totalPrice || 0, + })); return ( <> @@ -316,29 +327,29 @@ export function QuoteCalculationReport({
| No. | -자재명 | -규격 | -수량 | -단위 | -||||||
|---|---|---|---|---|---|---|---|---|---|---|
| {index + 1} | -{item.name} | -{item.spec} | -{item.quantity} | -{item.unit} | + {materialItems.length > 0 ? ( +
| No. | +품목코드 | +자재명 | +규격 | +수량 | +단위 |
|---|
3. 제작 사양 및 수량 변경 시 견적 금액이 변동될 수 있습니다.
4. 현장 여건에 따라 추가 비용이 발생할 수 있습니다.
- 문의: {quote.manager || '담당자'} | {quote.contact || '031-983-5130'} + 문의: {companyInfo?.managerName || quote.manager || '담당자'} | {companyInfo?.managerPhone || '-'}