完善个人每日对账并支持售后订单修改

This commit is contained in:
summer committed 2026-10-28 00:22:04 +08:00
1 parent aa7f7cad27
commit 5e1e4c600c
15 files changed
+1217 -51

No files matched your search

+5 -1
View File
@@ -16,7 +16,11 @@ function node(extra={}){return {innerHTML:'',textContent:'',disabled:false,hidde
function reportForFunds(funds){
const person=(recipient,name)=>({recipient,name,receipt:recipient==='owner'?funds.ownerReceipts.receipt:0,refund:recipient==='owner'?funds.ownerReceipts.refund:0,net:recipient==='owner'?funds.ownerReceipts.net:0,items:recipient==='owner'?['receipt','refund'].filter(kind=>funds.ownerReceipts[kind]).map(kind=>({id:kind,date:funds.date,order_date:funds.date,order_id:'synthetic-order',kind,amount:funds.ownerReceipts[kind],account:'麦麦微信'})):[]});
const cost=name=>({name,goods:0,paidFees:0,total:0,missingCount:0,pendingCount:0,items:[]});
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:{owner:person('owner','麦麦'),assistant:person('assistant','助理')},payerCosts:{owner:cost('麦麦'),assistant:cost('助理')},goods:0,expense:0,inventory:[],unsettled:[],warnings:[],customerBalance:0,settlementDue:0,close:null,dailyFunds:funds};
const recipientReceipts={owner:person('owner','麦麦'),assistant:person('assistant','助理')},member='owner',items=recipientReceipts.owner.items;
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:[]}}]));
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(/&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};}