feat: [dashboard-ceo] CEO 대시보드 섹션별 API 및 일일보고서 엑셀 추가
- DashboardCeoController/Service: 6개 섹션 API 신규 (매출/매입/생산/미출고/시공/근태) - DailyReportController/Service: 엑셀 다운로드 API 추가 (GET /daily-report/export) - 라우트: dashboard 하위 6개 + daily-report/export 엔드포인트 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -182,6 +182,76 @@ public function summary(array $params): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 엑셀 내보내기용 데이터 조합
|
||||
* DailyReportExport가 기대하는 구조로 변환
|
||||
*/
|
||||
public function exportData(array $params): array
|
||||
{
|
||||
$tenantId = $this->tenantId();
|
||||
$date = isset($params['date']) ? Carbon::parse($params['date']) : Carbon::today();
|
||||
$dateStr = $date->format('Y-m-d');
|
||||
$startOfDay = $date->copy()->startOfDay();
|
||||
$endOfDay = $date->copy()->endOfDay();
|
||||
|
||||
// 전일 잔액 계산 (전일까지 입금 합계 - 전일까지 출금 합계)
|
||||
$prevDeposits = Deposit::where('tenant_id', $tenantId)
|
||||
->where('deposit_date', '<', $startOfDay)
|
||||
->sum('amount');
|
||||
$prevWithdrawals = Withdrawal::where('tenant_id', $tenantId)
|
||||
->where('withdrawal_date', '<', $startOfDay)
|
||||
->sum('amount');
|
||||
$previousBalance = (float) ($prevDeposits - $prevWithdrawals);
|
||||
|
||||
// 당일 입금
|
||||
$dailyDeposits = Deposit::where('tenant_id', $tenantId)
|
||||
->whereBetween('deposit_date', [$startOfDay, $endOfDay])
|
||||
->get();
|
||||
$dailyDepositTotal = (float) $dailyDeposits->sum('amount');
|
||||
|
||||
// 당일 출금
|
||||
$dailyWithdrawals = Withdrawal::where('tenant_id', $tenantId)
|
||||
->whereBetween('withdrawal_date', [$startOfDay, $endOfDay])
|
||||
->get();
|
||||
$dailyWithdrawalTotal = (float) $dailyWithdrawals->sum('amount');
|
||||
|
||||
$currentBalance = $previousBalance + $dailyDepositTotal - $dailyWithdrawalTotal;
|
||||
|
||||
// 상세 내역 조합
|
||||
$details = [];
|
||||
|
||||
foreach ($dailyDeposits as $d) {
|
||||
$details[] = [
|
||||
'type_label' => '입금',
|
||||
'client_name' => $d->client?->name ?? '-',
|
||||
'account_code' => $d->account_code ?? '-',
|
||||
'deposit_amount' => (float) $d->amount,
|
||||
'withdrawal_amount' => 0,
|
||||
'description' => $d->description ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($dailyWithdrawals as $w) {
|
||||
$details[] = [
|
||||
'type_label' => '출금',
|
||||
'client_name' => $w->client?->name ?? '-',
|
||||
'account_code' => $w->account_code ?? '-',
|
||||
'deposit_amount' => 0,
|
||||
'withdrawal_amount' => (float) $w->amount,
|
||||
'description' => $w->description ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'date' => $dateStr,
|
||||
'previous_balance' => $previousBalance,
|
||||
'daily_deposit' => $dailyDepositTotal,
|
||||
'daily_withdrawal' => $dailyWithdrawalTotal,
|
||||
'current_balance' => $currentBalance,
|
||||
'details' => $details,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 미수금 잔액 계산
|
||||
* = 전체 매출 - 전체 입금 - 전체 수취어음 (기준일까지)
|
||||
|
||||
Reference in New Issue
Block a user