PageSourceSearch

https://designpro-beta-production.up.railway.app/assets/invoices-BxBXaqkE.js

js designpro-beta-production.up.railway.app collected 2026-10-03 12:12:27 UTC 13,102 bytes, 1 lines download raw bytes

1import{a as o,j as e}from"./vendor-react-DXumv_YA.js";import{aB as J,B as j,b as D,ay as w,k as W,I as x,aG as X,u as F,ae as I,d as f,q as C,o as M,r as K,c1 as Q,c2 as z}from"./index-VMqZ9vdK.js";import{B as A}from"./badge-oUN1VCeP.js";import{P as R}from"./plus-UTFQg5AM.js";import{S as Y}from"./send-DtXhy9Oq.js";import{B as Z}from"./ban-1fCdJx0_.js";import{T as ee}from"./trash-2-peXdFVel.js";import"./vendor-three-BwySL88Q.js";import"./vendor-firebase-6GlpQw54.js";const p=n=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n),U={paid:"bg-green-500/10 text-green-500 border-green-500/20",open:"bg-blue-500/10 text-blue-500 border-blue-500/20",overdue:"bg-red-500/10 text-red-500 border-red-500/20"};function se({open:n,onClose:c}){const{toast:d}=F(),{data:a}=D({queryKey:["/api/qbo/customers"],enabled:n}),[m,r]=o.useState(""),[u,i]=o.useState(""),[v,t]=o.useState(""),[N,L]=o.useState(""),[T,S]=o.useState(""),[E,B]=o.useState(""),[b,g]=o.useState([{description:"",qty:"1",unitPrice:""}]),G=o.useMemo(()=>{if(!a)return[];if(!u)return a.slice(0,10);const s=u.toLowerCase();return a.filter(l=>l.displayName?.toLowerCase().includes(s)||l.email?.toLowerCase().includes(s)).slice(0,10)},[a,u]),y=a?.find(s=>s.id===m),V=()=>g(s=>[...s,{description:"",qty:"1",unitPrice:""}]),_=s=>g(l=>l.filter((h,P)=>P!==s)),q=(s,l,h)=>{g(P=>P.map(($,H)=>H===s?{...$,[l]:h}:$))},O=b.reduce((s,l)=>s+(Number(l.qty)||0)*(Number(l.unitPrice)||0),0),k=I({mutationFn:()=>f("POST","/api/qbo/invoices",{customerRef:{value:m,name:y?.displayName},lines:b.filter(s=>s.description||s.unitPrice).map(s=>({description:s.description,qty:Number(s.qty)||1,unitPrice:Number(s.unitPrice)||0,amount:(Number(s.qty)||1)*(Number(s.unitPrice)||0)})),docNumber:v||void 0,dueDate:N||void 0,email:T||y?.email||void 0,privateNote:E||void 0}),onSuccess:()=>{C.invalidateQueries({queryKey:["/api/qbo/invoices"]}),C.invalidateQueries({queryKey:["/api/qbo/reports"]}),d({title:"Invoice created in QuickBooks"}),c(),r(""),t(""),L(""),S(""),B(""),g([{description:"",qty:"1",unitPrice:""}])},onError:s=>d({title:"Failed",description:s.message,variant:"destructive"})});return e.jsx(M,{open:n,onOpenChange:s=>!s&&c(),children:e.jsxs(K,{className:"w-full sm:max-w-lg overflow-y-auto",children:[e.jsx(Q,{children:e.jsx(z,{className:"text-base",children:"Create Invoice"})}),e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Customer"}),y?e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-card",children:[e.jsx("span",{className:"text-sm flex-1",children:y.displayName}),e.jsx(j,{size:"sm",variant:"ghost",className:"h-6 text-xs",onClick:()=>r(""),children:"Change"})]}):e.jsxs("div",{className:"space-y-1",children:[e.jsx(x,{placeholder:"Search customers...",value:u,onChange:s=>i(s.target.value),className:"h-8 text-sm"}),e.jsx("div",{className:"max-h-32 overflow-y-auto rounded border border-border divide-y divide-border",children:G.map(s=>e.jsxs("button",{className:"w-full text-left px-3 py-1.5 text-sm hover:bg-accent transition-colors",onClick:()=>{r(s.id),S(s.email||"")},children:[e.jsx("span",{className:"font-medium",children:s.displayName}),s.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:s.email})]},s.id))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Invoice #"}),e.jsx(x,{value:v,onChange:s=>t(s.target.value),placeholder:"Auto",className:"h-8 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Due Date"}),e.jsx(x,{type:"date",value:N,onChange:s=>L(s.target.value),className:"h-8 text-sm"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Email"}),e.jsx(x,{value:T,onChange:s=>S(s.target.value),placeholder:"[email protected]",className:"h-8 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-2 block",children:"Line Items"}),e.jsx("div",{className:"space-y-2",children:b.map((s,l)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(x,{value:s.description,onChange:h=>q(l,"description",h.target.value),placeholder:"Description",className:"h-8 text-sm flex-1"}),e.jsx(x,{type:"number",value:s.qty,onChange:h=>q(l,"qty",h.target.value),className:"h-8 text-sm w-16 text-center",min:"1"}),e.jsx(x,{type:"number",value:s.unitPrice,onChange:h=>q(l,"unitPrice",h.target.value),placeholder:"Price",className:"h-8 text-sm w-24 text-right",step:"0.01"}),e.jsx("span",{className:"text-xs text-muted-foreground w-20 text-right pt-2",children:p((Number(s.qty)||0)*(Number(s.unitPrice)||0))}),b.length>1&&e.jsx(j,{size:"icon",variant:"ghost",className:"h-8 w-8 flex-shrink-0",onClick:()=>_(l),children:e.jsx(ee,{className:"w-3.5 h-3.5 text-muted-foreground"})})]},l))}),e.jsxs(j,{size:"sm",variant:"outline",className:"mt-2 gap-1 h-7 text-xs",onClick:V,children:[e.jsx(R,{className:"w-3 h-3"})," Add line"]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-border pt-3",children:[e.jsx("span",{className:"text-sm font-medium",children:"Total"}),e.jsx("span",{className:"text-lg font-bold",children:p(O)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Note"}),e.jsx(x,{value:E,onChange:s=>B(s.target.value),placeholder:"Private note...",className:"h-8 text-sm"})]}),e.jsx(j,{className:"w-full",disabled:!m||k.isPending||O===0,onClick:()=>k.mutate(),children:k.isPending?"Creating...":"Create Invoice"})]})]})})}function te({invoiceId:n,onClose:c}){const{toast:d}=F(),{data:a,isLoading:m}=D({queryKey:["/api/qbo/invoices",n],queryFn:()=>f("GET",`/api/qbo/invoices/${n}`).then(i=>i.json()),enabled:!!n}),r=I({mutationFn:()=>f("POST",`/api/qbo/invoices/${n}/send`),onSuccess:()=>d({title:"Invoice sent"}),onError:i=>d({title:"Send failed",description:i.message,variant:"destructive"})}),u=I({mutationFn:()=>f("POST",`/api/qbo/invoices/${n}/void`),onSuccess:()=>{C.invalidateQueries({queryKey:["/api/qbo/invoices"]}),C.invalidateQueries({queryKey:["/api/qbo/reports"]}),d({title:"Invoice voided"}),c()},onError:i=>d({title:"Void failed",description:i.message,variant:"destructive"})});return e.jsx(M,{open:!!n,onOpenChange:i=>!i&&c(),children:e.jsxs(K,{className:"w-full sm:max-w-lg overflow-y-auto",children:[e.jsx(Q,{children:e.jsxs(z,{className:"text-base flex items-center gap-2",children:["Invoice ",a?.docNumber||"",a?.status&&e.jsx(A,{className:`${U[a.status]} text-[10px] border`,children:a.status})]})}),m?e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsx(w,{className:"h-6 w-48"}),e.jsx(w,{className:"h-4 w-32"}),e.jsx(w,{className:"h-20 w-full"})]}
1):a?e.jsxs("div",{className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Customer"}),e.jsx("p",{className:"font-medium",children:a.customerName})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Date"}),e.jsx("p",{className:"font-medium",children:a.date})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Due Date"}),e.jsx("p",{className:"font-medium",children:a.dueDate||"-"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email"}),e.jsx("p",{className:"font-medium truncate",children:a.email||"-"})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:"Line Items"}),e.jsx("div",{className:"divide-y divide-border rounded-lg border border-border overflow-hidden",children:a.lines.map((i,v)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-sm",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"truncate",children:i.description||"Item"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.qty," x ",p(i.unitPrice)]})]}),e.jsx("p",{className:"font-medium",children:p(i.amount)})]},v))})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-border pt-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total"}),e.jsx("p",{className:"text-xl font-bold",children:p(a.total)})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Balance Due"}),e.jsx("p",{className:`text-xl font-bold ${a.balance>0?"text-red-500":"text-green-500"}`,children:p(a.balance)})]})]}),a.privateNote&&e.jsxs("div",{className:"p-3 rounded-lg bg-muted/50 border border-border",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Note"}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:a.privateNote})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[a.status!=="paid"&&e.jsxs(j,{size:"sm",variant:"outline",className:"gap-1.5 flex-1",onClick:()=>r.mutate(),disabled:r.isPending,children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),r.isPending?"Sending...":"Send Email"]}),a.status!=="paid"&&e.jsxs(j,{size:"sm",variant:"outline",className:"gap-1.5 text-destructive hover:text-destructive",onClick:()=>{confirm("Void this invoice?")&&u.mutate()},disabled:u.isPending,children:[e.jsx(Z,{className:"w-3.5 h-3.5"}),"Void"]})]})]}):null]})})}function ae({onSelect:n}){const[c,d]=o.useState(""),[a,m]=o.useState("all"),{data:r,isLoading:u}=D({queryKey:["/api/qbo/invoices"],queryFn:()=>f("GET","/api/qbo/invoices?limit=100").then(t=>t.json())}),i=o.useMemo(()=>r?r.filter(t=>a==="all"||t.status===a).filter(t=>{if(!c)return!0;const N=c.toLowerCase();return t.customerName?.toLowerCase().includes(N)||t.docNumber?.toLowerCase().includes(N)}):[],[r,a,c]),v=o.useMemo(()=>r?{all:r.length,open:r.filter(t=>t.status==="open").length,overdue:r.filter(t=>t.status==="overdue").length,paid:r.filter(t=>t.status==="paid").length}:{all:0,open:0,overdue:0,paid:0},[r]);return u?e.jsx("div",{className:"space-y-2",children:[...Array(5)].map((t,N)=>e.jsx(w,{className:"h-16"},N))}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex gap-2 items-center",children:e.jsxs("div",{className:"relative flex-1",children:[e.jsx(W,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(x,{value:c,onChange:t=>d(t.target.value),placeholder:"Search invoices...",className:"h-8 text-sm pl-8"})]})}),e.jsx("div",{className:"flex gap-1.5",children:["all","open","overdue","paid"].map(t=>e.jsxs("button",{onClick:()=>m(t),className:`px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${a===t?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:text-foreground"}`,children:[t.charAt(0).toUpperCase()+t.slice(1)," (",v[t],")"]},t))}),e.jsxs("div",{className:"space-y-1.5",children:[i.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No invoices found"}),i.map(t=>e.jsxs("button",{onClick:()=>n(t.id),className:"w-full text-left flex items-center gap-3 p-3 rounded-xl border border-border bg-card hover:bg-accent/50 transition-colors",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(X,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t.docNumber||`#${t.id}`}),e.jsx(A,{className:`${U[t.status]} text-[10px] border px-1.5`,children:t.status})]}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[t.customerName," · ",t.date]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("p",{className:"text-sm font-semibold",children:p(t.total)}),t.balance>0&&t.balance<t.total&&e.jsxs("p",{className:"text-[10px] text-orange-500",children:["Due: ",p(t.balance)]})]})]},t.id))]})]})}
1function xe(){const n=J(),[c,d]=o.useState(null),[a,m]=o.useState(!1);return e.jsxs("div",{className:`${n?"px-4 py-4":"px-6 py-5 max-w-6xl mx-auto"} space-y-4`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:`font-display font-bold tracking-tight ${n?"text-[28px] leading-tight":"text-2xl"}`,children:"Invoices"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"QuickBooks Online invoices and payments. Revenue reporting moved to the dashboard on Home."})]}),e.jsxs(j,{size:"sm",className:"gap-1.5",onClick:()=>m(!0),children:[e.jsx(R,{className:"w-4 h-4"})," New Invoice"]})]}),e.jsx(ae,{onSelect:d}),e.jsx(te,{invoiceId:c,onClose:()=>d(null)}),e.jsx(se,{open:a,onClose:()=>m(!1)})]})}export{xe 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.