PageSourceSearch

https://app.upmetrics.co/chunks/DO5yRNqh.js

js upmetrics.co collected 2026-10-01 11:52:28 UTC 9,897 bytes, 1 lines download raw bytes

1import{r as I,j as o}from"./Dem1e8VV.js";import{d as W}from"./dWhdajSv.js";import{u as v,ay as Y,cC as z,cD as J,aM as q,aN as R,y as Q,cj as Z,aK as ee}from"../entry/CcVTEBpa.js";import"./BnZNklX7.js";import{P as te,a as se,A as ne,b as re,t as ae,c as w,d as K,G as U,E as oe,R as ie,s as le,F as ce,e as de,f as ue}from"./D4uaOMhM.js";import{S as pe}from"./CN-sS7h1.js";import"./phrJN640.js";import{F as Se,u as k}from"./CTibiPUG.js";import{u as me,r as Ae}from"./CJcZnSSQ.js";import{A as Ee}from"./CKTnXhDW.js";import{T as F,V as fe}from"./BdhxqbeK.js";import"./Dh95b2SR.js";import"./Cscm7JI5.js";const X={capitalSpend:"ASSETS_PLAN.CHART_CAPITAL_SPEND",depreciation:"ASSETS_PLAN.CHART_DEPRECIATION",bookValue:"ASSETS_PLAN.CHART_BOOK_VALUE"},G=le("assets","capitalSpend",X);function _e(e){const{businessId:c,projection:m,year:h}=W(),d=v(),{humanizeCompactInteger:i}=Y(),[u,n]=I.useState("capitalSpend");I.useEffect(()=>{c&&n(G.get(c))},[c]);const{assets:s,labels:t,spendSeries:A,depreciationSeries:p,bookValueSeries:T,actualBookValueSeries:f}=e,O=I.useMemo(()=>{if(u==="bookValue"){const l={name:d("ASSETS_PLAN.CHART_BOOK_VALUE"),data:T,dataType:"plannedData",key:"closingBalance",color:se,fillColor:te,legendName:d("COMP_ASSETS.PLANNED")};return f!=null&&f.some(g=>g!=null)?[l,{...l,name:`${d("ASSETS_PLAN.CHART_BOOK_VALUE")} (${d("COMP_ASSETS.ACTUAL")})`,data:f,dataType:"actualData",color:re,fillColor:ne,legendName:d("COMP_ASSETS.ACTUAL")}]:[l]}const N=u==="capitalSpend"?A.seriesByItem:p.seriesByItem;return s.filter(l=>{var g;return((g=N[l.id])!=null?g:[]).some(L=>L!==0)}).map(l=>{var g;return{name:l.name,data:(g=N[l.id])!=null?g:[],dataType:"plannedData",key:l.id,color:l.color,legendName:l.name}})},[u,s,A,p,T,f,d]),M=I.useMemo(()=>{if(!t.length)return{};const E=u==="bookValue",N=E?"area":"column",l=E&&!!(f!=null&&f.some(L=>L!=null)),g=ae(O,N);return{chart:{type:N,spacingBottom:0},title:{text:void 0},xAxis:{categories:t,gridLineWidth:1,gridLineColor:U,gridLineDashStyle:"Dash",lineWidth:0,labels:{style:{color:K}}},yAxis:{gridLineWidth:1,gridLineColor:U,gridLineDashStyle:"Dash",lineWidth:0,labels:{formatter:function(){return i(this.value,2,!0)},style:{color:K}},title:{text:""}},tooltip:{useHTML:!0,shared:!0,backgroundColor:"transparent",borderWidth:0,shadow:!1,padding:0,formatter:function(){if(!this.points||this.points.length===0)return"";const L=this.points[0].category,C=oe(this.points);let P;if(!E){let S=0;Object.values(C).forEach(x=>{var b;S+=(b=x.planned)!=null?b:0}),P={label:d(u==="capitalSpend"?"ASSETS_PLAN.CHART_CAPITAL_SPEND":"ASSETS_PLAN.CHART_DEPRECIATION"),planned:S}}return ie(L,C,l,d,i,P)}},legend:{enabled:!0,margin:6,padding:4,itemDistance:18,labelFormatter:function(){return this.userOptions.legendName||this.name}},credits:{enabled:!1},plotOptions:{area:{marker:{radius:4,lineWidth:2,lineColor:w},fillOpacity:.2},column:{borderWidth:2,borderColor:w,borderRadius:2,groupPadding:.1,stacking:"normal"}},series:g,accessibility:{enabled:!1}}},[O,t,u]),_=I.useCallback(E=>{n(E),c&&G.set(c,E)},[c]);return{selectedOption:u,handleOptionChange:_,chartOptions:M,chartKey:`${c}-${m}-${h}`}}const B={"metaInfo.type":{$in:Ee}},D=e=>e&&e.length?e[e.length-1]:0,V=e=>(e!=null?e:[]).reduce((c,m)=>c+(m||0),0);function ge(){const{businessId:e,projection:c,year:m}=W(),h=z(),d=J(),i=I.useMemo(()=>h.getDataFilterMeta(e,c,m),[e,c,m]),{dataKeys:u}=I.useMemo(()=>d.getColumnAndKeys(e,i),[e,i]),n=u.join("|"),s=me({groupCollection:q,itemCollection:R,seriesKey:Se.asset.seriesKey,itemFields:{isSetupPending:1},filter:B,groupFilter:{type:"capEx"}}),t=k({collection:R,seriesKey:"capitalInvestments",filter:B},[]),A=k({collection:R,seriesKey:"depreciation",filter:B},[]),p=k({collection:R,seriesKey:"accumulatedDepreciation",filter:B},[]),T=Q(()=>Z.findOne({businessId:e},{fields:{"actualData.grossLongTermAssets":1,"actualData.accumulatedDepreciation":1}}),[e]),f=I.useMemo(()=>{var C,P;const _=(C=T==null?void 0:T.actualData)==null?void 0:C.grossLongTermAssets,E=(P=T==null?void 0:T.actualData)==null?void 0:P.accumulatedDepreciation;if(!_)return{series:void 0,periods:0,total:0};const N=(S,x)=>{var b;return(b=(S!=null?S:{})[x])!=null?b:0},l=u.map(S=>Object.prototype.hasOwnProperty.call(_,S)?N(_,S)-N(E,S):null),g=l.filter(S=>S!==null).length,L=[...l].reverse().find(S=>S!==null);return{series:g?l:void 0,periods:g,total:L!=null?L:0}},[T,n]),O=s.items.map(_=>{var E;return`${_._id}:${JSON.stringify((E=_.metaInfo)!=null?E:{})}`}).join("|"),M=I.useMemo(()=>{const _=Object.keys(s.seriesByGroup).reduce((r,a)=>r+D(s.seriesByGroup[a]),0);let E=0,N=0,l=0;
1s.items.forEach(r=>{var j;const a=(j=r.metaInfo)!=null?j:{},y=D(s.seriesByItem[r._id]);a.type==="currentAssets"?N+=y:E+=y,a.noDepreciation&&(l+=y)});const g=Object.keys(t.seriesByItem).reduce((r,a)=>r+V(t.seriesByItem[a]),0),L=Object.keys(A.seriesByItem).reduce((r,a)=>r+V(A.seriesByItem[a]),0),C=Object.keys(p.seriesByItem).reduce((r,a)=>r+D(p.seriesByItem[a]),0),P=_+C,S=s.groups.length>1,x=Ae(s.items,{nameOf:r=>{var a;return((a=r.metaInfo)==null?void 0:a.name)||""},valueOf:r=>D(s.seriesByItem[r._id]),colorOf:S?r=>{var a;return(a=s.groups.find(y=>y.id===r.groupId))==null?void 0:a.color}:void 0}),b=s.groups.map(r=>{const a=D(s.seriesByGroup[r.id]);return{...r,total:a,share:_>0?a/_*100:0}}).sort((r,a)=>a.total-r.total);return{bookValue:_,fixed:E,current:N,notDepreciated:l,spend:g,depreciation:L,cost:P,writtenOff:C,lifeRemaining:P>0?_/P*100:null,bookValueSeries:Object.keys(s.seriesByGroup).reduce((r,a)=>{var y;return((y=s.seriesByGroup[a])!=null?y:[]).forEach((j,$)=>{var H;r[$]=((H=r[$])!=null?H:0)+j}),r},[]),spendSeries:t,depreciationSeries:A,assets:x,assetGroups:b,largest:x[0]}},[O,s.seriesByGroup,s.seriesByItem,s.groups,t,A,p]);return{...s,...M,actualBookValueSeries:f.series,actualBookValue:f.total,recordedBookValuePeriods:f.periods}}function Te({items:e,bookValueOf:c,notDepreciated:m,bookValue:h,spend:d,depreciation:i}){const u=e.map(n=>{var s;return`${n._id}:${n.isSetupPending}:${JSON.stringify((s=n.metaInfo)!=null?s:{})}`}).join("|");return I.useMemo(()=>{const n=[];if(!e.length)return n;const s=t=>{var A;return((A=t.metaInfo)==null?void 0:A.name)||""};return e.forEach(t=>{var A,p;if(t.isSetupPending){n.push({id:`unfinished:${t._id}`,rowId:t._id,subject:s(t),message:"NOTE_NEEDS_SETUP"});return}(A=t.metaInfo)!=null&&A.noDepreciation&&n.push({id:`nodep:${t._id}`,rowId:t._id,subject:s(t),message:"NOTE_NO_DEPRECIATION"}),!((p=t.metaInfo)!=null&&p.noDepreciation)&&c(t._id)===0&&n.push({id:`spent:${t._id}`,rowId:t._id,subject:s(t),message:"NOTE_FULLY_DEPRECIATED"})}),h>0&&m/h>=.5&&n.push({id:"mostly-not-depreciated",subject:"",message:"NOTE_MOSTLY_NOT_DEPRECIATED"}),i>0&&d===0&&n.push({id:"no-replacement",subject:"",message:"NOTE_NO_REPLACEMENT"}),n},[u,m,h,d,i])}function he({bookValue:e,scopeLabel:c,itemCount:m,cost:h,lifeRemaining:d,spend:i,depreciation:u,actualBookValue:n,recordedPeriods:s}){const t=v(),{formatCompactNumber:A}=ee(),p=O=>A(O,1,!0),T=O=>`${O.toFixed(O%1===0?0:1)}%`,f=s&&n!=null&&e?(n-e)/Math.abs(e)*100:null;return o.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[o.jsxs(F,{label:`${t("ASSETS_PLAN.TOTAL_BOOK_VALUE")} · ${c}`,note:m?t("ASSETS_PLAN.ACROSS_ASSETS",{count:m}):void 0,children:[o.jsx("span",{className:"text-2xl font-bold tabular-nums tracking-tight text-foreground",children:m?p(e):"—"}),!!s&&n!=null&&o.jsxs("span",{className:"mt-1 flex items-center gap-x-3",children:[o.jsxs("span",{className:"text-xs text-muted-foreground",children:[t("COMP_ASSETS.ACTUAL")," ",o.jsx("span",{className:"font-semibold tabular-nums text-foreground",children:p(n)})]}),o.jsx(fe,{value:f,higherIsBetter:!0})]})]}),o.jsx(F,{label:t("ASSETS_PLAN.LIFE_REMAINING"),note:d==null?t("ASSETS_PLAN.LIFE_NEEDS_ASSETS"):o.jsxs(o.Fragment,{children:[p(e)," ",t("ASSETS_PLAN.OF_COST",{cost:""}),p(h)]}),children:o.jsx("span",{className:"text-lg font-semibold tabular-nums text-foreground",children:d==null?"—":T(d)})}),o.jsx(F,{label:t("ASSETS_PLAN.CAPITAL_SPEND"),note:t("ASSETS_PLAN.SPEND_HINT"),children:o.jsx("span",{className:"text-lg font-semibold tabular-nums text-foreground",children:i>0?p(i):"—"})}),o.jsx(F,{label:t("ASSETS_PLAN.DEPRECIATION_SCOPED"),note:t("ASSETS_PLAN.DEPRECIATION_HINT"),children:o.jsx("span",{className:"text-lg font-semibold tabular-nums text-foreground",children:u>0?p(u):"—"})})]})}function Be(){const e=ge(),{selectedOption:c,handleOptionChange:m,chartOptions:h,chartKey:d}=_e(e),i=v(),u=Te({items:e.items,bookValueOf:n=>{var t;const s=(t=e.seriesByItem[n])!=null?t:[];return s.length?s[s.length-1]:0},notDepreciated:e.notDepreciated,bookValue:e.bookValue,spend:e.spend,depreciation:e.depreciation});return e.isUnstarted?null:o.jsxs("div",{className:"space-y-4",children:[o.jsx(he,{bookValue:e.bookValue,scopeLabel:e.scopeLabel,itemCount:e.itemCount,cost:e.cost,lifeRemaining:e.lifeRemaining,spend:e.spend,depreciation:e.depreciation,actualBookValue:e.actualBookValue,recordedPeriods:e.recordedBookValuePeriods}),o.jsx(ce,{notes:u,i18n:"ASSETS_PLAN"}),o.jsxs("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-[2fr_1fr] [&>*]:min-w-0",children:[o.jsx(de,{isEmpty:!e.hasRows,chartOptions:h,options:X,selectedOption:c,onOptionChange:m,chartKey:`${d}:${c}`}),o.jsxs("div",{className:"flex flex-col gap-4 xl:h-0 xl:min-h-full",children:[o.jsx(ue,{className:"flex-1",groups:e.assets,alternate:{rows:e.assetGroups,groupLabel:i("ASSETS_PLAN.MIX_BY_ASSET",{raw:!0}),rowLabel:i("ASSETS_PLAN.MIX_BY_GROUP",{raw:!0})},title:i("ASSETS_PLAN.ASSET_MIX"),scopeLabel:e.scopeLabel,emptyLabel:i("ASSETS_PLAN.MIX_EMPTY",{raw:!0})}),o.jsx(pe,{title:i("ASSETS_PLAN.FIXED_VS_CURRENT"),segments:[{label:i("ASSETS_PLAN.FIXED",{raw:!0}),value:e.fixed},{label:i("ASSETS_PLAN.CURRENT",{raw:!0}),value:e.current}],hint:n=>i("ASSETS_PLAN.FIXED_SHARE_HINT",{percent:n.toFixed(0)})})]})]})]})}export{Be as OverviewComponent};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.