@accounter/client 0.0.9-alpha-20251210055933-a2a456db38cdbeec48f8784efb6588b0194e79d3 → 0.0.9-alpha-20251210070646-6fbc969b26176272e5d76f110746fe3af5aeefcf

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.
Files changed (94) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-BHVKlxRj.js → Checkbox-DUyxts6I.js} +1 -1
  3. package/dist/assets/{MultiSelect-DY08OexD.js → MultiSelect-mJTNaBvj.js} +1 -1
  4. package/dist/assets/{Progress-CkBW27DM.js → Progress-CbEkKbvT.js} +1 -1
  5. package/dist/assets/{Table-bhKB4PFK.js → Table-BD-Y5pOR.js} +1 -1
  6. package/dist/assets/{Typography-DclIL89E.js → Typography-CdxJ9FGD.js} +1 -1
  7. package/dist/assets/{YearPickerInput-DgK0Ih6X.js → YearPickerInput-Bka3kNAU.js} +1 -1
  8. package/dist/assets/{accordion-CAxRDsFz.js → accordion-DQeKF8al.js} +1 -1
  9. package/dist/assets/{accountant-approvals-Dgsw0WDb.js → accountant-approvals-BxwZf4R5.js} +1 -1
  10. package/dist/assets/{accounter-table-DIm6Wedu.js → accounter-table-Brq5y129.js} +1 -1
  11. package/dist/assets/{addDays-CpwSVE6j.js → addDays-BKzA2JVL.js} +1 -1
  12. package/dist/assets/{all-charges-CS_0zCEZ.js → all-charges-zbnc8c0w.js} +1 -1
  13. package/dist/assets/{arrow-up-down-BCKzoFzo.js → arrow-up-down-BL4JClUu.js} +1 -1
  14. package/dist/assets/{building-2-Cp2Es1mt.js → building-2-Bg-rF-On.js} +1 -1
  15. package/dist/assets/{business-B1WVYc0i.js → business-DeIv5a1x.js} +2 -2
  16. package/dist/assets/{business-extended-info-NwMS1Rj6.js → business-extended-info-BzvYZDrX.js} +1 -1
  17. package/dist/assets/{business-header-D7w2Xzis.js → business-header-D4uSFuTz.js} +1 -1
  18. package/dist/assets/{business-ledger-filters-BBCKjVgu.js → business-ledger-filters-B_KOoEZi.js} +1 -1
  19. package/dist/assets/{business-ledger-single-CjmguyFq.js → business-ledger-single-BNRwnlGk.js} +1 -1
  20. package/dist/assets/{business-trip-BljjobKa.js → business-trip-Cmeyg86P.js} +1 -1
  21. package/dist/assets/charge-gtojshxD.js +1 -0
  22. package/dist/assets/{charges-filters-D_ruML4x.js → charges-filters-BTiGpLnh.js} +1 -1
  23. package/dist/assets/{charges-ledger-validation-RNuvPfFo.js → charges-ledger-validation-DPXMr9tU.js} +1 -1
  24. package/dist/assets/{charges-table-Dmz1Fxim.js → charges-table-DAgbJYqd.js} +1 -1
  25. package/dist/assets/{chart-MqLuc9m0.js → chart-BwU_CSjE.js} +1 -1
  26. package/dist/assets/{contracts-DCmvv-5I.js → contracts-uxjAMebQ.js} +1 -1
  27. package/dist/assets/{data-table-column-header-CT7O7uRT.js → data-table-column-header-C23SEs2k.js} +1 -1
  28. package/dist/assets/{data-table-pagination-Bn6-S7wX.js → data-table-pagination-BQNSZ2L6.js} +1 -1
  29. package/dist/assets/{deposits-transactions-table-BAObjoYX.js → deposits-transactions-table-DkCO1YMQ.js} +1 -1
  30. package/dist/assets/{download-csv-button-BsXK9P76.js → download-csv-button-DDfbg2Ju.js} +1 -1
  31. package/dist/assets/{edit-issue-document-modal-CG9FH4t_.js → edit-issue-document-modal-CoDIF8wL.js} +1 -1
  32. package/dist/assets/{editable-business-trip-CH61WHL7.js → editable-business-trip-DlCsUKF5.js} +1 -1
  33. package/dist/assets/{eye-off-Cc-ssiRk.js → eye-off-B09TfzwY.js} +1 -1
  34. package/dist/assets/{funnel-4UXATjU3.js → funnel-DyklXeNl.js} +1 -1
  35. package/dist/assets/{index-D8HuUMKu.js → index--iJB0sxH.js} +1 -1
  36. package/dist/assets/{index-YQXRLoVL.js → index-3QXfdVxu.js} +1 -1
  37. package/dist/assets/{index-CHtpNrAW.js → index-3R_zL83W.js} +4 -4
  38. package/dist/assets/{index-C9bDcLJk.js → index-8pKwHvS9.js} +1 -1
  39. package/dist/assets/{index-DYUcGCvp.js → index-B0G1u66z.js} +1 -1
  40. package/dist/assets/{index-BWtniMl1.js → index-BKPGYmU-.js} +1 -1
  41. package/dist/assets/{index-JJZ0k_k8.js → index-BSKBXgwE.js} +1 -1
  42. package/dist/assets/{index-SV9JUpu6.js → index-Bd97U3hC.js} +1 -1
  43. package/dist/assets/{index-CPuaqVQw.js → index-BfcmcL6K.js} +1 -1
  44. package/dist/assets/{index-xOkwbA9z.js → index-BjuUvxKm.js} +1 -1
  45. package/dist/assets/{index-CjcufnQY.js → index-C6Zrze8T.js} +1 -1
  46. package/dist/assets/{index-lpyXbMDd.js → index-CG9Rvi6d.js} +1 -1
  47. package/dist/assets/{index-qyF0HH0t.js → index-Cx6vlnNj.js} +1 -1
  48. package/dist/assets/{index-BNGi9a78.js → index-D0hgb0zb.js} +1 -1
  49. package/dist/assets/{index-BNMU0DUr.js → index-D9NtAUH-.js} +1 -1
  50. package/dist/assets/{index-BHTel4x6.js → index-D9hW-VSC.js} +1 -1
  51. package/dist/assets/{index-Cz49agDK.js → index-DccvyKKG.js} +1 -1
  52. package/dist/assets/{index-D42PKeAo.js → index-DdmQcg10.js} +1 -1
  53. package/dist/assets/{index-De4VpPkV.js → index-DgdaooUO.js} +1 -1
  54. package/dist/assets/{index-DPzHTlTo.js → index-DjVyUwTs.js} +1 -1
  55. package/dist/assets/{index-CFOw7tWS.js → index-GPz1OvDX.js} +1 -1
  56. package/dist/assets/{index-DVU7w2C4.js → index-NqZEUKdc.js} +1 -1
  57. package/dist/assets/{index-Cw81Wg3b.js → index-QibxRyXY.js} +1 -1
  58. package/dist/assets/{index-CFrclniY.js → index-Tfghmwvz.js} +1 -1
  59. package/dist/assets/{index-C3pJ0CeY.js → index-acshDJGW.js} +1 -1
  60. package/dist/assets/{index-DQsGXPYg.js → index-r6BRIiv_.js} +1 -1
  61. package/dist/assets/{index.es-DnF4r6Dk.js → index.es-DO643o1z.js} +1 -1
  62. package/dist/assets/{insert-business-trip-modal-CQv_ZpxL.js → insert-business-trip-modal-CQ2SX9SN.js} +1 -1
  63. package/dist/assets/issue-document-BQ0ogJOO.js +1 -0
  64. package/dist/assets/{list-plus-DsfXaxO5.js → list-plus-BYDB6Bug.js} +1 -1
  65. package/dist/assets/{login-page-DKeixPVN.js → login-page-CSAu4EPx.js} +1 -1
  66. package/dist/assets/{match-document-modal-LhAEyv1y.js → match-document-modal-CcYNlqoN.js} +1 -1
  67. package/dist/assets/{missing-info-charges-DCVKrfEr.js → missing-info-charges-BMG4Sqri.js} +1 -1
  68. package/dist/assets/{modal-YTgF-R03.js → modal-ZC7sNmLW.js} +1 -1
  69. package/dist/assets/{modify-contract-dialog-D7Z8bOws.js → modify-contract-dialog-Cx5gt7hE.js} +1 -1
  70. package/dist/assets/{page-layout-Cs7LzhPs.js → page-layout-CowMhn5y.js} +1 -1
  71. package/dist/assets/{page-not-found-Cs086tZP.js → page-not-found-DUGJ7yMm.js} +1 -1
  72. package/dist/assets/{panel-top-open-DfXV4xoB.js → panel-top-open-DNq_YeJ3.js} +1 -1
  73. package/dist/assets/{pencil-3H1z0dQ2.js → pencil-Bl19crq5.js} +1 -1
  74. package/dist/assets/{report-commentary-row-DNTsFgf_.js → report-commentary-row-DQCpV1AP.js} +1 -1
  75. package/dist/assets/{save-D2KnX2aJ.js → save-BKXGqFkY.js} +1 -1
  76. package/dist/assets/{similar-transactions-modal-DN6pAqBR.js → similar-transactions-modal-DTnZQkpm.js} +1 -1
  77. package/dist/assets/{sub-UiWBdxTZ.js → sub-BqAPBfvE.js} +1 -1
  78. package/dist/assets/subMonths-Cpq9u0d9.js +1 -0
  79. package/dist/assets/{summary-DLRjO19t.js → summary-dKO6hc4g.js} +1 -1
  80. package/dist/assets/{toggle-expansion-button-ByfnT_sn.js → toggle-expansion-button-C91T0tTd.js} +1 -1
  81. package/dist/assets/tooltip-h3zSyeCb.js +1 -0
  82. package/dist/assets/{use-url-query-DMunwqS4.js → use-url-query-Bdqm6AUY.js} +1 -1
  83. package/dist/index.html +1 -1
  84. package/package.json +1 -1
  85. package/src/components/business/admin/financial-account-section.tsx +2 -0
  86. package/src/components/financial-accounts/financial-account-card.tsx +4 -0
  87. package/src/components/financial-accounts/modify-financial-account-dialog.tsx +19 -0
  88. package/src/components/financial-accounts/types.ts +1 -0
  89. package/src/gql/gql.ts +3 -3
  90. package/src/gql/graphql.ts +5 -2
  91. package/dist/assets/charge-ChPubJah.js +0 -1
  92. package/dist/assets/issue-document-DJMGPj2s.js +0 -1
  93. package/dist/assets/subMonths-DZvdAXT7.js +0 -1
  94. package/dist/assets/tooltip-0-bix6mQ.js +0 -1
