每日对账底部新增按归属人逐日利润表

This commit is contained in:
summer committed 2026-11-03 00:29:34 +08:00
1 parent d8daf90b00
commit f4ac7502d3
8 files changed
+141 -10

No files matched your search

+2 -2
View File
@@ -22,14 +22,14 @@ function reportForFunds(funds){
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}};
for(const b of Object.values(ownershipBusiness))b.ownerAdvances={basis:'orderDate',from:funds.from,date:funds.date,days:[]};
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};
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,dailyProfits:{basis:'orderDate',date:funds.date,from:funds.from,rows:[],summary:{recordCount:0,orderCount:0,afterSaleCount:0,draftCount:0,sales:0,knownTotalCost:0,knownProfit:0,totalCost:0,profit:0,unknownCostCount:0,unknownProfitCount:0,incomplete:false}},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(/&quot;/g,'"').replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');return result;}
function deferred(){let resolve,reject;const promise=new Promise((yes,no)=>{resolve=yes;reject=no;});return {promise,resolve,reject};}
function harness(initial=data(),role='owner'){
const nodes=new Map(),saved=new Map(),calls=[],toasts=[],handlers={},responses=new Map([[initial.date,clone(initial)]]),postResults=new Map();let forms=[];
const user={id:role,name:role==='owner'?'麦麦':'助理',role};
for(const key of ['#main','#daily-funds-content','#report-content','#daily-reimbursements-list','#pending','#toast','#reimbursement-edit-total'])nodes.set(key,node());
for(const key of ['#main','#daily-funds-content','#report-daily-profits-content','#report-content','#daily-reimbursements-list','#pending','#toast','#reimbursement-edit-total'])nodes.set(key,node());
nodes.set('#daily-reimbursements-dialog',node({open:false,showModal(){this.open=true;},close(){this.open=false;}}));
function parseForms(html){
for(const old of forms)nodes.delete('#'+old.id);forms=[];