feat: 周期账单 — 自动生成定期交易(房租/订阅/工资)
This commit is contained in:
64
client/src/api/recurring.ts
Normal file
64
client/src/api/recurring.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { request } from '@/utils/request'
|
||||
|
||||
/** 周期模板 */
|
||||
export interface RecurringTemplate {
|
||||
id: number
|
||||
user_id: number
|
||||
amount: number
|
||||
type: 'expense' | 'income'
|
||||
category_id: number
|
||||
note: string
|
||||
frequency: 'weekly' | 'monthly' | 'yearly'
|
||||
next_date: string
|
||||
end_date: string | null
|
||||
is_active: number
|
||||
group_id: number | null
|
||||
category_name?: string
|
||||
category_icon?: string
|
||||
category_color?: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
/** 获取周期模板列表 */
|
||||
export function getRecurringTemplates() {
|
||||
return request<RecurringTemplate[]>({ url: '/recurring' })
|
||||
}
|
||||
|
||||
/** 创建周期模板 */
|
||||
export function createRecurringTemplate(data: {
|
||||
amount: number
|
||||
type: 'expense' | 'income'
|
||||
category_id: number
|
||||
note?: string
|
||||
frequency: 'weekly' | 'monthly' | 'yearly'
|
||||
next_date: string
|
||||
end_date?: string | null
|
||||
group_id?: number | null
|
||||
}) {
|
||||
return request<{ id: number }>({ url: '/recurring', method: 'POST', data })
|
||||
}
|
||||
|
||||
/** 更新周期模板 */
|
||||
export function updateRecurringTemplate(id: number, data: {
|
||||
amount?: number
|
||||
type?: 'expense' | 'income'
|
||||
category_id?: number
|
||||
note?: string
|
||||
frequency?: 'weekly' | 'monthly' | 'yearly'
|
||||
next_date?: string
|
||||
end_date?: string | null
|
||||
is_active?: number
|
||||
}) {
|
||||
return request({ url: `/recurring/${id}`, method: 'PUT', data })
|
||||
}
|
||||
|
||||
/** 删除周期模板 */
|
||||
export function deleteRecurringTemplate(id: number) {
|
||||
return request({ url: `/recurring/${id}`, method: 'DELETE' })
|
||||
}
|
||||
|
||||
/** 同步周期账单(生成到期交易) */
|
||||
export function syncRecurring() {
|
||||
return request<{ generated: number }>({ url: '/recurring/sync', method: 'POST' })
|
||||
}
|
||||
Reference in New Issue
Block a user