chore: migrate to KT financial system
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import { requestClient } from '../request';
|
||||
|
||||
export namespace FinanceApi {
|
||||
export type TransactionStatus =
|
||||
| 'draft'
|
||||
| 'pending'
|
||||
| 'approved'
|
||||
| 'rejected'
|
||||
| 'paid';
|
||||
|
||||
// 货币类型
|
||||
export interface Currency {
|
||||
code: string;
|
||||
@@ -71,6 +78,38 @@ export namespace FinanceApi {
|
||||
createdAt: string;
|
||||
isDeleted?: boolean;
|
||||
deletedAt?: string;
|
||||
status: TransactionStatus;
|
||||
statusUpdatedAt?: string;
|
||||
reimbursementBatch?: string;
|
||||
reviewNotes?: string;
|
||||
submittedBy?: string;
|
||||
approvedBy?: string;
|
||||
approvedAt?: string;
|
||||
}
|
||||
|
||||
export interface MediaMessage {
|
||||
id: number;
|
||||
chatId: number;
|
||||
messageId: number;
|
||||
userId: number;
|
||||
username?: string;
|
||||
displayName?: string;
|
||||
fileType: string;
|
||||
fileId: string;
|
||||
fileUniqueId?: string;
|
||||
caption?: string;
|
||||
fileName?: string;
|
||||
filePath: string;
|
||||
fileSize?: number;
|
||||
mimeType?: string;
|
||||
duration?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
forwardedTo?: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
available: boolean;
|
||||
downloadUrl: string | null;
|
||||
}
|
||||
|
||||
// 创建交易的参数
|
||||
@@ -85,6 +124,34 @@ export namespace FinanceApi {
|
||||
project?: string;
|
||||
memo?: string;
|
||||
createdAt?: string;
|
||||
status?: TransactionStatus;
|
||||
reimbursementBatch?: string | null;
|
||||
reviewNotes?: string | null;
|
||||
submittedBy?: string | null;
|
||||
approvedBy?: string | null;
|
||||
approvedAt?: string | null;
|
||||
statusUpdatedAt?: string;
|
||||
}
|
||||
|
||||
export interface CreateReimbursementParams {
|
||||
type?: 'expense' | 'income' | 'transfer';
|
||||
amount: number;
|
||||
currency?: string;
|
||||
categoryId?: number;
|
||||
accountId?: number;
|
||||
transactionDate: string;
|
||||
description?: string;
|
||||
project?: string;
|
||||
memo?: string;
|
||||
createdAt?: string;
|
||||
status?: TransactionStatus;
|
||||
reimbursementBatch?: string | null;
|
||||
reviewNotes?: string | null;
|
||||
submittedBy?: string | null;
|
||||
approvedBy?: string | null;
|
||||
approvedAt?: string | null;
|
||||
statusUpdatedAt?: string;
|
||||
requester?: string | null;
|
||||
}
|
||||
|
||||
// 预算
|
||||
@@ -210,9 +277,21 @@ export namespace FinanceApi {
|
||||
*/
|
||||
export async function getTransactions(params?: {
|
||||
type?: 'expense' | 'income' | 'transfer';
|
||||
statuses?: TransactionStatus[];
|
||||
includeDeleted?: boolean;
|
||||
}) {
|
||||
const query: Record<string, any> = {};
|
||||
if (params?.type) {
|
||||
query.type = params.type;
|
||||
}
|
||||
if (params?.statuses && params.statuses.length > 0) {
|
||||
query.statuses = params.statuses.join(',');
|
||||
}
|
||||
if (params?.includeDeleted !== undefined) {
|
||||
query.includeDeleted = params.includeDeleted;
|
||||
}
|
||||
return requestClient.get<Transaction[]>('/finance/transactions', {
|
||||
params,
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -233,6 +312,66 @@ export namespace FinanceApi {
|
||||
return requestClient.put<Transaction>(`/finance/transactions/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报销申请
|
||||
*/
|
||||
export async function getReimbursements(params?: {
|
||||
type?: 'expense' | 'income' | 'transfer';
|
||||
statuses?: TransactionStatus[];
|
||||
includeDeleted?: boolean;
|
||||
}) {
|
||||
const query: Record<string, any> = {};
|
||||
if (params?.type) {
|
||||
query.type = params.type;
|
||||
}
|
||||
if (params?.statuses && params.statuses.length > 0) {
|
||||
query.statuses = params.statuses.join(',');
|
||||
}
|
||||
if (params?.includeDeleted !== undefined) {
|
||||
query.includeDeleted = params.includeDeleted;
|
||||
}
|
||||
return requestClient.get<Transaction[]>('/finance/reimbursements', {
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建报销申请
|
||||
*/
|
||||
export async function createReimbursement(
|
||||
data: CreateReimbursementParams,
|
||||
) {
|
||||
return requestClient.post<Transaction>('/finance/reimbursements', data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新报销申请
|
||||
*/
|
||||
export async function updateReimbursement(
|
||||
id: number,
|
||||
data: Partial<CreateReimbursementParams>,
|
||||
) {
|
||||
return requestClient.put<Transaction>(`/finance/reimbursements/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除报销申请
|
||||
*/
|
||||
export async function deleteReimbursement(id: number) {
|
||||
return requestClient.delete<{ message: string }>(
|
||||
`/finance/transactions/${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复报销申请
|
||||
*/
|
||||
export async function restoreReimbursement(id: number) {
|
||||
return requestClient.put<Transaction>(`/finance/reimbursements/${id}`, {
|
||||
isDeleted: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 软删除交易
|
||||
*/
|
||||
@@ -290,4 +429,30 @@ export namespace FinanceApi {
|
||||
isDeleted: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取媒体消息
|
||||
*/
|
||||
export async function getMediaMessages(params?: {
|
||||
limit?: number;
|
||||
fileTypes?: string[];
|
||||
}) {
|
||||
const query: Record<string, any> = {};
|
||||
if (params?.limit) {
|
||||
query.limit = params.limit;
|
||||
}
|
||||
if (params?.fileTypes && params.fileTypes.length > 0) {
|
||||
query.types = params.fileTypes.join(',');
|
||||
}
|
||||
return requestClient.get<MediaMessage[]>('/finance/media', {
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条媒体消息详情
|
||||
*/
|
||||
export async function getMediaMessage(id: number) {
|
||||
return requestClient.get<MediaMessage>(`/finance/media/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user