@accounter/client 0.0.8-alpha-20251031220720-423345df83e7f1559a86ea4e0d2fd294baa2496f → 0.0.8-alpha-20251101011644-cdff5ccf160bd7f96295d651a5365f7fd36dc669
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-CMTNcrRo.js → Checkbox-xGXU5JAb.js} +1 -1
- package/dist/assets/{MultiSelect-DP26KzMa.js → MultiSelect-DXQxo0-S.js} +1 -1
- package/dist/assets/{Progress-C3jVWDXK.js → Progress-9xNJv4nh.js} +1 -1
- package/dist/assets/{Table-c1ug6Rpw.js → Table-BM6YZZrt.js} +1 -1
- package/dist/assets/{Typography-BC-9NaKB.js → Typography-CX3-8fXx.js} +1 -1
- package/dist/assets/{YearPickerInput-CNSe9Fno.js → YearPickerInput-DEG2pQQo.js} +1 -1
- package/dist/assets/{accordion-CLvZdMsA.js → accordion-BZSyOkM7.js} +1 -1
- package/dist/assets/{accountant-approvals-BbNBYszL.js → accountant-approvals-vwtBEWiQ.js} +1 -1
- package/dist/assets/{accounter-table-C7UgjlTA.js → accounter-table-DBMvyGoN.js} +1 -1
- package/dist/assets/{addDays-CB-j-d4t.js → addDays-DMNXN6YX.js} +1 -1
- package/dist/assets/{all-charges-vuUUzmwW.js → all-charges-BYDZFSuI.js} +1 -1
- package/dist/assets/{arrow-up-down-DWlT-GED.js → arrow-up-down-BCyreEvt.js} +1 -1
- package/dist/assets/{building-2-Dkd3B-3N.js → building-2-MBHE4zmH.js} +1 -1
- package/dist/assets/{business-BuVKb8Oy.js → business-CoX2eGPA.js} +1 -1
- package/dist/assets/{business-extended-info-B4Wt-Sq3.js → business-extended-info-CUG_B-2c.js} +1 -1
- package/dist/assets/{business-header-BpYfBk40.js → business-header-zXgJn2Vk.js} +1 -1
- package/dist/assets/{business-ledger-filters-ByAYFfgh.js → business-ledger-filters-DLN498DB.js} +1 -1
- package/dist/assets/{business-ledger-single-cLd56KYs.js → business-ledger-single-Dhw0wzP7.js} +1 -1
- package/dist/assets/{business-trip-BWUbbHEK.js → business-trip-I1x0ip90.js} +1 -1
- package/dist/assets/{charge-DyLqPZn0.js → charge-D7pWgL3K.js} +1 -1
- package/dist/assets/{charges-filters-CUyYbpwk.js → charges-filters-Cn5t0R5G.js} +1 -1
- package/dist/assets/{charges-ledger-validation-Br2BBUCN.js → charges-ledger-validation-wwGJXRHw.js} +1 -1
- package/dist/assets/{charges-table-Cw-X1ZkK.js → charges-table-BuVDqB4z.js} +1 -1
- package/dist/assets/{chart-TrN24kVd.js → chart-Cq954UQg.js} +1 -1
- package/dist/assets/{contracts-CbwbCzFG.js → contracts-BsfmpY2J.js} +1 -1
- package/dist/assets/{data-table-pagination-BZmytrQe.js → data-table-pagination-cKgNAmlV.js} +1 -1
- package/dist/assets/{download-csv-button-r9hq7Mun.js → download-csv-button-BBgOyW3z.js} +1 -1
- package/dist/assets/{edit-issue-document-modal-aZgmep8e.js → edit-issue-document-modal-TINM_yyf.js} +1 -1
- package/dist/assets/{editable-business-trip-BCj8haJN.js → editable-business-trip-BP4Pz4ld.js} +1 -1
- package/dist/assets/{eye-off-Cd4HW5Ki.js → eye-off-DsWzdkGo.js} +1 -1
- package/dist/assets/{funnel-DlU6IKDd.js → funnel-9aCMMcQP.js} +1 -1
- package/dist/assets/{index-Dzi5mI80.js → index-3UYjJ7iT.js} +1 -1
- package/dist/assets/{index-CsxUWF65.js → index-BKvdBq2W.js} +1 -1
- package/dist/assets/{index-BGcp3XaM.js → index-BUB8PTds.js} +1 -1
- package/dist/assets/{index-jpqj1MvA.js → index-BVzmbqPT.js} +1 -1
- package/dist/assets/{index-Cuu0j4Ul.js → index-BZeCq-Gk.js} +1 -1
- package/dist/assets/{index-Wu-q9oyp.js → index-Bd6atUjF.js} +1 -1
- package/dist/assets/{index-DOzNNsNU.js → index-BoekMQSy.js} +1 -1
- package/dist/assets/{index-4Zj8Hp3W.js → index-C-ESD0jY.js} +1 -1
- package/dist/assets/{index-UOt3vExk.js → index-CIAQBv17.js} +102 -102
- package/dist/assets/{index-CS2mkstk.js → index-CVwWYUG4.js} +1 -1
- package/dist/assets/{index-C4ozKIHg.js → index-ClimUI_Y.js} +1 -1
- package/dist/assets/{index-DPLJ9sZn.js → index-CnJzyL0a.js} +1 -1
- package/dist/assets/{index-BwqfmUGW.js → index-D4MUOKdt.js} +1 -1
- package/dist/assets/{index-DnkSW9Wf.js → index-DAzoMW55.js} +1 -1
- package/dist/assets/{index-Bo91VSNv.js → index-DKe--HuR.js} +1 -1
- package/dist/assets/{index-BnDJ3EgW.js → index-DWMtUj_k.js} +1 -1
- package/dist/assets/{index-VYPC3lji.js → index-Dlr5EVXf.js} +1 -1
- package/dist/assets/{index-BM_DgFX-.js → index-DoW4tFSv.js} +1 -1
- package/dist/assets/{index-BovGiTUZ.js → index-Dr5l2Lph.js} +1 -1
- package/dist/assets/{index-Dl3yi4zQ.js → index-DraAMxEl.js} +1 -1
- package/dist/assets/{index-as7vp0Ty.js → index-DtNgVdl6.js} +1 -1
- package/dist/assets/{index-DmC4088R.js → index-HmZffzr8.js} +1 -1
- package/dist/assets/{index-Bt94reMP.js → index-JS-ElY0h.js} +1 -1
- package/dist/assets/{index-CLyrvG5S.js → index-MjNdAph2.js} +1 -1
- package/dist/assets/{index-jFDc_D4d.js → index-fxIibaZl.js} +1 -1
- package/dist/assets/{index.es-CuvVRlqN.js → index.es-CloazbFx.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-DyHAvuG6.js → insert-business-trip-modal-WRRM6504.js} +1 -1
- package/dist/assets/issue-document-CQzMV_wL.js +1 -0
- package/dist/assets/{list-plus-CYtq--On.js → list-plus-CnE5HRyh.js} +1 -1
- package/dist/assets/{login-page-DcZw6k7i.js → login-page-BrpMdMlX.js} +1 -1
- package/dist/assets/{match-document-modal-Bs-5Zbj9.js → match-document-modal-jwgQRgRO.js} +1 -1
- package/dist/assets/{missing-info-charges-e6O9it1V.js → missing-info-charges-CIyfSJIg.js} +1 -1
- package/dist/assets/{modal-CqL_DX_G.js → modal-CCob5Wtp.js} +1 -1
- package/dist/assets/{modify-contract-dialog-C8WuljxW.js → modify-contract-dialog-BJ2KI3hD.js} +1 -1
- package/dist/assets/{page-layout-DfZJtWW1.js → page-layout-CVpEeEVI.js} +1 -1
- package/dist/assets/{page-not-found-DnA0E-xR.js → page-not-found-Bp2RtrZ-.js} +1 -1
- package/dist/assets/{panel-top-open-D0lkFvhk.js → panel-top-open-CpfvrJ7c.js} +1 -1
- package/dist/assets/{pencil-DhN5v-Lb.js → pencil-HYykjv0U.js} +1 -1
- package/dist/assets/{report-commentary-row-DvvXelmb.js → report-commentary-row-CcVbcLKQ.js} +1 -1
- package/dist/assets/{save-CCZ-i4rw.js → save-DuH1YgIu.js} +1 -1
- package/dist/assets/{similar-transactions-modal-kFlTMg9C.js → similar-transactions-modal-BBKoKpL4.js} +1 -1
- package/dist/assets/{sub-BKVGhLrr.js → sub-DQC73fqa.js} +1 -1
- package/dist/assets/subMonths-C5xLwL1V.js +1 -0
- package/dist/assets/{summary-BuSv6nwb.js → summary-OKeTUxcz.js} +1 -1
- package/dist/assets/{toggle-expansion-button-CojtDNtC.js → toggle-expansion-button-BLwBnyJd.js} +1 -1
- package/dist/assets/tooltip-BUql9ooX.js +1 -0
- package/dist/assets/{use-url-query-90MrwS1C.js → use-url-query-BhOR-Upe.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/assets/issue-document-BvIvdS89.js +0 -1
- package/dist/assets/subMonths-Cbkj4M6-.js +0 -1
- package/dist/assets/tooltip-CoQF2skM.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as V,g as E,ea as q,r,t as k,i as F,u as $,eb as _,j as s,c as L,l as R,B as H,m as Q,n as X}from"./index-
|
|
1
|
+
import{v as V,g as E,ea as q,r,t as k,i as F,u as $,eb as _,j as s,c as L,l as R,B as H,m as Q,n as X}from"./index-CIAQBv17.js";import{c as G}from"./charges-table-BuVDqB4z.js";import{C as J,M as K}from"./Checkbox-xGXU5JAb.js";/**
|
|
2
2
|
* @license lucide-react v0.548.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as y,dm as O,t as R,r as t,dn as H,G as b,by as C,j as e,D as V,aX as q,B as M,a2 as z,x as P,aY as G,aZ as $,ar as L,as as X,at as Y,au as J,aw as Q,w as v,dp as w,y as U,H as Z,bv as K,V as W,a1 as _,bz as ee,bA as se,bB as te,bC as B,bD as m,bE as ne,bF as x,bG as ae,bH as re,a3 as le,bI as ce,bJ as oe,F as ie,c as ue}from"./index-
|
|
1
|
+
import{u as y,dm as O,t as R,r as t,dn as H,G as b,by as C,j as e,D as V,aX as q,B as M,a2 as z,x as P,aY as G,aZ as $,ar as L,as as X,at as Y,au as J,aw as Q,w as v,dp as w,y as U,H as Z,bv as K,V as W,a1 as _,bz as ee,bA as se,bB as te,bC as B,bD as m,bE as ne,bF as x,bG as ae,bH as re,a3 as le,bI as ce,bJ as oe,F as ie,c as ue}from"./index-CIAQBv17.js";import{u as de,E as he}from"./edit-issue-document-modal-TINM_yyf.js";import{s as F}from"./subMonths-C5xLwL1V.js";const me=()=>{const[{data:c,fetching:o,error:l},f]=y({query:O});l&&(console.error(`Error fetching contracts: ${l}`),R.error("Error",{description:"Unable to fetch contracts"}));const a=t.useMemo(()=>c?.allOpenContracts?.slice().sort((r,u)=>r.client.originalBusiness.name>u.client.originalBusiness.name?1:-1)??[],[c]),h=t.useMemo(()=>a.map(r=>({value:r.id,label:r.client.originalBusiness.name})),[a]);return{fetching:o,refresh:()=>f(),openContracts:a,selectableOpenContracts:h}};function xe({issueMonth:c,contracts:o,onAdd:l}){const[f,a]=t.useState(!1),[h,r]=t.useState(""),[{data:u},i]=y({query:H,variables:{issueMonth:c,clientId:h}}),p=t.useCallback(d=>{r(d),i()},[i,r]);return t.useEffect(()=>{h!==""&&u&&(l(b(C,u.clientMonthlyChargeDraft)),a(!1))},[h,u,l]),e.jsxs(V,{open:f,onOpenChange:a,children:[e.jsx(q,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"icon",children:e.jsx(z,{})})}),e.jsxs(P,{className:"w-[400px] max-w-screen-md",children:[e.jsx(G,{children:e.jsx($,{children:"Select document recipient"})}),e.jsxs(L,{onValueChange:p,children:[e.jsx(X,{children:e.jsx(Y,{placeholder:"Recipient"})}),e.jsx(J,{children:o.map(d=>e.jsx(Q,{value:d.client.originalBusiness.id,children:d.client.originalBusiness.name},d.client.originalBusiness.id))})]})]})]})}const fe=({drafts:c})=>{const[o,l]=t.useState(c.map(s=>b(C,s))),f=v(F(new Date,1),"yyyy-MM-dd"),[a,h]=t.useState(f),[{data:r},u]=y({query:w,variables:{issueMonth:a},pause:!0});t.useEffect(()=>{r?.clientMonthlyChargesDrafts&&l(r.clientMonthlyChargesDrafts.map(s=>b(C,s)))},[r,l]),t.useEffect(()=>{u()},[a,u]);const i=U({values:{generateDocumentsInfo:o}}),{issueDocuments:p}=de(),{openContracts:d}=me(),{fields:I,append:N,remove:E,update:A}=Z({control:i.control,name:"generateDocumentsInfo"}),T=i.watch("generateDocumentsInfo"),g=t.useMemo(()=>I.map((s,n)=>({...s,...T[n],id:s.client?.id})),[I,T]),S=t.useCallback(s=>{p(s)},[p]),k=t.useMemo(()=>d.filter(s=>s.billingCycle===K.Monthly&&!g.some(n=>n.client?.id===s.client.originalBusiness.id)),[g,d]);return e.jsx("div",{className:"p-2",children:e.jsx(W,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(S),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(_,{children:"Issue Month:"}),e.jsx(ee,{value:new Date(a),onChange:s=>{const n=new Date(s.getFullYear(),s.getMonth(),15);h(v(n,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(se,{children:[e.jsx(te,{children:e.jsxs(B,{children:[e.jsx(m,{children:"Name"}),e.jsx(m,{children:"Document"}),e.jsx(m,{children:"Amount"}),e.jsx(m,{children:"Remark"}),e.jsx(m,{children:"Recipients"}),e.jsx(m,{})]})}),e.jsx(ne,{children:g.map(({id:s,...n},D)=>e.jsxs(B,{children:[e.jsx(x,{children:n.client?.name}),e.jsx(x,{children:n.type}),e.jsxs(x,{children:[n.income?.[0]?.price," ",n.income?.[0]?.currency]}),e.jsx(x,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:n.remarks})}),e.jsx(x,{children:e.jsx("div",{className:"flex flex-col",children:n.client?.emails?.map(j=>e.jsx("span",{className:"text-sm text-gray-500",children:j},j))})}),e.jsx(x,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(ae,{children:[e.jsx(re,{asChild:!0,type:"button",children:e.jsx(M,{className:"size-7.5",variant:"secondary",onClick:()=>E(D),children:e.jsx(le,{size:16})})}),e.jsx(ce,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(he,{draft:n,onApprove:j=>{i.setValue(`generateDocumentsInfo.${D}`,j,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),A(D,{...j})}})]})})]},s))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(xe,{contracts:k,onAdd:N,issueMonth:a}),e.jsx(oe,{onConfirm:i.handleSubmit(S),title:`Are you sure you want to issue ${g.length} documents?`,children:e.jsx(M,{children:"Issue"})})]})]})})})},ye=()=>{const{setFiltersContext:c}=t.useContext(ie),[{data:o,fetching:l}]=y({query:w,variables:{issueMonth:v(F(new Date,1),"yyyy-MM-dd")}});return t.useEffect(()=>{o?.clientMonthlyChargesDrafts||c(null)},[o,c]),l?e.jsx(ue,{}):e.jsx(fe,{drafts:o?.clientMonthlyChargesDrafts??[]})};export{ye as IssueDocuments};
|
|
@@ -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,f$ as w}from"./index-
|
|
1
|
+
import{r as c,j as e,B as u,a as y,F as g,u as P,L as D,f$ as w}from"./index-CIAQBv17.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as E}from"./page-layout-CVpEeEVI.js";import{R as d}from"./report-commentary-row-CcVbcLKQ.js";import{P as v}from"./modal-CCob5Wtp.js";import{Y as p}from"./YearPickerInput-DEG2pQQo.js";import{F}from"./funnel-9aCMMcQP.js";import{T as C}from"./Table-BM6YZZrt.js";import"./toggle-expansion-button-BLwBnyJd.js";import"./panel-top-open-CpfvrJ7c.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 +1 @@
|
|
|
1
|
-
import{j as e,X as C,Y as p,Z as S,_ as y,ax as w,a0 as b,I as L,g as k,hN as H,r as u,t as m,i as E,D as R,aX as M,B as x,bY as _,x as A,aY as T,aZ as $,u as P,hO as Q,L as O,y as q,V as K,a8 as V,hP as Y,F as z,bK as X,bA as Z,bB as G,bC as I,bD as J,bN as v,bE as W,bF as g,hQ as ee,bQ as se,bP as te,bR as oe}from"./index-
|
|
1
|
+
import{j as e,X as C,Y as p,Z as S,_ as y,ax as w,a0 as b,I as L,g as k,hN as H,r as u,t as m,i as E,D as R,aX as M,B as x,bY as _,x as A,aY as T,aZ as $,u as P,hO as Q,L as O,y as q,V as K,a8 as V,hP as Y,F as z,bK as X,bA as Z,bB as G,bC as I,bD as J,bN as v,bE as W,bF as g,hQ as ee,bQ as se,bP as te,bR as oe}from"./index-CIAQBv17.js";import{D as re}from"./data-table-pagination-cKgNAmlV.js";import{P as ne}from"./page-layout-CVpEeEVI.js";import{A as D}from"./arrow-up-down-BCyreEvt.js";function B({isInsert:s,formManager:n}){const{control:o}=n;return e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"key",control:o,disabled:!s,rules:{required:"Required",validate:{positive:t=>Number(t)>0||"Key must be a positive number",integer:t=>Number.isInteger(Number(t))||"Key must be an integer"}},render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Key"}),e.jsx(y,{children:e.jsx(w,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0,thousandSeparator:"",required:!0})}),e.jsx(b,{})]})}),e.jsx(C,{name:"name",control:o,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Name"}),e.jsx(y,{children:e.jsx(L,{...t,value:t.value??void 0,required:!0})}),e.jsx(b,{})]})}),e.jsx(C,{name:"defaultIrsCode",control:o,render:({field:t})=>e.jsxs(p,{children:[e.jsx(S,{children:"Default IRS Code"}),e.jsx(y,{children:e.jsx(w,{...t,value:t.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(b,{})]})})]})}const ae="updateSortCode",de=()=>{const[{fetching:s},n]=k(H),o=u.useCallback(async t=>{const d=`Error updating sort code ID [${t.key}]`,r=`${ae}-${t.key}`;m.loading("Updating Sort Code...",{id:r});try{const a=await n(t),i=E(a,d,r,"updateSortCode");if(i)return m.success("Success",{id:r,description:"SortCode updated"}),i.updateSortCode}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}return!1},[n]);return{fetching:s,updateSortCode:o}};function ie({sortCodeKey:s,onAdd:n}){const[o,t]=u.useState(!1);return e.jsxs(R,{open:o,onOpenChange:t,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{variant:"outline",size:"icon",children:e.jsx(_,{})})}),e.jsxs(A,{className:"w-[400px] max-w-screen-md",children:[e.jsx(T,{children:e.jsx($,{children:"Edit Sort Code"})}),e.jsx(le,{sortCodeKey:s,close:()=>t(!1),onAdd:n})]})]})}function le({sortCodeKey:s,close:n,onAdd:o}){const[{data:t,fetching:d}]=P({query:Q,variables:{key:s}}),r=t?.sortCode;return!r&&!d&&m.error("Error",{description:"Couldn't find sort code"}),d?e.jsx(O,{className:"h-10 w-10 animate-spin"}):r?e.jsx(ce,{sortCode:r,close:n,onAdd:o}):e.jsx("div",{children:"Sort code not found"})}function ce({sortCode:s,close:n,onAdd:o}){const t=q({defaultValues:s}),{handleSubmit:d,formState:{dirtyFields:r}}=t,{updateSortCode:a,fetching:i}=de(),l=({key:c,...U})=>{const h=V(U,r);if(h&&Object.keys(h).length>0){let N;if(h.defaultIrsCode){const f=h.defaultIrsCode,j=Number(f);if(!Number.isInteger(j)||j<2||j>9999)throw new Error(`Invalid IRS code: ${f}`);N=j}a({fields:{...h,defaultIrsCode:N},key:s.key}).then(f=>{f&&(o?.(s.key),n())})}};return e.jsx(K,{...t,children:e.jsxs("form",{onSubmit:d(l),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(B,{isInsert:!1,formManager:t})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:i,children:"Update"})})]})})}const ue="addSortCode",me=()=>{const[{fetching:s},n]=k(Y),o=u.useCallback(async t=>{const d=`Error adding new sort code [${t.name}]`,r=`${ue}-${t.name}`;m.loading("Adding sort code",{id:r});try{const a=await n(t);E(a,d,r)&&m.success("Success",{id:r,description:`"${t.name}" sort code was successfully added`})}catch(a){console.error(`${d}: ${a}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,addSortCode:o}};function xe({onAdd:s}){const[n,o]=u.useState(!1);return e.jsxs(R,{open:n,onOpenChange:o,children:[e.jsx(M,{asChild:!0,children:e.jsx(x,{children:"Add Sort Code"})}),e.jsxs(A,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(T,{children:e.jsx($,{children:"Add New Sort Code"})}),e.jsx(he,{close:()=>o(!1),onAdd:s})]})]})}function he({close:s,onAdd:n}){const o=q({}),{handleSubmit:t}=o,{addSortCode:d,fetching:r}=me(),a=i=>{i.key&&=parseInt(i.key.toString()),i.defaultIrsCode&&=parseInt(i.defaultIrsCode.toString()),d(i).then(()=>{s(),n?.()})};return e.jsx(K,{...o,children:e.jsxs("form",{onSubmit:t(a),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(B,{isInsert:!0,formManager:o})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(x,{type:"submit",disabled:r,children:"Add Sort Code"})})]})})}const F=[{id:"key",accessorKey:"key",cell:({row:s})=>e.jsx(g,{children:s.original.key}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Key",e.jsx(D,{})]})},{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(g,{children:s.original.name}),header:({column:s})=>e.jsxs(x,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(D,{})]})},{id:"defaultIrsCode",accessorKey:"defaultIrsCode",cell:({row:s})=>e.jsx(g,{className:"flex flex-wrap gap-1 p-1",children:s.original.defaultIrsCode&&e.jsx(x,{variant:"outline",disabled:!0,className:"p-1 w-15",children:s.original.defaultIrsCode})}),header:"Default IRS Code"},{id:"edit",cell:({row:s})=>e.jsx(ie,{sortCodeKey:s.original.key,onAdd:s.original.refetchSortCodes})}],pe=()=>{const[{data:s,fetching:n,error:o},t]=P({query:ee}),{setFiltersContext:d}=u.useContext(z),r=u.useMemo(()=>s?.allSortCodes?.map(l=>({...l,refetchSortCodes:t}))??[],[s?.allSortCodes,t]),a=X({data:r,columns:F,getCoreRowModel:oe(),getPaginationRowModel:te(),getSortedRowModel:se(),initialState:{pagination:{pageSize:100}}}),i=a.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx(re,{table:a})}))},[d,a,i]),u.useEffect(()=>{o&&(console.error("Error fetching sort codes",o),m.error("Error",{description:"Error fetching sort codes"}))},[o]),e.jsx(ne,{title:`Sort Codes (${r.length})`,description:"All sort codes",headerActions:e.jsx(xe,{onAdd:()=>t()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(O,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(Z,{children:[e.jsx(G,{children:a.getHeaderGroups().map(l=>e.jsx(I,{children:l.headers.map(c=>e.jsx(J,{children:c.isPlaceholder?null:v(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),e.jsx(W,{children:a.getRowModel().rows.length===0?e.jsx(I,{children:e.jsx(g,{colSpan:F.length,className:"text-center py-8",children:"No sort codes found"})}):a.getRowModel().rows.map(l=>e.jsx(I,{children:l.getVisibleCells().map(c=>e.jsx(g,{children:v(c.column.columnDef.cell,c.getContext())},c.id))},l.id))})]})})})};export{pe as SortCodes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as b,bi as U,j as e,D as W,aX as _,B as g,x as z,aY as Q,aZ as Z,a1 as T,aq as J,aM as R,ar as A,as as O,at as k,au as E,aw as D,cZ as K,G as j,b8 as w,g5 as I,g6 as X,g7 as S,g8 as ee,g9 as M,ga as L,gb as B,gc as N,gd as p,ge as P,gf as Y,du as se,gg as re,b3 as te,b4 as ae,b5 as v,gh as V,F as le,u as de,J as ne,K as oe,W as ce,gi as ie}from"./index-UOt3vExk.js";import{F as $}from"./funnel-DlU6IKDd.js";import{B as me}from"./building-2-Dkd3B-3N.js";import{E as ue}from"./eye-off-Cd4HW5Ki.js";import{S as xe}from"./save-CCZ-i4rw.js";const C=["2020","2021","2022","2023"];function he({selectedBusiness:t,setSelectedBusiness:d,selectedYear:s,setSelectedYear:c,referenceYear:l,setReferenceYear:o}){const[n,r]=b.useState(!s||!t),{selectableBusinesses:a,fetching:i}=U(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(W,{open:n,onOpenChange:r,children:[e.jsx(_,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx($,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(z,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(Q,{children:e.jsxs(Z,{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(J,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(A,{value:s,onValueChange:c,children:[e.jsx(O,{id:"year-select",children:e.jsx(k,{})}),e.jsx(E,{children:C.map(x=>e.jsx(D,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(A,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(O,{id:"reference-year-select",children:e.jsx(k,{})}),e.jsxs(E,{children:[e.jsx(D,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(D,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const m=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=G=>Number.parseFloat(G.replace(/[,\s₪]/g,""))||0,H=f(h),F=f(x);return F===0?null:(H-F)/F*100};if(!n(d))return null;const i=o?a(d,c):null;return e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-gray-200",dir:"rtl",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[t," ",s&&`(${s})`]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r(d)?"text-gray-400":""}`,children:r(d)?"0":d}),i!==null&&e.jsxs("span",{className:`text-xs px-1 py-0.5 rounded ${i>0?"text-green-700 bg-green-100":i<0?"text-red-700 bg-red-100":"text-gray-700 bg-gray-100"}`,children:[i>0?"+":"",i.toFixed(1),"%"]})]})]})},u=({codes:t,referenceCodes:d,code:s,showEmptyFields:c})=>{const{value:l,label:o}=b.useMemo(()=>{const r=t.find(a=>a.code===s);return{value:r?.amount||0,label:r?.label||"לא זוהה קוד"}},[t,s]),n=b.useMemo(()=>d?.find(r=>r.code===s)?.amount.toString()||"",[d,s]);return e.jsx(m,{label:o,value:K(l,0),code:String(s),showChange:!0,showEmptyFields:c,referenceValue:n})},be=[{title:"מזומנים ושווי מזומנים",codes:[7110,7120,7150],sumCode:7100},{title:"ניירות ערך",codes:[7215,7225,7230,7290,7295],sumCode:7200},{title:"לקוחות",codes:[7310,7320,7330,7350,7360,7380,7390],sumCode:7300},{title:"חייבים ויתרות חובה",codes:[7410,7420,7430,7440,7450,7461,7462,7470,7490],sumCode:7400},{title:"מסים נדחים לזמן קצר",codes:[7610,7620,7690],sumCode:7600},{title:"הלוואות לזמן קצר",codes:[7711,7712,7720],sumCode:7700},{title:"מלאי",codes:[7805,7810,7815,7820,7825,7830,7840,7850,7860,7870,7890],sumCode:7800}],je=[{title:"רכוש קבוע",codes:[8010,8020,8025,8030,8040,8050,8060,8080,8090,8095,8100,8105,8110,8120,8130,8140,8150,8160,8170,8180,8190],sumCode:8e3},{title:"נכסים לא שוטפים מוחזקים למכירה",codes:[8710],sumCode:8700},{title:"הוצאות מראש לזמן ארוך",codes:[8210,8220,8290],sumCode:8200},{title:"השקעות בחברות מוחזקות כלולות ומאוחדות",codes:[8315,8325,8335,8340,8350],sumCode:8300},{title:'השקעות בחברות אחרות כולל ני"ע סחירים מוחזקים לזמן ארוך',codes:[8410,8420,8440,8450,8460,8490],sumCode:8400},{title:"מסים נדחים לזמן ארוך",codes:[8510,8520,8590],sumCode:8500},{title:"הוצאות נדחות ורכוש אחר",codes:[8610,8620,8630,8640,8690],sumCode:8600}],pe=[{title:"בנקים והלואות לזמן קצר",codes:[9110,9120,9130,9140,9151,9152,9190],sumCode:9100},{title:"ספקים ונותני שירותים",codes:[9210,9220,9230,9290],sumCode:9200},{title:"זכאים ויתרות זכות",codes:[9310,9320,9330,9340,9350,9360,9370,9410,9420,9431,9432,9435,9440,9450,9460,9470,9480,9490],sumCode:9400},{title:"עתודה למסים נדחים לזמן קצר",codes:[9510,9520,9530],sumCode:9500}],ge=[{title:"התחייבויות לזמן ארוך",codes:[9605,9610,9620,9631,9632,9640,9650,9660,9670,9690],sumCode:9600},{title:"התחייבויות בשל סיום יחסי עובד-מעביד",codes:[9710,9720,9790],sumCode:9700},{title:"עתודה למסים נדחים לזמן ארוך",codes:[9810,9820,9890],sumCode:9800}],fe=[{title:"הון עצמי",codes:[9910,9920,9930,9940,9950,9960,9980],sumCode:9900}];function Ne({data:t,referenceData:d,showEmptyFields:s=!1}){const l=j(I,t).balanceSheet||[],n=j(I,d)?.balanceSheet||[];return e.jsx(w,{value:"balanceSheet",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני המאזן"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-blue-800 border-b pb-2",children:"נכסים"}),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx("h5",{className:"font-bold",children:"רכוש שוטף"})}),be.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:7e3,showEmptyFields:s})}),je.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:8888,showEmptyFields:s})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-red-800 border-b pb-2",children:"התחייבויות והון"}),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx("h5",{className:"font-bold",children:"התחייבויות שוטפות"})}),pe.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9e3,showEmptyFields:s})}),ge.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),fe.map(r=>e.jsxs("div",{className:"bg-green-50 p-4 rounded-md",children:[e.jsx("h5",{className:"font-bold mb-3",children:r.title}),e.jsx("div",{className:"space-y-2",children:r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a))})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9999,showEmptyFields:s})})]})]})]})})}const ve=t=>{switch(t){case"1":return"תעשייתי";case"2":return"מסחרי";case"3":return"נותני שירותים";case"99":return"הדיווח כולל יותר מעסק אחד";default:return""}},Ce=t=>{switch(t){case S.Cash:return"מזומן";case S.Accrual:return"מצטבר";case S.DollarRegulations:return"לפי תקנות דולריות";default:return""}},ye=t=>{switch(t){case M.Shekels:return"שקלים";case M.Dollars:return"דולרים";default:return""}},Se=t=>{switch(t){case L.DoubleEntry:return"כפולה";case L.SingleEntry:return"חד-צידית";default:return""}},we=t=>{switch(t){case B.Computerized:return"ממוחשב";case B.Manual:return"ידני";default:return""}},Fe=t=>{switch(t){case N.Option_1:return"חלופה 1";case N.Option_2Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010";case N.Option_3Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010";case N.None:return"ללא חלופה";default:return""}},Te=t=>{switch(t){case p.Unqualified:return"נוסח אחיד (בלתי מסוייג)";case p.UnqualifiedWithGoingConcern:return"בנוסח אחיד עם הפניית תשומת לב להערת עסק חי";case p.UnqualifiedWithOtherEmphases:return"בנוסח אחיד עם הפניות תשומת לב אחרת";case p.Qualified:return"הסתייגות";case p.Adverse:return"שלילית";case p.Disclaimer:return"המנעות";case p.None:return"אין חוות דעת";default:return""}},y=t=>t==null?"":t?"כן":"לא";function De({data:t,businessInfo:d}){const{header:s}=j(X,t),c=j(ee,d);return e.jsx(w,{value:"header",className:"border rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",dir:"rtl",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטים מזהים"}),e.jsx(m,{label:"השם הרשום",value:c.name,showEmptyFields:!0}),e.jsx(m,{label:"תיאור העיסוק המדווח",value:s.businessDescription??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר זהות",value:s.idNumber,showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק",value:s.taxFileNumber,showEmptyFields:!0}),e.jsx(m,{label:'תיק מדווח למע"מ',value:s.vatFileNumber??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק ניכויים",value:s.withholdingTaxFileNumber??"",showEmptyFields:!0})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטי העסק"}),e.jsx(m,{value:ve(s.businessType),label:"סוג העסק המדווח",showEmptyFields:!0}),e.jsx(m,{label:"שיטת דיווח",value:Ce(s.reportingMethod),showEmptyFields:!0}),s.reportingMethod===S.DollarRegulations&&e.jsx(m,{label:"מטבע הסכומים",value:ye(s.currencyType),showEmptyFields:!0}),e.jsx(m,{label:"הסכום באלפים",value:y(s.amountsInThousands),showEmptyFields:!0}),e.jsx(m,{label:"שיטת חשבונאות",value:Se(s.accountingMethod),showEmptyFields:!0}),e.jsx(m,{label:"הנהלת חשבונות",value:we(s.accountingSystem),showEmptyFields:!0}),e.jsx(m,{label:"חייב ברישום תוכנה",value:y(!!s.softwareRegistrationNumber),showEmptyFields:!0}),s.softwareRegistrationNumber&&e.jsx(m,{label:"מספר תעודת רישום",value:s.softwareRegistrationNumber,showEmptyFields:!0}),e.jsx(m,{label:"דוח בגין שותפות",value:y(!!s.isPartnership),showEmptyFields:!0}),s.isPartnership&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"מספר שותפים",value:s.partnershipCount?.toString()??"",showEmptyFields:!0}),e.jsx(m,{label:"חלקי ברווחי השותפות",value:`${s.partnershipProfitShare}%`,showEmptyFields:!0})]}),e.jsx(m,{label:"יישום תקני חשבונאות (IFRS)",value:y(!!s.ifrsImplementationYear||!!s.ifrsReportingOption),showEmptyFields:!0}),(!!s.ifrsImplementationYear||!!s.ifrsReportingOption)&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"החל משנת המס",value:s.ifrsImplementationYear??"",showEmptyFields:!0}),e.jsx(m,{label:"דווח בחלופה",value:Fe(s.ifrsReportingOption),showEmptyFields:!0})]}),e.jsx(m,{label:"מספר ענף כלכלי של המדווח",value:s.industryCode,showEmptyFields:!0}),e.jsx(m,{label:"חוות דעת המבקר",value:Te(s.auditOpinionType),showEmptyFields:!0})]})]})})}const Re=[{title:"הכנסות ממכירות ומתן שירותים",color:"text-blue-700",codes:[1010,1015,1020,1025,1030,1040,1051,1052,1090],sumCode:1e3},{title:"עלות המכירות ומתן השירותים וביצוע עבודות",color:"text-purple-700",codes:[1306,1308,1307,1310,1320,1330,1340,1350,1360,1371,1372,1390,1400,1450],sumCode:1300},{title:"עלויות ייצור ועלויות אצל קבלן בונה",color:"text-rose-700",codes:[2005,2006,2011,2012,2015,2020,2025,2030,2035,2040,2045,2050,2060,2066,2067,2068,2070,2075,2080,2085,2090,2095],sumCode:2e3},{title:"הוצאות מחקר ופיתוח",color:"text-amber-700",codes:[2510,2520,2530,2540,2550,2560,2570,2590],sumCode:2500},{title:"הוצאות מכירה",color:"text-green-700",codes:[3011,3013,3012,3015,3020,3025,3030,3040,3045,3050,3060,3066,3067,3068,3070,3075,3080,3085,3090,3100,3120,3190],sumCode:3e3},{title:"הוצאות הנהלה וכלליות",color:"text-cyan-700",codes:[3511,3513,3512,3515,3520,3530,3535,3540,3545,3550,3560,3566,3567,3568,3570,3575,3580,3590,3595,3600,3610,3620,3625,3631,3632,3640,3650,3660,3665,3680,3685,3690],sumCode:3500},{title:"הוצאות מימון",color:"text-indigo-700",codes:[5010,5020,5025,5030,5040,5050,5051,5090],sumCode:5e3},{title:"הכנסות מימון",color:"text-fuchsia-700",codes:[5110,5121,5122,5130,5150,5160,5190],sumCode:5100},{title:"הכנסות אחרות",color:"text-red-700",codes:[5210,5220,5230,5236,5237,5240,5250,5260,5270,5290],sumCode:5200},{title:"הוצאות אחרות",color:"text-yellow-700",codes:[5310,5320,5330,5390],sumCode:5300}],Ae=[{title:"מסים על הכנסה",color:"text-sky-700",codes:[5610,5620,5630],sumCode:5600},{title:"ייעוד הרווחים",color:"text-violet-700",codes:[5710],sumCode:5700},{title:"רווח/הפסד אקויטי",color:"text-pink-700",codes:[5810],sumCode:5800}];function Oe({selectedYear:t,referenceYear:d,data:s,referenceData:c,showEmptyFields:l=!1}){const{profitAndLoss:o}=j(P,s),r=j(P,c)?.profitAndLoss||[];return e.jsx(w,{value:"profitLoss",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני רווח והפסד"}),d&&t!==d&&e.jsxs("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded",children:["מציג שינויים לעומת ",d]})]}),Re.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title)),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:o,referenceCodes:r,code:6666,showEmptyFields:l})}),Ae.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title))]})})}const ke=[{title:"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010 בנושא IFRS",color:"red",codes:[103,104]},{title:"התאמות נדרשות לצרכי מס (הוסף/הפחת)",color:"yellow",codes:[110,120,130,135,140,150,160,170,180,181,182,183,184,190,200,300,310,320,330,350,360],sumCode:370},{title:"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010 בנושא IFRS שלא מצאו את ביטויין בהתאמות הנדרשות לצרכי מס",color:"emerald",codes:[383],sumCode:400},{title:"יישום הוראות חוקי מס נוספים",color:"sky",codes:[430,480,490],sumCode:500},{title:"נתונים נוספים",color:"violet",codes:[510,520,530,540,550,570,575,580,585,590]},{title:"בשותפות",color:"pink",codes:[600]}],q={red:{header:"text-red-700",sum:"bg-red-50 border-red-200"},yellow:{header:"text-yellow-700",sum:"bg-yellow-50 border-yellow-200"},emerald:{header:"text-emerald-700",sum:"bg-emerald-50 border-emerald-200"},sky:{header:"text-sky-700",sum:"bg-sky-50 border-sky-200"},violet:{header:"text-violet-700",sum:"bg-violet-50 border-violet-200"},pink:{header:"text-pink-700",sum:"bg-pink-50 border-pink-200"}};function Ee({data:t,referenceData:d,showEmptyFields:s=!1}){const{taxAdjustment:c}=j(Y,t),o=j(Y,d)?.taxAdjustment||[];return e.jsx(w,{value:"taxAdjustment",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:'נתוני דו"ח התאמה למס'}),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:c,referenceCodes:o,code:100,showEmptyFields:s})}),ke.map(n=>{const{header:r,sum:a}=q[n.color]||q.red;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:"font-bold mb-4 "+r,children:n.title}),e.jsx("div",{className:"space-y-2",children:n.codes.map(i=>e.jsx(u,{codes:c,referenceCodes:o,code:i,showEmptyFields:s},i))})]}),n.sumCode&&e.jsx("div",{className:"p-4 rounded-md border-2 "+a,children:e.jsx(u,{codes:c,referenceCodes:o,code:n.sumCode,showEmptyFields:s})})]},n.title)})]})})}function Ie({data:t,referenceData:d,businessInfo:s,selectedYear:c,referenceYear:l}){const o=j(V,t),n=j(V,d),[r,a]=b.useState("header"),[i,h]=b.useState(!0);return e.jsxs("div",{className:"p-4 border-gray-300",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:i?"outline":"default",size:"sm",onClick:()=>h(!i),className:"flex items-center gap-2",children:[i?e.jsx(ue,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"}),i?"הסתר שדות ריקים":"הצג שדות ריקים"]}),e.jsx("span",{className:"text-sm text-gray-500",children:i?"מציג את כל השדות":"מציג רק שדות עם נתונים"})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4"}),"הורד"]}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"שמור"]})]})]}),e.jsxs(te,{value:r,onValueChange:a,className:"w-full",children:[e.jsxs(ae,{className:"grid grid-cols-4 w-full",dir:"rtl",children:[e.jsx(v,{value:"header",children:"פרטים מזהים"}),e.jsx(v,{value:"profitLoss",children:"רווח והפסד"}),e.jsx(v,{value:"taxAdjustment",children:"התאמה למס"}),e.jsx(v,{value:"balanceSheet",children:"מאזן"})]}),e.jsx(De,{data:o,businessInfo:s}),e.jsx(Oe,{selectedYear:c,referenceYear:l,data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ee,{data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ne,{data:o,referenceData:n,showEmptyFields:i})]})]})}function qe(){const{setFiltersContext:t}=b.useContext(le),[d,s]=b.useState(void 0),[c,l]=b.useState(void 0),[o,n]=b.useState(void 0),[{data:r,fetching:a}]=de({query:ie,variables:{year:c?Number.parseInt(c,10):0,businessId:d},pause:!c||!d});return b.useEffect(()=>{t(e.jsx("div",{className:"flex flex-row gap-x-5",dir:"rtl",children:e.jsx(he,{selectedBusiness:d,setSelectedBusiness:s,selectedYear:c,setSelectedYear:l,referenceYear:o,setReferenceYear:n})}))},[t,d,c,o]),e.jsx("div",{className:"container mx-auto",dir:"rtl",children:e.jsxs(ne,{className:"border-2 border-gray-300",children:[e.jsx(oe,{className:"bg-gray-100 border-b-2 border-gray-300 flex flex-row justify-between items-center",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("h1",{className:"text-2xl font-bold",children:'נספח לטופס הדו"ח השנתי ליחיד ולחבר בני אדם'}),e.jsxs("h2",{className:"text-xl",children:["לשנת המס ",c]}),e.jsx("p",{className:"text-sm",children:'נתוני הדוחות הכספיים, מאזן, רווח והפסד ודו"ח ההתאמה למס'})]})}),e.jsx(ce,{className:"p-0",children:e.jsx(Me,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Me({fetching:t,data:d,selectedBusiness:s,selectedYear:c,referenceYear:l}){if(t)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"טוען נתונים..."})});if(!c||!s)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"יש לבחור עסק ושנת דיווח"})});const o=d?.shaam6111.data;return o?e.jsx(Ie,{data:o,businessInfo:d.shaam6111.business,selectedBusiness:s,selectedYear:c,referenceYear:l}):e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"אין נתונים זמינים עבור העסק והשנה שנבחרו"})})}export{qe as Shaam6111Report};
|
|
1
|
+
import{r as b,bi as U,j as e,D as W,aX as _,B as g,x as z,aY as Q,aZ as Z,a1 as T,aq as J,aM as R,ar as A,as as O,at as k,au as E,aw as D,cZ as K,G as j,b8 as w,g5 as I,g6 as X,g7 as S,g8 as ee,g9 as M,ga as L,gb as B,gc as N,gd as p,ge as P,gf as Y,du as se,gg as re,b3 as te,b4 as ae,b5 as v,gh as V,F as le,u as de,J as ne,K as oe,W as ce,gi as ie}from"./index-CIAQBv17.js";import{F as $}from"./funnel-9aCMMcQP.js";import{B as me}from"./building-2-MBHE4zmH.js";import{E as ue}from"./eye-off-DsWzdkGo.js";import{S as xe}from"./save-DuH1YgIu.js";const C=["2020","2021","2022","2023"];function he({selectedBusiness:t,setSelectedBusiness:d,selectedYear:s,setSelectedYear:c,referenceYear:l,setReferenceYear:o}){const[n,r]=b.useState(!s||!t),{selectableBusinesses:a,fetching:i}=U(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(W,{open:n,onOpenChange:r,children:[e.jsx(_,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx($,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(z,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(Q,{children:e.jsxs(Z,{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(J,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(A,{value:s,onValueChange:c,children:[e.jsx(O,{id:"year-select",children:e.jsx(k,{})}),e.jsx(E,{children:C.map(x=>e.jsx(D,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(T,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(A,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(O,{id:"reference-year-select",children:e.jsx(k,{})}),e.jsxs(E,{children:[e.jsx(D,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(D,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const m=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=G=>Number.parseFloat(G.replace(/[,\s₪]/g,""))||0,H=f(h),F=f(x);return F===0?null:(H-F)/F*100};if(!n(d))return null;const i=o?a(d,c):null;return e.jsxs("div",{className:"flex justify-between items-center py-2 border-b border-gray-200",dir:"rtl",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[t," ",s&&`(${s})`]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${r(d)?"text-gray-400":""}`,children:r(d)?"0":d}),i!==null&&e.jsxs("span",{className:`text-xs px-1 py-0.5 rounded ${i>0?"text-green-700 bg-green-100":i<0?"text-red-700 bg-red-100":"text-gray-700 bg-gray-100"}`,children:[i>0?"+":"",i.toFixed(1),"%"]})]})]})},u=({codes:t,referenceCodes:d,code:s,showEmptyFields:c})=>{const{value:l,label:o}=b.useMemo(()=>{const r=t.find(a=>a.code===s);return{value:r?.amount||0,label:r?.label||"לא זוהה קוד"}},[t,s]),n=b.useMemo(()=>d?.find(r=>r.code===s)?.amount.toString()||"",[d,s]);return e.jsx(m,{label:o,value:K(l,0),code:String(s),showChange:!0,showEmptyFields:c,referenceValue:n})},be=[{title:"מזומנים ושווי מזומנים",codes:[7110,7120,7150],sumCode:7100},{title:"ניירות ערך",codes:[7215,7225,7230,7290,7295],sumCode:7200},{title:"לקוחות",codes:[7310,7320,7330,7350,7360,7380,7390],sumCode:7300},{title:"חייבים ויתרות חובה",codes:[7410,7420,7430,7440,7450,7461,7462,7470,7490],sumCode:7400},{title:"מסים נדחים לזמן קצר",codes:[7610,7620,7690],sumCode:7600},{title:"הלוואות לזמן קצר",codes:[7711,7712,7720],sumCode:7700},{title:"מלאי",codes:[7805,7810,7815,7820,7825,7830,7840,7850,7860,7870,7890],sumCode:7800}],je=[{title:"רכוש קבוע",codes:[8010,8020,8025,8030,8040,8050,8060,8080,8090,8095,8100,8105,8110,8120,8130,8140,8150,8160,8170,8180,8190],sumCode:8e3},{title:"נכסים לא שוטפים מוחזקים למכירה",codes:[8710],sumCode:8700},{title:"הוצאות מראש לזמן ארוך",codes:[8210,8220,8290],sumCode:8200},{title:"השקעות בחברות מוחזקות כלולות ומאוחדות",codes:[8315,8325,8335,8340,8350],sumCode:8300},{title:'השקעות בחברות אחרות כולל ני"ע סחירים מוחזקים לזמן ארוך',codes:[8410,8420,8440,8450,8460,8490],sumCode:8400},{title:"מסים נדחים לזמן ארוך",codes:[8510,8520,8590],sumCode:8500},{title:"הוצאות נדחות ורכוש אחר",codes:[8610,8620,8630,8640,8690],sumCode:8600}],pe=[{title:"בנקים והלואות לזמן קצר",codes:[9110,9120,9130,9140,9151,9152,9190],sumCode:9100},{title:"ספקים ונותני שירותים",codes:[9210,9220,9230,9290],sumCode:9200},{title:"זכאים ויתרות זכות",codes:[9310,9320,9330,9340,9350,9360,9370,9410,9420,9431,9432,9435,9440,9450,9460,9470,9480,9490],sumCode:9400},{title:"עתודה למסים נדחים לזמן קצר",codes:[9510,9520,9530],sumCode:9500}],ge=[{title:"התחייבויות לזמן ארוך",codes:[9605,9610,9620,9631,9632,9640,9650,9660,9670,9690],sumCode:9600},{title:"התחייבויות בשל סיום יחסי עובד-מעביד",codes:[9710,9720,9790],sumCode:9700},{title:"עתודה למסים נדחים לזמן ארוך",codes:[9810,9820,9890],sumCode:9800}],fe=[{title:"הון עצמי",codes:[9910,9920,9930,9940,9950,9960,9980],sumCode:9900}];function Ne({data:t,referenceData:d,showEmptyFields:s=!1}){const l=j(I,t).balanceSheet||[],n=j(I,d)?.balanceSheet||[];return e.jsx(w,{value:"balanceSheet",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני המאזן"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-blue-800 border-b pb-2",children:"נכסים"}),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx("h5",{className:"font-bold",children:"רכוש שוטף"})}),be.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:7e3,showEmptyFields:s})}),je.map(r=>e.jsxs("div",{className:"bg-blue-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-blue-100 p-4 rounded-md border-2 border-blue-300",children:e.jsx(u,{codes:l,code:8888,showEmptyFields:s})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"text-lg font-bold text-red-800 border-b pb-2",children:"התחייבויות והון"}),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx("h5",{className:"font-bold",children:"התחייבויות שוטפות"})}),pe.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9e3,showEmptyFields:s})}),ge.map(r=>e.jsxs("div",{className:"bg-red-50 p-4 rounded-md",children:[e.jsx("h6",{className:"font-bold mb-3",children:r.title}),e.jsxs("div",{className:"space-y-2",children:[r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:l,referenceCodes:n,code:r.sumCode,showEmptyFields:s})})]})]},r.title)),fe.map(r=>e.jsxs("div",{className:"bg-green-50 p-4 rounded-md",children:[e.jsx("h5",{className:"font-bold mb-3",children:r.title}),e.jsx("div",{className:"space-y-2",children:r.codes.map(a=>e.jsx(u,{codes:l,referenceCodes:n,code:a,showEmptyFields:s},a))})]},r.title)),e.jsx("div",{className:"bg-red-100 p-4 rounded-md border-2 border-red-300",children:e.jsx(u,{codes:l,code:9999,showEmptyFields:s})})]})]})]})})}const ve=t=>{switch(t){case"1":return"תעשייתי";case"2":return"מסחרי";case"3":return"נותני שירותים";case"99":return"הדיווח כולל יותר מעסק אחד";default:return""}},Ce=t=>{switch(t){case S.Cash:return"מזומן";case S.Accrual:return"מצטבר";case S.DollarRegulations:return"לפי תקנות דולריות";default:return""}},ye=t=>{switch(t){case M.Shekels:return"שקלים";case M.Dollars:return"דולרים";default:return""}},Se=t=>{switch(t){case L.DoubleEntry:return"כפולה";case L.SingleEntry:return"חד-צידית";default:return""}},we=t=>{switch(t){case B.Computerized:return"ממוחשב";case B.Manual:return"ידני";default:return""}},Fe=t=>{switch(t){case N.Option_1:return"חלופה 1";case N.Option_2Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010";case N.Option_3Adjustments:return"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010";case N.None:return"ללא חלופה";default:return""}},Te=t=>{switch(t){case p.Unqualified:return"נוסח אחיד (בלתי מסוייג)";case p.UnqualifiedWithGoingConcern:return"בנוסח אחיד עם הפניית תשומת לב להערת עסק חי";case p.UnqualifiedWithOtherEmphases:return"בנוסח אחיד עם הפניות תשומת לב אחרת";case p.Qualified:return"הסתייגות";case p.Adverse:return"שלילית";case p.Disclaimer:return"המנעות";case p.None:return"אין חוות דעת";default:return""}},y=t=>t==null?"":t?"כן":"לא";function De({data:t,businessInfo:d}){const{header:s}=j(X,t),c=j(ee,d);return e.jsx(w,{value:"header",className:"border rounded-md p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",dir:"rtl",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטים מזהים"}),e.jsx(m,{label:"השם הרשום",value:c.name,showEmptyFields:!0}),e.jsx(m,{label:"תיאור העיסוק המדווח",value:s.businessDescription??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר זהות",value:s.idNumber,showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק",value:s.taxFileNumber,showEmptyFields:!0}),e.jsx(m,{label:'תיק מדווח למע"מ',value:s.vatFileNumber??"",showEmptyFields:!0}),e.jsx(m,{label:"מספר תיק ניכויים",value:s.withholdingTaxFileNumber??"",showEmptyFields:!0})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"פרטי העסק"}),e.jsx(m,{value:ve(s.businessType),label:"סוג העסק המדווח",showEmptyFields:!0}),e.jsx(m,{label:"שיטת דיווח",value:Ce(s.reportingMethod),showEmptyFields:!0}),s.reportingMethod===S.DollarRegulations&&e.jsx(m,{label:"מטבע הסכומים",value:ye(s.currencyType),showEmptyFields:!0}),e.jsx(m,{label:"הסכום באלפים",value:y(s.amountsInThousands),showEmptyFields:!0}),e.jsx(m,{label:"שיטת חשבונאות",value:Se(s.accountingMethod),showEmptyFields:!0}),e.jsx(m,{label:"הנהלת חשבונות",value:we(s.accountingSystem),showEmptyFields:!0}),e.jsx(m,{label:"חייב ברישום תוכנה",value:y(!!s.softwareRegistrationNumber),showEmptyFields:!0}),s.softwareRegistrationNumber&&e.jsx(m,{label:"מספר תעודת רישום",value:s.softwareRegistrationNumber,showEmptyFields:!0}),e.jsx(m,{label:"דוח בגין שותפות",value:y(!!s.isPartnership),showEmptyFields:!0}),s.isPartnership&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"מספר שותפים",value:s.partnershipCount?.toString()??"",showEmptyFields:!0}),e.jsx(m,{label:"חלקי ברווחי השותפות",value:`${s.partnershipProfitShare}%`,showEmptyFields:!0})]}),e.jsx(m,{label:"יישום תקני חשבונאות (IFRS)",value:y(!!s.ifrsImplementationYear||!!s.ifrsReportingOption),showEmptyFields:!0}),(!!s.ifrsImplementationYear||!!s.ifrsReportingOption)&&e.jsxs(e.Fragment,{children:[e.jsx(m,{label:"החל משנת המס",value:s.ifrsImplementationYear??"",showEmptyFields:!0}),e.jsx(m,{label:"דווח בחלופה",value:Fe(s.ifrsReportingOption),showEmptyFields:!0})]}),e.jsx(m,{label:"מספר ענף כלכלי של המדווח",value:s.industryCode,showEmptyFields:!0}),e.jsx(m,{label:"חוות דעת המבקר",value:Te(s.auditOpinionType),showEmptyFields:!0})]})]})})}const Re=[{title:"הכנסות ממכירות ומתן שירותים",color:"text-blue-700",codes:[1010,1015,1020,1025,1030,1040,1051,1052,1090],sumCode:1e3},{title:"עלות המכירות ומתן השירותים וביצוע עבודות",color:"text-purple-700",codes:[1306,1308,1307,1310,1320,1330,1340,1350,1360,1371,1372,1390,1400,1450],sumCode:1300},{title:"עלויות ייצור ועלויות אצל קבלן בונה",color:"text-rose-700",codes:[2005,2006,2011,2012,2015,2020,2025,2030,2035,2040,2045,2050,2060,2066,2067,2068,2070,2075,2080,2085,2090,2095],sumCode:2e3},{title:"הוצאות מחקר ופיתוח",color:"text-amber-700",codes:[2510,2520,2530,2540,2550,2560,2570,2590],sumCode:2500},{title:"הוצאות מכירה",color:"text-green-700",codes:[3011,3013,3012,3015,3020,3025,3030,3040,3045,3050,3060,3066,3067,3068,3070,3075,3080,3085,3090,3100,3120,3190],sumCode:3e3},{title:"הוצאות הנהלה וכלליות",color:"text-cyan-700",codes:[3511,3513,3512,3515,3520,3530,3535,3540,3545,3550,3560,3566,3567,3568,3570,3575,3580,3590,3595,3600,3610,3620,3625,3631,3632,3640,3650,3660,3665,3680,3685,3690],sumCode:3500},{title:"הוצאות מימון",color:"text-indigo-700",codes:[5010,5020,5025,5030,5040,5050,5051,5090],sumCode:5e3},{title:"הכנסות מימון",color:"text-fuchsia-700",codes:[5110,5121,5122,5130,5150,5160,5190],sumCode:5100},{title:"הכנסות אחרות",color:"text-red-700",codes:[5210,5220,5230,5236,5237,5240,5250,5260,5270,5290],sumCode:5200},{title:"הוצאות אחרות",color:"text-yellow-700",codes:[5310,5320,5330,5390],sumCode:5300}],Ae=[{title:"מסים על הכנסה",color:"text-sky-700",codes:[5610,5620,5630],sumCode:5600},{title:"ייעוד הרווחים",color:"text-violet-700",codes:[5710],sumCode:5700},{title:"רווח/הפסד אקויטי",color:"text-pink-700",codes:[5810],sumCode:5800}];function Oe({selectedYear:t,referenceYear:d,data:s,referenceData:c,showEmptyFields:l=!1}){const{profitAndLoss:o}=j(P,s),r=j(P,c)?.profitAndLoss||[];return e.jsx(w,{value:"profitLoss",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:"נתוני רווח והפסד"}),d&&t!==d&&e.jsxs("span",{className:"text-sm text-blue-600 bg-blue-50 px-2 py-1 rounded",children:["מציג שינויים לעומת ",d]})]}),Re.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title)),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:o,referenceCodes:r,code:6666,showEmptyFields:l})}),Ae.map(a=>e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:`font-bold mb-4 ${a.color}`,children:a.title}),e.jsxs("div",{className:"space-y-2",children:[a.codes.map(i=>e.jsx(u,{codes:o,referenceCodes:r,code:i,showEmptyFields:l},i)),e.jsx("div",{className:"border-2 rounded-md border-gray-300",children:e.jsx(u,{codes:o,referenceCodes:r,code:a.sumCode,showEmptyFields:l})})]})]},a.title))]})})}const ke=[{title:"התאמות חשבונאיות למי שיישם את חלופה 2 בהוראת ביצוע 7/2010 בנושא IFRS",color:"red",codes:[103,104]},{title:"התאמות נדרשות לצרכי מס (הוסף/הפחת)",color:"yellow",codes:[110,120,130,135,140,150,160,170,180,181,182,183,184,190,200,300,310,320,330,350,360],sumCode:370},{title:"התאמות חשבונאיות למי שיישם את חלופה 3 בהוראת ביצוע 7/2010 בנושא IFRS שלא מצאו את ביטויין בהתאמות הנדרשות לצרכי מס",color:"emerald",codes:[383],sumCode:400},{title:"יישום הוראות חוקי מס נוספים",color:"sky",codes:[430,480,490],sumCode:500},{title:"נתונים נוספים",color:"violet",codes:[510,520,530,540,550,570,575,580,585,590]},{title:"בשותפות",color:"pink",codes:[600]}],q={red:{header:"text-red-700",sum:"bg-red-50 border-red-200"},yellow:{header:"text-yellow-700",sum:"bg-yellow-50 border-yellow-200"},emerald:{header:"text-emerald-700",sum:"bg-emerald-50 border-emerald-200"},sky:{header:"text-sky-700",sum:"bg-sky-50 border-sky-200"},violet:{header:"text-violet-700",sum:"bg-violet-50 border-violet-200"},pink:{header:"text-pink-700",sum:"bg-pink-50 border-pink-200"}};function Ee({data:t,referenceData:d,showEmptyFields:s=!1}){const{taxAdjustment:c}=j(Y,t),o=j(Y,d)?.taxAdjustment||[];return e.jsx(w,{value:"taxAdjustment",className:"border rounded-md p-4",children:e.jsxs("div",{className:"space-y-6",dir:"rtl",children:[e.jsx("h3",{className:"text-lg font-bold border-b pb-2",children:'נתוני דו"ח התאמה למס'}),e.jsx("div",{className:"bg-emerald-50 p-4 rounded-md border-2 border-emerald-200",children:e.jsx(u,{codes:c,referenceCodes:o,code:100,showEmptyFields:s})}),ke.map(n=>{const{header:r,sum:a}=q[n.color]||q.red;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gray-50 p-4 rounded-md",children:[e.jsx("h4",{className:"font-bold mb-4 "+r,children:n.title}),e.jsx("div",{className:"space-y-2",children:n.codes.map(i=>e.jsx(u,{codes:c,referenceCodes:o,code:i,showEmptyFields:s},i))})]}),n.sumCode&&e.jsx("div",{className:"p-4 rounded-md border-2 "+a,children:e.jsx(u,{codes:c,referenceCodes:o,code:n.sumCode,showEmptyFields:s})})]},n.title)})]})})}function Ie({data:t,referenceData:d,businessInfo:s,selectedYear:c,referenceYear:l}){const o=j(V,t),n=j(V,d),[r,a]=b.useState("header"),[i,h]=b.useState(!0);return e.jsxs("div",{className:"p-4 border-gray-300",dir:"rtl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:i?"outline":"default",size:"sm",onClick:()=>h(!i),className:"flex items-center gap-2",children:[i?e.jsx(ue,{className:"h-4 w-4"}):e.jsx(se,{className:"h-4 w-4"}),i?"הסתר שדות ריקים":"הצג שדות ריקים"]}),e.jsx("span",{className:"text-sm text-gray-500",children:i?"מציג את כל השדות":"מציג רק שדות עם נתונים"})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4"}),"הורד"]}),e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"שמור"]})]})]}),e.jsxs(te,{value:r,onValueChange:a,className:"w-full",children:[e.jsxs(ae,{className:"grid grid-cols-4 w-full",dir:"rtl",children:[e.jsx(v,{value:"header",children:"פרטים מזהים"}),e.jsx(v,{value:"profitLoss",children:"רווח והפסד"}),e.jsx(v,{value:"taxAdjustment",children:"התאמה למס"}),e.jsx(v,{value:"balanceSheet",children:"מאזן"})]}),e.jsx(De,{data:o,businessInfo:s}),e.jsx(Oe,{selectedYear:c,referenceYear:l,data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ee,{data:o,referenceData:n,showEmptyFields:i}),e.jsx(Ne,{data:o,referenceData:n,showEmptyFields:i})]})]})}function qe(){const{setFiltersContext:t}=b.useContext(le),[d,s]=b.useState(void 0),[c,l]=b.useState(void 0),[o,n]=b.useState(void 0),[{data:r,fetching:a}]=de({query:ie,variables:{year:c?Number.parseInt(c,10):0,businessId:d},pause:!c||!d});return b.useEffect(()=>{t(e.jsx("div",{className:"flex flex-row gap-x-5",dir:"rtl",children:e.jsx(he,{selectedBusiness:d,setSelectedBusiness:s,selectedYear:c,setSelectedYear:l,referenceYear:o,setReferenceYear:n})}))},[t,d,c,o]),e.jsx("div",{className:"container mx-auto",dir:"rtl",children:e.jsxs(ne,{className:"border-2 border-gray-300",children:[e.jsx(oe,{className:"bg-gray-100 border-b-2 border-gray-300 flex flex-row justify-between items-center",children:e.jsxs("div",{className:"text-center w-full",children:[e.jsx("h1",{className:"text-2xl font-bold",children:'נספח לטופס הדו"ח השנתי ליחיד ולחבר בני אדם'}),e.jsxs("h2",{className:"text-xl",children:["לשנת המס ",c]}),e.jsx("p",{className:"text-sm",children:'נתוני הדוחות הכספיים, מאזן, רווח והפסד ודו"ח ההתאמה למס'})]})}),e.jsx(ce,{className:"p-0",children:e.jsx(Me,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Me({fetching:t,data:d,selectedBusiness:s,selectedYear:c,referenceYear:l}){if(t)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"טוען נתונים..."})});if(!c||!s)return e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"יש לבחור עסק ושנת דיווח"})});const o=d?.shaam6111.data;return o?e.jsx(Ie,{data:o,businessInfo:d.shaam6111.business,selectedBusiness:s,selectedYear:c,referenceYear:l}):e.jsx("div",{className:"container mx-auto p-8 text-center",dir:"rtl",children:e.jsx("p",{className:"text-lg text-gray-600",children:"אין נתונים זמינים עבור העסק והשנה שנבחרו"})})}export{qe as Shaam6111Report};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,F as C,u as S,j as e,T as h,B as g,bc as u,bd as a,L as y,be as N,bf as R}from"./index-
|
|
1
|
+
import{r as l,F as C,u as S,j as e,T as h,B as g,bc as u,bd as a,L as y,be as N,bf as R}from"./index-CIAQBv17.js";import{u as T}from"./use-url-query-BhOR-Upe.js";import{A as v}from"./accounter-table-DBMvyGoN.js";import{P as E}from"./page-layout-CVpEeEVI.js";import{C as L,a as F,B,M as z}from"./business-extended-info-CUG_B-2c.js";import{B as I}from"./business-ledger-filters-DLN498DB.js";import{P as A,a as k}from"./panel-top-open-CpfvrJ7c.js";import{T as O}from"./Table-BM6YZZrt.js";import"./download-csv-button-BBgOyW3z.js";import"./modal-CCob5Wtp.js";import"./funnel-9aCMMcQP.js";import"./MultiSelect-DXQxo0-S.js";const W=()=>{const{get:t}=T(),{setFiltersContext:i}=l.useContext(C),[r,o]=l.useState(!1),[x,j]=l.useState(!1),[m,p]=l.useState(t("ledgerRecordsFilters")?JSON.parse(decodeURIComponent(t("ledgerRecordsFilters"))):{}),[{data:c,fetching:w}]=S({query:N,variables:{filters:m}});l.useEffect(()=>{i(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(I,{filter:m,setFilter:p}),e.jsx(h,{label:"Expand all accounts",children:e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(s=>!s),children:r?e.jsx(A,{className:"size-5"}):e.jsx(k,{className:"size-5"})})}),e.jsx(h,{label:"Expand all currencies",children:e.jsx(g,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>j(s=>!s),children:x?e.jsx(L,{className:"size-5"}):e.jsx(F,{className:"size-5"})})})]}))},[c,m,i,p,r,o,x]);const b=l.useMemo(()=>c?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:c?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?c.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((s,d)=>s.business.name.localeCompare(d.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(u,{c:"red",children:s.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(u,{c:"green",children:s.credit.formatted})})]}),style:{whiteSpace:"nowrap"}},{title:"Total",value:s=>e.jsx(u,{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(x)];return e.jsx(E,{title:"Business Ledger Records",description:"Business Ledger Records Summary",children:w?e.jsx(y,{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,d)=>s.disabled?null:e.jsx("th",{children:s.title},String(d))),e.jsx("th",{children:"More Info"})]})}),e.jsx("tbody",{children:b.map((s,d)=>e.jsx(v,{columns:f,item:s,moreInfo:()=>e.jsx(B,{businessID:s.business.id,filter:m}),isShowAll:r},d))})]})})};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(u,{c:"red",children:r.debit.formatted})}),e.jsx("p",{className:"flex flex-row gap-2 whitespace-nowrap",children:e.jsx(u,{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(z,{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=>!R.includes(r)).map(n).flat():[]}export{W as BusinessLedgerRecordsSummery};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,bn as k,j as e,bh as _,B as I,bg as V,y as Q,bi as G,dg as K,ap as q,dh as z,bj as y,bm as A,bk as F,bl as B,w as S,u as R,gu as X,J as P,c as U,K as $,O as J,a3 as W,W as Y,F as Z,ad as ee,ay as ae,Q as se,dL as te,gv as re,bd as ne}from"./index-UOt3vExk.js";import{u as O}from"./use-url-query-90MrwS1C.js";import{P as oe}from"./page-layout-DfZJtWW1.js";import{k as ie,B as N,X as H,Y as le,l as ce,m as de,n as ue,o as me,p as pe,q as xe,r as ge}from"./chart-TrN24kVd.js";import{P as he}from"./modal-CqL_DX_G.js";import{F as fe}from"./funnel-DlU6IKDd.js";import{M as L}from"./MultiSelect-DP26KzMa.js";import{T as be}from"./index-Dzi5mI80.js";import{s as je}from"./sub-BKVGhLrr.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-kFlTMg9C.js";import"./addDays-CB-j-d4t.js";import"./list-plus-CYtq--On.js";import"./tooltip-CoQF2skM.js";import"./subMonths-Cbkj4M6-.js";var ye=ie({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:le}],formatAxisMap:ce});function ve(s){return!s||V(s)?null:encodeURIComponent(JSON.stringify(s))}const E="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:i,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=Q({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=G(),{selectableFinancialEntities:f,fetching:v}=K(),{selectableTags:p,fetching:j}=q(),M=a=>{i(a),c()},C=g("excludedTags"),o=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),n=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:o,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:n,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:i,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=O();m.useEffect(()=>{const p=ve(s),j=h(E);p!==j&&f(E,p)},[s,h,f]);const v=m.useCallback(p=>{k(p,s)||(i(p),b(!!p))},[s,i]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(he,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(_,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:i,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=R({query:X,variables:{transactionIDs:i}}),g=m.useMemo(()=>t?.transactionsByIDs?i.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,i]);return e.jsx(P,{className:"mt-5 w-full",children:r?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs(J,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(W,{className:"h-4 w-4"})})]})}),e.jsx(Y,{children:e.jsx(be,{transactionsProps:g})})]})})},w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,i,c){switch(c){case x.MONTHLY:{const t=String(i).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=i%2===0?i-1:i,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(i/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=i>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,i){switch(i){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=te(ne.Usd),ke=()=>{const{setFiltersContext:s}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=O(),t=m.useMemo(()=>{const o={ownerId:i?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(je(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(E);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(n){console.log("Error parsing balance report filters from URL:",n)}return o},[i?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:o,fromDate:d,toDate:n}=r;return{ownerId:o,fromDate:d,toDate:n}},[r]),[{data:j,fetching:M}]=R({query:re,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ae,{options:Object.entries(w).map(([o,d])=>({label:d.label,value:o})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(o=>({...o,ownerId:i?.context.adminBusinessId}))},[i]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const o=new Map;j.transactionsForBalanceReport.map(n=>{if(n.counterparty?.id&&(!n.isFee&&i?.context.financialAccountsBusinessesIds?.includes(n.counterparty.id)||r.excludedCounterparties?.includes(n.counterparty.id))||r.includedTags.length>0&&(!n.charge?.tags||n.charge.tags.length===0||!n.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&n.charge?.tags.length&&n.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(n.year,n.month,r.period);o.has(a)||o.set(a,{income:0,expense:0,delta:0,transactions:[]});const l=o.get(a);n.amountUsd.raw>0?l.income+=n.amountUsd.raw:l.expense+=n.amountUsd.raw,l.delta+=n.amountUsd.raw,l.transactions.push(n)});let d=0;return Array.from(o.entries()).sort((n,a)=>n[0].localeCompare(a[0])).map(([n,a])=>(d+=a.delta,{period:n,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((l,u)=>Math.abs(u.amountUsd.raw)-Math.abs(l.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,i?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full",children:[e.jsx($,{children:e.jsx(se,{children:"Click specific period to expand it's transactions data"})}),e.jsx(Y,{children:e.jsx(de,{config:w,className:"h-150 w-full",children:e.jsxs(ye,{accessibilityLayer:!0,data:C,onClick:o=>h(o.activeLabel),children:[e.jsx(ue,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:o=>Me(o,r.period)}),e.jsx(me,{content:e.jsx(pe,{formatter:(o,d,n,a)=>{const l=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${l} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${l}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]})}})}),e.jsx(xe,{content:e.jsx(ge,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{ke as BalanceReport};
|
|
1
|
+
import{r as m,bn as k,j as e,bh as _,B as I,bg as V,y as Q,bi as G,dg as K,ap as q,dh as z,bj as y,bm as A,bk as F,bl as B,w as S,u as R,gu as X,J as P,c as U,K as $,O as J,a3 as W,W as Y,F as Z,ad as ee,ay as ae,Q as se,dL as te,gv as re,bd as ne}from"./index-CIAQBv17.js";import{u as O}from"./use-url-query-BhOR-Upe.js";import{P as oe}from"./page-layout-CVpEeEVI.js";import{k as ie,B as N,X as H,Y as le,l as ce,m as de,n as ue,o as me,p as pe,q as xe,r as ge}from"./chart-Cq954UQg.js";import{P as he}from"./modal-CCob5Wtp.js";import{F as fe}from"./funnel-9aCMMcQP.js";import{M as L}from"./MultiSelect-DXQxo0-S.js";import{T as be}from"./index-3UYjJ7iT.js";import{s as je}from"./sub-DQC73fqa.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-BBKoKpL4.js";import"./addDays-DMNXN6YX.js";import"./list-plus-CnE5HRyh.js";import"./tooltip-BUql9ooX.js";import"./subMonths-C5xLwL1V.js";var ye=ie({chartName:"BarChart",GraphicalChild:N,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:H},{axisType:"yAxis",AxisComp:le}],formatAxisMap:ce});function ve(s){return!s||V(s)?null:encodeURIComponent(JSON.stringify(s))}const E="balanceReportFilters",x={MONTHLY:"Monthly",BI_MONTHLY:"Bi-monthly",QUARTERLY:"Quarterly",SEMI_ANNUALLY:"Semi-Annually",ANNUALLY:"Annually"};function Ce({filter:s,setFilter:i,closeModal:c}){const{control:t,handleSubmit:r,watch:g}=Q({defaultValues:{...s}}),{selectableBusinesses:b,fetching:h}=G(),{selectableFinancialEntities:f,fetching:v}=K(),{selectableTags:p,fetching:j}=q(),M=a=>{i(a),c()},C=g("excludedTags"),o=m.useMemo(()=>p.filter(a=>!C.includes(a.value)),[C,p]),d=g("includedTags"),n=m.useMemo(()=>p.filter(a=>!d.includes(a.value)),[d,p]);return e.jsxs("form",{onSubmit:r(M),children:[e.jsxs(z,{cols:2,children:[e.jsx(y,{name:"ownerId",control:t,defaultValue:s?.ownerId,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:b,value:a.value,disabled:h,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"fromDate",control:t,defaultValue:s?.fromDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"toDate",control:t,defaultValue:s?.toDate,rules:{pattern:{value:F,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:l})=>e.jsx(B,{...a,onChange:u=>{const T=u?typeof u=="string"?u:S(u,"yyyy-MM-dd"):void 0;T!==a.value&&a.onChange(T)},value:a.value?new Date(a.value):void 0,error:l.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(y,{name:"period",control:t,defaultValue:x.MONTHLY,render:({field:a,fieldState:l})=>e.jsx(A,{...a,data:Object.values(x).map(u=>({value:u,label:u})),value:a.value,label:"Period",maxDropdownHeight:160,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedCounterparties",control:t,defaultValue:s.excludedCounterparties,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:f,value:a.value??[],disabled:v,label:"Excluded Counterparties",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"includedTags",control:t,defaultValue:s.includedTags,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:o,value:a.value??[],disabled:j,label:"Included Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})}),e.jsx(y,{name:"excludedTags",control:t,defaultValue:s.excludedTags,render:({field:a,fieldState:l})=>e.jsx(L,{...a,data:n,value:a.value??[],disabled:j,label:"Excluded Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:l.error?.message,withinPortal:!0})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:h,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:c,children:"Cancel"})]})]})}function Te({filter:s,setFilter:i,initiallyOpened:c=!1}){const[t,r]=m.useState(c),[g,b]=m.useState(!!s),{get:h,set:f}=O();m.useEffect(()=>{const p=ve(s),j=h(E);p!==j&&f(E,p)},[s,h,f]);const v=m.useCallback(p=>{k(p,s)||(i(p),b(!!p))},[s,i]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(he,{opened:t,onClose:()=>r(!1),content:e.jsx(Ce,{filter:s,setFilter:v,closeModal:()=>r(!1)}),modalSize:"xl"}),e.jsx(_,{inline:!0,size:16,disabled:!g,children:e.jsx(I,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>r(!0),children:e.jsx(fe,{className:"size-5"})})})]})}const we=({period:s,transactionIDs:i,onCloseExtendedTransactions:c})=>{const[{data:t,fetching:r}]=R({query:X,variables:{transactionIDs:i}}),g=m.useMemo(()=>t?.transactionsByIDs?i.map(b=>t?.transactionsByIDs.find(h=>h.id===b)).filter(Boolean):[],[t,i]);return e.jsx(P,{className:"mt-5 w-full",children:r?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:e.jsxs(J,{className:"flex justify-between",children:[e.jsxs("span",{children:[s," Transactions"]}),e.jsx(I,{variant:"link",onClick:c,children:e.jsx(W,{className:"h-4 w-4"})})]})}),e.jsx(Y,{children:e.jsx(be,{transactionsProps:g})})]})})},w={income:{label:"Income",color:"rgba(0, 255, 50, 0.5)"},expense:{label:"Expense",color:"rgba(255, 0, 0, 0.5)"},delta:{label:"Delta",color:"rgba(0, 30, 255, 0.5)"},cumulative:{label:"Cumulative Balance",color:"rgba(100, 0, 255, 0.5)"}};function Ne(s,i,c){switch(c){case x.MONTHLY:{const t=String(i).padStart(2,"0");return`${s}-${t}`}case x.BI_MONTHLY:{const t=i%2===0?i-1:i,r=String(t).padStart(2,"0");return`${s}-${r}`}case x.QUARTERLY:{const t=Math.ceil(i/3);return`${s}-Q${t}`}case x.SEMI_ANNUALLY:{const t=i>6?2:1;return`${s}-H${t}`}case x.ANNUALLY:return String(s)}}function Me(s,i){switch(i){case x.MONTHLY:{const[c,t]=s.split("-");return`${t}/${c}`}case x.BI_MONTHLY:{const[c,t]=s.split("-"),r=Number(t)+1,g=String(r).padStart(2,"0");return`${t}-${g}/${c}`}case x.QUARTERLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.SEMI_ANNUALLY:{const[c,t]=s.split("-");return`${t}, ${c}`}case x.ANNUALLY:return s}}const D=te(ne.Usd),ke=()=>{const{setFiltersContext:s}=m.useContext(Z),{userContext:i}=m.useContext(ee),{get:c}=O(),t=m.useMemo(()=>{const o={ownerId:i?.context.adminBusinessId,toDate:S(new Date,"yyyy-MM-dd"),period:x.MONTHLY,fromDate:S(je(new Date,{years:1}),"yyyy-MM-dd"),excludedCounterparties:[],includedTags:[],excludedTags:[]},d=c(E);if(d)try{return JSON.parse(decodeURIComponent(d))}catch(n){console.log("Error parsing balance report filters from URL:",n)}return o},[i?.context.adminBusinessId,c]),[r,g]=m.useState(t),[b,h]=m.useState(void 0),[f,v]=m.useState(Object.keys(w)),p=m.useMemo(()=>{const{ownerId:o,fromDate:d,toDate:n}=r;return{ownerId:o,fromDate:d,toDate:n}},[r]),[{data:j,fetching:M}]=R({query:re,variables:p,pause:!r});m.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Te,{filter:r,setFilter:g,initiallyOpened:!r}),e.jsx(ae,{options:Object.entries(w).map(([o,d])=>({label:d.label,value:o})),onValueChange:v,defaultValue:f,placeholder:"Select Data Sets",variant:"default",maxCount:1})]})),h(void 0)},[j,M,r,s,g,f]),m.useEffect(()=>{g(o=>({...o,ownerId:i?.context.adminBusinessId}))},[i]);const C=m.useMemo(()=>{if(!j?.transactionsForBalanceReport)return[];const o=new Map;j.transactionsForBalanceReport.map(n=>{if(n.counterparty?.id&&(!n.isFee&&i?.context.financialAccountsBusinessesIds?.includes(n.counterparty.id)||r.excludedCounterparties?.includes(n.counterparty.id))||r.includedTags.length>0&&(!n.charge?.tags||n.charge.tags.length===0||!n.charge.tags.some(u=>r.includedTags.includes(u.id)))||r.excludedTags.length>0&&n.charge?.tags.length&&n.charge.tags.some(u=>r.excludedTags.includes(u.id)))return;const a=Ne(n.year,n.month,r.period);o.has(a)||o.set(a,{income:0,expense:0,delta:0,transactions:[]});const l=o.get(a);n.amountUsd.raw>0?l.income+=n.amountUsd.raw:l.expense+=n.amountUsd.raw,l.delta+=n.amountUsd.raw,l.transactions.push(n)});let d=0;return Array.from(o.entries()).sort((n,a)=>n[0].localeCompare(a[0])).map(([n,a])=>(d+=a.delta,{period:n,income:a.income,expense:a.expense,delta:a.delta,cumulative:d,transactions:a.transactions.sort((l,u)=>Math.abs(u.amountUsd.raw)-Math.abs(l.amountUsd.raw))}))},[j,r.period,r.excludedCounterparties,i?.context.financialAccountsBusinessesIds,r.includedTags,r.excludedTags]);return e.jsx(oe,{title:"Balance Report",description:"Accounts periodical balance",children:M?e.jsx(U,{}):e.jsxs(e.Fragment,{children:[e.jsxs(P,{className:"w-full",children:[e.jsx($,{children:e.jsx(se,{children:"Click specific period to expand it's transactions data"})}),e.jsx(Y,{children:e.jsx(de,{config:w,className:"h-150 w-full",children:e.jsxs(ye,{accessibilityLayer:!0,data:C,onClick:o=>h(o.activeLabel),children:[e.jsx(ue,{vertical:!1}),e.jsx(H,{dataKey:"period",tickLine:!1,tickMargin:10,axisLine:!1,tickFormatter:o=>Me(o,r.period)}),e.jsx(me,{content:e.jsx(pe,{formatter:(o,d,n,a)=>{const l=`bg-[var(--color-${d})]`;return a<2?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`${l} h-2.5 w-2.5 shrink-0 rounded-[2px]`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]}):e.jsxs("div",{className:"mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground",children:[e.jsx("div",{className:`h-2.5 w-2.5 shrink-0 rounded-[2px] mr-2 ${l}`}),w[d]?.label||d,e.jsx("div",{className:"ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground",children:D.format(Number(o))})]})}})}),e.jsx(xe,{content:e.jsx(ge,{})}),f.includes("income")&&e.jsx(N,{dataKey:"income",fill:"var(--color-income)",radius:4}),f.includes("expense")&&e.jsx(N,{dataKey:"expense",fill:"var(--color-expense)",radius:4}),f.includes("delta")&&e.jsx(N,{dataKey:"delta",fill:"var(--color-delta)",radius:4}),f.includes("cumulative")&&e.jsx(N,{dataKey:"cumulative",fill:"var(--color-cumulative)",radius:4})]})})})]}),b&&e.jsx(we,{period:b,onCloseExtendedTransactions:()=>h(void 0),transactionIDs:C.find(o=>o.period===b)?.transactions.map(o=>o.id)??[]})]})})};export{ke as BalanceReport};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as h,bg as S,j as e,bh as N,B as y,y as k,bi as $,ad as R,V as O,bj as f,bk as D,bl as C,w as F,X as A,Y as E,Z as z,_ as P,am as L,bn as M,bc as w,T as B,aN as j,bd as p,G as V,dx as _,cZ as v,F as G,u as Z,dy as q,bL as U,L as H,dz as J}from"./index-
|
|
1
|
+
import{r as h,bg as S,j as e,bh as N,B as y,y as k,bi as $,ad as R,V as O,bj as f,bk as D,bl as C,w as F,X as A,Y as E,Z as z,_ as P,am as L,bn as M,bc as w,T as B,aN as j,bd as p,G as V,dx as _,cZ as v,F as G,u as Z,dy as q,bL as U,L as H,dz as J}from"./index-CIAQBv17.js";import{u as I}from"./use-url-query-BhOR-Upe.js";import{P as Q}from"./page-layout-CVpEeEVI.js";import{P as X}from"./modal-CCob5Wtp.js";import{F as K}from"./funnel-9aCMMcQP.js";import{M as T}from"./MultiSelect-DXQxo0-S.js";import{D as W}from"./download-csv-button-BBgOyW3z.js";import{B as Y}from"./business-extended-info-CUG_B-2c.js";import{P as ee,a as te}from"./panel-top-open-CpfvrJ7c.js";import{T as se}from"./Table-BM6YZZrt.js";function re({filter:t,setFilter:s,closeModal:i}){const n=k({defaultValues:{...t}}),{control:a,handleSubmit:o}=n,{selectableBusinesses:r,fetching:u}=$(),{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(L,{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){M(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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as x,c1 as h,G as T,r,j as s,bh as g,c2 as j,F as B,T as w,am as C,L as v,a2 as E,c3 as P}from"./index-
|
|
1
|
+
import{u as x,c1 as h,G as T,r,j as s,bh as g,c2 as j,F as B,T as w,am as C,L as v,a2 as E,c3 as P}from"./index-CIAQBv17.js";import{E as y,P as b,C as L}from"./editable-business-trip-BP4Pz4ld.js";import{I as F}from"./insert-business-trip-modal-WRRM6504.js";import{P as I}from"./page-layout-CVpEeEVI.js";import{A as m}from"./summary-OKeTUxcz.js";import"./list-plus-CnE5HRyh.js";import"./Table-BM6YZZrt.js";import"./toggle-expansion-button-BLwBnyJd.js";import"./panel-top-open-CpfvrJ7c.js";import"./MultiSelect-DXQxo0-S.js";import"./similar-transactions-modal-BBKoKpL4.js";import"./tooltip-BUql9ooX.js";const S=({data:d,isOpened:o,shouldValidate:l})=>{const e=T(j,d),[{data:i,fetching:a}]=x({pause:!l,query:h,variables:{id:e.id}}),c=r.useMemo(()=>l?i?.businessTrip&&(i.businessTrip.uncategorizedTransactions?.length||i?.businessTrip.summary?.errors?.length):!1,[i]),u=c||e?.accountantApproval!=="APPROVED";return s.jsxs(m.Item,{value:e.id,children:[s.jsx(m.Control,{children:s.jsx(g,{inline:!0,size:12,processing:a,disabled:!u,color:c?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(m.Panel,{children:o&&s.jsx(y,{tripId:e.id,isExtended:!0},e.id)})]})},U=()=>{const{setFiltersContext:d}=r.useContext(B),[o,l]=r.useState([]),[e,i]=r.useState(!1),[{data:a,fetching:c}]=x({query:P});r.useEffect(()=>{if(!a?.allBusinessTrips?.length){l([]);return}const t=a.allBusinessTrips.sort((n,p)=>n.dates?.start&&p.dates?.start?n.dates.start<p.dates.start?1:-1:n.dates?.start?-1:p.dates?.start?1:n.name.toLocaleLowerCase()<p.name.toLocaleLowerCase()?-1:1);l(t)},[a?.allBusinessTrips]);const[u,f]=r.useState([]);return r.useEffect(()=>{d(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(F,{}),s.jsx(w,{label:"Toggle business trips validation",children:s.jsxs("div",{className:"flex flex-row items-center gap-x-2",children:[s.jsx(C,{checked:e??!1,onCheckedChange:t=>i(t)}),s.jsx("span",{className:"text-sm text-gray-500",children:"Validate"})]})}),s.jsx(b,{filename:"business_trips"})]}))},[a,c,d,e]),s.jsx(I,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&c?s.jsx(v,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(L,{children:s.jsx(m,{className:"w-full",multiple:!0,value:u,onChange:f,chevron:s.jsx(E,{size:"1rem"}),styles:{chevron:{"&[data-rotate]":{transform:"rotate(45deg)"}}},children:o?.map(t=>s.jsx(S,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:u.includes(t.id)},t.id))})})})};export{U as BusinessTrips};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,bg as w,bn as K,j as e,bh as O,B as c,ad as U,y as z,w as v,dg as _,V as B,dh as H,bj as D,bk as M,bl as I,X as L,Y as q,Z as G,_ as Q,am as J,F as X,u as Y,bK as Z,L as W,di as $,dj as ee,bA as te,bB as se,bC as S,bD as ae,bN as k,bE as ne,bF as T,bp as re,bq as ie,br as le,bM as oe,dk as ce,bQ as de,bP as me,bR as ue}from"./index-UOt3vExk.js";import{u as P}from"./use-url-query-90MrwS1C.js";import{a as ge}from"./accounter-table-C7UgjlTA.js";import{D as he}from"./data-table-pagination-BZmytrQe.js";import{P as V}from"./modal-CqL_DX_G.js";import{P as xe}from"./page-layout-DfZJtWW1.js";import{F as pe}from"./funnel-DlU6IKDd.js";import{M as R}from"./MultiSelect-DP26KzMa.js";import{s as je}from"./sub-BKVGhLrr.js";import{A as b}from"./arrow-up-down-DWlT-GED.js";import"./Table-c1ug6Rpw.js";import"./addDays-CB-j-d4t.js";import"./subMonths-Cbkj4M6-.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:p}=r.useContext(U),h=z({defaultValues:{ownerIDs:p?.context.adminBusinessId?[p.context.adminBusinessId]:void 0,toDate:v(new Date,"yyyy-MM-dd"),fromDate:v(je(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=h,{selectableFinancialEntities:i,fetching:d}=_(),C=a=>{s(a),x()};function m(){s({}),x()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(B,{...h,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(H,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(R,{...a,data:i,value:a.value??[],disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(R,{...a,data:i,value:a.value??[],disabled:d,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(I,{...a,onChange:l=>{const j=l?typeof l=="string"?l:v(l,"yyyy-MM-dd"):void 0;j!==a.value&&a.onChange(j)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(I,{...a,onChange:l=>{const j=l?typeof l=="string"?l:v(l,"yyyy-MM-dd"):void 0;j!==a.value&&a.onChange(j)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(L,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(q,{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(G,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(J,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:d,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:m,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:x,children:"Cancel"})]})]})})]})}function be({filter:t={},setFilter:s,initiallyOpened:x=!1}){const[p,h]=r.useState(x),[o,y]=r.useState(!w(t)),{get:i,set:d}=P();r.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=i("documentsFilters");m!==a&&d("documentsFilters",m)},[t,i,d]);const C=r.useCallback(m=>{K(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(V,{opened:p,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(O,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(!0),children:e.jsx(pe,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(c,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:v(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(ge,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?v(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?v(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],Ee=()=>{const[t,s]=r.useState(null),[x,p]=r.useState(!1),{get:h}=P(),o=h("documentsFilters"),y=r.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[i,d]=r.useState(y),[C,m]=r.useState([]),[a,g]=r.useState({}),{setFiltersContext:l}=r.useContext(X),[{data:j,fetching:F},N]=Y({query:ce,variables:{filters:i??{}},pause:!0});r.useEffect(()=>{i&&N()},[i,N]);const f=Z({data:j?.documentsByFilters??[],columns:E,getCoreRowModel:ue(),getPaginationRowModel:me(),onSortingChange:m,getSortedRowModel:de(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),A=f.getState().pagination.pageIndex;return r.useEffect(()=>{l(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(he,{table:f}),e.jsx(be,{filter:i,setFilter:d,initiallyOpened:!i})]}))},[f,F,i,l,d,y,A]),e.jsx(xe,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(re,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(c,{className:"ml-auto",children:"Columns"})}),e.jsx(le,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(oe,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(c,{onClick:()=>p(!0),children:"Upload Documents"})]}),children:F?e.jsx(W,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx($,{open:x,onOpenChange:p,onChange:N}),t&&e.jsx(V,{modalSize:"45%",content:e.jsx(ee,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(te,{children:[e.jsx(se,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(ae,{children:u.isPlaceholder?null:k(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ne,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(T,{children:k(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(T,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{Ee as DocumentsReport,E as columns};
|
|
1
|
+
import{r,bg as w,bn as K,j as e,bh as O,B as c,ad as U,y as z,w as v,dg as _,V as B,dh as H,bj as D,bk as M,bl as I,X as L,Y as q,Z as G,_ as Q,am as J,F as X,u as Y,bK as Z,L as W,di as $,dj as ee,bA as te,bB as se,bC as S,bD as ae,bN as k,bE as ne,bF as T,bp as re,bq as ie,br as le,bM as oe,dk as ce,bQ as de,bP as me,bR as ue}from"./index-CIAQBv17.js";import{u as P}from"./use-url-query-BhOR-Upe.js";import{a as ge}from"./accounter-table-DBMvyGoN.js";import{D as he}from"./data-table-pagination-cKgNAmlV.js";import{P as V}from"./modal-CCob5Wtp.js";import{P as xe}from"./page-layout-CVpEeEVI.js";import{F as pe}from"./funnel-9aCMMcQP.js";import{M as R}from"./MultiSelect-DXQxo0-S.js";import{s as je}from"./sub-DQC73fqa.js";import{A as b}from"./arrow-up-down-BCyreEvt.js";import"./Table-BM6YZZrt.js";import"./addDays-DMNXN6YX.js";import"./subMonths-C5xLwL1V.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:p}=r.useContext(U),h=z({defaultValues:{ownerIDs:p?.context.adminBusinessId?[p.context.adminBusinessId]:void 0,toDate:v(new Date,"yyyy-MM-dd"),fromDate:v(je(new Date,{years:1}),"yyyy-MM-dd"),...t}}),{control:o,handleSubmit:y}=h,{selectableFinancialEntities:i,fetching:d}=_(),C=a=>{s(a),x()};function m(){s({}),x()}return e.jsxs(e.Fragment,{children:[d?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(B,{...h,children:e.jsxs("form",{onSubmit:y(C),children:[e.jsxs(H,{cols:2,children:[e.jsx(D,{name:"ownerIDs",control:o,defaultValue:t.ownerIDs,render:({field:a,fieldState:g})=>e.jsx(R,{...a,data:i,value:a.value??[],disabled:d,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"businessIDs",control:o,defaultValue:t.businessIDs,render:({field:a,fieldState:g})=>e.jsx(R,{...a,data:i,value:a.value??[],disabled:d,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message,withinPortal:!0})}),e.jsx(D,{name:"fromDate",control:o,defaultValue:t.fromDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(I,{...a,onChange:l=>{const j=l?typeof l=="string"?l:v(l,"yyyy-MM-dd"):void 0;j!==a.value&&a.onChange(j)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(D,{name:"toDate",control:o,defaultValue:t.toDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:a,fieldState:g})=>e.jsx(I,{...a,onChange:l=>{const j=l?typeof l=="string"?l:v(l,"yyyy-MM-dd"):void 0;j!==a.value&&a.onChange(j)},value:a.value?new Date(a.value):void 0,error:g.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(L,{name:"unmatched",control:o,render:({field:a})=>e.jsxs(q,{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(G,{children:"Unmatched only"})}),e.jsx(Q,{children:e.jsx(J,{defaultChecked:t.unmatched??!1,onCheckedChange:a.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:d,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:m,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:x,children:"Cancel"})]})]})})]})}function be({filter:t={},setFilter:s,initiallyOpened:x=!1}){const[p,h]=r.useState(x),[o,y]=r.useState(!w(t)),{get:i,set:d}=P();r.useEffect(()=>{const m=w(t)?null:encodeURIComponent(JSON.stringify(t)),a=i("documentsFilters");m!==a&&d("documentsFilters",m)},[t,i,d]);const C=r.useCallback(m=>{K(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(V,{opened:p,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(O,{inline:!0,size:16,disabled:!o,children:e.jsx(c,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>h(!0),children:e.jsx(pe,{className:"size-5"})})})]})}const E=[{accessorKey:"__typename",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Type"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>{const{__typename:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s})}},{accessorKey:"image",header:()=>e.jsx("div",{className:"text-left",children:"Image"}),cell:({row:t})=>{const{image:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s?e.jsx("img",{alt:"missing img",src:s?.toString(),height:80,width:80}):"No image"})}},{accessorKey:"file",header:()=>e.jsx("div",{className:"text-left",children:"File"}),cell:({row:t})=>{const{file:s}=t.original;return e.jsx("div",{className:"text-left font-medium",children:s&&e.jsx(c,{variant:"outline",size:"sm",asChild:!0,children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s?.toString(),children:"Open"})})})}},{accessorKey:"date",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Date"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"date"in t.original&&t.original.date?e.jsx("div",{className:"text-left font-medium",children:v(new Date(t.original.date),"dd/MM/yy")}):null},{accessorKey:"serialNumber",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Serial Number"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"serialNumber"in t.original&&t.original.serialNumber?e.jsx("div",{className:"text-left font-medium",children:t.original.serialNumber}):null},{accessorKey:"vat.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"VAT"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"vat"in t.original&&t.original.vat?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.vat.formatted}):null},{accessorKey:"amount.raw",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Amount"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"amount"in t.original&&t.original.amount?.formatted?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.amount.formatted}):null},{accessorKey:"creditor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Creditor"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"creditor"in t.original&&t.original.creditor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.creditor.name}):null},{accessorKey:"debtor.name",header:({column:t})=>e.jsxs(c,{variant:"ghost",onClick:()=>t.toggleSorting(t.getIsSorted()==="asc"),children:[e.jsx("div",{className:"text-left",children:"Debtor"}),e.jsx(b,{className:"ml-2 h-4 w-4"})]}),cell:({row:t})=>"debtor"in t.original&&t.original.debtor?.name?e.jsx("div",{className:"text-left font-medium whitespace-nowrap",children:t.original.debtor.name}):null},{accessorKey:"charge.transactions[0].id",header:()=>e.jsx("div",{className:"text-left",children:"Related Transaction"}),cell:({row:t})=>t.original.charge?.transactions?.[0]?.id?e.jsx(ge,{items:t.original.charge?.transactions??[],columns:[{title:"Transaction Amount",value:s=>s?.amount.formatted},{title:"Transaction Created At",value:s=>s?.eventDate?v(new Date(s.eventDate),"dd/MM/yy"):null},{title:"Transaction Effective Date",value:s=>s?.effectiveDate?v(new Date(s.effectiveDate),"dd/MM/yy"):null},{title:"Transaction Description",value:s=>s?.sourceDescription}]}):"No Related Transaction"}],Ee=()=>{const[t,s]=r.useState(null),[x,p]=r.useState(!1),{get:h}=P(),o=h("documentsFilters"),y=r.useMemo(()=>{if(o)try{return JSON.parse(decodeURIComponent(o))}catch{return}},[o]),[i,d]=r.useState(y),[C,m]=r.useState([]),[a,g]=r.useState({}),{setFiltersContext:l}=r.useContext(X),[{data:j,fetching:F},N]=Y({query:ce,variables:{filters:i??{}},pause:!0});r.useEffect(()=>{i&&N()},[i,N]);const f=Z({data:j?.documentsByFilters??[],columns:E,getCoreRowModel:ue(),getPaginationRowModel:me(),onSortingChange:m,getSortedRowModel:de(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),A=f.getState().pagination.pageIndex;return r.useEffect(()=>{l(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(he,{table:f}),e.jsx(be,{filter:i,setFilter:d,initiallyOpened:!i})]}))},[f,F,i,l,d,y,A]),e.jsx(xe,{title:"Documents",description:"All documents",headerActions:e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsxs(re,{children:[e.jsx(ie,{asChild:!0,children:e.jsx(c,{className:"ml-auto",children:"Columns"})}),e.jsx(le,{align:"end",children:f.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(oe,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:u=>n.toggleVisibility(!!u),children:n.id},n.id))})]}),e.jsx(c,{onClick:()=>p(!0),children:"Upload Documents"})]}),children:F?e.jsx(W,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx($,{open:x,onOpenChange:p,onChange:N}),t&&e.jsx(V,{modalSize:"45%",content:e.jsx(ee,{src:t}),opened:!!t,onClose:()=>s(null)}),e.jsxs(te,{children:[e.jsx(se,{children:f.getHeaderGroups().map(n=>e.jsx(S,{children:n.headers.map(u=>e.jsx(ae,{children:u.isPlaceholder?null:k(u.column.columnDef.header,u.getContext())},u.id))},n.id))}),e.jsx(ne,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(n=>e.jsx(S,{"data-state":n.getIsSelected()&&"selected",children:n.getVisibleCells().map(u=>e.jsx(T,{children:k(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(T,{colSpan:E.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{Ee as DocumentsReport,E as columns};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as T,hC as N,r as u,t as l,i as f,y,G as b,j as e,V as C,ee as D,X as F,Y as $,Z as w,_ as k,I as j,a0 as E,hD as v,hE as A,a8 as S,l as z,T as L,B as p,bY as M,n as O,hF as P,hG as B,F as q,u as _,hH as U,L as G,cf as V,hI as R}from"./index-
|
|
1
|
+
import{g as T,hC as N,r as u,t as l,i as f,y,G as b,j as e,V as C,ee as D,X as F,Y as $,Z as w,_ as k,I as j,a0 as E,hD as v,hE as A,a8 as S,l as z,T as L,B as p,bY as M,n as O,hF as P,hG as B,F as q,u as _,hH as U,L as G,cf as V,hI as R}from"./index-CIAQBv17.js";import{P as Y}from"./page-layout-CVpEeEVI.js";import{L as H}from"./list-plus-CnE5HRyh.js";const Q="updateTag",X=()=>{const[{fetching:c},r]=T(N),i=u.useCallback(async t=>{const a=`Error updating tag ID [${t.tagId}]`,s=`${Q}-${t.tagId}`;l.loading("Updating Tag...",{id:s});try{const n=await r(t),d=f(n,a,s,"updateTag");if(d)return l.success("Success",{id:s,description:"Tag updated"}),d.updateTag}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}return!1},[r]);return{fetching:c,updateTag:i}},Z=({onDone:c,data:r,close:i})=>{const{updateTag:t,fetching:a}=X(),s=b(A,r),n=y({defaultValues:{name:s.name,parentId:s.parent?.id}}),{control:d,handleSubmit:m,formState:{dirtyFields:h}}=n,x=o=>{const g=S(o,h);i(),g&&Object.keys(g).length>0&&t({tagId:s.id,fields:g}).then(()=>c?.())};return e.jsx(C,{...n,children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs(D,{cols:3,children:[e.jsx(F,{name:"name",control:d,defaultValue:s.name,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o})=>e.jsxs($,{children:[e.jsx(w,{children:"Name"}),e.jsx(k,{children:e.jsx(j,{...o,value:o.value??void 0})}),e.jsx(E,{})]})}),e.jsx(v,{formManager:n,tagsPath:"parentId",label:"Parent Tag"})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>m(x),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:a||Object.keys(h).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:i,children:"Cancel"})]})]})})},J=({onDone:c,data:r})=>{const[i,{open:t,close:a}]=z(!1);function s(){a(),c?.()}return e.jsxs(e.Fragment,{children:[e.jsx(L,{label:"Edit Tag",children:e.jsx(p,{variant:"ghost",size:"icon",className:"size-7.5",onClick:t,children:e.jsx(M,{className:"size-5"})})}),e.jsx(O,{centered:!0,opened:i,onClose:a,title:"Insert Business Trip",children:e.jsx(Z,{close:a,onDone:s,data:r})})]})},K="addTag",W=()=>{const[{fetching:c},r]=T(P),i=u.useCallback(async t=>{const a=`Error adding new tag [${t.tagName}]`,s=`${K}-${t.tagName}`;l.loading("Adding tag",{id:s});try{const n=await r(t);f(n,a,s)&&l.success("Success",{id:s,description:`"${t.tagName}" tag was successfully added`})}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}},[r]);return{fetching:c,addTag:i}},ee="deleteTag",se=()=>{const[{fetching:c},r]=T(B),i=u.useCallback(async t=>{const a=`Error deleting new tag [${t.name}]`,s=`${ee}-${t.tagId}`;l.loading(`Deleting tag [${t.name}]`,{id:s});try{const n=await r(t);f(n,a,s)&&l.success("Tag Deleted",{id:s,description:`[${t.name}] tag was successfully removed`})}catch(n){console.error(`${a}: ${n}`),l.error("Error",{id:s,description:a,duration:1e5,closeButton:!0})}},[r]);return{fetching:c,deleteTag:i}},oe=()=>{const{setFiltersContext:c}=u.useContext(q),[r,i]=u.useState(""),[{data:t,fetching:a},s]=_({query:R}),{addTag:n}=W(),{deleteTag:d}=se();u.useEffect(()=>{c(null)},[c]);const m=U(t?.allTags??[]),h=u.useCallback(o=>{o.length>2&&n({tagName:o}).then(()=>{s()})},[n,s]),x=u.useCallback((o,g)=>{d({tagId:o,name:g}).then(()=>{s()})},[d,s]);return e.jsx(Y,{title:"Tags",description:"Manage tags for your bookmarks.",children:a?e.jsx(G,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m?.map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-gray-600 mb-2",children:[e.jsxs("div",{className:"w-full mt-1 relative rounded-md shadow-xs",children:[o.namePath?.map((g,I)=>e.jsx("span",{className:"ms-2"},I)),o.name]}),e.jsx(J,{data:o}),e.jsx(p,{variant:"ghost",size:"icon",className:"size-7.5",onClick:()=>x(o.id,o.name),children:e.jsx(V,{className:"size-5"})})]},o.id)),e.jsxs("div",{className:"flex justify-start items-center gap-2 text-gray-600 mb-2",children:[e.jsx(j,{className:"w-80",value:r,onChange:o=>i(o.currentTarget.value),placeholder:"Add new tag",required:!0}),e.jsx(p,{variant:"ghost",size:"icon",className:"size-7.5",disabled:r.length<2,onClick:()=>h(r),children:e.jsx(H,{className:"size-5"})})]})]})})};export{oe as TagsManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n,r as x,B as g,G as h,gm as j,a as v,F as D,u as R,L as E,bh as y,dL as T,T as u,gn as w}from"./index-
|
|
1
|
+
import{j as n,r as x,B as g,G as h,gm as j,a as v,F as D,u as R,L as E,bh as y,dL as T,T as u,gn as w}from"./index-CIAQBv17.js";import{d as C}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as A}from"./page-layout-CVpEeEVI.js";import{P as b}from"./modal-CCob5Wtp.js";import{Y as F}from"./YearPickerInput-DEG2pQQo.js";import{F as I}from"./funnel-9aCMMcQP.js";import{T as N}from"./Table-BM6YZZrt.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 u,j as e,w as b,G as R,gj as M,F as $,u as k,bK as B,L as P,bA as T,bB as L,bC as d,bD as V,bN as C,bE as S,bF as t,gk as Y,bP as K,bR as O,dL as A,bd as H}from"./index-
|
|
1
|
+
import{r as u,j as e,w as b,G as R,gj as M,F as $,u as k,bK as B,L as P,bA as T,bB as L,bC as d,bD as V,bN as C,bE as S,bF as t,gk as Y,bP as K,bR as O,dL as A,bd as H}from"./index-CIAQBv17.js";import{D as z}from"./data-table-pagination-cKgNAmlV.js";import{P as q}from"./page-layout-CVpEeEVI.js";import{D as E}from"./download-csv-button-BBgOyW3z.js";import{Y as G}from"./YearPickerInput-DEG2pQQo.js";const Q=({data:a,year:s})=>{const n=u.useCallback(async()=>{if(!a)return{fileContent:"",fileName:""};const x=R(M,a),m=_(x),l=`${s}_ledger`;return{fileContent:m,fileName:l}},[a,s]);return a?e.jsx(E,{createFileVariables:n}):e.jsx("div",{})},F=[{key:"",valueFn:()=>""},{key:"",valueFn:()=>""},{key:"Counterparty",valueFn:a=>j(a.counterParty?.name??"")},{key:"Invoice Date",valueFn:a=>b(a.invoiceDate,"yyyy-MM-dd")},{key:"Value Date",valueFn:a=>b(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)}],_=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)}`,v=`,,,,,,,,${(n.totalCredit.raw-n.totalDebit.raw).toFixed(2)} Diff,`;s.push(x,m,...n.records.map(o=>F.map(({valueFn:D})=>D(o)).join(",")),l,g,v)}),s.join(`\r
|
|
2
2
|
`)};function j(a){return a.replace(/"/g,'""').replace(/,/g,".")}const c=A(H.Ils),J=[{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=b(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=b(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:Y,variables:{year:s}}),l=x?.yearlyLedgerReport,{financialEntitiesInfo:g}=l??{},v=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:v,columns:J,getCoreRowModel:O(),getPaginationRowModel:K(),initialState:{pagination:{pageSize:100}}}),D=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(z,{table:o})}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(G,{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(Q,{data:l,year:s})]})]}))},[s,m,a,l,o,D]),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(L,{children:o.getHeaderGroups().map(r=>e.jsx(d,{children:r.headers.map(i=>e.jsx(V,{children:i.isPlaceholder?null:C(i.column.columnDef.header,i.getContext())},i.id))},r.id))}),e.jsx(S,{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(U,{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(W,{row:r})]})})})]})}):e.jsx("div",{className:"rounded-md border h-24 text-center",children:"No results."})})};function U({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 W({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 U,r as d,j as e,G as p,B as g,dY as q,dZ as H,d_ as _,cZ as F,d$ as M,e0 as Q,e1 as $,e2 as J,e3 as Y,e4 as Z,e5 as K,u as E,t as W,e6 as X,T as ee,e7 as te,ad as T,bg as se,y as ae,dg as ne,bj as A,bm as S,e8 as N,bz as re,w as D,bn as oe,F as ie,L as ce,e9 as le}from"./index-
|
|
1
|
+
import{v as U,r as d,j as e,G as p,B as g,dY as q,dZ as H,d_ as _,cZ as F,d$ as M,e0 as Q,e1 as $,e2 as J,e3 as Y,e4 as Z,e5 as K,u as E,t as W,e6 as X,T as ee,e7 as te,ad as T,bg as se,y as ae,dg as ne,bj as A,bm as S,e8 as N,bz as re,w as D,bn as oe,F as ie,L as ce,e9 as le}from"./index-CIAQBv17.js";import{d as R}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as V}from"./use-url-query-BhOR-Upe.js";import{M as de}from"./index-CVwWYUG4.js";import{E as he,I as me,M as xe}from"./match-document-modal-jwgQRgRO.js";import{P as ue}from"./page-layout-CVpEeEVI.js";import{C as I,u as pe,a as z,b as O}from"./charges-table-BuVDqB4z.js";import{P as w,a as y}from"./panel-top-open-CpfvrJ7c.js";import{T as k}from"./toggle-expansion-button-BLwBnyJd.js";import{T as P}from"./Table-BM6YZZrt.js";import{c as ge}from"./charges-filters-Cn5t0R5G.js";import{P as je}from"./modal-CCob5Wtp.js";import{F as fe}from"./funnel-9aCMMcQP.js";import"./Checkbox-xGXU5JAb.js";import"./YearPickerInput-DEG2pQQo.js";import"./list-plus-CnE5HRyh.js";import"./insert-business-trip-modal-WRRM6504.js";import"./accounter-table-DBMvyGoN.js";import"./index-3UYjJ7iT.js";import"./similar-transactions-modal-BBKoKpL4.js";import"./addDays-DMNXN6YX.js";import"./tooltip-BUql9ooX.js";import"./summary-OKeTUxcz.js";import"./sub-DQC73fqa.js";import"./subMonths-C5xLwL1V.js";import"./MultiSelect-DXQxo0-S.js";/**
|
|
2
2
|
* @license lucide-react v0.548.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|