@accounter/client 0.0.8-alpha-20251029111239-192c5afd2d66a4d11ea8217039b86666b6fff216 → 0.0.8-alpha-20251029124448-6b4f8bc975a23de63429b68d0806022dbfc5b226
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-BfB2aYmM.js → Checkbox-Ddw01d64.js} +2 -2
- package/dist/assets/{MultiSelect-CGvaXcuH.js → MultiSelect-CBtq6WUv.js} +1 -1
- package/dist/assets/{Pagination-D4fkmYTl.js → Pagination-BM-86UO5.js} +1 -1
- package/dist/assets/{Progress-CQs7EuQ2.js → Progress-Bda-J3ZH.js} +1 -1
- package/dist/assets/{Table-C2EjuqpH.js → Table-CYqAEQfS.js} +1 -1
- package/dist/assets/{Typography-bz4ZX5sI.js → Typography--U0GsZ21.js} +1 -1
- package/dist/assets/{YearPickerInput-CURoIYu6.js → YearPickerInput-CgU-feeq.js} +1 -1
- package/dist/assets/{accordion-DWmBRtUi.js → accordion-B8kebokE.js} +1 -1
- package/dist/assets/{accountant-approvals-C9FCfRoL.js → accountant-approvals-CUluc3sH.js} +1 -1
- package/dist/assets/{accounter-table-C70NKDaW.js → accounter-table-CM6PQ9Aw.js} +1 -1
- package/dist/assets/{addDays-BGYF7FkS.js → addDays-DGlDD_vj.js} +1 -1
- package/dist/assets/{all-charges-CkPb7TjD.js → all-charges-DpQS6Xp3.js} +1 -1
- package/dist/assets/{arrow-up-down-B-KqfJyD.js → arrow-up-down-C61ge4J5.js} +1 -1
- package/dist/assets/{building-2-BAwr8r-2.js → building-2-3KauBrnS.js} +1 -1
- package/dist/assets/{business-DLu0ofgu.js → business-RCuQN-RO.js} +7 -17
- package/dist/assets/business-extended-info-DmQ7B7-Z.js +13 -0
- package/dist/assets/{business-header-B_qcrJW_.js → business-header-B-uHcc1D.js} +1 -1
- package/dist/assets/business-transactions-filters-D-Y8vZwZ.js +1 -0
- package/dist/assets/business-transactions-single-CEE249QN.js +1 -0
- package/dist/assets/business-trip-3kCBQ5MD.js +1 -0
- package/dist/assets/{charge-aBSxCGi3.js → charge-D19rkm2C.js} +1 -1
- package/dist/assets/{charges-filters-BRuJ3XbB.js → charges-filters-BUFmsiTq.js} +1 -1
- package/dist/assets/{charges-ledger-validation-DjuvGES2.js → charges-ledger-validation-OPtbHzXu.js} +1 -1
- package/dist/assets/charges-table-D_GDHvFS.js +62 -0
- package/dist/assets/{chart-BSh0rsm7.js → chart-iyOBgiH0.js} +1 -1
- package/dist/assets/{data-table-pagination-BCuaIseR.js → data-table-pagination-CKN0E29f.js} +1 -1
- package/dist/assets/download-csv-button-DZ5cKqkV.js +1 -0
- package/dist/assets/{editable-business-trip-BLWzKbN3.js → editable-business-trip-CRiuNdbP.js} +1 -1
- package/dist/assets/{funnel-XiON1wPY.js → funnel-BlaCusqP.js} +1 -1
- package/dist/assets/{index-BdnLryTF.js → index-B2_EbsaK.js} +191 -191
- package/dist/assets/index-B8pzYiEH.js +1 -0
- package/dist/assets/{index-DOSLXKPY.js → index-BAGVbiiM.js} +1 -1
- package/dist/assets/{index-D7GKOJU4.js → index-BD86tRnn.js} +2 -2
- package/dist/assets/{index-C_nLGgCr.js → index-BGh0NOfw.js} +1 -1
- package/dist/assets/{index-CtDDVAsw.js → index-BKiLhEyi.js} +1 -1
- package/dist/assets/{index-D9RA6cVt.js → index-BNAjS3Tn.js} +2 -2
- package/dist/assets/{index-DbbPcdZ7.js → index-BRSlJnxd.js} +2 -2
- package/dist/assets/{index-CA6LHUxs.js → index-BoL57v1D.js} +1 -1
- package/dist/assets/{index-C-RIsd1H.js → index-C2GP2DWO.js} +2 -2
- package/dist/assets/{index-CJP0f2Bm.js → index-CM60VmgR.js} +1 -1
- package/dist/assets/index-CRLPoT61.js +6 -0
- package/dist/assets/index-CRooGu6R.js +1 -0
- package/dist/assets/{index-CxE91GPE.js → index-C_OSDuUb.js} +1 -1
- package/dist/assets/{index-CVNgfFi3.js → index-Cc7exUI5.js} +1 -1
- package/dist/assets/{index-BwrF7ixX.js → index-Co66MgF6.js} +2 -2
- package/dist/assets/{index-BPLQ_Cjg.js → index-CyBAoT0l.js} +1 -1
- package/dist/assets/{index-BYCdqffp.js → index-D5tmtR-a.js} +7 -7
- package/dist/assets/{index-3Fyx3NBp.js → index-DINxWoMX.js} +1 -1
- package/dist/assets/{index-BdzdEbUC.js → index-DIiuo0-v.js} +1 -1
- package/dist/assets/{index-Diqx01g3.js → index-DtrRL2jA.js} +1 -1
- package/dist/assets/{index-BVTpNGNk.js → index-EaY6ZYvr.js} +2 -2
- package/dist/assets/{index-DaSx2wiU.js → index-mMqWkzUL.js} +1 -1
- package/dist/assets/{index-pjJUDHWQ.js → index-xLWv_qf6.js} +1 -1
- package/dist/assets/{index-By2sHbGk.js → index-yOhbO3fy.js} +1 -1
- package/dist/assets/{index.es-BWSz-k0E.js → index.es-CaOIcY7v.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-Bk-kugZI.js → insert-business-trip-modal-BwOnvw7X.js} +2 -2
- package/dist/assets/issue-document-CzBtBCCO.js +1 -0
- package/dist/assets/{list-plus-DINtfnSi.js → list-plus-CGvSlslE.js} +1 -1
- package/dist/assets/{login-page-DVwxXAvd.js → login-page-BTcklqv4.js} +1 -1
- package/dist/assets/{match-document-modal--iAusdTp.js → match-document-modal-DcL0siQq.js} +4 -4
- package/dist/assets/{missing-info-charges-CQNTClQ3.js → missing-info-charges-DfwRkzNe.js} +1 -1
- package/dist/assets/{modal-BzwJJ2TM.js → modal-B0uNLang.js} +1 -1
- package/dist/assets/{page-layout-NF77oib6.js → page-layout-C0GJoVTR.js} +1 -1
- package/dist/assets/{page-not-found-Cu_0zp5u.js → page-not-found-9UX5vsGE.js} +1 -1
- package/dist/assets/{panel-top-open-BApXXBMD.js → panel-top-open-BFNhAe3f.js} +1 -1
- package/dist/assets/{pencil-CLaFsm6E.js → pencil-9Th5X-OY.js} +1 -1
- package/dist/assets/{report-commentary-row-BGN_tI-P.js → report-commentary-row-CNIlhboC.js} +1 -1
- package/dist/assets/{save-DsE11_Et.js → save-qtyyZLc5.js} +1 -1
- package/dist/assets/{similar-transactions-modal-CoZU6FU3.js → similar-transactions-modal-nk8VHEtX.js} +1 -1
- package/dist/assets/sub-fkVv9ghZ.js +1 -0
- package/dist/assets/subMonths-5wFmciT1.js +1 -0
- package/dist/assets/{summary-BasZ3QlN.js → summary-DuWhfNdL.js} +1 -1
- package/dist/assets/{toggle-expansion-button-DPcDIe-2.js → toggle-expansion-button-41Ejffq3.js} +1 -1
- package/dist/assets/tooltip-lhMCop8U.js +1 -0
- package/dist/assets/{use-url-query-Bp_LkJaa.js → use-url-query-BPzyQB93.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/app.tsx +108 -0
- package/src/components/business/index.tsx +1 -31
- package/src/components/business/transactions-section.tsx +2 -24
- package/src/components/{business-ledger → business-transactions}/business-extended-info.tsx +27 -25
- package/src/components/{business-ledger/business-ledger-filters.tsx → business-transactions/business-transactions-filters.tsx} +12 -12
- package/src/components/{business-ledger/business-ledger-single.tsx → business-transactions/business-transactions-single.tsx} +13 -13
- package/src/components/{business-ledger → business-transactions}/download-csv.tsx +25 -25
- package/src/components/{business-ledger → business-transactions}/index.tsx +15 -15
- package/src/components/charges/charge-extended-info.tsx +4 -45
- package/src/components/layout/sidelinks.tsx +2 -2
- package/src/components/ledger-table/columns.tsx +4 -4
- package/src/components/ledger-table/index.tsx +181 -152
- package/src/components/reports/conto/custom-node.tsx +1 -1
- package/src/components/reports/trial-balance-report/trial-balance-report-account.tsx +1 -1
- package/src/components/transactions-table/columns.tsx +9 -9
- package/src/components/transactions-table/index.tsx +21 -56
- package/src/gql/gql.ts +12 -30
- package/src/gql/graphql.ts +406 -181
- package/src/providers/index.ts +4 -0
- package/src/router/config.tsx +14 -14
- package/src/router/routes.ts +2 -2
- package/dist/assets/business-extended-info-vAiMQKwm.js +0 -13
- package/dist/assets/business-ledger-filters-CNjRVS0K.js +0 -1
- package/dist/assets/business-ledger-single-BrattJvc.js +0 -1
- package/dist/assets/business-trip-DZqft86E.js +0 -1
- package/dist/assets/charges-table--gOKotyF.js +0 -62
- package/dist/assets/download-csv-button-B0eh9bzg.js +0 -1
- package/dist/assets/index-B05N38w4.js +0 -6
- package/dist/assets/index-BS5IhG6A.js +0 -1
- package/dist/assets/index-Ci8Rcu9T.js +0 -1
- package/dist/assets/issue-document-BcWeUsrG.js +0 -1
- package/dist/assets/sub-DLRNYZyc.js +0 -1
- package/dist/assets/subMonths-Bc9skHhr.js +0 -1
- package/dist/assets/tooltip-CICdw5IX.js +0 -1
- package/src/components/business/balance-section.tsx +0 -26
- package/src/components/business/ledger-section.tsx +0 -49
- package/src/providers/index.tsx +0 -56
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as l,F as C,u as S,j as e,T as h,B as j,bj as m,aN as a,L as T,bk as y,bl as N}from"./index-B2_EbsaK.js";import{u as v}from"./use-url-query-BPzyQB93.js";import{A as E}from"./accounter-table-CM6PQ9Aw.js";import{P as F}from"./page-layout-C0GJoVTR.js";import{C as B,a as R,B as z,M as I}from"./business-extended-info-DmQ7B7-Z.js";import{B as L}from"./business-transactions-filters-D-Y8vZwZ.js";import{P as k,a as A}from"./panel-top-open-BFNhAe3f.js";import{T as O}from"./Table-CYqAEQfS.js";import"./Pagination-BM-86UO5.js";import"./create-event-handler-BiA-1lGu.js";import"./download-csv-button-DZ5cKqkV.js";import"./modal-B0uNLang.js";import"./funnel-BlaCusqP.js";import"./MultiSelect-CBtq6WUv.js";const Y=()=>{const{get:t}=v(),{setFiltersContext:i}=l.useContext(C),[r,o]=l.useState(!1),[p,w]=l.useState(!1),[d,x]=l.useState(t("transactionsFilters")?JSON.parse(decodeURIComponent(t("transactionsFilters"))):{}),[{data:c,fetching:b}]=S({query:y,variables:{filters:d}});l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(L,{filter:d,setFilter:x}),e.jsx(h,{label:"Expand all accounts",children:e.jsx(j,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(s=>!s),children:r?e.jsx(k,{className:"size-5"}):e.jsx(A,{className:"size-5"})})}),e.jsx(h,{label:"Expand all currencies",children:e.jsx(j,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>w(s=>!s),children:p?e.jsx(B,{className:"size-5"}):e.jsx(R,{className:"size-5"})})})]}))},[c,d,i,x,r,o,p]);const g=l.useMemo(()=>c?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:c?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?c.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((s,u)=>s.business.name.localeCompare(u.business.name)):[],[c?.businessTransactionsSumFromLedgerRecords]),f=[{title:"Business Name",value:s=>s.business.name},{title:"Debit / Credit",value:s=>e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"red",children:s.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"green",children:s.credit.formatted})})]}),style:{whiteSpace:"nowrap"}},{title:"Total",value:s=>e.jsx(m,{c:s.total.raw<-1e-4?"red":s.total.raw>1e-4?"green":void 0,fw:700,children:s.total.formatted}),style:{whiteSpace:"nowrap"}},...n(a.Eur),...n(a.Usd),...n(a.Gbp),...n(a.Cad),...n(a.Jpy),...n(a.Aud),...n(a.Sek),...P(p)];return e.jsx(F,{title:"Business Transactions",description:"Business Transactions Summery",children:b?e.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(O,{striped:!0,highlightOnHover:!0,children:[e.jsx("thead",{className:"sticky top-0 z-20",children:e.jsxs("tr",{className:"tracking-wider font-medium text-gray-900 text-sm bg-gray-100",children:[f.map((s,u)=>s.disabled?null:e.jsx("th",{children:s.title},String(u))),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:g.map((s,u)=>e.jsx(E,{columns:f,item:s,moreInfo:()=>e.jsx(z,{businessID:s.business.id,filter:d}),isShowAll:r},u))})]})})};function n(t){return[{title:`${t} Debit / Credit`,value:i=>{const r=i.foreignCurrenciesSum.find(o=>o.currency===t);return r?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"red",children:r.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(m,{c:"green",children:r.credit.formatted})})]}):null},style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:i=>{const r=i.foreignCurrenciesSum.find(o=>o.currency===t);return r?.total?.raw&&(r.total.raw<-1e-4||r.total.raw>1e-4)?e.jsx(I,{color:r.total.raw>0?"green":"red",children:r.total.formatted}):r?.total?.formatted},style:{whiteSpace:"nowrap"}}]}function P(t){return t?Object.values(a).filter(r=>!N.includes(r)).map(n).flat():[]}export{Y as BusinessTransactionsSummery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,r as x,B as g,J as h,
|
|
1
|
+
import{j as n,r as x,B as g,J as h,ge as j,a as v,F as D,u as R,L as E,bn as y,dE as T,T as u,gf as w}from"./index-B2_EbsaK.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as A}from"./page-layout-C0GJoVTR.js";import{P as b}from"./modal-B0uNLang.js";import{Y as F}from"./YearPickerInput-CgU-feeq.js";import{F as I}from"./funnel-BlaCusqP.js";import{T as N}from"./Table-CYqAEQfS.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,2 +1,2 @@
|
|
|
1
|
-
import{r as F,j as r,e as
|
|
2
|
-
`);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(
|
|
1
|
+
import{r as F,j as r,e as Q,u as q,gR as H,L as E,a8 as K,bm as $,B as U,G as X,bo as ee,bp as te,bs as ne,cI as O,x as k,gS as T,bt as se,F as oe,K as re,P as ie,W as le}from"./index-B2_EbsaK.js";import{u as W}from"./use-url-query-BPzyQB93.js";import{P as ae}from"./page-layout-C0GJoVTR.js";import{A as ce,a as fe,c as ue,b as he}from"./accordion-B8kebokE.js";import{P as de}from"./modal-B0uNLang.js";import{F as pe}from"./funnel-BlaCusqP.js";var v={},z;function ye(){if(z)return v;z=1,Object.defineProperty(v,"__esModule",{value:!0}),v.calcSlices=v.applyPatch=v.calcPatch=v.lcs=v.diff=v.diff_core=void 0;function c(e,n){const{b:t,eq:s,stack_base:i}=e;let{i:l,N:o,j:h,M:a,Z:f,stack_top:x}=e;for(;;)switch(n){case 0:{e:for(;o>0&&a>0;){t.fill(0,0,2*f);const V=o-a,_=o+a,B=_&1,Y=l+o-1,Z=h+a-1,J=(_+B)/2;let N;t:for(let M=0;M<=J;M++){const I=2*Math.max(0,M-a)-M,L=M-2*Math.max(0,M-o);for(let u=I;u<=L;u+=2){const A=t[u-1-f*Math.floor((u-1)/f)],R=t[u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,S=w-u;let b=w,C=S;for(;b<o&&C<a&&s(l+b,h+C);)b++,C++;if(t[u-f*Math.floor(u/f)]=b,B===1&&(N=V-u)>=1-M&&N<M&&b+t[f+N-f*Math.floor(N/f)]>=o)if(M>1||b!==w){i[x++]=l+b,i[x++]=o-b,i[x++]=h+C,i[x++]=a-C,o=w,a=S,f=2*(Math.min(o,a)+1);continue e}else break t}for(let u=I;u<=L;u+=2){const A=t[f+u-1-f*Math.floor((u-1)/f)],R=t[f+u+1-f*Math.floor((u+1)/f)],w=u===-M||u!==M&&A<R?R:A+1,S=w-u;let b=w,C=S;for(;b<o&&C<a&&s(Y-b,Z-C);)b++,C++;if(t[f+u-f*Math.floor(u/f)]=b,B===0&&(N=V-u)>=-M&&N<=M&&b+t[N-f*Math.floor(N/f)]>=o)if(M>0||b!==w){i[x++]=l+o-w,i[x++]=w,i[x++]=h+a-S,i[x++]=S,o=o-b,a=a-C,f=2*(Math.min(o,a)+1);continue e}else break t}}if(o!==a){a>o?(l+=o,h+=o,a-=o,o=0):(l+=a,h+=a,o-=a,a=0);break}}if(o+a!==0)if(e.pxe===l||e.pye===h)e.pxe=l+o,e.pye=h+a;else{const V=e.pxs;if(e.oxs=e.pxs,e.oxe=e.pxe,e.oys=e.pys,e.oye=e.pye,e.pxs=l,e.pxe=l+o,e.pys=h,e.pye=h+a,V>=0)return e.i=l,e.N=o,e.j=h,e.M=a,e.Z=f,e.stack_top=x,1}}case 1:{if(x===0)return 2;a=i[--x],h=i[--x],o=i[--x],l=i[--x],f=2*(Math.min(o,a)+1),n=0}}}class m{constructor(n){this.state=n,this.c=0,this.result={value:null,done:!1}}[Symbol.iterator](){return this}next(){const{state:n,result:t}=this;if(this.c>1)return t.done=!0,t.value=void 0,t;const s=c(n,this.c);return this.c=s,s===1?(t.value=[n.oxs,n.oxe,n.oys,n.oye],t):n.pxs>=0?(t.value=[n.pxs,n.pxe,n.pys,n.pye],t):(t.done=!0,t.value=void 0,t)}}function D(e,n,t,s,i){const l=(Math.min(n,s)+1)*2,o=n+s,h=new(o<256?Uint8Array:o<65536?Uint16Array:Uint32Array)(2*l);return new m({i:e,N:n,j:t,M:s,Z:l,b:h,eq:i,pxs:-1,pxe:-1,pys:-1,pye:-1,oxs:-1,oxe:-1,oys:-1,oye:-1,stack_top:0,stack_base:[]})}v.diff_core=D;function d(e,n,t){let[s,i,l]=[0,e.length,n.length];if(typeof t=="function"){for(;s<i&&s<l&&t(s,s);)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;t(--i,--l)&&i>s&&l>s;);}else{for(;s<i&&s<l&&e[s]===n[s];)s++;if(s===i&&s===l)return[][Symbol.iterator]();for(;e[--i]===n[--l]&&i>s&&l>s;);t=(o,h)=>e[o]===n[h]}return D(s,i+1-s,s,l+1-s,t)}v.diff=d;class p{constructor(n,t){this.diff=n,this.N=t,this.i=0,this.j=0}[Symbol.iterator](){return this}next(){const n=this.diff.next();if(n.done){const{i:a,j:f,N:x}=this;return a<x&&(n.done=!1,n.value=[a,f,x-a],this.i=x),n}const t=n.value,s=t[0],i=t[1],l=t[3],{i:o,j:h}=this;return o!==s&&(t.length--,t[0]=o,t[1]=h,t[2]=s-o),this.i=i,this.j=l,n}}function y(e,n,t){return new p(d(e,n,t),e.length)}v.lcs=y;function*g(e,n,t){const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const i of d(e,n,t))i[2]=s.call(n,i[2],i[3]),yield i}v.calcPatch=g;function*P(e,n){let t=0;const s=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[i,l,o]of n)t<i&&(yield s.call(e,t,i)),o.length>0&&(yield o),t=l;t<e.length&&(yield s.call(e,t))}v.applyPatch=P;function*j(e,n,t){let s=0;const i=ArrayBuffer.isView(e)?Uint8Array.prototype.subarray:e.slice;for(const[l,o,h,a]of d(e,n,t))s<l&&(yield[0,i.call(e,s,l)]),l<o&&(yield[-1,i.call(e,l,o)]),h<a&&(yield[1,i.call(n,h,a)]),s=o;s<e.length&&(yield[0,e.slice(s)])}return v.calcSlices=j,v}var xe=ye();const me=({children:c})=>r.jsx("span",{className:"bg-green-100",children:c}),je=({children:c})=>r.jsx("span",{className:"bg-red-100 line-through",children:c}),G=({children:c})=>r.jsx("span",{children:c}),ge=({content:c,contentOrigin:m,monthDate:D})=>{const d=F.useMemo(()=>{const p=[];if(!m)return p;const y=c.split(""),g=m.split(""),P=Array.from(xe.calcPatch(g,y)),j=[];let e=0;for(const[t,s,i]of P)if(j.length===0&&t>=17&&s<=25&&i.length===s-t){if(P.length===1)return p;continue}else e<t&&j.push([g.slice(e,t).join(""),G]),s>t&&j.push([g.slice(t,s).join(""),je]),i.length>0&&j.push([i.join(""),me]),e=s;e<g.length&&j.push([g.slice(e).join(""),G]);let n=[];for(const[t,s]of j){const i=t.split(`
|
|
2
|
+
`);i.length===1?n.push(r.jsx(s,{children:t},`unchanged-${n.length}`)):i.map((l,o)=>{n.push(r.jsx(s,{children:l},o)),p.push(r.jsx("div",{children:n},p.length-1)),n=[]})}return n.length>0&&p.push(r.jsx("div",{children:n},p.length-1)),p},[c,m]);return r.jsxs("div",{className:"flex flex-col",children:[r.jsxs("div",{className:"text-sm text-gray-500 flex flex-row gap-2",children:[r.jsx("span",{className:"font-bold",children:"Month:"}),r.jsx("span",{children:D.slice(0,7)}),!d.length&&r.jsx(Q,{className:"text-green-500"})]}),!!d.length&&d]})},Me=({filter:c})=>{const[{data:m,fetching:D,hasNext:d}]=q({query:H,variables:c}),p=F.useMemo(()=>m?.pcnByDate?m.pcnByDate.sort((y,g)=>g.date>y.date?1:g.date<y.date?-1:0):[],[m?.pcnByDate]);return D?r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}):r.jsxs("div",{className:"flex flex-col gap-4",children:[!!m&&d&&r.jsx("div",{className:"w-full h-full flex justify-center",children:r.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"})}),p.map((y,g)=>r.jsx(ge,{content:y.content,contentOrigin:y.diffContent,monthDate:y.date},g))]})};function be({filter:c,setFilter:m,closeModal:D}){const{control:d,handleSubmit:p,setValue:y}=X({defaultValues:{...c}}),{selectableBusinesses:g,fetching:P}=ee(),j=e=>{m(e),D()};return r.jsxs(r.Fragment,{children:[P?r.jsx("div",{children:"Loading..."}):r.jsx("div",{}),r.jsxs("form",{onSubmit:p(j),children:[r.jsx(te,{name:"businessId",control:d,defaultValue:void 0,render:({field:e,fieldState:n})=>r.jsx(ne,{...e,data:g,value:e.value,disabled:P,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),r.jsx(O,{label:"From date",defaultValue:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,defaultDate:c?.fromMonthDate?new Date(c.fromMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("fromMonthDate",k(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsx(O,{label:"To date",defaultValue:c?.toMonthDate?new Date(c.toMonthDate):new Date,defaultDate:c?.toMonthDate?new Date(c.toMonthDate):new Date,onChange:e=>{const n=new Date(e.getFullYear(),e.getMonth(),15);y("toMonthDate",k(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}}),r.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[r.jsx(U,{type:"submit",children:"Filter"}),r.jsx(U,{type:"button",onClick:D,children:"Cancel"})]})]})]})}function ve({filter:c,setFilter:m}){const[D,d]=F.useState(!1),{get:p,set:y}=W(),{userContext:g}=F.useContext(K);function P(j){j||={businessId:g?.context.adminBusinessId??c.businessId,fromMonthDate:k(T(new Date),"yyyy-MM-15"),toMonthDate:k(new Date,"yyyy-MM-15")},se(j,c)||m(j)}return F.useEffect(()=>{const j=$(c??{})?null:encodeURIComponent(JSON.stringify(c)),e=p("validateReportsFilters");j!==e&&y("validateReportsFilters",j)},[c,p,y]),r.jsxs(r.Fragment,{children:[r.jsx(de,{opened:D,onClose:()=>d(!1),content:r.jsx(be,{filter:c,setFilter:P,closeModal:()=>d(!1)})}),r.jsx(U,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:r.jsx(pe,{className:"size-5"})})]})}const Se=()=>{const{get:c}=W(),{setFiltersContext:m}=F.useContext(oe),D=F.useMemo(()=>{try{if(c("validateReportsFilters"))return JSON.parse(decodeURIComponent(c("validateReportsFilters")))}catch(y){console.error("Error parsing filter from URL",y)}return{fromMonthDate:k(T(new Date),"yyyy-MM-15"),toMonthDate:k(new Date,"yyyy-MM-15")}},[c]),[d,p]=F.useState(D);return F.useEffect(()=>{m(r.jsx("div",{className:"flex flex-row gap-2",children:r.jsx(ve,{filter:{...d},setFilter:p})}))},[d,m]),r.jsx(ae,{title:"Report Validations",children:r.jsx(ce,{type:"single",collapsible:!0,children:r.jsx(fe,{value:"pcn874",children:r.jsxs(re,{className:"p-4",children:[r.jsx(ue,{children:r.jsx(ie,{children:"Monthly VAT (PCN874)"})}),r.jsx(he,{children:r.jsx(le,{children:r.jsx(Me,{filter:d})})})]})})})})};export{Se as ValidateReportsScreen};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as M,
|
|
1
|
+
import{u as M,d7 as Q,t as C,r as s,g as U,i as W,d8 as Y,d9 as J,J as F,da as E,j as e,D as R,aO as G,B as v,au as K,z as V,aP as X,aQ as Z,am as _,an as ee,ao as se,ap as te,ar as ne,db as ae,dc as re,dd as q,de as z,bU as ce,df as H,dg as ie,K as k,W as B,L as A,dh as le,e as oe,N as de,P as ue,di as me,be as he,b1 as xe,dj as je,x as P,dk as $,G as pe,bG as fe,w as ge,V as ye,b8 as ve,cI as De,cT as be,cU as Ce,cV as O,cW as g,cY as Ne,cZ as y,aw as we,bQ as Ie,F as Me,c as Te}from"./index-B2_EbsaK.js";import{s as L}from"./subMonths-5wFmciT1.js";const Se=()=>{const[{data:u,fetching:o,error:c},x]=M({query:Q});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",Ee=()=>{const[{fetching:u},o]=U(Y),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=W(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(E,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(K,{})})}),e.jsxs(V,{className:"w-[400px] max-w-screen-md",children:[e.jsx(X,{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(q,{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(H,{children:e.jsx("p",{children:"Edit document"})})]})}),e.jsx(V,{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(E,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(E,r)))},[t,c]),s.useEffect(()=>{d()},[a,d]);const h=pe({values:{generateDocumentsInfo:o}}),{issueDocuments:j}=Ee(),{openContracts:n}=Se(),{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},S)=>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(q,{children:[e.jsx(z,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>D(S),children:e.jsx(we,{size:16})})}),e.jsx(H,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(ke,{draft:m,onApprove:b=>{h.setValue(`generateDocumentsInfo.${S}`,b,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),w(S,{...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 +1 @@
|
|
|
1
|
-
import{j as e,
|
|
1
|
+
import{j as e,cV as D,cZ as a,x as f,cu as n,J as N,fX as v,r as d,bt as T,D as E,aO as A,B as Y,z as I,bm as O,G as V,cO as M,V as P,X as y,Y as C,Z as F,_ as B,as as L,a0 as R,al as U,aT as _,F as k,a8 as q,u as z,c as G,cT as J,cU as Q,cW as o,cY as $,fY as H}from"./index-B2_EbsaK.js";import{u as w}from"./use-url-query-BPzyQB93.js";import{P as X}from"./page-layout-C0GJoVTR.js";import{F as Z}from"./funnel-BlaCusqP.js";const W=({record:s})=>{const t=N(v,s);return e.jsxs(D,{children:[e.jsx(a,{children:s.description}),e.jsx(a,{children:f(new Date(s.purchaseDate),"dd/MM/yyyy")}),e.jsx(a,{children:s.activationDate?f(new Date(s.activationDate),"dd/MM/yyyy"):void 0}),e.jsx(a,{children:t.originalCost?n(t.originalCost,0):void 0}),e.jsx(a,{children:t.reportYearDelta?n(t.reportYearDelta,0):void 0}),e.jsx(a,{children:n(t.totalDepreciableCosts,0)}),e.jsxs(a,{children:[n(s.statutoryDepreciationRate,0),"%"]}),e.jsx(a,{children:s.claimedDepreciationRate?`${n(s.claimedDepreciationRate,1)}%`:"-"}),e.jsx(a,{children:t.reportYearClaimedDepreciation?n(t.reportYearClaimedDepreciation,0):"-"}),e.jsx(a,{children:t.pastYearsAccumulatedDepreciation?n(t.pastYearsAccumulatedDepreciation,0):"-"}),e.jsx(a,{children:t.totalDepreciation?n(t.totalDepreciation,0):"-"}),e.jsx(a,{children:t.netValue?n(t.netValue,0):"-"})]})};function K(s){return!s||O(s)?null:encodeURIComponent(JSON.stringify(s))}const b="depreciationReportFilters";function ee({filter:s,setFilter:t,close:r}){const m=V({defaultValues:{...s}}),{control:c,handleSubmit:x}=m,{selectableFinancialEntities:u,fetching:l}=M(),j=i=>{t({...i,year:Number(i.year)}),r()};return e.jsx(P,{...m,children:e.jsxs("form",{onSubmit:x(j),className:"space-y-4",children:[e.jsx(y,{name:"year",control:c,rules:{required:"Year is required",validate:i=>{const p=Number(i);return Number.isNaN(p)||p<2e3||p>2100?"Invalid year":!0}},render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Year"}),e.jsx(B,{children:e.jsx(L,{...i,hideControls:!0,decimalScale:0})}),e.jsx(R,{})]})}),e.jsx(y,{name:"financialEntityId",defaultValue:s?.financialEntityId,control:c,render:({field:i})=>e.jsxs(C,{children:[e.jsx(F,{children:"Owner"}),e.jsx(U,{...i,data:u,value:i.value??void 0,disabled:l,placeholder:"Select a financial entity",formPart:!0}),e.jsx(R,{})]})}),e.jsx(_,{children:e.jsx(Y,{type:"submit",disabled:l,children:"Filter"})})]})})}function ae({filter:s,setFilter:t}){const[r,m]=d.useState(!1),{get:c,set:x}=w();d.useEffect(()=>{const l=K(s),j=c(b);l!==j&&x(b,l)},[s,c,x]);const u=d.useCallback(l=>{T(l,s)||t(l)},[s,t]);return e.jsxs(E,{open:r,onOpenChange:m,children:[e.jsx(A,{asChild:!0,children:e.jsx(Y,{variant:"outline",size:"icon",children:e.jsx(Z,{size:20})})}),e.jsx(I,{className:"sm:max-w-[425px]",children:e.jsx(ee,{filter:s,setFilter:u,close:()=>m(!1)})})]})}const g=({data:s,groupName:t})=>{const r=N(v,s);return e.jsxs(D,{className:"font-bold border-b border-black",children:[e.jsx(a,{children:t?"Group Total":"Overall Total"}),e.jsx(a,{colSpan:2,children:t}),e.jsx(a,{children:r.originalCost?n(r.originalCost,0):void 0}),e.jsx(a,{children:r.reportYearDelta?n(r.reportYearDelta,0):void 0}),e.jsx(a,{children:r.totalDepreciableCosts?n(r.totalDepreciableCosts,0):void 0}),e.jsx(a,{}),e.jsx(a,{}),e.jsx(a,{children:r.reportYearClaimedDepreciation?n(r.reportYearClaimedDepreciation,0):void 0}),e.jsx(a,{children:r.pastYearsAccumulatedDepreciation?n(r.pastYearsAccumulatedDepreciation,0):void 0}),e.jsx(a,{children:r.totalDepreciation?n(r.totalDepreciation,0):void 0}),e.jsx(a,{children:r.netValue?n(r.netValue,0):void 0})]})},ne=()=>{const{setFiltersContext:s}=d.useContext(k),{userContext:t}=d.useContext(q),{get:r}=w(),m=d.useMemo(()=>{const i={financialEntityId:t?.context.adminBusinessId,year:new Date().getFullYear()},p=r(b);if(p)try{return JSON.parse(decodeURIComponent(p))}catch(h){console.error("Failed to parse depreciation report filters from URL",h)}return i},[t?.context.adminBusinessId]),[c,x]=d.useState(m),[{data:u,fetching:l}]=z({query:H,variables:{filters:c}});d.useEffect(()=>{s(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(ae,{filter:c,setFilter:x})}))},[c,s,x]);const j=d.useMemo(()=>`Depreciation Report for ${c.year}`,[c.year]);return e.jsx(X,{title:"Depreciation Report",description:j,children:l?e.jsx(G,{}):e.jsxs(J,{children:[e.jsxs(Q,{children:[e.jsxs(D,{className:"font-bold text-xl",children:[e.jsx(o,{colSpan:6,className:"text-center border-x",children:"List of Assets and Costs"}),e.jsx(o,{colSpan:5,className:"text-center border-x",children:"Depreciation"}),e.jsx(o,{className:"text-center border-x",children:"Remaining"})]}),e.jsxs(D,{className:"border-b border-black",children:[e.jsx(o,{className:"whitespace-normal",children:"Assets List and Descriptions"}),e.jsx(o,{className:"whitespace-normal",children:"Date of Purchase"}),e.jsx(o,{className:"whitespace-normal",children:"Activation Date"}),e.jsx(o,{className:"whitespace-normal",children:"Original Cost"}),e.jsx(o,{className:"whitespace-normal",children:"Changes During the Year"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciable Assets"}),e.jsx(o,{className:"whitespace-normal",children:"Statutory Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Claimed Depreciation Rate"}),e.jsx(o,{className:"whitespace-normal",children:"Depreciation Claimed This Year"}),e.jsx(o,{className:"whitespace-normal",children:"Previous Tax Years Accumulated Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Total Depreciation"}),e.jsx(o,{className:"whitespace-normal",children:"Net Book Value"})]})]}),e.jsx($,{children:u?.depreciationReport&&e.jsxs(e.Fragment,{children:[u.depreciationReport.categories.map((i,p)=>e.jsxs(d.Fragment,{children:[e.jsxs(D,{className:"font-bold",children:[e.jsx(a,{children:`Category ${p+1}`}),e.jsx(a,{colSpan:2,children:i.category.name}),e.jsx(a,{colSpan:3}),e.jsxs(a,{children:[n(i.category.percentage,0),"%"]}),e.jsx(a,{colSpan:5})]}),i.records.sort((h,S)=>h.purchaseDate.localeCompare(S.purchaseDate)).map(h=>e.jsx(W,{record:h},h.id)),e.jsx(g,{data:i.summary,groupName:i.category.name})]},i.id)),e.jsx(g,{data:u.depreciationReport.summary})]})})]})})};export{ne as DepreciationReport};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as h,
|
|
1
|
+
import{r as h,bm as S,j as e,bn as N,B as y,G as $,bo as k,a8 as R,V as O,bp as f,bq as D,br as C,x as F,X as A,Y as E,Z as z,_ as P,ah as M,bt as L,bj as w,T as B,a$ as j,aN as p,J as V,dl as _,cu as v,F as G,u as q,dm as U,dn as Z,L as H,dp as J}from"./index-B2_EbsaK.js";import{u as I}from"./use-url-query-BPzyQB93.js";import{P as Q}from"./page-layout-C0GJoVTR.js";import{P as X}from"./modal-B0uNLang.js";import{F as K}from"./funnel-BlaCusqP.js";import{M as T}from"./MultiSelect-CBtq6WUv.js";import{D as W}from"./download-csv-button-DZ5cKqkV.js";import{B as Y}from"./business-extended-info-DmQ7B7-Z.js";import{P as ee,a as te}from"./panel-top-open-BFNhAe3f.js";import{T as se}from"./Table-CYqAEQfS.js";function re({filter:t,setFilter:s,closeModal:i}){const n=$({defaultValues:{...t}}),{control:a,handleSubmit:o}=n,{selectableBusinesses:r,fetching:u}=k(),{userContext:m}=h.useContext(R),c=l=>{l.fromDate?.trim()===""&&(l.fromDate=void 0),l.toDate?.trim()===""&&(l.toDate=void 0),s(l),i()};function d(){s({}),i()}return e.jsxs(e.Fragment,{children:[u?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(O,{...n,children:e.jsxs("form",{onSubmit:o(c),className:"space-y-2",children:[e.jsx(f,{name:"ownerIds",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.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(f,{name:"businessIDs",control:a,defaultValue:void 0,render:({field:l,fieldState:b})=>e.jsx(T,{...l,data:r,value:l.value??void 0,disabled:u,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:b.error?.message})}),e.jsx(f,{name:"fromDate",control:a,defaultValue:t.fromDate,rules:{required:"Required",pattern:{value:D,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"From Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(f,{name:"toDate",control:a,defaultValue:t.toDate,rules:{pattern:{value:D,message:"Date must be im format yyyy-mm-dd"}},render:({field:l,fieldState:b})=>e.jsx(C,{...l,onChange:x=>{const g=x?typeof x=="string"?x:F(x,"yyyy-MM-dd"):void 0;g!==l.value&&l.onChange(g)},value:l.value?new Date(l.value):void 0,label:"To Date",error:b.error?.message,required:!0,popoverProps:{withinPortal:!0}})}),e.jsx(A,{name:"isShowZeroedAccounts",control:a,render:({field:l})=>e.jsxs(E,{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(z,{children:"Show zeroed accounts"})}),e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(P,{children:e.jsx(M,{defaultChecked:t.isShowZeroedAccounts??!1,onCheckedChange:l.onChange,checked:l.value===!0})}),e.jsx("span",{children:l.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:i,children:"Cancel"})]})]})})]})}function ae({filter:t,setFilter:s}){const[i,n]=h.useState(!1),[a,o]=h.useState(!S(t)),{get:r,set:u}=I();function m(d){return Object.entries(d??{}).filter(([b,x])=>x!==void 0&&Array.isArray(x)&&x.length>0).length>0}function c(d){L(d,t)||(s(d),o(m(d)))}return h.useEffect(()=>{const d=S(t)?null:encodeURIComponent(JSON.stringify(t)),l=r("trialBalanceReportFilters");d!==l&&u("trialBalanceReportFilters",d)},[t,r,u]),e.jsxs(e.Fragment,{children:[e.jsx(X,{opened:i,onClose:()=>n(!1),content:e.jsx(re,{filter:t,setFilter:c,closeModal:()=>n(!1)})}),e.jsx(N,{inline:!0,size:16,disabled:!a,children:e.jsx(y,{variant:"outline",onClick:()=>n(!0),className:"p-2",children:e.jsx(K,{size:20})})})]})}const ne=({data:t,fromDate:s,toDate:i})=>{const n=h.useCallback(async()=>{const a=oe(t),o=`trial_balance_report${s?`_${s}`:""}${i?`_${i}`:""}`;return{fileContent:a,fileName:o}},[t,s,i]);return e.jsx(W,{createFileVariables:n})},oe=t=>{let s="";s+=`Sort Code,Account Name,Debit,Credit,Balance\r
|
|
2
2
|
`;for(const[i,n]of Object.entries(t)){const a=ie(i,n);s+=a}return s+=`Report total:,,${Object.values(t).reduce((i,n)=>i+n.totalDebit,0)},${Object.values(t).reduce((i,n)=>i+n.totalCredit,0)},${Object.values(t).reduce((i,n)=>i+n.sum,0)}\r
|
|
3
3
|
`,s};function ie(t,s){let i="";return Object.values(s.sortCodes).sort((n,a)=>n.key-a.key).map(n=>{const a=le(n);i+=a}),i+=`${t.replaceAll("0","*")},Group Total:,${s.totalDebit??""},${s.totalCredit??""},${s.sum}\r
|
|
4
4
|
`,i}function le(t){let s="";s+=`${t.name}\r
|
|
@@ -6,4 +6,4 @@ import{r as h,bo as S,j as e,bp as N,B as y,G as $,bq as k,a8 as R,V as O,br as
|
|
|
6
6
|
`;s+=c});const i=`${t.key},Group total:,${t.totalDebit??""},${t.totalCredit??""},${t.sum}\r
|
|
7
7
|
`;s+=i;const n=t.debit?`,,,Total Debit Balances:,${t.debit}\r
|
|
8
8
|
`:"";s+=n;const a=t.credit?`,,,Total Credit Balances:,${t.credit}\r
|
|
9
|
-
`:"";return s+=a,s}function ce(t){let s="";return s=t.replace(/"/g,'""'),s}const de=({record:t,sortCodeKey:s,filter:i,isAllOpened:n})=>{const[a,o]=h.useState(n),r=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:(r>.001||r<-.001)&&e.jsx(w,{color:r>0?"green":"red",children:t?.total?.formatted})}),e.jsx("td",{children:e.jsx(B,{label:"Detailed records",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(c=>!c),children:a||n?e.jsx(ee,{className:"size-5"}):e.jsx(te,{className:"size-5"})})})})]},t.business.id),(a||n)&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx(Y,{businessID:t.business?.id,filter:i})})})]})},ue=({sortCode:t,filter:s,isAllOpened:i})=>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,a)=>n.business.name.localeCompare(a.business.name)).map(n=>e.jsx(de,{record:n,sortCodeKey:t.key,filter:s,isAllOpened:i},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(w,{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,me=({group:t,data:s,filter:i,isAllOpened:n})=>e.jsxs(e.Fragment,{children:[Object.values(s.sortCodes).sort((a,o)=>a.key-o.key).map((a,o)=>e.jsx(ue,{sortCode:a,filter:i,isAllOpened:n},`${a.key} ${o}`)),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(w,{fw:700,c:s.sum>0?"green":s.sum<0?"red":void 0,children:j(s.sum,p.Ils)})})]},"group"+t)]});function xe(t){return Math.floor(t/100)*100}const he=({data:t,filter:s,isAllOpened:i})=>{const{businessTransactionsSum:n}=V(_,t),a=h.useMemo(()=>{const o={};for(const r of n){r.business.sortCode??={id:"-999",key:-999,name:"Misc"};const u=!r.total.raw||r.total.raw<.001&&r.total.raw>-.001;if(!s.isShowZeroedAccounts&&u)continue;const m=xe(r.business.sortCode.key);o[m]??={sortCodes:{},totalCredit:0,totalDebit:0,credit:0,debit:0,sum:0};const c=o[m];c.sortCodes[r.business.sortCode.key]??={...r.business.sortCode,totalCredit:0,totalDebit:0,records:[],credit:0,debit:0,sum:0};const d=c.sortCodes[r.business.sortCode.key];d.totalCredit+=r.credit.raw,d.totalDebit+=r.debit.raw,d.sum+=r.total.raw,c.totalCredit+=r.credit.raw,c.totalDebit+=r.debit.raw,c.sum+=r.total.raw,r.total.raw>0?(d.credit+=r.total.raw,c.credit+=r.total.raw):(d.debit+=r.total.raw,c.debit+=r.total.raw),d.records.push(r)}return o},[n,s.isShowZeroedAccounts]);return e.jsxs(se,{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(ne,{data:a,fromDate:s.fromDate??void 0,toDate:s.toDate??void 0})})]})}),e.jsxs("tbody",{children:[Object.entries(a).map(([o,r])=>e.jsx(me,{data:r,group:o,filter:s,isAllOpened:i},o)),e.jsxs("tr",{className:"bg-gray-100",children:[e.jsx("td",{colSpan:2,children:"Report total:"}),e.jsx("td",{}),e.jsxs("td",{children:["(",v(Object.values(a).reduce((o,r)=>o+r.totalDebit,0)),")"]}),e.jsxs("td",{children:["(",v(Object.values(a).reduce((o,r)=>o+r.totalCredit,0)),")"]}),e.jsx("td",{colSpan:1,children:v(Object.values(a).reduce((o,r)=>o+r.sum,0))})]})]})]})},Ce=()=>{const[t,s]=h.useState(!1),{get:i}=I(),{setFiltersContext:n}=h.useContext(
|
|
9
|
+
`:"";return s+=a,s}function ce(t){let s="";return s=t.replace(/"/g,'""'),s}const de=({record:t,sortCodeKey:s,filter:i,isAllOpened:n})=>{const[a,o]=h.useState(n),r=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:(r>.001||r<-.001)&&e.jsx(w,{color:r>0?"green":"red",children:t?.total?.formatted})}),e.jsx("td",{children:e.jsx(B,{label:"Detailed records",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(c=>!c),children:a||n?e.jsx(ee,{className:"size-5"}):e.jsx(te,{className:"size-5"})})})})]},t.business.id),(a||n)&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx(Y,{businessID:t.business?.id,filter:i})})})]})},ue=({sortCode:t,filter:s,isAllOpened:i})=>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,a)=>n.business.name.localeCompare(a.business.name)).map(n=>e.jsx(de,{record:n,sortCodeKey:t.key,filter:s,isAllOpened:i},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(w,{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,me=({group:t,data:s,filter:i,isAllOpened:n})=>e.jsxs(e.Fragment,{children:[Object.values(s.sortCodes).sort((a,o)=>a.key-o.key).map((a,o)=>e.jsx(ue,{sortCode:a,filter:i,isAllOpened:n},`${a.key} ${o}`)),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(w,{fw:700,c:s.sum>0?"green":s.sum<0?"red":void 0,children:j(s.sum,p.Ils)})})]},"group"+t)]});function xe(t){return Math.floor(t/100)*100}const he=({data:t,filter:s,isAllOpened:i})=>{const{businessTransactionsSum:n}=V(_,t),a=h.useMemo(()=>{const o={};for(const r of n){r.business.sortCode??={id:"-999",key:-999,name:"Misc"};const u=!r.total.raw||r.total.raw<.001&&r.total.raw>-.001;if(!s.isShowZeroedAccounts&&u)continue;const m=xe(r.business.sortCode.key);o[m]??={sortCodes:{},totalCredit:0,totalDebit:0,credit:0,debit:0,sum:0};const c=o[m];c.sortCodes[r.business.sortCode.key]??={...r.business.sortCode,totalCredit:0,totalDebit:0,records:[],credit:0,debit:0,sum:0};const d=c.sortCodes[r.business.sortCode.key];d.totalCredit+=r.credit.raw,d.totalDebit+=r.debit.raw,d.sum+=r.total.raw,c.totalCredit+=r.credit.raw,c.totalDebit+=r.debit.raw,c.sum+=r.total.raw,r.total.raw>0?(d.credit+=r.total.raw,c.credit+=r.total.raw):(d.debit+=r.total.raw,c.debit+=r.total.raw),d.records.push(r)}return o},[n,s.isShowZeroedAccounts]);return e.jsxs(se,{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(ne,{data:a,fromDate:s.fromDate??void 0,toDate:s.toDate??void 0})})]})}),e.jsxs("tbody",{children:[Object.entries(a).map(([o,r])=>e.jsx(me,{data:r,group:o,filter:s,isAllOpened:i},o)),e.jsxs("tr",{className:"bg-gray-100",children:[e.jsx("td",{colSpan:2,children:"Report total:"}),e.jsx("td",{}),e.jsxs("td",{children:["(",v(Object.values(a).reduce((o,r)=>o+r.totalDebit,0)),")"]}),e.jsxs("td",{children:["(",v(Object.values(a).reduce((o,r)=>o+r.totalCredit,0)),")"]}),e.jsx("td",{colSpan:1,children:v(Object.values(a).reduce((o,r)=>o+r.sum,0))})]})]})]})},Ce=()=>{const[t,s]=h.useState(!1),{get:i}=I(),{setFiltersContext:n}=h.useContext(G),[a,o]=h.useState(i("trialBalanceReportFilters")?JSON.parse(decodeURIComponent(i("trialBalanceReportFilters"))):{}),[{data:r,fetching:u}]=q({query:J,variables:{filters:{fromDate:a?.fromDate,toDate:a?.toDate,ownerIds:a?.ownerIds,businessIDs:a?.businessIDs}}});h.useEffect(()=>{n(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(B,{label:"Expand all accounts",children:e.jsx(y,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>s(c=>!c),children:t?e.jsx(U,{className:"size-5"}):e.jsx(Z,{className:"size-5"})})}),e.jsx(ae,{filter:a,setFilter:o})]}))},[a,t,n]);const m=h.useMemo(()=>r?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?void 0:r?.businessTransactionsSumFromLedgerRecords,[r?.businessTransactionsSumFromLedgerRecords]);return e.jsx(Q,{title:"Trial Balance Report",description:"Trial balance report for all businesses",children:u||!m?e.jsx(H,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(he,{data:m,filter:a,isAllOpened:t})})};export{Ce as TrialBalanceReport};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{v as G,r as d,j as e,J as p,B as g,
|
|
1
|
+
import{v as G,r as d,j as e,J as p,B as g,dR as q,dS as H,dT as _,cu as F,dU as M,dV as J,dW as Q,dX as $,dY as Y,dZ as W,d_ as X,u as T,t as Z,d$ as K,T as ee,e0 as te,a8 as E,bm as se,G as ae,cO as ne,bp as S,bs as A,e1 as N,cI as re,x as D,bt as oe,F as ie,L as ce,e2 as le}from"./index-B2_EbsaK.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as V}from"./use-url-query-BPzyQB93.js";import{M as de}from"./index-EaY6ZYvr.js";import{E as he,I as me,M as xe}from"./match-document-modal-DcL0siQq.js";import{P as ue}from"./page-layout-C0GJoVTR.js";import{C as I,u as pe,a as z,b as O}from"./charges-table-D_GDHvFS.js";import{P as w,a as y}from"./panel-top-open-BFNhAe3f.js";import{T as k}from"./toggle-expansion-button-41Ejffq3.js";import{T as P}from"./Table-CYqAEQfS.js";import{c as ge}from"./charges-filters-BUFmsiTq.js";import{P as je}from"./modal-B0uNLang.js";import{F as fe}from"./funnel-BlaCusqP.js";import"./Checkbox-Ddw01d64.js";import"./YearPickerInput-CgU-feeq.js";import"./list-plus-CGvSlslE.js";import"./insert-business-trip-modal-BwOnvw7X.js";import"./accounter-table-CM6PQ9Aw.js";import"./Pagination-BM-86UO5.js";import"./create-event-handler-BiA-1lGu.js";import"./index-CRLPoT61.js";import"./similar-transactions-modal-nk8VHEtX.js";import"./addDays-DGlDD_vj.js";import"./tooltip-lhMCop8U.js";import"./summary-DuWhfNdL.js";import"./sub-fkVv9ghZ.js";import"./subMonths-5wFmciT1.js";import"./MultiSelect-CBtq6WUv.js";/**
|
|
2
2
|
* @license lucide-react v0.548.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=G("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(q,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(H,a),{updateChargeAccountantApproval:r}=pe();return e.jsx("td",{children:e.jsx(_,{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(Q,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:["₪ ",F(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",F(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(z,{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(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(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)})})]})]})},Fe=({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:"₪ "+F(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(z,{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})})})})]})},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(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(Fe,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},De=({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]=T({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",D(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??N.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}=V(),{userContext:s}=d.useContext(E);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:D(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 rt=()=>{const{get:a}=V(),{setFiltersContext:c}=d.useContext(ie),{userContext:l}=d.useContext(E),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:D(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}]=T({query:R(le),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(de,{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(ue,{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!==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: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(De,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),m&&e.jsx(he,{chargeId:m.id,close:()=>x(void 0)}),t&&e.jsx(me,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(xe,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>u(void 0)})]})})};export{rt 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=G("file-digit",ve),ye=({data:a,setEditCharge:c,setInsertDocument:l,setMatchDocuments:r,toggleMergeCharge:o,mergeSelectedCharges:n})=>{const s=p(q,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(H,a),{updateChargeAccountantApproval:r}=pe();return e.jsx("td",{children:e.jsx(_,{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:["₪ ",F(r,0)]}),e.jsxs("td",{className:"whitespace-nowrap",children:["₪ ",F(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(z,{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)})})]})]})},Fe=({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:"₪ "+F(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(z,{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})})})})]})},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(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(Fe,{data:t,toggleMergeCharge:c,mergeSelectedCharges:l,cumulativeAmount:h},i)})})]})]})},De=({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"})}),"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(X,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})]})},Se=({filter:{monthDate:a,financialEntityId:c},isLoading:l})=>{const[{data:r,fetching:o,error:n},s]=T({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}`),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"});K(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 Ae({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",D(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(S,{name:"financialEntityId",control:r,defaultValue:void 0,render:({field:m,fieldState:x})=>e.jsx(A,{...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(S,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:m,fieldState:x})=>e.jsx(A,{...m,data:ge,value:m.value??N.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}=V(),{userContext:s}=d.useContext(E);function t(i){i||={financialEntityId:s?.context.adminBusinessId??a.financialEntityId,monthDate:D(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(Ae,{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 rt=()=>{const{get:a}=V(),{setFiltersContext:c}=d.useContext(ie),{userContext:l}=d.useContext(E),[r,o]=d.useState(a("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(a("vatMonthlyReportFilters"))):{financialEntityId:l?.context.adminBusinessId??"",monthDate:D(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}]=T({query:R(le),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(Se,{filter:r,isLoading:b}),e.jsx(Me,{filter:{...r},setFilter:o}),e.jsx(de,{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(ue,{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!==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: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(De,{data:j?.vatReport,setEditCharge:x,setInsertDocument:i,setMatchDocuments:u,toggleMergeCharge:f,mergeSelectedCharges:C}),m&&e.jsx(he,{chargeId:m.id,close:()=>x(void 0)}),t&&e.jsx(me,{chargeId:t.id,close:()=>i(void 0)}),h&&e.jsx(xe,{chargeId:h.id,ownerId:h.ownerId,setMatchDocuments:()=>u(void 0)})]})})};export{rt as VatMonthlyReport};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,B as u,a as y,F as g,u as P,L as D,
|
|
1
|
+
import{r as c,j as e,B as u,a as y,F as g,u as P,L as D,fT as w}from"./index-B2_EbsaK.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as E}from"./page-layout-C0GJoVTR.js";import{R as d}from"./report-commentary-row-CNIlhboC.js";import{P as v}from"./modal-B0uNLang.js";import{Y as p}from"./YearPickerInput-CgU-feeq.js";import{F}from"./funnel-BlaCusqP.js";import{T as C}from"./Table-CYqAEQfS.js";import"./toggle-expansion-button-41Ejffq3.js";import"./panel-top-open-BFNhAe3f.js";function A({year:l,setYear:h,referenceYears:o,setReferenceYears:j}){const[m,x]=c.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(v,{opened:m,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&&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:()=>x(!0),children:e.jsx(F,{className:"size-5"})})]})}const I=()=>{const{year:l}=y(),{setFiltersContext:h}=c.useContext(g),[o,j]=c.useState(l?Number(l):new Date().getFullYear()),[m,x]=c.useState([]),[{data:n,fetching:i}]=P({query:R(w),variables:{reportYear:o,referenceYears:m}});c.useEffect(()=>{h(e.jsx("div",{className:"flex flex-row gap-2",children:e.jsx(A,{year:o,setYear:j,referenceYears:m,setReferenceYears:x})}))},[o,i,h,m,x]);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,2 +1,2 @@
|
|
|
1
|
-
import{r as u,j as e,x as v,J as R,
|
|
2
|
-
`)};function j(a){return a.replace(/"/g,'""').replace(/,/g,".")}const c=H(z.Ils),W=[{id:"placeholder",header:"",cell:()=>null},{id:"counterparty",accessorKey:"counterparty",header:"Counterparty",cell:({row:a})=>e.jsx("div",{className:"font-medium",children:a.original.counterParty?.name})},{id:"invoiceDate",accessorKey:"invoiceDate",header:"Invoice Date",cell:({row:a})=>{const s=new Date(a.getValue("invoiceDate")),n=v(s,"yyyy-MM-dd");return e.jsx("div",{className:"font-medium",children:n})}},{id:"valueDate",accessorKey:"valueDate",header:"Value Date",cell:({row:a})=>{const s=new Date(a.getValue("valueDate")),n=v(s,"yyyy-MM-dd");return e.jsx("div",{className:"font-medium",children:n})}},{id:"reference",accessorKey:"reference",header:"Reference"},{id:"description",accessorKey:"description",header:"Description"},{id:"debit",header:"Debit",cell:({row:a})=>{const s=a.original.amount.raw;return s<0?e.jsx("div",{className:"font-medium",children:c.format(s*-1)}):null}},{id:"credit",header:"Credit",cell:({row:a})=>{const s=a.original.amount.raw;return s>=0?e.jsx("div",{className:"font-medium",children:c.format(s)}):null}},{id:"balance",accessorKey:"balance",header:"Balance",cell:({row:a})=>e.jsx("div",{className:"font-medium",children:c.format(a.getValue("balance"))})}],te=()=>{const{setFiltersContext:a}=u.useContext($),[s,n]=u.useState(new Date().getFullYear()-1),[{data:x,fetching:m}]=k({query:
|
|
1
|
+
import{r as u,j as e,x as v,J as R,gb as M,F as $,u as k,cQ as B,L as P,cT as T,cU as V,cV as d,cW as L,cX as C,cY as Y,cZ as t,gc as S,d4 as K,d5 as O,dE as H,aN as z}from"./index-B2_EbsaK.js";import{D as A}from"./data-table-pagination-CKN0E29f.js";import{P as Q}from"./page-layout-C0GJoVTR.js";import{D as q}from"./download-csv-button-DZ5cKqkV.js";import{Y as E}from"./YearPickerInput-CgU-feeq.js";const J=({data:a,year:s})=>{const n=u.useCallback(async()=>{if(!a)return{fileContent:"",fileName:""};const x=R(M,a),m=U(x),l=`${s}_ledger`;return{fileContent:m,fileName:l}},[a,s]);return a?e.jsx(q,{createFileVariables:n}):e.jsx("div",{})},F=[{key:"",valueFn:()=>""},{key:"",valueFn:()=>""},{key:"Counterparty",valueFn:a=>j(a.counterParty?.name??"")},{key:"Invoice Date",valueFn:a=>v(a.invoiceDate,"yyyy-MM-dd")},{key:"Value Date",valueFn:a=>v(a.valueDate,"yyyy-MM-dd")},{key:"Reference",valueFn:a=>a.reference?`"${j(a.reference)}"`:""},{key:"Description",valueFn:a=>a.description?`"${j(a.description)}"`:""},{key:"Debit Amount",valueFn:a=>a.amount.raw<0?Math.abs(a.amount.raw).toFixed(2):""},{key:"Credit Amount",valueFn:a=>a.amount.raw>=0?a.amount.raw.toFixed(2):""},{key:"Balance",valueFn:a=>a.balance.toFixed(2)}],U=a=>{const s=[F.map(({key:n})=>n).join(",")];return a.financialEntitiesInfo.map(n=>{const x=`${j(n.entity.name)},${n.entity.sortCode?.key}`,m=`,Opening Balance,,,,,,,,${n.openingBalance.raw.toFixed(2)}`,l=`Total,${j(n.entity.name)},,,,,,,${Math.abs(n.totalDebit.raw).toFixed(2)} Debit,`,g=`,,,,,,,,${n.totalCredit.raw.toFixed(2)} Credit,${n.closingBalance.raw.toFixed(2)}`,D=`,,,,,,,,${(n.totalCredit.raw-n.totalDebit.raw).toFixed(2)} Diff,`;s.push(x,m,...n.records.map(o=>F.map(({valueFn:b})=>b(o)).join(",")),l,g,D)}),s.join(`\r
|
|
2
|
+
`)};function j(a){return a.replace(/"/g,'""').replace(/,/g,".")}const c=H(z.Ils),W=[{id:"placeholder",header:"",cell:()=>null},{id:"counterparty",accessorKey:"counterparty",header:"Counterparty",cell:({row:a})=>e.jsx("div",{className:"font-medium",children:a.original.counterParty?.name})},{id:"invoiceDate",accessorKey:"invoiceDate",header:"Invoice Date",cell:({row:a})=>{const s=new Date(a.getValue("invoiceDate")),n=v(s,"yyyy-MM-dd");return e.jsx("div",{className:"font-medium",children:n})}},{id:"valueDate",accessorKey:"valueDate",header:"Value Date",cell:({row:a})=>{const s=new Date(a.getValue("valueDate")),n=v(s,"yyyy-MM-dd");return e.jsx("div",{className:"font-medium",children:n})}},{id:"reference",accessorKey:"reference",header:"Reference"},{id:"description",accessorKey:"description",header:"Description"},{id:"debit",header:"Debit",cell:({row:a})=>{const s=a.original.amount.raw;return s<0?e.jsx("div",{className:"font-medium",children:c.format(s*-1)}):null}},{id:"credit",header:"Credit",cell:({row:a})=>{const s=a.original.amount.raw;return s>=0?e.jsx("div",{className:"font-medium",children:c.format(s)}):null}},{id:"balance",accessorKey:"balance",header:"Balance",cell:({row:a})=>e.jsx("div",{className:"font-medium",children:c.format(a.getValue("balance"))})}],te=()=>{const{setFiltersContext:a}=u.useContext($),[s,n]=u.useState(new Date().getFullYear()-1),[{data:x,fetching:m}]=k({query:S,variables:{year:s}}),l=x?.yearlyLedgerReport,{financialEntitiesInfo:g}=l??{},D=u.useMemo(()=>g?.flatMap(r=>{const{entity:i,openingBalance:y,closingBalance:h,totalCredit:p,totalDebit:w}=r;return r.records.map(N=>({entity:i,openingBalance:y,closingBalance:h,totalCredit:p,totalDebit:w,...N}))})??[],[g]),o=B({data:D,columns:W,getCoreRowModel:O(),getPaginationRowModel:K(),initialState:{pagination:{pageSize:100}}}),b=o.getState().pagination.pageIndex;return u.useEffect(()=>{a(e.jsxs("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:[e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(A,{table:o})}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(E,{value:new Date(s,0,1),onChange:r=>r&&n(r?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsx(J,{data:l,year:s})]})]}))},[s,m,a,l,o,b]),e.jsx(Q,{title:"Yearly Ledger Report",children:m?e.jsx(P,{className:"h-10 w-10 animate-spin mr-2 self-center"}):l?e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(T,{children:[e.jsx(V,{children:o.getHeaderGroups().map(r=>e.jsx(d,{children:r.headers.map(i=>e.jsx(L,{children:i.isPlaceholder?null:C(i.column.columnDef.header,i.getContext())},i.id))},r.id))}),e.jsx(Y,{children:o.getRowModel().rows.map((r,i)=>{const y=o.getRowModel().rows[i-1],h=o.getRowModel().rows[i+1],p=!y||y.original.entity.id!==r.original.entity.id,w=!h||h.original.entity.id!==r.original.entity.id;return e.jsxs(e.Fragment,{children:[p&&i!==0&&e.jsx(d,{className:"border-y-2 border-t-gray-300 border-b-gray-500",children:e.jsx(t,{})}),p&&e.jsx(X,{row:r}),e.jsx(d,{children:r.getVisibleCells().map(f=>e.jsx(t,{children:C(f.column.columnDef.cell,f.getContext())},f.id))},r.id),w&&e.jsx(Z,{row:r})]})})})]})}):e.jsx("div",{className:"rounded-md border h-24 text-center",children:"No results."})})};function X({row:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(d,{className:"bg-gray-300",children:[e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.name})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.sortCode?.key})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{})]},`${a.id}-opening1`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:"Opening Balance"})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:c.format(a.original.openingBalance.raw)})})]},`${a.id}-opening2`)]})}function Z({row:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:"Total"})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:a.original.entity.name})}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalDebit.raw)," Debit"]})}),e.jsx(t,{})]},`${a.id}-totals1`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalCredit.raw)," Credit"]})}),e.jsx(t,{children:e.jsx("div",{className:"font-medium",children:c.format(a.original.closingBalance.raw)})})]},`${a.id}-totals2`),e.jsxs(d,{className:"bg-gray-200",children:[e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{}),e.jsx(t,{children:e.jsxs("div",{className:"font-medium",children:[c.format(a.original.totalCredit.raw-a.original.totalDebit.raw)," Diff"]})}),e.jsx(t,{})]},`${a.id}-totals3`)]})}export{te as YearlyLedgerReport};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as it,r as m,
|
|
1
|
+
import{v as it,r as m,cE as Nc,ab as V,cJ as kc,ac as ae,j as v,cH as vn,dq as It,dr as ge,ds as Ho,cK as Lc,dt as Vc,du as nn,dv as jc,bm as Fi,D as _r,aO as zr,bn as Fc,B as ee,z as $r,aP as Ur,aQ as Hr,G as Wo,bo as Bc,a8 as _c,bp as An,bq as Bi,br as _i,x as rn,ah as Go,b8 as Ko,bt as zc,g as qo,dw as $c,t as Pe,i as Xo,u as rr,dx as Uc,cQ as Hc,dy as Wc,d3 as Gc,d4 as Kc,d5 as qc,L as Yo,I as Wr,cT as Xc,cU as Yc,cV as Nn,cW as Zc,cX as zi,cY as Jc,cZ as $i,c_ as Zo,c$ as Jo,d0 as Qo,dz as Qc,dA as eu,dB as sn,dC as tu,H as nu,a4 as ru,V as iu,X as su,Y as ou,Z as au,_ as lu,a0 as cu,aT as uu,a6 as Ui,dD as du,e as hu,aw as fu,av as Hi,dE as pu,dF as gu,dG as Wi,bR as mu,aN as vu,F as yu,aj as bu,dH as Tu,dI as xu}from"./index-B2_EbsaK.js";import{u as ea}from"./use-url-query-BPzyQB93.js";import{T as yn}from"./tooltip-lhMCop8U.js";import{A as Gi}from"./arrow-up-down-C61ge4J5.js";import{D as Su}from"./download-csv-button-DZ5cKqkV.js";import{B as wu}from"./business-extended-info-DmQ7B7-Z.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--U0GsZ21.js";import{P as Cu}from"./pencil-9Th5X-OY.js";import{P as Eu,a as Ou}from"./panel-top-open-BFNhAe3f.js";import{F as Pu}from"./funnel-BlaCusqP.js";import{M as Mu}from"./MultiSelect-CBtq6WUv.js";import"./Table-CYqAEQfS.js";/**
|
|
2
2
|
* @license lucide-react v0.548.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|