@accounter/client 0.0.8-alpha-20251023065832-9a9f37786b0e29dc8e6ea58ec9856bc043cc0e8a → 0.0.8-alpha-20251023070808-bdd9d09db3d693f2c0061a2bbd66a4bfe5224012

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 (88) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-lfqFDKZM.js → Checkbox-Bm30-WRa.js} +2 -2
  3. package/dist/assets/{Progress-DvGsu87E.js → Progress-DxcT-wYo.js} +1 -1
  4. package/dist/assets/{Typography-BX4mj53o.js → Typography-CZLHs9y2.js} +1 -1
  5. package/dist/assets/{accordion-lOk81yKP.js → accordion-_VaDHoQb.js} +1 -1
  6. package/dist/assets/accountant-approvals-C7GnMLyl.js +1 -0
  7. package/dist/assets/{all-charges-DhPxcK73.js → all-charges-DS-mdep6.js} +1 -1
  8. package/dist/assets/{arrow-up-down-CFrneqND.js → arrow-up-down-Bt3_puEZ.js} +1 -1
  9. package/dist/assets/business-Db4PzgLz.js +42 -0
  10. package/dist/assets/{business-transactions-single-CJ5pLN-D.js → business-transactions-single-Canul8rR.js} +1 -1
  11. package/dist/assets/{business-trip-Jlc0bfXC.js → business-trip-x8lljSMP.js} +1 -1
  12. package/dist/assets/charges-filters-DkO9FBdC.js +1 -0
  13. package/dist/assets/{charges-ledger-validation-Bln73m_U.js → charges-ledger-validation-wla_aWIc.js} +1 -1
  14. package/dist/assets/{chart-Wut6cPCx.js → chart-2uS7cQLX.js} +1 -1
  15. package/dist/assets/{data-table-pagination-BnQGVnmE.js → data-table-pagination-CQQBbtVE.js} +1 -1
  16. package/dist/assets/{editable-business-trip-CjJg13b0.js → editable-business-trip-D50scoPo.js} +2 -2
  17. package/dist/assets/{index-y8Z-aJKc.js → index-B20Tn_iF.js} +2 -2
  18. package/dist/assets/{index-BoSqeUi7.js → index-BJ63UrPP.js} +6 -6
  19. package/dist/assets/{index-C2INIVq3.js → index-BNPAKzBY.js} +1 -1
  20. package/dist/assets/index-BP2Hv2J-.js +1 -0
  21. package/dist/assets/{index-Csqyxwgx.js → index-BTiGhl3N.js} +2 -2
  22. package/dist/assets/index-BaDl3RPI.js +1 -0
  23. package/dist/assets/index-BmSAw35b.js +1 -0
  24. package/dist/assets/{index-CN7VPpiB.js → index-BsGG-RLV.js} +13 -13
  25. package/dist/assets/index-Bskia9ol.js +1 -0
  26. package/dist/assets/index-C4JVZBO-.js +1 -0
  27. package/dist/assets/{index-BX3VSsge.js → index-CDHKPA0l.js} +1 -1
  28. package/dist/assets/{index-DquDHLbE.js → index-CqZy7PVr.js} +1 -1
  29. package/dist/assets/index-CzzfC-dD.css +1 -0
  30. package/dist/assets/index-D2w9iaKk.js +1 -0
  31. package/dist/assets/index-D5CFY1GF.js +1 -0
  32. package/dist/assets/index-DBjj2AmF.js +1 -0
  33. package/dist/assets/index-DJ33tRZ1.js +1 -0
  34. package/dist/assets/index-DKS2QKOQ.js +1 -0
  35. package/dist/assets/index-DOKYSdGb.js +1 -0
  36. package/dist/assets/{index-BagyRbeI.js → index-D_PykgGt.js} +2 -2
  37. package/dist/assets/index-Dk4NeG4m.js +1 -0
  38. package/dist/assets/{index-DjSJrgv5.js → index-Dkqd5T8J.js} +2 -2
  39. package/dist/assets/{index-CVz9TqoS.js → index-IN8Kpfsx.js} +2 -2
  40. package/dist/assets/index-OqG78rNq.js +9 -0
  41. package/dist/assets/{index.es-D8leRAY2.js → index.es-DKjfxgqg.js} +1 -1
  42. package/dist/assets/{issue-document-DKE0dzdE.js → issue-document-BFOjGS-U.js} +1 -1
  43. package/dist/assets/login-page-CpRailN7.js +1 -0
  44. package/dist/assets/{missing-info-charges-CgMJ4Bu3.js → missing-info-charges-BnYMeatL.js} +1 -1
  45. package/dist/assets/page-not-found-BLrYvmf4.js +1 -0
  46. package/dist/assets/{pencil-CUSCcyVn.js → pencil-DC6M9VTY.js} +1 -1
  47. package/dist/assets/report-commentary-row-DJPRyQur.js +1 -0
  48. package/dist/assets/save-Dr3CNkcl.js +11 -0
  49. package/dist/assets/similar-charges-by-business-modal-CCw5opHn.js +1 -0
  50. package/dist/assets/sub-DKnwnbwx.js +1 -0
  51. package/dist/assets/subMonths-B44KizJf.js +1 -0
  52. package/dist/index.html +2 -2
  53. package/package.json +2 -2
  54. package/src/components/business/business-header.tsx +2 -21
  55. package/src/components/businesses/all-businesses-row.tsx +87 -0
  56. package/src/components/businesses/cells/hebrew-name.tsx +31 -0
  57. package/src/components/businesses/cells/index.ts +2 -0
  58. package/src/components/businesses/cells/name.tsx +31 -0
  59. package/src/components/businesses/index.tsx +36 -45
  60. package/src/components/common/forms/business-card.tsx +234 -0
  61. package/src/components/common/forms/index.ts +1 -0
  62. package/src/gql/gql.ts +30 -6
  63. package/src/gql/graphql.ts +30 -7
  64. package/dist/assets/accountant-approvals-DWLEu1Um.js +0 -1
  65. package/dist/assets/building-2-Bqvbwz7Q.js +0 -6
  66. package/dist/assets/business--eNnF4xF.js +0 -42
  67. package/dist/assets/business-header-DjutqTRC.js +0 -1
  68. package/dist/assets/charges-filters-C-H07qp1.js +0 -1
  69. package/dist/assets/index-BE5nnZYY.js +0 -9
  70. package/dist/assets/index-BQrSA2Kk.js +0 -1
  71. package/dist/assets/index-BkeJsHyM.js +0 -1
  72. package/dist/assets/index-BtAgm6J8.js +0 -1
  73. package/dist/assets/index-BwIQ8ifH.js +0 -1
  74. package/dist/assets/index-Bxlzprxi.js +0 -1
  75. package/dist/assets/index-C--YkrHw.js +0 -1
  76. package/dist/assets/index-CQXFj3Uj.css +0 -1
  77. package/dist/assets/index-CalcGztb.js +0 -1
  78. package/dist/assets/index-Dr2UkUOm.js +0 -1
  79. package/dist/assets/index-E2rO9Bsf.js +0 -1
  80. package/dist/assets/index-Ggixi4PP.js +0 -1
  81. package/dist/assets/index-WCosiqtQ.js +0 -1
  82. package/dist/assets/index-vsZbkVMv.js +0 -1
  83. package/dist/assets/login-page-BYwtRBMd.js +0 -1
  84. package/dist/assets/page-not-found-Cfte6bjZ.js +0 -1
  85. package/dist/assets/report-commentary-row-B-uxVnyO.js +0 -1
  86. package/dist/assets/save-qyt28nOG.js +0 -6
  87. package/dist/assets/sub-LLu8afpC.js +0 -1
  88. package/dist/assets/subMonths-C1UIPrOU.js +0 -1
