完善逐件置换的旧料、折旧、补金与独立成本结算

This commit is contained in:
summer committed 2026-11-24 21:56:05 +08:00
1 parent 2e4e7dad55
commit d0809d61a7
9 files changed
+248 -23

No files matched your search

+10
View File
@@ -138,3 +138,13 @@ test('多商品新货合计参与补金与余料,外配空值保留,工费
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 进货工费/);
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);
});
test('逐件完整置换分别补金与退余料,整单汇总不沿用第一件回收金额',()=>{
const h=harness(),second={...h.draft(),new_name:'第二件',incoming_weight:'20',melted_weight:'20',new_quantity:'12',buy_rate:'850',pocket:'',labor_rate:'30',depreciation_rate:'5',cost_labor_mode:'total',cost_labor_value:'60',labor_payer:'assistant2'};
const draft={...swap,independent_products:true,incoming_weight:'10',melted_weight:'10',new_quantity:'15',material_rate:'800',extra_products:[second]},input=h.input(draft),q=h.calculate(input);
assert.equal(q.differenceMg,5000);assert.equal(q.surplusMg,8000);assert.equal(q.netSettlement,-98000);assert.equal(q.purchaseAmount,680000);assert.equal(input.exchange.items[1].exchange.pocket,'');
h.context.__input=input;assert.doesNotThrow(()=>h.run('validateRecoveryInput(__input)'));h.context.__draft=h.draft(draft);const html=h.run('recoveryFormHTML(__draft)');
for(const name of ['incoming_weight','melted_weight','purity','old_pocket','buy_rate','buy_total','gold_price','depreciation_rate','depreciation_weight','material_source','material_pool_id','material_rate','material_payer']){assert.ok(html.includes('name="'+name+'"'));assert.ok(html.includes('name="extra_'+name+'"'));}
assert.equal((html.match(/data-recovery-item=/g)||[]).length,2);
const discounted=h.calculate(h.input({...draft,discount:'5500'}));assert.equal(discounted.receivable,32000);assert.equal(discounted.netSettlement,-648000);
});