import{a as e,n as t}from"./index-D-ox0wtk.js";function n(e,t,n){let r=e=>Number.isSafeInteger(e)&&e>=0,i=e=>e===null||r(e);if(!e||e.date!==t.date||e.member!==t.member||!Array.isArray(e.entries)||e.entries.length!==t.entries.length||!Array.isArray(e.pools))throw Error(`分来源料费未完整返回,请刷新料价。`);for(let a of t.entries){let o=e.entries.find(e=>e.lineIndex===a.lineIndex);if(!o||o.poolId!==a.poolId||o.mg!==a.mg||!i(o.amount)||!Array.isArray(o.allocations)||!Array.isArray(o.materialSources)||o.materialSources.reduce((e,t)=>e+t.quantity,0)!==o.mg)throw Error(`分来源料费与当前商品不一致,请重新核对。`);for(let e of o.materialSources)if(![`personal_recovery`,`public`].includes(e.kind)||e.kind===`personal_recovery`&&e.member!==t.member||!r(e.quantity)||!i(e.amount)||!Array.isArray(e.allocations)||e.allocations.some(e=>!n.includes(e.payer)||!r(e.amount))||e.amount!==null&&e.allocations.reduce((e,t)=>e+t.amount,0)!==e.amount)throw Error(`个人回收料或付款来源不完整,请重新读取。`);if(o.amount!==null&&(o.materialSources.some(e=>e.amount===null)||o.materialSources.reduce((e,t)=>e+t.amount,0)!==o.amount||o.allocations.reduce((e,t)=>e+t.amount,0)!==o.amount))throw Error(`分来源料费合计不一致,请重新读取。`)}if(e.pools.length!==new Set(t.entries.map(e=>e.poolId)).size||e.pools.some(e=>!t.entries.some(t=>t.poolId===e.poolId)||![`personalRemainingMg`,`publicRemainingMg`,`eligibleRemainingMg`].every(t=>r(e[t]))||!i(e.personalRemainingAmount)||!i(e.publicRemainingAmount)))throw Error(`个人与公共可用克重未完整返回,请重新读取。`);return e}function r(n=[],r){return n.map(n=>{let i=n.kind===`personal_recovery`?(n.member?r(n.member):`待补`)+`个人回收料`:`公共料`,a=n.amount==null?`料费待补`:`¥`+e(n.amount),o=n.averageRate==null?``:`(加权约 ¥`+e(n.averageRate)+`/克)`;return i+` `+t(n.quantity)+`g · `+a+o}).join(`;`)}function i(e){return(e.before?`本次前可用:个人 `+t(e.before.personalRemainingMg)+`g,公共 `+t(e.before.publicRemainingMg)+`g;`:``)+`本次后余:个人回收料 `+t(e.personalRemainingMg)+`g,公共料 `+t(e.publicRemainingMg)+`g。`}export{r as n,n as r,i as t};