@accounter/client 0.0.8-alpha-20251027003629-e64c01111f4a4cec34d5ca9a84e02646b69f80b1 → 0.0.8-alpha-20251027125446-75cc2031ef62f7abf48ecfbd31f62ddbddee2bd8
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-DjollWGm.js → Checkbox-BzSHHEEI.js} +2 -2
- package/dist/assets/{Progress-AG7ZMAJu.js → Progress-CmZjJ77Z.js} +1 -1
- package/dist/assets/{Typography-Cd0kk1vc.js → Typography-CuW3aX-4.js} +1 -1
- package/dist/assets/{accordion-s9Ku08QQ.js → accordion-BZB-JxAM.js} +1 -1
- package/dist/assets/{accountant-approvals-Bqrsn1y5.js → accountant-approvals-BtF90Myx.js} +1 -1
- package/dist/assets/{all-charges-BQcsaMon.js → all-charges-X26mmfb3.js} +1 -1
- package/dist/assets/{arrow-up-down-J-i_WnHP.js → arrow-up-down-_p0E2yis.js} +1 -1
- package/dist/assets/{building-2-B92gXbOj.js → building-2-CKq13SAn.js} +1 -1
- package/dist/assets/business--pLros0g.js +27 -0
- package/dist/assets/{business-header-Cr5S_Mz7.js → business-header-C8fXEo4_.js} +1 -1
- package/dist/assets/{business-transactions-single-BD4bLNv2.js → business-transactions-single-CXmdF2-o.js} +1 -1
- package/dist/assets/{business-trip-DYkKK6Gk.js → business-trip-wd9Embtb.js} +1 -1
- package/dist/assets/{charges-filters-CoFkjW00.js → charges-filters-Fu2ZAzWC.js} +1 -1
- package/dist/assets/{charges-ledger-validation-D_cg1bn-.js → charges-ledger-validation-BXXhWS5W.js} +1 -1
- package/dist/assets/{chart-CQ9Opsuw.js → chart-3ddx32Qz.js} +1 -1
- package/dist/assets/{data-table-pagination-CN5CnGZV.js → data-table-pagination-BopLOYg9.js} +1 -1
- package/dist/assets/{editable-business-trip--kNXo9tv.js → editable-business-trip-C34Ue7Hf.js} +2 -2
- package/dist/assets/{index-BNtiIPMq.js → index-B0uGI3EC.js} +1 -1
- package/dist/assets/{index-BGHdyfCs.js → index-B6vWXPp8.js} +1 -1
- package/dist/assets/{index-n3bzj3IE.js → index-BEtUypi7.js} +2 -2
- package/dist/assets/{index-CC_fLCrA.js → index-BGW4bQ-L.js} +1 -1
- package/dist/assets/{index-Cw9zbBbJ.js → index-BpCZ3X72.js} +7 -7
- package/dist/assets/{index-C3pV-XkD.js → index-BsqMXEt3.js} +2 -2
- package/dist/assets/{index-DNTlYcfH.js → index-CkFRewFP.js} +2 -2
- package/dist/assets/{index-hr9hQe_a.js → index-Cr24h-Cl.js} +1 -1
- package/dist/assets/{index-Au8Djmrz.js → index-CuczBTlN.js} +1 -1
- package/dist/assets/{index-DzNfXERJ.js → index-CvS1Q-ya.js} +1 -1
- package/dist/assets/{index-DDGgWxhe.js → index-DA1mkO2v.js} +2 -2
- package/dist/assets/{index-DfI9E1Fb.js → index-DL8q44ap.js} +263 -258
- package/dist/assets/{index-fwXllLnH.js → index-DeQnadsl.js} +1 -1
- package/dist/assets/{index-DS_RReq_.js → index-Dia_wOFb.js} +1 -1
- package/dist/assets/{index-DepseT6D.js → index-HzZyyExI.js} +1 -1
- package/dist/assets/{index-C7al3ztL.js → index-JfxexlPg.js} +2 -2
- package/dist/assets/{index-BWpLPx22.js → index-PaJBRncn.js} +1 -1
- package/dist/assets/index-SmrmFP8m.js +1 -0
- package/dist/assets/{index-BSmbKLQe.js → index-cZSBCnNJ.js} +2 -2
- package/dist/assets/{index-CS40C1qp.js → index-dP8CSci_.js} +1 -1
- package/dist/assets/{index-Cc4HfGhd.js → index-o-HWUpBy.js} +1 -1
- package/dist/assets/{index--XWh2RKR.js → index-pjGYYOoy.js} +1 -1
- package/dist/assets/{index-C66UYUUf.js → index-szVd1r0-.js} +1 -1
- package/dist/assets/{index.es-CKlpQqlO.js → index.es-ZISWba9V.js} +1 -1
- package/dist/assets/{issue-document-B4kkfOo0.js → issue-document-B-c96E9w.js} +1 -1
- package/dist/assets/{login-page-NvQKYh34.js → login-page-C_RNlOZS.js} +1 -1
- package/dist/assets/{missing-info-charges-DrF2b0mO.js → missing-info-charges-BrFjY7yz.js} +1 -1
- package/dist/assets/{page-not-found-7AAOkZhu.js → page-not-found-s0xtsc5O.js} +1 -1
- package/dist/assets/{pencil-DNPAJOPL.js → pencil-D-2dJ444.js} +1 -1
- package/dist/assets/{report-commentary-row-CF-l1YIC.js → report-commentary-row-aIxbqTgK.js} +1 -1
- package/dist/assets/{save-D84vX5ea.js → save-DZ9jxz9u.js} +1 -1
- package/dist/assets/{sub-BbpGm1pj.js → sub-o9iEG2Bl.js} +1 -1
- package/dist/assets/subMonths-CpJ3oidH.js +1 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/clients/modify-client-dialog.tsx +27 -9
- package/src/components/common/modals/insert-business.tsx +87 -36
- package/src/components/layout/user-nav.tsx +25 -3
- package/dist/assets/business-CfqFJUkR.js +0 -32
- package/dist/assets/index-DVbMTBK4.js +0 -1
- package/dist/assets/subMonths-0tIJizDp.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,cZ as w,u as P,d0 as O,j as e,c_ as V,bz as U,B as c,c$ as z,ae as K,V as _,H as b,dh as B,a0 as H,di as L,bO as D,ch as M,bT as I,bU as T,a2 as q,a3 as G,a4 as J,a5 as Q,aI as X,bu as Z,F as $,a as W,dj as Y,c as ee,L as te,dk as se,dl as ae,dm as ne,dn as le,dp as S,dq as re,dr as k,ds as ie,dt as R,du as oe,dv as ce,dw as de,dx as me,dy as ue,dz as ge,dA as he,dB as xe}from"./index-DfI9E1Fb.js";import{D as je}from"./data-table-pagination-CN5CnGZV.js";import{s as pe}from"./sub-BbpGm1pj.js";import{A as v}from"./arrow-up-down-J-i_WnHP.js";import"./subMonths-0tIJizDp.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:j}=l.useContext(K),h=_({defaultValues:{ownerIDs:j?.context.adminBusinessId?[j.context.adminBusinessId]:void 0,toDate:b(new Date,"yyyy-MM-dd"),fromDate:b(pe(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=h,{selectableFinancialEntities:r,fetching:d}=B(),C=a=>{s(a),x()};function m(){s({}),x()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(H,{...h,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(L,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:d,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(T,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(T,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(q,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(G,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(J,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(X,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:d,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:m,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:x,children:"Cancel"})]})]})})]})}function ve({filter:t={},setFilter:s,initiallyOpened:x=!1}){const[j,h]=l.useState(x),[o,y]=l.useState(!w(t)),{get:r,set:d}=P();l.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=r("documentsFilters");m!==a&&d("documentsFilters",m)},[t,r,d]);const C=l.useCallback(m=>{O(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(V,{opened:j,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(U,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(!0),children:e.jsx(z,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(c,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:b(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(Z,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?b(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?b(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],we=()=>{const[t,s]=l.useState(null),[x,j]=l.useState(!1),{get:h}=P(),o=h("documentsFilters"),y=l.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[r,d]=l.useState(y),[C,m]=l.useState([]),[a,g]=l.useState({}),{setFiltersContext:i}=l.useContext($),[{data:p,fetching:F},N]=W({query:ue,variables:{filters:r??{}},pause:!0});l.useEffect(()=>{r&&N()},[r,N]);const f=Y({data:p?.documentsByFilters??[],columns:E,getCoreRowModel:xe(),getPaginationRowModel:he(),onSortingChange:m,getSortedRowModel:ge(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),A=f.getState().pagination.pageIndex;return l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(je,{table:f}),e.jsx(ve,{filter:r,setFilter:d,initiallyOpened:!r})]}))},[f,F,r,i,d,y,A]),e.jsx(ee,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsx(c,{className:"ml-auto",children:"Columns"})}),e.jsx(de,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(me,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(c,{onClick:()=>j(!0),children:"Upload Documents"})]}),children:F?e.jsx(te,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(se,{open:x,onOpenChange:j,onChange:N}),t&&e.jsx(V,{modalSize:"45%",content:e.jsx(ae,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(ne,{children:[e.jsx(le,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(re,{children:u.isPlaceholder?null:k(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ie,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(R,{children:k(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(R,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{we as DocumentsReport,E as columns};
|
|
1
|
+
import{r as l,c_ as w,u as P,d1 as O,j as e,c$ as V,bA as U,B as c,d0 as K,af as z,V as _,H as b,di as B,a1 as H,dj as L,bP as D,ci as M,bU as I,bV as T,a3 as q,a4 as G,a5 as J,a6 as Q,ap as X,bv as $,F as W,a as Y,dk as Z,c as ee,L as te,dl as se,dm as ae,dn as ne,dp as le,dq as S,dr as re,ds as k,dt as ie,du as R,dv as oe,dw as ce,dx as de,dy as me,dz as ue,dA as ge,dB as xe,dC as he}from"./index-DL8q44ap.js";import{D as je}from"./data-table-pagination-BopLOYg9.js";import{s as pe}from"./sub-o9iEG2Bl.js";import{A as v}from"./arrow-up-down-_p0E2yis.js";import"./subMonths-CpJ3oidH.js";function fe({filter:t,setFilter:s,closeModal:h}){const{userContext:j}=l.useContext(z),x=_({defaultValues:{ownerIDs:j?.context.adminBusinessId?[j.context.adminBusinessId]:void 0,toDate:b(new Date,"yyyy-MM-dd"),fromDate:b(pe(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=x,{selectableFinancialEntities:r,fetching:d}=B(),C=a=>{s(a),h()};function m(){s({}),h()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(H,{...x,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(L,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:d,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(T,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(T,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(q,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(G,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(J,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(X,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:d,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:m,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:h,children:"Cancel"})]})]})})]})}function ve({filter:t={},setFilter:s,initiallyOpened:h=!1}){const[j,x]=l.useState(h),[o,y]=l.useState(!w(t)),{get:r,set:d}=P();l.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=r("documentsFilters");m!==a&&d("documentsFilters",m)},[t,r,d]);const C=l.useCallback(m=>{O(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(V,{opened:j,onClose:()=>x(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>x(!1)}),modalSize:"xl"}),e.jsx(U,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(K,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(c,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:b(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx($,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?b(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?b(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],we=()=>{const[t,s]=l.useState(null),[h,j]=l.useState(!1),{get:x}=P(),o=x("documentsFilters"),y=l.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[r,d]=l.useState(y),[C,m]=l.useState([]),[a,g]=l.useState({}),{setFiltersContext:i}=l.useContext(W),[{data:p,fetching:F},N]=Y({query:ue,variables:{filters:r??{}},pause:!0});l.useEffect(()=>{r&&N()},[r,N]);const f=Z({data:p?.documentsByFilters??[],columns:E,getCoreRowModel:he(),getPaginationRowModel:xe(),onSortingChange:m,getSortedRowModel:ge(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),A=f.getState().pagination.pageIndex;return l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(je,{table:f}),e.jsx(ve,{filter:r,setFilter:d,initiallyOpened:!r})]}))},[f,F,r,i,d,y,A]),e.jsx(ee,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(oe,{children:[e.jsx(ce,{asChild:!0,children:e.jsx(c,{className:"ml-auto",children:"Columns"})}),e.jsx(de,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(me,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(c,{onClick:()=>j(!0),children:"Upload Documents"})]}),children:F?e.jsx(te,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(se,{open:h,onOpenChange:j,onChange:N}),t&&e.jsx(V,{modalSize:"45%",content:e.jsx(ae,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(ne,{children:[e.jsx(le,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(re,{children:u.isPlaceholder?null:k(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ie,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(R,{children:k(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(R,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{we as DocumentsReport,E as columns};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as e,
|
|
1
|
+
import{r as h,j as e,c$ as u,eL as f,B as y,d0 as R,bq as D,F as T,a as E,c as b,L as w,cb as F,eN as g}from"./index-DL8q44ap.js";import{d as v}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{R as d}from"./report-commentary-row-aIxbqTgK.js";function B({year:c,setYear:m,referenceYears:x,setReferenceYears:j}){const[i,o]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(u,{opened:i,onClose:()=>o(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Change report year",value:new Date(c,0,1),onChange:n=>n&&m(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(f,{type:"multiple",label:"Pick reference years",value:x?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(l=>l.getFullYear()).filter(l=>c!==l)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(!0),children:e.jsx(R,{className:"size-5"})})]})}const Y=()=>{const{year:c}=D(),{setFiltersContext:m}=h.useContext(T),[x,j]=h.useState(c?Number(c):new Date().getFullYear()),[i,o]=h.useState([]),[{data:n,fetching:l}]=E({query:v(g),variables:{reportYear:x,referenceYears:i}});h.useEffect(()=>{m(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(B,{year:x,setYear:j,referenceYears:i,setReferenceYears:o})}))},[x,l,m,i,o]);const p=n?.taxReport,s=p?.report,r=p?.reference??[];return e.jsx(b,{title:"Tax Report",children:l?e.jsx(w,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:s&&e.jsxs(F,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:x},x),e.jsx("th",{}),r.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:"Profit Before Tax"}),e.jsx("th",{children:s.profitBeforeTax.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("th",{children:a.profitBeforeTax.amount.formatted},a.year))]}),commentaryData:s.profitBeforeTax}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses By Records"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesByRecords.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpensesByRecords.amount.formatted},a.year))]}),commentaryData:s.researchAndDevelopmentExpensesByRecords}),e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses For Tax"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesForTax.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.researchAndDevelopmentExpensesForTax.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Fines"}),e.jsx("td",{children:s.fines.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.fines.amount.formatted},a.year))]}),commentaryData:s.fines}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Untaxable Gifts"}),e.jsx("td",{children:s.untaxableGifts.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.untaxableGifts.amount.formatted},a.year))]}),commentaryData:s.untaxableGifts}),e.jsxs("tr",{children:[e.jsx("td",{children:"Business Trips Excess Expenses"}),e.jsx("td",{children:s.businessTripsExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.businessTripsExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Salary Excess Expenses"}),e.jsx("td",{children:s.salaryExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.salaryExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Reserves"}),e.jsx("td",{children:s.reserves.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.reserves.amount.formatted},a.year))]}),commentaryData:s.reserves}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Nontaxable Linkage"}),e.jsx("td",{children:s.nontaxableLinkage.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.nontaxableLinkage.amount.formatted},a.year))]}),commentaryData:s.nontaxableLinkage}),e.jsxs("tr",{children:[e.jsx("th",{children:"Taxable Income"}),e.jsx("th",{children:s.taxableIncome.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.taxableIncome.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax Rate"}),e.jsxs("td",{children:[(s.taxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.taxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Income with Special Tax Rate"}),e.jsx("td",{children:s.specialTaxableIncome.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.specialTaxableIncome.amount.formatted},a.year))]}),commentaryData:s.specialTaxableIncome}),e.jsxs("tr",{children:[e.jsx("td",{children:"Special Tax Rate"}),e.jsxs("td",{children:[(s.specialTaxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.specialTaxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Annual Tax Expense"}),e.jsx("th",{children:s.annualTaxExpense.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.annualTaxExpense.formatted},t.year)),e.jsx("td",{})]})})]})})})};export{Y as TaxReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,
|
|
1
|
+
import{j as e,dq as D,du as t,H as f,cT as n,X as N,eQ as v,c_ as T,r as d,u as w,d1 as A,K as I,aW as O,B as S,d0 as P,N as L,V as M,di as V,a1 as q,a3 as y,a4 as R,a5 as C,a6 as B,aA as U,a8 as F,at as $,a$ as _,F as k,af as H,a as Q,c as z,n as G,dn as J,dp as K,dr as o,dt as W,eR as X}from"./index-DL8q44ap.js";const Z=({record:a})=>{const s=N(v,a);return e.jsxs(D,{children:[e.jsx(t,{children:a.description}),e.jsx(t,{children:f(new Date(a.purchaseDate),"dd/MM/yyyy")}),e.jsx(t,{children:a.activationDate?f(new Date(a.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(t,{children:s.originalCost?n(s.originalCost,0):void 0}),e.jsx(t,{children:s.reportYearDelta?n(s.reportYearDelta,0):void 0}),e.jsx(t,{children:n(s.totalDepreciableCosts,0)}),e.jsxs(t,{children:[n(a.statutoryDepreciationRate,0),"%"]}),e.jsx(t,{children:a.claimedDepreciationRate?`${n(a.claimedDepreciationRate,1)}%`:"-"}),e.jsx(t,{children:s.reportYearClaimedDepreciation?n(s.reportYearClaimedDepreciation,0):"-"}),e.jsx(t,{children:s.pastYearsAccumulatedDepreciation?n(s.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(t,{children:s.totalDepreciation?n(s.totalDepreciation,0):"-"}),e.jsx(t,{children:s.netValue?n(s.netValue,0):"-"})]})};function Y(a){return!a||T(a)?null:encodeURIComponent(JSON.stringify(a))}const b="depreciationReportFilters";function ee({filter:a,setFilter:s,close:r}){const p=M({defaultValues:{...a}}),{control:c,handleSubmit:x}=p,{selectableFinancialEntities:u,fetching:l}=V(),j=i=>{s({...i,year:Number(i.year)}),r()};return e.jsx(q,{...p,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const m=Number(i);return Number.isNaN(m)||m<2e3||m>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(R,{children:[e.jsx(C,{children:"Year"}),e.jsx(B,{children:e.jsx(U,{...i,hideControls:!0,decimalScale:0})}),e.jsx(F,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:a?.financialEntityId,control:c,render:({field:i})=>e.jsxs(R,{children:[e.jsx(C,{children:"Owner"}),e.jsx($,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(F,{})]})}),e.jsx(_,{children:e.jsx(S,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:a,setFilter:s}){const[r,p]=d.useState(!1),{get:c,set:x}=w();d.useEffect(()=>{const l=Y(a),j=c(b);l!==j&&x(b,l)},[a,c,x]);const u=d.useCallback(l=>{A(l,a)||s(l)},[a,s]);return e.jsxs(I,{open:r,onOpenChange:p,children:[e.jsx(O,{asChild:!0,children:e.jsx(S,{variant:"outline",size:"icon",children:e.jsx(P,{size:20})})}),e.jsx(L,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:a,setFilter:u,close:()=>p(!1)})})]})}const g=({data:a,groupName:s})=>{const r=N(v,a);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(t,{children:s?"Group Total":"Overall Total"}),e.jsx(t,{colSpan:2,children:s}),e.jsx(t,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(t,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(t,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(t,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(t,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(t,{children:r.netValue?n(r.netValue,0):void 0})]})};function te(a){const s=new URLSearchParams,r=Y(a);return r&&s.append(b,r),`/reports/depreciation${s.size>0?`?${s}`:""}`}const re=()=>{const{setFiltersContext:a}=d.useContext(k),{userContext:s}=d.useContext(H),{get:r}=w(),p=d.useMemo(()=>{const i={financialEntityId:s?.context.adminBusinessId,year:new Date().getFullYear()},m=r(b);if(m)try{return JSON.parse(decodeURIComponent(m))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[s?.context.adminBusinessId]),[c,x]=d.useState(p),[{data:u,fetching:l}]=Q({query:X,variables:{filters:c}});d.useEffect(()=>{a(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,a,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(z,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(J,{children:[e.jsxs(K,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx(W,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,m)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(t,{children:`Category ${m+1}`}),e.jsx(t,{colSpan:2,children:i.category.name}),e.jsx(t,{colSpan:3}),e.jsxs(t,{children:[n(i.category.percentage,0),"%"]}),e.jsx(t,{colSpan:5})]}),i.records.sort((h,E)=>h.purchaseDate.localeCompare(E.purchaseDate)).map(h=>e.jsx(Z,{record:h},h.id)),e.jsx(g,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(g,{data:u.depreciationReport.summary})]})})]})})};export{re as DepreciationReport,te as getDepreciationReportHref};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as P,j as r,g as
|
|
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(
|
|
1
|
+
import{r as P,j as r,g as H,a as J,fd as W,L as E,u as Y,af as q,c_ as K,c$ as X,B as U,d0 as ee,V as te,ce as ne,bP as se,bQ as oe,dc as O,H as S,fe as G,d1 as re,F as ie,c as le,Y as ae,$ as ce,a2 as fe}from"./index-DL8q44ap.js";import{A as ue,a as he,c as de,b as pe}from"./accordion-BZB-JxAM.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:f,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*f);const R=o-a,_=o+a,B=_&1,Q=l+o-1,Z=h+a-1,$=(_+B)/2;let F;t:for(let M=0;M<=$;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let u=I;u<=L;u+=2){const A=t[u-1-f*Math.floor((u-1)/f)],V=t[u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<V?V:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[u-f*Math.floor(u/f)]=b,B===1&&(F=R-u)>=1-M&&F<M&&b+t[f+F-f*Math.floor(F/f)]>=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,f=2*(Math.min(o,a)+1);continue e}else break t}for(let u=I;u<=L;u+=2){const A=t[f+u-1-f*Math.floor((u-1)/f)],V=t[f+u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<V?V:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(Q-b,Z-C);)b++,C++;if(t[f+u-f*Math.floor(u/f)]=b,B===0&&(F=R-u)>=-M&&F<=M&&b+t[F-f*Math.floor(F/f)]>=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,f=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=f,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],f=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:f,N:x}=this;return a<x&&(n.done=!1,n.value=[a,f,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
|
+
`);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(H,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=J({query:W,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(G(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(G(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(ue,{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(fe,{children:r.jsx(Me,{filter:d})})})]})})})})};export{Ce as ValidateReportsScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,
|
|
1
|
+
import{j as e,a3 as C,a4 as p,a5 as S,a6 as y,aA as v,a8 as I,v as L,i as D,g0 as H,r as u,t as m,l as A,K as E,aW as M,B as x,c8 as V,N as R,aX as T,aY as $,a as q,g1 as _,L as O,V as P,a1 as K,ac as z,g2 as Q,F as W,dk as X,c as Y,dn as G,dp as J,dq as b,dr as Z,ds as w,dt as ee,du as h,g3 as se,dA as te,dB as re,dC as oe}from"./index-DL8q44ap.js";import{D as ne}from"./data-table-pagination-BopLOYg9.js";import{A as k}from"./arrow-up-down-_p0E2yis.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=A(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(E,{open:r,onOpenChange:t,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{variant:"outline",size:"icon",children:e.jsx(V,{})})}),e.jsxs(R,{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:_,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 g=z(U,o);if(g&&Object.keys(g).length>0){let N;if(g.defaultIrsCode){const j=g.defaultIrsCode,f=Number(j);if(!Number.isInteger(f)||f<2||f>9999)throw new Error(`Invalid IRS code: ${j}`);N=f}a({fields:{...g,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);A(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(E,{open:n,onOpenChange:r,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{children:"Add Sort Code"})}),e.jsxs(R,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(T,{children:e.jsx($,{children:"Add New Sort Code"})}),e.jsx(ge,{close:()=>r(!1),onAdd:s})]})]})}function ge({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 F=[{id:"key",accessorKey:"key",cell:({row:s})=>e.jsx(h,{children:s.original.key}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Key",e.jsx(k,{})]})},{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(h,{children:s.original.name}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(k,{})]})},{id:"defaultIrsCode",accessorKey:"defaultIrsCode",cell:({row:s})=>e.jsx(h,{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(W),o=u.useMemo(()=>s?.allSortCodes?.map(l=>({...l,refetchSortCodes:t}))??[],[s?.allSortCodes,t]),a=X({data:o,columns:F,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(Y,{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(G,{children:[e.jsx(J,{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(h,{colSpan:F.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(h,{children:w(c.column.columnDef.cell,c.getContext())},c.id))},l.id))})]})})})};export{Ce as SortCodes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c_ as _,r as m,u as R,d1 as k,j as e,c$ as Q,bA as q,B as I,d0 as G,V as z,ce as K,di as X,as as J,dj as Z,bP as y,bQ as A,bU as B,bV as F,H as S,ci as L,a as P,f8 as W,Y as U,n as $,Z as Y,$ as ee,aE as ae,a2 as O,f9 as se,F as te,af as re,aB as ne,c as oe,a0 as le,e9 as ie,fa as ce,aV as de}from"./index-DL8q44ap.js";import{k as ue,B as N,X as H,Y as me,l as pe,m as xe,n as ge,o as he,p as fe,q as be,r as je}from"./chart-3ddx32Qz.js";import{s as ye}from"./sub-o9iEG2Bl.js";import"./sequential-CAnleQny.js";import"./subMonths-CpJ3oidH.js";var ve=ue({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:me}],formatAxisMap:pe});function V(s){return!s||_(s)?null:encodeURIComponent(JSON.stringify(s))}const E="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:n,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=z({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=K(),{selectableFinancialEntities:f,fetching:v}=X(),{selectableTags:p,fetching:j}=J(),M=a=>{n(a),c()},C=g("excludedTags"),l=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),o=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(Z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:B,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(F,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:B,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(F,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:i})=>e.jsx(L,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:i})=>e.jsx(L,{...a,data:l,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:i})=>e.jsx(L,{...a,data:o,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,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-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:n,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=R();m.useEffect(()=>{const p=V(s),j=h(E);p!==j&&f(E,p)},[s,h,f]);const v=m.useCallback(p=>{k(p,s)||(n(p),b(!!p))},[s,n]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(Q,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(q,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(G,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:n,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=P({query:W,variables:{transactionIDs:n}}),g=m.useMemo(()=>t?.transactionsByIDs?n.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,n]);return e.jsx(U,{className:"mt-5 w-full",children:r?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{children:e.jsxs(ee,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(ae,{className:"h-4 w-4"})})]})}),e.jsx(O,{children:e.jsx(se,{transactionsProps:g})})]})})};function Fe(s){const n=new URLSearchParams,c=V(s);return c&&n.append(E,c),`/reports/balance${n.size>0?`?${n}`:""}`}const w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,n,c){switch(c){case x.MONTHLY:{const t=String(n).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=n%2===0?n-1:n,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(n/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=n>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,n){switch(n){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=ie(de.Usd),De=()=>{const{setFiltersContext:s}=m.useContext(te),{userContext:n}=m.useContext(re),{get:c}=R(),t=m.useMemo(()=>{const l={ownerId:n?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(ye(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(E);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(o){console.log("Error parsing balance report filters from URL:",o)}return l},[n?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:l,fromDate:d,toDate:o}=r;return{ownerId:l,fromDate:d,toDate:o}},[r]),[{data:j,fetching:M}]=P({query:ce,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ne,{options:Object.entries(w).map(([l,d])=>({label:d.label,value:l})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(l=>({...l,ownerId:n?.context.adminBusinessId}))},[n]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const l=new Map;j.transactionsForBalanceReport.map(o=>{if(o.counterparty?.id&&(!o.isFee&&n?.context.financialAccountsBusinessesIds?.includes(o.counterparty.id)||r.excludedCounterparties?.includes(o.counterparty.id))||r.includedTags.length>0&&(!o.charge?.tags||o.charge.tags.length===0||!o.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&o.charge?.tags.length&&o.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(o.year,o.month,r.period);l.has(a)||l.set(a,{income:0,expense:0,delta:0,transactions:[]});const i=l.get(a);o.amountUsd.raw>0?i.income+=o.amountUsd.raw:i.expense+=o.amountUsd.raw,i.delta+=o.amountUsd.raw,i.transactions.push(o)});let d=0;return Array.from(l.entries()).sort((o,a)=>o[0].localeCompare(a[0])).map(([o,a])=>(d+=a.delta,{period:o,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((i,u)=>Math.abs(u.amountUsd.raw)-Math.abs(i.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,n?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{className:"w-full",children:[e.jsx(Y,{children:e.jsx(le,{children:"Click specific period to expand it's transactions data"})}),e.jsx(O,{children:e.jsx(xe,{config:w,className:"h-150 w-full",children:e.jsxs(ve,{accessibilityLayer:!0,data:C,onClick:l=>h(l.activeLabel),children:[e.jsx(ge,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:l=>Me(l,r.period)}),e.jsx(he,{content:e.jsx(fe,{formatter:(l,d,o,a)=>{const i=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${i} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${i}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]})}})}),e.jsx(be,{content:e.jsx(je,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(l=>l.period===b)?.transactions.map(l=>l.id)??[]})]})})};export{De as BalanceReport,Fe as getBalanceReportHref};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{D as U,r as b,
|
|
1
|
+
import{D as U,r as b,ce as W,j as e,K as z,aW as X,B as g,d0 as R,N as G,aX as Q,aY as Z,bg as T,at as K,b5 as A,au as O,av as k,aw as E,ax as M,az as D,cT as J,X as j,bo as w,eS as I,eT as ee,eU as S,eV as se,eW as L,eX as B,eY as P,eZ as N,e_ as p,e$ as Y,f0 as V,dO as re,f1 as te,bj as ae,bk as le,bl as v,f2 as $,F as de,a as ne,Y as oe,Z as ce,a2 as ie,f3 as ue}from"./index-DL8q44ap.js";import{B as me}from"./building-2-CKq13SAn.js";import{S as xe}from"./save-DZ9jxz9u.js";/**
|
|
2
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
|
-
*/const he=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],be=U("eye-off",he),y=["2020","2021","2022","2023"];function je({selectedBusiness:t,setSelectedBusiness:d,selectedYear:s,setSelectedYear:c,referenceYear:l,setReferenceYear:o}){const[n,r]=b.useState(!s||!t),{selectableBusinesses:a,fetching:i}=W(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(z,{open:n,onOpenChange:r,children:[e.jsx(G,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(Q,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(X,{children:e.jsxs(Z,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(K,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(k,{value:s,onValueChange:c,children:[e.jsx(O,{id:"year-select",children:e.jsx(M,{})}),e.jsx(E,{children:y.map(x=>e.jsx(D,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",y.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(k,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(O,{id:"reference-year-select",children:e.jsx(M,{})}),e.jsxs(E,{children:[e.jsx(D,{value:"none",children:"ללא"},"none"),y.map(x=>e.jsx(D,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",y.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const u=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=H=>Number.parseFloat(H.replace(/[,\s₪]/g,""))||0,q=f(h),F=f(x);return F===0?null:(q-F)/F*100};if(!n(d))return null;const i=o?a(d,c):null;return e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-gray-200",dir:"rtl",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[t," ",s&&`(${s})`]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r(d)?"text-gray-400":""}`,children:r(d)?"0":d}),i!==null&&e.jsxs("span",{className:`text-xs px-1 py-0.5 rounded ${i>0?"text-green-700 bg-green-100":i<0?"text-red-700 bg-red-100":"text-gray-700 bg-gray-100"}`,children:[i>0?"+":"",i.toFixed(1),"%"]})]})]})},m=({codes:t,referenceCodes:d,code:s,showEmptyFields:c})=>{const{value:l,label:o}=b.useMemo(()=>{const r=t.find(a=>a.code===s);return{value:r?.amount||0,label:r?.label||"לא זוהה קוד"}},[t,s]),n=b.useMemo(()=>d?.find(r=>r.code===s)?.amount.toString()||"",[d,s]);return e.jsx(u,{label:o,value:J(l,0),code:String(s),showChange:!0,showEmptyFields:c,referenceValue:n})},pe=[{title:"מזומנים ושווי מזומנים",codes:[7110,7120,7150],sumCode:7100},{title:"ניירות ערך",codes:[7215,7225,7230,7290,7295],sumCode:7200},{title:"לקוחות",codes:[7310,7320,7330,7350,7360,7380,7390],sumCode:7300},{title:"חייבים ויתרות חובה",codes:[7410,7420,7430,7440,7450,7461,7462,7470,7490],sumCode:7400},{title:"מסים נדחים לזמן קצר",codes:[7610,7620,7690],sumCode:7600},{title:"הלוואות לזמן קצר",codes:[7711,7712,7720],sumCode:7700},{title:"מלאי",codes:[7805,7810,7815,7820,7825,7830,7840,7850,7860,7870,7890],sumCode:7800}],ge=[{title:"רכוש קבוע",codes:[8010,8020,8025,8030,8040,8050,8060,8080,8090,8095,8100,8105,8110,8120,8130,8140,8150,8160,8170,8180,8190],sumCode:8e3},{title:"נכסים לא שוטפים מוחזקים למכירה",codes:[8710],sumCode:8700},{title:"הוצאות מראש לזמן ארוך",codes:[8210,8220,8290],sumCode:8200},{title:"השקעות בחברות מוחזקות כלולות ומאוחדות",codes:[8315,8325,8335,8340,8350],sumCode:8300},{title:'השקעות בחברות אחרות כולל ני"ע סחירים מוחזקים לזמן ארוך',codes:[8410,8420,8440,8450,8460,8490],sumCode:8400},{title:"מסים נדחים לזמן ארוך",codes:[8510,8520,8590],sumCode:8500},{title:"הוצאות נדחות ורכוש אחר",codes:[8610,8620,8630,8640,8690],sumCode:8600}],fe=[{title:"בנקים והלואות לזמן קצר",codes:[9110,9120,9130,9140,9151,9152,9190],sumCode:9100},{title:"ספקים ונותני שירותים",codes:[9210,9220,9230,9290],sumCode:9200},{title:"זכאים ויתרות זכות",codes:[9310,9320,9330,9340,9350,9360,9370,9410,9420,9431,9432,9435,9440,9450,9460,9470,9480,9490],sumCode:9400},{title:"עתודה למסים נדחים לזמן קצר",codes:[9510,9520,9530],sumCode:9500}],Ne=[{title:"התחייבויות לזמן ארוך",codes:[9605,9610,9620,9631,9632,9640,9650,9660,9670,9690],sumCode:9600},{title:"התחייבויות בשל סיום יחסי עובד-מעביד",codes:[9710,9720,9790],sumCode:9700},{title:"עתודה למסים נדחים לזמן ארוך",codes:[9810,9820,9890],sumCode:9800}],ve=[{title:"הון עצמי",codes:[9910,9920,9930,9940,9950,9960,9980],sumCode:9900}];function ye({data:t,referenceData:d,showEmptyFields:s=!1}){const l=j(I,t).balanceSheet||[],n=j(I,d)?.balanceSheet||[];return e.jsx(w,{value:"balanceSheet",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני המאזן"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-blue-800 border-b pb-2",children:"נכסים"}),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx("h5",{className:"font-bold",children:"רכוש שוטף"})}),pe.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(m,{codes:l,code:7e3,showEmptyFields:s})}),ge.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(m,{codes:l,code:8888,showEmptyFields:s})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-red-800 border-b pb-2",children:"התחייבויות והון"}),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx("h5",{className:"font-bold",children:"התחייבויות שוטפות"})}),fe.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(m,{codes:l,code:9e3,showEmptyFields:s})}),Ne.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),ve.map(r=>e.jsxs("div",{className:"bg-green-50 p-4 rounded-md",children:[e.jsx("h5",{className:"font-bold mb-3",children:r.title}),e.jsx("div",{className:"space-y-2",children:r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a))})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(m,{codes:l,code:9999,showEmptyFields:s})})]})]})]})})}const Ce=t=>{switch(t){case"1":return"תעשייתי";case"2":return"מסחרי";case"3":return"נותני שירותים";case"99":return"הדיווח כולל יותר מעסק אחד";default:return""}},Se=t=>{switch(t){case S.Cash:return"מזומן";case S.Accrual:return"מצטבר";case S.DollarRegulations:return"לפי תקנות דולריות";default:return""}},we=t=>{switch(t){case L.Shekels:return"שקלים";case L.Dollars:return"דולרים";default:return""}},Fe=t=>{switch(t){case B.DoubleEntry:return"כפולה";case B.SingleEntry:return"חד-צידית";default:return""}},Te=t=>{switch(t){case P.Computerized:return"ממוחשב";case P.Manual:return"ידני";default:return""}},De=t=>{switch(t){case N.Option_1:return"חלופה 1";case N.Option_2Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010";case N.Option_3Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010";case N.None:return"ללא חלופה";default:return""}},Re=t=>{switch(t){case p.Unqualified:return"נוסח אחיד (בלתי מסוייג)";case p.UnqualifiedWithGoingConcern:return"בנוסח אחיד עם הפניית תשומת לב להערת עסק חי";case p.UnqualifiedWithOtherEmphases:return"בנוסח אחיד עם הפניות תשומת לב אחרת";case p.Qualified:return"הסתייגות";case p.Adverse:return"שלילית";case p.Disclaimer:return"המנעות";case p.None:return"אין חוות דעת";default:return""}},C=t=>t==null?"":t?"כן":"לא";function Ae({data:t,businessInfo:d}){const{header:s}=j(ee,t),c=j(se,d);return e.jsx(w,{value:"header",className:"border rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",dir:"rtl",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטים מזהים"}),e.jsx(u,{label:"השם הרשום",value:c.name,showEmptyFields:!0}),e.jsx(u,{label:"תיאור העיסוק המדווח",value:s.businessDescription??"",showEmptyFields:!0}),e.jsx(u,{label:"מספר זהות",value:s.idNumber,showEmptyFields:!0}),e.jsx(u,{label:"מספר תיק",value:s.taxFileNumber,showEmptyFields:!0}),e.jsx(u,{label:'תיק מדווח למע"מ',value:s.vatFileNumber??"",showEmptyFields:!0}),e.jsx(u,{label:"מספר תיק ניכויים",value:s.withholdingTaxFileNumber??"",showEmptyFields:!0})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטי העסק"}),e.jsx(u,{value:Ce(s.businessType),label:"סוג העסק המדווח",showEmptyFields:!0}),e.jsx(u,{label:"שיטת דיווח",value:Se(s.reportingMethod),showEmptyFields:!0}),s.reportingMethod===S.DollarRegulations&&e.jsx(u,{label:"מטבע הסכומים",value:we(s.currencyType),showEmptyFields:!0}),e.jsx(u,{label:"הסכום באלפים",value:C(s.amountsInThousands),showEmptyFields:!0}),e.jsx(u,{label:"שיטת חשבונאות",value:Fe(s.accountingMethod),showEmptyFields:!0}),e.jsx(u,{label:"הנהלת חשבונות",value:Te(s.accountingSystem),showEmptyFields:!0}),e.jsx(u,{label:"חייב ברישום תוכנה",value:C(!!s.softwareRegistrationNumber),showEmptyFields:!0}),s.softwareRegistrationNumber&&e.jsx(u,{label:"מספר תעודת רישום",value:s.softwareRegistrationNumber,showEmptyFields:!0}),e.jsx(u,{label:"דוח בגין שותפות",value:C(!!s.isPartnership),showEmptyFields:!0}),s.isPartnership&&e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"מספר שותפים",value:s.partnershipCount?.toString()??"",showEmptyFields:!0}),e.jsx(u,{label:"חלקי ברווחי השותפות",value:`${s.partnershipProfitShare}%`,showEmptyFields:!0})]}),e.jsx(u,{label:"יישום תקני חשבונאות (IFRS)",value:C(!!s.ifrsImplementationYear||!!s.ifrsReportingOption),showEmptyFields:!0}),(!!s.ifrsImplementationYear||!!s.ifrsReportingOption)&&e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"החל משנת המס",value:s.ifrsImplementationYear??"",showEmptyFields:!0}),e.jsx(u,{label:"דווח בחלופה",value:De(s.ifrsReportingOption),showEmptyFields:!0})]}),e.jsx(u,{label:"מספר ענף כלכלי של המדווח",value:s.industryCode,showEmptyFields:!0}),e.jsx(u,{label:"חוות דעת המבקר",value:Re(s.auditOpinionType),showEmptyFields:!0})]})]})})}const ke=[{title:"הכנסות ממכירות ומתן שירותים",color:"text-blue-700",codes:[1010,1015,1020,1025,1030,1040,1051,1052,1090],sumCode:1e3},{title:"עלות המכירות ומתן השירותים וביצוע עבודות",color:"text-purple-700",codes:[1306,1308,1307,1310,1320,1330,1340,1350,1360,1371,1372,1390,1400,1450],sumCode:1300},{title:"עלויות ייצור ועלויות אצל קבלן בונה",color:"text-rose-700",codes:[2005,2006,2011,2012,2015,2020,2025,2030,2035,2040,2045,2050,2060,2066,2067,2068,2070,2075,2080,2085,2090,2095],sumCode:2e3},{title:"הוצאות מחקר ופיתוח",color:"text-amber-700",codes:[2510,2520,2530,2540,2550,2560,2570,2590],sumCode:2500},{title:"הוצאות מכירה",color:"text-green-700",codes:[3011,3013,3012,3015,3020,3025,3030,3040,3045,3050,3060,3066,3067,3068,3070,3075,3080,3085,3090,3100,3120,3190],sumCode:3e3},{title:"הוצאות הנהלה וכלליות",color:"text-cyan-700",codes:[3511,3513,3512,3515,3520,3530,3535,3540,3545,3550,3560,3566,3567,3568,3570,3575,3580,3590,3595,3600,3610,3620,3625,3631,3632,3640,3650,3660,3665,3680,3685,3690],sumCode:3500},{title:"הוצאות מימון",color:"text-indigo-700",codes:[5010,5020,5025,5030,5040,5050,5051,5090],sumCode:5e3},{title:"הכנסות מימון",color:"text-fuchsia-700",codes:[5110,5121,5122,5130,5150,5160,5190],sumCode:5100},{title:"הכנסות אחרות",color:"text-red-700",codes:[5210,5220,5230,5236,5237,5240,5250,5260,5270,5290],sumCode:5200},{title:"הוצאות אחרות",color:"text-yellow-700",codes:[5310,5320,5330,5390],sumCode:5300}],Oe=[{title:"מסים על הכנסה",color:"text-sky-700",codes:[5610,5620,5630],sumCode:5600},{title:"ייעוד הרווחים",color:"text-violet-700",codes:[5710],sumCode:5700},{title:"רווח/הפסד אקויטי",color:"text-pink-700",codes:[5810],sumCode:5800}];function Me({selectedYear:t,referenceYear:d,data:s,referenceData:c,showEmptyFields:l=!1}){const{profitAndLoss:o}=j(Y,s),r=j(Y,c)?.profitAndLoss||[];return e.jsx(w,{value:"profitLoss",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני רווח והפסד"}),d&&t!==d&&e.jsxs("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded",children:["מציג שינויים לעומת ",d]})]}),ke.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(m,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title)),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(m,{codes:o,referenceCodes:r,code:6666,showEmptyFields:l})}),Oe.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(m,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title))]})})}const Ee=[{title:"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010 בנושא IFRS",color:"red",codes:[103,104]},{title:"התאמות נדרשות לצרכי מס (הוסף/הפחת)",color:"yellow",codes:[110,120,130,135,140,150,160,170,180,181,182,183,184,190,200,300,310,320,330,350,360],sumCode:370},{title:"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010 בנושא IFRS שלא מצאו את ביטויין בהתאמות הנדרשות לצרכי מס",color:"emerald",codes:[383],sumCode:400},{title:"יישום הוראות חוקי מס נוספים",color:"sky",codes:[430,480,490],sumCode:500},{title:"נתונים נוספים",color:"violet",codes:[510,520,530,540,550,570,575,580,585,590]},{title:"בשותפות",color:"pink",codes:[600]}],_={red:{header:"text-red-700",sum:"bg-red-50 border-red-200"},yellow:{header:"text-yellow-700",sum:"bg-yellow-50 border-yellow-200"},emerald:{header:"text-emerald-700",sum:"bg-emerald-50 border-emerald-200"},sky:{header:"text-sky-700",sum:"bg-sky-50 border-sky-200"},violet:{header:"text-violet-700",sum:"bg-violet-50 border-violet-200"},pink:{header:"text-pink-700",sum:"bg-pink-50 border-pink-200"}};function Ie({data:t,referenceData:d,showEmptyFields:s=!1}){const{taxAdjustment:c}=j($,t),o=j($,d)?.taxAdjustment||[];return e.jsx(w,{value:"taxAdjustment",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:'נתוני דו"ח התאמה למס'}),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(m,{codes:c,referenceCodes:o,code:100,showEmptyFields:s})}),Ee.map(n=>{const{header:r,sum:a}=_[n.color]||_.red;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:"font-bold mb-4 "+r,children:n.title}),e.jsx("div",{className:"space-y-2",children:n.codes.map(i=>e.jsx(m,{codes:c,referenceCodes:o,code:i,showEmptyFields:s},i))})]}),n.sumCode&&e.jsx("div",{className:"p-4 rounded-md border-2 "+a,children:e.jsx(m,{codes:c,referenceCodes:o,code:n.sumCode,showEmptyFields:s})})]},n.title)})]})})}function Le({data:t,referenceData:d,businessInfo:s,selectedYear:c,referenceYear:l}){const o=j(V,t),n=j(V,d),[r,a]=b.useState("header"),[i,h]=b.useState(!0);return e.jsxs("div",{className:"p-4 border-gray-300",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:i?"outline":"default",size:"sm",onClick:()=>h(!i),className:"flex items-center gap-2",children:[i?e.jsx(be,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),i?"הסתר שדות ריקים":"הצג שדות ריקים"]}),e.jsx("span",{className:"text-sm text-gray-500",children:i?"מציג את כל השדות":"מציג רק שדות עם נתונים"})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"הורד"]}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"שמור"]})]})]}),e.jsxs(ae,{value:r,onValueChange:a,className:"w-full",children:[e.jsxs(le,{className:"grid grid-cols-4 w-full",dir:"rtl",children:[e.jsx(v,{value:"header",children:"פרטים מזהים"}),e.jsx(v,{value:"profitLoss",children:"רווח והפסד"}),e.jsx(v,{value:"taxAdjustment",children:"התאמה למס"}),e.jsx(v,{value:"balanceSheet",children:"מאזן"})]}),e.jsx(Ae,{data:o,businessInfo:s}),e.jsx(Me,{selectedYear:c,referenceYear:l,data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ie,{data:o,referenceData:n,showEmptyFields:i}),e.jsx(ye,{data:o,referenceData:n,showEmptyFields:i})]})]})}function _e(){const{setFiltersContext:t}=b.useContext(de),[d,s]=b.useState(void 0),[c,l]=b.useState(void 0),[o,n]=b.useState(void 0),[{data:r,fetching:a}]=ne({query:ue,variables:{year:c?Number.parseInt(c,10):0,businessId:d},pause:!c||!d});return b.useEffect(()=>{t(e.jsx("div",{className:"flex flex-row gap-x-5",dir:"rtl",children:e.jsx(je,{selectedBusiness:d,setSelectedBusiness:s,selectedYear:c,setSelectedYear:l,referenceYear:o,setReferenceYear:n})}))},[t,d,c,o]),e.jsx("div",{className:"container mx-auto",dir:"rtl",children:e.jsxs(oe,{className:"border-2 border-gray-300",children:[e.jsx(ce,{className:"bg-gray-100 border-b-2 border-gray-300 flex flex-row justify-between items-center",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("h1",{className:"text-2xl font-bold",children:'נספח לטופס הדו"ח השנתי ליחיד ולחבר בני אדם'}),e.jsxs("h2",{className:"text-xl",children:["לשנת המס ",c]}),e.jsx("p",{className:"text-sm",children:'נתוני הדוחות הכספיים, מאזן, רווח והפסד ודו"ח ההתאמה למס'})]})}),e.jsx(ie,{className:"p-0",children:e.jsx(Be,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Be({fetching:t,data:d,selectedBusiness:s,selectedYear:c,referenceYear:l}){if(t)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"טוען נתונים..."})});if(!c||!s)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"יש לבחור עסק ושנת דיווח"})});const o=d?.shaam6111.data;return o?e.jsx(Le,{data:o,businessInfo:d.shaam6111.business,selectedBusiness:s,selectedYear:c,referenceYear:l}):e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"אין נתונים זמינים עבור העסק והשנה שנבחרו"})})}export{_e as Shaam6111Report};
|
|
6
|
+
*/const he=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],be=U("eye-off",he),C=["2020","2021","2022","2023"];function je({selectedBusiness:t,setSelectedBusiness:d,selectedYear:s,setSelectedYear:c,referenceYear:l,setReferenceYear:o}){const[n,r]=b.useState(!s||!t),{selectableBusinesses:a,fetching:i}=W(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(z,{open:n,onOpenChange:r,children:[e.jsx(X,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(G,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(Q,{children:e.jsxs(Z,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(K,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(O,{value:s,onValueChange:c,children:[e.jsx(k,{id:"year-select",children:e.jsx(E,{})}),e.jsx(M,{children:C.map(x=>e.jsx(D,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(O,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(k,{id:"reference-year-select",children:e.jsx(E,{})}),e.jsxs(M,{children:[e.jsx(D,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(D,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const u=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=q=>Number.parseFloat(q.replace(/[,\s₪]/g,""))||0,H=f(h),F=f(x);return F===0?null:(H-F)/F*100};if(!n(d))return null;const i=o?a(d,c):null;return e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-gray-200",dir:"rtl",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[t," ",s&&`(${s})`]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r(d)?"text-gray-400":""}`,children:r(d)?"0":d}),i!==null&&e.jsxs("span",{className:`text-xs px-1 py-0.5 rounded ${i>0?"text-green-700 bg-green-100":i<0?"text-red-700 bg-red-100":"text-gray-700 bg-gray-100"}`,children:[i>0?"+":"",i.toFixed(1),"%"]})]})]})},m=({codes:t,referenceCodes:d,code:s,showEmptyFields:c})=>{const{value:l,label:o}=b.useMemo(()=>{const r=t.find(a=>a.code===s);return{value:r?.amount||0,label:r?.label||"לא זוהה קוד"}},[t,s]),n=b.useMemo(()=>d?.find(r=>r.code===s)?.amount.toString()||"",[d,s]);return e.jsx(u,{label:o,value:J(l,0),code:String(s),showChange:!0,showEmptyFields:c,referenceValue:n})},pe=[{title:"מזומנים ושווי מזומנים",codes:[7110,7120,7150],sumCode:7100},{title:"ניירות ערך",codes:[7215,7225,7230,7290,7295],sumCode:7200},{title:"לקוחות",codes:[7310,7320,7330,7350,7360,7380,7390],sumCode:7300},{title:"חייבים ויתרות חובה",codes:[7410,7420,7430,7440,7450,7461,7462,7470,7490],sumCode:7400},{title:"מסים נדחים לזמן קצר",codes:[7610,7620,7690],sumCode:7600},{title:"הלוואות לזמן קצר",codes:[7711,7712,7720],sumCode:7700},{title:"מלאי",codes:[7805,7810,7815,7820,7825,7830,7840,7850,7860,7870,7890],sumCode:7800}],ge=[{title:"רכוש קבוע",codes:[8010,8020,8025,8030,8040,8050,8060,8080,8090,8095,8100,8105,8110,8120,8130,8140,8150,8160,8170,8180,8190],sumCode:8e3},{title:"נכסים לא שוטפים מוחזקים למכירה",codes:[8710],sumCode:8700},{title:"הוצאות מראש לזמן ארוך",codes:[8210,8220,8290],sumCode:8200},{title:"השקעות בחברות מוחזקות כלולות ומאוחדות",codes:[8315,8325,8335,8340,8350],sumCode:8300},{title:'השקעות בחברות אחרות כולל ני"ע סחירים מוחזקים לזמן ארוך',codes:[8410,8420,8440,8450,8460,8490],sumCode:8400},{title:"מסים נדחים לזמן ארוך",codes:[8510,8520,8590],sumCode:8500},{title:"הוצאות נדחות ורכוש אחר",codes:[8610,8620,8630,8640,8690],sumCode:8600}],fe=[{title:"בנקים והלואות לזמן קצר",codes:[9110,9120,9130,9140,9151,9152,9190],sumCode:9100},{title:"ספקים ונותני שירותים",codes:[9210,9220,9230,9290],sumCode:9200},{title:"זכאים ויתרות זכות",codes:[9310,9320,9330,9340,9350,9360,9370,9410,9420,9431,9432,9435,9440,9450,9460,9470,9480,9490],sumCode:9400},{title:"עתודה למסים נדחים לזמן קצר",codes:[9510,9520,9530],sumCode:9500}],Ne=[{title:"התחייבויות לזמן ארוך",codes:[9605,9610,9620,9631,9632,9640,9650,9660,9670,9690],sumCode:9600},{title:"התחייבויות בשל סיום יחסי עובד-מעביד",codes:[9710,9720,9790],sumCode:9700},{title:"עתודה למסים נדחים לזמן ארוך",codes:[9810,9820,9890],sumCode:9800}],ve=[{title:"הון עצמי",codes:[9910,9920,9930,9940,9950,9960,9980],sumCode:9900}];function Ce({data:t,referenceData:d,showEmptyFields:s=!1}){const l=j(I,t).balanceSheet||[],n=j(I,d)?.balanceSheet||[];return e.jsx(w,{value:"balanceSheet",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני המאזן"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-blue-800 border-b pb-2",children:"נכסים"}),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx("h5",{className:"font-bold",children:"רכוש שוטף"})}),pe.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(m,{codes:l,code:7e3,showEmptyFields:s})}),ge.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(m,{codes:l,code:8888,showEmptyFields:s})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-red-800 border-b pb-2",children:"התחייבויות והון"}),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx("h5",{className:"font-bold",children:"התחייבויות שוטפות"})}),fe.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(m,{codes:l,code:9e3,showEmptyFields:s})}),Ne.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),ve.map(r=>e.jsxs("div",{className:"bg-green-50 p-4 rounded-md",children:[e.jsx("h5",{className:"font-bold mb-3",children:r.title}),e.jsx("div",{className:"space-y-2",children:r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a))})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(m,{codes:l,code:9999,showEmptyFields:s})})]})]})]})})}const ye=t=>{switch(t){case"1":return"תעשייתי";case"2":return"מסחרי";case"3":return"נותני שירותים";case"99":return"הדיווח כולל יותר מעסק אחד";default:return""}},Se=t=>{switch(t){case S.Cash:return"מזומן";case S.Accrual:return"מצטבר";case S.DollarRegulations:return"לפי תקנות דולריות";default:return""}},we=t=>{switch(t){case L.Shekels:return"שקלים";case L.Dollars:return"דולרים";default:return""}},Fe=t=>{switch(t){case B.DoubleEntry:return"כפולה";case B.SingleEntry:return"חד-צידית";default:return""}},Te=t=>{switch(t){case P.Computerized:return"ממוחשב";case P.Manual:return"ידני";default:return""}},De=t=>{switch(t){case N.Option_1:return"חלופה 1";case N.Option_2Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010";case N.Option_3Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010";case N.None:return"ללא חלופה";default:return""}},Re=t=>{switch(t){case p.Unqualified:return"נוסח אחיד (בלתי מסוייג)";case p.UnqualifiedWithGoingConcern:return"בנוסח אחיד עם הפניית תשומת לב להערת עסק חי";case p.UnqualifiedWithOtherEmphases:return"בנוסח אחיד עם הפניות תשומת לב אחרת";case p.Qualified:return"הסתייגות";case p.Adverse:return"שלילית";case p.Disclaimer:return"המנעות";case p.None:return"אין חוות דעת";default:return""}},y=t=>t==null?"":t?"כן":"לא";function Ae({data:t,businessInfo:d}){const{header:s}=j(ee,t),c=j(se,d);return e.jsx(w,{value:"header",className:"border rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",dir:"rtl",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטים מזהים"}),e.jsx(u,{label:"השם הרשום",value:c.name,showEmptyFields:!0}),e.jsx(u,{label:"תיאור העיסוק המדווח",value:s.businessDescription??"",showEmptyFields:!0}),e.jsx(u,{label:"מספר זהות",value:s.idNumber,showEmptyFields:!0}),e.jsx(u,{label:"מספר תיק",value:s.taxFileNumber,showEmptyFields:!0}),e.jsx(u,{label:'תיק מדווח למע"מ',value:s.vatFileNumber??"",showEmptyFields:!0}),e.jsx(u,{label:"מספר תיק ניכויים",value:s.withholdingTaxFileNumber??"",showEmptyFields:!0})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטי העסק"}),e.jsx(u,{value:ye(s.businessType),label:"סוג העסק המדווח",showEmptyFields:!0}),e.jsx(u,{label:"שיטת דיווח",value:Se(s.reportingMethod),showEmptyFields:!0}),s.reportingMethod===S.DollarRegulations&&e.jsx(u,{label:"מטבע הסכומים",value:we(s.currencyType),showEmptyFields:!0}),e.jsx(u,{label:"הסכום באלפים",value:y(s.amountsInThousands),showEmptyFields:!0}),e.jsx(u,{label:"שיטת חשבונאות",value:Fe(s.accountingMethod),showEmptyFields:!0}),e.jsx(u,{label:"הנהלת חשבונות",value:Te(s.accountingSystem),showEmptyFields:!0}),e.jsx(u,{label:"חייב ברישום תוכנה",value:y(!!s.softwareRegistrationNumber),showEmptyFields:!0}),s.softwareRegistrationNumber&&e.jsx(u,{label:"מספר תעודת רישום",value:s.softwareRegistrationNumber,showEmptyFields:!0}),e.jsx(u,{label:"דוח בגין שותפות",value:y(!!s.isPartnership),showEmptyFields:!0}),s.isPartnership&&e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"מספר שותפים",value:s.partnershipCount?.toString()??"",showEmptyFields:!0}),e.jsx(u,{label:"חלקי ברווחי השותפות",value:`${s.partnershipProfitShare}%`,showEmptyFields:!0})]}),e.jsx(u,{label:"יישום תקני חשבונאות (IFRS)",value:y(!!s.ifrsImplementationYear||!!s.ifrsReportingOption),showEmptyFields:!0}),(!!s.ifrsImplementationYear||!!s.ifrsReportingOption)&&e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"החל משנת המס",value:s.ifrsImplementationYear??"",showEmptyFields:!0}),e.jsx(u,{label:"דווח בחלופה",value:De(s.ifrsReportingOption),showEmptyFields:!0})]}),e.jsx(u,{label:"מספר ענף כלכלי של המדווח",value:s.industryCode,showEmptyFields:!0}),e.jsx(u,{label:"חוות דעת המבקר",value:Re(s.auditOpinionType),showEmptyFields:!0})]})]})})}const Oe=[{title:"הכנסות ממכירות ומתן שירותים",color:"text-blue-700",codes:[1010,1015,1020,1025,1030,1040,1051,1052,1090],sumCode:1e3},{title:"עלות המכירות ומתן השירותים וביצוע עבודות",color:"text-purple-700",codes:[1306,1308,1307,1310,1320,1330,1340,1350,1360,1371,1372,1390,1400,1450],sumCode:1300},{title:"עלויות ייצור ועלויות אצל קבלן בונה",color:"text-rose-700",codes:[2005,2006,2011,2012,2015,2020,2025,2030,2035,2040,2045,2050,2060,2066,2067,2068,2070,2075,2080,2085,2090,2095],sumCode:2e3},{title:"הוצאות מחקר ופיתוח",color:"text-amber-700",codes:[2510,2520,2530,2540,2550,2560,2570,2590],sumCode:2500},{title:"הוצאות מכירה",color:"text-green-700",codes:[3011,3013,3012,3015,3020,3025,3030,3040,3045,3050,3060,3066,3067,3068,3070,3075,3080,3085,3090,3100,3120,3190],sumCode:3e3},{title:"הוצאות הנהלה וכלליות",color:"text-cyan-700",codes:[3511,3513,3512,3515,3520,3530,3535,3540,3545,3550,3560,3566,3567,3568,3570,3575,3580,3590,3595,3600,3610,3620,3625,3631,3632,3640,3650,3660,3665,3680,3685,3690],sumCode:3500},{title:"הוצאות מימון",color:"text-indigo-700",codes:[5010,5020,5025,5030,5040,5050,5051,5090],sumCode:5e3},{title:"הכנסות מימון",color:"text-fuchsia-700",codes:[5110,5121,5122,5130,5150,5160,5190],sumCode:5100},{title:"הכנסות אחרות",color:"text-red-700",codes:[5210,5220,5230,5236,5237,5240,5250,5260,5270,5290],sumCode:5200},{title:"הוצאות אחרות",color:"text-yellow-700",codes:[5310,5320,5330,5390],sumCode:5300}],ke=[{title:"מסים על הכנסה",color:"text-sky-700",codes:[5610,5620,5630],sumCode:5600},{title:"ייעוד הרווחים",color:"text-violet-700",codes:[5710],sumCode:5700},{title:"רווח/הפסד אקויטי",color:"text-pink-700",codes:[5810],sumCode:5800}];function Ee({selectedYear:t,referenceYear:d,data:s,referenceData:c,showEmptyFields:l=!1}){const{profitAndLoss:o}=j(Y,s),r=j(Y,c)?.profitAndLoss||[];return e.jsx(w,{value:"profitLoss",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני רווח והפסד"}),d&&t!==d&&e.jsxs("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded",children:["מציג שינויים לעומת ",d]})]}),Oe.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(m,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title)),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(m,{codes:o,referenceCodes:r,code:6666,showEmptyFields:l})}),ke.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(m,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title))]})})}const Me=[{title:"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010 בנושא IFRS",color:"red",codes:[103,104]},{title:"התאמות נדרשות לצרכי מס (הוסף/הפחת)",color:"yellow",codes:[110,120,130,135,140,150,160,170,180,181,182,183,184,190,200,300,310,320,330,350,360],sumCode:370},{title:"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010 בנושא IFRS שלא מצאו את ביטויין בהתאמות הנדרשות לצרכי מס",color:"emerald",codes:[383],sumCode:400},{title:"יישום הוראות חוקי מס נוספים",color:"sky",codes:[430,480,490],sumCode:500},{title:"נתונים נוספים",color:"violet",codes:[510,520,530,540,550,570,575,580,585,590]},{title:"בשותפות",color:"pink",codes:[600]}],_={red:{header:"text-red-700",sum:"bg-red-50 border-red-200"},yellow:{header:"text-yellow-700",sum:"bg-yellow-50 border-yellow-200"},emerald:{header:"text-emerald-700",sum:"bg-emerald-50 border-emerald-200"},sky:{header:"text-sky-700",sum:"bg-sky-50 border-sky-200"},violet:{header:"text-violet-700",sum:"bg-violet-50 border-violet-200"},pink:{header:"text-pink-700",sum:"bg-pink-50 border-pink-200"}};function Ie({data:t,referenceData:d,showEmptyFields:s=!1}){const{taxAdjustment:c}=j(V,t),o=j(V,d)?.taxAdjustment||[];return e.jsx(w,{value:"taxAdjustment",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:'נתוני דו"ח התאמה למס'}),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(m,{codes:c,referenceCodes:o,code:100,showEmptyFields:s})}),Me.map(n=>{const{header:r,sum:a}=_[n.color]||_.red;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:"font-bold mb-4 "+r,children:n.title}),e.jsx("div",{className:"space-y-2",children:n.codes.map(i=>e.jsx(m,{codes:c,referenceCodes:o,code:i,showEmptyFields:s},i))})]}),n.sumCode&&e.jsx("div",{className:"p-4 rounded-md border-2 "+a,children:e.jsx(m,{codes:c,referenceCodes:o,code:n.sumCode,showEmptyFields:s})})]},n.title)})]})})}function Le({data:t,referenceData:d,businessInfo:s,selectedYear:c,referenceYear:l}){const o=j($,t),n=j($,d),[r,a]=b.useState("header"),[i,h]=b.useState(!0);return e.jsxs("div",{className:"p-4 border-gray-300",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:i?"outline":"default",size:"sm",onClick:()=>h(!i),className:"flex items-center gap-2",children:[i?e.jsx(be,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),i?"הסתר שדות ריקים":"הצג שדות ריקים"]}),e.jsx("span",{className:"text-sm text-gray-500",children:i?"מציג את כל השדות":"מציג רק שדות עם נתונים"})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"הורד"]}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"שמור"]})]})]}),e.jsxs(ae,{value:r,onValueChange:a,className:"w-full",children:[e.jsxs(le,{className:"grid grid-cols-4 w-full",dir:"rtl",children:[e.jsx(v,{value:"header",children:"פרטים מזהים"}),e.jsx(v,{value:"profitLoss",children:"רווח והפסד"}),e.jsx(v,{value:"taxAdjustment",children:"התאמה למס"}),e.jsx(v,{value:"balanceSheet",children:"מאזן"})]}),e.jsx(Ae,{data:o,businessInfo:s}),e.jsx(Ee,{selectedYear:c,referenceYear:l,data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ie,{data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ce,{data:o,referenceData:n,showEmptyFields:i})]})]})}function _e(){const{setFiltersContext:t}=b.useContext(de),[d,s]=b.useState(void 0),[c,l]=b.useState(void 0),[o,n]=b.useState(void 0),[{data:r,fetching:a}]=ne({query:ue,variables:{year:c?Number.parseInt(c,10):0,businessId:d},pause:!c||!d});return b.useEffect(()=>{t(e.jsx("div",{className:"flex flex-row gap-x-5",dir:"rtl",children:e.jsx(je,{selectedBusiness:d,setSelectedBusiness:s,selectedYear:c,setSelectedYear:l,referenceYear:o,setReferenceYear:n})}))},[t,d,c,o]),e.jsx("div",{className:"container mx-auto",dir:"rtl",children:e.jsxs(oe,{className:"border-2 border-gray-300",children:[e.jsx(ce,{className:"bg-gray-100 border-b-2 border-gray-300 flex flex-row justify-between items-center",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("h1",{className:"text-2xl font-bold",children:'נספח לטופס הדו"ח השנתי ליחיד ולחבר בני אדם'}),e.jsxs("h2",{className:"text-xl",children:["לשנת המס ",c]}),e.jsx("p",{className:"text-sm",children:'נתוני הדוחות הכספיים, מאזן, רווח והפסד ודו"ח ההתאמה למס'})]})}),e.jsx(ie,{className:"p-0",children:e.jsx(Be,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Be({fetching:t,data:d,selectedBusiness:s,selectedYear:c,referenceYear:l}){if(t)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"טוען נתונים..."})});if(!c||!s)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"יש לבחור עסק ושנת דיווח"})});const o=d?.shaam6111.data;return o?e.jsx(Le,{data:o,businessInfo:d.shaam6111.business,selectedBusiness:s,selectedYear:c,referenceYear:l}):e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"אין נתונים זמינים עבור העסק והשנה שנבחרו"})})}export{_e as Shaam6111Report};
|
|
@@ -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-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
|
+
import{j as e,T as ae,B as U,aC as se,ce as ne,a as D,fx as te,r as x,af as q,fy as le,fz as z,V,t as f,a1 as oe,fA as ie,dc as G,bP as u,bQ as k,a3 as de,fB as ce,a4 as me,a5 as ue,a6 as xe,v as ye,a8 as pe,bW as g,bR as S,H as E,ac as ge,i as W,fC as he,l as Q,fD as je,fE as _,e as fe,fF as ve,fG as be,u as J,c_ as Ne,d1 as Se,c$ as Ee,d0 as we,ci as Fe,X as w,fH as Ce,fI as De,fJ as Ie,fK as Ae,fL as Pe,fM as Re,fN as Te,fO as ke,fP as Me,F as Be,c as Le,L as Ze,fQ as Oe}from"./index-DL8q44ap.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=Q(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(_,{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=Q(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(_,{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 Qe({filter:t,setFilter:a}){const[o,d]=x.useState(!1),{get:l,set:i}=J();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 _e=({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})})})]})})})},Je=({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(Je,{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(_e,{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}=J(),[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(Qe,{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};
|