@accounter/client 0.0.11-alpha-20260125180828-ba6265251b2d2e84e3355b96352f5bf83918317f → 0.0.11-alpha-20260126094406-5e339d8e89f94400c777170c689d55bd9dd5f95c

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.
Files changed (102) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-DWmOT4mx.js → Checkbox-Dmuz3t7B.js} +1 -1
  3. package/dist/assets/{MultiSelect-DhEZHYxn.js → MultiSelect-DBeIExB5.js} +1 -1
  4. package/dist/assets/{Progress-DE13gAJ5.js → Progress---sZILQb.js} +1 -1
  5. package/dist/assets/{Table-rNmO5bBI.js → Table-BQv3frL8.js} +1 -1
  6. package/dist/assets/{Typography-C1pdNNG8.js → Typography-B8Kph7eR.js} +1 -1
  7. package/dist/assets/accordion-Bn08_4fN.js +1 -0
  8. package/dist/assets/{accountant-approvals-DXUA4Z8R.js → accountant-approvals-DuNl7y6H.js} +1 -1
  9. package/dist/assets/{accounter-table-CGncq_73.js → accounter-table-DTsgtq5M.js} +1 -1
  10. package/dist/assets/{addDays-DpkzPtfc.js → addDays-DTiBTTns.js} +1 -1
  11. package/dist/assets/{all-charges-CAf5Sz2_.js → all-charges-DPyM-a74.js} +1 -1
  12. package/dist/assets/{arrow-up-down-MrfN0fhR.js → arrow-up-down-VY6mkkTR.js} +1 -1
  13. package/dist/assets/{building-2-CWrl-iq9.js → building-2-CMKd_bU8.js} +1 -1
  14. package/dist/assets/{business-CnobDfUp.js → business-BVMKhHFx.js} +1 -1
  15. package/dist/assets/{business-extended-info-6Ykvm7VT.js → business-extended-info-B94y5ZK6.js} +1 -1
  16. package/dist/assets/business-header-BC86M-9m.js +1 -0
  17. package/dist/assets/{business-ledger-filters-Bi9mwcxM.js → business-ledger-filters-es3H4rPK.js} +1 -1
  18. package/dist/assets/{business-ledger-single-SwmnJ5M-.js → business-ledger-single-U3zkqgW2.js} +1 -1
  19. package/dist/assets/business-trip-BUKYnQkG.js +1 -0
  20. package/dist/assets/charge-DuqIMfNm.js +1 -0
  21. package/dist/assets/charges-filters-CFCAP-bP.js +1 -0
  22. package/dist/assets/{charges-ledger-validation-ClbJGvF9.js → charges-ledger-validation-CCTNRpCE.js} +1 -1
  23. package/dist/assets/{charges-table-zGkVW5or.js → charges-table-BJtpvXfL.js} +3 -3
  24. package/dist/assets/contracts-ljjcB_x7.js +1 -0
  25. package/dist/assets/{data-table-column-header-DDRUwuwC.js → data-table-column-header-CZ1dXiU0.js} +1 -1
  26. package/dist/assets/{data-table-pagination-DxOcd13P.js → data-table-pagination-XAlQIbO9.js} +1 -1
  27. package/dist/assets/deposits-transactions-table-2rtRFZgK.js +1 -0
  28. package/dist/assets/{download-csv-BmamqJJW.js → download-csv-BSGaUZsM.js} +1 -1
  29. package/dist/assets/{download-csv-button-BFfxSTjQ.js → download-csv-button-CMQBUQeX.js} +1 -1
  30. package/dist/assets/{editable-business-trip-CPfdEl45.js → editable-business-trip-CED1Su3d.js} +1 -1
  31. package/dist/assets/{eye-off-DtXkBVx1.js → eye-off-Buv7eciz.js} +1 -1
  32. package/dist/assets/{funnel-B1ZA9LM9.js → funnel-Cfb9Pxmr.js} +1 -1
  33. package/dist/assets/index-3ev2Q3E9.js +1 -0
  34. package/dist/assets/{index-Cs7XgdTM.js → index-7gCTV42h.js} +2 -2
  35. package/dist/assets/{index-Bsnch-zI.js → index-8fdLByFg.js} +1 -1
  36. package/dist/assets/index-B0hZ0TDG.js +1 -0
  37. package/dist/assets/{index-DCmEMj8e.js → index-B4OP8iL7.js} +3 -3
  38. package/dist/assets/{index-DKmgIoB5.js → index-BN-I0GSO.js} +2 -2
  39. package/dist/assets/index-BhFsGqUx.js +1 -0
  40. package/dist/assets/{index-Chao5nQb.js → index-Bui9zV-z.js} +1 -1
  41. package/dist/assets/{index-ciP7vurq.js → index-C7p19nIa.js} +1 -1
  42. package/dist/assets/{index-DwGxsIkH.js → index-CPMJQkvw.js} +1 -1
  43. package/dist/assets/{index-BBOAkvDK.js → index-CSdQtH7c.js} +1 -1
  44. package/dist/assets/index-CcZll7L2.js +1 -0
  45. package/dist/assets/index-CjG9JDZB.js +2 -0
  46. package/dist/assets/{index-DqoPYGJE.js → index-DGAT1KYx.js} +1 -1
  47. package/dist/assets/index-DIrLsKod.js +1 -0
  48. package/dist/assets/{index-DfBrqs5_.js → index-DJY6AKiM.js} +2 -2
  49. package/dist/assets/{index-Bv5ZyMGd.js → index-DOy0Yf1i.js} +1 -1
  50. package/dist/assets/{index-CywvUChw.js → index-DRBzHdu9.js} +1 -1
  51. package/dist/assets/index-Dal_ULkA.js +1 -0
  52. package/dist/assets/{index-DJQjDgkB.js → index-DokXNUuN.js} +1 -1
  53. package/dist/assets/{index-DjsqV-Fn.js → index-Dq33WQoi.js} +1 -1
  54. package/dist/assets/{index-C60AFYOu.js → index-DzzUoyj4.js} +1 -1
  55. package/dist/assets/{index-Vxd58TOQ.js → index-GlUqZUgQ.js} +1 -1
  56. package/dist/assets/index-X3RoQQa9.js +1 -0
  57. package/dist/assets/index-X9rrwleE.js +1 -0
  58. package/dist/assets/{index-DRqooPz9.js → index-rI994S3C.js} +4 -4
  59. package/dist/assets/{index.es-C6H8Q1nD.js → index.es-C2YDJ0AL.js} +1 -1
  60. package/dist/assets/issue-document-zNxGzRkY.js +1 -0
  61. package/dist/assets/login-page-BimTSmTC.js +1 -0
  62. package/dist/assets/{missing-info-charges-Dr8TvB2G.js → missing-info-charges-CVhY60ZL.js} +1 -1
  63. package/dist/assets/{modal-CPrQ9jQu.js → modal-BXR_xgUm.js} +1 -1
  64. package/dist/assets/modify-contract-dialog-flMl2p_T.js +1 -0
  65. package/dist/assets/{page-layout-Dp9Tr43G.js → page-layout-DMGj5xhW.js} +1 -1
  66. package/dist/assets/{page-not-found-BIERJkiT.js → page-not-found-B_GB5ntj.js} +1 -1
  67. package/dist/assets/{panel-top-open-lnF5tdL1.js → panel-top-open-Bf39HBrp.js} +1 -1
  68. package/dist/assets/report-commentary-row-BMyeQR9J.js +1 -0
  69. package/dist/assets/{save-BaXyzRSW.js → save-jkuyCWyY.js} +1 -1
  70. package/dist/assets/{similar-transactions-modal-DilkLkpx.js → similar-transactions-modal-DX3CPrMo.js} +1 -1
  71. package/dist/assets/{sub-764RJPt0.js → sub-CEXBz_OW.js} +1 -1
  72. package/dist/assets/subMonths-DY4HlBVa.js +1 -0
  73. package/dist/assets/summary-CPKS_69D.js +1 -0
  74. package/dist/assets/{toggle-expansion-button-BquTpOYj.js → toggle-expansion-button-Y2eS7nqg.js} +1 -1
  75. package/dist/assets/{update-accountant-status-Btcm95Uc.js → update-accountant-status-zL6vnwU9.js} +1 -1
  76. package/dist/assets/use-issue-monthly-documents-D9vQpbaZ.js +1 -0
  77. package/dist/assets/{use-url-query-A8PE3FMA.js → use-url-query-CqWra6gD.js} +1 -1
  78. package/dist/index.html +1 -1
  79. package/package.json +1 -1
  80. package/dist/assets/accordion-Air1oXnF.js +0 -1
  81. package/dist/assets/business-header-CAJaQahQ.js +0 -1
  82. package/dist/assets/business-trip-ADSYpFTM.js +0 -1
  83. package/dist/assets/charge-CLyQ-8f8.js +0 -1
  84. package/dist/assets/charges-filters-CYR6-jcu.js +0 -1
  85. package/dist/assets/contracts-DCd159UE.js +0 -1
  86. package/dist/assets/deposits-transactions-table-Dhm74qLm.js +0 -1
  87. package/dist/assets/index-5Ht40D_c.js +0 -1
  88. package/dist/assets/index-BL8siR4m.js +0 -1
  89. package/dist/assets/index-C0Bd8nM_.js +0 -1
  90. package/dist/assets/index-CFLkhm3K.js +0 -1
  91. package/dist/assets/index-CXZphjyK.js +0 -1
  92. package/dist/assets/index-Cd9YArsS.js +0 -1
  93. package/dist/assets/index-DynC0Vxq.js +0 -1
  94. package/dist/assets/index-cd89pXq_.js +0 -1
  95. package/dist/assets/index-d-FcvOUD.js +0 -2
  96. package/dist/assets/issue-document-B8SLRY9w.js +0 -1
  97. package/dist/assets/login-page-DF0c_Pay.js +0 -1
  98. package/dist/assets/modify-contract-dialog-BMTCgQ3i.js +0 -1
  99. package/dist/assets/report-commentary-row-BsA3JSzG.js +0 -1
  100. package/dist/assets/subMonths-CZ2djAnO.js +0 -1
  101. package/dist/assets/summary-BvHHpnIR.js +0 -1
  102. package/dist/assets/use-issue-monthly-documents-Dx6_0gyN.js +0 -1
