支持回收单修改取消、按归属人优先用料及锁价交付改单
This commit is contained in:
1 parent
0e146739bc
commit
19b1b0263c
41 files changed
+1814
-203
No files matched your search
@@ -93,3 +93,13 @@ test('每日料池明细为锁价提供独立入口,助理只看可见锁单
|
||||
const h=harness();h.context.__pool=pool({settlement:{legacyReadOnly:true},usages:[{kind:'priceLock',date:D,price_lock_id:'own-lock',member:'assistant',number:'合成可见锁价',customer:'合成客户',product:'足金999',active:1,mg:12000,amount:1032000,allocations:[{payer:'owner',amount:850000},{payer:'assistant',amount:182000}]},{kind:'priceLock',anonymous:true,active:1,mg:1000,amount:86000},{kind:'priceLock',date:D,price_lock_id:'other-lock',member:'assistant2',number:'不应展示他人锁价',active:1,mg:1000,amount:86000}]});
|
||||
const html=h.run('state.user={id:"synthetic-assistant",role:"assistant",member:"assistant"};materialPoolDetailHTML(__pool)');assert.match(html,/data-action="open-price-lock" data-id="own-lock"/);assert.match(html,/锁价原料 · 足金999/);assert.match(html,/麦麦 ¥8,500\.00 · 娜娜 ¥1,820\.00/);assert.doesNotMatch(html,/不应展示他人锁价|商品 NaN|data-id="undefined"|NaN/);assert.equal(h.run('materialPoolUsagePayersText({})'),'付款来源待补齐');
|
||||
});
|
||||
test('锁价混合个人料与公共料短交逐来源切分,跨来源分币与后端快照逐分一致',()=>{
|
||||
const Allocation=require('../material-pool-allocation'),Locks=require('../price-lock-pools'),p={id:D,date:D,materialGroups:Allocation.groups([{id:'private',mg:3,amount:2,payer:'assistant',materialOwner:'assistant'},{id:'common',mg:2,amount:3,payer:'owner'}])},snapshot=Allocation.allocate(p,[{kind:'priceLock',member:'assistant',mg:5,reserved_mg:5,snapshot:{}}])[0].lockSnapshot,h=harness();h.context.__lock=lock({locked_mg:5,material_amount:snapshot.amount,materialPool:snapshot});
|
||||
for(const mg of [1,2,3,4,5]){const expected=Locks.split(snapshot,mg),actual=h.json(`priceLockDeliveryCost(__lock,'${(mg/1000).toFixed(3)}','')`);assert.equal(actual.originalUsedCost,expected.amount);assert.equal(actual.leftoverCost,expected.leftoverCost);assert.deepEqual(actual.materialSources.map(source=>[source.kind,source.quantity,source.amount]),expected.materialSources.map(source=>[source.kind,source.quantity,source.amount]));assert.equal(actual.materialSources.reduce((sum,source)=>sum+source.amount,0)+actual.leftoverMaterialSources.reduce((sum,source)=>sum+source.amount,0),snapshot.amount);}
|
||||
assert.equal(h.json("priceLockDeliveryCost(__lock,'0.002','').originalUsedCost"),1,'不得按整个锁单混合均价把两毫克算成两分');
|
||||
});
|
||||
test('个人料锁价按选中归属报价,公共无料仍可用个人料,界面显示分段与用后余量',async()=>{
|
||||
const h=harness();h.fields.member=node({value:'assistant'});h.fields.material_source.value='pool';h.fields.quantity.value='1.5';h.use(pool({totalMg:2000,totalAmount:200000,averageRate:100000,remainingMg:2000,personalPools:{assistant:{remainingMg:1000}}}));
|
||||
const own={kind:'personal_recovery',member:'assistant',quantity:1000,amount:85000,averageRate:85000,allocations:[{payer:'assistant',amount:85000}]},common={kind:'public',member:null,quantity:500,amount:50000,averageRate:100000,allocations:[{payer:'owner',amount:50000}]};h.context.__quote={date:D,member:'assistant',entries:[{lineIndex:0,poolId:D,mg:1500,amount:135000,allocations:[...own.allocations,...common.allocations],materialSources:[own,common]}],pools:[{poolId:D,revision:'segmented-v1',personalRemainingMg:0,personalRemainingAmount:0,publicRemainingMg:1500,publicRemainingAmount:150000,eligibleRemainingMg:1500,before:{personalRemainingMg:1000,publicRemainingMg:2000,eligibleRemainingMg:3000}}]};const calls=[];h.context.__api=async(url,input)=>{calls.push({url,input});return h.context.__quote;};h.run('api=__api;syncPriceLockCreate()');assert.equal(h.nodes.get('#lock-pool-material-estimate').textContent,'待确定');assert.match(h.nodes.get('#lock-pool-material-note').textContent,/正在按订单归属核对/);await h.run('loadMaterialQuote()');assert.equal(calls[0].input.member,'assistant');assert.equal(h.nodes.get('#lock-pool-material-estimate').textContent,'¥1,350.00');assert.match(h.nodes.get('#lock-pool-material-payers').innerHTML,/娜娜个人回收料.*1\.000g.*850\.00.*公共料.*0\.500g.*500\.00/);assert.match(h.nodes.get('#lock-pool-material-note').textContent,/本次后余.*个人回收料 0\.000g.*公共料 1\.500g/);assert.equal(h.poolRoot.dataset.ready,'true');
|
||||
h.fields.quantity.value='1';h.use(pool({totalMg:0,totalAmount:0,averageRate:null,remainingMg:0,personalPools:{assistant:{remainingMg:1000}}}));h.context.__quote.entries=[{lineIndex:0,poolId:D,mg:1000,amount:85000,allocations:own.allocations,materialSources:[own]}];h.context.__quote.pools=[{poolId:D,revision:'private-only-v1',personalRemainingMg:0,personalRemainingAmount:0,publicRemainingMg:0,publicRemainingAmount:0,eligibleRemainingMg:0,before:{personalRemainingMg:1000,publicRemainingMg:0,eligibleRemainingMg:1000}}];h.run('syncPriceLockCreate()');await h.run('loadMaterialQuote()');assert.equal(h.nodes.get('#lock-pool-material-estimate').textContent,'¥850.00');assert.equal(h.poolRoot.dataset.ready,'true');
|
||||
});
|
||||
Reference in new issue
Block a user