diff --git a/app/Exports/DailyReportExport.php b/app/Exports/DailyReportExport.php index f8c4eee..f90c18b 100644 --- a/app/Exports/DailyReportExport.php +++ b/app/Exports/DailyReportExport.php @@ -7,6 +7,7 @@ use Maatwebsite\Excel\Concerns\WithHeadings; use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Concerns\WithTitle; +use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class DailyReportExport implements FromArray, ShouldAutoSize, WithHeadings, WithStyles, WithTitle @@ -47,6 +48,7 @@ public function array(): array { $rows = []; + // ── 예금 입출금 내역 ── foreach ($this->report['details'] as $detail) { $rows[] = [ $detail['type_label'], @@ -58,7 +60,7 @@ public function array(): array ]; } - // 합계 행 추가 + // 합계 행 $rows[] = []; $rows[] = [ '합계', @@ -69,6 +71,37 @@ public function array(): array '', ]; + // ── 어음 및 외상매출채권 현황 ── + $noteReceivables = $this->report['note_receivables'] ?? []; + + $rows[] = []; + $rows[] = []; + $rows[] = ['어음 및 외상매출채권 현황']; + $rows[] = ['No.', '내용', '금액', '발행일', '만기일']; + + $noteTotal = 0; + $no = 1; + foreach ($noteReceivables as $item) { + $amount = $item['current_balance'] ?? 0; + $noteTotal += $amount; + $rows[] = [ + $no++, + $item['content'] ?? '-', + $amount > 0 ? number_format($amount) : '', + $item['issue_date'] ?? '-', + $item['due_date'] ?? '-', + ]; + } + + // 어음 합계 + $rows[] = [ + '합계', + '', + number_format($noteTotal), + '', + '', + ]; + return $rows; } @@ -77,7 +110,7 @@ public function array(): array */ public function styles(Worksheet $sheet): array { - return [ + $styles = [ 1 => ['font' => ['bold' => true, 'size' => 14]], 3 => ['font' => ['bold' => true]], 4 => ['font' => ['bold' => true]], @@ -86,10 +119,32 @@ public function styles(Worksheet $sheet): array 8 => [ 'font' => ['bold' => true], 'fill' => [ - 'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, + 'fillType' => Fill::FILL_SOLID, 'startColor' => ['rgb' => 'E0E0E0'], ], ], ]; + + // 어음 섹션 헤더 스타일 (동적 행 번호) + // headings 8행 + details 수 + 합계 2행 + 빈 2행 + 어음 제목 1행 + 어음 헤더 1행 + $detailCount = count($this->report['details']); + $noteHeaderTitleRow = 8 + $detailCount + 2 + 2 + 1; // 어음 제목 행 + $noteHeaderRow = $noteHeaderTitleRow + 1; // 어음 컬럼 헤더 행 + + $styles[$noteHeaderTitleRow] = ['font' => ['bold' => true, 'size' => 12]]; + $styles[$noteHeaderRow] = [ + 'font' => ['bold' => true], + 'fill' => [ + 'fillType' => Fill::FILL_SOLID, + 'startColor' => ['rgb' => 'E0E0E0'], + ], + ]; + + // 어음 합계 행 + $noteCount = count($this->report['note_receivables'] ?? []); + $noteTotalRow = $noteHeaderRow + $noteCount + 1; + $styles[$noteTotalRow] = ['font' => ['bold' => true]]; + + return $styles; } } diff --git a/app/Services/DailyReportService.php b/app/Services/DailyReportService.php index d2be5ca..8069ffc 100644 --- a/app/Services/DailyReportService.php +++ b/app/Services/DailyReportService.php @@ -242,6 +242,9 @@ public function exportData(array $params): array ]; } + // 어음 및 외상매출채권 현황 + $noteReceivables = $this->noteReceivables($params); + return [ 'date' => $dateStr, 'previous_balance' => $previousBalance, @@ -249,6 +252,7 @@ public function exportData(array $params): array 'daily_withdrawal' => $dailyWithdrawalTotal, 'current_balance' => $currentBalance, 'details' => $details, + 'note_receivables' => $noteReceivables, ]; }