@@ -1 +0,0 @@
1
- import{a,r as o,F as u,u as m,j as s,c,ci as d}from"./index-DRqooPz9.js";import{P as x,E as l}from"./editable-business-trip-CPfdEl45.js";import{P as f}from"./page-layout-Dp9Tr43G.js";import"./summary-BvHHpnIR.js";import"./update-accountant-status-Btcm95Uc.js";import"./Table-rNmO5bBI.js";import"./toggle-expansion-button-BquTpOYj.js";import"./panel-top-open-lnF5tdL1.js";import"./MultiSelect-DhEZHYxn.js";import"./similar-transactions-modal-DilkLkpx.js";import"./building-2-CWrl-iq9.js";import"./accordion-Air1oXnF.js";const C=({businessTripId:n})=>{const{businessTripId:p}=a(),{setFiltersContext:e}=o.useContext(u),i=n??p??"",[{data:r,fetching:t}]=m({query:d,variables:{businessTripId:i}});return o.useEffect(()=>{e(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(x,{filename:"business_trip_report"})}))},[r,t,e]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(f,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx("div",{children:i&&s.jsx(l,{tripId:i,isExtended:!0})})})};export{C as BusinessTrip};
@@ -1 +0,0 @@
1
- import{a as n,b as h,u,r as d,j as a,c as g,C as f}from"./index-DRqooPz9.js";import{C as l}from"./charges-table-zGkVW5or.js";import"./toggle-expansion-button-BquTpOYj.js";import"./panel-top-open-lnF5tdL1.js";import"./update-accountant-status-Btcm95Uc.js";import"./index-ciP7vurq.js";import"./similar-transactions-modal-DilkLkpx.js";import"./building-2-CWrl-iq9.js";import"./addDays-DpkzPtfc.js";import"./Table-rNmO5bBI.js";import"./summary-BvHHpnIR.js";import"./accordion-Air1oXnF.js";import"./deposits-transactions-table-Dhm74qLm.js";import"./Checkbox-DWmOT4mx.js";import"./data-table-column-header-DDRUwuwC.js";import"./eye-off-DtXkBVx1.js";const R=({chargeId:s})=>{const{chargeId:i}=n(),t=s||i;let r;try{r=h()}catch{}const[{data:c,fetching:m},e]=u({query:f,pause:!t||!!r,variables:{chargeId:t??""}});d.useEffect(()=>{t&&!r&&e()},[t,r,e]);const o=r||c,p=!r&&m;return t?p?a.jsx(g,{}):a.jsx(l,{data:o?.charge?[o.charge]:[],isAllOpened:!0}):a.jsx("div",{children:"Charge not found"})};export{R as Charge};
@@ -1 +0,0 @@
1
- import{r as i,bB as I,bI as z,j as e,P as U,bC as G,B as V,aC as _,E as $,w as N,aE as D,dr as q,b4 as J,W as Q,ds as X,bE as x,hE as Z,bF as O,bG as P,bH as L,en as E,at as p,a3 as K,Z as j,_ as g,$ as b,a0 as y,bU as Y,bV as ee,bW as se}from"./index-DRqooPz9.js";import{u as ae}from"./use-url-query-A8PE3FMA.js";import{a as te}from"./update-accountant-status-Btcm95Uc.js";import{P as ne}from"./modal-CPrQ9jQu.js";import{F as oe}from"./funnel-B1ZA9LM9.js";import{s as re}from"./sub-764RJPt0.js";import{M as A}from"./MultiSelect-DhEZHYxn.js";function le(a){return!a||I(a)?null:encodeURIComponent(JSON.stringify(a))}const ce=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ie=[{label:"All",value:E.All},{label:"Income",value:E.Income},{label:"Expense",value:E.Expense}];function de({filter:a,setFilter:u,closeModal:c}){const{userContext:h}=i.useContext(_),o=$({defaultValues:{byOwners:h?.context.adminBusinessId?[h.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(re(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:r,handleSubmit:k,watch:C}=o,[f,S]=i.useState(a.sortBy?.asc??!1),[d,m]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:F,fetching:t}=q(),{selectableTags:v,fetching:B}=J(),T=C("sortBy.field");i.useEffect(()=>{T&&!d?m(!0):!T&&d&&m(!1)},[T,d]);const H=s=>{f!=null&&s.sortBy?.field&&(s.sortBy.asc=f),u(s),c()};function R(){u({}),S(!1),c()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(Q,{...o,children:e.jsxs("form",{onSubmit:k(H),children:[e.jsxs(X,{cols:2,children:[e.jsx(x,{name:"byOwners",control:r,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:F,value:s.value??[],disabled:t,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(x,{name:"byBusinesses",control:r,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:F,value:s.value??[],disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(x,{name:"byTags",control:r,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:v,itemComponent:Z,value:s.value??[],disabled:B,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(l,w,M)=>M.label?.toLowerCase().includes(l.toLowerCase().trim())||M.description?.toLowerCase().includes(l.toLowerCase().trim())})}),e.jsx(x,{name:"fromAnyDate",control:r,defaultValue:a.fromAnyDate,rules:{pattern:{value:O,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(P,{...s,onChange:l=>{const w=l?typeof l=="string"?l:N(l,"yyyy-MM-dd"):void 0;w!==s.value&&s.onChange(w)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(x,{name:"toAnyDate",control:r,defaultValue:a.toAnyDate,rules:{pattern:{value:O,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(P,{...s,onChange:l=>{const w=l?typeof l=="string"?l:N(l,"yyyy-MM-dd"):void 0;w!==s.value&&s.onChange(w)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(x,{name:"chargesType",control:r,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(L,{...s,data:ie,value:s.value??E.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(x,{name:"sortBy.field",control:r,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(L,{...s,data:ce,label:"Field to sort by",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,rightSectionProps:{style:{width:"5rem"}},withinPortal:!0,rightSection:e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(p,{defaultChecked:a.sortBy?.asc??!1,checked:f??!1,disabled:!d,onCheckedChange:S}),e.jsx("span",{className:"text-xs",children:f?"ASC":"DESC"})]})})}),e.jsx(x,{name:"accountantStatus",control:r,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(A,{...s,value:s.value??[],itemComponent:W,data:Object.values(te),disabled:t,label:"Accountant Status",placeholder:"All",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4 rounded-lg border p-3 shadow-sm space-y-2",children:[e.jsx(K,{children:"Missing Information:"}),e.jsx(j,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without Invoice"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without Receipts"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without Documents"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"With Open Documents"})}),e.jsx(y,{children:e.jsxs(Y,{children:[e.jsx(ee,{children:e.jsx(p,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(se,{children:e.jsx("p",{children:"Show only charges with documents that are currently open"})})]})})]})}),e.jsx(j,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without Transactions"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Unbalanced businesses"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(j,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(g,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(b,{children:"Without ledger"})}),e.jsx(y,{children:e.jsx(p,{defaultChecked:a.withoutLedger??!1,onCheckedChange:s.onChange})})]})})]})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:t||B,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:R,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:c,children:"Cancel"})]})]})})]})}function be({filter:a={},setFilter:u,activePage:c,setPage:h,totalPages:o=1,initiallyOpened:r=!1}){const[k,C]=i.useState(r),[f,S]=i.useState(!I(a)),{get:d,set:m}=ae();i.useEffect(()=>{const t=c>0?c.toFixed(0):null,v=d("page");t!==v&&m("page",t)},[c,d,m]),i.useEffect(()=>{const t=le(a),v=d("chargesFilters");t!==v&&(m("chargesFilters",t),m("page"),h(0))},[a,d,m,h]);const F=i.useCallback(t=>{z(t,a)||(u(t),S(!I(t)))},[a,u]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(ne,{opened:k,onClose:()=>C(!1),content:e.jsx(de,{filter:a,setFilter:F,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(U,{className:"flex-fit w-fit mx-0",currentPageIndex:c,onChange:h,totalPages:o}),e.jsx(G,{inline:!0,size:16,disabled:!f,children:e.jsx(V,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(oe,{className:"size-5"})})})]})}const W=i.forwardRef(({bgColor:a,label:u,color:c,icon:h,...o},r)=>e.jsxs(V,{ref:r,...o,variant:"ghost",size:"sm",className:`h-7 p-0 ${a}`,title:u,children:[e.jsx(h,{className:`h-3.5 w-3.5 ${c}`}),u]}));W.displayName="AccountantStatusMultiSelectItem";export{be as C,ie as c};
@@ -1 +0,0 @@
1
- import{j as e,ah as T,R,p as k,af as B,B as C,a9 as se,r as i,D as z,aL as H,x as _,al as $,am as q,an as J,a3 as S,ao as w,ap as I,aq as L,ar as M,as as x,bJ as te,bK as ae,bL as ne,w as O,u as Q,bM as le,aJ as ie,E as re,J as ce,c as W,W as oe,bN as de,bO as X,bP as Y,bQ as b,bR as f,bS as Z,bT as g,bU as ue,bV as me,a5 as xe,bW as he,bX as ge,H as G,aK as je,bY as pe,bZ as fe,b_ as Ce,b$ as ve,c0 as De,c1 as Ne,c2 as E,P as ye,c3 as Se,c4 as be,c5 as we,c6 as Ie,c7 as Le,aC as Me,b as Fe,c8 as Ae}from"./index-DRqooPz9.js";import{M as Re,s as Te,a as Pe}from"./modify-contract-dialog-BMTCgQ3i.js";import{D as m}from"./data-table-column-header-DDRUwuwC.js";import{F as Ve}from"./funnel-B1ZA9LM9.js";import{u as ke,a as Be}from"./use-issue-monthly-documents-Dx6_0gyN.js";import{s as Oe}from"./subMonths-CZ2djAnO.js";import"./eye-off-DtXkBVx1.js";const U=({timelessDate:s})=>e.jsx("p",{className:"text-sm font-medium",children:new Date(s).toLocaleDateString(void 0,{timeZone:"UTC"})});function Ee({id:s,name:t}){return e.jsx("div",{className:"flex flex-wrap flex-col justify-center",children:e.jsx(T,{to:R.BUSINESSES.DETAIL(s),target:"_blank",rel:"noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold",children:t})})}const K=[{id:"select",header:({table:s})=>e.jsx(k,{checked:s.getIsAllPageRowsSelected()||s.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:t=>s.toggleAllPageRowsSelected(!!t),"aria-label":"Select all"}),cell:({row:s})=>e.jsx(k,{checked:s.getIsSelected(),onCheckedChange:t=>s.toggleSelected(!!t),"aria-label":"Select row"}),enableSorting:!1,enableHiding:!1},{accessorKey:"isActive",header:({column:s})=>e.jsx(m,{column:s,title:"Is Active"}),cell:({row:s})=>s.getValue("isActive")?e.jsx(B,{variant:"default",children:"Active"}):e.jsx(B,{variant:"destructive",children:"Inactive"})},{accessorKey:"client.name",header:({column:s})=>e.jsx(m,{column:s,title:"Client"}),cell:({row:s})=>e.jsx(Ee,{id:s.original.client.id,name:s.original.client.name})},{accessorKey:"startDate",header:({column:s})=>e.jsx(m,{column:s,title:"Start"}),cell:({row:s})=>e.jsx(U,{timelessDate:s.getValue("startDate")})},{accessorKey:"endDate",header:({column:s})=>e.jsx(m,{column:s,title:"End"}),cell:({row:s})=>e.jsx(U,{timelessDate:s.getValue("endDate")})},{accessorKey:"purchaseOrder",header:({column:s})=>e.jsx(m,{column:s,title:"Purchase Order"}),cell:({row:s})=>e.jsxs("div",{className:"flex flex-row gap-1 items-center",children:[s.original.msCloud&&e.jsx(T,{to:s.original.msCloud,target:"_blank",rel:"noreferrer",className:"size-8",children:e.jsx(C,{variant:"link",size:"sm",children:e.jsx(se,{className:"size-4"})})}),e.jsx("span",{className:"text-sm font-medium",children:s.getValue("purchaseOrder")})]})},{accessorKey:"product",header:({column:s})=>e.jsx(m,{column:s,title:"Product"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("product")})},{accessorKey:"plan",header:({column:s})=>e.jsx(m,{column:s,title:"Subscription Plan"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("plan")})},{accessorKey:"billingCycle",header:({column:s})=>e.jsx(m,{column:s,title:"Billing Cycle"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("billingCycle")})},{accessorKey:"amount.raw",header:({column:s})=>e.jsx(m,{column:s,title:"Amount"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.original.amount.formatted})},{accessorKey:"operationsLimit",header:({column:s})=>e.jsx(m,{column:s,title:"Operations Limit"}),cell:({row:s})=>{const t=s.getValue("operationsLimit");return t?e.jsx("p",{className:"text-sm font-medium",children:t.toString()}):null}},{accessorKey:"edit",header:"",cell:({row:s})=>e.jsx(Re,{clientId:s.original.client.id,contractId:s.original.id}),enableSorting:!1}];function Ue({table:s}){const[t,r]=i.useState(!1);return e.jsxs(z,{open:t,onOpenChange:r,children:[e.jsx(H,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"outline",children:e.jsx(Ve,{className:"size-4"})})}),e.jsxs(_,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs($,{children:[e.jsx(q,{children:"Filter Contracts"}),e.jsx(J,{children:"Filter contracts based on various criteria"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Product Type"}),e.jsxs(w,{onValueChange:a=>s.getColumn("product")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("product")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(te).map(a=>e.jsx(x,{value:a,children:a},a))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Billing Cycle"}),e.jsxs(w,{onValueChange:a=>s.getColumn("billingCycle")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("billingCycle")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(ae).map(a=>e.jsx(x,{value:a,children:Te(a)},a))]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Subscription Plan"}),e.jsxs(w,{onValueChange:a=>s.getColumn("plan")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("plan")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(ne).map(a=>e.jsx(x,{value:a,children:Pe(a)},a))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Is Active"}),e.jsxs(w,{onValueChange:a=>s.getColumn("isActive")?.setFilterValue(a==="NULL"?void 0:a==="active"),value:Ke(s.getColumn("isActive")?.getFilterValue()),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),e.jsx(x,{value:"active",children:"Active"}),e.jsx(x,{value:"inactive",children:"Inactive"})]})]})]})]})]})]})]})}function Ke(s){return s===void 0?"NULL":s?"active":"inactive"}const ze=({contractIds:s})=>{const[t,r]=i.useState(!1),[a,v]=i.useState(O(Oe(new Date,1),"yyyy-MM-dd")),[h,D]=i.useState([]),{issueDocuments:j}=ke(),[{data:N,fetching:y},c]=Q({query:le,variables:{issueMonth:a,contractIds:s},pause:!t});i.useEffect(()=>{N?.periodicalDocumentDraftsByContracts&&D(N.periodicalDocumentDraftsByContracts.map(u=>ie(G(je,u))))},[N,D]),i.useEffect(()=>{t&&c()},[t,c]);const n=re({values:{drafts:h}}),l=i.useCallback(async u=>{await j({generateDocumentsInfo:u.drafts}),r(!1)},[j]),{fields:d,remove:F,update:ee}=ce({control:n.control,name:"drafts"}),P=n.watch("drafts"),V=i.useMemo(()=>d.map((u,o)=>({...u,...P[o],id:u.id})),[d,P]);return e.jsxs(z,{open:t,onOpenChange:r,children:[e.jsx(H,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"outline",disabled:s.length===0,children:"Issue Documents"})}),e.jsxs(_,{className:"min-w-[90vw] w-full max-h-[90vh] overflow-y-auto",children:[e.jsxs($,{children:[e.jsx(q,{children:"Issue Documents for Contracts"}),e.jsx(J,{children:"Review and issue monthly documents for the selected contracts"})]}),y?e.jsx(W,{}):e.jsx(oe,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(l),className:"min-w-5xl w-full",children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(S,{children:"Issue Month:"}),e.jsx(de,{value:new Date(a),onChange:u=>{const o=new Date(u.getFullYear(),u.getMonth(),15);v(O(o,"yyyy-MM-dd"))},popoverProps:{withinPortal:!1}})]}),e.jsxs(X,{children:[e.jsx(Y,{children:e.jsxs(b,{children:[e.jsx(f,{children:"Name"}),e.jsx(f,{children:"Document"}),e.jsx(f,{children:"Amount"}),e.jsx(f,{children:"Remark"}),e.jsx(f,{children:"Recipients"}),e.jsx(f,{})]})}),e.jsx(Z,{children:V.map(({id:u,...o},A)=>e.jsxs(b,{children:[e.jsx(g,{children:e.jsx(T,{to:o.client?.id?R.BUSINESSES.DETAIL(o.client?.id):R.BUSINESSES.ALL,target:"_blank",rel:"noreferrer",onClick:p=>p.stopPropagation(),className:"inline-flex items-center font-semibold",children:o.client?.name})}),e.jsx(g,{children:o.type}),e.jsxs(g,{children:[o.income?.[0]?.price," ",o.income?.[0]?.currency]}),e.jsx(g,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:o.remarks})}),e.jsx(g,{children:e.jsx("div",{className:"flex flex-col",children:o.client?.emails?.map(p=>e.jsx("span",{className:"text-sm text-gray-500",children:p},p))})}),e.jsx(g,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,type:"button",children:e.jsx(C,{className:"size-7.5",variant:"secondary",onClick:()=>F(A),children:e.jsx(xe,{size:16})})}),e.jsx(he,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(Be,{draft:o,onApprove:p=>{n.setValue(`drafts.${A}`,p,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),ee(A,{...p})}})]})})]},u))})]}),e.jsx("div",{className:"flex justify-between items-center mt-4",children:e.jsx(ge,{onConfirm:n.handleSubmit(l),title:`Are you sure you want to issue ${V.length} documents?`,children:e.jsx(C,{children:"Issue"})})})]})})]})]})};function He(s){const t=G(Le,s);return{id:t.id,isActive:t.isActive,client:{id:t.client.id,name:t.client.originalBusiness.name},purchaseOrder:t.purchaseOrders[0],startDate:t.startDate,endDate:t.endDate,amount:{raw:t.amount.raw,formatted:t.amount.formatted},billingCycle:t.billingCycle,product:t.product??void 0,plan:t.plan??void 0,operationsLimit:t.operationsLimit,msCloud:t.msCloud?.toString()??void 0}}const _e=({data:s})=>{const[t,r]=i.useState([{id:"endDate",desc:!0},{id:"amount.raw",desc:!0}]),[a,v]=i.useState({}),[h,D]=i.useState([]),[j,N]=i.useState([]),y=i.useMemo(()=>s.map(n=>He(n)),[s]),c=pe({data:y,columns:K,getCoreRowModel:Ie(),onSortingChange:r,getSortedRowModel:we(),getPaginationRowModel:be(),onRowSelectionChange:v,onColumnFiltersChange:D,getFilteredRowModel:Se(),state:{sorting:t,rowSelection:a,columnFilters:h},initialState:{pagination:{pageIndex:0,pageSize:50}}});return i.useEffect(()=>{const n=Object.entries(a).filter(([,d])=>!!d).map(([d])=>Number(d)),l=Array.from(new Set(y.filter((d,F)=>n.includes(F)).map(d=>d.id)));(j.length!==l.length||!j.every(d=>l.includes(d)))&&N(l)},[a,y,j,h]),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsx(Ue,{table:c}),e.jsxs(fe,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(C,{variant:"outline",children:["Columns ",e.jsx(ve,{})]})}),e.jsx(De,{align:"end",children:c.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(Ne,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:l=>n.toggleVisibility(!!l),children:n.id},n.id))})]}),e.jsx("div",{className:"ml-auto",children:e.jsx(ze,{contractIds:j,className:"ml-auto"})})]}),e.jsx("div",{className:"overflow-hidden rounded-md border",children:e.jsxs(X,{children:[e.jsx(Y,{children:c.getHeaderGroups().map(n=>e.jsx(b,{children:n.headers.map(l=>e.jsx(f,{colSpan:l.colSpan,children:l.isPlaceholder?null:E(l.column.columnDef.header,l.getContext())},l.id))},n.id))}),e.jsx(Z,{children:c.getRowModel().rows?.length?c.getRowModel().rows.map(n=>e.jsx(b,{children:n.getVisibleCells().map(l=>e.jsx(g,{children:E(l.column.columnDef.cell,l.getContext())},l.id))},n.id)):e.jsx(b,{children:e.jsx(g,{colSpan:K.length,className:"h-24 text-center",children:"No results."})})})]})}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 py-4",children:[e.jsxs("div",{className:"text-muted-foreground flex-1 text-sm",children:[c.getFilteredSelectedRowModel().rows.length," of"," ",c.getFilteredRowModel().rows.length," row(s) selected."]}),e.jsx(ye,{className:"w-fit mx-0",currentPageIndex:c.getState().pagination.pageIndex,totalPages:c.getPageCount(),onChange:n=>c.setPageIndex(n)})]})]})},Ze=()=>{const{userContext:s}=i.useContext(Me),t=s?.context.adminBusinessId;let r;try{r=Fe()}catch{}const[{data:a,fetching:v}]=Q({query:Ae,pause:!t||!!r,variables:{adminId:t??""}}),h=r||a;return!r&&v&&!h?.contractsByAdmin?e.jsx(W,{}):!t||!h?.contractsByAdmin?e.jsx("div",{children:"Contracts not found"}):e.jsx(_e,{data:h.contractsByAdmin})};export{Ze as ContractsScreen};
@@ -1 +0,0 @@
1
- import{v as E,j as t,w as K,r as l,af as N,B as p,dI as y,b$ as D,g as U,ic as H,t as b,i as q,u as $,fE as z,D as V,aL as _,x as G,al as P,am as Q,a3 as W,ao as J,ap as Y,aq as X,ar as Z,as as ee,au as te,aC as se,id as ae,H as ne,ie as re,ay as x,bY as oe,c5 as ce,c6 as ie,L as le,bO as de,bP as ue,bQ as T,bR as ge,c2 as A,bS as me,bT as F}from"./index-DRqooPz9.js";const he=[["path",{d:"M12 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5",key:"x6cv4u"}],["path",{d:"m16 19 3 3 3-3",key:"1ibux0"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M6 12h.01",key:"c2rlol"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],R=E("banknote-arrow-down",he);const xe=[["path",{d:"M12 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5",key:"x6cv4u"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M19 22v-6",key:"qhmiwi"}],["path",{d:"m22 19-3-3-3 3",key:"rn6bg2"}],["path",{d:"M6 12h.01",key:"c2rlol"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],fe=E("banknote-arrow-up",xe);function pe({transaction:e}){return t.jsx("div",{className:"flex flex-col justify-center",children:e.eventDate?K(new Date(e.eventDate),"dd/MM/yyyy"):"-"})}function je({transaction:e}){const{isInterest:a,amount:n}=e,r=l.useMemo(()=>Number(n.raw)<0,[n.raw]);return t.jsx("div",{className:"flex items-center gap-2",children:a?t.jsxs(t.Fragment,{children:[t.jsx(R,{className:"size-4 text-red-600"}),t.jsx(N,{variant:"outline",className:"bg-red-50 text-red-700",children:"Interest"})]}):r?t.jsxs(t.Fragment,{children:[t.jsx(fe,{className:"size-4 text-green-600"}),t.jsx(N,{variant:"outline",className:"bg-green-50 text-green-700",children:"Deposit"})]}):t.jsxs(t.Fragment,{children:[t.jsx(R,{className:"size-4 text-red-600"}),t.jsx(N,{variant:"outline",className:"bg-red-50 text-red-700",children:"Withdrawal"})]})})}function ye({transaction:e}){const n=Number(e.amount.raw)<0?"text-green-700":"text-red-500";return t.jsx("div",{className:`flex flex-col justify-center font-mono ${n}`,children:e.amount.formatted})}function De({transaction:e}){const a=l.useMemo(()=>{const{currency:n}=e.amount;return new Intl.NumberFormat("en-US",{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e.cumulativeBalance)},[e.cumulativeBalance,e.amount]);return t.jsx("div",{className:"flex flex-col justify-center font-mono font-semibold",children:a})}function Ce({transaction:e}){const a=l.useMemo(()=>{const{currency:n}=e.amount;return new Intl.NumberFormat("en-US",{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e.totalInterest)},[e.totalInterest,e.amount]);return t.jsx("div",{className:"flex flex-col justify-center font-mono font-semibold",children:a})}function ve({transaction:e}){const a=l.useMemo(()=>new Intl.NumberFormat("en-US",{style:"currency",currency:e.localCurrency,minimumFractionDigits:2,maximumFractionDigits:2}).format(e.localAmount),[e.localAmount,e.localCurrency]);return t.jsx("div",{className:"flex flex-col justify-center font-mono text-muted-foreground",children:a})}function Ie({transaction:e}){const a=l.useMemo(()=>new Intl.NumberFormat("en-US",{style:"currency",currency:e.localCurrency,minimumFractionDigits:2,maximumFractionDigits:2}).format(e.localCumulativeBalance),[e.localCumulativeBalance,e.localCurrency]);return t.jsx("div",{className:"flex flex-col justify-center font-mono font-semibold text-muted-foreground",children:a})}const L=[{id:"date",accessorKey:"eventDate",sortingFn:e=>e.original.eventDate?new Date(e.original.eventDate).getTime():0,header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(pe,{transaction:e.original})},{id:"indicator",accessorKey:"amount.raw",header:"Type",cell:({row:e})=>t.jsx(je,{transaction:e.original})},{id:"amount",accessorKey:"amount.raw",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Origin Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(ye,{transaction:e.original})},{id:"cumulativeBalance",accessorKey:"cumulativeBalance",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Origin Balance",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(De,{transaction:e.original})},{id:"totalInterest",accessorKey:"totalInterest",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Interest",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(Ce,{transaction:e.original})},{id:"localAmount",accessorKey:"localAmount",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Local Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(ve,{transaction:e.original})},{id:"localCumulativeBalance",accessorKey:"localCumulativeBalance",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Local Balance",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(Ie,{transaction:e.original})}],we="assignChargeToDeposit",Se=()=>{const[{fetching:e},a]=U(H),n=l.useCallback(async r=>{const h=`Error assigning charge ${r.chargeId} to deposit ${r.depositId}`,o=`${we}-${r.chargeId}`;b.loading("Assigning to deposit",{id:o});try{const c=await a(r),u=q(c,h,o);u&&b.success("Success",{id:o,description:`Charge assigned to deposit ${u.assignChargeToDeposit.id}`})}catch(c){console.error(`${h}: ${c}`),b.error("Error",{id:o,description:h,duration:1e5,closeButton:!0})}},[a]);return{assigning:e,assignChargeToDeposit:n}};function Ne({depositId:e,chargeId:a,refetch:n}){const[r,h]=l.useState(!1),[o,c]=l.useState(void 0),[{data:u}]=$({query:z,pause:!r}),{assigning:g,assignChargeToDeposit:d}=Se(),f=l.useMemo(()=>(u?.allDeposits??[]).filter(s=>s.isOpen&&s.id!==e),[u?.allDeposits,e]),m=l.useCallback(async()=>{o&&(await d({chargeId:a,depositId:o}),h(!1),c(void 0),n?.())},[d,o,n,a]);return l.useEffect(()=>{r&&c(void 0)},[r]),t.jsxs(V,{open:r,onOpenChange:h,children:[t.jsx(_,{children:t.jsx(p,{variant:"ghost",size:"sm",children:"Reassign"})}),t.jsxs(G,{children:[t.jsx(P,{children:t.jsx(Q,{children:"Reassign Transaction"})}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(W,{htmlFor:"target-deposit-select",children:"Target Deposit"}),t.jsxs(J,{value:o,onValueChange:s=>c(s),children:[t.jsx(Y,{className:"min-w-[220px]",children:t.jsx(X,{id:"target-deposit-select",placeholder:f.length?"Select deposit":"No open deposits"})}),t.jsx(Z,{children:f.map(s=>t.jsxs(ee,{value:s.id,children:[s.id," (",s.currency,")"]},s.id))})]})]})}),t.jsx(te,{children:t.jsx(p,{variant:"secondary",disabled:!o||g,onClick:m,children:g?"Reassigning…":"Reassign"})})]})]})}function be(e,a){const{getId:n,getChargeId:r,getAmount:h}=a,o=new Map;for(const u of e){const g=r(u);if(!g)continue;const d=o.get(g)??[];d.push(u),o.has(g)||o.set(g,d)}const c=new Set;for(const[,u]of o)if(u.length>1){const g=[...u].sort((d,f)=>Math.abs(h(f))-Math.abs(h(d)));for(let d=1;d<g.length;d++)c.add(n(g[d]))}return c}const Te={[x.Eur]:"eur",[x.Gbp]:"gbp",[x.Cad]:"cad",[x.Jpy]:"jpy",[x.Aud]:"aud",[x.Sek]:"sek",[x.Usd]:"usd"};function ke({depositId:e,enableReassign:a=!1,refetch:n}){const{userContext:r}=l.useContext(se),[h,o]=l.useState([{id:"date",desc:!1}]),[{data:c,fetching:u}]=$({query:ae,variables:{depositId:e}}),g=l.useMemo(()=>{if(!c?.deposit?.transactions)return[];const m=c.deposit.transactions.map(i=>ne(re,i)),s=be(m,{getId:i=>i.id,getChargeId:i=>i.chargeId,getAmount:i=>Number(i.amount.raw??0)}),S=[...m].sort((i,C)=>{const v=i.eventDate?new Date(i.eventDate).getTime():0,I=C.eventDate?new Date(C.eventDate).getTime():0;return v-I});let w=0,j=0,M=0;return S.map(i=>{let C=null;const v=Te[i.amount.currency];v&&(C=i.debitExchangeRates?.[v]??i.eventExchangeRates?.[v]??null);const I=Number(i.amount.raw),k=I*(C??1),O=r?.context.defaultLocalCurrency??x.Ils,B=s.has(i.id);return B?j+=I:(w+=I,M+=k),{...i,cumulativeBalance:w,localCumulativeBalance:M,localAmount:k,localCurrency:O,totalInterest:j,isInterest:B}})},[c?.deposit,r]),d=l.useMemo(()=>{const m=r?.context.defaultLocalCurrency??x.Ils,S=!!c?.deposit?.currency&&c.deposit.currency===m?L.filter(j=>j.id!=="amount"&&j.id!=="cumulativeBalance"):L,w=a?[{id:"actions",header:"Actions",cell:({row:j})=>t.jsx(Ne,{depositId:e,chargeId:j.original.chargeId,refetch:n})}]:[];return[...S,...w]},[a,e,n,c?.deposit?.currency,r?.context.defaultLocalCurrency]),f=oe({data:g,columns:d,getCoreRowModel:ie(),onSortingChange:o,getSortedRowModel:ce(),state:{sorting:h}});return u?t.jsx("div",{className:"flex h-64 w-full items-center justify-center",children:t.jsx(le,{className:"size-10 animate-spin"})}):t.jsxs(de,{children:[t.jsx(ue,{children:f.getHeaderGroups().map(m=>t.jsx(T,{children:m.headers.map(s=>t.jsx(ge,{colSpan:s.colSpan,children:s.isPlaceholder?null:A(s.column.columnDef.header,s.getContext())},s.id))},m.id))}),t.jsx(me,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(m=>t.jsx(T,{children:m.getVisibleCells().map(s=>t.jsx(F,{children:A(s.column.columnDef.cell,s.getContext())},s.id))},m.id)):t.jsx(T,{children:t.jsx(F,{colSpan:d.length,className:"h-24 text-center",children:"No transactions in this deposit."})})})]})}export{ke as D,Se as u};
@@ -1 +0,0 @@
1
- import{r as b,bD as _,j as e,D as z,aL as G,B as g,x as Q,al as W,am as K,a3 as D,b5 as X,aO as R,ao as A,ap as O,aq as k,ar as E,as as T,d7 as J,H as j,br as w,gm as I,gn as Z,go as S,gp as ee,gq as L,gr as M,gs as B,gt as N,gu as p,gv as P,gw as q,dD as se,gk as re,bl as te,bm as ae,bn as v,gx as H,F as le,u as de,K as ne,N as oe,X as ce,gy as ie}from"./index-DRqooPz9.js";import{F as V}from"./funnel-B1ZA9LM9.js";import{B as me}from"./building-2-CWrl-iq9.js";import{E as ue}from"./eye-off-DtXkBVx1.js";import{S as xe}from"./save-BaXyzRSW.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}=_(),h=b.useMemo(()=>t?a.find(f=>f.value===t)?.label??"":"",[a,t]);return e.jsxs(z,{open:n,onOpenChange:r,children:[e.jsx(G,{asChild:!0,children:e.jsxs(g,{variant:"outline",className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4"}),"מסננים",e.jsxs("span",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-0.5 rounded-full",children:[h," • ",s]})]})}),e.jsxs(Q,{className:"sm:max-w-md",dir:"rtl",children:[e.jsx(W,{children:e.jsxs(K,{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-5 w-5"}),"מסנני דוח"]})}),e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"business-select",className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4"}),"בחירת עסק"]}),e.jsx(X,{onChange:x=>d(x??void 0),data:a,value:t,disabled:i,placeholder:"Scroll to see all options",triggerProps:{className:"w-full"}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת דיווח"]}),e.jsxs(A,{value:s,onValueChange:c,children:[e.jsx(O,{id:"year-select",children:e.jsx(k,{})}),e.jsx(E,{children:C.map(x=>e.jsx(T,{value:x,children:x},x))})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{htmlFor:"reference-year-select",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),"שנת השוואה"]}),e.jsxs(A,{value:l,onValueChange:x=>o(x==="none"?void 0:x),children:[e.jsx(O,{id:"reference-year-select",children:e.jsx(k,{})}),e.jsxs(E,{children:[e.jsx(T,{value:"none",children:"ללא"},"none"),C.map(x=>e.jsx(T,{value:x,children:x},x))]})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["זמינות נתונים: ",C.join(", ")]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(g,{variant:"outline",onClick:()=>r(!1),children:"ביטול"}),e.jsx(g,{onClick:()=>r(!1),children:"אישור"})]})]})]})]})}const m=({label:t,value:d,code:s,referenceValue:c,showEmptyFields:l,showChange:o=!1})=>{const n=h=>l?!0:!r(h),r=h=>!h||h.trim()===""||h==="0"||h==="0.00",a=(h,x)=>{if(!x)return null;const f=U=>Number.parseFloat(U.replace(/[,\s₪]/g,""))||0,$=f(h),F=f(x);return F===0?null:($-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:J(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 L.Shekels:return"שקלים";case L.Dollars:return"דולרים";default:return""}},Se=t=>{switch(t){case M.DoubleEntry:return"כפולה";case M.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""}},De=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 Te({data:t,businessInfo:d}){const{header:s}=j(Z,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:De(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]}],Y={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(q,t),o=j(q,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}=Y[n.color]||Y.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(H,t),n=j(H,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(Te,{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 Ye(){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(Le,{fetching:a,data:r,selectedBusiness:d,selectedYear:c,referenceYear:o})})]})})}function Le({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{Ye as Shaam6111Report};
@@ -1 +0,0 @@
1
- import{j as e,Z as C,_ as p,$ as S,a0 as y,b7 as w,a2 as b,I as L,g as F,ik as H,r as u,t as m,i as E,D as R,aL as M,B as x,ag as _,x as T,al as A,am as $,u as P,il as z,L as O,E as q,W as K,aa as Q,im as V,F as W,bY as Y,bO as Z,bP as G,bQ as I,bR as J,c2 as v,bS as X,bT as g,io as ee,c5 as se,c4 as te,c6 as oe}from"./index-DRqooPz9.js";import{D as re}from"./data-table-pagination-DxOcd13P.js";import{P as ne}from"./page-layout-Dp9Tr43G.js";import{A as k}from"./arrow-up-down-MrfN0fhR.js";function U({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]=F(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(T,{className:"w-[400px] max-w-screen-md",children:[e.jsx(A,{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:z,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,...B})=>{const h=Q(B,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(U,{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]=F(V),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(T,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(A,{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(U,{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 D=[{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(k,{})]})},{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(k,{})]})},{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(W),r=u.useMemo(()=>s?.allSortCodes?.map(l=>({...l,refetchSortCodes:t}))??[],[s?.allSortCodes,t]),a=Y({data:r,columns:D,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(X,{children:a.getRowModel().rows.length===0?e.jsx(I,{children:e.jsx(g,{colSpan:D.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 +0,0 @@
1
- import{r as a,u as y,dy as P,aJ as b,H as C,aK as S,j as e,D as O,aL as q,B as M,a4 as V,x as z,al as H,am as U,ao as J,ap as K,aq as Q,ar as W,as as X,w as I,dz as F,E as $,dA as Y,J as _,bK as G,W as Z,a3 as ee,bN as se,bO as te,bP as ae,bQ as E,bR as h,bS as ne,bT as x,ah as le,R as w,bU as re,bV as ce,a5 as oe,bW as ie,bX as ue,F as de,c as me}from"./index-DRqooPz9.js";import{u as he,a as xe}from"./use-issue-monthly-documents-Dx6_0gyN.js";import{s as A}from"./subMonths-CZ2djAnO.js";function fe({issueMonth:u,clients:r,onAdd:c}){const[j,o]=a.useState(!1),[f,d]=a.useState(""),[{data:m},n]=y({query:P,variables:{issueMonth:u,clientId:f},pause:!j}),p=a.useCallback(l=>{d(l),n()},[n,d]);return a.useEffect(()=>{f!==""&&m&&(c(b(C(S,m.clientMonthlyChargeDraft))),o(!1))},[f,m,c]),e.jsxs(O,{open:j,onOpenChange:o,children:[e.jsx(q,{asChild:!0,children:e.jsx(M,{variant:"outline",size:"icon",children:e.jsx(V,{})})}),e.jsxs(z,{className:"w-[400px] max-w-screen-md",children:[e.jsx(H,{children:e.jsx(U,{children:"Select document recipient"})}),e.jsxs(J,{onValueChange:p,children:[e.jsx(K,{children:e.jsx(Q,{placeholder:"Recipient"})}),e.jsx(W,{children:r.map(l=>e.jsx(X,{value:l.id,children:l.name},l.id))})]})]})]})}const je=({drafts:u})=>{const[r,c]=a.useState(u.map(s=>b(C(S,s)))),j=I(A(new Date,1),"yyyy-MM-dd"),[o,f]=a.useState(j),[{data:d},m]=y({query:F,variables:{issueMonth:o},pause:!0});a.useEffect(()=>{d?.periodicalDocumentDrafts&&c(d.periodicalDocumentDrafts.map(s=>b(C(S,s))))},[d,c]),a.useEffect(()=>{m()},[o,m]);const n=$({values:{generateDocumentsInfo:r}}),{issueDocuments:p}=he(),[{data:l}]=y({query:Y}),{fields:v,append:k,remove:B,update:R}=_({control:n.control,name:"generateDocumentsInfo"}),T=n.watch("generateDocumentsInfo"),D=a.useMemo(()=>v.map((s,t)=>({...s,...T[t],id:s.client?.id})),[v,T]),N=a.useCallback(s=>{p(s)},[p]),L=a.useMemo(()=>l?.allOpenContracts.filter(s=>s.billingCycle===G.Monthly&&!D.some(t=>t.client?.id===s.client.id)),[D,l]);return e.jsx("div",{className:"p-2",children:e.jsx(Z,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(N),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(ee,{children:"Issue Month:"}),e.jsx(se,{value:new Date(o),onChange:s=>{const t=new Date(s.getFullYear(),s.getMonth(),15);f(I(t,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(te,{children:[e.jsx(ae,{children:e.jsxs(E,{children:[e.jsx(h,{children:"Name"}),e.jsx(h,{children:"Document"}),e.jsx(h,{children:"Amount"}),e.jsx(h,{children:"Remark"}),e.jsx(h,{children:"Recipients"}),e.jsx(h,{})]})}),e.jsx(ne,{children:D.map(({id:s,...t},g)=>e.jsxs(E,{children:[e.jsx(x,{children:e.jsx(le,{to:s?w.BUSINESSES.DETAIL(s):w.BUSINESSES.ALL,target:"_blank",rel:"noreferrer",onClick:i=>i.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.client?.name})}),e.jsx(x,{children:t.type}),e.jsxs(x,{children:[t.income?.[0]?.price," ",t.income?.[0]?.currency]}),e.jsx(x,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:t.remarks})}),e.jsx(x,{children:e.jsx("div",{className:"flex flex-col",children:t.client?.emails?.map(i=>e.jsx("span",{className:"text-sm text-gray-500",children:i},i))})}),e.jsx(x,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(re,{children:[e.jsx(ce,{asChild:!0,type:"button",children:e.jsx(M,{className:"size-7.5",variant:"secondary",onClick:()=>B(g),children:e.jsx(oe,{size:16})})}),e.jsx(ie,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(xe,{draft:t,onApprove:i=>{n.setValue(`generateDocumentsInfo.${g}`,i,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),R(g,{...i})}})]})})]},s))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(fe,{clients:L?.map(s=>({id:s.client.originalBusiness.id,name:s.client.originalBusiness.name}))??[],onAdd:k,issueMonth:o}),e.jsx(ue,{onConfirm:n.handleSubmit(N),title:`Are you sure you want to issue ${D.length} documents?`,children:e.jsx(M,{children:"Issue"})})]})]})})})},ge=()=>{const{setFiltersContext:u}=a.useContext(de),[{data:r,fetching:c}]=y({query:F,variables:{issueMonth:I(A(new Date,1),"yyyy-MM-dd")}});return a.useEffect(()=>{r?.periodicalDocumentDrafts||u(null)},[r,u]),c?e.jsx(me,{}):e.jsx(je,{drafts:r?.periodicalDocumentDrafts??[]})};export{ge as IssueDocuments};
@@ -1 +0,0 @@
1
- import{v as _,r as o,j as e,K as I,H as r,B as w,e9 as je,aP as T,ay as V,ea as fe,eb as q,ec as u,ah as G,R as Q,d7 as L,ed as be,bY as Y,ee as Z,c5 as J,c6 as K,bp as W,bO as X,bP as ee,bQ as S,bR as te,c2 as E,b$ as se,dI as ae,bS as ne,bT as D,dw as re,ef as N,eg as Ne,eh as we,ei as ye,u as oe,t as ve,ej as Se,T as Ce,ek as Ae,el as Te,aC as le,bB as Ve,E as De,em as Ie,bE as U,bH as $,en as B,bN as Re,w as P,bI as Me,F as Ee,L as Fe,eo as ze}from"./index-DRqooPz9.js";import{d as ce}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{u as ie}from"./use-url-query-A8PE3FMA.js";import{C as O,a as de,b as me,M as ke}from"./charges-table-zGkVW5or.js";import{P as Le}from"./page-layout-Dp9Tr43G.js";import{P as R,a as M}from"./panel-top-open-lnF5tdL1.js";import{C as ue}from"./index-ciP7vurq.js";import{T as xe}from"./toggle-expansion-button-BquTpOYj.js";import{U as Be}from"./update-accountant-status-Btcm95Uc.js";import{c as Pe}from"./charges-filters-CYR6-jcu.js";import{P as Oe}from"./modal-CPrQ9jQu.js";import{F as He}from"./funnel-B1ZA9LM9.js";import"./Table-rNmO5bBI.js";import"./summary-BvHHpnIR.js";import"./accordion-Air1oXnF.js";import"./deposits-transactions-table-Dhm74qLm.js";import"./Checkbox-DWmOT4mx.js";import"./data-table-column-header-DDRUwuwC.js";import"./eye-off-DtXkBVx1.js";import"./similar-transactions-modal-DilkLkpx.js";import"./building-2-CWrl-iq9.js";import"./addDays-DpkzPtfc.js";import"./sub-764RJPt0.js";import"./subMonths-CZ2djAnO.js";import"./MultiSelect-DhEZHYxn.js";const Ue=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],pe=_("chart-column",Ue);const $e=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],_e=_("file-digit",$e),qe=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(je,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.businessTrips.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Business Trips"]})}),c&&a&&e.jsx(O,{data:a.businessTrips,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})};function H(t){switch(t){case"C":case"M":return"Self Invoice";case"H":return"Single Doc By Law";case"I":return"Palestinian Customer";case"K":return"Petty Cash";case"L1":return"Unidentified Customer";case"L2":return"Unidentified Zero or Exempt";case"P":return"Palestinian Supplier";case"R":return"Import";case"S1":case"T":return"Regular";case"S2":return"Zero or Exempt";case"Y":return"Export";default:return"Unknown"}}const Ge=t=>{const s=t.reduce((n,a)=>(n[a.recordType]||={recordType:a.recordType,count:0,vatTotal:0,totalBeforeVat:0},n[a.recordType].count++,n[a.recordType].vatTotal+=a.roundedLocalVatAfterDeduction?.raw??0,n[a.recordType].totalBeforeVat+=a.taxReducedLocalAmount?.raw??0,n),{});return Object.values(s)},he=({records:t})=>{const s=o.useMemo(()=>Ge(t??[]),[t]);return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left",children:[e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground",children:"Record Type"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"Count"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"Total Before VAT"}),e.jsx("th",{className:"pb-3 text-sm font-medium text-muted-foreground text-right",children:"VAT Total"})]})}),e.jsx("tbody",{children:s.map(n=>e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsxs("td",{className:"py-3 text-sm font-medium",children:[H(n.recordType)," (",n.recordType,")"]}),e.jsx("td",{className:"py-3 text-sm text-right",children:n.count}),e.jsx("td",{className:"py-3 text-sm text-right",children:T(n.totalBeforeVat,V.Ils)}),e.jsx("td",{className:"py-3 text-sm text-right",children:T(n.vatTotal,V.Ils)})]},n.recordType))})]})})};function ge({data:t}){const{chargeId:s,chargeAccountantStatus:n}=r(fe,t);return e.jsx("td",{children:e.jsx(Be,{value:n??void 0,chargeId:s})})}const b=q(),z=[b.accessor(t=>r(u,t.data).recordType,{id:"recordType",header:"Record Type",cell:t=>{const s=t.getValue();return e.jsx("p",{className:"whitespace-wrap",children:`${H(s)} (${s})`})}}),b.accessor(t=>r(u,t.data).business?.name??"",{id:"business",header:"Business",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-1",children:[s.business?.id?e.jsx(G,{to:Q.BUSINESSES.DETAIL(s.business.id),target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:s.business.name}):e.jsx("span",{children:s.business?.name}),s.vatNumber&&e.jsx("span",{className:"text-[10px] text-gray-500",children:s.vatNumber})]})}}),b.display({id:"invoice",header:"Invoice",cell:t=>{const s=r(u,t.row.original.data);return s.image?e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})}):null}}),b.accessor(t=>r(u,t.data).documentSerial??"",{id:"documentSerial",header:"Invoice Serial#",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.getValue()}),s.allocationNumber&&e.jsxs("span",{className:"text-xs",children:["(",s.allocationNumber,")"]})]})}}),b.accessor(t=>r(u,t.data).documentDate??"",{id:"documentDate",header:"Invoice Date",cell:t=>t.getValue()}),b.accessor(t=>r(u,t.data).chargeDate??"",{id:"chargeDate",header:"Transaction Date",cell:t=>t.getValue()}),b.accessor(t=>r(u,t.data).amount.raw??0,{id:"amount",header:"Amount",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.amount.formatted})}}),b.accessor(t=>r(u,t.data).localAmount?.raw??0,{id:"localAmount",header:"Amount ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localAmount?.formatted})}}),b.accessor(t=>r(u,t.data).localVat?.raw??0,{id:"localVat",header:"VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localVat?.formatted})}}),b.accessor(t=>r(u,t.data).localVatAfterDeduction?.raw??0,{id:"localVatAfterDeduction",header:"VAT ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.localVatAfterDeduction?.formatted})}}),b.accessor(t=>r(u,t.data).foreignVatAfterDeduction?.raw??0,{id:"foreignVatAfterDeduction",header:"Actual VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.foreignVatAfterDeduction?.formatted})}}),b.accessor(t=>r(u,t.data).roundedLocalVatAfterDeduction?.raw??0,{id:"roundedLocalVatAfterDeduction",header:"Rounded VAT",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.roundedLocalVatAfterDeduction?.formatted})}}),b.accessor(t=>t.cumulativeVat,{id:"cumulativeVat",header:"Cumulative VAT",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),b.accessor(t=>r(u,t.data).taxReducedLocalAmount?.raw??0,{id:"taxReducedLocalAmount",header:"Amount without VAT ₪",cell:t=>{const s=r(u,t.row.original.data);return e.jsx("span",{className:"whitespace-nowrap",children:s.taxReducedLocalAmount?.formatted})}}),b.accessor(t=>t.cumulativeAmount,{id:"cumulativeAmount",header:"Cumulative Amount without VAT ₪",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),b.display({id:"accountantApproval",header:"Accountant Approval",cell:t=>{const s=r(u,t.row.original.data);return e.jsx(ge,{data:s})}}),b.display({id:"actions",header:"Edit",cell:t=>{const s=r(u,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(xe,{toggleExpansion:()=>t.row.toggleExpanded(),isExpanded:t.row.getIsExpanded()}),e.jsx(de,{toggleMergeSelected:()=>t.row.original.toggleMergeCharge(s.chargeId),mergeSelected:t.row.original.mergeSelectedCharges.has(s.chargeId)}),e.jsx(ue,{chargeId:s.chargeId})]})}})],Qe=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const{expenses:a}=r(be,t)??{expenses:[]},[c,l]=o.useState(!0),[p,x]=o.useState([]),[j,i]=o.useState({}),[f,h]=o.useState({}),[g,C]=o.useState("detailed"),F=o.useMemo(()=>{let d=0,m=0;return a.map(y=>(d+=y.taxReducedLocalAmount?.raw??0,m+=y.roundedLocalVatAfterDeduction?.raw??0,{data:y,toggleMergeCharge:s,mergeSelectedCharges:n,cumulativeVat:m,cumulativeAmount:d}))},[a,s,n]),A=Y({data:F,columns:z,getCoreRowModel:K(),onSortingChange:x,getSortedRowModel:J(),onColumnVisibilityChange:i,onExpandedChange:h,getExpandedRowModel:Z(),state:{sorting:p,columnVisibility:j,expanded:f}});return e.jsxs(I,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(d=>!d),children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Expenses"]}),c&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:g==="detailed"?"default":"outline",size:"sm",onClick:()=>C("detailed"),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Detailed"]}),e.jsxs(w,{variant:g==="summarized"?"default":"outline",size:"sm",onClick:()=>C("summarized"),children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Summarized"]})]})]}),c&&(g==="detailed"?e.jsxs(X,{children:[e.jsx(ee,{children:A.getHeaderGroups().map(d=>e.jsx(S,{children:d.headers.map(m=>e.jsx(te,{colSpan:m.colSpan,children:m.isPlaceholder?null:e.jsxs(w,{variant:"ghost",onClick:m.column.getToggleSortingHandler(),className:"h-auto p-0 hover:bg-transparent",children:[E(m.column.columnDef.header,m.getContext()),{asc:e.jsx(ae,{className:"size-5"}),desc:e.jsx(se,{className:"size-5"})}[m.column.getIsSorted()]??null]})},m.id))},d.id))}),e.jsx(ne,{children:A.getRowModel().rows?.length?A.getRowModel().rows.map(d=>{const m=r(u,d.original.data);return e.jsxs(o.Fragment,{children:[e.jsx(S,{"data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(y=>e.jsx(D,{children:E(y.column.columnDef.cell,y.getContext())},y.id))}),d.getIsExpanded()&&e.jsx(S,{children:e.jsx(D,{colSpan:z.length,children:e.jsx(re,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(me,{chargeID:m.chargeId,fetching:!!m})})})})]},d.id)}):e.jsx(S,{children:e.jsx(D,{colSpan:z.length,className:"h-24 text-center",children:"No results."})})})]}):e.jsx(he,{records:a}))]})},v=q(),k=[v.accessor(t=>r(N,t.data).recordType,{id:"recordType",header:"Record Type",cell:t=>{const s=t.getValue();return e.jsx("p",{className:"whitespace-wrap",children:`${H(s)} (${s})`})}}),v.accessor(t=>r(N,t.data).business?.name??"",{id:"business",header:"Business",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-1",children:[s.business?.id?e.jsx(G,{to:Q.BUSINESSES.DETAIL(s.business.id),target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:s.business.name}):e.jsx("span",{children:s.business?.name}),s.vatNumber&&e.jsx("span",{className:"text-[10px] text-gray-500",children:s.vatNumber})]})}}),v.display({id:"invoice",header:"Invoice",cell:t=>{const s=r(N,t.row.original.data);return s.image?e.jsx("a",{href:s.image,target:"_blank",rel:"noreferrer",children:e.jsx("img",{alt:"missing img",src:s.image,height:80,width:80})}):null}}),v.accessor(t=>r(N,t.data).documentSerial??"",{id:"documentSerial",header:"Invoice Serial#",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:t.getValue()}),s.allocationNumber&&e.jsxs("span",{className:"text-xs",children:["(",s.allocationNumber,")"]})]})}}),v.accessor(t=>r(N,t.data).documentDate??"",{id:"documentDate",header:"Invoice Date",cell:t=>t.getValue()}),v.accessor(t=>r(N,t.data).chargeDate??"",{id:"chargeDate",header:"Transaction Date",cell:t=>t.getValue()}),v.accessor(t=>r(N,t.data).taxReducedForeignAmount?.raw??0,{id:"amount",header:"Amount",cell:t=>r(N,t.row.original.data).taxReducedForeignAmount?.formatted??""}),v.accessor(t=>r(N,t.data).taxReducedLocalAmount?.raw??0,{id:"localAmount",header:"Amount ₪",cell:t=>r(N,t.row.original.data).taxReducedLocalAmount?.formatted??""}),v.accessor(t=>t.cumulativeAmount,{id:"cumulativeAmount",header:"Cumulative Amount ₪",cell:t=>e.jsxs("span",{className:"whitespace-nowrap",children:["₪ ",L(t.getValue(),0)]})}),v.display({id:"accountantApproval",header:"Accountant Approval",cell:t=>{const s=r(N,t.row.original.data);return e.jsx(ge,{data:s})}}),v.display({id:"actions",header:"Edit",cell:t=>{const s=r(N,t.row.original.data);return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(xe,{toggleExpansion:()=>t.row.toggleExpanded(),isExpanded:t.row.getIsExpanded()}),e.jsx(de,{toggleMergeSelected:()=>t.row.original.toggleMergeCharge(s.chargeId),mergeSelected:t.row.original.mergeSelectedCharges.has(s.chargeId)}),e.jsx(ue,{chargeId:s.chargeId})]})}})],Ye=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const{income:a}=r(Ne,t)??{income:[]},[c,l]=o.useState(!0),[p,x]=o.useState([]),[j,i]=o.useState({}),[f,h]=o.useState({}),[g,C]=o.useState("detailed"),F=o.useMemo(()=>{let d=0;return a.map(m=>(d+=m.taxReducedLocalAmount?.raw??0,{data:m,toggleMergeCharge:s,mergeSelectedCharges:n,cumulativeAmount:d}))},[a,s,n]),A=Y({data:F,columns:k,getCoreRowModel:K(),onSortingChange:x,getSortedRowModel:J(),onColumnVisibilityChange:i,onExpandedChange:h,getExpandedRowModel:Z(),state:{sorting:p,columnVisibility:j,expanded:f}});return e.jsxs(I,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(d=>!d),children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Income"]}),c&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(w,{variant:g==="detailed"?"default":"outline",size:"sm",onClick:()=>C("detailed"),children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Detailed"]}),e.jsxs(w,{variant:g==="summarized"?"default":"outline",size:"sm",onClick:()=>C("summarized"),children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Summarized"]})]})]}),c&&(g==="detailed"?e.jsxs(X,{children:[e.jsx(ee,{children:A.getHeaderGroups().map(d=>e.jsx(S,{children:d.headers.map(m=>e.jsx(te,{colSpan:m.colSpan,children:m.isPlaceholder?null:e.jsxs(w,{variant:"ghost",onClick:m.column.getToggleSortingHandler(),className:"h-auto p-0 hover:bg-transparent",children:[E(m.column.columnDef.header,m.getContext()),{asc:e.jsx(ae,{className:"size-5"}),desc:e.jsx(se,{className:"size-5"})}[m.column.getIsSorted()]??null]})},m.id))},d.id))}),e.jsx(ne,{children:A.getRowModel().rows?.length?A.getRowModel().rows.map(d=>{const m=r(N,d.original.data);return e.jsxs(o.Fragment,{children:[e.jsx(S,{"data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(y=>e.jsx(D,{children:E(y.column.columnDef.cell,y.getContext())},y.id))}),d.getIsExpanded()&&e.jsx(S,{children:e.jsx(D,{colSpan:k.length,children:e.jsx(re,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:e.jsx(me,{chargeID:m.chargeId,fetching:!!m})})})})]},d.id)}):e.jsx(S,{children:e.jsx(D,{colSpan:k.length,className:"h-24 text-center",children:"No results."})})})]}):e.jsx(he,{records:a}))]})},Ze=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(we,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.differentMonthDoc.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Misc Charges (which are not on the above tables)"]})}),c&&a&&e.jsx(O,{data:a.differentMonthDoc,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})},Je=({data:t,toggleMergeCharge:s,mergeSelectedCharges:n})=>{const a=r(ye,t),[c,l]=o.useState(!0);return e.jsxs(I,{className:"p-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(p=>!p),disabled:!a||a.missingInfo.length===0,children:c?e.jsx(R,{className:"size-5"}):e.jsx(M,{className:"size-5"})}),"Missing Info"]})}),c&&a&&e.jsx(O,{data:a.missingInfo,isAllOpened:!1,toggleMergeCharge:s,mergeSelectedCharges:n})]})},Ke=({filter:{monthDate:t,financialEntityId:s},isLoading:n})=>{const[{data:a,fetching:c,error:l},p]=oe({query:ce(Ae),pause:!0,variables:{monthDate:t,financialEntityId:s}});return o.useEffect(()=>{if(l){const x="Error generating PCN874 file";console.error(`${x}: ${l}`),ve.error("Error",{description:x,duration:5e3,closeButton:!0})}},[l]),o.useEffect(()=>{if(a){const x=new File([a.pcnFile.reportContent],"pcn874.txt",{type:"text/plain"});Se(x)}},[a]),e.jsx(Ce,{content:"Generate and Download PCN874 File",children:e.jsx(w,{disabled:c||n,variant:"outline",size:"icon",className:"size-7.5",onClick:p,children:e.jsx(_e,{className:"size-5"})})})},We=({data:t})=>{const s=r(Te,t),n=o.useMemo(()=>s?.expenses??[],[s?.expenses]),a=o.useMemo(()=>s?.income??[],[s?.income]),c=o.useMemo(()=>a.reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[a]),l=o.useMemo(()=>a.reduce((i,f)=>i+(f.roundedLocalVatAfterDeduction?.raw??0),0),[a]),p=o.useMemo(()=>a.filter(i=>(i.roundedLocalVatAfterDeduction?.raw??0)===0).reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[a]),x=o.useMemo(()=>n.filter(i=>i.isProperty).reduce((i,f)=>i+(f.taxReducedLocalAmount?.raw??0),0),[n]),j=o.useMemo(()=>l-n.reduce((i,f)=>i+(f.roundedLocalVatAfterDeduction?.raw??0),0),[l,n]);return e.jsxs(I,{className:"p-6",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:"Report Summary"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Taxable Sales Total"}),e.jsx("p",{className:"text-2xl font-bold",children:T(c,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Taxable Sales VAT"}),e.jsx("p",{className:"text-2xl font-bold",children:T(l,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Zero / Exempt Sales"}),e.jsx("p",{className:"text-2xl font-bold",children:T(p,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Equipment Inputs"}),e.jsx("p",{className:"text-2xl font-bold",children:T(x,V.Ils)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total VAT Amount"}),e.jsx("p",{className:"text-2xl font-bold",children:T(j,V.Ils)})]})]})]})};function Xe({filter:t,setFilter:s,closeModal:n}){const{control:a,handleSubmit:c,setValue:l}=De({defaultValues:{...t}}),{selectableAdminBusinesses:p,fetching:x}=Ie(),j=h=>{s(h),n()};function i(){s(),n()}function f(h){const g=new Date(h.getFullYear(),h.getMonth(),15);l("monthDate",P(g,"yyyy-MM-dd"))}return e.jsxs(e.Fragment,{children:[x?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:c(j),children:[e.jsx(U,{name:"financialEntityId",control:a,defaultValue:void 0,render:({field:h,fieldState:g})=>e.jsx($,{...h,data:p,value:h.value,disabled:x,label:"Report Issuer (Admin Business)",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:g.error?.message})}),e.jsx(U,{name:"chargesType",control:a,defaultValue:t.chargesType,render:({field:h,fieldState:g})=>e.jsx($,{...h,data:Pe,value:h.value??B.All,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:g.error?.message})}),e.jsx(Re,{defaultValue:t?.monthDate?new Date(t.monthDate):new Date,defaultDate:t?.monthDate?new Date(t.monthDate):new Date,onChange:f,popoverProps:{withinPortal:!0}}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:i,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:n,children:"Cancel"})]})]})]})}function et({filter:t,setFilter:s}){const[n,a]=o.useState(!1),{get:c,set:l}=ie(),{userContext:p}=o.useContext(le);function x(j){j||={financialEntityId:p?.context.adminBusinessId??t.financialEntityId,monthDate:P(new Date,"yyyy-MM-15")},Me(j,t)||s(j)}return o.useEffect(()=>{const j=Ve(t??{})?null:encodeURIComponent(JSON.stringify(t)),i=c("vatMonthlyReportFilters");j!==i&&l("vatMonthlyReportFilters",j)},[t,c,l]),e.jsxs(e.Fragment,{children:[e.jsx(Oe,{opened:n,onClose:()=>a(!1),content:e.jsx(Xe,{filter:t,setFilter:x,closeModal:()=>a(!1)})}),e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>a(!0),children:e.jsx(He,{className:"size-5"})})]})}const At=()=>{const{get:t}=ie(),{setFiltersContext:s}=o.useContext(Ee),{userContext:n}=o.useContext(le),[a,c]=o.useState(t("vatMonthlyReportFilters")?JSON.parse(decodeURIComponent(t("vatMonthlyReportFilters"))):{financialEntityId:n?.context.adminBusinessId??"",monthDate:P(new Date,"yyyy-MM-15")}),[l,p]=o.useState([]);o.useEffect(()=>{(!a.financialEntityId||a.financialEntityId==="")&&n?.context.adminBusinessId&&c({...a,financialEntityId:n.context.adminBusinessId})},[a,n?.context.adminBusinessId]);const[{data:x,fetching:j}]=oe({query:ce(ze),variables:{filters:a},pause:a.financialEntityId===""}),i=o.useCallback(g=>{l.includes(g)?p(l.filter(C=>C!==g)):p([...l,g])},[l]);function f(){p([])}o.useEffect(()=>{s(e.jsxs("div",{className:"flex flex-row gap-2",children:[e.jsx(Ke,{filter:a,isLoading:j}),e.jsx(et,{filter:{...a},setFilter:c}),e.jsx(ke,{selected:l.map(g=>({id:g,onChange:()=>{}})),resetMerge:f})]}))},[x,a,j,s,l]);const h=o.useMemo(()=>new Set(l),[l]);return e.jsx(Le,{title:"VAT Monthly Report",children:j?e.jsx(Fe,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx("div",{className:"min-h-screen",children:e.jsxs("div",{className:"space-y-4",children:[a.financialEntityId&&a.monthDate&&e.jsx(We,{data:x?.vatReport}),a.chargesType!==B.Expense&&e.jsx(Ye,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),a.chargesType!==B.Income&&e.jsx(Qe,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(Je,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(qe,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h}),e.jsx(Ze,{data:x?.vatReport,toggleMergeCharge:i,mergeSelectedCharges:h})]})})})};export{At as VatMonthlyReport};
@@ -1 +0,0 @@
1
- import{g as v,ig as L,r as g,t as m,i as F,b3 as U,j as e,Z as C,_ as j,$ as f,a0 as p,I as B,a1 as y,a2 as b,bE as V,bH as _,b7 as z,at as K,D as E,aL as D,B as h,x as M,al as R,am as A,E as O,W as P,ih as Q,ag as G,u as $,ii as W,L as k,F as Y,bY as Z,bO as J,bP as X,bQ as T,bR as ee,c2 as S,bS as se,bT as w,ij as te,c5 as ae,c4 as re,c6 as oe}from"./index-DRqooPz9.js";import{D as ne}from"./data-table-pagination-DxOcd13P.js";import{P as ie}from"./page-layout-Dp9Tr43G.js";import{A as N}from"./arrow-up-down-MrfN0fhR.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(L),t=g.useCallback(async a=>{const d="Error creating tax category",r=de;m.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return m.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function q({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=U();g.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return g.useEffect(()=>{if(c){const o=x.find(u=>u.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:u})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(B,{...o,value:o.value??void 0,required:!0,className:t?"":y(u)})}),e.jsx(b,{})]})}),e.jsx(V,{name:"sortCode",control:a,render:({field:o,fieldState:u})=>e.jsx(_,{...o,onChange:H=>{o.onChange(Number(H))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(u)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:u})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(u),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(b,{})]})}),e.jsx(C,{control:a,name:"taxExcluded",render:({field:o})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{children:"Tax excluded category"})}),e.jsx(p,{children:e.jsx(K,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=g.useState(!1);return e.jsxs(E,{open:n,onOpenChange:t,children:[e.jsx(D,{asChild:!0,children:e.jsx(h,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(R,{children:e.jsx(A,{children:"Add New Tax Category"})}),e.jsx(xe,{close:()=>t(!1),onAdd:s})]})]})}function xe({close:s,onAdd:n}){const t=O({}),{handleSubmit:a}=t,[d,r]=g.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx(P,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ge="updateTaxCategory",ue=()=>{const[{fetching:s},n]=v(Q),t=g.useCallback(async a=>{const d="Error updating tax category",r=`${ge}-${a.taxCategoryId}`;m.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return m.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),m.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function me({taxCategoryId:s,onAdd:n}){const[t,a]=g.useState(!1);return e.jsxs(E,{open:t,onOpenChange:a,children:[e.jsx(D,{asChild:!0,children:e.jsx(h,{variant:"outline",size:"icon",children:e.jsx(G,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(R,{children:e.jsx(A,{children:"Edit Tax Category"})}),e.jsx(he,{taxCategoryId:s,close:()=>a(!1),onAdd:n})]})]})}function he({taxCategoryId:s,close:n,onAdd:t}){const[{data:a,fetching:d}]=$({query:W,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&m.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx(k,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=O({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=g.useState(!1),{updateTaxCategory:l,fetching:x}=ue(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(u=>{u?.id&&(t?.(u.id),n())})};return e.jsx(P,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(h,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),I=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(N,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(h,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(N,{})]})},{id:"edit",cell:({row:s})=>e.jsx(me,{taxCategoryId:s.original.id})}],Se=()=>{const[{data:s,fetching:n,error:t},a]=$({query:te}),{setFiltersContext:d}=g.useContext(Y),r=s?.taxCategories??[],i=Z({data:r,columns:I,getCoreRowModel:oe(),getPaginationRowModel:re(),getSortedRowModel:ae(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return g.useEffect(()=>{d(e.jsx("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(ne,{table:i})})}))},[d,i,l]),g.useEffect(()=>{t&&m.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(ie,{title:`Tax Categories (${r.length})`,description:"All tax categories",headerActions:e.jsx(le,{onAdd:()=>a()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(k,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(J,{children:[e.jsx(X,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(ee,{children:c.isPlaceholder?null:S(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(se,{children:i.getRowModel().rows.length===0?e.jsx(T,{children:e.jsx(w,{colSpan:I.length,className:"text-center py-8",children:"No tax categories found"})}):i.getRowModel().rows.map(x=>e.jsx(T,{children:x.getVisibleCells().map(c=>e.jsx(w,{children:S(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{Se as TaxCategories};
@@ -1 +0,0 @@
1
- import{r,bB as w,bI as A,j as e,bC as K,B as c,aC as U,E as _,w as v,dr as z,W as B,ds as H,bE as D,bF as M,bG as I,Z as L,_ as G,$ as Q,a0 as q,at as J,F as Z,u as W,bY as X,L as Y,dt as $,du as ee,bO as te,bP as se,bQ as S,bR as ae,c2 as T,bS as ne,bT as k,bZ as re,b_ as ie,c0 as le,c1 as oe,dv as ce,c5 as de,c4 as me,c6 as ue}from"./index-DRqooPz9.js";import{u as P}from"./use-url-query-A8PE3FMA.js";import{a as ge}from"./accounter-table-CGncq_73.js";import{D as he}from"./data-table-pagination-DxOcd13P.js";import{P as O}from"./modal-CPrQ9jQu.js";import{P as xe}from"./page-layout-Dp9Tr43G.js";import{F as pe}from"./funnel-B1ZA9LM9.js";import{M as E}from"./MultiSelect-DhEZHYxn.js";import{s as je}from"./sub-764RJPt0.js";import{A as b}from"./arrow-up-down-MrfN0fhR.js";import"./Table-rNmO5bBI.js";import"./addDays-DpkzPtfc.js";import"./subMonths-CZ2djAnO.js";function fe({filter:t,setFilter:s,closeModal:x}){const{userContext:p}=r.useContext(U),h=_({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}=z(),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(E,{...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(E,{...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(G,{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(Q,{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=>{A(m,t)||(s(m),y(!w(m)))},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(O,{opened:p,onClose:()=>h(!1),content:e.jsx(fe,{filter:t,setFilter:C,closeModal:()=>h(!1)}),modalSize:"xl"}),e.jsx(K,{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 R=[{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"}],Re=()=>{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(Z),[{data:j,fetching:F},N]=W({query:ce,variables:{filters:i??{}},pause:!0});r.useEffect(()=>{i&&N()},[i,N]);const f=X({data:j?.documentsByFilters??[],columns:R,getCoreRowModel:ue(),getPaginationRowModel:me(),onSortingChange:m,getSortedRowModel:de(),onColumnVisibilityChange:g,state:{sorting:C,columnVisibility:a}}),V=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,V]),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(Y,{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(O,{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:T(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(k,{children:T(u.column.columnDef.cell,u.getContext())},u.id))},n.id)):e.jsx(S,{children:e.jsx(k,{colSpan:R.length,className:"h-24 text-center",children:"No results."})})})]})]})})};export{Re as DocumentsReport,R as columns};
@@ -1 +0,0 @@
1
- import{j as n,r as x,g9 as g,B as v,H as h,gB as j,a as D,F as R,u as E,L as y,bC as w,dX as C,T as f,gC as T}from"./index-DRqooPz9.js";import{d as A}from"./graphql-document-dedupe-fragments-ByT8-wlV.js";import{P as b}from"./page-layout-Dp9Tr43G.js";import{P as F}from"./modal-CPrQ9jQu.js";import{F as N}from"./funnel-B1ZA9LM9.js";import{T as I}from"./Table-rNmO5bBI.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,o]=x.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(F,{opened:r,onClose:()=>o(!1),withCloseButton:!0,content:n.jsx(g,{type:"multiple",label:"Pick years",value:a?.map(c=>new Date(c,0,1)),onChange:c=>t(c.map(p=>p.getFullYear())),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date})}),n.jsx(v,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>o(!0),children:n.jsx(N,{className:"size-5"})})]})}const u=({originalRuleData:a,diffRuleData:t})=>{const r=h(j,a),o=h(j,t),c=o?.isCompliant!==r.isCompliant||o?.percentage.formatted!==r.percentage.formatted;return!o||!c?n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:r.percentage.formatted}):n.jsx("td",{className:r.isCompliant?"text-green-500":"text-red-500",children:n.jsxs("div",{className:"flex flex-col",children:[n.jsx("p",{className:"line-through ".concat(r.isCompliant?"text-green-500":"text-red-500"),children:r.percentage.formatted}),o&&n.jsx("div",{className:"border-2 border-yellow-500 rounded-md ".concat(o.isCompliant?"text-green-500":"text-red-500"),children:o.percentage.formatted})]})})},d=(a,t)=>C(t).format(a);function m(a,t){if(a.length!==0)return d(a.reduce((r,o)=>r+o,0),t)}const O=()=>{const{year:a}=D(),{setFiltersContext:t}=x.useContext(R),[r,o]=x.useState(a?[Number(a)]:[new Date().getFullYear()]),[{data:c,fetching:p}]=E({query:A(T),variables:{years:r}});x.useEffect(()=>{t(n.jsx("div",{className:"flex flex-row gap-2",children:n.jsx(P,{years:r,setYears:o})}))},[r,p,t]);const s=c?.corporateTaxRulingComplianceReport??[];return n.jsx(b,{title:"Corporate Tax Ruling Compliance Report",children:p?n.jsx(y,{className:"h-10 w-10 animate-spin mr-2 self-center"}):n.jsx("div",{className:"flex flex-col gap-4",children:s&&n.jsxs(I,{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(w,{inline:!0,size:12,processing:!s.find(l=>l.year===e)?.differences,disabled:!!s.find(l=>l.year===e)?.differences,color:"orange",zIndex:"auto",children:e})},e)),n.jsx("th",{children:"Summary"},"sum")]})}),n.jsxs("tbody",{children:[n.jsxs("tr",{children:[n.jsx("td",{children:"Total Income"}),s.map(e=>n.jsx(i,{originalAmount:e.totalIncome.formatted,diffAmount:e.differences?.totalIncome?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.totalIncome.raw).reduce((e,l)=>e+l,0),s[0].totalIncome.currency),diffAmount:m(s.map(e=>e.differences?.totalIncome?.raw??e.totalIncome.raw).filter(e=>!!e),s[0].totalIncome.currency)},"sum")]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Total R&D Expensess"}),s.map(e=>n.jsx(i,{originalAmount:e.researchAndDevelopmentExpenses.formatted,diffAmount:e.differences?.researchAndDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.researchAndDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.rndRelativeToIncome.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"R&D Expenses out of Income"})})}),s.map(e=>n.jsx(u,{originalRuleData:e.rndRelativeToIncome,diffRuleData:e.differences?.rndRelativeToIncome??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Local Development Expenses"}),s.map(e=>n.jsx(i,{originalAmount:e.localDevelopmentExpenses.formatted,diffAmount:e.differences?.localDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.localDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.localDevelopmentRelativeToRnd.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"Local Development out of R&D"})})}),s.map(e=>n.jsx(u,{originalRuleData:e.localDevelopmentRelativeToRnd,diffRuleData:e.differences?.localDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"Foreign Development Expenses"}),s.map(e=>n.jsx(i,{originalAmount:e.foreignDevelopmentExpenses.formatted,diffAmount:e.differences?.foreignDevelopmentExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.foreignDevelopmentExpenses.raw).reduce((e,l)=>e+l,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(f,{content:s[0]?.foreignDevelopmentRelativeToRnd.rule,className:"max-w-[220px] whitespace-normal",children:n.jsx("p",{children:"Foreign Development out of R&D"})})}),s.map(e=>n.jsx(u,{originalRuleData:e.foreignDevelopmentRelativeToRnd,diffRuleData:e.differences?.foreignDevelopmentRelativeToRnd??void 0},e.year)),n.jsx("td",{})]}),n.jsxs("tr",{children:[n.jsx("td",{children:"R&D Business Trips Expenses"}),s.map(e=>n.jsx(i,{originalAmount:e.businessTripRndExpenses.formatted,diffAmount:e.differences?.businessTripRndExpenses?.formatted??void 0},e.year)),n.jsx(i,{originalAmount:d(s.map(e=>e.businessTripRndExpenses.raw).reduce((e,l)=>e+l,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{O as CorporateTaxRulingComplianceReport};
@@ -1 +0,0 @@
1
- import{u as m,ce as f,H as h,r,j as s,bC as g,cf as T,F as j,cg as B,T as w,at as C,L as E,ch as y}from"./index-DRqooPz9.js";import{E as b,P as v}from"./editable-business-trip-CPfdEl45.js";import{P as A}from"./page-layout-Dp9Tr43G.js";import{a as L,b as P,c as F,A as S}from"./accordion-Air1oXnF.js";import"./summary-BvHHpnIR.js";import"./update-accountant-status-Btcm95Uc.js";import"./Table-rNmO5bBI.js";import"./toggle-expansion-button-BquTpOYj.js";import"./panel-top-open-lnF5tdL1.js";import"./MultiSelect-DhEZHYxn.js";import"./similar-transactions-modal-DilkLkpx.js";import"./building-2-CWrl-iq9.js";const D=({data:d,isOpened:o,shouldValidate:c})=>{const e=h(T,d),[{data:i,fetching:a}]=m({pause:!c,query:f,variables:{id:e.id}}),l=r.useMemo(()=>c?i?.businessTrip&&(i.businessTrip.uncategorizedTransactions?.length||i?.businessTrip.summary?.errors?.length):!1,[i]),u=l||e?.accountantApproval!=="APPROVED";return s.jsxs(L,{value:e.id,children:[s.jsx(P,{children:s.jsx(g,{inline:!0,size:12,processing:a,disabled:!u,color:l?"red":"yellow",zIndex:"auto",children:e.name})}),s.jsx(F,{children:o&&s.jsx(b,{tripId:e.id,isExtended:!0},e.id)})]})},_=()=>{const{setFiltersContext:d}=r.useContext(j),[o,c]=r.useState([]),[e,i]=r.useState(!1),[{data:a,fetching:l}]=m({query:y});r.useEffect(()=>{if(!a?.allBusinessTrips?.length){c([]);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);c(t)},[a?.allBusinessTrips]);const[u,x]=r.useState([]);return r.useEffect(()=>{d(s.jsxs("div",{className:"flex flex-row gap-x-5",children:[s.jsx(B,{}),s.jsx(w,{content:"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(v,{filename:"business_trips"})]}))},[a,l,d,e]),s.jsx(A,{title:"Business Trips",description:"Manage business trips",children:o.length===0&&l?s.jsx(E,{className:"h-10 w-10 animate-spin mr-2 self-center"}):s.jsx(S,{className:"w-full",type:"multiple",value:u,onValueChange:x,children:o?.map(t=>s.jsx(D,{data:o.find(n=>n.id===t.id),shouldValidate:e,isOpened:u.includes(t.id)},t.id))})})};export{_ as BusinessTrips};
@@ -1,2 +0,0 @@
1
- import{dX as C,j as e,ah as L,R as U,ay as a,H as b,gg as y,r as u,b$ as N,gh as D,gi as k,K as R,gj as A,u as $,F as E,g9 as T,B as O,gk as P,c as z,gl as M}from"./index-DRqooPz9.js";import{P as Y}from"./page-layout-Dp9Tr43G.js";const d=(s,o)=>C(o,{minimumFractionDigits:0}).format(s);function B(s){return{id:s.id,chargeId:s.chargeId,date:s.date,description:s.description??"",reference:s.reference??"",amountILS:s.revenueLocal.raw,amountUSD:s.revenueDefaultForeign.raw,originalAmount:s.revenueOriginal.formatted}}const H=({recordData:s})=>{const o=b(y,s),r=B(o);return e.jsx("div",{className:"p-2 bg-background rounded-lg border border-border/30 text-sm",children:e.jsxs(L,{to:U.CHARGES.DETAIL(r.chargeId),target:"_blank",rel:"noreferrer",onClick:g=>g.stopPropagation(),className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-foreground",children:r.reference}),e.jsx("p",{className:"font-medium text-foreground",children:r.description}),e.jsxs("div",{className:"flex gap-4 mt-1 text-xs text-muted-foreground",children:[e.jsx("span",{children:r.chargeId}),e.jsx("span",{children:r.date})]})]}),e.jsxs("div",{className:"invisible md:visible md:text-right flex-shrink-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:d(r.amountILS,a.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d(r.amountUSD,a.Usd)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.originalAmount})]}),e.jsx("div",{className:"md:invisible ml-2 text-right",children:e.jsx("p",{className:"text-xs font-medium text-foreground",children:d(r.amountILS,a.Ils)})})]})})};function V(s){return{id:s.id,name:s.name,revenueILS:s.revenueLocal.raw,revenueUSD:s.revenueDefaultForeign.raw,records:s.records.map(o=>({id:o.id,data:o}))}}const q=({clientData:s})=>{const[o,r]=u.useState(!1),g=b(k,s),t=V(g),v=()=>{r(l=>!l)},x=u.useMemo(()=>t.records.slice().sort((l,i)=>l.data.date.localeCompare(i.data.date)),[t.records]);return e.jsxs("div",{children:[e.jsxs("button",{onClick:v,className:"w-full flex items-center justify-between p-2 bg-background rounded-lg border border-border/50 hover:bg-accent/5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[o?e.jsx(N,{className:"size-4 text-muted-foreground flex-shrink-0"}):e.jsx(D,{className:"size-4 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium text-foreground text-sm",children:t.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.records?.length||0," record",t.records?.length===1?"":"s"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:d(t.revenueILS,a.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"text-xs text-muted-foreground",children:d(t.revenueUSD,a.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-xs font-medium text-foreground",children:d(t.revenueILS,a.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d(t.revenueUSD,a.Usd)})]})]}),o&&x&&e.jsx("div",{className:"mt-3 ml-2 space-y-3 border-l-2 border-border/50 pl-2",children:x.map(l=>e.jsx(H,{recordData:l.data},l.id))})]})};function G(s){return{code:s.code,name:s.name,revenues:{ILS:s.revenueLocal.raw,USD:s.revenueDefaultForeign.raw},clients:s.clients.map(o=>({id:o.id,data:o}))}}const K=({countryData:s})=>{const[o,r]=u.useState(!1),g=b(A,s),t=G(g),v=()=>{r(i=>!i)},x={ILS:t.revenues.ILS,USD:t.revenues.USD},l=u.useMemo(()=>t.clients.slice().sort((i,j)=>j.data.revenueDefaultForeign.raw-i.data.revenueDefaultForeign.raw),[t.clients]);return e.jsxs(R,{className:"border border-border",children:[e.jsxs("button",{onClick:()=>v(),className:"w-full px-4 py-2 hover:bg-accent/5 transition-colors flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[o?e.jsx(N,{className:"size-5 text-muted-foreground flex-shrink-0"}):e.jsx(D,{className:"size-5 text-muted-foreground flex-shrink-0"}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-lg",children:t.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.clients.length," clients"]})]})]}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:d(t.revenues.ILS,a.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:d(t.revenues.USD,a.Usd)})]})]})]}),e.jsxs("div",{className:"md:hidden px-2 py-2 bg-accent/5 border-t border-border flex gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:d(t.revenues.ILS,a.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:d(t.revenues.USD,a.Usd)})]})]}),o&&e.jsx("div",{className:"border-t border-border",children:e.jsxs("div",{className:"space-y-2 p-3 bg-muted/30",children:[l.map(i=>e.jsx(q,{clientData:i.data},i.id)),e.jsx("div",{className:"pt-2 border-t border-border/50 mt-4",children:e.jsxs("div",{className:"flex items-center justify-between p-2",children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:"Clients Subtotal"}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right",children:[e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:d(x.ILS,a.Ils)})}),e.jsx("div",{children:e.jsx("p",{className:"font-semibold text-foreground",children:d(x.USD,a.Usd)})})]}),e.jsxs("div",{className:"md:hidden ml-4 text-right",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:d(x.ILS,a.Ils)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:d(x.USD,a.Usd)})]})]})})]})})]},t.code)},_=()=>{const[s,o]=u.useState(new Date().getFullYear()-1),[{data:r,fetching:g}]=$({query:M,variables:{filters:{year:s}}}),{setFiltersContext:t}=u.useContext(E),v=u.useMemo(()=>`Annual Revenue Report for ${s}`,[s]),{totalClients:x,totalRevenueIls:l,totalRevenueUsd:i}=u.useMemo(()=>{const n={totalClients:0,totalRevenueIls:0,totalRevenueUsd:0};return r?.annualRevenueReport.countries.map(p=>{n.totalClients+=p.clients.length,n.totalRevenueIls+=p.revenueLocal.raw,n.totalRevenueUsd+=p.revenueDefaultForeign.raw}),n},[r?.annualRevenueReport.countries]),j=u.useCallback(()=>{const n=[];n.push("Country,Client,charge ID,Date,Description,Revenue ILS,Revenue USD"),n.push(`Annual,,,,TOTAL,${l.toFixed(2)},${i.toFixed(2)}`),r?.annualRevenueReport.countries.sort((m,c)=>c.revenueDefaultForeign.raw-m.revenueDefaultForeign.raw).map(m=>{n.push(`${m.name},,,,TOTAL,${m.revenueLocal.raw.toFixed(2)},${m.revenueDefaultForeign.raw.toFixed(2)}`),m.clients.sort((c,h)=>h.revenueDefaultForeign.raw-c.revenueDefaultForeign.raw).map(c=>{c.records&&c.records.length>0?(n.push(`${m.name},${c.name},,,TOTAL,${c.revenueLocal.raw.toFixed(2)},${c.revenueDefaultForeign.raw.toFixed(2)}`),c.records.sort((h,I)=>h.date.localeCompare(I.date)).map(h=>{n.push(`${m.name},${c.name},${h.chargeId},${h.date},${h.description},${h.revenueLocal.raw.toFixed(2)},${h.revenueDefaultForeign.raw.toFixed(2)}`)})):n.push(`${m.name},${c.name},,,,,`)})});const p=n.join(`
2
- `),w=new Blob([p],{type:"text/csv;charset=utf-8;"}),f=document.createElement("a"),F=URL.createObjectURL(w);f.setAttribute("href",F),f.setAttribute("download",`annual-revenue-${s}.csv`),f.style.visibility="hidden",document.body.appendChild(f),f.click(),document.body.removeChild(f)},[r,s]);u.useEffect(()=>{t(e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(T,{value:new Date(s,0,1),onChange:n=>n&&o(n?.getFullYear()),popoverProps:{withinPortal:!0},minDate:new Date(2010,0,1),maxDate:new Date}),e.jsxs(O,{onClick:j,variant:"outline",size:"sm",className:"flex items-center gap-2 bg-transparent",children:[e.jsx(P,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Export CSV"})]})]}))},[s,g,t,j]);const S=u.useMemo(()=>r?.annualRevenueReport.countries.slice().sort((n,p)=>p.revenueDefaultForeign.raw-n.revenueDefaultForeign.raw),[r]);return e.jsx(Y,{title:"Annual Revenue Report",description:v,children:g?e.jsx(z,{}):e.jsx("div",{className:"min-h-screen bg-background",children:e.jsx("main",{className:"container mx-auto px-2 py-2 max-w-7xl",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(R,{className:"border border-border bg-accent/10",children:[e.jsxs("div",{className:"w-full px-4 py-2 pl-12 transition-colors flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-2 flex-1",children:e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-semibold text-foreground text-lg",children:"Total Revenue"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[x," clients"]})]})}),e.jsxs("div",{className:"hidden md:grid grid-cols-2 gap-4 text-right flex-shrink-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:d(l,a.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:d(i,a.Usd)})]})]})]}),e.jsxs("div",{className:"md:hidden px-2 py-2 bg-accent/5 border-t border-border flex gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"ILS"}),e.jsx("p",{className:"font-semibold text-foreground",children:d(l,a.Ils)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"USD"}),e.jsx("p",{className:"font-semibold text-foreground",children:d(i,a.Usd)})]})]})]}),S?.map(n=>e.jsx(K,{countryData:n},n.id))]})})})})};export{_ as AnnualRevenueReport};
@@ -1 +0,0 @@
1
- import{j as e,dx as t}from"./index-DRqooPz9.js";import{P as o}from"./page-layout-Dp9Tr43G.js";const n=()=>e.jsx(o,{title:"New Document",description:"Issue a document for a client",children:e.jsx(t,{})});export{n as IssueDocumentScreen};
@@ -1 +0,0 @@
1
- import{r as n,ip as g,o as f,E as p,G as b,j as e,W as v,Z as o,_ as l,$ as c,a0 as i,I as d,a2 as m,B as w,a8 as N,R as y,t as x,ac as u}from"./index-DRqooPz9.js";const S=N({username:u().min(2).max(50),password:u().min(2).max(50)});function F(){const{authService:a}=n.useContext(g);n.useEffect(()=>{a.logout()},[a]);const h=f(),s=p({resolver:b(S),defaultValues:{username:"",password:""}});function j(r){try{a.login(r.username,r.password).then(t=>{h(y.HOME)}),x.success("Success",{description:"You have successfully logged in."})}catch(t){console.error(t),x.error("Error",{description:"Invalid credentials. Please try again."})}}return e.jsxs("div",{className:"w-full flex flex-col justify-center items-center h-screen lg:grid lg:min-h-[200px] lg:grid-cols-2 xl:min-h-screen",children:[e.jsx("div",{className:"flex items-center justify-center",children:e.jsx(v,{...s,children:e.jsxs("form",{onSubmit:s.handleSubmit(j),className:"space-y-8 w-[300px]",children:[e.jsxs("div",{className:"grid gap-2 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Accounter"}),e.jsx("h1",{className:"text-3xl font-bold",children:"Login"}),e.jsx("p",{className:"text-balance text-muted-foreground",children:"Enter your credentials to login."})]}),e.jsx(o,{control:s.control,name:"username",render:({field:r})=>e.jsxs(l,{children:[e.jsx(c,{children:"Username"}),e.jsx(i,{children:e.jsx(d,{placeholder:"Username",...r})}),e.jsx(m,{})]})}),e.jsx(o,{control:s.control,name:"password",render:({field:r})=>e.jsxs(l,{children:[e.jsx(c,{children:"Password"}),e.jsx(i,{children:e.jsx(d,{placeholder:"Password",type:"password",...r})}),e.jsx(m,{})]})}),e.jsx(w,{disabled:s.formState.isSubmitting||!s.formState.isValid,className:"w-full font-semibold",type:"submit",children:"Login"})]})})}),e.jsx("div",{className:"hidden bg-muted lg:block bg-black rounded-tl-3xl rounded-bl-3xl",children:e.jsx("div",{className:"flex flex-row justify-center items-center h-screen",children:e.jsx("img",{src:"../../icons/guild-logo.svg",alt:"nature",className:"w-[100px] h-[100px] object-cover"})})})]})}export{F as LoginPage};
@@ -1 +0,0 @@
1
- import{v as re,bK as N,bL as S,g as K,c9 as se,r as p,t as k,i as Q,ca as ie,cb as B,bJ as G,ay as V,u as ce,cc as oe,E as le,G as de,a8 as ue,w,j as e,D as me,aL as pe,B as C,ag as he,a4 as U,x as xe,al as je,am as ye,an as ge,W as Ce,Z as o,_ as l,$ as d,a0 as u,I as f,a2 as m,af as fe,a5 as De,ao as T,ap as O,aq as I,ar as L,as as A,at as _,aQ as be,bb as we,a3 as ke,au as ve,cd as Ne,aw as v,ac as H,ax as Te,be as Oe,ad as Ie,ab as Le,ae as J,aA as Ae,bf as Se}from"./index-DRqooPz9.js";const Pe=[["path",{d:"M5 7a2 2 0 0 0-2 2v11",key:"1yhqjt"}],["path",{d:"M5.803 18H5a2 2 0 0 0 0 4h9.5a.5.5 0 0 0 .5-.5V21",key:"edzzo5"}],["path",{d:"M9 15V4a2 2 0 0 1 2-2h9.5a.5.5 0 0 1 .5.5v14a.5.5 0 0 1-.5.5H11a2 2 0 0 1 0-4h10",key:"1nwzrg"}]],Ee=re("book-copy",Pe);function Me(c){switch(c){case N.Annual:return"Annual";case N.Monthly:return"Monthly";default:throw new Error(`Unsupported Billing Cycle: ${c}`)}}function Be(c){switch(c){case S.Enterprise:return"Enterprise";case S.Pro:return"Pro";default:throw new Error(`Unsupported Subscription plan: ${c}`)}}const Ve="createContract",Fe=()=>{const[{fetching:c},h]=K(se),g=p.useCallback(async x=>{const y=`Error creating new contract for client[${x.input.clientId}]`,s=`${Ve}-${x.input.clientId}`;k.loading("Creating contract",{id:s});try{const i=await h(x);Q(i,y,s)&&k.success("Success",{id:s,description:`Contract for client ${x.input.clientId} was successfully created`})}catch(i){console.error(`${y}: ${i}`),k.error("Error",{id:s,description:y,duration:1e5,closeButton:!0})}},[h]);return{creating:c,createContract:g}},$e="updateContract",ze=()=>{const[{fetching:c},h]=K(ie),g=p.useCallback(async x=>{const y=`Error updating contract ID [${x.contractId}]`,s=`${$e}-${x.contractId}`;k.loading("Updating contract",{id:s});try{const i=await h(x),D=Q(i,y,s,"updateContract");if(D)return k.success("Success",{id:s,description:"Contract updated"}),D.updateContract}catch(i){console.error(`${y}: ${i}`),k.error("Error",{id:s,description:y,duration:1e5,closeButton:!0})}},[h]);return{updating:c,updateContract:g}},Re=ue({id:Ae().optional(),startDate:J("Start date is required"),endDate:J("End date is required"),pos:Le(H()),paymentAmount:Ie().min(0,"Payment amount must be non-negative"),paymentCurrency:v(Object.values(V),"Currency is required"),productType:v(Object.values(G)).optional(),msCloudLink:Oe().optional().or(Se("")),billingCycle:v(Object.values(N)).optional(),subscriptionPlan:v(Object.values(S)).optional(),isActive:Te(),defaultRemark:H().optional(),defaultDocumentType:v(Object.values(B)),operationsLimit:Ne().min(BigInt(0),"Operations limit must be non-negative")}),qe={startDate:"",endDate:"",pos:[],paymentAmount:0,paymentCurrency:V.Usd,productType:G.Hive,msCloudLink:void 0,billingCycle:N.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:B.Proforma,operationsLimit:BigInt(0)};function _e({clientId:c,contract:h,contractId:g,onDone:x,duplicate:y}){const{isEditing:s,isDuplicating:i}=p.useMemo(()=>{const t=!!h||!!g,n=y===!0&&t;return{isEditing:t&&!n,isDuplicating:n}},[h,g,y]),[D,b]=p.useState(!1),[P,W]=p.useState(!1),[r,F]=p.useState(qe),[$,z]=p.useState(""),{updateContract:R,updating:X}=ze(),{createContract:E,creating:Z}=Fe(),[{data:M,fetching:Y}]=ce({query:oe,pause:!g||!D,variables:{contractId:g??""}}),a=le({resolver:de(Re),defaultValues:r}),q=()=>{const t=$.trim();if(t){const n=a.getValues("pos");n.includes(t)||a.setValue("pos",[...n,t],{shouldDirty:!0}),z("")}},ee=t=>{const n=a.getValues("pos");a.setValue("pos",n.filter((j,ae)=>ae!==t),{shouldDirty:!0})};p.useEffect(()=>{h&&F(h)},[h]),p.useEffect(()=>{if(M?.contractsById){const t=M.contractsById,n={startDate:t.startDate,endDate:t.endDate,pos:t.purchaseOrders,paymentAmount:t.amount.raw,paymentCurrency:t.amount.currency,productType:t.product??void 0,msCloudLink:t.msCloud?.toString()??void 0,billingCycle:t.billingCycle,subscriptionPlan:t.plan??void 0,isActive:t.isActive,defaultRemark:t.remarks??void 0,defaultDocumentType:t.documentType,operationsLimit:BigInt(t.operationsLimit)};F({id:t.id,...n})}},[M]);const te=p.useMemo(()=>r?JSON.stringify(r):null,[r]);p.useEffect(()=>{r&&a.reset({startDate:r.startDate,endDate:r.endDate,pos:r.pos,paymentAmount:r.paymentAmount,paymentCurrency:r.paymentCurrency,productType:r.productType,msCloudLink:r.msCloudLink,billingCycle:r.billingCycle,subscriptionPlan:r.subscriptionPlan,isActive:r.isActive,defaultRemark:r.defaultRemark,defaultDocumentType:r.defaultDocumentType,operationsLimit:BigInt(r.operationsLimit)})},[te,a.reset]);const ne=p.useCallback(async t=>{if(i||s){if(!r?.id)return;if(i){if(!t.billingCycle){a.setError("billingCycle",{message:"Billing cycle is required"});return}await E({input:{clientId:c,amount:{raw:t.paymentAmount,currency:t.paymentCurrency},billingCycle:t.billingCycle,documentType:t.defaultDocumentType,endDate:w(new Date(t.endDate),"yyyy-MM-dd"),isActive:t.isActive,msCloud:t.msCloudLink,plan:t.subscriptionPlan,product:t.productType,purchaseOrders:t.pos,remarks:t.defaultRemark,startDate:w(new Date(t.startDate),"yyyy-MM-dd"),operationsLimit:t.operationsLimit,deactivateContracts:P?[r.id]:void 0}})}else await R({contractId:r.id,input:{amount:{raw:t.paymentAmount,currency:t.paymentCurrency},billingCycle:t.billingCycle,documentType:t.defaultDocumentType,endDate:w(new Date(t.endDate),"yyyy-MM-dd"),isActive:t.isActive,msCloud:t.msCloudLink,plan:t.subscriptionPlan,product:t.productType,purchaseOrders:t.pos,remarks:t.defaultRemark,startDate:w(new Date(t.startDate),"yyyy-MM-dd"),operationsLimit:t.operationsLimit}})}else{if(!t.billingCycle){a.setError("billingCycle",{message:"Billing cycle is required"});return}await E({input:{clientId:c,amount:{raw:t.paymentAmount,currency:t.paymentCurrency},billingCycle:t.billingCycle,documentType:t.defaultDocumentType,endDate:w(new Date(t.endDate),"yyyy-MM-dd"),isActive:t.isActive,msCloud:t.msCloudLink,plan:t.subscriptionPlan,product:t.productType,purchaseOrders:t.pos,remarks:t.defaultRemark,startDate:w(new Date(t.startDate),"yyyy-MM-dd"),operationsLimit:t.operationsLimit}})}b(!1),x?.()},[r,x,E,R,c,a,s,i,P]);return e.jsxs(me,{open:D,onOpenChange:b,children:[e.jsx(pe,{asChild:!0,children:s?e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>b(!0),children:e.jsx(he,{className:"size-5"})}):i?e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>b(!0),children:e.jsx(Ee,{className:"size-5"})}):e.jsxs(C,{size:"sm",onClick:()=>b(!0),children:[e.jsx(U,{className:"size-4 mr-2"}),"New Contract"]})}),e.jsxs(xe,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(je,{children:[e.jsx(ye,{children:s?"Edit Contract":"Create New Contract"}),e.jsx(ge,{children:s?"Update contract details":i?"Create a new contract based on an existing one":"Add a new contract with all required details"})]}),Y?e.jsx(e.Fragment,{children:"Fetching contract details..."}):e.jsx(Ce,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(ne),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(o,{control:a.control,name:"operationsLimit",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"Operations Limit"}),e.jsx(u,{children:e.jsx(f,{placeholder:"500",...t,value:t.value?.toLocaleString(),onChange:n=>{const j=n.target.value.replace(/[^0-9]/g,"");t.onChange(BigInt(j||0))}})}),e.jsx(m,{})]})}),e.jsx(o,{control:a.control,name:"pos",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"Purchase Orders"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{placeholder:"Add PO...",value:$,onChange:n=>z(n.target.value),onKeyDown:n=>{n.key==="Enter"&&(n.preventDefault(),q())}}),e.jsx(C,{type:"button",size:"sm",onClick:q,children:e.jsx(U,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:t.value?.map((n,j)=>e.jsxs(fe,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[n,j===(t.value?.length??0)-1&&e.jsx(C,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>ee(j),children:e.jsx(De,{className:"size-3 cursor-pointer flex-shrink-0"})})]},n))}),e.jsx(m,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(o,{control:a.control,name:"startDate",render:({field:{onChange:t,...n}})=>e.jsxs(l,{children:[e.jsx(d,{children:"Start Date"}),e.jsx(u,{children:e.jsx(f,{type:"date",...n,onInput:j=>t(j)})}),e.jsx(m,{})]})}),e.jsx(o,{control:a.control,name:"endDate",render:({field:{onChange:t,...n}})=>e.jsxs(l,{children:[e.jsx(d,{children:"End Date"}),e.jsx(u,{children:e.jsx(f,{type:"date",...n,onInput:j=>t(j)})}),e.jsx(m,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(o,{control:a.control,name:"paymentAmount",render:({field:t})=>e.jsxs(l,{className:"md:col-span-2",children:[e.jsx(d,{children:"Payment Amount"}),e.jsx(u,{children:e.jsx(f,{type:"number",placeholder:"24000",...t,onChange:n=>{t.onChange(n?.target.value?Number(n?.target.value):void 0)}})}),e.jsx(m,{})]})}),e.jsx(o,{control:a.control,name:"paymentCurrency",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"Currency"}),e.jsxs(T,{onValueChange:t.onChange,defaultValue:t.value,children:[e.jsx(u,{children:e.jsx(O,{children:e.jsx(I,{})})}),e.jsx(L,{children:Object.values(V).map(n=>e.jsx(A,{value:n,children:n},n))})]}),e.jsx(m,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(o,{control:a.control,name:"productType",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"Product Type"}),e.jsx(u,{children:e.jsx(f,{placeholder:"Cloud Services",...t})}),e.jsx(m,{})]})}),e.jsx(o,{control:a.control,name:"billingCycle",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"Billing Cycle"}),e.jsxs(T,{onValueChange:t.onChange,defaultValue:t.value,children:[e.jsx(u,{children:e.jsx(O,{children:e.jsx(I,{})})}),e.jsx(L,{children:Object.values(N).map(n=>e.jsx(A,{value:n,children:Me(n)},n))})]}),e.jsx(m,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(o,{control:a.control,name:"subscriptionPlan",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"Subscription Plan"}),e.jsx(u,{children:e.jsxs(T,{onValueChange:t.onChange,defaultValue:t.value,children:[e.jsx(u,{children:e.jsx(O,{children:e.jsx(I,{})})}),e.jsx(L,{children:Object.values(S).map(n=>e.jsx(A,{value:n,children:Be(n)},n))})]})}),e.jsx(m,{})]})}),e.jsx(o,{control:a.control,name:"isActive",render:({field:t})=>e.jsxs(l,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(d,{className:"text-base",children:"Active Status"})}),e.jsx(u,{children:e.jsx(_,{checked:t.value,onCheckedChange:t.onChange})})]})})]}),e.jsx(o,{control:a.control,name:"msCloudLink",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"MS Cloud Link"}),e.jsx(u,{children:e.jsx(f,{type:"url",placeholder:"https://portal.azure.com/contract-id",...t})}),e.jsx(m,{})]})}),e.jsx(o,{control:a.control,name:"defaultDocumentType",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"Default Document Type"}),e.jsxs(T,{onValueChange:t.onChange,defaultValue:t.value,children:[e.jsx(u,{children:e.jsx(O,{children:e.jsx(I,{})})}),e.jsx(L,{children:Object.values(B).map(n=>e.jsx(A,{value:n,children:be(n)},n))})]}),e.jsx(m,{})]})}),e.jsx(o,{control:a.control,name:"defaultRemark",render:({field:t})=>e.jsxs(l,{children:[e.jsx(d,{children:"Default Remark"}),e.jsx(u,{children:e.jsx(we,{placeholder:"Enter default remark for this contract...",rows:3,...t})}),e.jsx(m,{})]})}),i&&e.jsxs("div",{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(ke,{className:"text-base",children:"Deactivate Original Contract"})}),e.jsx(_,{checked:P,onCheckedChange:W})]})]}),e.jsxs(ve,{children:[e.jsx(C,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(C,{type:"submit",disabled:Z||X,children:s?"Update Contract":"Create Contract"})]})]})})]})]})}export{_e as M,Be as a,Me as s};
@@ -1 +0,0 @@
1
- import{r as i,H as c,gc as m,j as t,gd as j}from"./index-DRqooPz9.js";import{T as h}from"./toggle-expansion-button-BquTpOYj.js";import{T as x}from"./Table-rNmO5bBI.js";const p=({subCommentaryData:o,dataRow:a})=>{const[s,l]=i.useState(!1),r=o.map(e=>c(m,e)),d=t.jsx(h,{toggleExpansion:l,isExpanded:s});return t.jsxs(t.Fragment,{children:[a(d),s&&t.jsx("tr",{children:t.jsx("td",{colSpan:99,children:t.jsxs(x,{striped:!0,highlightOnHover:!0,className:"ml-8 w-full h-full",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Entity"}),t.jsx("th",{children:"Amount"})]})}),t.jsxs("tbody",{children:[r?.sort((e,n)=>e.financialEntity.name.localeCompare(n.financialEntity.name)).map(e=>t.jsxs("tr",{children:[t.jsx("td",{children:e.financialEntity.name}),t.jsx("td",{children:e.amount.formatted})]},e.financialEntity.id)),t.jsx("tr",{children:t.jsx("td",{colSpan:8})})]})]})})})]})},f=({commentaryData:o,dataRow:a})=>{const[s,l]=i.useState(!1),{records:r}=c(j,o),d=r.length?t.jsx(h,{toggleExpansion:l,isExpanded:s}):null;return t.jsxs(t.Fragment,{children:[a(d),s&&t.jsx("tr",{children:t.jsx("td",{colSpan:99,children:t.jsxs(x,{striped:!0,highlightOnHover:!0,className:"ml-8 w-full h-full",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{children:"Sort Code"}),t.jsx("th",{children:"Amount"}),t.jsx("th",{})]})}),t.jsxs("tbody",{children:[r?.sort((e,n)=>e.sortCode.key-n.sortCode.key).map(e=>t.jsx(p,{dataRow:n=>t.jsxs("tr",{children:[t.jsxs("td",{children:[e.sortCode.key," - ",e.sortCode.name]}),t.jsx("td",{children:e.amount.formatted}),t.jsx("td",{children:n})]},e.sortCode.key),subCommentaryData:e.records},e.sortCode.key)),t.jsx("tr",{children:t.jsx("td",{colSpan:8})})]})]})})})]})};export{f as R};
@@ -1 +0,0 @@
1
- import{gO as n}from"./index-DRqooPz9.js";function a(o,s,t){return n(o,-s,t)}export{a as s};
@@ -1 +0,0 @@
1
- import{f$ as Tr,g0 as Rr,g1 as Lr,r as g,by as C,ev as T,eu as $,bz as P,aF as _,fu as kr,ew as ie,bA as R,dw as Be,eS as le,g2 as Fe,g3 as zr,fY as pe,d8 as ce,ey as Ar,bv as S,eT as Br,eA as Fr,ep as Hr,H as de,j as l,g4 as Vr,g as Xr,g5 as Gr,t as se,i as Ur,bX as Wr,g6 as Kr,f2 as Yr,R as qr,w as me,g7 as Zr,g8 as Jr,dp as F,ay as H}from"./index-DRqooPz9.js";import{U as Qr}from"./update-accountant-status-Btcm95Uc.js";import{T as et}from"./Table-rNmO5bBI.js";function rt(e,r,t){const[n,o]=Tr(t?.in,e,r),i=ge(n,o),a=Math.abs(Rr(n,o));n.setDate(n.getDate()-i*a);const s=+(ge(n,o)===-i),c=i*(a-s);return c===0?0:c}function ge(e,r){const t=e.getFullYear()-r.getFullYear()||e.getMonth()-r.getMonth()||e.getDate()-r.getDate()||e.getHours()-r.getHours()||e.getMinutes()-r.getMinutes()||e.getSeconds()-r.getSeconds()||e.getMilliseconds()-r.getMilliseconds();return t<0?-1:t>0?1:t}function ve(e,r,t){const n=Lr(e,t?.in);return n.setHours(r),n}function G(e,r){let t=e;for(;(t=t.parentElement)&&!t.matches(r););return t}function tt(e,r,t){for(let n=e-1;n>=0;n-=1)if(!r[n].disabled)return n;if(t){for(let n=r.length-1;n>-1;n-=1)if(!r[n].disabled)return n}return e}function nt(e,r,t){for(let n=e+1;n<r.length;n+=1)if(!r[n].disabled)return n;if(t){for(let n=0;n<r.length;n+=1)if(!r[n].disabled)return n}return e}function ot(e,r,t){return G(e,t)===G(r,t)}function at({parentSelector:e,siblingSelector:r,onKeyDown:t,loop:n=!0,activateOnFocus:o=!1,dir:i="rtl",orientation:a}){return s=>{var c;t?.(s);const f=Array.from(((c=G(s.currentTarget,e))==null?void 0:c.querySelectorAll(r))||[]).filter(v=>ot(s.currentTarget,v,e)),d=f.findIndex(v=>s.currentTarget===v),u=nt(d,f,n),m=tt(d,f,n);switch(s.key){case"ArrowRight":break;case"ArrowLeft":break;case"ArrowUp":{s.stopPropagation(),s.preventDefault(),f[m].focus(),o&&f[m].click();break}case"ArrowDown":{s.stopPropagation(),s.preventDefault(),f[u].focus(),o&&f[u].click();break}case"Home":{s.stopPropagation(),s.preventDefault(),!f[0].disabled&&f[0].focus();break}case"End":{s.stopPropagation(),s.preventDefault();const v=f.length-1;!f[v].disabled&&f[v].focus();break}}}}function st(e,r,t){var n;return t?Array.from(((n=G(t,r))==null?void 0:n.querySelectorAll(e))||[]).findIndex(o=>o===t):null}function N(e,r){return t=>{e?.(t),r?.(t)}}function it(){const[e,r]=g.useState(-1);return[e,{setHovered:r,resetHovered:()=>r(-1)}]}const lt={xs:$(12),sm:$(18),md:$(24),lg:$(34),xl:$(42)};var ct=C((e,{color:r,transitionDuration:t},{size:n})=>{const o=T({size:n,sizes:lt}),i=r||(e.colorScheme==="dark"?e.white:e.black);return{root:{borderRadius:e.radius.sm,width:`calc(${o} + ${e.spacing.xs})`,height:`calc(${o} + ${e.spacing.xs})`,padding:`calc(${e.spacing.xs} / 2)`,cursor:"pointer"},burger:{position:"relative",userSelect:"none",boxSizing:"border-box","&, &::before, &::after":{display:"block",width:o,height:`calc(${o} / 12)`,backgroundColor:i,outline:`${$(1)} solid transparent`,transitionProperty:"background-color, transform",transitionDuration:`${t}ms`,"@media (prefers-reduced-motion)":{transitionDuration:e.respectReducedMotion?"0ms":void 0}},"&::before, &::after":{position:"absolute",content:'""',left:0},"&::before":{top:`calc((${o} / 3) * -1)`},"&::after":{top:`calc(${o} / 3)`},"&[data-opened]":{backgroundColor:"transparent","&::before":{transform:`translateY(calc(${o} / 3)) rotate(45deg)`},"&::after":{transform:`translateY(calc(-${o} / 3)) rotate(-45deg)`}}}}}),dt=Object.defineProperty,U=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,_e=(e,r,t)=>r in e?dt(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,ft=(e,r)=>{for(var t in r||(r={}))He.call(r,t)&&_e(e,t,r[t]);if(U)for(var t of U(r))Ve.call(r,t)&&_e(e,t,r[t]);return e},ut=(e,r)=>{var t={};for(var n in e)He.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&U)for(var n of U(e))r.indexOf(n)<0&&Ve.call(e,n)&&(t[n]=e[n]);return t};const pt={size:"md",transitionDuration:300},Xe=g.forwardRef((e,r)=>{const t=P("Burger",pt,e),{className:n,opened:o,color:i,size:a,classNames:s,styles:c,transitionDuration:f,variant:d}=t,u=ut(t,["className","opened","color","size","classNames","styles","transitionDuration","variant"]),{classes:m,cx:v}=ct({color:i,transitionDuration:f},{classNames:s,styles:c,name:"Burger",variant:d,size:a});return _.createElement(kr,ft({className:v(m.root,n),ref:r},u),_.createElement("div",{"data-opened":o||void 0,className:m.burger}))});Xe.displayName="@mantine/core/Burger";const Ge=g.createContext({padding:0}),mt=Ge.Provider,gt=()=>g.useContext(Ge).padding;var vt=C((e,{padding:r,withBorder:t,inheritPadding:n})=>{const o=T({size:r,sizes:e.spacing}),i=`calc(-1 * ${o})`,a=e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[3];return{cardSection:{display:"block",marginLeft:i,marginRight:i,paddingLeft:n?o:void 0,paddingRight:n?o:void 0,borderTop:t?`${$(1)} solid ${a}`:void 0,borderBottom:t?`${$(1)} solid ${a}`:void 0,"& + &":{borderTop:0},"&[data-first]":{marginTop:i,borderTop:0,borderBottom:t?`${$(1)} solid ${a}`:void 0},"&[data-last]":{marginBottom:i,borderBottom:0}}}}),_t=Object.defineProperty,W=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,We=Object.prototype.propertyIsEnumerable,ye=(e,r,t)=>r in e?_t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,yt=(e,r)=>{for(var t in r||(r={}))Ue.call(r,t)&&ye(e,t,r[t]);if(W)for(var t of W(r))We.call(r,t)&&ye(e,t,r[t]);return e},ht=(e,r)=>{var t={};for(var n in e)Ue.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&W)for(var n of W(e))r.indexOf(n)<0&&We.call(e,n)&&(t[n]=e[n]);return t};const xt={withBorder:!1,inheritPadding:!1},Ke=g.forwardRef((e,r)=>{const t=P("CardSection",xt,e),{className:n,withBorder:o,inheritPadding:i,unstyled:a,variant:s}=t,c=ht(t,["className","withBorder","inheritPadding","unstyled","variant"]),{classes:f,cx:d}=vt({padding:gt(),withBorder:o,inheritPadding:i},{name:"Card",unstyled:a,variant:s});return _.createElement(R,yt({className:d(f.cardSection,n),ref:r},c))});Ke.displayName="@mantine/core/CardSection";const Ye=ie(Ke);var wt=C(e=>({root:{position:"relative",overflow:"hidden",backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white}})),Ot=Object.defineProperty,K=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable,he=(e,r,t)=>r in e?Ot(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,$t=(e,r)=>{for(var t in r||(r={}))qe.call(r,t)&&he(e,t,r[t]);if(K)for(var t of K(r))Ze.call(r,t)&&he(e,t,r[t]);return e},Pt=(e,r)=>{var t={};for(var n in e)qe.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&K)for(var n of K(e))r.indexOf(n)<0&&Ze.call(e,n)&&(t[n]=e[n]);return t};const bt={padding:"md"},fe=g.forwardRef((e,r)=>{const t=P("Card",bt,e),{className:n,padding:o,radius:i,children:a,unstyled:s,variant:c}=t,f=Pt(t,["className","padding","radius","children","unstyled","variant"]),{classes:d,cx:u}=wt(null,{name:"Card",unstyled:s,variant:c}),m=g.Children.toArray(a),v=m.map((p,y)=>typeof p=="object"&&p&&"type"in p&&p.type===Ye?g.cloneElement(p,{variant:c,padding:o,"data-first":y===0||void 0,"data-last":y===m.length-1||void 0}):p);return _.createElement(mt,{value:{padding:o}},_.createElement(Be,$t({className:u(d.root,n),radius:i,p:o,ref:r},f),v))});fe.Section=Ye;fe.displayName="@mantine/core/Card";const mo=ie(fe),[St,jt]=le("Grid component was not found in tree");var Et=Object.defineProperty,xe=Object.getOwnPropertySymbols,It=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,we=(e,r,t)=>r in e?Et(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Nt=(e,r)=>{for(var t in r||(r={}))It.call(r,t)&&we(e,t,r[t]);if(xe)for(var t of xe(r))Ct.call(r,t)&&we(e,t,r[t]);return e};const ue=(e,r)=>e==="content"?"auto":e==="auto"?"0rem":e?`${100/(r/e)}%`:void 0,Je=(e,r,t)=>t||e==="auto"||e==="content"?"unset":ue(e,r),Qe=(e,r)=>{if(e)return e==="auto"||r?1:0},er=(e,r)=>e===0?0:e?`${100/(r/e)}%`:void 0,rr=(e,r)=>typeof e<"u"?`calc(${T({size:e,sizes:r.spacing})} / 2)`:void 0;function Mt({sizes:e,offsets:r,orders:t,theme:n,columns:o,gutters:i,grow:a}){return Fe.reduce((s,c)=>(s[`@media (min-width: ${zr(n.breakpoints[c])})`]={order:t[c],flexBasis:ue(e[c],o),padding:rr(i[c],n),flexShrink:0,width:e[c]==="content"?"auto":void 0,maxWidth:Je(e[c],o,a),marginLeft:er(r[c],o),flexGrow:Qe(e[c],a)},s),{})}var Dt=C((e,{gutter:r,gutterXs:t,gutterSm:n,gutterMd:o,gutterLg:i,gutterXl:a,grow:s,offset:c,offsetXs:f,offsetSm:d,offsetMd:u,offsetLg:m,offsetXl:v,columns:p,span:y,xs:h,sm:x,md:w,lg:j,xl:D,order:L,orderXs:k,orderSm:z,orderMd:A,orderLg:E,orderXl:O})=>({col:Nt({boxSizing:"border-box",flexGrow:Qe(y,s),order:L,padding:rr(r,e),marginLeft:er(c,p),flexBasis:ue(y,p),flexShrink:0,width:y==="content"?"auto":void 0,maxWidth:Je(y,p,s)},Mt({sizes:{xs:h,sm:x,md:w,lg:j,xl:D},offsets:{xs:f,sm:d,md:u,lg:m,xl:v},orders:{xs:k,sm:z,md:A,lg:E,xl:O},gutters:{xs:t,sm:n,md:o,lg:i,xl:a},theme:e,columns:p,grow:s}))})),Tt=Object.defineProperty,Y=Object.getOwnPropertySymbols,tr=Object.prototype.hasOwnProperty,nr=Object.prototype.propertyIsEnumerable,Oe=(e,r,t)=>r in e?Tt(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Rt=(e,r)=>{for(var t in r||(r={}))tr.call(r,t)&&Oe(e,t,r[t]);if(Y)for(var t of Y(r))nr.call(r,t)&&Oe(e,t,r[t]);return e},Lt=(e,r)=>{var t={};for(var n in e)tr.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&Y)for(var n of Y(e))r.indexOf(n)<0&&nr.call(e,n)&&(t[n]=e[n]);return t};const kt={};function zt(e){return e==="auto"||e==="content"?!0:typeof e=="number"&&e>0&&e%1===0}const or=g.forwardRef((e,r)=>{const t=P("GridCol",kt,e),{children:n,span:o,offset:i,offsetXs:a,offsetSm:s,offsetMd:c,offsetLg:f,offsetXl:d,xs:u,sm:m,md:v,lg:p,xl:y,order:h,orderXs:x,orderSm:w,orderMd:j,orderLg:D,orderXl:L,className:k,unstyled:z,variant:A}=t,E=Lt(t,["children","span","offset","offsetXs","offsetSm","offsetMd","offsetLg","offsetXl","xs","sm","md","lg","xl","order","orderXs","orderSm","orderMd","orderLg","orderXl","className","unstyled","variant"]),O=jt(),M=o||O.columns,{classes:B,cx:X}=Dt({gutter:O.gutter,gutterXs:O.gutterXs,gutterSm:O.gutterSm,gutterMd:O.gutterMd,gutterLg:O.gutterLg,gutterXl:O.gutterXl,offset:i,offsetXs:a,offsetSm:s,offsetMd:c,offsetLg:f,offsetXl:d,xs:u,sm:m,md:v,lg:p,xl:y,order:h,orderXs:x,orderSm:w,orderMd:j,orderLg:D,orderXl:L,grow:O.grow,columns:O.columns,span:M},{unstyled:z,name:"Grid",variant:A});return!zt(M)||M>O.columns?null:_.createElement(R,Rt({className:X(B.col,k),ref:r},E),n)});or.displayName="@mantine/core/Col";var At=Object.defineProperty,$e=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,Pe=(e,r,t)=>r in e?At(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Ht=(e,r)=>{for(var t in r||(r={}))Bt.call(r,t)&&Pe(e,t,r[t]);if($e)for(var t of $e(r))Ft.call(r,t)&&Pe(e,t,r[t]);return e};function Vt(e,r){return Fe.reduce((t,n)=>(typeof e[n]<"u"&&(t[`@media (min-width: ${r.breakpoints[n]})`]={margin:`calc(-${T({size:e[n],sizes:r.spacing})} / 2)`}),t),{})}var Xt=C((e,{justify:r,align:t,gutter:n,gutterXs:o,gutterSm:i,gutterMd:a,gutterLg:s,gutterXl:c})=>({root:Ht({margin:`calc(-${T({size:n,sizes:e.spacing})} / 2)`,display:"flex",flexWrap:"wrap",justifyContent:r,alignItems:t},Vt({xs:o,sm:i,md:a,lg:s,xl:c},e))})),Gt=Object.defineProperty,q=Object.getOwnPropertySymbols,ar=Object.prototype.hasOwnProperty,sr=Object.prototype.propertyIsEnumerable,be=(e,r,t)=>r in e?Gt(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Ut=(e,r)=>{for(var t in r||(r={}))ar.call(r,t)&&be(e,t,r[t]);if(q)for(var t of q(r))sr.call(r,t)&&be(e,t,r[t]);return e},Wt=(e,r)=>{var t={};for(var n in e)ar.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&q)for(var n of q(e))r.indexOf(n)<0&&sr.call(e,n)&&(t[n]=e[n]);return t};const Kt={gutter:"md",justify:"flex-start",align:"stretch",columns:12},b=g.forwardRef((e,r)=>{const t=P("Grid",Kt,e),{gutter:n,gutterXs:o,gutterSm:i,gutterMd:a,gutterLg:s,gutterXl:c,children:f,grow:d,justify:u,align:m,columns:v,className:p,unstyled:y,variant:h}=t,x=Wt(t,["gutter","gutterXs","gutterSm","gutterMd","gutterLg","gutterXl","children","grow","justify","align","columns","className","unstyled","variant"]),{classes:w,cx:j}=Xt({gutter:n,justify:u,align:m,gutterXs:o,gutterSm:i,gutterMd:a,gutterLg:s,gutterXl:c},{unstyled:y,name:"Grid",variant:h});return _.createElement(St,{value:{gutter:n,gutterXs:o,gutterSm:i,gutterMd:a,gutterLg:s,gutterXl:c,grow:d,columns:v}},_.createElement(R,Ut({className:j(w.root,p),ref:r},x),f))});b.Col=or;b.displayName="@mantine/core/Grid";function Yt({open:e,close:r,openDelay:t,closeDelay:n}){const o=g.useRef(-1),i=g.useRef(-1),a=()=>{window.clearTimeout(o.current),window.clearTimeout(i.current)},s=()=>{a(),t===0?e():o.current=window.setTimeout(e,t)},c=()=>{a(),n===0?r():i.current=window.setTimeout(r,n)};return g.useEffect(()=>a,[]),{openDropdown:s,closeDropdown:c}}const[qt,Zt]=le("List component was not found in tree");var Jt=C((e,{spacing:r,center:t})=>({itemWrapper:{ref:pe("itemWrapper"),display:"inline-flex",flexDirection:"column",whiteSpace:"normal"},item:{whiteSpace:"nowrap",lineHeight:t?1:e.lineHeight,"&:not(:first-of-type)":{marginTop:T({size:r,sizes:e.spacing})},"&[data-with-icon]":{listStyle:"none",[`& .${pe("itemWrapper")}`]:{display:"inline-flex",alignItems:t?"center":"flex-start",flexDirection:"row"}}},itemIcon:{display:"inline-block",verticalAlign:"middle",marginRight:e.spacing.sm}})),Qt=Object.defineProperty,Z=Object.getOwnPropertySymbols,ir=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable,Se=(e,r,t)=>r in e?Qt(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,en=(e,r)=>{for(var t in r||(r={}))ir.call(r,t)&&Se(e,t,r[t]);if(Z)for(var t of Z(r))lr.call(r,t)&&Se(e,t,r[t]);return e},rn=(e,r)=>{var t={};for(var n in e)ir.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&Z)for(var n of Z(e))r.indexOf(n)<0&&lr.call(e,n)&&(t[n]=e[n]);return t};const tn={},cr=g.forwardRef((e,r)=>{const t=P("ListItem",tn,e),{className:n,children:o,icon:i}=t,a=rn(t,["className","children","icon"]),{icon:s,spacing:c,center:f,listStyleType:d,size:u,withPadding:m,classNames:v,styles:p,unstyled:y,variant:h}=Zt(),x=i||s,{classes:w,cx:j}=Jt({withPadding:m,listStyleType:d,center:f,spacing:c},{classNames:v,styles:p,unstyled:y,name:"List",variant:h,size:u});return _.createElement(R,en({component:"li",className:j(w.item,n),"data-with-icon":!!x||void 0,ref:r},a),_.createElement("div",{className:w.itemWrapper},x&&_.createElement("span",{className:w.itemIcon},x),_.createElement("span",null,o)))});cr.displayName="@mantine/core/ListItem";var nn=Object.defineProperty,on=Object.defineProperties,an=Object.getOwnPropertyDescriptors,je=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,ln=Object.prototype.propertyIsEnumerable,Ee=(e,r,t)=>r in e?nn(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,cn=(e,r)=>{for(var t in r||(r={}))sn.call(r,t)&&Ee(e,t,r[t]);if(je)for(var t of je(r))ln.call(r,t)&&Ee(e,t,r[t]);return e},dn=(e,r)=>on(e,an(r)),fn=C((e,{withPadding:r,listStyleType:t},{size:n})=>({root:dn(cn({},e.fn.fontStyles()),{listStyleType:t,color:e.colorScheme==="dark"?e.colors.dark[0]:e.black,fontSize:T({size:n,sizes:e.fontSizes}),lineHeight:e.lineHeight,margin:0,paddingLeft:r?e.spacing.xl:0,listStylePosition:"inside"})})),un=Object.defineProperty,J=Object.getOwnPropertySymbols,dr=Object.prototype.hasOwnProperty,fr=Object.prototype.propertyIsEnumerable,Ie=(e,r,t)=>r in e?un(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,pn=(e,r)=>{for(var t in r||(r={}))dr.call(r,t)&&Ie(e,t,r[t]);if(J)for(var t of J(r))fr.call(r,t)&&Ie(e,t,r[t]);return e},mn=(e,r)=>{var t={};for(var n in e)dr.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&J)for(var n of J(e))r.indexOf(n)<0&&fr.call(e,n)&&(t[n]=e[n]);return t};const gn={type:"unordered",size:"md",spacing:0},Q=g.forwardRef((e,r)=>{const t=P("List",gn,e),{children:n,type:o,size:i,listStyleType:a,withPadding:s,center:c,spacing:f,icon:d,className:u,styles:m,classNames:v,unstyled:p,variant:y}=t,h=mn(t,["children","type","size","listStyleType","withPadding","center","spacing","icon","className","styles","classNames","unstyled","variant"]),{classes:x,cx:w}=fn({withPadding:s,listStyleType:a,center:c,spacing:f},{classNames:v,styles:m,name:"List",unstyled:p,size:i,variant:y});return _.createElement(qt,{value:{spacing:f,center:c,icon:d,listStyleType:a,size:i,withPadding:s,classNames:v,styles:m,unstyled:p,variant:y}},_.createElement(R,pn({component:o==="unordered"?"ul":"ol",className:w(x.root,u),ref:r},h),n))});Q.Item=cr;Q.displayName="@mantine/core/List";const ur={context:"Menu component was not found in the tree",children:"Menu.Target component children should be an element or a component that accepts ref. Fragments, strings, numbers and other primitive values are not supported"},[vn,V]=le(ur.context);var _n=C(e=>({divider:{marginTop:$(4),marginBottom:$(4),borderTop:`${$(1)} solid ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[2]}`}})),yn=Object.defineProperty,ee=Object.getOwnPropertySymbols,pr=Object.prototype.hasOwnProperty,mr=Object.prototype.propertyIsEnumerable,Ce=(e,r,t)=>r in e?yn(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,hn=(e,r)=>{for(var t in r||(r={}))pr.call(r,t)&&Ce(e,t,r[t]);if(ee)for(var t of ee(r))mr.call(r,t)&&Ce(e,t,r[t]);return e},xn=(e,r)=>{var t={};for(var n in e)pr.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&ee)for(var n of ee(e))r.indexOf(n)<0&&mr.call(e,n)&&(t[n]=e[n]);return t};const wn={},gr=g.forwardRef((e,r)=>{const t=P("MenuDivider",wn,e),{children:n,className:o}=t,i=xn(t,["children","className"]),{classNames:a,styles:s,unstyled:c,variant:f}=V(),{classes:d,cx:u}=_n(null,{name:"Menu",classNames:a,styles:s,unstyled:c,variant:f});return _.createElement(R,hn({className:u(d.divider,o),ref:r},i))});gr.displayName="@mantine/core/MenuDivider";var On=Object.defineProperty,re=Object.getOwnPropertySymbols,vr=Object.prototype.hasOwnProperty,_r=Object.prototype.propertyIsEnumerable,Ne=(e,r,t)=>r in e?On(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,$n=(e,r)=>{for(var t in r||(r={}))vr.call(r,t)&&Ne(e,t,r[t]);if(re)for(var t of re(r))_r.call(r,t)&&Ne(e,t,r[t]);return e},Pn=(e,r)=>{var t={};for(var n in e)vr.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&re)for(var n of re(e))r.indexOf(n)<0&&_r.call(e,n)&&(t[n]=e[n]);return t};const bn={};function yr(e){const r=P("MenuDropdown",bn,e),{children:t,onMouseEnter:n,onMouseLeave:o}=r,i=Pn(r,["children","onMouseEnter","onMouseLeave"]),a=g.useRef(),s=V(),c=u=>{var m;(u.key==="ArrowUp"||u.key==="ArrowDown")&&(u.preventDefault(),(m=a.current.querySelectorAll("[data-menu-item]:not(:disabled)")[0])==null||m.focus())},f=N(n,()=>s.trigger==="hover"&&s.openDropdown()),d=N(o,()=>s.trigger==="hover"&&s.closeDropdown());return _.createElement(ce.Dropdown,$n({onMouseEnter:f,onMouseLeave:d,role:"menu","aria-orientation":"vertical"},i),_.createElement("div",{tabIndex:-1,"data-menu-dropdown":!0,"data-autofocus":!0,onKeyDown:c,ref:a,style:{outline:0}},t))}yr.displayName="@mantine/core/MenuDropdown";var Sn=Object.defineProperty,jn=Object.defineProperties,En=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertySymbols,In=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable,De=(e,r,t)=>r in e?Sn(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Nn=(e,r)=>{for(var t in r||(r={}))In.call(r,t)&&De(e,t,r[t]);if(Me)for(var t of Me(r))Cn.call(r,t)&&De(e,t,r[t]);return e},Mn=(e,r)=>jn(e,En(r)),Dn=C((e,{color:r,radius:t})=>({item:Mn(Nn({},e.fn.fontStyles()),{WebkitTapHighlightColor:"transparent",fontSize:e.fontSizes.sm,border:0,backgroundColor:"transparent",outline:0,width:"100%",textAlign:"left",textDecoration:"none",boxSizing:"border-box",padding:`${e.spacing.xs} ${e.spacing.sm}`,cursor:"pointer",borderRadius:e.fn.radius(t),color:r?e.fn.variant({variant:"filled",primaryFallback:!1,color:r}).background:e.colorScheme==="dark"?e.colors.dark[0]:e.black,display:"flex",alignItems:"center","&:disabled":{color:e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[5],pointerEvents:"none",userSelect:"none"},"&[data-hovered]":{backgroundColor:r?e.fn.variant({variant:"light",color:r}).background:e.colorScheme==="dark"?e.fn.rgba(e.colors.dark[3],.35):e.colors.gray[1]}}),itemLabel:{flex:1},itemIcon:{display:"flex",justifyContent:"center",alignItems:"center",marginRight:e.spacing.xs},itemRightSection:{}})),Tn=Object.defineProperty,Rn=Object.defineProperties,Ln=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,hr=Object.prototype.hasOwnProperty,xr=Object.prototype.propertyIsEnumerable,Te=(e,r,t)=>r in e?Tn(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,kn=(e,r)=>{for(var t in r||(r={}))hr.call(r,t)&&Te(e,t,r[t]);if(te)for(var t of te(r))xr.call(r,t)&&Te(e,t,r[t]);return e},zn=(e,r)=>Rn(e,Ln(r)),An=(e,r)=>{var t={};for(var n in e)hr.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&te)for(var n of te(e))r.indexOf(n)<0&&xr.call(e,n)&&(t[n]=e[n]);return t};const Bn={},wr=g.forwardRef((e,r)=>{const t=P("MenuItem",Bn,e),{children:n,className:o,color:i,closeMenuOnClick:a,icon:s,rightSection:c}=t,f=An(t,["children","className","color","closeMenuOnClick","icon","rightSection"]),d=V(),{classes:u,cx:m,theme:v}=Dn({radius:d.radius,color:i},{name:"Menu",classNames:d.classNames,styles:d.styles,unstyled:d.unstyled,variant:d.variant}),p=g.useRef(),y=d.getItemIndex(p.current),h=f,x=N(h.onMouseLeave,()=>d.setHovered(-1)),w=N(h.onMouseEnter,()=>d.setHovered(d.getItemIndex(p.current))),j=N(h.onClick,()=>{typeof a=="boolean"?a&&d.closeDropdownImmediately():d.closeOnItemClick&&d.closeDropdownImmediately()}),D=N(h.onFocus,()=>d.setHovered(d.getItemIndex(p.current)));return _.createElement(R,zn(kn({component:"button",type:"button"},f),{tabIndex:-1,onFocus:D,className:m(u.item,o),ref:Ar(p,r),role:"menuitem","data-menu-item":!0,"data-hovered":d.hovered===y?!0:void 0,onMouseEnter:w,onMouseLeave:x,onClick:j,onKeyDown:at({siblingSelector:"[data-menu-item]",parentSelector:"[data-menu-dropdown]",activateOnFocus:!1,loop:d.loop,dir:v.dir,orientation:"vertical",onKeyDown:h.onKeydown})}),s&&_.createElement("div",{className:u.itemIcon},s),n&&_.createElement("div",{className:u.itemLabel},n),c&&_.createElement("div",{className:u.itemRightSection},c))});wr.displayName="@mantine/core/MenuItem";const Fn=ie(wr);var Hn=C(e=>({label:{color:e.colorScheme==="dark"?e.colors.dark[2]:e.colors.gray[6],fontWeight:500,fontSize:e.fontSizes.xs,padding:`calc(${e.spacing.xs} / 2) ${e.spacing.sm}`,cursor:"default"}})),Vn=Object.defineProperty,ne=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,$r=Object.prototype.propertyIsEnumerable,Re=(e,r,t)=>r in e?Vn(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Xn=(e,r)=>{for(var t in r||(r={}))Or.call(r,t)&&Re(e,t,r[t]);if(ne)for(var t of ne(r))$r.call(r,t)&&Re(e,t,r[t]);return e},Gn=(e,r)=>{var t={};for(var n in e)Or.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&ne)for(var n of ne(e))r.indexOf(n)<0&&$r.call(e,n)&&(t[n]=e[n]);return t};const Un={},Pr=g.forwardRef((e,r)=>{const t=P("MenuLabel",Un,e),{children:n,className:o}=t,i=Gn(t,["children","className"]),{classNames:a,styles:s,unstyled:c,variant:f}=V(),{classes:d,cx:u}=Hn(null,{name:"Menu",classNames:a,styles:s,unstyled:c,variant:f});return _.createElement(S,Xn({className:u(d.label,o),ref:r},i),n)});Pr.displayName="@mantine/core/MenuLabel";var Wn=Object.defineProperty,oe=Object.getOwnPropertySymbols,br=Object.prototype.hasOwnProperty,Sr=Object.prototype.propertyIsEnumerable,Le=(e,r,t)=>r in e?Wn(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,Kn=(e,r)=>{for(var t in r||(r={}))br.call(r,t)&&Le(e,t,r[t]);if(oe)for(var t of oe(r))Sr.call(r,t)&&Le(e,t,r[t]);return e},Yn=(e,r)=>{var t={};for(var n in e)br.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&oe)for(var n of oe(e))r.indexOf(n)<0&&Sr.call(e,n)&&(t[n]=e[n]);return t};const qn={refProp:"ref"},jr=g.forwardRef((e,r)=>{const t=P("MenuTarget",qn,e),{children:n,refProp:o}=t,i=Yn(t,["children","refProp"]);if(!Br(n))throw new Error(ur.children);const a=V(),s=N(n.props.onClick,()=>a.trigger==="click"&&a.toggleDropdown()),c=N(n.props.onMouseEnter,()=>a.trigger==="hover"&&a.openDropdown()),f=N(n.props.onMouseLeave,()=>a.trigger==="hover"&&a.closeDropdown());return _.createElement(ce.Target,Kn({refProp:o,popupType:"menu",ref:r},i),g.cloneElement(n,{onClick:s,onMouseEnter:c,onMouseLeave:f,"data-expanded":a.opened?!0:void 0}))});jr.displayName="@mantine/core/MenuTarget";var Zn=C({dropdown:{padding:$(4)}}),Jn=Object.defineProperty,Qn=Object.defineProperties,eo=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,Er=Object.prototype.hasOwnProperty,Ir=Object.prototype.propertyIsEnumerable,ke=(e,r,t)=>r in e?Jn(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,ze=(e,r)=>{for(var t in r||(r={}))Er.call(r,t)&&ke(e,t,r[t]);if(ae)for(var t of ae(r))Ir.call(r,t)&&ke(e,t,r[t]);return e},Ae=(e,r)=>Qn(e,eo(r)),ro=(e,r)=>{var t={};for(var n in e)Er.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&ae)for(var n of ae(e))r.indexOf(n)<0&&Ir.call(e,n)&&(t[n]=e[n]);return t};const to={closeOnItemClick:!0,loop:!0,trigger:"click",openDelay:0,closeDelay:100};function I(e){const r=P("Menu",to,e),{children:t,onOpen:n,onClose:o,opened:i,defaultOpened:a,onChange:s,closeOnItemClick:c,loop:f,closeOnEscape:d,trigger:u,openDelay:m,closeDelay:v,classNames:p,styles:y,unstyled:h,radius:x,variant:w}=r,j=ro(r,["children","onOpen","onClose","opened","defaultOpened","onChange","closeOnItemClick","loop","closeOnEscape","trigger","openDelay","closeDelay","classNames","styles","unstyled","radius","variant"]),{classes:D,cx:L}=Zn(),[k,{setHovered:z,resetHovered:A}]=it(),[E,O]=Fr({value:i,defaultValue:a,finalValue:!1,onChange:s}),M=()=>{O(!1),E&&o?.()},B=()=>{O(!0),!E&&n?.()},X=()=>E?M():B(),{openDropdown:Cr,closeDropdown:Nr}=Yt({open:B,close:M,closeDelay:v,openDelay:m}),Mr=Dr=>st("[data-menu-item]","[data-menu-dropdown]",Dr);return Hr(()=>{A()},[E]),_.createElement(vn,{value:{opened:E,toggleDropdown:X,getItemIndex:Mr,hovered:k,setHovered:z,closeOnItemClick:c,closeDropdown:u==="click"?M:Nr,openDropdown:u==="click"?B:Cr,closeDropdownImmediately:M,loop:f,trigger:u,radius:x,classNames:p,styles:y,unstyled:h,variant:w}},_.createElement(ce,Ae(ze({},j),{radius:x,opened:E,onChange:X,defaultOpened:a,trapFocus:u==="click"&&E,closeOnEscape:d&&u==="click",__staticSelector:"Menu",classNames:Ae(ze({},p),{dropdown:L(D.dropdown,p?.dropdown)}),styles:y,unstyled:h,variant:w}),t))}I.displayName="@mantine/core/Menu";I.Item=Fn;I.Label=Pr;I.Dropdown=yr;I.Target=jr;I.Divider=gr;function no({data:e,onChange:r}){const t=de(Vr,e),[n,o]=g.useState(t.accountantApproval);return g.useEffect(()=>{n==null&&t.accountantApproval!=null&&o(t.accountantApproval)},[n,t.accountantApproval]),l.jsx(Qr,{value:n,businessTripId:t.id,onChange:r})}const oo="creditShareholdersBusinessTripTravelAndSubsistence",ao=()=>{const[{fetching:e},r]=Xr(Gr),t=g.useCallback(async n=>{const o=`Error crediting shareholders for trip ID ${n.businessTripId}`,i=`${oo}-${n.businessTripId}`;se.loading("Crediting Shareholders",{id:i});try{const a=await r(n),s=Ur(a,o,i);s&&se.success("Shareholders Credited",{id:i,description:`${s.creditShareholdersBusinessTripTravelAndSubsistence.length} Corresponding charges were successfully generated`})}catch(a){console.error(`${o}: ${a}`),se.error("Error",{id:i,description:o,duration:1e5,closeButton:!0})}},[r]);return{fetching:e,creditShareholders:t}};function so({businessTripId:e}){const[r,t]=g.useState(!1),{creditShareholders:n}=ao();return l.jsxs(I,{shadow:"md",width:200,opened:r,children:[l.jsx(I.Target,{children:l.jsx(Xe,{opened:r,onClick:o=>{o.stopPropagation(),t(i=>!i)}})}),l.jsxs(I.Dropdown,{children:[l.jsx(I.Label,{children:"Summarize Trip"}),l.jsx(Wr,{onConfirm:()=>{n({businessTripId:e})},title:"Credit shareholders with travel and subsistence surplus?",children:l.jsx(I.Item,{icon:l.jsx(Kr,{size:14}),children:"Credit surplus T&S"})})]})]})}const go=({data:e,onChange:r})=>{const t=de(Zr,e),{name:n,dates:o,purpose:i,destination:a}=t;return l.jsxs(b,{children:[l.jsxs(b.Col,{span:12,className:"flex flex-row justify-between items-center",children:[l.jsx(S,{fz:"xl",children:n}),l.jsxs("div",{className:"flex flex-row gap-2",children:[l.jsx(no,{data:t,onChange:r}),l.jsx(Yr,{isLink:!0,content:`${window.location.origin}${qr.BUSINESS_TRIPS.DETAIL(t.id)}`}),l.jsx(so,{businessTripId:t.id})]})]}),l.jsxs(b.Col,{xl:2,lg:3,md:6,children:["From Date:",l.jsx(S,{fz:"lg",children:o?.start?me(new Date(o.start),"dd/MM/yy"):"Missing"})]}),l.jsxs(b.Col,{xl:2,lg:3,md:6,children:["To Date:",l.jsx(S,{fz:"lg",children:o?.end?me(new Date(o.end),"dd/MM/yy"):"Missing"})]}),l.jsxs(b.Col,{xl:2,lg:3,md:6,children:["Destination:",l.jsx(S,{fz:"lg",children:a?.name})]}),l.jsxs(b.Col,{xl:4,lg:6,md:12,orderMd:6,children:["Description:",l.jsx(S,{fz:"lg",children:i})]}),l.jsxs(b.Col,{xl:2,lg:3,md:6,children:["Total Days:",l.jsx(S,{fz:"lg",children:o?io(o.start,o.end):"Missing"})]})]})};function io(e,r){return rt(ve(new Date(r),22),ve(new Date(e),6))+1}function lo(e){return e.split("_").map(co).join(" ")}function co(e){return e.slice(0,1).toUpperCase()+e.slice(1,e.length).toLowerCase()}const vo=({data:e})=>{const{summary:r}=de(Jr,e);return r?l.jsxs("div",{className:"flex flex-col gap-2 mt-5",children:[r.errors?.length&&l.jsxs(Be,{shadow:"xs",p:"md",children:[l.jsx(S,{c:"red",children:"Errors:"}),l.jsx(Q,{size:"sm",withPadding:!0,children:r.errors.map((t,n)=>l.jsx(Q.Item,{children:l.jsx(S,{c:"red",children:t})},n))})]}),l.jsxs(et,{highlightOnHover:!0,withBorder:!0,children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:"Expense Type"}),l.jsxs("th",{children:["Total ",F(H.Usd)]}),l.jsxs("th",{children:["Total ",F(H.Ils)]}),l.jsxs("th",{children:["Max Taxable ",F(H.Usd)]}),l.jsxs("th",{children:["Taxable ",F(H.Usd)]}),l.jsxs("th",{children:["Taxable ",F(H.Ils)]}),l.jsx("th",{children:"Excess Expenditure"})]})}),l.jsx("tbody",{children:r.rows.map(t=>l.jsxs("tr",{children:[l.jsx("td",{children:lo(t.type)}),l.jsx("td",{children:t.totalForeignCurrency?.formatted}),l.jsx("td",{children:t.totalLocalCurrency?.formatted}),l.jsx("td",{children:t.maxTaxableForeignCurrency?.formatted}),l.jsx("td",{children:t.taxableForeignCurrency?.formatted}),l.jsx("td",{children:t.taxableLocalCurrency?.formatted}),l.jsx("td",{children:t.excessExpenditure?.formatted})]},t.type))})]}),l.jsxs(b,{justify:"flex-end",children:[l.jsxs(b.Col,{lg:2,md:4,children:["Excess Expenditure Tax:",l.jsxs(S,{fz:"lg",children:[r.excessTax??"0","%"]})]}),l.jsx(b.Col,{lg:2,md:3,className:"flex flex-col justify-end",children:l.jsx(S,{fz:"lg",children:r.excessExpenditure?.formatted??"0.00"})})]})]}):l.jsx(S,{children:"Loading..."})};export{Xe as B,mo as C,b as G,Q as L,I as M,go as R,vo as S};
@@ -1 +0,0 @@
1
- import{r as a,j as e,D,aL as C,bU as I,bV as E,B as p,ag as T,bW as P,x as k,dB as F,dC as A,K as v,X as f,L as N,dD as S,e as B,N as G,Q as M,dE as O,bp as R,bh as L,dF as q,g as z,t as h,i as H,dG as V}from"./index-DRqooPz9.js";function U({onApprove:u,draft:o}){const[l,r]=a.useState(!1),s=t=>{u(t),r(!1)};return e.jsxs(D,{open:l,onOpenChange:r,children:[e.jsx(C,{asChild:!0,type:"button",children:e.jsxs(I,{children:[e.jsx(E,{asChild:!0,type:"button",children:e.jsx(p,{className:"size-7.5",variant:"secondary",onClick:()=>r(t=>!t),type:"button",children:e.jsx(T,{className:"size-5"})})}),e.jsx(P,{children:e.jsx("p",{children:"Edit document"})})]})}),e.jsx(k,{className:"w-7xl sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:e.jsx("div",{className:"min-h-screen bg-gray-50 p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Edit Document"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Modify and preview your accounting document before issuing"})]}),e.jsx($,{onApprove:s,draft:o})]})})})]})}function $({onApprove:u,draft:o}){const[l,r]=a.useState(!1),[s,t]=a.useState(null),{previewDocument:d,fetching:i}=F(),[n,y]=a.useState(o),b=a.useCallback((c,m)=>{y(x=>({...x,[c]:m}))},[]);a.useEffect(()=>{r(!1)},[n]);const j=a.useCallback(async()=>{try{const c=await d({input:n});if(!c)throw new Error("No preview data returned");t(c),r(!0)}catch(c){console.error("Failed to generate preview:",c)}},[n,d]);a.useEffect(()=>{s||j()},[s,j]);const g=n.income?.reduce((c,m)=>{const x=m.price*m.quantity,w=x*((m.vatRate||0)/100);return c+x+w},0)||0;return e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(A,{formData:n,updateFormData:b}),e.jsx(v,{children:e.jsxs(f,{className:"pt-6",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(p,{onClick:j,disabled:i||l,variant:"outline",className:"flex-1 bg-transparent",children:i?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-4 h-4 mr-2"}),"Preview"]})}),e.jsxs(p,{onClick:()=>u(n),className:"flex-1",children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"Accept Changes"]})]}),g>0&&e.jsx("div",{className:"mt-4 p-3 bg-blue-50 rounded-lg",children:e.jsxs("div",{className:"flex justify-between items-center font-medium text-blue-900",children:[e.jsx("span",{children:"Total Document Amount:"}),e.jsxs("span",{children:[g.toFixed(2)," ",n.currency]})]})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(v,{className:"h-fit",children:[e.jsx(G,{children:e.jsx(M,{children:"Document Preview"})}),e.jsx(f,{children:e.jsx("div",{className:"border-2 border-dashed border-gray-200 rounded-lg min-h-[600px] flex items-center justify-center bg-gray-50",children:i?e.jsxs("div",{className:"text-center",children:[e.jsx(N,{className:"w-8 h-8 animate-spin mx-auto mb-4 text-gray-400"}),e.jsx("p",{className:"text-gray-500",children:"Generating document preview..."})]}):s?e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"bg-white shadow-lg rounded-lg overflow-hidden",children:e.jsx("div",{className:"aspect-[8.5/11] bg-white border",children:e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(O,{src:s}),!l&&e.jsx("p",{className:"text-xs text-amber-600 mt-3 bg-amber-50 px-2 py-1 rounded",children:"Preview may be outdated"})]})})})})}):e.jsxs("div",{className:"text-center",children:[e.jsx(R,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"text-gray-500 mb-2",children:"No preview available"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Click Preview to generate document"})]})})})]}),n.client&&e.jsx(L,{businessId:n.client?.id,linkedDocumentIds:n.linkedDocumentIds??[]}),e.jsx(q,{documentType:n.type})]})]})}const K="issue-monthly-documents",W=()=>{const[{fetching:u},o]=z(V),l=a.useCallback(async r=>{const s="Error issuing monthly documents",t=K;h.loading("Issuing documents",{id:t});try{const d=await o(r),i=H(d,s,t);if(i?.issueGreenInvoiceDocuments?.success){h.success("Success",{id:t,description:"Documents issued successfully"});return}i?.issueGreenInvoiceDocuments?.errors&&console.error(i.issueGreenInvoiceDocuments.errors),h.error("Error",{id:t,description:s,duration:1e5,closeButton:!0})}catch(d){console.error(`${s}: ${d}`),h.error("Error",{id:t,description:s,duration:1e5,closeButton:!0})}},[o]);return{fetching:u,issueDocuments:l}};export{$ as E,U as a,W as u};