每日对账底部新增按归属人逐日利润表
This commit is contained in:
1 parent
d8daf90b00
commit
f4ac7502d3
8 files changed
+141
-10
No files matched your search
@@ -67,6 +67,8 @@ input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-
|
||||
|
||||
.report-owner-advances{margin-top:17px;padding-top:15px;border-top:1px solid var(--border);min-width:0}.report-owner-advances>h3{font-size:13px;font-weight:550;margin:0}.report-owner-advances>p.small{font-size:11px;line-height:1.7;margin:7px 0 0}.report-owner-advance-day{margin-top:12px;padding-top:11px;border-top:1px solid var(--border)}.report-owner-advance-day>header{display:flex;align-items:baseline;flex-wrap:wrap;gap:7px 22px;font-size:12px}.report-owner-advance-day h4{font-size:13px;font-weight:550;margin:0}.report-owner-advance-day header strong{font-size:18px;color:var(--green);margin-left:9px;font-variant-numeric:tabular-nums}.report-owner-advance-day>.report-owner-advance{font-size:12px;line-height:1.8;margin:8px 0}.report-owner-advance-day>.table-wrap{margin-top:10px}.report-owner-advance-table{font-size:12px;min-width:510px}.report-owner-advance-table th,.report-owner-advance-table td{padding:10px 9px;white-space:normal;overflow-wrap:anywhere}.report-owner-advance-table th:first-child{width:100px}.report-owner-advance-table th:nth-child(2){width:25%}.report-owner-advance-table th:last-child{width:155px;text-align:right}.report-owner-advance-table small{display:block;font-size:10px;line-height:1.7;margin-top:4px}.report-owner-advance-table .link-button{font-size:12px}.report-business-history>summary{font-size:12px;color:var(--muted);font-weight:500}.report-business-history>p.small{font-size:11px;line-height:1.7}@media(max-width:650px){.report-owner-advance-table{min-width:430px;font-size:11px}.report-owner-advance-table th,.report-owner-advance-table td{padding:8px 6px}.report-owner-advance-table th:first-child{width:86px}.report-owner-advance-table th:last-child{width:120px}}
|
||||
|
||||
.report-daily-profits{min-width:0;margin-bottom:20px}.report-daily-profits h2{font-size:16px;margin:0 0 8px}.report-daily-profits>p{font-size:11px;line-height:1.7}.report-daily-profits .table-wrap{margin-top:14px}.report-daily-profits table{font-size:13px;min-width:550px;font-variant-numeric:tabular-nums}.report-daily-profits th,.report-daily-profits td{padding:12px 10px;white-space:normal;overflow-wrap:anywhere}.report-daily-profits th.number{text-align:right}.report-daily-profits td:first-child{width:120px;white-space:nowrap}.report-daily-profits small{display:block;font-size:10px;line-height:1.6;margin-top:4px}.report-daily-profits tfoot td{font-weight:600;background:var(--soft);border-top:1px solid var(--border)}.report-daily-profits .report-daily-profit-note{margin:12px 0 0}@media(max-width:650px){.report-daily-profits{padding:17px 14px}.report-daily-profits table{min-width:500px;font-size:12px}.report-daily-profits th,.report-daily-profits td{padding:10px 7px}}
|
||||
|
||||
/* 售后只登记实际费用,与销售订单同表查看。 */
|
||||
#after-sale-dialog{width:min(560px,96vw);padding:26px 28px}#after-sale-title{margin:0 0 9px}#after-sale-dialog>p{margin-bottom:20px;padding-right:24px}#after-sale-form .grid>label:last-child{grid-column:1/-1}#after-sale-form .form-actions{margin-top:22px}.after-sale-identity strong,.after-sale-identity span{display:block;overflow-wrap:anywhere}.after-sale-identity strong{font-size:12px;font-weight:600}.after-sale-identity span{font-size:12px;margin-top:2px}.report-payer-table td>.small{font-size:10px;margin-top:4px}.order-book-table .order-after-sale{background:#faf8f0}.order-after-sale .order-profit{color:var(--danger)}
|
||||
@media(max-width:650px){#after-sale-dialog{padding:22px 18px}#after-sale-form .form-actions{align-items:flex-start;gap:12px}.report-payer-table td>.small{font-size:10px}}
|
||||
|
||||
+25
-2
@@ -1494,9 +1494,19 @@ function reportRecipientReceiptsText(r){
|
||||
}
|
||||
function reportQueryState(range,error=''){
|
||||
const body=$('#report-content');if(!body)return;
|
||||
const profits=$('#report-daily-profits-content');if(profits)profits.innerHTML='';
|
||||
currentReport=null;reportLoadedUser='';body.setAttribute('aria-busy',String(!error));
|
||||
body.innerHTML=`<div class="cards report-cards">${['销售净额','累计实收','累计实退','订单净利润'].map(title=>card(title,'—',error?'尚未取得数据':'正在读取')).join('')}</div><section class="panel report-query-message${error?' error':''}"><p>${error?e(error):'正在读取'+e(reportPeriod(range))+'订单与售后的当前结果…'}</p>${error?button('重新读取','report-retry'):''}</section>`;
|
||||
}
|
||||
function reportDailyProfitAmount(value,known,profit=false){return value===null?(profit?'待核算(已核算 ¥':'待补齐(已知 ¥')+yuan(known)+')':'¥'+yuan(value);}
|
||||
function reportDailyProfitsHTML(r){
|
||||
const table=r.dailyProfits,amounts=row=>`<td class="number">¥${yuan(row.sales)}</td><td class="number">${e(reportDailyProfitAmount(row.totalCost,row.knownTotalCost))}</td><td class="number${(row.profit??row.knownProfit)<0?' danger-text':''}">${e(reportDailyProfitAmount(row.profit,row.knownProfit,true))}</td>`;
|
||||
return `<section class="panel report-daily-profits" aria-label="每日利润表"><h2>每日利润表</h2><p class="small muted">${e(reportPeriod(table))} · 按日期、订单归属人核对。勾选“汇总当月”可查看当月逐日利润。</p><div class="table-wrap"><table aria-label="每日利润明细"><thead><tr><th scope="col">日期</th><th scope="col">归属人</th><th scope="col" class="number">销售净额</th><th scope="col" class="number">成本</th><th scope="col" class="number">利润</th></tr></thead><tbody>${table.rows.map(row=>`<tr data-date="${e(row.date)}" data-member="${e(row.member)}"><td>${e(row.date)}</td><td>${e(row.name)}<small class="muted">销售 ${row.orderCount} 单${row.afterSaleCount?' · 售后 '+row.afterSaleCount+' 笔':''}${row.draftCount?' · 旧草稿 '+row.draftCount+' 单未计金额':''}</small></td>${amounts(row)}</tr>`).join('')||'<tr><td colspan="5" class="muted">所选范围暂无订单或售后记录。</td></tr>'}</tbody><tfoot><tr><td colspan="2">所选范围合计</td>${amounts(table.summary)}</tr></tfoot></table></div><p class="small muted report-daily-profit-note">普通订单按开单日、锁价成单按交付日、售后按记录日归集。成本含实际耗用料费和费用;退货、作废沿原账冲回。${table.summary.unknownProfitCount?'待核算项目不按0计作完整利润,括号内仅为已核算部分。':''}</p></section>`;
|
||||
}
|
||||
function reportDailyProfitsText(r){
|
||||
const table=r.dailyProfits,rowText=row=>`销售净额 ¥${yuan(row.sales)} / 成本 ${reportDailyProfitAmount(row.totalCost,row.knownTotalCost)} / 利润 ${reportDailyProfitAmount(row.profit,row.knownProfit,true)}`;
|
||||
return ['每日利润表(按日期与订单归属人;普通订单按开单日、锁价成单按交付日、售后按记录日)',...(table.rows.length?table.rows.map(row=>`${row.date} / ${row.name} / ${rowText(row)}`):['所选范围暂无订单或售后记录。']),`所选范围合计:${rowText(table.summary)}`,''];
|
||||
}
|
||||
function validateReport(r,range){
|
||||
if(r.basis!=='orderDate'||r.date!==range.date||r.from!==range.from)throw new Error('返回口径或日期与当前选择不一致,请重新读取。');
|
||||
if(!r.summary||!Array.isArray(r.orderRows)||!Array.isArray(r.accounts)||!r.receiptsByOrderDate||!teamDataKeys(r.payerCosts).length||!teamDataKeys(r.payerCosts).every(key=>{
|
||||
@@ -1506,6 +1516,18 @@ function validateReport(r,range){
|
||||
if(!recipientKeys.length||!recipients.every((person,index)=>person&&person.recipient===recipientKeys[index]&&typeof person.name==='string'&&person.name&&Array.isArray(person.items)&&['receipt','refund','net'].every(key=>Number.isSafeInteger(person[key]))&&person.items.every(item=>item&&['receipt','refund'].includes(item.kind)&&Number.isSafeInteger(item.amount)&&typeof item.account==='string'&&validOrderDate(item.date))&&person.net===person.receipt-person.refund&&['receipt','refund'].every(kind=>person.items.filter(item=>item.kind===kind).reduce((sum,item)=>sum+item.amount,0)===person[kind]))||!['receipt','refund','net'].every(key=>recipients.reduce((sum,person)=>sum+person[key],0)===r.receiptsByOrderDate[key]))throw new Error('收款人汇总与明细未完整返回或金额不一致,请重新读取。');
|
||||
validateOwnershipReceipts(r);
|
||||
validateOwnershipBusiness(r);
|
||||
validateDailyProfits(r);
|
||||
}
|
||||
function validateDailyProfits(r){
|
||||
const fail=()=>{throw new Error('每日利润表未完整返回或与当前对账金额不一致,请重新读取。');},table=r.dailyProfits,money=Number.isSafeInteger,count=value=>money(value)&&value>=0,nullable=value=>value===null||money(value),members=teamDataKeys(r.ownershipReceipts);
|
||||
const amounts=['sales','knownTotalCost','knownProfit'],counts=['recordCount','orderCount','afterSaleCount','draftCount','unknownCostCount','unknownProfitCount'];
|
||||
const valid=row=>row&&amounts.every(key=>money(row[key]))&&counts.every(key=>count(row[key]))&&nullable(row.totalCost)&&nullable(row.profit)&&typeof row.incomplete==='boolean'&&row.recordCount===row.orderCount+row.afterSaleCount&&row.draftCount<=row.orderCount&&row.unknownCostCount<=row.recordCount&&row.unknownProfitCount<=row.recordCount&&row.totalCost===(row.unknownCostCount?null:row.knownTotalCost)&&row.profit===(row.unknownProfitCount?null:row.knownProfit)&&((row.unknownCostCount||row.unknownProfitCount)?row.incomplete:true)&&(row.profit===null||row.totalCost!==null&&row.sales-row.totalCost===row.profit);
|
||||
if(!table||table.basis!=='orderDate'||table.from!==r.from||table.date!==r.date||!Array.isArray(table.rows)||!valid(table.summary))fail();
|
||||
let previous='';for(const row of table.rows){
|
||||
if(!valid(row)||!row.recordCount||!members.includes(row.member)||typeof row.name!=='string'||!row.name||!validOrderDate(row.date)||row.date<r.from||row.date>r.date)fail();
|
||||
const key=row.date+':'+teamMemberKeys.indexOf(row.member);if(key<=previous)fail();previous=key;
|
||||
}
|
||||
if([...amounts,...counts].some(key=>table.rows.reduce((sum,row)=>sum+row[key],0)!==table.summary[key])||table.rows.some(row=>row.incomplete)!==table.summary.incomplete||table.summary.sales!==r.summary.sale||table.summary.knownTotalCost!==r.summary.totalCost||table.summary.knownProfit!==r.summary.profit||table.summary.recordCount!==r.orderRows.length||table.summary.unknownProfitCount!==(r.summary.unknownProfitCount||0)+(r.summary.draftCount||0)||table.summary.unknownCostCount!==(r.summary.unknownCostCount||0)+(r.summary.draftCount||0))fail();
|
||||
}
|
||||
function validateOwnershipReceipts(r){
|
||||
const fail=()=>{throw new Error('所属订单净收入与账户明细未完整返回或金额不一致,请重新读取。');},keys=teamDataKeys(r.ownershipReceipts),selected=teamMode()?(state.user.role==='owner'?reportMember:currentMember()):'',expected=selected?[selected]:teamMode()?teamMemberKeys:teamDataKeys(r.recipientReceipts);
|
||||
@@ -1577,7 +1599,7 @@ function validateOwnershipBusiness(r){
|
||||
async function renderReport(){
|
||||
if(!reportDateInitialized){reportDate=reportDate||state.today;reportDateInitialized=true;}
|
||||
invalidateReport();const request=reportRequest,user=state.user.id||state.user.name;let range;
|
||||
$('#main').innerHTML=heading('DAILY CHECK','每日对账','核对本人或所选成员的所属订单收入、实际支出与收款账户。',`<div class="report-controls">${memberFilterHTML('report-member-filter',reportMember)}<label>对账日期<input type="date" id="report-date" value="${e(reportDate)}" max="${e(state.today)}" aria-label="对账日期"></label><label class="check"><input type="checkbox" id="report-month" ${reportMonth?'checked':''}>汇总当月</label></div>`)+`<p class="small muted report-scope">普通订单按开单日期、售后按记录日期筛选。锁价收付按实际发生日期,销售和完整利润在交付日计入;原锁付款不会重复计入交付日支出。</p><div id="report-content" aria-live="polite"></div><div id="daily-funds-content" aria-live="polite"></div>`;
|
||||
$('#main').innerHTML=heading('DAILY CHECK','每日对账','核对本人或所选成员的所属订单收入、实际支出与收款账户。',`<div class="report-controls">${memberFilterHTML('report-member-filter',reportMember)}<label>对账日期<input type="date" id="report-date" value="${e(reportDate)}" max="${e(state.today)}" aria-label="对账日期"></label><label class="check"><input type="checkbox" id="report-month" ${reportMonth?'checked':''}>汇总当月</label></div>`)+`<p class="small muted report-scope">普通订单按开单日期、售后按记录日期筛选。锁价收付按实际发生日期,销售和完整利润在交付日计入;原锁付款不会重复计入交付日支出。</p><div id="report-content" aria-live="polite"></div><div id="daily-funds-content" aria-live="polite"></div><div id="report-daily-profits-content" aria-live="polite"></div>`;
|
||||
try{range=reportRange();}catch(err){reportQueryState(null,err.message);return;}
|
||||
reportQueryState(range);
|
||||
if(typeof prepareDailyFundsReport==='function')prepareDailyFundsReport({...range,month:reportMonth});
|
||||
@@ -1606,6 +1628,7 @@ function renderReportContent(r,range){
|
||||
body.setAttribute('aria-busy','false');
|
||||
body.innerHTML=`${reportOwnershipReceiptsHTML(r,range)}<div class="order-people-strip report-people-strip">${peopleCountHTML(r.peopleCount)}</div><div class="cards report-cards">${card('所选'+(reportMonth?'月':'日')+'销售净额',e(reportSummaryAmount(s,'sale')),e(countHints))}${card('本期实收','¥'+yuan(receipts.receipt),'普通订单累计收款+本期锁价实收')}${card('本期实退','¥'+yuan(receipts.refund),'普通订单累计退款+本期锁价实退')}${card('本期净利润'+(profitMissing?'(已核算部分)':''),e(reportSummaryAmount(s,'profit')),profitMissing?profitMissing+' 单利润待补齐'+(r.pendingMaterialCount?',其中 '+r.pendingMaterialCount+' 单料费待补':''):'销售净额 − 订单耗用成本 − 实际费用(含售后)',true)}</div><div class="report-primary"><section class="panel report-accounts"><h2>按收款账户核对</h2><p class="small muted">${e(reportPeriod(range))}普通订单当前收付,加上同期锁价实际收付。</p><div class="table-wrap"><table aria-label="按收款账户核对"><thead><tr><th>账户</th><th class="number">实收</th><th class="number">实退</th><th class="number">净额</th></tr></thead><tbody>${reportActiveAccounts(r).map(a=>`<tr><td>${e(a.account)}</td><td class="number">¥${yuan(a.receipt)}</td><td class="number">¥${yuan(a.refund)}</td><td class="number">¥${yuan(a.net)}</td></tr>`).join('')||'<tr><td colspan="4" class="muted">所选范围没有收退款活动账户。</td></tr>'}</tbody><tfoot><tr><td>合计</td><td class="number">¥${yuan(receipts.receipt)}</td><td class="number">¥${yuan(receipts.refund)}</td><td class="number">¥${yuan(receipts.net)}</td></tr></tfoot></table></div><p class="small muted report-cost-note">请按这些订单的收退款记录与微信、支付宝、现金、信用卡核对;系统尚未接入支付平台账单。</p></section>${reportPayerCostsHTML(r)}</div>`;
|
||||
body.insertAdjacentHTML('beforeend',priceLockActivityHTML(r.priceLockActivity)+materialPoolActivityHTML(r.materialPoolActivity)+reportOrderNetHTML(r,range)+reportGlobalHTML(r)+`<section class="panel"><div class="panel-title"><h2>需要查看 ${r.warnings.length} 项</h2><span class="small muted">截至现在所有订单,不受日期筛选</span></div>${r.warnings.length?`<ul>${r.warnings.map(w=>`<li>${w.id?`<button class="link-button" data-action="open-order" data-id="${e(w.id)}">${e(w.number)}</button> `:''}${e(w.message)}</li>`).join('')}</ul>`:'<p class="ok">系统内未发现待补成本、待退款和待复核项。实际到账仍需核对。</p>'}<div class="form-actions"><div class="small ${close?.stale?'danger-text':'muted'}">${e(closeStatus)}</div><div class="actions">${button('下载对账报告','download-report')}${state.user.role==='owner'&&!reportMonth?button('保存核对快照','close-day','primary'):''}</div></div></section>`+(teamMode()?teamHistoricalReportHTML(r):reportUnsettledHTML(r)+materialPoolGlobalSettlementHTML(r.materialPoolSettlement)));
|
||||
$('#report-daily-profits-content').innerHTML=reportDailyProfitsHTML(r);
|
||||
}
|
||||
function requireCurrentReport(){
|
||||
const range=reportRange(),r=currentReport;
|
||||
@@ -1618,7 +1641,7 @@ function reportDownloadText(r){
|
||||
const s=r.summary,receipts=r.receiptsByOrderDate,people=teamDataKeys(r.payerCosts).map(key=>r.payerCosts[key]),missing=people.reduce((sum,c)=>sum+c.missingCount,0),pending=people.reduce((sum,c)=>sum+c.pendingCount,0);
|
||||
const costs=people.flatMap(c=>[`${c.name}支出成本:货品成本 ${reportCostAmount(c.goods,c.missingCount)};已付费用 ¥${yuan(c.paidFees)}${c.items.some(item=>item.kind==='afterSale')?'(其中售后 ¥'+yuan(reportAfterSaleAmount(c))+')':''};支出合计 ${reportCostAmount(c.total,c.missingCount+c.pendingCount)}`,reportPayerHints(c),`${c.name}逐项明细(货品成本为 0 的分项省略,已核实为 0 的费用保留):`,...reportCostItems(c).map(item=>`${item.date} / ${reportCostIdentity(item)} / ${item.name} / ${item.source}${item.calculation?' / '+reportCostFormula(item):''} / ${reportCostItemAmount(item)}${item.kind==='pending'?'(未计入实际成本与合计)':''}`),'']);
|
||||
const orders=r.orderRows.map(row=>`${row.date} / ${row.kind==='afterSale'?'售后 · '+row.project+' / 客户 '+row.customer+' / '+afterSalePayerName(row)+'支付':row.paper_number||row.number} / ${label[row.status]||row.status} / 销售净额 ${reportRowAmount(row,'sale')} / 货品成本 ${reportRowAmount(row,'goods')} / 已付费用 ${reportRowAmount(row,'paidFees')} / 成本合计 ${reportRowAmount(row,'totalCost')} / 净利润 ${reportRowAmount(row,'profit')}${row.costHint?' / '+row.costHint:''}`);
|
||||
return [`麦麦珠宝新账 · ${reportPeriod(r)} 对账报告`,'口径:普通订单按开单日期、售后按记录日期;锁价收付款按实际发生日期,销售与完整利润按交付日期。原锁料费不会重复计入交付日实际支出。',`销售订单:${s.orderCount} 单;售后 ${s.afterSaleCount||0} 笔;完成 ${s.completedCount} 单;退货 ${s.returnedCount} 单;取消 ${s.cancelledCount} 单;旧草稿 ${s.draftCount} 单(未计金额)`,...peopleCountReportLines(r.peopleCount),`销售净额:${reportSummaryAmount(s,'sale')}`,`累计实收:¥${yuan(receipts.receipt)}`,`累计实退:¥${yuan(receipts.refund)}`,`客户收款净额:¥${yuan(receipts.net)}`,`订单耗用货品成本:${reportCostAmount(r.goods,s.missingCosts)}`,`订单已付费用:¥${yuan(r.expense)}${s.afterSaleCount?'(其中售后 ¥'+yuan(people.reduce((sum,c)=>sum+reportAfterSaleAmount(c),0))+')':''}`,`各人实际货品支出:${reportCostAmount(r.outlayGoods??r.goods,missing)}`,`各人实际费用支出:¥${yuan(r.outlayExpense??r.expense)}`,`各人实际支出合计:${reportCostAmount(r.outlayTotal??r.goods+r.expense,missing+pending)}`,`本期净利润${s.unknownProfitCount?'(已核算部分)':''}:${reportSummaryAmount(s,'profit')}${s.unknownProfitCount?';'+s.unknownProfitCount+' 单利润待补齐':''}`,'',...reportOwnershipReceiptsText(r),...(typeof dailyFundsDownloadText==='function'?dailyFundsDownloadText(r):[]),...reportRecipientReceiptsText(r),'按收款账户核对(普通订单累计收付+同期锁价实际收付)',...reportActiveAccounts(r).map(a=>`${a.account}:实收 ¥${yuan(a.receipt)},实退 ¥${yuan(a.refund)},净额 ¥${yuan(a.net)}`),'',(teamMode()?'各人支出成本(未入账费用不计合计)':'双方支出成本(未入账费用不计合计)'),...costs,...priceLockActivityText(r.priceLockActivity),...(r.materialPoolActivity?.purchases?.length?['本期实际购料(已计入各人实际支出,不再加总)',...r.materialPoolActivity.purchases.map(item=>`${item.date} / ${grams(item.mg)}g / ¥${yuan(item.amount)} / ${materialPayerName(item.payer)} / ${item.note||''}`),'']:[]),'订单与售后净额明细(订单按开单日期、售后按售后日期)',...orders,'',`${r.date} 账面库存(按所选日及此前流水计算,月汇总仍显示所选日)`,...r.inventory.map(i=>`${i.pocket}:${grams(i.mg)}g`),'','截至现在的全局未结事项(不受日期筛选)',`客户待收款:¥${yuan(r.customerBalance)}`,`订单与剩余料款待结净额:${materialReportMoney(r.settlementDue)}`,...r.unsettled.map(o=>`${o.number}:货款待结 ${materialReportMoney(o.costDue)},利润待结 ${materialReportMoney(o.profitDue)},麦麦直收净额 ¥${yuan(o.ownerDirect)},总待结 ${materialReportMoney(o.total)}`),'','当前待处理(所有订单,不受日期筛选)',...r.warnings.map(w=>`${w.number||''} ${w.message}`),'',...(r.materialPoolSettlement?.pools?.length?['剩余料款与助理结算(正数助理交麦麦,负数麦麦转回助理)',...r.materialPoolSettlement.pools.map(item=>`${item.date}:助理剩余料款 ${materialReportMoney(item.assistantInventoryCredit)},实际已交净额 ¥${yuan(item.transferred)},待结 ${materialReportMoney(item.settlementDue)}`),'']:[]),'收款由经办人登记,不代表支付平台自动核验。各人实际付款与订单耗用成本分别核对;退货冲回耗用成本,锁价实际进货付款保留。净利润不含房租、工资、水电。'].join('\n');
|
||||
return [`麦麦珠宝新账 · ${reportPeriod(r)} 对账报告`,'口径:普通订单按开单日期、售后按记录日期;锁价收付款按实际发生日期,销售与完整利润按交付日期。原锁料费不会重复计入交付日实际支出。',`销售订单:${s.orderCount} 单;售后 ${s.afterSaleCount||0} 笔;完成 ${s.completedCount} 单;退货 ${s.returnedCount} 单;取消 ${s.cancelledCount} 单;旧草稿 ${s.draftCount} 单(未计金额)`,...peopleCountReportLines(r.peopleCount),`销售净额:${reportSummaryAmount(s,'sale')}`,`累计实收:¥${yuan(receipts.receipt)}`,`累计实退:¥${yuan(receipts.refund)}`,`客户收款净额:¥${yuan(receipts.net)}`,`订单耗用货品成本:${reportCostAmount(r.goods,s.missingCosts)}`,`订单已付费用:¥${yuan(r.expense)}${s.afterSaleCount?'(其中售后 ¥'+yuan(people.reduce((sum,c)=>sum+reportAfterSaleAmount(c),0))+')':''}`,`各人实际货品支出:${reportCostAmount(r.outlayGoods??r.goods,missing)}`,`各人实际费用支出:¥${yuan(r.outlayExpense??r.expense)}`,`各人实际支出合计:${reportCostAmount(r.outlayTotal??r.goods+r.expense,missing+pending)}`,`本期净利润${s.unknownProfitCount?'(已核算部分)':''}:${reportSummaryAmount(s,'profit')}${s.unknownProfitCount?';'+s.unknownProfitCount+' 单利润待补齐':''}`,'',...reportDailyProfitsText(r),...reportOwnershipReceiptsText(r),...(typeof dailyFundsDownloadText==='function'?dailyFundsDownloadText(r):[]),...reportRecipientReceiptsText(r),'按收款账户核对(普通订单累计收付+同期锁价实际收付)',...reportActiveAccounts(r).map(a=>`${a.account}:实收 ¥${yuan(a.receipt)},实退 ¥${yuan(a.refund)},净额 ¥${yuan(a.net)}`),'',(teamMode()?'各人支出成本(未入账费用不计合计)':'双方支出成本(未入账费用不计合计)'),...costs,...priceLockActivityText(r.priceLockActivity),...(r.materialPoolActivity?.purchases?.length?['本期实际购料(已计入各人实际支出,不再加总)',...r.materialPoolActivity.purchases.map(item=>`${item.date} / ${grams(item.mg)}g / ¥${yuan(item.amount)} / ${materialPayerName(item.payer)} / ${item.note||''}`),'']:[]),'订单与售后净额明细(订单按开单日期、售后按售后日期)',...orders,'',`${r.date} 账面库存(按所选日及此前流水计算,月汇总仍显示所选日)`,...r.inventory.map(i=>`${i.pocket}:${grams(i.mg)}g`),'','截至现在的全局未结事项(不受日期筛选)',`客户待收款:¥${yuan(r.customerBalance)}`,`订单与剩余料款待结净额:${materialReportMoney(r.settlementDue)}`,...r.unsettled.map(o=>`${o.number}:货款待结 ${materialReportMoney(o.costDue)},利润待结 ${materialReportMoney(o.profitDue)},麦麦直收净额 ¥${yuan(o.ownerDirect)},总待结 ${materialReportMoney(o.total)}`),'','当前待处理(所有订单,不受日期筛选)',...r.warnings.map(w=>`${w.number||''} ${w.message}`),'',...(r.materialPoolSettlement?.pools?.length?['剩余料款与助理结算(正数助理交麦麦,负数麦麦转回助理)',...r.materialPoolSettlement.pools.map(item=>`${item.date}:助理剩余料款 ${materialReportMoney(item.assistantInventoryCredit)},实际已交净额 ¥${yuan(item.transferred)},待结 ${materialReportMoney(item.settlementDue)}`),'']:[]),'收款由经办人登记,不代表支付平台自动核验。各人实际付款与订单耗用成本分别核对;退货冲回耗用成本,锁价实际进货付款保留。净利润不含房租、工资、水电。'].join('\n');
|
||||
}
|
||||
function printSettingsDirty(form=$('#print-settings')){
|
||||
if(!form)return false;
|
||||
|
||||
@@ -46,5 +46,5 @@ document.addEventListener('submit',async ev=>{const form=ev.target;if(!['team-fu
|
||||
function orderTeamFundsHTML(order){return `<section class="panel"><h2>${e(teamMemberName(order.member))}的经营订单</h2><p class="small muted">利润留在店里,计入${e(teamMemberName(order.member))}的业绩。代收与垫付请到团队账目核对,转款按实际到账另行登记。</p>${button('核对成员往来','goto-team-funds')}</section>`;}
|
||||
function reportTeamDownloadText(report){
|
||||
const summary=report.summary,receipts=report.receiptsByOrderDate;
|
||||
return ['麦麦珠宝三人账 · '+reportPeriod(report),'利润留在店里,按订单归属分别记业绩。经营款各自管理;未导入真实期初经营款。',...peopleCountReportLines(report.peopleCount),'销售净额:'+reportSummaryAmount(summary,'sale'),'本期净利润:'+reportSummaryAmount(summary,'profit'),'本期实收:¥'+yuan(receipts.receipt)+';本期实退:¥'+yuan(receipts.refund),...reportOwnershipReceiptsText(report),...dailyFundsDownloadText(report),...reportRecipientReceiptsText(report),'按实际付款人核对成本',...teamDataKeys(report.payerCosts).flatMap(member=>{const row=report.payerCosts[member];return [teamMemberName(member)+':实际货品支出 '+reportCostAmount(row.goods,row.missingCount)+';已付费用 ¥'+yuan(row.paidFees),...reportCostItems(row).map(item=>item.date+' / '+reportCostIdentity(item)+' / '+item.name+' / '+reportCostItemAmount(item))];}),'订单与售后',...report.orderRows.map(row=>row.date+' / '+(row.paper_number||row.number||row.project)+' / '+(row.customer||'未填客户')+' / '+teamMemberName(row.member)+' / 销售 '+reportRowAmount(row,'sale')+' / 净利润 '+reportRowAmount(row,'profit')),'历史两人结算不计入团队新债务。'].join('\n');
|
||||
return ['麦麦珠宝三人账 · '+reportPeriod(report),'利润留在店里,按订单归属分别记业绩。经营款各自管理;未导入真实期初经营款。',...peopleCountReportLines(report.peopleCount),'销售净额:'+reportSummaryAmount(summary,'sale'),'本期净利润:'+reportSummaryAmount(summary,'profit'),'本期实收:¥'+yuan(receipts.receipt)+';本期实退:¥'+yuan(receipts.refund),...reportDailyProfitsText(report),...reportOwnershipReceiptsText(report),...dailyFundsDownloadText(report),...reportRecipientReceiptsText(report),'按实际付款人核对成本',...teamDataKeys(report.payerCosts).flatMap(member=>{const row=report.payerCosts[member];return [teamMemberName(member)+':实际货品支出 '+reportCostAmount(row.goods,row.missingCount)+';已付费用 ¥'+yuan(row.paidFees),...reportCostItems(row).map(item=>item.date+' / '+reportCostIdentity(item)+' / '+item.name+' / '+reportCostItemAmount(item))];}),'订单与售后',...report.orderRows.map(row=>row.date+' / '+(row.paper_number||row.number||row.project)+' / '+(row.customer||'未填客户')+' / '+teamMemberName(row.member)+' / 销售 '+reportRowAmount(row,'sale')+' / 净利润 '+reportRowAmount(row,'profit')),'历史两人结算不计入团队新债务。'].join('\n');
|
||||
}
|
||||
Reference in new issue
Block a user