置换默认一份旧料换多件新货,统一结算差重与寄存

This commit is contained in:
summer committed 2026-11-27 15:48:37 +08:00
1 parent b070da1e3d
commit 9186480118
5 files changed
+35 -14

No files matched your search

+9 -1
View File
@@ -135,7 +135,7 @@ test('多商品新货合计参与补金与余料,外配空值保留,工费
const input=h.input(draft),calc=h.calculate(input);assert.equal(input.exchange.products.length,2);assert.equal(input.exchange.products[1].pocket,'');assert.equal(input.exchange.products[1].cost_labor.amount,'90');
assert.equal(calc.newMg,30000);assert.equal(calc.differenceMg,10000);assert.equal(calc.laborAmount,78000);assert.equal(calc.netSettlement,1098000);
h.context.__input=input;assert.doesNotThrow(()=>h.run('validateRecoveryInput(__input)'));
h.context.__draft=h.draft(draft);const html=h.run('recoveryFormHTML(__draft)');assert.match(html,/recovery-add-product/);assert.match(html,/recovery-remove-product/);assert.match(html,/外配(不扣店内库存)/);assert.match(html,/name="extra_new_quantity" value="18"/);assert.match(html,/新货 1 进货工费/);
h.context.__draft=h.draft(draft);const html=h.run('recoveryFormHTML(__draft)');assert.match(html,/recovery-add-product/);assert.match(html,/recovery-remove-product/);assert.match(html,/外配(不扣店内库存)/);assert.match(html,/name="extra_new_quantity" value="18"/);assert.match(html,/本件内部成本/);assert.match(html,/name="cost_labor_value"/);assert.match(html,/name="extra_cost_labor_value"/);
const surplus=h.input({...draft,incoming_weight:'40',melted_weight:'40',buy_rate:'850'}),back=h.calculate(surplus);assert.equal(back.surplusMg,10000);assert.equal(back.purchaseAmount,850000);assert.equal(surplus.exchange.cost_material,undefined);
});
@@ -163,3 +163,11 @@ test('余料处理可选寄存,取消隐藏旧回收款;每件独立选择
const mixed=h.json('recoveryInput(__draft)'),total=h.calculate(mixed);assert.equal(mixed.exchange.items[1].surplus_mode,undefined);assert.equal(total.depositMg,1439);assert.equal(total.purchaseMg,1000);assert.equal(total.purchaseAmount,85000);
const html=h.run('recoveryFormHTML(__draft)');assert.match(html,/name="surplus_mode"/);assert.match(html,/name="extra_surplus_mode"/);assert.match(html,/添加到寄存料,暂不结算/);assert.match(html,/data-surplus-buy/);
});
test('新建默认一份旧料换多件新货,旧料和寄存选择只出现一次,工费及货盘逐件完整',()=>{
const h=harness();assert.equal(h.json('recoveryStoredDraft()').independent_products,false);assert.equal(h.draft({mode:'exchange'}).independent_products,false);
const extra=h.draft({new_name:'足金戒指',new_quantity:'3',pocket:'',labor_rate:'20',cost_labor_value:'3',labor_payer:'assistant'}),draft=h.draft({...swap,new_quantity:'15',labor_rate:'25',surplus_mode:'deposit',surplus_memo:'共享旧料余2克',extra_products:[extra]});h.context.__draft=draft;
const input=h.json('recoveryInput(__draft)'),q=h.calculate(input);assert.equal(input.old_lines.length,1);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);assert.equal(q.receivable,61500);
const html=h.run('recoveryFormHTML(__draft)');assert.equal((html.match(/name="incoming_weight"/g)||[]).length,1);assert.equal((html.match(/name="surplus_mode"/g)||[]).length,1);assert.equal((html.match(/name="cost_labor_value"/g)||[]).length,1);assert.match(html,/name="extra_cost_labor_value"/);assert.match(html,/name="extra_pocket"/);assert.doesNotMatch(html,/name="extra_incoming_weight"|recovery-upgrade-items/);assert.match(html,/上方旧料只录一次/);
h.saved.set('mm-recovery-draft-'+h.user.id,JSON.stringify({...draft,independent_products:true,extra_products:[]}));assert.equal(h.json('recoveryStoredDraft()').independent_products,false);
});