优化
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
|
||||
import { listSuppliers, type SupplierCategory } from '@/modules/suppliers'
|
||||
|
||||
export type InboundFeeDirection = 'RECEIVABLE' | 'PAYABLE'
|
||||
export type InboundFeeReviewStatus = 'PENDING' | 'APPROVED' | 'REJECTED'
|
||||
@@ -11,8 +12,9 @@ export interface InboundFeeDetail {
|
||||
sourceFeeVersion: number
|
||||
inboundCode: string | null
|
||||
direction: InboundFeeDirection
|
||||
partnerId: string | number | null
|
||||
partnerName: string | null
|
||||
supplierId: string | number | null
|
||||
supplierName: string | null
|
||||
supplierCategory: SupplierCategory | null
|
||||
businessDate: string
|
||||
customerName: string | null
|
||||
feeTypeNameSnapshot: string
|
||||
@@ -25,7 +27,6 @@ export interface InboundFeeDetail {
|
||||
reviewerName: string | null
|
||||
reviewedAt: string | null
|
||||
publicationStatus: string
|
||||
settlementIncluded: boolean
|
||||
}
|
||||
|
||||
export interface SaveInboundFeeDetailRequest {
|
||||
@@ -35,20 +36,26 @@ export interface SaveInboundFeeDetailRequest {
|
||||
unitPrice: number
|
||||
currency: string
|
||||
amount: number
|
||||
settlementIncluded: boolean
|
||||
partnerId: string | number | null
|
||||
partnerName: string | null
|
||||
supplierId: string | number | null
|
||||
remark: string | null
|
||||
}
|
||||
|
||||
export interface InboundFeeItemOption {
|
||||
id: string | number
|
||||
feeTypeName: string
|
||||
feeCode: string
|
||||
supplierCategory: SupplierCategory | null
|
||||
warehousePayable: boolean
|
||||
warehouseReceivable: boolean
|
||||
}
|
||||
|
||||
export interface InboundFeePartnerOption { id: string | number; partnerName: string }
|
||||
export interface InboundFeeSupplierOption { id: string; supplierName: string; category: SupplierCategory }
|
||||
|
||||
const supplierCategories: SupplierCategory[] = ['BOOKING', 'CUSTOMS', 'TRUCKING', 'CERTIFICATE']
|
||||
|
||||
function supplierCategory(value: unknown): SupplierCategory | null {
|
||||
return supplierCategories.includes(value as SupplierCategory) ? value as SupplierCategory : null
|
||||
}
|
||||
|
||||
function basePath(inboundId: string) {
|
||||
const identifier = String(inboundId ?? '').trim()
|
||||
@@ -95,15 +102,22 @@ export async function voidInboundFeeDetail(accountId: string, inboundId: string,
|
||||
}
|
||||
|
||||
export async function listInboundFeeItemOptions() {
|
||||
const response = await http.get<unknown, ApiEnvelope<{ records: InboundFeeItemOption[] }>>(
|
||||
const response = await http.get<unknown, ApiEnvelope<{ records: Record<string, unknown>[] }>>(
|
||||
'/platform/v1/fee-items', { params: { status: 'ACTIVE', page: 1, size: 200 } },
|
||||
)
|
||||
return unwrapApiResponse(response).records || []
|
||||
return (unwrapApiResponse(response).records || []).map((raw): InboundFeeItemOption => ({
|
||||
id: raw.id as string | number,
|
||||
feeTypeName: String(raw.feeTypeName || ''),
|
||||
feeCode: String(raw.feeCode || ''),
|
||||
supplierCategory: supplierCategory(raw.supplierCategory),
|
||||
warehousePayable: Boolean(raw.warehousePayable),
|
||||
warehouseReceivable: Boolean(raw.warehouseReceivable),
|
||||
}))
|
||||
}
|
||||
|
||||
export async function listInboundFeePartnerOptions() {
|
||||
const response = await http.get<unknown, ApiEnvelope<{ records: InboundFeePartnerOption[] }>>(
|
||||
'/platform/v1/partners', { params: { status: 'ACTIVE', page: 1, size: 200 } },
|
||||
)
|
||||
return unwrapApiResponse(response).records || []
|
||||
export async function listInboundFeeSupplierOptions(category: SupplierCategory) {
|
||||
const page = await listSuppliers({ status: 'ACTIVE', category, page: 1, size: 200 })
|
||||
return page.records.filter((supplier) => supplier.status === 'ACTIVE' && supplier.category === category).map((supplier): InboundFeeSupplierOption => ({
|
||||
id: supplier.id, supplierName: supplier.name, category: supplier.category,
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user