import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http' import type { FeePage } from './overseasFees' import type { OverseasFee } from './overseasFees' export async function adjustStorageRentFee(id: string, body: { expectedVersion: number; amount: number; reason: string; idempotencyKey: string }) { return unwrapApiResponse(await http.post, ApiEnvelope>(`/platform/v1/last-leg/storage-rent/fees/${encodeURIComponent(id)}/adjust`, body)) } export interface StorageRentLot { id: string; customerId: string; customerName: string; businessType: string; businessNo: string warehouseId: string; warehouseName: string; batchNo: string; inboundAt: string; storageDays: number originalQuantity: number; remainingQuantity: number; quantityUnit: string; billingQuantity: number billingUnit: string; ruleCode: string; status: string; generatedAmount: number | null generatedCurrency: string | null; generatedAmounts: Array<{ currency: string; amount: number }> settledAmount?: number; chargeCount?: number; settledChargeCount?: number } export interface StorageRentCharge { billingQuantity?: number | null; billingUnit?: string | null id: string; outboundNo: string; businessNo: string; quantity: number; storageDays: number originalAmount: number; currency: string; settlementAmount: number; currencyRate: number; status: string createdAt: string; outboundAt: string } export interface StorageRentDetail { lot: StorageRentLot; charges: StorageRentCharge[] } const base = '/platform/v1/last-leg/storage-rent' function normalizeLot(row: StorageRentLot): StorageRentLot { return { ...row, id: String(row.id), customerId: String(row.customerId), warehouseId: String(row.warehouseId) } } export async function listStorageRentLots(params: Record) { const response = await http.get>, ApiEnvelope>>(base, { params }) const data = unwrapApiResponse(response) return { ...data, total: Number(data.total), records: data.records.map(normalizeLot) } } export async function getStorageRentLot(id: string) { const data = unwrapApiResponse(await http.get, ApiEnvelope>(`${base}/${encodeURIComponent(id)}`)) return { lot: normalizeLot(data.lot), charges: data.charges.map(row => ({ ...row, id: String(row.id) })) } } export async function listStorageRentWarehouses() { const data = unwrapApiResponse(await http.get>, ApiEnvelope>>(`${base}/warehouse-options`)) return data.map(row => ({ ...row, id: String(row.id) })) }