feat: [entertainment] 접대비 상세 조회 날짜 필터 파라미터 추가
- EntertainmentController: detail에 start_date/end_date 파라미터 전달 - EntertainmentService: getDetail 리스크/사용자분포/거래내역에 날짜 필터 적용 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,9 +42,11 @@ public function detail(Request $request): JsonResponse
|
||||
$companyType = $request->query('company_type', 'medium');
|
||||
$year = $request->query('year') ? (int) $request->query('year') : null;
|
||||
$quarter = $request->query('quarter') ? (int) $request->query('quarter') : null;
|
||||
$startDate = $request->query('start_date');
|
||||
$endDate = $request->query('end_date');
|
||||
|
||||
return ApiResponse::handle(function () use ($companyType, $year, $quarter) {
|
||||
return $this->entertainmentService->getDetail($companyType, $year, $quarter);
|
||||
return ApiResponse::handle(function () use ($companyType, $year, $quarter, $startDate, $endDate) {
|
||||
return $this->entertainmentService->getDetail($companyType, $year, $quarter, $startDate, $endDate);
|
||||
}, __('message.fetched'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,9 @@ private function getMissingReceiptRisk(int $tenantId, string $startDate, string
|
||||
public function getDetail(
|
||||
?string $companyType = 'medium',
|
||||
?int $year = null,
|
||||
?int $quarter = null
|
||||
?int $quarter = null,
|
||||
?string $startDate = null,
|
||||
?string $endDate = null
|
||||
): array {
|
||||
$tenantId = $this->tenantId();
|
||||
$now = Carbon::now();
|
||||
@@ -236,13 +238,18 @@ public function getDetail(
|
||||
$companyType = $companyType ?? 'medium';
|
||||
$quarter = $quarter ?? $now->quarter;
|
||||
|
||||
// 연간 기간 범위
|
||||
// 연간 기간 범위 (summary, calculation, quarterly, monthly_usage용 - 항상 연간)
|
||||
$annualStartDate = Carbon::create($year, 1, 1)->format('Y-m-d');
|
||||
$annualEndDate = Carbon::create($year, 12, 31)->format('Y-m-d');
|
||||
|
||||
// 분기 기간 범위
|
||||
$quarterStartDate = Carbon::create($year, ($quarter - 1) * 3 + 1, 1)->format('Y-m-d');
|
||||
$quarterEndDate = Carbon::create($year, $quarter * 3, 1)->endOfMonth()->format('Y-m-d');
|
||||
// 거래/리스크 필터 기간 (start_date/end_date 전달 시 사용, 없으면 분기 기본)
|
||||
if ($startDate && $endDate) {
|
||||
$filterStartDate = $startDate;
|
||||
$filterEndDate = $endDate;
|
||||
} else {
|
||||
$filterStartDate = Carbon::create($year, ($quarter - 1) * 3 + 1, 1)->format('Y-m-d');
|
||||
$filterEndDate = Carbon::create($year, $quarter * 3, 1)->endOfMonth()->format('Y-m-d');
|
||||
}
|
||||
|
||||
// 기본한도 계산 (중소기업: 3,600만, 일반법인: 1,200만)
|
||||
$baseLimit = $companyType === 'large' ? 12000000 : 36000000;
|
||||
@@ -273,11 +280,11 @@ public function getDetail(
|
||||
'annual_exceeded' => (int) $annualExceeded,
|
||||
];
|
||||
|
||||
// 2. 리스크 검토 카드 (기존 getSummary의 리스크 쿼리 재활용)
|
||||
$weekendLateNight = $this->getWeekendLateNightRisk($tenantId, $annualStartDate, $annualEndDate);
|
||||
$prohibitedBiz = $this->getProhibitedBizTypeRisk($tenantId, $annualStartDate, $annualEndDate);
|
||||
$highAmount = $this->getHighAmountRisk($tenantId, $annualStartDate, $annualEndDate);
|
||||
$missingReceipt = $this->getMissingReceiptRisk($tenantId, $annualStartDate, $annualEndDate);
|
||||
// 2. 리스크 검토 카드 (날짜 필터 적용)
|
||||
$weekendLateNight = $this->getWeekendLateNightRisk($tenantId, $filterStartDate, $filterEndDate);
|
||||
$prohibitedBiz = $this->getProhibitedBizTypeRisk($tenantId, $filterStartDate, $filterEndDate);
|
||||
$highAmount = $this->getHighAmountRisk($tenantId, $filterStartDate, $filterEndDate);
|
||||
$missingReceipt = $this->getMissingReceiptRisk($tenantId, $filterStartDate, $filterEndDate);
|
||||
|
||||
$riskReview = [
|
||||
['label' => '주말/심야', 'amount' => (int) $weekendLateNight['total'], 'count' => $weekendLateNight['count']],
|
||||
@@ -289,11 +296,11 @@ public function getDetail(
|
||||
// 3. 월별 사용 추이
|
||||
$monthlyUsage = $this->getMonthlyUsageTrend($tenantId, $year);
|
||||
|
||||
// 4. 사용자별 분포
|
||||
$userDistribution = $this->getUserDistribution($tenantId, $annualStartDate, $annualEndDate);
|
||||
// 4. 사용자별 분포 (날짜 필터 적용)
|
||||
$userDistribution = $this->getUserDistribution($tenantId, $filterStartDate, $filterEndDate);
|
||||
|
||||
// 5. 거래 내역
|
||||
$transactions = $this->getTransactions($tenantId, $quarterStartDate, $quarterEndDate);
|
||||
// 5. 거래 내역 (날짜 필터 적용)
|
||||
$transactions = $this->getTransactions($tenantId, $filterStartDate, $filterEndDate);
|
||||
|
||||
// 6. 손금한도 계산 정보
|
||||
$calculation = [
|
||||
|
||||
Reference in New Issue
Block a user