feat: 2.4 입금/출금 관리 API 구현
- 마이그레이션: deposits, withdrawals 테이블 생성 - 모델: Deposit, Withdrawal (BelongsToTenant, SoftDeletes) - 서비스: DepositService, WithdrawalService (CRUD + summary) - 컨트롤러: DepositController, WithdrawalController - FormRequest: Store/Update 검증 클래스 - Swagger: 입금/출금 API 문서 (12개 엔드포인트) - 라우트: /v1/deposits, /v1/withdrawals 등록
This commit is contained in:
54
app/Http/Requests/V1/Deposit/StoreDepositRequest.php
Normal file
54
app/Http/Requests/V1/Deposit/StoreDepositRequest.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V1\Deposit;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreDepositRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'deposit_date' => ['required', 'date'],
|
||||
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
||||
'client_name' => ['nullable', 'string', 'max:100'],
|
||||
'bank_account_id' => ['nullable', 'integer', 'exists:bank_accounts,id'],
|
||||
'amount' => ['required', 'numeric', 'min:0'],
|
||||
'payment_method' => ['required', 'string', 'in:cash,transfer,card,check'],
|
||||
'account_code' => ['nullable', 'string', 'max:20'],
|
||||
'description' => ['nullable', 'string', 'max:1000'],
|
||||
'reference_type' => ['nullable', 'string', 'max:50'],
|
||||
'reference_id' => ['nullable', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'deposit_date.required' => __('validation.required', ['attribute' => __('validation.attributes.deposit_date')]),
|
||||
'amount.required' => __('validation.required', ['attribute' => __('validation.attributes.amount')]),
|
||||
'amount.min' => __('validation.min.numeric', ['attribute' => __('validation.attributes.amount'), 'min' => 0]),
|
||||
'payment_method.required' => __('validation.required', ['attribute' => __('validation.attributes.payment_method')]),
|
||||
'payment_method.in' => __('validation.in', ['attribute' => __('validation.attributes.payment_method')]),
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'deposit_date' => __('validation.attributes.deposit_date'),
|
||||
'client_id' => __('validation.attributes.client_id'),
|
||||
'client_name' => __('validation.attributes.client_name'),
|
||||
'bank_account_id' => __('validation.attributes.bank_account_id'),
|
||||
'amount' => __('validation.attributes.amount'),
|
||||
'payment_method' => __('validation.attributes.payment_method'),
|
||||
'account_code' => __('validation.attributes.account_code'),
|
||||
'description' => __('validation.attributes.description'),
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Http/Requests/V1/Deposit/UpdateDepositRequest.php
Normal file
43
app/Http/Requests/V1/Deposit/UpdateDepositRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V1\Deposit;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateDepositRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'deposit_date' => ['sometimes', 'date'],
|
||||
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
||||
'client_name' => ['nullable', 'string', 'max:100'],
|
||||
'bank_account_id' => ['nullable', 'integer', 'exists:bank_accounts,id'],
|
||||
'amount' => ['sometimes', 'numeric', 'min:0'],
|
||||
'payment_method' => ['sometimes', 'string', 'in:cash,transfer,card,check'],
|
||||
'account_code' => ['nullable', 'string', 'max:20'],
|
||||
'description' => ['nullable', 'string', 'max:1000'],
|
||||
'reference_type' => ['nullable', 'string', 'max:50'],
|
||||
'reference_id' => ['nullable', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'deposit_date' => __('validation.attributes.deposit_date'),
|
||||
'client_id' => __('validation.attributes.client_id'),
|
||||
'client_name' => __('validation.attributes.client_name'),
|
||||
'bank_account_id' => __('validation.attributes.bank_account_id'),
|
||||
'amount' => __('validation.attributes.amount'),
|
||||
'payment_method' => __('validation.attributes.payment_method'),
|
||||
'account_code' => __('validation.attributes.account_code'),
|
||||
'description' => __('validation.attributes.description'),
|
||||
];
|
||||
}
|
||||
}
|
||||
54
app/Http/Requests/V1/Withdrawal/StoreWithdrawalRequest.php
Normal file
54
app/Http/Requests/V1/Withdrawal/StoreWithdrawalRequest.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V1\Withdrawal;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreWithdrawalRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'withdrawal_date' => ['required', 'date'],
|
||||
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
||||
'client_name' => ['nullable', 'string', 'max:100'],
|
||||
'bank_account_id' => ['nullable', 'integer', 'exists:bank_accounts,id'],
|
||||
'amount' => ['required', 'numeric', 'min:0'],
|
||||
'payment_method' => ['required', 'string', 'in:cash,transfer,card,check'],
|
||||
'account_code' => ['nullable', 'string', 'max:20'],
|
||||
'description' => ['nullable', 'string', 'max:1000'],
|
||||
'reference_type' => ['nullable', 'string', 'max:50'],
|
||||
'reference_id' => ['nullable', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'withdrawal_date.required' => __('validation.required', ['attribute' => __('validation.attributes.withdrawal_date')]),
|
||||
'amount.required' => __('validation.required', ['attribute' => __('validation.attributes.amount')]),
|
||||
'amount.min' => __('validation.min.numeric', ['attribute' => __('validation.attributes.amount'), 'min' => 0]),
|
||||
'payment_method.required' => __('validation.required', ['attribute' => __('validation.attributes.payment_method')]),
|
||||
'payment_method.in' => __('validation.in', ['attribute' => __('validation.attributes.payment_method')]),
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'withdrawal_date' => __('validation.attributes.withdrawal_date'),
|
||||
'client_id' => __('validation.attributes.client_id'),
|
||||
'client_name' => __('validation.attributes.client_name'),
|
||||
'bank_account_id' => __('validation.attributes.bank_account_id'),
|
||||
'amount' => __('validation.attributes.amount'),
|
||||
'payment_method' => __('validation.attributes.payment_method'),
|
||||
'account_code' => __('validation.attributes.account_code'),
|
||||
'description' => __('validation.attributes.description'),
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Http/Requests/V1/Withdrawal/UpdateWithdrawalRequest.php
Normal file
43
app/Http/Requests/V1/Withdrawal/UpdateWithdrawalRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V1\Withdrawal;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateWithdrawalRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'withdrawal_date' => ['sometimes', 'date'],
|
||||
'client_id' => ['nullable', 'integer', 'exists:clients,id'],
|
||||
'client_name' => ['nullable', 'string', 'max:100'],
|
||||
'bank_account_id' => ['nullable', 'integer', 'exists:bank_accounts,id'],
|
||||
'amount' => ['sometimes', 'numeric', 'min:0'],
|
||||
'payment_method' => ['sometimes', 'string', 'in:cash,transfer,card,check'],
|
||||
'account_code' => ['nullable', 'string', 'max:20'],
|
||||
'description' => ['nullable', 'string', 'max:1000'],
|
||||
'reference_type' => ['nullable', 'string', 'max:50'],
|
||||
'reference_id' => ['nullable', 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'withdrawal_date' => __('validation.attributes.withdrawal_date'),
|
||||
'client_id' => __('validation.attributes.client_id'),
|
||||
'client_name' => __('validation.attributes.client_name'),
|
||||
'bank_account_id' => __('validation.attributes.bank_account_id'),
|
||||
'amount' => __('validation.attributes.amount'),
|
||||
'payment_method' => __('validation.attributes.payment_method'),
|
||||
'account_code' => __('validation.attributes.account_code'),
|
||||
'description' => __('validation.attributes.description'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user