内部备注必填并支持快捷标签,置换结算可带入当日加权料价
This commit is contained in:
1 parent
6fe7504e52
commit
ac9073471d
30 files changed
+194
-72
No files matched your search
@@ -178,3 +178,19 @@ test('已缓存的多商品逐件草稿恢复成一份来料,保留新货并
|
||||
h.context.__draft=converted;const input=h.json('recoveryInput(__draft)'),q=h.calculate(input);assert.equal(input.exchange.items,undefined);assert.equal(input.exchange.products.length,2);assert.equal(q.oldMg,20000);assert.equal(q.newMg,18000);assert.equal(q.depositMg,2000);
|
||||
const html=h.run('recoveryFormHTML(__draft)');assert.equal((html.match(/name="incoming_weight"/g)||[]).length,1);assert.doesNotMatch(html,/extra_incoming_weight|data-independent-products="true"/);assert.match(html,/置换新货 2/);assert.deepEqual(h.json('recoveryStoredDraft()'),converted);
|
||||
});
|
||||
|
||||
function rateEntry(h,name='gold_price'){
|
||||
const f=h.form({...swap,buy_total_manual:true});f.contains=()=>true;f.elements[name]={value:'1000',disabled:false};f.elements.verified={checked:true};
|
||||
const status={textContent:''},node={dataset:{rateField:name},disabled:false,closest:q=>q==='[data-recovery-item]'?null:{querySelector:()=>status}};
|
||||
h.nodes.set('#recovery-form',f);h.context.__node=node;h.context.__pool={id:D,date:D,totalMg:10000,totalAmount:855000,averageRate:85500};
|
||||
h.run('api=async function(url){__posts.push({url});return __pool;};syncRecoveryForm=function(){};rememberRecoveryDraft=function(){};');return {f,node,status};
|
||||
}
|
||||
test('置换客户补金与退余料可带入当日公共加权价,保留手填且不改变成本来源',async()=>{
|
||||
for(const name of ['gold_price','buy_rate']){const h=harness(),{f,node,status}=rateEntry(h,name);await h.run('recoveryUseDailyRate(__node)');assert.equal(f.elements[name].value,'855.00');assert.equal(f.elements.verified.checked,false);assert.equal(f.elements.material_source.value,'manual');assert.equal(node.disabled,false);assert.match(status.textContent,/2026-10-25 公共加权/);assert.equal(h.posts[0].url,'/api/material-pools/'+D+'?member=owner');if(name==='buy_rate')assert.equal(f.dataset.buy_total_manual,'false');}
|
||||
const h=harness();h.context.__draft=h.draft(swap);const html=h.run('recoveryFormHTML(__draft)');assert.match(html,/data-rate-field="gold_price"/);assert.match(html,/data-rate-field="buy_rate"/);
|
||||
});
|
||||
test('无当日料价、读取失败或等待读取时已修改价格,均不覆盖原客户结算价',async()=>{
|
||||
const h=harness(),{f,status}=rateEntry(h);h.context.__pool.averageRate=null;await assert.rejects(h.run('recoveryUseDailyRate(__node)'),/暂无可用/);assert.equal(f.elements.gold_price.value,'1000');assert.match(status.textContent,/原价格保留/);
|
||||
h.run('api=async function(){throw new Error("断连");}');await assert.rejects(h.run('recoveryUseDailyRate(__node)'),/断连/);assert.equal(f.elements.gold_price.value,'1000');
|
||||
h.run('api=function(){return new Promise(resolve=>{globalThis.__resolve=resolve;});}');const task=h.run('recoveryUseDailyRate(__node)');f.elements.gold_price.value='999';h.context.__pool.averageRate=85500;h.run('__resolve(__pool)');await task;assert.equal(f.elements.gold_price.value,'999');assert.match(status.textContent,/表单已变化/);
|
||||
});
|
||||
Reference in new issue
Block a user