保存同行基础版:店铺配置与员工管理
This commit is contained in:
1 parent
ecb8d6dec0
commit
b7b987064b
84 files changed
+1884
-573
No files matched your search
@@ -26,6 +26,17 @@ test('旧版已填成本按名称接入,不重复生成也不覆盖原金额',
|
||||
const rows=Estimates.sync([{key:'certificate',note:'证书',amount:'5.5',payer:'owner'}],[product([charge('证书')])]);assert.equal(rows.length,1);assert.equal(rows[0].amount,'5.5');assert.equal(rows[0].payer,'owner');
|
||||
const c=charge('包装盒'),old={key:'charge:'+c.id,note:'包装',sourceName:'包装',amount:'3',payer:'assistant',edited:false};for(const previous of [old,{...old,key:'box',sourceName:undefined}]){const next=Estimates.sync([previous],[product([c])]);assert.equal(next.length,1);assert.equal(next[0].payer,'assistant');}
|
||||
});
|
||||
test('店铺费用配置只生成新默认值,保留旧订单、模板及手填成本',()=>{
|
||||
const certificate=charge('证书'),packaging=charge('包装'),shipping=charge('快递');
|
||||
const original=Estimates.sync([],[product([certificate,packaging,shipping])],{addShipping:true});
|
||||
const shopDefaults={certificate:'8.50',packaging:'7',shipping:'12',packagingPayer:'assistant2'};
|
||||
const fresh=Estimates.sync([],[product([certificate,packaging,shipping])],{addShipping:true,defaultPayer:'assistant',shopDefaults});
|
||||
assert.deepEqual(fresh.map(row=>[row.amount,row.payer]),[['12','assistant'],['8.50','assistant'],['7','assistant2']]);
|
||||
assert.deepEqual(Estimates.sync(original,[product([certificate,packaging,shipping])],{addShipping:true,shopDefaults}),original);
|
||||
const custom=original.map(row=>({...row,amount:'0',payer:'assistant2',edited:true}));
|
||||
assert.deepEqual(Estimates.sync(custom,[product([certificate,packaging,shipping])],{addShipping:true,shopDefaults}),custom);
|
||||
assert.deepEqual(Estimates.sync([],[product([certificate,packaging])],{shopDefaults:{certificate:'0',packaging:'0',shipping:'0',packagingPayer:'assistant'}}).map(row=>[row.amount,row.payer]),[['0','assistant'],['0','assistant']]);
|
||||
});
|
||||
test('预估保存与确认订单不造支出;交付前核实真实费用,防重并准确算利润',t=>{
|
||||
const {l,save,act,run}=fixture(t),charges=[charge('证书'),charge('包装')],lines=[product(charges)],fees=Estimates.sync([],lines,{addShipping:true});const id=save({lines,fee_items:fees});assert.equal(l.detail(id).draftFees,1300);assert.equal(l.detail(id).estimatedProfit,20700);
|
||||
save({id,revision:l.detail(id).revision,lines,fee_items:fees});assert.equal(l.detail(id).fee_items.length,3);act(id,'confirm');assert.equal(l.detail(id).expenses.length,0);assert.equal(l.detail(id).pendingFees.length,3);assert.equal(l.report(date).expense,0);assert.ok(l.report(date).warnings.some(w=>w.message==='附加成本待核实'));
|
||||
|
||||
Reference in new issue
Block a user