'use client'; /** * 거래명세서 보기 모달 * * 견적 데이터를 거래명세서 양식으로 표시 * - 결재라인 * - 수요자/공급자 정보 * - 품목내역 * - 금액 계산 (소계, 할인율, 할인금액, 할인 후 금액, 부가세, 합계) * - 증명 문구 + 인감 */ import { DocumentViewer } from '@/components/document-system'; import type { QuoteFormDataV2 } from './QuoteRegistration'; interface QuoteTransactionModalProps { open: boolean; onOpenChange: (open: boolean) => void; quoteData: QuoteFormDataV2 | null; /** 할인율 (%) */ discountRate?: number; /** 할인금액 (원) */ discountAmount?: number; } export function QuoteTransactionModal({ open, onOpenChange, quoteData, discountRate = 0, discountAmount = 0, }: QuoteTransactionModalProps) { if (!quoteData) return null; // locations 배열 (undefined 방어) const locations = quoteData.locations || []; // 소계 (할인 전 금액) const subtotal = locations.reduce((sum, loc) => sum + (loc.totalPrice || 0), 0); // 할인 적용 후 금액 const afterDiscount = subtotal - discountAmount; // 부가세 const vat = Math.round(afterDiscount * 0.1); // 부가세 포함 여부 const vatIncluded = quoteData.vatType === 'included'; // 총 금액 (부가세 포함 여부에 따라) const grandTotal = vatIncluded ? afterDiscount + vat : afterDiscount; // 할인 적용 여부 const hasDiscount = discountAmount > 0; // 오늘 날짜 const today = new Date().toISOString().split('T')[0]; return (
{/* 헤더: 제목 + 결재란 */}
{/* 왼쪽: 제목 */}

거 래 명 세 서

문서번호: {quoteData.quoteNumber || 'ABC123'} | 작성일자: {quoteData.registrationDate || today}

{/* 오른쪽: 결재란 */}
작성 승인 승인 승인
홍길동 이름 이름 이름
부서명 부서명 부서명 부서명
{/* 수요자 / 공급자 정보 (좌우 배치) */}
{/* 수요자 */}
수 요 자
업체명 {quoteData.clientName || '-'}
제품명 {locations[0]?.productCode || '-'}
현장명 {quoteData.siteName || '-'}
담당자 {quoteData.manager || '-'}
연락처 {quoteData.contact || '-'}
{/* 공급자 */}
공 급 자
상호 회사명
등록번호 123-12-12345 대표자 홍길동
사업장주소 주소명
업태 제조업 종목 방화셔터, 금속창호
TEL 031-123-1234 FAX 02-1234-1234
{/* 내역 테이블 */}
내 역
{locations.length > 0 ? ( locations.map((loc, index) => ( )) ) : ( )} {/* 소계 */} {/* 할인율 */} {/* 할인금액 */} {/* 할인 후 금액 */} {/* 부가세 포함일 때 추가 행들 */} {vatIncluded && ( <> )}
No. 종류 부호 제품명 오픈사이즈 수량 단위 단가 합계금액
가로 세로
{index + 1} {loc.floor || '-'} {loc.code || '-'} {loc.productCode || '-'} {loc.openWidth || 0} {loc.openHeight || 0} {loc.quantity || 1} SET {(loc.unitPrice || 0).toLocaleString()} {(loc.totalPrice || 0).toLocaleString()}
등록된 품목이 없습니다
소계 {locations.reduce((sum, loc) => sum + (loc.quantity || 0), 0)} {subtotal.toLocaleString()}
할인율 {hasDiscount ? `${discountRate.toFixed(1)} %` : '0.0 %'}
할인금액 {hasDiscount ? discountAmount.toLocaleString() : '0'}
할인 후 금액 {afterDiscount.toLocaleString()}
부가가치세 합계 {vat.toLocaleString()}
총 금액 {grandTotal.toLocaleString()}
{/* 합계금액 박스 */}
합계금액 ({vatIncluded ? '부가세 포함' : '부가세 별도'}) ₩ {grandTotal.toLocaleString()}
{/* 증명 문구 + 인감 */}

위와 같이 거래하였습니다.

); }