1import{r as I,j as d}from"./Dem1e8VV.js";import{d as W}from"./CNFvtpL4.js";import{u as V,ay as oe,c2 as le,dU as re,cA as ie,cB as ce,y as J,ci as de,g4 as ue,aL as Le,aK as Ae}from"../entry/whq2ljq-.js";import"./BnZNklX7.js";import{P as pe,a as M,A as fe,b as Pe,t as me,c as Q,d as Z,G as ee,E as Oe,R as _e,s as Ne,g as he,S as te,F as Te,e as Re,f as Se}from"./DR1JvnZi.js";import{S as Ee}from"./D0_jY_ez.js";import{o as ge,r as ye,T as w,V as Ce}from"./BtOoKPxr.js";import"./phrJN640.js";import{F as De}from"./DDMThJ-o.js";import{u as be,r as Ie}from"./DYloDeCX.js";import{m as k}from"./DFFJHtLE.js";import"./Dh95b2SR.js";import"./BS4HFmLj.js";const se={totalSalary:"PAYROLL_PLAN.CHART_TOTAL",byTeam:"PAYROLL_PLAN.CHART_BY_TEAM",directIndirect:"PAYROLL_PLAN.CHART_DIRECT_INDIRECT",salaryBenefits:"PAYROLL_PLAN.CHART_SALARY_BENEFITS",headcount:"PAYROLL_PLAN.CHART_HEADCOUNT"},ae=Ne("payroll","totalSalary",se);function xe(e){const{businessId:L,projection:N,year:r}=W(),s=V(),{humanizeCompactInteger:T}=oe(),[o,R]=I.useState("byTeam");I.useEffect(()=>{L&&R(ae.get(L))},[L]);const{groups:c,seriesByGroup:f,actualSeriesByGroup:O,hasActuals:h,recordedIndices:A,labels:a,directSeries:t,indirectSeries:n,basicSalarySeries:u,benefitsSeries:y,headcountSeries:_,actualDirectSeries:D,actualIndirectSeries:S,actualBasicSalarySeries:H,actualBenefitsSeries:j,totalSalarySeries:B,actualTotalSalarySeries:E}=e,F=o==="totalSalary"||o==="directIndirect"||o==="salaryBenefits",x=(P,p,C,g,l)=>{const i={name:P,data:g,dataType:"plannedData",key:p,color:C,stack:"planned",legendName:P};return!h||!(l!=null&&l.some(m=>m!=null))?[i]:[i,{...i,name:`${P} (${s("PAYROLL_PLAN.ACTUAL")})`,data:l,dataType:"actualData",color:he(C),stack:"actual",linkedTo:":previous",legendName:`${P} (${s("PAYROLL_PLAN.ACTUAL")})`}]},b=o==="headcount",U=I.useMemo(()=>{if(o==="totalSalary"){const P={name:s("PAYROLL_PLAN.CHART_TOTAL"),data:B,dataType:"plannedData",key:"totalSalary",color:M,fillColor:pe,stack:"planned",legendName:s("PAYROLL_PLAN.PLANNED")};return!h||!(E!=null&&E.some(p=>p!=null))?[P]:[P,{...P,name:`${s("PAYROLL_PLAN.CHART_TOTAL")} (${s("PAYROLL_PLAN.ACTUAL")})`,data:E,dataType:"actualData",color:Pe,fillColor:fe,stack:"actual",legendName:s("PAYROLL_PLAN.ACTUAL")}]}return o==="byTeam"?c.filter(p=>{var l,i;const C=(l=f[p.id])!=null?l:[],g=(i=O[p.id])!=null?i:[];return C.some(m=>m!==0)||g.some(m=>m!==0)}).flatMap(p=>{var l,i;const C=(l=O[p.id])!=null?l:[],g={name:p.name,data:(i=f[p.id])!=null?i:[],dataType:"plannedData",key:p.id,color:p.color||M,stack:"planned",legendName:p.name};return!h||!C.some(m=>m!==0)?[g]:[g,{...g,name:`${p.name} (${s("PAYROLL_PLAN.ACTUAL")})`,data:ge(C,A),dataType:"actualData",stack:"actual",dashStyle:"ShortDash",linkedTo:":previous",legendName:`${p.name} (${s("PAYROLL_PLAN.ACTUAL")})`}]}):o==="directIndirect"?[...x(s("PAYROLL_PLAN.DIRECT_LABOR.TITLE"),"totalCostOfSales",M,t,D),...x(s("PAYROLL_PLAN.INDIRECT_LABOR.TITLE"),"totalNonCos",te,n,S)]:o==="salaryBenefits"?[...x(s("PAYROLL_PLAN.BASIC_SALARY"),"basicSalary",M,u,H),...x(s("PAYROLL_PLAN.BENEFITS_AND_TAXES"),"benefitsAndTaxes",te,y,j)]:[{name:s("PAYROLL_PLAN.HEADCOUNT"),data:_,dataType:"plannedData",key:"totalEmployee",color:M,stack:"planned",legendName:s("PAYROLL_PLAN.HEADCOUNT")}]},[o,c,f,O,h,A,s,t,n,u,y,_,D,S,H,j,B,E]),v=I.useMemo(()=>{var l;if(!a.length)return{};const P=o==="totalSalary"?"areaspline":"column",p=h&&F,C=me(U,P),g=i=>b?String(Math.round(i!=null?i:0)):T(i!=null?i:0,2,!0);return{chart:{type:P,spacingBottom:0},title:{text:void 0},xAxis:{categories:a,gridLineWidth:1,gridLineColor:ee,gridLineDashStyle:"Dash",lineWidth:0,labels:{style:{color:Z}},plotLines:p&&A.length?ye(A,s("FORECAST_OVERVIEW.RECORDED_BOUNDARY",{period:(l=a[Math.max(...A)])!=null?l:"",raw:!0}),a.length):[]},yAxis:{gridLineWidth:1,gridLineColor:ee,gridLineDashStyle:"Dash",lineWidth:0,allowDecimals:!b,labels:{formatter:function(){return g(this.value)},style:{color:Z}},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 i=this.points[0].category,m=Oe(this.points);let Y;if(!b&&o!=="totalSalary"){let X=0,z=0,G=!1;Object.values(m).forEach(K=>{var q;X+=(q=K.planned)!=null?q:0,K.actual!=null&&(z+=K.actual,G=!0)}),Y={label:s("PAYROLL_PLAN.CHART_TOTAL"),planned:X,actual:G?z:void 0}}return _e(i,m,p,s,g,Y,{higherIsBetter:!1})}},legend:{enabled:!b,margin:6,padding:4,itemDistance:18,labelFormatter:function(){return this.userOptions.legendName||this.name}},credits:{enabled:!1},plotOptions:{areaspline:{fillOpacity:.2,stacking:"normal"},column:{stacking:"normal",borderWidth:2,borderColor:Q,borderRadius:2,groupPadding:.1},series:{lineWidth:2,marker:{enabled:!1,states:{hover:{enabled:!0,radius:4,lineWidth:2,lineColor:Q}}},clip:!0}},series:C,accessibility:{enabled:!1}}},[U,a,o,h,b,A,s]),$=I.useCallback(P=>{R(P),L&&ae.set(L,P)},[L]);return{selectedOption:o,handleOptionChange:$,chartOptions:v,chartKey:`${L}-${N}-${r}`}}function Ye(){const{businessId:e,projection:L,year:N}=W(),r=be({groupCollection:le,itemCollection:re,seriesKey:De.payroll.seriesKey,itemFields:{isSetupPending:1}}),s=ie(),T=ce(),o=I.useMemo(()=>s.getDataFilterMeta(e,L,N),[e,L,N]),{dataKeys:R}=I.useMemo(()=>T.getColumnAndKeys(e,o),[e,o]),c=J(()=>de.findOne({businessId:e},{fields:{"plannedData.totalSalary":1,"plannedData.totalEmployee":1,"plannedData.totalCostOfSales":1,"plannedData.totalNonCos":1,"plannedData.basicSalary":1,"plannedData.benefitsAndTaxes":1,"actualData.totalSalary":1,"actualData.totalCostOfSales":1,"actualData.totalNonCos":1,"actualData.basicSalary":1,"actualData.benefitsAndTaxes":1}}),[e]),f=J(()=>ue.findOne({businessId:e},{fields:{"plannedData.netRevenue":1,"actualData.netRevenue":1}}),[e]),O=R.join("|"),h=I.useMemo(()=>{var P,p,C,g;const a=l=>T.getSeriesData(R,l)||[],t=l=>a(l).reduce((i,m)=>i+(m||0),0),n=(P=c==null?void 0:c.plannedData)!=null?P:{},u=(p=c==null?void 0:c.actualData)!=null?p:{},y=R.reduce((l,i,m)=>{const Y=u.totalSalary;return Y&&Object.prototype.hasOwnProperty.call(Y,i)&&l.push(m),l},[]),_=l=>a(l).map((m,Y)=>y.includes(Y)?m:null),D=l=>a(l).reduce((i,m,Y)=>i+(y.includes(Y)&&m||0),0),S=a(n.totalEmployee),H=S.filter(l=>l>0),j=S.length?S[S.length-1]:0,B=S.length?S[0]:0,E=H.length?H.reduce((l,i)=>l+i,0)/H.length:0,F=t(n.totalCostOfSales),x=t(n.totalNonCos),b=t(n.basicSalary),U=t(n.benefitsAndTaxes),v=t((C=f==null?void 0:f.plannedData)==null?void 0:C.netRevenue),$=t((g=f==null?void 0:f.actualData)==null?void 0:g.netRevenue);return{actualTotal:t(u.totalSalary),plannedToDateTotal:D(n.totalSalary),recordedPeriods:y.length,recordedIndices:y,actualDirect:t(u.totalCostOfSales),plannedToDateDirect:D(n.totalCostOfSales),plannedToDateBasicSalary:D(n.basicSalary),plannedToDateBenefits:D(n.benefitsAndTaxes),plannedToDateIndirect:D(n.totalNonCos),actualIndirect:t(u.totalNonCos),actualBasicSalary:t(u.basicSalary),actualBenefits:t(u.benefitsAndTaxes),totalSalarySeries:a(n.totalSalary),actualTotalSalarySeries:_(u.totalSalary),actualDirectSeries:_(u.totalCostOfSales),actualIndirectSeries:_(u.totalNonCos),actualBasicSalarySeries:_(u.basicSalary),actualBenefitsSeries:_(u.benefitsAndTaxes),headcountSeries:S,endingHeadcount:j,startingHeadcount:B,averageHeadcount:E,direct:F,indirect:x,directSeries:a(n.totalCostOfSales),indirectSeries:a(n.totalNonCos),basicSalary:b,benefits:U,basicSalarySeries:a(n.basicSalary),benef
1itsSeries:a(n.benefitsAndTaxes),costPerEmployee:E>0?r.total/E:null,revenuePerEmployee:E>0&&v>0?v/E:null,shareOfRevenue:v>0?r.total/v*100:null,actualShareOfRevenue:$>0&&y.length>0?t(u.totalSalary)/$*100:null}},[c,f,O,r.total,r.actualTotal,r.recordedPeriods]),A=I.useMemo(()=>Ie(r.items,{nameOf:a=>{var t;return((t=a.metaInfo)==null?void 0:t.name)||""},valueOf:a=>{var t;return(t=r.totalByItem[a._id])!=null?t:0},colorOf:a=>{var t;return(t=r.groups.find(n=>n.id===a.groupId))==null?void 0:t.color}}),[r.items,r.totalByItem,r.groups]);return{...r,...h,rows:A}}function ne(e,L){if(!e||!L)return 0;const[N,r]=e.split("-").map(Number),[s,T]=L.split("-").map(Number);return(s-N)*12+(T-r)+1}function He({items:e,totalByItem:L,startingHeadcount:N,endingHeadcount:r,shareOfRevenue:s}){const{businessId:T}=W(),o=Le(),R=e.map(c=>{var f,O;return`${c._id}:${JSON.stringify((f=c.metaInfo)!=null?f:{})}:${c.isSetupPending}:${(O=L[c._id])!=null?O:0}`}).join("|");return I.useMemo(()=>{const c=o.getPlanningDates(T),f=k(c==null?void 0:c.startDate),O=k(c==null?void 0:c.endDate),h=ne(f,O)||12;if(!e.length)return[];const A=[],a=t=>{var n;return((n=t.metaInfo)==null?void 0:n.name)||""};return e.filter(t=>t.isSetupPending).forEach(t=>{A.push({id:`unfinished:${t._id}`,rowId:t._id,subject:a(t),message:"NOTE_NEEDS_SETUP"})}),e.filter(t=>!t.isSetupPending).forEach(t=>{var j,B,E,F,x,b;const n=(j=t.metaInfo)!=null?j:{},u=a(t),y=(B=k(n.startDate))!=null?B:f,_=(E=k(n.endDate))!=null?E:O,D=ne(y,_)||h,S=Number((F=n.variation)!=null?F:0),H=Number((x=n.benefitsAndTaxes)!=null?x:0);!S&&n.salaryConst!==!1&&D>=24&&A.push({id:`flat:${t._id}`,rowId:t._id,subject:u,message:"NOTE_NO_RAISE"}),!H&&n.onStaffRole!==!1&&A.push({id:`benefits:${t._id}`,rowId:t._id,subject:u,message:"NOTE_NO_BENEFITS"}),S&&n.variationFrequency==="monthly"&&Math.pow(1+S/100,Math.max(0,D-1))>=3&&A.push({id:`raise:${t._id}`,rowId:t._id,subject:u,message:"NOTE_STEEP_RAISE"}),((b=L[t._id])!=null?b:0)===0&&A.push({id:`nil:${t._id}`,rowId:t._id,subject:u,message:"NOTE_NO_EFFECT"})}),r>0&&r===N&&h>=24&&A.push({id:"flat-headcount",subject:"",message:"NOTE_FLAT_HEADCOUNT"}),s!=null&&s>=60&&A.push({id:"heavy-payroll",subject:"",message:"NOTE_HEAVY_PAYROLL"}),A},[T,R,N,r,s])}function je({total:e,scopeLabel:L,itemCount:N,endingHeadcount:r,startingHeadcount:s,costPerEmployee:T,revenuePerEmployee:o,shareOfRevenue:R,actualShareOfRevenue:c,isActualEnabled:f,actual:O,plannedToDate:h,recordedPeriods:A}){const a=V(),{formatCompactNumber:t}=Ae(),n=_=>t(_,1,!0),u=_=>`${_.toFixed(_%1===0?0:1)}%`,y=r!==s;return d.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[d.jsxs(w,{label:`${a("PAYROLL_PLAN.TOTAL_COST")} · ${L}`,note:f&&A||!N?void 0:a("PAYROLL_PLAN.ACROSS_ROWS",{count:N}),children:[d.jsx("span",{className:"text-2xl font-bold tabular-nums tracking-tight text-foreground",children:N?n(e):"â"}),f&&!!A&&(()=>{const _=h?((O!=null?O:0)-h)/h*100:null;return d.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[d.jsxs("span",{className:"text-xs text-muted-foreground",children:[a("PAYROLL_PLAN.ACTUAL")," ",d.jsx("span",{className:"font-semibold tabular-nums text-foreground",children:O!=null?n(O):"â"})]}),d.jsx(Ce,{value:_,higherIsBetter:!1}),!!A&&d.jsx("span",{className:"text-xs text-muted-foreground",children:a("PAYROLL_PLAN.RECORDED_PERIODS",{count:A})})]})})()]}),d.jsx(w,{label:a("PAYROLL_PLAN.HEADCOUNT"),note:r?y?a("PAYROLL_PLAN.HEADCOUNT_FROM",{count:s}):a("PAYROLL_PLAN.HEADCOUNT_FLAT"):a("PAYROLL_PLAN.HEADCOUNT_NONE"),children:d.jsx("span",{className:"text-lg font-semibold tabular-nums text-foreground",children:r?a("PAYROLL_PLAN.PEOPLE_COUNT",{count:r}):"â"})}),d.jsx(w,{label:a("PAYROLL_PLAN.COST_PER_EMPLOYEE"),note:o!=null?d.jsxs(d.Fragment,{children:[n(o)," ",a("PAYROLL_PLAN.REVENUE_PER_EMPLOYEE")]}):a("PAYROLL_PLAN.PER_EMPLOYEE_HINT"),children:d.jsx("span",{className:"text-lg font-semibold tabular-nums text-foreground",children:T==null?"â":n(T)})}),d.jsx(w,{label:a("PAYROLL_PLAN.SHARE_OF_REVENUE"),note:R==null?a("PAYROLL_PLAN.SHARE_NEEDS_REVENUE"):c!=null?a("PAYROLL_PLAN.SHARE_ACTUAL",{value:u(c)}):a("PAYROLL_PLAN.SHARE_HINT"),children:d.jsx("span",{className:"text-lg font-semibold tabular-nums text-foreground",children:R==null?"â":u(R)})})]})}function Ge(){const e=Ye(),{selectedOption:L,handleOptionChange:N,chartOptions:r,chartKey:s}=xe(e),T=He({items:e.items,totalByItem:e.totalByItem,startingHeadcount:e.startingHeadcount,endingHeadcount:e.endingHeadcount,shareOfRevenue:e.shareOfRevenue}),o=V();return e.isUnstarted?null:d.jsxs("div",{className:"space-y-4",children:[d.jsx(je,{total:e.total,scopeLabel:e.scopeLabel,itemCount:e.itemCount,endingHeadcount:e.endingHeadcount,startingHeadcount:e.startingHeadcount,costPerEmployee:e.costPerEmployee,revenuePerEmployee:e.revenuePerEmployee,shareOfRevenue:e.shareOfRevenue,actualShareOfRevenue:e.actualShareOfRevenue,isActualEnabled:e.hasActuals,actual:e.actualTotal,plannedToDate:e.plannedToDateTotal,recordedPeriods:e.recordedPeriods}),d.jsx(Te,{notes:T,i18n:"PAYROLL_PLAN"}),d.jsxs("div",{className:"grid grid-cols-1 gap-4 xl:grid-cols-[2fr_1fr] [&>*]:min-w-0",children:[d.jsx(Re,{isEmpty:!e.hasRows,chartOptions:r,options:se,selectedOption:L,onOptionChange:N,chartKey:`${s}:${L}
1`,subtitle:e.hasRecordedFigures&&L==="byTeam"?o("PAYROLL_PLAN.CHART_DASHED_HINT"):void 0}),d.jsxs("div",{className:"flex flex-col gap-4 xl:h-0 xl:min-h-full",children:[d.jsx(Se,{className:"flex-1",groups:e.groups,alternate:{rows:e.rows,groupLabel:o("PAYROLL_PLAN.MIX_BY_TEAM",{raw:!0}),rowLabel:o("PAYROLL_PLAN.MIX_BY_PERSON",{raw:!0})},title:o("PAYROLL_PLAN.PAYROLL_MIX"),scopeLabel:e.scopeLabel,emptyLabel:o("PAYROLL_PLAN.MIX_EMPTY",{raw:!0})}),d.jsx(Ee,{title:o("PAYROLL_PLAN.DIRECT_VS_INDIRECT"),higherIsBetter:!1,segments:[{label:o("PAYROLL_PLAN.DIRECT_LABOR.TITLE",{raw:!0}),value:e.direct,actual:e.recordedPeriods?e.actualDirect:void 0,plannedToDate:e.plannedToDateDirect},{label:o("PAYROLL_PLAN.INDIRECT_LABOR.TITLE",{raw:!0}),value:e.indirect,actual:e.recordedPeriods?e.actualIndirect:void 0,plannedToDate:e.plannedToDateIndirect}],hint:R=>o("PAYROLL_PLAN.DIRECT_SHARE_HINT",{percent:R.toFixed(0)})})]})]})]})}export{Ge 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.