From 1b2363d6616487766972fecebbd12fca09f023e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9C=A0=EB=B3=91=EC=B2=A0?= Date: Thu, 5 Mar 2026 10:06:48 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[daily-report]=20=EC=97=91=EC=85=80=20?= =?UTF-8?q?=EB=82=B4=EB=B3=B4=EB=82=B4=EA=B8=B0=EC=97=90=20=EC=96=B4?= =?UTF-8?q?=EC=9D=8C/=EC=99=B8=EC=83=81=EB=A7=A4=EC=B6=9C=EC=B1=84?= =?UTF-8?q?=EA=B6=8C=20=ED=98=84=ED=99=A9=20=EC=84=B9=EC=85=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DailyReportExport: 어음 현황 테이블 + 합계 + 스타일링 추가 - DailyReportService: exportData에 noteReceivables 데이터 포함 Co-Authored-By: Claude Opus 4.6 --- app/Exports/DailyReportExport.php | 61 +++++++++++++++++++++++++++-- app/Services/DailyReportService.php | 4 ++ 2 files changed, 62 insertions(+), 3 deletions(-) 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, ]; }