From cac8dba138b6f3b1b34d705bdff8e7fda977b05f Mon Sep 17 00:00:00 2001 From: hskwon Date: Wed, 24 Dec 2025 19:41:33 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=96=B4=EC=9D=8C=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=20=EC=A4=91=EB=B3=B5=EB=B2=88=ED=98=B8=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - StoreBillRequest에 tenant scope unique 검증 규칙 추가 - lang/ko/error.php에 bill.duplicate_number 에러 메시지 추가 - SAM 표준 패턴 적용 (app('tenant_id')) --- app/Http/Requests/V1/Bill/StoreBillRequest.php | 13 ++++++++++++- lang/ko/error.php | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Http/Requests/V1/Bill/StoreBillRequest.php b/app/Http/Requests/V1/Bill/StoreBillRequest.php index 01c262e..562dc98 100644 --- a/app/Http/Requests/V1/Bill/StoreBillRequest.php +++ b/app/Http/Requests/V1/Bill/StoreBillRequest.php @@ -3,6 +3,7 @@ namespace App\Http\Requests\V1\Bill; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Validation\Rule; class StoreBillRequest extends FormRequest { @@ -13,8 +14,17 @@ public function authorize(): bool public function rules(): array { + $tenantId = app('tenant_id') ?? 0; + return [ - 'bill_number' => ['nullable', 'string', 'max:50'], + 'bill_number' => [ + 'nullable', + 'string', + 'max:50', + Rule::unique('bills', 'bill_number')->where(function ($query) use ($tenantId) { + return $query->where('tenant_id', $tenantId); + }), + ], 'bill_type' => ['required', 'string', 'in:received,issued'], 'client_id' => ['nullable', 'integer', 'exists:clients,id'], 'client_name' => ['nullable', 'string', 'max:100'], @@ -37,6 +47,7 @@ public function rules(): array public function messages(): array { return [ + 'bill_number.unique' => __('error.bill.duplicate_number'), 'bill_type.required' => __('validation.required', ['attribute' => __('validation.attributes.bill_type')]), 'bill_type.in' => __('validation.in', ['attribute' => __('validation.attributes.bill_type')]), 'amount.required' => __('validation.required', ['attribute' => __('validation.attributes.amount')]), diff --git a/lang/ko/error.php b/lang/ko/error.php index 7f8fb4e..139f0c9 100644 --- a/lang/ko/error.php +++ b/lang/ko/error.php @@ -289,6 +289,11 @@ 'recipient_email_required' => '수신자 이메일이 필요합니다.', ], + // 어음 관리 관련 + 'bill' => [ + 'duplicate_number' => '이미 존재하는 어음번호입니다.', + ], + // 계정 관리 관련 'account' => [ 'invalid_password' => '비밀번호가 일치하지 않습니다.',