32 lines
958 B
TypeScript
32 lines
958 B
TypeScript
|
|
import { apiFetch, type PaginatedResponse } from './api';
|
||
|
|
|
||
|
|
export interface DATEVExportResponse {
|
||
|
|
id: string;
|
||
|
|
start_date: string;
|
||
|
|
end_date: string;
|
||
|
|
file_path?: string | null;
|
||
|
|
total_amount: number;
|
||
|
|
created_at?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export interface DATEVExportCreate {
|
||
|
|
start_date: string;
|
||
|
|
end_date: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function createDatevExport(data: DATEVExportCreate): Promise<DATEVExportResponse> {
|
||
|
|
return apiFetch<DATEVExportResponse>('/datev/export', {
|
||
|
|
method: 'POST',
|
||
|
|
body: JSON.stringify(data),
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function listDatevExports(page = 1, pageSize = 20): Promise<PaginatedResponse<DATEVExportResponse>> {
|
||
|
|
return apiFetch<PaginatedResponse<DATEVExportResponse>>(`/datev/exports?page=${page}&page_size=${pageSize}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
export function getDatevDownloadUrl(id: string): string {
|
||
|
|
const baseUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api/v1';
|
||
|
|
return `${baseUrl}/datev/exports/${id}/download`;
|
||
|
|
}
|