This commit is contained in:
2026-08-11 13:55:23 +08:00
parent e3757cc9f9
commit d6b2ea0938
5 changed files with 113 additions and 18 deletions
+15 -1
View File
@@ -1,5 +1,5 @@
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import type { FinanceBillDetail, FinanceBillLine, FinanceBillResource, FinanceCostResource, FinancePaymentMethod, FinanceReceiptResource } from '../types'
import type { FinanceBillDetail, FinanceBillLine, FinanceBillResource, FinanceCostResource, FinancePaymentMethod, FinanceReceiptResource, FinanceVoucherResource } from '../types'
const basePath = '/platform/finance/v1'
function idempotencyKey(operation: string) { return `finance-${operation}-${Date.now()}-${Math.random().toString(36).slice(2)}` }
@@ -94,6 +94,20 @@ export async function createFinanceReceipt(payload: Record<string, unknown>, vou
return unwrapApiResponse(response)
}
export async function uploadFinanceVoucher(customerId: string, file: File): Promise<FinanceVoucherResource> {
const body = new FormData()
body.append('file', file)
const response = await http.post<ApiEnvelope<RawResource>, ApiEnvelope<RawResource>>(`${basePath}/vouchers`, body, {
params: { customerId }, headers: { 'Content-Type': 'multipart/form-data' },
})
const item = unwrapApiResponse(response)
return {
fileId: stringValue(item.fileId ?? item.file_id), customerId: stringValue(item.tenantId ?? item.customerId ?? customerId),
fileName: stringValue(item.fileName ?? item.file_name), contentType: stringValue(item.contentType ?? item.content_type),
sizeBytes: numberValue(item.sizeBytes ?? item.size_bytes),
}
}
export async function listFinanceCosts(customerId?: string) {
const response = await http.get<ApiEnvelope<RawPage>, ApiEnvelope<RawPage>>(`${basePath}/cost-entries`, { params: { customerId: customerId || undefined } })
return normalizePage<FinanceCostResource>(unwrapApiResponse(response), (item) => ({