PageSourceSearch

https://taxease360.ai/assets/WorkflowReportBuilder-B4r7NfDt.js

js taxease360.ai collected 2026-10-05 14:25:19 UTC 35,040 bytes, 12 lines download raw bytes

1import{c as Ve,am as bt,u as jt,aa as wt,a4 as _t,r as d,p as L,j as t,q as ye,aj as Nt,t as _,a8 as St,F as kt,w as N,I as T,X as Ct,a1 as Dt}from"./index-CfXbMZ_V.js";import{E as Tt}from"./jspdf.es.min-B4Gj2_67.js";import Ot from"./html2canvas.esm-QH1iLAAe.js";import{D as Z,a as ee,b as te,c as ae,d as se}from"./dialog-D3H816yE.js";import{O as We,W as z}from"./workflowBoard-DyyHEBsQ.js";import{C as Rt}from"./chevron-left-BFeklwt6.js";import{S as Ue}from"./save-DxI-RWzE.js";import{D as At}from"./download-oHmw96Dk.js";import{C as Mt}from"./clock-DmU1_sat.js";/**
2 * @license lucide-react v0.475.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 Lt=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],$t=Ve("Printer",Lt);/**
7 * @license lucide-react v0.475.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 Pt=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],Be=Ve("SlidersHorizontal",Pt),Ft=[...z,"Archived"],zt=[{key:"created_date",label:"Created date"},{key:"updated_date",label:"Last updated"},{key:"last_activity_date",label:"Date entered current stage"},{key:"lodged_at",label:"Lodgement date"},{key:"completed_at",label:"Completion date"}],It=["all","today","yesterday","this_week","last_week","this_month","last_month","this_fy","custom"],Je=["Low","Medium","High","Urgent"],Et={"Individual Tax Return":"Individual","Company Tax Return":"Company","Trust Tax Return":"Trust","Partnership Tax Return":"Partnership","SMSF Annual Return":"SMSF","Tax Return – Review Required":"Other",BAS:"Other","ASIC Annual Review":"Other",Other:"Other"},Wt=["Individual","Company","Trust","Partnership","SMSF","Other"],Ut={"Verification Pending":5,"Documents Requested":7,"Waiting for Signature":7,"Waiting for Payment":14,"Ready to Lodge":5},$=[{key:"client_name",label:"Client name",get:a=>a.client_name,raw:a=>a.client_name||""},{key:"entity_type",label:"Client entity type",get:a=>ve(a),raw:a=>ve(a)},{key:"title",label:"Job name",get:a=>a.title,raw:a=>a.title||""},{key:"job_type",label:"Job type",get:a=>a.job_type,raw:a=>a.job_type||""},{key:"financial_year",label:"Financial year",get:a=>a.financial_year||"—",raw:a=>a.financial_year||""},{key:"status",label:"Current status",get:a=>a.status,raw:a=>z.indexOf(a.status)},{key:"outstanding_action",label:"Outstanding action",get:a=>We[a.status]||"—",raw:a=>We[a.status]||""},{key:"assigned_accountant",label:"Assigned staff",get:a=>a.assigned_accountant||"Unassigned",raw:a=>a.assigned_accountant||""},{key:"office_name",label:"Office",get:a=>a.office_name||"—",raw:a=>a.office_name||""},{key:"created_date",label:"Date created",get:a=>ne(a.created_date),raw:a=>new Date(a.created_date||0).getTime()},{key:"last_activity_date",label:"Last updated",get:a=>ne(a.updated_date),raw:a=>new Date(a.updated_date||0).getTime()},{key:"days_in_stage",label:"Days in stage",get:a=>B(a),raw:a=>B(a)},{key:"days_in_workflow",label:"Days in workflow",get:a=>be(a),raw:a=>be(a)},{key:"lodged_at",label:"Lodgement date",get:a=>ne(a.lodged_at),raw:a=>new Date(a.lodged_at||0).getTime()},{key:"completed_at",label:"Completion date",get:a=>ne(a.completed_at),raw:a=>new Date(a.completed_at||0).getTime()},{key:"priority",label:"Priority",get:a=>a.priority,raw:a=>Je.indexOf(a.priority)},{key:"lodgement_status",label:"Lodgement status",get:a=>je(a),raw:a=>je(a)},{key:"signature_status",label:"Signature status",get:a=>He(a),raw:a=>He(a)},{key:"document_status",label:"Document status",get:a=>Ye(a),raw:a=>Ye(a)},{key:"payment_status",label:"Payment status",get:a=>qe(a),raw:a=>qe(a)},{key:"overdue",label:"Overdue",get:a=>le(a)?"Yes":"No",raw:a=>le(a)?1:0},{key:"amount_invoiced",label:"Amount invoiced",get:a=>pe(a.amount_invoiced),raw:a=>Number(a.amount_invoiced||0),financial:!0},{key:"amount_paid",label:"Amount paid",get:a=>pe(a.amount_paid),raw:a=>Number(a.amount_paid||0),financial:!0},{key:"amount_outstanding",label:"Amount outstanding",get:a=>pe((Number(a.amount_invoiced)||0)-(Number(a.amount_paid)||0)),raw:a=>(Number(a.amount_invoiced)||0)-(Number(a.amount_paid)||0),financial:!0}],Bt=["client_name","title","job_type","financial_year","status","assigned_accountant","office_name","created_date","days_in_stage","lodged_at"],Ht={field:"created_date",direction:"desc"};function ve(a){return Et[a.job_type]||"Other"}function ne(a){if(!a)return"—";const i=new Date(a);return isNaN(i)?"—":i.toLocaleDateString("en-AU",{day:"numeric",month:"short",year:"numeric"})}function B(a){const i=new Date(a.last_activity_date||a.updated_date||a.created_date||0);return i.getTime()?Math.floor((Date.now()-i.getTime())/864e5):0}function be(a){const i=new Date(a.created_date||0);if(!i.getTime())return 0;const j=new Date(a.completed_at||a.lodged_at||Date.now());return Math.max(0,Math.floor((j.getTime()-i.getTime())/864e5))}function le(a){const i=Ut[a.status];return i?B(a)>i:!1}function je(a){return a.lodged_at||a.status==="Lodged"||a.status==="Completed"?"L
11odged":"Not lodged"}function we(a){return z.indexOf(a.status)}function He(a){const i=we(a);return a.status==="Waiting for Signature"?"Awaiting signature":i>=z.indexOf("Waiting for Signature")?"Signed":"Not required"}function Ye(a){const i=we(a);return a.status==="Documents Requested"?"Awaiting documents":i>=z.indexOf("Documents Requested")?"Provided":"Not requested"}function qe(a){const i=we(a);return a.status==="Waiting for Payment"?"Awaiting payment":i>=z.indexOf("Waiting for Payment")?"Paid":"Not yet"}function pe(a){return"$"+Number(a||0).toLocaleString("en-AU",{minimumFractionDigits:0})}function Yt(a,i,j,x){const b=x||new Date,[u,m]=(j||"09:00").split(":").map(l=>parseInt(l,10)||0),f=new Date(b);if(f.setHours(u,m,0,0),f<=b&&f.setDate(f.getDate()+1),a==="weekly"){let g=((i??f.getDay())-f.getDay()+7)%7;g===0&&f<=b&&(g=7),f.setDate(f.getDate()+g)}else if(a==="monthly"){const l=i&&i>=1&&i<=28?i:1;f.setDate(l),f<=b&&f.setMonth(f.getMonth()+1)}return f.toISOString()}function qt(a){const i=new Date,j=u=>{const m=new Date(u);return m.setHours(0,0,0,0),m},x=u=>{const m=new Date(u);return m.setHours(23,59,59,999),m},b=u=>{const m=j(u),f=(m.getDay()+6)%7;return m.setDate(m.getDate()-f),m};switch(a){case"today":return[j(i),x(i)];case"yesterday":{const u=new Date(i);return u.setDate(u.getDate()-1),[j(u),x(u)]}case"this_week":{const u=b(i),m=new Date(u);return m.setDate(m.getDate()+6),[u,x(m)]}case"last_week":{const u=b(i);u.setDate(u.getDate()-7);const m=new Date(u);return m.setDate(m.getDate()+6),[u,x(m)]}case"this_month":{const u=new Date(i.getFullYear(),i.getMonth(),1),m=new Date(i.getFullYear(),i.getMonth()+1,0);return[j(u),x(m)]}case"last_month":{const u=new Date(i.getFullYear(),i.getMonth()-1,1),m=new Date(i.getFullYear(),i.getMonth(),0);return[j(u),x(m)]}case"this_fy":{const u=i.getMonth()>=6?i.getFullYear():i.getFullYear()-1,m=new Date(u,6,1),f=new Date(u+1,6,0);return[j(m),x(f)]}default:return null}}const fe={search:"",statuses:[],office:[],staff:[],jobType:[],fy:[],priority:[],category:[],dateDim:"created_date",datePreset:"all",dateFrom:"",dateTo:"",daysMin:"",overdue:!1};function sa(){const a=bt(),i=jt(),[j]=wt(),{toast:x}=_t(),[b,u]=d.useState({jobs:[],offices:[],staff:[]}),[m,f]=d.useState(!0),[l,g]=d.useState(fe),[I,H]=d.useState("all"),[E,W]=d.useState(Bt),[S,ie]=d.useState(Ht),[P,_e]=d.useState(""),[y,Ke]=d.useState(null),U=(y==null?void 0:y.role)==="admin"||(y==null?void 0:y.role)==="super_admin",Xe=U,[Qe,re]=d.useState(!1),[Ze,et]=d.useState(!0),[Ne,oe]=d.useState([]),[tt,Y]=d.useState(!1),[at,q]=d.useState(!1),[ce,Se]=d.useState(""),[ke,Ce]=d.useState(""),[De,Te]=d.useState("private"),[st,G]=d.useState(!1),[Oe,nt]=d.useState(null),[C,Re]=d.useState("daily"),[V,de]=d.useState(1),[ue,Ae]=d.useState("09:00"),[Me,Le]=d.useState(""),[me,$e]=d.useState(["email"]),[xe,Pe]=d.useState(!1),[J,K]=d.useState(!1),X=d.useRef(null);d.useEffect(()=>{(async()=>{var s,o,r,c;try{const[n,p]=await Promise.all([L.functions.invoke("loadWorkflowReport"),L.auth.me()]);u({jobs:((s=n==null?void 0:n.data)==null?void 0:s.jobs)||[],offices:((o=n==null?void 0:n.data)==null?void 0:o.offices)||[],staff:((r=n==null?void 0:n.data)==null?void 0:r.staff)||[]}),Ke(p);const w=(c=a.state)==null?void 0:c.initialFilters;w&&g(v=>({...v,search:w.search||"",office:w.office&&w.office!=="all"?[w.office]:[],statuses:Array.isArray(w.statuses)?w.statuses:[]}))}catch(n){x({title:"Could not load report data",description:n.message,variant:"destructive"})}finally{f(!1)}he();const e=j.get("report");e&&setTimeout(()=>Ie(e),0)})()},[]);const he=async()=>{try{const e=await L.entities.SavedReport.list("-updated_date",200);oe(e||[])}catch{oe([])}},lt=d.useMemo(()=>{const e=new Set(b.jobs.map(s=>s.financial_year).filter(Boolean));for(let s=2024;s<=2030;s++)e.add(`FY${s}`);return Array.from(e).sort()},[b.jobs]),it=d.useMemo(()=>Array.from(new Set(b.jobs.map(e=>e.job_type).filter(Boolean))).sort(),[b.jobs]),k=d.useMemo(()=>{const e=[];if(l.search){const n=l.search.toLowerCase();e.push(p=>(p.client_name||"").toLowerCase().includes(n)||(p.title||"").toLowerCase().includes(n)||(p.client_email||"").toLowerCase().includes(n))}l.statuses.length&&e.push(n=>l.statuses.includes("Archived")?n.archived:!n.archived&&l.statuses.includes(n.status)),l.office.length&&e.push(n=>l.office.includes(n.office_id)),l.staff.length&&e.push(n=>l.staff.includes(n.assigned_accountant)),l.jobType.length&&e.push(n=>l.jobType.includes(n.job_type)),l.fy.length&&e.push(n=>l.fy.includes(n.financial_year)),l.priority.length&&e.push(n=>l.priority.includes(n.priority)),l.category.length&&e.push(n=>l.category.includes(ve(n))),l.daysMin!==""&&e.push(n=>B(n)>=Number(l.daysMin)),l.overdue&&e.push(n=>le(n));let s=null;if(l.datePreset==="custom"&&(l.dateFrom||l.dateTo)){const n=l.dateFrom?new Date(l.dateFrom+"T00:00:00"):null,p=l.dateTo?new Date(l.dateTo+"T23:59:59"):null;s=w=>{const v=new Date(w[l.dateDim]||0);return v.getTime()?(!n||v>=n)&&(!p||v<=p):!1}}else if(l.datePreset!=="all"&&l.datePreset!=="custom"){const n=qt(l.datePreset);if(n){const[p,w]=n;s=v=>{const D=new Date(v[l.dateDim]||0);return D.getTime()?D>=p&&D<=w:!1}
11}}const o=n=>e.length?I==="all"?e.every(p=>p(n)):e.some(p=>p(n)):!0;let r=b.jobs.filter(n=>o(n)&&(!s||s(n)));const c=$.find(n=>n.key===S.field)||$.find(n=>n.key==="created_date");return r=[...r].sort((n,p)=>{const w=c.raw(n),v=c.raw(p);return w<v?S.direction==="asc"?-1:1:w>v?S.direction==="asc"?1:-1:0}),r},[b.jobs,l,I,S]),h=d.useMemo(()=>{const e=k,s=new Set(e.map(r=>r.client_id).filter(Boolean)),o=r=>e.filter(c=>c.status===r).length;return{total:e.length,clients:s.size,ready:o("Ready to Lodge"),waitingPay:o("Waiting for Payment"),waitingSig:o("Waiting for Signature"),lodged:e.filter(r=>je(r)==="Lodged").length,completed:o("Completed"),overdue:e.filter(le).length,avgStage:e.length?Math.round(e.reduce((r,c)=>r+B(c),0)/e.length):0,avgTurnaround:e.length?Math.round(e.reduce((r,c)=>r+be(c),0)/e.length):0,totalInvoiced:e.reduce((r,c)=>r+Number(c.amount_invoiced||0),0),totalOutstanding:e.reduce((r,c)=>r+Math.max(0,(Number(c.amount_invoiced)||0)-(Number(c.amount_paid)||0)),0)}},[k]),O=E.map(e=>$.find(s=>s.key===e)).filter(e=>e&&(!e.financial||U)),rt=d.useMemo(()=>{if(!P)return[{key:null,rows:k}];const e={};return k.forEach(s=>{var r;const o=((r=$.find(c=>c.key===P))==null?void 0:r.raw(s))??"—";(e[o]=e[o]||[]).push(s)}),Object.entries(e).sort((s,o)=>String(s[0]).localeCompare(String(o[0]))).map(([s,o])=>({key:s,rows:o}))},[k,P]),M=(e,s)=>e.includes(s)?e.filter(o=>o!==s):[...e,s],Fe=e=>ie(s=>s.field===e?{field:e,direction:s.direction==="asc"?"desc":"asc"}:{field:e,direction:"asc"}),ot=()=>{const e=O.map(r=>`"${r.label}"`).join(","),s=k.map(r=>O.map(c=>`"${String(c.get(r)??"").replace(/"/g,'""')}"`).join(",")),o=new Blob([[e,...s].join(`
12`)],{type:"text/csv;charset=utf-8;"});Ge(o,`workflow-report-${Date.now()}.csv`)},ct=()=>{const e=k.map(r=>`<tr>${O.map(c=>`<td>${F(c.get(r)??"")}</td>`).join("")}</tr>`).join(""),s=`<table border="1"><thead><tr>${O.map(r=>`<th>${F(r.label)}</th>`).join("")}</tr></thead><tbody>${e}</tbody></table>`,o=new Blob([`\uFEFF<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"><head><meta charset="utf-8"></head><body>${s}</body></html>`],{type:"application/vnd.ms-excel;charset=utf-8;"});Ge(o,`workflow-report-${Date.now()}.xls`)},ze=()=>{const e=`Generated ${new Date().toLocaleString("en-AU")} by ${(y==null?void 0:y.full_name)||"—"}`,s=U?` · Total invoiced: $${h.totalInvoiced.toLocaleString("en-AU")} · Total outstanding: $${h.totalOutstanding.toLocaleString("en-AU")}`:"",o=`Total: ${h.total} · Clients: ${h.clients} · Ready: ${h.ready} · Waiting payment: ${h.waitingPay} · Waiting signature: ${h.waitingSig} · Lodged: ${h.lodged} · Completed: ${h.completed} · Overdue: ${h.overdue} · Avg days in stage: ${h.avgStage} · Avg turnaround: ${h.avgTurnaround}${s}`,r=O.map(n=>`<th>${F(n.label)}</th>`).join(""),c=k.map(n=>`<tr>${O.map(p=>`<td>${F(p.get(n)??"")}</td>`).join("")}</tr>`).join("");return`<h2>Workflow Report</h2><p style="font-size:11px;color:#666">${F(e)}</p><p style="font-size:11px;color:#666">${F(o)}</p><table border="1" cellspacing="0" cellpadding="4" style="border-collapse:collapse;font-size:11px"><thead style="background:#f0f0f0"><tr>${r}</tr></thead><tbody>${c}</tbody></table>`},dt=()=>{const e=window.open("","_blank");if(!e){x({title:"Pop-up blocked",description:"Allow pop-ups to print the report.",variant:"destructive"});return}e.document.write(`<!doctype html><html><head><title>Workflow Report</title><meta charset="utf-8"></head><body style="font-family:Arial,sans-serif">${ze()}<script>window.onload=()=>window.print()<\/script></body></html>`),e.document.close()},ut=async()=>{if(X.current){K(!0);try{X.current.innerHTML=ze();const e=await Ot(X.current,{scale:2,backgroundColor:"#ffffff"}),o=e.width/800,r=new Tt("l","pt","a4"),c=r.internal.pageSize.getWidth(),n=r.internal.pageSize.getHeight(),p=c,w=Math.ceil(n*o),v=document.createElement("canvas");v.width=e.width;let D=0;for(;D<e.height;){const Q=Math.min(w,e.height-D);v.height=Math.ceil(Q);const ge=v.getContext("2d");ge.fillStyle="#fff",ge.fillRect(0,0,v.width,v.height),ge.drawImage(e,0,D,e.width,Q,0,0,e.width,Q);
12const ft=v.toDataURL("image/png"),vt=v.width/p;r.addImage(ft,"PNG",0,0,p,v.height/vt),D+=Q,D<e.height&&r.addPage()}r.save(`workflow-report-${Date.now()}.pdf`)}catch(e){x({title:"PDF export failed",description:e.message,variant:"destructive"})}finally{K(!1)}}},mt=()=>{Se(""),Ce(""),Te("private"),q(!0)},xt=async()=>{if(!ce.trim()){x({title:"Enter a report name"});return}K(!0);try{await L.entities.SavedReport.create({name:ce.trim(),description:ke.trim(),report_type:"workflow_jobs",filters:{...l,matchMode:I},columns:E,sort:S,group_by:P,visibility:De,organisation_id:(y==null?void 0:y.company_id)||null,owner_user_id:(y==null?void 0:y.id)||null,owner_name:(y==null?void 0:y.full_name)||null}),x({title:"Report saved"}),q(!1),he()}catch(e){x({title:"Save failed",description:e.message,variant:"destructive"})}finally{K(!1)}},Ie=async e=>{try{const s=await L.entities.SavedReport.get(e),o=s.filters||{};g({...fe,...o}),o.matchMode&&H(o.matchMode),Array.isArray(s.columns)&&W(s.columns),s.sort&&ie(s.sort),s.group_by&&_e(s.group_by),Y(!1),x({title:`Loaded "${s.name}"`})}catch(s){x({title:"Load failed",description:s.message,variant:"destructive"})}},ht=async e=>{try{await L.entities.SavedReport.delete(e),oe(s=>s.filter(o=>o.id!==e)),x({title:"Report deleted"})}catch(s){x({title:"Delete failed",description:s.message,variant:"destructive"})}},gt=e=>{nt(e),Re(e.schedule_cadence&&e.schedule_cadence!=="none"?e.schedule_cadence:"daily"),de(e.schedule_day??1),Ae(e.schedule_time||"09:00"),Le(Array.isArray(e.schedule_recipients)?e.schedule_recipients.join(", "):""),$e(Array.isArray(e.schedule_delivery)&&e.schedule_delivery.length?e.schedule_delivery:["email"]),G(!0)},Ee=e=>$e(s=>s.includes(e)?s.filter(o=>o!==e):[...s,e]),yt=async()=>{if(!Oe)return;const e=Me.split(",").map(s=>s.trim()).filter(Boolean);if(C!=="none"&&e.length===0){x({title:"Add at least one recipient email"});return}Pe(!0);try{const s=C==="none"?null:Yt(C,V,ue,new Date);await L.entities.SavedReport.update(Oe.id,{schedule_cadence:C,schedule_day:Number(V),schedule_time:ue,schedule_recipients:e,schedule_delivery:me,owner_email:(y==null?void 0:y.email)||null,next_run_at:s}),x({title:C==="none"?"Schedule removed":"Schedule saved"}),G(!1),he()}catch(s){x({title:"Could not save schedule",description:s.message,variant:"destructive"})}finally{Pe(!1)}};if(m)return t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsx(ye,{className:"w-7 h-7 text-gray-400 animate-spin"})});const pt=[{label:"Total jobs",value:h.total},{label:"Total clients",value:h.clients},{label:"Ready to lodge",value:h.ready},{label:"Waiting payment",value:h.waitingPay},{label:"Waiting signature",value:h.waitingSig},{label:"Lodged",value:h.lodged},{label:"Completed",value:h.completed},{label:"Overdue",value:h.overdue,red:!0},{label:"Avg days in stage",value:h.avgStage},{label:"Avg turnaround",value:h.avgTurnaround},...U?[{label:"Total invoiced",value:"$"+h.totalInvoiced.toLocaleString("en-AU")},{label:"Total outstanding",value:"$"+h.totalOutstanding.toLocaleString("en-AU"),red:h.totalOutstanding>0}]:[]];return t.jsxs("div",{className:"space-y-4 pb-10",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:()=>i("/staff/workflow"),className:"flex items-center gap-1 text-sm text-gray-500 hover:text-gray-800",children:[t.jsx(Rt,{size:18})," Board"]}),t.jsxs("h1",{className:"text-xl font-bold text-gray-900 flex items-center gap-2 ml-2",children:[t.jsx(Nt,{size:20,className:"text-emerald-600"})," Workflow Report Builder"]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(_,{variant:"outline",size:"sm",onClick:()=>Y(!0),className:"h-8 text-xs",children:[t.jsx(Ue,{size:14})," Saved"]}),t.jsxs(_,{variant:"outline",size:"sm",onClick:mt,className:"h-8 text-xs",children:[t.jsx(Ue,{size:14})," Save"]}),t.jsxs("div",{className:"flex items-center gap-1 border-l pl-2 ml-1",children:[t.jsxs(_,{variant:"outline",size:"sm",onClick:ot,className:"h-8 text-xs",children:[t.jsx(At,{size:14})," CSV"]}),t.jsxs(_,{variant:"outline",size:"sm",onClick:ct,className:"h-8 text-xs",children:[t.jsx(St,{size:14})," Excel"]}),t.jsxs(_,{variant:"outline",size:"sm",onClick:dt,className:"h-8 text-xs",children:[t.jsx($t,{size:14})," Print"]}),t.jsxs(_,{variant:"outline",size:"sm",onClick:ut,disabled:J,className:"h-8 text-xs",children:[t.jsx(kt,{size:14})," PDF"]})]})]})]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-10 gap-2",children:pt.map(e=>t.jsxs("div",{className:"bg-white border border-gray-100 rounded-xl p-2.5 shadow-sm",children:[t.jsx("p",{className:"text-[10px] font-medium text-gray-500 truncate",children:e.label}),t.jsx("p",{className:`text-xl font-bold mt-0.5 ${e.red?"text-red-600":"text-gray-900"}`,children:e.value})]},e.label))}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap bg-white border border-gray-100 rounded-xl p-2.5",children:[t.jsxs("button",{onClick:()=>et(e=>!e),className:"inline-flex items-center gap-1 text-xs font-medium text-gray-600 hover:text-gray-900 px-2 py-1.5 rounded-md hover:bg-gray-100",children:[t.jsx(Be,{size:14})," Filters"]}),t.jsx("span",{className:"text-xs text-gray-400",children:"|"}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-gray-500",children:"Match:"}),t.jsx("button",{onClick:()=>H("all"),className:`text-xs px-2 py-1 rounded-md ${I==="all"?"bg-emerald-600 text-white":"bg-gray-100 text-gray-600"}`,children:"All (AND)"}),t.jsx("button",{onClick:()=>H("any"),className:`text-xs px-2 py-1 rounded-md ${I==="any"?"bg-emerald-600 text-white":"bg-gray-100 text-gray-600"}`,children:"Any (OR)"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-gray-500",children:"Sort:"}),t.jsx("select",{value:S.field,onChange:e=>Fe(e.target.value),className:"h-8 text-xs border border-gray-200 rounded-md bg-white px-1.5 text-gray-800",children:$.map(e=>t.jsx("option",{value:e.key,children:e.label},e.key))}),t.jsx("button",{onClick:()=>ie(e=>({...e,direction:e.direction==="asc"?"desc":"asc"})),className:"text-xs px-2 py-1 rounded-md bg-gray-100 text-gray-600",children:S.direction==="asc"?"Asc ↑":"Desc ↓"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-gray-500",children:"Group:"}),t.jsxs("select",{value:P,onChange:e=>_e(e.target.value),className:"h-8 text-xs border border-gray-200 rounded-md bg-white px-1.5 text-gray-800",children:[t.jsx("option",{value:"",children:"None"}),t.jsx("option",{value:"office_name",children:"Office"}),t.jsx("option",{value:"assigned_accountant",children:"Staff member"}),t.jsx("option",{value:"status",children:"Status"}),t.jsx("option",{value:"job_type",children:"Job type"}),t.jsx("option",{value:"financial_year",children:"Financial year"})]})]}),t.jsxs(_,{variant:"outline",size:"sm",onClick:()=>re(!0),className:"h-8 text-xs ml-auto",children:[t.jsx(Be,{size:14})," Columns"]})]}),t.jsxs("div",{className:"lg:grid lg:grid-cols-[260px_1fr] lg:gap-4",children:[Ze&&t.jsxs("div",{className:"bg-white border border-gray-100 rounded-xl p-3 space-y-3 lg:max-h-[calc(100vh-340px)] lg:overflow-y-auto mb-3 lg:mb-0",children:[t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Search"}),t.jsx(T,{value:l.search,onChange:e=>g(s=>({...s,search:e.target.value})),placeholder:"Client, job or email",className:"h-8 mt-1 text-xs"})]}),t.jsx(R,{label:"Status",children:Ft.map(e=>t.jsx(A,{active:l.statuses.includes(e),onClick:()=>g(s=>({...s,statuses:M(s.statuses,e)})),children:e},e))}),b.offices.length>0&&t.jsx(R,{label:"Office",children:b.offices.map(e=>t.jsx(A,{active:l.office.includes(e.id),onClick:()=>g(s=>({...s,office:M(s.office,e.id)})),children:e.name},e.id))}),b.staff.length>0&&t.jsx(R,{label:"Assigned staff",children:b.staff.map(e=>t.jsx(A,{active:l.staff.includes(e.name),onClick:()=>g(s=>({...s,staff:M(s.staff,e.name)})),children:e.name},e.id))}),t.jsx(R,{label:"Job type",children:it.map(e=>t.jsx(A,{active:l.jobType.includes(e),onClick:()=>g(s=>({...s,jobType:M(s.jobType,e)})),children:e},e))}),t.jsx(R,{label:"Financial year",children:lt.map(e=>t.jsx(A,{active:l.fy.includes(e),onClick:()=>g(s=>({...s,fy:M(s.fy,e)})),children:e},e))}),t.jsx(R,{label:"Priority",children:Je.map(e=>t.jsx(A,{active:l.priority.includes(e),onClick:()=>g(s=>({...s,priority:M(s.priority,e)})),children:e},e))}),t.jsx(R,{label:"Client entity type",children:Wt.map(e=>t.jsx(A,{active:l.category.includes(e),onClick:()=>g(s=>({...s,category:M(s.category,e)})),children:e},e))}),t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Date dimension"}),t.jsx("select",{value:l.dateDim,onChange:e=>g(s=>({...s,dateDim:e.target.value})),className:"h-8 w-full text-xs border border-gray-200 rounded-md bg-white px-1.5 mt-1 text-gray-800",children:zt.map(e=>t.jsx("option",{value:e.key,children:e.label},e.key))})]}),t.jsx(R,{label:"Date preset",children:It.map(e=>t.jsx(A,{active:l.datePreset===e,onClick:()=>g(s=>({...s,datePreset:e})),children:e==="all"?"All time":e.replace("_"," ")},e))}),l.datePreset==="custom"&&t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"From"}),t.jsx(T,{type:"date",value:l.dateFrom,onChange:e=>g(s=>({...s,dateFrom:e.target.value})),className:"h-8 text-xs mt-1"})]}),t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"To"}),t.jsx(T,{type:"date",value:l.dateTo,onChange:e=>g(s=>({...s,dateTo:e.target.value})),className:"h-8 text-xs mt-1"})]})]}),t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Min days in current stage"}),t.jsx(T,{type:"number",min:"0",value:l.daysMin,onChange:e=>g(s=>({...s,daysMin:e.target.value})),placeholder:"e.g. 30",className:"h-8 text-xs mt-1"})]}),t.jsxs("label",{className:"flex items-center gap-2 text-xs text-gray-700",children:[t.jsx("input",{type:"checkbox",checked:l.overdue,onChange:e=>g(s=>({...s,overdue:e.target.checked})),className:"w-4 h-4 rounded border-gray-300 text-emerald-600"}),"Overdue only"]}),t.jsx(_,{variant:"ghost",size:"sm",onClick:()=>{g(fe),H("all")},className:"h-8 text-xs w-full text-gray-500",children:"Reset filters"})]}),t.jsxs("div",{className:"bg-white border border-gray-100 rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"px-3 py-2 border-b border-gray-100 flex items-center justify-between",children:[t.jsxs("p",{className:"text-xs text-gray-500",children:[k.length," job(s) match"]}),t.jsx("p",{className:"text-[11px] text-gray-400",children:"Click a row to open the job (new tab)"})]}),t.jsxs("div",{className:"overflow-x-auto max-h-[calc(100vh-380px)] overflow-y-auto",children:[rt.map((e,s)=>t.jsxs("div",{children:[e.key!==null&&t.jsxs("div",{className:"sticky top-0 bg-gray-50 border-y border-gray-100 px-3 py-1.5 flex items-center justify-between text-xs font-semibold text-gray-700 z-10",children:[t.jsxs("span",{children:[Gt(P),": ",e.key]}),t.jsx("span",{className:"text-gray-400 font-normal",children:e.rows.length})]}),t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-white sticky top-0 z-10",children:t.jsx("tr",{children:O.map(o=>t.jsxs("th",{onClick:()=>Fe(o.key),className:`text-left font-semibold text-gray-500 px-3 py-2 cursor-pointer hover:text-gray-800 whitespace-nowrap ${S.field===o.key?"text-emerald-700":""}`,children:[o.label,S.field===o.key?S.direction==="asc"?" ↑":" ↓":""]},o.key))})}),t.jsx("tbody",{children:e.rows.map(o=>t.jsx("tr",{className:"border-t border-gray-50 hover:bg-emerald-50/40",children:O.map(r=>
12t.jsx("td",{className:"px-3 py-2 text-gray-700 whitespace-nowrap",children:t.jsx("a",{href:`/staff/jobs/${o.id}`,target:"_blank",rel:"noreferrer",className:r.key==="client_name"?"font-semibold text-gray-900 hover:text-emerald-700":"",children:r.get(o)})},r.key))},o.id))})]})]},s)),k.length===0&&t.jsx("p",{className:"text-center text-sm text-gray-400 py-10",children:"No jobs match the current filters."})]})]})]}),t.jsx("div",{ref:X,className:"hidden"}),t.jsx(Z,{open:Qe,onOpenChange:re,children:t.jsxs(ee,{className:"max-w-lg",children:[t.jsx(te,{children:t.jsx(ae,{children:"Report columns"})}),t.jsx("p",{className:"text-xs text-gray-500",children:"Toggle columns on/off. Use the arrows to reorder."}),t.jsx("div",{className:"max-h-[50vh] overflow-y-auto space-y-1",children:E.map((e,s)=>{const o=$.find(r=>r.key===e);return o?t.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-lg px-2 py-1.5",children:[t.jsx("span",{className:"flex-1 text-sm text-gray-700",children:o.label}),t.jsx("button",{disabled:s===0,onClick:()=>W(r=>{const c=[...r];return[c[s-1],c[s]]=[c[s],c[s-1]],c}),className:"text-xs text-gray-500 disabled:opacity-30 px-1.5",children:"↑"}),t.jsx("button",{disabled:s===E.length-1,onClick:()=>W(r=>{const c=[...r];return[c[s+1],c[s]]=[c[s],c[s+1]],c}),className:"text-xs text-gray-500 disabled:opacity-30 px-1.5",children:"↓"}),t.jsx("button",{onClick:()=>W(r=>r.filter(c=>c!==e)),className:"text-rose-500 px-1.5",children:t.jsx(Ct,{size:14})})]},e):null})}),t.jsx("p",{className:"text-xs font-semibold text-gray-500 mt-2",children:"Add column"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:$.filter(e=>!E.includes(e.key)&&(!e.financial||U)).map(e=>t.jsxs("button",{onClick:()=>W(s=>[...s,e.key]),className:"text-xs px-2 py-1 rounded-md bg-gray-100 text-gray-600 hover:bg-gray-200",children:["+ ",e.label]},e.key))}),t.jsx(se,{children:t.jsx(_,{onClick:()=>re(!1),children:"Done"})})]})}),t.jsx(Z,{open:at,onOpenChange:q,children:t.jsxs(ee,{className:"max-w-sm",children:[t.jsx(te,{children:t.jsx(ae,{children:"Save report"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Report name"}),t.jsx(T,{value:ce,onChange:e=>Se(e.target.value),className:"mt-1",placeholder:"e.g. Ready to Lodge This Week"})]}),t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Description"}),t.jsx(T,{value:ke,onChange:e=>Ce(e.target.value),className:"mt-1",placeholder:"Optional"})]}),t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Visibility"}),t.jsxs("select",{value:De,onChange:e=>Te(e.target.value),className:"h-9 w-full text-sm border border-gray-200 rounded-md bg-white px-2 mt-1 text-gray-800",children:[t.jsx("option",{value:"private",children:"Private (only me)"}),t.jsx("option",{value:"shared",children:"Shared (organisation)"})]})]})]}),t.jsxs(se,{children:[t.jsx(_,{variant:"outline",onClick:()=>q(!1),disabled:J,children:"Cancel"}),t.jsx(_,{onClick:xt,disabled:J,className:"bg-emerald-600 hover:bg-emerald-700",children:J?t.jsx(ye,{size:16,className:"animate-spin"}):"Save"})]})]})}),t.jsx(Z,{open:tt,onOpenChange:Y,children:t.jsxs(ee,{className:"max-w-md",children:[t.jsx(te,{children:t.jsx(ae,{children:"Saved reports"})}),Ne.length===0?t.jsx("p",{className:"text-sm text-gray-400 py-4 text-center",children:"No saved reports yet."}):t.jsx("div",{className:"max-h-[50vh] overflow-y-auto space-y-1.5",children:Ne.map(e=>t.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 rounded-lg px-3 py-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("button",{onClick:()=>Ie(e.id),className:"text-sm font-semibold text-gray-900 hover:text-emerald-700 truncate block",children:e.name}),e.description&&t.jsx("p",{className:"text-xs text-gray-400 truncate",children:e.description}),t.jsxs("p",{className:"text-[10px] text-gray-400",children:[e.visibility==="shared"?"Shared":"Private"," · ",e.owner_name||"—",e.schedule_cadence&&e.schedule_cadence!=="none"?` · ${e.schedule_cadence}`:""]})]}),Xe&&t.jsx("button",{onClick:()=>gt(e),className:"text-emerald-600 hover:bg-emerald-50 p-1.5 rounded-md","aria-label":"Schedule",children:t.jsx(Mt,{size:14})}),t.jsx("button",{onClick:()=>ht(e.id),className:"text-rose-500 hover:bg-rose-50 p-1.5 rounded-md","aria-label":"Delete",children:t.jsx(Dt,{size:14})})]},e.id))}),t.jsx(se,{children:t.jsx(_,{variant:"outline",onClick:()=>Y(!1),children:"Close"})})]})}),t.jsx(Z,{open:st,onOpenChange:G,children:t.jsxs(ee,{className:"max-w-sm",children:[t.jsx(te,{children:t.jsx(ae,{children:"Schedule report"})}),t.jsx("p",{className:"text-xs text-gray-500",children:"Schedules run against live data and deliver a summary with a link to open the full filtered report. Recipients must be registered TaxEase360 users."}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Cadence"}),t.jsxs("select",{value:C,onChange:e=>Re(e.target.value),className:"h-9 w-full text-sm border border-gray-200 rounded-md bg-white px-2 mt-1 text-gray-800",children:[t.jsx("option",{value:"none",children:"Off (no sc
12hedule)"}),t.jsx("option",{value:"daily",children:"Daily"}),t.jsx("option",{value:"weekly",children:"Weekly"}),t.jsx("option",{value:"monthly",children:"Monthly"})]})]}),C==="weekly"&&t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Day of week"}),t.jsx("select",{value:V,onChange:e=>de(Number(e.target.value)),className:"h-9 w-full text-sm border border-gray-200 rounded-md bg-white px-2 mt-1 text-gray-800",children:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"].map((e,s)=>t.jsx("option",{value:s,children:e},e))})]}),C==="monthly"&&t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Day of month (1–28)"}),t.jsx(T,{type:"number",min:"1",max:"28",value:V,onChange:e=>de(e.target.value),className:"mt-1"})]}),C!=="none"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Time (24h)"}),t.jsx(T,{type:"time",value:ue,onChange:e=>Ae(e.target.value),className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Recipients (comma-separated emails)"}),t.jsx(T,{value:Me,onChange:e=>Le(e.target.value),placeholder:"[email protected]",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx(N,{className:"text-xs text-gray-500",children:"Delivery"}),t.jsxs("div",{className:"flex gap-2 mt-1",children:[t.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700",children:[t.jsx("input",{type:"checkbox",checked:me.includes("email"),onChange:()=>Ee("email"),className:"w-4 h-4 rounded border-gray-300 text-emerald-600"})," Email"]}),t.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-gray-700",children:[t.jsx("input",{type:"checkbox",checked:me.includes("notification"),onChange:()=>Ee("notification"),className:"w-4 h-4 rounded border-gray-300 text-emerald-600"})," In-app notification"]})]})]})]})]}),t.jsxs(se,{children:[t.jsx(_,{variant:"outline",onClick:()=>G(!1),disabled:xe,children:"Cancel"}),t.jsx(_,{onClick:yt,disabled:xe,className:"bg-emerald-600 hover:bg-emerald-700",children:xe?t.jsx(ye,{size:16,className:"animate-spin"}):"Save schedule"})]})]})})]})}function Gt(a){return{office_name:"Office",assigned_accountant:"Staff",status:"Status",job_type:"Job type",financial_year:"FY"}[a]||a}function R({label:a,children:i}){return t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-semibold text-gray-500 mb-1.5",children:a}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:i})]})}function A({active:a,onClick:i,children:j}){return t.jsx("button",{onClick:i,className:`shrink-0 px-2.5 py-1 rounded-full text-xs font-medium border transition-colors ${a?"bg-emerald-600 text-white border-emerald-600":"bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,children:j})}function Ge(a,i){const j=URL.createObjectURL(a),x=document.createElement("a");x.href=j,x.download=i,x.click(),setTimeout(()=>URL.revokeObjectURL(j),2e3)}function F(a){return String(a??"").replace(/[&<>"]/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[i])}export{sa 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.