@accounter/client 0.0.8-alpha-20251028120806-2ffeafaf43eece2a7685012216a6fcc962bc1406 → 0.0.8-alpha-20251028122020-22393814f274e46c107aca0d7b3f8acafeabbb81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -18
- package/dist/assets/{Checkbox-B3flPa-J.js → Checkbox-D9q62D8v.js} +3 -3
- package/dist/assets/{Progress-C8oF3q5W.js → Progress-DRjeFVVZ.js} +1 -1
- package/dist/assets/{Typography-CYdMLBAy.js → Typography-CbuOxmxV.js} +1 -1
- package/dist/assets/{accordion-D-BLHAB1.js → accordion-pfIKfX4Y.js} +1 -1
- package/dist/assets/{accountant-approvals-DXpMnnLy.js → accountant-approvals-CXholBsN.js} +1 -1
- package/dist/assets/{all-charges-C-gOh0e5.js → all-charges-Cq7JGIw2.js} +1 -1
- package/dist/assets/{arrow-up-down-0SO17vu7.js → arrow-up-down-Dh7BsmBW.js} +2 -2
- package/dist/assets/{building-2-UCsUqLT9.js → building-2-DsBmoiLM.js} +2 -2
- package/dist/assets/business-B0Z0CMjU.js +32 -0
- package/dist/assets/{business-header-DN3_Woio.js → business-header-DDDNCIl7.js} +1 -1
- package/dist/assets/{business-transactions-single-ymtxGGw6.js → business-transactions-single-C8LdMKdp.js} +1 -1
- package/dist/assets/{business-trip-Be37IRkC.js → business-trip-C5sPEx_a.js} +1 -1
- package/dist/assets/{charges-filters-DzuinQ4L.js → charges-filters-CoxkLwLG.js} +1 -1
- package/dist/assets/{charges-ledger-validation-D7JvV6db.js → charges-ledger-validation-ZfrK_Aim.js} +1 -1
- package/dist/assets/{chart-BiIM6DWC.js → chart-DT0S7sTG.js} +1 -1
- package/dist/assets/{data-table-pagination-C_EzPtAd.js → data-table-pagination-BIpu2Fzl.js} +3 -3
- package/dist/assets/{editable-business-trip-Dz-_eywR.js → editable-business-trip-DTNGD1cG.js} +5 -5
- package/dist/assets/{index-Cyhthk3f.js → index-0cS85m-R.js} +1 -1
- package/dist/assets/{index-D3EgDFsb.js → index-2pcc30po.js} +3 -3
- package/dist/assets/{index-oHas_Yts.js → index-3FSzrAcq.js} +1 -1
- package/dist/assets/{index-DtE5Y1ZB.css → index-BU7S_VxQ.css} +1 -1
- package/dist/assets/{index-DeT7-16U.js → index-BbN569Ip.js} +2 -2
- package/dist/assets/index-BxZQN0p6.js +1 -0
- package/dist/assets/{index-6Nuk8w9V.js → index-C82IZR7M.js} +1 -1
- package/dist/assets/{index-fxPSWWbK.js → index-CH7ebmNN.js} +1 -1
- package/dist/assets/{index-BALGUcFk.js → index-CM0HVUR5.js} +1 -1
- package/dist/assets/{index-B6-Dd7fT.js → index-CQqv3cqO.js} +2 -2
- package/dist/assets/{index-DArFiXr9.js → index-CX33776G.js} +1 -1
- package/dist/assets/{index-DPpEG9bb.js → index-CbXs_TpY.js} +348 -353
- package/dist/assets/{index-Dmofir00.js → index-CfBh4W-y.js} +3 -3
- package/dist/assets/{index-DmcLgst1.js → index-CqQ5r7_V.js} +1 -1
- package/dist/assets/{index-ovonWEgv.js → index-Cst4LEdT.js} +7 -7
- package/dist/assets/{index-VP5lfKug.js → index-DA5dVRCr.js} +4 -4
- package/dist/assets/{index-B0mITck_.js → index-DTVw9idN.js} +1 -1
- package/dist/assets/{index-CC0Or6Vc.js → index-DUATm10r.js} +1 -1
- package/dist/assets/{index-DjStozDN.js → index-DqHvHWlp.js} +1 -1
- package/dist/assets/{index-MxAmN534.js → index-DxULggyH.js} +7 -7
- package/dist/assets/{index-6MojwZ8r.js → index-TrMaspii.js} +1 -1
- package/dist/assets/{index-DzlC3eG5.js → index-c5ib3rgl.js} +1 -1
- package/dist/assets/{index-fcGRxy6s.js → index-cLwQhCXe.js} +2 -2
- package/dist/assets/{index-Ck1_vgAE.js → index-tjro57tL.js} +1 -1
- package/dist/assets/{index.es-CflUflSH.js → index.es-BUc4piRK.js} +1 -1
- package/dist/assets/{issue-document-cScH_CFA.js → issue-document-B_RjziMe.js} +1 -1
- package/dist/assets/{login-page-DONx5Mdv.js → login-page-B2shLJFL.js} +1 -1
- package/dist/assets/{missing-info-charges-BrifDJy6.js → missing-info-charges-DNA-ZjLm.js} +1 -1
- package/dist/assets/{page-not-found-_lLiym0-.js → page-not-found-CAQqHYW0.js} +1 -1
- package/dist/assets/{pencil-CUBEsfNn.js → pencil-DZ5pOEVX.js} +2 -2
- package/dist/assets/{report-commentary-row-SS9lG0SF.js → report-commentary-row-BHgKNhnX.js} +1 -1
- package/dist/assets/{save-ZTUk8WJM.js → save-CL8bhoFP.js} +2 -2
- package/dist/assets/{sub-CmPBwyt8.js → sub-C_dogjkK.js} +1 -1
- package/dist/assets/subMonths-adiK1C_h.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +5 -5
- package/src/components/business/admin-business-section.tsx +36 -74
- package/src/components/clients/modify-client-dialog.tsx +9 -27
- package/src/components/common/modals/insert-business.tsx +36 -88
- package/src/components/layout/user-nav.tsx +3 -22
- package/src/gql/gql.ts +3 -3
- package/src/gql/graphql.ts +16 -19
- package/dist/assets/business-c9QmKg9c.js +0 -27
- package/dist/assets/index-DSLXwBq5.js +0 -1
- package/dist/assets/subMonths-B4EBfn4r.js +0 -1
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import{D as Ne,G as ve,S as Se,H as ue,a as be,J as Rs,r as N,j as e,K as qe,N as Ge,O as Ms,n as ps,Q as $s,i as Ie,t as _,l as De,U as Us,V as Te,W as We,X as Ce,Y as q,Z as G,_ as js,$ as W,a0 as K,a1 as Ee,a2 as H,a3 as g,a4 as f,a5 as v,a6 as y,v as D,a7 as C,a8 as b,a9 as ae,aa as Ke,B as E,ab as zs,ac as He,ad as Xe,ae as O,af as gs,ag as Je,ah as qs,s as Gs,C as Ws,ai as Ks,aj as P,ak as ss,al as Hs,am as Xs,an as Js,ao as Y,ap as Q,aq as Qs,ar as Ys,as as Zs,at as Ve,au as he,av as xe,aw as pe,ax as je,ay as et,az as ge,aA as st,aB as tt,aC as Z,aD as ee,aE as ye,aF as nt,aG as at,aH as _e,aI as Re,aJ as fs,aK as rt,aL as Me,aM as it,aN as ts,aO as vs,aP as ns,aQ as ys,aR as lt,aS as ct,aT as Qe,aU as Ns,aV as Ye,aW as bs,aX as Cs,aY as ws,aZ as As,a_ as Ss,a$ as ks,b0 as oe,b1 as ot,b2 as as,b3 as dt,b4 as mt,b5 as ut,b6 as ht,b7 as xt,b8 as pt,b9 as jt,ba as gt,bb as ft,bc as A,bd as vt,be as Ze,bf as yt,bg as Nt,bh as bt,bi as Ct,bj as wt,bk as At,bl as J,bm as St,bn as kt,bo as z,bp as It,bq as Dt,br as Tt,bs as Et}from"./index-DPpEG9bb.js";import{S as es}from"./save-ZTUk8WJM.js";import{B as Bt}from"./business-header-DN3_Woio.js";import{i as Pt,D as Ot,f as Lt,E as Ft,L as Pe,a as we,C as Vt,A as _t,b as de,c as Rt,d as $e,h as Mt,e as $t,g as Is,u as Ut,G as zt,j as rs,k as qt,X as Ds,Y as Ts,l as Gt,m as Wt,R as Kt,n as Ht,o as Xt,p as Jt}from"./chart-BiIM6DWC.js";import{P as Qt}from"./pencil-CUBEsfNn.js";import{A as Yt,a as Oe,b as Le,c as is}from"./accordion-D-BLHAB1.js";import{B as Zt}from"./building-2-UCsUqLT9.js";import"./sequential-CAnleQny.js";/**
|
|
2
|
-
* @license lucide-react v0.546.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const en=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ls=Ne("circle-check",en);/**
|
|
7
|
-
* @license lucide-react v0.546.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const sn=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],Ae=Ne("dollar-sign",sn);/**
|
|
12
|
-
* @license lucide-react v0.546.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const tn=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],nn=Ne("file-check",tn);/**
|
|
17
|
-
* @license lucide-react v0.546.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const an=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],rn=Ne("plug",an);/**
|
|
22
|
-
* @license lucide-react v0.546.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const ln=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Fe=Ne("trending-up",ln);function Es(s){switch(s){case ve.Annual:return"Annual";case ve.Monthly:return"Monthly";default:throw new Error(`Unsupported Billing Cycle: ${s}`)}}function Bs(s){switch(s){case Se.Enterprise:return"Enterprise";case Se.Pro:return"Pro";default:throw new Error(`Unsupported Subscription plan: ${s}`)}}function cn(s){return ue(s,"yyyy-MM-dd")}function on({businessId:s,tagIds:t,description:n,open:a,onOpenChange:l,onClose:o}){const[{data:i,fetching:r},c]=be({pause:!0,query:Rs,variables:{businessId:s,tagsDifferentThan:t?t.map(u=>u.id):void 0,descriptionDifferentThan:n}});N.useEffect(()=>{a&&(t||n)&&!i&&c()},[a,t,n,c,i]);const d=N.useCallback(u=>{l(u),a&&!u&&o?.()},[l,o,a]),h=N.useMemo(()=>a&&(!!t||!!n)&&i&&i?.similarChargesByBusiness.length>0,[a,t,n,i]);return e.jsx(qe,{open:h,onOpenChange:d,children:e.jsx(Ge,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:u=>u.stopPropagation(),children:e.jsx(Ms,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:r?e.jsx(ps,{}):t||n?e.jsx($s,{data:i?.similarChargesByBusiness??[],tagIds:t,description:n,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const dn="updateAdminBusiness",mn=()=>{const[{fetching:s},t]=Ie(Us),n=N.useCallback(async a=>{const l=`Error updating admin business ID [${a.adminBusinessId}]`,o=`${dn}-${a.adminBusinessId}`;_.loading("Updating admin business",{id:o});try{const i=await t(a),r=De(i,l,o,"updateAdminBusiness");if(r)return _.success("Success",{id:o,description:"Admin Business Updated"}),r.updateAdminBusiness}catch(i){console.error(`${l}: ${i}`),_.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateAdminBusiness:n}},un=He({withholdingTaxBookNumber:O().min(1,{message:"Withholding Tax Book Number is required"}),withholdingTaxFileNumber:O().min(1,{message:"Withholding Tax File Number is required"}),socialSecurityEmployerId:O().min(1,{message:"National Insurance Employer ID is required"}),taxAdvancesRate:gs().min(0,{message:"Advance Tax Rate must be at least 0"}).max(100,{message:"Advance Tax Rate must be at most 100"}),taxAdvancesId:O().min(1,{message:"Tax Advances ID is required"}),registrationDate:O().min(1,{message:"Business Registration Start Date is required"})});function cs(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{withholdingTaxBookNumber:s.adminInfo.withholdingTaxBookNumber??"",withholdingTaxFileNumber:s.adminInfo.withholdingTaxFileNumber??"",socialSecurityEmployerId:s.adminInfo.socialSecurityEmployerId??"",taxAdvancesRate:s.adminInfo.taxAdvancesRate??0,taxAdvancesId:s.adminInfo.taxAdvancesId??"",registrationDate:s.adminInfo.registrationDate??""}}function hn(s){return{withholdingTaxBookNumber:s.withholdingTaxBookNumber,withholdingTaxFileNumber:s.withholdingTaxFileNumber,socialSecurityEmployerId:s.socialSecurityEmployerId,taxAdvancesRate:s.taxAdvancesRate,taxAdvancesId:s.taxAdvancesId,registrationDate:s.registrationDate?cn(new Date(s.registrationDate)):void 0}}function xn({data:s,refetchBusiness:t}){const n=Ce(zs,s),[a,l]=N.useState(cs(n)),{updateAdminBusiness:o,fetching:i}=mn(),r=Te({resolver:We(un),defaultValues:a}),c=async d=>{if(!n)return;const h=Xe(d,r.formState.dirtyFields);if(!h)return;const u=hn(h);await o({adminBusinessId:n.id,fields:u}),t?.()};return N.useEffect(()=>{if(n){const d=cs(n);l(d),r.reset(d)}},[n,r]),e.jsxs(q,{children:[e.jsxs(G,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"h-5 w-5 text-primary"}),e.jsx(W,{children:"Admin Business Configuration"})]}),e.jsx(K,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Ee,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(c),className:"space-y-6",children:[e.jsx(H,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Withholding Tax"}),e.jsx(g,{control:r.control,name:"withholdingTaxBookNumber",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Book Number"}),e.jsx(y,{children:e.jsx(D,{placeholder:"Enter book number",...d,className:C(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:r.control,name:"withholdingTaxFileNumber",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"File Number"}),e.jsx(y,{children:e.jsx(D,{placeholder:"Enter file number",...d,className:C(h)})}),e.jsx(b,{})]})}),e.jsx(ae,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Tax Advances"}),e.jsx(g,{control:r.control,name:"taxAdvancesId",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Identification number"}),e.jsx(y,{children:e.jsx(D,{placeholder:"Enter tax advances ID",...d,className:C(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:r.control,name:"taxAdvancesRate",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Tax Rate (%)"}),e.jsx(y,{children:e.jsx(D,{type:"number",step:"0.01",min:"0",max:"100",placeholder:"Enter tax rate",...d,className:C(h)})}),e.jsx(b,{})]})}),e.jsx(ae,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Social Security"}),e.jsx(g,{control:r.control,name:"socialSecurityEmployerId",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Employer Identifier"}),e.jsx(y,{children:e.jsx(D,{placeholder:"Enter employer ID",...d,className:C(h)})}),e.jsx(b,{})]})}),e.jsx(ae,{className:"md:col-span-2"}),e.jsx(g,{control:r.control,name:"registrationDate",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Business Registration Start Date"}),e.jsx(y,{children:e.jsx(D,{type:"date",...d,className:C(h)})}),e.jsx(b,{})]})})]})}),e.jsx(Ke,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(E,{type:"submit",disabled:i||Object.keys(r.formState.dirtyFields).length===0||!r.formState.isValid,children:[e.jsx(es,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function pn({businessId:s}){const{userContext:t}=N.useContext(Je),[n,a]=N.useState(1),[{data:l,fetching:o}]=be({query:qs,variables:{filters:{byOwners:t?.context.adminBusinessId?[t.context.adminBusinessId]:void 0,sortBy:{field:Ks.Date,asc:!1},byBusinesses:[s]},page:n,limit:100}}),i=l?.allCharges?.pageInfo.totalPages??1,r=l?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(q,{children:[e.jsxs(G,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(W,{children:"Charges"}),e.jsx(K,{children:"Recurring and one-time charges for this business"})]})}),i>1&&e.jsx(Gs,{className:"flex-fit",value:n,onChange:a,total:i})]}),e.jsx(H,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Ws,{data:r,isAllOpened:!1})})})]})}var jn=["type","layout","connectNulls","ref"],gn=["key"];function re(s){"@babel/helpers - typeof";return re=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},re(s)}function os(s,t){if(s==null)return{};var n=fn(s,t),a,l;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(l=0;l<o.length;l++)a=o[l],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(s,a)&&(n[a]=s[a])}return n}function fn(s,t){if(s==null)return{};var n={};for(var a in s)if(Object.prototype.hasOwnProperty.call(s,a)){if(t.indexOf(a)>=0)continue;n[a]=s[a]}return n}function fe(){return fe=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(s[a]=n[a])}return s},fe.apply(this,arguments)}function ds(s,t){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);t&&(a=a.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),n.push.apply(n,a)}return n}function F(s){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ds(Object(n),!0).forEach(function(a){R(s,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):ds(Object(n)).forEach(function(a){Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(n,a))})}return s}function ne(s){return bn(s)||Nn(s)||yn(s)||vn()}function vn(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
27
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yn(s,t){if(s){if(typeof s=="string")return Ue(s,t);var n=Object.prototype.toString.call(s).slice(8,-1);if(n==="Object"&&s.constructor&&(n=s.constructor.name),n==="Map"||n==="Set")return Array.from(s);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ue(s,t)}}function Nn(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function bn(s){if(Array.isArray(s))return Ue(s)}function Ue(s,t){(t==null||t>s.length)&&(t=s.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=s[n];return a}function Cn(s,t){if(!(s instanceof t))throw new TypeError("Cannot call a class as a function")}function ms(s,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(s,Os(a.key),a)}}function wn(s,t,n){return t&&ms(s.prototype,t),n&&ms(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function An(s,t,n){return t=ke(t),Sn(s,Ps()?Reflect.construct(t,n||[],ke(s).constructor):t.apply(s,n))}function Sn(s,t){if(t&&(re(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kn(s)}function kn(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ps(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ps=function(){return!!s})()}function ke(s){return ke=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ke(s)}function In(s,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(t&&t.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),t&&ze(s,t)}function ze(s,t){return ze=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,l){return a.__proto__=l,a},ze(s,t)}function R(s,t,n){return t=Os(t),t in s?Object.defineProperty(s,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[t]=n,s}function Os(s){var t=Dn(s,"string");return re(t)=="symbol"?t:t+""}function Dn(s,t){if(re(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var a=n.call(s,t);if(re(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var ie=(function(s){function t(){var n;Cn(this,t);for(var a=arguments.length,l=new Array(a),o=0;o<a;o++)l[o]=arguments[o];return n=An(this,t,[].concat(l)),R(n,"state",{isAnimationFinished:!0,totalLength:0}),R(n,"generateSimpleStrokeDasharray",function(i,r){return"".concat(r,"px ").concat(i-r,"px")}),R(n,"getStrokeDasharray",function(i,r,c){var d=c.reduce(function(B,L){return B+L});if(!d)return n.generateSimpleStrokeDasharray(r,i);for(var h=Math.floor(i/d),u=i%d,x=r-i,S=[],m=0,p=0;m<c.length;p+=c[m],++m)if(p+c[m]>u){S=[].concat(ne(c.slice(0,m)),[u-p]);break}var k=S.length%2===0?[0,x]:[x];return[].concat(ne(t.repeat(c,h)),ne(S),k).map(function(B){return"".concat(B,"px")}).join(", ")}),R(n,"id",Ut("recharts-line-")),R(n,"pathRef",function(i){n.mainCurve=i}),R(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),R(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return In(t,s),wn(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();this.setState({totalLength:a})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();a!==this.state.totalLength&&this.setState({totalLength:a})}}},{key:"getTotalLength",value:function(){var a=this.mainCurve;try{return a&&a.getTotalLength&&a.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(a,l){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,i=o.points,r=o.xAxis,c=o.yAxis,d=o.layout,h=o.children,u=Lt(h,Ft);if(!u)return null;var x=function(p,k){return{x:p.x,y:p.y,value:p.value,errorVal:Is(p.payload,k)}},S={clipPath:a?"url(#clipPath-".concat(l,")"):null};return P.createElement(Pe,S,u.map(function(m){return P.cloneElement(m,{key:"bar-".concat(m.props.dataKey),data:i,xAxis:r,yAxis:c,layout:d,dataPointFormatter:x})}))}},{key:"renderDots",value:function(a,l,o){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var r=this.props,c=r.dot,d=r.points,h=r.dataKey,u=we(this.props,!1),x=we(c,!0),S=d.map(function(p,k){var B=F(F(F({key:"dot-".concat(k),r:3},u),x),{},{index:k,cx:p.x,cy:p.y,value:p.value,dataKey:h,payload:p.payload,points:d});return t.renderDotItem(c,B)}),m={clipPath:a?"url(#clipPath-".concat(l?"":"dots-").concat(o,")"):null};return P.createElement(Pe,fe({className:"recharts-line-dots",key:"dots"},m),S)}},{key:"renderCurveStatically",value:function(a,l,o,i){var r=this.props,c=r.type,d=r.layout,h=r.connectNulls;r.ref;var u=os(r,jn),x=F(F(F({},we(u,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:l?"url(#clipPath-".concat(o,")"):null,points:a},i),{},{type:c,layout:d,connectNulls:h});return P.createElement(Vt,fe({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(a,l){var o=this,i=this.props,r=i.points,c=i.strokeDasharray,d=i.isAnimationActive,h=i.animationBegin,u=i.animationDuration,x=i.animationEasing,S=i.animationId,m=i.animateNewValues,p=i.width,k=i.height,B=this.state,L=B.prevPoints,M=B.totalLength;return P.createElement(_t,{begin:h,duration:u,isActive:d,easing:x,from:{t:0},to:{t:1},key:"line-".concat(S),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function($){var V=$.t;if(L){var X=L.length/r.length,U=r.map(function(T,Be){var le=Math.floor(Be*X);if(L[le]){var ce=L[le],te=de(ce.x,T.x),Fs=de(ce.y,T.y);return F(F({},T),{},{x:te(V),y:Fs(V)})}if(m){var Vs=de(p*2,T.x),_s=de(k/2,T.y);return F(F({},T),{},{x:Vs(V),y:_s(V)})}return F(F({},T),{},{x:T.x,y:T.y})});return o.renderCurveStatically(U,a,l)}var se=de(0,M),j=se(V),w;if(c){var I="".concat(c).split(/[,\s]+/gim).map(function(T){return parseFloat(T)});w=o.getStrokeDasharray(j,M,I)}else w=o.generateSimpleStrokeDasharray(M,j);return o.renderCurveStatically(r,a,l,{strokeDasharray:w})})}},{key:"renderCurve",value:function(a,l){var o=this.props,i=o.points,r=o.isAnimationActive,c=this.state,d=c.prevPoints,h=c.totalLength;return r&&i&&i.length&&(!d&&h>0||!Rt(d,i))?this.renderCurveWithAnimation(a,l):this.renderCurveStatically(i,a,l)}},{key:"render",value:function(){var a,l=this.props,o=l.hide,i=l.dot,r=l.points,c=l.className,d=l.xAxis,h=l.yAxis,u=l.top,x=l.left,S=l.width,m=l.height,p=l.isAnimationActive,k=l.id;if(o||!r||!r.length)return null;var B=this.state.isAnimationFinished,L=r.length===1,M=ss("recharts-line",c),$=d&&d.allowDataOverflow,V=h&&h.allowDataOverflow,X=$||V,U=$e(k)?this.id:k,se=(a=we(i,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},j=se.r,w=j===void 0?3:j,I=se.strokeWidth,T=I===void 0?2:I,Be=Mt(i)?i:{},le=Be.clipDot,ce=le===void 0?!0:le,te=w*2+T;return P.createElement(Pe,{className:M},$||V?P.createElement("defs",null,P.createElement("clipPath",{id:"clipPath-".concat(U)},P.createElement("rect",{x:$?x:x-S/2,y:V?u:u-m/2,width:$?S:S*2,height:V?m:m*2})),!ce&&P.createElement("clipPath",{id:"clipPath-dots-".concat(U)},P.createElement("rect",{x:x-te/2,y:u-te/2,width:S+te,height:m+te}))):null,!L&&this.renderCurve(X,U),this.renderErrorBar(X,U),(L||i)&&this.renderDots(X,ce,U),(!p||B)&&$t.renderCallByParent(this.props,r))}}],[{key:"getDerivedStateFromProps",value:function(a,l){return a.animationId!==l.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,prevPoints:l.curPoints}:a.points!==l.curPoints?{curPoints:a.points}:null}},{key:"repeat",value:function(a,l){for(var o=a.length%2!==0?[].concat(ne(a),[0]):a,i=[],r=0;r<l;++r)i=[].concat(ne(i),ne(o));return i}},{key:"renderDotItem",value:function(a,l){var o;if(P.isValidElement(a))o=P.cloneElement(a,l);else if(Pt(a))o=a(l);else{var i=l.key,r=os(l,gn),c=ss("recharts-line-dot",typeof a!="boolean"?a.className:"");o=P.createElement(Ot,fe({key:i},r,{className:c}))}return o}}])})(N.PureComponent);R(ie,"displayName","Line");R(ie,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!zt.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});R(ie,"getComposedData",function(s){var t=s.props,n=s.xAxis,a=s.yAxis,l=s.xAxisTicks,o=s.yAxisTicks,i=s.dataKey,r=s.bandSize,c=s.displayedData,d=s.offset,h=t.layout,u=c.map(function(x,S){var m=Is(x,i);return h==="horizontal"?{x:rs({axis:n,ticks:l,bandSize:r,entry:x,index:S}),y:$e(m)?null:a.scale(m),value:m,payload:x}:{x:$e(m)?null:n.scale(m),y:rs({axis:a,ticks:o,bandSize:r,entry:x,index:S}),value:m,payload:x}});return F({points:u,layout:h},d)});var Tn=qt({chartName:"LineChart",GraphicalChild:ie,axisComponents:[{axisType:"xAxis",AxisComp:Ds},{axisType:"yAxis",AxisComp:Ts}],formatAxisMap:Gt});const me=[{month:"Jan",revenue:12500,expenses:8200},{month:"Feb",revenue:15800,expenses:9100},{month:"Mar",revenue:18200,expenses:10500},{month:"Apr",revenue:16900,expenses:9800},{month:"May",revenue:21300,expenses:11200},{month:"Jun",revenue:24500,expenses:12800},{month:"Jul",revenue:22800,expenses:11900},{month:"Aug",revenue:26100,expenses:13500},{month:"Sep",revenue:28900,expenses:14200},{month:"Oct",revenue:31200,expenses:15100}];function En(){const s=me.reduce((n,a)=>n+a.revenue,0),t=s/me.length;return e.jsxs(q,{children:[e.jsxs(G,{children:[e.jsx(W,{children:"Revenue Analytics"}),e.jsx(K,{children:"Revenue and expenses over time"})]}),e.jsxs(H,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3 mb-6",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ae,{className:"h-4 w-4"}),"Total Revenue"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",s.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+24.5% from last period"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ae,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",t.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+18.2% growth rate"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Ae,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",me[me.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Wt,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Kt,{width:"100%",height:"100%",children:e.jsxs(Tn,{data:me,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Ht,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Ds,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ts,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Xt,{content:e.jsx(Jt,{})}),e.jsx(ie,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(ie,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Bn="updateBusiness",Ls=()=>{const[{fetching:s},t]=Ie(Hs),n=N.useCallback(async a=>{const l=`Error updating business ID [${a.businessId}]`,o=`${Bn}-${a.businessId}`;_.loading("Updating business",{id:o});try{const i=await t(a),r=De(i,l,o,"updateBusiness");if(r)return _.success("Success",{id:o,description:"Business updated"}),r.updateBusiness}catch(i){console.error(`${l}: ${i}`),_.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateBusiness:n}},Pn=Object.values(nt);function us(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{isClient:!!s.clientInfo?.id,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough??void 0,isDocumentsOptional:s.isDocumentsOptional??void 0,isVatOptional:s.optionalVAT??void 0,isExemptDealer:s.exemptDealer??void 0,sortCode:s.sortCode?.key?.toString()??void 0,taxCategory:s.taxCategory?.id??void 0,pcn874RecordType:s?.pcn874RecordType??void 0,irsCode:s?.irsCode??void 0,description:s.suggestions?.description??void 0,tags:s.suggestions?.tags?.map(t=>t.id)??[],phrases:s.suggestions?.phrases??[],emails:s.suggestions?.emails??[],internalLinks:s.suggestions?.emailListener?.internalEmailLinks??[],attachmentTypes:s.suggestions?.emailListener?.attachments??[],useMessageBody:s.suggestions?.emailListener?.emailBody??void 0}}function On(s){const n=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,l=s.description||s.tags||s.phrases||s.emails||n?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:n}:void 0;return{optionalVAT:s.isVatOptional,exemptDealer:s.isExemptDealer,sortCode:s.sortCode?parseInt(s.sortCode):void 0,taxCategory:s.taxCategory,pcn874RecordType:s.pcn874RecordType,irsCode:s.irsCode,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough,isDocumentsOptional:s.isDocumentsOptional,suggestions:l}}function Ln({data:s,refetchBusiness:t}){const n=Ce(Js,s),[a,l]=N.useState(us(n)),{userContext:o}=N.useContext(Je),{updateBusiness:i,fetching:r}=Ls(),[c,d]=N.useState(!1),[h,u]=N.useState(void 0),x=Te({defaultValues:a}),S=async p=>{if(!n||!o?.context.adminBusinessId)return;const k=Xe(p,x.formState.dirtyFields);if(!k)return;const B=On(k);await i({businessId:n.id,ownerId:o.context.adminBusinessId,fields:B}),k.tags?.length||k.description?(u({tagIds:k.tags?.map(L=>({id:L})),description:k.description}),d(!0)):t?.()};if(N.useEffect(()=>{if(n){const p=us(n);l(p),x.reset(p)}},[n,x]),!n)return e.jsx("div",{});const m=x.watch("isClient");return e.jsxs(q,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Configurations"}),e.jsx(K,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!m&&e.jsx(Xs,{businessId:n.id,onDone:t})]})}),e.jsx(Ee,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(S),children:[e.jsxs(H,{className:"space-y-6",children:[e.jsx(Fn,{form:x}),e.jsx(ae,{}),e.jsx(Vn,{form:x}),e.jsx(ae,{}),e.jsx(_n,{form:x}),e.jsx(ae,{}),e.jsx(Rn,{form:x})]}),e.jsx(Ke,{className:"flex justify-end border-t pt-6",children:e.jsxs(E,{type:"submit",disabled:r||Object.keys(x.formState.dirtyFields).length===0,children:[e.jsx(es,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(on,{businessId:n.id,tagIds:h?.tagIds,description:h?.description,open:c,onOpenChange:d,onClose:t})]})}function Fn({form:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Business Status & Behavior"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{control:s.control,name:"isClient",render:({field:t,fieldState:n})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{children:"Is Client"}),e.jsx(Y,{children:"Mark this business as a client"})]}),e.jsx(y,{children:e.jsx(Q,{disabled:!0,checked:t.value,onCheckedChange:t.onChange,className:C(n)})})]})}),e.jsx(g,{control:s.control,name:"isActive",render:({field:t,fieldState:n})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{children:"Is Active"}),e.jsx(Y,{children:"Business is currently active"})]}),e.jsx(y,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:C(n)})})]})}),e.jsx(g,{control:s.control,name:"isReceiptEnough",render:({field:t,fieldState:n})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{children:"Is Receipt Enough"}),e.jsx(Y,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(y,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:C(n)})})]})}),e.jsx(g,{control:s.control,name:"isDocumentsOptional",render:({field:t,fieldState:n})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{children:"No Docs Required"}),e.jsx(Y,{children:"Skip document validation for common charges"})]}),e.jsx(y,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:C(n)})})]})}),e.jsx(g,{control:s.control,name:"isVatOptional",render:({field:t,fieldState:n})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{children:"Is VAT Optional"}),e.jsx(Y,{children:"Mute missing VAT indicator"})]}),e.jsx(y,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:C(n)})})]})}),e.jsx(g,{control:s.control,name:"isExemptDealer",render:({field:t,fieldState:n})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{children:"Is Exempt Dealer"}),e.jsx(Y,{children:"Business is exempt from VAT requirements"})]}),e.jsx(y,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:C(n)})})]})})]})]})}function Vn({form:s}){const{selectableTaxCategories:t,fetching:n}=Qs(),{selectableSortCodes:a,fetching:l,sortCodes:o}=Ys(),{selectableTags:i,fetching:r}=Zs(),c=N.useCallback(d=>{if(d){const h=o.find(u=>Number(u.key)===Number(d));h&&(h.defaultIrsCode?s.setValue("irsCode",h.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,o]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Default Settings"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{control:s.control,name:"sortCode",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Sort Code"}),e.jsx(y,{children:e.jsx(Ve,{onChange:u=>{c(u),d.onChange(u)},data:a,value:d.value,disabled:l,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(h)}})}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"taxCategory",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Tax Category"}),e.jsx(y,{children:e.jsx(Ve,{data:t,disabled:n,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(h)}})}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"PCN874 Record Type"}),e.jsxs(he,{onValueChange:d.onChange,value:d.value,children:[e.jsx(y,{children:e.jsx(xe,{className:C(h),children:e.jsx(pe,{})})}),e.jsx(je,{children:Object.entries(et).map(([u,x])=>e.jsx(ge,{value:u,children:`${x} (${u})`},u))})]}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"irsCode",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"IRS Code"}),e.jsx(y,{children:e.jsx(st,{value:d.value??void 0,onValueChange:u=>d.onChange(u??null),hideControls:!0,decimalScale:0,className:C(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"description",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Charge Description"}),e.jsx(y,{children:e.jsx(D,{placeholder:"Enter default charge description",...d,className:C(h)})}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"tags",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Tags"}),e.jsx(y,{children:e.jsx(tt,{options:Object.values(i).map(({value:u,label:x})=>({label:x,value:u})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:r,className:C(h)})}),e.jsx(b,{})]})})]})]})}function _n({form:s}){const[t,n]=N.useState(""),[a,l]=N.useState(""),o=()=>{if(t.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,t.trim()],{shouldDirty:!0}),n("")}},i=()=>{if(a.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,a.trim()],{shouldDirty:!0}),l("")}},r=d=>{const h=s.getValues("phrases");s.setValue("phrases",h.filter((u,x)=>x!==d),{shouldDirty:!0})},c=d=>{const h=s.getValues("emails");s.setValue("emails",h.filter((u,x)=>x!==d),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Auto-matching Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure patterns for automatic matching of bank transactions and documents"}),e.jsx(g,{control:s.control,name:"phrases",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{placeholder:"Add phrase...",value:t,onChange:u=>n(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),o())},className:C(h)}),e.jsx(E,{type:"button",size:"sm",onClick:o,children:e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((u,x)=>e.jsxs(ee,{variant:"secondary",className:"gap-1",children:[u,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>r(x),children:e.jsx(ye,{className:"size-3 cursor-pointer",onClick:()=>r(x)})})]},x))}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"emails",render:({field:d,fieldState:h})=>e.jsxs(f,{children:[e.jsx(v,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{type:"email",placeholder:"Add email...",value:a,onChange:u=>l(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),i())},className:C(h)}),e.jsx(E,{type:"button",size:"sm",onClick:i,children:e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((u,x)=>e.jsxs(ee,{variant:"secondary",className:"gap-1",children:[u,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>c(x),children:e.jsx(ye,{className:"size-3 cursor-pointer"})})]},x))}),e.jsx(b,{})]})})]})}function Rn({form:s}){const[t,n]=N.useState(""),a=()=>{if(t.trim()){const i=s.getValues("internalLinks");s.setValue("internalLinks",[...i,t.trim()],{shouldDirty:!0}),n("")}},l=i=>{const r=s.getValues("attachmentTypes");s.setValue("attachmentTypes",r?.includes(i)?r.filter(c=>c!==i):[...r,i],{shouldDirty:!0})},o=i=>{const r=s.getValues("internalLinks");s.setValue("internalLinks",r.filter((c,d)=>d!==i),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Gmail Feature Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Gmail integration settings for document processing"}),e.jsx(g,{control:s.control,name:"attachmentTypes",render:({field:i,fieldState:r})=>e.jsxs(f,{children:[e.jsx(v,{children:"Attachment Types"}),e.jsx("div",{className:C(r)+" rounded-md flex flex-wrap gap-2",children:Pn.map(c=>e.jsx(ee,{variant:i.value?.includes(c)?"default":"outline",className:"cursor-pointer",onClick:()=>l(c),children:c},c))}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"internalLinks",render:({field:i,fieldState:r})=>e.jsxs(f,{children:[e.jsx(v,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{type:"url",placeholder:"Add internal link...",value:t,onChange:c=>n(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),a())}}),e.jsx(E,{type:"button",size:"sm",onClick:a,children:e.jsx(Z,{className:"h-4 w-4"})})]}),e.jsx("div",{className:C(r)+" flex flex-wrap gap-2 rounded-md",children:i.value?.map((c,d)=>e.jsxs(ee,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[c,e.jsx(E,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(ye,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(b,{})]})}),e.jsx(g,{control:s.control,name:"useMessageBody",render:({field:i,fieldState:r})=>e.jsxs(f,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(v,{children:"Should Use Message Body"}),e.jsx(Y,{children:"Extract information from email message body"})]}),e.jsx(y,{children:e.jsx(Q,{checked:i.value,onCheckedChange:i.onChange,className:C(r)})})]})})]})}const Mn=He({businessName:O().min(1,"Business name is required"),locality:O().min(1,"Locality is required"),localName:O().optional(),govId:O().optional(),address:O().optional(),localAddress:O().optional(),phone:O().optional(),website:vs("Invalid URL").optional().or(ys("")),generalContacts:ts(ns()).optional(),billingEmails:ts(ns()).optional()});function hs(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(t=>t.trim()),billingEmails:s.clientInfo?.emails}}function $n(s){return{name:s.businessName,country:s.locality,hebrewName:s.localName,governmentId:s.govId,address:s.address,phoneNumber:s.phone,website:s.website,email:s.generalContacts?.join(", ")}}function Un({data:s,refetchBusiness:t}){const n=Ce(it,s),[a,l]=N.useState(hs(n)),{userContext:o}=N.useContext(Je),{updateBusiness:i,fetching:r}=Ls(),c=Te({resolver:We(Mn),defaultValues:a}),{countries:d,fetching:h}=at(),[u,x]=N.useState(""),[S,m]=N.useState(""),p=c.watch("locality"),k=c.watch("address"),B=c.watch("localAddress");N.useEffect(()=>{k!==a.address&&c.setValue("address",k,{shouldDirty:!0})},[k,a.address,c]),N.useEffect(()=>{B!==a.localAddress&&c.setValue("localAddress",B,{shouldDirty:!0})},[B,a.localAddress,c]);const L=n&&"clientInfo"in n&&!!n.clientInfo,M=p===o?.context.locality,$=j=>{u.trim()&&(c.setValue("generalContacts",[...j,u.trim()],{shouldDirty:!0}),x(""))},V=(j,w)=>{c.setValue("generalContacts",j.filter((I,T)=>T!==w),{shouldDirty:!0})},X=j=>{S.trim()&&(c.setValue("billingEmails",[...j,S.trim()],{shouldDirty:!0}),m(""))},U=(j,w)=>{c.setValue("billingEmails",j.filter((I,T)=>T!==w),{shouldDirty:!0})},se=async j=>{if(!n||!o?.context.adminBusinessId)return;const w=Xe(j,c.formState.dirtyFields);if(!w)return;const I=$n(w);await i({businessId:n.id,ownerId:o.context.adminBusinessId,fields:I}),t?.()};return N.useEffect(()=>{if(n){const j=hs(n);l(j),c.reset(j)}},[n,c]),e.jsxs(q,{children:[e.jsxs(G,{children:[e.jsx(W,{children:"Contact Information"}),e.jsx(K,{children:"Business contact details and address information"})]}),e.jsx(Ee,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(se),children:[e.jsx(H,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(g,{control:c.control,name:"businessName",render:({field:j,fieldState:w})=>e.jsxs(f,{children:[e.jsx(v,{children:"Business Name"}),e.jsx(y,{children:e.jsx(D,{...j,className:C(w)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"locality",render:({field:j,fieldState:w})=>e.jsxs(f,{children:[e.jsx(v,{children:"Locality / Country"}),e.jsx(Ve,{onChange:j.onChange,data:d.map(I=>({value:I.code,label:I.name})),value:j.value,disabled:h,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(w)}}),e.jsx(b,{})]})}),M&&e.jsx(g,{control:c.control,name:"localName",render:({field:j,fieldState:w})=>e.jsxs(f,{children:[e.jsx(v,{children:"Local Name"}),e.jsx(y,{children:e.jsx(D,{...j,placeholder:"Business name in local language",className:C(w)})}),e.jsx(b,{})]})}),M&&e.jsx(g,{control:c.control,name:"govId",render:({field:j,fieldState:w})=>e.jsxs(f,{children:[e.jsx(v,{children:"Government ID"}),e.jsx(y,{children:e.jsx(D,{...j,placeholder:"Enter Government ID",className:C(w)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"address",render:({field:j,fieldState:w})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Address"]}),e.jsx(y,{children:e.jsx(Re,{...j,rows:3,placeholder:"Enter business address",className:C(w)})}),e.jsx(b,{})]})}),M&&e.jsx(g,{control:c.control,name:"localAddress",render:({field:j,fieldState:w})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(y,{children:e.jsx(Re,{...j,rows:3,placeholder:"Enter address in local language",className:C(w)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"phone",render:({field:j,fieldState:w})=>e.jsxs(f,{children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Phone"]}),e.jsx(y,{children:e.jsx(D,{...j,type:"tel",placeholder:"+1 (555) 123-4567",className:C(w)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"website",render:({field:j,fieldState:w})=>e.jsxs(f,{children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"h-4 w-4"}),"Website"]}),e.jsx(y,{children:e.jsx(D,{...j,type:"url",placeholder:"https://example.com",className:C(w)})}),e.jsx(b,{})]})}),e.jsx(g,{control:c.control,name:"generalContacts",render:({field:j,fieldState:w})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(y,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:C(w)+" flex flex-wrap gap-2 mb-2 rounded-md",children:j.value?.map((I,T)=>e.jsxs(ee,{variant:"secondary",className:"gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>V(j.value??[],T),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ye,{className:"h-3 w-3"})})]},T))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{value:u,onChange:I=>x(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),$(j.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(E,{type:"button",variant:"outline",size:"icon",disabled:!u.trim(),onClick:()=>$(j.value??[]),children:e.jsx(Z,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})}),L&&e.jsx(g,{control:c.control,name:"billingEmails",render:({field:j,fieldState:w})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsxs(v,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(y,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:C(w)+" flex flex-wrap gap-2 mb-2 rounded-md",children:j.value?.map((I,T)=>e.jsxs(ee,{variant:"secondary",className:"gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>U(j.value??[],T),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ye,{className:"h-3 w-3"})})]},T))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(D,{value:S,onChange:I=>m(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),X(j.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(E,{type:"button",variant:"outline",size:"icon",disabled:!S.trim(),onClick:()=>X(j.value??[]),children:e.jsx(Z,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})})]})}),e.jsx(Ke,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(E,{type:"submit",disabled:r||Object.keys(c.formState.dirtyFields).length===0,children:[e.jsx(es,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}const zn="createContract",qn=()=>{const[{fetching:s},t]=Ie(lt),n=N.useCallback(async a=>{const l=`Error creating new contract for client[${a.input.clientId}]`,o=`${zn}-${a.input.clientId}`;_.loading("Creating contract",{id:o});try{const i=await t(a);De(i,l,o)&&_.success("Success",{id:o,description:`Contract for client ${a.input.clientId} was successfully created`})}catch(i){console.error(`${l}: ${i}`),_.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{creating:s,createContract:n}},Gn="updateContract",Wn=()=>{const[{fetching:s},t]=Ie(ct),n=N.useCallback(async a=>{const l=`Error updating contract ID [${a.contractId}]`,o=`${Gn}-${a.contractId}`;_.loading("Updating contract",{id:o});try{const i=await t(a),r=De(i,l,o,"updateContract");if(r)return _.success("Success",{id:o,description:"Contract updated"}),r.updateContract}catch(i){console.error(`${l}: ${i}`),_.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{updating:s,updateContract:n}},Kn=He({id:dt().optional(),startDate:as("Start date is required"),endDate:as("End date is required"),po:O().optional(),paymentAmount:gs().min(0,"Payment amount must be non-negative"),paymentCurrency:oe(Object.values(Ye),"Currency is required"),productType:oe(Object.values(Ns)).optional(),msCloudLink:vs().optional().or(ys("")),billingCycle:oe(Object.values(ve)).optional(),subscriptionPlan:oe(Object.values(Se)).optional(),isActive:ot(),defaultRemark:O().optional(),defaultDocumentType:oe(Object.values(Qe))}),xs={startDate:"",endDate:"",po:void 0,paymentAmount:0,paymentCurrency:Ye.Usd,productType:Ns.Hive,msCloudLink:void 0,billingCycle:ve.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:Qe.Proforma};function Hn({clientId:s,contract:t,onDone:n}){const[a,l]=N.useState(!1),[o,i]=N.useState(null),{updateContract:r,updating:c}=Wn(),{createContract:d,creating:h}=qn(),u=Te({resolver:We(Kn),defaultValues:t||xs});N.useEffect(()=>{t&&(i(t),u.reset({startDate:t.startDate,endDate:t.endDate,po:t.po,paymentAmount:t.paymentAmount,paymentCurrency:t.paymentCurrency,productType:t.productType,msCloudLink:t.msCloudLink,billingCycle:t.billingCycle,subscriptionPlan:t.subscriptionPlan,isActive:t.isActive,defaultRemark:t.defaultRemark,defaultDocumentType:t.defaultDocumentType}),l(!0))},[t,u]);const x=()=>{i(null),u.reset(xs),l(!0)},S=N.useCallback(async m=>{if(o)await r({contractId:o.id,input:{amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:ue(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrder:m.po,remarks:m.defaultRemark,startDate:ue(new Date(m.startDate),"yyyy-MM-dd")}});else{if(!m.billingCycle){u.setError("billingCycle",{message:"Billing cycle is required"});return}await d({input:{clientId:s,amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:ue(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrder:m.po,remarks:m.defaultRemark,startDate:ue(new Date(m.startDate),"yyyy-MM-dd")}})}l(!1),i(null),n?.()},[o,n,d,r,s,u]);return e.jsxs(qe,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(E,{size:"sm",onClick:x,children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),"New Contract"]})}),e.jsxs(Ge,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(ws,{children:o?"Edit Contract":"Create New Contract"}),e.jsx(As,{children:o?"Update contract details":"Add a new contract with all required details"})]}),e.jsx(Ee,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(S),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:e.jsx(g,{control:u.control,name:"po",render:({field:m})=>e.jsxs(f,{children:[e.jsx(v,{children:"PO Number"}),e.jsx(y,{children:e.jsx(D,{placeholder:"PO-2024-001",...m})}),e.jsx(b,{})]})})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{control:u.control,name:"startDate",render:({field:{onChange:m,...p}})=>e.jsxs(f,{children:[e.jsx(v,{children:"Start Date"}),e.jsx(y,{children:e.jsx(D,{type:"date",...p,onInput:k=>m(k)})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"endDate",render:({field:{onChange:m,...p}})=>e.jsxs(f,{children:[e.jsx(v,{children:"End Date"}),e.jsx(y,{children:e.jsx(D,{type:"date",...p,onInput:k=>m(k)})}),e.jsx(b,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(g,{control:u.control,name:"paymentAmount",render:({field:m})=>e.jsxs(f,{className:"md:col-span-2",children:[e.jsx(v,{children:"Payment Amount"}),e.jsx(y,{children:e.jsx(D,{type:"number",placeholder:"24000",...m,onChange:p=>{m.onChange(p?.target.value?Number(p?.target.value):void 0)}})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"paymentCurrency",render:({field:m})=>e.jsxs(f,{children:[e.jsx(v,{children:"Currency"}),e.jsxs(he,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(y,{children:e.jsx(xe,{children:e.jsx(pe,{})})}),e.jsx(je,{children:Object.values(Ye).map(p=>e.jsx(ge,{value:p,children:p},p))})]}),e.jsx(b,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{control:u.control,name:"productType",render:({field:m})=>e.jsxs(f,{children:[e.jsx(v,{children:"Product Type"}),e.jsx(y,{children:e.jsx(D,{placeholder:"Cloud Services",...m})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"billingCycle",render:({field:m})=>e.jsxs(f,{children:[e.jsx(v,{children:"Billing Cycle"}),e.jsxs(he,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(y,{children:e.jsx(xe,{children:e.jsx(pe,{})})}),e.jsx(je,{children:Object.values(ve).map(p=>e.jsx(ge,{value:p,children:Es(p)},p))})]}),e.jsx(b,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(g,{control:u.control,name:"subscriptionPlan",render:({field:m})=>e.jsxs(f,{children:[e.jsx(v,{children:"Subscription Plan"}),e.jsx(y,{children:e.jsxs(he,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(y,{children:e.jsx(xe,{children:e.jsx(pe,{})})}),e.jsx(je,{children:Object.values(Se).map(p=>e.jsx(ge,{value:p,children:Bs(p)},p))})]})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"isActive",render:({field:m})=>e.jsxs(f,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(v,{className:"text-base",children:"Active Status"})}),e.jsx(y,{children:e.jsx(Q,{checked:m.value,onCheckedChange:m.onChange})})]})})]}),e.jsx(g,{control:u.control,name:"msCloudLink",render:({field:m})=>e.jsxs(f,{children:[e.jsx(v,{children:"MS Cloud Link"}),e.jsx(y,{children:e.jsx(D,{type:"url",placeholder:"https://portal.azure.com/contract-id",...m})}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"defaultDocumentType",render:({field:m})=>e.jsxs(f,{children:[e.jsx(v,{children:"Default Document Type"}),e.jsxs(he,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(y,{children:e.jsx(xe,{children:e.jsx(pe,{})})}),e.jsx(je,{children:Object.values(Qe).map(p=>e.jsx(ge,{value:p,children:Ss(p)},p))})]}),e.jsx(b,{})]})}),e.jsx(g,{control:u.control,name:"defaultRemark",render:({field:m})=>e.jsxs(f,{children:[e.jsx(v,{children:"Default Remark"}),e.jsx(y,{children:e.jsx(Re,{placeholder:"Enter default remark for this contract...",rows:3,...m})}),e.jsx(b,{})]})})]}),e.jsxs(ks,{children:[e.jsx(E,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(E,{type:"submit",disabled:h||c,children:o?"Update Contract":"Create Contract"})]})]})})]})]})}function Xn(s){return{id:s.id,po:s.purchaseOrder??void 0,startDate:s.startDate,endDate:s.endDate,paymentAmount:s.amount.raw,paymentCurrency:s.amount.currency,productType:s.product??void 0,billingCycle:s.billingCycle,msCloudLink:s.msCloud?.toString(),isActive:s.isActive,subscriptionPlan:s.plan??void 0,defaultRemark:s.remarks??void 0,defaultDocumentType:s.documentType??void 0}}function Jn({clientId:s}){const[t,n]=N.useState(null),[{data:a,fetching:l},o]=be({query:mt,variables:{clientId:s}}),i=a?.contractsByClient??[];return l?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(q,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Contracts"}),e.jsx(K,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Hn,{clientId:s,contract:t,onDone:o})]})}),e.jsx(H,{className:"space-y-4",children:i.map(r=>{const c=!!r.isActive;return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:r.product}),e.jsx(ee,{variant:c?"default":"secondary",children:r.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:r.id})]}),e.jsx(E,{variant:"ghost",size:"sm",onClick:()=>n(Xn(r)),children:e.jsx(Qt,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(ut,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(r.startDate).toLocaleDateString()," →"," ",new Date(r.endDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"PO Number"}),e.jsx("p",{className:"text-sm font-medium font-mono",children:r.purchaseOrder})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Payment"}),e.jsx("p",{className:"text-sm font-medium",children:ht(r.amount.raw,r.amount.currency)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Billing Cycle"}),e.jsx("p",{className:"text-sm font-medium",children:Es(r.billingCycle)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscription Plan"}),e.jsx("p",{className:"text-sm font-medium",children:r.plan?Bs(r.plan):"N/A"})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Document Type"}),e.jsx("p",{className:"text-sm font-medium",children:Ss(r.documentType)})]})]}),r.remarks&&e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remark"}),e.jsx("p",{className:"text-sm",children:r.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.msCloud&&e.jsx(E,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:r.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(xt,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(pt,{className:"h-3 w-3 ml-1"})]})})})]},r.id)})})]})}function Qn({businessId:s}){return e.jsxs(q,{children:[e.jsx(G,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(W,{children:"Documents"}),e.jsx(K,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(H,{children:e.jsx(jt,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const Yn=[{id:"hive",name:"Hive",description:"Schema registry, analytics, metrics and gateway for GraphQL federation and other GraphQL APIs",status:"disconnected",lastSync:"Never"},{id:"slack",name:"Slack",description:"Team communication and notifications",status:"disconnected",lastSync:"Never"},{id:"retool",name:"Retool",description:"Internal tools and dashboards",status:"disconnected",lastSync:"Never"},{id:"linear",name:"Linear",description:"Issue tracking and project management",status:"disconnected",lastSync:"Never"},{id:"workflowy",name:"Workflowy",description:"Task management and note taking",status:"disconnected",lastSync:"Never"}];function Zn({data:s}){const t=Ce(yt,s),[{data:n,fetching:a},l]=be({query:gt,variables:{clientId:t?.id??""},pause:!t?.clientInfo?.greenInvoiceId||!t?.id}),{updateClient:o}=ft(),i=N.useCallback((c,d)=>{if(!t?.id)return;const h={};h[d]=c,o({businessId:t?.id,fields:h})},[t?.id,o]);N.useEffect(()=>{t?.clientInfo?.greenInvoiceId&&t?.id&&l()},[t?.clientInfo?.greenInvoiceId,t?.id,l]);const r=n?.greenInvoiceClient;return e.jsxs(q,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Integrations"}),e.jsx(K,{children:"Connected external services and providers"})]}),e.jsxs(E,{size:"sm",children:[e.jsx(Z,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(H,{className:"space-y-6",children:e.jsxs(Yt,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[a?e.jsxs(Oe,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx(A,{className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-6 w-32"}),e.jsx(A,{className:"h-5 w-5 rounded-full"})]}),e.jsx(A,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-8 w-24"}),e.jsx(A,{className:"h-8 w-8"})]})]})}),e.jsx(Le,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-32"}),e.jsx(A,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(Oe,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-600 flex items-center justify-center text-white font-bold",children:"GI"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Green Invoice"}),e.jsx(ls,{className:"h-5 w-5 text-green-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Israeli invoicing system integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ea,{id:t?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async c=>i(c,"greenInvoiceId")}),e.jsx(is,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Le,{children:r&&e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Business Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Integration ID"}),e.jsx("p",{className:"text-sm font-mono",children:t?.clientInfo?.greenInvoiceId})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Business Name"}),e.jsx("p",{className:"text-sm",children:r.name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Country"}),e.jsx("p",{className:"text-sm",children:r.country})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"text-sm font-mono",children:r.taxId})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Contact Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Me,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.emails?.map((c,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:c},d))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(fs,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:r.phone})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Mobile"}),e.jsx("p",{className:"text-sm font-mono",children:r.mobile})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Fax"}),e.jsx("p",{className:"text-sm font-mono",children:r.fax})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),"Address"]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Street Address"}),e.jsx("p",{className:"text-sm",children:r.address})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"City"}),e.jsx("p",{className:"text-sm",children:r.city})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Zip Code"}),e.jsx("p",{className:"text-sm font-mono",children:r.zip})]})]})]})]})})]}),Yn.map(c=>e.jsxs(Oe,{value:c.id,className:"rounded-lg border",children:[e.jsx("div",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3 flex-1",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:c.name}),c.status==="connected"?e.jsx(ls,{className:"h-4 w-4 text-green-600"}):e.jsx(vt,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(Ze,{className:"h-4 w-4"})}),e.jsx(is,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Le,{children:e.jsx("div",{className:"px-4 pb-4 pt-2 border-t",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last sync: "}),e.jsx("span",{className:"font-medium",children:c.lastSync})]})})})]},c.id))]})})]})}function ea({id:s,provider:t,updateClient:n}){const[a,l]=N.useState(!1),[o,i]=N.useState(s),r=N.useCallback(async()=>{await n(o),l(!1)},[o,n]);return e.jsxs(qe,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(E,{variant:"outline",size:"sm",onClick:c=>c.stopPropagation(),children:[e.jsx(Ze,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(Ge,{onClick:c=>c.stopPropagation(),children:[e.jsxs(Cs,{children:[e.jsxs(ws,{children:["Configure ",t]}),e.jsxs(As,{children:["Update your ",t," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Nt,{htmlFor:"id",children:[t," ID"]}),e.jsx(D,{id:"id",value:o,onChange:c=>i(c.target.value),placeholder:`Enter ${t} ID`})]})}),e.jsxs(ks,{children:[e.jsx(E,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(E,{onClick:r,disabled:!o,children:"Save Changes"})]})]})]})}function sa({businessId:s}){return e.jsxs(q,{children:[e.jsx(G,{className:"flex w-full justify-between items-center",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(W,{children:"Transactions"}),e.jsx(K,{children:"Complete transaction history for this business"})]})})}),e.jsx(H,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(bt,{businessID:s,filter:{}})})})]})}function ta({data:s,refetchBusiness:t}){const n=Ce(It,s),[a,l]=Ct(),o=a.get("tab")||"contact",i=d=>{l({tab:d})};if(!n)return e.jsx("div",{children:"Business not found"});const r="clientInfo"in n&&!!n.clientInfo,c="adminInfo"in n&&!!n.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Bt,{data:n}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(wt,{value:o,onValueChange:i,className:"w-full",children:[e.jsxs(At,{className:"grid w-full lg:grid-cols-8 sm:grid-cols-4 grid-cols-8 mb-6 h-auto gap-1 bg-muted/50 p-1",children:[e.jsxs(J,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Zt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(J,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ze,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(J,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ae,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(J,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(St,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(J,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(kt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(J,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(nn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(J,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(rn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),c&&e.jsxs(J,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(js,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx(z,{value:"contact",className:"mt-0",children:e.jsx(Un,{data:n,refetchBusiness:t})}),e.jsx(z,{value:"config",className:"mt-0",children:e.jsx(Ln,{data:n,refetchBusiness:t})}),e.jsx(z,{value:"charges",className:"mt-0",children:e.jsx(pn,{businessId:n.id})}),e.jsx(z,{value:"transactions",className:"mt-0",children:e.jsx(sa,{businessId:n.id})}),e.jsx(z,{value:"documents",className:"mt-0",children:e.jsx(Qn,{businessId:n.id})}),r&&e.jsxs(e.Fragment,{children:[e.jsx(z,{value:"contracts",className:"mt-0",children:e.jsx(Jn,{clientId:n.id})}),e.jsx(z,{value:"integrations",className:"mt-0",children:e.jsx(Zn,{data:n})}),e.jsx(z,{value:"charts",className:"mt-0",children:e.jsx(En,{})})]}),c&&e.jsx(z,{value:"admin",className:"mt-0",children:e.jsx(xn,{data:n})})]})})]})}function ma(s){return`/businesses/${s}`}const ua=()=>{const{businessId:s}=Dt();let t;try{t=Tt()}catch{}const[{data:n,fetching:a},l]=be({query:Et,pause:!s||!!t,variables:{businessId:s??""}}),o=t||n;return!t&&a&&!o?.business?e.jsx(ps,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(ta,{data:o.business,refetchBusiness:async()=>l()})};export{ua as BusinessScreen,ma as getBusinessHref};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c_ as _,r as m,u as R,d1 as k,j as e,c$ as Q,bA as q,B as I,d0 as G,V as z,ce as K,di as X,as as J,dj as Z,bP as y,bQ as A,bU as B,bV as F,H as S,ci as L,a as P,f8 as W,Y as U,n as $,Z as Y,$ as ee,aE as ae,a2 as O,f9 as se,F as te,ag as re,aB as ne,c as oe,a0 as le,e9 as ie,fa as ce,aV as de}from"./index-DPpEG9bb.js";import{k as ue,B as N,X as H,Y as me,l as pe,m as xe,n as ge,o as he,p as fe,q as be,r as je}from"./chart-BiIM6DWC.js";import{s as ye}from"./sub-CmPBwyt8.js";import"./sequential-CAnleQny.js";import"./subMonths-B4EBfn4r.js";var ve=ue({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:me}],formatAxisMap:pe});function V(s){return!s||_(s)?null:encodeURIComponent(JSON.stringify(s))}const E="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:n,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=z({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=K(),{selectableFinancialEntities:f,fetching:v}=X(),{selectableTags:p,fetching:j}=J(),M=a=>{n(a),c()},C=g("excludedTags"),l=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),o=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(Z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:B,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(F,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:B,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:i})=>e.jsx(F,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:i.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:i})=>e.jsx(A,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:i})=>e.jsx(L,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:i})=>e.jsx(L,{...a,data:l,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:i})=>e.jsx(L,{...a,data:o,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:i.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:n,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=R();m.useEffect(()=>{const p=V(s),j=h(E);p!==j&&f(E,p)},[s,h,f]);const v=m.useCallback(p=>{k(p,s)||(n(p),b(!!p))},[s,n]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(Q,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(q,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(G,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:n,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=P({query:W,variables:{transactionIDs:n}}),g=m.useMemo(()=>t?.transactionsByIDs?n.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,n]);return e.jsx(U,{className:"mt-5 w-full",children:r?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{children:e.jsxs(ee,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(ae,{className:"h-4 w-4"})})]})}),e.jsx(O,{children:e.jsx(se,{transactionsProps:g})})]})})};function Fe(s){const n=new URLSearchParams,c=V(s);return c&&n.append(E,c),`/reports/balance${n.size>0?`?${n}`:""}`}const w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,n,c){switch(c){case x.MONTHLY:{const t=String(n).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=n%2===0?n-1:n,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(n/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=n>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,n){switch(n){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=ie(de.Usd),De=()=>{const{setFiltersContext:s}=m.useContext(te),{userContext:n}=m.useContext(re),{get:c}=R(),t=m.useMemo(()=>{const l={ownerId:n?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(ye(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(E);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(o){console.log("Error parsing balance report filters from URL:",o)}return l},[n?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:l,fromDate:d,toDate:o}=r;return{ownerId:l,fromDate:d,toDate:o}},[r]),[{data:j,fetching:M}]=P({query:ce,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ne,{options:Object.entries(w).map(([l,d])=>({label:d.label,value:l})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(l=>({...l,ownerId:n?.context.adminBusinessId}))},[n]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const l=new Map;j.transactionsForBalanceReport.map(o=>{if(o.counterparty?.id&&(!o.isFee&&n?.context.financialAccountsBusinessesIds?.includes(o.counterparty.id)||r.excludedCounterparties?.includes(o.counterparty.id))||r.includedTags.length>0&&(!o.charge?.tags||o.charge.tags.length===0||!o.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&o.charge?.tags.length&&o.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(o.year,o.month,r.period);l.has(a)||l.set(a,{income:0,expense:0,delta:0,transactions:[]});const i=l.get(a);o.amountUsd.raw>0?i.income+=o.amountUsd.raw:i.expense+=o.amountUsd.raw,i.delta+=o.amountUsd.raw,i.transactions.push(o)});let d=0;return Array.from(l.entries()).sort((o,a)=>o[0].localeCompare(a[0])).map(([o,a])=>(d+=a.delta,{period:o,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((i,u)=>Math.abs(u.amountUsd.raw)-Math.abs(i.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,n?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx($,{}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{className:"w-full",children:[e.jsx(Y,{children:e.jsx(le,{children:"Click specific period to expand it's transactions data"})}),e.jsx(O,{children:e.jsx(xe,{config:w,className:"h-150 w-full",children:e.jsxs(ve,{accessibilityLayer:!0,data:C,onClick:l=>h(l.activeLabel),children:[e.jsx(ge,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:l=>Me(l,r.period)}),e.jsx(he,{content:e.jsx(fe,{formatter:(l,d,o,a)=>{const i=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${i} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${i}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(l))})]})}})}),e.jsx(be,{content:e.jsx(je,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(l=>l.period===b)?.transactions.map(l=>l.id)??[]})]})})};export{De as BalanceReport,Fe as getBalanceReportHref};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{fw as n}from"./index-DPpEG9bb.js";function a(o,s,t){return n(o,-s,t)}export{a as s};
|