@accounter/client 0.0.8-alpha-20251029232510-4bc0c8b8c08a26f0c27788725ae584e515236d20 → 0.0.8-alpha-20251029233659-8fb74309c9f1de4f20423db029c5740e2df4bb5d
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 +1 -15
- package/dist/assets/{Checkbox-Cmx4P-eR.js → Checkbox-CSPHEKoR.js} +2 -2
- package/dist/assets/{MultiSelect-tfWMeMsf.js → MultiSelect-CszuVk07.js} +1 -1
- package/dist/assets/{Pagination-p2BVFuhf.js → Pagination-Cp6iKPSu.js} +1 -1
- package/dist/assets/{Progress-BwoJerOb.js → Progress-ByaKYSXX.js} +1 -1
- package/dist/assets/{Table-Cve82Lq5.js → Table-CQ4GTcIY.js} +1 -1
- package/dist/assets/{Typography-CAgQOS4U.js → Typography-Cn08y9HC.js} +1 -1
- package/dist/assets/{YearPickerInput-BPVLgEAY.js → YearPickerInput-BsQymTcP.js} +1 -1
- package/dist/assets/{accordion-Ca5XgpUz.js → accordion-CG93-Cqs.js} +1 -1
- package/dist/assets/accountant-approvals-Dxy1hGw7.js +1 -0
- package/dist/assets/{accounter-table-CBlUbpQl.js → accounter-table-Dgvw-xm_.js} +1 -1
- package/dist/assets/{addDays-ClGDfhvI.js → addDays-Di-hbHs3.js} +1 -1
- package/dist/assets/{all-charges-DV7V8QJ6.js → all-charges-DRl4EcMG.js} +1 -1
- package/dist/assets/{arrow-up-down-DMdWvrmz.js → arrow-up-down-Hh3TlLSU.js} +1 -1
- package/dist/assets/{building-2-Y3dys8Pf.js → building-2-DGfYgfU_.js} +1 -1
- package/dist/assets/business-aamFaOhr.js +27 -0
- package/dist/assets/business-extended-info-CeEMIazB.js +13 -0
- package/dist/assets/{business-header-S5R7Fq8P.js → business-header-BphijNiC.js} +1 -1
- package/dist/assets/business-transactions-filters-DYBvDjKs.js +1 -0
- package/dist/assets/business-transactions-single-B77wu9sA.js +1 -0
- package/dist/assets/business-trip-C1cYIMHX.js +1 -0
- package/dist/assets/{charge-C79C95t6.js → charge-D-99eJ1v.js} +1 -1
- package/dist/assets/{charges-filters-RFRXF1Oa.js → charges-filters-Dxaf2lVd.js} +1 -1
- package/dist/assets/{charges-ledger-validation-DTglElRA.js → charges-ledger-validation-BAY3PYth.js} +1 -1
- package/dist/assets/charges-table-CNWVDMmv.js +62 -0
- package/dist/assets/{chart-2MG3qLL8.js → chart-DM5P1yGj.js} +1 -1
- package/dist/assets/{data-table-pagination-Dhmbf7BR.js → data-table-pagination-TG7sqb1-.js} +1 -1
- package/dist/assets/download-csv-button-jQXIlRax.js +1 -0
- package/dist/assets/{editable-business-trip-BlqinsvU.js → editable-business-trip-DlAsZ0aQ.js} +2 -2
- package/dist/assets/{funnel-B2plvroD.js → funnel-BQEGwl1q.js} +1 -1
- package/dist/assets/{index-Csdsjvrl.js → index--OgMtW-2.js} +2 -2
- package/dist/assets/index-B-USUC2v.js +1 -0
- package/dist/assets/index-BYfofaiM.js +1 -0
- package/dist/assets/{index-C6OmHOHr.js → index-BmZql10x.js} +213 -213
- package/dist/assets/{index-Bs4RBq4h.js → index-CFY-4iKE.js} +1 -1
- package/dist/assets/{index-C4gCwrJJ.js → index-CGQclWiq.js} +1 -1
- package/dist/assets/index-CIY9x3TF.js +6 -0
- package/dist/assets/{index-arYAg9nt.js → index-CJEUQmMx.js} +1 -1
- package/dist/assets/{index-DKZGNBg3.js → index-CXRSu47J.js} +2 -2
- package/dist/assets/{index-DemO-kJJ.js → index-CiXTFJcq.js} +2 -2
- package/dist/assets/{index-CSEktEoZ.js → index-CkIv3Veq.js} +7 -7
- package/dist/assets/{index-BRNnfzgV.js → index-ClzPFBOc.js} +2 -2
- package/dist/assets/{index-qMYyjtmt.js → index-CzEcZ0Dn.js} +2 -2
- package/dist/assets/{index-HG5RXBPG.js → index-D9zE4pLO.js} +1 -1
- package/dist/assets/{index-DZ6Bqs7R.js → index-DKjsW6q7.js} +7 -7
- package/dist/assets/{index-C0ZATVhv.js → index-DOh5XsM3.js} +2 -2
- package/dist/assets/index-DROHY2Kd.js +1 -0
- package/dist/assets/index-DWXHJxFq.css +1 -0
- package/dist/assets/index-DgbPiRkF.js +1 -0
- package/dist/assets/{index-5R7-0kTp.js → index-DkKTDpFK.js} +1 -1
- package/dist/assets/{index-Cn4t95Q9.js → index-DnFwBDCa.js} +1 -1
- package/dist/assets/index-Dt4KpoN0.js +1 -0
- package/dist/assets/{index-BdRubi2c.js → index-IuUe41KG.js} +1 -1
- package/dist/assets/{index-eIVAASqp.js → index-NofRnQ8o.js} +1 -1
- package/dist/assets/{index-P9_YuS6e.js → index-WaN-m0WB.js} +1 -1
- package/dist/assets/index-juMfNCjV.js +1 -0
- package/dist/assets/{index.es-BrfHJ6Yj.js → index.es-BJEu0vdb.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-COXHjjIY.js → insert-business-trip-modal-CXgUJdgl.js} +2 -2
- package/dist/assets/issue-document-BSkWYnI5.js +1 -0
- package/dist/assets/{list-plus-DbuCDPM8.js → list-plus-BlHtPDEN.js} +1 -1
- package/dist/assets/{login-page-ChNFTZLU.js → login-page-DmCLAM1G.js} +1 -1
- package/dist/assets/{match-document-modal-Cp2DKG3j.js → match-document-modal-KjnSxB69.js} +4 -4
- package/dist/assets/{missing-info-charges-IUzXIDY1.js → missing-info-charges-BiEeQwER.js} +1 -1
- package/dist/assets/{modal-CCAYjiOC.js → modal-dLkQjDNz.js} +1 -1
- package/dist/assets/{page-layout-DpwpZHY3.js → page-layout-DxGYaCiw.js} +1 -1
- package/dist/assets/{page-not-found-NbOMK1Jv.js → page-not-found-ChLEFKCs.js} +1 -1
- package/dist/assets/{panel-top-open-CNX1-h4c.js → panel-top-open-CWsfFRNu.js} +1 -1
- package/dist/assets/{pencil-Z4i9z0vF.js → pencil-BEefjySD.js} +1 -1
- package/dist/assets/{report-commentary-row-C4I-ATEX.js → report-commentary-row-Cci0ntye.js} +1 -1
- package/dist/assets/{save-D0kOxdMh.js → save-BkV97OA1.js} +1 -1
- package/dist/assets/similar-transactions-modal-8T9lL2yX.js +1 -0
- package/dist/assets/sub-DdivcKGZ.js +1 -0
- package/dist/assets/subMonths-Kz3NJUOL.js +1 -0
- package/dist/assets/{summary-CkpRtdVA.js → summary-DzLJ6sUY.js} +1 -1
- package/dist/assets/{toggle-expansion-button-Babot8nj.js → toggle-expansion-button-BzVlE1kb.js} +1 -1
- package/dist/assets/tooltip-Ht3m2Q26.js +1 -0
- package/dist/assets/{use-url-query-BSUiacze.js → use-url-query-DV9K0FAR.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/app.tsx +108 -0
- package/src/components/business/admin-business-section.tsx +103 -299
- package/src/components/business/index.tsx +1 -33
- package/src/components/business/transactions-section.tsx +2 -24
- package/src/components/{business-ledger → business-transactions}/business-extended-info.tsx +27 -25
- package/src/components/{business-ledger/business-ledger-filters.tsx → business-transactions/business-transactions-filters.tsx} +12 -12
- package/src/components/{business-ledger/business-ledger-single.tsx → business-transactions/business-transactions-single.tsx} +13 -13
- package/src/components/{business-ledger → business-transactions}/download-csv.tsx +25 -25
- package/src/components/{business-ledger → business-transactions}/index.tsx +15 -15
- package/src/components/charges/charge-extended-info.tsx +4 -45
- package/src/components/layout/sidelinks.tsx +2 -2
- package/src/components/ledger-table/columns.tsx +4 -4
- package/src/components/ledger-table/index.tsx +181 -141
- package/src/components/reports/conto/custom-node.tsx +1 -1
- package/src/components/reports/trial-balance-report/trial-balance-report-account.tsx +1 -1
- package/src/components/tags/index.tsx +2 -4
- package/src/components/transactions-table/columns.tsx +9 -9
- package/src/components/transactions-table/index.tsx +21 -43
- package/src/gql/gql.ts +15 -33
- package/src/gql/graphql.ts +423 -234
- package/src/providers/index.tsx +56 -0
- package/src/router/config.tsx +14 -14
- package/src/router/routes.ts +2 -2
- package/dist/assets/accountant-approvals-BXTzXE96.js +0 -1
- package/dist/assets/business-CRd0ns94.js +0 -37
- package/dist/assets/business-extended-info-BKVk3weU.js +0 -13
- package/dist/assets/business-ledger-filters-C_x4y5uJ.js +0 -1
- package/dist/assets/business-ledger-single-Dku8gbU9.js +0 -1
- package/dist/assets/business-trip-CB51p6xt.js +0 -1
- package/dist/assets/charges-table-D3WwcB50.js +0 -62
- package/dist/assets/download-csv-button-BQSz29rY.js +0 -1
- package/dist/assets/index--xgmdJzW.js +0 -1
- package/dist/assets/index-BUJm5I0K.css +0 -1
- package/dist/assets/index-BgLtHIxa.js +0 -1
- package/dist/assets/index-CIdZZL-X.js +0 -1
- package/dist/assets/index-DA3Ccstm.js +0 -1
- package/dist/assets/index-DhRIY5eN.js +0 -1
- package/dist/assets/index-aEEtRfbo.js +0 -1
- package/dist/assets/index-nshyF-PE.js +0 -6
- package/dist/assets/issue-document-CBKTg1VC.js +0 -1
- package/dist/assets/similar-transactions-modal-DgD48GZ2.js +0 -1
- package/dist/assets/sub-BAZr7Qdd.js +0 -1
- package/dist/assets/subMonths-Df-03cZk.js +0 -1
- package/dist/assets/tooltip-DStdzzhK.js +0 -1
- package/src/components/business/balance-section.tsx +0 -26
- package/src/components/business/ledger-section.tsx +0 -49
- package/src/components/ui/pagination.tsx +0 -194
- package/src/providers/index.ts +0 -4
package/dist/assets/{editable-business-trip-BlqinsvU.js → editable-business-trip-DlAsZ0aQ.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as ve,
|
|
1
|
+
import{v as ve,by as Ye,bz as Ze,r as p,bA as Ke,bB as ie,ab as Xe,bC as Je,bD as Qe,bE as es,j as e,B as v,L as Se,g as B,bF as ss,t as j,i as S,bG as Ie,u as ne,bH as ge,bp as b,bs as q,bI as ae,bJ as Ne,a8 as ts,bq as U,br as W,x as M,aN as Fe,bK as Me,l as L,T as w,au as G,G as N,n as C,V as I,X as z,Y as P,Z as X,_ as $,I as J,a0 as _,as as ze,bL as Y,d as Z,bM as ns,bN as rs,bO as is,bj as D,bP as as,bQ as Pe,bR as $e,J as A,bS as be,R as ye,bT as os,bU as Q,e as ee,bV as cs,bW as ds,bX as ls,bY as us,bo as Oe,bZ as hs,b_ as ps,b$ as xs,c0 as Re,c1 as ms,c2 as gs,c3 as js,c4 as fs,c5 as vs,c6 as bs,ah as je,c7 as ys,c8 as Ts,c9 as Es,ca as Cs,cb as As,cc as ws,cd as Ds,ce as Bs,cf as Ss,cg as Is,ch as Ns,ci as Fs,cj as Ms,ck as zs,cl as Ps,cm as $s,cn as Os,co as Rs,cp as ks,q as Hs,cq as _s,cr as Vs,cs as Ls,ct as Us,cu as Ws,cv as fe,cw as qs,cx as Gs}from"./index-BmZql10x.js";import{L as ke}from"./list-plus-BlHtPDEN.js";import{G as te,L as xe,C as He,R as Ys,A as E,S as Zs}from"./summary-DzLJ6sUY.js";import{T as se}from"./Table-CQ4GTcIY.js";import{T as Ks}from"./toggle-expansion-button-BzVlE1kb.js";import{M as _e}from"./MultiSelect-CszuVk07.js";import{u as Xs,S as Js}from"./similar-transactions-modal-8T9lL2yX.js";import{T as Qs}from"./tooltip-Ht3m2Q26.js";/**
|
|
2
2
|
* @license lucide-react v0.548.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -13,4 +13,4 @@ import{v as ve,bB as Ye,bC as Ze,r as p,bD as Ke,bE as ie,ah as Qe,bF as Xe,bG a
|
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const rt=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],it=ve("printer",rt);var at=Ye((i,{fluid:n,sizes:r},{size:t})=>({root:{paddingLeft:i.spacing.md,paddingRight:i.spacing.md,maxWidth:n?"100%":Ze({size:t,sizes:r}),marginLeft:"auto",marginRight:"auto"}})),ot=Object.defineProperty,me=Object.getOwnPropertySymbols,Ve=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,Te=(i,n,r)=>n in i?ot(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,ct=(i,n)=>{for(var r in n||(n={}))Ve.call(n,r)&&Te(i,r,n[r]);if(me)for(var r of me(n))Le.call(n,r)&&Te(i,r,n[r]);return i},dt=(i,n)=>{var r={};for(var t in i)Ve.call(i,t)&&n.indexOf(t)<0&&(r[t]=i[t]);if(i!=null&&me)for(var t of me(i))n.indexOf(t)<0&&Le.call(i,t)&&(r[t]=i[t]);return r};const lt={sizes:{xs:ie(540),sm:ie(720),md:ie(960),lg:ie(1140),xl:ie(1320)}},ut=p.forwardRef((i,n)=>{const r=Ke("Container",lt,i),{className:t,fluid:s,size:a,unstyled:o,sizes:d,variant:x}=r,m=dt(r,["className","fluid","size","unstyled","sizes","variant"]),{classes:h,cx:l}=at({fluid:s,sizes:d},{unstyled:o,name:"Container",variant:x,size:a});return Qe.createElement(Xe,ct({className:l(h.root,t),ref:n},m))});ut.displayName="@mantine/core/Container";var H=3.77952755906,he={method:"save",resolution:3,page:{margin:0,format:"A4",orientation:"portrait"},canvas:{mimeType:"image/jpeg",qualityRatio:1,useCORS:!0,logging:!1},overrides:{}},ht=class{pdf;canvas;options;constructor(i,n){this.canvas=i,this.options=n,this.pdf=new es({format:this.options.page.format,orientation:this.options.page.orientation,...this.options.overrides?.pdf,unit:"mm"})}getMarginTopMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.top:this.options.page.margin;return Number(i)}getMarginLeftMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.left:this.options.page.margin;return Number(i)}getMarginRightMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.right:this.options.page.margin;return Number(i)}getMarginBottomMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.bottom:this.options.page.margin;return Number(i)}getMarginTop(){return this.getMarginTopMM()*H}getMarginBottom(){return this.getMarginBottomMM()*H}getMarginLeft(){return this.getMarginLeftMM()*H}getMarginRight(){return this.getMarginRightMM()*H}getScale(){return this.options.resolution}getPageHeight(){return this.getPageHeightMM()*H}getPageHeightMM(){return this.pdf.internal.pageSize.height}getPageWidthMM(){return this.pdf.internal.pageSize.width}getPageWidth(){return this.getPageWidthMM()*H}getOriginalCanvasWidth(){return this.canvas.width/this.getScale()}getOriginalCanvasHeight(){return this.canvas.height/this.getScale()}getCanvasPageAvailableHeight(){return this.getPageAvailableHeight()*this.getScale()*this.getHorizontalFitFactor()}getPageAvailableWidth(){return this.getPageWidth()-(this.getMarginLeft()+this.getMarginRight())}getPageAvailableHeight(){return this.getPageHeight()-(this.getMarginTop()+this.getMarginBottom())}getPageAvailableWidthMM(){return this.getPageAvailableWidth()/H}getPageAvailableHeightMM(){return this.getPageAvailableHeight()/H}getNumberPages(){return Math.ceil(this.canvas.height/this.getCanvasPageAvailableHeight())}getHorizontalFitFactor(){return this.getPageAvailableWidth()<this.getOriginalCanvasWidth()?this.getOriginalCanvasWidth()/this.getPageAvailableWidth():1}getCanvasOffsetY(i){return this.getCanvasPageAvailableHeight()*(i-1)}getCanvasHeightLeft(i){return this.canvas.height-this.getCanvasOffsetY(i)}getCanvasPageHeight(i){if(this.canvas.height<this.getCanvasPageAvailableHeight())return this.canvas.height;const n=this.getCanvasHeightLeft(i);return n<this.getCanvasPageAvailableHeight()?n:this.getCanvasPageAvailableHeight()}getCanvasPageWidth(){return this.canvas.width}createCanvasPage(i){const n=this.getCanvasPageWidth(),r=this.getCanvasPageHeight(i),t=document.createElement("canvas");return t.setAttribute("width",String(n)),t.setAttribute("height",String(r)),t.getContext("2d").drawImage(this.canvas,0,this.getCanvasOffsetY(i),this.canvas.width,r,0,0,this.canvas.width,r),t}convert(){let i=1;const n=this.getNumberPages();for(;i<=n;){i>1&&this.pdf.addPage(this.options.page.format,this.options.page.orientation);const r=this.createCanvasPage(i),t=r.toDataURL(this.options.canvas.mimeType,this.options.canvas.qualityRatio);this.pdf.setPage(i),this.pdf.addImage({imageData:t,width:r.width/(this.getScale()*H*this.getHorizontalFitFactor()),height:r.height/(this.getScale()*H*this.getHorizontalFitFactor()),x:this.getMarginLeftMM(),y:this.getMarginTopMM()}),i+=1}return this.pdf}},pt=i=>i?{...he,...i,canvas:{...he.canvas,...i.canvas},page:{...he.page,...i.page}}:he,xt=i=>typeof i=="function"?i():i?.current,mt=async(i,n)=>{const r=pt(n),t=xt(i);if(!t){console.error("Unable to get the target element.");return}const s=await Je(t,{useCORS:r.canvas.useCORS,logging:r.canvas.logging,scale:r.resolution,...r.overrides?.canvas}),o=new ht(s,r).convert();switch(r.method){case"build":return o;case"open":return window.open(o.output("bloburl"),"_blank"),o;case"save":default:{const d=r.filename??`${new Date().getTime()}.pdf`;return await o.save(d,{returnPromise:!0}),o}}},gt=mt;const jt={method:"open",overrides:{pdf:{compress:!0}}},ft=()=>document.getElementById("main-page"),Hn=({filename:i})=>{const[n,r]=p.useState(!1),t=async()=>{r(!0),await gt(ft,{...jt,filename:i}),r(!1)};return e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:t,disabled:n,children:n?e.jsx(Se,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(it,{className:"size-5"})})},vt="addBusinessTripAccommodationsExpense",bt=()=>{const[{fetching:i},n]=B(ss),r=p.useCallback(async t=>{const s="Error adding business trip accommodations expense",a=vt;j.loading("Adding Business Trip Accommodations Expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip accommodations expense added"}),d.addBusinessTripAccommodationsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripAccommodationsExpense:r}};function Ue({formManager:i,attendeesStayPath:n,attendeesData:r,fetchingAttendees:t=!1,businessTripId:s}){const{control:a,watch:o,trigger:d}=i,{fields:x,append:m,remove:h}=Ie({control:a,name:n}),[l,c]=p.useState(t),[u,g]=p.useState(r??[]),f=o(n),T=x.map((F,R)=>({...F,...f[R]}));p.useEffect(()=>{r&&g(r)},[r]),p.useEffect(()=>{c(t)},[t]);const[{data:y,fetching:O},K]=ne({query:ge,pause:!0,variables:{businessTripId:s??""}});return p.useEffect(()=>{if(y?.businessTrip?.attendees.length){const F=y.businessTrip.attendees.map(R=>({value:R.id,label:R.name}))??[];g(F)}},[y?.businessTrip?.attendees]),p.useEffect(()=>{c(O)},[O]),p.useEffect(()=>{!r&&!y&&!t&&!O&&K({businessTripId:s})},[r,t,O,K,s,y]),!s&&!r?e.jsx("div",{children:"Cannot edit attendees stay, lacking some mandatory information!"}):e.jsxs("div",{children:[e.jsx("span",{className:"mantine-InputWrapper-label mantine-Select-label",children:"Employees Stay"}),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[T?.map((F,R)=>e.jsxs("div",{className:"flex items-end gap-2 text-gray-600 mb-2",children:[e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(b,{name:`${n}.${R}.attendeeId`,control:a,rules:{required:"Required"},render:({field:k,fieldState:re})=>e.jsx(q,{...k,disabled:l,data:u,value:k.value??void 0,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:re.error?.message,withinPortal:!0,required:!0})})}),e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(b,{control:a,name:`${n}.${R}.nightsCount`,render:({field:k,fieldState:re})=>e.jsx(ae,{className:"w-full",...k,min:0,label:"Nights Count",value:k.value??void 0,hideControls:!0,precision:0,error:re.error?.message,required:!0,onChange:V=>k.onChange(V&&typeof V=="number"?V:void 0)})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"mb-2 size-7.5",onClick:()=>{h(R),d(n)},children:e.jsx(Ne,{className:"size-5"})})]},F.id)),e.jsx(v,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>{m({}),d(n)},children:e.jsx(ke,{className:"size-5"})})]})]})}function oe({businessTripId:i,control:n,setFetching:r}){const[t,s]=p.useState([]),[{data:a,fetching:o,error:d}]=ne({query:ge,variables:{businessTripId:i}}),{userContext:x}=p.useContext(ts);p.useEffect(()=>{a?.businessTrip?.attendees.length&&s(a.businessTrip.attendees.map(h=>({value:h.id,label:h.name})).sort((h,l)=>h.label>l.label?1:-1))},[a,s]),p.useEffect(()=>{r(o)},[r,o]),p.useEffect(()=>{d&&j.error("Error",{description:"Oops, we have an error fetching attendees"})},[d]);const m=p.useMemo(()=>x?.context.ledgerLock,[x]);return e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"date",control:n,rules:{min:m?{value:m,message:`Date must be after ${m}`}:void 0,pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:h,fieldState:l})=>e.jsx(W,{"data-autofocus":!0,...h,onChange:c=>{const u=c?typeof c=="string"?c:M(c,"yyyy-MM-dd"):void 0;u!==h.value&&h.onChange(u)},value:h.value?new Date(h.value):void 0,error:l.error?.message,label:"Date",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"valueDate",control:n,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"},min:m?{value:m,message:`Date must be after ${m}`}:void 0},render:({field:h,fieldState:l})=>e.jsx(W,{...h,onChange:c=>{const u=c?typeof c=="string"?c:M(c,"yyyy-MM-dd"):void 0;u!==h.value&&h.onChange(u)},value:h.value?new Date(h.value):void 0,error:l.error?.message,label:"Value Date",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"amount",control:n,render:({field:h,fieldState:l})=>e.jsx(b,{name:"currency",control:n,defaultValue:Fe.Ils,render:({field:c,fieldState:u})=>e.jsx(Me,{...h,value:h.value??void 0,error:l.error?.message||u.error?.message,label:"Amount",currencyCodeProps:{...c,label:"Currency"}})})}),e.jsx(b,{name:"employeeBusinessId",control:n,render:({field:h,fieldState:l})=>e.jsx(q,{...h,data:t,value:h.value,disabled:o,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]})}function Ee(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Accommodations Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(yt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function yt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripAccommodationsExpense:m,fetching:h}=bt(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Accommodation Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{control:a,name:"country",render:({field:c})=>e.jsxs(P,{children:[e.jsx(Q,{children:"Country"}),e.jsx($,{children:e.jsx(X,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx(z,{name:"nightsCount",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(Q,{children:"Nights Count"}),e.jsx($,{children:e.jsx(ze,{...c,value:c.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:","})}),e.jsx(_,{})]})}),e.jsx(Ue,{formManager:s,attendeesStayPath:"attendeesStay",businessTripId:i}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Tt="updateBusinessTripAccommodationsExpense",Et=()=>{const[{fetching:i},n]=B(ns),r=p.useCallback(async t=>{const s="Error updating business trip accommodations expense",a=Tt;j.loading("Updating trip accommodations expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip accommodations expense was updated"}),d.updateBusinessTripAccommodationsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripAccommodationsExpense:r}},Ct="categorizeIntoExistingBusinessTripExpense",At=()=>{const[{fetching:i},n]=B(rs),r=p.useCallback(async t=>{const s="Error updating business trip expense category",a=Ct;j.loading("Updating business trip expense category",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense category was updated"}),d.categorizeIntoExistingBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,categorizeIntoExistingBusinessTripExpense:r}};function ce(i){const{businessTripExpenseId:n,businessTripId:r,onChange:t}=i,[s,{close:a,open:o}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Attach Uncategorized Transaction",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:d=>{d.stopPropagation(),o()},children:e.jsx(G,{className:"size-5"})})}),s&&e.jsx(wt,{businessTripExpenseId:n,businessTripId:r,opened:s,close:a,onChange:t})]})}function wt({businessTripExpenseId:i,businessTripId:n,opened:r,close:t,onChange:s}){const{control:a,handleSubmit:o,setValue:d}=N({defaultValues:{businessTripExpenseId:i}}),[x,m]=p.useState([]),[{data:h,fetching:l,error:c}]=ne({query:is,variables:{businessTripId:n}}),{categorizeIntoExistingBusinessTripExpense:u,fetching:g}=At(),f=T=>{u({fields:T}).then(()=>{s?.(),t()})};return p.useEffect(()=>{if(h?.businessTrip?.uncategorizedTransactions.length){const T=h.businessTrip.uncategorizedTransactions.filter(y=>y?.transaction);m(T.map(({transaction:y})=>({eventDate:y.eventDate,sourceDescription:y.sourceDescription,referenceKey:y.referenceKey,counterparty:y.counterparty?.name,amount:y.amount.formatted,rawAmount:y.amount.raw,value:y.id,label:`${y.eventDate} | ${y.counterparty?.name} | ${y.amount.formatted}`})).sort((y,O)=>y.eventDate.localeCompare(O.eventDate)))}},[h,m]),p.useEffect(()=>{c&&j.error("Error",{description:"Oops, we have an error fetching transactions to categorize"})},[c]),e.jsxs(C,{opened:r,onClose:t,centered:!0,children:[e.jsx(C.Title,{children:"Set Transaction Category"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:o(f),className:"flex flex-col gap-3 mt-3",children:[e.jsx(b,{name:"transactionId",control:a,render:({field:T,fieldState:y})=>e.jsx(q,{...T,itemComponent:Dt,data:x??[],disabled:l,label:"Transactions",placeholder:"Scroll to see all options",maxDropdownHeight:160,error:y.error?.message,withAsterisk:!0,withinPortal:!0,onChange:O=>{const K=x.find(F=>F.value===O);K?.rawAmount&&d("amount",K.rawAmount),T.onChange(O)}})}),e.jsx(b,{name:"amount",control:a,render:({field:T,fieldState:y})=>e.jsx(ae,{...T,value:T.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:y.error?.message,label:"Amount"})}),e.jsx("div",{className:"flex justify-center 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:"Confirm"})})]})}),g&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Dt=p.forwardRef(({eventDate:i,sourceDescription:n,referenceKey:r,counterparty:t,amount:s,...a},o)=>e.jsx("div",{ref:o,...a,children:e.jsxs(te,{children:[e.jsx(te.Col,{span:4,children:i}),e.jsx(te.Col,{span:4,children:e.jsx(D,{size:"sm",children:t})}),e.jsx(te.Col,{span:4,children:e.jsx(D,{size:"sm",children:s})}),e.jsx(te.Col,{span:8,children:e.jsx(D,{size:"xs",opacity:.65,children:n})}),e.jsxs(te.Col,{span:4,children:["Reference: ",r]})]})})),Bt="deleteBusinessTripExpense",St=()=>{const[{fetching:i},n]=B(as),r=p.useCallback(async t=>{const s="Error deleting business trip expense",a=`${Bt}-${t.businessTripExpenseId}`;j.loading("Deleting trip expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense was deleted"}),d.deleteBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,deleteBusinessTripExpense:r}};function de(i){const{fetching:n,deleteBusinessTripExpense:r}=St(),t=p.useCallback(()=>{r({businessTripExpenseId:i.businessTripExpenseId}).then(()=>{i.onDelete?.()})},[i,r]);return e.jsx(Pe,{onConfirm:t,title:"Are you sure you want to remove expense?",children:e.jsx(w,{label:"Remove Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:n,children:e.jsx($e,{className:"size-5"})})})})}const le=({data:i,isEditMode:n=!1,control:r,businessTripId:t})=>{const s=A(os,i),[a,o]=p.useState([]),[{data:d,fetching:x,error:m}]=ne({query:ge,variables:{businessTripId:t}});p.useEffect(()=>{d?.businessTrip?.attendees.length&&o(d.businessTrip.attendees.map(l=>({value:l.id,label:l.name})).sort((l,c)=>l.label>c.label?1:-1))},[d,o]),p.useEffect(()=>{m&&j.error("Error",{description:"Oops, we have an error fetching attendees"})},[m]);const h=Array.from(new Set(s.charges?.map(l=>l.id)));return e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:n&&s.payedByEmployee?e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"date",control:r,defaultValue:s.date,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,form:`form ${s.id}`,"data-autofocus":!0,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"Date",error:c.error?.message,popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"valueDate",control:r,defaultValue:s.valueDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,form:`form ${s.id}`,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"Value Date",error:c.error?.message,popoverProps:{withinPortal:!0}})})]}):e.jsxs(e.Fragment,{children:[s.date&&M(new Date(s.date),"dd/MM/yy"),e.jsx(D,{fz:"sm",c:"dimmed",children:s.valueDate&&M(new Date(s.valueDate),"dd/MM/yy")})]})})}),e.jsx("td",{children:n&&s.payedByEmployee?e.jsx(b,{name:"amount",control:r,defaultValue:s.amount?.raw??void 0,render:({field:l,fieldState:c})=>e.jsx(b,{name:"currency",control:r,defaultValue:s.amount?.currency??Fe.Ils,render:({field:u,fieldState:g})=>e.jsx(Me,{form:`form ${s.id}`,...l,value:l.value??void 0,error:c.error?.message||g.error?.message,label:"Amount",currencyCodeProps:{...u,label:"Currency",form:`form ${s.id}`}})})}):e.jsx("div",{children:s.amount?.formatted})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:n&&s.payedByEmployee?e.jsx(b,{name:"employeeBusinessId",control:r,defaultValue:s.employee?.id,render:({field:l,fieldState:c})=>e.jsx(q,{form:`form ${s.id}`,...l,data:a,value:l.value,disabled:x,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withinPortal:!0})}):e.jsx("div",{className:"flex flex-row gap-2 items-center",children:s.payedByEmployee&&e.jsx(D,{c:s.employee?.name?void 0:"red",children:s.employee?.name??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:h.map(l=>e.jsx(be,{to:ye.CHARGES.DETAIL(l),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:"To Charge"},l))})})]})},ue=()=>e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Payed By Attendee"}),e.jsx("th",{children:"Charges"})]}),It=({data:i,businessTripId:n,onChange:r})=>{const t=A(cs,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n,attendeesStay:t.attendeesStay.map(c=>({attendeeId:c.id,nightsCount:c.nightsCount}))}}),{control:d,handleSubmit:x}=o,{updateBusinessTripAccommodationsExpense:m,fetching:h}=Et(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"country",control:d,defaultValue:t.country,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(X,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.country?void 0:"red",children:t.country??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"nightsCount",control:d,defaultValue:t.nightsCount,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(ze,{...c,value:c.value??void 0,form:`form ${t.id}`,hideControls:!0,decimalScale:0,thousandSeparator:","})}),e.jsx(_,{})]})})}):e.jsx(D,{c:t.nightsCount?void 0:"red",children:t.nightsCount??"Missing"})})}),e.jsx("td",{children:s?e.jsx(I,{...o,children:e.jsx(Ue,{formManager:o,attendeesStayPath:"attendeesStay",businessTripId:n})}):e.jsx(xe,{listStyleType:"disc",children:t.attendeesStay?.length?t.attendeesStay.map(c=>e.jsxs(xe.Item,{children:[c.attendee.name," (",c.nightsCount,")"]},c.id)):e.jsx(D,{c:"red",fz:"sm",children:"Missing"})})}),e.jsx("td",{children:r&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})})]},t.id)},We=({businessTripId:i,expenses:n,onChange:r})=>{if(!n?.length)return r?e.jsx(Ee,{businessTripId:i,onAdd:r}):e.jsx(e.Fragment,{});const t=n.map(s=>A(ds,s));return e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Location"}),e.jsx("th",{children:"Nights"}),e.jsx("th",{children:"Attendees Stay"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[t.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(It,{data:s,businessTripId:i,onChange:r},s.id)),r&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Ee,{businessTripId:i,onAdd:r})})})]})]})})},Nt=({data:i,onChange:n})=>{const{accommodationExpenses:r,id:t}=A(ls,i);return e.jsx(We,{businessTripId:t,expenses:r,onChange:n})},Ft="insertBusinessTripAttendee",Mt=()=>{const[{fetching:i},n]=B(us),r=p.useCallback(async t=>{const s="Error adding attendee to business trip",a=Ft;j.loading("Adding attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Attendee was added to the business trip"}),d.insertBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,insertBusinessTripAttendee:r}};function Ce(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Attendee",children:e.jsx(v,{variant:"outline",size:"icon",onClick:o=>{o.stopPropagation(),a()},className:"size-7.5",children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(zt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function zt({businessTripId:i,opened:n,close:r,onAdd:t}){const{selectableBusinesses:s,fetching:a}=Oe(),{control:o,handleSubmit:d}=N({defaultValues:{businessTripId:i}}),{insertBusinessTripAttendee:x,fetching:m}=Mt(),h=l=>{x({fields:l}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,children:[e.jsx(C.Title,{children:"Add Attendee"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:d(h),children:[e.jsx(b,{name:"attendeeId",control:o,render:({field:l,fieldState:c})=>e.jsx(q,{"data-autofocus":!0,...l,data:s,value:l.value,disabled:a,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withAsterisk:!0,withinPortal:!0})}),e.jsx(b,{name:"arrivalDate",control:o,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,error:c.error?.message,label:"Arrival",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"departureDate",control:o,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,error:c.error?.message,label:"Departure",popoverProps:{withinPortal:!0}})}),e.jsx("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:"Add"})})]})}),(m||a)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Pt="updateBusinessTripAttendee",$t=()=>{const[{fetching:i},n]=B(hs),r=p.useCallback(async t=>{const s="Error updating business trip attendee",a=Pt;j.loading("Updating trip attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip attendee was updated"}),d.updateBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripAttendee:r}},Ot="deleteBusinessTripAttendee",Rt=()=>{const[{fetching:i},n]=B(ps),r=p.useCallback(async t=>{const s="Error removing business trip attendee",a=Ot;j.loading("Removing business trip attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip attendee was removed"}),d.deleteBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,deleteBusinessTripAttendee:r}};function kt(i){const{fetching:n,deleteBusinessTripAttendee:r}=Rt(),t=p.useCallback(()=>{r({fields:{businessTripId:i.businessTripId,attendeeId:i.attendeeId}}).then(()=>{i.onDelete?.()})},[i,r]);return e.jsx(Pe,{onConfirm:t,title:"Are you sure you want to remove attendee?",children:e.jsx(w,{label:"Remove Attendee",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:n,children:e.jsx($e,{className:"size-5"})})})})}const Ht="addBusinessTripFlightsExpense",_t=()=>{const[{fetching:i},n]=B(xs),r=p.useCallback(async t=>{const s="Error adding business trip flight expense",a=Ht;j.loading("Adding business trip flight expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip flight expense added"}),d.addBusinessTripFlightsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripFlightsExpense:r}};function qe({formManager:i,flightPathPath:n,flightPathData:r}){const{control:t,watch:s,trigger:a}=i,{fields:o,append:d,remove:x}=Ie({control:t,name:n}),m=s(n),h=o.map((l,c)=>({...l,...m[c]}));return r?e.jsxs("div",{children:[e.jsx("span",{className:"mantine-InputWrapper-label mantine-Select-label",children:"Flight Path"}),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[h?.map((l,c)=>e.jsxs("div",{className:"flex items-end gap-2 text-gray-600 mb-2",children:[e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(z,{name:`${n}.${c}`,control:t,rules:{required:"Required"},render:({field:u})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(X,{...u,value:u.value??void 0,placeholder:"Destination"})}),e.jsx(_,{})]})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"mb-2 size-7.5",onClick:()=>{x(c),a(n)},children:e.jsx(Ne,{className:"size-5"})})]},l.id)),e.jsx(v,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>{d(""),a(n)},children:e.jsx(ke,{className:"size-5"})})]})]}):e.jsx("div",{children:"Cannot edit flight path stay, lacking some mandatory information!"})}function Ae(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Flight Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(Lt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}const Vt=Object.entries(Re).map(([i,n])=>({value:n,label:i}));function Lt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),[{data:m,fetching:h}]=ne({query:ge,variables:{businessTripId:i}}),{addBusinessTripFlightsExpense:l,fetching:c}=_t(),u=f=>{l({fields:f}).then(()=>{t?.(),r()})},g=m?.businessTrip?.attendees.map(f=>({value:f.id,label:f.name}))??[];return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Flight Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(u),children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(qe,{formManager:s,flightPathPath:"path"}),e.jsx(b,{name:"flightClass",control:a,render:({field:f,fieldState:T})=>e.jsx(q,{...f,data:Vt,value:f.value,label:"Flight Class",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:T.error?.message,withinPortal:!0})}),e.jsx(b,{name:"attendeeIds",control:a,render:({field:f,fieldState:T})=>e.jsx(_e,{...f,disabled:h,data:g,value:f.value??[],label:"Attendees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:T.error?.message,withinPortal:!0})}),e.jsx("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:"Add"})})]})})}),(c||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Ut="updateBusinessTripFlightsExpense",Wt=()=>{const[{fetching:i},n]=B(ms),r=p.useCallback(async t=>{const s="Error updating business trip flights expense",a=Ut;j.loading("Updating trip flights expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip flights expense was updated"}),d.updateBusinessTripFlightsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripFlightsExpense:r}},qt=Object.entries(Re).map(([i,n])=>({value:n,label:i})),Gt=({data:i,businessTripId:n,onChange:r,attendees:t})=>{const s=A(gs,i),[a,o]=p.useState(!1),d=N({defaultValues:{id:s.id,businessTripId:n,attendeeIds:s.attendees?.map(g=>g.id)??[],path:s.path??[]}}),{control:x,handleSubmit:m}=d,{updateBusinessTripFlightsExpense:h,fetching:l}=Wt(),c=g=>{h({fields:g}).then(()=>{r?.(),o(!1)})},u=t.map(g=>({value:g.id,label:g.name}));return e.jsxs("tr",{children:[e.jsx(le,{data:s,isEditMode:a,control:x,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...d,children:e.jsx("form",{id:`form ${s.id}`,onSubmit:m(c),children:e.jsxs("div",{className:"flex flex-col gap-2 justify-center",children:[a?e.jsx(qe,{formManager:d,flightPathPath:"path",flightPathData:s.path??void 0}):e.jsx("div",{className:"flex gap-2 items-center",children:s.path?.length?s.path.map((g,f)=>e.jsxs(e.Fragment,{children:[e.jsx(D,{fw:700,children:g},f),f<s.path.length-1&&(g===s.path[f+1]?" | ":" → ")]})):e.jsx(D,{fw:700,className:"flex gap-2 items-center",c:"red",children:"Missing"})}),a?e.jsx(b,{name:"flightClass",control:x,defaultValue:s.class??void 0,render:({field:g,fieldState:f})=>e.jsx(q,{form:`form ${s.id}`,"data-autofocus":!0,...g,data:qt,value:g.value,label:"Flight Class",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:f.error?.message,withinPortal:!0})}):e.jsx(D,{c:s.class?void 0:"red",fz:"sm",children:`Class: ${s.class??"Missing"}`})]})})})}),e.jsx("td",{children:a?e.jsx(b,{name:"attendeeIds",control:x,defaultValue:s.attendees?.map(g=>g.id)??void 0,render:({field:g,fieldState:f})=>e.jsx(_e,{...g,form:`form ${s.id}`,data:u,value:g.value??[],label:"Attendees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:f.error?.message,withinPortal:!0})}):e.jsx(xe,{listStyleType:"disc",children:s.attendees?.length?s.attendees.map(g=>e.jsx(xe.Item,{children:g.name},g.id)):e.jsx(D,{c:"red",fz:"sm",children:"Missing"})})}),e.jsx("td",{children:r&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:l,variant:a?"default":"outline",size:"icon",className:"size-7.5",onClick:g=>{g.stopPropagation(),o(f=>!f)},children:e.jsx(J,{className:"size-5"})})}),a&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${s.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:s.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:s.id,onDelete:r})]})})]},s.id)},Ge=({businessTripId:i,expenses:n,attendees:r,onChange:t})=>{if(!n?.length)return t?e.jsx(Ae,{businessTripId:i,onAdd:t}):e.jsx(e.Fragment,{});const s=n.map(a=>A(js,a));return e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Flight"}),e.jsx("th",{children:"Attendees"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[s.sort((a,o)=>a.date&&o.date?a.date<o.date?1:-1:a.date?-1:o.date?1:0).map(a=>e.jsx(Gt,{data:a,businessTripId:i,onChange:t,attendees:r},a.id)),t&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(Ae,{businessTripId:i,onAdd:t})})})]})]})})},Yt=({data:i,businessTripId:n,onChange:r})=>{const t=A(fs,i),[s,a]=p.useState(!1),[o,d]=p.useState(!1),{control:x,handleSubmit:m}=N({defaultValues:{businessTripId:n,attendeeId:t.id,arrivalDate:t.arrivalDate,departureDate:t.departureDate}}),{updateBusinessTripAttendee:h,fetching:l}=$t(),c=u=>{h({fields:u}).then(()=>{r?.(),a(!1)})};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{children:s?e.jsx("form",{id:`form ${t.id}`,onSubmit:m(c),children:e.jsx(b,{name:"arrivalDate",control:x,defaultValue:t.arrivalDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:u,fieldState:g})=>e.jsx(W,{...u,onChange:f=>{const T=f?typeof f=="string"?f:M(f,"yyyy-MM-dd"):void 0;T!==u.value&&u.onChange(T)},"data-autofocus":!0,value:u.value?new Date(u.value):void 0,error:g.error?.message,label:"Arrival",popoverProps:{withinPortal:!0}})})}):t.arrivalDate}),e.jsx("td",{children:s?e.jsx(b,{name:"departureDate",control:x,defaultValue:t.departureDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:u,fieldState:g})=>e.jsx(W,{...u,onChange:f=>{const T=f?typeof f=="string"?f:M(f,"yyyy-MM-dd"):void 0;T!==u.value&&u.onChange(T)},value:u.value?new Date(u.value):void 0,error:g.error?.message,label:"Departure",popoverProps:{withinPortal:!0}})}):t.departureDate}),e.jsxs("td",{className:"flex items-center gap-2",children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:l,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),a(g=>!g)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(kt,{businessTripId:n,attendeeId:t.id,onDelete:r}),e.jsx(Ks,{toggleExpansion:d,isExpanded:o})]})]},t.id),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx(He,{shadow:"sm",withBorder:!0,children:e.jsxs("div",{className:"flex flex-col gap-2",children:[t.flights&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Flights:"}),e.jsx(Ge,{businessTripId:n,attendees:[],expenses:t.flights})]}),t.accommodations&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Accommodations:"}),e.jsx(We,{businessTripId:n,expenses:t.accommodations})]})]})})})},`${t.id}-expension`)]})},Zt=({data:i,onChange:n})=>{const{attendees:r,id:t}=A(vs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Arrival Date"}),e.jsx("th",{children:"Departure Date"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.name.toLocaleLowerCase()>a.name.toLocaleLowerCase()?1:-1).map(s=>e.jsx(Yt,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx(Ce,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(Ce,{businessTripId:t,onAdd:n})},pe="addBusinessTripCarRentalExpense",Kt=()=>{const[{fetching:i},n]=B(bs),r=p.useCallback(async t=>{const s="Error adding business trip car rental expense";j.loading("Adding car rental expense...",{id:pe});try{const a=await n(t),o=S(a,s,pe);if(o)return j.success("Success",{id:pe,description:"Car rental expense added"}),o.addBusinessTripCarRentalExpense}catch(a){console.error(`${s}: ${a}`),j.error("Error",{id:pe,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripCarRentalExpense:r}};function we(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Car Rental Expense",children:e.jsx(v,{variant:"outline",size:"icon",onClick:o=>{o.stopPropagation(),a()},className:"size-7.5",children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(Qt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function Qt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripCarRentalExpense:m,fetching:h}=Kt(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Car Rental Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(b,{name:"days",control:a,render:({field:c,fieldState:u})=>e.jsx(ae,{...c,value:c.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:u.error?.message,label:"Rent Days"})}),e.jsx(z,{name:"isFuelExpense",control:a,render:({field:{value:c,...u}})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(Q,{children:"Is Fuel Expense"})}),e.jsx($,{children:e.jsx(je,{...u,checked:c===!0,onCheckedChange:u.onChange})}),e.jsx(_,{})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Xt="updateBusinessTripCarRentalExpense",Jt=()=>{const[{fetching:i},n]=B(ys),r=p.useCallback(async t=>{const s="Error updating business trip car rental expense",a=Xt;j.loading("Updating trip car rental expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip car rental expense was updated"}),d.updateBusinessTripCarRentalExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripCarRentalExpense:r}},en=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ts,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripCarRentalExpense:m,fetching:h}=Jt(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:t.isFuelExpense!==!0&&(s?e.jsx(b,{name:"days",control:d,defaultValue:t.days,render:({field:c,fieldState:u})=>e.jsx(ae,{...c,value:c.value??void 0,form:`form ${t.id}`,hideControls:!0,precision:2,removeTrailingZeros:!0,error:u.error?.message,placeholder:"Rent Days"})}):e.jsx(D,{c:t.days?void 0:"red",children:t.days??"Missing"}))})})})}),e.jsx("td",{children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"isFuelExpense",control:d,defaultValue:t.isFuelExpense,render:({field:c})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(Q,{children:"Is Fuel Expense"})}),e.jsx($,{children:e.jsx(je,{form:`form ${t.id}`,checked:c.value===!0,onCheckedChange:c.onChange})})]})})}):t.isFuelExpense===!0?e.jsx(nt,{}):e.jsx(st,{})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},sn=({data:i,onChange:n})=>{const{carRentalExpenses:r,id:t}=A(Es,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Days"}),e.jsx("th",{children:"Type"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(en,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(we,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(we,{businessTripId:t,onAdd:n})},tn=({data:i,onChange:n})=>{const{flightExpenses:r,id:t,attendees:s}=A(Cs,i);return e.jsx(Ge,{businessTripId:t,attendees:s,expenses:r,onChange:n})},nn="addBusinessTripOtherExpense",rn=()=>{const[{fetching:i},n]=B(As),r=p.useCallback(async t=>{const s='Error adding business trip "other" expense',a=nn;j.loading('Adding trip "other" expense',{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:'Business trip "other" expense was added'}),d.addBusinessTripOtherExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripOtherExpense:r}};function De(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Other Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(an,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function an({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripOtherExpense:m,fetching:h}=rn(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Other Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{name:"description",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(Q,{children:"Description"}),e.jsx($,{children:e.jsx(X,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx(z,{control:s.control,name:"deductibleExpense",render:({field:c})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(Q,{children:"Deductible Expense"})}),e.jsx($,{children:e.jsx(je,{checked:c.value===!0,onCheckedChange:c.onChange})})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const on="updateBusinessTripOtherExpense",cn=()=>{const[{fetching:i},n]=B(ws),r=p.useCallback(async t=>{const s='Error updating business trip "other" expense',a=on;j.loading('Updating business trip "other" expense',{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:'Business trip "other" expense was updated'}),d.updateBusinessTripOtherExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripOtherExpense:r}},dn=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ds,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripOtherExpense:m,fetching:h}=cn(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"description",control:d,defaultValue:t.description,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(X,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.description?void 0:"red",children:t.description??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"deductibleExpense",control:o.control,defaultValue:t.deductibleExpense,render:({field:c})=>e.jsx(P,{children:e.jsx($,{children:e.jsx(je,{form:`form ${t.id}`,checked:c.value===!0,onCheckedChange:c.onChange})})})})}):e.jsx(D,{c:t.deductibleExpense?void 0:"red",children:t.deductibleExpense===!0?"Yes":t.deductibleExpense===!1?"No":"Missing"})})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},ln=({data:i,onChange:n})=>{const{otherExpenses:r,id:t}=A(Bs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Deductible Expense"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(dn,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(De,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(De,{businessTripId:t,onAdd:n})},un="addBusinessTripTravelAndSubsistenceExpense",hn=()=>{const[{fetching:i},n]=B(Ss),r=p.useCallback(async t=>{const s="Error adding business trip travel&subsistence expense",a=un;j.loading("Adding trip travel&subsistence expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip travel&subsistence expense was added"}),d.addBusinessTripTravelAndSubsistenceExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripTravelAndSubsistenceExpense:r}};function Be(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add T&S Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(pn,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function pn({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripTravelAndSubsistenceExpense:m,fetching:h}=hn(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Travel & Subsistence Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{name:"expenseType",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(Q,{children:"Expense Type"}),e.jsx($,{children:e.jsx(X,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const xn="updateBusinessTripTravelAndSubsistenceExpense",mn=()=>{const[{fetching:i},n]=B(Is),r=p.useCallback(async t=>{const s="Error updating business trip travel&subsistence expense",a=xn;j.loading("Updating trip travel&subsistence expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip travel&subsistence expense was updated"}),d.updateBusinessTripTravelAndSubsistenceExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripTravelAndSubsistenceExpense:r}},gn=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ns,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripTravelAndSubsistenceExpense:m,fetching:h}=mn(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"expenseType",control:d,defaultValue:t.expenseType,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(X,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.expenseType?void 0:"red",children:t.expenseType??"Missing"})})})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(J,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},jn=({data:i,onChange:n})=>{const{travelAndSubsistenceExpenses:r,id:t}=A(Fs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Expense Type"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(gn,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Be,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(Be,{businessTripId:t,onAdd:n})},fn=({data:i})=>{const n=A(Ms,i),r="effectiveDate"in n?n.effectiveDate:void 0;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col justify-center",children:[e.jsx("div",{children:r&&M(new Date(r),"dd/MM/yy")}),n.sourceEffectiveDate&&e.jsxs("div",{className:"text-xs text-gray-500",children:["(Originally ",M(new Date(n.sourceEffectiveDate),"dd/MM/yy"),")"]})]})})},vn=({data:i})=>{const n=A(zs,i),r="eventDate"in n?n.eventDate:void 0;return e.jsx("td",{children:e.jsx("div",{className:"flex flex-col justify-center",children:r&&M(new Date(r),"dd/MM/yy")})})},bn=({data:i})=>{const n=A(Ps,i),{account:r}=n,t=r.type,s=r.name;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[e.jsx("p",{children:t}),e.jsx("p",{children:s})]})})},yn=({data:i})=>{const n=A($s,i),r="sourceDescription"in n?n.sourceDescription:"Missing";return e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap",children:e.jsx("div",{className:"flex flex-col justify-center",children:r})})})},Tn=({data:i})=>{const n=A(Os,i);return e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap",children:e.jsx("div",{className:"flex flex-col justify-center",children:n.referenceKey})})})};function En({data:i,onChange:n,enableEdit:r}){const{id:t,counterparty:s,missingInfoSuggestions:a,id:o,sourceDescription:d}=A(Rs,i),x=!!a?.business&&r,m=x?a?.business?.name:"Missing",h=x?a?.business?.id:null,l=s?.name??m,[c,u]=p.useState(!1),{updateTransaction:g,fetching:f}=Qs(),T=p.useCallback(async V=>{await g({transactionId:o,fields:{counterpartyId:V}}),u(!0)},[o,g]),y=p.useCallback(async V=>{await T(V),n?.()},[T,n]),{selectableBusinesses:O,fetching:K}=Oe(),[F,R]=p.useState(h??null),[k,re]=p.useState(d);return e.jsxs("td",{children:[e.jsx("div",{className:"flex flex-wrap gap-1 items-center justify-center",children:s?.id?e.jsx(be,{to:ye.BUSINESSES.DETAIL(s.id),target:"_blank",rel:"noreferrer",onClick:V=>V.stopPropagation(),className:"inline-flex items-center font-semibold",children:l}):e.jsxs(e.Fragment,{children:[e.jsx(ks,{options:O,value:F,onChange:R,search:k,onSearchChange:re,placeholder:"Choose or create a business",empty:k?e.jsx(Hs,{description:k,onAdd:y}):null}),e.jsx(Js,{content:"Approve",children:e.jsx(v,{variant:"outline",size:"icon",onClick:()=>F&&T(F),disabled:f||K||!F,children:e.jsx(ee,{className:"size-4"})})})]})}),e.jsx(Xs,{transactionId:t,counterpartyId:s?.id??F,open:c,onOpenChange:u,onClose:n})]})}const Cn="categorizeBusinessTripExpense",An=()=>{const[{fetching:i},n]=B(_s),r=p.useCallback(async t=>{const s="Error updating business trip expense category",a=Cn;j.loading("Updating trip expense category",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense category was updated"}),d.categorizeBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,categorizeBusinessTripExpense:r}};function wn(i){const{businessTripId:n,transactionId:r,onChange:t,defaultAmount:s}=i,[a,{close:o,open:d}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Categorize",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:x=>{x.stopPropagation(),d()},children:e.jsx(J,{className:"size-5"})})}),a&&e.jsx(Bn,{businessTripId:n,transactionId:r,opened:a,close:o,onChange:t,defaultAmount:s})]})}const Dn=Object.entries(Vs).map(([i,n])=>({value:n,label:i}));function Bn({businessTripId:i,transactionId:n,defaultAmount:r,opened:t,close:s,onChange:a}){const{control:o,handleSubmit:d}=N({defaultValues:{businessTripId:i,transactionId:n}}),{categorizeBusinessTripExpense:x,fetching:m}=An(),h=l=>{x({fields:l}).then(()=>{a?.(),s()})};return e.jsxs(C,{opened:t,onClose:s,centered:!0,children:[e.jsx(C.Title,{children:"Set Expense Category"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:d(h),className:"flex flex-col gap-3 mt-3",children:[e.jsx(b,{name:"category",control:o,render:({field:l,fieldState:c})=>e.jsx(q,{"data-autofocus":!0,...l,data:Dn,value:l.value,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withinPortal:!0})}),e.jsx(b,{name:"amount",control:o,defaultValue:r,render:({field:l,fieldState:c})=>e.jsx(ae,{...l,value:l.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:c.error?.message,label:"Amount"})}),e.jsx("div",{className:"flex justify-center 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:"Confirm"})})]})}),m&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Sn=({data:i,onChange:n})=>{const{uncategorizedTransactions:r,id:t}=A(Ls,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Event Date"}),e.jsx("th",{children:"Debit Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{}),e.jsx("th",{children:"Account"}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Reference#"}),e.jsx("th",{children:"Counterparty"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:r.sort((s,a)=>s.transaction.eventDate.localeCompare(a.transaction.eventDate)).map(s=>e.jsxs("tr",{children:[e.jsx(vn,{data:s.transaction}),e.jsx(fn,{data:s.transaction}),e.jsx(In,{data:s}),e.jsx("td",{children:e.jsx(be,{to:ye.CHARGES.DETAIL(s.transaction.chargeId),target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex items-center font-semibold",children:"To Charge"})}),e.jsx(bn,{data:s.transaction}),e.jsx(yn,{data:s.transaction}),e.jsx(Tn,{data:s.transaction}),e.jsx(En,{data:s.transaction}),e.jsx("td",{children:e.jsx(wn,{businessTripId:t,transactionId:s.transaction.id,onChange:n,defaultAmount:s.transaction.amount.raw})})]},s.transaction.id))})]})}):e.jsx(e.Fragment,{})},In=({data:i})=>{const{transaction:n,categorizedAmount:r,errors:t}=A(Us,i),s="amount"in n?n.amount:void 0,a=s?.raw!==r.raw&&r.raw!==0;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col whitespace-nowrap",style:{color:Number(s?.raw)>0?"green":"red"},children:[e.jsxs("div",{className:"flex gap-1",children:[s?.formatted,t.length>0&&e.jsx(Nn,{errors:t})]}),a&&e.jsxs("div",{className:"text-gray-500 ml-2",children:[r.formatted," categorized "]}),n.cryptoExchangeRate&&e.jsxs("div",{className:"text-gray-500 ml-2",children:[`(Rate: ${n.cryptoExchangeRate.rate})`,e.jsx("br",{}),s?.raw?`${Ws(s.raw*n.cryptoExchangeRate.rate)}$`:null]})]})})},Nn=({errors:i})=>{const[n,{close:r,open:t}]=L(!1);return e.jsxs(fe,{width:200,position:"bottom",shadow:"md",opened:n,children:[e.jsx(fe.Target,{children:e.jsx(qs,{onMouseEnter:t,onMouseLeave:r})}),e.jsx(fe.Dropdown,{sx:{pointerEvents:"none"},className:"whitespace-normal text-red-500",children:i.map((s,a)=>e.jsx(D,{size:"sm",children:s},a))})]})};function _n({tripId:i,isExtended:n=!1}){const[r,t]=p.useState(),[s,a]=p.useState([]),[{data:o},d]=ne({query:Gs,variables:{businessTripId:i}});function x(h){s.includes(h)?a(l=>l.filter(c=>c!==h)):a(l=>[...l,h])}const m=d;return p.useEffect(()=>{o?.businessTrip&&t(o.businessTrip)},[o?.businessTrip]),e.jsx(He,{shadow:"sm",radius:"md",withBorder:!0,children:r?e.jsxs(e.Fragment,{children:[e.jsx(Ys,{data:r,onChange:m}),e.jsxs(E,{className:"w-full",multiple:!0,value:s,chevron:e.jsx(G,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[e.jsxs(E.Item,{value:"attendees",children:[e.jsx(E.Control,{onClick:()=>x("attendees"),children:"Attendees"}),e.jsx(E.Panel,{children:e.jsx(Zt,{data:r,onChange:m})})]}),n&&e.jsxs(E.Item,{value:"uncategorized-transactions",children:[e.jsx(E.Control,{onClick:()=>x("uncategorized-transactions"),disabled:!r.uncategorizedTransactions?.length,children:"Uncategorized Transactions"}),e.jsx(E.Panel,{children:e.jsx(Sn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"flights",children:[e.jsx(E.Control,{onClick:()=>x("flights"),children:"Flights"}),e.jsx(E.Panel,{children:e.jsx(tn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"accommodations",children:[e.jsx(E.Control,{onClick:()=>x("accommodations"),children:"Accommodations"}),e.jsx(E.Panel,{children:e.jsx(Nt,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"travelAndSubsistence",children:[e.jsx(E.Control,{onClick:()=>x("travelAndSubsistence"),children:"Travel & Subsistence"}),e.jsx(E.Panel,{children:e.jsx(jn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"other",children:[e.jsx(E.Control,{onClick:()=>x("other"),children:"Other"}),e.jsx(E.Panel,{children:e.jsx(ln,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"carRental",children:[e.jsx(E.Control,{onClick:()=>x("carRental"),children:"Car Rental"}),e.jsx(E.Panel,{children:e.jsx(sn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"summary",children:[e.jsx(E.Control,{onClick:()=>x("summary"),children:"Summary"}),e.jsx(E.Panel,{children:e.jsx(Zs,{data:r})})]})]})]}):e.jsx(Se,{className:"h-10 w-10 animate-spin mr-2 self-center"})})}export{ut as C,_n as E,Hn as P};
|
|
16
|
+
*/const rt=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],it=ve("printer",rt);var at=Ye((i,{fluid:n,sizes:r},{size:t})=>({root:{paddingLeft:i.spacing.md,paddingRight:i.spacing.md,maxWidth:n?"100%":Ze({size:t,sizes:r}),marginLeft:"auto",marginRight:"auto"}})),ot=Object.defineProperty,me=Object.getOwnPropertySymbols,Ve=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,Te=(i,n,r)=>n in i?ot(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,ct=(i,n)=>{for(var r in n||(n={}))Ve.call(n,r)&&Te(i,r,n[r]);if(me)for(var r of me(n))Le.call(n,r)&&Te(i,r,n[r]);return i},dt=(i,n)=>{var r={};for(var t in i)Ve.call(i,t)&&n.indexOf(t)<0&&(r[t]=i[t]);if(i!=null&&me)for(var t of me(i))n.indexOf(t)<0&&Le.call(i,t)&&(r[t]=i[t]);return r};const lt={sizes:{xs:ie(540),sm:ie(720),md:ie(960),lg:ie(1140),xl:ie(1320)}},ut=p.forwardRef((i,n)=>{const r=Ke("Container",lt,i),{className:t,fluid:s,size:a,unstyled:o,sizes:d,variant:x}=r,m=dt(r,["className","fluid","size","unstyled","sizes","variant"]),{classes:h,cx:l}=at({fluid:s,sizes:d},{unstyled:o,name:"Container",variant:x,size:a});return Xe.createElement(Je,ct({className:l(h.root,t),ref:n},m))});ut.displayName="@mantine/core/Container";var H=3.77952755906,he={method:"save",resolution:3,page:{margin:0,format:"A4",orientation:"portrait"},canvas:{mimeType:"image/jpeg",qualityRatio:1,useCORS:!0,logging:!1},overrides:{}},ht=class{pdf;canvas;options;constructor(i,n){this.canvas=i,this.options=n,this.pdf=new es({format:this.options.page.format,orientation:this.options.page.orientation,...this.options.overrides?.pdf,unit:"mm"})}getMarginTopMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.top:this.options.page.margin;return Number(i)}getMarginLeftMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.left:this.options.page.margin;return Number(i)}getMarginRightMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.right:this.options.page.margin;return Number(i)}getMarginBottomMM(){const i=typeof this.options.page.margin=="object"?this.options.page.margin.bottom:this.options.page.margin;return Number(i)}getMarginTop(){return this.getMarginTopMM()*H}getMarginBottom(){return this.getMarginBottomMM()*H}getMarginLeft(){return this.getMarginLeftMM()*H}getMarginRight(){return this.getMarginRightMM()*H}getScale(){return this.options.resolution}getPageHeight(){return this.getPageHeightMM()*H}getPageHeightMM(){return this.pdf.internal.pageSize.height}getPageWidthMM(){return this.pdf.internal.pageSize.width}getPageWidth(){return this.getPageWidthMM()*H}getOriginalCanvasWidth(){return this.canvas.width/this.getScale()}getOriginalCanvasHeight(){return this.canvas.height/this.getScale()}getCanvasPageAvailableHeight(){return this.getPageAvailableHeight()*this.getScale()*this.getHorizontalFitFactor()}getPageAvailableWidth(){return this.getPageWidth()-(this.getMarginLeft()+this.getMarginRight())}getPageAvailableHeight(){return this.getPageHeight()-(this.getMarginTop()+this.getMarginBottom())}getPageAvailableWidthMM(){return this.getPageAvailableWidth()/H}getPageAvailableHeightMM(){return this.getPageAvailableHeight()/H}getNumberPages(){return Math.ceil(this.canvas.height/this.getCanvasPageAvailableHeight())}getHorizontalFitFactor(){return this.getPageAvailableWidth()<this.getOriginalCanvasWidth()?this.getOriginalCanvasWidth()/this.getPageAvailableWidth():1}getCanvasOffsetY(i){return this.getCanvasPageAvailableHeight()*(i-1)}getCanvasHeightLeft(i){return this.canvas.height-this.getCanvasOffsetY(i)}getCanvasPageHeight(i){if(this.canvas.height<this.getCanvasPageAvailableHeight())return this.canvas.height;const n=this.getCanvasHeightLeft(i);return n<this.getCanvasPageAvailableHeight()?n:this.getCanvasPageAvailableHeight()}getCanvasPageWidth(){return this.canvas.width}createCanvasPage(i){const n=this.getCanvasPageWidth(),r=this.getCanvasPageHeight(i),t=document.createElement("canvas");return t.setAttribute("width",String(n)),t.setAttribute("height",String(r)),t.getContext("2d").drawImage(this.canvas,0,this.getCanvasOffsetY(i),this.canvas.width,r,0,0,this.canvas.width,r),t}convert(){let i=1;const n=this.getNumberPages();for(;i<=n;){i>1&&this.pdf.addPage(this.options.page.format,this.options.page.orientation);const r=this.createCanvasPage(i),t=r.toDataURL(this.options.canvas.mimeType,this.options.canvas.qualityRatio);this.pdf.setPage(i),this.pdf.addImage({imageData:t,width:r.width/(this.getScale()*H*this.getHorizontalFitFactor()),height:r.height/(this.getScale()*H*this.getHorizontalFitFactor()),x:this.getMarginLeftMM(),y:this.getMarginTopMM()}),i+=1}return this.pdf}},pt=i=>i?{...he,...i,canvas:{...he.canvas,...i.canvas},page:{...he.page,...i.page}}:he,xt=i=>typeof i=="function"?i():i?.current,mt=async(i,n)=>{const r=pt(n),t=xt(i);if(!t){console.error("Unable to get the target element.");return}const s=await Qe(t,{useCORS:r.canvas.useCORS,logging:r.canvas.logging,scale:r.resolution,...r.overrides?.canvas}),o=new ht(s,r).convert();switch(r.method){case"build":return o;case"open":return window.open(o.output("bloburl"),"_blank"),o;case"save":default:{const d=r.filename??`${new Date().getTime()}.pdf`;return await o.save(d,{returnPromise:!0}),o}}},gt=mt;const jt={method:"open",overrides:{pdf:{compress:!0}}},ft=()=>document.getElementById("main-page"),Hn=({filename:i})=>{const[n,r]=p.useState(!1),t=async()=>{r(!0),await gt(ft,{...jt,filename:i}),r(!1)};return e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:t,disabled:n,children:n?e.jsx(Se,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(it,{className:"size-5"})})},vt="addBusinessTripAccommodationsExpense",bt=()=>{const[{fetching:i},n]=B(ss),r=p.useCallback(async t=>{const s="Error adding business trip accommodations expense",a=vt;j.loading("Adding Business Trip Accommodations Expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip accommodations expense added"}),d.addBusinessTripAccommodationsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripAccommodationsExpense:r}};function Ue({formManager:i,attendeesStayPath:n,attendeesData:r,fetchingAttendees:t=!1,businessTripId:s}){const{control:a,watch:o,trigger:d}=i,{fields:x,append:m,remove:h}=Ie({control:a,name:n}),[l,c]=p.useState(t),[u,g]=p.useState(r??[]),f=o(n),T=x.map((F,R)=>({...F,...f[R]}));p.useEffect(()=>{r&&g(r)},[r]),p.useEffect(()=>{c(t)},[t]);const[{data:y,fetching:O},K]=ne({query:ge,pause:!0,variables:{businessTripId:s??""}});return p.useEffect(()=>{if(y?.businessTrip?.attendees.length){const F=y.businessTrip.attendees.map(R=>({value:R.id,label:R.name}))??[];g(F)}},[y?.businessTrip?.attendees]),p.useEffect(()=>{c(O)},[O]),p.useEffect(()=>{!r&&!y&&!t&&!O&&K({businessTripId:s})},[r,t,O,K,s,y]),!s&&!r?e.jsx("div",{children:"Cannot edit attendees stay, lacking some mandatory information!"}):e.jsxs("div",{children:[e.jsx("span",{className:"mantine-InputWrapper-label mantine-Select-label",children:"Employees Stay"}),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[T?.map((F,R)=>e.jsxs("div",{className:"flex items-end gap-2 text-gray-600 mb-2",children:[e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(b,{name:`${n}.${R}.attendeeId`,control:a,rules:{required:"Required"},render:({field:k,fieldState:re})=>e.jsx(q,{...k,disabled:l,data:u,value:k.value??void 0,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:re.error?.message,withinPortal:!0,required:!0})})}),e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(b,{control:a,name:`${n}.${R}.nightsCount`,render:({field:k,fieldState:re})=>e.jsx(ae,{className:"w-full",...k,min:0,label:"Nights Count",value:k.value??void 0,hideControls:!0,precision:0,error:re.error?.message,required:!0,onChange:V=>k.onChange(V&&typeof V=="number"?V:void 0)})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"mb-2 size-7.5",onClick:()=>{h(R),d(n)},children:e.jsx(Ne,{className:"size-5"})})]},F.id)),e.jsx(v,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>{m({}),d(n)},children:e.jsx(ke,{className:"size-5"})})]})]})}function oe({businessTripId:i,control:n,setFetching:r}){const[t,s]=p.useState([]),[{data:a,fetching:o,error:d}]=ne({query:ge,variables:{businessTripId:i}}),{userContext:x}=p.useContext(ts);p.useEffect(()=>{a?.businessTrip?.attendees.length&&s(a.businessTrip.attendees.map(h=>({value:h.id,label:h.name})).sort((h,l)=>h.label>l.label?1:-1))},[a,s]),p.useEffect(()=>{r(o)},[r,o]),p.useEffect(()=>{d&&j.error("Error",{description:"Oops, we have an error fetching attendees"})},[d]);const m=p.useMemo(()=>x?.context.ledgerLock,[x]);return e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"date",control:n,rules:{min:m?{value:m,message:`Date must be after ${m}`}:void 0,pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:h,fieldState:l})=>e.jsx(W,{"data-autofocus":!0,...h,onChange:c=>{const u=c?typeof c=="string"?c:M(c,"yyyy-MM-dd"):void 0;u!==h.value&&h.onChange(u)},value:h.value?new Date(h.value):void 0,error:l.error?.message,label:"Date",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"valueDate",control:n,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"},min:m?{value:m,message:`Date must be after ${m}`}:void 0},render:({field:h,fieldState:l})=>e.jsx(W,{...h,onChange:c=>{const u=c?typeof c=="string"?c:M(c,"yyyy-MM-dd"):void 0;u!==h.value&&h.onChange(u)},value:h.value?new Date(h.value):void 0,error:l.error?.message,label:"Value Date",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"amount",control:n,render:({field:h,fieldState:l})=>e.jsx(b,{name:"currency",control:n,defaultValue:Fe.Ils,render:({field:c,fieldState:u})=>e.jsx(Me,{...h,value:h.value??void 0,error:l.error?.message||u.error?.message,label:"Amount",currencyCodeProps:{...c,label:"Currency"}})})}),e.jsx(b,{name:"employeeBusinessId",control:n,render:({field:h,fieldState:l})=>e.jsx(q,{...h,data:t,value:h.value,disabled:o,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]})}function Ee(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Accommodations Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(yt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function yt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripAccommodationsExpense:m,fetching:h}=bt(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Accommodation Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{control:a,name:"country",render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Country"}),e.jsx($,{children:e.jsx(J,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx(z,{name:"nightsCount",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Nights Count"}),e.jsx($,{children:e.jsx(ze,{...c,value:c.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:","})}),e.jsx(_,{})]})}),e.jsx(Ue,{formManager:s,attendeesStayPath:"attendeesStay",businessTripId:i}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Tt="updateBusinessTripAccommodationsExpense",Et=()=>{const[{fetching:i},n]=B(ns),r=p.useCallback(async t=>{const s="Error updating business trip accommodations expense",a=Tt;j.loading("Updating trip accommodations expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip accommodations expense was updated"}),d.updateBusinessTripAccommodationsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripAccommodationsExpense:r}},Ct="categorizeIntoExistingBusinessTripExpense",At=()=>{const[{fetching:i},n]=B(rs),r=p.useCallback(async t=>{const s="Error updating business trip expense category",a=Ct;j.loading("Updating business trip expense category",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense category was updated"}),d.categorizeIntoExistingBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,categorizeIntoExistingBusinessTripExpense:r}};function ce(i){const{businessTripExpenseId:n,businessTripId:r,onChange:t}=i,[s,{close:a,open:o}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Attach Uncategorized Transaction",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:d=>{d.stopPropagation(),o()},children:e.jsx(G,{className:"size-5"})})}),s&&e.jsx(wt,{businessTripExpenseId:n,businessTripId:r,opened:s,close:a,onChange:t})]})}function wt({businessTripExpenseId:i,businessTripId:n,opened:r,close:t,onChange:s}){const{control:a,handleSubmit:o,setValue:d}=N({defaultValues:{businessTripExpenseId:i}}),[x,m]=p.useState([]),[{data:h,fetching:l,error:c}]=ne({query:is,variables:{businessTripId:n}}),{categorizeIntoExistingBusinessTripExpense:u,fetching:g}=At(),f=T=>{u({fields:T}).then(()=>{s?.(),t()})};return p.useEffect(()=>{if(h?.businessTrip?.uncategorizedTransactions.length){const T=h.businessTrip.uncategorizedTransactions.filter(y=>y?.transaction);m(T.map(({transaction:y})=>({eventDate:y.eventDate,sourceDescription:y.sourceDescription,referenceKey:y.referenceKey,counterparty:y.counterparty?.name,amount:y.amount.formatted,rawAmount:y.amount.raw,value:y.id,label:`${y.eventDate} | ${y.counterparty?.name} | ${y.amount.formatted}`})).sort((y,O)=>y.eventDate.localeCompare(O.eventDate)))}},[h,m]),p.useEffect(()=>{c&&j.error("Error",{description:"Oops, we have an error fetching transactions to categorize"})},[c]),e.jsxs(C,{opened:r,onClose:t,centered:!0,children:[e.jsx(C.Title,{children:"Set Transaction Category"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:o(f),className:"flex flex-col gap-3 mt-3",children:[e.jsx(b,{name:"transactionId",control:a,render:({field:T,fieldState:y})=>e.jsx(q,{...T,itemComponent:Dt,data:x??[],disabled:l,label:"Transactions",placeholder:"Scroll to see all options",maxDropdownHeight:160,error:y.error?.message,withAsterisk:!0,withinPortal:!0,onChange:O=>{const K=x.find(F=>F.value===O);K?.rawAmount&&d("amount",K.rawAmount),T.onChange(O)}})}),e.jsx(b,{name:"amount",control:a,render:({field:T,fieldState:y})=>e.jsx(ae,{...T,value:T.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:y.error?.message,label:"Amount"})}),e.jsx("div",{className:"flex justify-center 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:"Confirm"})})]})}),g&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Dt=p.forwardRef(({eventDate:i,sourceDescription:n,referenceKey:r,counterparty:t,amount:s,...a},o)=>e.jsx("div",{ref:o,...a,children:e.jsxs(te,{children:[e.jsx(te.Col,{span:4,children:i}),e.jsx(te.Col,{span:4,children:e.jsx(D,{size:"sm",children:t})}),e.jsx(te.Col,{span:4,children:e.jsx(D,{size:"sm",children:s})}),e.jsx(te.Col,{span:8,children:e.jsx(D,{size:"xs",opacity:.65,children:n})}),e.jsxs(te.Col,{span:4,children:["Reference: ",r]})]})})),Bt="deleteBusinessTripExpense",St=()=>{const[{fetching:i},n]=B(as),r=p.useCallback(async t=>{const s="Error deleting business trip expense",a=`${Bt}-${t.businessTripExpenseId}`;j.loading("Deleting trip expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense was deleted"}),d.deleteBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,deleteBusinessTripExpense:r}};function de(i){const{fetching:n,deleteBusinessTripExpense:r}=St(),t=p.useCallback(()=>{r({businessTripExpenseId:i.businessTripExpenseId}).then(()=>{i.onDelete?.()})},[i,r]);return e.jsx(Pe,{onConfirm:t,title:"Are you sure you want to remove expense?",children:e.jsx(w,{label:"Remove Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:n,children:e.jsx($e,{className:"size-5"})})})})}const le=({data:i,isEditMode:n=!1,control:r,businessTripId:t})=>{const s=A(os,i),[a,o]=p.useState([]),[{data:d,fetching:x,error:m}]=ne({query:ge,variables:{businessTripId:t}});p.useEffect(()=>{d?.businessTrip?.attendees.length&&o(d.businessTrip.attendees.map(l=>({value:l.id,label:l.name})).sort((l,c)=>l.label>c.label?1:-1))},[d,o]),p.useEffect(()=>{m&&j.error("Error",{description:"Oops, we have an error fetching attendees"})},[m]);const h=Array.from(new Set(s.charges?.map(l=>l.id)));return e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:n&&s.payedByEmployee?e.jsxs(e.Fragment,{children:[e.jsx(b,{name:"date",control:r,defaultValue:s.date,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,form:`form ${s.id}`,"data-autofocus":!0,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"Date",error:c.error?.message,popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"valueDate",control:r,defaultValue:s.valueDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,form:`form ${s.id}`,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"Value Date",error:c.error?.message,popoverProps:{withinPortal:!0}})})]}):e.jsxs(e.Fragment,{children:[s.date&&M(new Date(s.date),"dd/MM/yy"),e.jsx(D,{fz:"sm",c:"dimmed",children:s.valueDate&&M(new Date(s.valueDate),"dd/MM/yy")})]})})}),e.jsx("td",{children:n&&s.payedByEmployee?e.jsx(b,{name:"amount",control:r,defaultValue:s.amount?.raw??void 0,render:({field:l,fieldState:c})=>e.jsx(b,{name:"currency",control:r,defaultValue:s.amount?.currency??Fe.Ils,render:({field:u,fieldState:g})=>e.jsx(Me,{form:`form ${s.id}`,...l,value:l.value??void 0,error:c.error?.message||g.error?.message,label:"Amount",currencyCodeProps:{...u,label:"Currency",form:`form ${s.id}`}})})}):e.jsx("div",{children:s.amount?.formatted})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:n&&s.payedByEmployee?e.jsx(b,{name:"employeeBusinessId",control:r,defaultValue:s.employee?.id,render:({field:l,fieldState:c})=>e.jsx(q,{form:`form ${s.id}`,...l,data:a,value:l.value,disabled:x,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withinPortal:!0})}):e.jsx("div",{className:"flex flex-row gap-2 items-center",children:s.payedByEmployee&&e.jsx(D,{c:s.employee?.name?void 0:"red",children:s.employee?.name??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:h.map(l=>e.jsx(be,{to:ye.CHARGES.DETAIL(l),target:"_blank",rel:"noreferrer",onClick:c=>c.stopPropagation(),className:"inline-flex items-center font-semibold",children:"To Charge"},l))})})]})},ue=()=>e.jsxs(e.Fragment,{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Payed By Attendee"}),e.jsx("th",{children:"Charges"})]}),It=({data:i,businessTripId:n,onChange:r})=>{const t=A(cs,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n,attendeesStay:t.attendeesStay.map(c=>({attendeeId:c.id,nightsCount:c.nightsCount}))}}),{control:d,handleSubmit:x}=o,{updateBusinessTripAccommodationsExpense:m,fetching:h}=Et(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"country",control:d,defaultValue:t.country,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(J,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.country?void 0:"red",children:t.country??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"nightsCount",control:d,defaultValue:t.nightsCount,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(ze,{...c,value:c.value??void 0,form:`form ${t.id}`,hideControls:!0,decimalScale:0,thousandSeparator:","})}),e.jsx(_,{})]})})}):e.jsx(D,{c:t.nightsCount?void 0:"red",children:t.nightsCount??"Missing"})})}),e.jsx("td",{children:s?e.jsx(I,{...o,children:e.jsx(Ue,{formManager:o,attendeesStayPath:"attendeesStay",businessTripId:n})}):e.jsx(xe,{listStyleType:"disc",children:t.attendeesStay?.length?t.attendeesStay.map(c=>e.jsxs(xe.Item,{children:[c.attendee.name," (",c.nightsCount,")"]},c.id)):e.jsx(D,{c:"red",fz:"sm",children:"Missing"})})}),e.jsx("td",{children:r&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(Q,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})})]},t.id)},We=({businessTripId:i,expenses:n,onChange:r})=>{if(!n?.length)return r?e.jsx(Ee,{businessTripId:i,onAdd:r}):e.jsx(e.Fragment,{});const t=n.map(s=>A(ds,s));return e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Location"}),e.jsx("th",{children:"Nights"}),e.jsx("th",{children:"Attendees Stay"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[t.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(It,{data:s,businessTripId:i,onChange:r},s.id)),r&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Ee,{businessTripId:i,onAdd:r})})})]})]})})},Nt=({data:i,onChange:n})=>{const{accommodationExpenses:r,id:t}=A(ls,i);return e.jsx(We,{businessTripId:t,expenses:r,onChange:n})},Ft="insertBusinessTripAttendee",Mt=()=>{const[{fetching:i},n]=B(us),r=p.useCallback(async t=>{const s="Error adding attendee to business trip",a=Ft;j.loading("Adding attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Attendee was added to the business trip"}),d.insertBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,insertBusinessTripAttendee:r}};function Ce(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Attendee",children:e.jsx(v,{variant:"outline",size:"icon",onClick:o=>{o.stopPropagation(),a()},className:"size-7.5",children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(zt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function zt({businessTripId:i,opened:n,close:r,onAdd:t}){const{selectableBusinesses:s,fetching:a}=Oe(),{control:o,handleSubmit:d}=N({defaultValues:{businessTripId:i}}),{insertBusinessTripAttendee:x,fetching:m}=Mt(),h=l=>{x({fields:l}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,children:[e.jsx(C.Title,{children:"Add Attendee"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:d(h),children:[e.jsx(b,{name:"attendeeId",control:o,render:({field:l,fieldState:c})=>e.jsx(q,{"data-autofocus":!0,...l,data:s,value:l.value,disabled:a,label:"Attendee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withAsterisk:!0,withinPortal:!0})}),e.jsx(b,{name:"arrivalDate",control:o,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,error:c.error?.message,label:"Arrival",popoverProps:{withinPortal:!0}})}),e.jsx(b,{name:"departureDate",control:o,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:c})=>e.jsx(W,{...l,onChange:u=>{const g=u?typeof u=="string"?u:M(u,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,error:c.error?.message,label:"Departure",popoverProps:{withinPortal:!0}})}),e.jsx("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:"Add"})})]})}),(m||a)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Pt="updateBusinessTripAttendee",$t=()=>{const[{fetching:i},n]=B(hs),r=p.useCallback(async t=>{const s="Error updating business trip attendee",a=Pt;j.loading("Updating trip attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip attendee was updated"}),d.updateBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripAttendee:r}},Ot="deleteBusinessTripAttendee",Rt=()=>{const[{fetching:i},n]=B(ps),r=p.useCallback(async t=>{const s="Error removing business trip attendee",a=Ot;j.loading("Removing business trip attendee",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip attendee was removed"}),d.deleteBusinessTripAttendee}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,deleteBusinessTripAttendee:r}};function kt(i){const{fetching:n,deleteBusinessTripAttendee:r}=Rt(),t=p.useCallback(()=>{r({fields:{businessTripId:i.businessTripId,attendeeId:i.attendeeId}}).then(()=>{i.onDelete?.()})},[i,r]);return e.jsx(Pe,{onConfirm:t,title:"Are you sure you want to remove attendee?",children:e.jsx(w,{label:"Remove Attendee",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:n,children:e.jsx($e,{className:"size-5"})})})})}const Ht="addBusinessTripFlightsExpense",_t=()=>{const[{fetching:i},n]=B(xs),r=p.useCallback(async t=>{const s="Error adding business trip flight expense",a=Ht;j.loading("Adding business trip flight expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip flight expense added"}),d.addBusinessTripFlightsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripFlightsExpense:r}};function qe({formManager:i,flightPathPath:n,flightPathData:r}){const{control:t,watch:s,trigger:a}=i,{fields:o,append:d,remove:x}=Ie({control:t,name:n}),m=s(n),h=o.map((l,c)=>({...l,...m[c]}));return r?e.jsxs("div",{children:[e.jsx("span",{className:"mantine-InputWrapper-label mantine-Select-label",children:"Flight Path"}),e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[h?.map((l,c)=>e.jsxs("div",{className:"flex items-end gap-2 text-gray-600 mb-2",children:[e.jsx("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:e.jsx(z,{name:`${n}.${c}`,control:t,rules:{required:"Required"},render:({field:u})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(J,{...u,value:u.value??void 0,placeholder:"Destination"})}),e.jsx(_,{})]})})}),e.jsx(v,{variant:"ghost",size:"icon",className:"mb-2 size-7.5",onClick:()=>{x(c),a(n)},children:e.jsx(Ne,{className:"size-5"})})]},l.id)),e.jsx(v,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>{d(""),a(n)},children:e.jsx(ke,{className:"size-5"})})]})]}):e.jsx("div",{children:"Cannot edit flight path stay, lacking some mandatory information!"})}function Ae(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Flight Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(Lt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}const Vt=Object.entries(Re).map(([i,n])=>({value:n,label:i}));function Lt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),[{data:m,fetching:h}]=ne({query:ge,variables:{businessTripId:i}}),{addBusinessTripFlightsExpense:l,fetching:c}=_t(),u=f=>{l({fields:f}).then(()=>{t?.(),r()})},g=m?.businessTrip?.attendees.map(f=>({value:f.id,label:f.name}))??[];return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Flight Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(u),children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(qe,{formManager:s,flightPathPath:"path"}),e.jsx(b,{name:"flightClass",control:a,render:({field:f,fieldState:T})=>e.jsx(q,{...f,data:Vt,value:f.value,label:"Flight Class",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:T.error?.message,withinPortal:!0})}),e.jsx(b,{name:"attendeeIds",control:a,render:({field:f,fieldState:T})=>e.jsx(_e,{...f,disabled:h,data:g,value:f.value??[],label:"Attendees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:T.error?.message,withinPortal:!0})}),e.jsx("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:"Add"})})]})})}),(c||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Ut="updateBusinessTripFlightsExpense",Wt=()=>{const[{fetching:i},n]=B(ms),r=p.useCallback(async t=>{const s="Error updating business trip flights expense",a=Ut;j.loading("Updating trip flights expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip flights expense was updated"}),d.updateBusinessTripFlightsExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripFlightsExpense:r}},qt=Object.entries(Re).map(([i,n])=>({value:n,label:i})),Gt=({data:i,businessTripId:n,onChange:r,attendees:t})=>{const s=A(gs,i),[a,o]=p.useState(!1),d=N({defaultValues:{id:s.id,businessTripId:n,attendeeIds:s.attendees?.map(g=>g.id)??[],path:s.path??[]}}),{control:x,handleSubmit:m}=d,{updateBusinessTripFlightsExpense:h,fetching:l}=Wt(),c=g=>{h({fields:g}).then(()=>{r?.(),o(!1)})},u=t.map(g=>({value:g.id,label:g.name}));return e.jsxs("tr",{children:[e.jsx(le,{data:s,isEditMode:a,control:x,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...d,children:e.jsx("form",{id:`form ${s.id}`,onSubmit:m(c),children:e.jsxs("div",{className:"flex flex-col gap-2 justify-center",children:[a?e.jsx(qe,{formManager:d,flightPathPath:"path",flightPathData:s.path??void 0}):e.jsx("div",{className:"flex gap-2 items-center",children:s.path?.length?s.path.map((g,f)=>e.jsxs(e.Fragment,{children:[e.jsx(D,{fw:700,children:g},f),f<s.path.length-1&&(g===s.path[f+1]?" | ":" → ")]})):e.jsx(D,{fw:700,className:"flex gap-2 items-center",c:"red",children:"Missing"})}),a?e.jsx(b,{name:"flightClass",control:x,defaultValue:s.class??void 0,render:({field:g,fieldState:f})=>e.jsx(q,{form:`form ${s.id}`,"data-autofocus":!0,...g,data:qt,value:g.value,label:"Flight Class",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:f.error?.message,withinPortal:!0})}):e.jsx(D,{c:s.class?void 0:"red",fz:"sm",children:`Class: ${s.class??"Missing"}`})]})})})}),e.jsx("td",{children:a?e.jsx(b,{name:"attendeeIds",control:x,defaultValue:s.attendees?.map(g=>g.id)??void 0,render:({field:g,fieldState:f})=>e.jsx(_e,{...g,form:`form ${s.id}`,data:u,value:g.value??[],label:"Attendees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:f.error?.message,withinPortal:!0})}):e.jsx(xe,{listStyleType:"disc",children:s.attendees?.length?s.attendees.map(g=>e.jsx(xe.Item,{children:g.name},g.id)):e.jsx(D,{c:"red",fz:"sm",children:"Missing"})})}),e.jsx("td",{children:r&&e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:l,variant:a?"default":"outline",size:"icon",className:"size-7.5",onClick:g=>{g.stopPropagation(),o(f=>!f)},children:e.jsx(Q,{className:"size-5"})})}),a&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${s.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:s.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:s.id,onDelete:r})]})})]},s.id)},Ge=({businessTripId:i,expenses:n,attendees:r,onChange:t})=>{if(!n?.length)return t?e.jsx(Ae,{businessTripId:i,onAdd:t}):e.jsx(e.Fragment,{});const s=n.map(a=>A(js,a));return e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Flight"}),e.jsx("th",{children:"Attendees"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[s.sort((a,o)=>a.date&&o.date?a.date<o.date?1:-1:a.date?-1:o.date?1:0).map(a=>e.jsx(Gt,{data:a,businessTripId:i,onChange:t,attendees:r},a.id)),t&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,children:e.jsx(Ae,{businessTripId:i,onAdd:t})})})]})]})})},Yt=({data:i,businessTripId:n,onChange:r})=>{const t=A(fs,i),[s,a]=p.useState(!1),[o,d]=p.useState(!1),{control:x,handleSubmit:m}=N({defaultValues:{businessTripId:n,attendeeId:t.id,arrivalDate:t.arrivalDate,departureDate:t.departureDate}}),{updateBusinessTripAttendee:h,fetching:l}=$t(),c=u=>{h({fields:u}).then(()=>{r?.(),a(!1)})};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{children:s?e.jsx("form",{id:`form ${t.id}`,onSubmit:m(c),children:e.jsx(b,{name:"arrivalDate",control:x,defaultValue:t.arrivalDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:u,fieldState:g})=>e.jsx(W,{...u,onChange:f=>{const T=f?typeof f=="string"?f:M(f,"yyyy-MM-dd"):void 0;T!==u.value&&u.onChange(T)},"data-autofocus":!0,value:u.value?new Date(u.value):void 0,error:g.error?.message,label:"Arrival",popoverProps:{withinPortal:!0}})})}):t.arrivalDate}),e.jsx("td",{children:s?e.jsx(b,{name:"departureDate",control:x,defaultValue:t.departureDate,rules:{pattern:{value:U,message:"Date must be im format yyyy-mm-dd"}},render:({field:u,fieldState:g})=>e.jsx(W,{...u,onChange:f=>{const T=f?typeof f=="string"?f:M(f,"yyyy-MM-dd"):void 0;T!==u.value&&u.onChange(T)},value:u.value?new Date(u.value):void 0,error:g.error?.message,label:"Departure",popoverProps:{withinPortal:!0}})}):t.departureDate}),e.jsxs("td",{className:"flex items-center gap-2",children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:l,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:u=>{u.stopPropagation(),a(g=>!g)},children:e.jsx(Q,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(kt,{businessTripId:n,attendeeId:t.id,onDelete:r}),e.jsx(Ks,{toggleExpansion:d,isExpanded:o})]})]},t.id),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx(He,{shadow:"sm",withBorder:!0,children:e.jsxs("div",{className:"flex flex-col gap-2",children:[t.flights&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Flights:"}),e.jsx(Ge,{businessTripId:n,attendees:[],expenses:t.flights})]}),t.accommodations&&e.jsxs(e.Fragment,{children:[e.jsx("div",{children:"Accommodations:"}),e.jsx(We,{businessTripId:n,expenses:t.accommodations})]})]})})})},`${t.id}-expension`)]})},Zt=({data:i,onChange:n})=>{const{attendees:r,id:t}=A(vs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Arrival Date"}),e.jsx("th",{children:"Departure Date"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.name.toLocaleLowerCase()>a.name.toLocaleLowerCase()?1:-1).map(s=>e.jsx(Yt,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx(Ce,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(Ce,{businessTripId:t,onAdd:n})},pe="addBusinessTripCarRentalExpense",Kt=()=>{const[{fetching:i},n]=B(bs),r=p.useCallback(async t=>{const s="Error adding business trip car rental expense";j.loading("Adding car rental expense...",{id:pe});try{const a=await n(t),o=S(a,s,pe);if(o)return j.success("Success",{id:pe,description:"Car rental expense added"}),o.addBusinessTripCarRentalExpense}catch(a){console.error(`${s}: ${a}`),j.error("Error",{id:pe,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripCarRentalExpense:r}};function we(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Car Rental Expense",children:e.jsx(v,{variant:"outline",size:"icon",onClick:o=>{o.stopPropagation(),a()},className:"size-7.5",children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(Xt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function Xt({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripCarRentalExpense:m,fetching:h}=Kt(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Car Rental Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(b,{name:"days",control:a,render:({field:c,fieldState:u})=>e.jsx(ae,{...c,value:c.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:u.error?.message,label:"Rent Days"})}),e.jsx(z,{name:"isFuelExpense",control:a,render:({field:{value:c,...u}})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(X,{children:"Is Fuel Expense"})}),e.jsx($,{children:e.jsx(je,{...u,checked:c===!0,onCheckedChange:u.onChange})}),e.jsx(_,{})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Jt="updateBusinessTripCarRentalExpense",Qt=()=>{const[{fetching:i},n]=B(ys),r=p.useCallback(async t=>{const s="Error updating business trip car rental expense",a=Jt;j.loading("Updating trip car rental expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip car rental expense was updated"}),d.updateBusinessTripCarRentalExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripCarRentalExpense:r}},en=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ts,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripCarRentalExpense:m,fetching:h}=Qt(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:t.isFuelExpense!==!0&&(s?e.jsx(b,{name:"days",control:d,defaultValue:t.days,render:({field:c,fieldState:u})=>e.jsx(ae,{...c,value:c.value??void 0,form:`form ${t.id}`,hideControls:!0,precision:2,removeTrailingZeros:!0,error:u.error?.message,placeholder:"Rent Days"})}):e.jsx(D,{c:t.days?void 0:"red",children:t.days??"Missing"}))})})})}),e.jsx("td",{children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"isFuelExpense",control:d,defaultValue:t.isFuelExpense,render:({field:c})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(X,{children:"Is Fuel Expense"})}),e.jsx($,{children:e.jsx(je,{form:`form ${t.id}`,checked:c.value===!0,onCheckedChange:c.onChange})})]})})}):t.isFuelExpense===!0?e.jsx(nt,{}):e.jsx(st,{})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(Q,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},sn=({data:i,onChange:n})=>{const{carRentalExpenses:r,id:t}=A(Es,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Days"}),e.jsx("th",{children:"Type"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(en,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(we,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(we,{businessTripId:t,onAdd:n})},tn=({data:i,onChange:n})=>{const{flightExpenses:r,id:t,attendees:s}=A(Cs,i);return e.jsx(Ge,{businessTripId:t,attendees:s,expenses:r,onChange:n})},nn="addBusinessTripOtherExpense",rn=()=>{const[{fetching:i},n]=B(As),r=p.useCallback(async t=>{const s='Error adding business trip "other" expense',a=nn;j.loading('Adding trip "other" expense',{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:'Business trip "other" expense was added'}),d.addBusinessTripOtherExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripOtherExpense:r}};function De(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add Other Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(an,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function an({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripOtherExpense:m,fetching:h}=rn(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Other Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{name:"description",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Description"}),e.jsx($,{children:e.jsx(J,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx(z,{control:s.control,name:"deductibleExpense",render:({field:c})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(X,{children:"Deductible Expense"})}),e.jsx($,{children:e.jsx(je,{checked:c.value===!0,onCheckedChange:c.onChange})})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const on="updateBusinessTripOtherExpense",cn=()=>{const[{fetching:i},n]=B(ws),r=p.useCallback(async t=>{const s='Error updating business trip "other" expense',a=on;j.loading('Updating business trip "other" expense',{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:'Business trip "other" expense was updated'}),d.updateBusinessTripOtherExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripOtherExpense:r}},dn=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ds,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripOtherExpense:m,fetching:h}=cn(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"description",control:d,defaultValue:t.description,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(J,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.description?void 0:"red",children:t.description??"Missing"})})})}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?e.jsx(I,{...o,children:e.jsx(z,{name:"deductibleExpense",control:o.control,defaultValue:t.deductibleExpense,render:({field:c})=>e.jsx(P,{children:e.jsx($,{children:e.jsx(je,{form:`form ${t.id}`,checked:c.value===!0,onCheckedChange:c.onChange})})})})}):e.jsx(D,{c:t.deductibleExpense?void 0:"red",children:t.deductibleExpense===!0?"Yes":t.deductibleExpense===!1?"No":"Missing"})})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(Q,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},ln=({data:i,onChange:n})=>{const{otherExpenses:r,id:t}=A(Bs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Deductible Expense"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(dn,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(De,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(De,{businessTripId:t,onAdd:n})},un="addBusinessTripTravelAndSubsistenceExpense",hn=()=>{const[{fetching:i},n]=B(Ss),r=p.useCallback(async t=>{const s="Error adding business trip travel&subsistence expense",a=un;j.loading("Adding trip travel&subsistence expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip travel&subsistence expense was added"}),d.addBusinessTripTravelAndSubsistenceExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,addBusinessTripTravelAndSubsistenceExpense:r}};function Be(i){const{businessTripId:n,onAdd:r}=i,[t,{close:s,open:a}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Add T&S Expense",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:o=>{o.stopPropagation(),a()},children:e.jsx(G,{className:"size-5"})})}),t&&e.jsx(pn,{businessTripId:n,opened:t,close:s,onAdd:r})]})}function pn({businessTripId:i,opened:n,close:r,onAdd:t}){const s=N({defaultValues:{businessTripId:i}}),{control:a,handleSubmit:o}=s,[d,x]=p.useState(!1),{addBusinessTripTravelAndSubsistenceExpense:m,fetching:h}=hn(),l=c=>{m({fields:c}).then(()=>{t?.(),r()})};return e.jsxs(C,{opened:n,onClose:r,centered:!0,lockScroll:!0,children:[e.jsx(C.Title,{children:"Add Travel & Subsistence Expense"}),e.jsx(C.Body,{children:e.jsx(I,{...s,children:e.jsxs("form",{onSubmit:o(l),className:"space-y-3",children:[e.jsx(oe,{businessTripId:i,control:a,setFetching:x}),e.jsx(z,{name:"expenseType",control:a,render:({field:c})=>e.jsxs(P,{children:[e.jsx(X,{children:"Expense Type"}),e.jsx($,{children:e.jsx(J,{...c,value:c.value??void 0})}),e.jsx(_,{})]})}),e.jsx("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:"Add"})})]})})}),(h||d)&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const xn="updateBusinessTripTravelAndSubsistenceExpense",mn=()=>{const[{fetching:i},n]=B(Is),r=p.useCallback(async t=>{const s="Error updating business trip travel&subsistence expense",a=xn;j.loading("Updating trip travel&subsistence expense",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip travel&subsistence expense was updated"}),d.updateBusinessTripTravelAndSubsistenceExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,updateBusinessTripTravelAndSubsistenceExpense:r}},gn=({data:i,businessTripId:n,onChange:r})=>{const t=A(Ns,i),[s,a]=p.useState(!1),o=N({defaultValues:{id:t.id,businessTripId:n}}),{control:d,handleSubmit:x}=o,{updateBusinessTripTravelAndSubsistenceExpense:m,fetching:h}=mn(),l=c=>{m({fields:c}).then(()=>{r?.(),a(!1)})};return e.jsxs("tr",{children:[e.jsx(le,{data:t,isEditMode:s,control:d,businessTripId:n}),e.jsx("td",{children:e.jsx(I,{...o,children:e.jsx("form",{id:`form ${t.id}`,onSubmit:x(l),children:s?e.jsx(z,{name:"expenseType",control:d,defaultValue:t.expenseType,render:({field:c})=>e.jsxs(P,{children:[e.jsx($,{children:e.jsx(J,{form:`form ${t.id}`,...c,value:c.value??void 0})}),e.jsx(_,{})]})}):e.jsx(D,{c:t.expenseType?void 0:"red",children:t.expenseType??"Missing"})})})}),e.jsxs("td",{children:[e.jsx(w,{label:"Edit",children:e.jsx(v,{disabled:h,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:c=>{c.stopPropagation(),a(u=>!u)},children:e.jsx(Q,{className:"size-5"})})}),s&&e.jsx(w,{label:"Confirm Changes",children:e.jsx(v,{type:"submit",form:`form ${t.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:e.jsx(ee,{className:"size-5"})})}),e.jsx(ce,{businessTripExpenseId:t.id,businessTripId:n,onChange:r}),e.jsx(de,{businessTripExpenseId:t.id,onDelete:r})]})]},t.id)},jn=({data:i,onChange:n})=>{const{travelAndSubsistenceExpenses:r,id:t}=A(Fs,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(ue,{}),e.jsx("th",{children:"Expense Type"}),e.jsx("th",{})]})}),e.jsxs("tbody",{children:[r.sort((s,a)=>s.date&&a.date?s.date<a.date?1:-1:s.date?-1:a.date?1:0).map(s=>e.jsx(gn,{data:s,businessTripId:t,onChange:n},s.id)),e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx(Be,{businessTripId:t,onAdd:n})})})]})]})}):e.jsx(Be,{businessTripId:t,onAdd:n})},fn=({data:i})=>{const n=A(Ms,i),r="effectiveDate"in n?n.effectiveDate:void 0;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col justify-center",children:[e.jsx("div",{children:r&&M(new Date(r),"dd/MM/yy")}),n.sourceEffectiveDate&&e.jsxs("div",{className:"text-xs text-gray-500",children:["(Originally ",M(new Date(n.sourceEffectiveDate),"dd/MM/yy"),")"]})]})})},vn=({data:i})=>{const n=A(zs,i),r="eventDate"in n?n.eventDate:void 0;return e.jsx("td",{children:e.jsx("div",{className:"flex flex-col justify-center",children:r&&M(new Date(r),"dd/MM/yy")})})},bn=({data:i})=>{const n=A(Ps,i),{account:r}=n,t=r.type,s=r.name;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[e.jsx("p",{children:t}),e.jsx("p",{children:s})]})})},yn=({data:i})=>{const n=A($s,i),r="sourceDescription"in n?n.sourceDescription:"Missing";return e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap",children:e.jsx("div",{className:"flex flex-col justify-center",children:r})})})},Tn=({data:i})=>{const n=A(Os,i);return e.jsx("td",{children:e.jsx("div",{className:"flex flex-wrap",children:e.jsx("div",{className:"flex flex-col justify-center",children:n.referenceKey})})})};function En({data:i,onChange:n,enableEdit:r}){const{id:t,counterparty:s,missingInfoSuggestions:a,id:o,sourceDescription:d}=A(Rs,i),x=!!a?.business&&r,m=x?a?.business?.name:"Missing",h=x?a?.business?.id:null,l=s?.name??m,[c,u]=p.useState(!1),{updateTransaction:g,fetching:f}=Xs(),T=p.useCallback(async V=>{await g({transactionId:o,fields:{counterpartyId:V}}),u(!0)},[o,g]),y=p.useCallback(async V=>{await T(V),n?.()},[T,n]),{selectableBusinesses:O,fetching:K}=Oe(),[F,R]=p.useState(h??null),[k,re]=p.useState(d);return e.jsxs("td",{children:[e.jsx("div",{className:"flex flex-wrap gap-1 items-center justify-center",children:s?.id?e.jsx(be,{to:ye.BUSINESSES.DETAIL(s.id),target:"_blank",rel:"noreferrer",onClick:V=>V.stopPropagation(),className:"inline-flex items-center font-semibold",children:l}):e.jsxs(e.Fragment,{children:[e.jsx(ks,{options:O,value:F,onChange:R,search:k,onSearchChange:re,placeholder:"Choose or create a business",empty:k?e.jsx(Hs,{description:k,onAdd:y}):null}),e.jsx(Qs,{content:"Approve",children:e.jsx(v,{variant:"outline",size:"icon",onClick:()=>F&&T(F),disabled:f||K||!F,children:e.jsx(ee,{className:"size-4"})})})]})}),e.jsx(Js,{transactionId:t,counterpartyId:s?.id??F,open:c,onOpenChange:u,onClose:n})]})}const Cn="categorizeBusinessTripExpense",An=()=>{const[{fetching:i},n]=B(_s),r=p.useCallback(async t=>{const s="Error updating business trip expense category",a=Cn;j.loading("Updating trip expense category",{id:a});try{const o=await n(t),d=S(o,s,a);if(d)return j.success("Success",{id:a,description:"Business trip expense category was updated"}),d.categorizeBusinessTripExpense}catch(o){console.error(`${s}: ${o}`),j.error("Error",{id:a,description:s,duration:1e5,closeButton:!0})}},[n]);return{fetching:i,categorizeBusinessTripExpense:r}};function wn(i){const{businessTripId:n,transactionId:r,onChange:t,defaultAmount:s}=i,[a,{close:o,open:d}]=L(!1);return e.jsxs(e.Fragment,{children:[e.jsx(w,{label:"Categorize",children:e.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:x=>{x.stopPropagation(),d()},children:e.jsx(Q,{className:"size-5"})})}),a&&e.jsx(Bn,{businessTripId:n,transactionId:r,opened:a,close:o,onChange:t,defaultAmount:s})]})}const Dn=Object.entries(Vs).map(([i,n])=>({value:n,label:i}));function Bn({businessTripId:i,transactionId:n,defaultAmount:r,opened:t,close:s,onChange:a}){const{control:o,handleSubmit:d}=N({defaultValues:{businessTripId:i,transactionId:n}}),{categorizeBusinessTripExpense:x,fetching:m}=An(),h=l=>{x({fields:l}).then(()=>{a?.(),s()})};return e.jsxs(C,{opened:t,onClose:s,centered:!0,children:[e.jsx(C.Title,{children:"Set Expense Category"}),e.jsx(C.Body,{children:e.jsxs("form",{onSubmit:d(h),className:"flex flex-col gap-3 mt-3",children:[e.jsx(b,{name:"category",control:o,render:({field:l,fieldState:c})=>e.jsx(q,{"data-autofocus":!0,...l,data:Dn,value:l.value,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:c.error?.message,withinPortal:!0})}),e.jsx(b,{name:"amount",control:o,defaultValue:r,render:({field:l,fieldState:c})=>e.jsx(ae,{...l,value:l.value??void 0,hideControls:!0,precision:2,removeTrailingZeros:!0,error:c.error?.message,label:"Amount"})}),e.jsx("div",{className:"flex justify-center 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:"Confirm"})})]})}),m&&e.jsx(Y,{blur:1,center:!0,children:e.jsx(Z,{})})]})}const Sn=({data:i,onChange:n})=>{const{uncategorizedTransactions:r,id:t}=A(Ls,i);return r?.length?e.jsx("div",{className:"flex flex-col gap-2 mt-5",children:e.jsxs(se,{highlightOnHover:!0,withBorder:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Event Date"}),e.jsx("th",{children:"Debit Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{}),e.jsx("th",{children:"Account"}),e.jsx("th",{children:"Description"}),e.jsx("th",{children:"Reference#"}),e.jsx("th",{children:"Counterparty"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:r.sort((s,a)=>s.transaction.eventDate.localeCompare(a.transaction.eventDate)).map(s=>e.jsxs("tr",{children:[e.jsx(vn,{data:s.transaction}),e.jsx(fn,{data:s.transaction}),e.jsx(In,{data:s}),e.jsx("td",{children:e.jsx(be,{to:ye.CHARGES.DETAIL(s.transaction.chargeId),target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex items-center font-semibold",children:"To Charge"})}),e.jsx(bn,{data:s.transaction}),e.jsx(yn,{data:s.transaction}),e.jsx(Tn,{data:s.transaction}),e.jsx(En,{data:s.transaction}),e.jsx("td",{children:e.jsx(wn,{businessTripId:t,transactionId:s.transaction.id,onChange:n,defaultAmount:s.transaction.amount.raw})})]},s.transaction.id))})]})}):e.jsx(e.Fragment,{})},In=({data:i})=>{const{transaction:n,categorizedAmount:r,errors:t}=A(Us,i),s="amount"in n?n.amount:void 0,a=s?.raw!==r.raw&&r.raw!==0;return e.jsx("td",{children:e.jsxs("div",{className:"flex flex-col whitespace-nowrap",style:{color:Number(s?.raw)>0?"green":"red"},children:[e.jsxs("div",{className:"flex gap-1",children:[s?.formatted,t.length>0&&e.jsx(Nn,{errors:t})]}),a&&e.jsxs("div",{className:"text-gray-500 ml-2",children:[r.formatted," categorized "]}),n.cryptoExchangeRate&&e.jsxs("div",{className:"text-gray-500 ml-2",children:[`(Rate: ${n.cryptoExchangeRate.rate})`,e.jsx("br",{}),s?.raw?`${Ws(s.raw*n.cryptoExchangeRate.rate)}$`:null]})]})})},Nn=({errors:i})=>{const[n,{close:r,open:t}]=L(!1);return e.jsxs(fe,{width:200,position:"bottom",shadow:"md",opened:n,children:[e.jsx(fe.Target,{children:e.jsx(qs,{onMouseEnter:t,onMouseLeave:r})}),e.jsx(fe.Dropdown,{sx:{pointerEvents:"none"},className:"whitespace-normal text-red-500",children:i.map((s,a)=>e.jsx(D,{size:"sm",children:s},a))})]})};function _n({tripId:i,isExtended:n=!1}){const[r,t]=p.useState(),[s,a]=p.useState([]),[{data:o},d]=ne({query:Gs,variables:{businessTripId:i}});function x(h){s.includes(h)?a(l=>l.filter(c=>c!==h)):a(l=>[...l,h])}const m=d;return p.useEffect(()=>{o?.businessTrip&&t(o.businessTrip)},[o?.businessTrip]),e.jsx(He,{shadow:"sm",radius:"md",withBorder:!0,children:r?e.jsxs(e.Fragment,{children:[e.jsx(Ys,{data:r,onChange:m}),e.jsxs(E,{className:"w-full",multiple:!0,value:s,chevron:e.jsx(G,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:[e.jsxs(E.Item,{value:"attendees",children:[e.jsx(E.Control,{onClick:()=>x("attendees"),children:"Attendees"}),e.jsx(E.Panel,{children:e.jsx(Zt,{data:r,onChange:m})})]}),n&&e.jsxs(E.Item,{value:"uncategorized-transactions",children:[e.jsx(E.Control,{onClick:()=>x("uncategorized-transactions"),disabled:!r.uncategorizedTransactions?.length,children:"Uncategorized Transactions"}),e.jsx(E.Panel,{children:e.jsx(Sn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"flights",children:[e.jsx(E.Control,{onClick:()=>x("flights"),children:"Flights"}),e.jsx(E.Panel,{children:e.jsx(tn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"accommodations",children:[e.jsx(E.Control,{onClick:()=>x("accommodations"),children:"Accommodations"}),e.jsx(E.Panel,{children:e.jsx(Nt,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"travelAndSubsistence",children:[e.jsx(E.Control,{onClick:()=>x("travelAndSubsistence"),children:"Travel & Subsistence"}),e.jsx(E.Panel,{children:e.jsx(jn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"other",children:[e.jsx(E.Control,{onClick:()=>x("other"),children:"Other"}),e.jsx(E.Panel,{children:e.jsx(ln,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"carRental",children:[e.jsx(E.Control,{onClick:()=>x("carRental"),children:"Car Rental"}),e.jsx(E.Panel,{children:e.jsx(sn,{data:r,onChange:m})})]}),e.jsxs(E.Item,{value:"summary",children:[e.jsx(E.Control,{onClick:()=>x("summary"),children:"Summary"}),e.jsx(E.Panel,{children:e.jsx(Zs,{data:r})})]})]})]}):e.jsx(Se,{className:"h-10 w-10 animate-spin mr-2 self-center"})})}export{ut as C,_n as E,Hn as P};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as
|
|
2
|
-
`);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(
|
|
1
|
+
import{r as F,j as r,e as Q,u as q,gR as H,L as E,a8 as K,bm as $,B as U,G as X,bo as ee,bp as te,bs as ne,cI as O,x as k,gS as T,bt as se,F as oe,K as re,P as ie,W as le}from"./index-BmZql10x.js";import{u as W}from"./use-url-query-DV9K0FAR.js";import{P as ae}from"./page-layout-DxGYaCiw.js";import{A as ce,a as fe,c as ue,b as he}from"./accordion-CG93-Cqs.js";import{P as de}from"./modal-dLkQjDNz.js";import{F as pe}from"./funnel-BQEGwl1q.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:l,N:o,j:h,M:a,Z:f,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*f);const V=o-a,_=o+a,B=_&1,Y=l+o-1,Z=h+a-1,J=(_+B)/2;let N;t:for(let M=0;M<=J;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let u=I;u<=L;u+=2){const A=t[u-1-f*Math.floor((u-1)/f)],R=t[u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,S=w-u;let b=w,C=S;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[u-f*Math.floor(u/f)]=b,B===1&&(N=V-u)>=1-M&&N<M&&b+t[f+N-f*Math.floor(N/f)]>=o)if(M>1||b!==w){i[x++]=l+b,i[x++]=o-b,i[x++]=h+C,i[x++]=a-C,o=w,a=S,f=2*(Math.min(o,a)+1);continue e}else break t}for(let u=I;u<=L;u+=2){const A=t[f+u-1-f*Math.floor((u-1)/f)],R=t[f+u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,S=w-u;let b=w,C=S;for(;b<o&&C<a&&s(Y-b,Z-C);)b++,C++;if(t[f+u-f*Math.floor(u/f)]=b,B===0&&(N=V-u)>=-M&&N<=M&&b+t[N-f*Math.floor(N/f)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-S,i[x++]=S,o=o-b,a=a-C,f=2*(Math.min(o,a)+1);continue e}else break t}}if(o!==a){a>o?(l+=o,h+=o,a-=o,o=0):(l+=a,h+=a,o-=a,a=0);break}}if(o+a!==0)if(e.pxe===l||e.pye===h)e.pxe=l+o,e.pye=h+a;else{const V=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=l,e.pxe=l+o,e.pys=h,e.pye=h+a,V>=0)return e.i=l,e.N=o,e.j=h,e.M=a,e.Z=f,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],f=2*(Math.min(o,a)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const l=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*l);return new m({i:e,N:n,j:t,M:s,Z:l,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,l]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<l&&t(s,s);)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;t(--i,--l)&&i>s&&l>s;);}else{for(;s<i&&s<l&&e[s]===n[s];)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;e[--i]===n[--l]&&i>s&&l>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,l+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:a,j:f,N:x}=this;return a<x&&(n.done=!1,n.value=[a,f,x-a],this.i=x),n}const t=n.value,s=t[0],i=t[1],l=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=l,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*P(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,l,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=l;t<e.length&&(yield s.call(e,t))}v.applyPatch=P;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[l,o,h,a]of d(e,n,t))s<l&&(yield[0,i.call(e,s,l)]),l<o&&(yield[-1,i.call(e,l,o)]),h<a&&(yield[1,i.call(n,h,a)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),G=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=F.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),P=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of P)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(P.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),G]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),G]);let n=[];for(const[t,s]of j){const i=t.split(`
|
|
2
|
+
`);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(Q,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=q({query:H,variables:c}),p=F.useMemo(()=>m?.pcnByDate?m.pcnByDate.sort((y,g)=>g.date>y.date?1:g.date<y.date?-1:0):[],[m?.pcnByDate]);return D?r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}):r.jsxs("div",{className:"flex flex-col gap-4",children:[!!m&&d&&r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}),p.map((y,g)=>r.jsx(ge,{content:y.content,contentOrigin:y.diffContent,monthDate:y.date},g))]})};function be({filter:c,setFilter:m,closeModal:D}){const{control:d,handleSubmit:p,setValue:y}=X({defaultValues:{...c}}),{selectableBusinesses:g,fetching:P}=ee(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[P?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(te,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(ne,{...e,data:g,value:e.value,disabled:P,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),r.jsx(O,{label:"From date",defaultValue:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,defaultDate:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("fromMonthDate",k(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsx(O,{label:"To date",defaultValue:c?.toMonthDate?new Date(c.toMonthDate):new Date,defaultDate:c?.toMonthDate?new Date(c.toMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("toMonthDate",k(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[r.jsx(U,{type:"submit",children:"Filter"}),r.jsx(U,{type:"button",onClick:D,children:"Cancel"})]})]})]})}function ve({filter:c,setFilter:m}){const[D,d]=F.useState(!1),{get:p,set:y}=W(),{userContext:g}=F.useContext(K);function P(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:k(T(new Date),"yyyy-MM-15"),toMonthDate:k(new Date,"yyyy-MM-15")},se(j,c)||m(j)}return F.useEffect(()=>{const j=$(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(de,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:P,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(pe,{className:"size-5"})})]})}const Se=()=>{const{get:c}=W(),{setFiltersContext:m}=F.useContext(oe),D=F.useMemo(()=>{try{if(c("validateReportsFilters"))return JSON.parse(decodeURIComponent(c("validateReportsFilters")))}catch(y){console.error("Error parsing filter from URL",y)}return{fromMonthDate:k(T(new Date),"yyyy-MM-15"),toMonthDate:k(new Date,"yyyy-MM-15")}},[c]),[d,p]=F.useState(D);return F.useEffect(()=>{m(r.jsx("div",{className:"flex flex-row gap-2",children:r.jsx(ve,{filter:{...d},setFilter:p})}))},[d,m]),r.jsx(ae,{title:"Report Validations",children:r.jsx(ce,{type:"single",collapsible:!0,children:r.jsx(fe,{value:"pcn874",children:r.jsxs(re,{className:"p-4",children:[r.jsx(ue,{children:r.jsx(ie,{children:"Monthly VAT (PCN874)"})}),r.jsx(he,{children:r.jsx(le,{children:r.jsx(Me,{filter:d})})})]})})})})};export{Se as ValidateReportsScreen};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as x,bu as h,J as T,r,j as s,bn as g,bv as j,F as B,T as w,ah as C,L as b,au as v,bw as E}from"./index-BmZql10x.js";import{E as P,P as y,C as L}from"./editable-business-trip-DlAsZ0aQ.js";import{I as F}from"./insert-business-trip-modal-CXgUJdgl.js";import{P as I}from"./page-layout-DxGYaCiw.js";import{A as m}from"./summary-DzLJ6sUY.js";import"./list-plus-BlHtPDEN.js";import"./Table-CQ4GTcIY.js";import"./toggle-expansion-button-BzVlE1kb.js";import"./panel-top-open-CWsfFRNu.js";import"./MultiSelect-CszuVk07.js";import"./similar-transactions-modal-8T9lL2yX.js";import"./tooltip-Ht3m2Q26.js";import"./create-event-handler-BiA-1lGu.js";const S=({data:u,isOpened:o,shouldValidate:l})=>{const e=T(j,u),[{data:i,fetching:a}]=x({pause:!l,query:h,variables:{id:e.id}}),d=r.useMemo(()=>l?i?.businessTrip&&(i.businessTrip.uncategorizedTransactions?.length||i?.businessTrip.summary?.errors?.length):!1,[i]),c=d||e?.accountantApproval!=="APPROVED";return s.jsxs(m.Item,{value:e.id,children:[s.jsx(m.Control,{children:s.jsx(g,{inline:!0,size:12,processing:a,disabled:!c,color:d?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(m.Panel,{children:o&&s.jsx(P,{tripId:e.id,isExtended:!0},e.id)})]})},_=()=>{const{setFiltersContext:u}=r.useContext(B),[o,l]=r.useState([]),[e,i]=r.useState(!1),[{data:a,fetching:d}]=x({query:E});r.useEffect(()=>{if(!a?.allBusinessTrips?.length){l([]);return}const t=a.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[a?.allBusinessTrips]);const[c,f]=r.useState([]);return r.useEffect(()=>{u(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(F,{}),s.jsx(w,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(C,{checked:e??!1,onCheckedChange:t=>i(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(y,{filename:"business_trips"})]}))},[a,d,u,e]),s.jsx(I,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&d?s.jsx(b,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(L,{children:s.jsx(m,{className:"w-full",multiple:!0,value:c,onChange:f,chevron:s.jsx(v,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:c.includes(t.id)},t.id))})})})};export{_ as BusinessTrips};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,F as C,u as S,j as e,T as h,B as j,bj as m,aN as a,L as T,bk as y,bl as N}from"./index-BmZql10x.js";import{u as v}from"./use-url-query-DV9K0FAR.js";import{A as E}from"./accounter-table-Dgvw-xm_.js";import{P as F}from"./page-layout-DxGYaCiw.js";import{C as B,a as R,B as z,M as I}from"./business-extended-info-CeEMIazB.js";import{B as L}from"./business-transactions-filters-DYBvDjKs.js";import{P as k,a as A}from"./panel-top-open-CWsfFRNu.js";import{T as O}from"./Table-CQ4GTcIY.js";import"./Pagination-Cp6iKPSu.js";import"./create-event-handler-BiA-1lGu.js";import"./download-csv-button-jQXIlRax.js";import"./modal-dLkQjDNz.js";import"./funnel-BQEGwl1q.js";import"./MultiSelect-CszuVk07.js";const Y=()=>{const{get:t}=v(),{setFiltersContext:i}=l.useContext(C),[r,o]=l.useState(!1),[p,w]=l.useState(!1),[d,x]=l.useState(t("transactionsFilters")?JSON.parse(decodeURIComponent(t("transactionsFilters"))):{}),[{data:c,fetching:b}]=S({query:y,variables:{filters:d}});l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(L,{filter:d,setFilter:x}),e.jsx(h,{label:"Expand all accounts",children:e.jsx(j,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(s=>!s),children:r?e.jsx(k,{className:"size-5"}):e.jsx(A,{className:"size-5"})})}),e.jsx(h,{label:"Expand all currencies",children:e.jsx(j,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>w(s=>!s),children:p?e.jsx(B,{className:"size-5"}):e.jsx(R,{className:"size-5"})})})]}))},[c,d,i,x,r,o,p]);const g=l.useMemo(()=>c?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:c?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?c.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((s,u)=>s.business.name.localeCompare(u.business.name)):[],[c?.businessTransactionsSumFromLedgerRecords]),f=[{title:"Business Name",value:s=>s.business.name},{title:"Debit / Credit",value:s=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"red",children:s.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"green",children:s.credit.formatted})})]}),style:{whiteSpace:"nowrap"}},{title:"Total",value:s=>e.jsx(m,{c:s.total.raw<-1e-4?"red":s.total.raw>1e-4?"green":void 0,fw:700,children:s.total.formatted}),style:{whiteSpace:"nowrap"}},...n(a.Eur),...n(a.Usd),...n(a.Gbp),...n(a.Cad),...n(a.Jpy),...n(a.Aud),...n(a.Sek),...P(p)];return e.jsx(F,{title:"Business Transactions",description:"Business Transactions Summery",children:b?e.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(O,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{className:"sticky top-0 z-20",children:e.jsxs("tr",{className:"tracking-wider font-medium text-gray-900 text-sm bg-gray-100",children:[f.map((s,u)=>s.disabled?null:e.jsx("th",{children:s.title},String(u))),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:g.map((s,u)=>e.jsx(E,{columns:f,item:s,moreInfo:()=>e.jsx(z,{businessID:s.business.id,filter:d}),isShowAll:r},u))})]})})};function n(t){return[{title:`${t} Debit / Credit`,value:i=>{const r=i.foreignCurrenciesSum.find(o=>o.currency===t);return r?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"red",children:r.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"green",children:r.credit.formatted})})]}):null},style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:i=>{const r=i.foreignCurrenciesSum.find(o=>o.currency===t);return r?.total?.raw&&(r.total.raw<-1e-4||r.total.raw>1e-4)?e.jsx(I,{color:r.total.raw>0?"green":"red",children:r.total.formatted}):r?.total?.formatted},style:{whiteSpace:"nowrap"}}]}function P(t){return t?Object.values(a).filter(r=>!N.includes(r)).map(n).flat():[]}export{Y as BusinessTransactionsSummery};
|