优化
This commit is contained in:
@@ -3,6 +3,8 @@ import { listSuppliers, type SupplierCategory } from '@/modules/suppliers'
|
||||
|
||||
export type ContainerFeeDirection = 'RECEIVABLE' | 'PAYABLE'
|
||||
export type ContainerFeeReviewStatus = 'PENDING' | 'APPROVED' | 'REJECTED'
|
||||
export type ContainerFeeSettlementMode = 'ON_ACCOUNT' | 'DIRECT_PAID'
|
||||
export type ContainerFeePaymentMethod = 'ONLINE' | 'BANK_TRANSFER' | 'CASH' | 'OTHER'
|
||||
|
||||
export interface ContainerFeeResource {
|
||||
id: string
|
||||
@@ -15,6 +17,11 @@ export interface ContainerFeeResource {
|
||||
supplierId: string | null
|
||||
supplierName: string | null
|
||||
supplierCategory: SupplierCategory | null
|
||||
settlementMode?: ContainerFeeSettlementMode | null
|
||||
paidAt?: string | null
|
||||
paymentMethod?: ContainerFeePaymentMethod | null
|
||||
paymentReferenceNo?: string | null
|
||||
paymentVoucherFileIds?: string[] | null
|
||||
businessDate: string
|
||||
amount: number
|
||||
currency: 'CNY'
|
||||
@@ -31,6 +38,11 @@ export interface ContainerFeeSaveRequest {
|
||||
feeItemId: string
|
||||
direction: ContainerFeeDirection
|
||||
supplierId: string | null
|
||||
settlementMode: ContainerFeeSettlementMode | null
|
||||
paidAt: string | null
|
||||
paymentMethod: ContainerFeePaymentMethod | null
|
||||
paymentReferenceNo: string | null
|
||||
paymentVoucherFileIds: string[] | null
|
||||
businessDate: string
|
||||
amount: number
|
||||
currency: 'CNY'
|
||||
@@ -98,6 +110,10 @@ function normalizeFee(raw: Record<string, unknown>): ContainerFeeResource {
|
||||
feeItemName: String(raw.feeItemNameSnapshot || ''), direction: raw.direction as ContainerFeeDirection,
|
||||
supplierId: raw.supplierId == null ? null : id(raw.supplierId), supplierName: raw.supplierName == null ? null : String(raw.supplierName),
|
||||
supplierCategory: supplierCategory(raw.supplierCategory),
|
||||
settlementMode: raw.settlementMode == null ? null : raw.settlementMode as ContainerFeeSettlementMode,
|
||||
paidAt: raw.paidAt == null ? null : String(raw.paidAt), paymentMethod: raw.paymentMethod == null ? null : raw.paymentMethod as ContainerFeePaymentMethod,
|
||||
paymentReferenceNo: raw.paymentReferenceNo == null ? null : String(raw.paymentReferenceNo),
|
||||
paymentVoucherFileIds: Array.isArray(raw.paymentVoucherFileIds) ? raw.paymentVoucherFileIds.map(id) : null,
|
||||
businessDate: String(raw.businessDate || ''), amount: numberValue(raw.amount), currency: 'CNY',
|
||||
reviewStatus: raw.reviewStatus as ContainerFeeReviewStatus,
|
||||
sourceStatus: raw.sourceStatus as ContainerFeeResource['sourceStatus'], sourceVersion: numberValue(raw.sourceVersion),
|
||||
@@ -143,6 +159,17 @@ export async function listContainerFeeSupplierOptions(category: SupplierCategory
|
||||
return page.records.filter((supplier) => supplier.status === 'ACTIVE' && (!category || supplier.category === category)).map((supplier) => ({ id: supplier.id, supplierName: supplier.name, category: supplier.category }))
|
||||
}
|
||||
|
||||
export async function uploadContainerFeePaymentVoucher(customerId: string, file: File): Promise<{ fileId: string; fileName: string }> {
|
||||
const body = new FormData(); body.append('file', file)
|
||||
const raw = unwrapApiResponse(await http.post<ApiEnvelope<Record<string, unknown>>, ApiEnvelope<Record<string, unknown>>>('/platform/finance/v1/vouchers', body, {
|
||||
params: { customerId }, headers: { 'Content-Type': 'multipart/form-data' },
|
||||
}))
|
||||
const fileId = raw.fileId == null ? '' : id(raw.fileId)
|
||||
const echoedCustomerId = raw.tenantId == null ? id(raw.customerId ?? customerId) : id(raw.tenantId)
|
||||
if (!fileId || echoedCustomerId !== customerId) throw new Error('付款凭证与当前客户不匹配')
|
||||
return { fileId, fileName: String(raw.fileName || raw.file_name || file.name) }
|
||||
}
|
||||
|
||||
export async function listContainerCostDetails(customerId: string, containerId: string): Promise<ContainerCostDetail[]> {
|
||||
const response = await http.get<ApiEnvelope<Record<string, unknown>[]>, ApiEnvelope<Record<string, unknown>[]>>('/platform/finance/v1/cost-entries', { params: { customerId } })
|
||||
const costs = unwrapApiResponse(response).filter((raw) => id(raw.customerId) === customerId && id(raw.containerId) === containerId)
|
||||
|
||||
Reference in New Issue
Block a user