PageSourceSearch

https://edgemxtiming.com/assets/PayoutDetailPage-5vTsF3Fd.js

js edgemxtiming.com collected 2026-10-02 01:30:05 UTC 11,283 bytes, 3 lines download raw bytes

1import{K as T,i as R,l as A,r as F,j as e,_ as B,B as g,aa as I,m as _,o as L,p as E,q as z,v as k,n as N,u as H,s as O}from"./index-Ct8eLu1I.js";import{d as U}from"./payoutInvoicePdf-gjnl3NuR.js";import{T as q,a as V,b as v,c as y}from"./tabs-BxjRtXE_.js";import{T as b,a as w,b as o,c as l,d as M,e as n}from"./table--nl4fhep.js";import{A as C}from"./arrow-left-xu1INuH2.js";import{F as G}from"./file-down-CbRcBN9_.js";import{P as J}from"./printer-BlI7yuPd.js";import{E as K}from"./external-link-Jsfrs_aE.js";import{f as x}from"./format-ybceeo2k.js";import"./jspdf.plugin.autotable-B3ApGzWF.js";import"./en-US-CGO0aXMi.js";function d(c){return`$${Number(c||0).toFixed(2)}`}function Q(c){return c==="paid"?"default":c==="failed"?"destructive":c==="draft"||c==="approved"||c==="processing"?"secondary":"outline"}function W(c,m){const s=m.map(D=>D.map($=>{const j=String($??"");return j.includes(",")||j.includes('"')||j.includes(`
2`)?`"${j.replace(/"/g,'""')}"`:j}).join(",")).join(`
3`),f=new Blob([s],{type:"text/csv"}),h=URL.createObjectURL(f),t=document.createElement("a");t.href=h,t.download=c,t.click(),URL.revokeObjectURL(h)}function ce(){const{payoutId:c}=T(),m=R(),{data:s,isLoading:f,error:h}=A({queryKey:["payout-breakdown",c],enabled:!!c,queryFn:async()=>{const{data:r,error:a}=await O.functions.invoke("payout-breakdown",{body:{payout_id:c}});if(a)throw a;if(r!=null&&r.error)throw new Error(r.error);return r}}),t=s==null?void 0:s.payout,D=F.useMemo(()=>t?`${x(new Date(t.period_start),"MMM d, yyyy")} – ${x(new Date(t.period_end),"MMM d, yyyy")}`:"",[t]),$=F.useMemo(()=>t?`payout-${x(new Date(t.period_end),"yyyy-MM-dd")}`:"payout",[t]),j=()=>{var p;if(!s||!t)return;const a=[["Section","Date","Description","Status","Amount"]];for(const i of s.registrations)a.push(["Registration",x(new Date(i.created_at),"yyyy-MM-dd"),`${i.first_name??""} ${i.last_name??""} — ${((p=i.events)==null?void 0:p.name)??""} (${i.confirmation_number??""})`,i.payment_status,Number(i.total_amount||0).toFixed(2)]);for(const i of s.ai_usage)a.push(["AI usage",x(new Date(i.created_at),"yyyy-MM-dd"),`${i.feature??i.model??"AI"}`,"",Number(i.total_cost||0).toFixed(2)]);for(const i of s.clawbacks)a.push(["Refund reconciliation",x(new Date(i.created_at),"yyyy-MM-dd"),i.note??i.stripe_refund_id??"",i.status,Number(i.amount||0).toFixed(2)]);a.push([]),a.push(["Totals","","","",""]),a.push(["Gross","","","",Number(t.gross_revenue).toFixed(2)]),a.push(["Refunds","","","",`-${Number(t.refunds_deducted).toFixed(2)}`]),a.push(["Platform fee","","","",`-${Number(t.platform_fee_cost).toFixed(2)}`]),a.push(["Stripe processing fees","","","",`-${Number(t.stripe_fee_cost||0).toFixed(2)}`]),a.push(["AI cost","","","",`-${Number(t.ai_cost).toFixed(2)}`]),a.push(["Manual adjustment","","",t.adjustment_note??"",Number(t.manual_adjustment).toFixed(2)]),a.push(["Carry-forward","","","",Number(t.carry_forward_amount).toFixed(2)]),a.push(["ACH transfer fee","","","",`-${Number(t.transfer_fee_cost).toFixed(2)}`]),a.push(["Net","","",t.status,Number(t.net_amount).toFixed(2)]),W(`${$}.csv`,a)},P=()=>{window.print()},S=()=>{var r,a,p;if(!(!s||!t))try{U({payout:t,organizationName:(p=(a=(r=s.registrations)==null?void 0:r[0])==null?void 0:a.events)==null?void 0:p.organization_name,registrations:s.registrations,ai_usage:s.ai_usage,clawbacks:s.clawbacks})}catch(i){H.error(i.message||"Failed to generate PDF")}};return f?e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex items-center justify-center p-12",children:e.jsx(B,{className:"h-6 w-6 animate-spin"})})}):h||!t?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"container max-w-3xl py-6",children:[e.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>m("/admin/payouts"),children:[e.jsx(C,{className:"h-4 w-4 mr-2"})," Back"]}),e.jsx("p",{className:"mt-6 text-sm text-destructive",children:(h==null?void 0:h.message)??"Payout not found."})]})}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"container max-w-6xl py-6 space-y-6 print:py-0 print:max-w-none",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap print:hidden",children:[e.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>m("/admin/payouts"),children:[e.jsx(C,{className:"h-4 w-4 mr-2"})," Back to Payouts"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(g,{variant:"default",size:"sm",onClick:S,children:[e.jsx(G,{className:"h-4 w-4 mr-2"})," Download invoice PDF"]}),e.jsxs(g,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(I,{className:"h-4 w-4 mr-2"})," Download CSV"]}),e.jsxs(g,{variant:"outline",size:"sm",onClick:P,children:[e.jsx(J,{className:"h-4 w-4 mr-2"})," Print / Save PDF"]})]})]}),e.jsxs(_,{children:[e.jsx(L,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsx(E,{children:"Payout statement"}),e.jsx(z,{children:D})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-2xl font-semibold",children:d(t.net_amount)}),e.jsxs("div",{className:"mt-1 flex items-center gap-2 justify-end",children:[e.jsx(k,{variant:Q(t.status),children:t.status}),t.stripe_transfer_id&&e.jsxs("a",{href:`https://dashboard.stripe.com/transfers/${t.stripe_transfer_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline inline-flex items-center gap-1",children:["Stripe transfer ",e.jsx(K,{className:"h-3 w-3"})]})]})]})]})}),e.jsxs(N,{children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 text-sm",children:[e.jsx(u,{label:"Gross revenue",value:d(t.gross_revenue)}),e.jsx(u,{label:"Refunds",value:`-${d(t.refunds_deducted)}`}),e.jsx(u,{label:"Platform fee",value:`-${d(t.platform_fee_cost)}`}
3),e.jsx(u,{label:"Stripe processing fees",value:`-${d(t.stripe_fee_cost||0)}`}),e.jsx(u,{label:"AI cost",value:`-${d(t.ai_cost)}`}),e.jsx(u,{label:"Manual adjustment",value:`${Number(t.manual_adjustment)>=0?"+":"-"}${d(Math.abs(Number(t.manual_adjustment)))}`,hint:t.adjustment_note??void 0}),e.jsx(u,{label:"Carry-forward",value:`${Number(t.carry_forward_amount)>=0?"+":"-"}${d(Math.abs(Number(t.carry_forward_amount)))}`}),e.jsx(u,{label:"ACH transfer fee",value:`-${d(t.transfer_fee_cost)}`}),e.jsx(u,{label:"Net",value:d(t.net_amount),bold:!0})]}),t.failure_message&&e.jsx("div",{className:"mt-4 p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:t.failure_message})]})]}),e.jsxs(q,{defaultValue:"registrations",className:"print:hidden",children:[e.jsxs(V,{children:[e.jsxs(v,{value:"registrations",children:["Registrations (",(s==null?void 0:s.registrations.length)??0,")"]}),e.jsxs(v,{value:"ai",children:["AI usage (",(s==null?void 0:s.ai_usage.length)??0,")"]}),e.jsxs(v,{value:"clawbacks",children:["Refund reconciliations (",(s==null?void 0:s.clawbacks.length)??0,")"]}),e.jsxs(v,{value:"audit",children:["Audit log (",(s==null?void 0:s.audit.length)??0,")"]})]}),e.jsx(y,{value:"registrations",children:e.jsx(_,{children:e.jsx(N,{className:"p-0",children:e.jsxs(b,{children:[e.jsx(w,{children:e.jsxs(o,{children:[e.jsx(l,{children:"Date"}),e.jsx(l,{children:"Name"}),e.jsx(l,{children:"Event"}),e.jsx(l,{children:"Confirmation"}),e.jsx(l,{children:"Status"}),e.jsx(l,{className:"text-right",children:"Total"})]})}),e.jsxs(M,{children:[((s==null?void 0:s.registrations)??[]).map(r=>{var a;return e.jsxs(o,{children:[e.jsx(n,{className:"text-xs whitespace-nowrap",children:x(new Date(r.created_at),"MMM d")}),e.jsxs(n,{children:[r.first_name," ",r.last_name]}),e.jsx(n,{className:"text-xs",children:(a=r.events)==null?void 0:a.name}),e.jsx(n,{className:"text-xs font-mono",children:r.confirmation_number}),e.jsx(n,{children:e.jsx(k,{variant:r.payment_status==="paid"?"default":"outline",children:r.payment_status})}),e.jsx(n,{className:"text-right",children:d(r.total_amount)})]},r.id)}),((s==null?void 0:s.registrations.length)??0)===0&&e.jsx(o,{children:e.jsx(n,{colSpan:6,className:"text-center text-sm text-muted-foreground py-8",children:"No registrations in this window."})})]})]})})})}),e.jsx(y,{value:"ai",children:e.jsx(_,{children:e.jsx(N,{className:"p-0",children:e.jsxs(b,{children:[e.jsx(w,{children:e.jsxs(o,{children:[e.jsx(l,{children:"Date"}),e.jsx(l,{children:"Feature"}),e.jsx(l,{children:"Model"}),e.jsx(l,{className:"text-right",children:"Cost"})]})}),e.jsxs(M,{children:[((s==null?void 0:s.ai_usage)??[]).map(r=>e.jsxs(o,{children:[e.jsx(n,{className:"text-xs whitespace-nowrap",children:x(new Date(r.created_at),"MMM d")}),e.jsx(n,{className:"text-xs",children:r.feature}),e.jsx(n,{className:"text-xs",children:r.model}),e.jsx(n,{className:"text-right",children:d(r.total_cost)})]},r.id)),((s==null?void 0:s.ai_usage.length)??0)===0&&e.jsx(o,{children:e.jsx(n,{colSpan:4,className:"text-center text-sm text-muted-foreground py-8",children:"No AI usage in this window."})})]})]})})})}),e.jsx(y,{value:"clawbacks",children:e.jsx(_,{children:e.jsx(N,{className:"p-0",children:e.jsxs(b,{children:[e.jsx(w,{children:e.jsxs(o,{children:[e.jsx(l,{children:"Date"}),e.jsx(l,{children:"Note"}),e.jsx(l,{children:"Refund ID"}),e.jsx(l,{children:"Role"}),e.jsx(l,{children:"Status"}),e.jsx(l,{className:"text-right",children:"Amount"})]})}),e.jsxs(M,{children:[((s==null?void 0:s.clawbacks)??[]).map(r=>e.jsxs(o,{children:[e.jsx(n,{className:"text-xs whitespace-nowrap",children:x(new Date(r.created_at),"MMM d")}),e.jsx(n,{className:"text-xs",children:r.note}),e.jsx(n,{className:"text-xs font-mono",children:r.stripe_refund_id??"—"}),e.jsx(n,{className:"text-xs",children:r.original_payout_id===c?"originated here":"applied here"}),e.jsx(n,{children:e.jsx(k,{variant:"outline",children:r.status})}),e.jsx(n,{className:"text-right",children:d(r.amount)})]},r.id)),((s==null?void 0:s.clawbacks.length)??0)===0&&e.jsx(o,{children:e.jsx(n,{colSpan:6,className:"text-center text-sm text-muted-foreground py-8",children:"No refund reconciliations linked to this payout."})})]})]})})})}),e.jsx(y,{value:"audit",children:e.jsx(_,{children:e.jsx(N,{className:"p-0",children:e.jsxs(b,{children:[e.jsx(w,{children:e.jsxs(o,{children:[e.jsx(l,{children:"When"}),e.jsx(l,{children:"Event"}),e.jsx(l,{children:"Details"})]})}),e.jsxs(M,{children:[((s==null?void 0:s.audit)??[]).map(r=>e.jsxs(o,{children:[e.jsx(n,{className:"text-xs whitespace-nowrap",children:x(new Date(r.created_at),"MMM d, HH:mm")}
3),e.jsx(n,{className:"text-xs",children:r.event}),e.jsxs(n,{className:"text-xs text-muted-foreground",children:[r.note&&e.jsx("div",{children:r.note}),r.before_state&&e.jsxs("div",{children:["before: ",e.jsx("code",{children:JSON.stringify(r.before_state)})]}),r.after_state&&e.jsxs("div",{children:["after: ",e.jsx("code",{children:JSON.stringify(r.after_state)})]})]})]},r.id)),((s==null?void 0:s.audit.length)??0)===0&&e.jsx(o,{children:e.jsx(n,{colSpan:3,className:"text-center text-sm text-muted-foreground py-8",children:"No audit events recorded."})})]})]})})})})]})]})})}function u({label:c,value:m,hint:s,bold:f}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:c}),e.jsx("div",{className:f?"text-lg font-semibold":"text-base",children:m}),s&&e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:s})]})}export{ce 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.