@accounter/client 0.0.8-alpha-20251027003629-e64c01111f4a4cec34d5ca9a84e02646b69f80b1 → 0.0.8-alpha-20251027125446-75cc2031ef62f7abf48ecfbd31f62ddbddee2bd8
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-DjollWGm.js → Checkbox-BzSHHEEI.js} +2 -2
- package/dist/assets/{Progress-AG7ZMAJu.js → Progress-CmZjJ77Z.js} +1 -1
- package/dist/assets/{Typography-Cd0kk1vc.js → Typography-CuW3aX-4.js} +1 -1
- package/dist/assets/{accordion-s9Ku08QQ.js → accordion-BZB-JxAM.js} +1 -1
- package/dist/assets/{accountant-approvals-Bqrsn1y5.js → accountant-approvals-BtF90Myx.js} +1 -1
- package/dist/assets/{all-charges-BQcsaMon.js → all-charges-X26mmfb3.js} +1 -1
- package/dist/assets/{arrow-up-down-J-i_WnHP.js → arrow-up-down-_p0E2yis.js} +1 -1
- package/dist/assets/{building-2-B92gXbOj.js → building-2-CKq13SAn.js} +1 -1
- package/dist/assets/business--pLros0g.js +27 -0
- package/dist/assets/{business-header-Cr5S_Mz7.js → business-header-C8fXEo4_.js} +1 -1
- package/dist/assets/{business-transactions-single-BD4bLNv2.js → business-transactions-single-CXmdF2-o.js} +1 -1
- package/dist/assets/{business-trip-DYkKK6Gk.js → business-trip-wd9Embtb.js} +1 -1
- package/dist/assets/{charges-filters-CoFkjW00.js → charges-filters-Fu2ZAzWC.js} +1 -1
- package/dist/assets/{charges-ledger-validation-D_cg1bn-.js → charges-ledger-validation-BXXhWS5W.js} +1 -1
- package/dist/assets/{chart-CQ9Opsuw.js → chart-3ddx32Qz.js} +1 -1
- package/dist/assets/{data-table-pagination-CN5CnGZV.js → data-table-pagination-BopLOYg9.js} +1 -1
- package/dist/assets/{editable-business-trip--kNXo9tv.js → editable-business-trip-C34Ue7Hf.js} +2 -2
- package/dist/assets/{index-BNtiIPMq.js → index-B0uGI3EC.js} +1 -1
- package/dist/assets/{index-BGHdyfCs.js → index-B6vWXPp8.js} +1 -1
- package/dist/assets/{index-n3bzj3IE.js → index-BEtUypi7.js} +2 -2
- package/dist/assets/{index-CC_fLCrA.js → index-BGW4bQ-L.js} +1 -1
- package/dist/assets/{index-Cw9zbBbJ.js → index-BpCZ3X72.js} +7 -7
- package/dist/assets/{index-C3pV-XkD.js → index-BsqMXEt3.js} +2 -2
- package/dist/assets/{index-DNTlYcfH.js → index-CkFRewFP.js} +2 -2
- package/dist/assets/{index-hr9hQe_a.js → index-Cr24h-Cl.js} +1 -1
- package/dist/assets/{index-Au8Djmrz.js → index-CuczBTlN.js} +1 -1
- package/dist/assets/{index-DzNfXERJ.js → index-CvS1Q-ya.js} +1 -1
- package/dist/assets/{index-DDGgWxhe.js → index-DA1mkO2v.js} +2 -2
- package/dist/assets/{index-DfI9E1Fb.js → index-DL8q44ap.js} +263 -258
- package/dist/assets/{index-fwXllLnH.js → index-DeQnadsl.js} +1 -1
- package/dist/assets/{index-DS_RReq_.js → index-Dia_wOFb.js} +1 -1
- package/dist/assets/{index-DepseT6D.js → index-HzZyyExI.js} +1 -1
- package/dist/assets/{index-C7al3ztL.js → index-JfxexlPg.js} +2 -2
- package/dist/assets/{index-BWpLPx22.js → index-PaJBRncn.js} +1 -1
- package/dist/assets/index-SmrmFP8m.js +1 -0
- package/dist/assets/{index-BSmbKLQe.js → index-cZSBCnNJ.js} +2 -2
- package/dist/assets/{index-CS40C1qp.js → index-dP8CSci_.js} +1 -1
- package/dist/assets/{index-Cc4HfGhd.js → index-o-HWUpBy.js} +1 -1
- package/dist/assets/{index--XWh2RKR.js → index-pjGYYOoy.js} +1 -1
- package/dist/assets/{index-C66UYUUf.js → index-szVd1r0-.js} +1 -1
- package/dist/assets/{index.es-CKlpQqlO.js → index.es-ZISWba9V.js} +1 -1
- package/dist/assets/{issue-document-B4kkfOo0.js → issue-document-B-c96E9w.js} +1 -1
- package/dist/assets/{login-page-NvQKYh34.js → login-page-C_RNlOZS.js} +1 -1
- package/dist/assets/{missing-info-charges-DrF2b0mO.js → missing-info-charges-BrFjY7yz.js} +1 -1
- package/dist/assets/{page-not-found-7AAOkZhu.js → page-not-found-s0xtsc5O.js} +1 -1
- package/dist/assets/{pencil-DNPAJOPL.js → pencil-D-2dJ444.js} +1 -1
- package/dist/assets/{report-commentary-row-CF-l1YIC.js → report-commentary-row-aIxbqTgK.js} +1 -1
- package/dist/assets/{save-D84vX5ea.js → save-DZ9jxz9u.js} +1 -1
- package/dist/assets/{sub-BbpGm1pj.js → sub-o9iEG2Bl.js} +1 -1
- package/dist/assets/subMonths-CpJ3oidH.js +1 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/clients/modify-client-dialog.tsx +27 -9
- package/src/components/common/modals/insert-business.tsx +87 -36
- package/src/components/layout/user-nav.tsx +25 -3
- package/dist/assets/business-CfqFJUkR.js +0 -32
- package/dist/assets/index-DVbMTBK4.js +0 -1
- package/dist/assets/subMonths-0tIJizDp.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{D as q,r as d,j as e,X as p,B as g,P as w,b as y,C as F,
|
|
1
|
+
import{D as q,r as d,j as e,X as p,B as g,P as w,b as y,C as F,el as G,em as H,en as _,eo as Q,cT as D,cn as M,ep as E,eq as T,er as R,es as $,et as J,cb as V,eu as X,ev as Y,ew as K,ex as W,a as z,t as Z,ey as ee,T as te,ez as se,u as O,af as k,c_ as ae,c$ as ne,d0 as re,V as oe,di as ie,bP as A,bQ as S,eA as N,dc as ce,H as I,d1 as le,F as de,c as he,L as xe,E as ue,I as me,M as pe,eB as ge}from"./index-DL8q44ap.js";import{d as B}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{M as je}from"./index-DA1mkO2v.js";import{c as fe}from"./charges-filters-Fu2ZAzWC.js";import"./Checkbox-BzSHHEEI.js";import"./sub-o9iEG2Bl.js";import"./subMonths-CpJ3oidH.js";/**
|
|
2
2
|
* @license lucide-react v0.546.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ve=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]],we=q("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(G,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(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function P({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(H,a),{updateChargeAccountantApproval:r}=_();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($,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(P,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(R,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(T,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p(J,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(V,{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 m=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const x=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:x,cumulativeAmount:m},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p(X,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(P,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(R,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(T,{chargeID:s.chargeId,fetching:!!s})})})})]})},Ne=({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(V,{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)})})]})]})},Fe=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(Z,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(F,{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(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"})}),"Missing Info"]}),t&&s&&e.jsx(F,{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]=z({query:B(se),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),W.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"});ee(t)}},[r]),e.jsx(te,{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}=oe({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ie(),i=x=>{c(x),l()};function h(){c(),l()}function m(x){const u=new Date(x.getFullYear(),x.getMonth(),15);n("monthDate",I(u,"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:x,fieldState:u})=>e.jsx(S,{...x,data:s,value:x.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:x,fieldState:u})=>e.jsx(S,{...x,data:fe,value:x.value??N.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:u.error?.message})}),e.jsx(ce,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.monthDate):new Date,onChange:m,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}=O(),{userContext:s}=d.useContext(k);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:I(new Date,"yyyy-MM-15")},le(i,a)||c(i)}return d.useEffect(()=>{const i=ae(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(ne,{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(re,{className:"size-5"})})]})}const Be=()=>{const{get:a}=O(),{setFiltersContext:c}=d.useContext(de),{userContext:l}=d.useContext(k),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:I(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=d.useState(void 0),[h,m]=d.useState(void 0),[x,u]=d.useState(void 0),[{data:j,fetching:b}]=z({query:B(ge),variables:{filters:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(U=>U!==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(je,{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(he,{title:"VAT Monthly Report",children:b?e.jsx(xe,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.chargesType!==N.Expense&&e.jsx(Ne,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==N.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Fe,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),x&&e.jsx(ue,{chargeId:x.id,close:()=>u(void 0)}),t&&e.jsx(me,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(pe,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>m(void 0)})]})})};export{Be as VatMonthlyReport};
|
|
6
|
+
*/const ve=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["rect",{width:"4",height:"6",x:"2",y:"12",rx:"2",key:"jm304g"}],["path",{d:"M10 12h2v6",key:"12zw74"}],["path",{d:"M10 18h4",key:"1ulq68"}]],we=q("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(G,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(F,{setEditChargeId:c,setInsertDocument:l,setMatchDocuments:r,data:s.businessTrips,isAllOpened:!1,toggleMergeCharge:o,mergeSelectedCharges:n})]})};function P({data:a}){const{chargeId:c,chargeAccountantStatus:l}=p(H,a),{updateChargeAccountantApproval:r}=_();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($,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(P,{data:t}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:s,isExpanded:n})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(t.chargeId),mergeSelected:l.includes(t.chargeId)})})]}),n&&e.jsx("tr",{children:e.jsx("td",{colSpan:17,children:e.jsx(T,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(R,{chargeID:t.chargeId,fetching:!!t})})})})]})},Ce=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l})=>{const{expenses:r}=p(J,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(V,{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 m=s;t+=i.roundedLocalVatAfterDeduction?.raw??0;const x=t;return e.jsx(be,{data:i,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeVat:x,cumulativeAmount:m},h)})})]})]})},De=({data:a,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:r})=>{const[o,n]=d.useState(!1),s=p(X,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(P,{data:s}),e.jsx("td",{children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(M,{toggleExpansion:n,isExpanded:o})})}),e.jsx("td",{children:e.jsx(E,{toggleMergeSelected:()=>c(s.chargeId),mergeSelected:l.includes(s.chargeId)})})]}),o&&e.jsx("tr",{children:e.jsx("td",{colSpan:11,children:e.jsx(T,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(R,{chargeID:s.chargeId,fetching:!!s})})})})]})},Ne=({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(V,{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)})})]})]})},Fe=({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(F,{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(F,{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]=z({query:B(se),pause:!0,variables:{monthDate:a,financialEntityId:c}});return d.useEffect(()=>{if(n){const t="Error generating PCN874 file";console.error(`${t}: ${n}`),Z.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"});ee(t)}},[r]),e.jsx(te,{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}=oe({defaultValues:{...a}}),{selectableFinancialEntities:s,fetching:t}=ie(),i=x=>{c(x),l()};function h(){c(),l()}function m(x){const u=new Date(x.getFullYear(),x.getMonth(),15);n("monthDate",I(u,"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:x,fieldState:u})=>e.jsx(S,{...x,data:s,value:x.value,disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:u.error?.message})}),e.jsx(A,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:x,fieldState:u})=>e.jsx(S,{...x,data:fe,value:x.value??N.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:u.error?.message})}),e.jsx(ce,{defaultValue:a?.monthDate?new Date(a.monthDate):new Date,defaultDate:a?.monthDate?new Date(a.monthDate):new Date,onChange:m,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}=O(),{userContext:s}=d.useContext(k);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:I(new Date,"yyyy-MM-15")},le(i,a)||c(i)}return d.useEffect(()=>{const i=ae(a??{})?null:encodeURIComponent(JSON.stringify(a)),h=o("vatMonthlyReportFilters");i!==h&&n("vatMonthlyReportFilters",i)},[a,o,n]),e.jsxs(e.Fragment,{children:[e.jsx(ne,{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(re,{className:"size-5"})})]})}const Be=()=>{const{get:a}=O(),{setFiltersContext:c}=d.useContext(de),{userContext:l}=d.useContext(k),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:I(new Date,"yyyy-MM-15")}),[n,s]=d.useState([]),[t,i]=d.useState(void 0),[h,m]=d.useState(void 0),[x,u]=d.useState(void 0),[{data:j,fetching:b}]=z({query:B(ge),variables:{filters:r}}),f=d.useCallback(v=>{n.includes(v)?s(n.filter(U=>U!==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(je,{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(he,{title:"VAT Monthly Report",children:b?e.jsx(xe,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.chargesType!==N.Expense&&e.jsx(Ne,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),r.chargesType!==N.Income&&e.jsx(Ce,{data:j?.vatReport,toggleMergeCharge:f,mergeSelectedCharges:n}),e.jsx(Ie,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(ye,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),e.jsx(Fe,{data:j?.vatReport,setEditCharge:u,setInsertDocument:i,setMatchDocuments:m,toggleMergeCharge:f,mergeSelectedCharges:C}),x&&e.jsx(ue,{chargeId:x.id,close:()=>u(void 0)}),t&&e.jsx(me,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(pe,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>m(void 0)})]})})};export{Be as VatMonthlyReport};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c_ as f,r as h,u as B,j as e,c$ as N,bA as $,B as w,d0 as R,V as k,ce as O,af as A,a1 as E,bP as v,ci as D,bU as C,bV as F,H as T,a3 as z,a4 as P,a5 as V,a6 as L,ap as M,d1 as U,dS as _,c0 as S,T as I,P as q,b as G,bh as H,b6 as j,aV as p,X as Z,dT as J,cb as Q,cT as y,F as W,a as X,dU as K,dV as Y,c as ee,L as te,dW as se}from"./index-DL8q44ap.js";function ae(t){return!t||f(t)?null:encodeURIComponent(JSON.stringify(t))}function re({filter:t,setFilter:s,closeModal:o}){const n=k({defaultValues:{...t}}),{control:r,handleSubmit:l}=n,{selectableBusinesses:a,fetching:u}=O(),{userContext:m}=h.useContext(A),c=i=>{i.fromDate?.trim()===""&&(i.fromDate=void 0),i.toDate?.trim()===""&&(i.toDate=void 0),s(i),o()};function d(){s({}),o()}return e.jsxs(e.Fragment,{children:[u?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(E,{...n,children:e.jsxs("form",{onSubmit:l(c),className:"space-y-2",children:[e.jsx(v,{name:"ownerIds",control:r,defaultValue:void 0,render:({field:i,fieldState:b})=>e.jsx(D,{...i,data:a,value:i.value??(m?.context.adminBusinessId?[m?.context.adminBusinessId]:void 0),disabled:u,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(v,{name:"businessIDs",control:r,defaultValue:void 0,render:({field:i,fieldState:b})=>e.jsx(D,{...i,data:a,value:i.value??void 0,disabled:u,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(v,{name:"fromDate",control:r,defaultValue:t.fromDate,rules:{required:"Required",pattern:{value:C,message:"Date must be im format yyyy-mm-dd"}},render:({field:i,fieldState:b})=>e.jsx(F,{...i,onChange:x=>{const g=x?typeof x=="string"?x:T(x,"yyyy-MM-dd"):void 0;g!==i.value&&i.onChange(g)},value:i.value?new Date(i.value):void 0,label:"From Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(v,{name:"toDate",control:r,defaultValue:t.toDate,rules:{pattern:{value:C,message:"Date must be im format yyyy-mm-dd"}},render:({field:i,fieldState:b})=>e.jsx(F,{...i,onChange:x=>{const g=x?typeof x=="string"?x:T(x,"yyyy-MM-dd"):void 0;g!==i.value&&i.onChange(g)},value:i.value?new Date(i.value):void 0,label:"To Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(z,{name:"isShowZeroedAccounts",control:r,render:({field:i})=>e.jsxs(P,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(V,{children:"Show zeroed accounts"})}),e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(L,{children:e.jsx(M,{defaultChecked:t.isShowZeroedAccounts??!1,onCheckedChange:i.onChange,checked:i.value===!0})}),e.jsx("span",{children:i.value?"show":"remove"})]})]})}),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:d,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:o,children:"Cancel"})]})]})})]})}function ne({filter:t,setFilter:s}){const[o,n]=h.useState(!1),[r,l]=h.useState(!f(t)),{get:a,set:u}=B();function m(d){return Object.entries(d??{}).filter(([b,x])=>x!==void 0&&Array.isArray(x)&&x.length>0).length>0}function c(d){U(d,t)||(s(d),l(m(d)))}return h.useEffect(()=>{const d=f(t)?null:encodeURIComponent(JSON.stringify(t)),i=a("trialBalanceReportFilters");d!==i&&u("trialBalanceReportFilters",d)},[t,a,u]),e.jsxs(e.Fragment,{children:[e.jsx(N,{opened:o,onClose:()=>n(!1),content:e.jsx(re,{filter:t,setFilter:c,closeModal:()=>n(!1)})}),e.jsx($,{inline:!0,size:16,disabled:!r,children:e.jsx(w,{variant:"outline",onClick:()=>n(!0),className:"p-2",children:e.jsx(R,{size:20})})})]})}const oe=({data:t,fromDate:s,toDate:o})=>{const n=h.useCallback(async()=>{const r=le(t),l=`trial_balance_report${s?`_${s}`:""}${o?`_${o}`:""}`;return{fileContent:r,fileName:l}},[t,s,o]);return e.jsx(_,{createFileVariables:n})},le=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
|
|
2
2
|
`;for(const[o,n]of Object.entries(t)){const r=ie(o,n);s+=r}return s+=`Report total:,,${Object.values(t).reduce((o,n)=>o+n.totalDebit,0)},${Object.values(t).reduce((o,n)=>o+n.totalCredit,0)},${Object.values(t).reduce((o,n)=>o+n.sum,0)}\r
|
|
3
3
|
`,s};function ie(t,s){let o="";return Object.values(s.sortCodes).sort((n,r)=>n.key-r.key).map(n=>{const r=ce(n);o+=r}),o+=`${t.replaceAll("0","*")},Group Total:,${s.totalDebit??""},${s.totalCredit??""},${s.sum}\r
|
|
4
4
|
`,o}function ce(t){let s="";s+=`${t.name}\r
|
|
@@ -6,4 +6,4 @@ import{cZ as f,r as h,u as B,j as e,c_ as $,bz as N,B as S,c$ as R,V as k,cd as
|
|
|
6
6
|
`;s+=c});const o=`${t.key},Group total:,${t.totalDebit??""},${t.totalCredit??""},${t.sum}\r
|
|
7
7
|
`;s+=o;const n=t.debit?`,,,Total Debit Balances:,${t.debit}\r
|
|
8
8
|
`:"";s+=n;const r=t.credit?`,,,Total Credit Balances:,${t.credit}\r
|
|
9
|
-
`:"";return s+=r,s}function de(t){let s="";return s=t.replace(/"/g,'""'),s}const ue=({record:t,sortCodeKey:s,filter:o,isAllOpened:n})=>{const[r,l]=h.useState(n),a=t?.total?.raw??0,u=t?.debit?.raw??0,m=t?.credit?.raw??0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:s}),e.jsx("td",{children:t.business.id}),e.jsx("td",{children:t.business.name??void 0}),e.jsx("td",{children:u?t?.debit?.formatted:void 0}),e.jsx("td",{children:m?t?.credit?.formatted:void 0}),e.jsx("td",{children:(a>.001||a<-.001)&&e.jsx(
|
|
9
|
+
`:"";return s+=r,s}function de(t){let s="";return s=t.replace(/"/g,'""'),s}const ue=({record:t,sortCodeKey:s,filter:o,isAllOpened:n})=>{const[r,l]=h.useState(n),a=t?.total?.raw??0,u=t?.debit?.raw??0,m=t?.credit?.raw??0;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{children:[e.jsx("td",{children:s}),e.jsx("td",{children:t.business.id}),e.jsx("td",{children:t.business.name??void 0}),e.jsx("td",{children:u?t?.debit?.formatted:void 0}),e.jsx("td",{children:m?t?.credit?.formatted:void 0}),e.jsx("td",{children:(a>.001||a<-.001)&&e.jsx(S,{color:a>0?"green":"red",children:t?.total?.formatted})}),e.jsx("td",{children:e.jsx(I,{label:"Detailed records",children:e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(c=>!c),children:r||n?e.jsx(q,{className:"size-5"}):e.jsx(G,{className:"size-5"})})})})]},t.business.id),(r||n)&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx(H,{businessID:t.business?.id,filter:o})})})]})},me=({sortCode:t,filter:s,isAllOpened:o})=>t.records.length>0?e.jsxs(e.Fragment,{children:[e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx("span",{className:"font-bold",children:t.name})})}),t.records.sort((n,r)=>n.business.name.localeCompare(r.business.name)).map(n=>e.jsx(ue,{record:n,sortCodeKey:t.key,filter:s,isAllOpened:o},n.business.id)),e.jsx("tr",{className:"bg-gray-100",children:t.records.length>1?e.jsxs(e.Fragment,{children:[e.jsx("td",{colSpan:2,children:"Group total:"}),e.jsx("td",{colSpan:1,children:t.key}),e.jsx("td",{colSpan:1,children:!!t.totalDebit&&j(t.totalDebit,p.Ils)}),e.jsx("td",{colSpan:1,children:!!t.totalCredit&&j(t.totalCredit,p.Ils)}),e.jsxs("td",{colSpan:1,children:[e.jsx(S,{c:t.sum>0?"green":t.sum<0?"red":void 0,children:j(t.sum,p.Ils)}),!!t.debit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"Total Debit Balances: ",j(t.debit,p.Ils)]}),!!t.credit&&e.jsxs(e.Fragment,{children:[e.jsx("br",{}),"Total Credit Balances: ",j(t.credit,p.Ils)]})]})]}):void 0})]}):null,xe=({group:t,data:s,filter:o,isAllOpened:n})=>e.jsxs(e.Fragment,{children:[Object.values(s.sortCodes).sort((r,l)=>r.key-l.key).map((r,l)=>e.jsx(me,{sortCode:r,filter:o,isAllOpened:n},`${r.key} ${l}`)),e.jsxs("tr",{className:"bg-gray-100",children:[e.jsx("td",{colSpan:2,children:"Group total:"}),e.jsx("td",{colSpan:1,children:t.replaceAll("0","*")}),e.jsx("td",{colSpan:1,children:!!s.totalDebit&&j(s.totalDebit,p.Ils)}),e.jsx("td",{colSpan:1,children:!!s.totalCredit&&j(s.totalCredit,p.Ils)}),e.jsx("td",{colSpan:1,children:e.jsx(S,{fw:700,c:s.sum>0?"green":s.sum<0?"red":void 0,children:j(s.sum,p.Ils)})})]},"group"+t)]});function he(t){return Math.floor(t/100)*100}const be=({data:t,filter:s,isAllOpened:o})=>{const{businessTransactionsSum:n}=Z(J,t),r=h.useMemo(()=>{const l={};for(const a of n){a.business.sortCode??={id:"-999",key:-999,name:"Misc"};const u=!a.total.raw||a.total.raw<.001&&a.total.raw>-.001;if(!s.isShowZeroedAccounts&&u)continue;const m=he(a.business.sortCode.key);l[m]??={sortCodes:{},totalCredit:0,totalDebit:0,credit:0,debit:0,sum:0};const c=l[m];c.sortCodes[a.business.sortCode.key]??={...a.business.sortCode,totalCredit:0,totalDebit:0,records:[],credit:0,debit:0,sum:0};const d=c.sortCodes[a.business.sortCode.key];d.totalCredit+=a.credit.raw,d.totalDebit+=a.debit.raw,d.sum+=a.total.raw,c.totalCredit+=a.credit.raw,c.totalDebit+=a.debit.raw,c.sum+=a.total.raw,a.total.raw>0?(d.credit+=a.total.raw,c.credit+=a.total.raw):(d.debit+=a.total.raw,c.debit+=a.total.raw),d.records.push(a)}return l},[n,s.isShowZeroedAccounts]);return e.jsxs(Q,{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:"Sort Code"}),e.jsx("th",{children:"Account"}),e.jsx("th",{children:"Account Name"}),e.jsx("th",{children:"Total Debit"}),e.jsx("th",{children:"Total Credit"}),e.jsx("th",{children:"Balance"}),e.jsx("th",{children:e.jsx(oe,{data:r,fromDate:s.fromDate??void 0,toDate:s.toDate??void 0})})]})}),e.jsxs("tbody",{children:[Object.entries(r).map(([l,a])=>e.jsx(xe,{data:a,group:l,filter:s,isAllOpened:o},l)),e.jsxs("tr",{className:"bg-gray-100",children:[e.jsx("td",{colSpan:2,children:"Report total:"}),e.jsx("td",{}),e.jsxs("td",{children:["(",y(Object.values(r).reduce((l,a)=>l+a.totalDebit,0)),")"]}),e.jsxs("td",{children:["(",y(Object.values(r).reduce((l,a)=>l+a.totalCredit,0)),")"]}),e.jsx("td",{colSpan:1,children:y(Object.values(r).reduce((l,a)=>l+a.sum,0))})]})]})]})};function pe(t){const s=new URLSearchParams,o=ae(t);return o&&s.append("trialBalanceReportFilters",o),`/reports/trial-balance${s.size>0?`?${s}`:""}`}const ge=()=>{const[t,s]=h.useState(!1),{get:o}=B(),{setFiltersContext:n}=h.useContext(W),[r,l]=h.useState(o("trialBalanceReportFilters")?JSON.parse(decodeURIComponent(o("trialBalanceReportFilters"))):{}),[{data:a,fetching:u}]=X({query:se,variables:{filters:{fromDate:r?.fromDate,toDate:r?.toDate,ownerIds:r?.ownerIds,businessIDs:r?.businessIDs}}});h.useEffect(()=>{n(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(I,{label:"Expand all accounts",children:e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>s(c=>!c),children:t?e.jsx(K,{className:"size-5"}):e.jsx(Y,{className:"size-5"})})}),e.jsx(ne,{filter:r,setFilter:l})]}))},[r,t,n]);const m=h.useMemo(()=>a?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?void 0:a?.businessTransactionsSumFromLedgerRecords,[a?.businessTransactionsSumFromLedgerRecords]);return e.jsx(ee,{title:"Trial Balance Report",description:"Trial balance report for all businesses",children:u||!m?e.jsx(te,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(be,{data:m,filter:r,isAllOpened:t})})};export{ge as TrialBalanceReport,pe as getTrialBalanceReportHref};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{cZ as fr,aj as gr,ai as ge,j as F,r as kt,u as io,c_ as pr,c$ as mr,B as br,d0 as xr,V as _r,H as le,bP as Pn,bU as Dn,bV as An,d1 as yr,F as wr,a as vr,d2 as Mr,aV as it,c as Sr,L as kr,d3 as Cr}from"./index-DL8q44ap.js";/*!
|
|
2
2
|
* decimal.js v10.6.0
|
|
3
3
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
4
4
|
* https://github.com/MikeMcl/decimal.js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as h,j as e,
|
|
1
|
+
import{r as h,j as e,c$ as u,eL as p,B as y,d0 as g,bq as D,F as P,a as w,c as R,L as E,cb as v,eM as F}from"./index-DL8q44ap.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{R as d}from"./report-commentary-row-aIxbqTgK.js";function A({year:l,setYear:m,referenceYears:o,setReferenceYears:j}){const[c,x]=h.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(u,{opened:c,onClose:()=>x(!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&&m(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(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>x(!0),children:e.jsx(g,{className:"size-5"})})]})}const S=()=>{const{year:l}=D(),{setFiltersContext:m}=h.useContext(P),[o,j]=h.useState(l?Number(l):new Date().getFullYear()),[c,x]=h.useState([]),[{data:n,fetching:i}]=w({query:C(F),variables:{reportYear:o,referenceYears:c}});h.useEffect(()=>{m(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:c,setReferenceYears:x})}))},[o,i,m,c,x]);const f=n?.profitAndLossReport,a=f?.report,s=f?.reference??[];return e.jsx(R,{title:"Profit and Loss Report",children:i?e.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"flex flex-col gap-4",children:a&&e.jsxs(v,{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:a.revenue.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("th",{children:r.revenue.amount.formatted},r.year))]}),commentaryData:a.revenue}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Cost of Sales"}),e.jsx("td",{children:a.costOfSales.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.costOfSales.amount.formatted},r.year))]}),commentaryData:a.costOfSales}),e.jsxs("tr",{children:[e.jsx("th",{children:"Gross Profit"}),e.jsx("th",{children:a.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:a.researchAndDevelopmentExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.researchAndDevelopmentExpenses.amount.formatted},r.year))]}),commentaryData:a.researchAndDevelopmentExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Marketing Expenses"}),e.jsx("td",{children:a.marketingExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.marketingExpenses.amount.formatted},r.year))]}),commentaryData:a.marketingExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Management and General Expenses"}),e.jsx("td",{children:a.managementAndGeneralExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.managementAndGeneralExpenses.amount.formatted},r.year))]}),commentaryData:a.managementAndGeneralExpenses}),e.jsxs("tr",{children:[e.jsx("th",{children:"Operating Profit"}),e.jsx("th",{children:a.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:a.financialExpenses.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.financialExpenses.amount.formatted},r.year))]}),commentaryData:a.financialExpenses}),e.jsx(d,{dataRow:t=>e.jsxs("tr",{children:[e.jsx("td",{children:"Other Income"}),e.jsx("td",{children:a.otherIncome.amount.formatted}),e.jsx("th",{children:t}),s.map(r=>e.jsx("td",{children:r.otherIncome.amount.formatted},r.year))]}),commentaryData:a.otherIncome}),e.jsxs("tr",{children:[e.jsx("th",{children:"Profit Before Tax"}),e.jsx("th",{children:a.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:a.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:a.netProfit.formatted}),e.jsx("th",{}),s.map(t=>e.jsx("th",{children:t.netProfit.formatted},t.year))]})})]})})})};export{S as ProfitAndLossReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as M,
|
|
1
|
+
import{a as M,dE as X,t as C,r as s,i as Y,l as K,dF as Q,dG as J,X as F,dH as S,j as e,K as R,aW as G,B as v,aC as U,N as q,aX as W,aY as Z,au as _,av as ee,aw as se,ax as te,az as ne,dI as ae,dJ as re,dK as H,dL as z,c8 as ce,dM as V,dN as ie,Y as k,a2 as B,L as A,dO as le,g as oe,Z as de,$ as ue,dP as me,bn as he,b9 as xe,dQ as je,H as P,dR as $,V as pe,bN as fe,G as ge,a1 as ye,bg as ve,dc as De,dn as be,dp as Ce,dq as O,dr as g,dt as Ne,du as y,aE as we,c2 as Ie,F as Me,n as Te}from"./index-DL8q44ap.js";import{s as L}from"./subMonths-CpJ3oidH.js";const Ee=()=>{const[{data:u,fetching:o,error:c},x]=M({query:X});c&&(console.error(`Error fetching contracts: ${c}`),C.error("Error",{description:"Unable to fetch contracts"}));const a=s.useMemo(()=>u?.allOpenContracts?.slice().sort((t,d)=>t.client.originalBusiness.name>d.client.originalBusiness.name?1:-1)??[],[u]),i=s.useMemo(()=>a.map(t=>({value:t.id,label:t.client.originalBusiness.name})),[a]);return{fetching:o,refresh:()=>x(),openContracts:a,selectableOpenContracts:i}},Fe="IssueMonthlyDocuments",Se=()=>{const[{fetching:u},o]=Y(Q),c=s.useCallback(async x=>{const a="Error issuing monthly documents",i=Fe;C.loading("Issuing documents",{id:i});try{const t=await o(x),d=K(t,a,i);if(d?.issueGreenInvoiceDocuments?.success){C.success("Success",{id:i,description:"Documents issued successfully"});return}d?.issueGreenInvoiceDocuments?.errors&&console.error(d.issueGreenInvoiceDocuments.errors),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}catch(t){console.error(`${a}: ${t}`),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}},[o]);return{fetching:u,issueDocuments:c}};function Pe({issueMonth:u,contracts:o,onAdd:c}){const[x,a]=s.useState(!1),[i,t]=s.useState(""),[{data:d},h]=M({query:J,variables:{issueMonth:u,clientId:i}}),j=s.useCallback(n=>{t(n),h()},[h,t]);return s.useEffect(()=>{i!==""&&d&&(c(F(S,d.clientMonthlyChargeDraft)),a(!1))},[i,d,c]),e.jsxs(R,{open:x,onOpenChange:a,children:[e.jsx(G,{asChild:!0,children:e.jsx(v,{variant:"outline",size:"icon",children:e.jsx(U,{})})}),e.jsxs(q,{className:"w-[400px] max-w-screen-md",children:[e.jsx(W,{children:e.jsx(Z,{children:"Select document recipient"})}),e.jsxs(_,{onValueChange:j,children:[e.jsx(ee,{children:e.jsx(se,{placeholder:"Recipient"})}),e.jsx(te,{children:o.map(n=>e.jsx(ne,{value:n.client.originalBusiness.id,children:n.client.originalBusiness.name},n.client.originalBusiness.id))})]})]})]})}function ke({onApprove:u,draft:o}){const[c,x]=s.useState(!1),[a,i]=s.useState(!1),[t,d]=s.useState(null),{previewDocument:h,fetching:j}=ae(),[n,N]=s.useState(re(o)),T=s.useCallback((l,p)=>{N(f=>({...f,[l]:p}))},[]);s.useEffect(()=>{i(!1)},[n]);const D=s.useCallback(async()=>{try{const l=await h({input:n});if(!l)throw new Error("No preview data returned");d(l),i(!0)}catch(l){console.error("Failed to generate preview:",l)}},[n,h]);s.useEffect(()=>{c&&!t&&D()},[c,t,D]);const w=n.income?.reduce((l,p)=>{const f=p.price*p.quantity,r=f*((p.vatRate||0)/100);return l+f+r},0)||0,I=()=>{u(n),x(!1)};return e.jsxs(R,{open:c,onOpenChange:x,children:[e.jsx(G,{asChild:!0,type:"button",children:e.jsxs(H,{children:[e.jsx(z,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>x(l=>!l),type:"button",children:e.jsx(ce,{className:"size-5"})})}),e.jsx(V,{children:e.jsx("p",{children:"Edit document"})})]})}),e.jsx(q,{className:"w-7xl sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:e.jsx("div",{className:"min-h-screen bg-gray-50 p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Edit Document"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Modify and preview your accounting document before issuing"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(ie,{formData:n,updateFormData:T}),e.jsx(k,{children:e.jsxs(B,{className:"pt-6",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(v,{onClick:D,disabled:j||a,variant:"outline",className:"flex-1 bg-transparent",children:j?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-4 h-4 mr-2"}),"Preview"]})}),e.jsxs(v,{onClick:I,className:"flex-1",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Accept Changes"]})]}),w>0&&e.jsx("div",{className:"mt-4 p-3 bg-blue-50 rounded-lg",children:e.jsxs("div",{className:"flex justify-between items-center font-medium text-blue-900",children:[e.jsx("span",{children:"Total Document Amount:"}),e.jsxs("span",{children:[w.toFixed(2)," ",n.currency]})]})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(k,{className:"h-fit",children:[e.jsx(de,{children:e.jsx(ue,{children:"Document Preview"})}),e.jsx(B,{children:e.jsx("div",{className:"border-2 border-dashed border-gray-200 rounded-lg min-h-[600px] flex items-center justify-center bg-gray-50",children:j?e.jsxs("div",{className:"text-center",children:[e.jsx(A,{className:"w-8 h-8 animate-spin mx-auto mb-4 text-gray-400"}),e.jsx("p",{className:"text-gray-500",children:"Generating document preview..."})]}):t?e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"bg-white shadow-lg rounded-lg overflow-hidden",children:e.jsx("div",{className:"aspect-[8.5/11] bg-white border",children:e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(me,{src:t}),!a&&e.jsx("p",{className:"text-xs text-amber-600 mt-3 bg-amber-50 px-2 py-1 rounded",children:"Preview may be outdated"})]})})})})}):e.jsxs("div",{className:"text-center",children:[e.jsx(he,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"text-gray-500 mb-2",children:"No preview available"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Click Preview to generate document"})]})})})]}),n.client?.id&&e.jsx(xe,{businessId:n.client?.id,linkedDocumentIds:n.linkedDocumentIds??[]}),e.jsx(je,{documentType:n.type})]})]})]})})})]})}const Be=({drafts:u})=>{const[o,c]=s.useState(u.map(r=>F(S,r))),x=P(L(new Date,1),"yyyy-MM-dd"),[a,i]=s.useState(x),[{data:t},d]=M({query:$,variables:{issueMonth:a},pause:!0});s.useEffect(()=>{t?.clientMonthlyChargesDrafts&&c(t.clientMonthlyChargesDrafts.map(r=>F(S,r)))},[t,c]),s.useEffect(()=>{d()},[a,d]);const h=pe({values:{generateDocumentsInfo:o}}),{issueDocuments:j}=Se(),{openContracts:n}=Ee(),{fields:N,append:T,remove:D,update:w}=fe({control:h.control,name:"generateDocumentsInfo"}),I=h.watch("generateDocumentsInfo"),l=s.useMemo(()=>N.map((r,m)=>({...r,...I[m],id:r.client?.id})),[N,I]),p=s.useCallback(r=>{j(r)},[j]),f=s.useMemo(()=>n.filter(r=>r.billingCycle===ge.Monthly&&!l.some(m=>m.client?.id===r.client.originalBusiness.id)),[l,n]);return e.jsx("div",{className:"p-2",children:e.jsx(ye,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(p),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(ve,{children:"Issue Month:"}),e.jsx(De,{value:new Date(a),onChange:r=>{const m=new Date(r.getFullYear(),r.getMonth(),15);i(P(m,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(be,{children:[e.jsx(Ce,{children:e.jsxs(O,{children:[e.jsx(g,{children:"Name"}),e.jsx(g,{children:"Document"}),e.jsx(g,{children:"Amount"}),e.jsx(g,{children:"Remark"}),e.jsx(g,{children:"Recipients"}),e.jsx(g,{})]})}),e.jsx(Ne,{children:l.map(({id:r,...m},E)=>e.jsxs(O,{children:[e.jsx(y,{children:m.client?.name}),e.jsx(y,{children:m.type}),e.jsxs(y,{children:[m.income?.[0]?.price," ",m.income?.[0]?.currency]}),e.jsx(y,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:m.remarks})}),e.jsx(y,{children:e.jsx("div",{className:"flex flex-col",children:m.client?.emails?.map(b=>e.jsx("span",{className:"text-sm text-gray-500",children:b},b))})}),e.jsx(y,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(H,{children:[e.jsx(z,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>D(E),children:e.jsx(we,{size:16})})}),e.jsx(V,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(ke,{draft:m,onApprove:b=>{h.setValue(`generateDocumentsInfo.${E}`,b,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),w(E,{...b})}})]})})]},r))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(Pe,{contracts:f,onAdd:T,issueMonth:a}),e.jsx(Ie,{onConfirm:h.handleSubmit(p),title:`Are you sure you want to issue ${l.length} documents?`,children:e.jsx(v,{children:"Issue"})})]})]})})})},Re=()=>{const{setFiltersContext:u}=s.useContext(Me),[{data:o,fetching:c}]=M({query:$,variables:{issueMonth:P(L(new Date,1),"yyyy-MM-dd")}});return s.useEffect(()=>{o?.clientMonthlyChargesDrafts||u(null)},[o,u]),c?e.jsx(Te,{}):e.jsx(Be,{drafts:o?.clientMonthlyChargesDrafts??[]})};export{Re as IssueDocuments};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as V,i as q,
|
|
1
|
+
import{D as V,i as q,eC as B,r,t as k,l as F,a as $,eD as _,j as s,n as L,eE as R,o as H,B as Q,p as X,q as G}from"./index-DL8q44ap.js";import{C as J,M as K}from"./Checkbox-BzSHHEEI.js";/**
|
|
2
2
|
* @license lucide-react v0.546.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -8,4 +8,4 @@ import{D as V,i as q,eB as E,r,t as k,l as F,a as $,eC as _,j as s,n as L,eD as
|
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const W=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],N=V("square-x",W),Y="mergeCharges",Z=()=>{const[{fetching:C},a]=q(
|
|
11
|
+
*/const W=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],N=V("square-x",W),Y="mergeCharges",Z=()=>{const[{fetching:C},a]=q(B),c=r.useCallback(async x=>{const u=`Error merging into charge ID [${x.baseChargeID}]`,l=`${Y}-${x.baseChargeID}`;k.loading("Merging Charges",{id:l});try{const d=await a(x),n=F(d,u,l,"mergeCharges");if(n)return k.success("Success",{id:l,description:"Charges were merged"}),n.mergeCharges.charge}catch(d){console.error(`${u}: ${d}`),k.error("Error",{id:l,description:u,duration:1e5,closeButton:!0})}},[a]);return{fetching:C,mergeCharges:c}};function ee({chargeIds:C,onDone:a,resetMerge:c}){const{mergeCharges:x,fetching:u}=Z(),l=Array.from(new Set(C)),[{data:d,fetching:n}]=$({query:_,variables:{chargeIds:l}}),[i,I]=r.useState(d?.chargesByIDs[0]),[m,p]=r.useState(void 0),[f,z]=r.useState(void 0),[j,w]=r.useState(void 0),[v,M]=r.useState(void 0),[D,T]=r.useState(void 0),[y,A]=r.useState(void 0),[b,O]=r.useState(void 0),[h,P]=r.useState(void 0),S=d?.chargesByIDs.length!==l.length&&"Some charges were not Found"||void 0,o=d?.chargesByIDs||[],E=r.useCallback(async()=>{if(!i){k.error("Error",{description:"No main charge selected"});return}if(l.length<2){k.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let e;return m&&m.value!==i.userDescription&&(e??={},e={...e,userDescription:m.value}),f&&f.value!==i.owner.id&&(e??={},e={...e,ownerId:f.value}),y&&y.value!==i.conversion&&(e??={},e={...e,isConversion:y.value}),j&&j.value!==i.property&&(e??={},e={...e,isProperty:j.value}),v&&v.value!==i.optionalVAT&&(e??={},e={...e,optionalVAT:v.value}),D&&D.value!==i.optionalDocuments&&(e??={},e={...e,optionalDocuments:D.value}),h&&h.value!==i.tags.map(t=>t.name).join(",")&&(e??={},e={...e,tags:h.value.split(",").filter(t=>t!=="").map(t=>({id:t}))}),b&&b.value!==i.isInvoicePaymentDifferentCurrency&&(e??={},e={...e,isInvoicePaymentDifferentCurrency:b.value}),await x({baseChargeID:i.id,chargeIdsToMerge:l.filter(t=>t!==i.id),fields:e}),c(),a()},[i,l,x,m,f,y,j,v,b,h,a,c]);return s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx(L,{})}),!n&&S&&s.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:s.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:S})}),!n&&!S&&s.jsxs(s.Fragment,{children:[s.jsxs("table",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:"Main"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:s.jsx(J,{checked:e.id===i?.id,size:"xl",onClick:()=>{I(e),p({id:e.id,value:e.userDescription??""}),z({id:e.id,value:e.owner.id}),w({id:e.id,value:e.property??!1}),M({id:e.id,value:e.optionalVAT??!1}),T({id:e.id,value:e.optionalDocuments??!1}),O({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1}),A({id:e.id,value:e.conversion??!1}),P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})}})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Description"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:!e.userDescription||m?.value===e.userDescription,onClick:()=>p({id:e.id,value:e.userDescription??""}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:m?.id===e.id?{background:"#228be633"}:{},children:e.userDescription})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Owner"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:f?.value===e.owner.id,onClick:()=>z({id:e.id,value:e.owner.id}),children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:f?.id===e.id?{background:"#228be633"}:{},children:e.owner.name})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Property"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.property==null||e.property===j?.value,onClick:()=>{w({id:e.id,value:e.property??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===e.id?{background:"#228be633"}:{},children:e.property?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Is Conversion"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.conversion==null||e.conversion===y?.value,onClick:()=>{A({id:e.id,value:e.conversion??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:y?.id===e.id?{background:"#228be633"}:{},children:e.conversion?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional VAT"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalVAT==null||e.optionalVAT===v?.value,onClick:()=>{M({id:e.id,value:e.optionalVAT??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:v?.id===e.id?{background:"#228be633"}:{},children:e.optionalVAT?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Optional Documents"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.optionalDocuments==null||e.optionalDocuments===D?.value,onClick:()=>{T({id:e.id,value:e.optionalDocuments??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:D?.id===e.id?{background:"#228be633"}:{},children:e.optionalDocuments?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoice-Payment Currency Difference"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.isInvoicePaymentDifferentCurrency==null||e.isInvoicePaymentDifferentCurrency===b?.value,onClick:()=>{w({id:e.id,value:e.isInvoicePaymentDifferentCurrency??!1})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===e.id?{background:"#228be633"}:{},children:e.isInvoicePaymentDifferentCurrency?s.jsx(g,{size:20,color:"green"}):s.jsx(N,{size:20,color:"red"})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Tags"}),o.map(e=>s.jsx("td",{children:s.jsx("button",{className:"w-full px-2",disabled:e.tags==null||e.tags.map(t=>t.name).join(",")===h?.value,onClick:()=>{P({id:e.id,value:(e.tags.map(t=>t.name)??[]).join(",")})},children:s.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:h?.id===e.id?{background:"#228be633"}:{},children:s.jsx(R,{items:e.tags.map(t=>s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{children:t.name}),t.namePath&&s.jsx("div",{children:t.namePath.join(" > ")})]},t.id))})})})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Transactions"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:e.metadata?.transactionsCount??0})},e.id))]}),s.jsxs("tr",{children:[s.jsx("th",{children:"Invoices"}),o.map(e=>s.jsx("td",{children:s.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:e.metadata?.invoicesCount??0})},e.id))]})]}),s.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[s.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:n||u,onClick:E,children:"Accept"}),s.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:a,children:"Cancel"}),s.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{c(),a()},children:"Reset Merge"})]})]})]})}function ie(C){const[a,{close:c,open:x}]=H(!1),{selected:u,resetMerge:l}=C,d=new Set(u.map(({id:p})=>p)),n=d.size>=1,[i,I]=r.useState(n?"default":"outline");r.useEffect(()=>{I(n?"default":"outline")},[n]);const m=r.useCallback(()=>{c(),u.map(({onChange:p})=>p())},[u,c]);return s.jsxs(s.Fragment,{children:[s.jsx(Q,{onClick:()=>{n&&x()},disabled:!n,variant:i,className:X("size-7.5",n?" bg-blue-500 hover:bg-blue-500/90":""),size:"icon",children:s.jsx(K,{className:"size-5"})}),s.jsx(G,{opened:a,onClose:c,size:"auto",centered:!0,children:s.jsx(ee,{chargeIds:Array.from(d),onDone:m,resetMerge:l})})]})}export{ie as M};
|