每日对账逐日展示麦麦垫付明细,区分历史累计往来
This commit is contained in:
1 parent
a72f4a276e
commit
d8daf90b00
6 files changed
+141
-18
No files matched your search
@@ -165,3 +165,30 @@ test('新增个人经营展示不改变旧字段、原hash和核对状态,读
|
||||
for(const key of Object.keys(stored).filter(key=>key!=='close'))assert.deepEqual(JSON.parse(JSON.stringify(current[key])),stored[key],key+'原返回值保持不变');
|
||||
assert.deepEqual(f.report(),current);f.report(D,D,'assistant');f.report(D,D,'assistant2');f.report(D3,D);f.report(D3);assert.equal(f.ledger.one('SELECT total_changes() AS count').count,changes);assert.equal(contents(f.ledger),before);
|
||||
});
|
||||
|
||||
test('麦麦垫付逐笔只列所选日所属订单和原分摊金额,昨日垫付与另一助理客户不混入',t=>{
|
||||
const f=fixture(t);f.purchase();const yesterday=f.save('assistant',{customer:'昨日垫付客户',lines:[line('100','60')]});
|
||||
const pooled=f.save('assistant',{date:D2,customer:'本日池料客户',lines:[{name:'足金合成挂件',unit:'g',quantity:'3',pocket:'',payer:'assistant',sale:'3000',costParts:{material:'',labor:'30',accessories:'5',other:'0'},costPayers:{material:'owner',labor:'owner'},costMaterial:{mode:'pool',poolId:D}}],fee_items:[{key:'shipping',note:'本日实付运费',amount:'6',payer:'owner'}]});
|
||||
const manual=f.save('assistant',{date:D2,customer:'本日配件客户',lines:[line('100','10')]});f.save('assistant2',{date:D2,customer:'另一助理秘密客户',payment_account:'助理2微信',lines:[line('1000','700')]});
|
||||
const report=check(f.report(D2,D2,'assistant')),own=report.ownershipBusiness.assistant,advances=own.ownerAdvances,day=advances.days[0];
|
||||
assert.deepEqual(advances.days.map(row=>row.date),[D2]);assert.equal(day.amount,274600);assert.equal(day.poolAmount,270000);assert.equal(day.otherAmount,4600);assert.equal(day.items.length,4);assert.deepEqual([...new Set(day.items.map(row=>row.id))].sort(),[pooled,manual].sort());
|
||||
const material=day.items.find(row=>row.poolMaterial);assert.equal(material.date,D2);assert.equal(material.poolId,D);assert.equal(material.name,'料池料费 · 麦麦垫付部分');assert.equal(material.amount,270000);assert.ok(!Object.hasOwn(material,'calculation'),'付款子行不携带整商品克重乘均价的误导公式');
|
||||
assert.ok(!JSON.stringify(advances).includes(yesterday));assert.ok(!JSON.stringify(advances).includes('另一助理'));assert.equal(own.settlement.dueOut,280600,'团队原累计余额继续保留,不能当成本日垫付');assert.deepEqual(advances,f.report(D2,D2,'owner','assistant').ownershipBusiness.assistant.ownerAdvances);
|
||||
f.action(pooled,'return',{date:D3,reason:'合成本日退回',returnPockets:['金料'],verified:true});const returned=check(f.report(D2,D2,'assistant')).ownershipBusiness.assistant.ownerAdvances.days[0];assert.equal(returned.amount,1600);assert.equal(returned.poolAmount,0);assert.ok(returned.items.every(row=>row.name!=='进货工费'&&!row.poolMaterial));
|
||||
});
|
||||
|
||||
test('月汇总麦麦垫付按开单日逐日展开,费用付款日仍可追溯,空日不从历史累计造垫付',t=>{
|
||||
const f=fixture(t),id=f.save('assistant',{customer:'月内第一天',lines:[line('100','60')]});f.save('assistant',{date:D2,customer:'月内第二天',lines:[line('100','70')]});f.action(id,'expense',{date:D3,amount:'5',payer:'owner',note:'跨日实际运费'});
|
||||
const before=contents(f.ledger),changes=f.ledger.one('SELECT total_changes() AS count').count,monthly=check(f.report(D2,D)).ownershipBusiness.assistant.ownerAdvances;
|
||||
assert.deepEqual(monthly.days.map(day=>[day.date,day.amount]),[[D,6500],[D2,7000]]);const fee=monthly.days[0].items.find(item=>item.name==='跨日实际运费');assert.equal(fee.date,D);assert.equal(fee.source,D3);assert.equal(fee.amount,500);
|
||||
assert.deepEqual(check(f.report(D3)).ownershipBusiness.assistant.ownerAdvances.days,[]);assert.equal(f.ledger.one('SELECT total_changes() AS count').count,changes);assert.equal(contents(f.ledger),before);
|
||||
});
|
||||
|
||||
test('未知池料归属不猜麦麦份额,预估未付只提示不计已垫付,零元和作废成本不列明细',t=>{
|
||||
const f=fixture(t);f.save('assistant',{date:D2,lines:[{name:'足金待补料',unit:'g',quantity:'1',pocket:'',payer:'assistant',sale:'1000',costParts:{material:'',labor:'30',accessories:'0',other:'0'},costPayers:{material:'assistant',labor:'owner'},costMaterial:{mode:'pool',poolId:D}}]});
|
||||
const pending=check(f.report(D2)).ownershipBusiness.assistant.ownerAdvances.days[0];assert.equal(pending.amount,null);assert.equal(pending.knownAmount,3000);assert.equal(pending.poolAmount,null);assert.equal(pending.otherAmount,3000);const missing=pending.items.find(item=>item.allocationPending);assert.equal(missing.amount,null);assert.equal(missing.name,'料池料费 · 麦麦份额待补');
|
||||
const other=fixture(t),old=other.save('assistant',{lines:[line('100','60')],fee_items:[{key:'shipping',note:'尚未实际付款运费',amount:'10',payer:'owner',status:'estimated'}]},false);other.action(old,'confirm');
|
||||
const estimate=check(other.report()).ownershipBusiness.assistant.ownerAdvances.days[0];assert.equal(estimate.amount,0);assert.equal(estimate.knownAmount,0);assert.equal(estimate.pendingCount,1);assert.equal(estimate.items[0].amount,null);assert.equal(estimate.items[0].estimatedAmount,1000);assert.equal(estimate.items[0].status,'pending');
|
||||
const zero=fixture(t);zero.after('assistant',{amount:'0'});const cancelled=zero.save('assistant');zero.voidOrder(cancelled);assert.deepEqual(check(zero.report()).ownershipBusiness.assistant.ownerAdvances.days,[]);
|
||||
zero.after('assistant',{amount:'12.34',project:'合成维修'});const after=check(zero.report()).ownershipBusiness.assistant.ownerAdvances.days[0];assert.equal(after.amount,1234);assert.equal(after.items[0].kind,'afterSale');assert.equal(after.items[0].name,'合成维修');
|
||||
});
|
||||
Reference in new issue
Block a user