Files
weiguang-jewelry-ledger/新账系统/web/dist/assets/materialQuote-B1yI_Tto.js
T

1 line
2.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{r as e,t}from"./format-u4LYCVYL.js";var n=e=>typeof e==`object`&&!!e,r=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,i=e=>e===null||r(e);function a(e){return n(e)&&typeof e.payer==`string`&&r(e.amount)}function o(e){return n(e)&&(e.kind===`personal_recovery`||e.kind===`public`)&&(e.member==null||typeof e.member==`string`)&&r(e.quantity)&&i(e.amount)&&(e.averageRate==null||r(e.averageRate))&&Array.isArray(e.allocations)&&e.allocations.every(a)}function s(e){return n(e)&&r(e.lineIndex)&&typeof e.poolId==`string`&&r(e.mg)&&i(e.amount)&&Array.isArray(e.allocations)&&e.allocations.every(a)&&Array.isArray(e.materialSources)&&e.materialSources.every(o)}function c(e){return n(e)&&r(e.personalRemainingMg)&&r(e.publicRemainingMg)&&r(e.eligibleRemainingMg)}function l(e){return n(e)&&typeof e.poolId==`string`&&typeof e.revision==`string`&&i(e.personalRemainingAmount)&&i(e.publicRemainingAmount)&&(!e.before||c(e.before))&&c(e)}function u(e,t,r){if(!n(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(`分来源料费未完整返回,请刷新料价。`);let i=e.entries;if(!i.every(s))throw Error(`分来源料费与当前商品不一致,请重新核对。`);for(let e of t.entries){let n=i.find(t=>t.lineIndex===e.lineIndex);if(!n||n.poolId!==e.poolId||n.mg!==e.mg||n.materialSources.reduce((e,t)=>e+t.quantity,0)!==n.mg)throw Error(`分来源料费与当前商品不一致,请重新核对。`);for(let e of n.materialSources)if(e.kind===`personal_recovery`&&e.member!==t.member||e.allocations.some(e=>!r.includes(e.payer))||e.amount!==null&&e.allocations.reduce((e,t)=>e+t.amount,0)!==e.amount)throw Error(`个人回收料或付款来源不完整,请重新读取。`);if(n.amount!==null&&(n.materialSources.some(e=>e.amount===null)||n.materialSources.reduce((e,t)=>e+(t.amount??0),0)!==n.amount||n.allocations.reduce((e,t)=>e+t.amount,0)!==n.amount))throw Error(`分来源料费合计不一致,请重新读取。`)}let a=e.pools;if(!a.every(l)||a.length!==new Set(t.entries.map(e=>e.poolId)).size||a.some(e=>!t.entries.some(t=>t.poolId===e.poolId)))throw Error(`个人与公共可用克重未完整返回,请重新读取。`);return{date:t.date,member:t.member,entries:i,pools:a}}function d(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 f(e){return(e.before?`本次前可用:个人 `+t(e.before.personalRemainingMg)+`g,公共 `+t(e.before.publicRemainingMg)+`g;`:``)+`本次后余:个人回收料 `+t(e.personalRemainingMg)+`g,公共料 `+t(e.publicRemainingMg)+`g。`}export{d as n,u as r,f as t};