Phase 0 - 공통 모듈: - ExportService.php 생성 (Maatwebsite/Excel 기반 엑셀 내보내기) - BulkUpdateAccountCodeRequest.php 생성 (계정과목 일괄변경 유효성 검사) Phase 1 - 계정과목 일괄변경: - WithdrawalController/Service: bulkUpdateAccountCode 메서드 추가 - DepositController/Service: bulkUpdateAccountCode 메서드 추가 - POST /v1/withdrawals/bulk-update-account-code - POST /v1/deposits/bulk-update-account-code Phase 2 - 엑셀 내보내기: - AttendanceController/Service: export, getExportData 메서드 추가 - SalaryController/Service: export, getExportData 메서드 추가 - GET /v1/attendances/export - GET /v1/salaries/export Co-Authored-By: Claude <noreply@anthropic.com>
115 lines
2.7 KiB
PHP
115 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1;
|
|
|
|
use App\Helpers\ApiResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\BulkUpdateAccountCodeRequest;
|
|
use App\Http\Requests\V1\Withdrawal\StoreWithdrawalRequest;
|
|
use App\Http\Requests\V1\Withdrawal\UpdateWithdrawalRequest;
|
|
use App\Services\WithdrawalService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class WithdrawalController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly WithdrawalService $service
|
|
) {}
|
|
|
|
/**
|
|
* 출금 목록
|
|
*/
|
|
public function index(Request $request)
|
|
{
|
|
$params = $request->only([
|
|
'search',
|
|
'start_date',
|
|
'end_date',
|
|
'client_id',
|
|
'payment_method',
|
|
'bank_account_id',
|
|
'sort_by',
|
|
'sort_dir',
|
|
'per_page',
|
|
'page',
|
|
]);
|
|
|
|
$withdrawals = $this->service->index($params);
|
|
|
|
return ApiResponse::success($withdrawals, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 출금 등록
|
|
*/
|
|
public function store(StoreWithdrawalRequest $request)
|
|
{
|
|
$withdrawal = $this->service->store($request->validated());
|
|
|
|
return ApiResponse::success($withdrawal, __('message.created'), [], 201);
|
|
}
|
|
|
|
/**
|
|
* 출금 상세
|
|
*/
|
|
public function show(int $id)
|
|
{
|
|
$withdrawal = $this->service->show($id);
|
|
|
|
return ApiResponse::success($withdrawal, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 출금 수정
|
|
*/
|
|
public function update(int $id, UpdateWithdrawalRequest $request)
|
|
{
|
|
$withdrawal = $this->service->update($id, $request->validated());
|
|
|
|
return ApiResponse::success($withdrawal, __('message.updated'));
|
|
}
|
|
|
|
/**
|
|
* 출금 삭제
|
|
*/
|
|
public function destroy(int $id)
|
|
{
|
|
$this->service->destroy($id);
|
|
|
|
return ApiResponse::success(null, __('message.deleted'));
|
|
}
|
|
|
|
/**
|
|
* 출금 요약 (기간별 합계)
|
|
*/
|
|
public function summary(Request $request)
|
|
{
|
|
$params = $request->only([
|
|
'start_date',
|
|
'end_date',
|
|
'client_id',
|
|
'payment_method',
|
|
]);
|
|
|
|
$summary = $this->service->summary($params);
|
|
|
|
return ApiResponse::success($summary, __('message.fetched'));
|
|
}
|
|
|
|
/**
|
|
* 계정과목 일괄 변경
|
|
*/
|
|
public function bulkUpdateAccountCode(BulkUpdateAccountCodeRequest $request)
|
|
{
|
|
$updatedCount = $this->service->bulkUpdateAccountCode(
|
|
$request->getIds(),
|
|
$request->getAccountCode()
|
|
);
|
|
|
|
return ApiResponse::success(
|
|
['updated_count' => $updatedCount],
|
|
__('message.bulk_updated')
|
|
);
|
|
}
|
|
}
|