修复置换草稿重复来料并统一新货表单布局
This commit is contained in:
1 parent
9186480118
commit
6fe7504e52
4 files changed
+40
-10
No files matched your search
@@ -143,7 +143,7 @@ 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)');
|
||||
h.context.__input=input;assert.doesNotThrow(()=>h.run('validateRecoveryInput(__input)'));h.context.__draft=h.draft(draft);const html=h.run('recoveryItemsFormHTML(__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);
|
||||
@@ -161,7 +161,7 @@ test('余料处理可选寄存,取消隐藏旧回收款;每件独立选择
|
||||
const input=h.input(draft),q=h.calculate(input);assert.equal(q.depositMg,1439);assert.equal(q.purchaseMg,0);assert.equal(q.purchaseAmount,0);assert.equal(q.netSettlement,q.receivable);assert.equal(input.surplus_memo,'袋B');h.context.__q=q;h.context.__input=input;assert.match(h.run('recoverySettlementHTML(__q,__input)'),/余料寄存:1.439g/);
|
||||
h.context.__draft=h.draft({...draft,independent_products:true,extra_products:[h.draft({...swap,incoming_weight:'3',melted_weight:'3',new_quantity:'2',buy_rate:'850'})]});
|
||||
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/);
|
||||
const html=h.run('recoveryItemsFormHTML(__draft)');assert.match(html,/name="surplus_mode"/);assert.match(html,/name="extra_surplus_mode"/);assert.match(html,/添加到寄存料,暂不结算/);assert.match(html,/data-surplus-buy/);
|
||||
});
|
||||
|
||||
test('新建默认一份旧料换多件新货,旧料和寄存选择只出现一次,工费及货盘逐件完整',()=>{
|
||||
@@ -171,3 +171,10 @@ test('新建默认一份旧料换多件新货,旧料和寄存选择只出现
|
||||
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);
|
||||
});
|
||||
|
||||
test('已缓存的多商品逐件草稿恢复成一份来料,保留新货并备份原草稿,刷新不会再次重复',()=>{
|
||||
const h=harness(),second=h.draft({...swap,incoming_weight:'20',melted_weight:'20',new_name:'足金戒指',new_quantity:'3',pocket:'',labor_rate:'20',cost_labor_value:'3'}),legacy=h.draft({...swap,independent_products:true,new_name:'足金手镯',new_quantity:'15',surplus_mode:'deposit',extra_products:[second],verified:true,buy_total_manual:true,buy_total:'999',depreciation_manual:true});
|
||||
const key='mm-recovery-draft-'+h.user.id;h.saved.set(key,JSON.stringify(legacy));const converted=h.json('recoveryStoredDraft()');assert.equal(converted.independent_products,false);assert.equal(converted.incoming_weight,'20');assert.equal(converted.extra_products[0].incoming_weight,undefined);assert.equal(converted.extra_products[0].new_quantity,'3');assert.equal(converted.extra_products[0].pocket,'');assert.equal(converted.verified,false);assert.equal(converted.buy_total_manual,false);assert.equal(converted.depreciation_manual,false);assert.deepEqual(JSON.parse(h.saved.get(key+'-before-shared-old')),legacy);
|
||||
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);
|
||||
});
|
||||
Reference in new issue
Block a user