@accounter/client 0.0.8-alpha-20251021225827-178e480c997a9811913e16f85cb94329041b096e → 0.0.8-alpha-20251022034712-a30a030f5a83f0dff0ee9fa8ccd0ebdaf7986647
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 -25
- package/dist/assets/index-B2UYAO1O.css +1 -0
- package/dist/assets/index-BexxGuN6.js +1224 -0
- package/dist/assets/{index.es-CYeQ4a5s.js → index.es-CWwhWGxX.js} +5 -5
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/components/business-transactions/business-extended-info.tsx +15 -13
- package/src/components/business-transactions/business-transactions-single.tsx +3 -3
- package/src/components/business-transactions/index.tsx +1 -12
- package/src/components/business-trips/business-trip.tsx +3 -3
- package/src/components/charges/cells/business-trip.tsx +8 -6
- package/src/components/charges/cells/counterparty.tsx +5 -7
- package/src/components/common/accounter-table.tsx +5 -6
- package/src/components/common/business-trip-report/parts/core-expense-row.tsx +9 -11
- package/src/components/common/business-trip-report/parts/uncategorized-transactions.tsx +13 -11
- package/src/components/common/buttons/button-with-label.tsx +41 -0
- package/src/components/common/buttons/button.tsx +44 -0
- package/src/components/common/buttons/index.ts +2 -0
- package/src/components/common/buttons/logout-button.tsx +6 -7
- package/src/components/common/documents-to-charge-matcher/selection-handler/index.tsx +2 -4
- package/src/components/common/documents-to-charge-matcher/selection-handler/wide-filtered-selection.tsx +7 -5
- package/src/components/common/forms/edit-document.tsx +10 -23
- package/src/components/common/new-documents-list.tsx +8 -10
- package/src/components/documents-table/cells/creditor.tsx +4 -11
- package/src/components/documents-table/cells/debtor.tsx +4 -11
- package/src/components/layout/dashboard-layout.tsx +0 -4
- package/src/components/layout/sidelinks.tsx +27 -28
- package/src/components/ledger-table/counterparty-cell.tsx +13 -19
- package/src/components/login-page.tsx +1 -2
- package/src/components/reports/corporate-tax-ruling-compliance-report/index.tsx +3 -3
- package/src/components/reports/profit-and-loss-report/index.tsx +3 -3
- package/src/components/reports/tax-report/index.tsx +3 -3
- package/src/components/screens/businesses/business.tsx +9 -21
- package/src/components/screens/charges/charge.tsx +9 -22
- package/src/components/transactions-table/cells/counterparty.tsx +2 -9
- package/src/components/transactions-table/cells-legacy/counterparty.tsx +2 -9
- package/src/index.tsx +22 -4
- package/src/providers/auth-guard.tsx +23 -14
- package/src/providers/index.tsx +2 -7
- package/src/providers/urql.tsx +12 -7
- package/src/providers/user-provider.tsx +2 -3
- package/dist/assets/Checkbox-CxedbJAl.js +0 -6
- package/dist/assets/Progress-D5SuJtCd.js +0 -1
- package/dist/assets/Typography-BQFz-z7L.js +0 -1
- package/dist/assets/accordion-COWOBKuq.js +0 -1
- package/dist/assets/accountant-approvals-Bd2y8us_.js +0 -1
- package/dist/assets/all-charges-SWBnaZu7.js +0 -1
- package/dist/assets/arrow-up-down-dZmrBLse.js +0 -6
- package/dist/assets/business--GVVfDEa.js +0 -37
- package/dist/assets/business-transactions-single-BsbkUf_H.js +0 -1
- package/dist/assets/business-trip-ByXPVXdG.js +0 -1
- package/dist/assets/charges-filters-D43UbXob.js +0 -1
- package/dist/assets/charges-ledger-validation-D0uMH_JE.js +0 -1
- package/dist/assets/chart-ClU1KbWe.js +0 -74
- package/dist/assets/data-table-pagination-D9Y0_Tn8.js +0 -11
- package/dist/assets/editable-business-trip-DhqOQBPa.js +0 -16
- package/dist/assets/graphql-document-dedupe-fragments-ByT8-wlV.js +0 -1
- package/dist/assets/index-1U6rQgQe.js +0 -6
- package/dist/assets/index-3-AKn8tg.js +0 -1
- package/dist/assets/index-91A2PLZ6.js +0 -137
- package/dist/assets/index-BBHuCWRn.js +0 -1
- package/dist/assets/index-BPNuFFtx.js +0 -1
- package/dist/assets/index-BXqHnRVY.js +0 -1
- package/dist/assets/index-BciOH8FS.js +0 -1
- package/dist/assets/index-BjHuUHDO.js +0 -1
- package/dist/assets/index-BxKmoNQd.js +0 -1
- package/dist/assets/index-C3bqiFIv.js +0 -2
- package/dist/assets/index-C5MeepK_.js +0 -11
- package/dist/assets/index-CAwm68Mg.js +0 -1
- package/dist/assets/index-CJ8OGXxv.js +0 -1
- package/dist/assets/index-CJyY-qF6.js +0 -1
- package/dist/assets/index-CMYnx46_.js +0 -6
- package/dist/assets/index-CNrwxUZ7.js +0 -1
- package/dist/assets/index-CvV5z5r9.js +0 -876
- package/dist/assets/index-D08H2GXq.js +0 -17
- package/dist/assets/index-GFsPY1p4.js +0 -2
- package/dist/assets/index-KwNwThNu.js +0 -1
- package/dist/assets/index-YA8IBFyB.js +0 -1
- package/dist/assets/index-ZpyI3qxW.js +0 -24
- package/dist/assets/index-gdTXrWXt.css +0 -1
- package/dist/assets/index-ytnIEraq.js +0 -9
- package/dist/assets/issue-document-CdikNnO2.js +0 -1
- package/dist/assets/login-page-effgZS3V.js +0 -1
- package/dist/assets/missing-info-charges-CnPFTzoZ.js +0 -1
- package/dist/assets/page-not-found-D8YlgDOm.js +0 -1
- package/dist/assets/pencil-mxW0-tGM.js +0 -6
- package/dist/assets/report-commentary-row-DCozKgVE.js +0 -1
- package/dist/assets/save-CHlytUqu.js +0 -11
- package/dist/assets/sequential-CAnleQny.js +0 -1
- package/dist/assets/similar-charges-by-business-modal-Dzbspk_r.js +0 -1
- package/dist/assets/sub-Cp_PhKiD.js +0 -1
- package/dist/assets/subMonths-DCj_iXAn.js +0 -1
- package/src/components/error-boundary.tsx +0 -189
- package/src/components/layout/breadcrumbs.tsx +0 -77
- package/src/components/layout/document-title.tsx +0 -31
- package/src/components/layout/navigation-progress.tsx +0 -52
- package/src/components/layout/page-skeleton.tsx +0 -49
- package/src/providers/urql-client.ts +0 -86
- package/src/router/config.tsx +0 -534
- package/src/router/layouts/dashboard-layout.tsx +0 -20
- package/src/router/layouts/root-layout.tsx +0 -69
- package/src/router/loaders/auth-loader.ts +0 -32
- package/src/router/loaders/business-loader.ts +0 -25
- package/src/router/loaders/charge-loader.ts +0 -25
- package/src/router/loaders/index.ts +0 -17
- package/src/router/routes.ts +0 -88
- package/src/router/types.ts +0 -62
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as h,j as e,c$ as u,eJ as p,B as y,d0 as g,bn as D,F as P,a as R,c as w,L as E,R as v,eK as F}from"./index-CvV5z5r9.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{R as d}from"./report-commentary-row-DCozKgVE.js";function A({year:l,setYear:m,referenceYears:o,setReferenceYears:j}){const[c,x]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(u,{opened:c,onClose:()=>x(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&m(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(g,{className:"size-5"})})]})}const b=()=>{const{year:l}=D(),{setFiltersContext:m}=h.useContext(P),[o,j]=h.useState(l?Number(l):new Date().getFullYear()),[c,x]=h.useState([]),[{data:n,fetching:i}]=R({query:C(F),variables:{reportYear:o,referenceYears:c}});h.useEffect(()=>{m(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:c,setReferenceYears:x})}))},[o,i,m,c,x]);const f=n?.profitAndLossReport,a=f?.report,s=f?.reference??[];return e.jsx(w,{title:"Profit and Loss Report",children:i?e.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:a&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:a.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("th",{children:r.revenue.amount.formatted},r.year))]}),commentaryData:a.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:a.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.costOfSales.amount.formatted},r.year))]}),commentaryData:a.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:a.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted},r.year))]}),commentaryData:a.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:a.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.marketingExpenses.amount.formatted},r.year))]}),commentaryData:a.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted},r.year))]}),commentaryData:a.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:a.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:a.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.financialExpenses.amount.formatted},r.year))]}),commentaryData:a.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:a.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.otherIncome.amount.formatted},r.year))]}),commentaryData:a.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:a.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:a.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:a.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{b as ProfitAndLossReport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,c_ as w,u as P,d1 as U,j as e,c$ as A,bA as O,B as c,d0 as K,U as z,k as _,Z as b,di as B,l as H,dj as L,bP as D,ch as M,bU as I,bV as k,ak as q,al as G,am as J,aq as Q,aG as X,bv as Z,F as $,a as W,dk as Y,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 T,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 he,dC as xe}from"./index-CvV5z5r9.js";import{D as je}from"./data-table-pagination-D9Y0_Tn8.js";import{s as pe}from"./sub-Cp_PhKiD.js";import{A as v}from"./arrow-up-down-dZmrBLse.js";import"./subMonths-DCj_iXAn.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:j}=l.useContext(z),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(k,{...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(k,{...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=>{U(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(A,{opened:j,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(O,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(!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(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}}),V=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,V]),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(A,{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:T(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:T(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 +0,0 @@
|
|
|
1
|
-
import{j as e,ak as C,al as p,am as S,aq as y,aN as w,ao as I,Q as L,p as D,f_ as H,r as u,t as m,s as E,ad as M,ae as R,B as x,c8 as _,ag as A,ah as T,ai as $,a as q,f$ as z,L as O,k as P,l as K,o as Q,g0 as V,F as G,dk as J,c as W,dn as X,dp as Y,dq as b,dr as Z,ds as v,dt as ee,du as g,g1 as se,dA as te,dB as oe,dC as re}from"./index-CvV5z5r9.js";import{D as ne}from"./data-table-pagination-D9Y0_Tn8.js";import{A as k}from"./arrow-up-down-dZmrBLse.js";function B({isInsert:s,formManager:n}){const{control:o}=n;return e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"key",control:o,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(w,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:"",required:!0})}),e.jsx(I,{})]})}),e.jsx(C,{name:"name",control:o,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:o,render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Default IRS Code"}),e.jsx(y,{children:e.jsx(w,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(I,{})]})})]})}const ae="updateSortCode",de=()=>{const[{fetching:s},n]=D(H),o=u.useCallback(async t=>{const d=`Error updating sort code ID [${t.key}]`,r=`${ae}-${t.key}`;m.loading("Updating Sort Code...",{id:r});try{const a=await n(t),i=E(a,d,r,"updateSortCode");if(i)return m.success("Success",{id:r,description:"SortCode updated"}),i.updateSortCode}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}return!1},[n]);return{fetching:s,updateSortCode:o}};function ie({sortCodeKey:s,onAdd:n}){const[o,t]=u.useState(!1);return e.jsxs(M,{open:o,onOpenChange:t,children:[e.jsx(R,{asChild:!0,children:e.jsx(x,{variant:"outline",size:"icon",children:e.jsx(_,{})})}),e.jsxs(A,{className:"w-[400px] max-w-screen-md",children:[e.jsx(T,{children:e.jsx($,{children:"Edit Sort Code"})}),e.jsx(le,{sortCodeKey:s,close:()=>t(!1),onAdd:n})]})]})}function le({sortCodeKey:s,close:n,onAdd:o}){const[{data:t,fetching:d}]=q({query:z,variables:{key:s}}),r=t?.sortCode;return!r&&!d&&m.error("Error",{description:"Couldn't find sort code"}),d?e.jsx(O,{className:"h-10 w-10 animate-spin"}):r?e.jsx(ce,{sortCode:r,close:n,onAdd:o}):e.jsx("div",{children:"Sort code not found"})}function ce({sortCode:s,close:n,onAdd:o}){const t=P({defaultValues:s}),{handleSubmit:d,formState:{dirtyFields:r}}=t,{updateSortCode:a,fetching:i}=de(),l=({key:c,...U})=>{const h=Q(U,r);if(h&&Object.keys(h).length>0){let N;if(h.defaultIrsCode){const f=h.defaultIrsCode,j=Number(f);if(!Number.isInteger(j)||j<2||j>9999)throw new Error(`Invalid IRS code: ${f}`);N=j}a({fields:{...h,defaultIrsCode:N},key:s.key}).then(f=>{f&&(o?.(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(V),o=u.useCallback(async t=>{const d=`Error adding new sort code [${t.name}]`,r=`${ue}-${t.name}`;m.loading("Adding sort code",{id:r});try{const a=await n(t);E(a,d,r)&&m.success("Success",{id:r,description:`"${t.name}" sort code was successfully added`})}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,addSortCode:o}};function xe({onAdd:s}){const[n,o]=u.useState(!1);return e.jsxs(M,{open:n,onOpenChange:o,children:[e.jsx(R,{asChild:!0,children:e.jsx(x,{children:"Add Sort Code"})}),e.jsxs(A,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(T,{children:e.jsx($,{children:"Add New Sort Code"})}),e.jsx(he,{close:()=>o(!1),onAdd:s})]})]})}function he({close:s,onAdd:n}){const o=P({}),{handleSubmit:t}=o,{addSortCode:d,fetching:r}=me(),a=i=>{i.key&&=parseInt(i.key.toString()),i.defaultIrsCode&&=parseInt(i.defaultIrsCode.toString()),d(i).then(()=>{s(),n?.()})};return e.jsx(K,{...o,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:o})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:r,children:"Add Sort Code"})})]})})}const F=[{id:"key",accessorKey:"key",cell:({row:s})=>e.jsx(g,{children:s.original.key}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Key",e.jsx(k,{})]})},{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(g,{children:s.original.name}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(k,{})]})},{id:"defaultIrsCode",accessorKey:"defaultIrsCode",cell:({row:s})=>e.jsx(g,{className:"flex flex-wrap gap-1 p-1",children:s.original.defaultIrsCode&&e.jsx(x,{variant:"outline",disabled:!0,className:"p-1 w-15",children:s.original.defaultIrsCode})}),header:"Default IRS Code"},{id:"edit",cell:({row:s})=>e.jsx(ie,{sortCodeKey:s.original.key,onAdd:s.original.refetchSortCodes})}],Ce=()=>{const[{data:s,fetching:n,error:o},t]=q({query:se}),{setFiltersContext:d}=u.useContext(G),r=u.useMemo(()=>s?.allSortCodes?.map(l=>({...l,refetchSortCodes:t}))??[],[s?.allSortCodes,t]),a=J({data:r,columns:F,getCoreRowModel:re(),getPaginationRowModel:oe(),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(()=>{o&&(console.error("Error fetching sort codes",o),m.error("Error",{description:"Error fetching sort codes"}))},[o]),e.jsx(W,{title:`Sort Codes (${r.length})`,description:"All sort codes",headerActions:e.jsx(xe,{onAdd:()=>t()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(O,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(X,{children:[e.jsx(Y,{children:a.getHeaderGroups().map(l=>e.jsx(b,{children:l.headers.map(c=>e.jsx(Z,{children:c.isPlaceholder?null:v(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),e.jsx(ee,{children:a.getRowModel().rows.length===0?e.jsx(b,{children:e.jsx(g,{colSpan: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(g,{children:v(c.column.columnDef.cell,c.getContext())},c.id))},l.id))})]})})})};export{Ce as SortCodes};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as f,fP as I,r as u,t as l,s as p,k as y,D as b,j as e,l as C,fy as D,ak as $,al as F,am as k,aq as w,Q as j,ao as v,fQ as E,fR as S,o as z,x as A,T as M,B as T,c8 as O,z as P,fS as L,fT as q,F as B,a as U,fU as _,c as Q,L as R,bS as V,bT as G,fV as H}from"./index-CvV5z5r9.js";const J="updateTag",K=()=>{const[{fetching:d},r]=f(I),c=u.useCallback(async t=>{const a=`Error updating tag ID [${t.tagId}]`,s=`${J}-${t.tagId}`;l.loading("Updating Tag...",{id:s});try{const n=await r(t),i=p(n,a,s,"updateTag");if(i)return l.success("Success",{id:s,description:"Tag updated"}),i.updateTag}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}return!1},[r]);return{fetching:d,updateTag:c}},W=({onDone:d,data:r,close:c})=>{const{updateTag:t,fetching:a}=K(),s=b(S,r),n=y({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:i,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=z(o,h);c(),g&&Object.keys(g).length>0&&t({tagId:s.id,fields:g}).then(()=>d?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs(D,{cols:3,children:[e.jsx($,{name:"name",control:i,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(F,{children:[e.jsx(k,{children:"Name"}),e.jsx(w,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(v,{})]})}),e.jsx(E,{formManager:n,tagsPath:"parentId",label:"Parent Tag"})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>m(x),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:a||Object.keys(h).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})})},X=({onDone:d,data:r})=>{const[c,{open:t,close:a}]=A(!1);function s(){a(),d?.()}return e.jsxs(e.Fragment,{children:[e.jsx(M,{label:"Edit Tag",children:e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:t,children:e.jsx(O,{className:"size-5"})})}),e.jsx(P,{centered:!0,opened:c,onClose:a,title:"Insert Business Trip",children:e.jsx(W,{close:a,onDone:s,data:r})})]})},Y="addTag",Z=()=>{const[{fetching:d},r]=f(L),c=u.useCallback(async t=>{const a=`Error adding new tag [${t.tagName}]`,s=`${Y}-${t.tagName}`;l.loading("Adding tag",{id:s});try{const n=await r(t);p(n,a,s)&&l.success("Success",{id:s,description:`"${t.tagName}" tag was successfully added`})}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}},[r]);return{fetching:d,addTag:c}},ee="deleteTag",se=()=>{const[{fetching:d},r]=f(q),c=u.useCallback(async t=>{const a=`Error deleting new tag [${t.name}]`,s=`${ee}-${t.tagId}`;l.loading(`Deleting tag [${t.name}]`,{id:s});try{const n=await r(t);p(n,a,s)&&l.success("Tag Deleted",{id:s,description:`[${t.name}] tag was successfully removed`})}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}},[r]);return{fetching:d,deleteTag:c}},ae=()=>{const{setFiltersContext:d}=u.useContext(B),[r,c]=u.useState(""),[{data:t,fetching:a},s]=U({query:H}),{addTag:n}=Z(),{deleteTag:i}=se();d(null);const m=_(t?.allTags??[]),h=u.useCallback(o=>{o.length>2&&n({tagName:o}).then(()=>{s()})},[n,s]),x=u.useCallback((o,g)=>{i({tagId:o,name:g}).then(()=>{s()})},[i,s]);return e.jsx(Q,{title:"Tags",description:"Manage tags for your bookmarks.",children:a?e.jsx(R,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m?.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-gray-600 mb-2",children:[e.jsxs("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:[o.namePath?.map((g,N)=>e.jsx("span",{className:"ms-2"},N)),o.name]}),e.jsx(X,{data:o}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(V,{className:"size-5"})})]},o.id)),e.jsxs("div",{className:"flex justify-start items-center gap-2 text-gray-600 mb-2",children:[e.jsx(j,{className:"w-80",value:r,onChange:o=>c(o.currentTarget.value),placeholder:"Add new tag",required:!0}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(G,{className:"size-5"})})]})]})})};export{ae as TagsManager};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as n,r as x,c$ as v,eJ as g,B as D,d0 as R,D as h,f4 as j,bn as E,F as y,a as w,c as C,L as T,R as A,bA as b,e9 as F,T as u,f5 as I}from"./index-CvV5z5r9.js";import{d as N}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";const o=({originalAmount:a,diffAmount:t})=>!t||a===t?n.jsx("td",{children:a}):n.jsx("td",{children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:t?"line-through":"",children:a}),t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:t})]})});function P({years:a,setYears:t}){const[r,l]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(v,{opened:r,onClose:()=>l(!1),withCloseButton:!0,content:n.jsx(g,{type:"multiple",label:"Pick years",value:a?.map(c=>new Date(c,0,1)),onChange:c=>t(c.map(p=>p.getFullYear())),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})}),n.jsx(D,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:n.jsx(R,{className:"size-5"})})]})}const f=({originalRuleData:a,diffRuleData:t})=>{const r=h(j,a),l=h(j,t),c=l?.isCompliant!==r.isCompliant||l?.percentage.formatted!==r.percentage.formatted;return!l||!c?n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:r.percentage.formatted}):n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:"line-through ".concat(r.isCompliant?"text-green-500":"text-red-500"),children:r.percentage.formatted}),l&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md ".concat(l.isCompliant?"text-green-500":"text-red-500"),children:l.percentage.formatted})]})})},d=(a,t)=>F(t).format(a);function m(a,t){if(a.length!==0)return d(a.reduce((r,l)=>r+l,0),t)}const B=()=>{const{year:a}=E(),{setFiltersContext:t}=x.useContext(y),[r,l]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:c,fetching:p}]=w({query:N(I),variables:{years:r}});x.useEffect(()=>{t(n.jsx("div",{className:"flex flex-row gap-2",children:n.jsx(P,{years:r,setYears:l})}))},[r,p,t]);const s=c?.corporateTaxRulingComplianceReport??[];return n.jsx(C,{title:"Corporate Tax Ruling Compliance Report",children:p?n.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-4",children:s&&n.jsxs(A,{highlightOnHover:!0,fontSize:"md",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{}),r.map(e=>n.jsx("th",{children:n.jsx(b,{inline:!0,size:12,processing:!s.find(i=>i.year===e)?.differences,disabled:!!s.find(i=>i.year===e)?.differences,color:"orange",zIndex:"auto",children:e})},e)),n.jsx("th",{children:"Summary"},"sum")]})}),n.jsxs("tbody",{children:[n.jsxs("tr",{children:[n.jsx("td",{children:"Total Income"}),s.map(e=>n.jsx(o,{originalAmount:e.totalIncome.formatted,diffAmount:e.differences?.totalIncome?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.totalIncome.raw).reduce((e,i)=>e+i,0),s[0].totalIncome.currency),diffAmount:m(s.map(e=>e.differences?.totalIncome?.raw??e.totalIncome.raw).filter(e=>!!e),s[0].totalIncome.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Total R&D Expensess"}),s.map(e=>n.jsx(o,{originalAmount:e.researchAndDevelopmentExpenses.formatted,diffAmount:e.differences?.researchAndDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].researchAndDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.researchAndDevelopmentExpenses?.raw??e.researchAndDevelopmentExpenses.raw).filter(e=>!!e),s[0].researchAndDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.rndRelativeToIncome.rule,children:n.jsx("p",{children:"R&D Expenses out of Income"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.rndRelativeToIncome,diffRuleData:e.differences?.rndRelativeToIncome??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Local Development Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.localDevelopmentExpenses.formatted,diffAmount:e.differences?.localDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].localDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.localDevelopmentExpenses?.raw??e.localDevelopmentExpenses.raw).filter(e=>!!e),s[0].localDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.localDevelopmentRelativeToRnd.rule,children:n.jsx("p",{children:"Local Development out of R&D"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.localDevelopmentRelativeToRnd,diffRuleData:e.differences?.localDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Foreign Development Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.foreignDevelopmentExpenses.formatted,diffAmount:e.differences?.foreignDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,i)=>e+i,0),s[0].foreignDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.foreignDevelopmentExpenses?.raw??e.foreignDevelopmentExpenses.raw).filter(e=>!!e),s[0].foreignDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.foreignDevelopmentRelativeToRnd.rule,children:n.jsx("p",{children:"Foreign Development out of R&D"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.foreignDevelopmentRelativeToRnd,diffRuleData:e.differences?.foreignDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"R&D Business Trips Expenses"}),s.map(e=>n.jsx(o,{originalAmount:e.businessTripRndExpenses.formatted,diffAmount:e.differences?.businessTripRndExpenses?.formatted??void 0},e.year)),n.jsx(o,{originalAmount:d(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,i)=>e+i,0),s[0].businessTripRndExpenses.currency),diffAmount:m(s.map(e=>e.differences?.businessTripRndExpenses?.raw??e.businessTripRndExpenses.raw).filter(e=>!!e),s[0].businessTripRndExpenses.currency)},"sum")]})]})]})})})};export{B as CorporateTaxRulingComplianceReport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as M,dE as Q,t as C,r as s,p as J,s as K,dF as U,dG as W,D as S,dH as E,j as e,ad as R,ae as q,B as v,af as X,ag as G,ah as Y,ai as Z,ap as _,ar as ee,as as se,at as te,au as ne,dI as ae,dJ as re,dK as H,dL as z,c8 as ce,dM as L,dN as ie,a0 as P,a4 as B,L as A,dO as le,g as oe,a1 as de,a2 as ue,dP as me,bk as he,b7 as xe,dQ as je,Z as k,dR as V,k as pe,bN as fe,W as ge,l as ye,bd as ve,dc as De,dn as be,dp as Ce,dq as O,dr as g,dt as Ne,du as y,an as we,c2 as Ie,F as Me,w as Te}from"./index-CvV5z5r9.js";import{s as $}from"./subMonths-DCj_iXAn.js";const Fe=()=>{const[{data:u,fetching:o,error:c},x]=M({query:Q});c&&(console.error(`Error fetching contracts: ${c}`),C.error("Error",{description:"Unable to fetch contracts"}));const a=s.useMemo(()=>u?.allOpenContracts?.slice().sort((t,d)=>t.client.originalBusiness.name>d.client.originalBusiness.name?1:-1)??[],[u]),i=s.useMemo(()=>a.map(t=>({value:t.id,label:t.client.originalBusiness.name})),[a]);return{fetching:o,refresh:()=>x(),openContracts:a,selectableOpenContracts:i}},Se="IssueMonthlyDocuments",Ee=()=>{const[{fetching:u},o]=J(U),c=s.useCallback(async x=>{const a="Error issuing monthly documents",i=Se;C.loading("Issuing documents",{id:i});try{const t=await o(x),d=K(t,a,i);if(d?.issueGreenInvoiceDocuments?.success){C.success("Success",{id:i,description:"Documents issued successfully"});return}d?.issueGreenInvoiceDocuments?.errors&&console.error(d.issueGreenInvoiceDocuments.errors),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}catch(t){console.error(`${a}: ${t}`),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}},[o]);return{fetching:u,issueDocuments:c}};function ke({issueMonth:u,contracts:o,onAdd:c}){const[x,a]=s.useState(!1),[i,t]=s.useState(""),[{data:d},h]=M({query:W,variables:{issueMonth:u,clientId:i}}),j=s.useCallback(n=>{t(n),h()},[h,t]);return s.useEffect(()=>{i!==""&&d&&(c(S(E,d.clientMonthlyChargeDraft)),a(!1))},[i,d,c]),e.jsxs(R,{open:x,onOpenChange:a,children:[e.jsx(q,{asChild:!0,children:e.jsx(v,{variant:"outline",size:"icon",children:e.jsx(X,{})})}),e.jsxs(G,{className:"w-[400px] max-w-screen-md",children:[e.jsx(Y,{children:e.jsx(Z,{children:"Select document recipient"})}),e.jsxs(_,{onValueChange:j,children:[e.jsx(ee,{children:e.jsx(se,{placeholder:"Recipient"})}),e.jsx(te,{children:o.map(n=>e.jsx(ne,{value:n.client.originalBusiness.id,children:n.client.originalBusiness.name},n.client.originalBusiness.id))})]})]})]})}function Pe({onApprove:u,draft:o}){const[c,x]=s.useState(!1),[a,i]=s.useState(!1),[t,d]=s.useState(null),{previewDocument:h,fetching:j}=ae(),[n,N]=s.useState(re(o)),T=s.useCallback((l,p)=>{N(f=>({...f,[l]:p}))},[]);s.useEffect(()=>{i(!1)},[n]);const D=s.useCallback(async()=>{try{const l=await h({input:n});if(!l)throw new Error("No preview data returned");d(l),i(!0)}catch(l){console.error("Failed to generate preview:",l)}},[n,h]);s.useEffect(()=>{c&&!t&&D()},[c,t,D]);const w=n.income?.reduce((l,p)=>{const f=p.price*p.quantity,r=f*((p.vatRate||0)/100);return l+f+r},0)||0,I=()=>{u(n),x(!1)};return e.jsxs(R,{open:c,onOpenChange:x,children:[e.jsx(q,{asChild:!0,type:"button",children:e.jsxs(H,{children:[e.jsx(z,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>x(l=>!l),type:"button",children:e.jsx(ce,{className:"size-5"})})}),e.jsx(L,{children:e.jsx("p",{children:"Edit document"})})]})}),e.jsx(G,{className:"w-7xl sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:e.jsx("div",{className:"min-h-screen bg-gray-50 p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Edit Document"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Modify and preview your accounting document before issuing"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(ie,{formData:n,updateFormData:T}),e.jsx(P,{children:e.jsxs(B,{className:"pt-6",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(v,{onClick:D,disabled:j||a,variant:"outline",className:"flex-1 bg-transparent",children:j?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-4 h-4 mr-2"}),"Preview"]})}),e.jsxs(v,{onClick:I,className:"flex-1",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Accept Changes"]})]}),w>0&&e.jsx("div",{className:"mt-4 p-3 bg-blue-50 rounded-lg",children:e.jsxs("div",{className:"flex justify-between items-center font-medium text-blue-900",children:[e.jsx("span",{children:"Total Document Amount:"}),e.jsxs("span",{children:[w.toFixed(2)," ",n.currency]})]})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(P,{className:"h-fit",children:[e.jsx(de,{children:e.jsx(ue,{children:"Document Preview"})}),e.jsx(B,{children:e.jsx("div",{className:"border-2 border-dashed border-gray-200 rounded-lg min-h-[600px] flex items-center justify-center bg-gray-50",children:j?e.jsxs("div",{className:"text-center",children:[e.jsx(A,{className:"w-8 h-8 animate-spin mx-auto mb-4 text-gray-400"}),e.jsx("p",{className:"text-gray-500",children:"Generating document preview..."})]}):t?e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"bg-white shadow-lg rounded-lg overflow-hidden",children:e.jsx("div",{className:"aspect-[8.5/11] bg-white border",children:e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(me,{src:t}),!a&&e.jsx("p",{className:"text-xs text-amber-600 mt-3 bg-amber-50 px-2 py-1 rounded",children:"Preview may be outdated"})]})})})})}):e.jsxs("div",{className:"text-center",children:[e.jsx(he,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"text-gray-500 mb-2",children:"No preview available"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Click Preview to generate document"})]})})})]}),n.client?.id&&e.jsx(xe,{businessId:n.client?.id,linkedDocumentIds:n.linkedDocumentIds??[]}),e.jsx(je,{documentType:n.type})]})]})]})})})]})}const Be=({drafts:u})=>{const[o,c]=s.useState(u.map(r=>S(E,r))),x=k($(new Date,1),"yyyy-MM-dd"),[a,i]=s.useState(x),[{data:t},d]=M({query:V,variables:{issueMonth:a},pause:!0});s.useEffect(()=>{t?.clientMonthlyChargesDrafts&&c(t.clientMonthlyChargesDrafts.map(r=>S(E,r)))},[t,c]),s.useEffect(()=>{d()},[a,d]);const h=pe({values:{generateDocumentsInfo:o}}),{issueDocuments:j}=Ee(),{openContracts:n}=Fe(),{fields:N,append:T,remove:D,update:w}=fe({control:h.control,name:"generateDocumentsInfo"}),I=h.watch("generateDocumentsInfo"),l=s.useMemo(()=>N.map((r,m)=>({...r,...I[m],id:r.client?.id})),[N,I]),p=s.useCallback(r=>{j(r)},[j]),f=s.useMemo(()=>n.filter(r=>r.billingCycle===ge.Monthly&&!l.some(m=>m.client?.id===r.client.originalBusiness.id)),[l,n]);return e.jsx("div",{className:"p-2",children:e.jsx(ye,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(p),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(ve,{children:"Issue Month:"}),e.jsx(De,{value:new Date(a),onChange:r=>{const m=new Date(r.getFullYear(),r.getMonth(),15);i(k(m,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(be,{children:[e.jsx(Ce,{children:e.jsxs(O,{children:[e.jsx(g,{children:"Name"}),e.jsx(g,{children:"Document"}),e.jsx(g,{children:"Amount"}),e.jsx(g,{children:"Remark"}),e.jsx(g,{children:"Recipients"}),e.jsx(g,{})]})}),e.jsx(Ne,{children:l.map(({id:r,...m},F)=>e.jsxs(O,{children:[e.jsx(y,{children:m.client?.name}),e.jsx(y,{children:m.type}),e.jsxs(y,{children:[m.income?.[0]?.price," ",m.income?.[0]?.currency]}),e.jsx(y,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:m.remarks})}),e.jsx(y,{children:e.jsx("div",{className:"flex flex-col",children:m.client?.emails?.map(b=>e.jsx("span",{className:"text-sm text-gray-500",children:b},b))})}),e.jsx(y,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(H,{children:[e.jsx(z,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>D(F),children:e.jsx(we,{size:16})})}),e.jsx(L,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(Pe,{draft:m,onApprove:b=>{h.setValue(`generateDocumentsInfo.${F}`,b,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),w(F,{...b})}})]})})]},r))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(ke,{contracts:f,onAdd:T,issueMonth:a}),e.jsx(Ie,{onConfirm:h.handleSubmit(p),title:`Are you sure you want to issue ${l.length} documents?`,children:e.jsx(v,{children:"Issue"})})]})]})})})},Re=()=>{const{setFiltersContext:u}=s.useContext(Me),[{data:o,fetching:c}]=M({query:V,variables:{issueMonth:k($(new Date,1),"yyyy-MM-dd")}});return s.useEffect(()=>{o?.clientMonthlyChargesDrafts||u(null)},[o,u]),c?e.jsx(Te,{}):e.jsx(Be,{drafts:o?.clientMonthlyChargesDrafts??[]})};export{Re as IssueDocuments};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as u,j as e,dS as R,Z as v,D as M,f2 as $,F as k,a as B,dk as P,eJ as T,c as V,L,dn as S,dp as Y,dq as d,dr as K,ds as C,dt as O,du as t,f3 as H,dB as q,dC as z,e9 as A,a_ as _}from"./index-CvV5z5r9.js";import{D as J}from"./data-table-pagination-D9Y0_Tn8.js";const Q=({data:a,year:s})=>{const n=u.useCallback(async()=>{if(!a)return{fileContent:"",fileName:""};const x=M($,a),m=Z(x),o=`${s}_ledger`;return{fileContent:m,fileName:o}},[a,s]);return a?e.jsx(R,{createFileVariables:n}):e.jsx("div",{})},F=[{key:"",valueFn:()=>""},{key:"",valueFn:()=>""},{key:"Counterparty",valueFn:a=>j(a.counterParty?.name??"")},{key:"Invoice Date",valueFn:a=>v(a.invoiceDate,"yyyy-MM-dd")},{key:"Value Date",valueFn:a=>v(a.valueDate,"yyyy-MM-dd")},{key:"Reference",valueFn:a=>a.reference?`"${j(a.reference)}"`:""},{key:"Description",valueFn:a=>a.description?`"${j(a.description)}"`:""},{key:"Debit Amount",valueFn:a=>a.amount.raw<0?Math.abs(a.amount.raw).toFixed(2):""},{key:"Credit Amount",valueFn:a=>a.amount.raw>=0?a.amount.raw.toFixed(2):""},{key:"Balance",valueFn:a=>a.balance.toFixed(2)}],Z=a=>{const s=[F.map(({key:n})=>n).join(",")];return a.financialEntitiesInfo.map(n=>{const x=`${j(n.entity.name)},${n.entity.sortCode?.key}`,m=`,Opening Balance,,,,,,,,${n.openingBalance.raw.toFixed(2)}`,o=`Total,${j(n.entity.name)},,,,,,,${Math.abs(n.totalDebit.raw).toFixed(2)} Debit,`,g=`,,,,,,,,${n.totalCredit.raw.toFixed(2)} Credit,${n.closingBalance.raw.toFixed(2)}`,D=`,,,,,,,,${(n.totalCredit.raw-n.totalDebit.raw).toFixed(2)} Diff,`;s.push(x,m,...n.records.map(l=>F.map(({valueFn:b})=>b(l)).join(",")),o,g,D)}),s.join(`\r
|
|
2
|
-
`)};function j(a){return a.replace(/"/g,'""').replace(/,/g,".")}const c=A(_.Ils),E=[{id:"placeholder",header:"",cell:()=>null},{id:"counterparty",accessorKey:"counterparty",header:"Counterparty",cell:({row:a})=>e.jsx("div",{className:"font-medium",children:a.original.counterParty?.name})},{id:"invoiceDate",accessorKey:"invoiceDate",header:"Invoice Date",cell:({row:a})=>{const s=new Date(a.getValue("invoiceDate")),n=v(s,"yyyy-MM-dd");return e.jsx("div",{className:"font-medium",children:n})}},{id:"valueDate",accessorKey:"valueDate",header:"Value Date",cell:({row:a})=>{const s=new Date(a.getValue("valueDate")),n=v(s,"yyyy-MM-dd");return e.jsx("div",{className:"font-medium",children:n})}},{id:"reference",accessorKey:"reference",header:"Reference"},{id:"description",accessorKey:"description",header:"Description"},{id:"debit",header:"Debit",cell:({row:a})=>{const s=a.original.amount.raw;return s<0?e.jsx("div",{className:"font-medium",children:c.format(s*-1)}):null}},{id:"credit",header:"Credit",cell:({row:a})=>{const s=a.original.amount.raw;return s>=0?e.jsx("div",{className:"font-medium",children:c.format(s)}):null}},{id:"balance",accessorKey:"balance",header:"Balance",cell:({row:a})=>e.jsx("div",{className:"font-medium",children:c.format(a.getValue("balance"))})}],I=()=>{const{setFiltersContext:a}=u.useContext(k),[s,n]=u.useState(new Date().getFullYear()-1),[{data:x,fetching:m}]=B({query:H,variables:{year:s}}),o=x?.yearlyLedgerReport,{financialEntitiesInfo:g}=o??{},D=u.useMemo(()=>g?.flatMap(r=>{const{entity:i,openingBalance:y,closingBalance:h,totalCredit:p,totalDebit:w}=r;return r.records.map(N=>({entity:i,openingBalance:y,closingBalance:h,totalCredit:p,totalDebit:w,...N}))})??[],[g]),l=P({data:D,columns:E,getCoreRowModel:z(),getPaginationRowModel:q(),initialState:{pagination:{pageSize:100}}}),b=l.getState().pagination.pageIndex;return u.useEffect(()=>{a(e.jsxs("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:[e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(J,{table:l})}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(T,{value:new Date(s,0,1),onChange:r=>r&&n(r?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(Q,{data:o,year:s})]})]}))},[s,m,a,o,l,b]),e.jsx(V,{title:"Yearly Ledger Report",children:m?e.jsx(L,{className:"h-10 w-10 animate-spin mr-2 self-center"}):o?e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(S,{children:[e.jsx(Y,{children:l.getHeaderGroups().map(r=>e.jsx(d,{children:r.headers.map(i=>e.jsx(K,{children:i.isPlaceholder?null:C(i.column.columnDef.header,i.getContext())},i.id))},r.id))}),e.jsx(O,{children:l.getRowModel().rows.map((r,i)=>{const y=l.getRowModel().rows[i-1],h=l.getRowModel().rows[i+1],p=!y||y.original.entity.id!==r.original.entity.id,w=!h||h.original.entity.id!==r.original.entity.id;return e.jsxs(e.Fragment,{children:[p&&i!==0&&e.jsx(d,{className:"border-y-2 border-t-gray-300 border-b-gray-500",children:e.jsx(t,{})}),p&&e.jsx(G,{row:r}),e.jsx(d,{children:r.getVisibleCells().map(f=>e.jsx(t,{children:C(f.column.columnDef.cell,f.getContext())},f.id))},r.id),w&&e.jsx(U,{row:r})]})})})]})}):e.jsx("div",{className:"rounded-md border h-24 text-center",children:"No results."})})};function G({row:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(d,{className:"bg-gray-300",children:[e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.name})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.sortCode?.key})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{})]},`${a.id}-opening1`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:"Opening Balance"})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:c.format(a.original.openingBalance.raw)})})]},`${a.id}-opening2`)]})}function U({row:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:"Total"})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.name})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalDebit.raw)," Debit"]})}),e.jsx(t,{})]},`${a.id}-totals1`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalCredit.raw)," Credit"]})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:c.format(a.original.closingBalance.raw)})})]},`${a.id}-totals2`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalCredit.raw-a.original.totalDebit.raw)," Diff"]})}),e.jsx(t,{})]},`${a.id}-totals3`)]})}export{I as YearlyLedgerReport};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{V,p as E,eA as q,r,t as k,s as F,a as $,eB as _,j as s,w as L,eC as R,x as H,B as Q,y as X,z as G}from"./index-CvV5z5r9.js";import{C as J,M as K}from"./Checkbox-CxedbJAl.js";/**
|
|
2
|
-
* @license lucide-react v0.546.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const U=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],g=V("square-check-big",U);/**
|
|
7
|
-
* @license lucide-react v0.546.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const W=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],N=V("square-x",W),Y="mergeCharges",Z=()=>{const[{fetching:C},a]=E(q),c=r.useCallback(async x=>{const u=`Error merging into charge ID [${x.baseChargeID}]`,l=`${Y}-${x.baseChargeID}`;k.loading("Merging Charges",{id:l});try{const d=await a(x),n=F(d,u,l,"mergeCharges");if(n)return k.success("Success",{id:l,description:"Charges were merged"}),n.mergeCharges.charge}catch(d){console.error(`${u}: ${d}`),k.error("Error",{id:l,description:u,duration:1e5,closeButton:!0})}},[a]);return{fetching:C,mergeCharges:c}};function ee({chargeIds:C,onDone:a,resetMerge:c}){const{mergeCharges:x,fetching:u}=Z(),l=Array.from(new Set(C)),[{data:d,fetching:n}]=$({query:_,variables:{chargeIds:l}}),[i,w]=r.useState(d?.chargesByIDs[0]),[m,p]=r.useState(void 0),[f,z]=r.useState(void 0),[j,I]=r.useState(void 0),[v,M]=r.useState(void 0),[D,A]=r.useState(void 0),[y,T]=r.useState(void 0),[b,O]=r.useState(void 0),[h,P]=r.useState(void 0),S=d?.chargesByIDs.length!==l.length&&"Some charges were not Found"||void 0,o=d?.chargesByIDs||[],B=r.useCallback(async()=>{if(!i){k.error("Error",{description:"No main charge selected"});return}if(l.length<2){k.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let e;return m&&m.value!==i.userDescription&&(e??={},e={...e,userDescription:m.value}),f&&f.value!==i.owner.id&&(e??={},e={...e,ownerId:f.value}),y&&y.value!==i.conversion&&(e??={},e={...e,isConversion:y.value}),j&&j.value!==i.property&&(e??={},e={...e,isProperty:j.value}),v&&v.value!==i.optionalVAT&&(e??={},e={...e,optionalVAT:v.value}),D&&D.value!==i.optionalDocuments&&(e??={},e={...e,optionalDocuments:D.value}),h&&h.value!==i.tags.map(t=>t.name).join(",")&&(e??={},e={...e,tags:h.value.split(",").filter(t=>t!=="").map(t=>({id:t}))}),b&&b.value!==i.isInvoicePaymentDifferentCurrency&&(e??={},e={...e,isInvoicePaymentDifferentCurrency:b.value}),await x({baseChargeID:i.id,chargeIdsToMerge:l.filter(t=>t!==i.id),fields:e}),c(),a()},[i,l,x,m,f,y,j,v,b,h,a,c]);return s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx(L,{})}),!n&&S&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:S})}),!n&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("table",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:"Main"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:s.jsx(J,{checked:e.id===i?.id,size:"xl",onClick:()=>{w(e),p({id:e.id,value:e.userDescription??""}),z({id:e.id,value:e.owner.id}),I({id:e.id,value:e.property??!1}),M({id:e.id,value:e.optionalVAT??!1}),A({id:e.id,value:e.optionalDocuments??!1}),O({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1}),T({id:e.id,value:e.conversion??!1}),P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})}})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Description"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:!e.userDescription||m?.value===e.userDescription,onClick:()=>p({id:e.id,value:e.userDescription??""}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:m?.id===e.id?{background:"#228be633"}:{},children:e.userDescription})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Owner"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:f?.value===e.owner.id,onClick:()=>z({id:e.id,value:e.owner.id}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:f?.id===e.id?{background:"#228be633"}:{},children:e.owner.name})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Property"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.property==null||e.property===j?.value,onClick:()=>{I({id:e.id,value:e.property??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===e.id?{background:"#228be633"}:{},children:e.property?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Conversion"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.conversion==null||e.conversion===y?.value,onClick:()=>{T({id:e.id,value:e.conversion??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:y?.id===e.id?{background:"#228be633"}:{},children:e.conversion?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional VAT"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalVAT==null||e.optionalVAT===v?.value,onClick:()=>{M({id:e.id,value:e.optionalVAT??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:v?.id===e.id?{background:"#228be633"}:{},children:e.optionalVAT?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional Documents"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalDocuments==null||e.optionalDocuments===D?.value,onClick:()=>{A({id:e.id,value:e.optionalDocuments??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:D?.id===e.id?{background:"#228be633"}:{},children:e.optionalDocuments?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoice-Payment Currency Difference"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.isInvoicePaymentDifferentCurrency==null||e.isInvoicePaymentDifferentCurrency===b?.value,onClick:()=>{I({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===e.id?{background:"#228be633"}:{},children:e.isInvoicePaymentDifferentCurrency?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Tags"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.tags==null||e.tags.map(t=>t.name).join(",")===h?.value,onClick:()=>{P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:h?.id===e.id?{background:"#228be633"}:{},children:s.jsx(R,{items:e.tags.map(t=>s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{children:t.name}),t.namePath&&s.jsx("div",{children:t.namePath.join(" > ")})]},t.id))})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Transactions"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:e.metadata?.transactionsCount??0})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoices"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:e.metadata?.invoicesCount??0})},e.id))]})]}),s.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[s.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:n||u,onClick:B,children:"Accept"}),s.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:a,children:"Cancel"}),s.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{c(),a()},children:"Reset Merge"})]})]})]})}function ie(C){const[a,{close:c,open:x}]=H(!1),{selected:u,resetMerge:l}=C,d=new Set(u.map(({id:p})=>p)),n=d.size>=1,[i,w]=r.useState(n?"default":"outline");r.useEffect(()=>{w(n?"default":"outline")},[n]);const m=r.useCallback(()=>{c(),u.map(({onChange:p})=>p())},[u,c]);return s.jsxs(s.Fragment,{children:[s.jsx(Q,{onClick:()=>{n&&x()},disabled:!n,variant:i,className:X("size-7.5",n?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:s.jsx(K,{className:"size-5"})}),s.jsx(G,{opened:a,onClose:c,size:"auto",centered:!0,children:s.jsx(ee,{chargeIds:Array.from(d),onDone:m,resetMerge:l})})]})}export{ie as M};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,dq as D,du as t,Z as y,cT as n,D as N,eO as w,c_ as T,r as d,u as v,d1 as A,ad as I,ae as O,B as S,d0 as P,ag as L,k as q,di as M,l as U,ak as f,al as C,am as F,aq as B,aN as V,ao as R,aL as k,aw as _,F as $,U as z,a as H,c as Q,w as G,dn as J,dp as Z,dr as o,dt as K,eP as W}from"./index-CvV5z5r9.js";const X=({record:a})=>{const s=N(w,a);return e.jsxs(D,{children:[e.jsx(t,{children:a.description}),e.jsx(t,{children:y(new Date(a.purchaseDate),"dd/MM/yyyy")}),e.jsx(t,{children:a.activationDate?y(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=q({defaultValues:{...a}}),{control:c,handleSubmit:x}=p,{selectableFinancialEntities:u,fetching:l}=M(),j=i=>{s({...i,year:Number(i.year)}),r()};return e.jsx(U,{...p,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(f,{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(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(B,{children:e.jsx(V,{...i,hideControls:!0,decimalScale:0})}),e.jsx(R,{})]})}),e.jsx(f,{name:"financialEntityId",defaultValue:a?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(k,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(R,{})]})}),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}=v();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(w,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($),{userContext:s}=d.useContext(z),{get:r}=v(),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}]=H({query:W,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(Q,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(J,{children:[e.jsxs(Z,{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(K,{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(X,{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 +0,0 @@
|
|
|
1
|
-
import{p as v,fW as H,r as u,t as m,s as F,aJ as U,j as e,ak as C,al as j,am as f,aq as p,Q as L,aH as y,ao as S,bP as Q,bQ as V,aN as z,aG as G,ad as D,ae as E,B as h,ag as M,ah as A,ai as R,k,l as O,fX as K,c8 as _,a as P,fY as J,L as $,F as W,dk as X,c as Y,dn as Z,dp as ee,dq as T,dr as se,ds as b,dt as te,du as w,fZ as ae,dA as re,dB as oe,dC as ne}from"./index-CvV5z5r9.js";import{D as ie}from"./data-table-pagination-D9Y0_Tn8.js";import{A as N}from"./arrow-up-down-dZmrBLse.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(H),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function q({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=U();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(L,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(S,{})]})}),e.jsx(Q,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(V,{...o,onChange:B=>{o.onChange(Number(B))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(g)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(S,{})]})}),e.jsx(C,{control:a,name:"taxExcluded",render:({field:o})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{children:"Tax excluded category"})}),e.jsx(p,{children:e.jsx(G,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(A,{children:e.jsx(R,{children:"Add New Tax Category"})}),e.jsx(xe,{close:()=>t(!1),onAdd:s})]})]})}function xe({close:s,onAdd:n}){const t=k({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx(O,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(K),t=u.useCallback(async a=>{const d="Error updating tax category",r=`${ue}-${a.taxCategoryId}`;m.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return m.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function me({taxCategoryId:s,onAdd:n}){const[t,a]=u.useState(!1);return e.jsxs(D,{open:t,onOpenChange:a,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(_,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(A,{children:e.jsx(R,{children:"Edit Tax Category"})}),e.jsx(he,{taxCategoryId:s,close:()=>a(!1),onAdd:n})]})]})}function he({taxCategoryId:s,close:n,onAdd:t}){const[{data:a,fetching:d}]=P({query:J,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&m.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx($,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=k({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx(O,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=P({query:ae}),{setFiltersContext:d}=u.useContext(W),r=s?.taxCategories??[],i=X({data:r,columns:I,getCoreRowModel:ne(),getPaginationRowModel:oe(),getSortedRowModel:re(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ie,{table:i})})}))},[d,i,l]),u.useEffect(()=>{t&&m.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(Y,{title:`Tax Categories (${r.length})`,description:"All tax categories",headerActions:e.jsx(le,{onAdd:()=>a()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx($,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(Z,{children:[e.jsx(ee,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(se,{children:c.isPlaceholder?null:b(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(te,{children:i.getRowModel().rows.length===0?e.jsx(T,{children:e.jsx(w,{colSpan:I.length,className:"text-center py-8",children:"No tax categories found"})}):i.getRowModel().rows.map(x=>e.jsx(T,{children:x.getVisibleCells().map(c=>e.jsx(w,{children:b(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{Se as TaxCategories};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,T as se,B as q,af as ae,cd as ne,a as D,fv as te,r as x,U as H,fw as le,fx as z,k as G,t as f,l as oe,fy as ie,dc as V,bP as u,bQ as k,ak as de,fz as ce,al as me,am as ue,aq as xe,Q as ye,ao as pe,bW as g,bR as S,Z as E,o as ge,p as W,fA as he,s as Q,fB as je,fC as _,e as fe,fD as ve,fE as be,u as J,c_ as Ne,d1 as Se,c$ as Ee,d0 as we,ch as Fe,D as w,fF as Ce,fG as De,fH as Ie,fI as Ae,fJ as Pe,fK as Re,fL as Te,fM as ke,fN as Me,F as Be,c as Le,L as Ze,fO as Oe}from"./index-CvV5z5r9.js";function Y(t){return e.jsx(se,{disabled:!t.tooltip,label:t.tooltip,children:e.jsx(q,{variant:"ghost",size:"icon",className:"size-7.5",...t,children:e.jsx(ae,{className:"size-5"})})})}const K=({isNewInsert:t=!0,defaultValues:s,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(H),[{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([]),[X,ee]=x.useState([]),P=s?.month??o,Z=G({defaultValues:{...s,month:P}}),{control:m,handleSubmit:O,formState:{dirtyFields:U},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,a)=>r.label>a.label?1:-1))},[c,T]),x.useEffect(()=>{b?.allTrainingFunds?.length&&T(b.allTrainingFunds.map(r=>({value:r.id,label:r.name})).sort((r,a)=>r.label>a.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,a)=>r.label>a.label?1:-1))},[I,T]),x.useEffect(()=>{!s?.employer&&v?.context.adminBusinessId&&B("employer",v.context.adminBusinessId,{shouldDirty:!0,shouldTouch:!0})},[B,s?.employer,v?.context.adminBusinessId]);const $=r=>{const a=ge(r,U);if(!(t&&(!a?.directPaymentAmount||!a?.employeeId||!a?.employer||!a?.month)))if(a&&Object.keys(a).length>0){if(!t){if(!s)return;a.employeeId??=s.employeeId,a.month??=s.month}d(a)}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($),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(V,{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:s?.employer,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:i,value:r.value,disabled:n,label:"Employer",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(de,{name:"chargeId",control:m,defaultValue:s?.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:s?.employeeId,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:X,value:r.value,disabled:M,label:"Employee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"baseSalary",control:m,defaultValue:s?.baseSalary,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Base Salary",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"globalAdditionalHours",control:m,defaultValue:s?.globalAdditionalHours,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Global Additional Hours",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"bonus",control:m,defaultValue:s?.bonus,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Bonus",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"gift",control:m,defaultValue:s?.gift,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Gift",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"travelAndSubsistence",control:m,defaultValue:s?.travelAndSubsistence,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Travel and Subsistence",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"recovery",control:m,defaultValue:s?.recovery,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Recovery",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency"}})}),e.jsx(u,{name:"vacationTakeout",control:m,defaultValue:s?.vacationTakeout,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Vacation Takeout",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"directPaymentAmount",control:m,defaultValue:s?.directPaymentAmount,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.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:s?.pensionFundId,render:({field:r,fieldState:a})=>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:a.error?.message})}),e.jsx(u,{name:"pensionEmployeeAmount",control:m,defaultValue:s?.pensionEmployeeAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Pension Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployeePercentage",control:m,defaultValue:s?.pensionEmployeePercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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:s?.pensionEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Pension Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployerPercentage",control:m,defaultValue:s?.pensionEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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:s?.compensationsEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Compensations Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"compensationsEmployerPercentage",control:m,defaultValue:s?.compensationsEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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:s?.trainingFundId,render:({field:r,fieldState:a})=>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:a.error?.message})}),e.jsx(u,{name:"trainingFundEmployeeAmount",control:m,defaultValue:s?.trainingFundEmployeeAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Training Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployeePercentage",control:m,defaultValue:s?.trainingFundEmployeePercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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:s?.trainingFundEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Training Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployerPercentage",control:m,defaultValue:s?.trainingFundEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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:s?.socialSecurityAmountEmployee,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Social Security - Employee",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"socialSecurityAmountEmployer",control:m,defaultValue:s?.socialSecurityAmountEmployer,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Social Security - Employer",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"healthPaymentAmount",control:m,defaultValue:s?.healthPaymentAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.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:s?.taxAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Income Tax",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"zkufot",control:m,defaultValue:s?.zkufot,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.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:s?.workDays,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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:s?.addedVacationDays,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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:s?.vacationDaysBalance,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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:s?.sicknessDaysBalance,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,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($),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(U).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"})]})]})})},Ue="updateSalaryRecord",$e=()=>{const[{fetching:t},s]=W(he),o=x.useCallback(async d=>{const l=`Error updating salary record [${d.salaryRecord.month}] employee [${d.salaryRecord.employeeId}]`,i=Ue;f.loading("Updating Salary Record",{id:i});try{const n=await s(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})}},[s]);return{fetching:t,updateSalaryRecord:o}},qe=({recordVariables:t,onDone:s})=>t?e.jsx(He,{recordVariables:t,onDone:s}):null,He=({recordVariables:t,onDone:s})=>{const{updateSalaryRecord:o,fetching:d}=$e(),[{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=>{s(),j&&o({salaryRecord:j})},[s,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:s,children:i||!n?e.jsx(fe,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx(K,{isNewInsert:!1,defaultValues:y,onDone:c,isModifying:d})})},ze="insertSalaryRecords",Ge=()=>{const[{fetching:t},s]=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 s(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})}},[s]);return{fetching:t,insertSalaryRecord:o}},Ve=({insertSalaryRecordParams:t,setInsertSalaryRecord:s})=>{const{insertSalaryRecord:o,fetching:d}=Ge(),l=x.useCallback(i=>{i&&o({salaryRecords:[i]}),s(void 0)},[s,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:()=>s(void 0),children:e.jsx(K,{isNewInsert:!0,onDone:l,isModifying:d,month:t.month})})};function L(){const t=new Date,s=E(t,"yyyy-MM-dd"),o=E(be(t),"yyyy-MM-dd");return{fromDate:s,toDate:o}}function We({filter:t,setFilter:s,closeModal:o}){const{control:d,handleSubmit:l,setValue:i}=G({defaultValues:{...t}}),[n,c]=x.useState([]),{userContext:y}=x.useContext(H),[{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,s(p),o()};function I(){s({...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(V,{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:s}){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)||s(c)},[t,s]);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(q,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:e.jsx(we,{className:"size-5"})})]})}const _e=({month:t,setInsertSalaryRecord:s})=>{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:s})})})]})})})},Je=({data:t})=>{const{employee:s,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:s?.name}),e.jsx("p",{className:"text-base font-medium text-gray-800",children:d})]})})})},Ye=({data:t})=>{const{pensionEmployeeAmount:s,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}),!!s?.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:[s?.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}%)`]})]})]})})})},Ke=({data:t})=>{const{healthInsuranceAmount:s,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})]})]}),!!s?.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:s?.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})]})]})]})})})},Xe=({data:t})=>{const{baseAmount:s,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:s?.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:s,workDays:o,sicknessDays:d}=w(Pe,t),{added:l,taken:i,balance:n}=s??{},{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:s})=>{const o=w(Te,s);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(Xe,{data:o}),e.jsx(Ye,{data:o}),e.jsx(Ke,{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"})]})},sr=({setEditSalaryRecord:t,setInsertSalaryRecord:s,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:s}),e.jsx("tr",{className:"h-3"}),d.map(l=>e.jsx(rr,{data:l,setEditSalaryRecord:()=>t(l.employee?.id)},`${l.month} ${l.employee?.id}`))]})},ar=({setEditSalaryRecord:t,setInsertSalaryRecord:s,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(sr,{data:i,setEditSalaryRecord:n=>t(n?{month:l,employeeId:n}:void 0),setInsertSalaryRecord:()=>s({month:l})},l))})})})]})})},tr=()=>{const{setFiltersContext:t}=x.useContext(Be),[s,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(ar,{setEditSalaryRecord:o,setInsertSalaryRecord:l,data:y?.salaryRecordsByDates}),e.jsx(qe,{recordVariables:s,onDone:()=>o(void 0)}),d&&e.jsx(Ve,{insertSalaryRecordParams:d,setInsertSalaryRecord:l})]})};export{tr as Salaries};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{V as q,r as d,j as e,D as p,B as g,P as w,b as y,C as F,el as G,em as H,en as _,eo as Q,cT as D,cm as M,J as E,K as R,ep as T,eq as J,er as $,R as V,es as K,et as Y,eu as Z,ev as W,a as z,t as X,ew as ee,T as te,ex as se,u as k,U as O,c_ as ae,c$ as ne,d0 as re,k as oe,di as ie,bP as A,bQ as S,ey as N,dc as ce,Z as I,d1 as le,F as de,c as he,L as xe,E as ue,I as me,M as pe,ez as ge}from"./index-CvV5z5r9.js";import{d as B}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{M as je}from"./index-C5MeepK_.js";import{c as fe}from"./charges-filters-D43UbXob.js";import"./Checkbox-CxedbJAl.js";import"./sub-Cp_PhKiD.js";import"./subMonths-DCj_iXAn.js";/**
|
|
2
|
-
* @license lucide-react v0.546.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ve=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]],we=q("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(G,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function P({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(H,a),{updateChargeAccountantApproval:r}=_();return e.jsx("td",{children:e.jsx(Q,{value:l??void 0,onChange:o=>r({chargeId:c,status:o})})})}const be=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:r,cumulativeAmount:o})=>{const[n,s]=d.useState(!1),t=p(J,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[t.business?.name,t.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:t.vatNumber})]}),e.jsx("td",{children:t.image&&e.jsx("a",{href:t.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:t.image,height:80,width:80})})}),e.jsx("td",{children:t.documentSerial}),e.jsx("td",{children:t.documentDate}),e.jsx("td",{children:t.chargeDate}),e.jsx("td",{className:"whitespace-nowrap",children:t.amount.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localAmount?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVat?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.foreignVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.roundedLocalVatAfterDeduction?.formatted}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(o,0)]}),e.jsx(P,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(R,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(T,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p($,a)??{expenses:[]},[o,n]=d.useState(!0);let s=0,t=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(i=>!i),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Expenses"]}),o&&e.jsxs(V,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"VAT"}),e.jsx("th",{children:"VAT ₪"}),e.jsx("th",{children:"Actual VAT"}),e.jsx("th",{children:"Rounded VAT"}),e.jsx("th",{children:"Cumulative VAT"}),e.jsx("th",{children:"Amount without VAT ₪"}),e.jsx("th",{children:"Cumulative Amount without VAT ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((i,h)=>{s+=i.taxReducedLocalAmount?.raw??0;const m=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const x=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:x,cumulativeAmount:m},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p(K,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[s.business?.name,s.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:s.vatNumber})]}),e.jsx("td",{children:s.image&&e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})})}),e.jsx("td",{children:s.documentSerial}),e.jsx("td",{children:s.documentDate}),e.jsx("td",{children:s.chargeDate}),e.jsx("td",{children:s.taxReducedForeignAmount?.formatted}),e.jsx("td",{children:s.taxReducedLocalAmount?.formatted}),e.jsx("td",{children:"₪ "+D(r,0)}),e.jsx(P,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(R,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(T,{chargeID:s.chargeId,fetching:!!s})})})})]})},Ne=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{income:r}=p(Y,a)??{income:[]},[o,n]=d.useState(!0);let s=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(t=>!t),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Income"]}),o&&e.jsxs(V,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"Cumulative Amount ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((t,i)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(De,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},Fe=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(Z,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ie=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(W,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ae=({filter:{monthDate:a,financialEntityId:c},isLoading:l})=>{const[{data:r,fetching:o,error:n},s]=z({query:B(se),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),X.error("Error",{description:t,duration:5e3,closeButton:!0})}},[n]),d.useEffect(()=>{if(r){const t=new File([r.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});ee(t)}},[r]),e.jsx(te,{label:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:o||l,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(we,{className:"size-5"})})})};function Se({filter:a,setFilter:c,closeModal:l}){const{control:r,handleSubmit:o,setValue:n}=oe({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ie(),i=x=>{c(x),l()};function h(){c(),l()}function m(x){const u=new Date(x.getFullYear(),x.getMonth(),15);n("monthDate",I(u,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:o(i),children:[e.jsx(A,{name:"financialEntityId",control:r,defaultValue:void 0,render:({field:x,fieldState:u})=>e.jsx(S,{...x,data:s,value:x.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:x,fieldState:u})=>e.jsx(S,{...x,data:fe,value:x.value??N.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:u.error?.message})}),e.jsx(ce,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.monthDate):new Date,onChange:m,popoverProps:{withinPortal:!0}}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",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:h,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:l,children:"Cancel"})]})]})]})}function Me({filter:a,setFilter:c}){const[l,r]=d.useState(!1),{get:o,set:n}=k(),{userContext:s}=d.useContext(O);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:I(new Date,"yyyy-MM-15")},le(i,a)||c(i)}return d.useEffect(()=>{const i=ae(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(ne,{opened:l,onClose:()=>r(!1),content:e.jsx(Se,{filter:a,setFilter:t,closeModal:()=>r(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(re,{className:"size-5"})})]})}const Be=()=>{const{get:a}=k(),{setFiltersContext:c}=d.useContext(de),{userContext:l}=d.useContext(O),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:I(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=d.useState(void 0),[h,m]=d.useState(void 0),[x,u]=d.useState(void 0),[{data:j,fetching:b}]=z({query:B(ge),variables:{filters:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(U=>U!==v)):s([...n,v])},[n]);function L(){s([])}d.useEffect(()=>{c(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:r,isLoading:b}),e.jsx(Me,{filter:{...r},setFilter:o}),e.jsx(je,{selected:n.map(v=>({id:v,onChange:()=>{}})),resetMerge:L})]}))},[j,r,b,c,n]);const C=d.useMemo(()=>new Set(n),[n]);return e.jsx(he,{title:"VAT Monthly Report",children:b?e.jsx(xe,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.chargesType!==N.Expense&&e.jsx(Ne,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==N.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Fe,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),x&&e.jsx(ue,{chargeId:x.id,close:()=>u(void 0)}),t&&e.jsx(me,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(pe,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>m(void 0)})]})})};export{Be as VatMonthlyReport};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m,by as h,D as T,r as a,j as s,bz as x,bA as g,bB as j,F as B,bC as C,T as b,aG as w,c as v,L as y,af as E,bD as P}from"./index-CvV5z5r9.js";import{E as D,P as L,C as F}from"./editable-business-trip-DhqOQBPa.js";const S=({data:c,isOpened:o,shouldValidate:l})=>{const e=T(j,c),[{data:r,fetching:i}]=m({pause:!l,query:h,variables:{id:e.id}}),d=a.useMemo(()=>l?r?.businessTrip&&(r.businessTrip.uncategorizedTransactions?.length||r?.businessTrip.summary?.errors?.length):!1,[r]),u=d||e?.accountantApproval!=="APPROVED";return s.jsxs(x.Item,{value:e.id,children:[s.jsx(x.Control,{children:s.jsx(g,{inline:!0,size:12,processing:i,disabled:!u,color:d?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(x.Panel,{children:o&&s.jsx(D,{tripId:e.id,isExtended:!0},e.id)})]})},N=()=>{const{setFiltersContext:c}=a.useContext(B),[o,l]=a.useState([]),[e,r]=a.useState(!1),[{data:i,fetching:d}]=m({query:P});a.useEffect(()=>{if(!i?.allBusinessTrips?.length){l([]);return}const t=i.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[i?.allBusinessTrips]);const[u,f]=a.useState([]);return a.useEffect(()=>{c(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(C,{}),s.jsx(b,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(w,{checked:e??!1,onCheckedChange:t=>r(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(L,{filename:"business_trips"})]}))},[i,d,c,e]),s.jsx(v,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&d?s.jsx(y,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(F,{children:s.jsx(x,{className:"w-full",multiple:!0,value:u,onChange:f,chevron:s.jsx(E,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:u.includes(t.id)},t.id))})})})};export{N as BusinessTrips};
|