PageSourceSearch

https://medifit-nienburg.de/assets/StudioProfit-DEEXzyZq.js

js medifit-nienburg.de collected 2026-10-04 03:32:04 UTC 9,498 bytes, 1 lines download raw bytes

1import{a as p,j as e}from"./trpc-vendor-Bta84Nsh.js";import{u as A,t as o}from"./index-_3-B0itT.js";import{t as g,ax as D,bp as G,j as $,ap as T}from"./ui-vendor-NEZNvIbV.js";import"./react-vendor-DpXpH6G7.js";const r=d=>d==null?"—":`${Number(d).toLocaleString("de-DE",{maximumFractionDigits:0})} €`,y=()=>{const d=new Date;return`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}`};function L(){const{user:d}=A(),m=d?.role==="admin",b=o.useUtils(),[l,k]=p.useState(y()),[u,w]=p.useState("revenue"),j=o.agencyProfit.summary.useQuery({month:l,allocation:u},{staleTime:3e4,enabled:m}),S=o.agencyProfit.listCosts.useQuery({month:l},{staleTime:3e4,enabled:m}),h=j.data??{studios:[],overheadTotal:0,totals:null},c=h.studios??[],f=S.data??[],N=()=>{b.agencyProfit.summary.invalidate(),b.agencyProfit.listCosts.invalidate()},v=o.agencyProfit.addCost.useMutation({onSuccess:()=>{N(),g.success("Kosten erfasst")},onError:t=>g.error(t?.message??"Fehler")}),P=o.agencyProfit.deleteCost.useMutation({onSuccess:()=>{N()}}),[s,n]=p.useState({brandId:"",category:"",amount:"",recurring:!1}),C=t=>c.find(M=>M.brandId===t)?.name??`#${t}`,a=h.totals,x=t=>t>=0?"text-emerald-500":"text-red-500";if(!m)return e.jsx("div",{className:"max-w-4xl mx-auto p-6",children:e.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 py-14 text-center",children:[e.jsx(D,{className:"w-8 h-8 text-muted-foreground/50 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Kein Zugriff — nur für Admin."})]})});const i="text-sm px-2.5 py-1.5 rounded-md border border-border bg-background outline-none focus:border-primary",I=()=>{if(!s.brandId||!s.category.trim()||!s.amount.trim()){g.error("Studio, Kategorie und Betrag nötig");return}v.mutate({brandId:Number(s.brandId),month:l,category:s.category.trim(),amount:s.amount.trim(),recurring:s.recurring}),n({brandId:"",category:"",amount:"",recurring:!1})};return e.jsxs("div",{className:"p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(G,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Gewinn pro Studio"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Was verdiene ich an jedem Studio? · Deckungsbeitrag & Netto"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("input",{type:"month",value:l,max:y(),onChange:t=>k(t.target.value),className:i}),e.jsxs("select",{value:u,onChange:t=>w(t.target.value),className:i,title:"Wie werden Gemeinkosten verteilt?",children:[e.jsx("option",{value:"revenue",children:"Gemeinkosten nach Umsatz"}),e.jsx("option",{value:"equal",children:"Gemeinkosten gleichmäßig"})]})]})]}),a&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-5",children:[e.jsxs("div",{className:"rounded-xl border border-border bg-card p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Umsatz (Monat)"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-foreground",children:r(a.einnahmen)})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Deckungsbeitrag"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-primary",children:r(a.db)})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Gemeinkosten"}),e.jsx("div",{className:"text-2xl font-bold mt-1 text-foreground",children:r(a.overhead)})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:"Netto-Gewinn"}),e.jsx("div",{className:`text-2xl font-bold mt-1 ${x(a.netto)}`,children:r(a.netto)})]})]}),j.isLoading?e.jsx("div",{className:"py-16 text-center text-sm text-muted-foreground",children:"Laden…"}):c.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 py-14 text-center text-sm text-muted-foreground",children:["Keine Studios mit Agentur-Pauschale. Trage sie pro Studio unter ",e.jsx("b",{children:"Setup → Stammdaten → Pricing & Ziele → Agentur-Pauschale"})," ein."]}):e.jsx("div",{className:"overflow-x-auto rounded-xl border border-border mb-6",children:e.jsxs("table",{className:"w-full text-sm min-w-[760px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-[10px] uppercase tracking-wider text-muted-foreground border-b border-border",children:[e.jsx("th",{className:"text-left px-4 py-2.5 font-semibold",children:"Studio"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold",children:"Einnahmen"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold",children:"Direkt"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold",children:"Deckungsbeitrag"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold",children:"Gemeink."}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold",children:"Netto"}),e.jsx("th",{className:"text-right px-4 py-2.5 font-semibold",children:"Marge"})]})}),e.jsxs("tbody",{children:[c.map(t=>e.jsxs("tr",{className:"border-b border-border last:border-0",children:[e.jsx("td",{className:"px-4 py-2.5 font-medium",children:t.name}),e.jsxs("td",{className:"px-4 py-2.5 text-right",children:[r(t.einnahmen),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Pausch. ",r(t.pauschale)," + Prov. ",r(t.provision)]})]}),e.jsxs("td",{className:"px-4 py-2.5 text-right",children:[r(t.direct),e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["Ad ",r(t.adSpend)," + man. ",r(t.manual)]})]}),e.jsx("td",{className:"px-4 py-2.5 text-right font-bold text-primary",children:r(t.db)}),e.jsx("td",{className:"px-4 py-2.5 text-right text-muted-foreground",children:r(t.overhead)}),e.jsxs("td",{className:`px-4 py-2.5 text-right font-bold ${x(t.netto)}`,children:[t.netto>=0?"+":"",r(t.netto)]}),e.jsxs("td",{className:`px-4 py-2.5 text-right font-semibold ${x(t.netto)}`,children:[t.nettoMargin," %"]})]},t.brandId)),a&&e.jsxs("tr",{className:"border-t-2 border-border bg-muted/20 font-bold",children:[e.jsx("td",{className:"px-4 py-2.5",children:"Gesamt"}),e.jsx("td",{className:"px-4 py-2.5 text-right",children:r(a.einnahmen)}),e.jsx("td",{className:"px-4 py-2.5 text-right",children:r(a.direct)}),e.jsx("td",{className:"px-4 py-2.5 text-right text-primary",children:r(a.db)}),e.jsx("td",{className:"px-4 py-2.5 text-right",children:r(a.overhead)}),e.jsx("td",{className:`px-4 py-2.5 text-right ${x(a.netto)}`,children:r(a.netto)}),e.jsx("td",{className:"px-4 py-2.5 text-right"})]})]})]})}),e.jsxs("div",{className:"text-[11px] text-muted-foreground mb-6",children:["Ad-Spend & Provision kommen automatisch. Provision = provisionspflichtige Verträge × Provisionssatz. Gemeinkosten aus ",e.jsx("b",{children:"Agenturkosten"})," (",r(h.overheadTotal)," im Monat), verteilt ",u==="revenue"?"nach Umsatz":"gleichmäßig","."]}),e.jsxs("div",{className:"rounded-xl border border-border bg-card p-4",children:[e.jsx("h2",{className:"text-sm font-bold uppercase tracking-wider mb-1",children:"Direkte Kosten erfassen"}),e.jsx("p",{className:"text-[11px] text-muted-foreground mb-3",children:'z.B. Plakate/Druck, Telefon, sonstige direkte Kosten pro Studio. „Wiederkehrend" = gilt jeden Monat.'}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2 mb-4",children:[e.jsxs("select",{value:s.brandId,onChange:t=>n({...s,brandId:t.target.value}),className:i,children:[e.jsx("option",{value:"",children:"Studio wählen…"}),c.map(t=>e.jsx("option",{value:t.brandId,children:t.name},t.brandId))]}),e.jsx("input",{value:s.category,onChange:t=>n({...s,category:t.target.value}),placeholder:"Kategorie (z.B. Plakate)",className:i}),e.jsx("input",{value:s.amount,onChange:t=>n({...s,amount:t.target.value.replace(/[^0-9.,]/g,"")}),placeholder:"Betrag €",className:`${i} w-28`,inputMode:"decimal"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:s.recurring,onChange:t=>n({...s,recurring:t.target.checked})})," wiederkehrend"]}),e.jsxs("button",{onClick:I,disabled:v.isPending,className:"inline-flex items-center gap-1.5 rounded-md bg-primary text-primary-foreground text-sm font-medium px-3.5 py-1.5 disabled:opacity-50",children:[e.jsx($,{className:"w-4 h-4"})," Hinzufügen"]})]}),f.length>0&&e.jsx("div",{className:"space-y-1.5",children:f.map(t=>e.jsxs("div",{className:"flex items-center justify-between text-xs rounded-lg border border-border px-3 py-2",children:[e.jsxs("span",{children:[e.jsx("b",{children:C(t.brandId)})," · ",t.category," ",t.recurring?e.jsx("span",{className:"text-primary",children:"· wiederkehrend"}):""]}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx("b",{children:r(Number(t.amount))}),e.jsx("button",{onClick:()=>P.mutate({id:t.id}),className:"text-muted-foreground hover:text-red-500",children:e.jsx(T,{className:"w-3.5 h-3.5"})})]})]},t.id))})]})]})}export{L 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.