@accounter/client 0.0.8-alpha-20251030162201-d2f279aafe537912ec3546af855cbd3a38ac0f5c → 0.0.8-alpha-20251030164843-d2f490daba879840366288d1f62974ab25081876
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 +27 -16
- package/dist/assets/{Checkbox-qEdmT4HE.js → Checkbox-dSmM5Kto.js} +2 -2
- package/dist/assets/{MultiSelect-Dm9mO7pJ.js → MultiSelect-BKzjkxRf.js} +1 -1
- package/dist/assets/{Progress-kr0gnfBa.js → Progress-CaCuNARE.js} +1 -1
- package/dist/assets/{Table-DnHfGe-y.js → Table-DxJ1YCr5.js} +1 -1
- package/dist/assets/{Typography-Cu3puAUK.js → Typography-rzf7AKzm.js} +1 -1
- package/dist/assets/{YearPickerInput-oa86GF4P.js → YearPickerInput-Bp2ytdrx.js} +1 -1
- package/dist/assets/{accordion-DLtMSqIv.js → accordion-B83CGJPM.js} +1 -1
- package/dist/assets/{accountant-approvals-DsL0uiBa.js → accountant-approvals-DRr7UYE4.js} +1 -1
- package/dist/assets/{accounter-table-BL_yrGIl.js → accounter-table-CLZmYCK0.js} +1 -1
- package/dist/assets/{addDays-DqZEDZy3.js → addDays-DbkSn4rN.js} +1 -1
- package/dist/assets/{all-charges-D3Xf-pEY.js → all-charges-Cn0oGAAS.js} +1 -1
- package/dist/assets/{arrow-up-down-DchtBEG4.js → arrow-up-down-kJRuABuk.js} +1 -1
- package/dist/assets/{building-2-ZTKteVvf.js → building-2-DAb5H_9e.js} +1 -1
- package/dist/assets/business-DeId1elJ.js +37 -0
- package/dist/assets/{business-extended-info-1mzdXJbs.js → business-extended-info-u-wZchjH.js} +4 -4
- package/dist/assets/{business-header-CJqfKV4d.js → business-header-vz6RQ5nZ.js} +1 -1
- package/dist/assets/{business-ledger-filters-BRB1r_DP.js → business-ledger-filters-DyyAMsOt.js} +1 -1
- package/dist/assets/{business-ledger-single-C8FIQJ8V.js → business-ledger-single-Cy7nqs_T.js} +1 -1
- package/dist/assets/business-trip-CA4-OIFH.js +1 -0
- package/dist/assets/{charge-Df3lWZH-.js → charge-DkSqluIG.js} +1 -1
- package/dist/assets/charges-filters-Djo_kWBf.js +1 -0
- package/dist/assets/{charges-ledger-validation-CtCBR3C-.js → charges-ledger-validation-DvCBQB1e.js} +1 -1
- package/dist/assets/{charges-table-CWbe3t13.js → charges-table-D1vDT-UP.js} +7 -7
- package/dist/assets/{chart-Cmm-jp0c.js → chart-BMSKXrwP.js} +1 -1
- package/dist/assets/contracts-ZJWgQOle.js +16 -0
- package/dist/assets/{data-table-pagination-fdOZTf64.js → data-table-pagination-BUpZwYMw.js} +2 -2
- package/dist/assets/{download-csv-button-CwK31swX.js → download-csv-button-tWswwko2.js} +1 -1
- package/dist/assets/edit-issue-document-modal-CHR5idQt.js +1 -0
- package/dist/assets/{editable-business-trip-Bjxkm9xV.js → editable-business-trip-D0UrHlFI.js} +2 -2
- package/dist/assets/eye-off-CGW7uC-c.js +6 -0
- package/dist/assets/{funnel-CMG4QvaK.js → funnel-Bmrsutts.js} +1 -1
- package/dist/assets/{index-CgokSIpu.js → index-2vL0dn5v.js} +1 -1
- package/dist/assets/index-B5HkjHjI.js +1 -0
- package/dist/assets/{index-Cw_aKL-8.js → index-BZ8AOwEl.js} +178 -173
- package/dist/assets/{index-CTatkdRy.js → index-Babx_Mc7.js} +2 -2
- package/dist/assets/{index-DLwMwjDQ.js → index-BnhjaCUg.js} +1 -1
- package/dist/assets/{index-xxe8M91O.js → index-Br0GTPfc.js} +2 -2
- package/dist/assets/index-BrSZxw1u.css +1 -0
- package/dist/assets/{index-DInU4RP4.js → index-C-VKA9Ok.js} +2 -2
- package/dist/assets/{index-CriBDqbK.js → index-C7cxxohd.js} +1 -1
- package/dist/assets/{index-C7oYbGGm.js → index-CUveXkuD.js} +1 -1
- package/dist/assets/index-CYX2yO-u.js +1 -0
- package/dist/assets/index-D1DOb6_Y.js +1 -0
- package/dist/assets/index-D7_jh5GD.js +1 -0
- package/dist/assets/index-DSuF8jdU.js +1 -0
- package/dist/assets/{index-CjC_SXIA.js → index-DTcOeWYo.js} +1 -1
- package/dist/assets/index-Dh1--D4F.js +1 -0
- package/dist/assets/{index-BEahR51x.js → index-Dkpu6Zhk.js} +2 -2
- package/dist/assets/index-DyH8FMHQ.js +1 -0
- package/dist/assets/index-HH5Rxplr.js +1 -0
- package/dist/assets/{index-B9CbQIGq.js → index-KBivZEq1.js} +2 -2
- package/dist/assets/{index-C_ZNQ0Zr.js → index-NS4xXWXV.js} +1 -1
- package/dist/assets/{index-6G62OvEh.js → index-cC755YI-.js} +1 -1
- package/dist/assets/{index-DFW4nqx8.js → index-dSI-XOHn.js} +7 -7
- package/dist/assets/index-h3vstU9e.js +1 -0
- package/dist/assets/{index-BZVrGMgV.js → index-tBA1vG1Y.js} +2 -2
- package/dist/assets/{index-jCPWIpdP.js → index-tMg1Ls6M.js} +1 -1
- package/dist/assets/{index.es-B_Bf6nNm.js → index.es-DNpMwt0n.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-Ds3RIlmF.js → insert-business-trip-modal-4vXkqVnt.js} +2 -2
- package/dist/assets/issue-document-BoFHPotT.js +1 -0
- package/dist/assets/{list-plus-B3EB-dKe.js → list-plus-CDqpqAwS.js} +1 -1
- package/dist/assets/login-page-Bi8pRR_Y.js +1 -0
- package/dist/assets/{match-document-modal-Bo9pBr8W.js → match-document-modal-CETycNjj.js} +4 -4
- package/dist/assets/{missing-info-charges-BQYXI7bj.js → missing-info-charges-BPeEhfPv.js} +1 -1
- package/dist/assets/{modal-Pj_6bAFk.js → modal-8mlzJehM.js} +1 -1
- package/dist/assets/modify-contract-dialog-DWLEVQ1d.js +1 -0
- package/dist/assets/{page-layout-CVTeUSZp.js → page-layout-BfCdWwql.js} +1 -1
- package/dist/assets/{page-not-found-TvTAiAs4.js → page-not-found-DukC1kEI.js} +1 -1
- package/dist/assets/{panel-top-open-DzBY_TuM.js → panel-top-open-CpMFDJrl.js} +1 -1
- package/dist/assets/{pencil-BBmFhuZN.js → pencil-R8t4mFRO.js} +1 -1
- package/dist/assets/{report-commentary-row-Dqw62LLo.js → report-commentary-row-Byk41KMN.js} +1 -1
- package/dist/assets/{save-BW18gNVs.js → save-BjBw7mG5.js} +1 -1
- package/dist/assets/similar-transactions-modal-BPFaQ7dD.js +1 -0
- package/dist/assets/sub-dol6DnIB.js +1 -0
- package/dist/assets/subMonths-Cu51bw_I.js +1 -0
- package/dist/assets/{summary-Bbsq64IN.js → summary-Sj8NMKlv.js} +1 -1
- package/dist/assets/{toggle-expansion-button-BrKkZtGj.js → toggle-expansion-button-Buzq87-g.js} +1 -1
- package/dist/assets/tooltip-gvPoRI4e.js +1 -0
- package/dist/assets/{use-url-query-C0mVgO2i.js → use-url-query-DOEL3cY1.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/components/business/admin-business-section.tsx +103 -282
- package/src/components/clients/contracts/modify-contract-dialog.tsx +335 -253
- package/src/components/contracts/cells/client.tsx +24 -0
- package/src/components/contracts/cells/date.tsx +14 -0
- package/src/components/contracts/cells/index.ts +2 -0
- package/src/components/contracts/columns.tsx +182 -0
- package/src/components/contracts/contracts-filter.tsx +159 -0
- package/src/components/contracts/index.tsx +263 -0
- package/src/components/contracts/issue-documents-modal.tsx +236 -0
- package/src/components/layout/sidelinks.tsx +7 -0
- package/src/components/screens/businesses/clients/contracts/contracts.tsx +54 -0
- package/src/gql/gql.ts +27 -3
- package/src/gql/graphql.ts +73 -52
- package/src/router/config.tsx +13 -0
- package/src/router/routes.ts +1 -0
- package/dist/assets/business-CAcKSrnu.js +0 -37
- package/dist/assets/business-trip-DkTEY8b1.js +0 -1
- package/dist/assets/charges-filters-DUuY-N0H.js +0 -1
- package/dist/assets/index-BD4s2ucv.css +0 -1
- package/dist/assets/index-BFwWHKS1.js +0 -1
- package/dist/assets/index-BI0XToIk.js +0 -1
- package/dist/assets/index-BQb_C-JL.js +0 -1
- package/dist/assets/index-CJQlHnFs.js +0 -1
- package/dist/assets/index-Cm6Blkgf.js +0 -1
- package/dist/assets/index-DJLQkpmI.js +0 -6
- package/dist/assets/index-DcwGbXWr.js +0 -1
- package/dist/assets/index-Dlj3jpuW.js +0 -1
- package/dist/assets/index-iya2tfvn.js +0 -1
- package/dist/assets/issue-document-_iHCFO9h.js +0 -1
- package/dist/assets/login-page-BtT_TCEJ.js +0 -1
- package/dist/assets/similar-transactions-modal-B39q1NLa.js +0 -1
- package/dist/assets/sub-DOjETdwl.js +0 -1
- package/dist/assets/subMonths-DqeFZ4O6.js +0 -1
- package/dist/assets/tooltip-CbnJYNc4.js +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import{v as Z,w as xs,u as ee,S as ps,r as p,j as e,D as Je,x as Qe,E as js,c as Ye,g as Ze,t as ne,i as es,U as gs,y as Be,z as ss,G as pe,H as M,J as $,K as as,N as z,O as U,Q as Te,V as G,W as j,X as g,Y as f,Z as C,I as B,_ as v,$ as w,a0 as ie,a1 as Ee,B as T,a2 as fs,a3 as ts,a4 as Pe,a5 as _,a6 as vs,a7 as Le,a8 as ys,P as Ns,a9 as bs,aa as P,ab as _e,ac as Cs,ad as ws,ae as Ss,af as J,ag as Q,ah as ks,ai as As,aj as Is,ak as we,al as Ds,am as Bs,an as Ts,ao as Es,ap as Ps,aq as Ls,ar as Os,as as Fs,at as re,au as Y,av as xe,aw as _s,ax as Vs,ay as Se,az as Ve,aA as ns,aB as Rs,aC as ke,aD as Ms,aE as Re,aF as $s,aG as Me,aH as zs,aI as Us,aJ as Gs,aK as qs,aL as Ws,aM as Ks,aN as Hs,aO as Xs,aP as Js,aQ as N,aR as Qs,aS as Oe,aT as Ys,aU as Zs,aV as ea,aW as sa,aX as aa,aY as ta,aZ as na,a_ as ia,a$ as ra,b0 as la,F as ca,b1 as oa,b2 as da,b3 as q,b4 as ma,b5 as ua,b6 as V,b7 as ha,a as xa,b as pa,b8 as ja}from"./index-BZ8AOwEl.js";import{S as Fe}from"./save-BjBw7mG5.js";import{B as ga}from"./business-extended-info-u-wZchjH.js";import{B as fa}from"./business-header-vz6RQ5nZ.js";import{S as va,C as ya,L as Na}from"./charges-table-D1vDT-UP.js";import{i as ba,D as Ca,f as wa,E as Sa,L as ye,a as je,C as ka,A as Aa,b as me,c as Ia,d as Ae,h as Da,e as Ba,g as is,u as Ta,G as Ea,j as $e,k as Pa,X as rs,Y as ls,l as La,m as Oa,R as Fa,n as _a,o as Va,p as Ra}from"./chart-BMSKXrwP.js";import{M as Ma,s as $a,a as za}from"./modify-contract-dialog-DWLEVQ1d.js";import{P as Ua}from"./pencil-R8t4mFRO.js";import{E as Ga,T as qa}from"./index-Br0GTPfc.js";import{A as Wa,a as Ne,b as be,c as ze}from"./accordion-B83CGJPM.js";import{B as Ka}from"./building-2-DAb5H_9e.js";import"./download-csv-button-tWswwko2.js";import"./Table-DxJ1YCr5.js";import"./toggle-expansion-button-Buzq87-g.js";import"./panel-top-open-CpMFDJrl.js";import"./summary-Sj8NMKlv.js";import"./list-plus-CDqpqAwS.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-BPFaQ7dD.js";import"./addDays-DbkSn4rN.js";import"./tooltip-gvPoRI4e.js";/**
|
|
2
|
+
* @license lucide-react v0.548.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 Ha=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Xa=Z("chart-line",Ha);/**
|
|
7
|
+
* @license lucide-react v0.548.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 Ja=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ue=Z("circle-check",Ja);/**
|
|
12
|
+
* @license lucide-react v0.548.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 Qa=[["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"}]],ge=Z("dollar-sign",Qa);/**
|
|
17
|
+
* @license lucide-react v0.548.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 Ya=[["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"}]],Za=Z("file-check",Ya);/**
|
|
22
|
+
* @license lucide-react v0.548.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 et=[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]],st=Z("notebook",et);/**
|
|
27
|
+
* @license lucide-react v0.548.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const at=[["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"}]],tt=Z("plug",at);/**
|
|
32
|
+
* @license lucide-react v0.548.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const nt=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Ce=Z("trending-up",nt);function it(s){return xs(s,"yyyy-MM-dd")}function rt({businessId:s,tagIds:t,description:a,open:n,onOpenChange:o,onClose:d}){const[{data:l,fetching:i},r]=ee({pause:!0,query:ps,variables:{businessId:s,tagsDifferentThan:t?t.map(u=>u.id):void 0,descriptionDifferentThan:a}});p.useEffect(()=>{n&&(t||a)&&!l&&r()},[n,t,a,r,l]);const c=p.useCallback(u=>{o(u),n&&!u&&d?.()},[o,d,n]),m=p.useMemo(()=>n&&(!!t||!!a)&&l&&l?.similarChargesByBusiness.length>0,[n,t,a,l]);return e.jsx(Je,{open:m,onOpenChange:c,children:e.jsx(Qe,{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(js,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:i?e.jsx(Ye,{}):t||a?e.jsx(va,{data:l?.similarChargesByBusiness??[],tagIds:t,description:a,onOpenChange:c,title:"Similar Charges by Business"}):null})})})}const lt="updateAdminBusiness",ct=()=>{const[{fetching:s},t]=Ze(gs),a=p.useCallback(async n=>{const o=`Error updating admin business ID [${n.adminBusinessId}]`,d=`${lt}-${n.adminBusinessId}`;ne.loading("Updating admin business",{id:d});try{const l=await t(n),i=es(l,o,d,"updateAdminBusiness");if(i)return ne.success("Success",{id:d,description:"Admin Business Updated"}),i.updateAdminBusiness}catch(l){console.error(`${o}: ${l}`),ne.error("Error",{id:d,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateAdminBusiness:a}},ot=ts({withholdingTaxBookNumber:_().min(1,{message:"Withholding Tax Book Number is required"}),withholdingTaxFileNumber:_().min(1,{message:"Withholding Tax File Number is required"}),socialSecurityEmployerId:_().min(1,{message:"National Insurance Employer ID is required"}),taxAdvancesRate:vs().min(0,{message:"Advance Tax Rate must be at least 0"}).max(100,{message:"Advance Tax Rate must be at most 100"}),taxAdvancesId:_().min(1,{message:"Tax Advances ID is required"}),registrationDate:_().min(1,{message:"Business Registration Start Date is required"})});function Ge(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 dt(s){return{withholdingTaxBookNumber:s.withholdingTaxBookNumber,withholdingTaxFileNumber:s.withholdingTaxFileNumber,socialSecurityEmployerId:s.socialSecurityEmployerId,taxAdvancesRate:s.taxAdvancesRate,taxAdvancesId:s.taxAdvancesId,registrationDate:s.registrationDate?it(new Date(s.registrationDate)):void 0}}function mt({data:s,refetchBusiness:t}){const a=pe(fs,s),[n,o]=p.useState(Ge(a)),{updateAdminBusiness:d,fetching:l}=ct(),i=Be({resolver:ss(ot),defaultValues:n}),r=async c=>{if(!a)return;const m=Pe(c,i.formState.dirtyFields);if(!m)return;const u=dt(m);await d({adminBusinessId:a.id,fields:u}),t?.()};return p.useEffect(()=>{if(a){const c=Ge(a);o(c),i.reset(c)}},[a,i]),e.jsxs(M,{children:[e.jsxs($,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(as,{className:"h-5 w-5 text-primary"}),e.jsx(z,{children:"Admin Business Configuration"})]}),e.jsx(U,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Te,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(r),className:"space-y-6",children:[e.jsx(G,{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(j,{control:i.control,name:"withholdingTaxBookNumber",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Book Number"}),e.jsx(C,{children:e.jsx(B,{placeholder:"Enter book number",...c,className:v(m)})}),e.jsx(w,{})]})}),e.jsx(j,{control:i.control,name:"withholdingTaxFileNumber",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"File Number"}),e.jsx(C,{children:e.jsx(B,{placeholder:"Enter file number",...c,className:v(m)})}),e.jsx(w,{})]})}),e.jsx(ie,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Tax Advances"}),e.jsx(j,{control:i.control,name:"taxAdvancesId",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Identification number"}),e.jsx(C,{children:e.jsx(B,{placeholder:"Enter tax advances ID",...c,className:v(m)})}),e.jsx(w,{})]})}),e.jsx(j,{control:i.control,name:"taxAdvancesRate",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Rate (%)"}),e.jsx(C,{children:e.jsx(B,{type:"number",step:"0.01",min:"0",max:"100",placeholder:"Enter tax rate",...c,className:v(m)})}),e.jsx(w,{})]})}),e.jsx(ie,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Social Security"}),e.jsx(j,{control:i.control,name:"socialSecurityEmployerId",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Employer Identifier"}),e.jsx(C,{children:e.jsx(B,{placeholder:"Enter employer ID",...c,className:v(m)})}),e.jsx(w,{})]})}),e.jsx(ie,{className:"md:col-span-2"}),e.jsx(j,{control:i.control,name:"registrationDate",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Registration Start Date"}),e.jsx(C,{children:e.jsx(B,{type:"date",...c,className:v(m)})}),e.jsx(w,{})]})})]})}),e.jsx(Ee,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(T,{type:"submit",disabled:l||Object.keys(i.formState.dirtyFields).length===0||!i.formState.isValid,children:[e.jsx(Fe,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function ut({businessId:s}){return e.jsxs(M,{children:[e.jsx($,{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(z,{children:"Balance"}),e.jsx(U,{children:"Business balance overview"})]})})}),e.jsx(G,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(ga,{businessID:s,filter:{}})})})]})}function ht({businessId:s}){const{userContext:t}=p.useContext(Le),[a,n]=p.useState(0),[{data:o,fetching:d}]=ee({query:ys,variables:{filters:{byOwners:t?.context.adminBusinessId?[t.context.adminBusinessId]:void 0,sortBy:{field:bs.Date,asc:!1},byBusinesses:[s]},page:a-1,limit:10}}),l=o?.allCharges?.pageInfo.totalPages??1,i=o?.allCharges?.nodes??[];return d?e.jsx("div",{children:"Loading charges..."}):e.jsxs(M,{children:[e.jsxs($,{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(z,{children:"Charges"}),e.jsx(U,{children:"Recurring and one-time charges for this business"})]})}),l>1&&e.jsx(Ns,{className:"flex-fit w-fit mx-0",value:a,onChange:n,total:l})]}),e.jsx(G,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(ya,{data:i,isAllOpened:!1})})})]})}var xt=["type","layout","connectNulls","ref"],pt=["key"];function le(s){"@babel/helpers - typeof";return le=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},le(s)}function qe(s,t){if(s==null)return{};var a=jt(s,t),n,o;if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(s);for(o=0;o<d.length;o++)n=d[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(a[n]=s[n])}return a}function jt(s,t){if(s==null)return{};var a={};for(var n in s)if(Object.prototype.hasOwnProperty.call(s,n)){if(t.indexOf(n)>=0)continue;a[n]=s[n]}return a}function he(){return he=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(s[n]=a[n])}return s},he.apply(this,arguments)}function We(s,t){var a=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),a.push.apply(a,n)}return a}function O(s){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?We(Object(a),!0).forEach(function(n){R(s,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):We(Object(a)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(a,n))})}return s}function te(s){return yt(s)||vt(s)||ft(s)||gt()}function gt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
37
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ft(s,t){if(s){if(typeof s=="string")return Ie(s,t);var a=Object.prototype.toString.call(s).slice(8,-1);if(a==="Object"&&s.constructor&&(a=s.constructor.name),a==="Map"||a==="Set")return Array.from(s);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Ie(s,t)}}function vt(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function yt(s){if(Array.isArray(s))return Ie(s)}function Ie(s,t){(t==null||t>s.length)&&(t=s.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=s[a];return n}function Nt(s,t){if(!(s instanceof t))throw new TypeError("Cannot call a class as a function")}function Ke(s,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(s,os(n.key),n)}}function bt(s,t,a){return t&&Ke(s.prototype,t),a&&Ke(s,a),Object.defineProperty(s,"prototype",{writable:!1}),s}function Ct(s,t,a){return t=fe(t),wt(s,cs()?Reflect.construct(t,a||[],fe(s).constructor):t.apply(s,a))}function wt(s,t){if(t&&(le(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return St(s)}function St(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function cs(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(cs=function(){return!!s})()}function fe(s){return fe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},fe(s)}function kt(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&&De(s,t)}function De(s,t){return De=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},De(s,t)}function R(s,t,a){return t=os(t),t in s?Object.defineProperty(s,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[t]=a,s}function os(s){var t=At(s,"string");return le(t)=="symbol"?t:t+""}function At(s,t){if(le(s)!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var n=a.call(s,t);if(le(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var ce=(function(s){function t(){var a;Nt(this,t);for(var n=arguments.length,o=new Array(n),d=0;d<n;d++)o[d]=arguments[d];return a=Ct(this,t,[].concat(o)),R(a,"state",{isAnimationFinished:!0,totalLength:0}),R(a,"generateSimpleStrokeDasharray",function(l,i){return"".concat(i,"px ").concat(l-i,"px")}),R(a,"getStrokeDasharray",function(l,i,r){var c=r.reduce(function(E,L){return E+L});if(!c)return a.generateSimpleStrokeDasharray(i,l);for(var m=Math.floor(l/c),u=l%c,h=i-l,k=[],b=0,A=0;b<r.length;A+=r[b],++b)if(A+r[b]>u){k=[].concat(te(r.slice(0,b)),[u-A]);break}var D=k.length%2===0?[0,h]:[h];return[].concat(te(t.repeat(r,m)),te(k),D).map(function(E){return"".concat(E,"px")}).join(", ")}),R(a,"id",Ta("recharts-line-")),R(a,"pathRef",function(l){a.mainCurve=l}),R(a,"handleAnimationEnd",function(){a.setState({isAnimationFinished:!0}),a.props.onAnimationEnd&&a.props.onAnimationEnd()}),R(a,"handleAnimationStart",function(){a.setState({isAnimationFinished:!1}),a.props.onAnimationStart&&a.props.onAnimationStart()}),a}return kt(t,s),bt(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,o){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var d=this.props,l=d.points,i=d.xAxis,r=d.yAxis,c=d.layout,m=d.children,u=wa(m,Sa);if(!u)return null;var h=function(A,D){return{x:A.x,y:A.y,value:A.value,errorVal:is(A.payload,D)}},k={clipPath:n?"url(#clipPath-".concat(o,")"):null};return P.createElement(ye,k,u.map(function(b){return P.cloneElement(b,{key:"bar-".concat(b.props.dataKey),data:l,xAxis:i,yAxis:r,layout:c,dataPointFormatter:h})}))}},{key:"renderDots",value:function(n,o,d){var l=this.props.isAnimationActive;if(l&&!this.state.isAnimationFinished)return null;var i=this.props,r=i.dot,c=i.points,m=i.dataKey,u=je(this.props,!1),h=je(r,!0),k=c.map(function(A,D){var E=O(O(O({key:"dot-".concat(D),r:3},u),h),{},{index:D,cx:A.x,cy:A.y,value:A.value,dataKey:m,payload:A.payload,points:c});return t.renderDotItem(r,E)}),b={clipPath:n?"url(#clipPath-".concat(o?"":"dots-").concat(d,")"):null};return P.createElement(ye,he({className:"recharts-line-dots",key:"dots"},b),k)}},{key:"renderCurveStatically",value:function(n,o,d,l){var i=this.props,r=i.type,c=i.layout,m=i.connectNulls;i.ref;var u=qe(i,xt),h=O(O(O({},je(u,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:o?"url(#clipPath-".concat(d,")"):null,points:n},l),{},{type:r,layout:c,connectNulls:m});return P.createElement(ka,he({},h,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,o){var d=this,l=this.props,i=l.points,r=l.strokeDasharray,c=l.isAnimationActive,m=l.animationBegin,u=l.animationDuration,h=l.animationEasing,k=l.animationId,b=l.animateNewValues,A=l.width,D=l.height,E=this.state,L=E.prevPoints,W=E.totalLength;return P.createElement(Aa,{begin:m,duration:u,isActive:c,easing:h,from:{t:0},to:{t:1},key:"line-".concat(k),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(K){var F=K.t;if(L){var X=L.length/i.length,H=i.map(function(I,ve){var oe=Math.floor(ve*X);if(L[oe]){var de=L[oe],ae=me(de.x,I.x),ms=me(de.y,I.y);return O(O({},I),{},{x:ae(F),y:ms(F)})}if(b){var us=me(A*2,I.x),hs=me(D/2,I.y);return O(O({},I),{},{x:us(F),y:hs(F)})}return O(O({},I),{},{x:I.x,y:I.y})});return d.renderCurveStatically(H,n,o)}var se=me(0,W),x=se(F),y;if(r){var S="".concat(r).split(/[,\s]+/gim).map(function(I){return parseFloat(I)});y=d.getStrokeDasharray(x,W,S)}else y=d.generateSimpleStrokeDasharray(W,x);return d.renderCurveStatically(i,n,o,{strokeDasharray:y})})}},{key:"renderCurve",value:function(n,o){var d=this.props,l=d.points,i=d.isAnimationActive,r=this.state,c=r.prevPoints,m=r.totalLength;return i&&l&&l.length&&(!c&&m>0||!Ia(c,l))?this.renderCurveWithAnimation(n,o):this.renderCurveStatically(l,n,o)}},{key:"render",value:function(){var n,o=this.props,d=o.hide,l=o.dot,i=o.points,r=o.className,c=o.xAxis,m=o.yAxis,u=o.top,h=o.left,k=o.width,b=o.height,A=o.isAnimationActive,D=o.id;if(d||!i||!i.length)return null;var E=this.state.isAnimationFinished,L=i.length===1,W=_e("recharts-line",r),K=c&&c.allowDataOverflow,F=m&&m.allowDataOverflow,X=K||F,H=Ae(D)?this.id:D,se=(n=je(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},x=se.r,y=x===void 0?3:x,S=se.strokeWidth,I=S===void 0?2:S,ve=Da(l)?l:{},oe=ve.clipDot,de=oe===void 0?!0:oe,ae=y*2+I;return P.createElement(ye,{className:W},K||F?P.createElement("defs",null,P.createElement("clipPath",{id:"clipPath-".concat(H)},P.createElement("rect",{x:K?h:h-k/2,y:F?u:u-b/2,width:K?k:k*2,height:F?b:b*2})),!de&&P.createElement("clipPath",{id:"clipPath-dots-".concat(H)},P.createElement("rect",{x:h-ae/2,y:u-ae/2,width:k+ae,height:b+ae}))):null,!L&&this.renderCurve(X,H),this.renderErrorBar(X,H),(L||l)&&this.renderDots(X,de,H),(!A||E)&&Ba.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,o){return n.animationId!==o.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:o.curPoints}:n.points!==o.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,o){for(var d=n.length%2!==0?[].concat(te(n),[0]):n,l=[],i=0;i<o;++i)l=[].concat(te(l),te(d));return l}},{key:"renderDotItem",value:function(n,o){var d;if(P.isValidElement(n))d=P.cloneElement(n,o);else if(ba(n))d=n(o);else{var l=o.key,i=qe(o,pt),r=_e("recharts-line-dot",typeof n!="boolean"?n.className:"");d=P.createElement(Ca,he({key:l},i,{className:r}))}return d}}])})(p.PureComponent);R(ce,"displayName","Line");R(ce,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Ea.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});R(ce,"getComposedData",function(s){var t=s.props,a=s.xAxis,n=s.yAxis,o=s.xAxisTicks,d=s.yAxisTicks,l=s.dataKey,i=s.bandSize,r=s.displayedData,c=s.offset,m=t.layout,u=r.map(function(h,k){var b=is(h,l);return m==="horizontal"?{x:$e({axis:a,ticks:o,bandSize:i,entry:h,index:k}),y:Ae(b)?null:n.scale(b),value:b,payload:h}:{x:Ae(b)?null:a.scale(b),y:$e({axis:n,ticks:d,bandSize:i,entry:h,index:k}),value:b,payload:h}});return O({points:u,layout:m},c)});var It=Pa({chartName:"LineChart",GraphicalChild:ce,axisComponents:[{axisType:"xAxis",AxisComp:rs},{axisType:"yAxis",AxisComp:ls}],formatAxisMap:La});const ue=[{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 Dt(){const s=ue.reduce((a,n)=>a+n.revenue,0),t=s/ue.length;return e.jsxs(M,{children:[e.jsxs($,{children:[e.jsx(z,{children:"Revenue Analytics"}),e.jsx(U,{children:"Revenue and expenses over time"})]}),e.jsxs(G,{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(ge,{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(Ce,{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(ge,{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(Ce,{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(ge,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",ue[ue.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Ce,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Oa,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Fa,{width:"100%",height:"100%",children:e.jsxs(It,{data:ue,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(_a,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(rs,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ls,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Va,{content:e.jsx(Ra,{})}),e.jsx(ce,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(ce,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Bt="updateBusiness",ds=()=>{const[{fetching:s},t]=Ze(Cs),a=p.useCallback(async n=>{const o=`Error updating business ID [${n.businessId}]`,d=`${Bt}-${n.businessId}`;ne.loading("Updating business",{id:d});try{const l=await t(n),i=es(l,o,d,"updateBusiness");if(i)return ne.success("Success",{id:d,description:"Business updated"}),i.updateBusiness}catch(l){console.error(`${o}: ${l}`),ne.error("Error",{id:d,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateBusiness:a}},Tt=Object.values(_s);function He(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 Et(s){const a=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,o=s.description||s.tags||s.phrases||s.emails||a?{description:s.description,tags:s.tags?.map(d=>({id:d})),phrases:s.phrases,emails:s.emails,emailListener:a}: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:o}}function Pt({data:s,refetchBusiness:t}){const a=pe(Ss,s),[n,o]=p.useState(He(a)),{userContext:d}=p.useContext(Le),{updateBusiness:l,fetching:i}=ds(),[r,c]=p.useState(!1),[m,u]=p.useState(void 0),h=Be({defaultValues:n}),k=async A=>{if(!a||!d?.context.adminBusinessId)return;const D=Pe(A,h.formState.dirtyFields);if(!D)return;const E=Et(D);await l({businessId:a.id,ownerId:d.context.adminBusinessId,fields:E}),D.tags?.length||D.description?(u({tagIds:D.tags?.map(L=>({id:L})),description:D.description}),c(!0)):t?.()};if(p.useEffect(()=>{if(a){const A=He(a);o(A),h.reset(A)}},[a,h]),!a)return e.jsx("div",{});const b=h.watch("isClient");return e.jsxs(M,{children:[e.jsx($,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(z,{children:"Configurations"}),e.jsx(U,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!b&&e.jsx(ws,{businessId:a.id,onDone:t})]})}),e.jsx(Te,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(k),children:[e.jsxs(G,{className:"space-y-6",children:[e.jsx(Lt,{form:h}),e.jsx(ie,{}),e.jsx(Ot,{form:h}),e.jsx(ie,{}),e.jsx(Ft,{form:h}),e.jsx(ie,{}),e.jsx(_t,{form:h})]}),e.jsx(Ee,{className:"flex justify-end border-t pt-6",children:e.jsxs(T,{type:"submit",disabled:i||Object.keys(h.formState.dirtyFields).length===0,children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(rt,{businessId:a.id,tagIds:m?.tagIds,description:m?.description,open:r,onOpenChange:c,onClose:t})]})}function Lt({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(j,{control:s.control,name:"isClient",render:({field:t,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Client"}),e.jsx(J,{children:"Mark this business as a client"})]}),e.jsx(C,{children:e.jsx(Q,{disabled:!0,checked:t.value,onCheckedChange:t.onChange,className:v(a)})})]})}),e.jsx(j,{control:s.control,name:"isActive",render:({field:t,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Active"}),e.jsx(J,{children:"Business is currently active"})]}),e.jsx(C,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:v(a)})})]})}),e.jsx(j,{control:s.control,name:"isReceiptEnough",render:({field:t,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Receipt Enough"}),e.jsx(J,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(C,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:v(a)})})]})}),e.jsx(j,{control:s.control,name:"isDocumentsOptional",render:({field:t,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"No Docs Required"}),e.jsx(J,{children:"Skip document validation for common charges"})]}),e.jsx(C,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:v(a)})})]})}),e.jsx(j,{control:s.control,name:"isVatOptional",render:({field:t,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is VAT Optional"}),e.jsx(J,{children:"Mute missing VAT indicator"})]}),e.jsx(C,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:v(a)})})]})}),e.jsx(j,{control:s.control,name:"isExemptDealer",render:({field:t,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Exempt Dealer"}),e.jsx(J,{children:"Business is exempt from VAT requirements"})]}),e.jsx(C,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:v(a)})})]})})]})]})}function Ot({form:s}){const{selectableTaxCategories:t,fetching:a}=ks(),{selectableSortCodes:n,fetching:o,sortCodes:d}=As(),{selectableTags:l,fetching:i}=Is(),r=p.useCallback(c=>{if(c){const m=d.find(u=>Number(u.key)===Number(c));m&&(m.defaultIrsCode?s.setValue("irsCode",m.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,d]);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(j,{control:s.control,name:"sortCode",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Sort Code"}),e.jsx(C,{children:e.jsx(we,{onChange:u=>{r(u),c.onChange(u)},data:n,value:c.value,disabled:o,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:v(m)}})}),e.jsx(w,{})]})}),e.jsx(j,{control:s.control,name:"taxCategory",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Category"}),e.jsx(C,{children:e.jsx(we,{data:t,disabled:a,value:c.value,onChange:c.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:v(m)}})}),e.jsx(w,{})]})}),e.jsx(j,{control:s.control,name:"pcn874RecordType",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"PCN874 Record Type"}),e.jsxs(Ds,{onValueChange:c.onChange,value:c.value,children:[e.jsx(C,{children:e.jsx(Bs,{className:v(m),children:e.jsx(Ts,{})})}),e.jsx(Es,{children:Object.entries(Ps).map(([u,h])=>e.jsx(Ls,{value:u,children:`${h} (${u})`},u))})]}),e.jsx(w,{})]})}),e.jsx(j,{control:s.control,name:"irsCode",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(C,{children:e.jsx(Os,{value:c.value??void 0,onValueChange:u=>c.onChange(u??null),hideControls:!0,decimalScale:0,className:v(m)})}),e.jsx(w,{})]})}),e.jsx(j,{control:s.control,name:"description",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Charge Description"}),e.jsx(C,{children:e.jsx(B,{placeholder:"Enter default charge description",...c,className:v(m)})}),e.jsx(w,{})]})}),e.jsx(j,{control:s.control,name:"tags",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tags"}),e.jsx(C,{children:e.jsx(Fs,{options:Object.values(l).map(({value:u,label:h})=>({label:h,value:u})),onValueChange:c.onChange,defaultValue:c.value,value:c.value,placeholder:"Select Default Tags",variant:"default",disabled:i,className:v(m)})}),e.jsx(w,{})]})})]})]})}function Ft({form:s}){const[t,a]=p.useState(""),[n,o]=p.useState(""),d=()=>{if(t.trim()){const c=s.getValues("phrases");s.setValue("phrases",[...c,t.trim()],{shouldDirty:!0}),a("")}},l=()=>{if(n.trim()){const c=s.getValues("emails");s.setValue("emails",[...c,n.trim()],{shouldDirty:!0}),o("")}},i=c=>{const m=s.getValues("phrases");s.setValue("phrases",m.filter((u,h)=>h!==c),{shouldDirty:!0})},r=c=>{const m=s.getValues("emails");s.setValue("emails",m.filter((u,h)=>h!==c),{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(j,{control:s.control,name:"phrases",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{placeholder:"Add phrase...",value:t,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),d())},className:v(m)}),e.jsx(T,{type:"button",size:"sm",onClick:d,children:e.jsx(re,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:c.value?.map((u,h)=>e.jsxs(Y,{variant:"secondary",className:"gap-1",children:[u,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>i(h),children:e.jsx(xe,{className:"size-3 cursor-pointer",onClick:()=>i(h)})})]},h))}),e.jsx(w,{})]})}),e.jsx(j,{control:s.control,name:"emails",render:({field:c,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{type:"email",placeholder:"Add email...",value:n,onChange:u=>o(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),l())},className:v(m)}),e.jsx(T,{type:"button",size:"sm",onClick:l,children:e.jsx(re,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:c.value?.map((u,h)=>e.jsxs(Y,{variant:"secondary",className:"gap-1",children:[u,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>r(h),children:e.jsx(xe,{className:"size-3 cursor-pointer"})})]},h))}),e.jsx(w,{})]})})]})}function _t({form:s}){const[t,a]=p.useState(""),n=()=>{if(t.trim()){const l=s.getValues("internalLinks");s.setValue("internalLinks",[...l,t.trim()],{shouldDirty:!0}),a("")}},o=l=>{const i=s.getValues("attachmentTypes");s.setValue("attachmentTypes",i?.includes(l)?i.filter(r=>r!==l):[...i,l],{shouldDirty:!0})},d=l=>{const i=s.getValues("internalLinks");s.setValue("internalLinks",i.filter((r,c)=>c!==l),{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(j,{control:s.control,name:"attachmentTypes",render:({field:l,fieldState:i})=>e.jsxs(g,{children:[e.jsx(f,{children:"Attachment Types"}),e.jsx("div",{className:v(i)+" rounded-md flex flex-wrap gap-2",children:Tt.map(r=>e.jsx(Y,{variant:l.value?.includes(r)?"default":"outline",className:"cursor-pointer",onClick:()=>o(r),children:r},r))}),e.jsx(w,{})]})}),e.jsx(j,{control:s.control,name:"internalLinks",render:({field:l,fieldState:i})=>e.jsxs(g,{children:[e.jsx(f,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{type:"url",placeholder:"Add internal link...",value:t,onChange:r=>a(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),n())}}),e.jsx(T,{type:"button",size:"sm",onClick:n,children:e.jsx(re,{className:"h-4 w-4"})})]}),e.jsx("div",{className:v(i)+" flex flex-wrap gap-2 rounded-md",children:l.value?.map((r,c)=>e.jsxs(Y,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[r,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>d(c),children:e.jsx(xe,{className:"size-3 cursor-pointer flex-shrink-0"})})]},c))}),e.jsx(w,{})]})}),e.jsx(j,{control:s.control,name:"useMessageBody",render:({field:l,fieldState:i})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Should Use Message Body"}),e.jsx(J,{children:"Extract information from email message body"})]}),e.jsx(C,{children:e.jsx(Q,{checked:l.value,onCheckedChange:l.onChange,className:v(i)})})]})})]})}const Vt=ts({businessName:_().min(1,"Business name is required"),locality:_().min(1,"Locality is required"),localName:_().optional(),govId:_().optional(),address:_().optional(),localAddress:_().optional(),phone:_().optional(),website:$s("Invalid URL").optional().or(zs("")),generalContacts:Re(Me()).optional(),billingEmails:Re(Me()).optional()});function Xe(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 Rt(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 Mt({data:s,refetchBusiness:t}){const a=pe(Ms,s),[n,o]=p.useState(Xe(a)),{userContext:d}=p.useContext(Le),{updateBusiness:l,fetching:i}=ds(),r=Be({resolver:ss(Vt),defaultValues:n}),{countries:c,fetching:m}=Vs(),[u,h]=p.useState(""),[k,b]=p.useState(""),A=r.watch("locality"),D=r.watch("address"),E=r.watch("localAddress");p.useEffect(()=>{D!==n.address&&r.setValue("address",D,{shouldDirty:!0})},[D,n.address,r]),p.useEffect(()=>{E!==n.localAddress&&r.setValue("localAddress",E,{shouldDirty:!0})},[E,n.localAddress,r]);const L=a&&"clientInfo"in a&&!!a.clientInfo,W=A===d?.context.locality,K=x=>{u.trim()&&(r.setValue("generalContacts",[...x,u.trim()],{shouldDirty:!0}),h(""))},F=(x,y)=>{r.setValue("generalContacts",x.filter((S,I)=>I!==y),{shouldDirty:!0})},X=x=>{k.trim()&&(r.setValue("billingEmails",[...x,k.trim()],{shouldDirty:!0}),b(""))},H=(x,y)=>{r.setValue("billingEmails",x.filter((S,I)=>I!==y),{shouldDirty:!0})},se=async x=>{if(!a||!d?.context.adminBusinessId)return;const y=Pe(x,r.formState.dirtyFields);if(!y)return;const S=Rt(y);await l({businessId:a.id,ownerId:d.context.adminBusinessId,fields:S}),t?.()};return p.useEffect(()=>{if(a){const x=Xe(a);o(x),r.reset(x)}},[a,r]),e.jsxs(M,{children:[e.jsxs($,{children:[e.jsx(z,{children:"Contact Information"}),e.jsx(U,{children:"Business contact details and address information"})]}),e.jsx(Te,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(se),children:[e.jsx(G,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:r.control,name:"businessName",render:({field:x,fieldState:y})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Name"}),e.jsx(C,{children:e.jsx(B,{...x,className:v(y)})}),e.jsx(w,{})]})}),e.jsx(j,{control:r.control,name:"locality",render:({field:x,fieldState:y})=>e.jsxs(g,{children:[e.jsx(f,{children:"Locality / Country"}),e.jsx(we,{onChange:x.onChange,data:c.map(S=>({value:S.code,label:S.name})),value:x.value,disabled:m,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:v(y)}}),e.jsx(w,{})]})}),W&&e.jsx(j,{control:r.control,name:"localName",render:({field:x,fieldState:y})=>e.jsxs(g,{children:[e.jsx(f,{children:"Local Name"}),e.jsx(C,{children:e.jsx(B,{...x,placeholder:"Business name in local language",className:v(y)})}),e.jsx(w,{})]})}),W&&e.jsx(j,{control:r.control,name:"govId",render:({field:x,fieldState:y})=>e.jsxs(g,{children:[e.jsx(f,{children:"Government ID"}),e.jsx(C,{children:e.jsx(B,{...x,placeholder:"Enter Government ID",className:v(y)})}),e.jsx(w,{})]})}),e.jsx(j,{control:r.control,name:"address",render:({field:x,fieldState:y})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4"}),"Address"]}),e.jsx(C,{children:e.jsx(Ve,{...x,rows:3,placeholder:"Enter business address",className:v(y)})}),e.jsx(w,{})]})}),W&&e.jsx(j,{control:r.control,name:"localAddress",render:({field:x,fieldState:y})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(C,{children:e.jsx(Ve,{...x,rows:3,placeholder:"Enter address in local language",className:v(y)})}),e.jsx(w,{})]})}),e.jsx(j,{control:r.control,name:"phone",render:({field:x,fieldState:y})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(ns,{className:"h-4 w-4"}),"Phone"]}),e.jsx(C,{children:e.jsx(B,{...x,type:"tel",placeholder:"+1 (555) 123-4567",className:v(y)})}),e.jsx(w,{})]})}),e.jsx(j,{control:r.control,name:"website",render:({field:x,fieldState:y})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-4 w-4"}),"Website"]}),e.jsx(C,{children:e.jsx(B,{...x,type:"url",placeholder:"https://example.com",className:v(y)})}),e.jsx(w,{})]})}),e.jsx(j,{control:r.control,name:"generalContacts",render:({field:x,fieldState:y})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(C,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:v(y)+" flex flex-wrap gap-2 mb-2 rounded-md",children:x.value?.map((S,I)=>e.jsxs(Y,{variant:"secondary",className:"gap-1 pr-1",children:[S,e.jsx("button",{type:"button",onClick:()=>F(x.value??[],I),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(xe,{className:"h-3 w-3"})})]},I))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{value:u,onChange:S=>h(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),K(x.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(T,{type:"button",variant:"outline",size:"icon",disabled:!u.trim(),onClick:()=>K(x.value??[]),children:e.jsx(re,{className:"h-4 w-4"})})]})]})}),e.jsx(w,{})]})}),L&&e.jsx(j,{control:r.control,name:"billingEmails",render:({field:x,fieldState:y})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(C,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:v(y)+" flex flex-wrap gap-2 mb-2 rounded-md",children:x.value?.map((S,I)=>e.jsxs(Y,{variant:"secondary",className:"gap-1 pr-1",children:[S,e.jsx("button",{type:"button",onClick:()=>H(x.value??[],I),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(xe,{className:"h-3 w-3"})})]},I))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(B,{value:k,onChange:S=>b(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),X(x.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(T,{type:"button",variant:"outline",size:"icon",disabled:!k.trim(),onClick:()=>X(x.value??[]),children:e.jsx(re,{className:"h-4 w-4"})})]})]})}),e.jsx(w,{})]})})]})}),e.jsx(Ee,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(T,{type:"submit",disabled:i||Object.keys(r.formState.dirtyFields).length===0,children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}function $t(s){return{id:s.id,pos:s.purchaseOrders??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,operationsLimit:s.operationsLimit}}function zt({clientId:s}){const[t,a]=p.useState(null),[{data:n,fetching:o},d]=ee({query:Us,variables:{clientId:s}}),l=n?.contractsByClient??[];return o?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(M,{children:[e.jsx($,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(z,{children:"Contracts"}),e.jsx(U,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Ma,{clientId:s,contract:t,onDone:d})]})}),e.jsx(G,{className:"space-y-4",children:l.map(i=>{const r=!!i.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:i.product}),e.jsx(Y,{variant:r?"default":"secondary",children:i.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:i.id})]}),e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>a($t(i)),children:e.jsx(Ua,{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(Gs,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(i.startDate).toLocaleDateString()," →"," ",new Date(i.endDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"PO Numbers"}),e.jsx("p",{className:"text-sm font-medium font-mono",children:i.purchaseOrders.toReversed()[0]??""}),i.purchaseOrders.length>1&&e.jsx("div",{className:"space-x-1",children:i.purchaseOrders.toReversed().slice(1).map(c=>e.jsx("span",{className:"text-xs font-thin font-mono",children:c},c))})]}),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:qs(i.amount.raw,i.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:$a(i.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:i.plan?za(i.plan):"N/A"})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Operations Limit"}),e.jsx("p",{className:"text-sm font-medium",children:i.operationsLimit.toLocaleString()})]}),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:Ws(i.documentType)})]})]}),i.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:i.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.msCloud&&e.jsx(T,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Ks,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(Ga,{className:"h-3 w-3 ml-1"})]})})})]},i.id)})})]})}function Ut({businessId:s}){return e.jsxs(M,{children:[e.jsx($,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(z,{children:"Documents"}),e.jsx(U,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(G,{children:e.jsx(Hs,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const Gt=[{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 qt({data:s}){const t=pe(Ys,s),[{data:a,fetching:n},o]=ee({query:Xs,variables:{clientId:t?.id??""},pause:!t?.clientInfo?.greenInvoiceId||!t?.id}),{updateClient:d}=Js(),l=p.useCallback((r,c)=>{if(!t?.id)return;const m={};m[c]=r,d({businessId:t?.id,fields:m})},[t?.id,d]);p.useEffect(()=>{t?.clientInfo?.greenInvoiceId&&t?.id&&o()},[t?.clientInfo?.greenInvoiceId,t?.id,o]);const i=a?.greenInvoiceClient;return e.jsxs(M,{children:[e.jsx($,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(z,{children:"Integrations"}),e.jsx(U,{children:"Connected external services and providers"})]}),e.jsxs(T,{size:"sm",children:[e.jsx(re,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(G,{className:"space-y-6",children:e.jsxs(Wa,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[n?e.jsxs(Ne,{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(N,{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(N,{className:"h-6 w-32"}),e.jsx(N,{className:"h-5 w-5 rounded-full"})]}),e.jsx(N,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:"h-8 w-24"}),e.jsx(N,{className:"h-8 w-8"})]})]})}),e.jsx(be,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{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(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{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(N,{className:"h-3 w-32"}),e.jsx(N,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{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(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(Ne,{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(Ue,{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(Wt,{id:t?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async r=>l(r,"greenInvoiceId")}),e.jsx(ze,{className:"hover:no-underline p-2"})]})]})}),e.jsx(be,{children:i&&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:i.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:i.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:i.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(ke,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.emails?.map((r,c)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:r},c))})]}),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(ns,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:i.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:i.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:i.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(Se,{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:i.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:i.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:i.zip})]})]})]})]})})]}),Gt.map(r=>e.jsxs(Ne,{value:r.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:r.name}),r.status==="connected"?e.jsx(Ue,{className:"h-4 w-4 text-green-600"}):e.jsx(Qs,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{variant:"ghost",size:"sm",onClick:c=>c.stopPropagation(),children:e.jsx(Oe,{className:"h-4 w-4"})}),e.jsx(ze,{className:"hover:no-underline p-2"})]})]})}),e.jsx(be,{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:r.lastSync})]})})})]},r.id))]})})]})}function Wt({id:s,provider:t,updateClient:a}){const[n,o]=p.useState(!1),[d,l]=p.useState(s),i=p.useCallback(async()=>{await a(d),o(!1)},[d,a]);return e.jsxs(Je,{open:n,onOpenChange:o,children:[e.jsx(Zs,{asChild:!0,children:e.jsxs(T,{variant:"outline",size:"sm",onClick:r=>r.stopPropagation(),children:[e.jsx(Oe,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(Qe,{onClick:r=>r.stopPropagation(),children:[e.jsxs(ea,{children:[e.jsxs(sa,{children:["Configure ",t]}),e.jsxs(aa,{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(ta,{htmlFor:"id",children:[t," ID"]}),e.jsx(B,{id:"id",value:d,onChange:r=>l(r.target.value),placeholder:`Enter ${t} ID`})]})}),e.jsxs(na,{children:[e.jsx(T,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(T,{onClick:i,disabled:!d,children:"Save Changes"})]})]})]})}function Kt({businessId:s}){const[{data:t,fetching:a}]=ee({query:ia,variables:{businessId:s}});return a?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(M,{children:[e.jsx($,{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(z,{children:"Ledger Records"}),e.jsx(U,{children:"Complete ledger history for this business"})]})})}),e.jsx(G,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Na,{ledgerRecordsData:t?.ledgerRecordsByFinancialEntity??[]})})})]})}function Ht({businessId:s}){const[{data:t,fetching:a}]=ee({query:ra,variables:{businessId:s}});return a?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(M,{children:[e.jsx($,{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(z,{children:"Transactions"}),e.jsx(U,{children:"Complete transaction history for this business"})]})})}),e.jsx(G,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(qa,{transactionsProps:t?.transactionsByFinancialEntity??[]})})})]})}function Xt({data:s,refetchBusiness:t}){const a=pe(ha,s),[n,o]=la(),{setFiltersContext:d}=p.useContext(ca);p.useEffect(()=>{d(null)},[d]);const l=n.get("tab")||"contact",i=m=>{o({tab:m})};if(!a)return e.jsx("div",{children:"Business not found"});const r="clientInfo"in a&&!!a.clientInfo,c="adminInfo"in a&&!!a.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(fa,{data:a}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(oa,{value:l,onValueChange:i,className:"w-full",children:[e.jsxs(da,{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(q,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ka,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(q,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Oe,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(q,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ge,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(q,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ma,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(q,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ua,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),e.jsxs(q,{value:"ledger",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:"Ledger"})]}),e.jsxs(q,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Xa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(q,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Za,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(q,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(tt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),c&&e.jsxs(q,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(as,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx(V,{value:"contact",className:"mt-0",children:e.jsx(Mt,{data:a,refetchBusiness:t})}),e.jsx(V,{value:"config",className:"mt-0",children:e.jsx(Pt,{data:a,refetchBusiness:t})}),e.jsx(V,{value:"charges",className:"mt-0",children:e.jsx(ht,{businessId:a.id})}),e.jsx(V,{value:"transactions",className:"mt-0",children:e.jsx(Ht,{businessId:a.id})}),e.jsx(V,{value:"documents",className:"mt-0",children:e.jsx(Ut,{businessId:a.id})}),e.jsx(V,{value:"ledger",className:"mt-0",children:e.jsx(Kt,{businessId:a.id})}),e.jsx(V,{value:"balance",className:"mt-0",children:e.jsx(ut,{businessId:a.id})}),r&&e.jsxs(e.Fragment,{children:[e.jsx(V,{value:"contracts",className:"mt-0",children:e.jsx(zt,{clientId:a.id})}),e.jsx(V,{value:"integrations",className:"mt-0",children:e.jsx(qt,{data:a})}),e.jsx(V,{value:"charts",className:"mt-0",children:e.jsx(Dt,{})})]}),c&&e.jsx(V,{value:"admin",className:"mt-0",children:e.jsx(mt,{data:a})})]})})]})}const fn=()=>{const{businessId:s}=xa();let t;try{t=pa()}catch{}const[{data:a,fetching:n},o]=ee({query:ja,pause:!s||!!t,variables:{businessId:s??""}}),d=t||a;return!t&&n&&!d?.business?e.jsx(Ye,{}):!s||!d?.business?e.jsx("div",{children:"Business not found"}):e.jsx(Xt,{data:d.business,refetchBusiness:async()=>o()})};export{fn as BusinessScreen};
|
package/dist/assets/{business-extended-info-1mzdXJbs.js → business-extended-info-u-wZchjH.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as M,
|
|
1
|
+
import{v as M,c5 as G,r as D,c7 as J,aa as V,c9 as H,j as e,de as K,w as v,u as Y,dX as q,bb as o,c as Q,T as W,B as X,bm as P,R as S,aK as A,bd as Z}from"./index-BZ8AOwEl.js";import{D as ee}from"./download-csv-button-tWswwko2.js";import{T as ne}from"./Table-DxJ1YCr5.js";/**
|
|
2
2
|
* @license lucide-react v0.548.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,6 +8,6 @@ import{v as M,bC as G,r as D,bE as V,ai as J,bG as H,j as e,cP as K,x as v,u 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 re=[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]],ae=M("chevrons-right-left",re);var oe=G((n,{color:s})=>({root:{backgroundColor:n.fn.themeColor(s,n.colorScheme==="dark"?5:2),color:n.colorScheme==="dark"?n.colors.dark[9]:"inherit"}})),ce=Object.defineProperty,C=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,
|
|
12
|
-
`;for(const a of n){const i=fe(a,t);s+=i}return s};function he(n){let s="";return n.map(t=>{const a=K(t);s+=`${t}(${a}) Amount,${t}(${a}) Balance,`}),s}function xe(n,s){let t="";return s.map(a=>{n.foreignAmount&&n.foreignAmount.currency===a?t+=`${n.foreignAmount.raw},${n[`${a.toLowerCase()}Balance`]??0},`:t+=",,"}),t}function fe(n,s){let t="";const a=n.invoiceDate?v(new Date(n.invoiceDate),"yyy-MM-dd"):null,i=n.invoiceDate?v(new Date(n.invoiceDate),"dd/MM/yy"):null,u=n.amount.raw,{ilsBalance:h,reference:x,details:f}=n,l=n.counterAccount?.name??"";return t+=`${a},${i},${u},${h},${xe(n,s)}${
|
|
13
|
-
`,t}function
|
|
11
|
+
*/const re=[["path",{d:"m20 17-5-5 5-5",key:"30x0n2"}],["path",{d:"m4 17 5-5-5-5",key:"16spf4"}]],ae=M("chevrons-right-left",re);var oe=G((n,{color:s})=>({root:{backgroundColor:n.fn.themeColor(s,n.colorScheme==="dark"?5:2),color:n.colorScheme==="dark"?n.colors.dark[9]:"inherit"}})),ce=Object.defineProperty,C=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,T=(n,s,t)=>s in n?ce(n,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[s]=t,ie=(n,s)=>{for(var t in s||(s={}))O.call(s,t)&&T(n,t,s[t]);if(C)for(var t of C(s))w.call(s,t)&&T(n,t,s[t]);return n},le=(n,s)=>{var t={};for(var a in n)O.call(n,a)&&s.indexOf(a)<0&&(t[a]=n[a]);if(n!=null&&C)for(var a of C(n))s.indexOf(a)<0&&w.call(n,a)&&(t[a]=n[a]);return t};const de={color:"yellow"},p=D.forwardRef((n,s)=>{const t=J("Mark",de,n),{color:a,className:i,unstyled:u,variant:h}=t,x=le(t,["color","className","unstyled","variant"]),{classes:f,cx:l}=oe({color:a},{unstyled:u,name:"Mark",variant:h});return V.createElement(H,ie({component:"mark",ref:s,className:l(f.root,i)},x))});p.displayName="@mantine/core/Mark";const ue=({ledgerRecords:n,businessName:s,fromDate:t,toDate:a})=>{const i=D.useCallback(async()=>{const u=me(n);return{fileName:`business_${s}_ledger_records${t?`_${t}`:""}${a?`_${a}`:""}`,fileContent:u}},[n,s,t,a]);return e.jsx(ee,{createFileVariables:i})},me=n=>{let s="";const t=Array.from(new Set(n.filter(a=>a.foreignAmount?.currency).map(a=>a.foreignAmount.currency)));s+=`Sorting Date,Date,Amount,Amount Balance,${he(t)}Reference,Details,Counter Account\r
|
|
12
|
+
`;for(const a of n){const i=fe(a,t);s+=i}return s};function he(n){let s="";return n.map(t=>{const a=K(t);s+=`${t}(${a}) Amount,${t}(${a}) Balance,`}),s}function xe(n,s){let t="";return s.map(a=>{n.foreignAmount&&n.foreignAmount.currency===a?t+=`${n.foreignAmount.raw},${n[`${a.toLowerCase()}Balance`]??0},`:t+=",,"}),t}function fe(n,s){let t="";const a=n.invoiceDate?v(new Date(n.invoiceDate),"yyy-MM-dd"):null,i=n.invoiceDate?v(new Date(n.invoiceDate),"dd/MM/yy"):null,u=n.amount.raw,{ilsBalance:h,reference:x,details:f}=n,l=n.counterAccount?.name??"";return t+=`${a},${i},${u},${h},${xe(n,s)}${b(x??"")},${b(f??"")},${b(l)},\r
|
|
13
|
+
`,t}function b(n){return n===""?"":Number.isNaN(Number(n))?String(n).replace(/"/g,'""').replace(/,/g,"."):Number(n).toFixed(2).toString()}function Ae({businessID:n,filter:s}){const[t,a]=D.useState(!1),{fromDate:i,ownerIds:u,toDate:h}=s??{},[{data:x,fetching:f}]=Y({query:q,variables:{filters:{fromDate:i,ownerIds:u,toDate:h,businessIDs:[n]}}}),l=x?.businessTransactionsFromLedgerRecords.__typename==="CommonError"?[]:x?.businessTransactionsFromLedgerRecords.businessTransactions.sort((r,g)=>r.invoiceDate>g.invoiceDate?1:-1)??[],j=[];for(let r=0;r<l.length;r++){const{__typename:g,...c}=l[r],z=r===0?c.amount.raw:(j[r-1].ilsBalance??0)+c.amount.raw,I={};Object.values(o).map(y=>{if(y!==o.Ils){const L=`${y.toLowerCase()}Balance`;I[L]=r===0?(c.foreignAmount?.currency===y?c.foreignAmount?.raw:0)??0:(j[r-1]?.[L]??0)+(c.foreignAmount?.currency===y?c.foreignAmount?.raw:0)}}),j.push({...c,ilsBalance:z,...I})}const m=new Set(l.filter(r=>r.foreignAmount?.currency).map(r=>r.foreignAmount.currency)),B=t||m.has(o.Eur),_=t||m.has(o.Usd),k=t||m.has(o.Gbp),E=t||m.has(o.Cad),N=t||m.has(o.Jpy),$=t||m.has(o.Aud),F=t||m.has(o.Sek),R=l[0]?.business.name??"unknown";return e.jsx("div",{className:"flex flex-row gap-5",children:f?e.jsx(Q,{}):e.jsxs(ne,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex: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:"Business Name"}),e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount Balance"}),B&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"EUR Amount"}),e.jsx("th",{children:"EUR Balance"})]}),_&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"USD Amount"}),e.jsx("th",{children:"USD Balance"})]}),k&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"GBP Amount"}),e.jsx("th",{children:"GBP Balance"})]}),E&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"CAD Amount"}),e.jsx("th",{children:"CAD Balance"})]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"JPY Amount"}),e.jsx("th",{children:"JPY Balance"})]}),$&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"AUD Amount"}),e.jsx("th",{children:"AUD Balance"})]}),F&&e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"SEK Amount"}),e.jsx("th",{children:"SEK Balance"})]}),e.jsx("th",{children:e.jsx(W,{label:"Expand all currencies",children:e.jsx(X,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>a(r=>!r),children:t?e.jsx(ae,{className:"size-5"}):e.jsx(se,{className:"size-5"})})})}),t&&e.jsx(e.Fragment,{children:U.map(r=>e.jsxs(e.Fragment,{children:[e.jsxs("th",{children:[r," Amount"]}),e.jsxs("th",{children:[r," Balance"]})]}))}),e.jsx("th",{children:"Reference"}),e.jsx("th",{children:"Details"}),e.jsx("th",{children:"Counter Account"}),e.jsx("th",{children:e.jsx(ue,{ledgerRecords:j,businessName:R,fromDate:s?.fromDate??void 0,toDate:s?.toDate??void 0})})]})}),e.jsx("tbody",{children:j.map((r,g)=>e.jsxs("tr",{className:"cursor-pointer",onClick:c=>{c.stopPropagation(),window.open(S.CHARGES.DETAIL(r.chargeId),"_blank","noreferrer")},children:[e.jsx("td",{children:e.jsx(P,{to:S.BUSINESSES.DETAIL(r.business.id),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:r.business.name})}),e.jsx("td",{children:r.invoiceDate?v(new Date(r.invoiceDate),"dd/MM/yy"):null}),e.jsx("td",{style:{whiteSpace:"nowrap"},children:r.amount&&r.amount.raw!==0&&e.jsx(p,{color:r.amount.raw>0?"green":"red",children:r.amount.formatted})}),e.jsx("td",{children:r.ilsBalance===0?A(r.ilsBalance,o.Ils):e.jsx(p,{color:r.ilsBalance>0?"green":"red",children:A(r.ilsBalance,o.Ils)})}),B&&e.jsx(d,{data:r,currency:o.Eur}),_&&e.jsx(d,{data:r,currency:o.Usd}),k&&e.jsx(d,{data:r,currency:o.Gbp}),E&&e.jsx(d,{data:r,currency:o.Cad}),N&&e.jsx(d,{data:r,currency:o.Jpy}),$&&e.jsx(d,{data:r,currency:o.Aud}),F&&e.jsx(d,{data:r,currency:o.Sek}),e.jsx("td",{}),t&&e.jsx(je,{data:r}),e.jsx("td",{children:r.reference}),e.jsx("td",{children:r.details}),e.jsx("td",{children:r.counterAccount&&e.jsx(P,{to:S.BUSINESSES.DETAIL(r.counterAccount.id),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:r.counterAccount.name})}),e.jsx("td",{})]},g))})]})})}function d({currency:n,data:s}){const t=s.foreignAmount&&s.foreignAmount.currency===n?s.foreignAmount:null,a=`${n.toLowerCase()}Balance`;return e.jsxs(e.Fragment,{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:!!t&&t.raw!==0&&e.jsx(p,{color:t.raw>0?"green":"red",children:t.formatted})}),e.jsx("td",{children:(s[a]??0)!==0&&(s[a]===0?A(s[a],n):e.jsx(p,{color:s[a]>0?"green":"red",children:A(s[a],n)}))})]})}const U=Object.values(o).filter(n=>!Z.includes(n));function je({data:n}){return e.jsx(e.Fragment,{children:U.map(s=>e.jsx(d,{currency:s,data:n},s))})}export{Ae as B,ae as C,p as M,se as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{G as l,j as e,au as t,w as m,b9 as x}from"./index-BZ8AOwEl.js";import{B as o}from"./building-2-DAb5H_9e.js";function h({data:n}){const s=l(x,n);if(!s||s.__typename!=="LtdFinancialEntity")return e.jsx("div",{});const{isActive:i,adminInfo:r,clientInfo:a}=s,d=!!r?.id,c=!!a?.id;return e.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border bg-card/95 backdrop-blur supports-[backdrop-filter]:bg-card/60",children:e.jsx("div",{className:"container mx-auto px-4 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs("div",{className:"flex h-16 items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-accent",children:e.jsx(o,{className:"h-5 w-5 text-accent-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:s.name}),i?e.jsx(t,{variant:"secondary",children:"Active"}):e.jsx(t,{variant:"destructive",children:"Inactive"}),d&&e.jsx(t,{variant:"outline",children:"Admin"}),c&&e.jsx(t,{variant:"outline",children:"Client"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["Business ID: ",s.id]})]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-6 text-sm",children:[s.governmentId&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"font-medium text-foreground",children:s.governmentId})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Since"}),e.jsx("p",{className:"font-medium text-foreground",children:m(s.createdAt,"MMM yyyy")})]})]})]})})})}export{h as B};
|
package/dist/assets/{business-ledger-filters-BRB1r_DP.js → business-ledger-filters-DyyAMsOt.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as
|
|
1
|
+
import{r as x,be as y,j as e,bf as C,B as S,y as I,bg as F,a7 as B,bh as m,bi as v,bj as j,w as f,bk as E,bl as w}from"./index-BZ8AOwEl.js";import{u as N}from"./use-url-query-DOEL3cY1.js";import{P as L}from"./modal-8mlzJehM.js";import{F as R}from"./funnel-Bmrsutts.js";import{M as D}from"./MultiSelect-BKzjkxRf.js";function A({filter:r,setFilter:b,closeModal:u,single:l=!1}){const{control:n,handleSubmit:p}=I({defaultValues:{...r}}),{selectableBusinesses:d,fetching:i}=F(),{userContext:g}=x.useContext(B),h=s=>{b(s),u()};function o(){b({businessIDs:l?r.businessIDs:void 0}),u()}return e.jsxs(e.Fragment,{children:[i?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:p(h),children:[e.jsx(m,{name:"ownerIds",control:n,defaultValue:r.ownerIds,render:({field:s,fieldState:a})=>e.jsx(D,{...s,data:d,value:s.value??(g?.context.adminBusinessId?[g.context.adminBusinessId]:void 0),disabled:i,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),!l&&e.jsx(m,{name:"businessIDs",control:n,defaultValue:r.businessIDs,render:({field:s,fieldState:a})=>e.jsx(D,{...s,data:d,value:s.value??void 0,disabled:i,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(m,{name:"fromDate",control:n,defaultValue:r.fromDate,rules:{pattern:{value:v,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:a})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:a.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"toDate",control:n,defaultValue:r.toDate,rules:{pattern:{value:v,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:a})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:a.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"type",control:n,defaultValue:null,render:({field:s,fieldState:a})=>e.jsx(E,{...s,onChange:t=>s.onChange(t==="NULL"?null:t),data:[{value:"NULL",label:"All"},{value:"BUSINESS",label:"Business"},{value:"TAX_CATEGORY",label:"Tax Category"}],error:a.error?.message,label:"Type"})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:o,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:u,children:"Cancel"})]})]})]})}function O({filter:r,setFilter:b}){const[u,l]=x.useState(!1),[n,p]=x.useState(!y(r)),{get:d,set:i}=N();function g(o){return Object.entries(o??{}).filter(([a,t])=>t!==void 0&&Array.isArray(t)&&t.length>0).length>0}function h(o){o.fromDate?.trim()===""&&(o.fromDate=void 0),o.toDate?.trim()===""&&(o.toDate=void 0),w(o,r)||(b(o),p(g(o)))}return x.useEffect(()=>{const o=y(r)?null:encodeURIComponent(JSON.stringify(r)),s=d("ledgerRecordsFilters");o!==s&&i("ledgerRecordsFilters",o)},[r,d,i]),e.jsxs(e.Fragment,{children:[e.jsx(L,{opened:u,onClose:()=>l(!1),content:e.jsx(A,{single:!0,filter:r,setFilter:h,closeModal:()=>l(!1)})}),e.jsx(C,{inline:!0,size:16,disabled:!n,children:e.jsx(S,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:e.jsx(R,{className:"size-5"})})})]})}export{O as B};
|
package/dist/assets/{business-ledger-single-C8FIQJ8V.js → business-ledger-single-Cy7nqs_T.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as S,r as c,F as w,u as C,j as n,c as x,
|
|
1
|
+
import{a as S,r as c,F as w,u as C,j as n,c as x,bb as o,bc as y}from"./index-BZ8AOwEl.js";import{u as h}from"./use-url-query-DOEL3cY1.js";import{a as F}from"./accounter-table-CLZmYCK0.js";import{M as p,B as R}from"./business-extended-info-u-wZchjH.js";import{B as v}from"./business-ledger-filters-DyyAMsOt.js";import"./Table-DxJ1YCr5.js";import"./download-csv-button-tWswwko2.js";import"./modal-8mlzJehM.js";import"./funnel-Bmrsutts.js";import"./MultiSelect-BKzjkxRf.js";const M=({businessId:t})=>{const{businessId:r}=S(),{get:s}=h(),{setFiltersContext:u}=c.useContext(w),l=t||r,[m,d]=c.useState(s("ledgerRecordsFilters")?{...JSON.parse(decodeURIComponent(s("ledgerRecordsFilters"))),businessIDs:l?[l]:[]}:{businessIDs:l?[l]:[]}),[{data:a,fetching:f}]=C({query:y,variables:{filters:m}});c.useEffect(()=>{u(n.jsx(v,{filter:m,setFilter:d}))},[a,m,u,d]);const b=c.useMemo(()=>a?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:a?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?a.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((e,g)=>e.business.name.localeCompare(g.business.name)):[],[a?.businessTransactionsSumFromLedgerRecords]);return f?n.jsx(x,{}):n.jsx(F,{moreInfo:e=>n.jsx(R,{businessID:e.business.id,filter:m}),striped:!0,highlightOnHover:!0,stickyHeader:!0,items:b,columns:[{title:"Business Name",value:e=>e.business.name},{title:"Debit",value:e=>e.debit.formatted,style:{whiteSpace:"nowrap"}},{title:"Credit",value:e=>e.credit.formatted,style:{whiteSpace:"nowrap"}},{title:"Total",value:e=>e.total.raw&&(e.total.raw<-1e-4||e.total.raw>1e-4)?n.jsx(p,{color:e.total.raw>0?"green":"red",children:e.total.formatted}):e.total.formatted,style:{whiteSpace:"nowrap"}},...i(o.Eur),...i(o.Usd),...i(o.Gbp),...i(o.Cad),...i(o.Jpy),...i(o.Aud),...i(o.Sek)]})};function i(t){return[{title:`${t} Debit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.debit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Credit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.credit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:r=>{const s=r.foreignCurrenciesSum.find(u=>u.currency===t);return s?.total?.raw&&(s.total.raw<-1e-4||s.total.raw>1e-4)?n.jsx(p,{color:s.total.raw>0?"green":"red",children:s.total.formatted}):s?.total?.formatted},style:{whiteSpace:"nowrap"}}]}export{M as BusinessLedgerRecordsSingle};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p,r as n,F as u,u as m,j as s,c,c4 as x}from"./index-BZ8AOwEl.js";import{P as d,C as l,E as f}from"./editable-business-trip-D0UrHlFI.js";import{P as T}from"./page-layout-BfCdWwql.js";import"./list-plus-CDqpqAwS.js";import"./summary-Sj8NMKlv.js";import"./Table-DxJ1YCr5.js";import"./toggle-expansion-button-Buzq87-g.js";import"./panel-top-open-CpMFDJrl.js";import"./MultiSelect-BKzjkxRf.js";import"./similar-transactions-modal-BPFaQ7dD.js";import"./tooltip-gvPoRI4e.js";const v=({businessTripId:o})=>{const{businessTripId:a}=p(),{setFiltersContext:i}=n.useContext(u),e=o??a??"",[{data:r,fetching:t}]=m({query:x,variables:{businessTripId:e}});return n.useEffect(()=>{i(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(d,{filename:"business_trip_report"})}))},[r,t,i]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(T,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(f,{tripId:e,isExtended:!0})})})};export{v as BusinessTrip};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as I,b as x,r,u as D,j as e,c as f,C as j}from"./index-
|
|
1
|
+
import{a as I,b as x,r,u as D,j as e,c as f,C as j}from"./index-BZ8AOwEl.js";import{C as v}from"./charges-table-D1vDT-UP.js";import{E as M,I as E,M as S}from"./match-document-modal-CETycNjj.js";import"./toggle-expansion-button-Buzq87-g.js";import"./panel-top-open-CpMFDJrl.js";import"./index-Br0GTPfc.js";import"./similar-transactions-modal-BPFaQ7dD.js";import"./addDays-DbkSn4rN.js";import"./list-plus-CDqpqAwS.js";import"./tooltip-gvPoRI4e.js";import"./Table-DxJ1YCr5.js";import"./summary-Sj8NMKlv.js";import"./YearPickerInput-Bp2ytdrx.js";import"./insert-business-trip-modal-4vXkqVnt.js";import"./accounter-table-CLZmYCK0.js";import"./modal-8mlzJehM.js";const G=({chargeId:u})=>{const{chargeId:g}=I(),a=u||g;let t;try{t=x()}catch{}const[o,n]=r.useState(void 0),[s,i]=r.useState(void 0),[c,d]=r.useState(void 0),[{data:p,fetching:l},m]=D({query:j,pause:!a||!!t,variables:{chargeId:a??""}});r.useEffect(()=>{a&&!t&&m()},[a,t,m]);const h=t||p,C=!t&&l;return a?e.jsxs(e.Fragment,{children:[C?e.jsx(f,{}):e.jsx(v,{setEditChargeId:n,setInsertDocument:i,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),o&&e.jsx(M,{chargeId:o?.id,close:()=>n(void 0),onChange:o.onChange}),s&&e.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>i(void 0)}),c&&e.jsx(S,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>d(void 0)})]}):e.jsx("div",{children:"Charge not found"})};export{G as Charge};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,be as B,bl as W,j as e,P as R,bf as z,B as G,a7 as U,y as _,w as N,a9 as D,dg as Q,aj as X,Q as Y,dh as q,bh as h,eh as J,bi as P,bj as O,bk as L,e8 as A,ag as m,hc as Z,aY as K,W as x,X as j,Y as p,Z as g,bF as $,bG as ee,bH as se}from"./index-BZ8AOwEl.js";import{u as ae}from"./use-url-query-DOEL3cY1.js";import{P as te}from"./modal-8mlzJehM.js";import{F as ne}from"./funnel-Bmrsutts.js";import{s as oe}from"./sub-dol6DnIB.js";import{M as k}from"./MultiSelect-BKzjkxRf.js";function re(a){return!a||B(a)?null:encodeURIComponent(JSON.stringify(a))}const le=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ce=[{label:"All",value:A.All},{label:"Income",value:A.Income},{label:"Expense",value:A.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:b}=i.useContext(U),o=_({defaultValues:{byOwners:b?.context.adminBusinessId?[b.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(oe(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:l,handleSubmit:T,watch:C}=o,[y,F]=i.useState(a.sortBy?.asc??!1),[c,u]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:S,fetching:t}=Q(),{selectableTags:v,fetching:I}=X(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const V=s=>{y!=null&&s.sortBy?.field&&(s.sortBy.asc=y),w(s),d()};function H(){w({}),F(!1),d()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(Y,{...o,children:e.jsxs("form",{onSubmit:T(V),children:[e.jsxs(q,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:S,value:s.value??[],disabled:t,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byBusinesses",control:l,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:S,value:s.value??[],disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byTags",control:l,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(k,{...s,data:v,itemComponent:J,value:s.value??[],disabled:I,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(r,f,M)=>M.label?.toLowerCase().includes(r.toLowerCase().trim())||M.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:P,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"toAnyDate",control:l,defaultValue:a.toAnyDate,rules:{pattern:{value:P,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"chargesType",control:l,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(L,{...s,data:ce,value:s.value??A.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"sortBy.field",control:l,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(L,{...s,data:le,label:"Field to sort by",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,rightSectionProps:{style:{width:"5rem"}},withinPortal:!0,rightSection:e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(m,{defaultChecked:a.sortBy?.asc??!1,checked:y??!1,disabled:!c,onCheckedChange:F}),e.jsx("span",{className:"text-xs",children:y?"ASC":"DESC"})]})})}),e.jsx(h,{name:"accountantStatus",control:l,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(k,{...s,value:s.value??[],data:Z,disabled:t,label:"Accountant Status",placeholder:"All",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4 rounded-lg border p-3 shadow-sm space-y-2",children:[e.jsx(K,{children:"Missing Information:"}),e.jsx(x,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Invoice"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Receipts"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Documents"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"With Open Documents"})}),e.jsx(g,{children:e.jsxs($,{children:[e.jsx(ee,{children:e.jsx(m,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(se,{children:e.jsx("p",{children:"Show only charges with documents that are currently open"})})]})})]})}),e.jsx(x,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Transactions"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Unbalanced businesses"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without ledger"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutLedger??!1,onCheckedChange:s.onChange})})]})})]})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:t||I,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:H,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:d,children:"Cancel"})]})]})})]})}function pe({filter:a={},setFilter:w,activePage:d,setPage:b,totalPages:o=1,initiallyOpened:l=!1}){const[T,C]=i.useState(l),[y,F]=i.useState(!B(a)),{get:c,set:u}=ae();i.useEffect(()=>{const t=d>1?d.toFixed(0):null,v=c("page");t!==v&&u("page",t)},[d,c,u]),i.useEffect(()=>{const t=re(a),v=c("chargesFilters");t!==v&&(u("chargesFilters",t),u("page"),b(1))},[a,c,u,b]);const S=i.useCallback(t=>{W(t,a)||(w(t),F(!B(t)))},[a,w]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(te,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(R,{className:"flex-fit w-fit mx-0",value:d,onChange:b,total:o}),e.jsx(z,{inline:!0,size:16,disabled:!y,children:e.jsx(G,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(ne,{className:"size-5"})})})]})}export{pe as C,ce as c};
|
package/dist/assets/{charges-ledger-validation-CtCBR3C-.js → charges-ledger-validation-DvCBQB1e.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,F as D,u as E,j as e,T as N,B as w,L as T,d as b,e as z,f as W}from"./index-
|
|
1
|
+
import{r as t,F as D,u as E,j as e,T as N,B as w,L as T,d as b,e as z,f as W}from"./index-BZ8AOwEl.js";import{u as O}from"./use-url-query-DOEL3cY1.js";import{C as k}from"./charges-filters-Djo_kWBf.js";import{C as B,T as R}from"./charges-table-D1vDT-UP.js";import{M as V}from"./index-Babx_Mc7.js";import{E as A,I as Q,M as U}from"./match-document-modal-CETycNjj.js";import{P as q}from"./page-layout-BfCdWwql.js";import{P as J}from"./Progress-CaCuNARE.js";import{P as $,a as G}from"./panel-top-open-CpMFDJrl.js";import"./modal-8mlzJehM.js";import"./funnel-Bmrsutts.js";import"./sub-dol6DnIB.js";import"./addDays-DbkSn4rN.js";import"./subMonths-Cu51bw_I.js";import"./MultiSelect-BKzjkxRf.js";import"./toggle-expansion-button-Buzq87-g.js";import"./index-Br0GTPfc.js";import"./similar-transactions-modal-BPFaQ7dD.js";import"./list-plus-CDqpqAwS.js";import"./tooltip-gvPoRI4e.js";import"./Table-DxJ1YCr5.js";import"./summary-Sj8NMKlv.js";import"./Checkbox-dSmM5Kto.js";import"./YearPickerInput-Bp2ytdrx.js";import"./insert-business-trip-modal-4vXkqVnt.js";import"./accounter-table-CLZmYCK0.js";const Me=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[l,x]=t.useState(void 0),[c,C]=t.useState(void 0),[g,f]=t.useState(!1),[r,d]=t.useState([]),{get:F}=O(),m=F("chargesFilters"),I=t.useMemo(()=>{if(m)try{return JSON.parse(decodeURIComponent(m))}catch{return}},[m]),[o,j]=t.useState(I),S=t.useCallback((s,y)=>{r.map(h=>h.id).includes(s)?d(r.filter(h=>h.id!==s)):d([...r,{id:s,onChange:y}])},[r]),[{data:a,fetching:M},v]=E({query:W,variables:{filters:o},pause:!0});function P(){d([])}const i=t.useMemo(()=>a?.chargesWithLedgerChanges?.length?a.chargesWithLedgerChanges[a.chargesWithLedgerChanges.length-1].progress:0,[a?.chargesWithLedgerChanges]),L=t.useCallback(s=>{j(s)},[j]);return t.useEffect(()=>{o&&v()},[o,v]),t.useEffect(()=>{p(e.jsxs("div",{className:"flex flex-row gap-x-5 items-center",children:[e.jsx(J,{value:i,label:`${i?.toFixed(2)}%`,size:"xl",animate:i<100,className:"min-w-52"}),e.jsx(k,{filter:o,setFilter:L,activePage:1,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{label:"Expand all accounts",children:e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>f(s=>!s),children:g?e.jsx($,{className:"size-5"}):e.jsx(G,{className:"size-5"})})}),e.jsx(V,{selected:r,resetMerge:P})]}))},[a,M,o,g,p,f,r,i,L]),e.jsxs(q,{title:"Charges Ledger Validation",description:"Manage charges",children:[M?e.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(B,{setEditChargeId:u,setInsertDocument:x,setMatchDocuments:C,toggleMergeCharge:S,mergeSelectedCharges:new Set(r.map(s=>s.id)),data:a?.chargesWithLedgerChanges.filter(s=>!!s.charge).map(s=>s.charge)??[],isAllOpened:g}),e.jsxs("div",{className:"flex flex-row justify-center my-2",children:[i>0&&i<100&&e.jsx(b,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(R,{radius:"xl",size:"xl",color:"green",children:e.jsx(z,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),l&&e.jsx(Q,{chargeId:l.id,onChange:l.onChange,close:()=>x(void 0)}),c&&e.jsx(U,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Me as ChargesLedgerValidation};
|