完善柜级费用分摊与财务来源展示
This commit is contained in:
@@ -9,6 +9,13 @@ export type ContainerFeePaymentMethod = 'ONLINE' | 'BANK_TRANSFER' | 'CASH' | 'O
|
||||
export interface ContainerFeeResource {
|
||||
id: string
|
||||
loadingPlanId: string
|
||||
customerId?: string
|
||||
allocationGroupId?: string | null
|
||||
allocationOrderId?: string | null
|
||||
allocationOrderNo?: string | null
|
||||
allocationInboundId?: string | null
|
||||
allocationInboundCode?: string | null
|
||||
allocationGroupAmount?: number | null
|
||||
containerBookingId: string | null
|
||||
containerNo: string | null
|
||||
feeItemId: string
|
||||
@@ -55,6 +62,27 @@ export interface ContainerFeeAdjustRequest {
|
||||
amount: number
|
||||
}
|
||||
|
||||
export interface ContainerFeeAllocation {
|
||||
customerId: string
|
||||
orderId: string
|
||||
orderNo: string
|
||||
inboundId: string | null
|
||||
inboundCode: string | null
|
||||
amount: number
|
||||
}
|
||||
|
||||
export interface ContainerFeeAllocationGroupRequest {
|
||||
fee: ContainerFeeSaveRequest
|
||||
allocations: ContainerFeeAllocation[]
|
||||
}
|
||||
|
||||
export interface ContainerFeeAllocationGroupAdjustRequest {
|
||||
expectedSourceVersion: number
|
||||
businessDate: string
|
||||
totalAmount: number
|
||||
allocations: Array<{ feeId: string; amount: number }>
|
||||
}
|
||||
|
||||
export interface ApplicableFeeItem {
|
||||
id: string
|
||||
name: string
|
||||
@@ -105,7 +133,14 @@ const params = (accountId: string) => ({ accountId })
|
||||
|
||||
function normalizeFee(raw: Record<string, unknown>): ContainerFeeResource {
|
||||
return {
|
||||
id: id(raw.id), loadingPlanId: id(raw.loadingPlanId), containerBookingId: raw.containerBookingId == null ? null : id(raw.containerBookingId),
|
||||
id: id(raw.id), loadingPlanId: id(raw.loadingPlanId), customerId: id(raw.tenantId),
|
||||
allocationGroupId: raw.allocationGroupId == null ? null : id(raw.allocationGroupId),
|
||||
allocationOrderId: raw.allocationOrderId == null ? null : id(raw.allocationOrderId),
|
||||
allocationOrderNo: raw.allocationOrderNo == null ? null : String(raw.allocationOrderNo),
|
||||
allocationInboundId: raw.allocationInboundId == null ? null : id(raw.allocationInboundId),
|
||||
allocationInboundCode: raw.allocationInboundCode == null ? null : String(raw.allocationInboundCode),
|
||||
allocationGroupAmount: raw.allocationGroupAmount == null ? null : numberValue(raw.allocationGroupAmount),
|
||||
containerBookingId: raw.containerBookingId == null ? null : id(raw.containerBookingId),
|
||||
containerNo: raw.containerNo == null ? null : String(raw.containerNo), feeItemId: id(raw.feeItemId),
|
||||
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),
|
||||
@@ -132,6 +167,30 @@ export async function createContainerFee(planId: string, accountId: string, payl
|
||||
return normalizeFee(unwrapApiResponse(response))
|
||||
}
|
||||
|
||||
export async function createContainerFeeAllocationGroup(planId: string, payload: ContainerFeeAllocationGroupRequest) {
|
||||
const response = await http.post<ApiEnvelope<Record<string, unknown>[]>, ApiEnvelope<Record<string, unknown>[]>>(`${base(planId)}/allocation-groups`, payload)
|
||||
return unwrapApiResponse(response).map(normalizeFee)
|
||||
}
|
||||
|
||||
export async function approveContainerFeeAllocationGroup(planId: string, groupId: string) {
|
||||
const response = await http.post<ApiEnvelope<Record<string, unknown>[]>, ApiEnvelope<Record<string, unknown>[]>>(`${base(planId)}/allocation-groups/${encodeURIComponent(groupId)}/approve`)
|
||||
return unwrapApiResponse(response).map(normalizeFee)
|
||||
}
|
||||
|
||||
export async function rejectContainerFeeAllocationGroup(planId: string, groupId: string, reason: string) {
|
||||
const response = await http.post<ApiEnvelope<Record<string, unknown>[]>, ApiEnvelope<Record<string, unknown>[]>>(`${base(planId)}/allocation-groups/${encodeURIComponent(groupId)}/reject`, { reason })
|
||||
return unwrapApiResponse(response).map(normalizeFee)
|
||||
}
|
||||
|
||||
export async function adjustContainerFeeAllocationGroup(planId: string, groupId: string, payload: ContainerFeeAllocationGroupAdjustRequest) {
|
||||
const response = await http.post<ApiEnvelope<Record<string, unknown>[]>, ApiEnvelope<Record<string, unknown>[]>>(`${base(planId)}/allocation-groups/${encodeURIComponent(groupId)}/adjust`, payload)
|
||||
return unwrapApiResponse(response).map(normalizeFee)
|
||||
}
|
||||
|
||||
export async function voidContainerFeeAllocationGroup(planId: string, groupId: string, expectedSourceVersion: number) {
|
||||
await http.post(`${base(planId)}/allocation-groups/${encodeURIComponent(groupId)}/void`, { expectedSourceVersion })
|
||||
}
|
||||
|
||||
export async function approveContainerFee(planId: string, accountId: string, feeId: string) {
|
||||
await http.post(`${base(planId)}/${encodeURIComponent(feeId)}/approve`, undefined, { params: params(accountId) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user