1import{r as h,Q as je,l as Y,s as v,a0 as K,j as e,b as S,I as T,B as p,a4 as le,m as ce,u as b}from"./index-BCH4IFx8.js";import{C as j,a as w,b as C,d as R,c as z}from"./card-DaE3Hwfn.js";import{T as ye,a as ge,b as O,c as M}from"./tabs-eUqQwHgv.js";import{B as D}from"./BpSpinner-Bqvfph1h.js";import{R as G}from"./refresh-cw-Bp2bbqxH.js";import{P as Ne}from"./plus-BhX-wvbj.js";import{T as ve}from"./trash-2-CrxPrdNf.js";import{T as be}from"./triangle-alert-m5K6MENR.js";const E=c=>Math.round((Number(c)||0)*100)/100;function de(c,o,m,l,n){const r=E(m),k=E(l),y=E(r-k);return{key:c,label:o,billed:r,cost:k,units:n==null?void 0:Math.round(n*1e3)/1e3,profit:y,margin:r>0?Math.round(y/r*1e3)/10:null}}function we(c){const o=new Map,m=[];for(const l of c)for(const n of l){const r=o.get(n.key);if(!r){m.push(n.key),o.set(n.key,de(n.key,n.label,n.billed,n.cost,n.units));continue}o.set(n.key,de(n.key,r.label,r.billed+n.billed,r.cost+n.cost,r.units==null&&n.units==null?void 0:(r.units??0)+(n.units??0)))}return m.map(l=>o.get(l)).filter(Boolean)}function L(c){const o=E(c.reduce((n,r)=>n+r.billed,0)),m=E(c.reduce((n,r)=>n+r.cost,0)),l=E(o-m);return{billed:o,cost:m,profit:l,margin:o>0?Math.round(l/o*1e3)/10:null}}const d=c=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(Number(c)||0);function Q(c,o=0){const[m,l,n]=c.split("-").map(Number);return new Date(m,(l||1)-1,(n||1)+o).toISOString()}function _e(){const c=new Date,o=new Date(c.getFullYear(),0,1),m=l=>`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")}`;return{from:m(o),to:m(c)}}function me(c,o){const m=o.map(r=>r.map(k=>`"${String(k??"").replace(/"/g,'""')}"`).join(",")).join(` 2`),l=URL.createObjectURL(new Blob([m],{type:"text/csv;charset=utf-8;"})),n=document.createElement("a");n.href=l,n.download=c,n.click(),URL.revokeObjectURL(l)}function Fe(){var ae;const c=_e(),[o,m]=h.useState(c.from),[l,n]=h.useState(c.to),[r,k]=h.useState(null),[y,H]=h.useState({}),[B,Z]=h.useState(null),_=je(),F=Y({queryKey:["platform-finance",r==null?void 0:r.from,r==null?void 0:r.to],enabled:!!r,staleTime:5*60*1e3,queryFn:async()=>{const{data:s,error:t}=await v.functions.invoke("platform-finance-report",{body:{mode:"revenue",period_start:Q(r.from),period_end:Q(r.to,1)}});if(t)throw new Error(t.message);if(s!=null&&s.error)throw new Error(s.error);return s}}),u=((ae=F.data)==null?void 0:ae.organizations)??[],q=h.useMemo(()=>we(u.map(s=>s.lines)),[u]),U=h.useMemo(()=>L(q),[q]),J=async s=>{Z(s);try{const{data:t,error:a}=await v.functions.invoke("platform-finance-report",{body:{mode:"money_flow",organization_id:s,period_start:Q(r.from),period_end:Q(r.to,1)}});if(a)throw new Error(a.message);if(t!=null&&t.error)throw new Error(t.error);H(i=>({...i,[s]:t}))}catch(t){b.error(`Could not read Stripe activity: ${t.message}`)}finally{Z(null)}},ue=async()=>{for(const s of u)await J(s.organization_id)},g=h.useMemo(()=>{const s=Object.values(y),t=a=>s.reduce((i,f)=>i+(a(f)||0),0);return{collected:t(a=>{var i;return((i=a.money_flow)==null?void 0:i.rider_payments)??0}),refunds:t(a=>{var i;return((i=a.money_flow)==null?void 0:i.rider_refunds)??0}),stripeFees:t(a=>{var i;return((i=a.money_flow)==null?void 0:i.stripe_fees)??0}),payouts:t(a=>{var i;return((i=a.money_flow)==null?void 0:i.bank_payouts)??0}),offline:t(a=>{var i;return((i=a.money_flow)==null?void 0:i.offline_collections)??0}),scanned:s.length}},[y]),A=Object.values(y).filter(s=>{var t;return(t=s.exception)==null?void 0:t.flagged}),he=Y({queryKey:["platform-unit-costs"],queryFn:async()=>{const{data:s,error:t}=await v.from("platform_unit_costs").select("*").order("unit_type").order("effective_from",{ascending:!1});if(t)throw t;return s??[]}}),[x,P]=h.useState({unit_type:"email",cost_per_unit:"",effective_from:c.to,notes:""}),X=K({mutationFn:async()=>{const{error:s}=await v.from("platform_unit_costs").insert({unit_type:x.unit_type,cost_per_unit:Number(x.cost_per_unit),effective_from:x.effective_from,notes:x.notes||null});if(s)throw s},onSuccess:()=>{b.success("Rate saved"),P(s=>({...s,cost_per_unit:"",notes:""}
2)),_.invalidateQueries({queryKey:["platform-unit-costs"]}),_.invalidateQueries({queryKey:["platform-finance"]})},onError:s=>b.error(s.message)}),xe=K({mutationFn:async s=>{const{error:t}=await v.from("platform_unit_costs").delete().eq("id",s);if(t)throw t},onSuccess:()=>{_.invalidateQueries({queryKey:["platform-unit-costs"]}),_.invalidateQueries({queryKey:["platform-finance"]})},onError:s=>b.error(s.message)}),[I,ee]=h.useState(""),V=Y({queryKey:["platform-provider-bills",o,l],queryFn:async()=>{const{data:s,error:t}=await v.functions.invoke("platform-provider-costs-sync",{body:{action:"summary",period_start:o,period_end:l}});if(t)throw new Error(t.message);if(s!=null&&s.error)throw new Error(s.error);return(s==null?void 0:s.bills)??[]}}),se=()=>{_.invalidateQueries({queryKey:["platform-provider-bills"]}),_.invalidateQueries({queryKey:["platform-unit-costs"]}),_.invalidateQueries({queryKey:["platform-finance"]})},W=K({mutationFn:async()=>{const{data:s,error:t}=await v.functions.invoke("platform-provider-costs-sync",{body:{action:"sync_twilio",period_start:o,period_end:l}});if(t)throw new Error(t.message);if(s!=null&&s.error)throw new Error(s.error);return s},onSuccess:s=>{b.success(`Twilio: ${d(s.total_spend)} of real charges pulled in`),se()},onError:s=>b.error(s.message)}),te=K({mutationFn:async()=>{const{data:s,error:t}=await v.functions.invoke("platform-provider-costs-sync",{body:{action:"set_resend_bill",period_start:o,period_end:l,amount:Number(I)}});if(t)throw new Error(t.message);if(s!=null&&s.error)throw new Error(s.error);return s},onSuccess:s=>{b.success(s.emails_sent>0?`Resend: ${d(s.amount)} spread over ${s.emails_sent} emails (${d(s.cost_per_email)} each)`:"Resend charge saved"),ee(""),se()},onError:s=>b.error(s.message)}),fe=()=>{const s=[["Organization","Line","Billed","Our cost","Profit","Margin %","Units"]];for(const t of u)for(const a of t.lines)s.push([t.organization_name,a.label,a.billed,a.cost,a.profit,a.margin??"",a.units??""]);for(const t of q)s.push(["ALL ORGANIZATIONS",t.label,t.billed,t.cost,t.profit,t.margin??"",t.units??""]);me(`beyond-pro-profit-${r==null?void 0:r.from}-to-${r==null?void 0:r.to}.csv`,s)},pe=()=>{var t,a,i,f,$,ne,ie;const s=[["Organization","Card payments","Refunds","Stripe fees","Paid to org","Collected off-Stripe","Recorded orders gross","Difference"]];for(const oe of u){const N=y[oe.organization_id];N&&s.push([oe.organization_name,((t=N.money_flow)==null?void 0:t.rider_payments)??0,((a=N.money_flow)==null?void 0:a.rider_refunds)??0,((i=N.money_flow)==null?void 0:i.stripe_fees)??0,((f=N.money_flow)==null?void 0:f.bank_payouts)??0,(($=N.money_flow)==null?void 0:$.offline_collections)??0,((ne=N.recorded)==null?void 0:ne.gross)??0,((ie=N.exception)==null?void 0:ie.delta)??0])}me(`beyond-pro-money-movement-${r==null?void 0:r.from}-to-${r==null?void 0:r.to}.csv`,s)},re=({lines:s})=>e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-muted-foreground",children:[e.jsx("th",{className:"py-2 text-left font-medium",children:"Line"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Units"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Billed"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Our cost"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Profit"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Margin"})]})}),e.jsxs("tbody",{children:[s.map(t=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-2",children:t.label}),e.jsx("td",{className:"py-2 text-right tabular-nums text-muted-foreground",children:t.units?t.units.toLocaleString():"â"}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:t.billed?d(t.billed):"â"}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:t.cost?d(t.cost):"â"}),e.jsx("td",{className:`py-2 text-right tabular-nums ${t.profit<0?"text-destructive":""}`,children:d(t.profit)}),e.jsx("td",{className:"py-2 text-right tabular-nums text-muted-foreground",children:t.margin==null?"â":`${t.margin}%`})]},t.key)),e.jsxs("tr",{className:"font-semibold",children:[e.jsx("td",{className:"py-2",children:"Net profit"}),e.jsx("td",{}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:d(L(s).billed)}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:d(L(s).cost)}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:d(L(s).profit)}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:L(s).margin==null?"â":`${L(s).margin}%`})]})]})]})});
2return e.jsxs("div",{className:"container mx-auto space-y-6 p-4 md:p-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Beyond Pro Finance"}),e.jsx("p",{className:"text-muted-foreground",children:"Every dollar that moved through the platform, what Beyond Pro earned, and what it kept."})]}),e.jsx(j,{children:e.jsxs(w,{className:"flex flex-wrap items-end gap-3 pt-6",children:[e.jsxs("div",{children:[e.jsx(S,{htmlFor:"from",children:"From"}),e.jsx(T,{id:"from",type:"date",value:o,onChange:s=>m(s.target.value),className:"w-44"})]}),e.jsxs("div",{children:[e.jsx(S,{htmlFor:"to",children:"To"}),e.jsx(T,{id:"to",type:"date",value:l,onChange:s=>n(s.target.value),className:"w-44"})]}),e.jsxs(p,{onClick:()=>{H({}),k({from:o,to:l})},disabled:!o||!l,children:[e.jsx(G,{className:"mr-2 h-4 w-4"}),"Run report"]}),F.isFetching&&e.jsx(D,{className:"h-5 w-5"})]})}),F.error&&e.jsx(j,{className:"border-destructive",children:e.jsx(w,{className:"pt-6 text-destructive",children:F.error.message})}),F.data&&e.jsxs(ye,{defaultValue:"overview",children:[e.jsxs(ge,{children:[e.jsx(O,{value:"overview",children:"Overview"}),e.jsx(O,{value:"movement",children:"Money movement"}),e.jsx(O,{value:"profit",children:"Revenue & profit"}),e.jsx(O,{value:"rates",children:"Cost rates"}),e.jsxs(O,{value:"exceptions",children:["Exceptions",A.length?` (${A.length})`:""]})]}),e.jsxs(M,{value:"overview",className:"space-y-4 pt-4",children:[e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[{label:"Billed to organizations",value:U.billed},{label:"Our cost",value:U.cost},{label:"Net profit",value:U.profit},{label:"Rider money recorded",value:u.reduce((s,t)=>s+t.registration.gross,0)}].map(s=>e.jsx(j,{children:e.jsxs(C,{className:"pb-2",children:[e.jsx(R,{children:s.label}),e.jsx(z,{className:"text-2xl tabular-nums",children:d(s.value)})]})},s.label))}),e.jsxs(j,{children:[e.jsxs(C,{children:[e.jsx(z,{children:"Platform total"}),e.jsxs(R,{children:[r==null?void 0:r.from," to ",r==null?void 0:r.to," · ",u.length," organizations"]})]}),e.jsx(w,{children:e.jsx(re,{lines:q})})]})]}),e.jsx(M,{value:"movement",className:"space-y-4 pt-4",children:e.jsxs(j,{children:[e.jsxs(C,{className:"flex-row items-center justify-between gap-3 space-y-0",children:[e.jsxs("div",{children:[e.jsx(z,{children:"Money movement (Stripe)"}),e.jsx(R,{children:"Stripe is the truth here. Read each organization's activity, then drill into the payments behind it."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(p,{variant:"outline",onClick:pe,disabled:!g.scanned,children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"CSV"]}),e.jsxs(p,{onClick:ue,disabled:!!B,children:[B?e.jsx(D,{className:"mr-2 h-4 w-4"}):e.jsx(G,{className:"mr-2 h-4 w-4"}),"Read all organizations"]})]})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[["Card payments",g.collected],["Refunds",g.refunds],["Stripe fees",g.stripeFees],["Paid to organizations",g.payouts],["Collected off-Stripe",g.offline]].map(([s,t])=>e.jsxs("div",{className:"rounded-lg border p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:s}),e.jsx("div",{className:"text-lg font-semibold tabular-nums",children:d(t)})]},s))}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-muted-foreground",children:[e.jsx("th",{className:"py-2 text-left font-medium",children:"Organization"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Card payments"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Refunds"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Stripe fees"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Paid out"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Recorded orders"}),e.jsx("th",{className:"py-2 text-right font-medium"})]})}),e.jsx("tbody",{children:u.map(s=>{var a,i,f,$;const t=y[s.organization_id];return e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsxs("td",{className:"py-2",children:[s.organization_name,(t==null?void 0:t.partial)&&e.jsx(ce,{variant:"outline",className:"ml-2",children:"partial"})]}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:t?d((a=t.money_flow)==null?void 0:a.rider_payments):"â"}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:t?d((i=t.money_flow)==null?void 0:i.rider_refunds):"â"}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:t?d((f=t.money_flow)==null?void 0:f.stripe_fees):"â"}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:t?d(($=t.money_flow)==null?void 0:$.bank_payouts):"â"}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:d(s.registration.gross)}),e.jsx("td",{className:"py-2 text-right",children:e.jsx(p,{size:"sm",variant:"outline",disabled:B===s.organization_id,onClick:()=>J(s.organization_id),children:B===s.organization_id?e.jsx(D,{className:"h-4 w-4"}):t?"Refresh":"Read"})})]},s.organization_id)})})]})})]})]})}),e.jsxs(M,{value:"profit",className:"space-y-4 pt-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(p,{variant:"outline",onClick:fe,children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"CSV"]})}),u.map(s=>{var t;return e.jsxs(j,{children:[e.jsxs(C,{className:"pb-2",children:[e.jsx(z,{className:"text-lg",children:s.organization_name}
2),e.jsxs(R,{children:[s.volumes.emails.toLocaleString()," emails · ",s.volumes.sms_segments.toLocaleString()," text segments ·"," ",s.volumes.mms.toLocaleString()," picture messages · ",s.volumes.ai.toLocaleString()," AI generations"]})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsx(re,{lines:s.lines}),(((t=s.timing_events)==null?void 0:t.length)??0)>0&&e.jsxs("details",{className:"rounded-md border p-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium",children:["Live timing by race (",s.timing_events.length,")"]}),e.jsx("div",{className:"mt-3 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"text-muted-foreground",children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"py-2 text-left font-medium",children:"Race"}),e.jsx("th",{className:"py-2 text-left font-medium",children:"Date"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Riders"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Class entries"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Timing value"})]})}),e.jsx("tbody",{children:s.timing_events.map(a=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-2",children:a.event_name}),e.jsx("td",{className:"py-2",children:a.event_date??"â"}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:a.riders.toLocaleString()}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:a.class_entries.toLocaleString()}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:d(a.value)})]},`${a.event_name}-${a.event_date??""}`))})]})})]})]})]},s.organization_id)})]}),e.jsxs(M,{value:"rates",className:"space-y-4 pt-4",children:[e.jsxs(j,{children:[e.jsxs(C,{children:[e.jsx(z,{children:"What our providers actually charged us"}),e.jsxs(R,{children:["Twilio's real charges for ",o," to ",l," are pulled straight from Twilio. Resend bills a flat plan with no way to read it automatically, so enter what you paid and it is spread across the emails sent in that window. Both update the cost per unit used on the Revenue & profit tab."]})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs(p,{onClick:()=>W.mutate(),disabled:W.isPending,children:[e.jsx(G,{className:`mr-2 h-4 w-4 ${W.isPending?"animate-spin":""}`}),"Pull Twilio charges"]}),e.jsxs("div",{children:[e.jsx(S,{children:"Resend plan charge for this window"}),e.jsx(T,{className:"w-40",type:"number",step:"0.01",placeholder:"0.00",value:I,onChange:s=>ee(s.target.value)})]}),e.jsx(p,{variant:"secondary",onClick:()=>te.mutate(),disabled:!I||te.isPending,children:"Save Resend charge"})]}),V.isLoading?e.jsx(D,{}):(V.data??[]).length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No provider charges recorded for this window yet."}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-muted-foreground",children:[e.jsx("th",{className:"py-2 text-left font-medium",children:"Provider"}),e.jsx("th",{className:"py-2 text-left font-medium",children:"What for"}),e.jsx("th",{className:"py-2 text-left font-medium",children:"Window"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Units"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Charged us"}),e.jsx("th",{className:"py-2 text-left font-medium",children:"Source"})]})}),e.jsx("tbody",{children:(V.data??[]).map(s=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-2 capitalize",children:s.provider}),e.jsx("td",{className:"py-2 capitalize",children:String(s.category).replace(/_/g," ")}),e.jsxs("td",{className:"py-2",children:[s.period_start," â ",s.period_end]}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:Number(s.units).toLocaleString()}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:d(s.amount)}),e.jsx("td",{className:"py-2",children:e.jsx(ce,{variant:s.source==="api"?"default":"secondary",children:s.source==="api"?"From provider":"Entered"})})]},s.id))})]})]})]}),e.jsxs(j,{children:[e.jsxs(C,{children:[e.jsx(z,{children:"Beyond Pro cost rates"}),e.jsx(R,{children:"What each unit costs us. Rates are dated, so adding a new one never changes past months."})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{children:[e.jsx(S,{children:"Type"}),e.jsxs("select",{className:"h-10 w-40 rounded-md border bg-background px-3 text-sm",value:x.unit_type,onCh
2ange:s=>P(t=>({...t,unit_type:s.target.value})),children:[e.jsx("option",{value:"email",children:"Email"}),e.jsx("option",{value:"sms",children:"Text (SMS) segment"}),e.jsx("option",{value:"mms",children:"Picture message"}),e.jsx("option",{value:"ai",children:"AI generation"})]})]}),e.jsxs("div",{children:[e.jsx(S,{children:"Our cost per unit"}),e.jsx(T,{className:"w-36",type:"number",step:"0.0001",value:x.cost_per_unit,onChange:s=>P(t=>({...t,cost_per_unit:s.target.value}))})]}),e.jsxs("div",{children:[e.jsx(S,{children:"Starts"}),e.jsx(T,{className:"w-44",type:"date",value:x.effective_from,onChange:s=>P(t=>({...t,effective_from:s.target.value}))})]}),e.jsxs("div",{className:"min-w-48 flex-1",children:[e.jsx(S,{children:"Note"}),e.jsx(T,{value:x.notes,onChange:s=>P(t=>({...t,notes:s.target.value}))})]}),e.jsxs(p,{onClick:()=>X.mutate(),disabled:!x.cost_per_unit||X.isPending,children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"Add rate"]})]}),e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-muted-foreground",children:[e.jsx("th",{className:"py-2 text-left font-medium",children:"Type"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Cost per unit"}),e.jsx("th",{className:"py-2 text-left font-medium",children:"Starts"}),e.jsx("th",{className:"py-2 text-left font-medium",children:"Note"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:(he.data??[]).map(s=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-2 capitalize",children:s.unit_type}),e.jsxs("td",{className:"py-2 text-right tabular-nums",children:["$",Number(s.cost_per_unit).toFixed(4)]}),e.jsx("td",{className:"py-2",children:s.effective_from}),e.jsx("td",{className:"py-2 text-muted-foreground",children:s.notes}),e.jsx("td",{className:"py-2 text-right",children:e.jsx(p,{size:"icon",variant:"ghost",onClick:()=>xe.mutate(s.id),children:e.jsx(ve,{className:"h-4 w-4"})})})]},s.id))})]})]})]})]}),e.jsx(M,{value:"exceptions",className:"space-y-4 pt-4",children:e.jsxs(j,{children:[e.jsxs(C,{children:[e.jsxs(z,{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-5 w-5 text-amber-600"}),"Stripe vs Beyond Pro records"]}),e.jsx(R,{children:"Read an organization on the Money movement tab to compare it. Anything over a dollar apart shows here."})]}),e.jsx(w,{children:g.scanned===0?e.jsx("p",{className:"text-muted-foreground",children:"No organizations read yet."}):A.length===0?e.jsxs("p",{className:"text-muted-foreground",children:["Everything read so far matches (",g.scanned," organizations)."]}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-muted-foreground",children:[e.jsx("th",{className:"py-2 text-left font-medium",children:"Organization"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Stripe"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Our records"}),e.jsx("th",{className:"py-2 text-right font-medium",children:"Difference"})]})}),e.jsx("tbody",{children:A.map(s=>{var a,i;const t=u.find(f=>f.organization_id===s.organization_id);return e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-2",children:(t==null?void 0:t.organization_name)??s.organization_id}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:d((a=s.money_flow)==null?void 0:a.rider_payments)}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:d((i=s.recorded)==null?void 0:i.gross)}),e.jsx("td",{className:"py-2 text-right tabular-nums text-destructive",children:d(s.exception.delta)})]},s.organization_id)})})]})})]})})]})]})}export{Fe 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.