feat(API): 종합분석 페이지 더미 데이터 추가

- 당월 예상 지출: 매입/카드/발행어음 라벨로 변경, 전월 대비 증감률 표시
- 접대비 현황: 연간 한도 4,000만원, 더미 사용량 데이터
- 복리후생비 현황: 인당 20만원 기준, 더미 사용량 데이터

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-02 11:15:05 +09:00
parent 7566814876
commit 561a4745e0

View File

@@ -86,7 +86,7 @@ protected function getMonthlyExpense(int $year, int $month): array
{ {
$tenantId = $this->tenantId(); $tenantId = $this->tenantId();
// 이번 달 예상 지출 합계 // 이번 달 예상 지출 합계 (유형별)
$expenses = ExpectedExpense::where('tenant_id', $tenantId) $expenses = ExpectedExpense::where('tenant_id', $tenantId)
->whereYear('expected_payment_date', $year) ->whereYear('expected_payment_date', $year)
->whereMonth('expected_payment_date', $month) ->whereMonth('expected_payment_date', $month)
@@ -95,47 +95,105 @@ protected function getMonthlyExpense(int $year, int $month): array
->get() ->get()
->keyBy('transaction_type'); ->keyBy('transaction_type');
// 미지급 금액 // 전월 데이터
$unpaidTotal = ExpectedExpense::where('tenant_id', $tenantId) $lastMonth = $month === 1 ? 12 : $month - 1;
->whereYear('expected_payment_date', $year) $lastYear = $month === 1 ? $year - 1 : $year;
->whereMonth('expected_payment_date', $month) $lastMonthExpenses = ExpectedExpense::where('tenant_id', $tenantId)
->where('payment_status', 'pending') ->whereYear('expected_payment_date', $lastYear)
->sum('amount'); ->whereMonth('expected_payment_date', $lastMonth)
->selectRaw('transaction_type, SUM(amount) as total')
->groupBy('transaction_type')
->get()
->keyBy('transaction_type');
// 지급 완료 금액 // 실제 데이터 추출
$paidTotal = ExpectedExpense::where('tenant_id', $tenantId) $purchaseTotal = (float) ($expenses['purchase']->total ?? 0);
->whereYear('expected_payment_date', $year) $cardTotal = (float) ($expenses['card']->total ?? 0);
->whereMonth('expected_payment_date', $month) $billTotal = (float) ($expenses['bill']->total ?? 0);
->where('payment_status', 'paid')
->sum('amount');
// 연체 금액 $lastPurchase = (float) ($lastMonthExpenses['purchase']->total ?? 0);
$overdueTotal = ExpectedExpense::where('tenant_id', $tenantId) $lastCard = (float) ($lastMonthExpenses['card']->total ?? 0);
->where('expected_payment_date', '<', Carbon::today()) $lastBill = (float) ($lastMonthExpenses['bill']->total ?? 0);
->where('payment_status', 'pending')
->sum('amount'); // 데이터가 없으면 더미 데이터 사용
$hasData = $purchaseTotal > 0 || $cardTotal > 0 || $billTotal > 0;
if (! $hasData) {
$purchaseTotal = 45000000; // 매입 4,500만원
$cardTotal = 8500000; // 카드 850만원
$billTotal = 12000000; // 발행어음 1,200만원
$lastPurchase = 42000000; // 전월 매입 4,200만원
$lastCard = 7800000; // 전월 카드 780만원
$lastBill = 11500000; // 전월 발행어음 1,150만원
}
$totalExpense = $purchaseTotal + $cardTotal + $billTotal;
$lastTotalExpense = $lastPurchase + $lastCard + $lastBill;
// 전월 대비 증감률 계산
$calculateChange = function ($current, $previous) {
if ($previous == 0) {
return $current > 0 ? '+100%' : '0%';
}
$change = (($current - $previous) / $previous) * 100;
return ($change >= 0 ? '+' : '').number_format($change, 1).'%';
};
$cards = [ $cards = [
['id' => 'expense-1', 'label' => '이번 달 예상 지출', 'amount' => (float) ($unpaidTotal + $paidTotal)], [
['id' => 'expense-2', 'label' => '미지급 금액', 'amount' => (float) $unpaidTotal], 'id' => 'expense-1',
['id' => 'expense-3', 'label' => '지급 완료', 'amount' => (float) $paidTotal], 'label' => '매입',
['id' => 'expense-4', 'label' => '연체 금액', 'amount' => (float) $overdueTotal], 'amount' => $purchaseTotal,
'previous_amount' => $lastPurchase,
'previous_label' => '전월 대비 '.$calculateChange($purchaseTotal, $lastPurchase),
],
[
'id' => 'expense-2',
'label' => '카드',
'amount' => $cardTotal,
'previous_amount' => $lastCard,
'previous_label' => '전월 대비 '.$calculateChange($cardTotal, $lastCard),
],
[
'id' => 'expense-3',
'label' => '발행어음',
'amount' => $billTotal,
'previous_amount' => $lastBill,
'previous_label' => '전월 대비 '.$calculateChange($billTotal, $lastBill),
],
[
'id' => 'expense-4',
'label' => '총 예상 지출 합계',
'amount' => $totalExpense,
'previous_amount' => $lastTotalExpense,
'previous_label' => '전월 대비 '.$calculateChange($totalExpense, $lastTotalExpense),
],
]; ];
$checkPoints = []; $checkPoints = [];
if ($overdueTotal > 0) { $changeRate = $lastTotalExpense > 0 ? (($totalExpense - $lastTotalExpense) / $lastTotalExpense) * 100 : 0;
if ($changeRate > 15) {
$checkPoints[] = [ $checkPoints[] = [
'id' => 'expense-cp-1', 'id' => 'expense-cp-1',
'type' => 'warning', 'type' => 'warning',
'message' => '연체 중인 지출이 있습니다.', 'message' => '이번 달 예상 지출이',
'highlight' => number_format($overdueTotal).'원', 'highlight' => '전월 대비 '.number_format($changeRate, 0).'% 증가했습니다. 매입 비용 증가가 주요 원인입니다.',
]; ];
} } elseif ($changeRate < -5) {
if ($unpaidTotal > $paidTotal * 2) {
$checkPoints[] = [ $checkPoints[] = [
'id' => 'expense-cp-2', 'id' => 'expense-cp-1',
'type' => 'success',
'message' => '이번 달 예상 지출이',
'highlight' => '전월 대비 '.number_format(abs($changeRate), 0).'% 감소했습니다.',
];
} else {
$checkPoints[] = [
'id' => 'expense-cp-1',
'type' => 'info', 'type' => 'info',
'message' => '미지급 금액이 지급 완료 금액보다 많습니다.', 'message' => '이번 달 예상 지출이',
'highlight' => '전월과 비슷한 수준입니다.',
]; ];
} }
@@ -215,7 +273,6 @@ protected function getEntertainment(int $year, int $month): array
$tenantId = $this->tenantId(); $tenantId = $this->tenantId();
// 실제로는 expense_category 등으로 접대비 분류 필요 // 실제로는 expense_category 등으로 접대비 분류 필요
// 현재는 기본값 반환
$monthlyTotal = ExpectedExpense::where('tenant_id', $tenantId) $monthlyTotal = ExpectedExpense::where('tenant_id', $tenantId)
->whereYear('expected_payment_date', $year) ->whereYear('expected_payment_date', $year)
->whereMonth('expected_payment_date', $month) ->whereMonth('expected_payment_date', $month)
@@ -227,20 +284,44 @@ protected function getEntertainment(int $year, int $month): array
->where('transaction_type', 'other') ->where('transaction_type', 'other')
->sum('amount'); ->sum('amount');
// 실제 데이터가 없으면 더미 데이터 사용
$annualLimit = 40000000; // 연간 한도 4,000만원
$monthlyUsage = $monthlyTotal > 0 ? (float) $monthlyTotal : 2400000; // 이번 달 240만원
$yearlyUsage = $yearlyTotal > 0 ? (float) $yearlyTotal : 24000000; // 연간 누계 2,400만원
$remainingLimit = $annualLimit - $yearlyUsage;
$lastMonthUsage = 1850000; // 전월 185만원 (더미)
$cards = [ $cards = [
['id' => 'ent-1', 'label' => '이번 달 접대비', 'amount' => (float) ($monthlyTotal * 0.1)], ['id' => 'ent-1', 'label' => '접대비 한도', 'amount' => (float) $annualLimit, 'sub_amount' => $yearlyUsage, 'sub_label' => '사용'],
['id' => 'ent-2', 'label' => '연간 접대비 누계', 'amount' => (float) ($yearlyTotal * 0.1)], ['id' => 'ent-2', 'label' => '접대비 사용액', 'amount' => $monthlyUsage],
['id' => 'ent-3', 'label' => '한도 잔액', 'amount' => $remainingLimit],
['id' => 'ent-4', 'label' => '전월 사용액', 'amount' => $lastMonthUsage],
]; ];
$usageRate = ($yearlyUsage / $annualLimit) * 100;
$checkPoints = []; $checkPoints = [];
// 접대비 한도 초과 경고 (예시)
$limit = 5000000; // 월 500만원 한도 if ($usageRate >= 100) {
if ($monthlyTotal * 0.1 > $limit) { $overAmount = $yearlyUsage - $annualLimit;
$checkPoints[] = [ $checkPoints[] = [
'id' => 'ent-cp-1', 'id' => 'ent-cp-1',
'type' => 'error', 'type' => 'error',
'message' => '접대비가 월 한도 초과했습니다.', 'message' => '접대비 한도 초과 '.number_format($overAmount).'원 발생.',
'highlight' => number_format($limit).'원 초과', 'highlight' => '손금불산입되어 법인세 부담 증가합니다.',
];
} elseif ($usageRate >= 85) {
$checkPoints[] = [
'id' => 'ent-cp-1',
'type' => 'warning',
'message' => '접대비 '.round($usageRate).'% 도달. 연내 한도 '.number_format($remainingLimit).'원 잔액입니다.',
'highlight' => '사용 계획에 집중해 주세요.',
];
} else {
$checkPoints[] = [
'id' => 'ent-cp-1',
'type' => 'success',
'message' => '접대비 사용 총 '.number_format($yearlyUsage).'원 / 한도 '.number_format($annualLimit).'원 ('.round($usageRate).'%).',
'highlight' => '여유 있게 운영 중입니다.',
]; ];
} }
@@ -281,24 +362,58 @@ protected function getWelfare(int $year, int $month): array
->whereIn('transaction_type', ['salary', 'insurance']) ->whereIn('transaction_type', ['salary', 'insurance'])
->sum('amount'); ->sum('amount');
// 실제 데이터가 없으면 더미 데이터 사용
$hasData = $monthlyTotal > 0 || $yearlyTotal > 0;
$employeeCount = 15; // 직원 수 (더미)
$perPersonLimit = 200000; // 1인당 월 20만원 한도
$totalLimit = $employeeCount * $perPersonLimit; // 총 한도 300만원
$monthlyWelfare = $hasData ? (float) $monthlyTotal : 2700000; // 이번 달 270만원
$yearlyWelfare = $hasData ? (float) $yearlyTotal : 32400000; // 연간 누계 3,240만원
$perPersonMonthly = $monthlyWelfare / $employeeCount; // 1인당 18만원
$cards = [ $cards = [
['id' => 'wf-1', 'label' => '이번 달 복리후생비', 'amount' => (float) $monthlyTotal], ['id' => 'wf-1', 'label' => ' 복리후생비 한도', 'amount' => (float) $totalLimit],
['id' => 'wf-2', 'label' => '급여 지출', 'amount' => (float) $salaryTotal], ['id' => 'wf-2', 'label' => '누적 복리후생비 사용', 'amount' => $yearlyWelfare],
['id' => 'wf-3', 'label' => '보험료 지출', 'amount' => (float) $insuranceTotal], ['id' => 'wf-3', 'label' => '이번 달 복리후생비', 'amount' => $monthlyWelfare],
['id' => 'wf-4', 'label' => '연간 복리후생비 누계', 'amount' => (float) $yearlyTotal], ['id' => 'wf-4', 'label' => '1인당 월 복리후생비', 'amount' => $perPersonMonthly],
]; ];
$checkPoints = []; $checkPoints = [];
// 복리후생비 비율 경고 (예시)
if ($monthlyTotal > 0 && $salaryTotal > 0) { // 1인당 복리후생비 기준 체크
$ratio = ($monthlyTotal / $salaryTotal) * 100; if ($perPersonMonthly >= 150000 && $perPersonMonthly <= 250000) {
if ($ratio < 5 || $ratio > 20) { $checkPoints[] = [
$checkPoints[] = [ 'id' => 'wf-cp-1',
'id' => 'wf-cp-1', 'type' => 'success',
'type' => 'warning', 'message' => '1인당 월 복리후생비 '.number_format($perPersonMonthly).'원. 업계 평균(15~25만원) 내',
'message' => '복리후생비 비율이 정상 범위(5~20%)를 벗어났습니다.', 'highlight' => '정상 운영 중입니다.',
]; ];
} } elseif ($perPersonMonthly > 250000) {
$checkPoints[] = [
'id' => 'wf-cp-1',
'type' => 'warning',
'message' => '1인당 월 복리후생비가 '.number_format($perPersonMonthly).'원으로',
'highlight' => '업계 평균(15~25만원)을 초과했습니다.',
];
} else {
$checkPoints[] = [
'id' => 'wf-cp-1',
'type' => 'info',
'message' => '1인당 월 복리후생비가 '.number_format($perPersonMonthly).'원으로',
'highlight' => '업계 평균보다 낮습니다.',
];
}
// 식대 비과세 한도 체크 (더미 경고)
$mealAllowance = 250000; // 식대 25만원 (더미)
if ($mealAllowance > 200000) {
$checkPoints[] = [
'id' => 'wf-cp-2',
'type' => 'warning',
'message' => '식대가 월 '.number_format($mealAllowance).'원으로',
'highlight' => '비과세 한도(20만원)를 초과했습니다. 초과분은 근로소득 과세됩니다.',
];
} }
return [ return [