fix(admin): update submitted measurement calculation strategy
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export { getInboundMeasurement, saveInboundMeasurementDraft } from './measurement/api'
|
||||
export { getInboundMeasurement, saveInboundMeasurementDraft, updateMeasurementCalculationStrategy } from './measurement/api'
|
||||
export { createInboundHoldIdempotencyKey, downloadPlatformInboundHoldEvidence, getPlatformInboundHold, holdPlatformInbound, releasePlatformInbound, uploadPlatformInboundHoldEvidence } from './core/api'
|
||||
export { default as InboundMeasurementPanel } from './measurement/InboundMeasurementPanel.vue'
|
||||
export { default as InboundMeasurementDialog } from './measurement/InboundMeasurementDialog.vue'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { http } from '@/shared/api/http'
|
||||
import { createManualCartonScan, downloadInboundMeasurementImage, getInboundMeasurement, saveInboundMeasurementDraft, submitInboundMeasurement, updateConfirmedPackageCount } from './api'
|
||||
import { createManualCartonScan, downloadInboundMeasurementImage, getInboundMeasurement, saveInboundMeasurementDraft, submitInboundMeasurement, updateConfirmedPackageCount, updateMeasurementCalculationStrategy } from './api'
|
||||
import type { SaveInboundMeasurementDraftRequest } from './types'
|
||||
|
||||
vi.mock('@/shared/api/http', () => ({
|
||||
@@ -76,6 +76,19 @@ describe('inbound measurement API', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('updates calculation strategy without resaving the frozen measurement batch', async () => {
|
||||
const payload = { measurementId: '9001', version: 3, coefficientMode: 'ADD' as const, chargeRuleId: null }
|
||||
const saved = { ...payload, version: 4, status: 'SUBMITTED' }
|
||||
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: saved })
|
||||
|
||||
await expect(updateMeasurementCalculationStrategy('10001', '7001', payload)).resolves.toEqual(saved)
|
||||
expect(http.put).toHaveBeenCalledWith(
|
||||
'/platform/v1/first-leg/inbounds/7001/measurement/calculation-strategy',
|
||||
payload,
|
||||
{ params: { tenantId: '10001' } },
|
||||
)
|
||||
})
|
||||
|
||||
it('downloads the current measurement image using the scoped file route', async () => {
|
||||
const image = new Blob(['image-data'], { type: 'image/jpeg' })
|
||||
vi.mocked(http.get).mockResolvedValue(image)
|
||||
|
||||
@@ -7,6 +7,8 @@ import type {
|
||||
ConfirmedPackageCountRequest,
|
||||
SaveInboundMeasurementDraftRequest,
|
||||
SubmitInboundMeasurementRequest,
|
||||
UpdateMeasurementCalculationStrategyRequest,
|
||||
MeasurementCalculationStrategyUpdated,
|
||||
ManualCartonScanRequest,
|
||||
} from './types'
|
||||
|
||||
@@ -57,6 +59,19 @@ export async function saveInboundMeasurementDraft(
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function updateMeasurementCalculationStrategy(
|
||||
customerId: string,
|
||||
inboundId: string,
|
||||
payload: UpdateMeasurementCalculationStrategyRequest,
|
||||
) {
|
||||
const response = await http.put<ApiEnvelope<MeasurementCalculationStrategyUpdated>, ApiEnvelope<MeasurementCalculationStrategyUpdated>>(
|
||||
`${measurementPath(inboundId)}/calculation-strategy`,
|
||||
payload,
|
||||
{ params: { tenantId: customerId } },
|
||||
)
|
||||
return unwrapApiResponse(response)
|
||||
}
|
||||
|
||||
export async function submitInboundMeasurement(
|
||||
customerId: string,
|
||||
inboundId: string,
|
||||
|
||||
@@ -9,7 +9,12 @@ export type InboundMeasurementProcessStatus =
|
||||
| 'WAIT_PRICING'
|
||||
| 'FEE_CONFIRMING'
|
||||
| 'INBOUNDING'
|
||||
| 'WAIT_PALLET'
|
||||
| 'WAIT_PALLETIZE'
|
||||
| 'WAIT_SPLIT'
|
||||
| 'LOADING'
|
||||
| 'LOADED'
|
||||
| 'DELIVERED'
|
||||
| 'VOIDED'
|
||||
|
||||
export interface InboundMeasurementItem {
|
||||
@@ -158,6 +163,18 @@ export interface InboundMeasurementDraftSaved {
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface UpdateMeasurementCalculationStrategyRequest {
|
||||
measurementId: MeasurementIdentifier
|
||||
version: number
|
||||
coefficientMode: 'ACTUAL' | 'ADD' | 'MULTIPLY'
|
||||
chargeRuleId?: MeasurementIdentifier | null
|
||||
}
|
||||
|
||||
export interface MeasurementCalculationStrategyUpdated extends InboundMeasurementDraftSaved {
|
||||
coefficientMode: 'ACTUAL' | 'ADD' | 'MULTIPLY'
|
||||
chargeRuleId: MeasurementIdentifier | null
|
||||
}
|
||||
|
||||
export interface ConfirmedPackageCountRequest {
|
||||
measurementVersion: number
|
||||
confirmedPackageCount: number
|
||||
|
||||
Reference in New Issue
Block a user