补齐证书齐备、证件折算、移动用证和合同绑定,并带上报销批量发放、付款备注以及个人开发流程升级,便于继续讨论已安排计划的调整规则。 Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
2.7 KiB
TypeScript
82 lines
2.7 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
import type { PlanQuota, QuotaSourceOption } from '../src/api/pl/quota-cert'
|
|
import {
|
|
initialLegacySelection,
|
|
measuredSources
|
|
} from '../src/components/business/pl-plan-quota-dialog/stop-model'
|
|
|
|
function source(partial: Partial<QuotaSourceOption> & Pick<QuotaSourceOption, 'sourceStopType' | 'sourceStopProductId' | 'planProductId'>): QuotaSourceOption {
|
|
return {
|
|
productName: '硫酸',
|
|
quantity: '1',
|
|
unit: '吨',
|
|
contractId: '',
|
|
contractProductId: '',
|
|
...partial
|
|
}
|
|
}
|
|
|
|
function plan(partial: Partial<PlanQuota>): PlanQuota {
|
|
return {
|
|
planId: 'plan',
|
|
planNo: 'PO',
|
|
configuration: {},
|
|
sourceOptions: [],
|
|
usages: [],
|
|
...partial
|
|
}
|
|
}
|
|
|
|
test('legacy plan restores the saved measuring side and the opposite pairing', () => {
|
|
const value = plan({
|
|
measurementVersion: 'legacy_single_side',
|
|
sourceOptions: [
|
|
source({ sourceStopType: 'load', sourceStopProductId: 'L', planProductId: 'P', partyName: '装货方' }),
|
|
source({ sourceStopType: 'delivery', sourceStopProductId: 'D', planProductId: 'P', partyName: '送货方' })
|
|
],
|
|
configuration: {
|
|
sourceMapping: [
|
|
{ sourceStopType: 'load', sourceStopProductId: 'L', relatedStopProductIds: ['D'] }
|
|
]
|
|
}
|
|
})
|
|
const selection = initialLegacySelection(value)
|
|
assert.equal(selection.sides.P, 'load')
|
|
assert.deepEqual(selection.pairs.L, ['D'])
|
|
assert.deepEqual(
|
|
measuredSources(value, selection.sides).map((row) => row.sourceStopProductId),
|
|
['L']
|
|
)
|
|
})
|
|
|
|
test('legacy plan with both sides and no saved mapping waits for a choice', () => {
|
|
const value = plan({
|
|
sourceOptions: [
|
|
source({ sourceStopType: 'load', sourceStopProductId: 'L', planProductId: 'P' }),
|
|
source({ sourceStopType: 'delivery', sourceStopProductId: 'D', planProductId: 'P' })
|
|
]
|
|
})
|
|
const selection = initialLegacySelection(value)
|
|
assert.equal(selection.sides.P, '')
|
|
assert.deepEqual(measuredSources(value, selection.sides), [])
|
|
})
|
|
|
|
test('a single delivery side is selected, and per-stop plans keep every side', () => {
|
|
const legacy = plan({
|
|
sourceOptions: [source({ sourceStopType: 'delivery', sourceStopProductId: 'D', planProductId: 'P' })]
|
|
})
|
|
assert.equal(initialLegacySelection(legacy).sides.P, 'delivery')
|
|
const current = plan({
|
|
measurementVersion: 'per_stop_v2',
|
|
sourceOptions: [
|
|
source({ sourceStopType: 'load', sourceStopProductId: 'L', planProductId: 'P' }),
|
|
source({ sourceStopType: 'delivery', sourceStopProductId: 'D', planProductId: 'P' })
|
|
]
|
|
})
|
|
assert.deepEqual(
|
|
measuredSources(current, {}).map((row) => row.sourceStopProductId),
|
|
['L', 'D']
|
|
)
|
|
})
|