@accounter/client 0.0.11-alpha-20260126140805-098cb12019a98fcf50be8b4f6d423adef45f1f8e → 0.0.11-alpha-20260126203116-e4ae2d445da89ef2194deb61fef02975089397cb
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 +16 -1
- package/dist/assets/{Checkbox-Dmuz3t7B.js → Checkbox-De6ghCZT.js} +1 -1
- package/dist/assets/{MultiSelect-DBeIExB5.js → MultiSelect-Ca6lO0tL.js} +1 -1
- package/dist/assets/{Progress---sZILQb.js → Progress-26V_Zxr-.js} +1 -1
- package/dist/assets/{Table-BQv3frL8.js → Table-8-ldSKpC.js} +1 -1
- package/dist/assets/{Typography-B8Kph7eR.js → Typography-DyOGysfv.js} +1 -1
- package/dist/assets/{accordion-Bn08_4fN.js → accordion-DP7ZozTk.js} +1 -1
- package/dist/assets/{accountant-approvals-DuNl7y6H.js → accountant-approvals-DKeksuRo.js} +1 -1
- package/dist/assets/{accounter-table-DTsgtq5M.js → accounter-table-D91AAtb3.js} +1 -1
- package/dist/assets/{addDays-DTiBTTns.js → addDays-DbQpcl70.js} +1 -1
- package/dist/assets/{all-charges-DPyM-a74.js → all-charges-C25sw4Vw.js} +1 -1
- package/dist/assets/{arrow-up-down-VY6mkkTR.js → arrow-up-down-Du86WmzT.js} +1 -1
- package/dist/assets/{building-2-CMKd_bU8.js → building-2-BgbaTAJm.js} +1 -1
- package/dist/assets/{business-BVMKhHFx.js → business-B_k5j_ba.js} +1 -1
- package/dist/assets/{business-extended-info-B94y5ZK6.js → business-extended-info-Dn8Jjrlr.js} +1 -1
- package/dist/assets/{business-header-BC86M-9m.js → business-header-CVNY-ll1.js} +1 -1
- package/dist/assets/{business-ledger-filters-es3H4rPK.js → business-ledger-filters-Ctqgcwo5.js} +1 -1
- package/dist/assets/{business-ledger-single-U3zkqgW2.js → business-ledger-single-B2zYi6oe.js} +1 -1
- package/dist/assets/business-trip-BTFVFqTb.js +1 -0
- package/dist/assets/charge-BiCrKZ5S.js +1 -0
- package/dist/assets/{charges-filters-CFCAP-bP.js → charges-filters-Ss76EpGY.js} +1 -1
- package/dist/assets/{charges-ledger-validation-CCTNRpCE.js → charges-ledger-validation-829LsQIR.js} +1 -1
- package/dist/assets/charges-table-CmHxXzVR.js +7 -0
- package/dist/assets/{contracts-ljjcB_x7.js → contracts-CoybM2nI.js} +1 -1
- package/dist/assets/{data-table-column-header-CZ1dXiU0.js → data-table-column-header-_ZrN0Vs6.js} +1 -1
- package/dist/assets/{data-table-pagination-XAlQIbO9.js → data-table-pagination-DAvY_qBU.js} +1 -1
- package/dist/assets/{deposits-transactions-table-2rtRFZgK.js → deposits-transactions-table-DGuOHsiS.js} +1 -1
- package/dist/assets/{download-csv-BSGaUZsM.js → download-csv-CI8CQmZN.js} +1 -1
- package/dist/assets/{download-csv-button-CMQBUQeX.js → download-csv-button-C12VYNQh.js} +1 -1
- package/dist/assets/{editable-business-trip-CED1Su3d.js → editable-business-trip-DEIjhoGd.js} +1 -1
- package/dist/assets/{eye-off-Buv7eciz.js → eye-off-DPLQFIHz.js} +1 -1
- package/dist/assets/{funnel-Cfb9Pxmr.js → funnel-DrbTHWGk.js} +1 -1
- package/dist/assets/{index-GlUqZUgQ.js → index-6voPIuBc.js} +1 -1
- package/dist/assets/{index-X3RoQQa9.js → index-B48UbZgd.js} +1 -1
- package/dist/assets/{index-Dq33WQoi.js → index-B6dfuYIx.js} +1 -1
- package/dist/assets/{index-B0hZ0TDG.js → index-BFXVaxb0.js} +1 -1
- package/dist/assets/{index-BhFsGqUx.js → index-BWVeSaVH.js} +1 -1
- package/dist/assets/{index-Bui9zV-z.js → index-BfmxxMgF.js} +1 -1
- package/dist/assets/{index-X9rrwleE.js → index-BmpxpR0w.js} +1 -1
- package/dist/assets/{index-DIrLsKod.js → index-CPWGn2pz.js} +1 -1
- package/dist/assets/{index-DGAT1KYx.js → index-CTwMeBqF.js} +1 -1
- package/dist/assets/{index-Dal_ULkA.js → index-CWB4GuES.js} +1 -1
- package/dist/assets/{index-CSdQtH7c.js → index-Ci6HaxoD.js} +1 -1
- package/dist/assets/{index-3ev2Q3E9.js → index-Cl0HzH8n.js} +1 -1
- package/dist/assets/{index-BN-I0GSO.js → index-D3BVMctX.js} +1 -1
- package/dist/assets/{index-CcZll7L2.js → index-DAU5uvX5.js} +1 -1
- package/dist/assets/{index-CjG9JDZB.js → index-DJdqwTB-.js} +1 -1
- package/dist/assets/{index-C7p19nIa.js → index-DLG-Can3.js} +1 -1
- package/dist/assets/{index-7gCTV42h.js → index-DT0MsOt-.js} +1 -1
- package/dist/assets/{index-DRBzHdu9.js → index-DiURoW7Y.js} +1 -1
- package/dist/assets/{index-DJY6AKiM.js → index-EUnNrMjG.js} +1 -1
- package/dist/assets/{index-DOy0Yf1i.js → index-HzW6tFXv.js} +1 -1
- package/dist/assets/{index-B4OP8iL7.js → index-SeZ6e2IY.js} +1 -1
- package/dist/assets/{index-8fdLByFg.js → index-Tbw04SMm.js} +1 -1
- package/dist/assets/{index-CPMJQkvw.js → index-Y8bTnSrF.js} +1 -1
- package/dist/assets/{index-DzzUoyj4.js → index-ZKG76s7Z.js} +1 -1
- package/dist/assets/{index-rI994S3C.js → index-llwTvhRi.js} +6 -6
- package/dist/assets/{index-DokXNUuN.js → index-xFXxtg2C.js} +1 -1
- package/dist/assets/{index.es-C2YDJ0AL.js → index.es-CFgf-VWh.js} +1 -1
- package/dist/assets/issue-document-DVCemcvP.js +1 -0
- package/dist/assets/{login-page-BimTSmTC.js → login-page-BUNJ0vL_.js} +1 -1
- package/dist/assets/{missing-info-charges-CVhY60ZL.js → missing-info-charges-Dsy5oUHu.js} +1 -1
- package/dist/assets/{modal-BXR_xgUm.js → modal-B0cCJdW9.js} +1 -1
- package/dist/assets/{modify-contract-dialog-flMl2p_T.js → modify-contract-dialog-DNQYpsqS.js} +1 -1
- package/dist/assets/{page-layout-DMGj5xhW.js → page-layout-ClvcCJfx.js} +1 -1
- package/dist/assets/{page-not-found-B_GB5ntj.js → page-not-found-zY3WEMae.js} +1 -1
- package/dist/assets/{panel-top-open-Bf39HBrp.js → panel-top-open-pJuuLeLe.js} +1 -1
- package/dist/assets/{report-commentary-row-BMyeQR9J.js → report-commentary-row-CuMCzc7C.js} +1 -1
- package/dist/assets/{save-jkuyCWyY.js → save-Dlfry6XY.js} +1 -1
- package/dist/assets/{similar-transactions-modal-DX3CPrMo.js → similar-transactions-modal-DjIjqO-0.js} +1 -1
- package/dist/assets/{sub-CEXBz_OW.js → sub-D5WK8Yq6.js} +1 -1
- package/dist/assets/subMonths-Ft6EDjKW.js +1 -0
- package/dist/assets/{summary-CPKS_69D.js → summary-yl9MRbvK.js} +1 -1
- package/dist/assets/{toggle-expansion-button-Y2eS7nqg.js → toggle-expansion-button-CGwmL9mo.js} +1 -1
- package/dist/assets/{update-accountant-status-zL6vnwU9.js → update-accountant-status-QJ1upFTt.js} +1 -1
- package/dist/assets/{use-issue-monthly-documents-D9vQpbaZ.js → use-issue-monthly-documents-pV0tTZGQ.js} +1 -1
- package/dist/assets/{use-url-query-CqWra6gD.js → use-url-query-C70bqR6l.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +4 -4
- package/src/components/common/merge-charges/index.tsx +1 -1
- package/src/components/common/modals/preview-document-modal.tsx +5 -2
- package/src/gql/graphql.ts +1 -1
- package/dist/assets/business-trip-BUKYnQkG.js +0 -1
- package/dist/assets/charge-DuqIMfNm.js +0 -1
- package/dist/assets/charges-table-BJtpvXfL.js +0 -7
- package/dist/assets/issue-document-zNxGzRkY.js +0 -1
- package/dist/assets/subMonths-DY4HlBVa.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as _,r as o,j as e,J as I,B as w,a6 as r,e9 as je,aP as T,ay as V,ea as fe,eb as u,ah as q,R as G,d7 as L,ec as Q,bY as J,ed as Y,c5 as Z,c6 as K,bp as W,bO as X,bP as ee,bQ as S,bR as te,c2 as E,b$ as se,dI as ae,bS as ne,bT as D,dw as re,ee as be,ef as N,eg as Ne,eh as we,ei as ye,u as oe,t as ve,ej as Se,T as Ce,ek as Ae,el as Te,aC as le,bB as Ve,E as De,em as Ie,bE as H,bH as $,en as B,bN as Re,w as P,bI as Me,F as Ee,L as Fe,eo as ze}from"./index-rI994S3C.js";import{d as ce}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as ie}from"./use-url-query-CqWra6gD.js";import{C as O,a as de,b as me,M as ke}from"./charges-table-BJtpvXfL.js";import{P as Le}from"./page-layout-DMGj5xhW.js";import{P as R,a as M}from"./panel-top-open-Bf39HBrp.js";import{C as ue}from"./index-C7p19nIa.js";import{T as xe}from"./toggle-expansion-button-Y2eS7nqg.js";import{U as Be}from"./update-accountant-status-zL6vnwU9.js";import{c as Pe}from"./charges-filters-CFCAP-bP.js";import{P as Oe}from"./modal-BXR_xgUm.js";import{F as Ue}from"./funnel-Cfb9Pxmr.js";import"./Table-BQv3frL8.js";import"./summary-CPKS_69D.js";import"./accordion-Bn08_4fN.js";import"./deposits-transactions-table-2rtRFZgK.js";import"./Checkbox-Dmuz3t7B.js";import"./data-table-column-header-CZ1dXiU0.js";import"./eye-off-Buv7eciz.js";import"./similar-transactions-modal-DX3CPrMo.js";import"./building-2-CMKd_bU8.js";import"./addDays-DTiBTTns.js";import"./sub-CEXBz_OW.js";import"./subMonths-DY4HlBVa.js";import"./MultiSelect-DBeIExB5.js";const He=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],pe=_("chart-column",He);const $e=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],_e=_("file-digit",$e),qe=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(je,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.businessTrips.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Business Trips"]})}),c&&a&&e.jsx(O,{data:a.businessTrips,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})};function U(t){switch(t){case"C":case"M":return"Self Invoice";case"H":return"Single Doc By Law";case"I":return"Palestinian Customer";case"K":return"Petty Cash";case"L1":return"Unidentified Customer";case"L2":return"Unidentified Zero or Exempt";case"P":return"Palestinian Supplier";case"R":return"Import";case"S1":case"T":return"Regular";case"S2":return"Zero or Exempt";case"Y":return"Export";default:return"Unknown"}}const Ge=t=>{const s=t.reduce((n,a)=>(n[a.recordType]||={recordType:a.recordType,count:0,vatTotal:0,totalBeforeVat:0},n[a.recordType].count++,n[a.recordType].vatTotal+=a.roundedLocalVatAfterDeduction?.raw??0,n[a.recordType].totalBeforeVat+=a.taxReducedLocalAmount?.raw??0,n),{});return Object.values(s)},he=({records:t})=>{const s=o.useMemo(()=>Ge(t??[]),[t]);return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left",children:[e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground",children:"Record Type"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"Count"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"Total Before VAT"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"VAT Total"})]})}),e.jsx("tbody",{children:s.map(n=>e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsxs("td",{className:"py-3 text-sm font-medium",children:[U(n.recordType)," (",n.recordType,")"]}),e.jsx("td",{className:"py-3 text-sm text-right",children:n.count}),e.jsx("td",{className:"py-3 text-sm text-right",children:T(n.totalBeforeVat,V.Ils)}),e.jsx("td",{className:"py-3 text-sm text-right",children:T(n.vatTotal,V.Ils)})]},n.recordType))})]})})};function ge({data:t}){const{chargeId:s,chargeAccountantStatus:n}=r(fe,t);return e.jsx("td",{children:e.jsx(Be,{value:n??void 0,chargeId:s})})}const b=Q(),z=[b.accessor(t=>r(u,t.data).recordType,{id:"recordType",header:"Record Type",cell:t=>{const s=t.getValue();return e.jsx("p",{className:"whitespace-wrap",children:`${U(s)} (${s})`})}}),b.accessor(t=>r(u,t.data).business?.name??"",{id:"business",header:"Business",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-1",children:[s.business?.id?e.jsx(q,{to:G.BUSINESSES.DETAIL(s.business.id),target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:s.business.name}):e.jsx("span",{children:s.business?.name}),s.vatNumber&&e.jsx("span",{className:"text-[10px] text-gray-500",children:s.vatNumber})]})}}),b.display({id:"invoice",header:"Invoice",cell:t=>{const s=r(u,t.row.original.data);return 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})}):null}}),b.accessor(t=>r(u,t.data).documentSerial??"",{id:"documentSerial",header:"Invoice Serial#",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.getValue()}),s.allocationNumber&&e.jsxs("span",{className:"text-xs",children:["(",s.allocationNumber,")"]})]})}}),b.accessor(t=>r(u,t.data).documentDate??"",{id:"documentDate",header:"Invoice Date",cell:t=>t.getValue()}),b.accessor(t=>r(u,t.data).chargeDate??"",{id:"chargeDate",header:"Transaction Date",cell:t=>t.getValue()}),b.accessor(t=>r(u,t.data).amount.raw??0,{id:"amount",header:"Amount",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.amount.formatted})}}),b.accessor(t=>r(u,t.data).localAmount?.raw??0,{id:"localAmount",header:"Amount ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localAmount?.formatted})}}),b.accessor(t=>r(u,t.data).localVat?.raw??0,{id:"localVat",header:"VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localVat?.formatted})}}),b.accessor(t=>r(u,t.data).localVatAfterDeduction?.raw??0,{id:"localVatAfterDeduction",header:"VAT ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localVatAfterDeduction?.formatted})}}),b.accessor(t=>r(u,t.data).foreignVatAfterDeduction?.raw??0,{id:"foreignVatAfterDeduction",header:"Actual VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.foreignVatAfterDeduction?.formatted})}}),b.accessor(t=>r(u,t.data).roundedLocalVatAfterDeduction?.raw??0,{id:"roundedLocalVatAfterDeduction",header:"Rounded VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.roundedLocalVatAfterDeduction?.formatted})}}),b.accessor(t=>t.cumulativeVat,{id:"cumulativeVat",header:"Cumulative VAT",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),b.accessor(t=>r(u,t.data).taxReducedLocalAmount?.raw??0,{id:"taxReducedLocalAmount",header:"Amount without VAT ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.taxReducedLocalAmount?.formatted})}}),b.accessor(t=>t.cumulativeAmount,{id:"cumulativeAmount",header:"Cumulative Amount without VAT ₪",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),b.display({id:"accountantApproval",header:"Accountant Approval",cell:t=>{const s=r(u,t.row.original.data);return e.jsx(ge,{data:s})}}),b.display({id:"actions",header:"Edit",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(xe,{toggleExpansion:()=>t.row.toggleExpanded(),isExpanded:t.row.getIsExpanded()}),e.jsx(de,{toggleMergeSelected:()=>t.row.original.toggleMergeCharge(s.chargeId),mergeSelected:t.row.original.mergeSelectedCharges.has(s.chargeId)}),e.jsx(ue,{chargeId:s.chargeId})]})}})],Qe=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const{expenses:a}=r(be,t)??{expenses:[]},[c,l]=o.useState(!0),[p,x]=o.useState([]),[j,i]=o.useState({}),[f,h]=o.useState({}),[g,C]=o.useState("detailed"),F=o.useMemo(()=>{let d=0,m=0;return a.map(y=>(d+=y.taxReducedLocalAmount?.raw??0,m+=y.roundedLocalVatAfterDeduction?.raw??0,{data:y,toggleMergeCharge:s,mergeSelectedCharges:n,cumulativeVat:m,cumulativeAmount:d}))},[a,s,n]),A=J({data:F,columns:z,getCoreRowModel:K(),onSortingChange:x,getSortedRowModel:Z(),onColumnVisibilityChange:i,onExpandedChange:h,getExpandedRowModel:Y(),state:{sorting:p,columnVisibility:j,expanded:f}});return e.jsxs(I,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(d=>!d),children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Expenses"]}),c&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:g==="detailed"?"default":"outline",size:"sm",onClick:()=>C("detailed"),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Detailed"]}),e.jsxs(w,{variant:g==="summarized"?"default":"outline",size:"sm",onClick:()=>C("summarized"),children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Summarized"]})]})]}),c&&(g==="detailed"?e.jsxs(X,{children:[e.jsx(ee,{children:A.getHeaderGroups().map(d=>e.jsx(S,{children:d.headers.map(m=>e.jsx(te,{colSpan:m.colSpan,children:m.isPlaceholder?null:e.jsxs(w,{variant:"ghost",onClick:m.column.getToggleSortingHandler(),className:"h-auto p-0 hover:bg-transparent",children:[E(m.column.columnDef.header,m.getContext()),{asc:e.jsx(ae,{className:"size-5"}),desc:e.jsx(se,{className:"size-5"})}[m.column.getIsSorted()]??null]})},m.id))},d.id))}),e.jsx(ne,{children:A.getRowModel().rows?.length?A.getRowModel().rows.map(d=>{const m=r(u,d.original.data);return e.jsxs(o.Fragment,{children:[e.jsx(S,{"data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(y=>e.jsx(D,{children:E(y.column.columnDef.cell,y.getContext())},y.id))}),d.getIsExpanded()&&e.jsx(S,{children:e.jsx(D,{colSpan:z.length,children:e.jsx(re,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(me,{chargeID:m.chargeId,fetching:!!m})})})})]},d.id)}):e.jsx(S,{children:e.jsx(D,{colSpan:z.length,className:"h-24 text-center",children:"No results."})})})]}):e.jsx(he,{records:a}))]})},v=Q(),k=[v.accessor(t=>r(N,t.data).recordType,{id:"recordType",header:"Record Type",cell:t=>{const s=t.getValue();return e.jsx("p",{className:"whitespace-wrap",children:`${U(s)} (${s})`})}}),v.accessor(t=>r(N,t.data).business?.name??"",{id:"business",header:"Business",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-1",children:[s.business?.id?e.jsx(q,{to:G.BUSINESSES.DETAIL(s.business.id),target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:s.business.name}):e.jsx("span",{children:s.business?.name}),s.vatNumber&&e.jsx("span",{className:"text-[10px] text-gray-500",children:s.vatNumber})]})}}),v.display({id:"invoice",header:"Invoice",cell:t=>{const s=r(N,t.row.original.data);return 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})}):null}}),v.accessor(t=>r(N,t.data).documentSerial??"",{id:"documentSerial",header:"Invoice Serial#",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.getValue()}),s.allocationNumber&&e.jsxs("span",{className:"text-xs",children:["(",s.allocationNumber,")"]})]})}}),v.accessor(t=>r(N,t.data).documentDate??"",{id:"documentDate",header:"Invoice Date",cell:t=>t.getValue()}),v.accessor(t=>r(N,t.data).chargeDate??"",{id:"chargeDate",header:"Transaction Date",cell:t=>t.getValue()}),v.accessor(t=>r(N,t.data).taxReducedForeignAmount?.raw??0,{id:"amount",header:"Amount",cell:t=>r(N,t.row.original.data).taxReducedForeignAmount?.formatted??""}),v.accessor(t=>r(N,t.data).taxReducedLocalAmount?.raw??0,{id:"localAmount",header:"Amount ₪",cell:t=>r(N,t.row.original.data).taxReducedLocalAmount?.formatted??""}),v.accessor(t=>t.cumulativeAmount,{id:"cumulativeAmount",header:"Cumulative Amount ₪",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),v.display({id:"accountantApproval",header:"Accountant Approval",cell:t=>{const s=r(N,t.row.original.data);return e.jsx(ge,{data:s})}}),v.display({id:"actions",header:"Edit",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(xe,{toggleExpansion:()=>t.row.toggleExpanded(),isExpanded:t.row.getIsExpanded()}),e.jsx(de,{toggleMergeSelected:()=>t.row.original.toggleMergeCharge(s.chargeId),mergeSelected:t.row.original.mergeSelectedCharges.has(s.chargeId)}),e.jsx(ue,{chargeId:s.chargeId})]})}})],Je=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const{income:a}=r(Ne,t)??{income:[]},[c,l]=o.useState(!0),[p,x]=o.useState([]),[j,i]=o.useState({}),[f,h]=o.useState({}),[g,C]=o.useState("detailed"),F=o.useMemo(()=>{let d=0;return a.map(m=>(d+=m.taxReducedLocalAmount?.raw??0,{data:m,toggleMergeCharge:s,mergeSelectedCharges:n,cumulativeAmount:d}))},[a,s,n]),A=J({data:F,columns:k,getCoreRowModel:K(),onSortingChange:x,getSortedRowModel:Z(),onColumnVisibilityChange:i,onExpandedChange:h,getExpandedRowModel:Y(),state:{sorting:p,columnVisibility:j,expanded:f}});return e.jsxs(I,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(d=>!d),children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Income"]}),c&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:g==="detailed"?"default":"outline",size:"sm",onClick:()=>C("detailed"),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Detailed"]}),e.jsxs(w,{variant:g==="summarized"?"default":"outline",size:"sm",onClick:()=>C("summarized"),children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Summarized"]})]})]}),c&&(g==="detailed"?e.jsxs(X,{children:[e.jsx(ee,{children:A.getHeaderGroups().map(d=>e.jsx(S,{children:d.headers.map(m=>e.jsx(te,{colSpan:m.colSpan,children:m.isPlaceholder?null:e.jsxs(w,{variant:"ghost",onClick:m.column.getToggleSortingHandler(),className:"h-auto p-0 hover:bg-transparent",children:[E(m.column.columnDef.header,m.getContext()),{asc:e.jsx(ae,{className:"size-5"}),desc:e.jsx(se,{className:"size-5"})}[m.column.getIsSorted()]??null]})},m.id))},d.id))}),e.jsx(ne,{children:A.getRowModel().rows?.length?A.getRowModel().rows.map(d=>{const m=r(N,d.original.data);return e.jsxs(o.Fragment,{children:[e.jsx(S,{"data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(y=>e.jsx(D,{children:E(y.column.columnDef.cell,y.getContext())},y.id))}),d.getIsExpanded()&&e.jsx(S,{children:e.jsx(D,{colSpan:k.length,children:e.jsx(re,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(me,{chargeID:m.chargeId,fetching:!!m})})})})]},d.id)}):e.jsx(S,{children:e.jsx(D,{colSpan:k.length,className:"h-24 text-center",children:"No results."})})})]}):e.jsx(he,{records:a}))]})},Ye=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(we,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.differentMonthDoc.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]})}),c&&a&&e.jsx(O,{data:a.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})},Ze=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(ye,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.missingInfo.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Missing Info"]})}),c&&a&&e.jsx(O,{data:a.missingInfo,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})},Ke=({filter:{monthDate:t,financialEntityId:s},isLoading:n})=>{const[{data:a,fetching:c,error:l},p]=oe({query:ce(Ae),pause:!0,variables:{monthDate:t,financialEntityId:s}});return o.useEffect(()=>{if(l){const x="Error generating PCN874 file";console.error(`${x}: ${l}`),ve.error("Error",{description:x,duration:5e3,closeButton:!0})}},[l]),o.useEffect(()=>{if(a){const x=new File([a.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Se(x)}},[a]),e.jsx(Ce,{content:"Generate and Download PCN874 File",children:e.jsx(w,{disabled:c||n,variant:"outline",size:"icon",className:"size-7.5",onClick:p,children:e.jsx(_e,{className:"size-5"})})})},We=({data:t})=>{const s=r(Te,t),n=o.useMemo(()=>s?.expenses??[],[s?.expenses]),a=o.useMemo(()=>s?.income??[],[s?.income]),c=o.useMemo(()=>a.reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[a]),l=o.useMemo(()=>a.reduce((i,f)=>i+(f.roundedLocalVatAfterDeduction?.raw??0),0),[a]),p=o.useMemo(()=>a.filter(i=>(i.roundedLocalVatAfterDeduction?.raw??0)===0).reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[a]),x=o.useMemo(()=>n.filter(i=>i.isProperty).reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[n]),j=o.useMemo(()=>l-n.reduce((i,f)=>i+(f.roundedLocalVatAfterDeduction?.raw??0),0),[l,n]);return e.jsxs(I,{className:"p-6",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Report Summary"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Taxable Sales Total"}),e.jsx("p",{className:"text-2xl font-bold",children:T(c,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Taxable Sales VAT"}),e.jsx("p",{className:"text-2xl font-bold",children:T(l,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Zero / Exempt Sales"}),e.jsx("p",{className:"text-2xl font-bold",children:T(p,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Equipment Inputs"}),e.jsx("p",{className:"text-2xl font-bold",children:T(x,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total VAT Amount"}),e.jsx("p",{className:"text-2xl font-bold",children:T(j,V.Ils)})]})]})]})};function Xe({filter:t,setFilter:s,closeModal:n}){const{control:a,handleSubmit:c,setValue:l}=De({defaultValues:{...t}}),{selectableAdminBusinesses:p,fetching:x}=Ie(),j=h=>{s(h),n()};function i(){s(),n()}function f(h){const g=new Date(h.getFullYear(),h.getMonth(),15);l("monthDate",P(g,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[x?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:c(j),children:[e.jsx(H,{name:"financialEntityId",control:a,defaultValue:void 0,render:({field:h,fieldState:g})=>e.jsx($,{...h,data:p,value:h.value,disabled:x,label:"Report Issuer (Admin Business)",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message})}),e.jsx(H,{name:"chargesType",control:a,defaultValue:t.chargesType,render:({field:h,fieldState:g})=>e.jsx($,{...h,data:Pe,value:h.value??B.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:g.error?.message})}),e.jsx(Re,{defaultValue:t?.monthDate?new Date(t.monthDate):new Date,defaultDate:t?.monthDate?new Date(t.monthDate):new Date,onChange:f,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: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:n,children:"Cancel"})]})]})]})}function et({filter:t,setFilter:s}){const[n,a]=o.useState(!1),{get:c,set:l}=ie(),{userContext:p}=o.useContext(le);function x(j){j||={financialEntityId:p?.context.adminBusinessId??t.financialEntityId,monthDate:P(new Date,"yyyy-MM-15")},Me(j,t)||s(j)}return o.useEffect(()=>{const j=Ve(t??{})?null:encodeURIComponent(JSON.stringify(t)),i=c("vatMonthlyReportFilters");j!==i&&l("vatMonthlyReportFilters",j)},[t,c,l]),e.jsxs(e.Fragment,{children:[e.jsx(Oe,{opened:n,onClose:()=>a(!1),content:e.jsx(Xe,{filter:t,setFilter:x,closeModal:()=>a(!1)})}),e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>a(!0),children:e.jsx(Ue,{className:"size-5"})})]})}const At=()=>{const{get:t}=ie(),{setFiltersContext:s}=o.useContext(Ee),{userContext:n}=o.useContext(le),[a,c]=o.useState(t("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(t("vatMonthlyReportFilters"))):{financialEntityId:n?.context.adminBusinessId??"",monthDate:P(new Date,"yyyy-MM-15")}),[l,p]=o.useState([]);o.useEffect(()=>{(!a.financialEntityId||a.financialEntityId==="")&&n?.context.adminBusinessId&&c({...a,financialEntityId:n.context.adminBusinessId})},[a,n?.context.adminBusinessId]);const[{data:x,fetching:j}]=oe({query:ce(ze),variables:{filters:a},pause:a.financialEntityId===""}),i=o.useCallback(g=>{l.includes(g)?p(l.filter(C=>C!==g)):p([...l,g])},[l]);function f(){p([])}o.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ke,{filter:a,isLoading:j}),e.jsx(et,{filter:{...a},setFilter:c}),e.jsx(ke,{selected:l.map(g=>({id:g,onChange:()=>{}})),resetMerge:f})]}))},[x,a,j,s,l]);const h=o.useMemo(()=>new Set(l),[l]);return e.jsx(Le,{title:"VAT Monthly Report",children:j?e.jsx(Fe,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"min-h-screen",children:e.jsxs("div",{className:"space-y-4",children:[a.financialEntityId&&a.monthDate&&e.jsx(We,{data:x?.vatReport}),a.chargesType!==B.Expense&&e.jsx(Je,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),a.chargesType!==B.Income&&e.jsx(Qe,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(Ze,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(qe,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(Ye,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h})]})})})};export{At as VatMonthlyReport};
|
|
1
|
+
import{v as _,r as o,j as e,J as I,B as w,a6 as r,e9 as je,aP as T,ay as V,ea as fe,eb as u,ah as q,R as G,d7 as L,ec as Q,bY as J,ed as Y,c5 as Z,c6 as K,bp as W,bO as X,bP as ee,bQ as S,bR as te,c2 as E,b$ as se,dI as ae,bS as ne,bT as D,dw as re,ee as be,ef as N,eg as Ne,eh as we,ei as ye,u as oe,t as ve,ej as Se,T as Ce,ek as Ae,el as Te,aC as le,bB as Ve,E as De,em as Ie,bE as H,bH as $,en as B,bN as Re,w as P,bI as Me,F as Ee,L as Fe,eo as ze}from"./index-llwTvhRi.js";import{d as ce}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as ie}from"./use-url-query-C70bqR6l.js";import{C as O,a as de,b as me,M as ke}from"./charges-table-CmHxXzVR.js";import{P as Le}from"./page-layout-ClvcCJfx.js";import{P as R,a as M}from"./panel-top-open-pJuuLeLe.js";import{C as ue}from"./index-DLG-Can3.js";import{T as xe}from"./toggle-expansion-button-CGwmL9mo.js";import{U as Be}from"./update-accountant-status-QJ1upFTt.js";import{c as Pe}from"./charges-filters-Ss76EpGY.js";import{P as Oe}from"./modal-B0cCJdW9.js";import{F as Ue}from"./funnel-DrbTHWGk.js";import"./Table-8-ldSKpC.js";import"./summary-yl9MRbvK.js";import"./accordion-DP7ZozTk.js";import"./deposits-transactions-table-DGuOHsiS.js";import"./Checkbox-De6ghCZT.js";import"./data-table-column-header-_ZrN0Vs6.js";import"./eye-off-DPLQFIHz.js";import"./similar-transactions-modal-DjIjqO-0.js";import"./building-2-BgbaTAJm.js";import"./addDays-DbQpcl70.js";import"./sub-D5WK8Yq6.js";import"./subMonths-Ft6EDjKW.js";import"./MultiSelect-Ca6lO0tL.js";const He=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],pe=_("chart-column",He);const $e=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],_e=_("file-digit",$e),qe=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(je,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.businessTrips.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Business Trips"]})}),c&&a&&e.jsx(O,{data:a.businessTrips,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})};function U(t){switch(t){case"C":case"M":return"Self Invoice";case"H":return"Single Doc By Law";case"I":return"Palestinian Customer";case"K":return"Petty Cash";case"L1":return"Unidentified Customer";case"L2":return"Unidentified Zero or Exempt";case"P":return"Palestinian Supplier";case"R":return"Import";case"S1":case"T":return"Regular";case"S2":return"Zero or Exempt";case"Y":return"Export";default:return"Unknown"}}const Ge=t=>{const s=t.reduce((n,a)=>(n[a.recordType]||={recordType:a.recordType,count:0,vatTotal:0,totalBeforeVat:0},n[a.recordType].count++,n[a.recordType].vatTotal+=a.roundedLocalVatAfterDeduction?.raw??0,n[a.recordType].totalBeforeVat+=a.taxReducedLocalAmount?.raw??0,n),{});return Object.values(s)},he=({records:t})=>{const s=o.useMemo(()=>Ge(t??[]),[t]);return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left",children:[e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground",children:"Record Type"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"Count"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"Total Before VAT"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"VAT Total"})]})}),e.jsx("tbody",{children:s.map(n=>e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsxs("td",{className:"py-3 text-sm font-medium",children:[U(n.recordType)," (",n.recordType,")"]}),e.jsx("td",{className:"py-3 text-sm text-right",children:n.count}),e.jsx("td",{className:"py-3 text-sm text-right",children:T(n.totalBeforeVat,V.Ils)}),e.jsx("td",{className:"py-3 text-sm text-right",children:T(n.vatTotal,V.Ils)})]},n.recordType))})]})})};function ge({data:t}){const{chargeId:s,chargeAccountantStatus:n}=r(fe,t);return e.jsx("td",{children:e.jsx(Be,{value:n??void 0,chargeId:s})})}const b=Q(),z=[b.accessor(t=>r(u,t.data).recordType,{id:"recordType",header:"Record Type",cell:t=>{const s=t.getValue();return e.jsx("p",{className:"whitespace-wrap",children:`${U(s)} (${s})`})}}),b.accessor(t=>r(u,t.data).business?.name??"",{id:"business",header:"Business",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-1",children:[s.business?.id?e.jsx(q,{to:G.BUSINESSES.DETAIL(s.business.id),target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:s.business.name}):e.jsx("span",{children:s.business?.name}),s.vatNumber&&e.jsx("span",{className:"text-[10px] text-gray-500",children:s.vatNumber})]})}}),b.display({id:"invoice",header:"Invoice",cell:t=>{const s=r(u,t.row.original.data);return 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})}):null}}),b.accessor(t=>r(u,t.data).documentSerial??"",{id:"documentSerial",header:"Invoice Serial#",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.getValue()}),s.allocationNumber&&e.jsxs("span",{className:"text-xs",children:["(",s.allocationNumber,")"]})]})}}),b.accessor(t=>r(u,t.data).documentDate??"",{id:"documentDate",header:"Invoice Date",cell:t=>t.getValue()}),b.accessor(t=>r(u,t.data).chargeDate??"",{id:"chargeDate",header:"Transaction Date",cell:t=>t.getValue()}),b.accessor(t=>r(u,t.data).amount.raw??0,{id:"amount",header:"Amount",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.amount.formatted})}}),b.accessor(t=>r(u,t.data).localAmount?.raw??0,{id:"localAmount",header:"Amount ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localAmount?.formatted})}}),b.accessor(t=>r(u,t.data).localVat?.raw??0,{id:"localVat",header:"VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localVat?.formatted})}}),b.accessor(t=>r(u,t.data).localVatAfterDeduction?.raw??0,{id:"localVatAfterDeduction",header:"VAT ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localVatAfterDeduction?.formatted})}}),b.accessor(t=>r(u,t.data).foreignVatAfterDeduction?.raw??0,{id:"foreignVatAfterDeduction",header:"Actual VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.foreignVatAfterDeduction?.formatted})}}),b.accessor(t=>r(u,t.data).roundedLocalVatAfterDeduction?.raw??0,{id:"roundedLocalVatAfterDeduction",header:"Rounded VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.roundedLocalVatAfterDeduction?.formatted})}}),b.accessor(t=>t.cumulativeVat,{id:"cumulativeVat",header:"Cumulative VAT",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),b.accessor(t=>r(u,t.data).taxReducedLocalAmount?.raw??0,{id:"taxReducedLocalAmount",header:"Amount without VAT ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.taxReducedLocalAmount?.formatted})}}),b.accessor(t=>t.cumulativeAmount,{id:"cumulativeAmount",header:"Cumulative Amount without VAT ₪",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),b.display({id:"accountantApproval",header:"Accountant Approval",cell:t=>{const s=r(u,t.row.original.data);return e.jsx(ge,{data:s})}}),b.display({id:"actions",header:"Edit",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(xe,{toggleExpansion:()=>t.row.toggleExpanded(),isExpanded:t.row.getIsExpanded()}),e.jsx(de,{toggleMergeSelected:()=>t.row.original.toggleMergeCharge(s.chargeId),mergeSelected:t.row.original.mergeSelectedCharges.has(s.chargeId)}),e.jsx(ue,{chargeId:s.chargeId})]})}})],Qe=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const{expenses:a}=r(be,t)??{expenses:[]},[c,l]=o.useState(!0),[p,x]=o.useState([]),[j,i]=o.useState({}),[f,h]=o.useState({}),[g,C]=o.useState("detailed"),F=o.useMemo(()=>{let d=0,m=0;return a.map(y=>(d+=y.taxReducedLocalAmount?.raw??0,m+=y.roundedLocalVatAfterDeduction?.raw??0,{data:y,toggleMergeCharge:s,mergeSelectedCharges:n,cumulativeVat:m,cumulativeAmount:d}))},[a,s,n]),A=J({data:F,columns:z,getCoreRowModel:K(),onSortingChange:x,getSortedRowModel:Z(),onColumnVisibilityChange:i,onExpandedChange:h,getExpandedRowModel:Y(),state:{sorting:p,columnVisibility:j,expanded:f}});return e.jsxs(I,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(d=>!d),children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Expenses"]}),c&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:g==="detailed"?"default":"outline",size:"sm",onClick:()=>C("detailed"),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Detailed"]}),e.jsxs(w,{variant:g==="summarized"?"default":"outline",size:"sm",onClick:()=>C("summarized"),children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Summarized"]})]})]}),c&&(g==="detailed"?e.jsxs(X,{children:[e.jsx(ee,{children:A.getHeaderGroups().map(d=>e.jsx(S,{children:d.headers.map(m=>e.jsx(te,{colSpan:m.colSpan,children:m.isPlaceholder?null:e.jsxs(w,{variant:"ghost",onClick:m.column.getToggleSortingHandler(),className:"h-auto p-0 hover:bg-transparent",children:[E(m.column.columnDef.header,m.getContext()),{asc:e.jsx(ae,{className:"size-5"}),desc:e.jsx(se,{className:"size-5"})}[m.column.getIsSorted()]??null]})},m.id))},d.id))}),e.jsx(ne,{children:A.getRowModel().rows?.length?A.getRowModel().rows.map(d=>{const m=r(u,d.original.data);return e.jsxs(o.Fragment,{children:[e.jsx(S,{"data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(y=>e.jsx(D,{children:E(y.column.columnDef.cell,y.getContext())},y.id))}),d.getIsExpanded()&&e.jsx(S,{children:e.jsx(D,{colSpan:z.length,children:e.jsx(re,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(me,{chargeID:m.chargeId,fetching:!!m})})})})]},d.id)}):e.jsx(S,{children:e.jsx(D,{colSpan:z.length,className:"h-24 text-center",children:"No results."})})})]}):e.jsx(he,{records:a}))]})},v=Q(),k=[v.accessor(t=>r(N,t.data).recordType,{id:"recordType",header:"Record Type",cell:t=>{const s=t.getValue();return e.jsx("p",{className:"whitespace-wrap",children:`${U(s)} (${s})`})}}),v.accessor(t=>r(N,t.data).business?.name??"",{id:"business",header:"Business",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-1",children:[s.business?.id?e.jsx(q,{to:G.BUSINESSES.DETAIL(s.business.id),target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:s.business.name}):e.jsx("span",{children:s.business?.name}),s.vatNumber&&e.jsx("span",{className:"text-[10px] text-gray-500",children:s.vatNumber})]})}}),v.display({id:"invoice",header:"Invoice",cell:t=>{const s=r(N,t.row.original.data);return 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})}):null}}),v.accessor(t=>r(N,t.data).documentSerial??"",{id:"documentSerial",header:"Invoice Serial#",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.getValue()}),s.allocationNumber&&e.jsxs("span",{className:"text-xs",children:["(",s.allocationNumber,")"]})]})}}),v.accessor(t=>r(N,t.data).documentDate??"",{id:"documentDate",header:"Invoice Date",cell:t=>t.getValue()}),v.accessor(t=>r(N,t.data).chargeDate??"",{id:"chargeDate",header:"Transaction Date",cell:t=>t.getValue()}),v.accessor(t=>r(N,t.data).taxReducedForeignAmount?.raw??0,{id:"amount",header:"Amount",cell:t=>r(N,t.row.original.data).taxReducedForeignAmount?.formatted??""}),v.accessor(t=>r(N,t.data).taxReducedLocalAmount?.raw??0,{id:"localAmount",header:"Amount ₪",cell:t=>r(N,t.row.original.data).taxReducedLocalAmount?.formatted??""}),v.accessor(t=>t.cumulativeAmount,{id:"cumulativeAmount",header:"Cumulative Amount ₪",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),v.display({id:"accountantApproval",header:"Accountant Approval",cell:t=>{const s=r(N,t.row.original.data);return e.jsx(ge,{data:s})}}),v.display({id:"actions",header:"Edit",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(xe,{toggleExpansion:()=>t.row.toggleExpanded(),isExpanded:t.row.getIsExpanded()}),e.jsx(de,{toggleMergeSelected:()=>t.row.original.toggleMergeCharge(s.chargeId),mergeSelected:t.row.original.mergeSelectedCharges.has(s.chargeId)}),e.jsx(ue,{chargeId:s.chargeId})]})}})],Je=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const{income:a}=r(Ne,t)??{income:[]},[c,l]=o.useState(!0),[p,x]=o.useState([]),[j,i]=o.useState({}),[f,h]=o.useState({}),[g,C]=o.useState("detailed"),F=o.useMemo(()=>{let d=0;return a.map(m=>(d+=m.taxReducedLocalAmount?.raw??0,{data:m,toggleMergeCharge:s,mergeSelectedCharges:n,cumulativeAmount:d}))},[a,s,n]),A=J({data:F,columns:k,getCoreRowModel:K(),onSortingChange:x,getSortedRowModel:Z(),onColumnVisibilityChange:i,onExpandedChange:h,getExpandedRowModel:Y(),state:{sorting:p,columnVisibility:j,expanded:f}});return e.jsxs(I,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(d=>!d),children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Income"]}),c&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:g==="detailed"?"default":"outline",size:"sm",onClick:()=>C("detailed"),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Detailed"]}),e.jsxs(w,{variant:g==="summarized"?"default":"outline",size:"sm",onClick:()=>C("summarized"),children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Summarized"]})]})]}),c&&(g==="detailed"?e.jsxs(X,{children:[e.jsx(ee,{children:A.getHeaderGroups().map(d=>e.jsx(S,{children:d.headers.map(m=>e.jsx(te,{colSpan:m.colSpan,children:m.isPlaceholder?null:e.jsxs(w,{variant:"ghost",onClick:m.column.getToggleSortingHandler(),className:"h-auto p-0 hover:bg-transparent",children:[E(m.column.columnDef.header,m.getContext()),{asc:e.jsx(ae,{className:"size-5"}),desc:e.jsx(se,{className:"size-5"})}[m.column.getIsSorted()]??null]})},m.id))},d.id))}),e.jsx(ne,{children:A.getRowModel().rows?.length?A.getRowModel().rows.map(d=>{const m=r(N,d.original.data);return e.jsxs(o.Fragment,{children:[e.jsx(S,{"data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(y=>e.jsx(D,{children:E(y.column.columnDef.cell,y.getContext())},y.id))}),d.getIsExpanded()&&e.jsx(S,{children:e.jsx(D,{colSpan:k.length,children:e.jsx(re,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(me,{chargeID:m.chargeId,fetching:!!m})})})})]},d.id)}):e.jsx(S,{children:e.jsx(D,{colSpan:k.length,className:"h-24 text-center",children:"No results."})})})]}):e.jsx(he,{records:a}))]})},Ye=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(we,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.differentMonthDoc.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]})}),c&&a&&e.jsx(O,{data:a.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})},Ze=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(ye,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.missingInfo.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Missing Info"]})}),c&&a&&e.jsx(O,{data:a.missingInfo,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})},Ke=({filter:{monthDate:t,financialEntityId:s},isLoading:n})=>{const[{data:a,fetching:c,error:l},p]=oe({query:ce(Ae),pause:!0,variables:{monthDate:t,financialEntityId:s}});return o.useEffect(()=>{if(l){const x="Error generating PCN874 file";console.error(`${x}: ${l}`),ve.error("Error",{description:x,duration:5e3,closeButton:!0})}},[l]),o.useEffect(()=>{if(a){const x=new File([a.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Se(x)}},[a]),e.jsx(Ce,{content:"Generate and Download PCN874 File",children:e.jsx(w,{disabled:c||n,variant:"outline",size:"icon",className:"size-7.5",onClick:p,children:e.jsx(_e,{className:"size-5"})})})},We=({data:t})=>{const s=r(Te,t),n=o.useMemo(()=>s?.expenses??[],[s?.expenses]),a=o.useMemo(()=>s?.income??[],[s?.income]),c=o.useMemo(()=>a.reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[a]),l=o.useMemo(()=>a.reduce((i,f)=>i+(f.roundedLocalVatAfterDeduction?.raw??0),0),[a]),p=o.useMemo(()=>a.filter(i=>(i.roundedLocalVatAfterDeduction?.raw??0)===0).reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[a]),x=o.useMemo(()=>n.filter(i=>i.isProperty).reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[n]),j=o.useMemo(()=>l-n.reduce((i,f)=>i+(f.roundedLocalVatAfterDeduction?.raw??0),0),[l,n]);return e.jsxs(I,{className:"p-6",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Report Summary"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Taxable Sales Total"}),e.jsx("p",{className:"text-2xl font-bold",children:T(c,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Taxable Sales VAT"}),e.jsx("p",{className:"text-2xl font-bold",children:T(l,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Zero / Exempt Sales"}),e.jsx("p",{className:"text-2xl font-bold",children:T(p,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Equipment Inputs"}),e.jsx("p",{className:"text-2xl font-bold",children:T(x,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total VAT Amount"}),e.jsx("p",{className:"text-2xl font-bold",children:T(j,V.Ils)})]})]})]})};function Xe({filter:t,setFilter:s,closeModal:n}){const{control:a,handleSubmit:c,setValue:l}=De({defaultValues:{...t}}),{selectableAdminBusinesses:p,fetching:x}=Ie(),j=h=>{s(h),n()};function i(){s(),n()}function f(h){const g=new Date(h.getFullYear(),h.getMonth(),15);l("monthDate",P(g,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[x?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:c(j),children:[e.jsx(H,{name:"financialEntityId",control:a,defaultValue:void 0,render:({field:h,fieldState:g})=>e.jsx($,{...h,data:p,value:h.value,disabled:x,label:"Report Issuer (Admin Business)",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message})}),e.jsx(H,{name:"chargesType",control:a,defaultValue:t.chargesType,render:({field:h,fieldState:g})=>e.jsx($,{...h,data:Pe,value:h.value??B.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:g.error?.message})}),e.jsx(Re,{defaultValue:t?.monthDate?new Date(t.monthDate):new Date,defaultDate:t?.monthDate?new Date(t.monthDate):new Date,onChange:f,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: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:n,children:"Cancel"})]})]})]})}function et({filter:t,setFilter:s}){const[n,a]=o.useState(!1),{get:c,set:l}=ie(),{userContext:p}=o.useContext(le);function x(j){j||={financialEntityId:p?.context.adminBusinessId??t.financialEntityId,monthDate:P(new Date,"yyyy-MM-15")},Me(j,t)||s(j)}return o.useEffect(()=>{const j=Ve(t??{})?null:encodeURIComponent(JSON.stringify(t)),i=c("vatMonthlyReportFilters");j!==i&&l("vatMonthlyReportFilters",j)},[t,c,l]),e.jsxs(e.Fragment,{children:[e.jsx(Oe,{opened:n,onClose:()=>a(!1),content:e.jsx(Xe,{filter:t,setFilter:x,closeModal:()=>a(!1)})}),e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>a(!0),children:e.jsx(Ue,{className:"size-5"})})]})}const At=()=>{const{get:t}=ie(),{setFiltersContext:s}=o.useContext(Ee),{userContext:n}=o.useContext(le),[a,c]=o.useState(t("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(t("vatMonthlyReportFilters"))):{financialEntityId:n?.context.adminBusinessId??"",monthDate:P(new Date,"yyyy-MM-15")}),[l,p]=o.useState([]);o.useEffect(()=>{(!a.financialEntityId||a.financialEntityId==="")&&n?.context.adminBusinessId&&c({...a,financialEntityId:n.context.adminBusinessId})},[a,n?.context.adminBusinessId]);const[{data:x,fetching:j}]=oe({query:ce(ze),variables:{filters:a},pause:a.financialEntityId===""}),i=o.useCallback(g=>{l.includes(g)?p(l.filter(C=>C!==g)):p([...l,g])},[l]);function f(){p([])}o.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ke,{filter:a,isLoading:j}),e.jsx(et,{filter:{...a},setFilter:c}),e.jsx(ke,{selected:l.map(g=>({id:g,onChange:()=>{}})),resetMerge:f})]}))},[x,a,j,s,l]);const h=o.useMemo(()=>new Set(l),[l]);return e.jsx(Le,{title:"VAT Monthly Report",children:j?e.jsx(Fe,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"min-h-screen",children:e.jsxs("div",{className:"space-y-4",children:[a.financialEntityId&&a.monthDate&&e.jsx(We,{data:x?.vatReport}),a.chargesType!==B.Expense&&e.jsx(Je,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),a.chargesType!==B.Income&&e.jsx(Qe,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(Ze,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(qe,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(Ye,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h})]})})})};export{At as VatMonthlyReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,u as y,dy as P,aJ as b,a6 as C,aK as S,j as e,D as O,aL as V,B as M,a3 as q,x as z,al as H,am as U,ao as K,ap as Q,aq as X,ar as $,as as J,w as I,dz as F,E as W,dA as Y,H as _,bK as G,V as Z,a2 as ee,bN as se,bO as te,bP as ae,bQ as E,bR as h,bS as ne,bT as x,ah as le,R as w,bU as re,bV as ce,a4 as oe,bW as ie,bX as ue,F as de,c as me}from"./index-
|
|
1
|
+
import{r as a,u as y,dy as P,aJ as b,a6 as C,aK as S,j as e,D as O,aL as V,B as M,a3 as q,x as z,al as H,am as U,ao as K,ap as Q,aq as X,ar as $,as as J,w as I,dz as F,E as W,dA as Y,H as _,bK as G,V as Z,a2 as ee,bN as se,bO as te,bP as ae,bQ as E,bR as h,bS as ne,bT as x,ah as le,R as w,bU as re,bV as ce,a4 as oe,bW as ie,bX as ue,F as de,c as me}from"./index-llwTvhRi.js";import{u as he,a as xe}from"./use-issue-monthly-documents-pV0tTZGQ.js";import{s as A}from"./subMonths-Ft6EDjKW.js";function fe({issueMonth:u,clients:r,onAdd:c}){const[j,o]=a.useState(!1),[f,d]=a.useState(""),[{data:m},n]=y({query:P,variables:{issueMonth:u,clientId:f},pause:!j}),p=a.useCallback(l=>{d(l),n()},[n,d]);return a.useEffect(()=>{f!==""&&m&&(c(b(C(S,m.clientMonthlyChargeDraft))),o(!1))},[f,m,c]),e.jsxs(O,{open:j,onOpenChange:o,children:[e.jsx(V,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"icon",children:e.jsx(q,{})})}),e.jsxs(z,{className:"w-[400px] max-w-screen-md",children:[e.jsx(H,{children:e.jsx(U,{children:"Select document recipient"})}),e.jsxs(K,{onValueChange:p,children:[e.jsx(Q,{children:e.jsx(X,{placeholder:"Recipient"})}),e.jsx($,{children:r.map(l=>e.jsx(J,{value:l.id,children:l.name},l.id))})]})]})]})}const je=({drafts:u})=>{const[r,c]=a.useState(u.map(s=>b(C(S,s)))),j=I(A(new Date,1),"yyyy-MM-dd"),[o,f]=a.useState(j),[{data:d},m]=y({query:F,variables:{issueMonth:o},pause:!0});a.useEffect(()=>{d?.periodicalDocumentDrafts&&c(d.periodicalDocumentDrafts.map(s=>b(C(S,s))))},[d,c]),a.useEffect(()=>{m()},[o,m]);const n=W({values:{generateDocumentsInfo:r}}),{issueDocuments:p}=he(),[{data:l}]=y({query:Y}),{fields:v,append:k,remove:B,update:R}=_({control:n.control,name:"generateDocumentsInfo"}),T=n.watch("generateDocumentsInfo"),D=a.useMemo(()=>v.map((s,t)=>({...s,...T[t],id:s.client?.id})),[v,T]),N=a.useCallback(s=>{p(s)},[p]),L=a.useMemo(()=>l?.allOpenContracts.filter(s=>s.billingCycle===G.Monthly&&!D.some(t=>t.client?.id===s.client.id)),[D,l]);return e.jsx("div",{className:"p-2",children:e.jsx(Z,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(N),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(ee,{children:"Issue Month:"}),e.jsx(se,{value:new Date(o),onChange:s=>{const t=new Date(s.getFullYear(),s.getMonth(),15);f(I(t,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(te,{children:[e.jsx(ae,{children:e.jsxs(E,{children:[e.jsx(h,{children:"Name"}),e.jsx(h,{children:"Document"}),e.jsx(h,{children:"Amount"}),e.jsx(h,{children:"Remark"}),e.jsx(h,{children:"Recipients"}),e.jsx(h,{})]})}),e.jsx(ne,{children:D.map(({id:s,...t},g)=>e.jsxs(E,{children:[e.jsx(x,{children:e.jsx(le,{to:s?w.BUSINESSES.DETAIL(s):w.BUSINESSES.ALL,target:"_blank",rel:"noreferrer",onClick:i=>i.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.client?.name})}),e.jsx(x,{children:t.type}),e.jsxs(x,{children:[t.income?.[0]?.price," ",t.income?.[0]?.currency]}),e.jsx(x,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:t.remarks})}),e.jsx(x,{children:e.jsx("div",{className:"flex flex-col",children:t.client?.emails?.map(i=>e.jsx("span",{className:"text-sm text-gray-500",children:i},i))})}),e.jsx(x,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(re,{children:[e.jsx(ce,{asChild:!0,type:"button",children:e.jsx(M,{className:"size-7.5",variant:"secondary",onClick:()=>B(g),children:e.jsx(oe,{size:16})})}),e.jsx(ie,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(xe,{draft:t,onApprove:i=>{n.setValue(`generateDocumentsInfo.${g}`,i,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),R(g,{...i})}})]})})]},s))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(fe,{clients:L?.map(s=>({id:s.client.originalBusiness.id,name:s.client.originalBusiness.name}))??[],onAdd:k,issueMonth:o}),e.jsx(ue,{onConfirm:n.handleSubmit(N),title:`Are you sure you want to issue ${D.length} documents?`,children:e.jsx(M,{children:"Issue"})})]})]})})})},ge=()=>{const{setFiltersContext:u}=a.useContext(de),[{data:r,fetching:c}]=y({query:F,variables:{issueMonth:I(A(new Date,1),"yyyy-MM-dd")}});return a.useEffect(()=>{r?.periodicalDocumentDrafts||u(null)},[r,u]),c?e.jsx(me,{}):e.jsx(je,{drafts:r?.periodicalDocumentDrafts??[]})};export{ge as IssueDocuments};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as T,i5 as N,r as u,t as l,i as f,E as y,j as e,V as b,eL as C,Y as $,Z as D,_ as F,$ as w,I as j,a1 as k,i6 as E,a6 as v,i7 as A,a9 as S,l as z,T as L,B as p,ag as M,n as O,i8 as P,i9 as B,F as q,u as _,ia as U,L as V,co as R,cp as G,ib as Q}from"./index-
|
|
1
|
+
import{g as T,i5 as N,r as u,t as l,i as f,E as y,j as e,V as b,eL as C,Y as $,Z as D,_ as F,$ as w,I as j,a1 as k,i6 as E,a6 as v,i7 as A,a9 as S,l as z,T as L,B as p,ag as M,n as O,i8 as P,i9 as B,F as q,u as _,ia as U,L as V,co as R,cp as G,ib as Q}from"./index-llwTvhRi.js";import{P as Y}from"./page-layout-ClvcCJfx.js";const Z="updateTag",H=()=>{const[{fetching:c},r]=T(N),i=u.useCallback(async t=>{const a=`Error updating tag ID [${t.tagId}]`,s=`${Z}-${t.tagId}`;l.loading("Updating Tag...",{id:s});try{const n=await r(t),d=f(n,a,s,"updateTag");if(d)return l.success("Success",{id:s,description:"Tag updated"}),d.updateTag}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}return!1},[r]);return{fetching:c,updateTag:i}},J=({onDone:c,data:r,close:i})=>{const{updateTag:t,fetching:a}=H(),s=v(A,r),n=y({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=S(o,h);i(),g&&Object.keys(g).length>0&&t({tagId:s.id,fields:g}).then(()=>c?.())};return e.jsx(b,{...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(C,{cols:3,children:[e.jsx($,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(D,{children:[e.jsx(F,{children:"Name"}),e.jsx(w,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(k,{})]})}),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:i,children:"Cancel"})]})]})})},K=({onDone:c,data:r})=>{const[i,{open:t,close:a}]=z(!1);function s(){a(),c?.()}return e.jsxs(e.Fragment,{children:[e.jsx(L,{content:"Edit Tag",children:e.jsx(p,{variant:"ghost",size:"icon",className:"size-7.5",onClick:t,children:e.jsx(M,{className:"size-5"})})}),e.jsx(O,{centered:!0,opened:i,onClose:a,title:"Insert Business Trip",children:e.jsx(J,{close:a,onDone:s,data:r})})]})},W="addTag",X=()=>{const[{fetching:c},r]=T(P),i=u.useCallback(async t=>{const a=`Error adding new tag [${t.tagName}]`,s=`${W}-${t.tagName}`;l.loading("Adding tag",{id:s});try{const n=await r(t);f(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:c,addTag:i}},ee="deleteTag",se=()=>{const[{fetching:c},r]=T(B),i=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);f(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:c,deleteTag:i}},ne=()=>{const{setFiltersContext:c}=u.useContext(q),[r,i]=u.useState(""),[{data:t,fetching:a},s]=_({query:Q}),{addTag:n}=X(),{deleteTag:d}=se();u.useEffect(()=>{c(null)},[c]);const m=U(t?.allTags??[]),h=u.useCallback(o=>{o.length>2&&n({tagName:o}).then(()=>{s()})},[n,s]),x=u.useCallback((o,g)=>{d({tagId:o,name:g}).then(()=>{s()})},[d,s]);return e.jsx(Y,{title:"Tags",description:"Manage tags for your bookmarks.",children:a?e.jsx(V,{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,I)=>e.jsx("span",{className:"ms-2"},I)),o.name]}),e.jsx(K,{data:o}),e.jsx(p,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(R,{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=>i(o.currentTarget.value),placeholder:"Add new tag",required:!0}),e.jsx(p,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(G,{className:"size-5"})})]})]})})};export{ne as TagsManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,Y as C,Z as p,_ as S,$ as y,b7 as w,a1 as b,I as L,g as F,ik as H,r as u,t as m,i as E,D as R,aL as M,B as x,ag as _,x as T,al as A,am as $,u as P,il as V,L as O,E as q,V as K,a9 as z,im as Q,F as Y,bY as Z,bO as G,bP as J,bQ as I,bR as W,c2 as v,bS as X,bT as g,io as ee,c5 as se,c4 as te,c6 as oe}from"./index-
|
|
1
|
+
import{j as e,Y as C,Z as p,_ as S,$ as y,b7 as w,a1 as b,I as L,g as F,ik as H,r as u,t as m,i as E,D as R,aL as M,B as x,ag as _,x as T,al as A,am as $,u as P,il as V,L as O,E as q,V as K,a9 as z,im as Q,F as Y,bY as Z,bO as G,bP as J,bQ as I,bR as W,c2 as v,bS as X,bT as g,io as ee,c5 as se,c4 as te,c6 as oe}from"./index-llwTvhRi.js";import{D as re}from"./data-table-pagination-DAvY_qBU.js";import{P as ne}from"./page-layout-ClvcCJfx.js";import{A as k}from"./arrow-up-down-Du86WmzT.js";function U({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(b,{})]})}),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(b,{})]})}),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(b,{})]})})]})}const ae="updateSortCode",de=()=>{const[{fetching:s},n]=F(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(R,{open:o,onOpenChange:t,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{variant:"outline",size:"icon",children:e.jsx(_,{})})}),e.jsxs(T,{className:"w-[400px] max-w-screen-md",children:[e.jsx(A,{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}]=P({query:V,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=q({defaultValues:s}),{handleSubmit:d,formState:{dirtyFields:r}}=t,{updateSortCode:a,fetching:i}=de(),l=({key:c,...B})=>{const h=z(B,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(U,{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]=F(Q),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(R,{open:n,onOpenChange:o,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{children:"Add Sort Code"})}),e.jsxs(T,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(A,{children:e.jsx($,{children:"Add New Sort Code"})}),e.jsx(he,{close:()=>o(!1),onAdd:s})]})]})}function he({close:s,onAdd:n}){const o=q({}),{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(U,{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 D=[{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})}],pe=()=>{const[{data:s,fetching:n,error:o},t]=P({query:ee}),{setFiltersContext:d}=u.useContext(Y),r=u.useMemo(()=>s?.allSortCodes?.map(l=>({...l,refetchSortCodes:t}))??[],[s?.allSortCodes,t]),a=Z({data:r,columns:D,getCoreRowModel:oe(),getPaginationRowModel:te(),getSortedRowModel:se(),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(re,{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(ne,{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(G,{children:[e.jsx(J,{children:a.getHeaderGroups().map(l=>e.jsx(I,{children:l.headers.map(c=>e.jsx(W,{children:c.isPlaceholder?null:v(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),e.jsx(X,{children:a.getRowModel().rows.length===0?e.jsx(I,{children:e.jsx(g,{colSpan:D.length,className:"text-center py-8",children:"No sort codes found"})}):a.getRowModel().rows.map(l=>e.jsx(I,{children:l.getVisibleCells().map(c=>e.jsx(g,{children:v(c.column.columnDef.cell,c.getContext())},c.id))},l.id))})]})})})};export{pe as SortCodes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as v,ig as L,r as g,t as m,i as F,b3 as U,j as e,Y as C,Z as j,_ as f,$ as p,I as B,a0 as y,a1 as b,bE as V,bH as _,b7 as z,at as K,D as E,aL as D,B as h,x as M,al as R,am as A,E as O,V as P,ih as Q,ag as Y,u as $,ii as G,L as k,F as Z,bY as J,bO as W,bP as X,bQ as T,bR as ee,c2 as S,bS as se,bT as w,ij as te,c5 as ae,c4 as re,c6 as oe}from"./index-
|
|
1
|
+
import{g as v,ig as L,r as g,t as m,i as F,b3 as U,j as e,Y as C,Z as j,_ as f,$ as p,I as B,a0 as y,a1 as b,bE as V,bH as _,b7 as z,at as K,D as E,aL as D,B as h,x as M,al as R,am as A,E as O,V as P,ih as Q,ag as Y,u as $,ii as G,L as k,F as Z,bY as J,bO as W,bP as X,bQ as T,bR as ee,c2 as S,bS as se,bT as w,ij as te,c5 as ae,c4 as re,c6 as oe}from"./index-llwTvhRi.js";import{D as ne}from"./data-table-pagination-DAvY_qBU.js";import{P as ie}from"./page-layout-ClvcCJfx.js";import{A as N}from"./arrow-up-down-Du86WmzT.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(L),t=g.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();g.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return g.useEffect(()=>{if(c){const o=x.find(u=>u.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:u})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(B,{...o,value:o.value??void 0,required:!0,className:t?"":y(u)})}),e.jsx(b,{})]})}),e.jsx(V,{name:"sortCode",control:a,render:({field:o,fieldState:u})=>e.jsx(_,{...o,onChange:H=>{o.onChange(Number(H))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(u)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:u})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(u),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(b,{})]})}),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(K,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=g.useState(!1);return e.jsxs(E,{open:n,onOpenChange:t,children:[e.jsx(D,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(R,{children:e.jsx(A,{children:"Add New Tax Category"})}),e.jsx(xe,{close:()=>t(!1),onAdd:s})]})]})}function xe({close:s,onAdd:n}){const t=O({}),{handleSubmit:a}=t,[d,r]=g.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(P,{...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 ge="updateTaxCategory",ue=()=>{const[{fetching:s},n]=v(Q),t=g.useCallback(async a=>{const d="Error updating tax category",r=`${ge}-${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]=g.useState(!1);return e.jsxs(E,{open:t,onOpenChange:a,children:[e.jsx(D,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(Y,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(R,{children:e.jsx(A,{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}]=$({query:G,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&m.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx(k,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=O({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=g.useState(!1),{updateTaxCategory:l,fetching:x}=ue(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(u=>{u?.id&&(t?.(u.id),n())})};return e.jsx(P,{...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]=$({query:te}),{setFiltersContext:d}=g.useContext(Z),r=s?.taxCategories??[],i=J({data:r,columns:I,getCoreRowModel:oe(),getPaginationRowModel:re(),getSortedRowModel:ae(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return g.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(ne,{table:i})})}))},[d,i,l]),g.useEffect(()=>{t&&m.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(ie,{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(k,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(W,{children:[e.jsx(X,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(ee,{children:c.isPlaceholder?null:S(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(se,{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:S(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{Se as TaxCategories};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,bQ as D,bT as a,w as f,d7 as n,a6 as N,ge as v,r as d,bI as E,D as T,aL as I,B as w,x as A,bB as O,E as P,dr as B,V as L,Y as y,Z as C,_ as F,$ as M,b7 as V,a1 as g,b5 as U,au as _,F as k,aC as q,u as Q,c as $,bO as z,bP as G,bR as o,bS as H,gf as J}from"./index-
|
|
1
|
+
import{j as e,bQ as D,bT as a,w as f,d7 as n,a6 as N,ge as v,r as d,bI as E,D as T,aL as I,B as w,x as A,bB as O,E as P,dr as B,V as L,Y as y,Z as C,_ as F,$ as M,b7 as V,a1 as g,b5 as U,au as _,F as k,aC as q,u as Q,c as $,bO as z,bP as G,bR as o,bS as H,gf as J}from"./index-llwTvhRi.js";import{u as S}from"./use-url-query-C70bqR6l.js";import{P as Z}from"./page-layout-ClvcCJfx.js";import{F as K}from"./funnel-DrbTHWGk.js";const W=({record:s})=>{const t=N(v,s);return e.jsxs(D,{children:[e.jsx(a,{children:s.description}),e.jsx(a,{children:f(new Date(s.purchaseDate),"dd/MM/yyyy")}),e.jsx(a,{children:s.activationDate?f(new Date(s.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(a,{children:t.originalCost?n(t.originalCost,0):void 0}),e.jsx(a,{children:t.reportYearDelta?n(t.reportYearDelta,0):void 0}),e.jsx(a,{children:n(t.totalDepreciableCosts,0)}),e.jsxs(a,{children:[n(s.statutoryDepreciationRate,0),"%"]}),e.jsx(a,{children:s.claimedDepreciationRate?`${n(s.claimedDepreciationRate,1)}%`:"-"}),e.jsx(a,{children:t.reportYearClaimedDepreciation?n(t.reportYearClaimedDepreciation,0):"-"}),e.jsx(a,{children:t.pastYearsAccumulatedDepreciation?n(t.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(a,{children:t.totalDepreciation?n(t.totalDepreciation,0):"-"}),e.jsx(a,{children:t.netValue?n(t.netValue,0):"-"})]})};function X(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=P({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=B(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(L,{...m,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const p=Number(i);return Number.isNaN(p)||p<2e3||p>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(M,{children:e.jsx(V,{...i,hideControls:!0,decimalScale:0})}),e.jsx(g,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:s?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(U,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(g,{})]})}),e.jsx(_,{children:e.jsx(w,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:s,setFilter:t}){const[r,m]=d.useState(!1),{get:c,set:x}=S();d.useEffect(()=>{const l=X(s),j=c(b);l!==j&&x(b,l)},[s,c,x]);const u=d.useCallback(l=>{E(l,s)||t(l)},[s,t]);return e.jsxs(T,{open:r,onOpenChange:m,children:[e.jsx(I,{asChild:!0,children:e.jsx(w,{variant:"outline",size:"icon",children:e.jsx(K,{size:20})})}),e.jsx(A,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const R=({data:s,groupName:t})=>{const r=N(v,s);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(a,{children:t?"Group Total":"Overall Total"}),e.jsx(a,{colSpan:2,children:t}),e.jsx(a,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(a,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(a,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(a,{}),e.jsx(a,{}),e.jsx(a,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(a,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(a,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(a,{children:r.netValue?n(r.netValue,0):void 0})]})},ne=()=>{const{setFiltersContext:s}=d.useContext(k),{userContext:t}=d.useContext(q),{get:r}=S(),m=d.useMemo(()=>{const i={financialEntityId:t?.context.adminBusinessId,year:new Date().getFullYear()},p=r(b);if(p)try{return JSON.parse(decodeURIComponent(p))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[t?.context.adminBusinessId]),[c,x]=d.useState(m),[{data:u,fetching:l}]=Q({query:J,variables:{filters:c}});d.useEffect(()=>{s(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,s,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(Z,{title:"Depreciation Report",description:j,children:l?e.jsx($,{}):e.jsxs(z,{children:[e.jsxs(G,{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(H,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,p)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(a,{children:`Category ${p+1}`}),e.jsx(a,{colSpan:2,children:i.category.name}),e.jsx(a,{colSpan:3}),e.jsxs(a,{children:[n(i.category.percentage,0),"%"]}),e.jsx(a,{colSpan:5})]}),i.records.sort((h,Y)=>h.purchaseDate.localeCompare(Y.purchaseDate)).map(h=>e.jsx(W,{record:h},h.id)),e.jsx(R,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(R,{data:u.depreciationReport.summary})]})})]})})};export{ne as DepreciationReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as b,bD as W,j as e,D as _,aL as z,B as g,x as G,al as Q,am as J,a2 as D,b5 as K,aO as R,ao as A,ap as O,aq as k,ar as E,as as T,d7 as X,br as w,a6 as j,gm as I,gn as Z,go as S,gp as ee,gq as L,gr as M,gs as B,gt as N,gu as p,gv as P,gw as q,dD as se,gk as re,bl as te,bm as ae,bn as v,gx as V,F as le,u as de,J as ne,K as oe,W as ce,gy as ie}from"./index-rI994S3C.js";import{F as Y}from"./funnel-Cfb9Pxmr.js";import{B as me}from"./building-2-CMKd_bU8.js";import{E as ue}from"./eye-off-Buv7eciz.js";import{S as xe}from"./save-jkuyCWyY.js";const C=["2020","2021","2022","2023"];function he({selectedBusiness:t,setSelectedBusiness:d,selectedYear:s,setSelectedYear:c,referenceYear:l,setReferenceYear:o}){const[n,r]=b.useState(!s||!t),{selectableBusinesses:a,fetching:i}=W(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(_,{open:n,onOpenChange:r,children:[e.jsx(z,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(G,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(Q,{children:e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(K,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(A,{value:s,onValueChange:c,children:[e.jsx(O,{id:"year-select",children:e.jsx(k,{})}),e.jsx(E,{children:C.map(x=>e.jsx(T,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(A,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(O,{id:"reference-year-select",children:e.jsx(k,{})}),e.jsxs(E,{children:[e.jsx(T,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(T,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const m=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=U=>Number.parseFloat(U.replace(/[,\s₪]/g,""))||0,H=f(h),F=f(x);return F===0?null:(H-F)/F*100};if(!n(d))return null;const i=o?a(d,c):null;return e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-gray-200",dir:"rtl",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[t," ",s&&`(${s})`]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r(d)?"text-gray-400":""}`,children:r(d)?"0":d}),i!==null&&e.jsxs("span",{className:`text-xs px-1 py-0.5 rounded ${i>0?"text-green-700 bg-green-100":i<0?"text-red-700 bg-red-100":"text-gray-700 bg-gray-100"}`,children:[i>0?"+":"",i.toFixed(1),"%"]})]})]})},u=({codes:t,referenceCodes:d,code:s,showEmptyFields:c})=>{const{value:l,label:o}=b.useMemo(()=>{const r=t.find(a=>a.code===s);return{value:r?.amount||0,label:r?.label||"לא זוהה קוד"}},[t,s]),n=b.useMemo(()=>d?.find(r=>r.code===s)?.amount.toString()||"",[d,s]);return e.jsx(m,{label:o,value:X(l,0),code:String(s),showChange:!0,showEmptyFields:c,referenceValue:n})},be=[{title:"מזומנים ושווי מזומנים",codes:[7110,7120,7150],sumCode:7100},{title:"ניירות ערך",codes:[7215,7225,7230,7290,7295],sumCode:7200},{title:"לקוחות",codes:[7310,7320,7330,7350,7360,7380,7390],sumCode:7300},{title:"חייבים ויתרות חובה",codes:[7410,7420,7430,7440,7450,7461,7462,7470,7490],sumCode:7400},{title:"מסים נדחים לזמן קצר",codes:[7610,7620,7690],sumCode:7600},{title:"הלוואות לזמן קצר",codes:[7711,7712,7720],sumCode:7700},{title:"מלאי",codes:[7805,7810,7815,7820,7825,7830,7840,7850,7860,7870,7890],sumCode:7800}],je=[{title:"רכוש קבוע",codes:[8010,8020,8025,8030,8040,8050,8060,8080,8090,8095,8100,8105,8110,8120,8130,8140,8150,8160,8170,8180,8190],sumCode:8e3},{title:"נכסים לא שוטפים מוחזקים למכירה",codes:[8710],sumCode:8700},{title:"הוצאות מראש לזמן ארוך",codes:[8210,8220,8290],sumCode:8200},{title:"השקעות בחברות מוחזקות כלולות ומאוחדות",codes:[8315,8325,8335,8340,8350],sumCode:8300},{title:'השקעות בחברות אחרות כולל ני"ע סחירים מוחזקים לזמן ארוך',codes:[8410,8420,8440,8450,8460,8490],sumCode:8400},{title:"מסים נדחים לזמן ארוך",codes:[8510,8520,8590],sumCode:8500},{title:"הוצאות נדחות ורכוש אחר",codes:[8610,8620,8630,8640,8690],sumCode:8600}],pe=[{title:"בנקים והלואות לזמן קצר",codes:[9110,9120,9130,9140,9151,9152,9190],sumCode:9100},{title:"ספקים ונותני שירותים",codes:[9210,9220,9230,9290],sumCode:9200},{title:"זכאים ויתרות זכות",codes:[9310,9320,9330,9340,9350,9360,9370,9410,9420,9431,9432,9435,9440,9450,9460,9470,9480,9490],sumCode:9400},{title:"עתודה למסים נדחים לזמן קצר",codes:[9510,9520,9530],sumCode:9500}],ge=[{title:"התחייבויות לזמן ארוך",codes:[9605,9610,9620,9631,9632,9640,9650,9660,9670,9690],sumCode:9600},{title:"התחייבויות בשל סיום יחסי עובד-מעביד",codes:[9710,9720,9790],sumCode:9700},{title:"עתודה למסים נדחים לזמן ארוך",codes:[9810,9820,9890],sumCode:9800}],fe=[{title:"הון עצמי",codes:[9910,9920,9930,9940,9950,9960,9980],sumCode:9900}];function Ne({data:t,referenceData:d,showEmptyFields:s=!1}){const l=j(I,t).balanceSheet||[],n=j(I,d)?.balanceSheet||[];return e.jsx(w,{value:"balanceSheet",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני המאזן"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-blue-800 border-b pb-2",children:"נכסים"}),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx("h5",{className:"font-bold",children:"רכוש שוטף"})}),be.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:7e3,showEmptyFields:s})}),je.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:8888,showEmptyFields:s})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-red-800 border-b pb-2",children:"התחייבויות והון"}),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx("h5",{className:"font-bold",children:"התחייבויות שוטפות"})}),pe.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9e3,showEmptyFields:s})}),ge.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),fe.map(r=>e.jsxs("div",{className:"bg-green-50 p-4 rounded-md",children:[e.jsx("h5",{className:"font-bold mb-3",children:r.title}),e.jsx("div",{className:"space-y-2",children:r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a))})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9999,showEmptyFields:s})})]})]})]})})}const ve=t=>{switch(t){case"1":return"תעשייתי";case"2":return"מסחרי";case"3":return"נותני שירותים";case"99":return"הדיווח כולל יותר מעסק אחד";default:return""}},Ce=t=>{switch(t){case S.Cash:return"מזומן";case S.Accrual:return"מצטבר";case S.DollarRegulations:return"לפי תקנות דולריות";default:return""}},ye=t=>{switch(t){case L.Shekels:return"שקלים";case L.Dollars:return"דולרים";default:return""}},Se=t=>{switch(t){case M.DoubleEntry:return"כפולה";case M.SingleEntry:return"חד-צידית";default:return""}},we=t=>{switch(t){case B.Computerized:return"ממוחשב";case B.Manual:return"ידני";default:return""}},Fe=t=>{switch(t){case N.Option_1:return"חלופה 1";case N.Option_2Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010";case N.Option_3Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010";case N.None:return"ללא חלופה";default:return""}},De=t=>{switch(t){case p.Unqualified:return"נוסח אחיד (בלתי מסוייג)";case p.UnqualifiedWithGoingConcern:return"בנוסח אחיד עם הפניית תשומת לב להערת עסק חי";case p.UnqualifiedWithOtherEmphases:return"בנוסח אחיד עם הפניות תשומת לב אחרת";case p.Qualified:return"הסתייגות";case p.Adverse:return"שלילית";case p.Disclaimer:return"המנעות";case p.None:return"אין חוות דעת";default:return""}},y=t=>t==null?"":t?"כן":"לא";function Te({data:t,businessInfo:d}){const{header:s}=j(Z,t),c=j(ee,d);return e.jsx(w,{value:"header",className:"border rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",dir:"rtl",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטים מזהים"}),e.jsx(m,{label:"השם הרשום",value:c.name,showEmptyFields:!0}),e.jsx(m,{label:"תיאור העיסוק המדווח",value:s.businessDescription??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר זהות",value:s.idNumber,showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק",value:s.taxFileNumber,showEmptyFields:!0}),e.jsx(m,{label:'תיק מדווח למע"מ',value:s.vatFileNumber??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק ניכויים",value:s.withholdingTaxFileNumber??"",showEmptyFields:!0})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטי העסק"}),e.jsx(m,{value:ve(s.businessType),label:"סוג העסק המדווח",showEmptyFields:!0}),e.jsx(m,{label:"שיטת דיווח",value:Ce(s.reportingMethod),showEmptyFields:!0}),s.reportingMethod===S.DollarRegulations&&e.jsx(m,{label:"מטבע הסכומים",value:ye(s.currencyType),showEmptyFields:!0}),e.jsx(m,{label:"הסכום באלפים",value:y(s.amountsInThousands),showEmptyFields:!0}),e.jsx(m,{label:"שיטת חשבונאות",value:Se(s.accountingMethod),showEmptyFields:!0}),e.jsx(m,{label:"הנהלת חשבונות",value:we(s.accountingSystem),showEmptyFields:!0}),e.jsx(m,{label:"חייב ברישום תוכנה",value:y(!!s.softwareRegistrationNumber),showEmptyFields:!0}),s.softwareRegistrationNumber&&e.jsx(m,{label:"מספר תעודת רישום",value:s.softwareRegistrationNumber,showEmptyFields:!0}),e.jsx(m,{label:"דוח בגין שותפות",value:y(!!s.isPartnership),showEmptyFields:!0}),s.isPartnership&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"מספר שותפים",value:s.partnershipCount?.toString()??"",showEmptyFields:!0}),e.jsx(m,{label:"חלקי ברווחי השותפות",value:`${s.partnershipProfitShare}%`,showEmptyFields:!0})]}),e.jsx(m,{label:"יישום תקני חשבונאות (IFRS)",value:y(!!s.ifrsImplementationYear||!!s.ifrsReportingOption),showEmptyFields:!0}),(!!s.ifrsImplementationYear||!!s.ifrsReportingOption)&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"החל משנת המס",value:s.ifrsImplementationYear??"",showEmptyFields:!0}),e.jsx(m,{label:"דווח בחלופה",value:Fe(s.ifrsReportingOption),showEmptyFields:!0})]}),e.jsx(m,{label:"מספר ענף כלכלי של המדווח",value:s.industryCode,showEmptyFields:!0}),e.jsx(m,{label:"חוות דעת המבקר",value:De(s.auditOpinionType),showEmptyFields:!0})]})]})})}const Re=[{title:"הכנסות ממכירות ומתן שירותים",color:"text-blue-700",codes:[1010,1015,1020,1025,1030,1040,1051,1052,1090],sumCode:1e3},{title:"עלות המכירות ומתן השירותים וביצוע עבודות",color:"text-purple-700",codes:[1306,1308,1307,1310,1320,1330,1340,1350,1360,1371,1372,1390,1400,1450],sumCode:1300},{title:"עלויות ייצור ועלויות אצל קבלן בונה",color:"text-rose-700",codes:[2005,2006,2011,2012,2015,2020,2025,2030,2035,2040,2045,2050,2060,2066,2067,2068,2070,2075,2080,2085,2090,2095],sumCode:2e3},{title:"הוצאות מחקר ופיתוח",color:"text-amber-700",codes:[2510,2520,2530,2540,2550,2560,2570,2590],sumCode:2500},{title:"הוצאות מכירה",color:"text-green-700",codes:[3011,3013,3012,3015,3020,3025,3030,3040,3045,3050,3060,3066,3067,3068,3070,3075,3080,3085,3090,3100,3120,3190],sumCode:3e3},{title:"הוצאות הנהלה וכלליות",color:"text-cyan-700",codes:[3511,3513,3512,3515,3520,3530,3535,3540,3545,3550,3560,3566,3567,3568,3570,3575,3580,3590,3595,3600,3610,3620,3625,3631,3632,3640,3650,3660,3665,3680,3685,3690],sumCode:3500},{title:"הוצאות מימון",color:"text-indigo-700",codes:[5010,5020,5025,5030,5040,5050,5051,5090],sumCode:5e3},{title:"הכנסות מימון",color:"text-fuchsia-700",codes:[5110,5121,5122,5130,5150,5160,5190],sumCode:5100},{title:"הכנסות אחרות",color:"text-red-700",codes:[5210,5220,5230,5236,5237,5240,5250,5260,5270,5290],sumCode:5200},{title:"הוצאות אחרות",color:"text-yellow-700",codes:[5310,5320,5330,5390],sumCode:5300}],Ae=[{title:"מסים על הכנסה",color:"text-sky-700",codes:[5610,5620,5630],sumCode:5600},{title:"ייעוד הרווחים",color:"text-violet-700",codes:[5710],sumCode:5700},{title:"רווח/הפסד אקויטי",color:"text-pink-700",codes:[5810],sumCode:5800}];function Oe({selectedYear:t,referenceYear:d,data:s,referenceData:c,showEmptyFields:l=!1}){const{profitAndLoss:o}=j(P,s),r=j(P,c)?.profitAndLoss||[];return e.jsx(w,{value:"profitLoss",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני רווח והפסד"}),d&&t!==d&&e.jsxs("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded",children:["מציג שינויים לעומת ",d]})]}),Re.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title)),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:o,referenceCodes:r,code:6666,showEmptyFields:l})}),Ae.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title))]})})}const ke=[{title:"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010 בנושא IFRS",color:"red",codes:[103,104]},{title:"התאמות נדרשות לצרכי מס (הוסף/הפחת)",color:"yellow",codes:[110,120,130,135,140,150,160,170,180,181,182,183,184,190,200,300,310,320,330,350,360],sumCode:370},{title:"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010 בנושא IFRS שלא מצאו את ביטויין בהתאמות הנדרשות לצרכי מס",color:"emerald",codes:[383],sumCode:400},{title:"יישום הוראות חוקי מס נוספים",color:"sky",codes:[430,480,490],sumCode:500},{title:"נתונים נוספים",color:"violet",codes:[510,520,530,540,550,570,575,580,585,590]},{title:"בשותפות",color:"pink",codes:[600]}],$={red:{header:"text-red-700",sum:"bg-red-50 border-red-200"},yellow:{header:"text-yellow-700",sum:"bg-yellow-50 border-yellow-200"},emerald:{header:"text-emerald-700",sum:"bg-emerald-50 border-emerald-200"},sky:{header:"text-sky-700",sum:"bg-sky-50 border-sky-200"},violet:{header:"text-violet-700",sum:"bg-violet-50 border-violet-200"},pink:{header:"text-pink-700",sum:"bg-pink-50 border-pink-200"}};function Ee({data:t,referenceData:d,showEmptyFields:s=!1}){const{taxAdjustment:c}=j(q,t),o=j(q,d)?.taxAdjustment||[];return e.jsx(w,{value:"taxAdjustment",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:'נתוני דו"ח התאמה למס'}),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:c,referenceCodes:o,code:100,showEmptyFields:s})}),ke.map(n=>{const{header:r,sum:a}=$[n.color]||$.red;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:"font-bold mb-4 "+r,children:n.title}),e.jsx("div",{className:"space-y-2",children:n.codes.map(i=>e.jsx(u,{codes:c,referenceCodes:o,code:i,showEmptyFields:s},i))})]}),n.sumCode&&e.jsx("div",{className:"p-4 rounded-md border-2 "+a,children:e.jsx(u,{codes:c,referenceCodes:o,code:n.sumCode,showEmptyFields:s})})]},n.title)})]})})}function Ie({data:t,referenceData:d,businessInfo:s,selectedYear:c,referenceYear:l}){const o=j(V,t),n=j(V,d),[r,a]=b.useState("header"),[i,h]=b.useState(!0);return e.jsxs("div",{className:"p-4 border-gray-300",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:i?"outline":"default",size:"sm",onClick:()=>h(!i),className:"flex items-center gap-2",children:[i?e.jsx(ue,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"}),i?"הסתר שדות ריקים":"הצג שדות ריקים"]}),e.jsx("span",{className:"text-sm text-gray-500",children:i?"מציג את כל השדות":"מציג רק שדות עם נתונים"})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4"}),"הורד"]}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"שמור"]})]})]}),e.jsxs(te,{value:r,onValueChange:a,className:"w-full",children:[e.jsxs(ae,{className:"grid grid-cols-4 w-full",dir:"rtl",children:[e.jsx(v,{value:"header",children:"פרטים מזהים"}),e.jsx(v,{value:"profitLoss",children:"רווח והפסד"}),e.jsx(v,{value:"taxAdjustment",children:"התאמה למס"}),e.jsx(v,{value:"balanceSheet",children:"מאזן"})]}),e.jsx(Te,{data:o,businessInfo:s}),e.jsx(Oe,{selectedYear:c,referenceYear:l,data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ee,{data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ne,{data:o,referenceData:n,showEmptyFields:i})]})]})}function $e(){const{setFiltersContext:t}=b.useContext(le),[d,s]=b.useState(void 0),[c,l]=b.useState(void 0),[o,n]=b.useState(void 0),[{data:r,fetching:a}]=de({query:ie,variables:{year:c?Number.parseInt(c,10):0,businessId:d},pause:!c||!d});return b.useEffect(()=>{t(e.jsx("div",{className:"flex flex-row gap-x-5",dir:"rtl",children:e.jsx(he,{selectedBusiness:d,setSelectedBusiness:s,selectedYear:c,setSelectedYear:l,referenceYear:o,setReferenceYear:n})}))},[t,d,c,o]),e.jsx("div",{className:"container mx-auto",dir:"rtl",children:e.jsxs(ne,{className:"border-2 border-gray-300",children:[e.jsx(oe,{className:"bg-gray-100 border-b-2 border-gray-300 flex flex-row justify-between items-center",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("h1",{className:"text-2xl font-bold",children:'נספח לטופס הדו"ח השנתי ליחיד ולחבר בני אדם'}),e.jsxs("h2",{className:"text-xl",children:["לשנת המס ",c]}),e.jsx("p",{className:"text-sm",children:'נתוני הדוחות הכספיים, מאזן, רווח והפסד ודו"ח ההתאמה למס'})]})}),e.jsx(ce,{className:"p-0",children:e.jsx(Le,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Le({fetching:t,data:d,selectedBusiness:s,selectedYear:c,referenceYear:l}){if(t)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"טוען נתונים..."})});if(!c||!s)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"יש לבחור עסק ושנת דיווח"})});const o=d?.shaam6111.data;return o?e.jsx(Ie,{data:o,businessInfo:d.shaam6111.business,selectedBusiness:s,selectedYear:c,referenceYear:l}):e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"אין נתונים זמינים עבור העסק והשנה שנבחרו"})})}export{$e as Shaam6111Report};
|
|
1
|
+
import{r as b,bD as W,j as e,D as _,aL as z,B as g,x as G,al as Q,am as J,a2 as D,b5 as K,aO as R,ao as A,ap as O,aq as k,ar as E,as as T,d7 as X,br as w,a6 as j,gm as I,gn as Z,go as S,gp as ee,gq as L,gr as M,gs as B,gt as N,gu as p,gv as P,gw as q,dD as se,gk as re,bl as te,bm as ae,bn as v,gx as V,F as le,u as de,J as ne,K as oe,W as ce,gy as ie}from"./index-llwTvhRi.js";import{F as Y}from"./funnel-DrbTHWGk.js";import{B as me}from"./building-2-BgbaTAJm.js";import{E as ue}from"./eye-off-DPLQFIHz.js";import{S as xe}from"./save-Dlfry6XY.js";const C=["2020","2021","2022","2023"];function he({selectedBusiness:t,setSelectedBusiness:d,selectedYear:s,setSelectedYear:c,referenceYear:l,setReferenceYear:o}){const[n,r]=b.useState(!s||!t),{selectableBusinesses:a,fetching:i}=W(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(_,{open:n,onOpenChange:r,children:[e.jsx(z,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(G,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(Q,{children:e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(K,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(A,{value:s,onValueChange:c,children:[e.jsx(O,{id:"year-select",children:e.jsx(k,{})}),e.jsx(E,{children:C.map(x=>e.jsx(T,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(A,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(O,{id:"reference-year-select",children:e.jsx(k,{})}),e.jsxs(E,{children:[e.jsx(T,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(T,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const m=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=U=>Number.parseFloat(U.replace(/[,\s₪]/g,""))||0,H=f(h),F=f(x);return F===0?null:(H-F)/F*100};if(!n(d))return null;const i=o?a(d,c):null;return e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-gray-200",dir:"rtl",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[t," ",s&&`(${s})`]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r(d)?"text-gray-400":""}`,children:r(d)?"0":d}),i!==null&&e.jsxs("span",{className:`text-xs px-1 py-0.5 rounded ${i>0?"text-green-700 bg-green-100":i<0?"text-red-700 bg-red-100":"text-gray-700 bg-gray-100"}`,children:[i>0?"+":"",i.toFixed(1),"%"]})]})]})},u=({codes:t,referenceCodes:d,code:s,showEmptyFields:c})=>{const{value:l,label:o}=b.useMemo(()=>{const r=t.find(a=>a.code===s);return{value:r?.amount||0,label:r?.label||"לא זוהה קוד"}},[t,s]),n=b.useMemo(()=>d?.find(r=>r.code===s)?.amount.toString()||"",[d,s]);return e.jsx(m,{label:o,value:X(l,0),code:String(s),showChange:!0,showEmptyFields:c,referenceValue:n})},be=[{title:"מזומנים ושווי מזומנים",codes:[7110,7120,7150],sumCode:7100},{title:"ניירות ערך",codes:[7215,7225,7230,7290,7295],sumCode:7200},{title:"לקוחות",codes:[7310,7320,7330,7350,7360,7380,7390],sumCode:7300},{title:"חייבים ויתרות חובה",codes:[7410,7420,7430,7440,7450,7461,7462,7470,7490],sumCode:7400},{title:"מסים נדחים לזמן קצר",codes:[7610,7620,7690],sumCode:7600},{title:"הלוואות לזמן קצר",codes:[7711,7712,7720],sumCode:7700},{title:"מלאי",codes:[7805,7810,7815,7820,7825,7830,7840,7850,7860,7870,7890],sumCode:7800}],je=[{title:"רכוש קבוע",codes:[8010,8020,8025,8030,8040,8050,8060,8080,8090,8095,8100,8105,8110,8120,8130,8140,8150,8160,8170,8180,8190],sumCode:8e3},{title:"נכסים לא שוטפים מוחזקים למכירה",codes:[8710],sumCode:8700},{title:"הוצאות מראש לזמן ארוך",codes:[8210,8220,8290],sumCode:8200},{title:"השקעות בחברות מוחזקות כלולות ומאוחדות",codes:[8315,8325,8335,8340,8350],sumCode:8300},{title:'השקעות בחברות אחרות כולל ני"ע סחירים מוחזקים לזמן ארוך',codes:[8410,8420,8440,8450,8460,8490],sumCode:8400},{title:"מסים נדחים לזמן ארוך",codes:[8510,8520,8590],sumCode:8500},{title:"הוצאות נדחות ורכוש אחר",codes:[8610,8620,8630,8640,8690],sumCode:8600}],pe=[{title:"בנקים והלואות לזמן קצר",codes:[9110,9120,9130,9140,9151,9152,9190],sumCode:9100},{title:"ספקים ונותני שירותים",codes:[9210,9220,9230,9290],sumCode:9200},{title:"זכאים ויתרות זכות",codes:[9310,9320,9330,9340,9350,9360,9370,9410,9420,9431,9432,9435,9440,9450,9460,9470,9480,9490],sumCode:9400},{title:"עתודה למסים נדחים לזמן קצר",codes:[9510,9520,9530],sumCode:9500}],ge=[{title:"התחייבויות לזמן ארוך",codes:[9605,9610,9620,9631,9632,9640,9650,9660,9670,9690],sumCode:9600},{title:"התחייבויות בשל סיום יחסי עובד-מעביד",codes:[9710,9720,9790],sumCode:9700},{title:"עתודה למסים נדחים לזמן ארוך",codes:[9810,9820,9890],sumCode:9800}],fe=[{title:"הון עצמי",codes:[9910,9920,9930,9940,9950,9960,9980],sumCode:9900}];function Ne({data:t,referenceData:d,showEmptyFields:s=!1}){const l=j(I,t).balanceSheet||[],n=j(I,d)?.balanceSheet||[];return e.jsx(w,{value:"balanceSheet",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני המאזן"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-blue-800 border-b pb-2",children:"נכסים"}),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx("h5",{className:"font-bold",children:"רכוש שוטף"})}),be.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:7e3,showEmptyFields:s})}),je.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:8888,showEmptyFields:s})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-red-800 border-b pb-2",children:"התחייבויות והון"}),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx("h5",{className:"font-bold",children:"התחייבויות שוטפות"})}),pe.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9e3,showEmptyFields:s})}),ge.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),fe.map(r=>e.jsxs("div",{className:"bg-green-50 p-4 rounded-md",children:[e.jsx("h5",{className:"font-bold mb-3",children:r.title}),e.jsx("div",{className:"space-y-2",children:r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a))})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9999,showEmptyFields:s})})]})]})]})})}const ve=t=>{switch(t){case"1":return"תעשייתי";case"2":return"מסחרי";case"3":return"נותני שירותים";case"99":return"הדיווח כולל יותר מעסק אחד";default:return""}},Ce=t=>{switch(t){case S.Cash:return"מזומן";case S.Accrual:return"מצטבר";case S.DollarRegulations:return"לפי תקנות דולריות";default:return""}},ye=t=>{switch(t){case L.Shekels:return"שקלים";case L.Dollars:return"דולרים";default:return""}},Se=t=>{switch(t){case M.DoubleEntry:return"כפולה";case M.SingleEntry:return"חד-צידית";default:return""}},we=t=>{switch(t){case B.Computerized:return"ממוחשב";case B.Manual:return"ידני";default:return""}},Fe=t=>{switch(t){case N.Option_1:return"חלופה 1";case N.Option_2Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010";case N.Option_3Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010";case N.None:return"ללא חלופה";default:return""}},De=t=>{switch(t){case p.Unqualified:return"נוסח אחיד (בלתי מסוייג)";case p.UnqualifiedWithGoingConcern:return"בנוסח אחיד עם הפניית תשומת לב להערת עסק חי";case p.UnqualifiedWithOtherEmphases:return"בנוסח אחיד עם הפניות תשומת לב אחרת";case p.Qualified:return"הסתייגות";case p.Adverse:return"שלילית";case p.Disclaimer:return"המנעות";case p.None:return"אין חוות דעת";default:return""}},y=t=>t==null?"":t?"כן":"לא";function Te({data:t,businessInfo:d}){const{header:s}=j(Z,t),c=j(ee,d);return e.jsx(w,{value:"header",className:"border rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",dir:"rtl",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטים מזהים"}),e.jsx(m,{label:"השם הרשום",value:c.name,showEmptyFields:!0}),e.jsx(m,{label:"תיאור העיסוק המדווח",value:s.businessDescription??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר זהות",value:s.idNumber,showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק",value:s.taxFileNumber,showEmptyFields:!0}),e.jsx(m,{label:'תיק מדווח למע"מ',value:s.vatFileNumber??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק ניכויים",value:s.withholdingTaxFileNumber??"",showEmptyFields:!0})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטי העסק"}),e.jsx(m,{value:ve(s.businessType),label:"סוג העסק המדווח",showEmptyFields:!0}),e.jsx(m,{label:"שיטת דיווח",value:Ce(s.reportingMethod),showEmptyFields:!0}),s.reportingMethod===S.DollarRegulations&&e.jsx(m,{label:"מטבע הסכומים",value:ye(s.currencyType),showEmptyFields:!0}),e.jsx(m,{label:"הסכום באלפים",value:y(s.amountsInThousands),showEmptyFields:!0}),e.jsx(m,{label:"שיטת חשבונאות",value:Se(s.accountingMethod),showEmptyFields:!0}),e.jsx(m,{label:"הנהלת חשבונות",value:we(s.accountingSystem),showEmptyFields:!0}),e.jsx(m,{label:"חייב ברישום תוכנה",value:y(!!s.softwareRegistrationNumber),showEmptyFields:!0}),s.softwareRegistrationNumber&&e.jsx(m,{label:"מספר תעודת רישום",value:s.softwareRegistrationNumber,showEmptyFields:!0}),e.jsx(m,{label:"דוח בגין שותפות",value:y(!!s.isPartnership),showEmptyFields:!0}),s.isPartnership&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"מספר שותפים",value:s.partnershipCount?.toString()??"",showEmptyFields:!0}),e.jsx(m,{label:"חלקי ברווחי השותפות",value:`${s.partnershipProfitShare}%`,showEmptyFields:!0})]}),e.jsx(m,{label:"יישום תקני חשבונאות (IFRS)",value:y(!!s.ifrsImplementationYear||!!s.ifrsReportingOption),showEmptyFields:!0}),(!!s.ifrsImplementationYear||!!s.ifrsReportingOption)&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"החל משנת המס",value:s.ifrsImplementationYear??"",showEmptyFields:!0}),e.jsx(m,{label:"דווח בחלופה",value:Fe(s.ifrsReportingOption),showEmptyFields:!0})]}),e.jsx(m,{label:"מספר ענף כלכלי של המדווח",value:s.industryCode,showEmptyFields:!0}),e.jsx(m,{label:"חוות דעת המבקר",value:De(s.auditOpinionType),showEmptyFields:!0})]})]})})}const Re=[{title:"הכנסות ממכירות ומתן שירותים",color:"text-blue-700",codes:[1010,1015,1020,1025,1030,1040,1051,1052,1090],sumCode:1e3},{title:"עלות המכירות ומתן השירותים וביצוע עבודות",color:"text-purple-700",codes:[1306,1308,1307,1310,1320,1330,1340,1350,1360,1371,1372,1390,1400,1450],sumCode:1300},{title:"עלויות ייצור ועלויות אצל קבלן בונה",color:"text-rose-700",codes:[2005,2006,2011,2012,2015,2020,2025,2030,2035,2040,2045,2050,2060,2066,2067,2068,2070,2075,2080,2085,2090,2095],sumCode:2e3},{title:"הוצאות מחקר ופיתוח",color:"text-amber-700",codes:[2510,2520,2530,2540,2550,2560,2570,2590],sumCode:2500},{title:"הוצאות מכירה",color:"text-green-700",codes:[3011,3013,3012,3015,3020,3025,3030,3040,3045,3050,3060,3066,3067,3068,3070,3075,3080,3085,3090,3100,3120,3190],sumCode:3e3},{title:"הוצאות הנהלה וכלליות",color:"text-cyan-700",codes:[3511,3513,3512,3515,3520,3530,3535,3540,3545,3550,3560,3566,3567,3568,3570,3575,3580,3590,3595,3600,3610,3620,3625,3631,3632,3640,3650,3660,3665,3680,3685,3690],sumCode:3500},{title:"הוצאות מימון",color:"text-indigo-700",codes:[5010,5020,5025,5030,5040,5050,5051,5090],sumCode:5e3},{title:"הכנסות מימון",color:"text-fuchsia-700",codes:[5110,5121,5122,5130,5150,5160,5190],sumCode:5100},{title:"הכנסות אחרות",color:"text-red-700",codes:[5210,5220,5230,5236,5237,5240,5250,5260,5270,5290],sumCode:5200},{title:"הוצאות אחרות",color:"text-yellow-700",codes:[5310,5320,5330,5390],sumCode:5300}],Ae=[{title:"מסים על הכנסה",color:"text-sky-700",codes:[5610,5620,5630],sumCode:5600},{title:"ייעוד הרווחים",color:"text-violet-700",codes:[5710],sumCode:5700},{title:"רווח/הפסד אקויטי",color:"text-pink-700",codes:[5810],sumCode:5800}];function Oe({selectedYear:t,referenceYear:d,data:s,referenceData:c,showEmptyFields:l=!1}){const{profitAndLoss:o}=j(P,s),r=j(P,c)?.profitAndLoss||[];return e.jsx(w,{value:"profitLoss",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני רווח והפסד"}),d&&t!==d&&e.jsxs("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded",children:["מציג שינויים לעומת ",d]})]}),Re.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title)),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:o,referenceCodes:r,code:6666,showEmptyFields:l})}),Ae.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title))]})})}const ke=[{title:"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010 בנושא IFRS",color:"red",codes:[103,104]},{title:"התאמות נדרשות לצרכי מס (הוסף/הפחת)",color:"yellow",codes:[110,120,130,135,140,150,160,170,180,181,182,183,184,190,200,300,310,320,330,350,360],sumCode:370},{title:"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010 בנושא IFRS שלא מצאו את ביטויין בהתאמות הנדרשות לצרכי מס",color:"emerald",codes:[383],sumCode:400},{title:"יישום הוראות חוקי מס נוספים",color:"sky",codes:[430,480,490],sumCode:500},{title:"נתונים נוספים",color:"violet",codes:[510,520,530,540,550,570,575,580,585,590]},{title:"בשותפות",color:"pink",codes:[600]}],$={red:{header:"text-red-700",sum:"bg-red-50 border-red-200"},yellow:{header:"text-yellow-700",sum:"bg-yellow-50 border-yellow-200"},emerald:{header:"text-emerald-700",sum:"bg-emerald-50 border-emerald-200"},sky:{header:"text-sky-700",sum:"bg-sky-50 border-sky-200"},violet:{header:"text-violet-700",sum:"bg-violet-50 border-violet-200"},pink:{header:"text-pink-700",sum:"bg-pink-50 border-pink-200"}};function Ee({data:t,referenceData:d,showEmptyFields:s=!1}){const{taxAdjustment:c}=j(q,t),o=j(q,d)?.taxAdjustment||[];return e.jsx(w,{value:"taxAdjustment",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:'נתוני דו"ח התאמה למס'}),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:c,referenceCodes:o,code:100,showEmptyFields:s})}),ke.map(n=>{const{header:r,sum:a}=$[n.color]||$.red;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:"font-bold mb-4 "+r,children:n.title}),e.jsx("div",{className:"space-y-2",children:n.codes.map(i=>e.jsx(u,{codes:c,referenceCodes:o,code:i,showEmptyFields:s},i))})]}),n.sumCode&&e.jsx("div",{className:"p-4 rounded-md border-2 "+a,children:e.jsx(u,{codes:c,referenceCodes:o,code:n.sumCode,showEmptyFields:s})})]},n.title)})]})})}function Ie({data:t,referenceData:d,businessInfo:s,selectedYear:c,referenceYear:l}){const o=j(V,t),n=j(V,d),[r,a]=b.useState("header"),[i,h]=b.useState(!0);return e.jsxs("div",{className:"p-4 border-gray-300",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:i?"outline":"default",size:"sm",onClick:()=>h(!i),className:"flex items-center gap-2",children:[i?e.jsx(ue,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"}),i?"הסתר שדות ריקים":"הצג שדות ריקים"]}),e.jsx("span",{className:"text-sm text-gray-500",children:i?"מציג את כל השדות":"מציג רק שדות עם נתונים"})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4"}),"הורד"]}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"שמור"]})]})]}),e.jsxs(te,{value:r,onValueChange:a,className:"w-full",children:[e.jsxs(ae,{className:"grid grid-cols-4 w-full",dir:"rtl",children:[e.jsx(v,{value:"header",children:"פרטים מזהים"}),e.jsx(v,{value:"profitLoss",children:"רווח והפסד"}),e.jsx(v,{value:"taxAdjustment",children:"התאמה למס"}),e.jsx(v,{value:"balanceSheet",children:"מאזן"})]}),e.jsx(Te,{data:o,businessInfo:s}),e.jsx(Oe,{selectedYear:c,referenceYear:l,data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ee,{data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ne,{data:o,referenceData:n,showEmptyFields:i})]})]})}function $e(){const{setFiltersContext:t}=b.useContext(le),[d,s]=b.useState(void 0),[c,l]=b.useState(void 0),[o,n]=b.useState(void 0),[{data:r,fetching:a}]=de({query:ie,variables:{year:c?Number.parseInt(c,10):0,businessId:d},pause:!c||!d});return b.useEffect(()=>{t(e.jsx("div",{className:"flex flex-row gap-x-5",dir:"rtl",children:e.jsx(he,{selectedBusiness:d,setSelectedBusiness:s,selectedYear:c,setSelectedYear:l,referenceYear:o,setReferenceYear:n})}))},[t,d,c,o]),e.jsx("div",{className:"container mx-auto",dir:"rtl",children:e.jsxs(ne,{className:"border-2 border-gray-300",children:[e.jsx(oe,{className:"bg-gray-100 border-b-2 border-gray-300 flex flex-row justify-between items-center",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("h1",{className:"text-2xl font-bold",children:'נספח לטופס הדו"ח השנתי ליחיד ולחבר בני אדם'}),e.jsxs("h2",{className:"text-xl",children:["לשנת המס ",c]}),e.jsx("p",{className:"text-sm",children:'נתוני הדוחות הכספיים, מאזן, רווח והפסד ודו"ח ההתאמה למס'})]})}),e.jsx(ce,{className:"p-0",children:e.jsx(Le,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Le({fetching:t,data:d,selectedBusiness:s,selectedYear:c,referenceYear:l}){if(t)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"טוען נתונים..."})});if(!c||!s)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"יש לבחור עסק ושנת דיווח"})});const o=d?.shaam6111.data;return o?e.jsx(Ie,{data:o,businessInfo:d.shaam6111.business,selectedBusiness:s,selectedYear:c,referenceYear:l}):e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"אין נתונים זמינים עבור העסק והשנה שנבחרו"})})}export{$e as Shaam6111Report};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,bI as _,j as e,bC as k,B as I,bB as V,E as Q,bD as G,dr as K,b4 as q,ds as z,bE as y,bH as A,bF as F,bG as D,w as S,u as R,gD as X,J as P,c as U,K as $,O as J,a4 as W,W as Y,F as Z,aC as ee,b8 as se,Q as ae,gE as te,dZ as re,ay as ne}from"./index-rI994S3C.js";import{u as O}from"./use-url-query-CqWra6gD.js";import{P as oe}from"./page-layout-DMGj5xhW.js";import{k as ie,B as N,X as H,Y as le,l as ce,q as de,m as ue,n as me,o as pe,p as xe,r as ge,s as he}from"./download-csv-BSGaUZsM.js";import{P as fe}from"./modal-BXR_xgUm.js";import{F as be}from"./funnel-Cfb9Pxmr.js";import{M as E}from"./MultiSelect-DBeIExB5.js";import{T as je}from"./index-C7p19nIa.js";import{s as ye}from"./sub-CEXBz_OW.js";import"./sequential-CjOfRLtc.js";import"./download-csv-button-CMQBUQeX.js";import"./similar-transactions-modal-DX3CPrMo.js";import"./building-2-CMKd_bU8.js";import"./addDays-DTiBTTns.js";import"./subMonths-DY4HlBVa.js";var ve=ie({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:le}],formatAxisMap:ce});function Ce(a){return!a||V(a)?null:encodeURIComponent(JSON.stringify(a))}const L="balanceReportFilters",g={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Te({filter:a,setFilter:i,closeModal:c}){const{control:t,handleSubmit:r,watch:p}=Q({defaultValues:{...a}}),{selectableBusinesses:b,fetching:h}=G(),{selectableFinancialEntities:f,fetching:v}=K(),{selectableTags:x,fetching:j}=q(),M=s=>{i(s),c()},C=p("excludedTags"),o=m.useMemo(()=>x.filter(s=>!C.includes(s.value)),[C,x]),d=p("includedTags"),n=m.useMemo(()=>x.filter(s=>!d.includes(s.value)),[d,x]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:a?.ownerId,render:({field:s,fieldState:l})=>e.jsx(A,{...s,data:b,value:s.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:a?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:l})=>e.jsx(D,{...s,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==s.value&&s.onChange(T)},value:s.value?new Date(s.value):void 0,error:l.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:a?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:l})=>e.jsx(D,{...s,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==s.value&&s.onChange(T)},value:s.value?new Date(s.value):void 0,error:l.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:g.MONTHLY,render:({field:s,fieldState:l})=>e.jsx(A,{...s,data:Object.values(g).map(u=>({value:u,label:u})),value:s.value,label:"Period",maxDropdownHeight:160,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:a.excludedCounterparties,render:({field:s,fieldState:l})=>e.jsx(E,{...s,data:f,value:s.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:a.includedTags,render:({field:s,fieldState:l})=>e.jsx(E,{...s,data:o,value:s.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:a.excludedTags,render:({field:s,fieldState:l})=>e.jsx(E,{...s,data:n,value:s.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function we({filter:a,setFilter:i,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[p,b]=m.useState(!!a),{get:h,set:f}=O();m.useEffect(()=>{const x=Ce(a),j=h(L);x!==j&&f(L,x)},[a,h,f]);const v=m.useCallback(x=>{_(x,a)||(i(x),b(!!x))},[a,i]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(fe,{opened:t,onClose:()=>r(!1),content:e.jsx(Te,{filter:a,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(k,{inline:!0,size:16,disabled:!p,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(be,{className:"size-5"})})})]})}const Ne=({period:a,transactionIDs:i,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=R({query:X,variables:{transactionIDs:i}}),p=m.useMemo(()=>t?.transactionsByIDs?i.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,i]);return e.jsx(P,{className:"mt-5 w-full",children:r?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs(J,{className:"flex justify-between",children:[e.jsxs("span",{children:[a," Transactions"]}),e.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[e.jsx(de,{rawTransactions:p}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(W,{className:"h-4 w-4"})})]})]})}),e.jsx(Y,{children:e.jsx(je,{transactionsProps:p})})]})})},w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Me(a,i,c){switch(c){case g.MONTHLY:{const t=String(i).padStart(2,"0");return`${a}-${t}`}case g.BI_MONTHLY:{const t=i%2===0?i-1:i,r=String(t).padStart(2,"0");return`${a}-${r}`}case g.QUARTERLY:{const t=Math.ceil(i/3);return`${a}-Q${t}`}case g.SEMI_ANNUALLY:{const t=i>6?2:1;return`${a}-H${t}`}case g.ANNUALLY:return String(a)}}function Se(a,i){switch(i){case g.MONTHLY:{const[c,t]=a.split("-");return`${t}/${c}`}case g.BI_MONTHLY:{const[c,t]=a.split("-"),r=Number(t)+1,p=String(r).padStart(2,"0");return`${t}-${p}/${c}`}case g.QUARTERLY:{const[c,t]=a.split("-");return`${t}, ${c}`}case g.SEMI_ANNUALLY:{const[c,t]=a.split("-");return`${t}, ${c}`}case g.ANNUALLY:return a}}const B=re(ne.Usd),ke=()=>{const{setFiltersContext:a}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=O(),t=m.useMemo(()=>{const o={ownerId:i?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:g.MONTHLY,fromDate:S(ye(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(L);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(n){console.log("Error parsing balance report filters from URL:",n)}return o},[i?.context.adminBusinessId,c]),[r,p]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),x=m.useMemo(()=>{const{ownerId:o,fromDate:d,toDate:n}=r;return{ownerId:o,fromDate:d,toDate:n}},[r]),[{data:j,fetching:M}]=R({query:te,variables:x,pause:!r});m.useEffect(()=>{a(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(we,{filter:r,setFilter:p,initiallyOpened:!r}),e.jsx(se,{options:Object.entries(w).map(([o,d])=>({label:d.label,value:o})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,a,p,f]),m.useEffect(()=>{p(o=>({...o,ownerId:i?.context.adminBusinessId}))},[i]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const o=new Map;j.transactionsForBalanceReport.map(n=>{if(n.counterparty?.id&&(!n.isFee&&i?.context.financialAccountsBusinessesIds?.includes(n.counterparty.id)||r.excludedCounterparties?.includes(n.counterparty.id))||r.includedTags.length>0&&(!n.charge?.tags||n.charge.tags.length===0||!n.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&n.charge?.tags.length&&n.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const s=Me(n.year,n.month,r.period);o.has(s)||o.set(s,{income:0,expense:0,delta:0,transactions:[]});const l=o.get(s);n.amountUsd.raw>0?l.income+=n.amountUsd.raw:l.expense+=n.amountUsd.raw,l.delta+=n.amountUsd.raw,l.transactions.push(n)});let d=0;return Array.from(o.entries()).sort((n,s)=>n[0].localeCompare(s[0])).map(([n,s])=>(d+=s.delta,{period:n,income:s.income,expense:s.expense,delta:s.delta,cumulative:d,transactions:s.transactions.sort((l,u)=>Math.abs(u.amountUsd.raw)-Math.abs(l.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,i?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full",children:[e.jsx($,{children:e.jsx(ae,{children:"Click specific period to expand it's transactions data"})}),e.jsx(Y,{children:e.jsx(ue,{config:w,className:"h-150 w-full",children:e.jsxs(ve,{accessibilityLayer:!0,data:C,onClick:o=>h(o.activeLabel),children:[e.jsx(me,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:o=>Se(o,r.period)}),e.jsx(pe,{content:e.jsx(xe,{formatter:(o,d,n,s)=>{const l=`bg-[var(--color-${d})]`;return s<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${l} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:B.format(Number(o))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${l}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:B.format(Number(o))})]})}})}),e.jsx(ge,{content:e.jsx(he,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(Ne,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{ke as BalanceReport};
|
|
1
|
+
import{r as m,bI as _,j as e,bC as k,B as I,bB as V,E as Q,bD as G,dr as K,b4 as q,ds as z,bE as y,bH as A,bF as F,bG as D,w as S,u as R,gD as X,J as P,c as U,K as $,O as J,a4 as W,W as Y,F as Z,aC as ee,b8 as se,Q as ae,gE as te,dZ as re,ay as ne}from"./index-llwTvhRi.js";import{u as O}from"./use-url-query-C70bqR6l.js";import{P as oe}from"./page-layout-ClvcCJfx.js";import{k as ie,B as N,X as H,Y as le,l as ce,q as de,m as ue,n as me,o as pe,p as xe,r as ge,s as he}from"./download-csv-CI8CQmZN.js";import{P as fe}from"./modal-B0cCJdW9.js";import{F as be}from"./funnel-DrbTHWGk.js";import{M as E}from"./MultiSelect-Ca6lO0tL.js";import{T as je}from"./index-DLG-Can3.js";import{s as ye}from"./sub-D5WK8Yq6.js";import"./sequential-CjOfRLtc.js";import"./download-csv-button-C12VYNQh.js";import"./similar-transactions-modal-DjIjqO-0.js";import"./building-2-BgbaTAJm.js";import"./addDays-DbQpcl70.js";import"./subMonths-Ft6EDjKW.js";var ve=ie({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:le}],formatAxisMap:ce});function Ce(a){return!a||V(a)?null:encodeURIComponent(JSON.stringify(a))}const L="balanceReportFilters",g={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Te({filter:a,setFilter:i,closeModal:c}){const{control:t,handleSubmit:r,watch:p}=Q({defaultValues:{...a}}),{selectableBusinesses:b,fetching:h}=G(),{selectableFinancialEntities:f,fetching:v}=K(),{selectableTags:x,fetching:j}=q(),M=s=>{i(s),c()},C=p("excludedTags"),o=m.useMemo(()=>x.filter(s=>!C.includes(s.value)),[C,x]),d=p("includedTags"),n=m.useMemo(()=>x.filter(s=>!d.includes(s.value)),[d,x]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:a?.ownerId,render:({field:s,fieldState:l})=>e.jsx(A,{...s,data:b,value:s.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:a?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:l})=>e.jsx(D,{...s,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==s.value&&s.onChange(T)},value:s.value?new Date(s.value):void 0,error:l.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:a?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:l})=>e.jsx(D,{...s,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==s.value&&s.onChange(T)},value:s.value?new Date(s.value):void 0,error:l.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:g.MONTHLY,render:({field:s,fieldState:l})=>e.jsx(A,{...s,data:Object.values(g).map(u=>({value:u,label:u})),value:s.value,label:"Period",maxDropdownHeight:160,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:a.excludedCounterparties,render:({field:s,fieldState:l})=>e.jsx(E,{...s,data:f,value:s.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:a.includedTags,render:({field:s,fieldState:l})=>e.jsx(E,{...s,data:o,value:s.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:a.excludedTags,render:({field:s,fieldState:l})=>e.jsx(E,{...s,data:n,value:s.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function we({filter:a,setFilter:i,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[p,b]=m.useState(!!a),{get:h,set:f}=O();m.useEffect(()=>{const x=Ce(a),j=h(L);x!==j&&f(L,x)},[a,h,f]);const v=m.useCallback(x=>{_(x,a)||(i(x),b(!!x))},[a,i]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(fe,{opened:t,onClose:()=>r(!1),content:e.jsx(Te,{filter:a,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(k,{inline:!0,size:16,disabled:!p,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(be,{className:"size-5"})})})]})}const Ne=({period:a,transactionIDs:i,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=R({query:X,variables:{transactionIDs:i}}),p=m.useMemo(()=>t?.transactionsByIDs?i.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,i]);return e.jsx(P,{className:"mt-5 w-full",children:r?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs(J,{className:"flex justify-between",children:[e.jsxs("span",{children:[a," Transactions"]}),e.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[e.jsx(de,{rawTransactions:p}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(W,{className:"h-4 w-4"})})]})]})}),e.jsx(Y,{children:e.jsx(je,{transactionsProps:p})})]})})},w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Me(a,i,c){switch(c){case g.MONTHLY:{const t=String(i).padStart(2,"0");return`${a}-${t}`}case g.BI_MONTHLY:{const t=i%2===0?i-1:i,r=String(t).padStart(2,"0");return`${a}-${r}`}case g.QUARTERLY:{const t=Math.ceil(i/3);return`${a}-Q${t}`}case g.SEMI_ANNUALLY:{const t=i>6?2:1;return`${a}-H${t}`}case g.ANNUALLY:return String(a)}}function Se(a,i){switch(i){case g.MONTHLY:{const[c,t]=a.split("-");return`${t}/${c}`}case g.BI_MONTHLY:{const[c,t]=a.split("-"),r=Number(t)+1,p=String(r).padStart(2,"0");return`${t}-${p}/${c}`}case g.QUARTERLY:{const[c,t]=a.split("-");return`${t}, ${c}`}case g.SEMI_ANNUALLY:{const[c,t]=a.split("-");return`${t}, ${c}`}case g.ANNUALLY:return a}}const B=re(ne.Usd),ke=()=>{const{setFiltersContext:a}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=O(),t=m.useMemo(()=>{const o={ownerId:i?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:g.MONTHLY,fromDate:S(ye(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(L);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(n){console.log("Error parsing balance report filters from URL:",n)}return o},[i?.context.adminBusinessId,c]),[r,p]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),x=m.useMemo(()=>{const{ownerId:o,fromDate:d,toDate:n}=r;return{ownerId:o,fromDate:d,toDate:n}},[r]),[{data:j,fetching:M}]=R({query:te,variables:x,pause:!r});m.useEffect(()=>{a(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(we,{filter:r,setFilter:p,initiallyOpened:!r}),e.jsx(se,{options:Object.entries(w).map(([o,d])=>({label:d.label,value:o})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,a,p,f]),m.useEffect(()=>{p(o=>({...o,ownerId:i?.context.adminBusinessId}))},[i]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const o=new Map;j.transactionsForBalanceReport.map(n=>{if(n.counterparty?.id&&(!n.isFee&&i?.context.financialAccountsBusinessesIds?.includes(n.counterparty.id)||r.excludedCounterparties?.includes(n.counterparty.id))||r.includedTags.length>0&&(!n.charge?.tags||n.charge.tags.length===0||!n.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&n.charge?.tags.length&&n.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const s=Me(n.year,n.month,r.period);o.has(s)||o.set(s,{income:0,expense:0,delta:0,transactions:[]});const l=o.get(s);n.amountUsd.raw>0?l.income+=n.amountUsd.raw:l.expense+=n.amountUsd.raw,l.delta+=n.amountUsd.raw,l.transactions.push(n)});let d=0;return Array.from(o.entries()).sort((n,s)=>n[0].localeCompare(s[0])).map(([n,s])=>(d+=s.delta,{period:n,income:s.income,expense:s.expense,delta:s.delta,cumulative:d,transactions:s.transactions.sort((l,u)=>Math.abs(u.amountUsd.raw)-Math.abs(l.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,i?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full",children:[e.jsx($,{children:e.jsx(ae,{children:"Click specific period to expand it's transactions data"})}),e.jsx(Y,{children:e.jsx(ue,{config:w,className:"h-150 w-full",children:e.jsxs(ve,{accessibilityLayer:!0,data:C,onClick:o=>h(o.activeLabel),children:[e.jsx(me,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:o=>Se(o,r.period)}),e.jsx(pe,{content:e.jsx(xe,{formatter:(o,d,n,s)=>{const l=`bg-[var(--color-${d})]`;return s<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${l} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:B.format(Number(o))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${l}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:B.format(Number(o))})]})}})}),e.jsx(ge,{content:e.jsx(he,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(Ne,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{ke as BalanceReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,r as x,g9 as g,B as v,a6 as h,gB as j,a as D,F as R,u as E,L as y,bC as w,T as f,dZ as C,gC as T}from"./index-
|
|
1
|
+
import{j as n,r as x,g9 as g,B as v,a6 as h,gB as j,a as D,F as R,u as E,L as y,bC as w,T as f,dZ as C,gC as T}from"./index-llwTvhRi.js";import{d as A}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as b}from"./page-layout-ClvcCJfx.js";import{P as F}from"./modal-B0cCJdW9.js";import{F as N}from"./funnel-DrbTHWGk.js";import{T as I}from"./Table-8-ldSKpC.js";const i=({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,o]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(F,{opened:r,onClose:()=>o(!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(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(!0),children:n.jsx(N,{className:"size-5"})})]})}const u=({originalRuleData:a,diffRuleData:t})=>{const r=h(j,a),o=h(j,t),c=o?.isCompliant!==r.isCompliant||o?.percentage.formatted!==r.percentage.formatted;return!o||!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}),o&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md ".concat(o.isCompliant?"text-green-500":"text-red-500"),children:o.percentage.formatted})]})})},d=(a,t)=>C(t).format(a);function m(a,t){if(a.length!==0)return d(a.reduce((r,o)=>r+o,0),t)}const O=()=>{const{year:a}=D(),{setFiltersContext:t}=x.useContext(R),[r,o]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:c,fetching:p}]=E({query:A(T),variables:{years:r}});x.useEffect(()=>{t(n.jsx("div",{className:"flex flex-row gap-2",children:n.jsx(P,{years:r,setYears:o})}))},[r,p,t]);const s=c?.corporateTaxRulingComplianceReport??[];return n.jsx(b,{title:"Corporate Tax Ruling Compliance Report",children:p?n.jsx(y,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-4",children:s&&n.jsxs(I,{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(w,{inline:!0,size:12,processing:!s.find(l=>l.year===e)?.differences,disabled:!!s.find(l=>l.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(i,{originalAmount:e.totalIncome.formatted,diffAmount:e.differences?.totalIncome?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.totalIncome.raw).reduce((e,l)=>e+l,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(i,{originalAmount:e.researchAndDevelopmentExpenses.formatted,diffAmount:e.differences?.researchAndDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.rndRelativeToIncome.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"R&D Expenses out of Income"})})}),s.map(e=>n.jsx(u,{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(i,{originalAmount:e.localDevelopmentExpenses.formatted,diffAmount:e.differences?.localDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.localDevelopmentRelativeToRnd.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"Local Development out of R&D"})})}),s.map(e=>n.jsx(u,{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(i,{originalAmount:e.foreignDevelopmentExpenses.formatted,diffAmount:e.differences?.foreignDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.foreignDevelopmentRelativeToRnd.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"Foreign Development out of R&D"})})}),s.map(e=>n.jsx(u,{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(i,{originalAmount:e.businessTripRndExpenses.formatted,diffAmount:e.differences?.businessTripRndExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,l)=>e+l,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{O as CorporateTaxRulingComplianceReport};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as h,bB as D,j as e,bC as N,B as y,E as $,bD as k,aC as R,V as O,bE as f,bF as S,bG as C,w as F,Y as E,Z as A,_ as z,$ as P,at as M,bI as L,bv as w,T as B,aP as j,ay as p,a6 as V,d7 as v,dH as _,F as G,u as q,dI as U,b$ as Z,L as H,dJ as J}from"./index-
|
|
1
|
+
import{r as h,bB as D,j as e,bC as N,B as y,E as $,bD as k,aC as R,V as O,bE as f,bF as S,bG as C,w as F,Y as E,Z as A,_ as z,$ as P,at as M,bI as L,bv as w,T as B,aP as j,ay as p,a6 as V,d7 as v,dH as _,F as G,u as q,dI as U,b$ as Z,L as H,dJ as J}from"./index-llwTvhRi.js";import{u as I}from"./use-url-query-C70bqR6l.js";import{P as Q}from"./page-layout-ClvcCJfx.js";import{P as K}from"./modal-B0cCJdW9.js";import{F as W}from"./funnel-DrbTHWGk.js";import{M as T}from"./MultiSelect-Ca6lO0tL.js";import{D as X}from"./download-csv-button-C12VYNQh.js";import{B as Y}from"./business-extended-info-Dn8Jjrlr.js";import{P as ee,a as te}from"./panel-top-open-pJuuLeLe.js";import{T as se}from"./Table-8-ldSKpC.js";import"./data-table-column-header-_ZrN0Vs6.js";import"./eye-off-DPLQFIHz.js";function re({filter:t,setFilter:s,closeModal:i}){const n=$({defaultValues:{...t}}),{control:a,handleSubmit:o}=n,{selectableBusinesses:r,fetching:u}=k(),{userContext:m}=h.useContext(R),c=l=>{l.fromDate?.trim()===""&&(l.fromDate=void 0),l.toDate?.trim()===""&&(l.toDate=void 0),s(l),i()};function d(){s({}),i()}return e.jsxs(e.Fragment,{children:[u?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(O,{...n,children:e.jsxs("form",{onSubmit:o(c),className:"space-y-2",children:[e.jsx(f,{name:"ownerIds",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??(m?.context.adminBusinessId?[m?.context.adminBusinessId]:void 0),disabled:u,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"businessIDs",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??void 0,disabled:u,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"fromDate",control:a,defaultValue:t.fromDate,rules:{required:"Required",pattern:{value:S,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"From Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(f,{name:"toDate",control:a,defaultValue:t.toDate,rules:{pattern:{value:S,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"To Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(E,{name:"isShowZeroedAccounts",control:a,render:({field:l})=>e.jsxs(A,{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(z,{children:"Show zeroed accounts"})}),e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(P,{children:e.jsx(M,{defaultChecked:t.isShowZeroedAccounts??!1,onCheckedChange:l.onChange,checked:l.value===!0})}),e.jsx("span",{children:l.value?"show":"remove"})]})]})}),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:d,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:i,children:"Cancel"})]})]})})]})}function ae({filter:t,setFilter:s}){const[i,n]=h.useState(!1),[a,o]=h.useState(!D(t)),{get:r,set:u}=I();function m(d){return Object.entries(d??{}).filter(([b,x])=>x!==void 0&&Array.isArray(x)&&x.length>0).length>0}function c(d){L(d,t)||(s(d),o(m(d)))}return h.useEffect(()=>{const d=D(t)?null:encodeURIComponent(JSON.stringify(t)),l=r("trialBalanceReportFilters");d!==l&&u("trialBalanceReportFilters",d)},[t,r,u]),e.jsxs(e.Fragment,{children:[e.jsx(K,{opened:i,onClose:()=>n(!1),content:e.jsx(re,{filter:t,setFilter:c,closeModal:()=>n(!1)})}),e.jsx(N,{inline:!0,size:16,disabled:!a,children:e.jsx(y,{variant:"outline",onClick:()=>n(!0),className:"p-2",children:e.jsx(W,{size:20})})})]})}const ne=({data:t,fromDate:s,toDate:i})=>{const n=h.useCallback(async()=>{const a=oe(t),o=`trial_balance_report${s?`_${s}`:""}${i?`_${i}`:""}`;return{fileContent:a,fileName:o}},[t,s,i]);return e.jsx(X,{createFileVariables:n})},oe=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
|
|
2
2
|
`;for(const[i,n]of Object.entries(t)){const a=ie(i,n);s+=a}return s+=`Report total:,,${Object.values(t).reduce((i,n)=>i+n.totalDebit,0)},${Object.values(t).reduce((i,n)=>i+n.totalCredit,0)},${Object.values(t).reduce((i,n)=>i+n.sum,0)}\r
|
|
3
3
|
`,s};function ie(t,s){let i="";return Object.values(s.sortCodes).sort((n,a)=>n.key-a.key).map(n=>{const a=le(n);i+=a}),i+=`${t.replaceAll("0","*")},Group Total:,${s.totalDebit??""},${s.totalCredit??""},${s.sum}\r
|
|
4
4
|
`,i}function le(t){let s="";s+=`${t.name}\r
|