@@ -1,4 +1,4 @@
1
- import{z as it,r as m,d5 as Nc,ag as V,da as kc,ah as ae,j as v,d8 as vn,dU as It,dV as ge,dW as Ho,db as Lc,dX as Vc,dY as rn,dZ as jc,cX as rr,u as Wo,J as zr,am as $r,bw as Fc,B as ee,cZ as Bc,K as Ur,ao as Hr,ap as Wr,Q as Go,ca as _c,ad as zc,bL as An,ce as $c,bQ as Bi,bR as _i,G as sn,aH as Ko,bc as qo,c_ as Uc,i as Xo,d_ as Hc,t as Pe,l as Yo,cK as yn,a as ir,d$ as Wc,dh as Gc,e0 as Kc,dx as qc,dy as Xc,dz as Yc,L as Zo,v as Gr,dk as Zc,dl as Jc,dm as Nn,dn as Qc,dp as zi,dq as eu,dr as $i,ds as Jo,dt as Qo,du as ea,e1 as tu,e2 as nu,e3 as on,e4 as ru,V as iu,a9 as su,$ as ou,a1 as au,a2 as lu,a3 as cu,a4 as uu,a6 as du,az as hu,ab as Ui,dP as fu,e5 as pu,g as gu,as as mu,ar as Hi,e6 as vu,e7 as yu,e8 as Wi,b$ as bu,P as Tu,b as xu,bd as Su,a_ as wu,F as Du,aJ as Cu,e9 as Eu,ea as Ou}from"./index-CN7VPpiB.js";import{A as Gi}from"./arrow-up-down-CFrneqND.js";import{_ as Pu,a as bn,s as we,g as Kr,u as Ki,c as qr,m as wt,d as sr,T as or}from"./Typography-BX4mj53o.js";import{P as Mu}from"./pencil-CUSCcyVn.js";/**
1
+ import{V as it,r as m,da as Nc,aj as V,df as kc,ak as ae,j as v,dd as vn,dZ as It,d_ as ge,d$ as Ho,dg as Lc,e0 as Vc,e1 as rn,e2 as jc,d0 as rr,u as Wo,ao as zr,ap as $r,bC as Fc,B as ee,d2 as Bc,ar as Ur,as as Hr,at as Wr,k as Go,cf as _c,U as zc,bR as An,cj as $c,bW as Bi,bX as _i,Y as sn,aK as Ko,bf as qo,d3 as Uc,p as Xo,e3 as Hc,t as Pe,s as Yo,cP as yn,a as ir,e4 as Wc,dm as Gc,e5 as Kc,dC as qc,dD as Xc,dE as Yc,L as Zo,Q as Gr,dq as Zc,dr as Jc,ds as Nn,dt as Qc,du as zi,dv as eu,dw as $i,dx as Jo,dy as Qo,dz as ea,e6 as tu,e7 as nu,e8 as on,e9 as ru,_ as iu,ac as su,l as ou,a4 as au,a5 as lu,a6 as cu,a7 as uu,a9 as du,aC as hu,ad as Ui,dU as fu,ea as pu,g as gu,av as mu,af as Hi,eb as vu,ec as yu,ed as Wi,c5 as bu,P as Tu,b as xu,bg as Su,b1 as wu,F as Du,aM as Cu,ee as Eu,ef as Ou}from"./index-BsGG-RLV.js";import{A as Gi}from"./arrow-up-down-Bt3_puEZ.js";import{_ as Pu,a as bn,s as we,g as Kr,u as Ki,c as qr,m as wt,d as sr,T as or}from"./Typography-CZLHs9y2.js";import{P as Mu}from"./pencil-DC6M9VTY.js";/**
2
2
  * @license lucide-react v0.546.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ import{p as v,fY as B,r as u,t as m,s as F,aM as H,j as e,a4 as C,a5 as j,a6 as f,a7 as p,Q as L,a8 as y,a9 as S,bR as K,bS as Q,aQ as V,aK as _,ao as D,ap as E,B as h,ar as M,as as R,at as A,k,l as $,fZ as z,ca as G,a as O,f_ as Y,L as P,F as Z,dm as J,c as W,dq as X,dr as ee,ds as T,dt as se,du as b,dv as te,dw as w,f$ as ae,dC as re,dD as oe,dE as ne}from"./index-BsGG-RLV.js";import{D as ie}from"./data-table-pagination-CQQBbtVE.js";import{A as N}from"./arrow-up-down-Bt3_puEZ.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(B),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function q({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=H();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(L,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(S,{})]})}),e.jsx(K,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(Q,{...o,onChange:U=>{o.onChange(Number(U))},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(V,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(S,{})]})}),e.jsx(C,{control:a,name:"taxExcluded",render:({field:o})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{children:"Tax excluded category"})}),e.jsx(p,{children:e.jsx(_,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(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=k({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx($,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(z),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(G,{})})}),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}]=O({query:Y,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&m.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx(P,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=k({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx($,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=O({query:ae}),{setFiltersContext:d}=u.useContext(Z),r=s?.taxCategories??[],i=J({data:r,columns:I,getCoreRowModel:ne(),getPaginationRowModel:oe(),getSortedRowModel:re(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ie,{table:i})})}))},[d,i,l]),u.useEffect(()=>{t&&m.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(W,{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(P,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(X,{children:[e.jsx(ee,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(se,{children:c.isPlaceholder?null:b(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(te,{children:i.getRowModel().rows.length===0?e.jsx(T,{children:e.jsx(w,{colSpan:I.length,className:"text-center py-8",children:"No tax categories found"})}):i.getRowModel().rows.map(x=>e.jsx(T,{children:x.getVisibleCells().map(c=>e.jsx(w,{children:b(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{Se as TaxCategories};
@@ -1,4 +1,4 @@
1
- import{z as V,i as q,ez as E,r,t as k,l as F,a as $,eA as _,j as s,n as L,eB as R,o as H,B as Q,p as X,q as G}from"./index-CN7VPpiB.js";import{C as J,M as K}from"./Checkbox-lfqFDKZM.js";/**
1
+ import{V,p as B,eC as q,r,t as k,s as F,a as $,eD as _,j as s,w as L,eE as R,x as H,B as Q,y as X,z as G}from"./index-BsGG-RLV.js";import{C as J,M as K}from"./Checkbox-Bm30-WRa.js";/**
2
2
  * @license lucide-react v0.546.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,4 +8,4 @@ import{z as V,i as q,ez as E,r,t as k,l as F,a as $,eA as _,j as s,n as L,eB as
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const W=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],N=V("square-x",W),Y="mergeCharges",Z=()=>{const[{fetching:C},a]=q(E),c=r.useCallback(async x=>{const u=`Error merging into charge ID [${x.baseChargeID}]`,l=`${Y}-${x.baseChargeID}`;k.loading("Merging Charges",{id:l});try{const d=await a(x),n=F(d,u,l,"mergeCharges");if(n)return k.success("Success",{id:l,description:"Charges were merged"}),n.mergeCharges.charge}catch(d){console.error(`${u}: ${d}`),k.error("Error",{id:l,description:u,duration:1e5,closeButton:!0})}},[a]);return{fetching:C,mergeCharges:c}};function ee({chargeIds:C,onDone:a,resetMerge:c}){const{mergeCharges:x,fetching:u}=Z(),l=Array.from(new Set(C)),[{data:d,fetching:n}]=$({query:_,variables:{chargeIds:l}}),[i,I]=r.useState(d?.chargesByIDs[0]),[m,p]=r.useState(void 0),[f,z]=r.useState(void 0),[j,w]=r.useState(void 0),[v,M]=r.useState(void 0),[D,A]=r.useState(void 0),[y,T]=r.useState(void 0),[b,O]=r.useState(void 0),[h,P]=r.useState(void 0),S=d?.chargesByIDs.length!==l.length&&"Some charges were not Found"||void 0,o=d?.chargesByIDs||[],B=r.useCallback(async()=>{if(!i){k.error("Error",{description:"No main charge selected"});return}if(l.length<2){k.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let e;return m&&m.value!==i.userDescription&&(e??={},e={...e,userDescription:m.value}),f&&f.value!==i.owner.id&&(e??={},e={...e,ownerId:f.value}),y&&y.value!==i.conversion&&(e??={},e={...e,isConversion:y.value}),j&&j.value!==i.property&&(e??={},e={...e,isProperty:j.value}),v&&v.value!==i.optionalVAT&&(e??={},e={...e,optionalVAT:v.value}),D&&D.value!==i.optionalDocuments&&(e??={},e={...e,optionalDocuments:D.value}),h&&h.value!==i.tags.map(t=>t.name).join(",")&&(e??={},e={...e,tags:h.value.split(",").filter(t=>t!=="").map(t=>({id:t}))}),b&&b.value!==i.isInvoicePaymentDifferentCurrency&&(e??={},e={...e,isInvoicePaymentDifferentCurrency:b.value}),await x({baseChargeID:i.id,chargeIdsToMerge:l.filter(t=>t!==i.id),fields:e}),c(),a()},[i,l,x,m,f,y,j,v,b,h,a,c]);return s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx(L,{})}),!n&&S&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:S})}),!n&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("table",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:"Main"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:s.jsx(J,{checked:e.id===i?.id,size:"xl",onClick:()=>{I(e),p({id:e.id,value:e.userDescription??""}),z({id:e.id,value:e.owner.id}),w({id:e.id,value:e.property??!1}),M({id:e.id,value:e.optionalVAT??!1}),A({id:e.id,value:e.optionalDocuments??!1}),O({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1}),T({id:e.id,value:e.conversion??!1}),P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})}})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Description"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:!e.userDescription||m?.value===e.userDescription,onClick:()=>p({id:e.id,value:e.userDescription??""}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:m?.id===e.id?{background:"#228be633"}:{},children:e.userDescription})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Owner"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:f?.value===e.owner.id,onClick:()=>z({id:e.id,value:e.owner.id}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:f?.id===e.id?{background:"#228be633"}:{},children:e.owner.name})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Property"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.property==null||e.property===j?.value,onClick:()=>{w({id:e.id,value:e.property??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===e.id?{background:"#228be633"}:{},children:e.property?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Conversion"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.conversion==null||e.conversion===y?.value,onClick:()=>{T({id:e.id,value:e.conversion??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:y?.id===e.id?{background:"#228be633"}:{},children:e.conversion?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional VAT"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalVAT==null||e.optionalVAT===v?.value,onClick:()=>{M({id:e.id,value:e.optionalVAT??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:v?.id===e.id?{background:"#228be633"}:{},children:e.optionalVAT?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional Documents"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalDocuments==null||e.optionalDocuments===D?.value,onClick:()=>{A({id:e.id,value:e.optionalDocuments??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:D?.id===e.id?{background:"#228be633"}:{},children:e.optionalDocuments?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoice-Payment Currency Difference"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.isInvoicePaymentDifferentCurrency==null||e.isInvoicePaymentDifferentCurrency===b?.value,onClick:()=>{w({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===e.id?{background:"#228be633"}:{},children:e.isInvoicePaymentDifferentCurrency?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Tags"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.tags==null||e.tags.map(t=>t.name).join(",")===h?.value,onClick:()=>{P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:h?.id===e.id?{background:"#228be633"}:{},children:s.jsx(R,{items:e.tags.map(t=>s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{children:t.name}),t.namePath&&s.jsx("div",{children:t.namePath.join(" > ")})]},t.id))})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Transactions"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:e.metadata?.transactionsCount??0})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoices"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:e.metadata?.invoicesCount??0})},e.id))]})]}),s.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[s.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:n||u,onClick:B,children:"Accept"}),s.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:a,children:"Cancel"}),s.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{c(),a()},children:"Reset Merge"})]})]})]})}function ie(C){const[a,{close:c,open:x}]=H(!1),{selected:u,resetMerge:l}=C,d=new Set(u.map(({id:p})=>p)),n=d.size>=1,[i,I]=r.useState(n?"default":"outline");r.useEffect(()=>{I(n?"default":"outline")},[n]);const m=r.useCallback(()=>{c(),u.map(({onChange:p})=>p())},[u,c]);return s.jsxs(s.Fragment,{children:[s.jsx(Q,{onClick:()=>{n&&x()},disabled:!n,variant:i,className:X("size-7.5",n?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:s.jsx(K,{className:"size-5"})}),s.jsx(G,{opened:a,onClose:c,size:"auto",centered:!0,children:s.jsx(ee,{chargeIds:Array.from(d),onDone:m,resetMerge:l})})]})}export{ie as M};
11
+ */const W=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],N=V("square-x",W),Y="mergeCharges",Z=()=>{const[{fetching:C},a]=B(q),c=r.useCallback(async x=>{const u=`Error merging into charge ID [${x.baseChargeID}]`,l=`${Y}-${x.baseChargeID}`;k.loading("Merging Charges",{id:l});try{const d=await a(x),n=F(d,u,l,"mergeCharges");if(n)return k.success("Success",{id:l,description:"Charges were merged"}),n.mergeCharges.charge}catch(d){console.error(`${u}: ${d}`),k.error("Error",{id:l,description:u,duration:1e5,closeButton:!0})}},[a]);return{fetching:C,mergeCharges:c}};function ee({chargeIds:C,onDone:a,resetMerge:c}){const{mergeCharges:x,fetching:u}=Z(),l=Array.from(new Set(C)),[{data:d,fetching:n}]=$({query:_,variables:{chargeIds:l}}),[i,w]=r.useState(d?.chargesByIDs[0]),[m,p]=r.useState(void 0),[f,z]=r.useState(void 0),[j,I]=r.useState(void 0),[v,M]=r.useState(void 0),[D,T]=r.useState(void 0),[y,A]=r.useState(void 0),[b,O]=r.useState(void 0),[h,P]=r.useState(void 0),S=d?.chargesByIDs.length!==l.length&&"Some charges were not Found"||void 0,o=d?.chargesByIDs||[],E=r.useCallback(async()=>{if(!i){k.error("Error",{description:"No main charge selected"});return}if(l.length<2){k.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let e;return m&&m.value!==i.userDescription&&(e??={},e={...e,userDescription:m.value}),f&&f.value!==i.owner.id&&(e??={},e={...e,ownerId:f.value}),y&&y.value!==i.conversion&&(e??={},e={...e,isConversion:y.value}),j&&j.value!==i.property&&(e??={},e={...e,isProperty:j.value}),v&&v.value!==i.optionalVAT&&(e??={},e={...e,optionalVAT:v.value}),D&&D.value!==i.optionalDocuments&&(e??={},e={...e,optionalDocuments:D.value}),h&&h.value!==i.tags.map(t=>t.name).join(",")&&(e??={},e={...e,tags:h.value.split(",").filter(t=>t!=="").map(t=>({id:t}))}),b&&b.value!==i.isInvoicePaymentDifferentCurrency&&(e??={},e={...e,isInvoicePaymentDifferentCurrency:b.value}),await x({baseChargeID:i.id,chargeIdsToMerge:l.filter(t=>t!==i.id),fields:e}),c(),a()},[i,l,x,m,f,y,j,v,b,h,a,c]);return s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx(L,{})}),!n&&S&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:S})}),!n&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("table",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:"Main"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:s.jsx(J,{checked:e.id===i?.id,size:"xl",onClick:()=>{w(e),p({id:e.id,value:e.userDescription??""}),z({id:e.id,value:e.owner.id}),I({id:e.id,value:e.property??!1}),M({id:e.id,value:e.optionalVAT??!1}),T({id:e.id,value:e.optionalDocuments??!1}),O({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1}),A({id:e.id,value:e.conversion??!1}),P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})}})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Description"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:!e.userDescription||m?.value===e.userDescription,onClick:()=>p({id:e.id,value:e.userDescription??""}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:m?.id===e.id?{background:"#228be633"}:{},children:e.userDescription})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Owner"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:f?.value===e.owner.id,onClick:()=>z({id:e.id,value:e.owner.id}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:f?.id===e.id?{background:"#228be633"}:{},children:e.owner.name})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Property"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.property==null||e.property===j?.value,onClick:()=>{I({id:e.id,value:e.property??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===e.id?{background:"#228be633"}:{},children:e.property?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Conversion"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.conversion==null||e.conversion===y?.value,onClick:()=>{A({id:e.id,value:e.conversion??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:y?.id===e.id?{background:"#228be633"}:{},children:e.conversion?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional VAT"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalVAT==null||e.optionalVAT===v?.value,onClick:()=>{M({id:e.id,value:e.optionalVAT??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:v?.id===e.id?{background:"#228be633"}:{},children:e.optionalVAT?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional Documents"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalDocuments==null||e.optionalDocuments===D?.value,onClick:()=>{T({id:e.id,value:e.optionalDocuments??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:D?.id===e.id?{background:"#228be633"}:{},children:e.optionalDocuments?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoice-Payment Currency Difference"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.isInvoicePaymentDifferentCurrency==null||e.isInvoicePaymentDifferentCurrency===b?.value,onClick:()=>{I({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===e.id?{background:"#228be633"}:{},children:e.isInvoicePaymentDifferentCurrency?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Tags"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.tags==null||e.tags.map(t=>t.name).join(",")===h?.value,onClick:()=>{P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:h?.id===e.id?{background:"#228be633"}:{},children:s.jsx(R,{items:e.tags.map(t=>s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{children:t.name}),t.namePath&&s.jsx("div",{children:t.namePath.join(" > ")})]},t.id))})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Transactions"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:e.metadata?.transactionsCount??0})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoices"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:e.metadata?.invoicesCount??0})},e.id))]})]}),s.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[s.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:n||u,onClick:E,children:"Accept"}),s.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:a,children:"Cancel"}),s.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{c(),a()},children:"Reset Merge"})]})]})]})}function ie(C){const[a,{close:c,open:x}]=H(!1),{selected:u,resetMerge:l}=C,d=new Set(u.map(({id:p})=>p)),n=d.size>=1,[i,w]=r.useState(n?"default":"outline");r.useEffect(()=>{w(n?"default":"outline")},[n]);const m=r.useCallback(()=>{c(),u.map(({onChange:p})=>p())},[u,c]);return s.jsxs(s.Fragment,{children:[s.jsx(Q,{onClick:()=>{n&&x()},disabled:!n,variant:i,className:X("size-7.5",n?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:s.jsx(K,{className:"size-5"})}),s.jsx(G,{opened:a,onClose:c,size:"auto",centered:!0,children:s.jsx(ee,{chargeIds:Array.from(d),onDone:m,resetMerge:l})})]})}export{ie as M};
@@ -0,0 +1 @@
1
+ import{r as c,a as N,i as k,j as e,e as w,U as E,k as z,l as D,m as L,n as A,o as T,p as O,q as P,t as B,s as R,v as U,w as $,x as q,B as C,y as S,z as H,D as v,G as _,H as Q,P as F,b as I,J as V,K as G,N as J,u as M,O as K,Q as W,F as X,T as Y,c as Z,L as ee,R as se,S as te}from"./index-BsGG-RLV.js";import{C as ne,M as ie}from"./Checkbox-Bm30-WRa.js";import{u as ae,S as re}from"./similar-charges-by-business-modal-CCw5opHn.js";function oe({businessID:t,updateBusiness:n}){const[r,u]=c.useState(void 0),[{data:o,fetching:i},l]=N({query:k,variables:{id:t}});return c.useEffect(()=>{i?u(void 0):o&&o.business.__typename==="LtdFinancialEntity"&&u(o.business)},[o,i]),c.useEffect(()=>{r&&n(r)},[r,n]),e.jsx("div",{className:"flex flex-col gap-5",children:r?e.jsx(le,{business:r,refetchBusiness:l}):i?e.jsx(w,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx("p",{children:"Error fetching extended information for this business"})})}function le({business:t,refetchBusiness:n}){const[r,u]=c.useState(!1),[o,i]=c.useState(!1),[l,d]=c.useState(void 0),{userContext:g}=c.useContext(E),{updateBusiness:f,fetching:a}=ae(),x=z({defaultValues:{...t,taxCategory:t.taxCategory?.id,sortCode:t?.sortCode?.key,irsCode:t?.irsCode}}),{handleSubmit:p,formState:{dirtyFields:h}}=x,b=async j=>{if(!t||!g?.context.adminBusinessId)return;const s=T(j,h);s&&Object.keys(s).length>0&&(s.sortCode&&=parseInt(s.sortCode.toString()),s.suggestions?.tags&&(s.suggestions.tags=s.suggestions.tags.map(m=>({id:m.id}))),s.suggestions?.phrases&&(s.suggestions.phrases=j.suggestions.phrases.map(m=>m)),s.suggestions?.emails&&(s.suggestions.emails=j.suggestions.emails.map(m=>m)),s.suggestions?.emailListener&&(s.suggestions.emailListener.attachments&&=j.suggestions.emailListener.attachments.map(m=>m),s.suggestions.emailListener.internalEmailLinks&&=j.suggestions.emailListener.internalEmailLinks.map(m=>m)),await f({businessId:t.id,ownerId:g.context.adminBusinessId,fields:s}),s.suggestions?.tags?.length||s.suggestions?.description?(d({tagIds:s.suggestions?.tags?.map(m=>({id:m.id})),description:s.suggestions?.description??void 0}),i(!0)):n())};return e.jsxs(e.Fragment,{children:[r&&e.jsx(w,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),e.jsx("div",{className:"flex flex-row gap-5",children:e.jsx(D,{...x,children:e.jsxs("form",{onSubmit:p(b),children:[e.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Business:"}),e.jsxs("div",{className:"flex flex-row gap-2",children:["ID: ",t.id,e.jsx(L,{content:t.id})]})]}),e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsx(A,{isInsert:!1,formManager:x,setFetching:u})}),e.jsx("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:e.jsx("button",{type:"submit",onClick:()=>p(b),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:"Update"})})]})})}),e.jsx(re,{businessId:t.id,tagIds:l?.tagIds,description:l?.description,open:o,onOpenChange:i,onClose:n})]})}const ce="mergeBusinesses",de=()=>{const[{fetching:t},n]=O(P),r=c.useCallback(async u=>{const o=`Error merging into business ID [${u.targetBusinessId}]`,i=`${ce}-${u.targetBusinessId}`;B.loading("Merging Businesses",{id:i});try{const l=await n(u),d=R(l,o,i);if(d)return B.success("Success",{id:i,description:"Businesses merged"}),d.mergeBusinesses.id}catch(l){console.error(`${o}: ${l}`),B.error("Error",{id:i,description:o,duration:1e5,closeButton:!0})}},[n]);return{fetching:t,mergeBusinesses:r}};function ue({businessIds:t,onDone:n,resetMerge:r}){const{mergeBusinesses:u,fetching:o}=de(),i=Array.from(new Set(t)),[{data:l,fetching:d}]=N({query:U,variables:{businessIds:i}}),[g,f]=c.useState(l?.businesses[0]),a=l?.businesses.length!==i.length&&"Some businesses were not Found"||void 0,x=l?.businesses||[],p=c.useCallback(async()=>{if(!g){B.error("Error",{description:"No main business selected"});return}if(i.length<2){B.error("Error",{description:"At least 2 businesses are required to execute a merge"});return}return await u({targetBusinessId:g.id,businessIdsToMerge:i.filter(h=>h!==g.id)}),r(),n()},[g,i,u,n,r]);return e.jsxs(e.Fragment,{children:[d&&e.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:e.jsx($,{})}),!d&&a&&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:a})}),!d&&!a&&e.jsxs(e.Fragment,{children:[e.jsxs("table",{children:[e.jsxs("tr",{children:[e.jsx("th",{children:"Main"}),x.map(h=>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(ne,{checked:h.id===g?.id,size:"xl",onClick:()=>{f(h)}})})},h.id))]}),e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),x.map(h=>e.jsx("td",{children:h.name},h.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:d||o,onClick:p,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:n,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:()=>{r(),n()},children:"Reset Merge"})]})]})]})}function ge(t){const[n,{close:r,open:u}]=q(!1),{selected:o,resetMerge:i}=t,l=new Set(o.map(({id:x})=>x)),d=l.size>=1,[g,f]=c.useState(d?"default":"outline");c.useEffect(()=>{f(d?"default":"outline")},[d]);const a=c.useCallback(()=>{r(),o.map(({onChange:x})=>x())},[o,r]);return e.jsxs(e.Fragment,{children:[e.jsx(C,{onClick:()=>{d&&u()},disabled:!d,variant:g,className:S("size-7.5",d?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:e.jsx(ie,{className:"size-5"})}),e.jsx(H,{opened:n,onClose:r,size:"auto",centered:!0,children:e.jsx(ue,{businessIds:Array.from(l),onDone:a,resetMerge:i})})]})}const me=({data:t})=>{const n=v(_,t);return e.jsx("td",{children:e.jsx("div",{style:{whiteSpace:"nowrap"},children:n.hebrewName})})},xe=({data:t})=>{const n=v(Q,t);return e.jsx("td",{children:e.jsx("div",{style:{whiteSpace:"nowrap"},children:n.name})})},he=({data:t,isAllOpened:n,toggleMergeBusiness:r,isSelectedForMerge:u})=>{const[o,i]=c.useState(!1),[l,d]=c.useState(v(J,t));return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx(xe,{data:l}),e.jsx(me,{data:l}),e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(C,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>{i(g=>!g)},children:n||o?e.jsx(F,{className:"size-5"}):e.jsx(I,{className:"size-5"})}),r&&e.jsx(V,{toggleMergeSelected:()=>r(()=>{}),mergeSelected:u})]})})]}),(n||o)&&e.jsx("tr",{children:e.jsx("td",{colSpan:12,children:e.jsx(G,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(oe,{businessID:l.id,updateBusiness:d})})})})]})};function fe({activePage:t,setPage:n,totalPages:r=1,businessName:u,setBusinessName:o}){const{get:i,set:l}=M(),[d,g]=c.useState(u);c.useEffect(()=>{const a=t>1?t.toFixed(0):void 0,x=i("page");a!==x&&a!=="1"&&l("page",a)},[t,i,l]),c.useEffect(()=>{const a=setTimeout(()=>{o(d)},600);return()=>{clearTimeout(a)}},[d,o]);const f=a=>{g(a)};return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(K,{className:"flex-auto",value:t,onChange:n,total:r}),e.jsx(W,{className:"w-72",placeholder:"Business Name",defaultValue:u??void 0,onChange:a=>f(a.target.value===""?void 0:a.target.value)})]})}const Be=()=>{const{get:t}=M(),[n,r]=c.useState(!1),[u,o]=c.useState(t("page")?Number(t("page")):1),[i,l]=c.useState(t("name")?t("page"):void 0),{setFiltersContext:d}=c.useContext(X),[{data:g,fetching:f}]=N({query:te,variables:{page:u,limit:100,name:i}}),[a,x]=c.useState([]),p=c.useCallback((s,m)=>{a.map(y=>y.id).includes(s)?x(a.filter(y=>y.id!==s)):x([...a,{id:s,onChange:m}])},[a]);function h(){x([])}c.useEffect(()=>{d(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(fe,{activePage:u,setPage:o,businessName:i,setBusinessName:l,totalPages:g?.allBusinesses?.pageInfo.totalPages}),e.jsx(Y,{label:"Expand all businesses",children:e.jsx(C,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(s=>!s),children:n?e.jsx(F,{className:"size-5"}):e.jsx(I,{className:"size-5"})})}),e.jsx(ge,{selected:a,resetMerge:h})]}))},[g,u,i,n,d,o,l,r,a]);const b=g?.allBusinesses?.nodes.filter(s=>s.__typename==="LtdFinancialEntity").sort((s,m)=>s.name.toLowerCase()>m.name.toLowerCase()?1:-1)??[],j=new Set(a.map(s=>s.id));return e.jsx(Z,{title:`Businesses (${b.length})`,description:"All businesses",children:f?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(ee,{className:S("h-10 w-10 animate-spin mr-2")})}):e.jsxs(se,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{className:"sticky top-0 z-20",children:e.jsxs("tr",{className:"px-10 py-10 title-font tracking-wider font-medium text-gray-900 text-sm bg-gray-100 rounded-tl rounded-bl",children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Hebrew Name"}),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:b.map(s=>e.jsx(he,{data:s,isAllOpened:n,toggleMergeBusiness:p?m=>p(s.id,m):void 0,isSelectedForMerge:j.has(s.id)??!1},s.id))})]})})};export{Be as Businesses};
@@ -0,0 +1 @@
1
+ import{r as l,d0 as w,u as P,d3 as K,j as e,d1 as A,bC as O,B as d,d2 as U,U as z,k as B,Y as b,dk as _,l as H,dl as L,bR as D,cj as M,bW as I,bX as k,a4 as q,a5 as G,a6 as J,a7 as Q,aK as X,bx as W,F as Y,a as Z,dm as $,c as ee,L as te,dn as se,dp as ae,dq as ne,dr as le,ds as S,dt as re,du as T,dv as ie,dw as R,dx as oe,dy as de,dz as ce,dA as me,dB as ue,dC as ge,dD as xe,dE as he}from"./index-BsGG-RLV.js";import{D as je}from"./data-table-pagination-CQQBbtVE.js";import{s as pe}from"./sub-DKnwnbwx.js";import{A as v}from"./arrow-up-down-Bt3_puEZ.js";import"./subMonths-B44KizJf.js";function fe({filter:t,setFilter:s,closeModal:h}){const{userContext:j}=l.useContext(z),x=B({defaultValues:{ownerIDs:j?.context.adminBusinessId?[j.context.adminBusinessId]:void 0,toDate:b(new Date,"yyyy-MM-dd"),fromDate:b(pe(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=x,{selectableFinancialEntities:r,fetching:c}=_(),C=a=>{s(a),h()};function m(){s({}),h()}return e.jsxs(e.Fragment,{children:[c?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(H,{...x,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(L,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:c,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(M,{...a,data:r,value:a.value??[],disabled:c,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(k,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:I,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(k,{...a,onChange:i=>{const p=i?typeof i=="string"?i:b(i,"yyyy-MM-dd"):void 0;p!==a.value&&a.onChange(p)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(q,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(G,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(J,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(X,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:c,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:m,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:h,children:"Cancel"})]})]})})]})}function ve({filter:t={},setFilter:s,initiallyOpened:h=!1}){const[j,x]=l.useState(h),[o,y]=l.useState(!w(t)),{get:r,set:c}=P();l.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=r("documentsFilters");m!==a&&c("documentsFilters",m)},[t,r,c]);const C=l.useCallback(m=>{K(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(A,{opened:j,onClose:()=>x(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>x(!1)}),modalSize:"xl"}),e.jsx(O,{inline:!0,size:16,disabled:!o,children:e.jsx(d,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(U,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(d,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:b(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(d,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(v,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(W,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?b(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?b(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],we=()=>{const[t,s]=l.useState(null),[h,j]=l.useState(!1),{get:x}=P(),o=x("documentsFilters"),y=l.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[r,c]=l.useState(y),[C,m]=l.useState([]),[a,g]=l.useState({}),{setFiltersContext:i}=l.useContext(Y),[{data:p,fetching:F},N]=Z({query:ue,variables:{filters:r??{}},pause:!0});l.useEffect(()=>{r&&N()},[r,N]);const f=$({data:p?.documentsByFilters??[],columns:E,getCoreRowModel:he(),getPaginationRowModel:xe(),onSortingChange:m,getSortedRowModel:ge(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),V=f.getState().pagination.pageIndex;return l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(je,{table:f}),e.jsx(ve,{filter:r,setFilter:c,initiallyOpened:!r})]}))},[f,F,r,i,c,y,V]),e.jsx(ee,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(oe,{children:[e.jsx(de,{asChild:!0,children:e.jsx(d,{className:"ml-auto",children:"Columns"})}),e.jsx(ce,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(me,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(d,{onClick:()=>j(!0),children:"Upload Documents"})]}),children:F?e.jsx(te,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(se,{open:h,onOpenChange:j,onChange:N}),t&&e.jsx(A,{modalSize:"45%",content:e.jsx(ae,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(ne,{children:[e.jsx(le,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(re,{children:u.isPlaceholder?null:T(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ie,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(R,{children:T(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(R,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{we as DocumentsReport,E as columns};