diff --git a/app/Http/Controllers/RdController.php b/app/Http/Controllers/RdController.php index 9ca2b89b..c19c33c0 100644 --- a/app/Http/Controllers/RdController.php +++ b/app/Http/Controllers/RdController.php @@ -54,6 +54,20 @@ public function createQuotation(Request $request): View|\Illuminate\Http\Respons return view('rd.ai-quotation.create'); } + /** + * AI 견적 문서 (인쇄용 견적서) + */ + public function documentQuotation(int $id): View + { + $quotation = $this->quotationService->getById($id); + + if (! $quotation || ! $quotation->isCompleted()) { + abort(404, '완료된 견적만 문서로 조회할 수 있습니다.'); + } + + return view('rd.ai-quotation.document', compact('quotation')); + } + /** * AI 견적 상세 */ diff --git a/resources/views/layouts/document.blade.php b/resources/views/layouts/document.blade.php new file mode 100644 index 00000000..950f6bb8 --- /dev/null +++ b/resources/views/layouts/document.blade.php @@ -0,0 +1,41 @@ + + + + + + @yield('title', '문서') - {{ config('app.name') }} + @vite(['resources/css/app.css']) + + @stack('styles') + + + {{-- 액션 버튼 (인쇄 시 숨김) --}} +
+ + +
+ + @yield('content') + + @stack('scripts') + + diff --git a/resources/views/rd/ai-quotation/document.blade.php b/resources/views/rd/ai-quotation/document.blade.php new file mode 100644 index 00000000..2370f95f --- /dev/null +++ b/resources/views/rd/ai-quotation/document.blade.php @@ -0,0 +1,235 @@ +@extends('layouts.document') + +@section('title', '견적서') + +@push('styles') + +@endpush + +@section('content') +@php + // 견적번호 + $quotationNo = 'AQ-' . $quotation->created_at->format('Y') . '-' . str_pad($quotation->id, 3, '0', STR_PAD_LEFT); + + // 회사 분석 정보 + $company = $quotation->analysis_result['company_analysis'] ?? []; + + // 구현 계획 + $plan = $quotation->quotation_result['implementation_plan'] ?? []; + $estimatedMonths = $plan['estimated_months'] ?? null; + + // 금액 계산 + $devSubtotal = (int) $quotation->total_dev_cost; + $monthlySubtotal = (int) $quotation->total_monthly_fee; + $devVat = (int) round($devSubtotal * 0.1); + $monthlyVat = (int) round($monthlySubtotal * 0.1); + $devTotal = $devSubtotal + $devVat; + $monthlyTotal = $monthlySubtotal + $monthlyVat; + + // 한글 금액 변환 + function numberToKorean(int $number): string { + if ($number === 0) return '영'; + $units = ['', '만', '억', '조']; + $digits = ['', '일', '이', '삼', '사', '오', '육', '칠', '팔', '구']; + $subUnits = ['', '십', '백', '천']; + + $result = ''; + $unitIndex = 0; + while ($number > 0) { + $chunk = $number % 10000; + if ($chunk > 0) { + $chunkStr = ''; + $subIndex = 0; + $temp = $chunk; + while ($temp > 0) { + $digit = $temp % 10; + if ($digit > 0) { + $prefix = ($digit === 1 && $subIndex > 0) ? '' : $digits[$digit]; + $chunkStr = $prefix . $subUnits[$subIndex] . $chunkStr; + } + $temp = (int)($temp / 10); + $subIndex++; + } + $result = $chunkStr . $units[$unitIndex] . $result; + } + $number = (int)($number / 10000); + $unitIndex++; + } + return $result; + } + + $devTotalKorean = numberToKorean($devSubtotal); + + // 필수 → 선택 순으로 정렬된 품목 + $sortedItems = $quotation->items->sortByDesc('is_required')->values(); +@endphp + +
+ + {{-- 제목 --}} +

+ 견 적 서 +

+ + {{-- 견적 정보 --}} +
+
+

견적번호: {{ $quotationNo }}

+

유효기간: 견적일로부터 30일

+
+
+

견적일자: {{ $quotation->created_at->format('Y년 m월 d일') }}

+
+
+ + {{-- 수신 / 공급자 --}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
수 신공 급 자
귀사명{{ $quotation->title }}상 호(주)코드브릿지엑스
업 종{{ $company['industry'] ?? '-' }}대 표권형석
규 모{{ $company['scale'] ?? '-' }}주 소인천 남동구 남동대로 215번길 30
현재시스템{{ !empty($company['current_systems']) ? implode(', ', $company['current_systems']) : '-' }}연락처032-123-4567
+ + {{-- 인사말 + 합계 --}} +
+

아래와 같이 견적합니다.

+

+ 합계금액: 금 {{ $devTotalKorean }}원정 + (₩{{ number_format($devSubtotal) }}) +

+

※ 부가가치세 별도 / 월 구독료 {{ number_format($monthlySubtotal) }}원 별도

+
+ + {{-- 품목 테이블 --}} + + + + + + + + + + + + + + + + + + + + + @foreach($sortedItems as $index => $item) + + + + + + + + + @endforeach + + + + + + + + + + + + + + + + + + +
No구분품 목설 명개발비 (원)월 구독료 (원)
{{ $index + 1 }} + {{ $item->is_required ? '필수' : '선택' }} + {{ $item->module_name }}{{ Str::limit($item->reason, 80) }}{{ number_format((int) $item->dev_cost) }}{{ number_format((int) $item->monthly_fee) }}
소 계{{ number_format($devSubtotal) }}{{ number_format($monthlySubtotal) }}
부가세 (10%){{ number_format($devVat) }}{{ number_format($monthlyVat) }}
합 계{{ number_format($devTotal) }}{{ number_format($monthlyTotal) }}
+ + {{-- 비고 --}} +
+ + + + + + + + + + + +
비 고
+
    +
  1. 상기 금액은 부가가치세 별도입니다.
  2. +
  3. 개발비 납부 조건: 계약 시 50%, 완료 시 50% 분할 납부
  4. +
  5. 월 구독료: 서비스 오픈일부터 과금 (월 {{ number_format($monthlyTotal) }}원, VAT 포함)
  6. + @if($estimatedMonths) +
  7. 예상 구축 기간: {{ $estimatedMonths }}개월
  8. + @endif +
  9. 본 견적서의 유효기간은 견적일로부터 30일입니다.
  10. +
  11. 세부 사항은 별도 협의를 통해 조정될 수 있습니다.
  12. +
+
+
+ + {{-- 서명 --}} +
+
+

(주)코드브릿지엑스

+

대표이사 권 형 석

+
+
(인)
+
+ +
+@endsection diff --git a/resources/views/rd/ai-quotation/show.blade.php b/resources/views/rd/ai-quotation/show.blade.php index acd1082a..ecacee15 100644 --- a/resources/views/rd/ai-quotation/show.blade.php +++ b/resources/views/rd/ai-quotation/show.blade.php @@ -16,6 +16,12 @@ 목록 + @if($quotation->isCompleted()) + + 견적서 보기 + + @endif @if($quotation->isCompleted() || $quotation->status === 'failed')