2026-01-21 10:25:18 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
|
|
|
|
|
|
use App\Helpers\ApiResponse;
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Services\WelfareService;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 복리후생비 현황 컨트롤러
|
|
|
|
|
*
|
|
|
|
|
* CEO 대시보드용 복리후생비 현황 데이터를 제공합니다.
|
|
|
|
|
*/
|
|
|
|
|
class WelfareController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private readonly WelfareService $welfareService
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 복리후생비 현황 요약 조회
|
|
|
|
|
*/
|
|
|
|
|
public function summary(Request $request): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
$limitType = $request->query('limit_type', 'quarterly');
|
|
|
|
|
$calculationType = $request->query('calculation_type', 'fixed');
|
|
|
|
|
$fixedAmountPerMonth = $request->query('fixed_amount_per_month')
|
|
|
|
|
? (int) $request->query('fixed_amount_per_month')
|
|
|
|
|
: 200000;
|
|
|
|
|
$ratio = $request->query('ratio')
|
|
|
|
|
? (float) $request->query('ratio')
|
|
|
|
|
: 0.05;
|
|
|
|
|
$year = $request->query('year') ? (int) $request->query('year') : null;
|
|
|
|
|
$quarter = $request->query('quarter') ? (int) $request->query('quarter') : null;
|
|
|
|
|
|
2026-01-21 10:29:59 +09:00
|
|
|
return ApiResponse::handle(function () use ($limitType, $calculationType, $fixedAmountPerMonth, $ratio, $year, $quarter) {
|
|
|
|
|
return $this->welfareService->getSummary(
|
|
|
|
|
$limitType,
|
|
|
|
|
$calculationType,
|
|
|
|
|
$fixedAmountPerMonth,
|
|
|
|
|
$ratio,
|
|
|
|
|
$year,
|
|
|
|
|
$quarter
|
|
|
|
|
);
|
|
|
|
|
}, __('message.fetched'));
|
2026-01-21 10:25:18 +09:00
|
|
|
}
|
2026-01-22 22:35:20 +09:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 복리후생비 상세 조회 (모달용)
|
|
|
|
|
*/
|
|
|
|
|
public function detail(Request $request): JsonResponse
|
|
|
|
|
{
|
|
|
|
|
$calculationType = $request->query('calculation_type', 'fixed');
|
|
|
|
|
$fixedAmountPerMonth = $request->query('fixed_amount_per_month')
|
|
|
|
|
? (int) $request->query('fixed_amount_per_month')
|
|
|
|
|
: 200000;
|
|
|
|
|
$ratio = $request->query('ratio')
|
|
|
|
|
? (float) $request->query('ratio')
|
|
|
|
|
: 0.05;
|
|
|
|
|
$year = $request->query('year') ? (int) $request->query('year') : null;
|
|
|
|
|
$quarter = $request->query('quarter') ? (int) $request->query('quarter') : null;
|
|
|
|
|
|
|
|
|
|
return ApiResponse::handle(function () use ($calculationType, $fixedAmountPerMonth, $ratio, $year, $quarter) {
|
|
|
|
|
return $this->welfareService->getDetail(
|
|
|
|
|
$calculationType,
|
|
|
|
|
$fixedAmountPerMonth,
|
|
|
|
|
$ratio,
|
|
|
|
|
$year,
|
|
|
|
|
$quarter
|
|
|
|
|
);
|
|
|
|
|
}, __('message.fetched'));
|
|
|
|
|
}
|
|
|
|
|
}
|