@accounter/client 0.0.9-alpha-20251209104152-e9b0a7512c73474e15ba64124dfc32d65146b50b → 0.0.9-alpha-20251209104231-5b2bda391432f505d4153f45a7a16b048432052c
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-Bg8QIoX-.js → Checkbox-BLRt_KKu.js} +1 -1
- package/dist/assets/{MultiSelect-Ci9EZTZI.js → MultiSelect-Bd3apSs_.js} +1 -1
- package/dist/assets/{Progress-Cp0hdL4W.js → Progress-BYqrsxrn.js} +1 -1
- package/dist/assets/{Table-BoGYZS9G.js → Table-DBy_FInH.js} +1 -1
- package/dist/assets/{Typography-Du-E1BvD.js → Typography-CYgmhLWw.js} +1 -1
- package/dist/assets/{YearPickerInput-DyrtOPag.js → YearPickerInput-DhwaekfD.js} +1 -1
- package/dist/assets/{accordion-DoQ_qACH.js → accordion-DeZhxk_l.js} +1 -1
- package/dist/assets/{accountant-approvals-DvInkcfn.js → accountant-approvals-DiXPSXAn.js} +1 -1
- package/dist/assets/{accounter-table-BESnwW3Q.js → accounter-table-2XtMS86c.js} +1 -1
- package/dist/assets/{addDays-BlCa-jFS.js → addDays-Dc61JWv1.js} +1 -1
- package/dist/assets/{all-charges-oBTG_-zh.js → all-charges-CTCSdwEH.js} +1 -1
- package/dist/assets/{arrow-up-down-BvVS_v54.js → arrow-up-down-DjT-Eoot.js} +1 -1
- package/dist/assets/{building-2-DhhtpgWz.js → building-2-CUCM6KOJ.js} +1 -1
- package/dist/assets/{business-Bx5BZtW-.js → business-D5G4XhGm.js} +1 -1
- package/dist/assets/{business-extended-info-Dbbk3S7D.js → business-extended-info-Dbj-tkfM.js} +1 -1
- package/dist/assets/{business-header-DJd-k_ub.js → business-header-ctdOgm4u.js} +1 -1
- package/dist/assets/{business-ledger-filters-lBTQb6Mt.js → business-ledger-filters-Bmuy2bsF.js} +1 -1
- package/dist/assets/{business-ledger-single-r588A0w4.js → business-ledger-single-D_eh-TKZ.js} +1 -1
- package/dist/assets/{business-trip-Dp9Q3hZf.js → business-trip-LfIgR2mJ.js} +1 -1
- package/dist/assets/charge-B9OrcpOy.js +1 -0
- package/dist/assets/{charges-filters-BethkZkN.js → charges-filters-wTVkn57g.js} +1 -1
- package/dist/assets/{charges-ledger-validation-CM6M3Hz5.js → charges-ledger-validation-D7S-GKAz.js} +1 -1
- package/dist/assets/{charges-table-BD77-Pk7.js → charges-table-CSBUejmC.js} +1 -1
- package/dist/assets/{chart-Xk9GqEcg.js → chart-B-Utupss.js} +1 -1
- package/dist/assets/{contracts-BhjFhUYG.js → contracts-C7hLtoUV.js} +1 -1
- package/dist/assets/{data-table-column-header-ISy5ikVk.js → data-table-column-header-FqJbxTUc.js} +1 -1
- package/dist/assets/{data-table-pagination-BCHk41p-.js → data-table-pagination-zMBRvFRC.js} +1 -1
- package/dist/assets/{deposits-transactions-table-DvW3-ikg.js → deposits-transactions-table-D2mHRvor.js} +1 -1
- package/dist/assets/{download-csv-button-TpaWtubl.js → download-csv-button-BwgBwkym.js} +1 -1
- package/dist/assets/{edit-issue-document-modal-BR6o8pOv.js → edit-issue-document-modal-DMmGgSNm.js} +1 -1
- package/dist/assets/{editable-business-trip-CARUoib7.js → editable-business-trip-B3H295Cd.js} +1 -1
- package/dist/assets/{eye-off-BCAg9QjG.js → eye-off-DX0qBOvM.js} +1 -1
- package/dist/assets/{funnel-gF7kKj_6.js → funnel-Chi4RPzj.js} +1 -1
- package/dist/assets/{index-DGtVpiKb.js → index-4IzUhDwE.js} +1 -1
- package/dist/assets/{index-RYJJ2pfq.js → index-B7aAVYVI.js} +1 -1
- package/dist/assets/{index-r-Alribw.js → index-BT0bQ-FL.js} +1 -1
- package/dist/assets/{index-BBbUy_Vy.js → index-BVjC-aH8.js} +1 -1
- package/dist/assets/{index-S7Bg8uSc.js → index-Bhiq8TpB.js} +1 -1
- package/dist/assets/{index-Cn_cLzqG.js → index-Bqk3--Z7.js} +1 -1
- package/dist/assets/{index-DaEMvSqd.js → index-CbAeaU5O.js} +1 -1
- package/dist/assets/{index-Cxyn8qSi.js → index-CcTJDt3m.js} +1 -1
- package/dist/assets/{index-BPNO4Lxn.js → index-CvyV_aE0.js} +1 -1
- package/dist/assets/{index-L-LcPaFO.js → index-D5uymx_b.js} +1 -1
- package/dist/assets/{index-DUVEE24V.js → index-DNnPw8Dq.js} +1 -1
- package/dist/assets/{index-Dpw6IqWE.js → index-DPk5MlBY.js} +1 -1
- package/dist/assets/{index-AgzQn0IX.js → index-DiytP5ES.js} +1 -1
- package/dist/assets/{index-CLdXBkte.js → index-Dq_0OFpr.js} +1 -1
- package/dist/assets/{index-slkEyzIA.js → index-DqkTiflU.js} +1 -1
- package/dist/assets/{index-B6NKfuMW.js → index-DtU8k0Rs.js} +1 -1
- package/dist/assets/{index-BCGtms8v.js → index-DvaorAJa.js} +1 -1
- package/dist/assets/{index-BAdKCUoP.js → index-GTPkjIlj.js} +1 -1
- package/dist/assets/{index-Di11EZVL.js → index-Hf0xrl2Z.js} +1 -1
- package/dist/assets/{index-BoyxBQXN.js → index-IBm4Ursh.js} +1 -1
- package/dist/assets/{index-DHlG9sEL.js → index-WGuJmgE0.js} +1 -1
- package/dist/assets/{index-D4dXfWoZ.js → index-bAy-i-WO.js} +1 -1
- package/dist/assets/{index-ei2X_JPQ.js → index-fKPbj_QU.js} +1 -1
- package/dist/assets/{index-AOn42Uur.js → index-h0DqWebR.js} +1 -1
- package/dist/assets/{index-4Z3D7Cs-.js → index-jPIJugRH.js} +1 -1
- package/dist/assets/{index-BUihugVY.js → index-mxG3trVw.js} +46 -46
- package/dist/assets/{index.es-CgkHyuXK.js → index.es-B38h3wVh.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-BuQeT-I2.js → insert-business-trip-modal-kI9R5YMW.js} +1 -1
- package/dist/assets/issue-document-DtQ0jY3L.js +1 -0
- package/dist/assets/{list-plus-BRJGZyM3.js → list-plus-BFzR0xCk.js} +1 -1
- package/dist/assets/{login-page-CwRSxMZz.js → login-page-C_treqcL.js} +1 -1
- package/dist/assets/{match-document-modal-CDJ9k2C7.js → match-document-modal-aTCZMq3A.js} +1 -1
- package/dist/assets/{missing-info-charges-BCQwkLLl.js → missing-info-charges-Bfw6XCf9.js} +1 -1
- package/dist/assets/{modal-B0kytztz.js → modal-COWLg06g.js} +1 -1
- package/dist/assets/{modify-contract-dialog-D1AvXXSg.js → modify-contract-dialog-Ceq5M6vV.js} +1 -1
- package/dist/assets/{page-layout-C0UTw1XM.js → page-layout-e5dcoG31.js} +1 -1
- package/dist/assets/{page-not-found-hcF8_-2K.js → page-not-found-CSjjMHtO.js} +1 -1
- package/dist/assets/{panel-top-open-CZgYU_qZ.js → panel-top-open-C6S_S_l5.js} +1 -1
- package/dist/assets/{pencil-CiP6AIvd.js → pencil-Ba3T8A4l.js} +1 -1
- package/dist/assets/{report-commentary-row-BujEIPN9.js → report-commentary-row-Crj56FnY.js} +1 -1
- package/dist/assets/{save-DOM5GPXc.js → save-CMypQNow.js} +1 -1
- package/dist/assets/{similar-transactions-modal-CebBOt3D.js → similar-transactions-modal-Dptc8s3r.js} +1 -1
- package/dist/assets/{sub-JQsW8K1m.js → sub-fkmgRadp.js} +1 -1
- package/dist/assets/subMonths-MMuRoKuu.js +1 -0
- package/dist/assets/{summary-CDfQDKYi.js → summary-ySM0WfQM.js} +1 -1
- package/dist/assets/{toggle-expansion-button-Ce1fUHyz.js → toggle-expansion-button-Ve1efFB2.js} +1 -1
- package/dist/assets/tooltip-DViqX6TG.js +1 -0
- package/dist/assets/{use-url-query-CdCUwmEx.js → use-url-query-ajxKL7cF.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +6 -6
- package/dist/assets/charge-Br1qCDp9.js +0 -1
- package/dist/assets/issue-document-wqWg8fQB.js +0 -1
- package/dist/assets/subMonths-W56yPxRG.js +0 -1
- package/dist/assets/tooltip-BCx6OnVj.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as p,hS as N,r as u,t as l,i as f,y,G as b,j as e,V as C,el as $,Y as D,Z as F,_ as w,$ as k,I as j,a1 as E,hT as v,hU as S,a9 as A,l as z,T as L,B as T,ah as M,n as O,hV as P,hW as B,F as q,u as U,hX as _,L as V,cl as G,hY as R}from"./index-
|
|
1
|
+
import{g as p,hS as N,r as u,t as l,i as f,y,G as b,j as e,V as C,el as $,Y as D,Z as F,_ as w,$ as k,I as j,a1 as E,hT as v,hU as S,a9 as A,l as z,T as L,B as T,ah as M,n as O,hV as P,hW as B,F as q,u as U,hX as _,L as V,cl as G,hY as R}from"./index-mxG3trVw.js";import{P as Y}from"./page-layout-e5dcoG31.js";import{L as Q}from"./list-plus-BFzR0xCk.js";const W="updateTag",X=()=>{const[{fetching:c},r]=p(N),i=u.useCallback(async t=>{const a=`Error updating tag ID [${t.tagId}]`,s=`${W}-${t.tagId}`;l.loading("Updating Tag...",{id:s});try{const n=await r(t),d=f(n,a,s,"updateTag");if(d)return l.success("Success",{id:s,description:"Tag updated"}),d.updateTag}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}return!1},[r]);return{fetching:c,updateTag:i}},Z=({onDone:c,data:r,close:i})=>{const{updateTag:t,fetching:a}=X(),s=b(S,r),n=y({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=A(o,h);i(),g&&Object.keys(g).length>0&&t({tagId:s.id,fields:g}).then(()=>c?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs($,{cols:3,children:[e.jsx(D,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs(F,{children:[e.jsx(w,{children:"Name"}),e.jsx(k,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(E,{})]})}),e.jsx(v,{formManager:n,tagsPath:"parentId",label:"Parent Tag"})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>m(x),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:a||Object.keys(h).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:i,children:"Cancel"})]})]})})},H=({onDone:c,data:r})=>{const[i,{open:t,close:a}]=z(!1);function s(){a(),c?.()}return e.jsxs(e.Fragment,{children:[e.jsx(L,{label:"Edit Tag",children:e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:t,children:e.jsx(M,{className:"size-5"})})}),e.jsx(O,{centered:!0,opened:i,onClose:a,title:"Insert Business Trip",children:e.jsx(Z,{close:a,onDone:s,data:r})})]})},J="addTag",K=()=>{const[{fetching:c},r]=p(P),i=u.useCallback(async t=>{const a=`Error adding new tag [${t.tagName}]`,s=`${J}-${t.tagName}`;l.loading("Adding tag",{id:s});try{const n=await r(t);f(n,a,s)&&l.success("Success",{id:s,description:`"${t.tagName}" tag was successfully added`})}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}},[r]);return{fetching:c,addTag:i}},ee="deleteTag",se=()=>{const[{fetching:c},r]=p(B),i=u.useCallback(async t=>{const a=`Error deleting new tag [${t.name}]`,s=`${ee}-${t.tagId}`;l.loading(`Deleting tag [${t.name}]`,{id:s});try{const n=await r(t);f(n,a,s)&&l.success("Tag Deleted",{id:s,description:`[${t.name}] tag was successfully removed`})}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}},[r]);return{fetching:c,deleteTag:i}},oe=()=>{const{setFiltersContext:c}=u.useContext(q),[r,i]=u.useState(""),[{data:t,fetching:a},s]=U({query:R}),{addTag:n}=K(),{deleteTag:d}=se();u.useEffect(()=>{c(null)},[c]);const m=_(t?.allTags??[]),h=u.useCallback(o=>{o.length>2&&n({tagName:o}).then(()=>{s()})},[n,s]),x=u.useCallback((o,g)=>{d({tagId:o,name:g}).then(()=>{s()})},[d,s]);return e.jsx(Y,{title:"Tags",description:"Manage tags for your bookmarks.",children:a?e.jsx(V,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m?.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-gray-600 mb-2",children:[e.jsxs("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:[o.namePath?.map((g,I)=>e.jsx("span",{className:"ms-2"},I)),o.name]}),e.jsx(H,{data:o}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(G,{className:"size-5"})})]},o.id)),e.jsxs("div",{className:"flex justify-start items-center gap-2 text-gray-600 mb-2",children:[e.jsx(j,{className:"w-80",value:r,onChange:o=>i(o.currentTarget.value),placeholder:"Add new tag",required:!0}),e.jsx(T,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(Q,{className:"size-5"})})]})]})})};export{oe as TagsManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,r as x,B as g,G as h,gE as j,a as v,F as D,u as R,L as E,bx as y,dT as T,T as u,gF as w}from"./index-
|
|
1
|
+
import{j as n,r as x,B as g,G as h,gE as j,a as v,F as D,u as R,L as E,bx as y,dT as T,T as u,gF as w}from"./index-mxG3trVw.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as A}from"./page-layout-e5dcoG31.js";import{P as b}from"./modal-COWLg06g.js";import{Y as F}from"./YearPickerInput-DhwaekfD.js";import{F as I}from"./funnel-Chi4RPzj.js";import{T as N}from"./Table-DBy_FInH.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(b,{opened:r,onClose:()=>l(!1),withCloseButton:!0,content:n.jsx(F,{type:"multiple",label:"Pick years",value:a?.map(d=>new Date(d,0,1)),onChange:d=>t(d.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),d=l?.isCompliant!==r.isCompliant||l?.percentage.formatted!==r.percentage.formatted;return!l||!d?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})]})})},c=(a,t)=>T(t).format(a);function m(a,t){if(a.length!==0)return c(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:d,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=d?.corporateTaxRulingComplianceReport??[];return n.jsx(A,{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:c(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:c(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:c(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:c(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:c(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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,j as e,B as u,a as y,F as R,u as T,L as D,gd as E}from"./index-
|
|
1
|
+
import{r as m,j as e,B as u,a as y,F as R,u as T,L as D,gd as E}from"./index-mxG3trVw.js";import{d as b}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as w}from"./page-layout-e5dcoG31.js";import{R as d}from"./report-commentary-row-Crj56FnY.js";import{P as F}from"./modal-COWLg06g.js";import{Y as f}from"./YearPickerInput-DhwaekfD.js";import{F as g}from"./funnel-Chi4RPzj.js";import{T as v}from"./Table-DBy_FInH.js";import"./toggle-expansion-button-Ve1efFB2.js";import"./panel-top-open-C6S_S_l5.js";function B({year:i,setYear:h,referenceYears:x,setReferenceYears:j}){const[l,c]=m.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(F,{opened:l,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(f,{label:"Change report year",value:new Date(i,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(f,{type:"multiple",label:"Pick reference years",value:x?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(o=>o.getFullYear()).filter(o=>i!==o)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(g,{className:"size-5"})})]})}const G=()=>{const{year:i}=y(),{setFiltersContext:h}=m.useContext(R),[x,j]=m.useState(i?Number(i):new Date().getFullYear()),[l,c]=m.useState([]),[{data:n,fetching:o}]=T({query:b(E),variables:{reportYear:x,referenceYears:l}});m.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(B,{year:x,setYear:j,referenceYears:l,setReferenceYears:c})}))},[x,o,h,l,c]);const p=n?.taxReport,s=p?.report,r=p?.reference??[];return e.jsx(w,{title:"Tax Report",children:o?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:s&&e.jsxs(v,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:x},x),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:s.profitBeforeTax.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("th",{children:a.profitBeforeTax.amount.formatted},a.year))]}),commentaryData:s.profitBeforeTax}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses By Records"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesByRecords.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpensesByRecords.amount.formatted},a.year))]}),commentaryData:s.researchAndDevelopmentExpensesByRecords}),e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses For Tax"}),e.jsx("td",{children:s.researchAndDevelopmentExpensesForTax.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.researchAndDevelopmentExpensesForTax.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Fines"}),e.jsx("td",{children:s.fines.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.fines.amount.formatted},a.year))]}),commentaryData:s.fines}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Untaxable Gifts"}),e.jsx("td",{children:s.untaxableGifts.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.untaxableGifts.amount.formatted},a.year))]}),commentaryData:s.untaxableGifts}),e.jsxs("tr",{children:[e.jsx("td",{children:"Business Trips Excess Expenses"}),e.jsx("td",{children:s.businessTripsExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.businessTripsExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Salary Excess Expenses"}),e.jsx("td",{children:s.salaryExcessExpensesAmount.formatted}),e.jsx("td",{}),r.map(t=>e.jsx("td",{children:t.salaryExcessExpensesAmount.formatted},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Reserves"}),e.jsx("td",{children:s.reserves.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.reserves.amount.formatted},a.year))]}),commentaryData:s.reserves}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Nontaxable Linkage"}),e.jsx("td",{children:s.nontaxableLinkage.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.nontaxableLinkage.amount.formatted},a.year))]}),commentaryData:s.nontaxableLinkage}),e.jsxs("tr",{children:[e.jsx("th",{children:"Taxable Income"}),e.jsx("th",{children:s.taxableIncome.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.taxableIncome.formatted},t.year)),e.jsx("td",{})]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax Rate"}),e.jsxs("td",{children:[(s.taxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.taxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Income with Special Tax Rate"}),e.jsx("td",{children:s.specialTaxableIncome.amount.formatted}),e.jsx("th",{children:t}),r.map(a=>e.jsx("td",{children:a.specialTaxableIncome.amount.formatted},a.year))]}),commentaryData:s.specialTaxableIncome}),e.jsxs("tr",{children:[e.jsx("td",{children:"Special Tax Rate"}),e.jsxs("td",{children:[(s.specialTaxRate*100).toFixed(1),"%"]}),e.jsx("td",{}),r.map(t=>e.jsxs("td",{children:[(t.specialTaxRate*100).toFixed(1),"%"]},t.year)),e.jsx("td",{})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Annual Tax Expense"}),e.jsx("th",{children:s.annualTaxExpense.formatted}),e.jsx("th",{}),r.map(t=>e.jsx("th",{children:t.annualTaxExpense.formatted},t.year)),e.jsx("td",{})]})})]})})})};export{G as TaxReport};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{dT as S,j as e,ai as w,R as C,ay as d,G as v,gi as R,r as c,bX as j,gj as b,gk as I,J as L,gl as y,u as U,F as k,B as A,gm as $,c as E,gn as T}from"./index-
|
|
1
|
+
import{dT as S,j as e,ai as w,R as C,ay as d,G as v,gi as R,r as c,bX as j,gj as b,gk as I,J as L,gl as y,u as U,F as k,B as A,gm as $,c as E,gn as T}from"./index-mxG3trVw.js";import{P}from"./page-layout-e5dcoG31.js";import{Y as z}from"./YearPickerInput-DhwaekfD.js";const o=(s,a)=>S(a,{minimumFractionDigits:0}).format(s);function O(s){return{id:s.id,chargeId:s.chargeId,date:s.date,description:s.description??"",reference:s.reference??"",amountILS:s.revenueLocal.raw,amountUSD:s.revenueDefaultForeign.raw,originalAmount:s.revenueOriginal.formatted}}const Y=({recordData:s})=>{const a=v(R,s),n=O(a);return e.jsx("div",{className:"p-2 bg-background rounded-lg border border-border/30 text-sm",children:e.jsxs(w,{to:C.CHARGES.DETAIL(n.chargeId),target:"_blank",rel:"noreferrer",onClick:h=>h.stopPropagation(),className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-foreground",children:n.reference}),e.jsx("p",{className:"font-medium text-foreground",children:n.description}),e.jsxs("div",{className:"flex gap-4 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.chargeId}),e.jsx("span",{children:n.date})]})]}),e.jsxs("div",{className:"invisible md:visible md:text-right flex-shrink-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:o(n.amountILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(n.amountUSD,d.Usd)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.originalAmount})]}),e.jsx("div",{className:"md:invisible ml-2 text-right",children:e.jsx("p",{className:"text-xs font-medium text-foreground",children:o(n.amountILS,d.Ils)})})]})})};function M(s){return{id:s.id,name:s.name,revenueILS:s.revenueLocal.raw,revenueUSD:s.revenueDefaultForeign.raw,records:s.records.map(a=>({id:a.id,data:a}))}}const B=({clientData:s})=>{const[a,n]=c.useState(!1),h=v(I,s),r=M(h),g=()=>{n(i=>!i)},u=c.useMemo(()=>r.records.slice().sort((i,t)=>i.data.date.localeCompare(t.data.date)),[r.records]);return e.jsxs("div",{children:[e.jsxs("button",{onClick:g,className:"w-full flex items-center justify-between p-2 bg-background rounded-lg border border-border/50 hover:bg-accent/5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[a?e.jsx(j,{className:"size-4 text-muted-foreground flex-shrink-0"}):e.jsx(b,{className:"size-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-foreground text-sm",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.records?.length||0," record",r.records?.length===1?"":"s"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueILS,d.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueUSD,d.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-xs font-medium text-foreground",children:o(r.revenueILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(r.revenueUSD,d.Usd)})]})]}),a&&u&&e.jsx("div",{className:"mt-3 ml-2 space-y-3 border-l-2 border-border/50 pl-2",children:u.map(i=>e.jsx(Y,{recordData:i.data},i.id))})]})};function G(s){return{code:s.code,name:s.name,revenues:{ILS:s.revenueLocal.raw,USD:s.revenueDefaultForeign.raw},clients:s.clients.map(a=>({id:a.id,data:a}))}}const V=({countryData:s})=>{const[a,n]=c.useState(!1),h=v(y,s),r=G(h),g=()=>{n(t=>!t)},u={ILS:r.revenues.ILS,USD:r.revenues.USD},i=c.useMemo(()=>r.clients.slice().sort((t,f)=>f.data.revenueDefaultForeign.raw-t.data.revenueDefaultForeign.raw),[r.clients]);return e.jsxs(L,{className:"border border-border",children:[e.jsxs("button",{onClick:()=>g(),className:"w-full px-4 py-2 hover:bg-accent/5 transition-colors flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[a?e.jsx(j,{className:"size-5 text-muted-foreground flex-shrink-0"}):e.jsx(b,{className:"size-5 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-lg",children:r.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.clients.length," clients"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.ILS,d.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.USD,d.Usd)})]})]})]}),e.jsxs("div",{className:"md:hidden px-2 py-2 bg-accent/5 border-t border-border flex gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.ILS,d.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:o(r.revenues.USD,d.Usd)})]})]}),a&&e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-2 p-3 bg-muted/30",children:[i.map(t=>e.jsx(B,{clientData:t.data},t.id)),e.jsx("div",{className:"pt-2 border-t border-border/50 mt-4",children:e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Clients Subtotal"}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right",children:[e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:o(u.ILS,d.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:o(u.USD,d.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:o(u.ILS,d.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:o(u.USD,d.Usd)})]})]})})]})})]},r.code)},Q=()=>{const[s,a]=c.useState(new Date().getFullYear()-1),[{data:n,fetching:h}]=U({query:T,variables:{filters:{year:s}}}),r=c.useCallback(()=>{const t=[];t.push("Country,Client,charge ID,Date,Description,Revenue ILS,Revenue USD"),n?.annualRevenueReport.countries.sort((x,l)=>l.revenueDefaultForeign.raw-x.revenueDefaultForeign.raw).map(x=>{t.push(`${x.name},,,,TOTAL,${x.revenueLocal.raw.toFixed(2)},${x.revenueDefaultForeign.raw.toFixed(2)}`),x.clients.sort((l,m)=>m.revenueDefaultForeign.raw-l.revenueDefaultForeign.raw).map(l=>{l.records&&l.records.length>0?(t.push(`${x.name},${l.name},,,TOTAL,${l.revenueLocal.raw.toFixed(2)},${l.revenueDefaultForeign.raw.toFixed(2)}`),l.records.sort((m,F)=>m.date.localeCompare(F.date)).map(m=>{t.push(`${x.name},${l.name},${m.chargeId},${m.date},${m.description},${m.revenueLocal.raw.toFixed(2)},${m.revenueDefaultForeign.raw.toFixed(2)}`)})):t.push(`${x.name},${l.name},,,,,`)})});const f=t.join(`
|
|
2
2
|
`),N=new Blob([f],{type:"text/csv;charset=utf-8;"}),p=document.createElement("a"),D=URL.createObjectURL(N);p.setAttribute("href",D),p.setAttribute("download",`annual-revenue-${s}.csv`),p.style.visibility="hidden",document.body.appendChild(p),p.click(),document.body.removeChild(p)},[n,s]),{setFiltersContext:g}=c.useContext(k);c.useEffect(()=>{g(e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(z,{value:new Date(s,0,1),onChange:t=>t&&a(t?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsxs(A,{onClick:r,variant:"outline",size:"sm",className:"flex items-center gap-2 bg-transparent",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Export CSV"})]})]}))},[s,h,g,r]);const u=c.useMemo(()=>`Annual Revenue Report for ${s}`,[s]),i=c.useMemo(()=>n?.annualRevenueReport.countries.slice().sort((t,f)=>f.revenueDefaultForeign.raw-t.revenueDefaultForeign.raw),[n]);return e.jsx(P,{title:"Annual Revenue Report",description:u,children:h?e.jsx(E,{}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("main",{className:"container mx-auto px-2 py-2 max-w-7xl",children:e.jsx("div",{className:"space-y-2",children:i?.map(t=>e.jsx(V,{countryData:t},t.id))})})})})};export{Q as AnnualRevenueReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e,B as u,a as y,F as g,u as P,L as D,gc as w}from"./index-
|
|
1
|
+
import{r as x,j as e,B as u,a as y,F as g,u as P,L as D,gc as w}from"./index-mxG3trVw.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as E}from"./page-layout-e5dcoG31.js";import{R as d}from"./report-commentary-row-Crj56FnY.js";import{P as v}from"./modal-COWLg06g.js";import{Y as p}from"./YearPickerInput-DhwaekfD.js";import{F}from"./funnel-Chi4RPzj.js";import{T as C}from"./Table-DBy_FInH.js";import"./toggle-expansion-button-Ve1efFB2.js";import"./panel-top-open-C6S_S_l5.js";function A({year:l,setYear:h,referenceYears:o,setReferenceYears:j}){const[m,c]=x.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(v,{opened:m,onClose:()=>c(!1),withCloseButton:!0,content:e.jsxs(e.Fragment,{children:[e.jsx(p,{label:"Change report year",value:new Date(l,0,1),onChange:n=>n&&h(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(p,{type:"multiple",label:"Pick reference years",value:o?.map(n=>new Date(n,0,1)),onChange:n=>j(n.map(i=>i.getFullYear()).filter(i=>l!==i)),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})]})}),e.jsx(u,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>c(!0),children:e.jsx(F,{className:"size-5"})})]})}const I=()=>{const{year:l}=y(),{setFiltersContext:h}=x.useContext(g),[o,j]=x.useState(l?Number(l):new Date().getFullYear()),[m,c]=x.useState([]),[{data:n,fetching:i}]=P({query:R(w),variables:{reportYear:o,referenceYears:m}});x.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:m,setReferenceYears:c})}))},[o,i,h,m,c]);const f=n?.profitAndLossReport,r=f?.report,s=f?.reference??[];return e.jsx(E,{title:"Profit and Loss Report",children:i?e.jsx(D,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:r&&e.jsxs(C,{highlightOnHover:!0,fontSize:"md",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{}),e.jsx("th",{children:o},o),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.year},t.year))]})}),e.jsxs("tbody",{children:[e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("th",{children:"Revenue"}),e.jsx("th",{children:r.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("th",{children:a.revenue.amount.formatted},a.year))]}),commentaryData:r.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:r.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.costOfSales.amount.formatted},a.year))]}),commentaryData:r.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:r.grossProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.grossProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"R&D Expenses"}),e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.researchAndDevelopmentExpenses.amount.formatted},a.year))]}),commentaryData:r.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:r.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.marketingExpenses.amount.formatted},a.year))]}),commentaryData:r.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted},a.year))]}),commentaryData:r.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:r.operatingProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.operatingProfit.formatted},t.year))]}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Financial Expenses"}),e.jsx("td",{children:r.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.financialExpenses.amount.formatted},a.year))]}),commentaryData:r.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:r.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(a=>e.jsx("td",{children:a.otherIncome.amount.formatted},a.year))]}),commentaryData:r.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:r.profitBeforeTax.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.profitBeforeTax.formatted},t.year))]}),e.jsxs("tr",{children:[e.jsx("td",{children:"Tax"}),e.jsx("td",{children:r.tax.formatted}),e.jsx("td",{}),s.map(t=>e.jsx("td",{children:t.tax.formatted},t.year))]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Net Profit"}),e.jsx("th",{children:r.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{I as ProfitAndLossReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,u as y,dt as L,G as b,bI as C,j as e,D as O,aU as P,B as M,a3 as q,x as V,al as H,am as U,ao as z,ap as Q,aq as $,ar as G,as as J,w as S,du as F,y as K,dv as X,H as Y,bF as _,V as W,a2 as Z,bJ as ee,bK as se,bL as te,bM as N,bN as h,bO as ne,bP as x,ai as ae,R as E,bQ as le,bR as re,a4 as oe,bS as ce,bT as ie,F as ue,c as de}from"./index-
|
|
1
|
+
import{r as n,u as y,dt as L,G as b,bI as C,j as e,D as O,aU as P,B as M,a3 as q,x as V,al as H,am as U,ao as z,ap as Q,aq as $,ar as G,as as J,w as S,du as F,y as K,dv as X,H as Y,bF as _,V as W,a2 as Z,bJ as ee,bK as se,bL as te,bM as N,bN as h,bO as ne,bP as x,ai as ae,R as E,bQ as le,bR as re,a4 as oe,bS as ce,bT as ie,F as ue,c as de}from"./index-mxG3trVw.js";import{u as me,E as he}from"./edit-issue-document-modal-DMmGgSNm.js";import{s as w}from"./subMonths-MMuRoKuu.js";function xe({issueMonth:u,clients:r,onAdd:o}){const[f,c]=n.useState(!1),[j,d]=n.useState(""),[{data:m},a]=y({query:L,variables:{issueMonth:u,clientId:j},pause:!f}),p=n.useCallback(l=>{d(l),a()},[a,d]);return n.useEffect(()=>{j!==""&&m&&(o(b(C,m.clientMonthlyChargeDraft)),c(!1))},[j,m,o]),e.jsxs(O,{open:f,onOpenChange:c,children:[e.jsx(P,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"icon",children:e.jsx(q,{})})}),e.jsxs(V,{className:"w-[400px] max-w-screen-md",children:[e.jsx(H,{children:e.jsx(U,{children:"Select document recipient"})}),e.jsxs(z,{onValueChange:p,children:[e.jsx(Q,{children:e.jsx($,{placeholder:"Recipient"})}),e.jsx(G,{children:r.map(l=>e.jsx(J,{value:l.id,children:l.name},l.id))})]})]})]})}const je=({drafts:u})=>{const[r,o]=n.useState(u.map(s=>b(C,s))),f=S(w(new Date,1),"yyyy-MM-dd"),[c,j]=n.useState(f),[{data:d},m]=y({query:F,variables:{issueMonth:c},pause:!0});n.useEffect(()=>{d?.clientMonthlyChargesDrafts&&o(d.clientMonthlyChargesDrafts.map(s=>b(C,s)))},[d,o]),n.useEffect(()=>{m()},[c,m]);const a=K({values:{generateDocumentsInfo:r}}),{issueDocuments:p}=me(),[{data:l}]=y({query:X}),{fields:I,append:A,remove:B,update:k}=Y({control:a.control,name:"generateDocumentsInfo"}),T=a.watch("generateDocumentsInfo"),D=n.useMemo(()=>I.map((s,t)=>({...s,...T[t],id:s.client?.businessId})),[I,T]),v=n.useCallback(s=>{p(s)},[p]),R=n.useMemo(()=>l?.allOpenContracts.filter(s=>s.billingCycle===_.Monthly&&!D.some(t=>t.client?.businessId===s.client.originalBusiness.id)),[D,l]);return e.jsx("div",{className:"p-2",children:e.jsx(W,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(v),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(Z,{children:"Issue Month:"}),e.jsx(ee,{value:new Date(c),onChange:s=>{const t=new Date(s.getFullYear(),s.getMonth(),15);j(S(t,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(se,{children:[e.jsx(te,{children:e.jsxs(N,{children:[e.jsx(h,{children:"Name"}),e.jsx(h,{children:"Document"}),e.jsx(h,{children:"Amount"}),e.jsx(h,{children:"Remark"}),e.jsx(h,{children:"Recipients"}),e.jsx(h,{})]})}),e.jsx(ne,{children:D.map(({id:s,...t},g)=>e.jsxs(N,{children:[e.jsx(x,{children:e.jsx(ae,{to:s?E.BUSINESSES.DETAIL(s):E.BUSINESSES.ALL,target:"_blank",rel:"noreferrer",onClick:i=>i.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.client?.name})}),e.jsx(x,{children:t.type}),e.jsxs(x,{children:[t.income?.[0]?.price," ",t.income?.[0]?.currency]}),e.jsx(x,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:t.remarks})}),e.jsx(x,{children:e.jsx("div",{className:"flex flex-col",children:t.client?.emails?.map(i=>e.jsx("span",{className:"text-sm text-gray-500",children:i},i))})}),e.jsx(x,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(le,{children:[e.jsx(re,{asChild:!0,type:"button",children:e.jsx(M,{className:"size-7.5",variant:"secondary",onClick:()=>B(g),children:e.jsx(oe,{size:16})})}),e.jsx(ce,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(he,{draft:t,onApprove:i=>{a.setValue(`generateDocumentsInfo.${g}`,i,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),k(g,{...i})}})]})})]},s))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(xe,{clients:R?.map(s=>({id:s.client.originalBusiness.id,name:s.client.originalBusiness.name}))??[],onAdd:A,issueMonth:c}),e.jsx(ie,{onConfirm:a.handleSubmit(v),title:`Are you sure you want to issue ${D.length} documents?`,children:e.jsx(M,{children:"Issue"})})]})]})})})},ye=()=>{const{setFiltersContext:u}=n.useContext(ue),[{data:r,fetching:o}]=y({query:F,variables:{issueMonth:S(w(new Date,1),"yyyy-MM-dd")}});return n.useEffect(()=>{r?.clientMonthlyChargesDrafts||u(null)},[r,u]),o?e.jsx(de,{}):e.jsx(je,{drafts:r?.clientMonthlyChargesDrafts??[]})};export{ye as IssueDocuments};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as it,r as m,dd as Nc,aF as V,dh as kc,aG as ae,j as v,dg as vn,dG as It,dH as ge,dI as Ho,di as Lc,dJ as Vc,dK as nn,dL as jc,bw as Fi,D as _r,aU as zr,bx as Fc,B as ee,x as $r,al as Ur,am as Hr,y as Wo,by as Bc,aC as _c,bz as An,bA as Bi,bB as _i,w as rn,at as Go,a2 as Ko,bD as zc,g as qo,dM as $c,t as Pe,i as Yo,u as rr,dN as Uc,bU as Hc,b$ as Wc,c1 as Gc,c0 as Kc,c2 as qc,L as Xo,I as Wr,bK as Yc,bL as Xc,bM as Nn,bN as Zc,b_ as zi,bO as Jc,bP as $i,bV as Zo,bW as Jo,bY as Qo,dO as Qc,dP as eu,dQ as sn,dR as tu,z as nu,a7 as ru,V as iu,Y as su,Z as ou,_ as au,$ as lu,a1 as cu,au as uu,ab as Ui,dS as du,e as hu,a4 as fu,ag as Hi,dT as pu,dU as gu,dV as Wi,cs as mu,ay as vu,F as yu,a$ as bu,dW as Tu,dX as xu}from"./index-
|
|
1
|
+
import{v as it,r as m,dd as Nc,aF as V,dh as kc,aG as ae,j as v,dg as vn,dG as It,dH as ge,dI as Ho,di as Lc,dJ as Vc,dK as nn,dL as jc,bw as Fi,D as _r,aU as zr,bx as Fc,B as ee,x as $r,al as Ur,am as Hr,y as Wo,by as Bc,aC as _c,bz as An,bA as Bi,bB as _i,w as rn,at as Go,a2 as Ko,bD as zc,g as qo,dM as $c,t as Pe,i as Yo,u as rr,dN as Uc,bU as Hc,b$ as Wc,c1 as Gc,c0 as Kc,c2 as qc,L as Xo,I as Wr,bK as Yc,bL as Xc,bM as Nn,bN as Zc,b_ as zi,bO as Jc,bP as $i,bV as Zo,bW as Jo,bY as Qo,dO as Qc,dP as eu,dQ as sn,dR as tu,z as nu,a7 as ru,V as iu,Y as su,Z as ou,_ as au,$ as lu,a1 as cu,au as uu,ab as Ui,dS as du,e as hu,a4 as fu,ag as Hi,dT as pu,dU as gu,dV as Wi,cs as mu,ay as vu,F as yu,a$ as bu,dW as Tu,dX as xu}from"./index-mxG3trVw.js";import{u as ea}from"./use-url-query-ajxKL7cF.js";import{T as yn}from"./tooltip-DViqX6TG.js";import{A as Gi}from"./arrow-up-down-DjT-Eoot.js";import{D as Su}from"./download-csv-button-BwgBwkym.js";import{B as wu}from"./business-extended-info-Dbj-tkfM.js";import{_ as Du,a as bn,s as we,g as Gr,u as Ki,c as Kr,m as wt,d as ir,T as sr}from"./Typography-CYgmhLWw.js";import{P as Cu}from"./pencil-Ba3T8A4l.js";import{P as Eu,a as Ou}from"./panel-top-open-C6S_S_l5.js";import{F as Pu}from"./funnel-Chi4RPzj.js";import{M as Mu}from"./MultiSelect-Bd3apSs_.js";import"./data-table-column-header-FqJbxTUc.js";import"./eye-off-DX0qBOvM.js";const Iu=[["path",{d:"m10.852 19.772-.383.924",key:"r7sl7d"}],["path",{d:"m13.148 14.228.383-.923",key:"1d5zpm"}],["path",{d:"M13.148 19.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1ydik7"}],["path",{d:"m13.53 20.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1m1vsf"}],["path",{d:"m14.772 15.852.923-.383",key:"660p6e"}],["path",{d:"m14.772 18.148.923.383",key:"hrcpis"}],["path",{d:"M4.2 15.1a7 7 0 1 1 9.93-9.858A7 7 0 0 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2",key:"j2q98n"}],["path",{d:"m9.228 15.852-.923-.383",key:"1p9ong"}],["path",{d:"m9.228 18.148-.923.383",key:"6558rz"}]],Ru=it("cloud-cog",Iu);const Au=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Nu=it("cloud-upload",Au);const ku=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ta=it("ellipsis",ku);const Lu=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Vu=it("folder-open",Lu);const ju=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Fu=it("folder-plus",ju);const Bu=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],_u=it("folder",Bu);function Gt(t){const e=m.useRef(t);return Nc(()=>{e.current=t}),m.useRef((...n)=>(0,e.current)(...n)).current}function or(t,e){return or=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},or(t,e)}function zu(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,or(t,e)}const qi=V.createContext(null);function $u(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qr(t,e){var n=function(s){return e&&m.isValidElement(s)?e(s):s},r=Object.create(null);return t&&m.Children.map(t,function(i){return i}).forEach(function(i){r[i.key]=n(i)}),r}function Uu(t,e){t=t||{},e=e||{};function n(u){return u in e?e[u]:t[u]}var r=Object.create(null),i=[];for(var s in t)s in e?i.length&&(r[s]=i,i=[]):i.push(s);var o,a={};for(var l in e){if(r[l])for(o=0;o<r[l].length;o++){var c=r[l][o];a[r[l][o]]=n(c)}a[l]=n(l)}for(o=0;o<i.length;o++)a[i[o]]=n(i[o]);return a}function _e(t,e,n){return n[e]!=null?n[e]:t.props[e]}function Hu(t,e){return qr(t.children,function(n){return m.cloneElement(n,{onExited:e.bind(null,n),in:!0,appear:_e(n,"appear",t),enter:_e(n,"enter",t),exit:_e(n,"exit",t)})})}function Wu(t,e,n){var r=qr(t.children),i=Uu(e,r);return Object.keys(i).forEach(function(s){var o=i[s];if(m.isValidElement(o)){var a=s in e,l=s in r,c=e[s],u=m.isValidElement(c)&&!c.props.in;l&&(!a||u)?i[s]=m.cloneElement(o,{onExited:n.bind(null,o),in:!0,exit:_e(o,"exit",t),enter:_e(o,"enter",t)}):!l&&a&&!u?i[s]=m.cloneElement(o,{in:!1}):l&&a&&m.isValidElement(c)&&(i[s]=m.cloneElement(o,{onExited:n.bind(null,o),in:c.props.in,exit:_e(o,"exit",t),enter:_e(o,"enter",t)}))}}),i}var Gu=Object.values||function(t){return Object.keys(t).map(function(e){return t[e]})},Ku={component:"div",childFactory:function(e){return e}},Yr=(function(t){zu(e,t);function e(r,i){var s;s=t.call(this,r,i)||this;var o=s.handleExited.bind($u(s));return s.state={contextValue:{isMounting:!0},handleExited:o,firstRender:!0},s}var n=e.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},e.getDerivedStateFromProps=function(i,s){var o=s.children,a=s.handleExited,l=s.firstRender;return{children:l?Hu(i,a):Wu(i,o,a),firstRender:!1}},n.handleExited=function(i,s){var o=qr(this.props.children);i.key in o||(i.props.onExited&&i.props.onExited(s),this.mounted&&this.setState(function(a){var l=kc({},a.children);return delete l[i.key],{children:l}}))},n.render=function(){var i=this.props,s=i.component,o=i.childFactory,a=Du(i,["component","childFactory"]),l=this.state.contextValue,c=Gu(this.state.children).map(o);return delete a.appear,delete a.enter,delete a.exit,s===null?V.createElement(qi.Provider,{value:l},c):V.createElement(qi.Provider,{value:l},V.createElement(s,a,c))},e})(V.Component);Yr.propTypes={};Yr.defaultProps=Ku;const Yi={};function na(t,e){const n=m.useRef(Yi);return n.current===Yi&&(n.current=t(e)),n}const qu=[];function Yu(t){m.useEffect(t,qu)}class Xr{static create(){return new Xr}currentId=null;start(e,n){this.clear(),this.currentId=setTimeout(()=>{this.currentId=null,n()},e)}clear=()=>{this.currentId!==null&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function Xu(){const t=na(Xr.create).current;return Yu(t.disposeEffect),t}function Xi(t){try{return t.matches(":focus-visible")}catch{}return!1}class on{static create(){return new on}static use(){const e=na(on.create).current,[n,r]=m.useState(!1);return e.shouldMount=n,e.setShouldMount=r,m.useEffect(e.mountEffect,[n]),e}constructor(){this.ref={current:null},this.mounted=null,this.didMount=!1,this.shouldMount=!1,this.setShouldMount=null}mount(){return this.mounted||(this.mounted=Ju(),this.shouldMount=!0,this.setShouldMount(this.shouldMount)),this.mounted}mountEffect=()=>{this.shouldMount&&!this.didMount&&this.ref.current!==null&&(this.didMount=!0,this.mounted.resolve())};start(...e){this.mount().then(()=>this.ref.current?.start(...e))}stop(...e){this.mount().then(()=>this.ref.current?.stop(...e))}pulsate(...e){this.mount().then(()=>this.ref.current?.pulsate(...e))}}function Zu(){return on.use()}function Ju(){let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n}function Qu(t){const{className:e,classes:n,pulsate:r=!1,rippleX:i,rippleY:s,rippleSize:o,in:a,onExited:l,timeout:c}=t,[u,d]=m.useState(!1),h=ae(e,n.ripple,n.rippleVisible,r&&n.ripplePulsate),f={width:o,height:o,top:-(o/2)+s,left:-(o/2)+i},p=ae(n.child,u&&n.childLeaving,r&&n.childPulsate);return!a&&!u&&d(!0),m.useEffect(()=>{if(!a&&l!=null){const g=setTimeout(l,c);return()=>{clearTimeout(g)}}},[l,a,c]),v.jsx("span",{className:h,style:f,children:v.jsx("span",{className:p})})}const le=bn("MuiTouchRipple",["root","ripple","rippleVisible","ripplePulsate","child","childLeaving","childPulsate"]),ar=550,ed=80,td=It`
|
|
2
2
|
0% {
|
|
3
3
|
transform: scale(0);
|
|
4
4
|
opacity: 0.1;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as F,j as r,e as Q,u as q,hd as H,L as E,aC as $,bw as K,B as U,y as X,by as ee,bz as te,bC as ne,bJ as O,w as S,he as T,bD as se,F as oe,J as re,O as ie,W as le}from"./index-
|
|
1
|
+
import{r as F,j as r,e as Q,u as q,hd as H,L as E,aC as $,bw as K,B as U,y as X,by as ee,bz as te,bC as ne,bJ as O,w as S,he as T,bD as se,F as oe,J as re,O as ie,W as le}from"./index-mxG3trVw.js";import{u as G}from"./use-url-query-ajxKL7cF.js";import{P as ae}from"./page-layout-e5dcoG31.js";import{A as ce,a as fe,c as ue,b as he}from"./accordion-DeZhxk_l.js";import{P as de}from"./modal-COWLg06g.js";import{F as pe}from"./funnel-Chi4RPzj.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:l,N:o,j:h,M:a,Z:f,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*f);const V=o-a,_=o+a,B=_&1,W=l+o-1,Y=h+a-1,Z=(_+B)/2;let N;t:for(let M=0;M<=Z;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let u=I;u<=L;u+=2){const A=t[u-1-f*Math.floor((u-1)/f)],R=t[u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[u-f*Math.floor(u/f)]=b,B===1&&(N=V-u)>=1-M&&N<M&&b+t[f+N-f*Math.floor(N/f)]>=o)if(M>1||b!==w){i[x++]=l+b,i[x++]=o-b,i[x++]=h+C,i[x++]=a-C,o=w,a=k,f=2*(Math.min(o,a)+1);continue e}else break t}for(let u=I;u<=L;u+=2){const A=t[f+u-1-f*Math.floor((u-1)/f)],R=t[f+u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,k=w-u;let b=w,C=k;for(;b<o&&C<a&&s(W-b,Y-C);)b++,C++;if(t[f+u-f*Math.floor(u/f)]=b,B===0&&(N=V-u)>=-M&&N<=M&&b+t[N-f*Math.floor(N/f)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-k,i[x++]=k,o=o-b,a=a-C,f=2*(Math.min(o,a)+1);continue e}else break t}}if(o!==a){a>o?(l+=o,h+=o,a-=o,o=0):(l+=a,h+=a,o-=a,a=0);break}}if(o+a!==0)if(e.pxe===l||e.pye===h)e.pxe=l+o,e.pye=h+a;else{const V=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=l,e.pxe=l+o,e.pys=h,e.pye=h+a,V>=0)return e.i=l,e.N=o,e.j=h,e.M=a,e.Z=f,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],f=2*(Math.min(o,a)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const l=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*l);return new m({i:e,N:n,j:t,M:s,Z:l,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,l]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<l&&t(s,s);)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;t(--i,--l)&&i>s&&l>s;);}else{for(;s<i&&s<l&&e[s]===n[s];)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;e[--i]===n[--l]&&i>s&&l>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,l+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:a,j:f,N:x}=this;return a<x&&(n.done=!1,n.value=[a,f,x-a],this.i=x),n}const t=n.value,s=t[0],i=t[1],l=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=l,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*P(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,l,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=l;t<e.length&&(yield s.call(e,t))}v.applyPatch=P;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[l,o,h,a]of d(e,n,t))s<l&&(yield[0,i.call(e,s,l)]),l<o&&(yield[-1,i.call(e,l,o)]),h<a&&(yield[1,i.call(n,h,a)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),J=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=F.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),P=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of P)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(P.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),J]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),J]);let n=[];for(const[t,s]of j){const i=t.split(`
|
|
2
2
|
`);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(Q,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=q({query:H,variables:c}),p=F.useMemo(()=>m?.pcnByDate?m.pcnByDate.sort((y,g)=>g.date>y.date?1:g.date<y.date?-1:0):[],[m?.pcnByDate]);return D?r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}):r.jsxs("div",{className:"flex flex-col gap-4",children:[!!m&&d&&r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}),p.map((y,g)=>r.jsx(ge,{content:y.content,contentOrigin:y.diffContent,monthDate:y.date},g))]})};function be({filter:c,setFilter:m,closeModal:D}){const{control:d,handleSubmit:p,setValue:y}=X({defaultValues:{...c}}),{selectableBusinesses:g,fetching:P}=ee(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[P?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(te,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(ne,{...e,data:g,value:e.value,disabled:P,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),r.jsx(O,{label:"From date",defaultValue:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,defaultDate:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("fromMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsx(O,{label:"To date",defaultValue:c?.toMonthDate?new Date(c.toMonthDate):new Date,defaultDate:c?.toMonthDate?new Date(c.toMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("toMonthDate",S(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[r.jsx(U,{type:"submit",children:"Filter"}),r.jsx(U,{type:"button",onClick:D,children:"Cancel"})]})]})]})}function ve({filter:c,setFilter:m}){const[D,d]=F.useState(!1),{get:p,set:y}=G(),{userContext:g}=F.useContext($);function P(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:S(T(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")},se(j,c)||m(j)}return F.useEffect(()=>{const j=K(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(de,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:P,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(pe,{className:"size-5"})})]})}const ke=()=>{const{get:c}=G(),{setFiltersContext:m}=F.useContext(oe),D=F.useMemo(()=>{try{if(c("validateReportsFilters"))return JSON.parse(decodeURIComponent(c("validateReportsFilters")))}catch(y){console.error("Error parsing filter from URL",y)}return{fromMonthDate:S(T(new Date),"yyyy-MM-15"),toMonthDate:S(new Date,"yyyy-MM-15")}},[c]),[d,p]=F.useState(D);return F.useEffect(()=>{m(r.jsx("div",{className:"flex flex-row gap-2",children:r.jsx(ve,{filter:{...d},setFilter:p})}))},[d,m]),r.jsx(ae,{title:"Report Validations",children:r.jsx(ce,{type:"single",collapsible:!0,children:r.jsx(fe,{value:"pcn874",children:r.jsxs(re,{className:"p-4",children:[r.jsx(ue,{children:r.jsx(ie,{children:"Monthly VAT (PCN874)"})}),r.jsx(he,{children:r.jsx(le,{children:r.jsx(Me,{filter:d})})})]})})})})};export{ke as ValidateReportsScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as U,r as d,j as e,G as p,B as g,e5 as H,e6 as _,e7 as q,d3 as D,e8 as M,e9 as J,ea as Q,eb as $,ec as Y,ed as K,ee as W,u as E,t as X,ef as Z,T as ee,eg as te,aC as T,bw as se,y as ae,dm as ne,bz as A,bC as S,eh as F,bJ as re,w as N,bD as oe,F as ie,L as ce,ei as le}from"./index-BUihugVY.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as z}from"./use-url-query-CdCUwmEx.js";import{C as I,u as de,a as V,b as O,M as he}from"./charges-table-BD77-Pk7.js";import{E as me,I as xe,M as ue}from"./match-document-modal-CDJ9k2C7.js";import{P as pe}from"./page-layout-C0UTw1XM.js";import{P as w,a as y}from"./panel-top-open-CZgYU_qZ.js";import{T as k}from"./toggle-expansion-button-Ce1fUHyz.js";import{T as P}from"./Table-BoGYZS9G.js";import{c as ge}from"./charges-filters-BethkZkN.js";import{P as je}from"./modal-B0kytztz.js";import{F as fe}from"./funnel-gF7kKj_6.js";import"./index-r-Alribw.js";import"./similar-transactions-modal-CebBOt3D.js";import"./addDays-BlCa-jFS.js";import"./list-plus-BRJGZyM3.js";import"./tooltip-BCx6OnVj.js";import"./summary-CDfQDKYi.js";import"./deposits-transactions-table-DvW3-ikg.js";import"./Checkbox-Bg8QIoX-.js";import"./accordion-DoQ_qACH.js";import"./data-table-column-header-ISy5ikVk.js";import"./eye-off-BCAg9QjG.js";import"./YearPickerInput-DyrtOPag.js";import"./insert-business-trip-modal-BuQeT-I2.js";import"./accounter-table-BESnwW3Q.js";import"./sub-JQsW8K1m.js";import"./subMonths-W56yPxRG.js";import"./MultiSelect-Ci9EZTZI.js";const ve=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],we=U("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(H,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function B({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(_,a),{updateChargeAccountantApproval:r}=de();return e.jsx("td",{children:e.jsx(q,{value:l??void 0,onChange:o=>r({chargeId:c,status:o})})})}const be=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:r,cumulativeAmount:o})=>{const[n,s]=d.useState(!1),t=p(J,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[t.business?.name,t.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:t.vatNumber})]}),e.jsx("td",{children:t.image&&e.jsx("a",{href:t.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:t.image,height:80,width:80})})}),e.jsx("td",{children:t.documentSerial}),e.jsx("td",{children:t.documentDate}),e.jsx("td",{children:t.chargeDate}),e.jsx("td",{className:"whitespace-nowrap",children:t.amount.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localAmount?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVat?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.foreignVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.roundedLocalVatAfterDeduction?.formatted}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(o,0)]}),e.jsx(B,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(k,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(O,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p(Q,a)??{expenses:[]},[o,n]=d.useState(!0);let s=0,t=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(i=>!i),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Expenses"]}),o&&e.jsxs(P,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"VAT"}),e.jsx("th",{children:"VAT ₪"}),e.jsx("th",{children:"Actual VAT"}),e.jsx("th",{children:"Rounded VAT"}),e.jsx("th",{children:"Cumulative VAT"}),e.jsx("th",{children:"Amount without VAT ₪"}),e.jsx("th",{children:"Cumulative Amount without VAT ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((i,h)=>{s+=i.taxReducedLocalAmount?.raw??0;const u=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const m=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:m,cumulativeAmount:u},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p($,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[s.business?.name,s.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:s.vatNumber})]}),e.jsx("td",{children:s.image&&e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})})}),e.jsx("td",{children:s.documentSerial}),e.jsx("td",{children:s.documentDate}),e.jsx("td",{children:s.chargeDate}),e.jsx("td",{children:s.taxReducedForeignAmount?.formatted}),e.jsx("td",{children:s.taxReducedLocalAmount?.formatted}),e.jsx("td",{children:"₪ "+D(r,0)}),e.jsx(B,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(k,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(O,{chargeID:s.chargeId,fetching:!!s})})})})]})},Fe=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{income:r}=p(Y,a)??{income:[]},[o,n]=d.useState(!0);let s=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(t=>!t),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Income"]}),o&&e.jsxs(P,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"Cumulative Amount ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((t,i)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(De,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},Ne=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(K,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ie=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(W,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ae=({filter:{monthDate:a,financialEntityId:c},isLoading:l})=>{const[{data:r,fetching:o,error:n},s]=E({query:R(te),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),X.error("Error",{description:t,duration:5e3,closeButton:!0})}},[n]),d.useEffect(()=>{if(r){const t=new File([r.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Z(t)}},[r]),e.jsx(ee,{label:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:o||l,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(we,{className:"size-5"})})})};function Se({filter:a,setFilter:c,closeModal:l}){const{control:r,handleSubmit:o,setValue:n}=ae({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ne(),i=m=>{c(m),l()};function h(){c(),l()}function u(m){const x=new Date(m.getFullYear(),m.getMonth(),15);n("monthDate",N(x,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:o(i),children:[e.jsx(A,{name:"financialEntityId",control:r,defaultValue:void 0,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:s,value:m.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:x.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:ge,value:m.value??F.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:x.error?.message})}),e.jsx(re,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.monthDate):new Date,onChange:u,popoverProps:{withinPortal:!0}}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:h,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:l,children:"Cancel"})]})]})]})}function Me({filter:a,setFilter:c}){const[l,r]=d.useState(!1),{get:o,set:n}=z(),{userContext:s}=d.useContext(T);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:N(new Date,"yyyy-MM-15")},oe(i,a)||c(i)}return d.useEffect(()=>{const i=se(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(je,{opened:l,onClose:()=>r(!1),content:e.jsx(Se,{filter:a,setFilter:t,closeModal:()=>r(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})]})}const ot=()=>{const{get:a}=z(),{setFiltersContext:c}=d.useContext(ie),{userContext:l}=d.useContext(T),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:N(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=d.useState(void 0),[h,u]=d.useState(void 0),[m,x]=d.useState(void 0),[{data:j,fetching:b}]=E({query:R(le),variables:{filters:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(G=>G!==v)):s([...n,v])},[n]);function L(){s([])}d.useEffect(()=>{c(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:r,isLoading:b}),e.jsx(Me,{filter:{...r},setFilter:o}),e.jsx(he,{selected:n.map(v=>({id:v,onChange:()=>{}})),resetMerge:L})]}))},[j,r,b,c,n]);const C=d.useMemo(()=>new Set(n),[n]);return e.jsx(pe,{title:"VAT Monthly Report",children:b?e.jsx(ce,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.chargesType!==F.Expense&&e.jsx(Fe,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==F.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Ne,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),m&&e.jsx(me,{chargeId:m.id,close:()=>x(void 0)}),t&&e.jsx(xe,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(ue,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>u(void 0)})]})})};export{ot as VatMonthlyReport};
|
|
1
|
+
import{v as U,r as d,j as e,G as p,B as g,e5 as H,e6 as _,e7 as q,d3 as D,e8 as M,e9 as J,ea as Q,eb as $,ec as Y,ed as K,ee as W,u as E,t as X,ef as Z,T as ee,eg as te,aC as T,bw as se,y as ae,dm as ne,bz as A,bC as S,eh as F,bJ as re,w as N,bD as oe,F as ie,L as ce,ei as le}from"./index-mxG3trVw.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as z}from"./use-url-query-ajxKL7cF.js";import{C as I,u as de,a as V,b as O,M as he}from"./charges-table-CSBUejmC.js";import{E as me,I as xe,M as ue}from"./match-document-modal-aTCZMq3A.js";import{P as pe}from"./page-layout-e5dcoG31.js";import{P as w,a as y}from"./panel-top-open-C6S_S_l5.js";import{T as k}from"./toggle-expansion-button-Ve1efFB2.js";import{T as P}from"./Table-DBy_FInH.js";import{c as ge}from"./charges-filters-wTVkn57g.js";import{P as je}from"./modal-COWLg06g.js";import{F as fe}from"./funnel-Chi4RPzj.js";import"./index-BT0bQ-FL.js";import"./similar-transactions-modal-Dptc8s3r.js";import"./addDays-Dc61JWv1.js";import"./list-plus-BFzR0xCk.js";import"./tooltip-DViqX6TG.js";import"./summary-ySM0WfQM.js";import"./deposits-transactions-table-D2mHRvor.js";import"./Checkbox-BLRt_KKu.js";import"./accordion-DeZhxk_l.js";import"./data-table-column-header-FqJbxTUc.js";import"./eye-off-DX0qBOvM.js";import"./YearPickerInput-DhwaekfD.js";import"./insert-business-trip-modal-kI9R5YMW.js";import"./accounter-table-2XtMS86c.js";import"./sub-fkmgRadp.js";import"./subMonths-MMuRoKuu.js";import"./MultiSelect-Bd3apSs_.js";const ve=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],we=U("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(H,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Business Trips"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function B({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(_,a),{updateChargeAccountantApproval:r}=de();return e.jsx("td",{children:e.jsx(q,{value:l??void 0,onChange:o=>r({chargeId:c,status:o})})})}const be=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:r,cumulativeAmount:o})=>{const[n,s]=d.useState(!1),t=p(J,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[t.business?.name,t.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:t.vatNumber})]}),e.jsx("td",{children:t.image&&e.jsx("a",{href:t.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:t.image,height:80,width:80})})}),e.jsx("td",{children:t.documentSerial}),e.jsx("td",{children:t.documentDate}),e.jsx("td",{children:t.chargeDate}),e.jsx("td",{className:"whitespace-nowrap",children:t.amount.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localAmount?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVat?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.localVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.foreignVatAfterDeduction?.formatted}),e.jsx("td",{className:"whitespace-nowrap",children:t.roundedLocalVatAfterDeduction?.formatted}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",D(o,0)]}),e.jsx(B,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(k,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(O,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p(Q,a)??{expenses:[]},[o,n]=d.useState(!0);let s=0,t=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(i=>!i),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Expenses"]}),o&&e.jsxs(P,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"VAT"}),e.jsx("th",{children:"VAT ₪"}),e.jsx("th",{children:"Actual VAT"}),e.jsx("th",{children:"Rounded VAT"}),e.jsx("th",{children:"Cumulative VAT"}),e.jsx("th",{children:"Amount without VAT ₪"}),e.jsx("th",{children:"Cumulative Amount without VAT ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((i,h)=>{s+=i.taxReducedLocalAmount?.raw??0;const u=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const m=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:m,cumulativeAmount:u},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p($,a);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"bg-gray-100",children:[e.jsxs("td",{className:"flex flex-col gap-1",children:[s.business?.name,s.vatNumber&&e.jsx("span",{style:{fontSize:"10px",color:"darkGray"},children:s.vatNumber})]}),e.jsx("td",{children:s.image&&e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})})}),e.jsx("td",{children:s.documentSerial}),e.jsx("td",{children:s.documentDate}),e.jsx("td",{children:s.chargeDate}),e.jsx("td",{children:s.taxReducedForeignAmount?.formatted}),e.jsx("td",{children:s.taxReducedLocalAmount?.formatted}),e.jsx("td",{children:"₪ "+D(r,0)}),e.jsx(B,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(k,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(V,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(M,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(O,{chargeID:s.chargeId,fetching:!!s})})})})]})},Fe=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{income:r}=p(Y,a)??{income:[]},[o,n]=d.useState(!0);let s=0;return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>n(t=>!t),children:o?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Income"]}),o&&e.jsxs(P,{highlightOnHover:!0,children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:20},children:e.jsxs("tr",{className:"bg-gray-300",children:[e.jsx("th",{children:"Business"}),e.jsx("th",{children:"Invoice"}),e.jsx("th",{children:"Invoice Serial#"}),e.jsx("th",{children:"Invoice Date"}),e.jsx("th",{children:"Transaction Date"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Amount ₪"}),e.jsx("th",{children:"Cumulative Amount ₪"}),e.jsx("th",{children:"Accountant Approval"}),e.jsx("th",{colSpan:2,children:"Edit"})]})}),e.jsx("tbody",{children:r.map((t,i)=>{s+=t.taxReducedLocalAmount?.raw??0;const h=s;return e.jsx(De,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},Ne=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(K,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ie=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(W,a),[t,i]=d.useState(!0);return e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-lg font-semibold whitespace-nowrap flex flex-row gap-4",children:[e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>i(h=>!h),children:t?e.jsx(w,{className:"size-5"}):e.jsx(y,{className:"size-5"})}),"Missing Info"]}),t&&s&&e.jsx(I,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.missingInfo,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})},Ae=({filter:{monthDate:a,financialEntityId:c},isLoading:l})=>{const[{data:r,fetching:o,error:n},s]=E({query:R(te),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),X.error("Error",{description:t,duration:5e3,closeButton:!0})}},[n]),d.useEffect(()=>{if(r){const t=new File([r.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Z(t)}},[r]),e.jsx(ee,{label:"Generate and Download PCN874 File",children:e.jsx(g,{disabled:o||l,variant:"outline",size:"icon",className:"size-7.5",onClick:s,children:e.jsx(we,{className:"size-5"})})})};function Se({filter:a,setFilter:c,closeModal:l}){const{control:r,handleSubmit:o,setValue:n}=ae({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ne(),i=m=>{c(m),l()};function h(){c(),l()}function u(m){const x=new Date(m.getFullYear(),m.getMonth(),15);n("monthDate",N(x,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:o(i),children:[e.jsx(A,{name:"financialEntityId",control:r,defaultValue:void 0,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:s,value:m.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:x.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:m,fieldState:x})=>e.jsx(S,{...m,data:ge,value:m.value??F.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:x.error?.message})}),e.jsx(re,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.monthDate):new Date,onChange:u,popoverProps:{withinPortal:!0}}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:h,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:l,children:"Cancel"})]})]})]})}function Me({filter:a,setFilter:c}){const[l,r]=d.useState(!1),{get:o,set:n}=z(),{userContext:s}=d.useContext(T);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:N(new Date,"yyyy-MM-15")},oe(i,a)||c(i)}return d.useEffect(()=>{const i=se(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(je,{opened:l,onClose:()=>r(!1),content:e.jsx(Se,{filter:a,setFilter:t,closeModal:()=>r(!1)})}),e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})]})}const ot=()=>{const{get:a}=z(),{setFiltersContext:c}=d.useContext(ie),{userContext:l}=d.useContext(T),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:N(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=d.useState(void 0),[h,u]=d.useState(void 0),[m,x]=d.useState(void 0),[{data:j,fetching:b}]=E({query:R(le),variables:{filters:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(G=>G!==v)):s([...n,v])},[n]);function L(){s([])}d.useEffect(()=>{c(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ae,{filter:r,isLoading:b}),e.jsx(Me,{filter:{...r},setFilter:o}),e.jsx(he,{selected:n.map(v=>({id:v,onChange:()=>{}})),resetMerge:L})]}))},[j,r,b,c,n]);const C=d.useMemo(()=>new Set(n),[n]);return e.jsx(pe,{title:"VAT Monthly Report",children:b?e.jsx(ce,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.chargesType!==F.Expense&&e.jsx(Fe,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==F.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Ne,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),m&&e.jsx(me,{chargeId:m.id,close:()=>x(void 0)}),t&&e.jsx(xe,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(ue,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>u(void 0)})]})})};export{ot as VatMonthlyReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as b,r as o,j as a,B as D,bX as R,gj as w,ag as i,bU as f,bK as y,bL as C,bM as s,bN as N,b_ as d,bO as I,bP as r,d5 as v,fy as B,i8 as F,c1 as E,c2 as S}from"./index-
|
|
1
|
+
import{u as b,r as o,j as a,B as D,bX as R,gj as w,ag as i,bU as f,bK as y,bL as C,bM as s,bN as N,b_ as d,bO as I,bP as r,d5 as v,fy as B,i8 as F,c1 as E,c2 as S}from"./index-mxG3trVw.js";import{D as T}from"./deposits-transactions-table-D2mHRvor.js";function V(){const[{data:c,fetching:g},p]=b({query:B}),[u,x]=o.useState([{id:"openDate",desc:!1}]),m=o.useMemo(()=>(c?.allDeposits??[]).map(t=>({id:t.id,currency:t.currency,openDate:t.openDate,closeDate:t.closeDate??null,isOpen:t.isOpen,currencyError:t.currencyError??[],currentBalanceRaw:t.currentBalance?.raw??0,currentBalanceFormatted:t.currentBalance?.formatted??"",totalDepositRaw:t.totalDeposit?.raw??0,totalDepositFormatted:t.totalDeposit?.formatted??"",totalInterestRaw:t.totalInterest?.raw??0,totalInterestFormatted:t.totalInterest?.formatted??""})),[c]),n=o.useRef([{id:"expander",header:()=>null,cell:({row:e})=>a.jsx(D,{variant:"ghost",size:"icon",onClick:()=>e.toggleExpanded(),"aria-label":e.getIsExpanded()?"Collapse":"Expand",children:e.getIsExpanded()?a.jsx(R,{}):a.jsx(w,{})}),enableSorting:!1},{accessorKey:"id",header:"Deposit ID",cell:e=>a.jsx("span",{className:"font-mono text-xs",children:e.getValue()})},{accessorKey:"currency",header:"Currency"},{accessorKey:"isOpen",header:"Status",cell:e=>e.getValue()?a.jsx(i,{className:"bg-green-600 text-white",variant:"secondary",children:"Open"}):a.jsx(i,{variant:"secondary",children:"Closed"}),sortingFn:(e,t)=>Number(e.original.isOpen)-Number(t.original.isOpen)},{accessorKey:"openDate",header:"Open Date",cell:e=>a.jsx("span",{children:e.getValue()})},{accessorKey:"closeDate",header:"Close Date",cell:e=>a.jsx("span",{children:e.getValue()??"-"}),sortingFn:(e,t)=>{const h=e.original.closeDate??"",j=t.original.closeDate??"";return h.localeCompare(j)}},{id:"totalDeposit",header:"Total Deposit",accessorFn:e=>e.totalDepositRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalDepositFormatted}),sortingFn:(e,t)=>e.original.totalDepositRaw-t.original.totalDepositRaw},{id:"currentBalance",header:"Current Balance",accessorFn:e=>e.currentBalanceRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.currentBalanceFormatted}),sortingFn:(e,t)=>e.original.currentBalanceRaw-t.original.currentBalanceRaw},{id:"totalInterest",header:"Total Interest",accessorFn:e=>e.totalInterestRaw,cell:e=>a.jsx("span",{className:"tabular-nums",children:e.row.original.totalInterestFormatted}),sortingFn:(e,t)=>e.original.totalInterestRaw-t.original.totalInterestRaw}]).current,l=f({data:m,columns:n,state:{sorting:u},onSortingChange:x,getCoreRowModel:S(),getSortedRowModel:E(),getExpandedRowModel:F(),getRowCanExpand:()=>!0});return a.jsxs("div",{className:"max-w-[95vw]",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsx("h1",{className:"text-2xl font-semibold",children:"Bank Deposits"})}),a.jsx("div",{className:"mt-6 overflow-hidden rounded-md border",children:a.jsxs(y,{children:[a.jsx(C,{children:l.getHeaderGroups().map(e=>a.jsx(s,{children:e.headers.map(t=>a.jsx(N,{colSpan:t.colSpan,children:t.isPlaceholder?null:d(t.column.columnDef.header,t.getContext())},t.id))},e.id))}),a.jsx(I,{children:g?a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"Loading..."})}):l.getRowModel().rows?.length?l.getRowModel().rows.map(e=>a.jsxs(a.Fragment,{children:[a.jsx(s,{"data-state":e.getIsSelected()&&"selected",children:e.getVisibleCells().map(t=>a.jsx(r,{children:d(t.column.columnDef.cell,t.getContext())},t.id))},e.id),e.getIsExpanded()?a.jsx(s,{children:a.jsxs(r,{colSpan:n.length,children:[e.original.currencyError.length>0&&a.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-800",children:[a.jsx(v,{className:"size-4"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:"Currency Conflict"}),a.jsxs("div",{className:"opacity-90",children:["Affected transaction IDs: ",e.original.currencyError.join(", ")]})]})]}),a.jsx(T,{depositId:e.original.id,enableReassign:!0,refetch:p})]})}):null]})):a.jsx(s,{children:a.jsx(r,{colSpan:n.length,className:"h-24 text-center",children:"No results."})})})]})})]})}export{V as DepositsScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as x,ca as h,G as T,r,j as s,bx as g,cb as j,F as B,T as w,at as C,L as v,a3 as E,cc as P}from"./index-
|
|
1
|
+
import{u as x,ca as h,G as T,r,j as s,bx as g,cb as j,F as B,T as w,at as C,L as v,a3 as E,cc as P}from"./index-mxG3trVw.js";import{E as b,P as y,C as L}from"./editable-business-trip-B3H295Cd.js";import{I as F}from"./insert-business-trip-modal-kI9R5YMW.js";import{P as I}from"./page-layout-e5dcoG31.js";import{A as m}from"./summary-ySM0WfQM.js";import"./list-plus-BFzR0xCk.js";import"./Table-DBy_FInH.js";import"./toggle-expansion-button-Ve1efFB2.js";import"./panel-top-open-C6S_S_l5.js";import"./MultiSelect-Bd3apSs_.js";import"./similar-transactions-modal-Dptc8s3r.js";import"./tooltip-DViqX6TG.js";const S=({data:d,isOpened:o,shouldValidate:l})=>{const e=T(j,d),[{data:i,fetching:a}]=x({pause:!l,query:h,variables:{id:e.id}}),c=r.useMemo(()=>l?i?.businessTrip&&(i.businessTrip.uncategorizedTransactions?.length||i?.businessTrip.summary?.errors?.length):!1,[i]),u=c||e?.accountantApproval!=="APPROVED";return s.jsxs(m.Item,{value:e.id,children:[s.jsx(m.Control,{children:s.jsx(g,{inline:!0,size:12,processing:a,disabled:!u,color:c?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(m.Panel,{children:o&&s.jsx(b,{tripId:e.id,isExtended:!0},e.id)})]})},U=()=>{const{setFiltersContext:d}=r.useContext(B),[o,l]=r.useState([]),[e,i]=r.useState(!1),[{data:a,fetching:c}]=x({query:P});r.useEffect(()=>{if(!a?.allBusinessTrips?.length){l([]);return}const t=a.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[a?.allBusinessTrips]);const[u,f]=r.useState([]);return r.useEffect(()=>{d(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(F,{}),s.jsx(w,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(C,{checked:e??!1,onCheckedChange:t=>i(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(y,{filename:"business_trips"})]}))},[a,c,d,e]),s.jsx(I,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&c?s.jsx(v,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(L,{children:s.jsx(m,{className:"w-full",multiple:!0,value:u,onChange:f,chevron:s.jsx(E,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:u.includes(t.id)},t.id))})})})};export{U as BusinessTrips};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,bD as _,j as e,bx as k,B as I,bw as V,y as Q,by as G,dm as K,b0 as q,dn as z,bz as y,bC as L,bA as F,bB as B,w as S,u as R,gM as X,J as P,c as U,K as $,O as J,a4 as W,W as Y,F as Z,aC as ee,b4 as ae,Q as se,dT as te,gN as re,ay as ne}from"./index-BUihugVY.js";import{u as O}from"./use-url-query-CdCUwmEx.js";import{P as oe}from"./page-layout-C0UTw1XM.js";import{k as ie,B as N,X as H,Y as le,l as ce,m as de,n as ue,o as me,p as pe,q as xe,r as ge}from"./chart-Xk9GqEcg.js";import{P as he}from"./modal-B0kytztz.js";import{F as fe}from"./funnel-gF7kKj_6.js";import{M as A}from"./MultiSelect-Ci9EZTZI.js";import{T as be}from"./index-r-Alribw.js";import{s as je}from"./sub-JQsW8K1m.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-CebBOt3D.js";import"./addDays-BlCa-jFS.js";import"./list-plus-BRJGZyM3.js";import"./tooltip-BCx6OnVj.js";import"./subMonths-W56yPxRG.js";var ye=ie({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:le}],formatAxisMap:ce});function ve(s){return!s||V(s)?null:encodeURIComponent(JSON.stringify(s))}const E="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:i,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=Q({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=G(),{selectableFinancialEntities:f,fetching:v}=K(),{selectableTags:p,fetching:j}=q(),M=a=>{i(a),c()},C=g("excludedTags"),o=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),n=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:o,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:n,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:i,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=O();m.useEffect(()=>{const p=ve(s),j=h(E);p!==j&&f(E,p)},[s,h,f]);const v=m.useCallback(p=>{_(p,s)||(i(p),b(!!p))},[s,i]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(he,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(k,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:i,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=R({query:X,variables:{transactionIDs:i}}),g=m.useMemo(()=>t?.transactionsByIDs?i.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,i]);return e.jsx(P,{className:"mt-5 w-full",children:r?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs(J,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(W,{className:"h-4 w-4"})})]})}),e.jsx(Y,{children:e.jsx(be,{transactionsProps:g})})]})})},w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,i,c){switch(c){case x.MONTHLY:{const t=String(i).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=i%2===0?i-1:i,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(i/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=i>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,i){switch(i){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=te(ne.Usd),_e=()=>{const{setFiltersContext:s}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=O(),t=m.useMemo(()=>{const o={ownerId:i?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(je(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(E);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(n){console.log("Error parsing balance report filters from URL:",n)}return o},[i?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:o,fromDate:d,toDate:n}=r;return{ownerId:o,fromDate:d,toDate:n}},[r]),[{data:j,fetching:M}]=R({query:re,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ae,{options:Object.entries(w).map(([o,d])=>({label:d.label,value:o})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(o=>({...o,ownerId:i?.context.adminBusinessId}))},[i]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const o=new Map;j.transactionsForBalanceReport.map(n=>{if(n.counterparty?.id&&(!n.isFee&&i?.context.financialAccountsBusinessesIds?.includes(n.counterparty.id)||r.excludedCounterparties?.includes(n.counterparty.id))||r.includedTags.length>0&&(!n.charge?.tags||n.charge.tags.length===0||!n.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&n.charge?.tags.length&&n.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(n.year,n.month,r.period);o.has(a)||o.set(a,{income:0,expense:0,delta:0,transactions:[]});const l=o.get(a);n.amountUsd.raw>0?l.income+=n.amountUsd.raw:l.expense+=n.amountUsd.raw,l.delta+=n.amountUsd.raw,l.transactions.push(n)});let d=0;return Array.from(o.entries()).sort((n,a)=>n[0].localeCompare(a[0])).map(([n,a])=>(d+=a.delta,{period:n,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((l,u)=>Math.abs(u.amountUsd.raw)-Math.abs(l.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,i?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full",children:[e.jsx($,{children:e.jsx(se,{children:"Click specific period to expand it's transactions data"})}),e.jsx(Y,{children:e.jsx(de,{config:w,className:"h-150 w-full",children:e.jsxs(ye,{accessibilityLayer:!0,data:C,onClick:o=>h(o.activeLabel),children:[e.jsx(ue,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:o=>Me(o,r.period)}),e.jsx(me,{content:e.jsx(pe,{formatter:(o,d,n,a)=>{const l=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${l} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${l}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]})}})}),e.jsx(xe,{content:e.jsx(ge,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{_e as BalanceReport};
|
|
1
|
+
import{r as m,bD as _,j as e,bx as k,B as I,bw as V,y as Q,by as G,dm as K,b0 as q,dn as z,bz as y,bC as L,bA as F,bB as B,w as S,u as R,gM as X,J as P,c as U,K as $,O as J,a4 as W,W as Y,F as Z,aC as ee,b4 as ae,Q as se,dT as te,gN as re,ay as ne}from"./index-mxG3trVw.js";import{u as O}from"./use-url-query-ajxKL7cF.js";import{P as oe}from"./page-layout-e5dcoG31.js";import{k as ie,B as N,X as H,Y as le,l as ce,m as de,n as ue,o as me,p as pe,q as xe,r as ge}from"./chart-B-Utupss.js";import{P as he}from"./modal-COWLg06g.js";import{F as fe}from"./funnel-Chi4RPzj.js";import{M as A}from"./MultiSelect-Bd3apSs_.js";import{T as be}from"./index-BT0bQ-FL.js";import{s as je}from"./sub-fkmgRadp.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-Dptc8s3r.js";import"./addDays-Dc61JWv1.js";import"./list-plus-BFzR0xCk.js";import"./tooltip-DViqX6TG.js";import"./subMonths-MMuRoKuu.js";var ye=ie({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:le}],formatAxisMap:ce});function ve(s){return!s||V(s)?null:encodeURIComponent(JSON.stringify(s))}const E="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:i,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=Q({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=G(),{selectableFinancialEntities:f,fetching:v}=K(),{selectableTags:p,fetching:j}=q(),M=a=>{i(a),c()},C=g("excludedTags"),o=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),n=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:o,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:n,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:i,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=O();m.useEffect(()=>{const p=ve(s),j=h(E);p!==j&&f(E,p)},[s,h,f]);const v=m.useCallback(p=>{_(p,s)||(i(p),b(!!p))},[s,i]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(he,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(k,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:i,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=R({query:X,variables:{transactionIDs:i}}),g=m.useMemo(()=>t?.transactionsByIDs?i.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,i]);return e.jsx(P,{className:"mt-5 w-full",children:r?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs(J,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(W,{className:"h-4 w-4"})})]})}),e.jsx(Y,{children:e.jsx(be,{transactionsProps:g})})]})})},w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,i,c){switch(c){case x.MONTHLY:{const t=String(i).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=i%2===0?i-1:i,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(i/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=i>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,i){switch(i){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=te(ne.Usd),_e=()=>{const{setFiltersContext:s}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=O(),t=m.useMemo(()=>{const o={ownerId:i?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(je(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(E);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(n){console.log("Error parsing balance report filters from URL:",n)}return o},[i?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:o,fromDate:d,toDate:n}=r;return{ownerId:o,fromDate:d,toDate:n}},[r]),[{data:j,fetching:M}]=R({query:re,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ae,{options:Object.entries(w).map(([o,d])=>({label:d.label,value:o})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(o=>({...o,ownerId:i?.context.adminBusinessId}))},[i]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const o=new Map;j.transactionsForBalanceReport.map(n=>{if(n.counterparty?.id&&(!n.isFee&&i?.context.financialAccountsBusinessesIds?.includes(n.counterparty.id)||r.excludedCounterparties?.includes(n.counterparty.id))||r.includedTags.length>0&&(!n.charge?.tags||n.charge.tags.length===0||!n.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&n.charge?.tags.length&&n.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(n.year,n.month,r.period);o.has(a)||o.set(a,{income:0,expense:0,delta:0,transactions:[]});const l=o.get(a);n.amountUsd.raw>0?l.income+=n.amountUsd.raw:l.expense+=n.amountUsd.raw,l.delta+=n.amountUsd.raw,l.transactions.push(n)});let d=0;return Array.from(o.entries()).sort((n,a)=>n[0].localeCompare(a[0])).map(([n,a])=>(d+=a.delta,{period:n,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((l,u)=>Math.abs(u.amountUsd.raw)-Math.abs(l.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,i?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full",children:[e.jsx($,{children:e.jsx(se,{children:"Click specific period to expand it's transactions data"})}),e.jsx(Y,{children:e.jsx(de,{config:w,className:"h-150 w-full",children:e.jsxs(ye,{accessibilityLayer:!0,data:C,onClick:o=>h(o.activeLabel),children:[e.jsx(ue,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:o=>Me(o,r.period)}),e.jsx(me,{content:e.jsx(pe,{formatter:(o,d,n,a)=>{const l=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${l} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${l}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]})}})}),e.jsx(xe,{content:e.jsx(ge,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{_e as BalanceReport};
|