feat:일반전표입력에 계정과목 설정 기능 이관
계좌입출금내역에서 제거된 계정과목 설정 기능을 일반전표입력 페이지로 이관 - JournalEntryController에 계정과목 CRUD 메서드 추가 - 계정과목 CRUD 라우트 추가 (journal-entries/account-codes/*) - AccountCodeSettingsModal 컴포넌트 추가 - 페이지 헤더에 계정과목 설정 버튼 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -644,4 +644,103 @@ public function deleteBankJournal(int $id): JsonResponse
|
||||
'message' => '분개가 삭제되었습니다.',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 전체 목록 (활성/비활성 포함)
|
||||
*/
|
||||
public function accountCodesAll(): JsonResponse
|
||||
{
|
||||
$codes = AccountCode::getAll();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $codes,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 추가
|
||||
*/
|
||||
public function accountCodeStore(Request $request): JsonResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'code' => 'required|string|max:10',
|
||||
'name' => 'required|string|max:100',
|
||||
'category' => 'nullable|string|max:50',
|
||||
]);
|
||||
|
||||
if (AccountCode::where('code', $validated['code'])->exists()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'error' => '이미 존재하는 계정과목 코드입니다.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$maxSort = AccountCode::max('sort_order') ?? 0;
|
||||
|
||||
$accountCode = AccountCode::create([
|
||||
'tenant_id' => 1,
|
||||
'code' => $validated['code'],
|
||||
'name' => $validated['name'],
|
||||
'category' => $validated['category'] ?? null,
|
||||
'sort_order' => $maxSort + 1,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '계정과목이 추가되었습니다.',
|
||||
'data' => $accountCode,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 수정
|
||||
*/
|
||||
public function accountCodeUpdate(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$accountCode = AccountCode::find($id);
|
||||
if (!$accountCode) {
|
||||
return response()->json(['success' => false, 'error' => '계정과목을 찾을 수 없습니다.'], 404);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'code' => 'sometimes|string|max:10',
|
||||
'name' => 'sometimes|string|max:100',
|
||||
'category' => 'nullable|string|max:50',
|
||||
'is_active' => 'sometimes|boolean',
|
||||
]);
|
||||
|
||||
if (isset($validated['code']) && $validated['code'] !== $accountCode->code) {
|
||||
if (AccountCode::where('code', $validated['code'])->where('id', '!=', $id)->exists()) {
|
||||
return response()->json(['success' => false, 'error' => '이미 존재하는 계정과목 코드입니다.'], 422);
|
||||
}
|
||||
}
|
||||
|
||||
$accountCode->update($validated);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '계정과목이 수정되었습니다.',
|
||||
'data' => $accountCode,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 계정과목 삭제
|
||||
*/
|
||||
public function accountCodeDestroy(int $id): JsonResponse
|
||||
{
|
||||
$accountCode = AccountCode::find($id);
|
||||
if (!$accountCode) {
|
||||
return response()->json(['success' => false, 'error' => '계정과목을 찾을 수 없습니다.'], 404);
|
||||
}
|
||||
|
||||
$accountCode->delete();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => '계정과목이 삭제되었습니다.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user