- 계정과목 관리를 accounting/common/으로 통합 (AccountSubjectSettingModal 이동) - GeneralJournalEntry: 계정과목 actions/types 분리, 모달 import 경로 변경 - CardTransactionInquiry: JournalEntryModal/ManualInputModal 개선 - TaxInvoiceManagement: actions/types 리팩토링 - DepositManagement/WithdrawalManagement: 소폭 개선 - ExpectedExpenseManagement: UI 개선 - GiftCertificateManagement: 상세/목록 개선 - BillManagement: BillDetail/Client/index 소폭 추가 - PurchaseManagement/SalesManagement: 상세뷰 개선 - CEO 대시보드: dashboard-invalidation 유틸 추가, useCEODashboard 확장 - OrderRegistration/OrderSalesDetailView 소폭 수정 - claudedocs: 계정과목 통합 계획/분석/체크리스트, 대시보드 검증 문서 추가
124 lines
3.8 KiB
TypeScript
124 lines
3.8 KiB
TypeScript
'use server';
|
|
|
|
import { executeServerAction, type ActionResult } from '@/lib/api/execute-server-action';
|
|
import { buildApiUrl } from '@/lib/api/query-params';
|
|
import type { AccountSubject, AccountSubjectApiData } from './types';
|
|
import { transformAccountSubjectApi } from './types';
|
|
|
|
// ===== 계정과목 목록 조회 =====
|
|
export async function getAccountSubjects(params?: {
|
|
search?: string;
|
|
category?: string;
|
|
subCategory?: string;
|
|
departmentType?: string;
|
|
depth?: number;
|
|
isActive?: boolean;
|
|
selectable?: boolean;
|
|
}): Promise<ActionResult<AccountSubject[]>> {
|
|
return executeServerAction({
|
|
url: buildApiUrl('/api/v1/account-subjects', {
|
|
search: params?.search || undefined,
|
|
category: params?.category && params.category !== 'all' ? params.category : undefined,
|
|
sub_category: params?.subCategory || undefined,
|
|
department_type: params?.departmentType || undefined,
|
|
depth: params?.depth,
|
|
is_active: params?.isActive,
|
|
selectable: params?.selectable,
|
|
}),
|
|
transform: (data: AccountSubjectApiData[]) => data.map(transformAccountSubjectApi),
|
|
errorMessage: '계정과목 목록 조회에 실패했습니다.',
|
|
});
|
|
}
|
|
|
|
// ===== 계정과목 추가 =====
|
|
export async function createAccountSubject(data: {
|
|
code: string;
|
|
name: string;
|
|
category: string;
|
|
subCategory?: string;
|
|
parentCode?: string;
|
|
depth?: number;
|
|
departmentType?: string;
|
|
description?: string;
|
|
sortOrder?: number;
|
|
}): Promise<ActionResult> {
|
|
return executeServerAction({
|
|
url: buildApiUrl('/api/v1/account-subjects'),
|
|
method: 'POST',
|
|
body: {
|
|
code: data.code,
|
|
name: data.name,
|
|
category: data.category,
|
|
sub_category: data.subCategory || undefined,
|
|
parent_code: data.parentCode || undefined,
|
|
depth: data.depth ?? 3,
|
|
department_type: data.departmentType || 'common',
|
|
description: data.description || undefined,
|
|
sort_order: data.sortOrder,
|
|
},
|
|
errorMessage: '계정과목 추가에 실패했습니다.',
|
|
});
|
|
}
|
|
|
|
// ===== 계정과목 수정 =====
|
|
export async function updateAccountSubject(
|
|
id: string,
|
|
data: {
|
|
name?: string;
|
|
category?: string;
|
|
subCategory?: string;
|
|
parentCode?: string;
|
|
depth?: number;
|
|
departmentType?: string;
|
|
description?: string;
|
|
sortOrder?: number;
|
|
}
|
|
): Promise<ActionResult> {
|
|
return executeServerAction({
|
|
url: buildApiUrl(`/api/v1/account-subjects/${id}`),
|
|
method: 'PUT',
|
|
body: {
|
|
name: data.name,
|
|
category: data.category,
|
|
sub_category: data.subCategory,
|
|
parent_code: data.parentCode,
|
|
depth: data.depth,
|
|
department_type: data.departmentType,
|
|
description: data.description,
|
|
sort_order: data.sortOrder,
|
|
},
|
|
errorMessage: '계정과목 수정에 실패했습니다.',
|
|
});
|
|
}
|
|
|
|
// ===== 계정과목 상태 토글 =====
|
|
export async function updateAccountSubjectStatus(
|
|
id: string,
|
|
isActive: boolean
|
|
): Promise<ActionResult> {
|
|
return executeServerAction({
|
|
url: buildApiUrl(`/api/v1/account-subjects/${id}/status`),
|
|
method: 'PATCH',
|
|
body: { is_active: isActive },
|
|
errorMessage: '계정과목 상태 변경에 실패했습니다.',
|
|
});
|
|
}
|
|
|
|
// ===== 계정과목 삭제 =====
|
|
export async function deleteAccountSubject(id: string): Promise<ActionResult> {
|
|
return executeServerAction({
|
|
url: buildApiUrl(`/api/v1/account-subjects/${id}`),
|
|
method: 'DELETE',
|
|
errorMessage: '계정과목 삭제에 실패했습니다.',
|
|
});
|
|
}
|
|
|
|
// ===== 기본 계정과목표 일괄 생성 =====
|
|
export async function seedDefaultAccountSubjects(): Promise<ActionResult<{ inserted_count: number }>> {
|
|
return executeServerAction({
|
|
url: buildApiUrl('/api/v1/account-subjects/seed-defaults'),
|
|
method: 'POST',
|
|
errorMessage: '기본 계정과목 생성에 실패했습니다.',
|
|
});
|
|
}
|