补齐证书齐备、证件折算、移动用证和合同绑定,并带上报销批量发放、付款备注以及个人开发流程升级,便于继续讨论已安排计划的调整规则。 Co-authored-by: Cursor <cursoragent@cursor.com>
83 lines
2.4 KiB
TypeScript
83 lines
2.4 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
import { describe, it } from 'node:test'
|
|
import {
|
|
alignStopProductUnitToContract,
|
|
allowedPackageSpecsForStopProduct,
|
|
collectContractProductRows,
|
|
stopProductUnitLocked
|
|
} from './pl-plan-contract-product'
|
|
|
|
const hydrochloricAcid = collectContractProductRows([
|
|
{
|
|
id: 'line-hcl',
|
|
productId: 'hcl',
|
|
productName: '工业盐酸',
|
|
packageSpecs: ['25kg/桶', '吨桶']
|
|
},
|
|
{
|
|
id: 'line-other',
|
|
productId: 'hcl',
|
|
productName: '工业盐酸',
|
|
packageSpec: '槽车'
|
|
}
|
|
])
|
|
|
|
describe('allowedPackageSpecsForStopProduct', () => {
|
|
it('keeps every package on the bound contract line after rows are split by spec', () => {
|
|
assert.deepEqual(
|
|
allowedPackageSpecsForStopProduct(hydrochloricAcid, {
|
|
productId: 'hcl',
|
|
contractProductId: 'line-hcl'
|
|
}),
|
|
['25kg/桶', '吨桶']
|
|
)
|
|
})
|
|
|
|
it('does not include another line of the same product', () => {
|
|
assert.deepEqual(
|
|
allowedPackageSpecsForStopProduct(hydrochloricAcid, {
|
|
productId: 'hcl',
|
|
contractProductId: 'line-other'
|
|
}),
|
|
['槽车']
|
|
)
|
|
})
|
|
|
|
it('uses all specs of the product when the stop row is not bound', () => {
|
|
assert.deepEqual(
|
|
allowedPackageSpecsForStopProduct(hydrochloricAcid, { productId: 'hcl' }),
|
|
['25kg/桶', '吨桶', '槽车']
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('stop product unit from contract', () => {
|
|
const lines = [
|
|
{ id: 'line-1', productId: 'acid', unit: '吨' },
|
|
{ id: 'line-1', productId: 'acid', unit: '' }
|
|
]
|
|
|
|
it('locks the unit only after a contract line is bound', () => {
|
|
assert.equal(stopProductUnitLocked({ contractProductId: '' }), false)
|
|
assert.equal(stopProductUnitLocked({ contractProductId: 'line-1' }), true)
|
|
})
|
|
|
|
it('rewrites a different unit to the contract unit', () => {
|
|
const row = { contractProductId: 'line-1', unit: 'kg' }
|
|
assert.equal(alignStopProductUnitToContract(row, lines), true)
|
|
assert.equal(row.unit, 'dun')
|
|
})
|
|
|
|
it('treats 吨 and dun as the same unit', () => {
|
|
const row = { contractProductId: 'line-1', unit: 'dun' }
|
|
assert.equal(alignStopProductUnitToContract(row, lines), false)
|
|
assert.equal(row.unit, 'dun')
|
|
})
|
|
|
|
it('leaves an unbound row unit unchanged', () => {
|
|
const row = { contractProductId: '', unit: 'kg' }
|
|
assert.equal(alignStopProductUnitToContract(row, lines), false)
|
|
assert.equal(row.unit, 'kg')
|
|
})
|
|
})
|