@accounter/client 0.0.8-alpha-20251024170933-d98d02506cc646957a7dbc39cb8fe9bfe2bac635 → 0.0.8-alpha-20251027003629-e64c01111f4a4cec34d5ca9a84e02646b69f80b1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/assets/{Checkbox-O_bmDshT.js → Checkbox-DjollWGm.js} +2 -2
- package/dist/assets/{Progress-DNAb6Lcr.js → Progress-AG7ZMAJu.js} +1 -1
- package/dist/assets/{Typography-KCSoinJM.js → Typography-Cd0kk1vc.js} +1 -1
- package/dist/assets/{accordion-CXrCBIkr.js → accordion-s9Ku08QQ.js} +1 -1
- package/dist/assets/{accountant-approvals-DpVkzbd9.js → accountant-approvals-Bqrsn1y5.js} +1 -1
- package/dist/assets/{all-charges-B88-JVp0.js → all-charges-BQcsaMon.js} +1 -1
- package/dist/assets/{arrow-up-down-VGHZ-r_x.js → arrow-up-down-J-i_WnHP.js} +2 -2
- package/dist/assets/{building-2-C1ZqxhA5.js → building-2-B92gXbOj.js} +2 -2
- package/dist/assets/business-CfqFJUkR.js +32 -0
- package/dist/assets/{business-header-kyLMnyZj.js → business-header-Cr5S_Mz7.js} +1 -1
- package/dist/assets/{business-transactions-single-idJgJNHY.js → business-transactions-single-BD4bLNv2.js} +1 -1
- package/dist/assets/{business-trip-C1SwPMTA.js → business-trip-DYkKK6Gk.js} +1 -1
- package/dist/assets/{charges-filters-D0LWtwp4.js → charges-filters-CoFkjW00.js} +1 -1
- package/dist/assets/{charges-ledger-validation-D0UN5-yy.js → charges-ledger-validation-D_cg1bn-.js} +1 -1
- package/dist/assets/{chart-C0g6q8sT.js → chart-CQ9Opsuw.js} +1 -1
- package/dist/assets/{data-table-pagination-Bd4MUVlc.js → data-table-pagination-CN5CnGZV.js} +3 -3
- package/dist/assets/{editable-business-trip-8FHSmyUI.js → editable-business-trip--kNXo9tv.js} +4 -4
- package/dist/assets/{index-ByawU2Ir.js → index--XWh2RKR.js} +1 -1
- package/dist/assets/{index-BRNqBfLg.js → index-Au8Djmrz.js} +1 -1
- package/dist/assets/{index-D1_IyaQG.js → index-BGHdyfCs.js} +1 -1
- package/dist/assets/{index-CiZLBY-T.js → index-BNtiIPMq.js} +1 -1
- package/dist/assets/{index-BMRiK-sA.js → index-BSmbKLQe.js} +2 -2
- package/dist/assets/{index-BuRaZ4DH.js → index-BWpLPx22.js} +1 -1
- package/dist/assets/{index--FKfT8sG.js → index-C3pV-XkD.js} +2 -2
- package/dist/assets/{index-BSCXwbPK.js → index-C66UYUUf.js} +1 -1
- package/dist/assets/{index-CvEGrHKM.js → index-C7al3ztL.js} +1 -1
- package/dist/assets/{index-ByEhIp5_.js → index-CC_fLCrA.js} +7 -7
- package/dist/assets/{index-CUFNiTlG.js → index-CS40C1qp.js} +1 -1
- package/dist/assets/{index-DJM7_Iht.js → index-Cc4HfGhd.js} +1 -1
- package/dist/assets/{index-Bco41uAi.js → index-Cw9zbBbJ.js} +1 -1
- package/dist/assets/{index-ByiR6WrS.js → index-DDGgWxhe.js} +3 -3
- package/dist/assets/{index-aTVSOG7M.js → index-DNTlYcfH.js} +1 -1
- package/dist/assets/{index-DVPWQUlL.js → index-DS_RReq_.js} +1 -1
- package/dist/assets/{index-DE1XBKEu.js → index-DVbMTBK4.js} +1 -1
- package/dist/assets/{index-Buz-IrXk.js → index-DepseT6D.js} +1 -1
- package/dist/assets/{index-B2DG6Av_.js → index-DfI9E1Fb.js} +98 -98
- package/dist/assets/{index-C-05m3Xe.js → index-DzNfXERJ.js} +1 -1
- package/dist/assets/{index-CBxS5gse.js → index-fwXllLnH.js} +1 -1
- package/dist/assets/{index-O1k5sVaE.js → index-hr9hQe_a.js} +1 -1
- package/dist/assets/{index-CAtbp5mY.js → index-n3bzj3IE.js} +1 -1
- package/dist/assets/{index.es-DvJwAZOE.js → index.es-CKlpQqlO.js} +1 -1
- package/dist/assets/{issue-document-MHaHnees.js → issue-document-B4kkfOo0.js} +1 -1
- package/dist/assets/{login-page--AsTB5y2.js → login-page-NvQKYh34.js} +1 -1
- package/dist/assets/{missing-info-charges-DptgiNMX.js → missing-info-charges-DrF2b0mO.js} +1 -1
- package/dist/assets/{page-not-found-CP-tMcOZ.js → page-not-found-7AAOkZhu.js} +1 -1
- package/dist/assets/{pencil-hO35_0S3.js → pencil-DNPAJOPL.js} +2 -2
- package/dist/assets/{report-commentary-row-DXBs2-Cb.js → report-commentary-row-CF-l1YIC.js} +1 -1
- package/dist/assets/{save-Bug88Y1k.js → save-D84vX5ea.js} +2 -2
- package/dist/assets/{sub-DOUvsu0j.js → sub-BbpGm1pj.js} +1 -1
- package/dist/assets/subMonths-0tIJizDp.js +1 -0
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/src/components/clients/modify-client-dialog.tsx +3 -3
- package/src/components/common/modals/insert-business.tsx +1 -1
- package/dist/assets/business-CxsRSA_r.js +0 -32
- package/dist/assets/subMonths-B_ekFNhW.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as f,fQ as I,r as u,t as l,l as p,V as b,X as y,j as e,a0 as C,fz as $,a2 as D,a3 as F,a4 as w,a5 as k,v as j,a7 as v,fR as E,fS as S,ab as z,o as A,T as M,B as T,c7 as O,q as L,fT as P,fU as q,F as B,a as U,fV as R,c as V,L as _,bR as Q,bS as G,fW as W}from"./index-
|
|
1
|
+
import{i as f,fQ as I,r as u,t as l,l as p,V as b,X as y,j as e,a0 as C,fz as $,a2 as D,a3 as F,a4 as w,a5 as k,v as j,a7 as v,fR as E,fS as S,ab as z,o as A,T as M,B as T,c7 as O,q as L,fT as P,fU as q,F as B,a as U,fV as R,c as V,L as _,bR as Q,bS as G,fW as W}from"./index-DfI9E1Fb.js";const X="updateTag",H=()=>{const[{fetching:i},r]=f(I),c=u.useCallback(async a=>{const t=`Error updating tag ID [${a.tagId}]`,s=`${X}-${a.tagId}`;l.loading("Updating Tag...",{id:s});try{const n=await r(a),d=p(n,t,s,"updateTag");if(d)return l.success("Success",{id:s,description:"Tag updated"}),d.updateTag}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}return!1},[r]);return{fetching:i,updateTag:c}},J=({onDone:i,data:r,close:c})=>{const{updateTag:a,fetching:t}=H(),s=y(S,r),n=b({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=z(o,h);c(),g&&Object.keys(g).length>0&&a({tagId:s.id,fields:g}).then(()=>i?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs($,{cols:3,children:[e.jsx(D,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(F,{children:[e.jsx(w,{children:"Name"}),e.jsx(k,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(v,{})]})}),e.jsx(E,{formManager:n,tagsPath:"parentId",label:"Parent Tag"})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>m(x),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:t||Object.keys(h).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})})},K=({onDone:i,data:r})=>{const[c,{open:a,close:t}]=A(!1);function s(){t(),i?.()}return e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Edit Tag",children:e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:a,children:e.jsx(O,{className:"size-5"})})}),e.jsx(L,{centered:!0,opened:c,onClose:t,title:"Insert Business Trip",children:e.jsx(J,{close:t,onDone:s,data:r})})]})},Y="addTag",Z=()=>{const[{fetching:i},r]=f(P),c=u.useCallback(async a=>{const t=`Error adding new tag [${a.tagName}]`,s=`${Y}-${a.tagName}`;l.loading("Adding tag",{id:s});try{const n=await r(a);p(n,t,s)&&l.success("Success",{id:s,description:`"${a.tagName}" tag was successfully added`})}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}},[r]);return{fetching:i,addTag:c}},ee="deleteTag",se=()=>{const[{fetching:i},r]=f(q),c=u.useCallback(async a=>{const t=`Error deleting new tag [${a.name}]`,s=`${ee}-${a.tagId}`;l.loading(`Deleting tag [${a.name}]`,{id:s});try{const n=await r(a);p(n,t,s)&&l.success("Tag Deleted",{id:s,description:`[${a.name}] tag was successfully removed`})}catch(n){console.error(`${t}: ${n}`),l.error("Error",{id:s,description:t,duration:1e5,closeButton:!0})}},[r]);return{fetching:i,deleteTag:c}},te=()=>{const{setFiltersContext:i}=u.useContext(B),[r,c]=u.useState(""),[{data:a,fetching:t},s]=U({query:W}),{addTag:n}=Z(),{deleteTag:d}=se();i(null);const m=R(a?.allTags??[]),h=u.useCallback(o=>{o.length>2&&n({tagName:o}).then(()=>{s()})},[n,s]),x=u.useCallback((o,g)=>{d({tagId:o,name:g}).then(()=>{s()})},[d,s]);return e.jsx(V,{title:"Tags",description:"Manage tags for your bookmarks.",children:t?e.jsx(_,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m?.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-gray-600 mb-2",children:[e.jsxs("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:[o.namePath?.map((g,N)=>e.jsx("span",{className:"ms-2"},N)),o.name]}),e.jsx(K,{data:o}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(Q,{className:"size-5"})})]},o.id)),e.jsxs("div",{className:"flex justify-start items-center gap-2 text-gray-600 mb-2",children:[e.jsx(j,{className:"w-80",value:r,onChange:o=>c(o.currentTarget.value),placeholder:"Add new tag",required:!0}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(G,{className:"size-5"})})]})]})})};export{te as TagsManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as e,c_ as u,eK as p,B as y,c$ as g,bp as D,F as P,a as w,c as R,L as E,ca as v,eL as F}from"./index-
|
|
1
|
+
import{r as h,j as e,c_ as u,eK as p,B as y,c$ as g,bp as D,F as P,a as w,c as R,L as E,ca as v,eL as F}from"./index-DfI9E1Fb.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{R as d}from"./report-commentary-row-CF-l1YIC.js";function A({year:l,setYear:m,referenceYears:o,setReferenceYears:j}){const[c,x]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(u,{opened:c,onClose:()=>x(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&m(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(g,{className:"size-5"})})]})}const b=()=>{const{year:l}=D(),{setFiltersContext:m}=h.useContext(P),[o,j]=h.useState(l?Number(l):new Date().getFullYear()),[c,x]=h.useState([]),[{data:n,fetching:i}]=w({query:C(F),variables:{reportYear:o,referenceYears:c}});h.useEffect(()=>{m(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:c,setReferenceYears:x})}))},[o,i,m,c,x]);const f=n?.profitAndLossReport,a=f?.report,s=f?.reference??[];return e.jsx(R,{title:"Profit and Loss Report",children:i?e.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:a&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:a.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("th",{children:r.revenue.amount.formatted},r.year))]}),commentaryData:a.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:a.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.costOfSales.amount.formatted},r.year))]}),commentaryData:a.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:a.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted},r.year))]}),commentaryData:a.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:a.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.marketingExpenses.amount.formatted},r.year))]}),commentaryData:a.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted},r.year))]}),commentaryData:a.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:a.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:a.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.financialExpenses.amount.formatted},r.year))]}),commentaryData:a.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:a.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.otherIncome.amount.formatted},r.year))]}),commentaryData:a.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:a.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:a.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:a.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{b as ProfitAndLossReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as v,fX as U,r as u,t as m,l as F,aK as H,j as e,a2 as C,a3 as j,a4 as f,a5 as p,v as L,a6 as y,a7 as S,bO as K,bP as V,aO as z,aI as _,K as D,an as E,B as h,N as M,ap as A,aq as R,V as O,a0 as k,fY as G,c7 as Q,a as P,fZ as X,L as $,F as Y,dj as Z,c as J,dm as W,dn as ee,dp as T,dq as se,dr as b,ds as te,dt as w,f_ as ae,dz as re,dA as oe,dB as ne}from"./index-
|
|
1
|
+
import{i as v,fX as U,r as u,t as m,l as F,aK as H,j as e,a2 as C,a3 as j,a4 as f,a5 as p,v as L,a6 as y,a7 as S,bO as K,bP as V,aO as z,aI as _,K as D,an as E,B as h,N as M,ap as A,aq as R,V as O,a0 as k,fY as G,c7 as Q,a as P,fZ as X,L as $,F as Y,dj as Z,c as J,dm as W,dn as ee,dp as T,dq as se,dr as b,ds as te,dt as w,f_ as ae,dz as re,dA as oe,dB as ne}from"./index-DfI9E1Fb.js";import{D as ie}from"./data-table-pagination-CN5CnGZV.js";import{A as N}from"./arrow-up-down-J-i_WnHP.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(U),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function q({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=H();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(L,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(S,{})]})}),e.jsx(K,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(V,{...o,onChange:B=>{o.onChange(Number(B))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(g)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(S,{})]})}),e.jsx(C,{control:a,name:"taxExcluded",render:({field:o})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{children:"Tax excluded category"})}),e.jsx(p,{children:e.jsx(_,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(A,{children:e.jsx(R,{children:"Add New Tax Category"})}),e.jsx(xe,{close:()=>t(!1),onAdd:s})]})]})}function xe({close:s,onAdd:n}){const t=O({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx(k,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(G),t=u.useCallback(async a=>{const d="Error updating tax category",r=`${ue}-${a.taxCategoryId}`;m.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return m.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function me({taxCategoryId:s,onAdd:n}){const[t,a]=u.useState(!1);return e.jsxs(D,{open:t,onOpenChange:a,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(Q,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(A,{children:e.jsx(R,{children:"Edit Tax Category"})}),e.jsx(he,{taxCategoryId:s,close:()=>a(!1),onAdd:n})]})]})}function he({taxCategoryId:s,close:n,onAdd:t}){const[{data:a,fetching:d}]=P({query:X,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&m.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx($,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=O({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx(k,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=P({query:ae}),{setFiltersContext:d}=u.useContext(Y),r=s?.taxCategories??[],i=Z({data:r,columns:I,getCoreRowModel:ne(),getPaginationRowModel:oe(),getSortedRowModel:re(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ie,{table:i})})}))},[d,i,l]),u.useEffect(()=>{t&&m.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(J,{title:`Tax Categories (${r.length})`,description:"All tax categories",headerActions:e.jsx(le,{onAdd:()=>a()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx($,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(W,{children:[e.jsx(ee,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(se,{children:c.isPlaceholder?null:b(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(te,{children:i.getRowModel().rows.length===0?e.jsx(T,{children:e.jsx(w,{colSpan:I.length,className:"text-center py-8",children:"No tax categories found"})}):i.getRowModel().rows.map(x=>e.jsx(T,{children:x.getVisibleCells().map(c=>e.jsx(w,{children:b(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{Se as TaxCategories};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as k,k as M,r,t as j,l as A,a as N,m as F,j as e,n as T,o as z,B as v,p as C,q as D,u as y,s as P,v as L,F as $,w as O,T as R,P as q,b as U,c as _,L as Q,x as V,R as B,y as H,z as K}from"./index-
|
|
1
|
+
import{i as k,k as M,r,t as j,l as A,a as N,m as F,j as e,n as T,o as z,B as v,p as C,q as D,u as y,s as P,v as L,F as $,w as O,T as R,P as q,b as U,c as _,L as Q,x as V,R as B,y as H,z as K}from"./index-DfI9E1Fb.js";import{B as G}from"./business-header-Cr5S_Mz7.js";import{C as J,M as W}from"./Checkbox-DjollWGm.js";import"./building-2-B92gXbOj.js";const X="mergeBusinesses",Y=()=>{const[{fetching:o},d]=k(M),u=r.useCallback(async l=>{const c=`Error merging into business ID [${l.targetBusinessId}]`,t=`${X}-${l.targetBusinessId}`;j.loading("Merging Businesses",{id:t});try{const a=await d(l),s=A(a,c,t);if(s)return j.success("Success",{id:t,description:"Businesses merged"}),s.mergeBusinesses.id}catch(a){console.error(`${c}: ${a}`),j.error("Error",{id:t,description:c,duration:1e5,closeButton:!0})}},[d]);return{fetching:o,mergeBusinesses:u}};function Z({businessIds:o,onDone:d,resetMerge:u}){const{mergeBusinesses:l,fetching:c}=Y(),t=Array.from(new Set(o)),[{data:a,fetching:s}]=N({query:F,variables:{businessIds:t}}),[m,f]=r.useState(a?.businesses[0]),n=a?.businesses.length!==t.length&&"Some businesses were not Found"||void 0,g=a?.businesses||[],h=r.useCallback(async()=>{if(!m){j.error("Error",{description:"No main business selected"});return}if(t.length<2){j.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await l({targetBusinessId:m.id,businessIdsToMerge:t.filter(x=>x!==m.id)}),u(),d()},[m,t,l,d,u]);return e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx(T,{})}),!s&&n&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:n})}),!s&&!n&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),g.map(x=>e.jsx("td",{children:e.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:e.jsx(J,{checked:x.id===m?.id,size:"xl",onClick:()=>{f(x)}})})},x.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),g.map(x=>e.jsx("td",{children:x.name},x.id))]})]}),e.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[e.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:s||c,onClick:h,children:"Accept"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{u(),d()},children:"Reset Merge"})]})]})]})}function ee(o){const[d,{close:u,open:l}]=z(!1),{selected:c,resetMerge:t}=o,a=new Set(c.map(({id:g})=>g)),s=a.size>=1,[m,f]=r.useState(s?"default":"outline");r.useEffect(()=>{f(s?"default":"outline")},[s]);const n=r.useCallback(()=>{u(),c.map(({onChange:g})=>g())},[c,u]);return e.jsxs(e.Fragment,{children:[e.jsx(v,{onClick:()=>{s&&l()},disabled:!s,variant:m,className:C("size-7.5",s?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(W,{className:"size-5"})}),e.jsx(D,{opened:d,onClose:u,size:"auto",centered:!0,children:e.jsx(Z,{businessIds:Array.from(a),onDone:n,resetMerge:t})})]})}function se({activePage:o,setPage:d,totalPages:u=1,businessName:l,setBusinessName:c}){const{get:t,set:a}=y(),[s,m]=r.useState(l);r.useEffect(()=>{const n=o>1?o.toFixed(0):void 0,g=t("page");n!==g&&n!=="1"&&a("page",n)},[o,t,a]),r.useEffect(()=>{const n=setTimeout(()=>{c(s)},600);return()=>{clearTimeout(n)}},[s,c]);const f=n=>{m(n)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(P,{className:"flex-auto",value:o,onChange:d,total:u}),e.jsx(L,{className:"w-72",placeholder:"Business Name",defaultValue:l??void 0,onChange:n=>f(n.target.value===""?void 0:n.target.value)})]})}const re=()=>{const{get:o}=y(),[d,u]=r.useState(!1),[l,c]=r.useState(o("page")?Number(o("page")):1),[t,a]=r.useState(o("name")?o("page"):void 0),{setFiltersContext:s}=r.useContext($),[{data:m,fetching:f},n]=N({query:K,variables:{page:l,limit:100,name:t}}),g=O(),[h,x]=r.useState([]),I=r.useCallback((i,p)=>{h.map(b=>b.id).includes(i)?x(h.filter(b=>b.id!==i)):x([...h,{id:i,onChange:p}])},[h]);function S(){x([])}r.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(se,{activePage:l,setPage:c,businessName:t,setBusinessName:a,totalPages:m?.allBusinesses?.pageInfo.totalPages}),e.jsx(R,{label:"Expand all businesses",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>u(i=>!i),children:d?e.jsx(q,{className:"size-5"}):e.jsx(U,{className:"size-5"})})}),e.jsx(ee,{selected:h,resetMerge:S})]}))},[m,l,t,d,s,c,a,u,h]);const w=m?.allBusinesses?.nodes.filter(i=>i.__typename==="LtdFinancialEntity").sort((i,p)=>i.name.toLowerCase()>p.name.toLowerCase()?1:-1)??[],E=new Set(h.map(i=>i.id));return e.jsx(_,{title:`Businesses (${m?.allBusinesses?.pageInfo.totalRecords??""})`,description:"All businesses",headerActions:e.jsx("div",{className:"flex items-center py-4 gap-4",children:e.jsx(H,{description:"",onAdd:()=>n()})}),children:f?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(Q,{className:C("h-10 w-10 animate-spin mr-2")})}):e.jsx("div",{className:"space-y-2",children:w.map(i=>e.jsx("div",{className:"group relative border rounded-lg hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"pl-4 flex items-center",children:e.jsx(V,{checked:E.has(i.id),onCheckedChange:()=>{I(i.id,()=>{})},className:"h-4 w-4 rounded border-gray-300 cursor-pointer",onClick:p=>p.stopPropagation()})}),e.jsx("div",{role:"button",tabIndex:0,className:"flex-1 cursor-pointer",onClick:()=>{g(B.BUSINESSES.DETAIL(i.id))},onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),g(B.BUSINESSES.DETAIL(i.id)))},children:e.jsx(G,{data:i})})]})},i.id))})})};export{re as Businesses};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{D as U,r as b,cd as W,j as e,K as z,an as G,B as g,c$ as R,N as Q,ap as X,aq as Z,bf as T,aM as K,b5 as A,au as k,av as O,aw as M,ax as E,ay as D,cS as J,X as j,bn as w,eR as I,eS as ee,eT as S,eU as se,eV as L,eW as B,eX as P,eY as N,eZ as p,e_ as Y,e$ as $,dN as re,f0 as te,bi as ae,bj as le,bk as v,f1 as V,F as de,a as ne,Y as oe,Z as ce,a1 as ie,f2 as ue}from"./index-
|
|
2
|
-
* @license lucide-react v0.
|
|
1
|
+
import{D as U,r as b,cd as W,j as e,K as z,an as G,B as g,c$ as R,N as Q,ap as X,aq as Z,bf as T,aM as K,b5 as A,au as k,av as O,aw as M,ax as E,ay as D,cS as J,X as j,bn as w,eR as I,eS as ee,eT as S,eU as se,eV as L,eW as B,eX as P,eY as N,eZ as p,e_ as Y,e$ as $,dN as re,f0 as te,bi as ae,bj as le,bk as v,f1 as V,F as de,a as ne,Y as oe,Z as ce,a1 as ie,f2 as ue}from"./index-DfI9E1Fb.js";import{B as me}from"./building-2-B92gXbOj.js";import{S as xe}from"./save-D84vX5ea.js";/**
|
|
2
|
+
* @license lucide-react v0.546.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,a2 as C,a3 as p,a4 as S,a5 as y,aO as v,a7 as I,v as L,i as D,f$ as H,r as u,t as m,l as E,K as M,an as R,B as x,c7 as z,N as A,ap as T,aq as $,a as q,g0 as V,L as O,V as P,a0 as K,ab as _,g1 as Q,F as G,dj as J,c as W,dm as X,dn as Y,dp as b,dq as Z,dr as w,ds as ee,dt as g,g2 as se,dz as te,dA as re,dB as oe}from"./index-
|
|
1
|
+
import{j as e,a2 as C,a3 as p,a4 as S,a5 as y,aO as v,a7 as I,v as L,i as D,f$ as H,r as u,t as m,l as E,K as M,an as R,B as x,c7 as z,N as A,ap as T,aq as $,a as q,g0 as V,L as O,V as P,a0 as K,ab as _,g1 as Q,F as G,dj as J,c as W,dm as X,dn as Y,dp as b,dq as Z,dr as w,ds as ee,dt as g,g2 as se,dz as te,dA as re,dB as oe}from"./index-DfI9E1Fb.js";import{D as ne}from"./data-table-pagination-CN5CnGZV.js";import{A as F}from"./arrow-up-down-J-i_WnHP.js";function B({isInsert:s,formManager:n}){const{control:r}=n;return e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"key",control:r,disabled:!s,rules:{required:"Required",validate:{positive:t=>Number(t)>0||"Key must be a positive number",integer:t=>Number.isInteger(Number(t))||"Key must be an integer"}},render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Key"}),e.jsx(y,{children:e.jsx(v,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:"",required:!0})}),e.jsx(I,{})]})}),e.jsx(C,{name:"name",control:r,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Name"}),e.jsx(y,{children:e.jsx(L,{...t,value:t.value??void 0,required:!0})}),e.jsx(I,{})]})}),e.jsx(C,{name:"defaultIrsCode",control:r,render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Default IRS Code"}),e.jsx(y,{children:e.jsx(v,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(I,{})]})})]})}const ae="updateSortCode",de=()=>{const[{fetching:s},n]=D(H),r=u.useCallback(async t=>{const d=`Error updating sort code ID [${t.key}]`,o=`${ae}-${t.key}`;m.loading("Updating Sort Code...",{id:o});try{const a=await n(t),i=E(a,d,o,"updateSortCode");if(i)return m.success("Success",{id:o,description:"SortCode updated"}),i.updateSortCode}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:o,description:d,duration:1e5,closeButton:!0})}return!1},[n]);return{fetching:s,updateSortCode:r}};function ie({sortCodeKey:s,onAdd:n}){const[r,t]=u.useState(!1);return e.jsxs(M,{open:r,onOpenChange:t,children:[e.jsx(R,{asChild:!0,children:e.jsx(x,{variant:"outline",size:"icon",children:e.jsx(z,{})})}),e.jsxs(A,{className:"w-[400px] max-w-screen-md",children:[e.jsx(T,{children:e.jsx($,{children:"Edit Sort Code"})}),e.jsx(le,{sortCodeKey:s,close:()=>t(!1),onAdd:n})]})]})}function le({sortCodeKey:s,close:n,onAdd:r}){const[{data:t,fetching:d}]=q({query:V,variables:{key:s}}),o=t?.sortCode;return!o&&!d&&m.error("Error",{description:"Couldn't find sort code"}),d?e.jsx(O,{className:"h-10 w-10 animate-spin"}):o?e.jsx(ce,{sortCode:o,close:n,onAdd:r}):e.jsx("div",{children:"Sort code not found"})}function ce({sortCode:s,close:n,onAdd:r}){const t=P({defaultValues:s}),{handleSubmit:d,formState:{dirtyFields:o}}=t,{updateSortCode:a,fetching:i}=de(),l=({key:c,...U})=>{const h=_(U,o);if(h&&Object.keys(h).length>0){let N;if(h.defaultIrsCode){const j=h.defaultIrsCode,f=Number(j);if(!Number.isInteger(f)||f<2||f>9999)throw new Error(`Invalid IRS code: ${j}`);N=f}a({fields:{...h,defaultIrsCode:N},key:s.key}).then(j=>{j&&(r?.(s.key),n())})}};return e.jsx(K,{...t,children:e.jsxs("form",{onSubmit:d(l),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(B,{isInsert:!1,formManager:t})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:i,children:"Update"})})]})})}const ue="addSortCode",me=()=>{const[{fetching:s},n]=D(Q),r=u.useCallback(async t=>{const d=`Error adding new sort code [${t.name}]`,o=`${ue}-${t.name}`;m.loading("Adding sort code",{id:o});try{const a=await n(t);E(a,d,o)&&m.success("Success",{id:o,description:`"${t.name}" sort code was successfully added`})}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:o,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,addSortCode:r}};function xe({onAdd:s}){const[n,r]=u.useState(!1);return e.jsxs(M,{open:n,onOpenChange:r,children:[e.jsx(R,{asChild:!0,children:e.jsx(x,{children:"Add Sort Code"})}),e.jsxs(A,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(T,{children:e.jsx($,{children:"Add New Sort Code"})}),e.jsx(he,{close:()=>r(!1),onAdd:s})]})]})}function he({close:s,onAdd:n}){const r=P({}),{handleSubmit:t}=r,{addSortCode:d,fetching:o}=me(),a=i=>{i.key&&=parseInt(i.key.toString()),i.defaultIrsCode&&=parseInt(i.defaultIrsCode.toString()),d(i).then(()=>{s(),n?.()})};return e.jsx(K,{...r,children:e.jsxs("form",{onSubmit:t(a),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(B,{isInsert:!0,formManager:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:o,children:"Add Sort Code"})})]})})}const k=[{id:"key",accessorKey:"key",cell:({row:s})=>e.jsx(g,{children:s.original.key}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Key",e.jsx(F,{})]})},{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(g,{children:s.original.name}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(F,{})]})},{id:"defaultIrsCode",accessorKey:"defaultIrsCode",cell:({row:s})=>e.jsx(g,{className:"flex flex-wrap gap-1 p-1",children:s.original.defaultIrsCode&&e.jsx(x,{variant:"outline",disabled:!0,className:"p-1 w-15",children:s.original.defaultIrsCode})}),header:"Default IRS Code"},{id:"edit",cell:({row:s})=>e.jsx(ie,{sortCodeKey:s.original.key,onAdd:s.original.refetchSortCodes})}],Ce=()=>{const[{data:s,fetching:n,error:r},t]=q({query:se}),{setFiltersContext:d}=u.useContext(G),o=u.useMemo(()=>s?.allSortCodes?.map(l=>({...l,refetchSortCodes:t}))??[],[s?.allSortCodes,t]),a=J({data:o,columns:k,getCoreRowModel:oe(),getPaginationRowModel:re(),getSortedRowModel:te(),initialState:{pagination:{pageSize:100}}}),i=a.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx(ne,{table:a})}))},[d,a,i]),u.useEffect(()=>{r&&(console.error("Error fetching sort codes",r),m.error("Error",{description:"Error fetching sort codes"}))},[r]),e.jsx(W,{title:`Sort Codes (${o.length})`,description:"All sort codes",headerActions:e.jsx(xe,{onAdd:()=>t()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(O,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(X,{children:[e.jsx(Y,{children:a.getHeaderGroups().map(l=>e.jsx(b,{children:l.headers.map(c=>e.jsx(Z,{children:c.isPlaceholder?null:w(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),e.jsx(ee,{children:a.getRowModel().rows.length===0?e.jsx(b,{children:e.jsx(g,{colSpan:k.length,className:"text-center py-8",children:"No sort codes found"})}):a.getRowModel().rows.map(l=>e.jsx(b,{children:l.getVisibleCells().map(c=>e.jsx(g,{children:w(c.column.columnDef.cell,c.getContext())},c.id))},l.id))})]})})})};export{Ce as SortCodes};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{D as q,r as d,j as e,X as p,B as g,P as w,b as y,C as F,ek as G,el as H,em as _,en as Q,cS as D,cm as M,eo as E,ep as R,eq as T,er as $,es as J,ca as V,et as X,eu as Y,ev as Z,ew as K,a as z,t as W,ex as ee,T as te,ey as se,u as O,ae as k,cZ as ae,c_ as ne,c$ as re,V as oe,dh as ie,bO as A,bP as S,ez as N,db as ce,H as I,d0 as le,F as de,c as he,L as xe,E as ue,I as me,M as pe,eA as ge}from"./index-
|
|
2
|
-
* @license lucide-react v0.
|
|
1
|
+
import{D as q,r as d,j as e,X as p,B as g,P as w,b as y,C as F,ek as G,el as H,em as _,en as Q,cS as D,cm as M,eo as E,ep as R,eq as T,er as $,es as J,ca as V,et as X,eu as Y,ev as Z,ew as K,a as z,t as W,ex as ee,T as te,ey as se,u as O,ae as k,cZ as ae,c_ as ne,c$ as re,V as oe,dh as ie,bO as A,bP as S,ez as N,db as ce,H as I,d0 as le,F as de,c as he,L as xe,E as ue,I as me,M as pe,eA as ge}from"./index-DfI9E1Fb.js";import{d as B}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{M as je}from"./index-DDGgWxhe.js";import{c as fe}from"./charges-filters-CoFkjW00.js";import"./Checkbox-DjollWGm.js";import"./sub-BbpGm1pj.js";import"./subMonths-0tIJizDp.js";/**
|
|
2
|
+
* @license lucide-react v0.546.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as m,bx as h,X as T,r as a,j as s,by as x,bz as g,bA as j,F as B,bB as C,T as b,aI as w,c as v,L as y,ao as E,bC as P}from"./index-
|
|
1
|
+
import{a as m,bx as h,X as T,r as a,j as s,by as x,bz as g,bA as j,F as B,bB as C,T as b,aI as w,c as v,L as y,ao as E,bC as P}from"./index-DfI9E1Fb.js";import{E as L,P as F,C as I}from"./editable-business-trip--kNXo9tv.js";const S=({data:c,isOpened:o,shouldValidate:l})=>{const e=T(j,c),[{data:r,fetching:i}]=m({pause:!l,query:h,variables:{id:e.id}}),d=a.useMemo(()=>l?r?.businessTrip&&(r.businessTrip.uncategorizedTransactions?.length||r?.businessTrip.summary?.errors?.length):!1,[r]),u=d||e?.accountantApproval!=="APPROVED";return s.jsxs(x.Item,{value:e.id,children:[s.jsx(x.Control,{children:s.jsx(g,{inline:!0,size:12,processing:i,disabled:!u,color:d?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(x.Panel,{children:o&&s.jsx(L,{tripId:e.id,isExtended:!0},e.id)})]})},N=()=>{const{setFiltersContext:c}=a.useContext(B),[o,l]=a.useState([]),[e,r]=a.useState(!1),[{data:i,fetching:d}]=m({query:P});a.useEffect(()=>{if(!i?.allBusinessTrips?.length){l([]);return}const t=i.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[i?.allBusinessTrips]);const[u,f]=a.useState([]);return a.useEffect(()=>{c(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(C,{}),s.jsx(b,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(w,{checked:e??!1,onCheckedChange:t=>r(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(F,{filename:"business_trips"})]}))},[i,d,c,e]),s.jsx(v,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&d?s.jsx(y,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(I,{children:s.jsx(x,{className:"w-full",multiple:!0,value:u,onChange:f,chevron:s.jsx(E,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:u.includes(t.id)},t.id))})})})};export{N as BusinessTrips};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as P,j as r,g as Q,a as W,fc as $,L as E,u as Y,ae as q,cZ as K,c_ as X,B as U,c$ as ee,V as te,cd as ne,bO as se,bP as oe,db as O,H as S,fd as Z,d0 as re,F as ie,c as le,Y as ae,_ as ce,a1 as ue}from"./index-
|
|
1
|
+
import{r as P,j as r,g as Q,a as W,fc as $,L as E,u as Y,ae as q,cZ as K,c_ as X,B as U,c$ as ee,V as te,cd as ne,bO as se,bP as oe,db as O,H as S,fd as Z,d0 as re,F as ie,c as le,Y as ae,_ as ce,a1 as ue}from"./index-DfI9E1Fb.js";import{A as fe,a as he,c as de,b as pe}from"./accordion-s9Ku08QQ.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:l,N:o,j:h,M:a,Z:u,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*u);const R=o-a,_=o+a,B=_&1,G=l+o-1,H=h+a-1,J=(_+B)/2;let F;t:for(let M=0;M<=J;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let f=I;f<=L;f+=2){const A=t[f-1-u*Math.floor((f-1)/u)],V=t[f+1-u*Math.floor((f+1)/u)],w=f===-M||f!==M&&A<V?V:A+1,k=w-f;let b=w,C=k;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[f-u*Math.floor(f/u)]=b,B===1&&(F=R-f)>=1-M&&F<M&&b+t[u+F-u*Math.floor(F/u)]>=o)if(M>1||b!==w){i[x++]=l+b,i[x++]=o-b,i[x++]=h+C,i[x++]=a-C,o=w,a=k,u=2*(Math.min(o,a)+1);continue e}else break t}for(let f=I;f<=L;f+=2){const A=t[u+f-1-u*Math.floor((f-1)/u)],V=t[u+f+1-u*Math.floor((f+1)/u)],w=f===-M||f!==M&&A<V?V:A+1,k=w-f;let b=w,C=k;for(;b<o&&C<a&&s(G-b,H-C);)b++,C++;if(t[u+f-u*Math.floor(f/u)]=b,B===0&&(F=R-f)>=-M&&F<=M&&b+t[F-u*Math.floor(F/u)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-k,i[x++]=k,o=o-b,a=a-C,u=2*(Math.min(o,a)+1);continue e}else break t}}if(o!==a){a>o?(l+=o,h+=o,a-=o,o=0):(l+=a,h+=a,o-=a,a=0);break}}if(o+a!==0)if(e.pxe===l||e.pye===h)e.pxe=l+o,e.pye=h+a;else{const R=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=l,e.pxe=l+o,e.pys=h,e.pye=h+a,R>=0)return e.i=l,e.N=o,e.j=h,e.M=a,e.Z=u,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],u=2*(Math.min(o,a)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const l=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*l);return new m({i:e,N:n,j:t,M:s,Z:l,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,l]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<l&&t(s,s);)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;t(--i,--l)&&i>s&&l>s;);}else{for(;s<i&&s<l&&e[s]===n[s];)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;e[--i]===n[--l]&&i>s&&l>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,l+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:a,j:u,N:x}=this;return a<x&&(n.done=!1,n.value=[a,u,x-a],this.i=x),n}const t=n.value,s=t[0],i=t[1],l=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=l,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*N(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,l,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=l;t<e.length&&(yield s.call(e,t))}v.applyPatch=N;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[l,o,h,a]of d(e,n,t))s<l&&(yield[0,i.call(e,s,l)]),l<o&&(yield[-1,i.call(e,l,o)]),h<a&&(yield[1,i.call(n,h,a)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),T=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=P.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),N=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of N)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(N.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),T]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),T]);let n=[];for(const[t,s]of j){const i=t.split(`
|
|
2
2
|
`);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(Q,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=W({query:$,variables:c}),p=P.useMemo(()=>m?.pcnByDate?m.pcnByDate.sort((y,g)=>g.date>y.date?1:g.date<y.date?-1:0):[],[m?.pcnByDate]);return D?r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}):r.jsxs("div",{className:"flex flex-col gap-4",children:[!!m&&d&&r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}),p.map((y,g)=>r.jsx(ge,{content:y.content,contentOrigin:y.diffContent,monthDate:y.date},g))]})};function be({filter:c,setFilter:m,closeModal:D}){const{control:d,handleSubmit:p,setValue:y}=te({defaultValues:{...c}}),{selectableBusinesses:g,fetching:N}=ne(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[N?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(se,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(oe,{...e,data:g,value:e.value,disabled:N,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),r.jsx(O,{label:"From date",defaultValue:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,defaultDate:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("fromMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsx(O,{label:"To date",defaultValue:c?.toMonthDate?new Date(c.toMonthDate):new Date,defaultDate:c?.toMonthDate?new Date(c.toMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("toMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[r.jsx(U,{type:"submit",children:"Filter"}),r.jsx(U,{type:"button",onClick:D,children:"Cancel"})]})]})]})}function ve({filter:c,setFilter:m}){const[D,d]=P.useState(!1),{get:p,set:y}=Y(),{userContext:g}=P.useContext(q);function N(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:S(Z(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")},re(j,c)||m(j)}return P.useEffect(()=>{const j=K(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(X,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:N,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(ee,{className:"size-5"})})]})}const Ce=()=>{const{get:c}=Y(),{setFiltersContext:m}=P.useContext(ie),D=P.useMemo(()=>{try{if(c("validateReportsFilters"))return JSON.parse(decodeURIComponent(c("validateReportsFilters")))}catch(y){console.error("Error parsing filter from URL",y)}return{fromMonthDate:S(Z(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")}},[c]),[d,p]=P.useState(D);return P.useEffect(()=>{m(r.jsx("div",{className:"flex flex-row gap-2",children:r.jsx(ve,{filter:{...d},setFilter:p})}))},[d,m]),r.jsx(le,{title:"Report Validations",children:r.jsx(fe,{type:"single",collapsible:!0,children:r.jsx(he,{value:"pcn874",children:r.jsxs(ae,{className:"p-4",children:[r.jsx(de,{children:r.jsx(ce,{children:"Monthly VAT (PCN874)"})}),r.jsx(pe,{children:r.jsx(ue,{children:r.jsx(Me,{filter:d})})})]})})})})};export{Ce as ValidateReportsScreen};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import{D as it,r as m,d7 as Nc,ah as V,dc as kc,ai as ae,j as v,da as vn,dW as It,dX as ge,dY as Ho,dd as Lc,dZ as Vc,d_ as rn,d$ as jc,cZ as rr,u as Wo,K as zr,an as $r,bz as Fc,B as ee,c$ as Bc,N as Ur,ap as Hr,aq as Wr,V as Go,cd as _c,ae as zc,bO as An,ch as $c,bT as Bi,bU as _i,H as sn,aI as Ko,bf as qo,d0 as Uc,i as Xo,e0 as Hc,t as Pe,l as Yo,cM as yn,a as ir,e1 as Wc,dj as Gc,e2 as Kc,dz as qc,dA as Xc,dB as Yc,L as Zo,v as Gr,dm as Zc,dn as Jc,dp as Nn,dq as Qc,dr as zi,ds as eu,dt as $i,du as Jo,dv as Qo,dw as ea,e3 as tu,e4 as nu,e5 as on,e6 as ru,W as iu,aa as su,a0 as ou,a2 as au,a3 as lu,a4 as cu,a5 as uu,a7 as du,aA as hu,ac as Ui,dR as fu,e7 as pu,g as gu,at as mu,as as Hi,e8 as vu,e9 as yu,ea as Wi,c2 as bu,P as Tu,b as xu,bg as Su,b1 as wu,F as Du,aK as Cu,eb as Eu,ec as Ou}from"./index-
|
|
2
|
-
* @license lucide-react v0.
|
|
1
|
+
import{D as it,r as m,d7 as Nc,ah as V,dc as kc,ai as ae,j as v,da as vn,dW as It,dX as ge,dY as Ho,dd as Lc,dZ as Vc,d_ as rn,d$ as jc,cZ as rr,u as Wo,K as zr,an as $r,bz as Fc,B as ee,c$ as Bc,N as Ur,ap as Hr,aq as Wr,V as Go,cd as _c,ae as zc,bO as An,ch as $c,bT as Bi,bU as _i,H as sn,aI as Ko,bf as qo,d0 as Uc,i as Xo,e0 as Hc,t as Pe,l as Yo,cM as yn,a as ir,e1 as Wc,dj as Gc,e2 as Kc,dz as qc,dA as Xc,dB as Yc,L as Zo,v as Gr,dm as Zc,dn as Jc,dp as Nn,dq as Qc,dr as zi,ds as eu,dt as $i,du as Jo,dv as Qo,dw as ea,e3 as tu,e4 as nu,e5 as on,e6 as ru,W as iu,aa as su,a0 as ou,a2 as au,a3 as lu,a4 as cu,a5 as uu,a7 as du,aA as hu,ac as Ui,dR as fu,e7 as pu,g as gu,at as mu,as as Hi,e8 as vu,e9 as yu,ea as Wi,c2 as bu,P as Tu,b as xu,bg as Su,b1 as wu,F as Du,aK as Cu,eb as Eu,ec as Ou}from"./index-DfI9E1Fb.js";import{A as Gi}from"./arrow-up-down-J-i_WnHP.js";import{_ as Pu,a as bn,s as we,g as Kr,u as Ki,c as qr,m as wt,d as sr,T as or}from"./Typography-Cd0kk1vc.js";import{P as Mu}from"./pencil-DNPAJOPL.js";/**
|
|
2
|
+
* @license lucide-react v0.546.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/const Ru=[["path",{d:"m10.852 19.772-.383.924",key:"r7sl7d"}],["path",{d:"m13.148 14.228.383-.923",key:"1d5zpm"}],["path",{d:"M13.148 19.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1ydik7"}],["path",{d:"m13.53 20.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1m1vsf"}],["path",{d:"m14.772 15.852.923-.383",key:"660p6e"}],["path",{d:"m14.772 18.148.923.383",key:"hrcpis"}],["path",{d:"M4.2 15.1a7 7 0 1 1 9.93-9.858A7 7 0 0 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"j2q98n"}],["path",{d:"m9.228 15.852-.923-.383",key:"1p9ong"}],["path",{d:"m9.228 18.148-.923.383",key:"6558rz"}]],Iu=it("cloud-cog",Ru);/**
|
|
7
|
-
* @license lucide-react v0.
|
|
7
|
+
* @license lucide-react v0.546.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/const Au=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Nu=it("cloud-upload",Au);/**
|
|
12
|
-
* @license lucide-react v0.
|
|
12
|
+
* @license lucide-react v0.546.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/const ku=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ta=it("ellipsis",ku);/**
|
|
17
|
-
* @license lucide-react v0.
|
|
17
|
+
* @license lucide-react v0.546.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
21
|
*/const Lu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Vu=it("folder-open",Lu);/**
|
|
22
|
-
* @license lucide-react v0.
|
|
22
|
+
* @license lucide-react v0.546.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
26
|
*/const ju=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Fu=it("folder-plus",ju);/**
|
|
27
|
-
* @license lucide-react v0.
|
|
27
|
+
* @license lucide-react v0.546.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,T as ae,B as U,ao as se,cd as ne,a as D,fw as te,r as x,ae as q,fx as le,fy as z,V,t as f,a0 as oe,fz as ie,db as G,bO as u,bP as k,a2 as de,fA as ce,a3 as me,a4 as ue,a5 as xe,v as ye,a7 as pe,bV as g,bQ as S,H as E,ab as ge,i as W,fB as he,l as _,fC as je,fD as J,e as fe,fE as ve,fF as be,u as Q,cZ as Ne,d0 as Se,c_ as Ee,c$ as we,ch as Fe,X as w,fG as Ce,fH as De,fI as Ie,fJ as Ae,fK as Pe,fL as Re,fM as Te,fN as ke,fO as Me,F as Be,c as Le,L as Ze,fP as Oe}from"./index-B2DG6Av_.js";function Y(t){return e.jsx(ae,{disabled:!t.tooltip,label:t.tooltip,children:e.jsx(U,{variant:"ghost",size:"icon",className:"size-7.5",...t,children:e.jsx(se,{className:"size-5"})})})}const X=({isNewInsert:t=!0,defaultValues:a,month:o,onDone:d,isModifying:l})=>{const{selectableBusinesses:i,fetching:n}=ne(),[{data:c,fetching:y,error:j}]=D({query:te}),{userContext:v}=x.useContext(q),[{data:b,fetching:F,error:R}]=D({query:le}),[{data:I,fetching:M,error:C}]=D({query:z,variables:{employerId:v?.context.adminBusinessId??""}}),[p,N]=x.useState([]),[A,T]=x.useState([]),[K,ee]=x.useState([]),P=a?.month??o,Z=V({defaultValues:{...a,month:P}}),{control:m,handleSubmit:O,formState:{dirtyFields:$},setValue:B}=Z;x.useEffect(()=>{j&&f.error("Error",{description:"Oh no!, we have an error fetching pension funds! 🤥"})},[j]),x.useEffect(()=>{R&&f.error("Error",{description:"Oh no!, we have an error fetching training funds! 🤥"})},[R]),x.useEffect(()=>{C&&f.error("Error",{description:"Oh no!, we have an error employees! 🤥"})},[C]),x.useEffect(()=>{c?.allPensionFunds?.length&&N(c.allPensionFunds.map(r=>({value:r.id,label:r.name})).sort((r,s)=>r.label>s.label?1:-1))},[c,T]),x.useEffect(()=>{b?.allTrainingFunds?.length&&T(b.allTrainingFunds.map(r=>({value:r.id,label:r.name})).sort((r,s)=>r.label>s.label?1:-1))},[b,T]),x.useEffect(()=>{I?.employeesByEmployerId.length&&ee(I.employeesByEmployerId.filter(r=>!r.name.toLocaleLowerCase().includes("batched")).map(r=>({value:r.id,label:r.name})).sort((r,s)=>r.label>s.label?1:-1))},[I,T]),x.useEffect(()=>{!a?.employer&&v?.context.adminBusinessId&&B("employer",v.context.adminBusinessId,{shouldDirty:!0,shouldTouch:!0})},[B,a?.employer,v?.context.adminBusinessId]);const H=r=>{const s=ge(r,$);if(!(t&&(!s?.directPaymentAmount||!s?.employeeId||!s?.employer||!s?.month)))if(s&&Object.keys(s).length>0){if(!t){if(!a)return;s.employeeId??=a.employeeId,s.month??=a.month}d(s)}else d()};function re(r){B("month",E(r,"yyyy-MM-dd"),{shouldDirty:!0,shouldTouch:!0})}return e.jsx(oe,{...Z,children:e.jsxs("form",{onSubmit:O(H),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs(ie,{cols:4,children:[e.jsxs("div",{className:"flex-column h-max justify-start block",children:[e.jsx(G,{defaultDate:P?new Date(P):void 0,defaultValue:P?new Date(P):void 0,onChange:re,popoverProps:{withinPortal:!0}}),e.jsx(u,{name:"employer",control:m,defaultValue:a?.employer,rules:{required:"Required"},render:({field:r,fieldState:s})=>e.jsx(k,{...r,data:i,value:r.value,disabled:n,label:"Employer",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:s.error?.message})}),e.jsx(de,{name:"chargeId",control:m,defaultValue:a?.chargeId,rules:{pattern:{value:ce,message:"Invalid UUID"}},render:({field:r})=>e.jsxs(me,{children:[e.jsx(ue,{children:"Charge ID"}),e.jsx(xe,{children:e.jsx(ye,{...r,value:r.value??void 0})}),e.jsx(pe,{})]})}),e.jsx(u,{name:"employeeId",control:m,defaultValue:a?.employeeId,rules:{required:"Required"},render:({field:r,fieldState:s})=>e.jsx(k,{...r,data:K,value:r.value,disabled:M,label:"Employee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:s.error?.message})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"baseSalary",control:m,defaultValue:a?.baseSalary,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Base Salary",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"globalAdditionalHours",control:m,defaultValue:a?.globalAdditionalHours,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Global Additional Hours",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"bonus",control:m,defaultValue:a?.bonus,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Bonus",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"gift",control:m,defaultValue:a?.gift,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Gift",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"travelAndSubsistence",control:m,defaultValue:a?.travelAndSubsistence,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Travel and Subsistence",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"recovery",control:m,defaultValue:a?.recovery,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Recovery",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency"}})}),e.jsx(u,{name:"vacationTakeout",control:m,defaultValue:a?.vacationTakeout,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Vacation Takeout",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"directPaymentAmount",control:m,defaultValue:a?.directPaymentAmount,rules:{required:"Required"},render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Direct Payment",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"pensionFundId",control:m,defaultValue:a?.pensionFundId,render:({field:r,fieldState:s})=>e.jsx(k,{...r,data:p,value:r.value,disabled:y,label:"Pension Fund",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:s.error?.message})}),e.jsx(u,{name:"pensionEmployeeAmount",control:m,defaultValue:a?.pensionEmployeeAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Pension Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployeePercentage",control:m,defaultValue:a?.pensionEmployeePercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Pension Employee Percentage"})}),e.jsx(u,{name:"pensionEmployerAmount",control:m,defaultValue:a?.pensionEmployerAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Pension Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployerPercentage",control:m,defaultValue:a?.pensionEmployerPercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Pension Employer Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"compensationsEmployerAmount",control:m,defaultValue:a?.compensationsEmployerAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Compensations Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"compensationsEmployerPercentage",control:m,defaultValue:a?.compensationsEmployerPercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Compensations Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"trainingFundId",control:m,defaultValue:a?.trainingFundId,render:({field:r,fieldState:s})=>e.jsx(k,{...r,data:A,value:r.value,disabled:F,label:"Training Fund",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:s.error?.message})}),e.jsx(u,{name:"trainingFundEmployeeAmount",control:m,defaultValue:a?.trainingFundEmployeeAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Training Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployeePercentage",control:m,defaultValue:a?.trainingFundEmployeePercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Training Employee Percentage"})}),e.jsx(u,{name:"trainingFundEmployerAmount",control:m,defaultValue:a?.trainingFundEmployerAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Training Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployerPercentage",control:m,defaultValue:a?.trainingFundEmployerPercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Training Employer Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"socialSecurityAmountEmployee",control:m,defaultValue:a?.socialSecurityAmountEmployee,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Social Security - Employee",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"socialSecurityAmountEmployer",control:m,defaultValue:a?.socialSecurityAmountEmployer,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Social Security - Employer",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"healthPaymentAmount",control:m,defaultValue:a?.healthPaymentAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Health Insurance",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"taxAmount",control:m,defaultValue:a?.taxAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Income Tax",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"zkufot",control:m,defaultValue:a?.zkufot,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,precision:0,label:"Notional Expense",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"workDays",control:m,defaultValue:a?.workDays,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Work Days"})}),e.jsx(u,{name:"addedVacationDays",control:m,defaultValue:a?.addedVacationDays,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Added Vacation Days"})}),e.jsx(u,{name:"vacationDaysBalance",control:m,defaultValue:a?.vacationDaysBalance,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Vacation Days Balance"})}),e.jsx(u,{name:"sicknessDaysBalance",control:m,defaultValue:a?.sicknessDaysBalance,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Sickness Days Balance"})})]})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>O(H),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:l||Object.keys($).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:()=>d(),children:"Cancel"})]})]})})},$e="updateSalaryRecord",He=()=>{const[{fetching:t},a]=W(he),o=x.useCallback(async d=>{const l=`Error updating salary record [${d.salaryRecord.month}] employee [${d.salaryRecord.employeeId}]`,i=$e;f.loading("Updating Salary Record",{id:i});try{const n=await a(d),c=_(n,l,i,"updateSalaryRecord");if(c)return f.success("Success",{id:i,description:"Salary record was updated"}),c.updateSalaryRecord.salaryRecord}catch(n){console.error(`${l}: ${n}`),f.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[a]);return{fetching:t,updateSalaryRecord:o}},Ue=({recordVariables:t,onDone:a})=>t?e.jsx(qe,{recordVariables:t,onDone:a}):null,qe=({recordVariables:t,onDone:a})=>{const{updateSalaryRecord:o,fetching:d}=He(),[{data:l,fetching:i}]=D({query:je,variables:{employeeIDs:[t.employeeId],month:E(new Date(t.month),"yyyy-MM-dd")}}),n=l?.salaryRecordsByDates?.[0],c=x.useCallback(j=>{a(),j&&o({salaryRecord:j})},[a,o]);if(!n?.employer?.id||!n?.employee?.id)return e.jsx(e.Fragment,{});const y={addedVacationDays:n?.vacationDays?.added,baseSalary:n?.baseAmount?.raw,bonus:n?.bonus?.raw,chargeId:n?.charge?.id,compensationsEmployerAmount:n?.compensationsAmount?.raw,compensationsEmployerPercentage:n?.compensationsPercentage,directPaymentAmount:n?.directAmount?.raw,employer:n.employer.id,employeeId:n.employee.id,gift:n?.gift?.raw,globalAdditionalHours:n?.globalAdditionalHoursAmount?.raw,healthPaymentAmount:n?.healthInsuranceAmount?.raw,month:n?.month,pensionEmployeeAmount:n?.pensionEmployeeAmount?.raw,pensionEmployeePercentage:n?.pensionEmployeePercentage,pensionEmployerAmount:n?.pensionEmployerAmount?.raw,pensionEmployerPercentage:n?.pensionEmployerPercentage,pensionFundId:n?.pensionFund?.id,recovery:n?.recovery?.raw,sicknessDaysBalance:n?.sicknessDays?.balance,socialSecurityAmountEmployee:n?.socialSecurityEmployeeAmount?.raw,socialSecurityAmountEmployer:n?.socialSecurityEmployerAmount?.raw,taxAmount:n?.incomeTaxAmount?.raw,trainingFundEmployeeAmount:n?.trainingFundEmployeeAmount?.raw,trainingFundEmployeePercentage:n?.trainingFundEmployeePercentage,trainingFundEmployerAmount:n?.trainingFundEmployerAmount?.raw,trainingFundEmployerPercentage:n?.trainingFundEmployerPercentage,trainingFundId:n?.trainingFund?.id,travelAndSubsistence:n?.travelAndSubsistence?.raw,vacationDaysBalance:n?.vacationDays?.balance,vacationTakeout:n?.vacationTakeout?.raw,workDays:n?.workDays,zkufot:n?.notionalExpense?.raw};return e.jsx(J,{modalSize:"fit-content",position:"bottom",title:e.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Salary Record:"}),e.jsxs("div",{className:"flex flex-row gap-2",children:["month: ",t.month," employeeId: ",t.employeeId]})]}),opened:!!t,onClose:a,children:i||!n?e.jsx(fe,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx(X,{isNewInsert:!1,defaultValues:y,onDone:c,isModifying:d})})},ze="insertSalaryRecords",Ve=()=>{const[{fetching:t},a]=W(ve),o=x.useCallback(async d=>{const l=ze;if(f.loading("Adding salary record",{id:l}),!d.salaryRecords||Array.isArray(d.salaryRecords)&&d.salaryRecords.length===0){f.error("Error",{id:l,description:"No salary records to insert",duration:1e5,closeButton:!0});return}const i=Array.isArray(d.salaryRecords)?d.salaryRecords[0]:d.salaryRecords;if(!i?.directPaymentAmount||!i?.employeeId||!i?.employer||!i?.month){f.error("Error",{id:l,description:"Missing required salary record fields",duration:1e5,closeButton:!0});return}const n=`Error adding salary record [${i.month}] employee [${i.employeeId}]`;try{const c=await a(d),y=_(c,n,l,"insertSalaryRecords");if(y)return f.success("Success",{id:l,description:"Salary record was added"}),y.insertSalaryRecords.salaryRecords[0]}catch(c){console.error(`${n}: ${c}`),f.error("Error",{id:l,description:n,duration:1e5,closeButton:!0})}},[a]);return{fetching:t,insertSalaryRecord:o}},Ge=({insertSalaryRecordParams:t,setInsertSalaryRecord:a})=>{const{insertSalaryRecord:o,fetching:d}=Ve(),l=x.useCallback(i=>{i&&o({salaryRecords:[i]}),a(void 0)},[a,o]);return e.jsx(J,{modalSize:"40%",position:"bottom",title:e.jsx("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Insert Salary Record:"})}),opened:!!t,onClose:()=>a(void 0),children:e.jsx(X,{isNewInsert:!0,onDone:l,isModifying:d,month:t.month})})};function L(){const t=new Date,a=E(t,"yyyy-MM-dd"),o=E(be(t),"yyyy-MM-dd");return{fromDate:a,toDate:o}}function We({filter:t,setFilter:a,closeModal:o}){const{control:d,handleSubmit:l,setValue:i}=V({defaultValues:{...t}}),[n,c]=x.useState([]),{userContext:y}=x.useContext(q),[{data:j,fetching:v,error:b},F]=D({query:z,variables:{employerId:y?.context.adminBusinessId??""},pause:!0});x.useEffect(()=>{F()},[y?.context.adminBusinessId,F]),x.useEffect(()=>{b&&f.error("Error",{description:"Oh no!, we have an error fetching employees! 🤥"})},[b]);const R=p=>{p.employeeIDs?.length===0&&delete p.employeeIDs,a(p),o()};function I(){a({...L()}),o()}x.useEffect(()=>{j?.employeesByEmployerId.length&&c(j.employeesByEmployerId.filter(p=>!p.name.toLocaleLowerCase().includes("batched")).map(p=>({value:p.id,label:p.name})).sort((p,N)=>p.label>N.label?1:-1))},[j,c]);function M([p,N]){if(N){const A=new Date(N.getFullYear(),N.getMonth()+1,0);i("toDate",E(A,"yyyy-MM-dd"))}if(p){const A=new Date(p.getFullYear(),p.getMonth(),1);i("fromDate",E(A,"yyyy-MM-dd"))}}const C=L();return e.jsxs(e.Fragment,{children:[v?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:l(R),children:[e.jsx(G,{type:"range",numberOfColumns:2,defaultValue:[new Date(t?.fromDate??C.fromDate),new Date(t?.toDate??C.toDate)],defaultDate:new Date(t?.fromDate??C.fromDate),onChange:M,popoverProps:{withinPortal:!0}}),e.jsx(u,{name:"employeeIDs",control:d,defaultValue:t.employeeIDs,render:({field:p,fieldState:N})=>e.jsx(Fe,{...p,data:n,value:p.value??[],disabled:v,label:"Employees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:N.error?.message})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:v,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:I,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:o,children:"Cancel"})]})]})]})}function _e({filter:t,setFilter:a}){const[o,d]=x.useState(!1),{get:l,set:i}=Q();x.useEffect(()=>{const c=Ne(t)?null:encodeURIComponent(JSON.stringify(t)),y=l("salariesFilters");c!==y&&i("salariesFilters",c)},[t,l,i]);const n=x.useCallback(c=>{Se(c,t)||a(c)},[t,a]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(Ee,{opened:o,onClose:()=>d(!1),content:e.jsx(We,{filter:t,setFilter:n,closeModal:()=>d(!1)}),modalSize:"xl"}),e.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:e.jsx(we,{className:"size-5"})})]})}const Je=({month:t,setInsertSalaryRecord:a})=>{const o=E(new Date(t),"MMMM yyyy");return e.jsx("tr",{tabIndex:0,className:"h-16 rounded-sm",children:e.jsx("td",{colSpan:100,children:e.jsxs("div",{className:"flex justify-between pl-5",children:[e.jsx("p",{className:"text-lg font-bold text-gray-800",children:o}),e.jsx("div",{className:"flex items-center",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Y,{onClick:a})})})]})})})},Qe=({data:t})=>{const{employee:a,month:o}=w(Ce,t),d=E(new Date(o),"MMMM yyyy");return e.jsx("td",{className:"",children:e.jsx("div",{className:"flex items-center pl-5",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-base font-bold text-gray-800",children:a?.name}),e.jsx("p",{className:"text-base font-medium text-gray-800",children:d})]})})})},Ye=({data:t})=>{const{pensionEmployeeAmount:a,pensionEmployeePercentage:o,pensionEmployerAmount:d,pensionEmployerPercentage:l,compensationsAmount:i,compensationsPercentage:n,pensionFund:c,trainingFund:y,trainingFundEmployeeAmount:j,trainingFundEmployeePercentage:v,trainingFundEmployerAmount:b,trainingFundEmployerPercentage:F}=w(De,t);return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-md font-bold text-gray-800",children:"Pension Fund"}),e.jsx("p",{className:"text-md font-medium text-gray-800",children:c?.name}),!!a?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[a?.formatted,o&&` (${o}%)`]})]}),!!d?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[d?.formatted,l&&` (${l}%)`]})]}),!!i?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Compensations Amount:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[i?.formatted,n&&` (${n}%)`]})]}),e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Training Fund"}),e.jsx("p",{className:"text-md font-medium text-gray-800",children:y?.name}),!!j?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[j?.formatted,v&&` (${v}%)`]})]}),!!b?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[b?.formatted,F&&` (${F}%)`]})]})]})})})},Xe=({data:t})=>{const{healthInsuranceAmount:a,socialSecurityEmployeeAmount:o,socialSecurityEmployerAmount:d,incomeTaxAmount:l,notionalExpense:i}=w(Ie,t),n=!!o||!!d;return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center pl-5",children:e.jsxs("div",{className:"flex flex-col",children:[n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800",children:"Social Security"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o?.formatted})]}),e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Pension Fund"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:d?.formatted})]})]}),!!a?.raw&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Health Insurance"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:a?.formatted})]})]}),(!!l?.raw||!!i?.raw)&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Taxes"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Income Tax:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l?.formatted})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Notional Expense:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i?.formatted})]})]})]})})})},Ke=({data:t})=>{const{baseAmount:a,directAmount:o,globalAdditionalHoursAmount:d,bonus:l,gift:i,recovery:n,vacationTakeout:c}=w(Ae,t);return e.jsx("td",{className:"pl-24",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Base Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:a?.formatted})]}),e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Global Extra Hours:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:d?.formatted})]}),!!l?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Bonus:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l?.formatted})]}),!!i?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Gift:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i?.formatted})]}),!!n?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Recovery:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:n?.formatted})]}),!!c?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Vacation Takeout:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:c?.formatted})]}),e.jsxs("div",{className:"flex justify-between mt-2",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Direct Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o?.formatted})]})]})})})},er=({data:t})=>{const{vacationDays:a,workDays:o,sicknessDays:d}=w(Pe,t),{added:l,taken:i,balance:n}=a??{},{balance:c}=d??{},y=!!l||!!i||!!n;return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[!!o&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md leading-none text-gray-800",children:"Work Days:"}),e.jsx("div",{className:"flex justify-between",children:e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o})})]}),y&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-md leading-none text-gray-800 mt-2",children:"Vacation Days:"}),!!l&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Added:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l})]}),!!i&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Taken:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i})]}),!!n&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Balance:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:n})]})]}),!!c&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md leading-none text-gray-800 mt-2",children:"Sickness Days:"}),e.jsx("div",{className:"flex justify-between",children:e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:c})})]})]})})})},rr=({setEditSalaryRecord:t,data:a})=>{const o=w(Te,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{tabIndex:0,className:"h-16 border border-gray-100 hover:bg-gray-100 rounded-sm",children:[e.jsx(Qe,{data:o}),e.jsx(Ke,{data:o}),e.jsx(Ye,{data:o}),e.jsx(Xe,{data:o}),e.jsx(er,{data:o}),e.jsx("td",{className:"pl-2",children:e.jsx("div",{className:"flex items-center",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Re,{onClick:t})})})})]}),e.jsx("tr",{className:"h-3"})]})},ar=({setEditSalaryRecord:t,setInsertSalaryRecord:a,data:o})=>{const d=o?.map(l=>w(ke,l))??[];return e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"h-3"}),e.jsx(Je,{month:d[0].month,setInsertSalaryRecord:a}),e.jsx("tr",{className:"h-3"}),d.map(l=>e.jsx(rr,{data:l,setEditSalaryRecord:()=>t(l.employee?.id)},`${l.month} ${l.employee?.id}`))]})},sr=({setEditSalaryRecord:t,setInsertSalaryRecord:a,data:o})=>{const d=x.useMemo(()=>{const l=o?.map(n=>w(Me,n))??[],i=new Map;return l.map(n=>{const{month:c}=n,y=i.get(c)??[];i.set(c,[...y,n])}),i},[o]);return e.jsx("div",{className:"sm:px-6 w-full",children:e.jsxs("div",{className:"bg-white py-4 md:py-7 px-4 md:px-8 xl:px-10",children:[e.jsxs("div",{className:"sm:flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800",children:e.jsx("div",{className:"py-2 px-8 bg-indigo-100 text-indigo-700 rounded-full",children:e.jsx("p",{children:"All"})})}),e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800 ml-4 sm:ml-8",children:e.jsx("div",{className:"py-2 px-8 text-gray-600 hover:text-indigo-700 hover:bg-indigo-100 rounded-full ",children:e.jsx("p",{children:"Done"})})}),e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800 ml-4 sm:ml-8",children:e.jsx("div",{className:"py-2 px-8 text-gray-600 hover:text-indigo-700 hover:bg-indigo-100 rounded-full ",children:e.jsx("p",{children:"Pending"})})})]}),e.jsx("button",{className:"focus:ring-2 focus:ring-offset-2 focus:ring-indigo-600 mt-4 sm:mt-0 inline-flex items-start justify-start px-6 py-3 bg-indigo-700 hover:bg-indigo-600 focus:outline-hidden rounded-sm",children:e.jsx("p",{className:"text-sm font-medium leading-none text-white",children:"Add Task"})})]}),e.jsx("div",{className:"mt-7 overflow-x-auto",children:e.jsx("table",{className:"w-full whitespace-nowrap",children:e.jsx("tbody",{children:Array.from(d).map(([l,i])=>e.jsx(ar,{data:i,setEditSalaryRecord:n=>t(n?{month:l,employeeId:n}:void 0),setInsertSalaryRecord:()=>a({month:l})},l))})})})]})})},tr=()=>{const{setFiltersContext:t}=x.useContext(Be),[a,o]=x.useState(void 0),[d,l]=x.useState(void 0),{get:i}=Q(),[n,c]=x.useState(i("salariesFilters")?JSON.parse(decodeURIComponent(i("salariesFilters"))):{...L()}),[{data:y,fetching:j}]=D({query:Oe,variables:{...n}});return x.useEffect(()=>{t(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(_e,{filter:n,setFilter:c}),e.jsx(Y,{variant:"default",onClick:()=>l({})})]}))},[y,j,n,t,c]),e.jsxs(Le,{title:"Salaries",description:"View and manage salaries of employees.",children:[j?e.jsx(Ze,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(sr,{setEditSalaryRecord:o,setInsertSalaryRecord:l,data:y?.salaryRecordsByDates}),e.jsx(Ue,{recordVariables:a,onDone:()=>o(void 0)}),d&&e.jsx(Ge,{insertSalaryRecordParams:d,setInsertSalaryRecord:l})]})};export{tr as Salaries};
|
|
1
|
+
import{j as e,T as ae,B as U,ao as se,cd as ne,a as D,fw as te,r as x,ae as q,fx as le,fy as z,V,t as f,a0 as oe,fz as ie,db as G,bO as u,bP as k,a2 as de,fA as ce,a3 as me,a4 as ue,a5 as xe,v as ye,a7 as pe,bV as g,bQ as S,H as E,ab as ge,i as W,fB as he,l as _,fC as je,fD as J,e as fe,fE as ve,fF as be,u as Q,cZ as Ne,d0 as Se,c_ as Ee,c$ as we,ch as Fe,X as w,fG as Ce,fH as De,fI as Ie,fJ as Ae,fK as Pe,fL as Re,fM as Te,fN as ke,fO as Me,F as Be,c as Le,L as Ze,fP as Oe}from"./index-DfI9E1Fb.js";function Y(t){return e.jsx(ae,{disabled:!t.tooltip,label:t.tooltip,children:e.jsx(U,{variant:"ghost",size:"icon",className:"size-7.5",...t,children:e.jsx(se,{className:"size-5"})})})}const X=({isNewInsert:t=!0,defaultValues:a,month:o,onDone:d,isModifying:l})=>{const{selectableBusinesses:i,fetching:n}=ne(),[{data:c,fetching:y,error:j}]=D({query:te}),{userContext:v}=x.useContext(q),[{data:b,fetching:F,error:R}]=D({query:le}),[{data:I,fetching:M,error:C}]=D({query:z,variables:{employerId:v?.context.adminBusinessId??""}}),[p,N]=x.useState([]),[A,T]=x.useState([]),[K,ee]=x.useState([]),P=a?.month??o,Z=V({defaultValues:{...a,month:P}}),{control:m,handleSubmit:O,formState:{dirtyFields:$},setValue:B}=Z;x.useEffect(()=>{j&&f.error("Error",{description:"Oh no!, we have an error fetching pension funds! 🤥"})},[j]),x.useEffect(()=>{R&&f.error("Error",{description:"Oh no!, we have an error fetching training funds! 🤥"})},[R]),x.useEffect(()=>{C&&f.error("Error",{description:"Oh no!, we have an error employees! 🤥"})},[C]),x.useEffect(()=>{c?.allPensionFunds?.length&&N(c.allPensionFunds.map(r=>({value:r.id,label:r.name})).sort((r,s)=>r.label>s.label?1:-1))},[c,T]),x.useEffect(()=>{b?.allTrainingFunds?.length&&T(b.allTrainingFunds.map(r=>({value:r.id,label:r.name})).sort((r,s)=>r.label>s.label?1:-1))},[b,T]),x.useEffect(()=>{I?.employeesByEmployerId.length&&ee(I.employeesByEmployerId.filter(r=>!r.name.toLocaleLowerCase().includes("batched")).map(r=>({value:r.id,label:r.name})).sort((r,s)=>r.label>s.label?1:-1))},[I,T]),x.useEffect(()=>{!a?.employer&&v?.context.adminBusinessId&&B("employer",v.context.adminBusinessId,{shouldDirty:!0,shouldTouch:!0})},[B,a?.employer,v?.context.adminBusinessId]);const H=r=>{const s=ge(r,$);if(!(t&&(!s?.directPaymentAmount||!s?.employeeId||!s?.employer||!s?.month)))if(s&&Object.keys(s).length>0){if(!t){if(!a)return;s.employeeId??=a.employeeId,s.month??=a.month}d(s)}else d()};function re(r){B("month",E(r,"yyyy-MM-dd"),{shouldDirty:!0,shouldTouch:!0})}return e.jsx(oe,{...Z,children:e.jsxs("form",{onSubmit:O(H),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs(ie,{cols:4,children:[e.jsxs("div",{className:"flex-column h-max justify-start block",children:[e.jsx(G,{defaultDate:P?new Date(P):void 0,defaultValue:P?new Date(P):void 0,onChange:re,popoverProps:{withinPortal:!0}}),e.jsx(u,{name:"employer",control:m,defaultValue:a?.employer,rules:{required:"Required"},render:({field:r,fieldState:s})=>e.jsx(k,{...r,data:i,value:r.value,disabled:n,label:"Employer",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:s.error?.message})}),e.jsx(de,{name:"chargeId",control:m,defaultValue:a?.chargeId,rules:{pattern:{value:ce,message:"Invalid UUID"}},render:({field:r})=>e.jsxs(me,{children:[e.jsx(ue,{children:"Charge ID"}),e.jsx(xe,{children:e.jsx(ye,{...r,value:r.value??void 0})}),e.jsx(pe,{})]})}),e.jsx(u,{name:"employeeId",control:m,defaultValue:a?.employeeId,rules:{required:"Required"},render:({field:r,fieldState:s})=>e.jsx(k,{...r,data:K,value:r.value,disabled:M,label:"Employee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:s.error?.message})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"baseSalary",control:m,defaultValue:a?.baseSalary,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Base Salary",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"globalAdditionalHours",control:m,defaultValue:a?.globalAdditionalHours,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Global Additional Hours",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"bonus",control:m,defaultValue:a?.bonus,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Bonus",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"gift",control:m,defaultValue:a?.gift,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Gift",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"travelAndSubsistence",control:m,defaultValue:a?.travelAndSubsistence,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Travel and Subsistence",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"recovery",control:m,defaultValue:a?.recovery,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Recovery",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency"}})}),e.jsx(u,{name:"vacationTakeout",control:m,defaultValue:a?.vacationTakeout,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Vacation Takeout",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"directPaymentAmount",control:m,defaultValue:a?.directPaymentAmount,rules:{required:"Required"},render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Direct Payment",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"pensionFundId",control:m,defaultValue:a?.pensionFundId,render:({field:r,fieldState:s})=>e.jsx(k,{...r,data:p,value:r.value,disabled:y,label:"Pension Fund",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:s.error?.message})}),e.jsx(u,{name:"pensionEmployeeAmount",control:m,defaultValue:a?.pensionEmployeeAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Pension Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployeePercentage",control:m,defaultValue:a?.pensionEmployeePercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Pension Employee Percentage"})}),e.jsx(u,{name:"pensionEmployerAmount",control:m,defaultValue:a?.pensionEmployerAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Pension Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployerPercentage",control:m,defaultValue:a?.pensionEmployerPercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Pension Employer Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"compensationsEmployerAmount",control:m,defaultValue:a?.compensationsEmployerAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Compensations Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"compensationsEmployerPercentage",control:m,defaultValue:a?.compensationsEmployerPercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Compensations Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"trainingFundId",control:m,defaultValue:a?.trainingFundId,render:({field:r,fieldState:s})=>e.jsx(k,{...r,data:A,value:r.value,disabled:F,label:"Training Fund",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:s.error?.message})}),e.jsx(u,{name:"trainingFundEmployeeAmount",control:m,defaultValue:a?.trainingFundEmployeeAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Training Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployeePercentage",control:m,defaultValue:a?.trainingFundEmployeePercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Training Employee Percentage"})}),e.jsx(u,{name:"trainingFundEmployerAmount",control:m,defaultValue:a?.trainingFundEmployerAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Training Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployerPercentage",control:m,defaultValue:a?.trainingFundEmployerPercentage,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Training Employer Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"socialSecurityAmountEmployee",control:m,defaultValue:a?.socialSecurityAmountEmployee,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Social Security - Employee",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"socialSecurityAmountEmployer",control:m,defaultValue:a?.socialSecurityAmountEmployer,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Social Security - Employer",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"healthPaymentAmount",control:m,defaultValue:a?.healthPaymentAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Health Insurance",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"taxAmount",control:m,defaultValue:a?.taxAmount,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,label:"Income Tax",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"zkufot",control:m,defaultValue:a?.zkufot,render:({field:r,fieldState:s})=>e.jsx(g,{...r,value:r.value??void 0,error:s.error?.message,precision:0,label:"Notional Expense",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"workDays",control:m,defaultValue:a?.workDays,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Work Days"})}),e.jsx(u,{name:"addedVacationDays",control:m,defaultValue:a?.addedVacationDays,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Added Vacation Days"})}),e.jsx(u,{name:"vacationDaysBalance",control:m,defaultValue:a?.vacationDaysBalance,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Vacation Days Balance"})}),e.jsx(u,{name:"sicknessDaysBalance",control:m,defaultValue:a?.sicknessDaysBalance,render:({field:{value:r,...s},fieldState:h})=>e.jsx(S,{...s,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Sickness Days Balance"})})]})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>O(H),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:l||Object.keys($).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:()=>d(),children:"Cancel"})]})]})})},$e="updateSalaryRecord",He=()=>{const[{fetching:t},a]=W(he),o=x.useCallback(async d=>{const l=`Error updating salary record [${d.salaryRecord.month}] employee [${d.salaryRecord.employeeId}]`,i=$e;f.loading("Updating Salary Record",{id:i});try{const n=await a(d),c=_(n,l,i,"updateSalaryRecord");if(c)return f.success("Success",{id:i,description:"Salary record was updated"}),c.updateSalaryRecord.salaryRecord}catch(n){console.error(`${l}: ${n}`),f.error("Error",{id:i,description:l,duration:1e5,closeButton:!0})}},[a]);return{fetching:t,updateSalaryRecord:o}},Ue=({recordVariables:t,onDone:a})=>t?e.jsx(qe,{recordVariables:t,onDone:a}):null,qe=({recordVariables:t,onDone:a})=>{const{updateSalaryRecord:o,fetching:d}=He(),[{data:l,fetching:i}]=D({query:je,variables:{employeeIDs:[t.employeeId],month:E(new Date(t.month),"yyyy-MM-dd")}}),n=l?.salaryRecordsByDates?.[0],c=x.useCallback(j=>{a(),j&&o({salaryRecord:j})},[a,o]);if(!n?.employer?.id||!n?.employee?.id)return e.jsx(e.Fragment,{});const y={addedVacationDays:n?.vacationDays?.added,baseSalary:n?.baseAmount?.raw,bonus:n?.bonus?.raw,chargeId:n?.charge?.id,compensationsEmployerAmount:n?.compensationsAmount?.raw,compensationsEmployerPercentage:n?.compensationsPercentage,directPaymentAmount:n?.directAmount?.raw,employer:n.employer.id,employeeId:n.employee.id,gift:n?.gift?.raw,globalAdditionalHours:n?.globalAdditionalHoursAmount?.raw,healthPaymentAmount:n?.healthInsuranceAmount?.raw,month:n?.month,pensionEmployeeAmount:n?.pensionEmployeeAmount?.raw,pensionEmployeePercentage:n?.pensionEmployeePercentage,pensionEmployerAmount:n?.pensionEmployerAmount?.raw,pensionEmployerPercentage:n?.pensionEmployerPercentage,pensionFundId:n?.pensionFund?.id,recovery:n?.recovery?.raw,sicknessDaysBalance:n?.sicknessDays?.balance,socialSecurityAmountEmployee:n?.socialSecurityEmployeeAmount?.raw,socialSecurityAmountEmployer:n?.socialSecurityEmployerAmount?.raw,taxAmount:n?.incomeTaxAmount?.raw,trainingFundEmployeeAmount:n?.trainingFundEmployeeAmount?.raw,trainingFundEmployeePercentage:n?.trainingFundEmployeePercentage,trainingFundEmployerAmount:n?.trainingFundEmployerAmount?.raw,trainingFundEmployerPercentage:n?.trainingFundEmployerPercentage,trainingFundId:n?.trainingFund?.id,travelAndSubsistence:n?.travelAndSubsistence?.raw,vacationDaysBalance:n?.vacationDays?.balance,vacationTakeout:n?.vacationTakeout?.raw,workDays:n?.workDays,zkufot:n?.notionalExpense?.raw};return e.jsx(J,{modalSize:"fit-content",position:"bottom",title:e.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Salary Record:"}),e.jsxs("div",{className:"flex flex-row gap-2",children:["month: ",t.month," employeeId: ",t.employeeId]})]}),opened:!!t,onClose:a,children:i||!n?e.jsx(fe,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx(X,{isNewInsert:!1,defaultValues:y,onDone:c,isModifying:d})})},ze="insertSalaryRecords",Ve=()=>{const[{fetching:t},a]=W(ve),o=x.useCallback(async d=>{const l=ze;if(f.loading("Adding salary record",{id:l}),!d.salaryRecords||Array.isArray(d.salaryRecords)&&d.salaryRecords.length===0){f.error("Error",{id:l,description:"No salary records to insert",duration:1e5,closeButton:!0});return}const i=Array.isArray(d.salaryRecords)?d.salaryRecords[0]:d.salaryRecords;if(!i?.directPaymentAmount||!i?.employeeId||!i?.employer||!i?.month){f.error("Error",{id:l,description:"Missing required salary record fields",duration:1e5,closeButton:!0});return}const n=`Error adding salary record [${i.month}] employee [${i.employeeId}]`;try{const c=await a(d),y=_(c,n,l,"insertSalaryRecords");if(y)return f.success("Success",{id:l,description:"Salary record was added"}),y.insertSalaryRecords.salaryRecords[0]}catch(c){console.error(`${n}: ${c}`),f.error("Error",{id:l,description:n,duration:1e5,closeButton:!0})}},[a]);return{fetching:t,insertSalaryRecord:o}},Ge=({insertSalaryRecordParams:t,setInsertSalaryRecord:a})=>{const{insertSalaryRecord:o,fetching:d}=Ve(),l=x.useCallback(i=>{i&&o({salaryRecords:[i]}),a(void 0)},[a,o]);return e.jsx(J,{modalSize:"40%",position:"bottom",title:e.jsx("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Insert Salary Record:"})}),opened:!!t,onClose:()=>a(void 0),children:e.jsx(X,{isNewInsert:!0,onDone:l,isModifying:d,month:t.month})})};function L(){const t=new Date,a=E(t,"yyyy-MM-dd"),o=E(be(t),"yyyy-MM-dd");return{fromDate:a,toDate:o}}function We({filter:t,setFilter:a,closeModal:o}){const{control:d,handleSubmit:l,setValue:i}=V({defaultValues:{...t}}),[n,c]=x.useState([]),{userContext:y}=x.useContext(q),[{data:j,fetching:v,error:b},F]=D({query:z,variables:{employerId:y?.context.adminBusinessId??""},pause:!0});x.useEffect(()=>{F()},[y?.context.adminBusinessId,F]),x.useEffect(()=>{b&&f.error("Error",{description:"Oh no!, we have an error fetching employees! 🤥"})},[b]);const R=p=>{p.employeeIDs?.length===0&&delete p.employeeIDs,a(p),o()};function I(){a({...L()}),o()}x.useEffect(()=>{j?.employeesByEmployerId.length&&c(j.employeesByEmployerId.filter(p=>!p.name.toLocaleLowerCase().includes("batched")).map(p=>({value:p.id,label:p.name})).sort((p,N)=>p.label>N.label?1:-1))},[j,c]);function M([p,N]){if(N){const A=new Date(N.getFullYear(),N.getMonth()+1,0);i("toDate",E(A,"yyyy-MM-dd"))}if(p){const A=new Date(p.getFullYear(),p.getMonth(),1);i("fromDate",E(A,"yyyy-MM-dd"))}}const C=L();return e.jsxs(e.Fragment,{children:[v?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:l(R),children:[e.jsx(G,{type:"range",numberOfColumns:2,defaultValue:[new Date(t?.fromDate??C.fromDate),new Date(t?.toDate??C.toDate)],defaultDate:new Date(t?.fromDate??C.fromDate),onChange:M,popoverProps:{withinPortal:!0}}),e.jsx(u,{name:"employeeIDs",control:d,defaultValue:t.employeeIDs,render:({field:p,fieldState:N})=>e.jsx(Fe,{...p,data:n,value:p.value??[],disabled:v,label:"Employees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:N.error?.message})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:v,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:I,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:o,children:"Cancel"})]})]})]})}function _e({filter:t,setFilter:a}){const[o,d]=x.useState(!1),{get:l,set:i}=Q();x.useEffect(()=>{const c=Ne(t)?null:encodeURIComponent(JSON.stringify(t)),y=l("salariesFilters");c!==y&&i("salariesFilters",c)},[t,l,i]);const n=x.useCallback(c=>{Se(c,t)||a(c)},[t,a]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(Ee,{opened:o,onClose:()=>d(!1),content:e.jsx(We,{filter:t,setFilter:n,closeModal:()=>d(!1)}),modalSize:"xl"}),e.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:e.jsx(we,{className:"size-5"})})]})}const Je=({month:t,setInsertSalaryRecord:a})=>{const o=E(new Date(t),"MMMM yyyy");return e.jsx("tr",{tabIndex:0,className:"h-16 rounded-sm",children:e.jsx("td",{colSpan:100,children:e.jsxs("div",{className:"flex justify-between pl-5",children:[e.jsx("p",{className:"text-lg font-bold text-gray-800",children:o}),e.jsx("div",{className:"flex items-center",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Y,{onClick:a})})})]})})})},Qe=({data:t})=>{const{employee:a,month:o}=w(Ce,t),d=E(new Date(o),"MMMM yyyy");return e.jsx("td",{className:"",children:e.jsx("div",{className:"flex items-center pl-5",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-base font-bold text-gray-800",children:a?.name}),e.jsx("p",{className:"text-base font-medium text-gray-800",children:d})]})})})},Ye=({data:t})=>{const{pensionEmployeeAmount:a,pensionEmployeePercentage:o,pensionEmployerAmount:d,pensionEmployerPercentage:l,compensationsAmount:i,compensationsPercentage:n,pensionFund:c,trainingFund:y,trainingFundEmployeeAmount:j,trainingFundEmployeePercentage:v,trainingFundEmployerAmount:b,trainingFundEmployerPercentage:F}=w(De,t);return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-md font-bold text-gray-800",children:"Pension Fund"}),e.jsx("p",{className:"text-md font-medium text-gray-800",children:c?.name}),!!a?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[a?.formatted,o&&` (${o}%)`]})]}),!!d?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[d?.formatted,l&&` (${l}%)`]})]}),!!i?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Compensations Amount:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[i?.formatted,n&&` (${n}%)`]})]}),e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Training Fund"}),e.jsx("p",{className:"text-md font-medium text-gray-800",children:y?.name}),!!j?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[j?.formatted,v&&` (${v}%)`]})]}),!!b?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[b?.formatted,F&&` (${F}%)`]})]})]})})})},Xe=({data:t})=>{const{healthInsuranceAmount:a,socialSecurityEmployeeAmount:o,socialSecurityEmployerAmount:d,incomeTaxAmount:l,notionalExpense:i}=w(Ie,t),n=!!o||!!d;return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center pl-5",children:e.jsxs("div",{className:"flex flex-col",children:[n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800",children:"Social Security"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o?.formatted})]}),e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Pension Fund"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:d?.formatted})]})]}),!!a?.raw&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Health Insurance"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:a?.formatted})]})]}),(!!l?.raw||!!i?.raw)&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Taxes"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Income Tax:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l?.formatted})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Notional Expense:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i?.formatted})]})]})]})})})},Ke=({data:t})=>{const{baseAmount:a,directAmount:o,globalAdditionalHoursAmount:d,bonus:l,gift:i,recovery:n,vacationTakeout:c}=w(Ae,t);return e.jsx("td",{className:"pl-24",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Base Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:a?.formatted})]}),e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Global Extra Hours:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:d?.formatted})]}),!!l?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Bonus:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l?.formatted})]}),!!i?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Gift:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i?.formatted})]}),!!n?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Recovery:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:n?.formatted})]}),!!c?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Vacation Takeout:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:c?.formatted})]}),e.jsxs("div",{className:"flex justify-between mt-2",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Direct Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o?.formatted})]})]})})})},er=({data:t})=>{const{vacationDays:a,workDays:o,sicknessDays:d}=w(Pe,t),{added:l,taken:i,balance:n}=a??{},{balance:c}=d??{},y=!!l||!!i||!!n;return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[!!o&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md leading-none text-gray-800",children:"Work Days:"}),e.jsx("div",{className:"flex justify-between",children:e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o})})]}),y&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-md leading-none text-gray-800 mt-2",children:"Vacation Days:"}),!!l&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Added:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l})]}),!!i&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Taken:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i})]}),!!n&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Balance:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:n})]})]}),!!c&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md leading-none text-gray-800 mt-2",children:"Sickness Days:"}),e.jsx("div",{className:"flex justify-between",children:e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:c})})]})]})})})},rr=({setEditSalaryRecord:t,data:a})=>{const o=w(Te,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{tabIndex:0,className:"h-16 border border-gray-100 hover:bg-gray-100 rounded-sm",children:[e.jsx(Qe,{data:o}),e.jsx(Ke,{data:o}),e.jsx(Ye,{data:o}),e.jsx(Xe,{data:o}),e.jsx(er,{data:o}),e.jsx("td",{className:"pl-2",children:e.jsx("div",{className:"flex items-center",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Re,{onClick:t})})})})]}),e.jsx("tr",{className:"h-3"})]})},ar=({setEditSalaryRecord:t,setInsertSalaryRecord:a,data:o})=>{const d=o?.map(l=>w(ke,l))??[];return e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"h-3"}),e.jsx(Je,{month:d[0].month,setInsertSalaryRecord:a}),e.jsx("tr",{className:"h-3"}),d.map(l=>e.jsx(rr,{data:l,setEditSalaryRecord:()=>t(l.employee?.id)},`${l.month} ${l.employee?.id}`))]})},sr=({setEditSalaryRecord:t,setInsertSalaryRecord:a,data:o})=>{const d=x.useMemo(()=>{const l=o?.map(n=>w(Me,n))??[],i=new Map;return l.map(n=>{const{month:c}=n,y=i.get(c)??[];i.set(c,[...y,n])}),i},[o]);return e.jsx("div",{className:"sm:px-6 w-full",children:e.jsxs("div",{className:"bg-white py-4 md:py-7 px-4 md:px-8 xl:px-10",children:[e.jsxs("div",{className:"sm:flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800",children:e.jsx("div",{className:"py-2 px-8 bg-indigo-100 text-indigo-700 rounded-full",children:e.jsx("p",{children:"All"})})}),e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800 ml-4 sm:ml-8",children:e.jsx("div",{className:"py-2 px-8 text-gray-600 hover:text-indigo-700 hover:bg-indigo-100 rounded-full ",children:e.jsx("p",{children:"Done"})})}),e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800 ml-4 sm:ml-8",children:e.jsx("div",{className:"py-2 px-8 text-gray-600 hover:text-indigo-700 hover:bg-indigo-100 rounded-full ",children:e.jsx("p",{children:"Pending"})})})]}),e.jsx("button",{className:"focus:ring-2 focus:ring-offset-2 focus:ring-indigo-600 mt-4 sm:mt-0 inline-flex items-start justify-start px-6 py-3 bg-indigo-700 hover:bg-indigo-600 focus:outline-hidden rounded-sm",children:e.jsx("p",{className:"text-sm font-medium leading-none text-white",children:"Add Task"})})]}),e.jsx("div",{className:"mt-7 overflow-x-auto",children:e.jsx("table",{className:"w-full whitespace-nowrap",children:e.jsx("tbody",{children:Array.from(d).map(([l,i])=>e.jsx(ar,{data:i,setEditSalaryRecord:n=>t(n?{month:l,employeeId:n}:void 0),setInsertSalaryRecord:()=>a({month:l})},l))})})})]})})},tr=()=>{const{setFiltersContext:t}=x.useContext(Be),[a,o]=x.useState(void 0),[d,l]=x.useState(void 0),{get:i}=Q(),[n,c]=x.useState(i("salariesFilters")?JSON.parse(decodeURIComponent(i("salariesFilters"))):{...L()}),[{data:y,fetching:j}]=D({query:Oe,variables:{...n}});return x.useEffect(()=>{t(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(_e,{filter:n,setFilter:c}),e.jsx(Y,{variant:"default",onClick:()=>l({})})]}))},[y,j,n,t,c]),e.jsxs(Le,{title:"Salaries",description:"View and manage salaries of employees.",children:[j?e.jsx(Ze,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(sr,{setEditSalaryRecord:o,setInsertSalaryRecord:l,data:y?.salaryRecordsByDates}),e.jsx(Ue,{recordVariables:a,onDone:()=>o(void 0)}),d&&e.jsx(Ge,{insertSalaryRecordParams:d,setInsertSalaryRecord:l})]})};export{tr as Salaries};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,r as x,c_ as v,eK as g,B as D,c$ as R,X as h,f5 as j,bp as E,F as y,a as w,c as C,L as T,ca as b,bz as A,e8 as F,T as u,f6 as I}from"./index-
|
|
1
|
+
import{j as n,r as x,c_ as v,eK as g,B as D,c$ as R,X as h,f5 as j,bp as E,F as y,a as w,c as C,L as T,ca as b,bz as A,e8 as F,T as u,f6 as I}from"./index-DfI9E1Fb.js";import{d as N}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";const o=({originalAmount:a,diffAmount:t})=>!t||a===t?n.jsx("td",{children:a}):n.jsx("td",{children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:t?"line-through":"",children:a}),t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:t})]})});function P({years:a,setYears:t}){const[r,l]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(v,{opened:r,onClose:()=>l(!1),withCloseButton:!0,content:n.jsx(g,{type:"multiple",label:"Pick years",value:a?.map(c=>new Date(c,0,1)),onChange:c=>t(c.map(p=>p.getFullYear())),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})}),n.jsx(D,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:n.jsx(R,{className:"size-5"})})]})}const f=({originalRuleData:a,diffRuleData:t})=>{const r=h(j,a),l=h(j,t),c=l?.isCompliant!==r.isCompliant||l?.percentage.formatted!==r.percentage.formatted;return!l||!c?n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:r.percentage.formatted}):n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:"line-through ".concat(r.isCompliant?"text-green-500":"text-red-500"),children:r.percentage.formatted}),l&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md ".concat(l.isCompliant?"text-green-500":"text-red-500"),children:l.percentage.formatted})]})})},d=(a,t)=>F(t).format(a);function m(a,t){if(a.length!==0)return d(a.reduce((r,l)=>r+l,0),t)}const B=()=>{const{year:a}=E(),{setFiltersContext:t}=x.useContext(y),[r,l]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:c,fetching:p}]=w({query:N(I),variables:{years:r}});x.useEffect(()=>{t(n.jsx("div",{className:"flex flex-row gap-2",children:n.jsx(P,{years:r,setYears:l})}))},[r,p,t]);const s=c?.corporateTaxRulingComplianceReport??[];return n.jsx(C,{title:"Corporate Tax Ruling Compliance Report",children:p?n.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-4",children:s&&n.jsxs(b,{highlightOnHover:!0,fontSize:"md",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{}),r.map(e=>n.jsx("th",{children:n.jsx(A,{inline:!0,size:12,processing:!s.find(i=>i.year===e)?.differences,disabled:!!s.find(i=>i.year===e)?.differences,color:"orange",zIndex:"auto",children:e})},e)),n.jsx("th",{children:"Summary"},"sum")]})}),n.jsxs("tbody",{children:[n.jsxs("tr",{children:[n.jsx("td",{children:"Total Income"}),s.map(e=>n.jsx(o,{originalAmount:e.totalIncome.formatted,diffAmount:e.differences?.totalIncome?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.totalIncome.raw).reduce((e,i)=>e+i,0),s[0].totalIncome.currency),diffAmount:m(s.map(e=>e.differences?.totalIncome?.raw??e.totalIncome.raw).filter(e=>!!e),s[0].totalIncome.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Total R&D Expensess"}),s.map(e=>n.jsx(o,{originalAmount:e.researchAndDevelopmentExpenses.formatted,diffAmount:e.differences?.researchAndDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].researchAndDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.researchAndDevelopmentExpenses?.raw??e.researchAndDevelopmentExpenses.raw).filter(e=>!!e),s[0].researchAndDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.rndRelativeToIncome.rule,children:n.jsx("p",{children:"R&D Expenses out of Income"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.rndRelativeToIncome,diffRuleData:e.differences?.rndRelativeToIncome??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Local Development Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.localDevelopmentExpenses.formatted,diffAmount:e.differences?.localDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].localDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.localDevelopmentExpenses?.raw??e.localDevelopmentExpenses.raw).filter(e=>!!e),s[0].localDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.localDevelopmentRelativeToRnd.rule,children:n.jsx("p",{children:"Local Development out of R&D"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.localDevelopmentRelativeToRnd,diffRuleData:e.differences?.localDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Foreign Development Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.foreignDevelopmentExpenses.formatted,diffAmount:e.differences?.foreignDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].foreignDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.foreignDevelopmentExpenses?.raw??e.foreignDevelopmentExpenses.raw).filter(e=>!!e),s[0].foreignDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.foreignDevelopmentRelativeToRnd.rule,children:n.jsx("p",{children:"Foreign Development out of R&D"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.foreignDevelopmentRelativeToRnd,diffRuleData:e.differences?.foreignDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"R&D Business Trips Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.businessTripRndExpenses.formatted,diffAmount:e.differences?.businessTripRndExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,i)=>e+i,0),s[0].businessTripRndExpenses.currency),diffAmount:m(s.map(e=>e.differences?.businessTripRndExpenses?.raw??e.businessTripRndExpenses.raw).filter(e=>!!e),s[0].businessTripRndExpenses.currency)},"sum")]})]})]})})})};export{B as CorporateTaxRulingComplianceReport};
|