优化
This commit is contained in:
@@ -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) => ({
|
||||
|
||||
Reference in New Issue
Block a user