PageSourceSearch

https://www.logistap.com/assets/FinanceHome-CwHHEaFr.js

js logistap.com collected 2026-10-02 01:35:37 UTC 33,889 bytes, 11 lines download raw bytes

1import{j as e}from"./index-CkAxGocv.js";import{r as s}from"./i18n-vendor-Co-krN6G.js";import{D as Ve}from"./DropdownSurface-DpDK6NwL.js";import{e as P,g as qe,s as We,a as Ye,h as Ge,j as Ue,f as Xe,d as Ze,k as be,l as Qe,r as fe}from"./companyFinance-Cy-kVkZF.js";import{c as Je,d as Ke}from"./permissionGuard-BRj1WUDY.js";import{T as et,a as tt}from"./Feedback-DlkCcoCE.js";import{u as Se,a as Me,t as at,b as K,f as ee,c as ge,d as re,e as te,g as st,h as O,i as rt}from"./financeShared-llUcF-Fg.js";import{S as ke}from"./sparkles-PWBhcwyB.js";import{W as ne}from"./wallet-tO41o_pz.js";import{L as nt}from"./landmark-DxA-n09b.js";import{c as Te}from"./createLucideIcon-BPd9wT8k.js";import{L as D}from"./react-vendor-D5E1hOjb.js";import{C as lt}from"./check-Dmd9WXya.js";import{A as je,a as ye,S as ot,F as ct}from"./FinanceQuickEntry-B1IY6Htm.js";import{G as dt}from"./GlobalDocumentModal-DZG8uXtI.js";import{P as it}from"./package-CrSNysU4.js";import{S as mt}from"./settings-2-CLpqIIFa.js";import{H as xt}from"./history-mGc1fu6Y.js";import{C as U}from"./chevron-right-B7wd-Mqk.js";import{A as we}from"./arrow-up-right-CQ-vdLu5.js";import{R as ht}from"./receipt-text-DrkvIWrT.js";import{S as ut}from"./scale-D6wVamen.js";import{C as Ae}from"./calendar-clock-CeWo-FHZ.js";import{E as pt}from"./ellipsis-DRehdTD6.js";import{P as bt}from"./paperclip-314kDu4j.js";import{F as Ne}from"./file-pen-line-CWIubxiM.js";import{T as ft}from"./trash-2-Dqc_E09R.js";import{U as gt}from"./undo-2-LfH1ogC1.js";import{C as kt}from"./chevron-down-dM4Lsy2M.js";import{C as jt}from"./chevron-left-CMJUBmiW.js";import{P as yt}from"./plus-kWcs1cQG.js";import{T as wt}from"./trending-up-BKhxdD8F.js";import"./supabase-vendor-Co_IX6oM.js";import"./loader-circle-BnjBO311.js";import"./x-vmD7m2IU.js";import"./info-DPZ067dm.js";import"./circle-alert-ENI3C5U8.js";import"./circle-check-Doi6ea3z.js";import"./refresh-cw-BvuhVw-0.js";import"./sliders-horizontal-Bexp6hhj.js";import"./FinanceQuickAdd-SIxeRL3b.js";import"./financeDateRules-Cy0oLmkL.js";import"./chevron-up-C_ovFRxy.js";import"./globalDocuments-DfK9f5uV.js";import"./documentWarningSettings-DSXYxoo4.js";import"./documentCompliance-Uez4h3Bj.js";import"./employeeDocumentOcr-D3pLfBnL.js";import"./dateFormatting-BQ_Cyswc.js";import"./documentDownload-y9Y71sKx.js";import"./employeePhotos-Bk2b9ZIj.js";import"./fileUploadPolicy-Dsb_MFV2.js";import"./browserCache-CpZow4D-.js";import"./employeeData-C8aL7inU.js";import"./employeeStore-DaTEjH3m.js";import"./employees-CZ6YCCge.js";import"./vehicleStore-Bv4yO8k3.js";import"./upload-CSd9GWjy.js";import"./minus-ydyAg4tj.js";import"./download-Cj8OUOB8.js";import"./triangle-alert-JFzfoOgH.js";import"./save-rkWxRPRI.js";/**
2 * @license lucide-react v1.11.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Nt=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],vt=Te("boxes",Nt);/**
7 * @license lucide-react v1.11.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ct=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}]],St=Te("list-checks",Ct);function ae({children:t,description:o,done:c,index:i,title:l}){return e.jsxs("div",{className:"flex gap-3 px-4 py-4",children:[e.jsx("span",{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-xs font-black ${c?"bg-emerald-600 text-white":"border border-slate-300 text-slate-500 dark:border-slate-600 dar
11k:text-slate-400"}`,children:c?e.jsx(lt,{size:16}):i}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`text-sm font-black ${c?"text-slate-400 line-through dark:text-slate-500":"text-slate-950 dark:text-white"}`,children:l}),e.jsx("p",{className:"mt-0.5 text-xs font-semibold leading-5 text-slate-500 dark:text-slate-400",children:o}),!c&&t&&e.jsx("div",{className:"mt-3",children:t})]})]})}function Mt({accounts:t,canAdmin:o,categories:c,hasTransactions:i,onCommitted:l,onRecordFirst:m}){const{tr:n}=Se(),{error:x,execute:N,pending:p,retryTask:f}=Me(l),[r,h]=s.useState("Cash"),[M,F]=s.useState("Cash"),[S,I]=s.useState("0"),[v,C]=s.useState(at()),[b,y]=s.useState(""),w=t.length>0,T=c.length>0,$=async()=>{if(!r.trim()){y(n("Give the account a name."));return}y("");const g=P(),E=P(),z=P();await N(()=>qe({accountRequestId:g,categoryRequestId:E,transactionRequestId:z,name:r.trim(),accountType:M,accountReference:null,openingBalance:S,asOfDate:v}),"Account added.")},j=async()=>{y(""),await N(()=>We({includeCashAccount:!1}),"Standard categories added.")};return o?e.jsxs("section",{className:"overflow-hidden rounded-lg border border-emerald-200 bg-white dark:border-emerald-900/70 dark:bg-slate-900",children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-emerald-100 bg-emerald-50/70 px-4 py-3 dark:border-emerald-900/50 dark:bg-emerald-950/20",children:[e.jsx(ke,{size:17,className:"text-emerald-600"}),e.jsx("h2",{className:"text-sm font-black text-slate-950 dark:text-white",children:n("Set up finance in three steps")}),e.jsxs("span",{className:"ms-auto text-xs font-black text-emerald-700 dark:text-emerald-300",children:[[w,T,i].filter(Boolean).length,"/3"]})]}),e.jsxs("div",{className:"divide-y divide-slate-100 dark:divide-slate-800",children:[e.jsx(ae,{done:w,index:1,title:n("Add the account your money sits in"),description:n("A cash box or a bank account. You can add more later."),children:e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 sm:items-end lg:grid-cols-[1fr_auto_10rem_10rem_auto]",children:[e.jsx(K,{label:n("Account name"),children:e.jsx("input",{value:r,onChange:g=>h(g.target.value),className:ee})}),e.jsx("div",{className:"grid grid-cols-2 gap-1 rounded-lg bg-slate-100 p-1 dark:bg-slate-950 sm:mb-0",children:["Cash","Bank"].map(g=>e.jsxs("button",{type:"button",onClick:()=>F(g),className:`inline-flex h-8 items-center justify-center gap-1.5 rounded-md px-3 text-xs font-black ${M===g?"bg-white text-slate-900 shadow-sm dark:bg-slate-800 dark:text-white":"text-slate-500"}`,children:[g==="Cash"?e.jsx(ne,{size:14}):e.jsx(nt,{size:14}),n(g)]},g))}),e.jsx(K,{label:n("Opening Balance"),children:e.jsx("input",{type:"number",min:"0",step:"0.01",value:S,onChange:g=>I(g.target.value),className:ee})}),e.jsx(K,{label:n("As of Date"),children:e.jsx("input",{type:"date",value:v,onChange:g=>C(g.target.value),className:ee})}),e.jsx(ge,{pending:p,type:"button",onClick:()=>void $(),children:n("Add account")})]})}),e.jsx(ae,{done:T,index:2,title:n("Add categories so money can be labelled"),description:n("Fuel, salary, rent and the rest. Nothing is locked in — rename or switch any of them off later."),children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(ge,{pending:p,type:"button",onClick:()=>void j(),children:[e.jsx(St,{size:15}),n("Use the standard categories")]}),e.jsx(D,{to:"/finance/company/setup",className:"text-xs font-black text-slate-500 underline underline-offset-4 hover:text-slate-800 dark:hover:text-slate-200",children:n("I will add my own")})]})}),e.jsx(ae,{done:i,index:3,title:n("Record your first transaction"),description:n("Try it with a real expense, like fuel."),children:e.jsx("button",{type:"button",disabled:!w||!T,onClick:m,className:"inline-flex h-10 items-center gap-2 rounded-lg border border-slate-300 px-4 text-xs font-black text-slate-700 hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-600 dark:text-slate-200 dark:hover:bg-slate-800",children:n("Record money out")})})]}),(!!b||!!x)&&e.jsxs("div",{className:"space-y-2 border-t border-slate-100 px-4 py-3 dark:border-slate-800",children:[b&&e.jsx("p",{className:"text-xs font-bold text-red-600 dark:text-red-400",children:b}),e.jsx(re,{error:x,onRetry:f??void 0,retrying:p})]})]}):e.jsx("section",{className:"rounded-lg border border-amber-200 bg-amber-50 p-5 dark:border-amber-900/70 dark:bg-amber-950/30",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ke,{size:19,className:"mt-0.5 shrink-0 text-amber-600"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-black text-amber-900 dark:text-amber-100",children:n("Finance is not set up yet")}),e.jsx("p",{className:"mt-1 text-xs font-semibold leading-5 text-amber-800 dark:text-amber-200",children:n("An administrator needs to add an account and categories before money can be recorded here.")})]})]})})}const Tt={blue:"border-blue-100 hover:border-blue-300 dark:border-slate-800 dark:hover:border-blue-800",amber:"border-amber-100 hover:border-amber-300 dark:border-slate-800 dark:hover:border-amber-800",emerald:"border-emerald-100 hover:border-emerald-300 dark:border-slate-800 dark:hover:border-emerald-800",slate:"border-slate-200 hover:border-slate-300 dark:border-slate-800 dark:hover:border-slate-700"}
11,At={blue:"bg-blue-50 text-blue-600 dark:bg-blue-950/30 dark:text-blue-300",amber:"bg-amber-50 text-amber-600 dark:bg-amber-950/30 dark:text-amber-300",emerald:"bg-emerald-50 text-emerald-600 dark:bg-emerald-950/30 dark:text-emerald-300",slate:"bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-300"},Ft=56,Et=20,Rt=100;function ve({badge:t,description:o,disabled:c,Icon:i,label:l,onClick:m,to:n,tone:x}){const N={emerald:"border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900/70 dark:bg-emerald-950/30 dark:text-emerald-300",red:"border-red-200 bg-red-50 text-red-700 dark:border-red-900/70 dark:bg-red-950/30 dark:text-red-300",amber:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900/70 dark:bg-amber-950/30 dark:text-amber-300",blue:"border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900/70 dark:bg-blue-950/30 dark:text-blue-300",slate:"border-slate-200 bg-slate-100 text-slate-600 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-300"}[x],p=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl border ${N}`,children:e.jsx(i,{size:21})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-sm font-black text-slate-950 dark:text-white",children:l}),t!==void 0&&t>0&&e.jsx("span",{className:"rounded-full bg-red-600 px-1.5 py-0.5 text-[10px] font-black leading-none text-white",children:t})]}),e.jsx("span",{className:"mt-0.5 block truncate text-xs font-semibold leading-5 text-slate-500 dark:text-slate-400",children:o})]}),!c&&e.jsx(U,{size:17,className:"shrink-0 text-slate-300 dark:text-slate-600"})]}),f="flex min-h-[76px] items-center gap-3 rounded-xl border bg-white p-3.5 text-start transition dark:bg-slate-900",r=c?"cursor-not-allowed border-slate-200 opacity-50 dark:border-slate-800":"border-slate-200 hover:-translate-y-0.5 hover:border-emerald-300 hover:shadow-md dark:border-slate-800 dark:hover:border-emerald-800";return n&&!c?e.jsx(D,{to:n,className:`${f} ${r}`,children:p}):e.jsx("button",{type:"button",disabled:c,onClick:m,className:`${f} ${r}`,children:p})}const le=t=>`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}`;function Ce(t){const[o,c]=t.split("-"),i=Number(o),l=Number(c),m=new Date(i,l,0).getDate();return{start:`${t}-01`,end:`${t}-${String(m).padStart(2,"0")}`}}function Fe(t,o){const[c,i]=t.split("-").map(Number);return new Intl.DateTimeFormat(o==="ar"?"ar-SA-u-nu-latn":"en-GB",{month:"short",year:"numeric"}).format(new Date(c,i-1,1))}function Dt({value:t,onChange:o,language:c,label:i}){const[l,m]=s.useState(!1),n=s.useMemo(()=>new Date,[]),x=n.getFullYear(),N=n.getMonth(),[p,f]=s.useMemo(()=>t.split("-").map(Number),[t]),[r,h]=s.useState(p),M=s.useRef(null),F=s.useRef(null),S=x-4;s.useEffect(()=>{l&&h(p)},[l,p]);const I=s.useMemo(()=>new Intl.DateTimeFormat(c==="ar"?"ar-SA-u-nu-latn":"en-GB",{month:"short"}),[c]);return e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs("button",{ref:M,type:"button",onClick:()=>m(v=>!v),"aria-label":i,"aria-expanded":l,className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-2.5 text-xs font-black text-slate-700 shadow-sm transition hover:border-emerald-300 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-200",children:[e.jsx(Ae,{size:14,className:"shrink-0 text-emerald-600 dark:text-emerald-400"}),Fe(t,c),e.jsx(kt,{size:13,className:`shrink-0 text-slate-400 transition-transform ${l?"rotate-180":""}`})]}),e.jsxs(Ve,{anchorRef:M,menuRef:F,menuId:"finance-home-month-picker",open:l,onRequestClose:()=>m(!1),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-slate-100 px-2 py-2 dark:border-slate-800",children:[e.jsx("button",{type:"button",onClick:()=>h(v=>Math.max(S,v-1)),disabled:r<=S,className:"flex h-7 w-7 items-center justify-center rounded-md text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-30 dark:text-slate-400 dark:hover:bg-slate-800",children:e.jsx(jt,{size:16})}),e.jsx("span",{className:"text-sm font-black text-slate-800 dark:text-slate-100",children:r}),e.jsx("button",{type:"button",onClick:()=>h(v=>Math.min(x,v+1)),disabled:r>=x,className:"flex h-7 w-7 items-center justify-center rounded-md text-slate-500 transition hover:bg-slate-100 disabled:cursor-not-allowed disabled:opacity-30 dark:text-slate-400 dark:hover:bg-slate-800",children:e.jsx(U,{size:16})})]}),e.jsx("div",{className:"grid min-h-0 flex-1 grid-cols-3 gap-1.5 overflow-y-auto p-2.5",children:Array.from({length:12},(v,C)=>{const b=r===x&&C>N,y=r===p&&C+1===f,w=r===x&&C===N;return e.jsx("button",{type:"button",disabled:b,onClick:()=>{o(`${r}-${String(C+1).padStart(2,"0")}`),m(!1)},className:`rounded-lg px-2 py-2 text-xs font-black transition ${y?"bg-emerald-600 text-white shadow-sm":b?"cursor-not-allowed text-slate-300 dark:text-slate-700":w?"border border-emerald-300 text-emerald-700 hover:bg-emerald-50 dark:border-emerald-800 dark:text-emerald-300 dark:hover:bg-emerald-950/30":"text-slate-600 hover:bg-slate-100 dar
11k:text-slate-300 dark:hover:bg-slate-800"}`,children:I.format(new Date(r,C,1))},C)})})]})]})}function se({Icon:t,label:o,value:c,caption:i,tone:l,actionLabel:m,actionDisabled:n,actionTo:x,onAction:N,ActionIcon:p=yt}){const f={emerald:{shell:"border-emerald-200 bg-emerald-50/70 dark:border-emerald-900/60 dark:bg-emerald-950/20",icon:"bg-white text-emerald-600 dark:bg-slate-900 dark:text-emerald-300",action:"bg-emerald-600 text-white hover:bg-emerald-700"},red:{shell:"border-red-200 bg-red-50/70 dark:border-red-900/60 dark:bg-red-950/20",icon:"bg-white text-red-600 dark:bg-slate-900 dark:text-red-300",action:"bg-red-600 text-white hover:bg-red-700"},slate:{shell:"border-slate-200 bg-slate-50/60 dark:border-slate-800 dark:bg-slate-900/40",icon:"bg-white text-slate-500 dark:bg-slate-900 dark:text-slate-300",action:"bg-slate-800 text-white hover:bg-slate-900 dark:bg-slate-700 dark:hover:bg-slate-600"}}[l],r=`finance-kpi-action flex h-9 min-w-9 grow basis-9 items-center sm:basis-full justify-center gap-1.5 rounded-lg text-xs font-black transition ${n?"cursor-not-allowed bg-slate-100 text-slate-400 dark:bg-slate-800 dark:text-slate-600":f.action}`,h=e.jsxs(e.Fragment,{children:[e.jsx(p,{size:13,strokeWidth:x?2.5:3,className:"shrink-0"}),e.jsx("span",{className:"finance-kpi-action-label",children:m})]});return e.jsx("div",{className:`finance-kpi-card min-w-0 rounded-xl border-2 p-3 ${f.shell}`,children:e.jsxs("div",{className:"flex flex-wrap items-start gap-x-2 gap-y-3",children:[e.jsxs("div",{className:"flex min-w-0 grow-[1000] items-center gap-2.5",children:[e.jsx("span",{className:`finance-kpi-icon h-9 w-9 shrink-0 items-center justify-center rounded-full shadow-sm ${f.icon}`,children:e.jsx(t,{size:16})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[11px] font-black text-slate-500 dark:text-slate-400",children:o}),e.jsx("p",{className:"text-sm font-black leading-tight text-slate-950 dark:text-white",children:c}),e.jsx("p",{className:"w-0 min-w-full text-[10px] font-semibold leading-tight text-slate-400 dark:text-slate-500",children:i})]})]}),x&&!n?e.jsx(D,{to:x,className:r,"aria-label":m,title:m,children:h}):e.jsx("button",{type:"button",disabled:n,onClick:N,className:r,"aria-label":m,title:m,children:h})]})})}function It(t,o){const[c,i]=t.split("-").map(Number);return le(new Date(c,i-1+o,1))}const oe=6;function $t({data:t,language:o,isRtl:c,loading:i,tr:l}){const p=s.useMemo(()=>new Intl.DateTimeFormat(o==="ar"?"ar-SA-u-nu-latn":"en-GB",{month:"short"}),[o]),f=s.useMemo(()=>{const r=c?[...t].reverse():t,h=640/Math.max(r.length,1),M=r.reduce((b,y)=>Math.max(b,y.summary.income,y.summary.expense),0),F=Math.max(M,1),S=114,I=h*.28,v=h*.06;return{bars:r.map((b,y)=>{const w=y*h+h/2,T=b.summary.income/F*S,$=b.summary.expense/F*S,[j,g]=b.monthKey.split("-").map(Number);return{monthKey:b.monthKey,centerX:w,incomeHeight:T,expenseHeight:$,barWidth:I,gap:v,label:p.format(new Date(j,g-1,1))}})}},[t,c,p]);return e.jsxs("div",{className:"shrink-0 rounded-xl border border-slate-200 bg-white p-4 dark:border-slate-800 dark:bg-slate-900",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-wide text-slate-400",children:l("Trend")}),e.jsx("h3",{className:"truncate text-sm font-black text-slate-950 dark:text-white",children:l("Money flow, last 6 months")})]}),e.jsx("span",{className:"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300",children:e.jsx(wt,{size:16})}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-black text-slate-500 dark:text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-emerald-500"}),l("Money In")]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-red-500"}),l("Money Out")]})]})]}),i?e.jsx("div",{className:"flex h-[11rem] animate-pulse items-end justify-center gap-3 px-4",children:Array.from({length:oe},(r,h)=>e.jsx("span",{style:{height:`${30+h*17%60}%`}
11,className:"w-8 rounded-t-md bg-slate-100 dark:bg-slate-800"},h))}):e.jsxs("svg",{role:"img","aria-label":l("Money flow, last 6 months"),viewBox:"0 0 640 176",className:"h-[11rem] w-full",children:[[14,142/2,128].map(r=>e.jsx("line",{x1:"0",x2:640,y1:r,y2:r,stroke:"currentColor",className:"text-slate-100 dark:text-slate-800",strokeDasharray:"3 5",vectorEffect:"non-scaling-stroke"},r)),f.bars.map(r=>e.jsxs("g",{children:[e.jsx("rect",{x:r.centerX-r.barWidth-r.gap/2,y:128-r.incomeHeight,width:r.barWidth,height:Math.max(r.incomeHeight,1.5),rx:"3",fill:"#10b981"}),e.jsx("rect",{x:r.centerX+r.gap/2,y:128-r.expenseHeight,width:r.barWidth,height:Math.max(r.expenseHeight,1.5),rx:"3",fill:"#ef4444"}),e.jsx("text",{x:r.centerX,y:148,textAnchor:"middle",className:"fill-slate-500 text-[10px] font-bold dark:fill-slate-400",children:r.label})]},r.monthKey))]})]})}function zt(t){const o=s.useRef(null),[c,i]=s.useState(5);return s.useLayoutEffect(()=>{const l=o.current;if(!l)return;const m=()=>{const x=l.clientHeight,N=Math.floor(x/Ft);i(Math.max(1,Math.min(t,N)))};m();const n=new ResizeObserver(m);return n.observe(l),()=>n.disconnect()},[t]),{bodyRef:o,visibleCount:c}}function qa(){const{tr:t,language:o}=Se(),c=Je("company_finance"),i=Ke("company_finance"),[l,m]=s.useState([]),[n,x]=s.useState([]),[N,p]=s.useState([]),[f,r]=s.useState([]),[h,M]=s.useState(!1),[F,S]=s.useState(!0),[I,v]=s.useState(null),[C,b]=s.useState(null),[y,w]=s.useState(null),[T,$]=s.useState(null),[j,g]=s.useState(()=>le(new Date)),E=s.useCallback(async()=>{S(!0),v(null);try{const[a,k,d,u,_]=await Promise.all([Ye(),Ge(),Ue(),Xe(),Ze()]);m(a),x(k),p(d),r(u),M(_.length>0)}catch(a){v(a)}finally{S(!1)}},[]);s.useEffect(()=>{E()},[E]);const z=s.useRef(new Map),[A,ce]=s.useState(null),[H,X]=s.useState(!0),[de,Z]=s.useState(null),V=s.useCallback(async(a,k)=>{const d=z.current.get(a);if(d&&!(k!=null&&k.force)){ce(d),Z(null),X(!1);return}X(!0),Z(null);try{const{start:u,end:_}=Ce(a),[J,G]=await Promise.all([be(u,_),Qe({dateFrom:u,dateTo:_,page:1,pageSize:Rt})]),L={summary:J,entries:G.items};z.current.set(a,L),ce(L)}catch(u){Z(u)}finally{X(!1)}},[]);s.useEffect(()=>{V(j)},[j,V]);const q=s.useRef(new Map),[Ee,Re]=s.useState([]),[De,ie]=s.useState(!0);s.useEffect(()=>{let a=!1;const k=Array.from({length:oe},(d,u)=>It(j,u-(oe-1)));return ie(!0),Promise.all(k.map(async d=>{var L;const u=q.current.get(d)??((L=z.current.get(d))==null?void 0:L.summary);if(u)return q.current.set(d,u),{monthKey:d,summary:u};const{start:_,end:J}=Ce(d),G=await be(_,J);return q.current.set(d,G),{monthKey:d,summary:G}})).then(d=>{a||(Re(d),ie(!1))}),()=>{a=!0}},[j,A]);const R=Me(async()=>{z.current.clear(),q.current.clear(),await Promise.all([E(),V(j,{force:!0})])}),Ie=s.useMemo(()=>l.reduce((a,k)=>a+k.balance,0),[l]),W=s.useMemo(()=>(A==null?void 0:A.entries)??[],[A]),me=s.useMemo(()=>W.filter(a=>a.status==="Draft").length,[W]),Q=s.useMemo(()=>W.filter(a=>a.status!=="Draft").slice(0,Et),[W]),xe=s.useMemo(()=>f.filter(a=>a.remainingAmount>0&&a.dueStatus!=="Cancelled").length,[f]),$e=s.useMemo(()=>f.filter(a=>a.dueStatus==="Overdue").length,[f]),ze=s.useMemo(()=>le(new Date),[]),Y=j===ze,B=(A==null?void 0:A.summary)??{income:0,expense:0,net:0,closingBalance:0},_e=Y?Ie:B.closingBalance,he=Fe(j,o),ue=l.length===0||n.length===0||!h,pe=c&&l.length>0&&n.length>0,Be=c&&l.filter(a=>a.status==="Active").length>=2,{bodyRef:Le,visibleCount:Oe}=zt(Q.length),Pe=async a=>{w(null);const k=P();await R.execute(()=>fe("finance_post_transaction",{requestId:k,transactionId:a.id,expectedVersion:a.lockVersion}),"Transaction posted successfully.")},He=async a=>{w(null);const k=P();await R.execute(()=>fe("finance_discard_transaction_draft",{requestId:k,transactionId:a.id,expectedVersion:a.lockVersion}),"Draft discarded successfully.")};return s.useEffect(()=>{if(!y)return;const a=()=>w(null);return document.addEventListener("click",a),()=>document.removeEventListener("click",a)},[y]),F||H&&!A?e.jsxs(e.Fragment,{children:[e.jsx(te,{title:t("Company Finance")}),e.jsx(et,{rows:6,columns:4})]}):I?e.jsxs(e.Fragment,{children:[e.jsx(te,{title:t("Company Finance")}),e.jsx(tt,{message:t("Company Finance could not be loaded."),onRetry:()=>void E()})]}):e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[e.jsx(te,{title:t("Company Finance")}),!!(R.success||R.error)&&e.jsxs("div",{className:"shrink-0 space-y-2",children:[e.jsx(st,{message:R.success}),e.jsx(re,{error:R.error,onRetry:R.retryTask??void 0,retrying:R.pending})]}),e.jsxs("div",{className:"grid shrink-0 gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]",children:[e.jsxs("div",{className:"flex min-h-0 flex-col gap-3",children:[e.jsxs("div",{className:"flex shrink-0 flex-wrap-reverse items-end justify-between gap-x-2 gap-y-3 rounded-xl border border-emerald-200 bg-emerald-50/70 p-3 dark:border-emerald-900/60 dark:bg-emerald-950/20 sm:p-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsxs("span",{className:"flex h-12 w-12 shrink-0 items-center justify-center rounded-2xl bg-white text-emerald-600 shadow-sm dark:bg-slate-900 dark:text-emerald-400 xl:h-14 xl:w-14",children:[e.jsx(ne,{size:24,className:"xl:hidden"}),e.jsx(ne,{size:28,className:"hidden xl:block"})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-wide text-emerald-800/70 dark:text-emerald-300/70 xl:text-xs",children:t(Y?"Company balance":"Closing balance")}),e.jsx("p",{className:`mt-0.5 text-xl font-black text-slate-950 dar
11k:text-white xl:text-2xl ${H?"opacity-50":""}`,children:O(_e,o)}),e.jsx("p",{className:"mt-0.5 w-0 min-w-full text-[11px] font-semibold text-emerald-800/60 dark:text-emerald-300/60 xl:text-xs",children:Y?t("Current available balance"):`${t("As of the end of")} ${he}`})]})]}),e.jsx(Dt,{value:j,onChange:g,language:o,label:t("Select month")})]}),e.jsx("nav",{"aria-label":t("More finance tools"),className:"finance-nav-grid grid min-h-0 flex-1 auto-rows-fr gap-2",children:[{Icon:it,label:t("Assets"),to:"/finance/company/assets",tone:"blue"},{Icon:vt,label:t("Stock"),to:"/finance/company/inventory",tone:"amber"},{Icon:mt,label:t("Accounts"),to:"/finance/company/setup",tone:"emerald"},{Icon:xt,label:t("History"),to:"/finance/company/history",tone:"slate"}].map(({Icon:a,label:k,to:d,tone:u})=>e.jsxs(D,{to:d,className:`finance-nav-tile group flex items-center gap-2.5 rounded-xl border-2 bg-white px-3 py-3 text-xs font-black text-slate-800 shadow-sm transition hover:-translate-y-0.5 hover:shadow-md dark:bg-slate-900 dark:text-slate-100 ${Tt[u]}`,children:[e.jsx("span",{className:`finance-nav-icon h-9 w-9 shrink-0 items-center justify-center rounded-lg ${At[u]}`,children:e.jsx(a,{size:17})}),e.jsx("span",{className:"min-w-0 flex-1 break-normal leading-tight",children:k}),e.jsx(U,{size:14,className:"shrink-0 text-slate-300 transition group-hover:translate-x-0.5 dark:text-slate-600"})]},d))})]}),e.jsx("div",{className:"flex min-h-0 flex-col",children:ue?e.jsx(Mt,{accounts:l,canAdmin:i,categories:n,hasTransactions:h,onCommitted:E,onRecordFirst:()=>b("Expense")}):e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white p-4 dark:border-slate-800 dark:bg-slate-900",children:[e.jsxs("p",{className:"text-[10px] font-black uppercase tracking-wide text-slate-400",children:[t(Y?"This month":"Selected month")," (",he,")"]}),de?e.jsx("div",{className:"mt-3",children:e.jsx(re,{error:de,onRetry:()=>void V(j,{force:!0}),retrying:H})}):e.jsxs("div",{className:`mt-3 grid grid-cols-1 gap-2 sm:grid-cols-3 ${H?"opacity-50":""}`,children:[e.jsx(se,{Icon:je,tone:"emerald",label:t("Money In"),value:O(B.income,o),caption:t("Total received"),actionLabel:t("Add Income"),actionDisabled:!pe,onAction:()=>b("Income")}),e.jsx(se,{Icon:we,tone:"red",label:t("Money Out"),value:O(B.expense,o),caption:t("Total paid"),actionLabel:t("Add Expense"),actionDisabled:!pe,onAction:()=>b("Expense")}),e.jsx(se,{Icon:ut,tone:"slate",label:t("Net flow"),value:`${B.net<0?"−":"+"}${O(Math.abs(B.net),o)}`,caption:t("Income minus expenses"),actionLabel:t("See records"),ActionIcon:ht,actionTo:`/finance/company/transactions?month=${j}`})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsx(ve,{Icon:Ae,label:t("Pay a bill"),description:xe>0?`${xe} ${t("payments still open")}`:t("Bills, rent, and installments."),tone:"amber",badge:$e,to:"/finance/company/commitments"}),e.jsx(ve,{Icon:ye,label:t("Transfer"),description:t("Move money between company accounts without changing income or expenses."),tone:"blue",disabled:!Be,to:"/finance/company/transactions?transfer=1"})]})]})})]}),!ue&&e.jsx("div",{className:"finance-lower-split-container flex min-h-0 flex-1 flex-col",children:e.jsxs("div",{className:"finance-lower-split flex min-h-0 flex-1 flex-col gap-3",children:[e.jsx("div",{className:"finance-lower-chart shrink-0",children:e.jsx($t,{data:Ee,language:o,isRtl:o==="ar",loading:De,tr:t})}),e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-slate-800 dark:bg-slate-900",children:[e.jsxs("header",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-slate-100 px-4 py-3 dark:border-slate-800",children:[e.jsx("h3",{className:"text-sm font-black text-slate-950 dark:text-white",children:t("Latest entries")}),e.jsx(D,{to:`/finance/company/transactions?month=${j}`,className:"text-xs font-black text-emerald-700 dark:text-emerald-400",children:t("View all")})]}),e.jsx("div",{ref:Le,className:"min-h-0 flex-1 overflow-hidden",children:Q.length===0?e.jsx("p",{className:"px-4 py-8 text-center text-sm font-bold text-slate-500",children:t("Nothing recorded yet.")}):e.jsx("div",{className:"h-full overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[28rem] table-fixed border-collapse text-start",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-100 text-[11px] font-black uppercase tracking-wide text-slate-400 dark:border-slate-800",children:[e.jsx("th",{scope:"col",className:"w-8 px-3 py-2 text-start",children:"#"}),e.jsx("th",{scope:"col",className:"w-20 px-2 py-2 text-start",children:t("Date")}),e.jsx("th",{scope:"col",className:"w-24 px-2 py-2 text-start",children:t("Type")}),e.jsx("th",{scope:"col",className:"px-2 py-2 text-start",children:t("Details")}),e.jsx("th",{scope:"col",className:"w-28 px-2 py-2 text-end",children:t("Amount")}),e.jsx("th",{scope:"col",className:"w-10 px-2 py-2",children:e.jsx("span",{className:"sr-only",children:t("Actions")})})]})}
11),e.jsx("tbody",{className:"divide-y divide-slate-100 dark:divide-slate-800",children:Q.slice(0,Oe).map((a,k)=>{const d=a.entryKind==="Transfer";return e.jsxs("tr",{className:"h-14",children:[e.jsx("td",{className:"px-3 text-xs font-bold text-slate-400",children:k+1}),e.jsx("td",{className:"px-2 text-[11px] font-semibold text-slate-500",children:rt(a.transactionDate,o)}),e.jsx("td",{className:"px-2",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-lg px-2 py-1 text-[11px] font-black ${d?"bg-blue-50 text-blue-600 dark:bg-blue-950/30":a.direction==="Income"?"bg-emerald-50 text-emerald-600 dark:bg-emerald-950/30":"bg-red-50 text-red-600 dark:bg-red-950/30"}`,children:[d?e.jsx(ye,{size:14}):a.direction==="Income"?e.jsx(je,{size:14}):e.jsx(we,{size:14}),d?t("Transfer"):a.direction==="Income"?t("Income"):t("Expense")]})}),e.jsx("td",{className:"truncate px-2 text-xs font-black text-slate-800 dark:text-slate-200",children:d?`${a.accountName} → ${a.toAccountName}`:a.note||a.referenceNo||t("Transaction")}),e.jsx("td",{className:`px-2 text-end text-sm font-black ${d?"text-blue-600":a.direction==="Income"?"text-emerald-600":"text-red-600"}`,children:O(a.amount,o)}),e.jsxs("td",{className:"relative px-2 text-end",children:[!d&&e.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),w(y===a.id?null:a.id)},className:"ms-auto flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-slate-400 hover:bg-slate-100 dark:hover:bg-slate-800","aria-label":t("Actions"),children:e.jsx(pt,{size:17})}),!d&&y===a.id&&e.jsxs("div",{onClick:u=>u.stopPropagation(),className:"absolute end-4 top-12 z-30 w-48 overflow-hidden rounded-lg border border-slate-200 bg-white p-1 text-start shadow-xl dark:border-slate-700 dark:bg-slate-900",children:[e.jsxs("button",{type:"button",onClick:()=>{$({id:a.id,note:a.note}),w(null)},className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-start text-xs font-bold hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx(bt,{size:14})," ",t("Supporting Document")]}),a.status==="Draft"&&c&&e.jsxs(e.Fragment,{children:[e.jsxs(D,{to:`/finance/company/transactions?edit=${a.id}`,onClick:()=>w(null),className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-start text-xs font-bold hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx(Ne,{size:14})," ",t("Edit this draft")]}),e.jsxs("button",{type:"button",onClick:()=>void Pe(a),className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-start text-xs font-bold text-emerald-700 hover:bg-emerald-50 dark:text-emerald-400 dark:hover:bg-emerald-950/30",children:[e.jsx(ot,{size:14})," ",t("Confirm it")]}),e.jsxs("button",{type:"button",onClick:()=>void He(a),className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-start text-xs font-bold text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/30",children:[e.jsx(ft,{size:14})," ",t("Throw the draft away")]})]}),a.status==="Posted"&&!a.reversesTransactionId&&i&&e.jsxs(D,{to:`/finance/company/transactions?correct=${a.id}`,onClick:()=>w(null),className:"flex w-full items-center gap-2 rounded-md px-3 py-2 text-start text-xs font-bold hover:bg-slate-100 dark:hover:bg-slate-800",children:[e.jsx(gt,{size:14})," ",t("Correct Transaction")]})]})]})]},a.id)})})]})})}),me>0&&e.jsxs(D,{to:`/finance/company/transactions?month=${j}`,className:"flex shrink-0 items-center gap-2 border-t border-slate-100 px-4 py-2.5 text-xs font-black text-slate-500 hover:bg-slate-50 dark:border-slate-800 dark:hover:bg-slate-800/60",children:[e.jsx(Ne,{size:14}),me," ",t("unfinished drafts"),e.jsx(U,{size:14,className:"ms-auto"})]})]})]})}),e.jsx(ct,{accounts:l,categories:n,direction:C??"Expense",onClose:()=>b(null),onCommitted:E,open:C!==null,parties:N}),T&&e.jsx(dt,{isOpen:!0,identity:{ownerType:"finance_transaction",ownerId:T.id,documentType:"supportingDocument"},title:t("Supporting Document"),noteOverride:t("Upload a receipt, invoice, or other supporting document."),currentData:{note:T.note},onClose:()=>$(null)})]})}export{qa as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.