"use client"; /** * 거래명세서 문서 컴포넌트 * - 스크린샷 형식 + 지출결의서 디자인 스타일 */ import { formatAmount } from "@/utils/formatAmount"; import { OrderItem } from "../actions"; interface TransactionDocumentProps { orderNumber: string; orderDate: string; client: string; clientBusinessNumber?: string; clientCeo?: string; clientContact?: string; clientAddress?: string; clientSiteName?: string; companyName?: string; companyCeo?: string; companyBusinessNumber?: string; companyContact?: string; companyAddress?: string; items?: OrderItem[]; subtotal?: number; discountRate?: number; totalAmount?: number; } export function TransactionDocument({ orderNumber, orderDate, client, clientBusinessNumber = "123-45-67890", clientCeo = "대표자", clientContact = "010-0123-4567", clientAddress = "서울시 강남구", clientSiteName = "-", companyName = "(주)케이디산업", companyCeo = "홍길동", companyBusinessNumber = "123-45-67890", companyContact = "02-1234-5678", companyAddress = "서울 강남구 테헤란로 123", items = [], subtotal = 0, discountRate = 0, totalAmount = 0, }: TransactionDocumentProps) { const discountAmount = Math.round(subtotal * (discountRate / 100)); const afterDiscount = subtotal - discountAmount; const vat = Math.round(afterDiscount * 0.1); const finalTotal = afterDiscount + vat; return (
{/* 제목 */}

거 래 명 세 서

수주번호: {orderNumber} | 발행일: {orderDate}

{/* 공급자/공급받는자 정보 */}
공급자
상호 {companyName}
대표자 {companyCeo}
사업자번호 {companyBusinessNumber}
주소 {companyAddress}
공급받는자
상호 {client}
담당자 {clientCeo}
연락처 {clientContact}
현장명 {clientSiteName}
{/* 품목내역 */}
품목내역
{items.length > 0 ? ( items.map((item, index) => ( )) ) : ( )}
순번 품목코드 품명 규격 수량 단위 단가 공급가액
{index + 1} {item.itemCode} {item.itemName} {item.spec} {item.quantity} {item.unit} {formatAmount(item.unitPrice)} {formatAmount(item.amount)}
등록된 품목이 없습니다
{/* 금액 계산 */}
공급가액 {formatAmount(subtotal)}원
할인율 {discountRate}%
할인액 -{formatAmount(discountAmount)}원
할인 후 공급가액 {formatAmount(afterDiscount)}원
부가세 (10%) {formatAmount(vat)}원
합계 금액 ₩ {formatAmount(finalTotal)}
{/* 증명 문구 */}

위 금액을 거래하였음을 증명합니다.

{orderDate}

); }