@accounter/client 0.0.8-alpha-20251027170934-006cd73f08bdddc55a4caff263dcfa5e2b8b63ec → 0.0.8-alpha-20251028103841-7bfcc6a48108b285963cd18e3cc0548f0dd19dd8
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 -1
- package/dist/assets/{Checkbox-BZ680-Kk.js → Checkbox-D8vMngET.js} +2 -2
- package/dist/assets/MultiSelect-DyHLxout.js +1 -0
- package/dist/assets/Pagination-J219P8nB.js +1 -0
- package/dist/assets/{Progress-DembKoIO.js → Progress-CtbG-tgE.js} +1 -1
- package/dist/assets/Table-DiM_oZiR.js +1 -0
- package/dist/assets/Typography-Cci39G2t.js +1 -0
- package/dist/assets/YearPickerInput-fBHzo-9n.js +1 -0
- package/dist/assets/accordion-CIgxze9K.js +1 -0
- package/dist/assets/accountant-approvals-Da-Rhpn-.js +1 -0
- package/dist/assets/accounter-table-CVAmEnx0.js +1 -0
- package/dist/assets/addDays-CkP1VB0c.js +1 -0
- package/dist/assets/all-charges-DBThy56x.js +1 -0
- package/dist/assets/{arrow-up-down-J9wnXx-h.js → arrow-up-down-DuRFov-X.js} +1 -1
- package/dist/assets/{building-2-1saARtmG.js → building-2-CSNfw8ff.js} +1 -1
- package/dist/assets/business-BwlprQsj.js +32 -0
- package/dist/assets/business-extended-info-CaNS8hMv.js +13 -0
- package/dist/assets/{business-header-SAnNK6FP.js → business-header-BwPwvICE.js} +1 -1
- package/dist/assets/business-transactions-filters-Dc2oWHEf.js +1 -0
- package/dist/assets/business-transactions-single-CPfIuNhV.js +1 -0
- package/dist/assets/business-trip-ChARfpOB.js +1 -0
- package/dist/assets/charge-DVi7MgMm.js +1 -0
- package/dist/assets/charges-filters-qR84DcIb.js +1 -0
- package/dist/assets/charges-ledger-validation-DtbFDZzl.js +1 -0
- package/dist/assets/charges-table-acSB8S00.js +62 -0
- package/dist/assets/{chart-Dq5fMHeT.js → chart-DtI3g0Q5.js} +6 -6
- package/dist/assets/create-event-handler-BiA-1lGu.js +1 -0
- package/dist/assets/{data-table-pagination-4YqSgXqX.js → data-table-pagination-Cv19AH6N.js} +1 -1
- package/dist/assets/download-csv-button-CBfb0Niq.js +1 -0
- package/dist/assets/editable-business-trip-BSVnyXpu.js +16 -0
- package/dist/assets/funnel-BjNIVF6D.js +6 -0
- package/dist/assets/{index-CBQNwu37.js → index-BBP2jL6K.js} +2 -2
- package/dist/assets/index-BcYldCey.js +1 -0
- package/dist/assets/index-C0gmUFjA.css +1 -0
- package/dist/assets/{index-AxUq37Ea.js → index-C1syq_qI.js} +2 -2
- package/dist/assets/index-C4ONlwvw.js +6 -0
- package/dist/assets/index-C5CNHfZr.js +1 -0
- package/dist/assets/index-CB2VcZw_.js +768 -0
- package/dist/assets/index-CHBmUMgX.js +1 -0
- package/dist/assets/index-CJmuVRwK.js +1 -0
- package/dist/assets/{index-sA_45leD.js → index-CRPI_Ng7.js} +3 -3
- package/dist/assets/index-CXbdg8VR.js +1 -0
- package/dist/assets/index-CaGyGe4W.js +9 -0
- package/dist/assets/index-CeKRCUfE.js +1 -0
- package/dist/assets/{index-BYoh_mMo.js → index-Cm34goSF.js} +3 -3
- package/dist/assets/index-CrszoO0T.js +1 -0
- package/dist/assets/index-Cwocz_5B.js +1 -0
- package/dist/assets/index-DFacP-84.js +1 -0
- package/dist/assets/index-DGwGMNjJ.js +2 -0
- package/dist/assets/index-DHPND3oV.js +1 -0
- package/dist/assets/index-DUpo5A07.js +1 -0
- package/dist/assets/index-DoiB6EIi.js +1 -0
- package/dist/assets/index-DrYwq6CI.js +1 -0
- package/dist/assets/index-QZZ5Nw4M.js +1 -0
- package/dist/assets/{index-B4-_AJ5N.js → index-bdZbvws5.js} +16 -16
- package/dist/assets/index-dYyPNFFk.js +2 -0
- package/dist/assets/index-zeuBKIVA.js +6 -0
- package/dist/assets/{index.es-Dwfw0glc.js → index.es-Ddqnt5kx.js} +1 -1
- package/dist/assets/insert-business-trip-modal-5QaUlEPB.js +6 -0
- package/dist/assets/issue-document-n_B8vFIC.js +1 -0
- package/dist/assets/list-plus-CdX74KkH.js +6 -0
- package/dist/assets/login-page-C7kjnYWZ.js +1 -0
- package/dist/assets/match-document-modal-BhJxxCwh.js +16 -0
- package/dist/assets/missing-info-charges-CogpD4pD.js +1 -0
- package/dist/assets/modal-CWL2uL48.js +1 -0
- package/dist/assets/page-layout-Di4aGcKz.js +1 -0
- package/dist/assets/page-not-found-BzIsL96K.js +1 -0
- package/dist/assets/panel-top-open-QFGcJlh7.js +11 -0
- package/dist/assets/{pencil-CYypGy_s.js → pencil-MpkgghkS.js} +1 -1
- package/dist/assets/report-commentary-row-DVBtcPLr.js +1 -0
- package/dist/assets/{save-BE7zhMeq.js → save-C550A2xp.js} +1 -1
- package/dist/assets/similar-transactions-modal-CuhHSiYp.js +1 -0
- package/dist/assets/sub-BJ17PU-y.js +1 -0
- package/dist/assets/subMonths-ClZ3ESsy.js +1 -0
- package/dist/assets/summary-Boa5uC3b.js +1 -0
- package/dist/assets/switch-DXxPikE7.js +1 -0
- package/dist/assets/toggle-expansion-button-DmgIHP4k.js +1 -0
- package/dist/assets/tooltip-B387WRNk.js +1 -0
- package/dist/assets/use-url-query-BPBYbbPQ.js +1 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/components/business/contracts-section.tsx +0 -7
- package/src/components/business-transactions/business-extended-info.tsx +56 -53
- package/src/components/business-transactions/index.tsx +1 -28
- package/src/components/businesses/index.tsx +6 -2
- package/src/components/charges/cells/business-trip.tsx +6 -1
- package/src/components/charges/cells/counterparty.tsx +4 -28
- package/src/components/clients/contracts/modify-contract-dialog.tsx +3 -7
- package/src/components/common/business-trip-report/parts/core-expense-row.tsx +2 -2
- package/src/components/common/business-trip-report/parts/report-header.tsx +2 -1
- package/src/components/common/business-trip-report/parts/uncategorized-transactions.tsx +2 -2
- package/src/components/common/buttons/charge-navigate-button.tsx +12 -11
- package/src/components/common/modals/edit-charge-modal.tsx +2 -2
- package/src/components/common/modals/insert-document-modal.tsx +2 -2
- package/src/components/common/modals/match-document-modal.tsx +2 -2
- package/src/components/common/new-documents-list.tsx +2 -2
- package/src/components/documents-table/cells/creditor.tsx +2 -11
- package/src/components/documents-table/cells/debtor.tsx +2 -11
- package/src/components/ledger-table/counterparty-cell.tsx +4 -33
- package/src/components/reports/conto/index.tsx +1 -18
- package/src/components/reports/trial-balance-report/index.tsx +1 -17
- package/src/components/screens/businesses/business.tsx +0 -4
- package/src/components/screens/charges/all-charges.tsx +1 -17
- package/src/components/screens/charges/charge.tsx +0 -4
- package/src/components/screens/reports/balance-report/index.tsx +0 -14
- package/src/components/screens/reports/depreciation-report/index.tsx +0 -14
- package/src/components/transactions-table/cells/counterparty.tsx +2 -23
- package/src/components/transactions-table/cells-legacy/counterparty.tsx +3 -26
- package/src/gql/gql.ts +3 -3
- package/src/gql/graphql.ts +2 -5
- package/src/providers/urql.tsx +2 -2
- package/dist/assets/Typography-DPXB3hIS.js +0 -1
- package/dist/assets/accordion-UZwiz3fM.js +0 -1
- package/dist/assets/accountant-approvals-DDxSuMql.js +0 -1
- package/dist/assets/all-charges-BCP7OG1d.js +0 -1
- package/dist/assets/business-CBRlGy9p.js +0 -32
- package/dist/assets/business-transactions-single-DvPZFvmH.js +0 -1
- package/dist/assets/business-trip-g2hB76cn.js +0 -1
- package/dist/assets/charges-filters-T9c4RGLH.js +0 -1
- package/dist/assets/charges-ledger-validation-DaD8DCN4.js +0 -1
- package/dist/assets/editable-business-trip-B95j7iAh.js +0 -16
- package/dist/assets/index-5Fl36gjg.js +0 -1
- package/dist/assets/index-BDKAR_k1.js +0 -1
- package/dist/assets/index-BKXeyD9a.js +0 -1
- package/dist/assets/index-BPSZWRv9.js +0 -9
- package/dist/assets/index-BVetJA6_.js +0 -6
- package/dist/assets/index-BXp9NrWt.js +0 -1
- package/dist/assets/index-Br0-IMSG.js +0 -1
- package/dist/assets/index-Bw6OrQ7c.js +0 -1
- package/dist/assets/index-C3bFFbEz.js +0 -1
- package/dist/assets/index-CDIzaROV.js +0 -2
- package/dist/assets/index-CgQ4Qjvh.js +0 -886
- package/dist/assets/index-D4O5HA1y.js +0 -1
- package/dist/assets/index-DAbvR7_s.js +0 -1
- package/dist/assets/index-DkwmPZgt.js +0 -1
- package/dist/assets/index-DpsNoHLd.js +0 -2
- package/dist/assets/index-DtE5Y1ZB.css +0 -1
- package/dist/assets/index-k-cHMsFi.js +0 -1
- package/dist/assets/index-vkYxo-Uq.js +0 -1
- package/dist/assets/index-vstSRm8a.js +0 -1
- package/dist/assets/issue-document-umUFIxCu.js +0 -1
- package/dist/assets/login-page-Ck61EC35.js +0 -1
- package/dist/assets/missing-info-charges-aak-KkPt.js +0 -1
- package/dist/assets/page-not-found-Dzg-czJK.js +0 -1
- package/dist/assets/report-commentary-row-B479zk-x.js +0 -1
- package/dist/assets/sub-BxFupCKS.js +0 -1
- package/dist/assets/subMonths-DskeQPiN.js +0 -1
- package/src/components/charges/helpers.ts +0 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function i(o,u){return c=>{o?.(c),u?.(c)}}export{i as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{v as t,j as e,am as i,an as c,ao as o,ap as l,aq as r,B as n,gD as x,gE as d}from"./index-CB2VcZw_.js";/**
|
|
2
2
|
* @license lucide-react v0.546.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as t,da as d,db as i,B as p,ga as x,dc as h}from"./index-CB2VcZw_.js";function u(n,s){const e=new Uint8Array([239,187,191]),c=new Blob([e,n],{type:"text/csv;charset=UTF-8"}),a=URL.createObjectURL(c),o=document.createElement("a");o.href=a,o.download=`${s}.csv`,document.body.appendChild(o),o.click(),document.body.removeChild(o)}const m=({createFileVariables:n,buttonProps:s,buttonContent:e,label:c})=>{const a=r.useCallback(()=>{n().then(({fileContent:o,fileName:l})=>{u(o,l)})},[n]);return t.jsxs(d,{children:[t.jsx(i,{children:t.jsx(p,{variant:"outline",className:"p-2",...s,onClick:a,children:e||t.jsx(x,{size:20})})}),t.jsx(h,{children:t.jsx("p",{children:c||"Download CSV"})})]})};export{m as D};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{v as ve,bv as Ye,bw as Ze,r as p,bx as Ke,by as ie,a9 as Xe,bz as Qe,bA as Je,bB as es,j as e,B as v,L as Se,g as B,bC as ss,t as j,i as S,bD as Ie,u as ne,bE as ge,bm as b,bp as q,bF as ae,bG as Ne,a6 as ts,bn as L,bo as W,x as M,aU as Fe,bH as Me,l as V,T as w,ag as G,G as N,n as C,Q as I,W as z,X as P,Y as X,Z as $,I as Q,$ as _,aF as ze,bI as Y,d as Z,bJ as ns,bK as rs,bL as is,bg as D,bM as as,bN as Pe,bO as $e,J as A,bP as be,R as ye,bQ as os,bR as J,e as ee,bS as cs,bT as ds,bU as ls,bV as us,bl as Oe,bW as hs,bX as ps,bY as xs,bZ as Re,b_ as ms,b$ as gs,c0 as js,c1 as fs,c2 as vs,c3 as bs,c4 as ys,c5 as Ts,c6 as Es,c7 as Cs,c8 as As,c9 as ws,ca as Ds,cb as Bs,cc as Ss,cd as Is,ce as Ns,cf as Fs,cg as Ms,ch as zs,ci as Ps,cj as $s,ck as Os,cl as Rs,cm as ks,q as Hs,cn as _s,co as Us,cp as Vs,cq as Ls,cr as Ws,cs as fe,ct as qs,cu as Gs}from"./index-CB2VcZw_.js";import{L as ke}from"./list-plus-CdX74KkH.js";import{G as te,L as xe,C as He,R as Ys,A as E,S as Zs}from"./summary-Boa5uC3b.js";import{T as se}from"./Table-DiM_oZiR.js";import{T as Ks}from"./toggle-expansion-button-DmgIHP4k.js";import{M as _e}from"./MultiSelect-DyHLxout.js";import{S as je}from"./switch-DXxPikE7.js";import{u as Xs,S as Qs}from"./similar-transactions-modal-CuhHSiYp.js";import{T as Js}from"./tooltip-B387WRNk.js";/**
|
|
2
|
+
* @license lucide-react v0.546.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const et=[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]],st=ve("car",et);/**
|
|
7
|
+
* @license lucide-react v0.546.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const tt=[["path",{d:"M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 4 0v-6.998a2 2 0 0 0-.59-1.42L18 5",key:"1wtuz0"}],["path",{d:"M14 21V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v16",key:"e09ifn"}],["path",{d:"M2 21h13",key:"1x0fut"}],["path",{d:"M3 9h11",key:"1p7c0w"}]],nt=ve("fuel",tt);/**
|
|
12
|
+
* @license lucide-react v0.546.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const 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,Ue=Object.prototype.hasOwnProperty,Ve=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={}))Ue.call(n,r)&&Te(i,r,n[r]);if(me)for(var r of me(n))Ve.call(n,r)&&Te(i,r,n[r]);return i},dt=(i,n)=>{var r={};for(var t in i)Ue.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&&Ve.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(Qe,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"),_n=({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 Le({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:U=>k.onChange(U&&typeof U=="number"?U: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:L,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:L,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}]=V(!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(Q,{...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(Le,{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}]=V(!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:L,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:L,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(Q,{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(Le,{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}]=V(!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:L,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:L,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(Q,{...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}]=V(!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(Vt,{businessTripId:n,opened:t,close:s,onAdd:r})]})}const Ut=Object.entries(Re).map(([i,n])=>({value:n,label:i}));function Vt({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:Ut,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 Lt="updateBusinessTripFlightsExpense",Wt=()=>{const[{fetching:i},n]=B(ms),r=p.useCallback(async t=>{const s="Error updating business trip flights expense",a=Lt;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:L,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:L,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}]=V(!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 Qt="updateBusinessTripCarRentalExpense",Jt=()=>{const[{fetching:i},n]=B(ys),r=p.useCallback(async t=>{const s="Error updating business trip car rental expense",a=Qt;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(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(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}]=V(!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(Q,{...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(Q,{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}]=V(!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(Q,{...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(Q,{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}=Xs(),T=p.useCallback(async U=>{await g({transactionId:o,fields:{counterpartyId:U}}),u(!0)},[o,g]),y=p.useCallback(async U=>{await T(U),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:U=>U.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(Qs,{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}]=V(!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(Us).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(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:"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(Ls,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}]=V(!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 Un({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,Un as E,_n as P};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{v as e}from"./index-CB2VcZw_.js";/**
|
|
2
|
+
* @license lucide-react v0.546.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const n=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],a=e("funnel",n);export{a as F};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{v as z,r as b,bl as U,j as e,D as W,af as G,B as g,z as Q,ah as J,ai as K,b5 as D,aD as X,aY as R,am as A,an as O,ao as k,ap as E,aq as T,cr as Z,J as j,bc as w,fW as M,fX as ee,fY as S,fZ as se,f_ as I,f$ as L,g0 as B,g1 as N,g2 as p,g3 as P,g4 as Y,de as re,g5 as te,b7 as ae,b8 as le,b9 as v,g6 as V,F as de,u as ne,K as oe,N as ce,V as ie,g7 as me}from"./index-CB2VcZw_.js";import{F as $}from"./funnel-BjNIVF6D.js";import{B as ue}from"./building-2-CSNfw8ff.js";import{S as xe}from"./save-C550A2xp.js";/**
|
|
2
2
|
* @license lucide-react v0.546.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const he=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],be=U("eye-off",he),y=["2020","2021","2022","2023"];function je({selectedBusiness:t,setSelectedBusiness:d,selectedYear:s,setSelectedYear:c,referenceYear:l,setReferenceYear:o}){const[n,r]=b.useState(!s||!t),{selectableBusinesses:a,fetching:i}=W(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(z,{open:n,onOpenChange:r,children:[e.jsx(G,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(Q,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(X,{children:e.jsxs(Z,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(K,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(O,{value:s,onValueChange:c,children:[e.jsx(k,{id:"year-select",children:e.jsx(M,{})}),e.jsx(E,{children:y.map(x=>e.jsx(D,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",y.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(O,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(k,{id:"reference-year-select",children:e.jsx(M,{})}),e.jsxs(E,{children:[e.jsx(D,{value:"none",children:"ללא"},"none"),y.map(x=>e.jsx(D,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",y.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const u=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=H=>Number.parseFloat(H.replace(/[,\s₪]/g,""))||0,q=f(h),F=f(x);return F===0?null:(q-F)/F*100};if(!n(d))return null;const i=o?a(d,c):null;return e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-gray-200",dir:"rtl",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[t," ",s&&`(${s})`]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r(d)?"text-gray-400":""}`,children:r(d)?"0":d}),i!==null&&e.jsxs("span",{className:`text-xs px-1 py-0.5 rounded ${i>0?"text-green-700 bg-green-100":i<0?"text-red-700 bg-red-100":"text-gray-700 bg-gray-100"}`,children:[i>0?"+":"",i.toFixed(1),"%"]})]})]})},m=({codes:t,referenceCodes:d,code:s,showEmptyFields:c})=>{const{value:l,label:o}=b.useMemo(()=>{const r=t.find(a=>a.code===s);return{value:r?.amount||0,label:r?.label||"לא זוהה קוד"}},[t,s]),n=b.useMemo(()=>d?.find(r=>r.code===s)?.amount.toString()||"",[d,s]);return e.jsx(u,{label:o,value:J(l,0),code:String(s),showChange:!0,showEmptyFields:c,referenceValue:n})},pe=[{title:"מזומנים ושווי מזומנים",codes:[7110,7120,7150],sumCode:7100},{title:"ניירות ערך",codes:[7215,7225,7230,7290,7295],sumCode:7200},{title:"לקוחות",codes:[7310,7320,7330,7350,7360,7380,7390],sumCode:7300},{title:"חייבים ויתרות חובה",codes:[7410,7420,7430,7440,7450,7461,7462,7470,7490],sumCode:7400},{title:"מסים נדחים לזמן קצר",codes:[7610,7620,7690],sumCode:7600},{title:"הלוואות לזמן קצר",codes:[7711,7712,7720],sumCode:7700},{title:"מלאי",codes:[7805,7810,7815,7820,7825,7830,7840,7850,7860,7870,7890],sumCode:7800}],ge=[{title:"רכוש קבוע",codes:[8010,8020,8025,8030,8040,8050,8060,8080,8090,8095,8100,8105,8110,8120,8130,8140,8150,8160,8170,8180,8190],sumCode:8e3},{title:"נכסים לא שוטפים מוחזקים למכירה",codes:[8710],sumCode:8700},{title:"הוצאות מראש לזמן ארוך",codes:[8210,8220,8290],sumCode:8200},{title:"השקעות בחברות מוחזקות כלולות ומאוחדות",codes:[8315,8325,8335,8340,8350],sumCode:8300},{title:'השקעות בחברות אחרות כולל ני"ע סחירים מוחזקים לזמן ארוך',codes:[8410,8420,8440,8450,8460,8490],sumCode:8400},{title:"מסים נדחים לזמן ארוך",codes:[8510,8520,8590],sumCode:8500},{title:"הוצאות נדחות ורכוש אחר",codes:[8610,8620,8630,8640,8690],sumCode:8600}],fe=[{title:"בנקים והלואות לזמן קצר",codes:[9110,9120,9130,9140,9151,9152,9190],sumCode:9100},{title:"ספקים ונותני שירותים",codes:[9210,9220,9230,9290],sumCode:9200},{title:"זכאים ויתרות זכות",codes:[9310,9320,9330,9340,9350,9360,9370,9410,9420,9431,9432,9435,9440,9450,9460,9470,9480,9490],sumCode:9400},{title:"עתודה למסים נדחים לזמן קצר",codes:[9510,9520,9530],sumCode:9500}],Ne=[{title:"התחייבויות לזמן ארוך",codes:[9605,9610,9620,9631,9632,9640,9650,9660,9670,9690],sumCode:9600},{title:"התחייבויות בשל סיום יחסי עובד-מעביד",codes:[9710,9720,9790],sumCode:9700},{title:"עתודה למסים נדחים לזמן ארוך",codes:[9810,9820,9890],sumCode:9800}],ve=[{title:"הון עצמי",codes:[9910,9920,9930,9940,9950,9960,9980],sumCode:9900}];function ye({data:t,referenceData:d,showEmptyFields:s=!1}){const l=j(I,t).balanceSheet||[],n=j(I,d)?.balanceSheet||[];return e.jsx(w,{value:"balanceSheet",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני המאזן"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-blue-800 border-b pb-2",children:"נכסים"}),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx("h5",{className:"font-bold",children:"רכוש שוטף"})}),pe.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(m,{codes:l,code:7e3,showEmptyFields:s})}),ge.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(m,{codes:l,code:8888,showEmptyFields:s})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-red-800 border-b pb-2",children:"התחייבויות והון"}),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx("h5",{className:"font-bold",children:"התחייבויות שוטפות"})}),fe.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(m,{codes:l,code:9e3,showEmptyFields:s})}),Ne.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),ve.map(r=>e.jsxs("div",{className:"bg-green-50 p-4 rounded-md",children:[e.jsx("h5",{className:"font-bold mb-3",children:r.title}),e.jsx("div",{className:"space-y-2",children:r.codes.map(a=>e.jsx(m,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a))})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(m,{codes:l,code:9999,showEmptyFields:s})})]})]})]})})}const Ce=t=>{switch(t){case"1":return"תעשייתי";case"2":return"מסחרי";case"3":return"נותני שירותים";case"99":return"הדיווח כולל יותר מעסק אחד";default:return""}},Se=t=>{switch(t){case S.Cash:return"מזומן";case S.Accrual:return"מצטבר";case S.DollarRegulations:return"לפי תקנות דולריות";default:return""}},we=t=>{switch(t){case L.Shekels:return"שקלים";case L.Dollars:return"דולרים";default:return""}},Fe=t=>{switch(t){case B.DoubleEntry:return"כפולה";case B.SingleEntry:return"חד-צידית";default:return""}},Te=t=>{switch(t){case P.Computerized:return"ממוחשב";case P.Manual:return"ידני";default:return""}},De=t=>{switch(t){case N.Option_1:return"חלופה 1";case N.Option_2Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010";case N.Option_3Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010";case N.None:return"ללא חלופה";default:return""}},Re=t=>{switch(t){case p.Unqualified:return"נוסח אחיד (בלתי מסוייג)";case p.UnqualifiedWithGoingConcern:return"בנוסח אחיד עם הפניית תשומת לב להערת עסק חי";case p.UnqualifiedWithOtherEmphases:return"בנוסח אחיד עם הפניות תשומת לב אחרת";case p.Qualified:return"הסתייגות";case p.Adverse:return"שלילית";case p.Disclaimer:return"המנעות";case p.None:return"אין חוות דעת";default:return""}},C=t=>t==null?"":t?"כן":"לא";function Ae({data:t,businessInfo:d}){const{header:s}=j(ee,t),c=j(se,d);return e.jsx(w,{value:"header",className:"border rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",dir:"rtl",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטים מזהים"}),e.jsx(u,{label:"השם הרשום",value:c.name,showEmptyFields:!0}),e.jsx(u,{label:"תיאור העיסוק המדווח",value:s.businessDescription??"",showEmptyFields:!0}),e.jsx(u,{label:"מספר זהות",value:s.idNumber,showEmptyFields:!0}),e.jsx(u,{label:"מספר תיק",value:s.taxFileNumber,showEmptyFields:!0}),e.jsx(u,{label:'תיק מדווח למע"מ',value:s.vatFileNumber??"",showEmptyFields:!0}),e.jsx(u,{label:"מספר תיק ניכויים",value:s.withholdingTaxFileNumber??"",showEmptyFields:!0})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטי העסק"}),e.jsx(u,{value:Ce(s.businessType),label:"סוג העסק המדווח",showEmptyFields:!0}),e.jsx(u,{label:"שיטת דיווח",value:Se(s.reportingMethod),showEmptyFields:!0}),s.reportingMethod===S.DollarRegulations&&e.jsx(u,{label:"מטבע הסכומים",value:we(s.currencyType),showEmptyFields:!0}),e.jsx(u,{label:"הסכום באלפים",value:C(s.amountsInThousands),showEmptyFields:!0}),e.jsx(u,{label:"שיטת חשבונאות",value:Fe(s.accountingMethod),showEmptyFields:!0}),e.jsx(u,{label:"הנהלת חשבונות",value:Te(s.accountingSystem),showEmptyFields:!0}),e.jsx(u,{label:"חייב ברישום תוכנה",value:C(!!s.softwareRegistrationNumber),showEmptyFields:!0}),s.softwareRegistrationNumber&&e.jsx(u,{label:"מספר תעודת רישום",value:s.softwareRegistrationNumber,showEmptyFields:!0}),e.jsx(u,{label:"דוח בגין שותפות",value:C(!!s.isPartnership),showEmptyFields:!0}),s.isPartnership&&e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"מספר שותפים",value:s.partnershipCount?.toString()??"",showEmptyFields:!0}),e.jsx(u,{label:"חלקי ברווחי השותפות",value:`${s.partnershipProfitShare}%`,showEmptyFields:!0})]}),e.jsx(u,{label:"יישום תקני חשבונאות (IFRS)",value:C(!!s.ifrsImplementationYear||!!s.ifrsReportingOption),showEmptyFields:!0}),(!!s.ifrsImplementationYear||!!s.ifrsReportingOption)&&e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"החל משנת המס",value:s.ifrsImplementationYear??"",showEmptyFields:!0}),e.jsx(u,{label:"דווח בחלופה",value:De(s.ifrsReportingOption),showEmptyFields:!0})]}),e.jsx(u,{label:"מספר ענף כלכלי של המדווח",value:s.industryCode,showEmptyFields:!0}),e.jsx(u,{label:"חוות דעת המבקר",value:Re(s.auditOpinionType),showEmptyFields:!0})]})]})})}const Oe=[{title:"הכנסות ממכירות ומתן שירותים",color:"text-blue-700",codes:[1010,1015,1020,1025,1030,1040,1051,1052,1090],sumCode:1e3},{title:"עלות המכירות ומתן השירותים וביצוע עבודות",color:"text-purple-700",codes:[1306,1308,1307,1310,1320,1330,1340,1350,1360,1371,1372,1390,1400,1450],sumCode:1300},{title:"עלויות ייצור ועלויות אצל קבלן בונה",color:"text-rose-700",codes:[2005,2006,2011,2012,2015,2020,2025,2030,2035,2040,2045,2050,2060,2066,2067,2068,2070,2075,2080,2085,2090,2095],sumCode:2e3},{title:"הוצאות מחקר ופיתוח",color:"text-amber-700",codes:[2510,2520,2530,2540,2550,2560,2570,2590],sumCode:2500},{title:"הוצאות מכירה",color:"text-green-700",codes:[3011,3013,3012,3015,3020,3025,3030,3040,3045,3050,3060,3066,3067,3068,3070,3075,3080,3085,3090,3100,3120,3190],sumCode:3e3},{title:"הוצאות הנהלה וכלליות",color:"text-cyan-700",codes:[3511,3513,3512,3515,3520,3530,3535,3540,3545,3550,3560,3566,3567,3568,3570,3575,3580,3590,3595,3600,3610,3620,3625,3631,3632,3640,3650,3660,3665,3680,3685,3690],sumCode:3500},{title:"הוצאות מימון",color:"text-indigo-700",codes:[5010,5020,5025,5030,5040,5050,5051,5090],sumCode:5e3},{title:"הכנסות מימון",color:"text-fuchsia-700",codes:[5110,5121,5122,5130,5150,5160,5190],sumCode:5100},{title:"הכנסות אחרות",color:"text-red-700",codes:[5210,5220,5230,5236,5237,5240,5250,5260,5270,5290],sumCode:5200},{title:"הוצאות אחרות",color:"text-yellow-700",codes:[5310,5320,5330,5390],sumCode:5300}],ke=[{title:"מסים על הכנסה",color:"text-sky-700",codes:[5610,5620,5630],sumCode:5600},{title:"ייעוד הרווחים",color:"text-violet-700",codes:[5710],sumCode:5700},{title:"רווח/הפסד אקויטי",color:"text-pink-700",codes:[5810],sumCode:5800}];function Me({selectedYear:t,referenceYear:d,data:s,referenceData:c,showEmptyFields:l=!1}){const{profitAndLoss:o}=j(Y,s),r=j(Y,c)?.profitAndLoss||[];return e.jsx(w,{value:"profitLoss",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני רווח והפסד"}),d&&t!==d&&e.jsxs("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded",children:["מציג שינויים לעומת ",d]})]}),Oe.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(m,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title)),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(m,{codes:o,referenceCodes:r,code:6666,showEmptyFields:l})}),ke.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(m,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(m,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title))]})})}const Ee=[{title:"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010 בנושא IFRS",color:"red",codes:[103,104]},{title:"התאמות נדרשות לצרכי מס (הוסף/הפחת)",color:"yellow",codes:[110,120,130,135,140,150,160,170,180,181,182,183,184,190,200,300,310,320,330,350,360],sumCode:370},{title:"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010 בנושא IFRS שלא מצאו את ביטויין בהתאמות הנדרשות לצרכי מס",color:"emerald",codes:[383],sumCode:400},{title:"יישום הוראות חוקי מס נוספים",color:"sky",codes:[430,480,490],sumCode:500},{title:"נתונים נוספים",color:"violet",codes:[510,520,530,540,550,570,575,580,585,590]},{title:"בשותפות",color:"pink",codes:[600]}],_={red:{header:"text-red-700",sum:"bg-red-50 border-red-200"},yellow:{header:"text-yellow-700",sum:"bg-yellow-50 border-yellow-200"},emerald:{header:"text-emerald-700",sum:"bg-emerald-50 border-emerald-200"},sky:{header:"text-sky-700",sum:"bg-sky-50 border-sky-200"},violet:{header:"text-violet-700",sum:"bg-violet-50 border-violet-200"},pink:{header:"text-pink-700",sum:"bg-pink-50 border-pink-200"}};function Ie({data:t,referenceData:d,showEmptyFields:s=!1}){const{taxAdjustment:c}=j(V,t),o=j(V,d)?.taxAdjustment||[];return e.jsx(w,{value:"taxAdjustment",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:'נתוני דו"ח התאמה למס'}),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(m,{codes:c,referenceCodes:o,code:100,showEmptyFields:s})}),Ee.map(n=>{const{header:r,sum:a}=_[n.color]||_.red;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:"font-bold mb-4 "+r,children:n.title}),e.jsx("div",{className:"space-y-2",children:n.codes.map(i=>e.jsx(m,{codes:c,referenceCodes:o,code:i,showEmptyFields:s},i))})]}),n.sumCode&&e.jsx("div",{className:"p-4 rounded-md border-2 "+a,children:e.jsx(m,{codes:c,referenceCodes:o,code:n.sumCode,showEmptyFields:s})})]},n.title)})]})})}function Le({data:t,referenceData:d,businessInfo:s,selectedYear:c,referenceYear:l}){const o=j($,t),n=j($,d),[r,a]=b.useState("header"),[i,h]=b.useState(!0);return e.jsxs("div",{className:"p-4 border-gray-300",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:i?"outline":"default",size:"sm",onClick:()=>h(!i),className:"flex items-center gap-2",children:[i?e.jsx(be,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),i?"הסתר שדות ריקים":"הצג שדות ריקים"]}),e.jsx("span",{className:"text-sm text-gray-500",children:i?"מציג את כל השדות":"מציג רק שדות עם נתונים"})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"הורד"]}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"שמור"]})]})]}),e.jsxs(ae,{value:r,onValueChange:a,className:"w-full",children:[e.jsxs(le,{className:"grid grid-cols-4 w-full",dir:"rtl",children:[e.jsx(v,{value:"header",children:"פרטים מזהים"}),e.jsx(v,{value:"profitLoss",children:"רווח והפסד"}),e.jsx(v,{value:"taxAdjustment",children:"התאמה למס"}),e.jsx(v,{value:"balanceSheet",children:"מאזן"})]}),e.jsx(Ae,{data:o,businessInfo:s}),e.jsx(Me,{selectedYear:c,referenceYear:l,data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ie,{data:o,referenceData:n,showEmptyFields:i}),e.jsx(ye,{data:o,referenceData:n,showEmptyFields:i})]})]})}function _e(){const{setFiltersContext:t}=b.useContext(de),[d,s]=b.useState(void 0),[c,l]=b.useState(void 0),[o,n]=b.useState(void 0),[{data:r,fetching:a}]=ne({query:ue,variables:{year:c?Number.parseInt(c,10):0,businessId:d},pause:!c||!d});return b.useEffect(()=>{t(e.jsx("div",{className:"flex flex-row gap-x-5",dir:"rtl",children:e.jsx(je,{selectedBusiness:d,setSelectedBusiness:s,selectedYear:c,setSelectedYear:l,referenceYear:o,setReferenceYear:n})}))},[t,d,c,o]),e.jsx("div",{className:"container mx-auto",dir:"rtl",children:e.jsxs(oe,{className:"border-2 border-gray-300",children:[e.jsx(ce,{className:"bg-gray-100 border-b-2 border-gray-300 flex flex-row justify-between items-center",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("h1",{className:"text-2xl font-bold",children:'נספח לטופס הדו"ח השנתי ליחיד ולחבר בני אדם'}),e.jsxs("h2",{className:"text-xl",children:["לשנת המס ",c]}),e.jsx("p",{className:"text-sm",children:'נתוני הדוחות הכספיים, מאזן, רווח והפסד ודו"ח ההתאמה למס'})]})}),e.jsx(ie,{className:"p-0",children:e.jsx(Be,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Be({fetching:t,data:d,selectedBusiness:s,selectedYear:c,referenceYear:l}){if(t)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"טוען נתונים..."})});if(!c||!s)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"יש לבחור עסק ושנת דיווח"})});const o=d?.shaam6111.data;return o?e.jsx(Le,{data:o,businessInfo:d.shaam6111.business,selectedBusiness:s,selectedYear:c,referenceYear:l}):e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"אין נתונים זמינים עבור העסק והשנה שנבחרו"})})}export{_e as Shaam6111Report};
|
|
6
|
+
*/const he=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],be=z("eye-off",he),C=["2020","2021","2022","2023"];function je({selectedBusiness:t,setSelectedBusiness:d,selectedYear:s,setSelectedYear:c,referenceYear:l,setReferenceYear:o}){const[n,r]=b.useState(!s||!t),{selectableBusinesses:a,fetching:i}=U(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(W,{open:n,onOpenChange:r,children:[e.jsx(G,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx($,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(Q,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(J,{children:e.jsxs(K,{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(X,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(A,{value:s,onValueChange:c,children:[e.jsx(O,{id:"year-select",children:e.jsx(k,{})}),e.jsx(E,{children:C.map(x=>e.jsx(T,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(A,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(O,{id:"reference-year-select",children:e.jsx(k,{})}),e.jsxs(E,{children:[e.jsx(T,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(T,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const m=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=H=>Number.parseFloat(H.replace(/[,\s₪]/g,""))||0,q=f(h),F=f(x);return F===0?null:(q-F)/F*100};if(!n(d))return null;const i=o?a(d,c):null;return e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-gray-200",dir:"rtl",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[t," ",s&&`(${s})`]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r(d)?"text-gray-400":""}`,children:r(d)?"0":d}),i!==null&&e.jsxs("span",{className:`text-xs px-1 py-0.5 rounded ${i>0?"text-green-700 bg-green-100":i<0?"text-red-700 bg-red-100":"text-gray-700 bg-gray-100"}`,children:[i>0?"+":"",i.toFixed(1),"%"]})]})]})},u=({codes:t,referenceCodes:d,code:s,showEmptyFields:c})=>{const{value:l,label:o}=b.useMemo(()=>{const r=t.find(a=>a.code===s);return{value:r?.amount||0,label:r?.label||"לא זוהה קוד"}},[t,s]),n=b.useMemo(()=>d?.find(r=>r.code===s)?.amount.toString()||"",[d,s]);return e.jsx(m,{label:o,value:Z(l,0),code:String(s),showChange:!0,showEmptyFields:c,referenceValue:n})},pe=[{title:"מזומנים ושווי מזומנים",codes:[7110,7120,7150],sumCode:7100},{title:"ניירות ערך",codes:[7215,7225,7230,7290,7295],sumCode:7200},{title:"לקוחות",codes:[7310,7320,7330,7350,7360,7380,7390],sumCode:7300},{title:"חייבים ויתרות חובה",codes:[7410,7420,7430,7440,7450,7461,7462,7470,7490],sumCode:7400},{title:"מסים נדחים לזמן קצר",codes:[7610,7620,7690],sumCode:7600},{title:"הלוואות לזמן קצר",codes:[7711,7712,7720],sumCode:7700},{title:"מלאי",codes:[7805,7810,7815,7820,7825,7830,7840,7850,7860,7870,7890],sumCode:7800}],ge=[{title:"רכוש קבוע",codes:[8010,8020,8025,8030,8040,8050,8060,8080,8090,8095,8100,8105,8110,8120,8130,8140,8150,8160,8170,8180,8190],sumCode:8e3},{title:"נכסים לא שוטפים מוחזקים למכירה",codes:[8710],sumCode:8700},{title:"הוצאות מראש לזמן ארוך",codes:[8210,8220,8290],sumCode:8200},{title:"השקעות בחברות מוחזקות כלולות ומאוחדות",codes:[8315,8325,8335,8340,8350],sumCode:8300},{title:'השקעות בחברות אחרות כולל ני"ע סחירים מוחזקים לזמן ארוך',codes:[8410,8420,8440,8450,8460,8490],sumCode:8400},{title:"מסים נדחים לזמן ארוך",codes:[8510,8520,8590],sumCode:8500},{title:"הוצאות נדחות ורכוש אחר",codes:[8610,8620,8630,8640,8690],sumCode:8600}],fe=[{title:"בנקים והלואות לזמן קצר",codes:[9110,9120,9130,9140,9151,9152,9190],sumCode:9100},{title:"ספקים ונותני שירותים",codes:[9210,9220,9230,9290],sumCode:9200},{title:"זכאים ויתרות זכות",codes:[9310,9320,9330,9340,9350,9360,9370,9410,9420,9431,9432,9435,9440,9450,9460,9470,9480,9490],sumCode:9400},{title:"עתודה למסים נדחים לזמן קצר",codes:[9510,9520,9530],sumCode:9500}],Ne=[{title:"התחייבויות לזמן ארוך",codes:[9605,9610,9620,9631,9632,9640,9650,9660,9670,9690],sumCode:9600},{title:"התחייבויות בשל סיום יחסי עובד-מעביד",codes:[9710,9720,9790],sumCode:9700},{title:"עתודה למסים נדחים לזמן ארוך",codes:[9810,9820,9890],sumCode:9800}],ve=[{title:"הון עצמי",codes:[9910,9920,9930,9940,9950,9960,9980],sumCode:9900}];function Ce({data:t,referenceData:d,showEmptyFields:s=!1}){const l=j(M,t).balanceSheet||[],n=j(M,d)?.balanceSheet||[];return e.jsx(w,{value:"balanceSheet",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני המאזן"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-blue-800 border-b pb-2",children:"נכסים"}),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx("h5",{className:"font-bold",children:"רכוש שוטף"})}),pe.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:7e3,showEmptyFields:s})}),ge.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:8888,showEmptyFields:s})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-red-800 border-b pb-2",children:"התחייבויות והון"}),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx("h5",{className:"font-bold",children:"התחייבויות שוטפות"})}),fe.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9e3,showEmptyFields:s})}),Ne.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),ve.map(r=>e.jsxs("div",{className:"bg-green-50 p-4 rounded-md",children:[e.jsx("h5",{className:"font-bold mb-3",children:r.title}),e.jsx("div",{className:"space-y-2",children:r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a))})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9999,showEmptyFields:s})})]})]})]})})}const ye=t=>{switch(t){case"1":return"תעשייתי";case"2":return"מסחרי";case"3":return"נותני שירותים";case"99":return"הדיווח כולל יותר מעסק אחד";default:return""}},Se=t=>{switch(t){case S.Cash:return"מזומן";case S.Accrual:return"מצטבר";case S.DollarRegulations:return"לפי תקנות דולריות";default:return""}},we=t=>{switch(t){case I.Shekels:return"שקלים";case I.Dollars:return"דולרים";default:return""}},Fe=t=>{switch(t){case L.DoubleEntry:return"כפולה";case L.SingleEntry:return"חד-צידית";default:return""}},De=t=>{switch(t){case B.Computerized:return"ממוחשב";case B.Manual:return"ידני";default:return""}},Te=t=>{switch(t){case N.Option_1:return"חלופה 1";case N.Option_2Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010";case N.Option_3Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010";case N.None:return"ללא חלופה";default:return""}},Re=t=>{switch(t){case p.Unqualified:return"נוסח אחיד (בלתי מסוייג)";case p.UnqualifiedWithGoingConcern:return"בנוסח אחיד עם הפניית תשומת לב להערת עסק חי";case p.UnqualifiedWithOtherEmphases:return"בנוסח אחיד עם הפניות תשומת לב אחרת";case p.Qualified:return"הסתייגות";case p.Adverse:return"שלילית";case p.Disclaimer:return"המנעות";case p.None:return"אין חוות דעת";default:return""}},y=t=>t==null?"":t?"כן":"לא";function Ae({data:t,businessInfo:d}){const{header:s}=j(ee,t),c=j(se,d);return e.jsx(w,{value:"header",className:"border rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",dir:"rtl",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטים מזהים"}),e.jsx(m,{label:"השם הרשום",value:c.name,showEmptyFields:!0}),e.jsx(m,{label:"תיאור העיסוק המדווח",value:s.businessDescription??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר זהות",value:s.idNumber,showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק",value:s.taxFileNumber,showEmptyFields:!0}),e.jsx(m,{label:'תיק מדווח למע"מ',value:s.vatFileNumber??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק ניכויים",value:s.withholdingTaxFileNumber??"",showEmptyFields:!0})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטי העסק"}),e.jsx(m,{value:ye(s.businessType),label:"סוג העסק המדווח",showEmptyFields:!0}),e.jsx(m,{label:"שיטת דיווח",value:Se(s.reportingMethod),showEmptyFields:!0}),s.reportingMethod===S.DollarRegulations&&e.jsx(m,{label:"מטבע הסכומים",value:we(s.currencyType),showEmptyFields:!0}),e.jsx(m,{label:"הסכום באלפים",value:y(s.amountsInThousands),showEmptyFields:!0}),e.jsx(m,{label:"שיטת חשבונאות",value:Fe(s.accountingMethod),showEmptyFields:!0}),e.jsx(m,{label:"הנהלת חשבונות",value:De(s.accountingSystem),showEmptyFields:!0}),e.jsx(m,{label:"חייב ברישום תוכנה",value:y(!!s.softwareRegistrationNumber),showEmptyFields:!0}),s.softwareRegistrationNumber&&e.jsx(m,{label:"מספר תעודת רישום",value:s.softwareRegistrationNumber,showEmptyFields:!0}),e.jsx(m,{label:"דוח בגין שותפות",value:y(!!s.isPartnership),showEmptyFields:!0}),s.isPartnership&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"מספר שותפים",value:s.partnershipCount?.toString()??"",showEmptyFields:!0}),e.jsx(m,{label:"חלקי ברווחי השותפות",value:`${s.partnershipProfitShare}%`,showEmptyFields:!0})]}),e.jsx(m,{label:"יישום תקני חשבונאות (IFRS)",value:y(!!s.ifrsImplementationYear||!!s.ifrsReportingOption),showEmptyFields:!0}),(!!s.ifrsImplementationYear||!!s.ifrsReportingOption)&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"החל משנת המס",value:s.ifrsImplementationYear??"",showEmptyFields:!0}),e.jsx(m,{label:"דווח בחלופה",value:Te(s.ifrsReportingOption),showEmptyFields:!0})]}),e.jsx(m,{label:"מספר ענף כלכלי של המדווח",value:s.industryCode,showEmptyFields:!0}),e.jsx(m,{label:"חוות דעת המבקר",value:Re(s.auditOpinionType),showEmptyFields:!0})]})]})})}const Oe=[{title:"הכנסות ממכירות ומתן שירותים",color:"text-blue-700",codes:[1010,1015,1020,1025,1030,1040,1051,1052,1090],sumCode:1e3},{title:"עלות המכירות ומתן השירותים וביצוע עבודות",color:"text-purple-700",codes:[1306,1308,1307,1310,1320,1330,1340,1350,1360,1371,1372,1390,1400,1450],sumCode:1300},{title:"עלויות ייצור ועלויות אצל קבלן בונה",color:"text-rose-700",codes:[2005,2006,2011,2012,2015,2020,2025,2030,2035,2040,2045,2050,2060,2066,2067,2068,2070,2075,2080,2085,2090,2095],sumCode:2e3},{title:"הוצאות מחקר ופיתוח",color:"text-amber-700",codes:[2510,2520,2530,2540,2550,2560,2570,2590],sumCode:2500},{title:"הוצאות מכירה",color:"text-green-700",codes:[3011,3013,3012,3015,3020,3025,3030,3040,3045,3050,3060,3066,3067,3068,3070,3075,3080,3085,3090,3100,3120,3190],sumCode:3e3},{title:"הוצאות הנהלה וכלליות",color:"text-cyan-700",codes:[3511,3513,3512,3515,3520,3530,3535,3540,3545,3550,3560,3566,3567,3568,3570,3575,3580,3590,3595,3600,3610,3620,3625,3631,3632,3640,3650,3660,3665,3680,3685,3690],sumCode:3500},{title:"הוצאות מימון",color:"text-indigo-700",codes:[5010,5020,5025,5030,5040,5050,5051,5090],sumCode:5e3},{title:"הכנסות מימון",color:"text-fuchsia-700",codes:[5110,5121,5122,5130,5150,5160,5190],sumCode:5100},{title:"הכנסות אחרות",color:"text-red-700",codes:[5210,5220,5230,5236,5237,5240,5250,5260,5270,5290],sumCode:5200},{title:"הוצאות אחרות",color:"text-yellow-700",codes:[5310,5320,5330,5390],sumCode:5300}],ke=[{title:"מסים על הכנסה",color:"text-sky-700",codes:[5610,5620,5630],sumCode:5600},{title:"ייעוד הרווחים",color:"text-violet-700",codes:[5710],sumCode:5700},{title:"רווח/הפסד אקויטי",color:"text-pink-700",codes:[5810],sumCode:5800}];function Ee({selectedYear:t,referenceYear:d,data:s,referenceData:c,showEmptyFields:l=!1}){const{profitAndLoss:o}=j(P,s),r=j(P,c)?.profitAndLoss||[];return e.jsx(w,{value:"profitLoss",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני רווח והפסד"}),d&&t!==d&&e.jsxs("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded",children:["מציג שינויים לעומת ",d]})]}),Oe.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title)),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:o,referenceCodes:r,code:6666,showEmptyFields:l})}),ke.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title))]})})}const Me=[{title:"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010 בנושא IFRS",color:"red",codes:[103,104]},{title:"התאמות נדרשות לצרכי מס (הוסף/הפחת)",color:"yellow",codes:[110,120,130,135,140,150,160,170,180,181,182,183,184,190,200,300,310,320,330,350,360],sumCode:370},{title:"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010 בנושא IFRS שלא מצאו את ביטויין בהתאמות הנדרשות לצרכי מס",color:"emerald",codes:[383],sumCode:400},{title:"יישום הוראות חוקי מס נוספים",color:"sky",codes:[430,480,490],sumCode:500},{title:"נתונים נוספים",color:"violet",codes:[510,520,530,540,550,570,575,580,585,590]},{title:"בשותפות",color:"pink",codes:[600]}],_={red:{header:"text-red-700",sum:"bg-red-50 border-red-200"},yellow:{header:"text-yellow-700",sum:"bg-yellow-50 border-yellow-200"},emerald:{header:"text-emerald-700",sum:"bg-emerald-50 border-emerald-200"},sky:{header:"text-sky-700",sum:"bg-sky-50 border-sky-200"},violet:{header:"text-violet-700",sum:"bg-violet-50 border-violet-200"},pink:{header:"text-pink-700",sum:"bg-pink-50 border-pink-200"}};function Ie({data:t,referenceData:d,showEmptyFields:s=!1}){const{taxAdjustment:c}=j(Y,t),o=j(Y,d)?.taxAdjustment||[];return e.jsx(w,{value:"taxAdjustment",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:'נתוני דו"ח התאמה למס'}),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:c,referenceCodes:o,code:100,showEmptyFields:s})}),Me.map(n=>{const{header:r,sum:a}=_[n.color]||_.red;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:"font-bold mb-4 "+r,children:n.title}),e.jsx("div",{className:"space-y-2",children:n.codes.map(i=>e.jsx(u,{codes:c,referenceCodes:o,code:i,showEmptyFields:s},i))})]}),n.sumCode&&e.jsx("div",{className:"p-4 rounded-md border-2 "+a,children:e.jsx(u,{codes:c,referenceCodes:o,code:n.sumCode,showEmptyFields:s})})]},n.title)})]})})}function Le({data:t,referenceData:d,businessInfo:s,selectedYear:c,referenceYear:l}){const o=j(V,t),n=j(V,d),[r,a]=b.useState("header"),[i,h]=b.useState(!0);return e.jsxs("div",{className:"p-4 border-gray-300",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:i?"outline":"default",size:"sm",onClick:()=>h(!i),className:"flex items-center gap-2",children:[i?e.jsx(be,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),i?"הסתר שדות ריקים":"הצג שדות ריקים"]}),e.jsx("span",{className:"text-sm text-gray-500",children:i?"מציג את כל השדות":"מציג רק שדות עם נתונים"})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"הורד"]}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"שמור"]})]})]}),e.jsxs(ae,{value:r,onValueChange:a,className:"w-full",children:[e.jsxs(le,{className:"grid grid-cols-4 w-full",dir:"rtl",children:[e.jsx(v,{value:"header",children:"פרטים מזהים"}),e.jsx(v,{value:"profitLoss",children:"רווח והפסד"}),e.jsx(v,{value:"taxAdjustment",children:"התאמה למס"}),e.jsx(v,{value:"balanceSheet",children:"מאזן"})]}),e.jsx(Ae,{data:o,businessInfo:s}),e.jsx(Ee,{selectedYear:c,referenceYear:l,data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ie,{data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ce,{data:o,referenceData:n,showEmptyFields:i})]})]})}function qe(){const{setFiltersContext:t}=b.useContext(de),[d,s]=b.useState(void 0),[c,l]=b.useState(void 0),[o,n]=b.useState(void 0),[{data:r,fetching:a}]=ne({query:me,variables:{year:c?Number.parseInt(c,10):0,businessId:d},pause:!c||!d});return b.useEffect(()=>{t(e.jsx("div",{className:"flex flex-row gap-x-5",dir:"rtl",children:e.jsx(je,{selectedBusiness:d,setSelectedBusiness:s,selectedYear:c,setSelectedYear:l,referenceYear:o,setReferenceYear:n})}))},[t,d,c,o]),e.jsx("div",{className:"container mx-auto",dir:"rtl",children:e.jsxs(oe,{className:"border-2 border-gray-300",children:[e.jsx(ce,{className:"bg-gray-100 border-b-2 border-gray-300 flex flex-row justify-between items-center",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("h1",{className:"text-2xl font-bold",children:'נספח לטופס הדו"ח השנתי ליחיד ולחבר בני אדם'}),e.jsxs("h2",{className:"text-xl",children:["לשנת המס ",c]}),e.jsx("p",{className:"text-sm",children:'נתוני הדוחות הכספיים, מאזן, רווח והפסד ודו"ח ההתאמה למס'})]})}),e.jsx(ie,{className:"p-0",children:e.jsx(Be,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Be({fetching:t,data:d,selectedBusiness:s,selectedYear:c,referenceYear:l}){if(t)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"טוען נתונים..."})});if(!c||!s)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"יש לבחור עסק ושנת דיווח"})});const o=d?.shaam6111.data;return o?e.jsx(Le,{data:o,businessInfo:d.shaam6111.business,selectedBusiness:s,selectedYear:c,referenceYear:l}):e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"אין נתונים זמינים עבור העסק והשנה שנבחרו"})})}export{qe as Shaam6111Report};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as n,r as x,B as g,J as h,gb as j,a as v,F as D,u as R,L as E,bk as y,dB as T,T as u,gc as w}from"./index-CB2VcZw_.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as b}from"./page-layout-Di4aGcKz.js";import{P as A}from"./modal-CWL2uL48.js";import{Y as F}from"./YearPickerInput-fBHzo-9n.js";import{F as I}from"./funnel-BjNIVF6D.js";import{T as N}from"./Table-DiM_oZiR.js";const i=({originalAmount:a,diffAmount:t})=>!t||a===t?n.jsx("td",{children:a}):n.jsx("td",{children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:t?"line-through":"",children:a}),t&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:t})]})});function P({years:a,setYears:t}){const[r,l]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(A,{opened:r,onClose:()=>l(!1),withCloseButton:!0,content:n.jsx(F,{type:"multiple",label:"Pick years",value:a?.map(c=>new Date(c,0,1)),onChange:c=>t(c.map(p=>p.getFullYear())),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})}),n.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:n.jsx(I,{className:"size-5"})})]})}const f=({originalRuleData:a,diffRuleData:t})=>{const r=h(j,a),l=h(j,t),c=l?.isCompliant!==r.isCompliant||l?.percentage.formatted!==r.percentage.formatted;return!l||!c?n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:r.percentage.formatted}):n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:"line-through ".concat(r.isCompliant?"text-green-500":"text-red-500"),children:r.percentage.formatted}),l&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md ".concat(l.isCompliant?"text-green-500":"text-red-500"),children:l.percentage.formatted})]})})},d=(a,t)=>T(t).format(a);function m(a,t){if(a.length!==0)return d(a.reduce((r,l)=>r+l,0),t)}const U=()=>{const{year:a}=v(),{setFiltersContext:t}=x.useContext(D),[r,l]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:c,fetching:p}]=R({query:C(w),variables:{years:r}});x.useEffect(()=>{t(n.jsx("div",{className:"flex flex-row gap-2",children:n.jsx(P,{years:r,setYears:l})}))},[r,p,t]);const s=c?.corporateTaxRulingComplianceReport??[];return n.jsx(b,{title:"Corporate Tax Ruling Compliance Report",children:p?n.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-4",children:s&&n.jsxs(N,{highlightOnHover:!0,fontSize:"md",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{}),r.map(e=>n.jsx("th",{children:n.jsx(y,{inline:!0,size:12,processing:!s.find(o=>o.year===e)?.differences,disabled:!!s.find(o=>o.year===e)?.differences,color:"orange",zIndex:"auto",children:e})},e)),n.jsx("th",{children:"Summary"},"sum")]})}),n.jsxs("tbody",{children:[n.jsxs("tr",{children:[n.jsx("td",{children:"Total Income"}),s.map(e=>n.jsx(i,{originalAmount:e.totalIncome.formatted,diffAmount:e.differences?.totalIncome?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.totalIncome.raw).reduce((e,o)=>e+o,0),s[0].totalIncome.currency),diffAmount:m(s.map(e=>e.differences?.totalIncome?.raw??e.totalIncome.raw).filter(e=>!!e),s[0].totalIncome.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Total R&D Expensess"}),s.map(e=>n.jsx(i,{originalAmount:e.researchAndDevelopmentExpenses.formatted,diffAmount:e.differences?.researchAndDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,o)=>e+o,0),s[0].researchAndDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.researchAndDevelopmentExpenses?.raw??e.researchAndDevelopmentExpenses.raw).filter(e=>!!e),s[0].researchAndDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.rndRelativeToIncome.rule,children:n.jsx("p",{children:"R&D Expenses out of Income"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.rndRelativeToIncome,diffRuleData:e.differences?.rndRelativeToIncome??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Local Development Expenses"}),s.map(e=>n.jsx(i,{originalAmount:e.localDevelopmentExpenses.formatted,diffAmount:e.differences?.localDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,o)=>e+o,0),s[0].localDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.localDevelopmentExpenses?.raw??e.localDevelopmentExpenses.raw).filter(e=>!!e),s[0].localDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.localDevelopmentRelativeToRnd.rule,children:n.jsx("p",{children:"Local Development out of R&D"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.localDevelopmentRelativeToRnd,diffRuleData:e.differences?.localDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Foreign Development Expenses"}),s.map(e=>n.jsx(i,{originalAmount:e.foreignDevelopmentExpenses.formatted,diffAmount:e.differences?.foreignDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,o)=>e+o,0),s[0].foreignDevelopmentExpenses.currency),diffAmount:m(s.map(e=>e.differences?.foreignDevelopmentExpenses?.raw??e.foreignDevelopmentExpenses.raw).filter(e=>!!e),s[0].foreignDevelopmentExpenses.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("th",{children:n.jsx(u,{multiline:!0,width:220,transitionProps:{duration:200},label:s[0]?.foreignDevelopmentRelativeToRnd.rule,children:n.jsx("p",{children:"Foreign Development out of R&D"})})}),s.map(e=>n.jsx(f,{originalRuleData:e.foreignDevelopmentRelativeToRnd,diffRuleData:e.differences?.foreignDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"R&D Business Trips Expenses"}),s.map(e=>n.jsx(i,{originalAmount:e.businessTripRndExpenses.formatted,diffAmount:e.differences?.businessTripRndExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,o)=>e+o,0),s[0].businessTripRndExpenses.currency),diffAmount:m(s.map(e=>e.differences?.businessTripRndExpenses?.raw??e.businessTripRndExpenses.raw).filter(e=>!!e),s[0].businessTripRndExpenses.currency)},"sum")]})]})]})})})};export{U as CorporateTaxRulingComplianceReport};
|