优化采购实时编辑与权限,支持先到货后补报价、按批次补录照片和批量附件上传。更新验收报告模板及明细选择,增加验收发票独立管理和付款前置校验。完善 BOM 数据权限及 App 更新兼容性。
33 lines
2.7 KiB
JavaScript
33 lines
2.7 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import {queueMatches,sortSheetRows,batchProgress} from '../../src/utils/purchase-sheet-view.js'
|
|
|
|
test('mixed batch progress preserves confirmed work rather than reporting wholly unquoted',()=>{
|
|
assert.equal(batchProgress({requestCount:43,openCount:43,unlockedCount:7,unpricedCount:7,arrivableCount:36}).label,'部分采购')
|
|
assert.equal(batchProgress({requestCount:43,openCount:7,unlockedCount:7,unpricedCount:7,arrivableCount:0}).label,'部分完成')
|
|
assert.equal(batchProgress({requestCount:43,openCount:43,unlockedCount:43,unpricedCount:7,arrivableCount:0}).label,'待报价')
|
|
assert.equal(batchProgress({requestCount:43,openCount:43,unlockedCount:7,pendingCount:2,arrivableCount:34}).label,'到货待衔接')
|
|
assert.equal(batchProgress({requestCount:9,openCount:9,unlockedCount:0,arrivableCount:9}).label,'采购中')
|
|
})
|
|
test('queues handle zero quotation, terminal records and partial deliveries',()=>{
|
|
const row={quantity:10,finalUnitPrice:0,priceLocked:false}
|
|
assert.ok(queueMatches(row,'confirm'));assert.ok(!queueMatches(row,'quote'))
|
|
const partial={...row,priceLocked:true,remainingQuantity:3,pendingArrivalQuantity:2,acceptedQuantity:5,receivedQuantity:4}
|
|
for(const q of ['arrival','acceptance','receipt'])assert.ok(queueMatches(partial,q))
|
|
assert.ok(!queueMatches(partial,'completed'));assert.ok(queueMatches({...partial,historical:true},'completed'))
|
|
assert.ok(!queueMatches({...partial,historical:true},'arrival'));assert.ok(queueMatches({...partial,purchaseStatus:5},'cancelled'))
|
|
assert.ok(!queueMatches({...partial,purchaseStatus:5},'acceptance'))
|
|
assert.ok(queueMatches({...partial,remainingQuantity:0,pendingArrivalQuantity:0,receivedQuantity:5},'completed'))
|
|
})
|
|
test('sort is stable and immutable; missing prices follow real prices including zero',()=>{
|
|
const rows=[{id:1,finalUnitPrice:null},{id:2,finalUnitPrice:0},{id:3,finalUnitPrice:10},{id:4,finalUnitPrice:2},{id:5,finalUnitPrice:2}]
|
|
assert.deepEqual(sortSheetRows(rows,'priceAsc').map(r=>r.id),[2,4,5,3,1]);assert.deepEqual(sortSheetRows(rows,'priceDesc').map(r=>r.id),[3,4,5,2,1])
|
|
assert.deepEqual(rows.map(r=>r.id),[1,2,3,4,5]);const snapshots=new Map(rows.map(r=>[r.id,{...r}]))
|
|
rows[3].finalUnitPrice=200;assert.deepEqual(sortSheetRows(rows,'priceAsc',row=>snapshots.get(row.id)).map(r=>r.id),[2,4,5,3,1])
|
|
})
|
|
|
|
test('unquoted physical receipt completes without waiting for quotation and quotes remain a separate queue',()=>{
|
|
const row={quantity:3,remainingQuantity:0,acceptedQuantity:3,receivedQuantity:3,priceLocked:false,finalUnitPrice:null};assert.ok(queueMatches(row,'completed'));assert.ok(queueMatches(row,'quote'));assert.ok(!queueMatches(row,'receipt'));
|
|
assert.ok(queueMatches({...row,receivedQuantity:1},'receipt'));
|
|
});
|