PageSourceSearch

https://vizops360.ai/assets/revenue-Dm5NYkjW.js

js vizops360.ai collected 2026-10-05 13:51:16 UTC 13,407 bytes, 3 lines download raw bytes

1import{d3 as ke,j as t,d4 as Pe,r as a,dr as Re,di as Me,d5 as De,d6 as Ee,dY as $e,dZ as Te,d_ as Ae,d$ as Le,e0 as Fe,c$ as Ie,b4 as Ge,b3 as He,L as E,n as Be,bN as H,bO as B,cI as Ke,bP as K,bQ as re,ao as Oe,bT as Ve,cf as Qe,cg as Ye,ch as We,ci as Ue,cj as D,ad as Ze,bS as ze,c6 as qe,da as Je,bf as _e,b9 as ie,aI as oe}from"./index-CpeGhXo5.js";import{S as Xe}from"./StatusBadge-BY1PyeXl.js";import{T as le,a as et}from"./EntityPill-btGCy98_.js";import{c as tt}from"./financeMappers-CUv1G2pV.js";import{b as st,f as nt,a as at}from"./currency-CACMzR5Q.js";import{u as rt}from"./syncStatus-CzKeOsxO.js";import{F as ot}from"./FilterBar-B_jdgGzl.js";import{u as lt}from"./filters-DQMtevU2.js";import{u as it}from"./useGlobalFilter-BkOUrZeG.js";import"./mock-Ci00pIzy.js";function Nt(){const o=ke();return o||t.jsx(dt,{})}const $=o=>{const h=new Date(o.date);return{year:h.getFullYear(),month:h.getMonth()+1}},ct=(o,h,T)=>[{key:"date",label:"Date",width:"100px",sortable:!0,render:n=>Je(new Date(n.date),"dd MMM yyyy")},{key:"invoiceNo",label:"Invoice No",width:"130px",sortable:!0,render:n=>n.invoiceNo},{key:"client",label:"Client",width:"180px",sortable:!0,render:n=>n.client},{key:"project",label:"Project",width:"140px",sortable:!0,render:n=>n.project},{key:"department",label:"Department",width:"130px",sortable:!0,render:n=>t.jsx(le,{name:n.department})},{key:"team",label:"Team",width:"100px",sortable:!0,render:n=>t.jsx(le,{name:n.team})},{key:"employee",label:"Employee",width:"130px",sortable:!0,render:n=>n.employee},{key:"salesPerson",label:"Sales Person",width:"130px",sortable:!0,render:n=>n.salesPerson},{key:"company",label:"Company",width:"190px",sortable:!0,render:n=>t.jsx(et,{name:n.company})},{key:"gross",label:"Gross",align:"right",width:"120px",sortable:!0,render:n=>{const{year:u,month:d}=$(n);return t.jsx("span",{className:"font-data",children:o.fmt(o.conv(n.gross,u,d))})}},{key:"tax",label:"Tax",align:"right",width:"100px",sortable:!0,render:n=>{const{year:u,month:d}=$(n);return t.jsx("span",{className:"font-data text-muted-foreground",children:o.fmtCompact(o.conv(n.tax,u,d))})}},{key:"net",label:"Net Amount",align:"right",width:"130px",sortable:!0,render:n=>{const{year:u,month:d}=$(n);return t.jsx("span",{className:"font-data font-semibold",children:o.fmt(o.conv(n.net,u,d))})}},{key:"status",label:"Status",width:"100px",sortable:!0,render:n=>t.jsx(Xe,{status:n.status})},{key:"actions",label:"ACTIONS",width:"80px",align:"center",fixed:"right",render:n=>t.jsxs("div",{className:"flex items-center justify-center gap-1",onClick:u=>u.stopPropagation(),children:[t.jsx(E,{to:`${h}/revenue/new?editId=${n.id}`,className:"p-1 rounded-md text-slate-500 hover:text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-950/50 transition-colors",title:"Edit Revenue Entry",children:t.jsx(_e,{className:"w-3.5 h-3.5"})}),t.jsx("button",{type:"button",onClick:()=>T([n.id]),className:"p-1 rounded-md text-slate-500 hover:text-rose-600 hover:bg-rose-50 dark:hover:bg-rose-950/50 transition-colors",title:"Delete Revenue Entry",children:t.jsx(ie,{className:"w-3.5 h-3.5"})})]})}];function dt(){const o=Pe();lt();const[h,T]=a.useState(""),[n,u]=a.useState(""),[d,ce]=a.useState("date"),[g,de]=a.useState("desc"),[A,b]=a.useState(1),[f,me]=a.useState(25),[mt,ut]=a.useState(!1),[y,ue]=a.useState("All"),[v,O]=a.useState([]),[he,L]=a.useState(!1),[pe,V]=a.useState([]),{data:Q,isLoading:xe,isFetching:ge,refetch:be}=Re({limit:2e3}),{data:w}=Me({limit:500}),{data:Y=[]}=De(),{data:W=[]}=Ee(),{data:U=[]}=$e(),{data:ht}=Te({limit:1e3}),[Z,fe]=a.useState([]);a.useEffect(()=>{let e=!0;return Ae.getProjects().then(s=>{e&&Array.isArray(s)&&fe(s.map(r=>({id:r.id,name:r.name})))}).catch(()=>{}),()=>{e=!1}},[]);const[ye]=Le(),S=a.useMemo(()=>{const e=(w?.items??[]).map(s=>s.fullName||`${s.firstName} ${s.lastName}`.trim()).filter(Boolean);return e.length>0?e:["Yuvraj Kaushik","Hemant Singh","Sanjay Kumar Kumar","Kundan Kumar Gupta","Harkirat Singh","Anil Kumar","Amritpal Singh"]},[w]),N=a.useMemo(()=>{const e=(w?.items??[]).map(s=>s.fullName||`${s.firstName} ${s.lastName}
1`.trim()).filter(Boolean);return e.length>0?e:["Nancy Arya","Janvi Arora","Rohit Kumar","Pooja Sharma"]},[w]),{data:z}=Fe({limit:500}),C=a.useMemo(()=>{const e=[],s=new Set,r=z?.items??[];for(const i of r)i.name&&i.name.trim()&&!s.has(i.name.trim().toLowerCase())&&(e.push(i.name.trim()),s.add(i.name.trim().toLowerCase()));return e.sort((i,c)=>i.localeCompare(c))},[z]),k=a.useMemo(()=>{const e=Z.map(s=>s.name).filter(Boolean);return e.length>0?e:["ELD","Hospital Management","ERP","Ticket Wiser","Quick Bin Hire","Restaurant Management","Pay With Wallet","AGS"]},[Z]),P=a.useMemo(()=>{const e=Y.map(s=>s.name).filter(Boolean);return e.length>0?e:["IT & Production","Engineering","Growth & Sales","Finance"]},[Y]),R=a.useMemo(()=>{const e=W.map(s=>s.name).filter(Boolean);return e.length>0?e:["MERN Stack","MERN Stack Team","DevOps & Infra","Full Stack"]},[W]),F=a.useMemo(()=>{const e=U.map(s=>s.name).filter(Boolean);return e.length>0?e:["Tekki Web Solutions Pvt. Ltd."]},[U]),ve=a.useMemo(()=>{const e=(Q?.items??[]).map(tt);return e.length===0?[]:e.map((s,r)=>({...s,client:s.client&&s.client!=="Client"?s.client:C.length>0?C[r%C.length]:s.client||"Client",project:s.project&&s.project!=="Project"?s.project:k.length>0?k[r%k.length]:s.project||"Project",department:s.department||(P.length>0?P[r%P.length]:""),team:s.team||(R.length>0?R[r%R.length]:""),employee:s.employee||(S.length>0?S[r%S.length]:""),salesPerson:s.salesPerson||(N.length>0?N[r%N.length]:""),company:s.company||(F.length>0?F[0]:"Tekki Web Solutions Pvt. Ltd.")}))},[Q,C,k,P,R,S,N,F]),q=it(ve,"date"),j=a.useMemo(()=>{let e=[...q];if(y!=="All"&&(e=e.filter(s=>s.status===y)),n.trim()){const s=n.toLowerCase();e=e.filter(r=>r.invoiceNo?.toLowerCase().includes(s)||r.client?.toLowerCase().includes(s)||r.project?.toLowerCase().includes(s)||r.company?.toLowerCase().includes(s))}return e.sort((s,r)=>{const i=s[d]??"",c=r[d]??"";return i<c?g==="asc"?-1:1:i>c?g==="asc"?1:-1:0}),e},[q,y,n,d,g]),{activeCurrency:M,exchangeRates:J,defaultRate:_}=Ie(),m=rt();m.state==="error"||m.state==="syncing"||m.connected,m.connected&&(m.state==="syncing"||m.state==="error"||m.lastSyncAt&&`${new Date(m.lastSyncAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`);const{fmt:X,fmtCompact:I,conv:x}=a.useMemo(()=>({fmt:e=>at(e,M),fmtCompact:e=>nt(e,M),conv:(e,s,r)=>st(e,M,s,r,J,_)}),[M,J,_]);a.useEffect(()=>{const e=window.setTimeout(()=>u(h),350);return()=>window.clearTimeout(e)},[h]),a.useEffect(()=>{b(1)},[n,y,d,g,f]);const G=j.length,ee=a.useMemo(()=>{const e=(A-1)*f;return j.slice(e,e+f)},[j,A,f]),te=a.useMemo(()=>{let e=0,s=0,r=0,i=0;for(const c of j){const{year:p,month:l}=$(c),Ne=x(c.gross,p,l),Ce=x(c.tax,p,l),ae=x(c.net,p,l);e+=Ne,r+=Ce,s+=ae,c.status==="Paid"&&(i+=ae)}return{gross:e,net:s,tax:r,paid:i,outstanding:s-i,count:G}},[j,x,G]),se=()=>{const e=ee,s="Date,Invoice No,Client,Project,Department,Team,Employee,Sales Person,Company,Gross,Tax,Net Amount,Status",r=e.map(l=>`"${l.date}","${l.invoiceNo}","${l.client}","${l.project}","${l.department}","${l.team}","${l.employee}","${l.salesPerson}","${l.company}","${l.gross}","${l.tax}","${l.net}","${l.status}"`).join(`
2`),i=new Blob([s+`
3`+r],{type:"text/csv"}),c=URL.createObjectURL(i),p=document.createElement("a");p.href=c,p.download=`revenue-${Date.now()}.csv`,p.click(),URL.revokeObjectURL(c)},ne=e=>{e.length&&(O(e),L(!0))},je=async()=>{try{await Promise.all(v.map(e=>ye(e).unwrap())),oe.success(v.length>1?"Selected entries deleted":"Entry deleted")}catch{oe.error("Failed to delete revenue entry")}finally{L(!1),O([]),V([])}},we=a.useMemo(()=>ct({fmt:X,fmtCompact:I,conv:x},o,ne),[X,I,x,o]),Se=[{id:"export",label:"Export",icon:t.jsx(re,{className:"w-3.5 h-3.5"}),onAction:async()=>se()},{id:"delete",label:"Delete",icon:t.jsx(ie,{className:"w-3.5 h-3.5 text-destructive"}),variant:"destructive",onAction:async e=>ne(e.map(s=>s.id))}];return t.jsxs("div",{className:"flex flex-col flex-1 h-full min-h-0 overflow-hidden bg-slate-50/50",children:[t.jsx(Ge,{title:"Revenue",subtitle:`${te.count} invoice records · Net ${I(te.net)}`,accentVar:"--mod-revenue",showMonthYearFilter:!1}),t.jsx("div",{className:"shrink-0 bg-surface/50 border-b border-border px-4 py-2 flex items-center justify-between flex-wrap gap-2",children:t.jsx(ot,{showMonths:!0,actions:t.jsx(He,{delayDuration:150,children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsxs(E,{to:`${o}/revenue/sync`,className:"h-8 px-2.5 rounded-lg border border-border bg-card hover:bg-accent/70 hover:border-emerald-500/40 text-xs font-medium inline-flex items-center gap-2 shadow-2xs transition-all shrink-0 group","aria-label":"Google Sheet Sync",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsxs("svg",{className:"w-3.5 h-3.5 shrink-0 transition-transform group-hover:scale-105",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[t.jsx("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",fill:"#0F9D58"}),t.jsx("path",{d:"M7 7H17V9H7V7Z",fill:"white"}),t.jsx("path",{d:"M7 11H17V13H7V11Z",fill:"white",fillOpacity:"0.8"}),t.jsx("path",{d:"M7 15H17V17H7V15Z",fill:"white",fillOpacity:"0.8"}),t.jsx("path",{d:"M11 7V17",stroke:"#0F9D58",strokeWidth:"1.5"})]}),t.jsx("span",{className:"hidden md:inline font-medium text-foreground",children:"Google Sheet"})]}),m.connected?m.state==="syncing"?t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] font-semibold rounded bg-blue-500/10 text-blue-600 border border-blue-500/20 flex items-center gap-1 shrink-0",children:[t.jsx(Be,{className:"w-2.5 h-2.5 animate-spin text-blue-600"}),"Syncing"]}):m.state==="error"?t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-semibold rounded bg-destructive/10 text-destructive border border-destructive/20 shrink-0",children:"Error"}):t.jsxs("span",{className:"px-1.5 py-0.5 text-[10px] font-semibold rounded bg-emerald-500/10 text-emerald-600 border border-emerald-500/20 flex items-center gap-1 shrink-0",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"}),"Live"]}):t.jsx("span",{className:"px-1.5 py-0.5 text-[10px] font-semibold rounded bg-amber-500/10 text-amber-600 border border-amber-500/20 shrink-0",children:"Not Connected"})]}
3),t.jsxs(H,{children:[t.jsx(B,{asChild:!0,children:t.jsx(E,{to:`${o}/revenue/import`,className:"h-8 w-8 rounded-lg border border-border bg-card hover:bg-accent text-foreground inline-flex items-center justify-center transition-colors shadow-2xs","aria-label":"Import Records",children:t.jsx(Ke,{className:"w-3.5 h-3.5"})})}),t.jsx(K,{side:"bottom",className:"text-xs font-medium",children:"Import Records"})]}),t.jsxs(H,{children:[t.jsx(B,{asChild:!0,children:t.jsx("button",{type:"button",onClick:se,className:"h-8 w-8 rounded-lg border border-border bg-card hover:bg-accent text-foreground inline-flex items-center justify-center transition-colors shadow-2xs cursor-pointer","aria-label":"Export Records",children:t.jsx(re,{className:"w-3.5 h-3.5"})})}),t.jsx(K,{side:"bottom",className:"text-xs font-medium",children:"Export Records"})]}),t.jsxs(H,{children:[t.jsx(B,{asChild:!0,children:t.jsx(E,{to:`${o}/revenue/new`,className:"h-8 w-8 p-0 rounded-lg bg-blue-600 hover:bg-blue-700 text-white inline-flex items-center justify-center shadow-2xs transition-colors shrink-0 cursor-pointer","aria-label":"Add Revenue Entry",children:t.jsx(Oe,{className:"w-4 h-4"})})}),t.jsx(K,{side:"bottom",align:"end",className:"text-xs font-medium",children:"Add Revenue Entry"})]})]})})})}),t.jsx("div",{className:"p-3 pb-3 flex-1 min-h-0 flex flex-col overflow-hidden",children:t.jsx(Ve,{mode:"server",rows:ee,columns:we,rowKey:e=>e.id,fetching:ge||xe,selectable:!0,selectedIds:pe,onSelectionChange:V,bulkActions:Se,page:A,pageSize:f,total:G,onPageChange:b,onPageSizeChange:e=>{me(e),b(1)},sortKey:d,sortDir:g,onSortChange:e=>{e.sortKey&&ce(e.sortKey),de(e.sortDir)},storageKey:"finance-revenue",empty:"No matching invoices",fillHeight:!0,onRowClick:e=>navigate(`${o}/revenue/new?editId=${e.id}`),onRefresh:()=>be(),searchSlot:t.jsx(ze,{value:h,onChange:e=>{T(e),b(1)},placeholder:"Search invoices…",className:"w-[300px] shrink-0"}),toolbar:t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsxs(Qe,{value:y,onValueChange:e=>{ue(e),b(1)},children:[t.jsx(Ye,{className:"w-28 shrink-0",children:t.jsx(We,{})}),t.jsxs(Ue,{children:[t.jsx(D,{value:"All",children:"All"}),t.jsx(D,{value:"Paid",children:"Paid"}),t.jsx(D,{value:"Pending",children:"Pending"}),t.jsx(D,{value:"Overdue",children:"Overdue"})]})]}),t.jsxs("button",{className:"h-8 px-3 rounded-[5px] border border-border bg-background hover:bg-accent text-xs font-medium inline-flex items-center gap-1.5 shadow-sm shrink-0",children:[t.jsx(Ze,{className:"w-3.5 h-3.5 text-muted-foreground"})," Filters"]})]})})}),t.jsx(qe,{isOpen:he,onClose:()=>L(!1),onConfirm:je,title:v.length>1?"Delete Revenue Entries":"Delete Revenue Entry",description:v.length>1?`You are about to delete ${v.length} revenue entries. This action cannot be undone.`:"You are about to delete this revenue entry. This action cannot be undone.",confirmText:"Delete",variant:"destructive"})]})}export{Nt as RevenueLayout,dt as RevenuePage,Nt 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.