fix: [quotes] QuoteCalculationReport items → locations 프로퍼티 매핑 수정
- QuoteFormDataV2에 맞춰 quote.items를 quote.locations로 전환 - bomMaterials를 locations[].bomResult.materials에서 추출하도록 변경 - 미사용 BomMaterial import 제거
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
import { QuoteFormDataV2 } from "./QuoteRegistration";
|
||||
import type { BomMaterial } from "./types";
|
||||
import type { CompanyFormData } from "@/components/settings/CompanyInfoManagement/types";
|
||||
|
||||
interface QuoteCalculationReportProps {
|
||||
@@ -34,17 +33,18 @@ 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) => {
|
||||
const itemTotal = item.totalAmount ||
|
||||
(item.unitPrice || 0) * (item.quantity || 1) ||
|
||||
(item.inspectionFee || 0) * (item.quantity || 1);
|
||||
return sum + itemTotal;
|
||||
// 총 금액 계산 (totalPrice > unitPrice * quantity > inspectionFee 우선순위)
|
||||
const totalAmount = quote.locations?.reduce((sum, loc) => {
|
||||
const locTotal = loc.totalPrice ||
|
||||
(loc.unitPrice || 0) * (loc.quantity || 1) ||
|
||||
(loc.inspectionFee || 0) * (loc.quantity || 1);
|
||||
return sum + locTotal;
|
||||
}, 0) || 0;
|
||||
|
||||
// 소요자재 내역 - BOM 자재 목록 (quote.bomMaterials)에서 가져옴
|
||||
// bomMaterials가 없으면 빈 배열 (BOM 계산 데이터 없음)
|
||||
const materialItems = (quote.bomMaterials || []).map((material, index) => ({
|
||||
// 소요자재 내역 - BOM 자재 목록 (locations[].bomResult.materials)에서 가져옴
|
||||
const materialItems = (quote.locations || []).flatMap(loc =>
|
||||
(loc.bomResult?.materials || [])
|
||||
).map((material, index) => ({
|
||||
no: index + 1,
|
||||
itemCode: material.itemCode || '-',
|
||||
name: material.itemName || '-',
|
||||
@@ -310,7 +310,7 @@ export function QuoteCalculationReport({
|
||||
</tr>
|
||||
<tr>
|
||||
<th>제품명</th>
|
||||
<td>{quote.items?.[0]?.productName || '-'}</td>
|
||||
<td>{quote.locations?.[0]?.productName || '-'}</td>
|
||||
<th>연락처</th>
|
||||
<td>{quote.contact || '-'}</td>
|
||||
</tr>
|
||||
@@ -364,7 +364,7 @@ export function QuoteCalculationReport({
|
||||
</div>
|
||||
|
||||
{/* 세부 산출내역서 */}
|
||||
{showDetailedBreakdown && quote.items && quote.items.length > 0 && (
|
||||
{showDetailedBreakdown && quote.locations && quote.locations.length > 0 && (
|
||||
<div className="page-break-after">
|
||||
<div className="section-title">세 부 산 출 내 역</div>
|
||||
|
||||
@@ -381,20 +381,18 @@ export function QuoteCalculationReport({
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{quote.items.map((item, index) => {
|
||||
// 단가: unitPrice > inspectionFee 우선순위
|
||||
const unitPrice = item.unitPrice || item.inspectionFee || 0;
|
||||
// 금액: totalAmount > unitPrice * quantity 우선순위
|
||||
const itemTotal = item.totalAmount || unitPrice * (item.quantity || 1);
|
||||
{quote.locations.map((loc, index) => {
|
||||
const unitPrice = loc.unitPrice || loc.inspectionFee || 0;
|
||||
const locTotal = loc.totalPrice || unitPrice * (loc.quantity || 1);
|
||||
return (
|
||||
<tr key={item.id || `item-${index}`}>
|
||||
<tr key={loc.id || `loc-${index}`}>
|
||||
<td style={{ textAlign: 'center' }}>{index + 1}</td>
|
||||
<td>{item.productName}</td>
|
||||
<td style={{ fontSize: '11px' }}>{`${item.openWidth}×${item.openHeight}mm`}</td>
|
||||
<td style={{ textAlign: 'right' }}>{Math.floor(item.quantity || 0)}</td>
|
||||
<td style={{ textAlign: 'center' }}>{item.unit || 'SET'}</td>
|
||||
<td>{loc.productName}</td>
|
||||
<td style={{ fontSize: '11px' }}>{`${loc.openWidth}×${loc.openHeight}mm`}</td>
|
||||
<td style={{ textAlign: 'right' }}>{Math.floor(loc.quantity || 0)}</td>
|
||||
<td style={{ textAlign: 'center' }}>SET</td>
|
||||
<td style={{ textAlign: 'right' }}>{formatAmount(unitPrice)}</td>
|
||||
<td style={{ textAlign: 'right', fontWeight: '600' }}>{formatAmount(itemTotal)}</td>
|
||||
<td style={{ textAlign: 'right', fontWeight: '600' }}>{formatAmount(locTotal)}</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
@@ -421,19 +419,19 @@ export function QuoteCalculationReport({
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>제품구분</th>
|
||||
<td>{quote.items?.[0]?.productCategory === 'steel' ? '철재' : '스크린'}</td>
|
||||
<td>{quote.locations?.[0]?.itemCategory === 'steel' ? '철재' : '스크린'}</td>
|
||||
<th>부호</th>
|
||||
<td>{quote.items?.[0]?.code || '-'}</td>
|
||||
<td>{quote.locations?.[0]?.code || '-'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>오픈사이즈</th>
|
||||
<td>W {quote.items?.[0]?.openWidth || '-'} × H {quote.items?.[0]?.openHeight || '-'} (mm)</td>
|
||||
<td>W {quote.locations?.[0]?.openWidth || '-'} × H {quote.locations?.[0]?.openHeight || '-'} (mm)</td>
|
||||
<th>제작사이즈</th>
|
||||
<td>W {Number(quote.items?.[0]?.openWidth || 0) + 100} × H {Number(quote.items?.[0]?.openHeight || 0) + 100} (mm)</td>
|
||||
<td>W {Number(quote.locations?.[0]?.openWidth || 0) + 100} × H {Number(quote.locations?.[0]?.openHeight || 0) + 100} (mm)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>수량</th>
|
||||
<td>{Math.floor(quote.items?.[0]?.quantity || 1)} {quote.items?.[0]?.unit || 'SET'}</td>
|
||||
<td>{Math.floor(quote.locations?.[0]?.quantity || 1)} SET</td>
|
||||
<th>케이스</th>
|
||||
<td>2438 × 550 (mm)</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user