保存工作区合并前的本地开发现场 ledger-route-sizes-389952f
This commit is contained in:
1 parent
389952f31c
commit
9952128ba4
45 files changed
+356
-321
No files matched your search
@@ -0,0 +1 @@
|
||||
import{n as e}from"./rolldown-runtime-Dl_DZoUm.js";import{i as t,t as n}from"./react-1o5M9n0k.js";import{l as r,o as i,s as a,u as o}from"./index-D-ox0wtk.js";import{n as s,r as c}from"./materialQuote--cXNGK6N.js";import{c as l,n as u,o as d,t as f}from"./shared-DZLPF0cC.js";import{f as p,o as m}from"./model-BDHsEKmI.js";var h=e(t(),1),g=n();function _(e,t){let n=(t,n)=>c(t,n,d.memberKeys(e));function r(e,t){let n=t,r=[],i=[];if(!Array.isArray(e.materialSources)||e.materialSources.reduce((e,t)=>e+t.quantity,0)!==e.quantity||e.materialSources.reduce((e,t)=>e+t.amount,0)!==e.amount)throw Error(`原锁分来源克重或成本未完整读到,请重新读取。`);for(let t of e.materialSources){if(![`quantity`,`amount`,`basisAmount`,`basisMg`,`prefixMg`,`prefixAmount`].every(e=>Number.isSafeInteger(t[e])&&t[e]>=0)||!t.basisMg||!Array.isArray(t.allocations)||t.allocations.reduce((e,t)=>e+t.amount,0)!==t.amount)throw Error(`原锁分来源成本未完整读到,请重新读取。`);let e=Math.min(n,t.quantity);if(n-=e,!e){i.push({...t});continue}if(e===t.quantity){r.push({...t});continue}let a=f.poolMaterialAmount(t.basisAmount,t.basisMg,t.prefixMg+e)-t.prefixAmount,o=[],s=[],c=a;for(let e of t.allocations){let t=Math.min(c,e.amount);t&&o.push({...e,amount:t}),e.amount>t&&s.push({...e,amount:e.amount-t}),c-=t}if(c||a<0||a>t.amount)throw Error(`原锁分来源分币未完整读到,请重新读取。`);!a&&!o.length&&o.push({payer:t.allocations[0]?.payer||`owner`,amount:0});let l=[],u=[],d=e;for(let e of t.batches||[]){let t=Math.min(d,e.mg);t&&l.push({...e,mg:t}),e.mg>t&&u.push({...e,mg:e.mg-t}),d-=t}r.push({...t,quantity:e,amount:a,allocations:o,batches:l}),i.push({...t,quantity:t.quantity-e,amount:t.amount-a,allocations:s,batches:u,prefixMg:t.prefixMg+e,prefixAmount:t.prefixAmount+a})}if(n)throw Error(`实际耗料超过原锁来源克重。`);return{taken:r,rest:i}}function i(e){let t=String(e??``).trim();if(!/^\d+(?:\.\d{1,3})?$/.test(t))throw Error(`克重请填写正数,最多3位小数。`);let[n,r=``]=t.split(`.`),i=Number(n)*1e3+Number(r.padEnd(3,`0`));if(!Number.isSafeInteger(i)||i<=0)throw Error(`克重请填写大于0的有效数字。`);return i}function a(e,t,n){if(!z(e))return f.priceLockCost({lockedQuantity:H(e.locked_mg),quantity:t,buyRate:(e.buy_rate/100).toFixed(2),extraBuyRate:n});let a=e.materialPool,o=i(t),s=Math.min(o,e.locked_mg),c=Math.max(0,o-e.locked_mg),l=e.locked_mg-s;if(!a||![`basisAmount`,`basisMg`,`prefixMg`,`prefixAmount`,`amount`].every(e=>Number.isSafeInteger(a[e])&&a[e]>=0)||!a.basisMg)throw Error(`原锁料池成本来源未完整读到,请重新读取锁价单。`);let u=a.materialSources?r(a,s):null,d=u?u.taken.reduce((e,t)=>e+t.amount,0):f.poolMaterialAmount(a.basisAmount,a.basisMg,a.prefixMg+s)-a.prefixAmount,p=c?f.cents(n,`补重进货料价`):0;if(c&&!p)throw Error(`补重进货料价必须大于0。`);let m=c?Number((BigInt(c)*BigInt(p)+500n)/1000n):0,h=d,g=[];for(let t of u?u.taken.flatMap(e=>e.allocations):N(e)){let e=Math.min(h,t.amount);(e||!d&&!g.length)&&g.push({payer:t.payer,amount:e}),h-=e}if(h||d<0||d>a.amount)throw Error(`原锁料池成本分摊不完整,请重新读取锁价单。`);return{lockedMg:e.locked_mg,finalMg:o,originalUsedMg:s,extraMg:c,leftoverMg:l,originalPurchase:a.amount,originalUsedCost:d,extraCost:m,materialCost:d+m,leftoverCost:a.amount-d,allocations:g,...u?{materialSources:u.taken,leftoverMaterialSources:u.rest}:{}}}function o(e){let t=e.line,n=N(e)[0]?.payer||e.buy_payer||`owner`;return{...t,quantity:H(e.locked_mg),goldPrice:(e.sell_rate/100).toFixed(2),laborRate:(t.laborRate/100).toFixed(2),sale:(t.sale/100).toFixed(2),baseSale:((t.baseSale??t.sale)/100).toFixed(2),charges:(t.charges||[]).map(e=>({...e,amount:(e.amount/100).toFixed(2)})),payer:n,costParts:{material:(e.material_amount/100).toFixed(2),labor:``,accessories:`0`,other:`0`},costMaterial:{mode:`total`},costLabor:{mode:`total`},costPayers:{material:n,labor:`owner`}}}function u(e){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:`order-header`,children:[(0,g.jsx)(`div`,{className:`eyebrow`,children:`GOLD PRICE LOCK`}),(0,g.jsxs)(`h2`,{children:[e.customer,` · `,U(e).length,`件黄金锁价`]})]}),_(e),U(e).length===1?E(e):``,(0,g.jsxs)(`p`,{className:`small muted`,children:[`预计报价 ¥`,V(e.estimated_total),`;交付时按最终克重、工费和附加项目重新结算,销售金价保持原锁价格。`]}),e.note?(0,g.jsx)(g.Fragment,{children:(0,g.jsx)(`p`,{children:e.note})}):``,e.status===`cancelled`?(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)(`p`,{className:`note`,children:[`已作废 · `,e.cancelled_reason||`原单记录保留`,(0,g.jsx)(`br`,{}),e.cancelled_at||``]})}):``,(0,g.jsx)(`div`,{className:`actions`,children:e.status===`pending`?(0,g.jsxs)(g.Fragment,{children:[j(`办理交付`,`deliver-price-lock`,`primary`,{"data-id":e.id}),A(e)]}):e.final_order_id?j(`查看销售单`,`open-lock-order`,`primary`,{"data-id":e.final_order_id}):``Line truncated
|
||||
Reference in new issue
Block a user