每日对账展示料池耗用公式与麦麦垫付成本明细
This commit is contained in:
1 parent
9893ecf037
commit
a72f4a276e
7 files changed
+139
-3
No files matched your search
@@ -63,6 +63,8 @@ input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-
|
||||
.report-ownership-equation{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 12px;margin:12px 0;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.report-ownership-equation b{font-weight:550;color:var(--ink)}.report-ownership-equation>strong{color:var(--green);font-weight:650}.report-ownership-accounts{display:flex;flex-wrap:wrap;gap:14px 28px;margin-top:16px;padding-top:14px;border-top:1px solid var(--border)}.report-ownership-account-group{flex:1 1 230px;min-width:0}.report-ownership-account-group h3{font-size:12px;color:var(--muted);font-weight:500;margin:0 0 8px}.report-ownership-account-group ul{list-style:none;padding:0;margin:0;display:grid;gap:9px}.report-ownership-account-group li{display:flex;align-items:baseline;justify-content:space-between;gap:12px;font-size:13px}.report-ownership-account-group li>div{min-width:0;overflow-wrap:anywhere}.report-ownership-account-group li small{display:block;font-size:10px;color:var(--muted);line-height:1.7;margin-top:2px}.report-ownership-account-group li>strong{font-size:14px;font-weight:550;max-width:50%;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.report-ownership-account-group>p{margin:0}.report-ownership-empty{margin-bottom:0}.report-ownership-empty>p{margin:0}@media(max-width:650px){.report-ownership-equation{gap:6px 9px}.report-ownership-accounts{gap:17px}.report-ownership-account-group{flex-basis:100%}}
|
||||
.report-business-cost,.report-business-profit,.report-business-settlement{border-top:1px solid var(--border);margin-top:17px;padding-top:15px;min-width:0}.report-business-cost h3,.report-business-profit h3,.report-business-settlement h3{font-size:13px;font-weight:550;margin:0}.report-business-heading{display:flex;align-items:baseline;flex-wrap:wrap;gap:7px 18px}.report-business-heading h3 .small{margin-left:9px;font-size:11px;font-weight:400}.report-business-heading>strong{font-size:22px;font-weight:600;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.report-business-paid{display:flex;flex-wrap:wrap;gap:10px 32px;margin-top:9px;font-size:13px}.report-business-paid>span{min-width:0;overflow-wrap:anywhere}.report-business-paid b{font-size:15px;font-weight:550;margin-left:5px;font-variant-numeric:tabular-nums}.report-business-paid small{display:block;font-size:11px;color:var(--muted);margin-top:4px}.report-business-profit{padding:13px 15px;background:#f1f5ed;border:1px solid #dce5d5;border-radius:7px}.report-business-profit-equation,.report-business-balance-equation{display:flex;align-items:baseline;flex-wrap:wrap;gap:5px 10px;font-size:13px;line-height:1.8;font-variant-numeric:tabular-nums;margin:7px 0 0;overflow-wrap:anywhere}.report-business-profit-equation b,.report-business-balance-equation b{font-weight:500}.report-business-profit-equation>strong{font-size:25px;font-weight:650;color:var(--green)}.report-business-profit-equation>strong.danger-text{color:var(--danger)}.report-business-profit-pending{display:block;font-size:22px;font-weight:600;margin-top:8px}.report-business-profit>p.small{margin:7px 0 0}.report-business-difference{font-size:11px;color:var(--muted);line-height:1.8;margin-top:9px}.report-business-difference p{margin:0}.report-business-difference ul{padding-left:17px;margin:5px 0 0}.report-business-dues{display:flex;flex-wrap:wrap;gap:12px 32px;margin-top:9px}.report-business-dues>div{display:flex;align-items:baseline;gap:10px;min-width:0;flex-wrap:wrap}.report-business-dues span{font-size:12px;color:var(--muted)}.report-business-dues strong{font-size:19px;font-weight:600;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.report-business-settlement-notice{margin:9px 0 0;line-height:1.7;font-size:11px}.report-business-period{margin:9px 0 0;font-size:11px;color:var(--muted);line-height:1.8;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}.report-business-period p{margin:3px 0 0}.report-business-counterparts{margin:13px 0 0}.report-business-counterparts>summary{font-size:12px;font-weight:500}.report-business-counterparts>section{border-top:1px solid var(--border);margin-top:12px;padding-top:12px}.report-business-counterparts h4{font-size:13px;font-weight:550;margin:0 0 6px}.report-business-counterparts p.small{margin:6px 0 0}.report-business-balance-equation{font-size:11px;gap:4px 8px}.report-business-balance-equation strong{font-weight:600}@media(max-width:650px){.report-business-heading{gap:6px 12px}.report-business-paid{gap:9px 18px}.report-business-profit{padding:12px}.report-business-profit-equation{font-size:12px}.report-business-profit-equation>strong{font-size:23px}.report-business-dues{gap:11px 20px}.report-business-dues>div{flex:1 1 175px}.report-business-balance-equation>span{max-width:100%}}
|
||||
|
||||
.report-pool-material{margin-top:13px;padding:12px 14px;background:var(--soft);border:1px solid var(--border);border-radius:7px;font-size:12px;font-variant-numeric:tabular-nums;overflow-wrap:anywhere}.report-pool-material-heading{display:flex;align-items:baseline;gap:7px 16px;flex-wrap:wrap}.report-pool-material-heading>strong{font-size:18px;font-weight:600;color:var(--green)}.report-pool-material ul{list-style:none;padding:0;margin:9px 0;display:grid;gap:6px}.report-pool-material li{display:flex;align-items:baseline;flex-wrap:wrap;gap:3px 14px;line-height:1.8}.report-pool-material li>span{color:var(--muted)}.report-pool-material li>strong{font-weight:500}.report-pool-material p{margin:7px 0 0;line-height:1.7}.report-pool-material p b{font-size:14px;font-weight:550;margin-left:7px}.report-pool-material .small{font-size:11px}.report-pool-material .report-owner-advance{font-weight:550;line-height:1.9}@media(max-width:650px){.report-pool-material{padding:10px 11px}.report-pool-material li{display:block}.report-pool-material li>strong{display:block}}
|
||||
|
||||
/* 售后只登记实际费用,与销售订单同表查看。 */
|
||||
#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}}
|
||||
|
||||
+34
-2
@@ -1423,9 +1423,28 @@ function reportOwnershipAccountsHTML(person){
|
||||
return `<p class="report-ownership-equation"><span>本人收款净额 <b>¥${yuan(net(ownAccounts))}</b></span><span aria-hidden="true">+</span><span>${otherAccounts.length===1?e(otherAccounts[0].account)+'代收':'他人代收'}净额 <b>¥${yuan(net(otherAccounts))}</b></span><span aria-hidden="true">=</span><strong>¥${yuan(person.net)}</strong></p><div class="report-ownership-accounts">${group('本人收款',ownAccounts)}${group('他人代收',otherAccounts)}</div>`;
|
||||
}
|
||||
function reportBusinessAmount(value,known){return (value===null?'已知 ':'')+'¥'+yuan(value===null?known:value);}
|
||||
function reportPoolMaterialFormula(day){
|
||||
return `${grams(day.mg)}g × ${day.averageRate===null?'待补料价':'¥'+yuan(day.averageRate)+'/g'} = ${day.amount===null?'料费待补(已知 ¥'+yuan(day.knownAmount)+')':'¥'+yuan(day.amount)}`;
|
||||
}
|
||||
function reportOwnerPoolAdvance(business){
|
||||
const pool=business.poolMaterial;if(business.member==='owner'||!pool?.days.length)return '';
|
||||
const payer=business.costByPayer.owner,material=pool.byPayer.owner,other=payer.totalCost===null||material.amount===null?null:payer.totalCost-material.amount;
|
||||
const term=(value,known)=>value===null?'待补(已知 ¥'+yuan(known)+')':'¥'+yuan(value);
|
||||
return `麦麦垫付合计:料费 ${term(material.amount,material.knownAmount)} + 其他成本 ${term(other,payer.knownTotalCost-material.knownAmount)} = ${term(other===null?null:payer.totalCost,payer.knownTotalCost)}`;
|
||||
}
|
||||
function reportPoolMaterialHTML(business){
|
||||
const pool=business.poolMaterial;if(!pool?.days.length)return '';
|
||||
const owner=pool.byPayer.owner,ownerAdvance=reportOwnerPoolAdvance(business);
|
||||
return `<div class="report-pool-material" aria-label="${e(business.name)}所属订单料池用料"><div class="report-pool-material-heading"><span>料池已用料费</span><strong>${e(reportBusinessAmount(pool.amount,pool.knownAmount))}</strong>${pool.missingCount?'<span class="badge warn">料费待补</span>':''}</div><ul>${pool.days.map(day=>`<li><span>${e(day.date)} 料池</span><strong>${e(reportPoolMaterialFormula(day))}</strong></li>`).join('')}</ul><p>其中麦麦垫付 <b>${e(reportBusinessAmount(owner.amount,owner.knownAmount))}</b></p><p>其他成本 <b>${e(reportBusinessAmount(pool.otherCosts.amount,pool.otherCosts.knownAmount))}</b><small class="muted">(其余商品成本、工费与费用)</small></p>${ownerAdvance?`<p class="report-owner-advance">${e(ownerAdvance)}</p>`:''}<p class="small muted">料费已计入总成本,已记入待转的部分不再另加。按未四舍五入均价逐单核算,显示料价相乘可能有分币差。${pool.hasPriceLocks?'锁价料费按原预留与回料日期记往来,交付日不再加一次。':''}</p></div>`;
|
||||
}
|
||||
function reportPoolMaterialText(business){
|
||||
const pool=business.poolMaterial;if(!pool?.days.length)return [];
|
||||
const owner=pool.byPayer.owner,ownerAdvance=reportOwnerPoolAdvance(business);
|
||||
return [`料池已用料费:${reportBusinessAmount(pool.amount,pool.knownAmount)}(已计入总成本,已记入待转的部分不再另加)`,...pool.days.map(day=>`${day.date} 料池:${reportPoolMaterialFormula(day)}`),`其中麦麦垫付:${reportBusinessAmount(owner.amount,owner.knownAmount)}`,`其他成本:${reportBusinessAmount(pool.otherCosts.amount,pool.otherCosts.knownAmount)}(其余商品成本、工费与费用)`,...(ownerAdvance?[ownerAdvance]:[]),'料费按未四舍五入均价逐单核算,显示料价相乘可能有分币差。',...(pool.hasPriceLocks?['锁价料费按原预留与回料日期记往来,交付日不再加一次。']:[])];
|
||||
}
|
||||
function reportOwnershipCostHTML(business){
|
||||
const showPayers=business.knownTotalCost!==0||business.totalCost===null,others=teamMemberKeys.filter(key=>key!==business.member).map(key=>business.costByPayer[key]).filter(payer=>payer.knownTotalCost!==0||payer.totalCost===null);
|
||||
return `<section class="report-business-cost" aria-label="${e(business.name)}所属订单成本"><div class="report-business-heading"><h3>所属订单总成本${business.afterSaleCount?`<span class="small muted">含售后 ${business.afterSaleCount} 笔</span>`:''}</h3><strong>${e(reportBusinessAmount(business.totalCost,business.knownTotalCost))}</strong>${business.totalCost===null?'<span class="badge warn">成本待补齐</span>':''}</div>${showPayers?`<div class="report-business-paid"><span>本人付款 <b>${e(reportBusinessAmount(business.selfCost,business.knownSelfCost))}</b></span><span>他人付款 <b>${e(reportBusinessAmount(business.otherCost,business.knownOtherCost))}</b>${others.length?`<small>${others.map(payer=>`${e(payer.name)} ${e(reportBusinessAmount(payer.totalCost,payer.knownTotalCost))}`).join(';')}</small>`:''}</span></div>`:''}</section>`;
|
||||
return `<section class="report-business-cost" aria-label="${e(business.name)}所属订单成本"><div class="report-business-heading"><h3>所属订单总成本${business.afterSaleCount?`<span class="small muted">含售后 ${business.afterSaleCount} 笔</span>`:''}</h3><strong>${e(reportBusinessAmount(business.totalCost,business.knownTotalCost))}</strong>${business.totalCost===null?'<span class="badge warn">成本待补齐</span>':''}</div>${reportPoolMaterialHTML(business)}${showPayers?`<div class="report-business-paid"><span>本人付款 <b>${e(reportBusinessAmount(business.selfCost,business.knownSelfCost))}</b></span><span>他人付款 <b>${e(reportBusinessAmount(business.otherCost,business.knownOtherCost))}</b>${others.length?`<small>${others.map(payer=>`${e(payer.name)} ${e(reportBusinessAmount(payer.totalCost,payer.knownTotalCost))}`).join(';')}</small>`:''}</span></div>`:''}</section>`;
|
||||
}
|
||||
function reportOwnershipProfitHTML(business,range){
|
||||
const equation=business.equation,title=reportMonth||range.from!==range.date?'本期利润':'当日利润',complete=equation.complete&&!business.incomplete&&business.totalCost!==null&&business.profit!==null,revenue=equation.basis==='netReceipts'?'所属订单净收入':'销售净额',difference=business.difference;
|
||||
@@ -1445,7 +1464,7 @@ function reportOwnershipReceiptsHTML(r,range){
|
||||
}
|
||||
function reportOwnershipBusinessText(business){
|
||||
const settlement=business.settlement;
|
||||
return [`所属订单总成本:${reportBusinessAmount(business.totalCost,business.knownTotalCost)};本人付款 ${reportBusinessAmount(business.selfCost,business.knownSelfCost)};他人付款 ${reportBusinessAmount(business.otherCost,business.knownOtherCost)}`,...teamMemberKeys.filter(key=>key!==business.member).map(key=>business.costByPayer[key]).filter(payer=>payer.knownTotalCost||payer.totalCost===null).map(payer=>`${payer.name}付款:${reportBusinessAmount(payer.totalCost,payer.knownTotalCost)}`),`本期利润:${business.equation.complete&&!business.incomplete&&business.profit!==null?'¥'+yuan(business.profit):'待核算,完整利润暂不显示'}`,...business.difference.reasons.map(reason=>reason.text),`截至 ${settlement.date} 待转:${settlement.available?(settlement.partial?'已知 ':'')+'本人应转他人 ¥'+yuan(settlement.dueOut)+';他人应转本人 ¥'+yuan(settlement.dueIn):'待核对历史结算,暂不显示金额'}`,...settlement.counterparts.filter(row=>row.openingDue||row.periodNew||row.periodTransferred||row.closingDue).map(row=>`${row.name}往来(正数本人转出,负数本人转入):此前 ${reportSettlementTerm(row.openingDue)} + 本期新增 ${reportSettlementTerm(row.periodNew)} − 本期实际已转 ${reportSettlementTerm(row.periodTransferred)} = 截至所选日 ${reportSettlementTerm(row.closingDue)}`),settlement.notice||''];
|
||||
return [`所属订单总成本:${reportBusinessAmount(business.totalCost,business.knownTotalCost)};本人付款 ${reportBusinessAmount(business.selfCost,business.knownSelfCost)};他人付款 ${reportBusinessAmount(business.otherCost,business.knownOtherCost)}`,...reportPoolMaterialText(business),...teamMemberKeys.filter(key=>key!==business.member).map(key=>business.costByPayer[key]).filter(payer=>payer.knownTotalCost||payer.totalCost===null).map(payer=>`${payer.name}付款:${reportBusinessAmount(payer.totalCost,payer.knownTotalCost)}`),`本期利润:${business.equation.complete&&!business.incomplete&&business.profit!==null?'¥'+yuan(business.profit):'待核算,完整利润暂不显示'}`,...business.difference.reasons.map(reason=>reason.text),`截至 ${settlement.date} 待转:${settlement.available?(settlement.partial?'已知 ':'')+'本人应转他人 ¥'+yuan(settlement.dueOut)+';他人应转本人 ¥'+yuan(settlement.dueIn):'待核对历史结算,暂不显示金额'}`,...settlement.counterparts.filter(row=>row.openingDue||row.periodNew||row.periodTransferred||row.closingDue).map(row=>`${row.name}往来(正数本人转出,负数本人转入):此前 ${reportSettlementTerm(row.openingDue)} + 本期新增 ${reportSettlementTerm(row.periodNew)} − 本期实际已转 ${reportSettlementTerm(row.periodTransferred)} = 截至所选日 ${reportSettlementTerm(row.closingDue)}`),settlement.notice||''];
|
||||
}
|
||||
function reportOwnershipReceiptsText(r){
|
||||
return ['按订单归属核对净收入(收款减退款,已含他人代收,尚未扣成本与费用)',...reportOwnershipKeys(r).flatMap(key=>{const person=r.ownershipReceipts[key];return [`${person.name}所属订单净收入:¥${yuan(person.net)};实收 ¥${yuan(person.receipt)};实退 ¥${yuan(person.refund)}`,...person.accounts.map(account=>`${account.recipient===person.member?'本人收款':'他人代收'} / ${account.account}:实收 ¥${yuan(account.receipt)},实退 ¥${yuan(account.refund)},净额 ¥${yuan(account.net)}`),...reportOwnershipBusinessText(r.ownershipBusiness[key]),''];})];
|
||||
@@ -1493,6 +1512,18 @@ function validateOwnershipReceipts(r){
|
||||
const identity=item=>JSON.stringify([item.id,item.kind,item.amount,item.account,item.date,item.order_id,item.price_lock_id]),actual=teamDataKeys(r.recipientReceipts).flatMap(key=>r.recipientReceipts[key].items).map(identity).sort(),copies=owned.map(identity).sort();
|
||||
if(actual.length!==copies.length||actual.some((value,index)=>value!==copies[index]))fail();
|
||||
}
|
||||
function validatePoolMaterialCosts(b,fail){
|
||||
const count=value=>Number.isSafeInteger(value)&&value>=0,nullable=value=>value===null||count(value),pool=b.poolMaterial;
|
||||
const valid=value=>value&&['mg','knownAmount','missingCount'].every(key=>count(value[key]))&&nullable(value.amount)&&value.amount===(value.missingCount?null:value.knownAmount)&&value.byPayer&&Object.keys(value.byPayer).length===teamMemberKeys.length&&teamMemberKeys.every(key=>{
|
||||
const payer=value.byPayer[key];return payer&&count(payer.knownAmount)&&nullable(payer.amount)&&payer.amount===(value.missingCount?null:payer.knownAmount);
|
||||
})&&teamMemberKeys.reduce((sum,key)=>sum+value.byPayer[key].knownAmount,0)===value.knownAmount;
|
||||
if(!valid(pool)||typeof pool.hasPriceLocks!=='boolean'||!Array.isArray(pool.days)||pool.missingCount>b.missingCostCount||!pool.otherCosts||!count(pool.otherCosts.knownAmount)||!nullable(pool.otherCosts.amount)||pool.otherCosts.amount!==null&&pool.otherCosts.amount!==pool.otherCosts.knownAmount)fail();
|
||||
const seen=new Set();for(const day of pool.days){
|
||||
if(!valid(day)||day.mg<=0||!/^\d{4}-\d{2}-\d{2}$/.test(day.poolId)||day.date!==day.poolId||!nullable(day.averageRate))fail();
|
||||
const key=day.poolId+':'+day.averageRate;if(seen.has(key))fail();seen.add(key);
|
||||
}
|
||||
if(['mg','knownAmount','missingCount'].some(key=>pool.days.reduce((sum,day)=>sum+day[key],0)!==pool[key])||teamMemberKeys.some(key=>pool.days.reduce((sum,day)=>sum+day.byPayer[key].knownAmount,0)!==pool.byPayer[key].knownAmount||pool.byPayer[key].knownAmount>b.costByPayer[key].knownTotalCost)||pool.knownAmount+pool.otherCosts.knownAmount!==b.knownTotalCost||b.totalCost!==null&&(pool.amount===null||pool.otherCosts.amount===null||pool.amount+pool.otherCosts.amount!==b.totalCost))fail();
|
||||
}
|
||||
function validateOwnershipBusiness(r){
|
||||
const fail=()=>{throw new Error('所属订单成本、利润或待转资料未完整返回,请重新读取。');},money=value=>Number.isSafeInteger(value),nullable=value=>value===null||money(value),count=value=>money(value)&&value>=0,keys=teamDataKeys(r.ownershipReceipts);
|
||||
if(!r.ownershipBusiness||typeof r.ownershipBusiness!=='object'||Array.isArray(r.ownershipBusiness)||Object.keys(r.ownershipBusiness).length!==keys.length||!keys.every(key=>Object.hasOwn(r.ownershipBusiness,key)))fail();
|
||||
@@ -1502,6 +1533,7 @@ function validateOwnershipBusiness(r){
|
||||
if(!b.costByPayer||Object.keys(b.costByPayer).length!==teamMemberKeys.length)fail();
|
||||
for(const payer of teamMemberKeys){const row=b.costByPayer[payer];if(!row||row.member!==payer||typeof row.name!=='string'||!row.name||!nullable(row.totalCost)||!money(row.knownTotalCost)||!count(row.missingCount)||!count(row.pendingCount)||row.totalCost!==null&&row.totalCost!==row.knownTotalCost)fail();}
|
||||
if(teamMemberKeys.reduce((total,key)=>total+b.costByPayer[key].knownTotalCost,0)!==b.knownTotalCost||b.costByPayer[member].knownTotalCost!==b.knownSelfCost||teamMemberKeys.reduce((total,key)=>total+b.costByPayer[key].missingCount,0)!==b.missingCostCount||teamMemberKeys.reduce((total,key)=>total+b.costByPayer[key].pendingCount,0)!==b.pendingCostCount)fail();
|
||||
validatePoolMaterialCosts(b,fail);
|
||||
const difference=b.difference,equation=b.equation,settlement=b.settlement;
|
||||
if(!difference||difference.amount!==b.netReceipts-b.sales||typeof difference.reconciled!=='boolean'||!Array.isArray(difference.reasons)||!difference.reasons.every(reason=>reason&&typeof reason.code==='string'&&typeof reason.text==='string'))fail();
|
||||
if(!equation||!['netReceipts','sales'].includes(equation.basis)||equation.revenue!==(equation.basis==='netReceipts'?b.netReceipts:b.sales)||equation.totalCost!==b.totalCost||equation.profit!==b.profit||typeof equation.complete!=='boolean'||equation.complete&&(!money(equation.totalCost)||!money(equation.profit)||equation.revenue-equation.totalCost!==equation.profit))fail();
|
||||
|
||||
Reference in new issue
Block a user