/** * 발주서 (Purchase Order Document) * * 공통 컴포넌트 사용: * - DocumentHeader: quote 레이아웃 + LotApprovalTable */ import { QuoteFormData } from "./types"; import type { CompanyFormData } from "@/components/settings/CompanyInfoManagement/types"; import { DocumentHeader, LotApprovalTable } from "@/components/document-system"; interface PurchaseOrderDocumentProps { quote: QuoteFormData; companyInfo?: CompanyFormData | null; } export function PurchaseOrderDocument({ quote, companyInfo }: PurchaseOrderDocumentProps) { const formatDate = (dateStr: string) => { if (!dateStr) return ''; const date = new Date(dateStr); return `${date.getFullYear()}년 ${String(date.getMonth() + 1).padStart(2, '0')}월 ${String(date.getDate()).padStart(2, '0')}일`; }; // 발주번호 생성 (견적번호 기반) const purchaseOrderNumber = quote.id?.replace('Q', 'KQ#-SC-') + '-01' || 'KQ#-SC-XXXXXX-01'; // BOM에서 부자재 목록 추출 (견적 품목 데이터 기반) const materialItems = quote.items?.length > 0 ? quote.items.map((item, index) => ({ no: index + 1, name: item.productName || '스크린셔터', spec: `${item.openWidth || 0}×${item.openHeight || 0}mm`, length: Number(item.openHeight) || 0, quantity: item.quantity || 1, note: item.guideRailType ? `레일: ${item.guideRailType}` : '' })) : []; return ( <> {/* 발주서 내용 */}
{/* 헤더: 제목 + 로트번호/결재란 (공통 컴포넌트) */} } /> {/* 신청업체 */}
신 청 업 체 발주처 {quote.clientName || '-'} 발주일 {formatDate(quote.registrationDate || '')}
담당자 {quote.manager || '-'} 연락처 {quote.contact || '-'}
F A X - 설치개소(총) {quote.items?.reduce((sum, item) => sum + (item.quantity || 0), 0) || 0}개소
{/* 신청내용 */}
신 청 내 용 현장명 {quote.siteName || '-'}
납기요청일 {formatDate(quote.dueDate || '')}
출고일 {formatDate(quote.registrationDate || '')} 배송방법 상차
납품주소 경기도 안성시 서운면 서운신기 16-180
수신자 {quote.manager || '-'} 연락처 {quote.contact || '-'}
{/* 발주개소 정보 */}
누적발주개소 - 금번발주개소 {quote.items?.reduce((sum, item) => sum + (item.quantity || 0), 0) || 0}개소
{/* 유의사항 */}

1. 귀사의 일익번영을 기원합니다.

2. 아래와 같이 주문하오니 품질 및 납기일을 준수하여 주시기 바랍니다.

{/* 부자재 테이블 */}
■ 부자재
{materialItems.map((item) => ( ))}
구분 품명 규격 길이(mm) 수량 비고
{item.no} {item.name} {item.spec} {item.length > 0 ? item.length.toLocaleString() : ''} {item.quantity} {item.note}
{/* 특이사항 */}
【특이사항】
{quote.remarks || '스크린 셔터 부품구성표 기반 자동 견적'}
{/* 하단 안내사항 */}

【 유의사항 】

• 발주서 승인 완료 후 작업을 진행해주시기 바랍니다.

• 납기 엄수 부탁드리며, 품질 기준에 맞춰 납품해주시기 바랍니다.

• 기타 문의사항은 담당자에게 연락 부탁드립니다.

문의: {companyInfo?.managerName || quote.writer || '담당자'} | {companyInfo?.managerPhone || '-'}

); }