PageSourceSearch

https://clozure.net/assets/TaxDashboard-B6Pkk8Bd.js

js clozure.net collected 2026-10-02 01:07:39 UTC 13,739 bytes, 1 lines download raw bytes

1import{p as de,r as $,j as e}from"./react-vendor-Ca39dfnS.js";import{a as E,u as P}from"./query-vendor-CZuItqE6.js";import{u as ce,K as oe,B as g,C as l,a as d,b as c,d as o,c as b,D as xe,a9 as me,y as he,z as ue,E as je,G as ge,L as N,R as q,U as B,V as I,W as M,X as r,I as R,aa as pe,e as p,a5 as fe,v as T,w as A}from"./main-klyVOJfp.js";import{T as H,a as V,b as w,c as x,d as J,e as m}from"./table-D2yQDG3z.js";import{$ as ye,aD as Ne,z as Y,H as O,k as z,q as ve,v as be,g as Te,h as we,F as De}from"./ui-vendor-CDWeqcbU.js";import{R as G,B as Ce,C as Se,X as Fe,Y as $e,T as X,l as Ee,a as _,g as Pe,h as Re,i as Ae,f as Oe,r as Ue}from"./chart-vendor-B24y44e_.js";import"./modulepreload-polyfill-B5Qt9EMX.js";const Ke={sales:"Sales Tax",income:"Income Tax",payroll:"Payroll Tax",property:"Property Tax",vat:"VAT"},D=t=>{if(!t)return"Other";const n=t.toString().toLowerCase();return Ke[n]??t.charAt(0).toUpperCase()+t.slice(1)+" Tax"},h=t=>{if(t==null)return 0;const n=typeof t=="number"?t:Number(t);return Number.isFinite(n)?n:0},W=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6"];function Ve(){const{businessId:t}=de(),{toast:n}=ce(),[f,Le]=$.useState(String(new Date().getUTCFullYear())),{data:u=[],isLoading:Z}=E({queryKey:["/api/gap/finance/tax-obligations",t,f],enabled:!!t}),{data:ee}=E({queryKey:["/api/gap/finance/tax-summary",t,f],enabled:!!t}),{data:U=[]}=E({queryKey:["/api/gap/finance/tax-rates",t],enabled:!!t}),[ae,C]=$.useState(!1),[i,j]=$.useState({rateType:"income",region:"US",jurisdiction:"US Federal",rate:"",description:""}),S=P({mutationFn:async()=>await A(`/api/gap/finance/tax-rates/${t}`,{method:"POST",body:JSON.stringify({rateType:i.rateType,region:i.region,jurisdiction:i.jurisdiction,rate:Number(i.rate),description:i.description||void 0})}),onSuccess:()=>{T.invalidateQueries({queryKey:["/api/gap/finance/tax-rates",t]}),C(!1),j({rateType:"income",region:"US",jurisdiction:"US Federal",rate:"",description:""}),n({title:"Tax rate added",description:'Will be applied on the next "Refresh from Transactions".'})},onError:a=>n({title:"Failed to add tax rate",description:a?.message||"Error",variant:"destructive"})}),K=P({mutationFn:async a=>await A(`/api/gap/finance/tax-rates/${t}/${a}`,{method:"DELETE"}),onSuccess:()=>{T.invalidateQueries({queryKey:["/api/gap/finance/tax-rates",t]}),n({title:"Tax rate removed"})},onError:a=>n({title:"Failed to remove tax rate",description:a?.message||"Error",variant:"destructive"})}),v=P({mutationFn:async()=>await A(`/api/gap/finance/tax-obligations/${t}/refresh`,{method:"POST",body:JSON.stringify({year:Number(f)})}),onSuccess:a=>{T.invalidateQueries({queryKey:["/api/gap/finance/tax-obligations",t,f]}
1),T.invalidateQueries({queryKey:["/api/gap/finance/tax-summary",t,f]});const s=a.warnings?.[0];n({title:"Tax obligations refreshed",description:`${a.generated} generated, ${a.updated} updated from your transactions.${s?` Note: ${s}`:""}`})},onError:a=>{n({title:"Failed to refresh tax obligations",description:a?.message||"Could not compute tax obligations from transactions",variant:"destructive"})}}),L=(u||[]).filter(a=>a.status==="pending"&&a.dueDate&&new Date(a.dueDate)>new Date).sort((a,s)=>new Date(a.dueDate).getTime()-new Date(s.dueDate).getTime()).slice(0,5),F=(u||[]).filter(a=>a.status==="pending"&&a.dueDate&&new Date(a.dueDate)<new Date).length,se=(u||[]).filter(a=>a.status==="pending").length,te=(u||[]).filter(a=>a.status==="filed"||a.status==="paid").length,ie=(u||[]).reduce((a,s)=>a+h(s.amountOwed),0),k=(ee?.byType||[]).map(a=>({name:D(a.taxType),value:h(a.totalOwed)})).filter(a=>a.value>0),ne=(()=>{const a={Q1:{estimated:0,actual:0},Q2:{estimated:0,actual:0},Q3:{estimated:0,actual:0},Q4:{estimated:0,actual:0}};return(u||[]).forEach(s=>{if(!s.dueDate)return;const y=new Date(s.dueDate).getMonth(),Q=y<3?"Q1":y<6?"Q2":y<9?"Q3":"Q4";a[Q].estimated+=h(s.amountOwed),s.status==="paid"&&(a[Q].actual+=h(s.amountPaid)||h(s.amountOwed))}),Object.entries(a).map(([s,y])=>({quarter:s,...y}))})(),re=(a,s)=>a==="paid"?e.jsxs(p,{className:"bg-green-100 text-green-800",children:[e.jsx(z,{className:"h-3 w-3 mr-1"}),"Paid"]}):a==="filed"?e.jsxs(p,{className:"bg-blue-100 text-blue-800",children:[e.jsx(De,{className:"h-3 w-3 mr-1"}),"Filed"]}):s&&new Date(s)<new Date?e.jsxs(p,{className:"bg-red-100 text-red-800",children:[e.jsx(Y,{className:"h-3 w-3 mr-1"}),"Overdue"]}):s&&new Date(s)<Ue(new Date,14)?e.jsxs(p,{className:"bg-yellow-100 text-yellow-800",children:[e.jsx(O,{className:"h-3 w-3 mr-1"}
1),"Due Soon"]}):e.jsxs(p,{variant:"outline",children:[e.jsx(O,{className:"h-3 w-3 mr-1"}),"Pending"]}),le=a=>{const s=Math.ceil((new Date(a).getTime()-new Date().getTime())/864e5);return s<0?e.jsxs("span",{className:"text-red-600 font-medium",children:[Math.abs(s)," days overdue"]}):s===0?e.jsx("span",{className:"text-red-600 font-medium",children:"Due today"}):s<=7?e.jsxs("span",{className:"text-yellow-600",children:[s," days"]}):e.jsxs("span",{children:[s," days"]})};return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsx(oe,{department:"FINANCE",title:"Tax Dashboard",subtitle:"Tax obligations, deadlines, and compliance tracking",actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:"outline",onClick:()=>v.mutate(),disabled:v.isPending,"data-testid":"button-refresh-tax-obligations",children:[e.jsx(ye,{className:`mr-2 h-4 w-4 ${v.isPending?"animate-spin":""}`}),v.isPending?"Calculating…":"Refresh from Transactions"]}),e.jsxs(g,{variant:"outline",children:[e.jsx(Ne,{className:"bg-white/20 text-white hover:bg-white/30 border-white/20"}),"Export"]})]}),compact:!0}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsxs(l,{className:F>0?"border-red-200 bg-red-50":"",children:[e.jsx(d,{className:"pb-2",children:e.jsx(c,{className:"text-sm font-medium text-muted-foreground",children:"Overdue"})}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:`h-5 w-5 ${F>0?"text-red-600":"text-gray-400"}`}),e.jsx("span",{className:"text-3xl font-bold",children:F})]})})]}),e.jsxs(l,{children:[e.jsx(d,{className:"pb-2",children:e.jsx(c,{className:"text-sm font-medium text-muted-foreground",children:"Pending"})}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{className:"h-5 w-5 text-yellow-500"}),e.jsx("span",{className:"text-3xl font-bold",children:se})]})})]}),e.jsxs(l,{children:[e.jsx(d,{className:"pb-2",children:e.jsx(c,{className:"text-sm font-medium text-muted-foreground",children:"Filed/Paid"})}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-5 w-5 text-green-500"}),e.jsx("span",{className:"text-3xl font-bold",children:te})]})})]}),e.jsxs(l,{children:[e.jsx(d,{className:"pb-2",children:e.jsx(c,{className:"text-sm font-medium text-muted-foreground",children:"Total Estimated"})}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"h-5 w-5 text-blue-500"}),e.jsxs("span",{className:"text-3xl font-bold",children:["$",(ie/1e3).toFixed(0),"K"]})]})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(l,{className:"lg:col-span-2",children:[e.jsxs(d,{children:[e.jsx(c,{children:"Quarterly Tax Liability"}),e.jsx(b,{children:"Estimated vs actual payments"})]}),e.jsx(o,{children:e.jsx("div",{className:"h-[300px]",children:e.jsx(G,{width:"100%",height:"100%",children:e.jsxs(Ce,{data:ne,children:[e.jsx(Se,{strokeDasharray:"3 3"}),e.jsx(Fe,{dataKey:"quarter"}),e.jsx($e,{tickFormatter:a=>`$${(a/1e3).toFixed(0)}K`}),e.jsx(X,{formatter:a=>`$${a.toLocaleString()}`}),e.jsx(Ee,{}),e.jsx(_,{dataKey:"estimated",fill:"#94a3b8",name:"Estimated"}),e.jsx(_,{dataKey:"actual",fill:"#3b82f6",name:"Actual Paid"})]})})})})]}),e.jsxs(l,{children:[e.jsxs(d,{children:[e.jsx(c,{children:"Tax Breakdown"}),e.jsx(b,{children:"By category"})]}),e.jsx(o,{children:e.jsx("div",{className:"h-[300px]",children:e.jsx(G,{width:"100%",height:"100%",children:e.jsxs(Pe,{children:[e.jsx(Re,{data:k,cx:"50%",cy:"50%",innerRadius:60,outerRadius:80,paddingAngle:5,dataKey:"value",label:({name:a,percent:s})=>`${a} ${(s*100).toFixed(0)}%`,labelLine:!1,children:k.map((a,s)=>e.jsx(Ae,{fill:W[s%W.length]},`cell-${s}`))}),e.jsx(X,{formatter:a=>`$${a.toLocaleString()}`})]})})})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(l,{children:[e.jsxs(d,{children:[e.jsx(c,{children:"Upcoming Deadlines"}),e.jsx(b,{children:"Next 5 tax obligations"})]}),e.jsx(o,{children:e.jsxs("div",{className:"space-y-4",children:[L.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:D(a.taxType)}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a.jurisdiction," • ",a.period]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"font-medium",children:["$",h(a.amountOwed).toLocaleStr
1ing()]}),e.jsx("p",{className:"text-sm",children:le(a.dueDate)})]})]},a.id)),L.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No upcoming deadlines"})]})})]}),e.jsxs(l,{children:[e.jsxs(d,{className:"flex flex-row items-center justify-between space-y-0",children:[e.jsxs("div",{children:[e.jsxs(c,{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),"Tax Rates"]}),e.jsx(b,{children:"Configure rates used by the tax engine"})]}),e.jsxs(xe,{open:ae,onOpenChange:C,children:[e.jsx(me,{asChild:!0,children:e.jsxs(g,{size:"sm",variant:"outline","data-testid":"button-add-tax-rate",children:[e.jsx(Te,{className:"h-4 w-4 mr-1"}),"Add Rate"]})}),e.jsxs(he,{children:[e.jsxs(ue,{children:[e.jsx(je,{children:"Add Tax Rate"}),e.jsx(ge,{children:"Income rate overrides the default 25% federal+state estimate. Sales rates are applied to income transactions during refresh."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(N,{children:"Type"}),e.jsxs(q,{value:i.rateType,onValueChange:a=>j(s=>({...s,rateType:a})),children:[e.jsx(B,{"data-testid":"select-rate-type",children:e.jsx(I,{})}),e.jsxs(M,{children:[e.jsx(r,{value:"income",children:"Income Tax"}),e.jsx(r,{value:"sales",children:"Sales Tax"}),e.jsx(r,{value:"vat",children:"VAT"}),e.jsx(r,{value:"gst",children:"GST"})]})]})]}),e.jsxs("div",{children:[e.jsx(N,{children:"Region"}),e.jsxs(q,{value:i.region,onValueChange:a=>j(s=>({...s,region:a})),children:[e.jsx(B,{"data-testid":"select-region",children:e.jsx(I,{})}),e.jsxs(M,{children:[e.jsx(r,{value:"US",children:"US"}),e.jsx(r,{value:"EU",children:"EU"}),e.jsx(r,{value:"UK",children:"UK"}),e.jsx(r,{value:"CA",children:"CA"}),e.jsx(r,{value:"AU",children:"AU"}),e.jsx(r,{value:"IN",children:"IN"}),e.jsx(r,{value:"global",children:"Global"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(N,{children:"Jurisdiction"}),e.jsx(R,{value:i.jurisdiction,onChange:a=>j(s=>({...s,jurisdiction:a.target.value})),placeholder:"e.g. California, US Federal, Texas","data-testid":"input-jurisdiction"})]}),e.jsxs("div",{children:[e.jsx(N,{children:"Rate (%)"}),e.jsx(R,{type:"number",step:"0.01",min:"0",max:"100",value:i.rate,onChange:a=>j(s=>({...s,rate:a.target.value})),placeholder:"e.g. 7.25","data-testid":"input-rate"})]}),e.jsxs("div",{children:[e.jsx(N,{children:"Description (optional)"}),e.jsx(R,{value:i.description,onChange:a=>j(s=>({...s,description:a.target.value})),placeholder:"e.g. State of California sales tax","data-testid":"input-description"})]})]}),e.jsxs(pe,{children:[e.jsx(g,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(g,{onClick:()=>S.mutate(),disabled:S.isPending||!i.rate||!i.jurisdiction,"data-testid":"button-save-tax-rate",children:S.isPending?"Saving…":"Save"})]})]})]})]}),e.jsx(o,{children:U.length===0?e.jsx("div",{className:"text-sm text-muted-foreground py-4 text-center",children:"No custom rates configured. The engine uses a 25% income-tax estimate and skips sales tax."}):e.jsxs(H,{children:[e.jsx(V,{children:e.jsxs(w,{children:[e.jsx(x,{children:"Type"}),e.jsx(x,{children:"Jurisdiction"}),e.jsx(x,{children:"Rate"}),e.jsx(x,{className:"w-[60px]"})]})}),e.jsx(J,{children:U.map(a=>e.jsxs(w,{children:[e.jsx(m,{children:e.jsx(p,{variant:"outline",children:D(a.rateType)})}),e.jsxs(m,{children:[e.jsx("p",{className:"font-medium",children:a.jurisdiction}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.region})]}),e.jsxs(m,{className:"font-mono",children:[h(a.rate).toFixed(2),"%"]}),e.jsx(m,{children:e.jsx(g,{size:"sm",variant:"ghost",onClick:()=>K.mutate(a.id),disabled:K.isPending,"data-testid":`button-delete-rate-${a.id}`,children:e.jsx(we,{className:"h-4 w-4 text-red-500"})})})]},a.id))})]})})]}),e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(c,{children:"All Obligations"})}),e.jsx(o,{children:Z?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((a,s)=>e.jsx(fe,{className:"h-12 w-full"},s))}):e.jsxs(H,{children:[e.jsx(V,{children:e.jsxs(w,{children:[e.jsx(x,{children:"Type"}),e.jsx(x,{children:"Due Date"}),e.jsx(x,{children:"Amount"}),e.jsx(x,{children:"Status"})]})}),e.jsx(J,{children:(u||[]).slice(0,8).map(a=>e.jsxs(w,{children:[e.jsxs(m,{children:[e.jsx("p",{className:"font-medium",children:D(a.taxType)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.jurisdiction})]}),e.jsx(m,{children:a.dueDate?Oe(new Date(a.dueDate),"MMM d, yyyy"):"-"}
1),e.jsxs(m,{children:["$",h(a.amountOwed).toLocaleString()]}),e.jsx(m,{children:re(a.status,a.dueDate)})]},a.id))})]})})]})]})]})}export{Ve 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.