@@ -1 +1 @@
1
- import{g as v,i0 as L,r as u,t as m,i as F,a$ as B,j as e,Y as C,Z as j,_ as f,$ as p,I as H,a0 as y,a1 as b,bz as V,bC as _,b3 as z,at as K,D,aU as E,B as h,x as M,al as R,am as A,y as $,V as O,i1 as G,ah as Q,u as P,i2 as Y,L as k,F as Z,bU as J,bK as W,bL as X,bM as T,bN as ee,b_ as S,bO as se,bP as w,i3 as te,c1 as ae,c0 as re,c2 as oe}from"./index-CHtpNrAW.js";import{D as ne}from"./data-table-pagination-Bn6-S7wX.js";import{P as ie}from"./page-layout-Cs7LzhPs.js";import{A as N}from"./arrow-up-down-BCKzoFzo.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(L),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function U({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=B();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(H,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(b,{})]})}),e.jsx(V,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(_,{...o,onChange:q=>{o.onChange(Number(q))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(g)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(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]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(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=$({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx(O,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(U,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(G),t=u.useCallback(async a=>{const d="Error updating tax category",r=`${ue}-${a.taxCategoryId}`;m.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return m.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function me({taxCategoryId:s,onAdd:n}){const[t,a]=u.useState(!1);return e.jsxs(D,{open:t,onOpenChange:a,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(Q,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(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}]=P({query:Y,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=$({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx(O,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(U,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=P({query:te}),{setFiltersContext:d}=u.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 u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ne,{table:i})})}))},[d,i,l]),u.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
+ import{g as v,i0 as L,r as u,t as m,i as F,a$ as B,j as e,Y as C,Z as j,_ as f,$ as p,I as H,a0 as y,a1 as b,bz as V,bC as _,b3 as z,at as K,D,aU as E,B as h,x as M,al as R,am as A,y as $,V as O,i1 as G,ah as Q,u as P,i2 as Y,L as k,F as Z,bU as J,bK as W,bL as X,bM as T,bN as ee,b_ as S,bO as se,bP as w,i3 as te,c1 as ae,c0 as re,c2 as oe}from"./index-3R_zL83W.js";import{D as ne}from"./data-table-pagination-BQNSZ2L6.js";import{P as ie}from"./page-layout-CowMhn5y.js";import{A as N}from"./arrow-up-down-BL4JClUu.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(L),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function U({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=B();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(H,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(b,{})]})}),e.jsx(V,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(_,{...o,onChange:q=>{o.onChange(Number(q))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(g)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(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]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(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=$({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx(O,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(U,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(G),t=u.useCallback(async a=>{const d="Error updating tax category",r=`${ue}-${a.taxCategoryId}`;m.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return m.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function me({taxCategoryId:s,onAdd:n}){const[t,a]=u.useState(!1);return e.jsxs(D,{open:t,onOpenChange:a,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(Q,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(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}]=P({query:Y,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=$({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx(O,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(U,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=P({query:te}),{setFiltersContext:d}=u.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 u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ne,{table:i})})}))},[d,i,l]),u.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,4 +1,4 @@
1
- import{r as h,bw as D,j as e,bx as N,B as y,y as $,by as k,aC as R,V as O,bz as f,bA as S,bB as C,w as F,Y as A,Z as E,_ as z,$ as P,at as M,bD as L,bq as w,T as B,aK as j,ay as p,G as V,dD as _,d3 as v,F as G,u as q,dE as U,bX as Z,L as H,dF as J}from"./index-CHtpNrAW.js";import{u as I}from"./use-url-query-DMunwqS4.js";import{P as K}from"./page-layout-Cs7LzhPs.js";import{P as Q}from"./modal-YTgF-R03.js";import{F as X}from"./funnel-4UXATjU3.js";import{M as T}from"./MultiSelect-DY08OexD.js";import{D as W}from"./download-csv-button-BsXK9P76.js";import{B as Y}from"./business-extended-info-NwMS1Rj6.js";import{P as ee,a as te}from"./panel-top-open-DfXV4xoB.js";import{T as se}from"./Table-bhKB4PFK.js";import"./data-table-column-header-CT7O7uRT.js";import"./eye-off-Cc-ssiRk.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(A,{name:"isShowZeroedAccounts",control:a,render:({field:l})=>e.jsxs(E,{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(Q,{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(X,{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(W,{createFileVariables:n})},oe=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
1
+ import{r as h,bw as D,j as e,bx as N,B as y,y as $,by as k,aC as R,V as O,bz as f,bA as S,bB as C,w as F,Y as A,Z as E,_ as z,$ as P,at as M,bD as L,bq as w,T as B,aK as j,ay as p,G as V,dD as _,d3 as v,F as G,u as q,dE as U,bX as Z,L as H,dF as J}from"./index-3R_zL83W.js";import{u as I}from"./use-url-query-Bdqm6AUY.js";import{P as K}from"./page-layout-CowMhn5y.js";import{P as Q}from"./modal-ZC7sNmLW.js";import{F as X}from"./funnel-DyklXeNl.js";import{M as T}from"./MultiSelect-mJTNaBvj.js";import{D as W}from"./download-csv-button-DDfbg2Ju.js";import{B as Y}from"./business-extended-info-BzvYZDrX.js";import{P as ee,a as te}from"./panel-top-open-DNq_YeJ3.js";import{T as se}from"./Table-BD-Y5pOR.js";import"./data-table-column-header-C23SEs2k.js";import"./eye-off-B09TfzwY.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(A,{name:"isShowZeroedAccounts",control:a,render:({field:l})=>e.jsxs(E,{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(Q,{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(X,{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(W,{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
@@ -1 +1 @@
1
- import{r as b,by as z,j as e,D as G,aU as W,B as g,x as _,al as J,am as Q,a2 as T,b1 as K,aJ as R,ao as A,ap as O,aq as k,ar as E,as as D,d3 as X,G as j,bm as w,go as I,gp as Z,gq as S,gr as ee,gs as M,gt as L,gu as B,gv as N,gw as p,gx as P,gy as q,dA as se,gm as re,bh as te,bi as ae,bj as v,gz as V,F as le,u as de,J as ne,K as oe,W as ce,gA as ie}from"./index-CHtpNrAW.js";import{F as Y}from"./funnel-4UXATjU3.js";import{B as me}from"./building-2-Cp2Es1mt.js";import{E as ue}from"./eye-off-Cc-ssiRk.js";import{S as xe}from"./save-D2KnX2aJ.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}=z(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(G,{open:n,onOpenChange:r,children:[e.jsx(W,{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(_,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(J,{children:e.jsxs(Q,{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(T,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(K,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(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(D,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(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(D,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(D,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const 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 M.Shekels:return"שקלים";case M.Dollars:return"דולרים";default:return""}},Se=t=>{switch(t){case L.DoubleEntry:return"כפולה";case L.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""}},Te=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 De({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:Te(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(De,{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(Me,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Me({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,by as z,j as e,D as G,aU as W,B as g,x as _,al as J,am as Q,a2 as T,b1 as K,aJ as R,ao as A,ap as O,aq as k,ar as E,as as D,d3 as X,G as j,bm as w,go as I,gp as Z,gq as S,gr as ee,gs as M,gt as L,gu as B,gv as N,gw as p,gx as P,gy as q,dA as se,gm as re,bh as te,bi as ae,bj as v,gz as V,F as le,u as de,J as ne,K as oe,W as ce,gA as ie}from"./index-3R_zL83W.js";import{F as Y}from"./funnel-DyklXeNl.js";import{B as me}from"./building-2-Bg-rF-On.js";import{E as ue}from"./eye-off-B09TfzwY.js";import{S as xe}from"./save-BKXGqFkY.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}=z(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(G,{open:n,onOpenChange:r,children:[e.jsx(W,{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(_,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(J,{children:e.jsxs(Q,{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(T,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(K,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(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(D,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(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(D,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(D,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const 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 M.Shekels:return"שקלים";case M.Dollars:return"דולרים";default:return""}},Se=t=>{switch(t){case L.DoubleEntry:return"כפולה";case L.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""}},Te=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 De({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:Te(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(De,{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(Me,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Me({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,4 +1,4 @@
1
- import{v as it,r as m,dd as Nc,aF as V,dh as kc,aG as ae,j as v,dg as vn,dG as It,dH as ge,dI as Ho,di as Lc,dJ as Vc,dK as nn,dL as jc,bw as Fi,D as _r,aU as zr,bx as Fc,B as ee,x as $r,al as Ur,am as Hr,y as Wo,by as Bc,aC as _c,bz as An,bA as Bi,bB as _i,w as rn,at as Go,a2 as Ko,bD as zc,g as qo,dM as $c,t as Pe,i as Yo,u as rr,dN as Uc,bU as Hc,b$ as Wc,c1 as Gc,c0 as Kc,c2 as qc,L as Xo,I as Wr,bK as Yc,bL as Xc,bM as Nn,bN as Zc,b_ as zi,bO as Jc,bP as $i,bV as Zo,bW as Jo,bY as Qo,dO as Qc,dP as eu,dQ as sn,dR as tu,z as nu,a7 as ru,V as iu,Y as su,Z as ou,_ as au,$ as lu,a1 as cu,au as uu,ab as Ui,dS as du,e as hu,a4 as fu,ag as Hi,dT as pu,dU as gu,dV as Wi,cs as mu,ay as vu,F as yu,a$ as bu,dW as Tu,dX as xu}from"./index-CHtpNrAW.js";import{u as ea}from"./use-url-query-DMunwqS4.js";import{T as yn}from"./tooltip-0-bix6mQ.js";import{A as Gi}from"./arrow-up-down-BCKzoFzo.js";import{D as Su}from"./download-csv-button-BsXK9P76.js";import{B as wu}from"./business-extended-info-NwMS1Rj6.js";import{_ as Du,a as bn,s as we,g as Gr,u as Ki,c as Kr,m as wt,d as ir,T as sr}from"./Typography-DclIL89E.js";import{P as Cu}from"./pencil-3H1z0dQ2.js";import{P as Eu,a as Ou}from"./panel-top-open-DfXV4xoB.js";import{F as Pu}from"./funnel-4UXATjU3.js";import{M as Mu}from"./MultiSelect-DY08OexD.js";import"./data-table-column-header-CT7O7uRT.js";import"./eye-off-Cc-ssiRk.js";const Iu=[["path",{d:"m10.852 19.772-.383.924",key:"r7sl7d"}],["path",{d:"m13.148 14.228.383-.923",key:"1d5zpm"}],["path",{d:"M13.148 19.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1ydik7"}],["path",{d:"m13.53 20.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1m1vsf"}],["path",{d:"m14.772 15.852.923-.383",key:"660p6e"}],["path",{d:"m14.772 18.148.923.383",key:"hrcpis"}],["path",{d:"M4.2 15.1a7 7 0 1 1 9.93-9.858A7 7 0 0 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"j2q98n"}],["path",{d:"m9.228 15.852-.923-.383",key:"1p9ong"}],["path",{d:"m9.228 18.148-.923.383",key:"6558rz"}]],Ru=it("cloud-cog",Iu);const Au=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Nu=it("cloud-upload",Au);const ku=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ta=it("ellipsis",ku);const Lu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Vu=it("folder-open",Lu);const ju=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Fu=it("folder-plus",ju);const Bu=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],_u=it("folder",Bu);function Gt(t){const e=m.useRef(t);return Nc(()=>{e.current=t}),m.useRef((...n)=>(0,e.current)(...n)).current}function or(t,e){return or=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},or(t,e)}function zu(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,or(t,e)}const qi=V.createContext(null);function $u(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qr(t,e){var n=function(s){return e&&m.isValidElement(s)?e(s):s},r=Object.create(null);return t&&m.Children.map(t,function(i){return i}).forEach(function(i){r[i.key]=n(i)}),r}function Uu(t,e){t=t||{},e=e||{};function n(u){return u in e?e[u]:t[u]}var r=Object.create(null),i=[];for(var s in t)s in e?i.length&&(r[s]=i,i=[]):i.push(s);var o,a={};for(var l in e){if(r[l])for(o=0;o<r[l].length;o++){var c=r[l][o];a[r[l][o]]=n(c)}a[l]=n(l)}for(o=0;o<i.length;o++)a[i[o]]=n(i[o]);return a}function _e(t,e,n){return n[e]!=null?n[e]:t.props[e]}function Hu(t,e){return qr(t.children,function(n){return m.cloneElement(n,{onExited:e.bind(null,n),in:!0,appear:_e(n,"appear",t),enter:_e(n,"enter",t),exit:_e(n,"exit",t)})})}function Wu(t,e,n){var r=qr(t.children),i=Uu(e,r);return Object.keys(i).forEach(function(s){var o=i[s];if(m.isValidElement(o)){var a=s in e,l=s in r,c=e[s],u=m.isValidElement(c)&&!c.props.in;l&&(!a||u)?i[s]=m.cloneElement(o,{onExited:n.bind(null,o),in:!0,exit:_e(o,"exit",t),enter:_e(o,"enter",t)}):!l&&a&&!u?i[s]=m.cloneElement(o,{in:!1}):l&&a&&m.isValidElement(c)&&(i[s]=m.cloneElement(o,{onExited:n.bind(null,o),in:c.props.in,exit:_e(o,"exit",t),enter:_e(o,"enter",t)}))}}),i}var Gu=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},Ku={component:"div",childFactory:function(e){return e}},Yr=(function(t){zu(e,t);function e(r,i){var s;s=t.call(this,r,i)||this;var o=s.handleExited.bind($u(s));return s.state={contextValue:{isMounting:!0},handleExited:o,firstRender:!0},s}var n=e.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},e.getDerivedStateFromProps=function(i,s){var o=s.children,a=s.handleExited,l=s.firstRender;return{children:l?Hu(i,a):Wu(i,o,a),firstRender:!1}},n.handleExited=function(i,s){var o=qr(this.props.children);i.key in o||(i.props.onExited&&i.props.onExited(s),this.mounted&&this.setState(function(a){var l=kc({},a.children);return delete l[i.key],{children:l}}))},n.render=function(){var i=this.props,s=i.component,o=i.childFactory,a=Du(i,["component","childFactory"]),l=this.state.contextValue,c=Gu(this.state.children).map(o);return delete a.appear,delete a.enter,delete a.exit,s===null?V.createElement(qi.Provider,{value:l},c):V.createElement(qi.Provider,{value:l},V.createElement(s,a,c))},e})(V.Component);Yr.propTypes={};Yr.defaultProps=Ku;const Yi={};function na(t,e){const n=m.useRef(Yi);return n.current===Yi&&(n.current=t(e)),n}const qu=[];function Yu(t){m.useEffect(t,qu)}class Xr{static create(){return new Xr}currentId=null;start(e,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=null,n()},e)}clear=()=>{this.currentId!==null&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function Xu(){const t=na(Xr.create).current;return Yu(t.disposeEffect),t}function Xi(t){try{return t.matches(":focus-visible")}catch{}return!1}class on{static create(){return new on}static use(){const e=na(on.create).current,[n,r]=m.useState(!1);return e.shouldMount=n,e.setShouldMount=r,m.useEffect(e.mountEffect,[n]),e}constructor(){this.ref={current:null},this.mounted=null,this.didMount=!1,this.shouldMount=!1,this.setShouldMount=null}mount(){return this.mounted||(this.mounted=Ju(),this.shouldMount=!0,this.setShouldMount(this.shouldMount)),this.mounted}mountEffect=()=>{this.shouldMount&&!this.didMount&&this.ref.current!==null&&(this.didMount=!0,this.mounted.resolve())};start(...e){this.mount().then(()=>this.ref.current?.start(...e))}stop(...e){this.mount().then(()=>this.ref.current?.stop(...e))}pulsate(...e){this.mount().then(()=>this.ref.current?.pulsate(...e))}}function Zu(){return on.use()}function Ju(){let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n}function Qu(t){const{className:e,classes:n,pulsate:r=!1,rippleX:i,rippleY:s,rippleSize:o,in:a,onExited:l,timeout:c}=t,[u,d]=m.useState(!1),h=ae(e,n.ripple,n.rippleVisible,r&&n.ripplePulsate),f={width:o,height:o,top:-(o/2)+s,left:-(o/2)+i},p=ae(n.child,u&&n.childLeaving,r&&n.childPulsate);return!a&&!u&&d(!0),m.useEffect(()=>{if(!a&&l!=null){const g=setTimeout(l,c);return()=>{clearTimeout(g)}}},[l,a,c]),v.jsx("span",{className:h,style:f,children:v.jsx("span",{className:p})})}const le=bn("MuiTouchRipple",["root","ripple","rippleVisible","ripplePulsate","child","childLeaving","childPulsate"]),ar=550,ed=80,td=It`
1
+ import{v as it,r as m,dd as Nc,aF as V,dh as kc,aG as ae,j as v,dg as vn,dG as It,dH as ge,dI as Ho,di as Lc,dJ as Vc,dK as nn,dL as jc,bw as Fi,D as _r,aU as zr,bx as Fc,B as ee,x as $r,al as Ur,am as Hr,y as Wo,by as Bc,aC as _c,bz as An,bA as Bi,bB as _i,w as rn,at as Go,a2 as Ko,bD as zc,g as qo,dM as $c,t as Pe,i as Yo,u as rr,dN as Uc,bU as Hc,b$ as Wc,c1 as Gc,c0 as Kc,c2 as qc,L as Xo,I as Wr,bK as Yc,bL as Xc,bM as Nn,bN as Zc,b_ as zi,bO as Jc,bP as $i,bV as Zo,bW as Jo,bY as Qo,dO as Qc,dP as eu,dQ as sn,dR as tu,z as nu,a7 as ru,V as iu,Y as su,Z as ou,_ as au,$ as lu,a1 as cu,au as uu,ab as Ui,dS as du,e as hu,a4 as fu,ag as Hi,dT as pu,dU as gu,dV as Wi,cs as mu,ay as vu,F as yu,a$ as bu,dW as Tu,dX as xu}from"./index-3R_zL83W.js";import{u as ea}from"./use-url-query-Bdqm6AUY.js";import{T as yn}from"./tooltip-h3zSyeCb.js";import{A as Gi}from"./arrow-up-down-BL4JClUu.js";import{D as Su}from"./download-csv-button-DDfbg2Ju.js";import{B as wu}from"./business-extended-info-BzvYZDrX.js";import{_ as Du,a as bn,s as we,g as Gr,u as Ki,c as Kr,m as wt,d as ir,T as sr}from"./Typography-CdxJ9FGD.js";import{P as Cu}from"./pencil-Bl19crq5.js";import{P as Eu,a as Ou}from"./panel-top-open-DNq_YeJ3.js";import{F as Pu}from"./funnel-DyklXeNl.js";import{M as Mu}from"./MultiSelect-mJTNaBvj.js";import"./data-table-column-header-C23SEs2k.js";import"./eye-off-B09TfzwY.js";const Iu=[["path",{d:"m10.852 19.772-.383.924",key:"r7sl7d"}],["path",{d:"m13.148 14.228.383-.923",key:"1d5zpm"}],["path",{d:"M13.148 19.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1ydik7"}],["path",{d:"m13.53 20.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1m1vsf"}],["path",{d:"m14.772 15.852.923-.383",key:"660p6e"}],["path",{d:"m14.772 18.148.923.383",key:"hrcpis"}],["path",{d:"M4.2 15.1a7 7 0 1 1 9.93-9.858A7 7 0 0 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"j2q98n"}],["path",{d:"m9.228 15.852-.923-.383",key:"1p9ong"}],["path",{d:"m9.228 18.148-.923.383",key:"6558rz"}]],Ru=it("cloud-cog",Iu);const Au=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Nu=it("cloud-upload",Au);const ku=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ta=it("ellipsis",ku);const Lu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Vu=it("folder-open",Lu);const ju=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Fu=it("folder-plus",ju);const Bu=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],_u=it("folder",Bu);function Gt(t){const e=m.useRef(t);return Nc(()=>{e.current=t}),m.useRef((...n)=>(0,e.current)(...n)).current}function or(t,e){return or=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},or(t,e)}function zu(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,or(t,e)}const qi=V.createContext(null);function $u(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qr(t,e){var n=function(s){return e&&m.isValidElement(s)?e(s):s},r=Object.create(null);return t&&m.Children.map(t,function(i){return i}).forEach(function(i){r[i.key]=n(i)}),r}function Uu(t,e){t=t||{},e=e||{};function n(u){return u in e?e[u]:t[u]}var r=Object.create(null),i=[];for(var s in t)s in e?i.length&&(r[s]=i,i=[]):i.push(s);var o,a={};for(var l in e){if(r[l])for(o=0;o<r[l].length;o++){var c=r[l][o];a[r[l][o]]=n(c)}a[l]=n(l)}for(o=0;o<i.length;o++)a[i[o]]=n(i[o]);return a}function _e(t,e,n){return n[e]!=null?n[e]:t.props[e]}function Hu(t,e){return qr(t.children,function(n){return m.cloneElement(n,{onExited:e.bind(null,n),in:!0,appear:_e(n,"appear",t),enter:_e(n,"enter",t),exit:_e(n,"exit",t)})})}function Wu(t,e,n){var r=qr(t.children),i=Uu(e,r);return Object.keys(i).forEach(function(s){var o=i[s];if(m.isValidElement(o)){var a=s in e,l=s in r,c=e[s],u=m.isValidElement(c)&&!c.props.in;l&&(!a||u)?i[s]=m.cloneElement(o,{onExited:n.bind(null,o),in:!0,exit:_e(o,"exit",t),enter:_e(o,"enter",t)}):!l&&a&&!u?i[s]=m.cloneElement(o,{in:!1}):l&&a&&m.isValidElement(c)&&(i[s]=m.cloneElement(o,{onExited:n.bind(null,o),in:c.props.in,exit:_e(o,"exit",t),enter:_e(o,"enter",t)}))}}),i}var Gu=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},Ku={component:"div",childFactory:function(e){return e}},Yr=(function(t){zu(e,t);function e(r,i){var s;s=t.call(this,r,i)||this;var o=s.handleExited.bind($u(s));return s.state={contextValue:{isMounting:!0},handleExited:o,firstRender:!0},s}var n=e.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},e.getDerivedStateFromProps=function(i,s){var o=s.children,a=s.handleExited,l=s.firstRender;return{children:l?Hu(i,a):Wu(i,o,a),firstRender:!1}},n.handleExited=function(i,s){var o=qr(this.props.children);i.key in o||(i.props.onExited&&i.props.onExited(s),this.mounted&&this.setState(function(a){var l=kc({},a.children);return delete l[i.key],{children:l}}))},n.render=function(){var i=this.props,s=i.component,o=i.childFactory,a=Du(i,["component","childFactory"]),l=this.state.contextValue,c=Gu(this.state.children).map(o);return delete a.appear,delete a.enter,delete a.exit,s===null?V.createElement(qi.Provider,{value:l},c):V.createElement(qi.Provider,{value:l},V.createElement(s,a,c))},e})(V.Component);Yr.propTypes={};Yr.defaultProps=Ku;const Yi={};function na(t,e){const n=m.useRef(Yi);return n.current===Yi&&(n.current=t(e)),n}const qu=[];function Yu(t){m.useEffect(t,qu)}class Xr{static create(){return new Xr}currentId=null;start(e,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=null,n()},e)}clear=()=>{this.currentId!==null&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function Xu(){const t=na(Xr.create).current;return Yu(t.disposeEffect),t}function Xi(t){try{return t.matches(":focus-visible")}catch{}return!1}class on{static create(){return new on}static use(){const e=na(on.create).current,[n,r]=m.useState(!1);return e.shouldMount=n,e.setShouldMount=r,m.useEffect(e.mountEffect,[n]),e}constructor(){this.ref={current:null},this.mounted=null,this.didMount=!1,this.shouldMount=!1,this.setShouldMount=null}mount(){return this.mounted||(this.mounted=Ju(),this.shouldMount=!0,this.setShouldMount(this.shouldMount)),this.mounted}mountEffect=()=>{this.shouldMount&&!this.didMount&&this.ref.current!==null&&(this.didMount=!0,this.mounted.resolve())};start(...e){this.mount().then(()=>this.ref.current?.start(...e))}stop(...e){this.mount().then(()=>this.ref.current?.stop(...e))}pulsate(...e){this.mount().then(()=>this.ref.current?.pulsate(...e))}}function Zu(){return on.use()}function Ju(){let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n}function Qu(t){const{className:e,classes:n,pulsate:r=!1,rippleX:i,rippleY:s,rippleSize:o,in:a,onExited:l,timeout:c}=t,[u,d]=m.useState(!1),h=ae(e,n.ripple,n.rippleVisible,r&&n.ripplePulsate),f={width:o,height:o,top:-(o/2)+s,left:-(o/2)+i},p=ae(n.child,u&&n.childLeaving,r&&n.childPulsate);return!a&&!u&&d(!0),m.useEffect(()=>{if(!a&&l!=null){const g=setTimeout(l,c);return()=>{clearTimeout(g)}}},[l,a,c]),v.jsx("span",{className:h,style:f,children:v.jsx("span",{className:p})})}const le=bn("MuiTouchRipple",["root","ripple","rippleVisible","ripplePulsate","child","childLeaving","childPulsate"]),ar=550,ed=80,td=It`
2
2
  0% {
3
3
  transform: scale(0);
4
4
  opacity: 0.1;
@@ -1 +1 @@
1
- import{g as p,hS as N,r as u,t as l,i as f,y,G as b,j as e,V as C,el as $,Y as D,Z as F,_ as w,$ as k,I as j,a1 as E,hT as v,hU as S,a9 as A,l as z,T as L,B as T,ah as M,n as O,hV as P,hW as B,F as q,u as U,hX as _,L as V,cl as G,hY as R}from"./index-CHtpNrAW.js";import{P as Y}from"./page-layout-Cs7LzhPs.js";import{L as Q}from"./list-plus-DsfXaxO5.js";const W="updateTag",X=()=>{const[{fetching:c},r]=p(N),i=u.useCallback(async t=>{const a=`Error updating tag ID [${t.tagId}]`,s=`${W}-${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}},Z=({onDone:c,data:r,close:i})=>{const{updateTag:t,fetching:a}=X(),s=b(S,r),n=y({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=A(o,h);i(),g&&Object.keys(g).length>0&&t({tagId:s.id,fields:g}).then(()=>c?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs($,{cols:3,children:[e.jsx(D,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(F,{children:[e.jsx(w,{children:"Name"}),e.jsx(k,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(E,{})]})}),e.jsx(v,{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"})]})]})})},H=({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,{label:"Edit Tag",children:e.jsx(T,{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(Z,{close:a,onDone:s,data:r})})]})},J="addTag",K=()=>{const[{fetching:c},r]=p(P),i=u.useCallback(async t=>{const a=`Error adding new tag [${t.tagName}]`,s=`${J}-${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]=p(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}},oe=()=>{const{setFiltersContext:c}=u.useContext(q),[r,i]=u.useState(""),[{data:t,fetching:a},s]=U({query:R}),{addTag:n}=K(),{deleteTag:d}=se();u.useEffect(()=>{c(null)},[c]);const m=_(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(H,{data:o}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(G,{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(T,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(Q,{className:"size-5"})})]})]})})};export{oe as TagsManager};
1
+ import{g as p,hS as N,r as u,t as l,i as f,y,G as b,j as e,V as C,el as $,Y as D,Z as F,_ as w,$ as k,I as j,a1 as E,hT as v,hU as S,a9 as A,l as z,T as L,B as T,ah as M,n as O,hV as P,hW as B,F as q,u as U,hX as _,L as V,cl as G,hY as R}from"./index-3R_zL83W.js";import{P as Y}from"./page-layout-CowMhn5y.js";import{L as Q}from"./list-plus-BYDB6Bug.js";const W="updateTag",X=()=>{const[{fetching:c},r]=p(N),i=u.useCallback(async t=>{const a=`Error updating tag ID [${t.tagId}]`,s=`${W}-${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}},Z=({onDone:c,data:r,close:i})=>{const{updateTag:t,fetching:a}=X(),s=b(S,r),n=y({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=A(o,h);i(),g&&Object.keys(g).length>0&&t({tagId:s.id,fields:g}).then(()=>c?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs($,{cols:3,children:[e.jsx(D,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(F,{children:[e.jsx(w,{children:"Name"}),e.jsx(k,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(E,{})]})}),e.jsx(v,{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"})]})]})})},H=({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,{label:"Edit Tag",children:e.jsx(T,{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(Z,{close:a,onDone:s,data:r})})]})},J="addTag",K=()=>{const[{fetching:c},r]=p(P),i=u.useCallback(async t=>{const a=`Error adding new tag [${t.tagName}]`,s=`${J}-${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]=p(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}},oe=()=>{const{setFiltersContext:c}=u.useContext(q),[r,i]=u.useState(""),[{data:t,fetching:a},s]=U({query:R}),{addTag:n}=K(),{deleteTag:d}=se();u.useEffect(()=>{c(null)},[c]);const m=_(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(H,{data:o}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(G,{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(T,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(Q,{className:"size-5"})})]})]})})};export{oe as TagsManager};
@@ -1,2 +1,2 @@
1
- import{dT as S,j as e,ai as w,R as C,ay as d,G as v,gi as R,r as c,bX as j,gj as b,gk as I,J as L,gl as y,u as U,F as k,B as A,gm as $,c as E,gn as T}from"./index-CHtpNrAW.js";import{P}from"./page-layout-Cs7LzhPs.js";import{Y as z}from"./YearPickerInput-DgK0Ih6X.js";const o=(s,a)=>S(a,{minimumFractionDigits:0}).format(s);function O(s){return{id:s.id,chargeId:s.chargeId,date:s.date,description:s.description??"",reference:s.reference??"",amountILS:s.revenueLocal.raw,amountUSD:s.revenueDefaultForeign.raw,originalAmount:s.revenueOriginal.formatted}}const Y=({recordData:s})=>{const a=v(R,s),n=O(a);return e.jsx("div",{className:"p-2 bg-background rounded-lg border border-border/30 text-sm",children:e.jsxs(w,{to:C.CHARGES.DETAIL(n.chargeId),target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-foreground",children:n.reference}),e.jsx("p",{className:"font-medium text-foreground",children:n.description}),e.jsxs("div",{className:"flex gap-4 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.chargeId}),e.jsx("span",{children:n.date})]})]}),e.jsxs("div",{className:"invisible md:visible md:text-right flex-shrink-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:o(n.amountILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(n.amountUSD,d.Usd)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.originalAmount})]}),e.jsx("div",{className:"md:invisible ml-2 text-right",children:e.jsx("p",{className:"text-xs font-medium text-foreground",children:o(n.amountILS,d.Ils)})})]})})};function M(s){return{id:s.id,name:s.name,revenueILS:s.revenueLocal.raw,revenueUSD:s.revenueDefaultForeign.raw,records:s.records.map(a=>({id:a.id,data:a}))}}const B=({clientData:s})=>{const[a,n]=c.useState(!1),h=v(I,s),r=M(h),g=()=>{n(i=>!i)},u=c.useMemo(()=>r.records.slice().sort((i,t)=>i.data.date.localeCompare(t.data.date)),[r.records]);return e.jsxs("div",{children:[e.jsxs("button",{onClick:g,className:"w-full flex items-center justify-between p-2 bg-background rounded-lg border border-border/50 hover:bg-accent/5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[a?e.jsx(j,{className:"size-4 text-muted-foreground flex-shrink-0"}):e.jsx(b,{className:"size-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-foreground text-sm",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.records?.length||0," record",r.records?.length===1?"":"s"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueILS,d.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueUSD,d.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-xs font-medium text-foreground",children:o(r.revenueILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueUSD,d.Usd)})]})]}),a&&u&&e.jsx("div",{className:"mt-3 ml-2 space-y-3 border-l-2 border-border/50 pl-2",children:u.map(i=>e.jsx(Y,{recordData:i.data},i.id))})]})};function G(s){return{code:s.code,name:s.name,revenues:{ILS:s.revenueLocal.raw,USD:s.revenueDefaultForeign.raw},clients:s.clients.map(a=>({id:a.id,data:a}))}}const V=({countryData:s})=>{const[a,n]=c.useState(!1),h=v(y,s),r=G(h),g=()=>{n(t=>!t)},u={ILS:r.revenues.ILS,USD:r.revenues.USD},i=c.useMemo(()=>r.clients.slice().sort((t,f)=>f.data.revenueDefaultForeign.raw-t.data.revenueDefaultForeign.raw),[r.clients]);return e.jsxs(L,{className:"border border-border",children:[e.jsxs("button",{onClick:()=>g(),className:"w-full px-4 py-2 hover:bg-accent/5 transition-colors flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[a?e.jsx(j,{className:"size-5 text-muted-foreground flex-shrink-0"}):e.jsx(b,{className:"size-5 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-lg",children:r.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.clients.length," clients"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.ILS,d.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.USD,d.Usd)})]})]})]}),e.jsxs("div",{className:"md:hidden px-2 py-2 bg-accent/5 border-t border-border flex gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.ILS,d.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.USD,d.Usd)})]})]}),a&&e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-2 p-3 bg-muted/30",children:[i.map(t=>e.jsx(B,{clientData:t.data},t.id)),e.jsx("div",{className:"pt-2 border-t border-border/50 mt-4",children:e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Clients Subtotal"}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right",children:[e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:o(u.ILS,d.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:o(u.USD,d.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:o(u.ILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(u.USD,d.Usd)})]})]})})]})})]},r.code)},Q=()=>{const[s,a]=c.useState(new Date().getFullYear()-1),[{data:n,fetching:h}]=U({query:T,variables:{filters:{year:s}}}),r=c.useCallback(()=>{const t=[];t.push("Country,Client,charge ID,Date,Description,Revenue ILS,Revenue USD"),n?.annualRevenueReport.countries.sort((x,l)=>l.revenueDefaultForeign.raw-x.revenueDefaultForeign.raw).map(x=>{t.push(`${x.name},,,,TOTAL,${x.revenueLocal.raw.toFixed(2)},${x.revenueDefaultForeign.raw.toFixed(2)}`),x.clients.sort((l,m)=>m.revenueDefaultForeign.raw-l.revenueDefaultForeign.raw).map(l=>{l.records&&l.records.length>0?(t.push(`${x.name},${l.name},,,TOTAL,${l.revenueLocal.raw.toFixed(2)},${l.revenueDefaultForeign.raw.toFixed(2)}`),l.records.sort((m,F)=>m.date.localeCompare(F.date)).map(m=>{t.push(`${x.name},${l.name},${m.chargeId},${m.date},${m.description},${m.revenueLocal.raw.toFixed(2)},${m.revenueDefaultForeign.raw.toFixed(2)}`)})):t.push(`${x.name},${l.name},,,,,`)})});const f=t.join(`
1
+ import{dT as S,j as e,ai as w,R as C,ay as d,G as v,gi as R,r as c,bX as j,gj as b,gk as I,J as L,gl as y,u as U,F as k,B as A,gm as $,c as E,gn as T}from"./index-3R_zL83W.js";import{P}from"./page-layout-CowMhn5y.js";import{Y as z}from"./YearPickerInput-Bka3kNAU.js";const o=(s,a)=>S(a,{minimumFractionDigits:0}).format(s);function O(s){return{id:s.id,chargeId:s.chargeId,date:s.date,description:s.description??"",reference:s.reference??"",amountILS:s.revenueLocal.raw,amountUSD:s.revenueDefaultForeign.raw,originalAmount:s.revenueOriginal.formatted}}const Y=({recordData:s})=>{const a=v(R,s),n=O(a);return e.jsx("div",{className:"p-2 bg-background rounded-lg border border-border/30 text-sm",children:e.jsxs(w,{to:C.CHARGES.DETAIL(n.chargeId),target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-foreground",children:n.reference}),e.jsx("p",{className:"font-medium text-foreground",children:n.description}),e.jsxs("div",{className:"flex gap-4 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.chargeId}),e.jsx("span",{children:n.date})]})]}),e.jsxs("div",{className:"invisible md:visible md:text-right flex-shrink-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:o(n.amountILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(n.amountUSD,d.Usd)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.originalAmount})]}),e.jsx("div",{className:"md:invisible ml-2 text-right",children:e.jsx("p",{className:"text-xs font-medium text-foreground",children:o(n.amountILS,d.Ils)})})]})})};function M(s){return{id:s.id,name:s.name,revenueILS:s.revenueLocal.raw,revenueUSD:s.revenueDefaultForeign.raw,records:s.records.map(a=>({id:a.id,data:a}))}}const B=({clientData:s})=>{const[a,n]=c.useState(!1),h=v(I,s),r=M(h),g=()=>{n(i=>!i)},u=c.useMemo(()=>r.records.slice().sort((i,t)=>i.data.date.localeCompare(t.data.date)),[r.records]);return e.jsxs("div",{children:[e.jsxs("button",{onClick:g,className:"w-full flex items-center justify-between p-2 bg-background rounded-lg border border-border/50 hover:bg-accent/5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[a?e.jsx(j,{className:"size-4 text-muted-foreground flex-shrink-0"}):e.jsx(b,{className:"size-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-foreground text-sm",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.records?.length||0," record",r.records?.length===1?"":"s"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueILS,d.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueUSD,d.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-xs font-medium text-foreground",children:o(r.revenueILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueUSD,d.Usd)})]})]}),a&&u&&e.jsx("div",{className:"mt-3 ml-2 space-y-3 border-l-2 border-border/50 pl-2",children:u.map(i=>e.jsx(Y,{recordData:i.data},i.id))})]})};function G(s){return{code:s.code,name:s.name,revenues:{ILS:s.revenueLocal.raw,USD:s.revenueDefaultForeign.raw},clients:s.clients.map(a=>({id:a.id,data:a}))}}const V=({countryData:s})=>{const[a,n]=c.useState(!1),h=v(y,s),r=G(h),g=()=>{n(t=>!t)},u={ILS:r.revenues.ILS,USD:r.revenues.USD},i=c.useMemo(()=>r.clients.slice().sort((t,f)=>f.data.revenueDefaultForeign.raw-t.data.revenueDefaultForeign.raw),[r.clients]);return e.jsxs(L,{className:"border border-border",children:[e.jsxs("button",{onClick:()=>g(),className:"w-full px-4 py-2 hover:bg-accent/5 transition-colors flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[a?e.jsx(j,{className:"size-5 text-muted-foreground flex-shrink-0"}):e.jsx(b,{className:"size-5 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-lg",children:r.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.clients.length," clients"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.ILS,d.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.USD,d.Usd)})]})]})]}),e.jsxs("div",{className:"md:hidden px-2 py-2 bg-accent/5 border-t border-border flex gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.ILS,d.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.USD,d.Usd)})]})]}),a&&e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-2 p-3 bg-muted/30",children:[i.map(t=>e.jsx(B,{clientData:t.data},t.id)),e.jsx("div",{className:"pt-2 border-t border-border/50 mt-4",children:e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Clients Subtotal"}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right",children:[e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:o(u.ILS,d.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:o(u.USD,d.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:o(u.ILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(u.USD,d.Usd)})]})]})})]})})]},r.code)},Q=()=>{const[s,a]=c.useState(new Date().getFullYear()-1),[{data:n,fetching:h}]=U({query:T,variables:{filters:{year:s}}}),r=c.useCallback(()=>{const t=[];t.push("Country,Client,charge ID,Date,Description,Revenue ILS,Revenue USD"),n?.annualRevenueReport.countries.sort((x,l)=>l.revenueDefaultForeign.raw-x.revenueDefaultForeign.raw).map(x=>{t.push(`${x.name},,,,TOTAL,${x.revenueLocal.raw.toFixed(2)},${x.revenueDefaultForeign.raw.toFixed(2)}`),x.clients.sort((l,m)=>m.revenueDefaultForeign.raw-l.revenueDefaultForeign.raw).map(l=>{l.records&&l.records.length>0?(t.push(`${x.name},${l.name},,,TOTAL,${l.revenueLocal.raw.toFixed(2)},${l.revenueDefaultForeign.raw.toFixed(2)}`),l.records.sort((m,F)=>m.date.localeCompare(F.date)).map(m=>{t.push(`${x.name},${l.name},${m.chargeId},${m.date},${m.description},${m.revenueLocal.raw.toFixed(2)},${m.revenueDefaultForeign.raw.toFixed(2)}`)})):t.push(`${x.name},${l.name},,,,,`)})});const f=t.join(`
2
2
  `),N=new Blob([f],{type:"text/csv;charset=utf-8;"}),p=document.createElement("a"),D=URL.createObjectURL(N);p.setAttribute("href",D),p.setAttribute("download",`annual-revenue-${s}.csv`),p.style.visibility="hidden",document.body.appendChild(p),p.click(),document.body.removeChild(p)},[n,s]),{setFiltersContext:g}=c.useContext(k);c.useEffect(()=>{g(e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(z,{value:new Date(s,0,1),onChange:t=>t&&a(t?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsxs(A,{onClick:r,variant:"outline",size:"sm",className:"flex items-center gap-2 bg-transparent",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Export CSV"})]})]}))},[s,h,g,r]);const u=c.useMemo(()=>`Annual Revenue Report for ${s}`,[s]),i=c.useMemo(()=>n?.annualRevenueReport.countries.slice().sort((t,f)=>f.revenueDefaultForeign.raw-t.revenueDefaultForeign.raw),[n]);return e.jsx(P,{title:"Annual Revenue Report",description:u,children:h?e.jsx(E,{}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("main",{className:"container mx-auto px-2 py-2 max-w-7xl",children:e.jsx("div",{className:"space-y-2",children:i?.map(t=>e.jsx(V,{countryData:t},t.id))})})})})};export{Q as AnnualRevenueReport};
@@ -1 +1 @@
1
- import{u as x,ca as h,G as T,r,j as s,bx as g,cb as j,F as B,T as w,at as C,L as v,a3 as E,cc as P}from"./index-CHtpNrAW.js";import{E as b,P as y,C as L}from"./editable-business-trip-CH61WHL7.js";import{I as F}from"./insert-business-trip-modal-CQv_ZpxL.js";import{P as I}from"./page-layout-Cs7LzhPs.js";import{A as m}from"./summary-DLRjO19t.js";import"./list-plus-DsfXaxO5.js";import"./Table-bhKB4PFK.js";import"./toggle-expansion-button-ByfnT_sn.js";import"./panel-top-open-DfXV4xoB.js";import"./MultiSelect-DY08OexD.js";import"./similar-transactions-modal-DN6pAqBR.js";import"./tooltip-0-bix6mQ.js";const S=({data:d,isOpened:o,shouldValidate:l})=>{const e=T(j,d),[{data:i,fetching:a}]=x({pause:!l,query:h,variables:{id:e.id}}),c=r.useMemo(()=>l?i?.businessTrip&&(i.businessTrip.uncategorizedTransactions?.length||i?.businessTrip.summary?.errors?.length):!1,[i]),u=c||e?.accountantApproval!=="APPROVED";return s.jsxs(m.Item,{value:e.id,children:[s.jsx(m.Control,{children:s.jsx(g,{inline:!0,size:12,processing:a,disabled:!u,color:c?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(m.Panel,{children:o&&s.jsx(b,{tripId:e.id,isExtended:!0},e.id)})]})},U=()=>{const{setFiltersContext:d}=r.useContext(B),[o,l]=r.useState([]),[e,i]=r.useState(!1),[{data:a,fetching:c}]=x({query:P});r.useEffect(()=>{if(!a?.allBusinessTrips?.length){l([]);return}const t=a.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[a?.allBusinessTrips]);const[u,f]=r.useState([]);return r.useEffect(()=>{d(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(F,{}),s.jsx(w,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(C,{checked:e??!1,onCheckedChange:t=>i(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(y,{filename:"business_trips"})]}))},[a,c,d,e]),s.jsx(I,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&c?s.jsx(v,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(L,{children:s.jsx(m,{className:"w-full",multiple:!0,value:u,onChange:f,chevron:s.jsx(E,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:u.includes(t.id)},t.id))})})})};export{U as BusinessTrips};
1
+ import{u as x,ca as h,G as T,r,j as s,bx as g,cb as j,F as B,T as w,at as C,L as v,a3 as E,cc as P}from"./index-3R_zL83W.js";import{E as b,P as y,C as L}from"./editable-business-trip-DlCsUKF5.js";import{I as F}from"./insert-business-trip-modal-CQ2SX9SN.js";import{P as I}from"./page-layout-CowMhn5y.js";import{A as m}from"./summary-dKO6hc4g.js";import"./list-plus-BYDB6Bug.js";import"./Table-BD-Y5pOR.js";import"./toggle-expansion-button-C91T0tTd.js";import"./panel-top-open-DNq_YeJ3.js";import"./MultiSelect-mJTNaBvj.js";import"./similar-transactions-modal-DTnZQkpm.js";import"./tooltip-h3zSyeCb.js";const S=({data:d,isOpened:o,shouldValidate:l})=>{const e=T(j,d),[{data:i,fetching:a}]=x({pause:!l,query:h,variables:{id:e.id}}),c=r.useMemo(()=>l?i?.businessTrip&&(i.businessTrip.uncategorizedTransactions?.length||i?.businessTrip.summary?.errors?.length):!1,[i]),u=c||e?.accountantApproval!=="APPROVED";return s.jsxs(m.Item,{value:e.id,children:[s.jsx(m.Control,{children:s.jsx(g,{inline:!0,size:12,processing:a,disabled:!u,color:c?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(m.Panel,{children:o&&s.jsx(b,{tripId:e.id,isExtended:!0},e.id)})]})},U=()=>{const{setFiltersContext:d}=r.useContext(B),[o,l]=r.useState([]),[e,i]=r.useState(!1),[{data:a,fetching:c}]=x({query:P});r.useEffect(()=>{if(!a?.allBusinessTrips?.length){l([]);return}const t=a.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[a?.allBusinessTrips]);const[u,f]=r.useState([]);return r.useEffect(()=>{d(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(F,{}),s.jsx(w,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(C,{checked:e??!1,onCheckedChange:t=>i(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(y,{filename:"business_trips"})]}))},[a,c,d,e]),s.jsx(I,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&c?s.jsx(v,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(L,{children:s.jsx(m,{className:"w-full",multiple:!0,value:u,onChange:f,chevron:s.jsx(E,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:u.includes(t.id)},t.id))})})})};export{U as BusinessTrips};
@@ -1 +1 @@
1
- import{g as k,h as M,r as a,t as j,i as A,u as N,k as F,j as e,c as L,l as P,B as S,m as C,n as T,P as z,I as D,F as $,o as O,T as R,L as U,p as q,R as b,q as _,s as Q}from"./index-CHtpNrAW.js";import{u as v}from"./use-url-query-DMunwqS4.js";import{B as V}from"./business-header-D7w2Xzis.js";import{C as H,M as K}from"./Checkbox-BHVKlxRj.js";import{P as G}from"./page-layout-Cs7LzhPs.js";import{P as J,a as W}from"./panel-top-open-DfXV4xoB.js";import"./building-2-Cp2Es1mt.js";const X="mergeBusinesses",Y=()=>{const[{fetching:o},d]=k(M),u=a.useCallback(async c=>{const l=`Error merging into business ID [${c.targetBusinessId}]`,t=`${X}-${c.targetBusinessId}`;j.loading("Merging Businesses",{id:t});try{const r=await d(c),s=A(r,l,t);if(s)return j.success("Success",{id:t,description:"Businesses merged"}),s.mergeBusinesses.id}catch(r){console.error(`${l}: ${r}`),j.error("Error",{id:t,description:l,duration:1e5,closeButton:!0})}},[d]);return{fetching:o,mergeBusinesses:u}};function Z({businessIds:o,onDone:d,resetMerge:u}){const{mergeBusinesses:c,fetching:l}=Y(),t=Array.from(new Set(o)),[{data:r,fetching:s}]=N({query:F,variables:{businessIds:t}}),[m,p]=a.useState(r?.businesses[0]),n=r?.businesses.length!==t.length&&"Some businesses were not Found"||void 0,g=r?.businesses||[],f=a.useCallback(async()=>{if(!m){j.error("Error",{description:"No main business selected"});return}if(t.length<2){j.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await c({targetBusinessId:m.id,businessIdsToMerge:t.filter(x=>x!==m.id)}),u(),d()},[m,t,c,d,u]);return e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx(L,{})}),!s&&n&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:n})}),!s&&!n&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),g.map(x=>e.jsx("td",{children:e.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:e.jsx(H,{checked:x.id===m?.id,size:"xl",onClick:()=>{p(x)}})})},x.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),g.map(x=>e.jsx("td",{children:x.name},x.id))]})]}),e.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[e.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:s||l,onClick:f,children:"Accept"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{u(),d()},children:"Reset Merge"})]})]})]})}function ee(o){const[d,{close:u,open:c}]=P(!1),{selected:l,resetMerge:t}=o,r=new Set(l.map(({id:g})=>g)),s=r.size>=1,[m,p]=a.useState(s?"default":"outline");a.useEffect(()=>{p(s?"default":"outline")},[s]);const n=a.useCallback(()=>{u(),l.map(({onChange:g})=>g())},[l,u]);return e.jsxs(e.Fragment,{children:[e.jsx(S,{onClick:()=>{s&&c()},disabled:!s,variant:m,className:C("size-7.5",s?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(K,{className:"size-5"})}),e.jsx(T,{opened:d,onClose:u,size:"auto",centered:!0,children:e.jsx(Z,{businessIds:Array.from(r),onDone:n,resetMerge:t})})]})}function se({activePage:o,setPage:d,totalPages:u=1,businessName:c,setBusinessName:l}){const{get:t,set:r}=v(),[s,m]=a.useState(c);a.useEffect(()=>{const n=o>0?o.toFixed(0):void 0,g=t("page");n!==g&&n!=="0"&&r("page",n)},[o,t,r]),a.useEffect(()=>{const n=setTimeout(()=>{l(s)},600);return()=>{clearTimeout(n)}},[s,l]);const p=n=>{m(n)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(z,{className:"flex-fit w-fit mx-0",currentPageIndex:o,onChange:d,totalPages:u}),e.jsx(D,{className:"w-72",placeholder:"Business Name",defaultValue:c??void 0,onChange:n=>p(n.target.value===""?void 0:n.target.value)})]})}const le=()=>{const{get:o}=v(),[d,u]=a.useState(!1),[c,l]=a.useState(o("page")?Number(o("page")):0),[t,r]=a.useState(o("name")?o("name"):void 0),{setFiltersContext:s}=a.useContext($),[{data:m,fetching:p},n]=N({query:Q,variables:{page:c,limit:100,name:t}}),g=O(),[f,x]=a.useState([]),y=a.useCallback((i,h)=>{f.map(B=>B.id).includes(i)?x(f.filter(B=>B.id!==i)):x([...f,{id:i,onChange:h}])},[f]);function I(){x([])}a.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(se,{activePage:c,setPage:l,businessName:t,setBusinessName:r,totalPages:m?.allBusinesses?.pageInfo.totalPages}),e.jsx(R,{label:"Expand all businesses",children:e.jsx(S,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>u(i=>!i),children:d?e.jsx(J,{className:"size-5"}):e.jsx(W,{className:"size-5"})})}),e.jsx(ee,{selected:f,resetMerge:I})]}))},[m,c,t,d,s,l,r,u,f]);const E=m?.allBusinesses?.nodes.filter(i=>i.__typename==="LtdFinancialEntity").sort((i,h)=>i.name.toLowerCase()>h.name.toLowerCase()?1:-1)??[],w=new Set(f.map(i=>i.id));return e.jsx(G,{title:`Businesses (${m?.allBusinesses?.pageInfo.totalRecords??""})`,description:"All businesses",headerActions:e.jsx("div",{className:"flex items-center py-4 gap-4",children:e.jsx(_,{description:"",onAdd:()=>n()})}),children:p?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(U,{className:C("h-10 w-10 animate-spin mr-2")})}):e.jsx("div",{className:"space-y-2",children:E.map(i=>e.jsx("div",{className:"group relative border rounded-lg hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"pl-4 flex items-center",children:e.jsx(q,{checked:w.has(i.id),onCheckedChange:()=>{y(i.id,()=>{})},className:"h-4 w-4 rounded border-gray-300 cursor-pointer",onClick:h=>h.stopPropagation()})}),e.jsx("div",{role:"button",tabIndex:0,className:"flex-1 cursor-pointer",onClick:()=>{g(b.BUSINESSES.DETAIL(i.id),{state:{from:b.BUSINESSES.ALL}})},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),g(b.BUSINESSES.DETAIL(i.id),{state:{from:b.BUSINESSES.ALL}}))},children:e.jsx(V,{data:i})})]})},i.id))})})};export{le as Businesses};
1
+ import{g as k,h as M,r as a,t as j,i as A,u as N,k as F,j as e,c as L,l as P,B as S,m as C,n as T,P as z,I as D,F as $,o as O,T as R,L as U,p as q,R as b,q as _,s as Q}from"./index-3R_zL83W.js";import{u as v}from"./use-url-query-Bdqm6AUY.js";import{B as V}from"./business-header-D4uSFuTz.js";import{C as H,M as K}from"./Checkbox-DUyxts6I.js";import{P as G}from"./page-layout-CowMhn5y.js";import{P as J,a as W}from"./panel-top-open-DNq_YeJ3.js";import"./building-2-Bg-rF-On.js";const X="mergeBusinesses",Y=()=>{const[{fetching:o},d]=k(M),u=a.useCallback(async c=>{const l=`Error merging into business ID [${c.targetBusinessId}]`,t=`${X}-${c.targetBusinessId}`;j.loading("Merging Businesses",{id:t});try{const r=await d(c),s=A(r,l,t);if(s)return j.success("Success",{id:t,description:"Businesses merged"}),s.mergeBusinesses.id}catch(r){console.error(`${l}: ${r}`),j.error("Error",{id:t,description:l,duration:1e5,closeButton:!0})}},[d]);return{fetching:o,mergeBusinesses:u}};function Z({businessIds:o,onDone:d,resetMerge:u}){const{mergeBusinesses:c,fetching:l}=Y(),t=Array.from(new Set(o)),[{data:r,fetching:s}]=N({query:F,variables:{businessIds:t}}),[m,p]=a.useState(r?.businesses[0]),n=r?.businesses.length!==t.length&&"Some businesses were not Found"||void 0,g=r?.businesses||[],f=a.useCallback(async()=>{if(!m){j.error("Error",{description:"No main business selected"});return}if(t.length<2){j.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await c({targetBusinessId:m.id,businessIdsToMerge:t.filter(x=>x!==m.id)}),u(),d()},[m,t,c,d,u]);return e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx(L,{})}),!s&&n&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:n})}),!s&&!n&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),g.map(x=>e.jsx("td",{children:e.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:e.jsx(H,{checked:x.id===m?.id,size:"xl",onClick:()=>{p(x)}})})},x.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),g.map(x=>e.jsx("td",{children:x.name},x.id))]})]}),e.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[e.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:s||l,onClick:f,children:"Accept"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{u(),d()},children:"Reset Merge"})]})]})]})}function ee(o){const[d,{close:u,open:c}]=P(!1),{selected:l,resetMerge:t}=o,r=new Set(l.map(({id:g})=>g)),s=r.size>=1,[m,p]=a.useState(s?"default":"outline");a.useEffect(()=>{p(s?"default":"outline")},[s]);const n=a.useCallback(()=>{u(),l.map(({onChange:g})=>g())},[l,u]);return e.jsxs(e.Fragment,{children:[e.jsx(S,{onClick:()=>{s&&c()},disabled:!s,variant:m,className:C("size-7.5",s?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(K,{className:"size-5"})}),e.jsx(T,{opened:d,onClose:u,size:"auto",centered:!0,children:e.jsx(Z,{businessIds:Array.from(r),onDone:n,resetMerge:t})})]})}function se({activePage:o,setPage:d,totalPages:u=1,businessName:c,setBusinessName:l}){const{get:t,set:r}=v(),[s,m]=a.useState(c);a.useEffect(()=>{const n=o>0?o.toFixed(0):void 0,g=t("page");n!==g&&n!=="0"&&r("page",n)},[o,t,r]),a.useEffect(()=>{const n=setTimeout(()=>{l(s)},600);return()=>{clearTimeout(n)}},[s,l]);const p=n=>{m(n)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(z,{className:"flex-fit w-fit mx-0",currentPageIndex:o,onChange:d,totalPages:u}),e.jsx(D,{className:"w-72",placeholder:"Business Name",defaultValue:c??void 0,onChange:n=>p(n.target.value===""?void 0:n.target.value)})]})}const le=()=>{const{get:o}=v(),[d,u]=a.useState(!1),[c,l]=a.useState(o("page")?Number(o("page")):0),[t,r]=a.useState(o("name")?o("name"):void 0),{setFiltersContext:s}=a.useContext($),[{data:m,fetching:p},n]=N({query:Q,variables:{page:c,limit:100,name:t}}),g=O(),[f,x]=a.useState([]),y=a.useCallback((i,h)=>{f.map(B=>B.id).includes(i)?x(f.filter(B=>B.id!==i)):x([...f,{id:i,onChange:h}])},[f]);function I(){x([])}a.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(se,{activePage:c,setPage:l,businessName:t,setBusinessName:r,totalPages:m?.allBusinesses?.pageInfo.totalPages}),e.jsx(R,{label:"Expand all businesses",children:e.jsx(S,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>u(i=>!i),children:d?e.jsx(J,{className:"size-5"}):e.jsx(W,{className:"size-5"})})}),e.jsx(ee,{selected:f,resetMerge:I})]}))},[m,c,t,d,s,l,r,u,f]);const E=m?.allBusinesses?.nodes.filter(i=>i.__typename==="LtdFinancialEntity").sort((i,h)=>i.name.toLowerCase()>h.name.toLowerCase()?1:-1)??[],w=new Set(f.map(i=>i.id));return e.jsx(G,{title:`Businesses (${m?.allBusinesses?.pageInfo.totalRecords??""})`,description:"All businesses",headerActions:e.jsx("div",{className:"flex items-center py-4 gap-4",children:e.jsx(_,{description:"",onAdd:()=>n()})}),children:p?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(U,{className:C("h-10 w-10 animate-spin mr-2")})}):e.jsx("div",{className:"space-y-2",children:E.map(i=>e.jsx("div",{className:"group relative border rounded-lg hover:shadow-md transition-shadow",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"pl-4 flex items-center",children:e.jsx(q,{checked:w.has(i.id),onCheckedChange:()=>{y(i.id,()=>{})},className:"h-4 w-4 rounded border-gray-300 cursor-pointer",onClick:h=>h.stopPropagation()})}),e.jsx("div",{role:"button",tabIndex:0,className:"flex-1 cursor-pointer",onClick:()=>{g(b.BUSINESSES.DETAIL(i.id),{state:{from:b.BUSINESSES.ALL}})},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),g(b.BUSINESSES.DETAIL(i.id),{state:{from:b.BUSINESSES.ALL}}))},children:e.jsx(V,{data:i})})]})},i.id))})})};export{le as Businesses};
@@ -1 +1 @@
1
- import{r as m,j as e,B as u,a as y,F as R,u as T,L as D,gd as E}from"./index-CHtpNrAW.js";import{d as b}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as w}from"./page-layout-Cs7LzhPs.js";import{R as d}from"./report-commentary-row-DNTsFgf_.js";import{P as F}from"./modal-YTgF-R03.js";import{Y as f}from"./YearPickerInput-DgK0Ih6X.js";import{F as g}from"./funnel-4UXATjU3.js";import{T as v}from"./Table-bhKB4PFK.js";import"./toggle-expansion-button-ByfnT_sn.js";import"./panel-top-open-DfXV4xoB.js";function B({year:i,setYear:h,referenceYears:x,setReferenceYears:j}){const[l,c]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(F,{opened:l,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Change report year",value:new Date(i,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(f,{type:"multiple",label:"Pick reference years",value:x?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(o=>o.getFullYear()).filter(o=>i!==o)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(g,{className:"size-5"})})]})}const G=()=>{const{year:i}=y(),{setFiltersContext:h}=m.useContext(R),[x,j]=m.useState(i?Number(i):new Date().getFullYear()),[l,c]=m.useState([]),[{data:n,fetching:o}]=T({query:b(E),variables:{reportYear:x,referenceYears:l}});m.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(B,{year:x,setYear:j,referenceYears:l,setReferenceYears:c})}))},[x,o,h,l,c]);const p=n?.taxReport,s=p?.report,r=p?.reference??[];return e.jsx(w,{title:"Tax Report",children:o?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:s&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:x},x),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:s.profitBeforeTax.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("th",{children:a.profitBeforeTax.amount.formatted},a.year))]}),commentaryData:s.profitBeforeTax}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses By Records"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesByRecords.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpensesByRecords.amount.formatted},a.year))]}),commentaryData:s.researchAndDevelopmentExpensesByRecords}),e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses For Tax"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesForTax.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.researchAndDevelopmentExpensesForTax.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Fines"}),e.jsx("td",{children:s.fines.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.fines.amount.formatted},a.year))]}),commentaryData:s.fines}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Untaxable Gifts"}),e.jsx("td",{children:s.untaxableGifts.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.untaxableGifts.amount.formatted},a.year))]}),commentaryData:s.untaxableGifts}),e.jsxs("tr",{children:[e.jsx("td",{children:"Business Trips Excess Expenses"}),e.jsx("td",{children:s.businessTripsExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.businessTripsExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Salary Excess Expenses"}),e.jsx("td",{children:s.salaryExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.salaryExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Reserves"}),e.jsx("td",{children:s.reserves.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.reserves.amount.formatted},a.year))]}),commentaryData:s.reserves}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Nontaxable Linkage"}),e.jsx("td",{children:s.nontaxableLinkage.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.nontaxableLinkage.amount.formatted},a.year))]}),commentaryData:s.nontaxableLinkage}),e.jsxs("tr",{children:[e.jsx("th",{children:"Taxable Income"}),e.jsx("th",{children:s.taxableIncome.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.taxableIncome.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax Rate"}),e.jsxs("td",{children:[(s.taxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.taxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Income with Special Tax Rate"}),e.jsx("td",{children:s.specialTaxableIncome.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.specialTaxableIncome.amount.formatted},a.year))]}),commentaryData:s.specialTaxableIncome}),e.jsxs("tr",{children:[e.jsx("td",{children:"Special Tax Rate"}),e.jsxs("td",{children:[(s.specialTaxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.specialTaxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Annual Tax Expense"}),e.jsx("th",{children:s.annualTaxExpense.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.annualTaxExpense.formatted},t.year)),e.jsx("td",{})]})})]})})})};export{G as TaxReport};
1
+ import{r as m,j as e,B as u,a as y,F as R,u as T,L as D,gd as E}from"./index-3R_zL83W.js";import{d as b}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as w}from"./page-layout-CowMhn5y.js";import{R as d}from"./report-commentary-row-DQCpV1AP.js";import{P as F}from"./modal-ZC7sNmLW.js";import{Y as f}from"./YearPickerInput-Bka3kNAU.js";import{F as g}from"./funnel-DyklXeNl.js";import{T as v}from"./Table-BD-Y5pOR.js";import"./toggle-expansion-button-C91T0tTd.js";import"./panel-top-open-DNq_YeJ3.js";function B({year:i,setYear:h,referenceYears:x,setReferenceYears:j}){const[l,c]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(F,{opened:l,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Change report year",value:new Date(i,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(f,{type:"multiple",label:"Pick reference years",value:x?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(o=>o.getFullYear()).filter(o=>i!==o)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(g,{className:"size-5"})})]})}const G=()=>{const{year:i}=y(),{setFiltersContext:h}=m.useContext(R),[x,j]=m.useState(i?Number(i):new Date().getFullYear()),[l,c]=m.useState([]),[{data:n,fetching:o}]=T({query:b(E),variables:{reportYear:x,referenceYears:l}});m.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(B,{year:x,setYear:j,referenceYears:l,setReferenceYears:c})}))},[x,o,h,l,c]);const p=n?.taxReport,s=p?.report,r=p?.reference??[];return e.jsx(w,{title:"Tax Report",children:o?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:s&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:x},x),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:s.profitBeforeTax.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("th",{children:a.profitBeforeTax.amount.formatted},a.year))]}),commentaryData:s.profitBeforeTax}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses By Records"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesByRecords.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpensesByRecords.amount.formatted},a.year))]}),commentaryData:s.researchAndDevelopmentExpensesByRecords}),e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses For Tax"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesForTax.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.researchAndDevelopmentExpensesForTax.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Fines"}),e.jsx("td",{children:s.fines.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.fines.amount.formatted},a.year))]}),commentaryData:s.fines}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Untaxable Gifts"}),e.jsx("td",{children:s.untaxableGifts.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.untaxableGifts.amount.formatted},a.year))]}),commentaryData:s.untaxableGifts}),e.jsxs("tr",{children:[e.jsx("td",{children:"Business Trips Excess Expenses"}),e.jsx("td",{children:s.businessTripsExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.businessTripsExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Salary Excess Expenses"}),e.jsx("td",{children:s.salaryExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.salaryExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Reserves"}),e.jsx("td",{children:s.reserves.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.reserves.amount.formatted},a.year))]}),commentaryData:s.reserves}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Nontaxable Linkage"}),e.jsx("td",{children:s.nontaxableLinkage.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.nontaxableLinkage.amount.formatted},a.year))]}),commentaryData:s.nontaxableLinkage}),e.jsxs("tr",{children:[e.jsx("th",{children:"Taxable Income"}),e.jsx("th",{children:s.taxableIncome.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.taxableIncome.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax Rate"}),e.jsxs("td",{children:[(s.taxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.taxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Income with Special Tax Rate"}),e.jsx("td",{children:s.specialTaxableIncome.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.specialTaxableIncome.amount.formatted},a.year))]}),commentaryData:s.specialTaxableIncome}),e.jsxs("tr",{children:[e.jsx("td",{children:"Special Tax Rate"}),e.jsxs("td",{children:[(s.specialTaxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.specialTaxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Annual Tax Expense"}),e.jsx("th",{children:s.annualTaxExpense.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.annualTaxExpense.formatted},t.year)),e.jsx("td",{})]})})]})})})};export{G as TaxReport};
@@ -1 +1 @@
1
- import{r as n,u as y,dt as L,G as b,bI as C,j as e,D as O,aU as P,B as M,a3 as q,x as V,al as H,am as U,ao as z,ap as Q,aq as $,ar as G,as as J,w as S,du as F,y as K,dv as X,H as Y,bF as _,V as W,a2 as Z,bJ as ee,bK as se,bL as te,bM as N,bN as h,bO as ne,bP as x,ai as ae,R as E,bQ as le,bR as re,a4 as oe,bS as ce,bT as ie,F as ue,c as de}from"./index-CHtpNrAW.js";import{u as me,E as he}from"./edit-issue-document-modal-CG9FH4t_.js";import{s as w}from"./subMonths-DZvdAXT7.js";function xe({issueMonth:u,clients:r,onAdd:o}){const[f,c]=n.useState(!1),[j,d]=n.useState(""),[{data:m},a]=y({query:L,variables:{issueMonth:u,clientId:j},pause:!f}),p=n.useCallback(l=>{d(l),a()},[a,d]);return n.useEffect(()=>{j!==""&&m&&(o(b(C,m.clientMonthlyChargeDraft)),c(!1))},[j,m,o]),e.jsxs(O,{open:f,onOpenChange:c,children:[e.jsx(P,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"icon",children:e.jsx(q,{})})}),e.jsxs(V,{className:"w-[400px] max-w-screen-md",children:[e.jsx(H,{children:e.jsx(U,{children:"Select document recipient"})}),e.jsxs(z,{onValueChange:p,children:[e.jsx(Q,{children:e.jsx($,{placeholder:"Recipient"})}),e.jsx(G,{children:r.map(l=>e.jsx(J,{value:l.id,children:l.name},l.id))})]})]})]})}const je=({drafts:u})=>{const[r,o]=n.useState(u.map(s=>b(C,s))),f=S(w(new Date,1),"yyyy-MM-dd"),[c,j]=n.useState(f),[{data:d},m]=y({query:F,variables:{issueMonth:c},pause:!0});n.useEffect(()=>{d?.clientMonthlyChargesDrafts&&o(d.clientMonthlyChargesDrafts.map(s=>b(C,s)))},[d,o]),n.useEffect(()=>{m()},[c,m]);const a=K({values:{generateDocumentsInfo:r}}),{issueDocuments:p}=me(),[{data:l}]=y({query:X}),{fields:I,append:A,remove:B,update:k}=Y({control:a.control,name:"generateDocumentsInfo"}),T=a.watch("generateDocumentsInfo"),D=n.useMemo(()=>I.map((s,t)=>({...s,...T[t],id:s.client?.businessId})),[I,T]),v=n.useCallback(s=>{p(s)},[p]),R=n.useMemo(()=>l?.allOpenContracts.filter(s=>s.billingCycle===_.Monthly&&!D.some(t=>t.client?.businessId===s.client.originalBusiness.id)),[D,l]);return e.jsx("div",{className:"p-2",children:e.jsx(W,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(v),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(Z,{children:"Issue Month:"}),e.jsx(ee,{value:new Date(c),onChange:s=>{const t=new Date(s.getFullYear(),s.getMonth(),15);j(S(t,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(se,{children:[e.jsx(te,{children:e.jsxs(N,{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(N,{children:[e.jsx(x,{children:e.jsx(ae,{to:s?E.BUSINESSES.DETAIL(s):E.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(le,{children:[e.jsx(re,{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(ce,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(he,{draft:t,onApprove:i=>{a.setValue(`generateDocumentsInfo.${g}`,i,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),k(g,{...i})}})]})})]},s))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(xe,{clients:R?.map(s=>({id:s.client.originalBusiness.id,name:s.client.originalBusiness.name}))??[],onAdd:A,issueMonth:c}),e.jsx(ie,{onConfirm:a.handleSubmit(v),title:`Are you sure you want to issue ${D.length} documents?`,children:e.jsx(M,{children:"Issue"})})]})]})})})},ye=()=>{const{setFiltersContext:u}=n.useContext(ue),[{data:r,fetching:o}]=y({query:F,variables:{issueMonth:S(w(new Date,1),"yyyy-MM-dd")}});return n.useEffect(()=>{r?.clientMonthlyChargesDrafts||u(null)},[r,u]),o?e.jsx(de,{}):e.jsx(je,{drafts:r?.clientMonthlyChargesDrafts??[]})};export{ye as IssueDocuments};
1
+ import{r as n,u as y,dt as L,G as b,bI as C,j as e,D as O,aU as P,B as M,a3 as q,x as V,al as H,am as U,ao as z,ap as Q,aq as $,ar as G,as as J,w as S,du as F,y as K,dv as X,H as Y,bF as _,V as W,a2 as Z,bJ as ee,bK as se,bL as te,bM as N,bN as h,bO as ne,bP as x,ai as ae,R as E,bQ as le,bR as re,a4 as oe,bS as ce,bT as ie,F as ue,c as de}from"./index-3R_zL83W.js";import{u as me,E as he}from"./edit-issue-document-modal-CoDIF8wL.js";import{s as w}from"./subMonths-Cpq9u0d9.js";function xe({issueMonth:u,clients:r,onAdd:o}){const[f,c]=n.useState(!1),[j,d]=n.useState(""),[{data:m},a]=y({query:L,variables:{issueMonth:u,clientId:j},pause:!f}),p=n.useCallback(l=>{d(l),a()},[a,d]);return n.useEffect(()=>{j!==""&&m&&(o(b(C,m.clientMonthlyChargeDraft)),c(!1))},[j,m,o]),e.jsxs(O,{open:f,onOpenChange:c,children:[e.jsx(P,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"icon",children:e.jsx(q,{})})}),e.jsxs(V,{className:"w-[400px] max-w-screen-md",children:[e.jsx(H,{children:e.jsx(U,{children:"Select document recipient"})}),e.jsxs(z,{onValueChange:p,children:[e.jsx(Q,{children:e.jsx($,{placeholder:"Recipient"})}),e.jsx(G,{children:r.map(l=>e.jsx(J,{value:l.id,children:l.name},l.id))})]})]})]})}const je=({drafts:u})=>{const[r,o]=n.useState(u.map(s=>b(C,s))),f=S(w(new Date,1),"yyyy-MM-dd"),[c,j]=n.useState(f),[{data:d},m]=y({query:F,variables:{issueMonth:c},pause:!0});n.useEffect(()=>{d?.clientMonthlyChargesDrafts&&o(d.clientMonthlyChargesDrafts.map(s=>b(C,s)))},[d,o]),n.useEffect(()=>{m()},[c,m]);const a=K({values:{generateDocumentsInfo:r}}),{issueDocuments:p}=me(),[{data:l}]=y({query:X}),{fields:I,append:A,remove:B,update:k}=Y({control:a.control,name:"generateDocumentsInfo"}),T=a.watch("generateDocumentsInfo"),D=n.useMemo(()=>I.map((s,t)=>({...s,...T[t],id:s.client?.businessId})),[I,T]),v=n.useCallback(s=>{p(s)},[p]),R=n.useMemo(()=>l?.allOpenContracts.filter(s=>s.billingCycle===_.Monthly&&!D.some(t=>t.client?.businessId===s.client.originalBusiness.id)),[D,l]);return e.jsx("div",{className:"p-2",children:e.jsx(W,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(v),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(Z,{children:"Issue Month:"}),e.jsx(ee,{value:new Date(c),onChange:s=>{const t=new Date(s.getFullYear(),s.getMonth(),15);j(S(t,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(se,{children:[e.jsx(te,{children:e.jsxs(N,{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(N,{children:[e.jsx(x,{children:e.jsx(ae,{to:s?E.BUSINESSES.DETAIL(s):E.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(le,{children:[e.jsx(re,{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(ce,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(he,{draft:t,onApprove:i=>{a.setValue(`generateDocumentsInfo.${g}`,i,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),k(g,{...i})}})]})})]},s))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(xe,{clients:R?.map(s=>({id:s.client.originalBusiness.id,name:s.client.originalBusiness.name}))??[],onAdd:A,issueMonth:c}),e.jsx(ie,{onConfirm:a.handleSubmit(v),title:`Are you sure you want to issue ${D.length} documents?`,children:e.jsx(M,{children:"Issue"})})]})]})})})},ye=()=>{const{setFiltersContext:u}=n.useContext(ue),[{data:r,fetching:o}]=y({query:F,variables:{issueMonth:S(w(new Date,1),"yyyy-MM-dd")}});return n.useEffect(()=>{r?.clientMonthlyChargesDrafts||u(null)},[r,u]),o?e.jsx(de,{}):e.jsx(je,{drafts:r?.clientMonthlyChargesDrafts??[]})};export{ye as IssueDocuments};
@@ -1 +1 @@
1
- import{r as x,j as e,B as u,a as y,F as g,u as P,L as D,gc as w}from"./index-CHtpNrAW.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as E}from"./page-layout-Cs7LzhPs.js";import{R as d}from"./report-commentary-row-DNTsFgf_.js";import{P as v}from"./modal-YTgF-R03.js";import{Y as p}from"./YearPickerInput-DgK0Ih6X.js";import{F}from"./funnel-4UXATjU3.js";import{T as C}from"./Table-bhKB4PFK.js";import"./toggle-expansion-button-ByfnT_sn.js";import"./panel-top-open-DfXV4xoB.js";function A({year:l,setYear:h,referenceYears:o,setReferenceYears:j}){const[m,c]=x.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(v,{opened:m,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(F,{className:"size-5"})})]})}const I=()=>{const{year:l}=y(),{setFiltersContext:h}=x.useContext(g),[o,j]=x.useState(l?Number(l):new Date().getFullYear()),[m,c]=x.useState([]),[{data:n,fetching:i}]=P({query:R(w),variables:{reportYear:o,referenceYears:m}});x.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:m,setReferenceYears:c})}))},[o,i,h,m,c]);const f=n?.profitAndLossReport,r=f?.report,s=f?.reference??[];return e.jsx(E,{title:"Profit and Loss Report",children:i?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:r&&e.jsxs(C,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:r.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("th",{children:a.revenue.amount.formatted},a.year))]}),commentaryData:r.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:r.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.costOfSales.amount.formatted},a.year))]}),commentaryData:r.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:r.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted},a.year))]}),commentaryData:r.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:r.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.marketingExpenses.amount.formatted},a.year))]}),commentaryData:r.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted},a.year))]}),commentaryData:r.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:r.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:r.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.financialExpenses.amount.formatted},a.year))]}),commentaryData:r.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:r.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.otherIncome.amount.formatted},a.year))]}),commentaryData:r.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:r.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:r.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:r.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{I as ProfitAndLossReport};
1
+ import{r as x,j as e,B as u,a as y,F as g,u as P,L as D,gc as w}from"./index-3R_zL83W.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as E}from"./page-layout-CowMhn5y.js";import{R as d}from"./report-commentary-row-DQCpV1AP.js";import{P as v}from"./modal-ZC7sNmLW.js";import{Y as p}from"./YearPickerInput-Bka3kNAU.js";import{F}from"./funnel-DyklXeNl.js";import{T as C}from"./Table-BD-Y5pOR.js";import"./toggle-expansion-button-C91T0tTd.js";import"./panel-top-open-DNq_YeJ3.js";function A({year:l,setYear:h,referenceYears:o,setReferenceYears:j}){const[m,c]=x.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(v,{opened:m,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(F,{className:"size-5"})})]})}const I=()=>{const{year:l}=y(),{setFiltersContext:h}=x.useContext(g),[o,j]=x.useState(l?Number(l):new Date().getFullYear()),[m,c]=x.useState([]),[{data:n,fetching:i}]=P({query:R(w),variables:{reportYear:o,referenceYears:m}});x.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:m,setReferenceYears:c})}))},[o,i,h,m,c]);const f=n?.profitAndLossReport,r=f?.report,s=f?.reference??[];return e.jsx(E,{title:"Profit and Loss Report",children:i?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:r&&e.jsxs(C,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:r.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("th",{children:a.revenue.amount.formatted},a.year))]}),commentaryData:r.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:r.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.costOfSales.amount.formatted},a.year))]}),commentaryData:r.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:r.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted},a.year))]}),commentaryData:r.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:r.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.marketingExpenses.amount.formatted},a.year))]}),commentaryData:r.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted},a.year))]}),commentaryData:r.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:r.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:r.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.financialExpenses.amount.formatted},a.year))]}),commentaryData:r.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:r.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.otherIncome.amount.formatted},a.year))]}),commentaryData:r.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:r.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:r.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:r.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{I as ProfitAndLossReport};
@@ -1 +1 @@
1
- import{u as b,r as o,j as a,B as D,bX as R,gj as w,ag as i,bU as f,bK as y,bL as C,bM as s,bN as N,b_ as d,bO as I,bP as r,d5 as v,fy as B,i8 as F,c1 as E,c2 as S}from"./index-CHtpNrAW.js";import{D as T}from"./deposits-transactions-table-BAObjoYX.js";function V(){const[{data:c,fetching:g},p]=b({query:B}),[u,x]=o.useState([{id:"openDate",desc:!1}]),m=o.useMemo(()=>(c?.allDeposits??[]).map(t=>({id:t.id,currency:t.currency,openDate:t.openDate,closeDate:t.closeDate??null,isOpen:t.isOpen,currencyError:t.currencyError??[],currentBalanceRaw:t.currentBalance?.raw??0,currentBalanceFormatted:t.currentBalance?.formatted??"",totalDepositRaw:t.totalDeposit?.raw??0,totalDepositFormatted:t.totalDeposit?.formatted??"",totalInterestRaw:t.totalInterest?.raw??0,totalInterestFormatted:t.totalInterest?.formatted??""})),[c]),n=o.useRef([{id:"expander",header:()=>null,cell:({row:e})=>a.jsx(D,{variant:"ghost",size:"icon",onClick:()=>e.toggleExpanded(),"aria-label":e.getIsExpanded()?"Collapse":"Expand",children:e.getIsExpanded()?a.jsx(R,{}):a.jsx(w,{})}),enableSorting:!1},{accessorKey:"id",header:"Deposit ID",cell:e=>a.jsx("span",{className:"font-mono text-xs",children:e.getValue()})},{accessorKey:"currency",header:"Currency"},{accessorKey:"isOpen",header:"Status",cell:e=>e.getValue()?a.jsx(i,{className:"bg-green-600 text-white",variant:"secondary",children:"Open"}):a.jsx(i,{variant:"secondary",children:"Closed"}),sortingFn:(e,t)=>Number(e.original.isOpen)-Number(t.original.isOpen)},{accessorKey:"openDate",header:"Open Date",cell:e=>a.jsx("span",{children:e.getValue()})},{accessorKey:"closeDate",header:"Close Date",cell:e=>a.jsx("span",{children:e.getValue()??"-"}),sortingFn:(e,t)=>{const h=e.original.closeDate??"",j=t.original.closeDate??"";return h.localeCompare(j)}},{id:"totalDeposit",header:"Total Deposit",accessorFn:e=>e.totalDepositRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalDepositFormatted}),sortingFn:(e,t)=>e.original.totalDepositRaw-t.original.totalDepositRaw},{id:"currentBalance",header:"Current Balance",accessorFn:e=>e.currentBalanceRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.currentBalanceFormatted}),sortingFn:(e,t)=>e.original.currentBalanceRaw-t.original.currentBalanceRaw},{id:"totalInterest",header:"Total Interest",accessorFn:e=>e.totalInterestRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalInterestFormatted}),sortingFn:(e,t)=>e.original.totalInterestRaw-t.original.totalInterestRaw}]).current,l=f({data:m,columns:n,state:{sorting:u},onSortingChange:x,getCoreRowModel:S(),getSortedRowModel:E(),getExpandedRowModel:F(),getRowCanExpand:()=>!0});return a.jsxs("div",{className:"max-w-[95vw]",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsx("h1",{className:"text-2xl font-semibold",children:"Bank Deposits"})}),a.jsx("div",{className:"mt-6 overflow-hidden rounded-md border",children:a.jsxs(y,{children:[a.jsx(C,{children:l.getHeaderGroups().map(e=>a.jsx(s,{children:e.headers.map(t=>a.jsx(N,{colSpan:t.colSpan,children:t.isPlaceholder?null:d(t.column.columnDef.header,t.getContext())},t.id))},e.id))}),a.jsx(I,{children:g?a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"Loading..."})}):l.getRowModel().rows?.length?l.getRowModel().rows.map(e=>a.jsxs(a.Fragment,{children:[a.jsx(s,{"data-state":e.getIsSelected()&&"selected",children:e.getVisibleCells().map(t=>a.jsx(r,{children:d(t.column.columnDef.cell,t.getContext())},t.id))},e.id),e.getIsExpanded()?a.jsx(s,{children:a.jsxs(r,{colSpan:n.length,children:[e.original.currencyError.length>0&&a.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-800",children:[a.jsx(v,{className:"size-4"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:"Currency Conflict"}),a.jsxs("div",{className:"opacity-90",children:["Affected transaction IDs: ",e.original.currencyError.join(", ")]})]})]}),a.jsx(T,{depositId:e.original.id,enableReassign:!0,refetch:p})]})}):null]})):a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"No results."})})})]})})]})}export{V as DepositsScreen};
1
+ import{u as b,r as o,j as a,B as D,bX as R,gj as w,ag as i,bU as f,bK as y,bL as C,bM as s,bN as N,b_ as d,bO as I,bP as r,d5 as v,fy as B,i8 as F,c1 as E,c2 as S}from"./index-3R_zL83W.js";import{D as T}from"./deposits-transactions-table-DkCO1YMQ.js";function V(){const[{data:c,fetching:g},p]=b({query:B}),[u,x]=o.useState([{id:"openDate",desc:!1}]),m=o.useMemo(()=>(c?.allDeposits??[]).map(t=>({id:t.id,currency:t.currency,openDate:t.openDate,closeDate:t.closeDate??null,isOpen:t.isOpen,currencyError:t.currencyError??[],currentBalanceRaw:t.currentBalance?.raw??0,currentBalanceFormatted:t.currentBalance?.formatted??"",totalDepositRaw:t.totalDeposit?.raw??0,totalDepositFormatted:t.totalDeposit?.formatted??"",totalInterestRaw:t.totalInterest?.raw??0,totalInterestFormatted:t.totalInterest?.formatted??""})),[c]),n=o.useRef([{id:"expander",header:()=>null,cell:({row:e})=>a.jsx(D,{variant:"ghost",size:"icon",onClick:()=>e.toggleExpanded(),"aria-label":e.getIsExpanded()?"Collapse":"Expand",children:e.getIsExpanded()?a.jsx(R,{}):a.jsx(w,{})}),enableSorting:!1},{accessorKey:"id",header:"Deposit ID",cell:e=>a.jsx("span",{className:"font-mono text-xs",children:e.getValue()})},{accessorKey:"currency",header:"Currency"},{accessorKey:"isOpen",header:"Status",cell:e=>e.getValue()?a.jsx(i,{className:"bg-green-600 text-white",variant:"secondary",children:"Open"}):a.jsx(i,{variant:"secondary",children:"Closed"}),sortingFn:(e,t)=>Number(e.original.isOpen)-Number(t.original.isOpen)},{accessorKey:"openDate",header:"Open Date",cell:e=>a.jsx("span",{children:e.getValue()})},{accessorKey:"closeDate",header:"Close Date",cell:e=>a.jsx("span",{children:e.getValue()??"-"}),sortingFn:(e,t)=>{const h=e.original.closeDate??"",j=t.original.closeDate??"";return h.localeCompare(j)}},{id:"totalDeposit",header:"Total Deposit",accessorFn:e=>e.totalDepositRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalDepositFormatted}),sortingFn:(e,t)=>e.original.totalDepositRaw-t.original.totalDepositRaw},{id:"currentBalance",header:"Current Balance",accessorFn:e=>e.currentBalanceRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.currentBalanceFormatted}),sortingFn:(e,t)=>e.original.currentBalanceRaw-t.original.currentBalanceRaw},{id:"totalInterest",header:"Total Interest",accessorFn:e=>e.totalInterestRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalInterestFormatted}),sortingFn:(e,t)=>e.original.totalInterestRaw-t.original.totalInterestRaw}]).current,l=f({data:m,columns:n,state:{sorting:u},onSortingChange:x,getCoreRowModel:S(),getSortedRowModel:E(),getExpandedRowModel:F(),getRowCanExpand:()=>!0});return a.jsxs("div",{className:"max-w-[95vw]",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsx("h1",{className:"text-2xl font-semibold",children:"Bank Deposits"})}),a.jsx("div",{className:"mt-6 overflow-hidden rounded-md border",children:a.jsxs(y,{children:[a.jsx(C,{children:l.getHeaderGroups().map(e=>a.jsx(s,{children:e.headers.map(t=>a.jsx(N,{colSpan:t.colSpan,children:t.isPlaceholder?null:d(t.column.columnDef.header,t.getContext())},t.id))},e.id))}),a.jsx(I,{children:g?a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"Loading..."})}):l.getRowModel().rows?.length?l.getRowModel().rows.map(e=>a.jsxs(a.Fragment,{children:[a.jsx(s,{"data-state":e.getIsSelected()&&"selected",children:e.getVisibleCells().map(t=>a.jsx(r,{children:d(t.column.columnDef.cell,t.getContext())},t.id))},e.id),e.getIsExpanded()?a.jsx(s,{children:a.jsxs(r,{colSpan:n.length,children:[e.original.currencyError.length>0&&a.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-800",children:[a.jsx(v,{className:"size-4"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:"Currency Conflict"}),a.jsxs("div",{className:"opacity-90",children:["Affected transaction IDs: ",e.original.currencyError.join(", ")]})]})]}),a.jsx(T,{depositId:e.original.id,enableReassign:!0,refetch:p})]})}):null]})):a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"No results."})})})]})})]})}export{V as DepositsScreen};
@@ -1,2 +1,2 @@
1
- import{r as F,j as r,e as Q,u as q,hd as H,L as E,aC as $,bw as K,B as U,y as X,by as ee,bz as te,bC as ne,bJ as O,w as S,he as T,bD as se,F as oe,J as re,O as ie,W as le}from"./index-CHtpNrAW.js";import{u as G}from"./use-url-query-DMunwqS4.js";import{P as ae}from"./page-layout-Cs7LzhPs.js";import{A as ce,a as fe,c as ue,b as he}from"./accordion-CAxRDsFz.js";import{P as de}from"./modal-YTgF-R03.js";import{F as pe}from"./funnel-4UXATjU3.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:l,N:o,j:h,M:a,Z:f,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*f);const V=o-a,_=o+a,B=_&1,W=l+o-1,Y=h+a-1,Z=(_+B)/2;let N;t:for(let M=0;M<=Z;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let u=I;u<=L;u+=2){const A=t[u-1-f*Math.floor((u-1)/f)],R=t[u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[u-f*Math.floor(u/f)]=b,B===1&&(N=V-u)>=1-M&&N<M&&b+t[f+N-f*Math.floor(N/f)]>=o)if(M>1||b!==w){i[x++]=l+b,i[x++]=o-b,i[x++]=h+C,i[x++]=a-C,o=w,a=k,f=2*(Math.min(o,a)+1);continue e}else break t}for(let u=I;u<=L;u+=2){const A=t[f+u-1-f*Math.floor((u-1)/f)],R=t[f+u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(W-b,Y-C);)b++,C++;if(t[f+u-f*Math.floor(u/f)]=b,B===0&&(N=V-u)>=-M&&N<=M&&b+t[N-f*Math.floor(N/f)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-k,i[x++]=k,o=o-b,a=a-C,f=2*(Math.min(o,a)+1);continue e}else break t}}if(o!==a){a>o?(l+=o,h+=o,a-=o,o=0):(l+=a,h+=a,o-=a,a=0);break}}if(o+a!==0)if(e.pxe===l||e.pye===h)e.pxe=l+o,e.pye=h+a;else{const V=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=l,e.pxe=l+o,e.pys=h,e.pye=h+a,V>=0)return e.i=l,e.N=o,e.j=h,e.M=a,e.Z=f,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],f=2*(Math.min(o,a)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const l=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*l);return new m({i:e,N:n,j:t,M:s,Z:l,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,l]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<l&&t(s,s);)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;t(--i,--l)&&i>s&&l>s;);}else{for(;s<i&&s<l&&e[s]===n[s];)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;e[--i]===n[--l]&&i>s&&l>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,l+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:a,j:f,N:x}=this;return a<x&&(n.done=!1,n.value=[a,f,x-a],this.i=x),n}const t=n.value,s=t[0],i=t[1],l=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=l,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*P(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,l,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=l;t<e.length&&(yield s.call(e,t))}v.applyPatch=P;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[l,o,h,a]of d(e,n,t))s<l&&(yield[0,i.call(e,s,l)]),l<o&&(yield[-1,i.call(e,l,o)]),h<a&&(yield[1,i.call(n,h,a)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),J=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=F.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),P=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of P)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(P.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),J]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),J]);let n=[];for(const[t,s]of j){const i=t.split(`
1
+ import{r as F,j as r,e as Q,u as q,hd as H,L as E,aC as $,bw as K,B as U,y as X,by as ee,bz as te,bC as ne,bJ as O,w as S,he as T,bD as se,F as oe,J as re,O as ie,W as le}from"./index-3R_zL83W.js";import{u as G}from"./use-url-query-Bdqm6AUY.js";import{P as ae}from"./page-layout-CowMhn5y.js";import{A as ce,a as fe,c as ue,b as he}from"./accordion-DQeKF8al.js";import{P as de}from"./modal-ZC7sNmLW.js";import{F as pe}from"./funnel-DyklXeNl.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:l,N:o,j:h,M:a,Z:f,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*f);const V=o-a,_=o+a,B=_&1,W=l+o-1,Y=h+a-1,Z=(_+B)/2;let N;t:for(let M=0;M<=Z;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let u=I;u<=L;u+=2){const A=t[u-1-f*Math.floor((u-1)/f)],R=t[u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[u-f*Math.floor(u/f)]=b,B===1&&(N=V-u)>=1-M&&N<M&&b+t[f+N-f*Math.floor(N/f)]>=o)if(M>1||b!==w){i[x++]=l+b,i[x++]=o-b,i[x++]=h+C,i[x++]=a-C,o=w,a=k,f=2*(Math.min(o,a)+1);continue e}else break t}for(let u=I;u<=L;u+=2){const A=t[f+u-1-f*Math.floor((u-1)/f)],R=t[f+u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(W-b,Y-C);)b++,C++;if(t[f+u-f*Math.floor(u/f)]=b,B===0&&(N=V-u)>=-M&&N<=M&&b+t[N-f*Math.floor(N/f)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-k,i[x++]=k,o=o-b,a=a-C,f=2*(Math.min(o,a)+1);continue e}else break t}}if(o!==a){a>o?(l+=o,h+=o,a-=o,o=0):(l+=a,h+=a,o-=a,a=0);break}}if(o+a!==0)if(e.pxe===l||e.pye===h)e.pxe=l+o,e.pye=h+a;else{const V=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=l,e.pxe=l+o,e.pys=h,e.pye=h+a,V>=0)return e.i=l,e.N=o,e.j=h,e.M=a,e.Z=f,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],f=2*(Math.min(o,a)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const l=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*l);return new m({i:e,N:n,j:t,M:s,Z:l,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,l]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<l&&t(s,s);)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;t(--i,--l)&&i>s&&l>s;);}else{for(;s<i&&s<l&&e[s]===n[s];)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;e[--i]===n[--l]&&i>s&&l>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,l+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:a,j:f,N:x}=this;return a<x&&(n.done=!1,n.value=[a,f,x-a],this.i=x),n}const t=n.value,s=t[0],i=t[1],l=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=l,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*P(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,l,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=l;t<e.length&&(yield s.call(e,t))}v.applyPatch=P;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[l,o,h,a]of d(e,n,t))s<l&&(yield[0,i.call(e,s,l)]),l<o&&(yield[-1,i.call(e,l,o)]),h<a&&(yield[1,i.call(n,h,a)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),J=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=F.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),P=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of P)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(P.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),J]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),J]);let n=[];for(const[t,s]of j){const i=t.split(`
2
2
  `);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(Q,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=q({query:H,variables:c}),p=F.useMemo(()=>m?.pcnByDate?m.pcnByDate.sort((y,g)=>g.date>y.date?1:g.date<y.date?-1:0):[],[m?.pcnByDate]);return D?r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}):r.jsxs("div",{className:"flex flex-col gap-4",children:[!!m&&d&&r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}),p.map((y,g)=>r.jsx(ge,{content:y.content,contentOrigin:y.diffContent,monthDate:y.date},g))]})};function be({filter:c,setFilter:m,closeModal:D}){const{control:d,handleSubmit:p,setValue:y}=X({defaultValues:{...c}}),{selectableBusinesses:g,fetching:P}=ee(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[P?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(te,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(ne,{...e,data:g,value:e.value,disabled:P,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),r.jsx(O,{label:"From date",defaultValue:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,defaultDate:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("fromMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsx(O,{label:"To date",defaultValue:c?.toMonthDate?new Date(c.toMonthDate):new Date,defaultDate:c?.toMonthDate?new Date(c.toMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("toMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[r.jsx(U,{type:"submit",children:"Filter"}),r.jsx(U,{type:"button",onClick:D,children:"Cancel"})]})]})]})}function ve({filter:c,setFilter:m}){const[D,d]=F.useState(!1),{get:p,set:y}=G(),{userContext:g}=F.useContext($);function P(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:S(T(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")},se(j,c)||m(j)}return F.useEffect(()=>{const j=K(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(de,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:P,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(pe,{className:"size-5"})})]})}const ke=()=>{const{get:c}=G(),{setFiltersContext:m}=F.useContext(oe),D=F.useMemo(()=>{try{if(c("validateReportsFilters"))return JSON.parse(decodeURIComponent(c("validateReportsFilters")))}catch(y){console.error("Error parsing filter from URL",y)}return{fromMonthDate:S(T(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")}},[c]),[d,p]=F.useState(D);return F.useEffect(()=>{m(r.jsx("div",{className:"flex flex-row gap-2",children:r.jsx(ve,{filter:{...d},setFilter:p})}))},[d,m]),r.jsx(ae,{title:"Report Validations",children:r.jsx(ce,{type:"single",collapsible:!0,children:r.jsx(fe,{value:"pcn874",children:r.jsxs(re,{className:"p-4",children:[r.jsx(ue,{children:r.jsx(ie,{children:"Monthly VAT (PCN874)"})}),r.jsx(he,{children:r.jsx(le,{children:r.jsx(Me,{filter:d})})})]})})})})};export{ke as ValidateReportsScreen};