fix: [finance] 계정과목 추가 시 tenant_id 불일치 수정 및 UX 개선

This commit is contained in:
김보곤
2026-03-20 12:46:36 +09:00
parent 3995355617
commit 8c1710f305
3 changed files with 27 additions and 6 deletions

View File

@@ -865,6 +865,13 @@ public function accountCodeStore(Request $request): JsonResponse
'category' => 'nullable|string|max:50',
]);
// TenantScope와 동일한 순서로 tenant_id 결정
$tenantId = $request->attributes->get('tenant_id')
?? $request->header('X-TENANT-ID')
?? session('selected_tenant_id')
?? auth()->user()?->tenant_id
?? 1;
if (AccountCode::where('code', $validated['code'])->exists()) {
return response()->json([
'success' => false,
@@ -875,7 +882,7 @@ public function accountCodeStore(Request $request): JsonResponse
$maxSort = AccountCode::max('sort_order') ?? 0;
$accountCode = AccountCode::create([
'tenant_id' => session('selected_tenant_id', 1),
'tenant_id' => (int) $tenantId,
'code' => $validated['code'],
'name' => $validated['name'],
'category' => $validated['category'] ?? null,