每日对账展示料池耗用公式与麦麦垫付成本明细
This commit is contained in:
1 parent
9893ecf037
commit
a72f4a276e
7 files changed
+139
-3
No files matched your search
@@ -20,6 +20,7 @@ function reportForFunds(funds){
|
||||
const owned={member,name:member==='owner'?'麦麦':'助理',...funds.ownerReceipts,items,accounts:items.length?[{account:'麦麦微信',recipient:'owner',channel:'wechat',...funds.ownerReceipts,entryCount:items.length}]:[]};
|
||||
const ownershipReceipts={owner:owned,assistant:{member:'assistant',name:'助理',receipt:0,refund:0,net:0,accounts:[],items:[]}};
|
||||
const ownershipBusiness=Object.fromEntries(Object.entries(ownershipReceipts).map(([member,person])=>[member,{member,name:person.name,basis:'orderDate',from:funds.from,date:funds.date,sales:0,netReceipts:person.net,totalCost:0,knownTotalCost:0,selfCost:0,knownSelfCost:0,otherCost:0,knownOtherCost:0,profit:0,knownProfit:0,incomplete:false,missingCostCount:0,pendingCostCount:0,unknownProfitCount:0,draftCount:0,recordCount:0,orderCount:0,afterSaleCount:0,hasActivity:person.items.length>0,costByPayer:Object.fromEntries(['owner','assistant','assistant2'].map(key=>[key,{member:key,name:key,totalCost:0,knownTotalCost:0,missingCount:0,pendingCount:0}])),difference:{amount:person.net,reconciled:person.net===0,reasons:[]},equation:{basis:'sales',revenue:0,totalCost:0,profit:0,complete:true},settlement:{available:false,basis:'cumulative-through-date',from:funds.from,date:funds.date,dueOut:null,dueIn:null,partial:false,pendingCount:0,legacyCount:0,notice:'旧双人结算请核对原单。',counterparts:[]}}]));
|
||||
for(const b of Object.values(ownershipBusiness))b.poolMaterial={mg:0,amount:0,knownAmount:0,missingCount:0,hasPriceLocks:false,byPayer:Object.fromEntries(['owner','assistant','assistant2'].map(key=>[key,{amount:0,knownAmount:0}])),days:[],otherCosts:{amount:0,knownAmount:0}};
|
||||
return {basis:'orderDate',date:funds.date,from:funds.from,summary:{orderCount:0,completedCount:0,returnedCount:0,cancelledCount:0,draftCount:0,afterSaleCount:0,sale:0,profit:0,totalCost:0,missingCosts:0},orderRows:[],accounts:[],receiptsByOrderDate:funds.ownerReceipts,recipientReceipts,ownershipReceipts,ownershipBusiness,payerCosts:{owner:cost('麦麦'),assistant:cost('助理')},goods:0,expense:0,inventory:[],unsettled:[],warnings:[],customerBalance:0,settlementDue:0,close:null,dailyFunds:funds};
|
||||
}
|
||||
function attrs(tag){const result={};for(const match of tag.matchAll(/([\w-]+)="([^"]*)"/g))result[match[1]]=match[2].replace(/"/g,'"').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');return result;}
|
||||
|
||||
@@ -99,12 +99,38 @@ test('日购料只把所属订单耗用计成本,不重复加整日采购;
|
||||
const paid=check(f.report()).ownershipBusiness.assistant;assert.equal(paid.totalCost,0);assert.equal(paid.profit,0);
|
||||
const report=check(f.report(D2)),own=report.ownershipBusiness.assistant;assert.equal(own.totalCost,274200);assert.equal(own.selfCost,3600);assert.equal(own.otherCost,270600);assert.equal(own.profit,25800);assert.equal(own.settlement.dueOut,270600);assert.notEqual(own.totalCost,900000);assert.equal(report.outlayTotal,4200);
|
||||
f.action(id,'return',{date:D3,reason:'合成池料退回',returnPockets:['金料'],verified:true});const returned=check(f.report(D2)).ownershipBusiness.assistant;assert.equal(returned.totalCost,600);assert.equal(returned.profit,-600);assert.equal(check(f.report(D3)).ownershipBusiness.assistant.settlement.dueOut,600);
|
||||
assert.equal(returned.poolMaterial.mg,0);assert.equal(returned.poolMaterial.amount,0);assert.deepEqual(returned.poolMaterial.days,[]);assert.equal(returned.poolMaterial.otherCosts.amount,600);
|
||||
});
|
||||
|
||||
test('所属订单料池明细克重不随多人FIFO分摊重复,分币用原金额,应转已经含麦麦垫付料费',t=>{
|
||||
const f=fixture(t);f.purchase({grams:'1',total:'900',payer:'assistant'});f.purchase({grams:'2',total:'2000',payer:'owner'});
|
||||
const pooled=(quantity,labor,accessories)=>({name:'足金合成挂件',unit:'g',quantity,pocket:'',payer:'assistant',sale:'3000',costParts:{material:'',labor,accessories,other:'0'},costPayers:{material:'owner',labor:'owner'},costMaterial:{mode:'pool',poolId:D}});
|
||||
f.save('assistant',{lines:[pooled('1.001','10','1')],fee_items:[{key:'shipping',note:'合成实付运费',amount:'6',payer:'owner'}]});f.save('assistant',{lines:[pooled('0.999','20','2')]});
|
||||
const report=check(f.report()),own=report.ownershipBusiness.assistant,pool=own.poolMaterial;
|
||||
assert.equal(pool.mg,2000);assert.equal(pool.amount,193333);assert.equal(pool.days.length,1);assert.equal(pool.days[0].averageRate,96667);assert.equal(pool.days[0].mg,2000);assert.equal(pool.days[0].amount,193333);
|
||||
assert.notEqual(pool.amount,pool.days[0].averageRate*2,'不能拿两位展示均价重新乘克重');assert.equal(pool.byPayer.assistant.amount,90000);assert.equal(pool.byPayer.owner.amount,103333);assert.equal(pool.byPayer.assistant2.amount,0);
|
||||
assert.equal(pool.otherCosts.amount,3900);assert.equal(own.totalCost,197233);assert.equal(own.settlement.dueOut,106933);assert.equal(own.settlement.counterparts.find(row=>row.member==='owner').periodNew,103333+3600);assert.equal(report.outlayGoods,293300,'采购现金保留原口径,未重复加耗用料费');
|
||||
const old=own.totalCost;f.save('assistant',{lines:[line('100','60')]});const mixed=check(f.report()).ownershipBusiness.assistant;assert.equal(mixed.poolMaterial.amount,193333);assert.equal(mixed.poolMaterial.otherCosts.amount,9900);assert.equal(mixed.totalCost,old+6000);assert.equal(mixed.settlement.dueOut,112933);
|
||||
const foreign=f.save('assistant2',{customer:'不可见池料客户',lines:[pooled('0.500','0','0')]});
|
||||
const personal=check(f.report(D,D,'assistant')).ownershipBusiness.assistant,filtered=check(f.report(D,D,'owner','assistant')).ownershipBusiness.assistant;
|
||||
assert.deepEqual(personal.poolMaterial,filtered.poolMaterial);assert.equal(personal.poolMaterial.mg,2000);assert.equal(personal.poolMaterial.amount,193333);assert.ok(!JSON.stringify(personal).includes(foreign));assert.ok(!JSON.stringify(personal).includes('不可见池料客户'));
|
||||
});
|
||||
|
||||
test('跨日多料池分别列原料价,未使用的采购及录错作废不计已用料费',t=>{
|
||||
const f=fixture(t);f.purchase();f.purchase({date:D2,grams:'10',total:'9500'});
|
||||
const pooled=(poolId,quantity)=>({name:'足金合成挂件',unit:'g',quantity,pocket:'',payer:'owner',sale:'3000',costParts:{material:'',labor:'0',accessories:'0',other:'0'},costMaterial:{mode:'pool',poolId}});
|
||||
assert.deepEqual(check(f.report()).ownershipBusiness.assistant.poolMaterial.days,[]);
|
||||
f.save('assistant',{date:D3,lines:[pooled(D,'1'),pooled(D2,'2')]});const pool=check(f.report(D3)).ownershipBusiness.assistant.poolMaterial;
|
||||
assert.equal(pool.mg,3000);assert.equal(pool.amount,280000);assert.deepEqual(pool.days.map(row=>[row.date,row.mg,row.averageRate,row.amount]),[[D,1000,90000,90000],[D2,2000,95000,190000]]);
|
||||
const mistaken=f.save('assistant',{date:D3,lines:[pooled(D2,'1')]});f.voidOrder(mistaken);const after=check(f.report(D3)).ownershipBusiness.assistant.poolMaterial;assert.equal(after.mg,3000);assert.equal(after.amount,280000);assert.equal(after.otherCosts.amount,0);
|
||||
});
|
||||
|
||||
test('成本缺失、料池待补与旧单未入账费用保留null和已知数,不能显示完整利润或结清',t=>{
|
||||
const f=fixture(t);f.save('assistant',{date:D2,lines:[{name:'足金合成待补',unit:'g',quantity:'1.000',pocket:'',payer:'owner',costPayers:{material:'owner',labor:'assistant'},sale:'1000',costParts:{material:'',labor:'30',accessories:'0',other:'0'},costMaterial:{mode:'pool',poolId:D}}],fee_items:[{key:'shipping',note:'合成实付运费',amount:'5',payer:'owner'}]});
|
||||
let own=check(f.report(D2)).ownershipBusiness.assistant;assert.equal(own.totalCost,null);assert.equal(own.knownTotalCost,3500);assert.equal(own.selfCost,3000);assert.equal(own.otherCost,null);assert.equal(own.knownOtherCost,500);assert.equal(own.profit,null);assert.equal(own.knownProfit,0);assert.equal(own.incomplete,true);assert.equal(own.missingCostCount,1);assert.equal(own.unknownProfitCount,1);assert.equal(own.equation.complete,false);assert.equal(own.settlement.partial,true);assert.ok(own.settlement.pendingCount>0);
|
||||
assert.equal(own.poolMaterial.mg,1000);assert.equal(own.poolMaterial.amount,null);assert.equal(own.poolMaterial.byPayer.owner.amount,null);assert.equal(own.poolMaterial.byPayer.assistant.amount,null);assert.equal(own.poolMaterial.otherCosts.amount,3500);assert.equal(own.poolMaterial.days[0].averageRate,null);
|
||||
f.purchase();own=check(f.report(D2)).ownershipBusiness.assistant;assert.equal(own.totalCost,93500);assert.equal(own.profit,6500);assert.equal(own.incomplete,false);
|
||||
assert.equal(own.poolMaterial.amount,90000);assert.equal(own.poolMaterial.byPayer.owner.amount,90000);assert.equal(own.poolMaterial.otherCosts.amount,3500);
|
||||
const old=f.save('assistant',{date:D2,lines:[line('100','60')],fee_items:[{key:'shipping',note:'合成旧单待核费',amount:'',payer:'owner',status:'estimated'}]},false);f.action(old,'confirm',{date:D2});
|
||||
own=check(f.report(D2)).ownershipBusiness.assistant;assert.equal(own.totalCost,null);assert.equal(own.profit,null);assert.equal(own.pendingCostCount,1);assert.equal(own.costByPayer.owner.pendingCount,1);assert.equal(own.settlement.partial,true);assert.ok(own.difference.reasons.some(row=>row.code==='unfinalized_orders'));
|
||||
f.save('assistant',{date:D2},false);own=check(f.report(D2)).ownershipBusiness.assistant;assert.equal(own.draftCount,1);assert.equal(own.costByPayer.assistant.totalCost,null);assert.equal(own.hasActivity,true);
|
||||
|
||||
@@ -29,12 +29,17 @@ test('同日少重交付只耗一次,随后补料同步原锁量、实际成
|
||||
f.buy('1','2000','assistant2');p=f.l.materialPools().current;const d=f.l.priceLockDetail(lock.id),o=f.l.detail(id);
|
||||
assert.equal(d.material_amount,200000);assert.equal(o.goodsCost,133333);assert.equal(o.profit,66667);assert.equal(d.delivery.leftover_cost,66667);assert.equal(p.consumedCost,133333);assert.equal(p.remainingCost,266667);assert.equal(p.totalAmount,p.consumedCost+p.remainingCost);
|
||||
assert.deepEqual(o.lines[0].materialAllocations.filter(a=>a.source==='original').map(a=>[a.payer,a.amount]),[['assistant',80000],['owner',53333]]);assert.equal(f.l.rows("SELECT * FROM team_fund_cash WHERE source_kind='price_lock' AND kind='outlay'").length,0);
|
||||
const report=f.l.asActor(f.actors.assistant).reportFor({date:D,basis:'orderDate'},f.actors.assistant),own=report.ownershipBusiness.assistant;
|
||||
assert.equal(own.poolMaterial.mg,1000);assert.equal(own.poolMaterial.amount,133333);assert.equal(own.poolMaterial.hasPriceLocks,true);assert.equal(own.poolMaterial.days[0].averageRate,133333);assert.equal(own.poolMaterial.byPayer.owner.amount,53333);assert.equal(own.poolMaterial.byPayer.assistant.amount,80000);assert.equal(own.poolMaterial.otherCosts.amount,0);assert.equal(own.settlement.dueOut,53333);
|
||||
});
|
||||
test('锁价日跨天冻结,少重余料按原成本与付款来源回交付日池,未用原锁重不进入期初',t=>{
|
||||
const f=fixture(t);f.buy('0.8','800','assistant',P);f.buy('1.2','1200','owner',P);f.enable(P);const lock=f.lock('1.500',P),old=f.l.priceLockDetail(lock.id);f.buy('1','3000');
|
||||
assert.equal(f.l.priceLockDetail(lock.id).material_amount,old.material_amount);assert.equal(f.l.materialPools().current.opening.mg,500);assert.equal(f.l.materialPools().current.opening.amount,50000);
|
||||
const id=f.deliver(lock.id,'0.500').id,p=f.l.materialPools().current;assert.equal(f.l.detail(id).goodsCost,50000);assert.equal(p.totalMg,2500);assert.equal(p.totalAmount,450000);assert.equal(p.usedMg,0);assert.equal(p.remainingMg,2500);assert.equal(f.l.priceLockDetail(lock.id).delivery.leftover_cost,100000);
|
||||
const ret=f.l.rows('SELECT * FROM price_lock_pool_returns WHERE price_lock_id=?',lock.id);assert.equal(ret.length,1);assert.deepEqual(JSON.parse(ret[0].allocations),[{payer:'assistant',amount:30000},{payer:'owner',amount:70000}]);assert.equal(f.l.rows("SELECT * FROM team_fund_cash WHERE source_kind='price_lock' AND kind='outlay'").length,0);
|
||||
const report=date=>f.l.asActor(f.actors.assistant).reportFor({date,basis:'orderDate'},f.actors.assistant).ownershipBusiness.assistant,original=report(P),delivery=report(D),poolCost=delivery.poolMaterial;
|
||||
assert.equal(original.poolMaterial.mg,0);assert.equal(original.poolMaterial.amount,0);assert.equal(original.settlement.dueOut,70000,'原锁日预留已产生往来,不能等交付再加');
|
||||
assert.equal(poolCost.mg,500);assert.equal(poolCost.amount,50000);assert.equal(poolCost.days[0].date,P);assert.equal(poolCost.days[0].averageRate,100000);assert.equal(poolCost.byPayer.owner.amount,0);assert.equal(poolCost.byPayer.assistant.amount,50000);assert.equal(delivery.settlement.dueOut,0);assert.equal(delivery.settlement.counterparts.find(row=>row.member==='owner').periodNew,-70000,'交付日只释放原锁余料,交付耗用不再增加一次往来');
|
||||
});
|
||||
test('采购删除造成锁价成本待补,拒绝交付并完整回滚,补料恢复成本和付款归属',t=>{
|
||||
const f=fixture(t);f.buy('0.8','800','assistant');const b=f.buy('1.2','1200');f.enable();const lock=f.lock();f.run({},()=>f.l.deleteMaterialPurchase(b.id,{revision:1},f.actors.owner));
|
||||
|
||||
@@ -10,7 +10,7 @@ function ownershipPerson(member,name,items){
|
||||
}
|
||||
function businessPerson(person,date=D,from=date,extra={}){
|
||||
const costByPayer=Object.fromEntries(['owner','assistant','assistant2'].map(member=>[member,{member,name:{owner:'麦麦',assistant:'助理1',assistant2:'助理2'}[member],totalCost:0,knownTotalCost:0,missingCount:0,pendingCount:0,...extra.costByPayer?.[member]}])),payers=Object.values(costByPayer),others=payers.filter(row=>row.member!==person.member),knownTotalCost=payers.reduce((total,row)=>total+row.knownTotalCost,0),totalCost=payers.some(row=>row.totalCost===null)?null:knownTotalCost,sales=extra.sales??person.net,profit=Object.hasOwn(extra,'profit')?extra.profit:totalCost===null?null:sales-totalCost,incomplete=extra.incomplete??(totalCost===null||profit===null);
|
||||
const result={member:person.member,name:person.name,basis:'orderDate',from,date,sales,netReceipts:person.net,totalCost,knownTotalCost,selfCost:costByPayer[person.member].totalCost,knownSelfCost:costByPayer[person.member].knownTotalCost,otherCost:others.some(row=>row.totalCost===null)?null:others.reduce((total,row)=>total+row.totalCost,0),knownOtherCost:others.reduce((total,row)=>total+row.knownTotalCost,0),profit,knownProfit:profit??0,incomplete,missingCostCount:payers.reduce((total,row)=>total+row.missingCount,0),pendingCostCount:payers.reduce((total,row)=>total+row.pendingCount,0),unknownProfitCount:profit===null?1:0,draftCount:0,recordCount:person.items.length,orderCount:person.items.length,afterSaleCount:0,hasActivity:person.items.length>0,costByPayer,difference:{amount:person.net-sales,reconciled:person.net===sales,reasons:person.net===sales?[]:[{code:'payment_sales_difference',text:'净收款与销售不同,按原账核对利润。'}]},equation:{basis:person.net===sales&&!incomplete?'netReceipts':'sales',revenue:person.net===sales&&!incomplete?person.net:sales,totalCost,profit,complete:!incomplete},settlement:{available:false,basis:'cumulative-through-date',from,date,dueOut:null,dueIn:null,partial:false,pendingCount:0,legacyCount:0,notice:'历史结算请核对原单。',counterparts:[]},...extra,costByPayer};return result;
|
||||
const result={member:person.member,name:person.name,basis:'orderDate',from,date,sales,netReceipts:person.net,totalCost,knownTotalCost,selfCost:costByPayer[person.member].totalCost,knownSelfCost:costByPayer[person.member].knownTotalCost,otherCost:others.some(row=>row.totalCost===null)?null:others.reduce((total,row)=>total+row.totalCost,0),knownOtherCost:others.reduce((total,row)=>total+row.knownTotalCost,0),profit,knownProfit:profit??0,incomplete,missingCostCount:payers.reduce((total,row)=>total+row.missingCount,0),pendingCostCount:payers.reduce((total,row)=>total+row.pendingCount,0),unknownProfitCount:profit===null?1:0,draftCount:0,recordCount:person.items.length,orderCount:person.items.length,afterSaleCount:0,hasActivity:person.items.length>0,costByPayer,difference:{amount:person.net-sales,reconciled:person.net===sales,reasons:person.net===sales?[]:[{code:'payment_sales_difference',text:'净收款与销售不同,按原账核对利润。'}]},equation:{basis:person.net===sales&&!incomplete?'netReceipts':'sales',revenue:person.net===sales&&!incomplete?person.net:sales,totalCost,profit,complete:!incomplete},settlement:{available:false,basis:'cumulative-through-date',from,date,dueOut:null,dueIn:null,partial:false,pendingCount:0,legacyCount:0,notice:'历史结算请核对原单。',counterparts:[]},...extra,costByPayer};return {...result,poolMaterial:extra.poolMaterial??{mg:0,amount:0,knownAmount:0,missingCount:0,hasPriceLocks:false,byPayer:Object.fromEntries(['owner','assistant','assistant2'].map(key=>[key,{amount:0,knownAmount:0}])),days:[],otherCosts:{amount:result.totalCost,knownAmount:result.knownTotalCost}}};
|
||||
}
|
||||
function syncBusiness(response){response.ownershipBusiness=Object.fromEntries(Object.entries(response.ownershipReceipts).map(([member,person])=>[member,businessPerson(person,response.date,response.from)]));return response;}
|
||||
function report(date=D,from=date,empty=false){
|
||||
@@ -195,3 +195,35 @@ test('经营投影缺失、付款不平、利润等式或待转构成错误均
|
||||
for(const change of changes){const response=businessReport();change(response);const h=businessHarness(response);await h.run('renderReport()');assert.equal(h.run('currentReport'),null);assert.match(h.content.innerHTML,/所属订单成本、利润或待转资料未完整返回/);assert.throws(()=>h.run('requireCurrentReport()'),/正在读取或已失效/);}
|
||||
const legacy=report();legacy.ownershipBusiness.assistant.settlement.partial=true;legacy.ownershipBusiness.assistant.settlement.legacyCount=1;const h=harness(legacy);await h.run('renderReport()');const html=memberCard(h.content.innerHTML,'assistant');assert.match(html,/待核对历史结算,暂不显示待转金额/);assert.doesNotMatch(html,/本人应转他人<\/span><strong>¥0\.00|已结清/);
|
||||
});
|
||||
|
||||
function poolBusinessReport(){
|
||||
const response=businessReport(),byPayer={owner:{amount:103333,knownAmount:103333},assistant:{amount:90000,knownAmount:90000},assistant2:{amount:0,knownAmount:0}},day={poolId:D,date:D,mg:2000,averageRate:96667,amount:193333,knownAmount:193333,missingCount:0,byPayer};
|
||||
response.ownershipBusiness.assistant=businessPerson(response.ownershipReceipts.assistant,D,D,{costByPayer:{owner:{totalCost:106933,knownTotalCost:106933},assistant:{totalCost:90300,knownTotalCost:90300}},poolMaterial:{mg:2000,amount:193333,knownAmount:193333,missingCount:0,hasPriceLocks:false,byPayer,days:[day],otherCosts:{amount:3900,knownAmount:3900}},settlement:settlement([counterpart('owner',50000,86933)])});
|
||||
return response;
|
||||
}
|
||||
test('料池用料在所属订单卡直接可见,保留原分币金额、麦麦垫付和其他成本,待转不再加一次',async()=>{
|
||||
const h=businessHarness(poolBusinessReport());await h.run('renderReport()');const html=memberCard(h.content.innerHTML,'assistant');
|
||||
assert.match(html,/所属订单总成本<\/h3><strong>¥1,972\.33/);assert.match(html,/料池已用料费<\/span><strong>¥1,933\.33/);assert.match(html,/2\.000g × ¥966\.67\/g = ¥1,933\.33/);assert.match(html,/其中麦麦垫付 <b>¥1,033\.33/);assert.match(html,/其他成本 <b>¥39\.00/);assert.match(html,/本人应转他人<\/span><strong>¥1,369\.33/);assert.match(html,/已记入待转的部分不再另加/);assert.match(html,/未四舍五入均价/);assert.doesNotMatch(html,/1,933\.34|3,302\.66/);
|
||||
assert.match(html,/麦麦垫付合计:料费 ¥1,033\.33 + 其他成本 ¥36\.00 = ¥1,069\.33/);assert.doesNotMatch(html,/麦麦垫付合计:料费 ¥1,033\.33 + 其他成本 ¥39\.00/);
|
||||
const text=h.run('reportOwnershipReceiptsText(currentReport).join(String.fromCharCode(10))');assert.match(text,/料池已用料费:¥1,933\.33/);assert.match(text,/2\.000g × ¥966\.67\/g = ¥1,933\.33/);assert.match(text,/其中麦麦垫付:¥1,033\.33/);assert.match(text,/其他成本:¥39\.00/);
|
||||
assert.match(text,/麦麦垫付合计:料费 ¥1,033\.33 + 其他成本 ¥36\.00 = ¥1,069\.33/);
|
||||
});
|
||||
|
||||
test('多日料池各列原均价与耗用额,跨日锁价说明不把交付料费当作本日新往来',async()=>{
|
||||
const response=poolBusinessReport(),pool=response.ownershipBusiness.assistant.poolMaterial,prior='2026-10-21';
|
||||
pool.hasPriceLocks=true;pool.days=[{...pool.days[0],poolId:prior,date:prior,mg:1000,averageRate:90000,amount:90000,knownAmount:90000,byPayer:{owner:{amount:0,knownAmount:0},assistant:{amount:90000,knownAmount:90000},assistant2:{amount:0,knownAmount:0}}},{...pool.days[0],mg:1000,averageRate:103333,amount:103333,knownAmount:103333,byPayer:{owner:{amount:103333,knownAmount:103333},assistant:{amount:0,knownAmount:0},assistant2:{amount:0,knownAmount:0}}}];
|
||||
const h=businessHarness(response);await h.run('renderReport()');const html=memberCard(h.content.innerHTML,'assistant');assert.match(html,/2026-10-21 料池/);assert.match(html,/1\.000g × ¥900\.00\/g = ¥900\.00/);assert.match(html,/2026-10-22 料池/);assert.match(html,/1\.000g × ¥1,033\.33\/g = ¥1,033\.33/);assert.match(html,/原预留与回料日期记往来,交付日不再加一次/);assert.match(html,/本人应转他人<\/span><strong>¥1,369\.33/);
|
||||
});
|
||||
|
||||
test('待补料费与未知FIFO付款人显示已知额和待补,其他已核实成本继续显示',async()=>{
|
||||
const response=poolBusinessReport(),pool=response.ownershipBusiness.assistant.poolMaterial;
|
||||
pool.amount=null;pool.knownAmount=0;pool.missingCount=1;pool.byPayer=Object.fromEntries(['owner','assistant','assistant2'].map(key=>[key,{amount:null,knownAmount:0}]));pool.days=[{poolId:D,date:D,mg:2000,averageRate:null,amount:null,knownAmount:0,missingCount:1,byPayer:pool.byPayer}];
|
||||
response.ownershipBusiness.assistant=businessPerson(response.ownershipReceipts.assistant,D,D,{costByPayer:{owner:{totalCost:null,knownTotalCost:3600,missingCount:1},assistant:{totalCost:300,knownTotalCost:300}},poolMaterial:pool,settlement:settlement([],D,D,{partial:true,pendingCount:1})});
|
||||
const h=businessHarness(response);await h.run('renderReport()');const html=memberCard(h.content.innerHTML,'assistant');assert.match(html,/2\.000g × 待补料价 = 料费待补(已知 ¥0\.00)/);assert.match(html,/其中麦麦垫付 <b>已知 ¥0\.00/);assert.match(html,/其他成本 <b>¥39\.00/);assert.match(html,/待核算/);assert.doesNotMatch(html,/2\.000g × ¥0\.00/);
|
||||
assert.match(html,/麦麦垫付合计:料费 待补(已知 ¥0\.00) + 其他成本 待补(已知 ¥36\.00) = 待补(已知 ¥36\.00)/);
|
||||
});
|
||||
|
||||
test('料费分项、克重、付款归属和其他成本必须守恒,缺失投影不会把料费隐藏成0',async()=>{
|
||||
const changes=[r=>delete r.ownershipBusiness.assistant.poolMaterial,r=>r.ownershipBusiness.assistant.poolMaterial.mg++,r=>r.ownershipBusiness.assistant.poolMaterial.days[0].amount++,r=>r.ownershipBusiness.assistant.poolMaterial.byPayer.owner.knownAmount++,r=>r.ownershipBusiness.assistant.poolMaterial.otherCosts.knownAmount++];
|
||||
for(const change of changes){const response=poolBusinessReport();change(response);const h=businessHarness(response);await h.run('renderReport()');assert.equal(h.run('currentReport'),null);assert.match(h.content.innerHTML,/所属订单成本、利润或待转资料未完整返回/);assert.doesNotMatch(h.content.innerHTML,/料池已用料费<\/span>/);}
|
||||
});
|
||||
Reference in new issue
Block a user