PageSourceSearch

https://medifit-nienburg.de/assets/RevenueSummary-C9GjAIeJ.js

js medifit-nienburg.de collected 2026-10-04 03:32:52 UTC 8,412 bytes, 2 lines download raw bytes

1import{a as c,j as e}from"./trpc-vendor-Bta84Nsh.js";import{t as x,C as k,e as T,f as V,B as N,h as B,I as oe,i as l,g as F}from"./index-_3-B0itT.js";import{S as Y,a as E,b as D,c as P,d as G}from"./select-DqcHU93A.js";import{t as J,m as ie,cz as ce,aj as w,ah as le,aA as me}from"./ui-vendor-NEZNvIbV.js";import"./react-vendor-DpXpH6G7.js";function de(){const a=new Date;return{year:a.getFullYear(),month:a.getMonth()+1}}const ue=["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"];function M(a,m){return`${ue[m-1]} ${a}`}function C(a){return a===1?"1-Monats-Abo":a===12?"12-Monats-Abo":a===24?"24-Monats-Abo":`${a}-Monats-Abo`}function xe(){const a=new Date,m=[];for(let i=0;i<12;i++){const h=new Date(a.getFullYear(),a.getMonth()-i,1);m.push({year:h.getFullYear(),month:h.getMonth()+1})}return m}function je(){const{year:a,month:m}=de(),[i,h]=c.useState(a),[p,K]=c.useState(m),[Q,H]=c.useState(null),[y,v]=c.useState(!1),[z,A]=c.useState(!1),[d,$]=c.useState({}),O=x.useUtils(),{data:Z=[]}=x.brands.list.useQuery(),f=Z,o=Q??f[0]?.id??null,g=f.find(t=>t.id===o),{data:n,isLoading:R}=x.revenueSummary.getRates.useQuery({brandId:o},{enabled:o!=null,staleTime:6e4}),{data:I=[],isLoading:_}=x.revenueSummary.get.useQuery({brandId:o??void 0,year:i,month:p},{enabled:o!=null,staleTime:3e4}),S=x.revenueSummary.updateRates.useMutation({onSuccess:()=>{J.success("Umsatz Moremembers gespeichert"),O.revenueSummary.getRates.invalidate({brandId:o}),v(!1)}});function b(t){return y&&d[t]!==void 0?parseFloat(d[t])||0:n?t===1?n.commission1m:t===12?n.commission12m:t===24?n.commission24m:n.commissionPerContract:39.8}const u=c.useMemo(()=>{const t=new Map;for(const s of I){const r=s.durationMonths,j=t.get(r)??{count:0,totalValue:0};t.set(r,{duration:r,count:j.count+s.count,totalValue:j.totalValue+s.totalValue})}return Array.from(t.values()).sort((s,r)=>s.duration-r.duration)},[I]),L=u.reduce((t,s)=>t+s.count,0),U=u.reduce((t,s)=>t+s.count*b(s.duration),0);function q(){const t={};n&&(t[1]=String(n.commission1m),t[12]=String(n.commission12m),t[24]=String(n.commission24m)),$(t),v(!0)}async function W(){o&&await S.mutateAsync({brandId:o,commission1m:parseFloat(d[1])||null,commission12m:parseFloat(d[12])||null,commission24m:parseFloat(d[24])||null})}function X(){const t=[];t.push(`Umsatz Moremembers Abrechnung – ${M(i,p)}`),g&&t.push(`Marke: ${g.name}
1`),t.push(""),t.push("Laufzeit          | Anzahl | Umsatz Moremembers/Abschluss | Gesamt"),t.push("──────────────────────────────────────────────────────────");for(const s of u){const r=b(s.duration),j=s.count*r,se=C(s.duration).padEnd(18),ae=String(s.count).padStart(6),re=l(r).padStart(20),ne=l(j).padStart(7);t.push(`${se}| ${ae} | ${re} | ${ne}`)}return t.push("──────────────────────────────────────────────────────────"),t.push(`Gesamt: ${L} Abschlüsse → Umsatz Moremembers: ${l(U)}`),t.join(`
2`)}async function ee(){await navigator.clipboard.writeText(X()),A(!0),J.success("In Zwischenablage kopiert"),setTimeout(()=>A(!1),2e3)}const te=xe();return e.jsxs("div",{className:"p-6 max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(ie,{className:"h-6 w-6 text-primary"}),"Umsatz-Zusammenfassung"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Umsatz Moremembers Abrechnung nach Vertragslaufzeiten"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Y,{value:`${i}-${p}`,onValueChange:t=>{const[s,r]=t.split("-").map(Number);h(s),K(r)},children:[e.jsx(E,{className:"w-44",children:e.jsx(D,{})}),e.jsx(P,{children:te.map(t=>e.jsx(G,{value:`${t.year}-${t.month}`,children:M(t.year,t.month)},`${t.year}-${t.month}`))})]}),f.length>1&&e.jsxs(Y,{value:String(o??""),onValueChange:t=>H(Number(t)),children:[e.jsx(E,{className:"w-44",children:e.jsx(D,{placeholder:"Marke wählen"})}),e.jsx(P,{children:f.map(t=>e.jsx(G,{value:String(t.id),children:t.name},t.id))})]})]})]}),e.jsxs(k,{className:"bg-card border-border",children:[e.jsx(T,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(V,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ce,{className:"h-4 w-4 text-primary"}),"Umsatz Moremembers Sätze"]}),y?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>v(!1),children:"Abbrechen"}),e.jsx(N,{size:"sm",onClick:W,disabled:S.isPending,children:S.isPending?e.jsx(w,{className:"h-3 w-3 animate-spin"}):"Speichern"})]}):e.jsx(N,{variant:"outline",size:"sm",onClick:q,disabled:R,children:"Bearbeiten"})]})}),e.jsx(B,{children:R?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(w,{className:"h-4 w-4 animate-spin"})," Lädt..."]}):e.jsx("div",{className:"grid grid-cols-3 gap-4",children:[1,12,24].map(t=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:C(t)}),y?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(oe,{type:"number",min:0,step:.01,value:d[t]??"",onChange:s=>$(r=>({...r,[t]:s.target.value})),className:"h-8 text-sm",placeholder:String(n?.commissionPerContract??39.8)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"€"})]}):e.jsx("p",{className:"text-lg font-semibold text-foreground",children:l(b(t))})]},t))})})]}),e.jsxs(k,{className:"bg-card border-border",children:[e.jsx(T,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(V,{className:"text-sm font-medium",children:[M(i,p),g&&e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["– ",g.name]})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:ee,disabled:u.length===0,children:[z?e.jsx(le,{className:"h-4 w-4 text-green-400"}):e.jsx(me,{className:"h-4 w-4"}),e.jsx("span",{className:"ml-1.5",children:z?"Kopiert":"Kopieren"})]})]})}),e.jsx(B,{className:"p-0",children:_?e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground gap-2",children:[e.jsx(w,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Lädt..."})]}):u.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground text-sm",children:"Keine Vertragsabschlüsse in diesem Monat."}):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 border-border bg-muted/30",children:[e.jsx("th",{className:"px-5 py-3 text-left font-medium text-muted-foreground",children:"Laufzeit"}),e.jsx("th",{className:"px-5 py-3 text-right font-medium text-muted-foreground",children:"Absc
2hlüsse"}),e.jsx("th",{className:"px-5 py-3 text-right font-medium text-muted-foreground",children:"Umsatz Moremembers / Abschluss"}),e.jsx("th",{className:"px-5 py-3 text-right font-medium text-muted-foreground",children:"Umsatz Moremembers gesamt"})]})}),e.jsx("tbody",{children:u.map(t=>{const s=b(t.duration),r=t.count*s;return e.jsxs("tr",{className:"border-b border-border/50 hover:bg-muted/20",children:[e.jsx("td",{className:"px-5 py-3.5 font-medium text-foreground",children:C(t.duration)}),e.jsx("td",{className:"px-5 py-3.5 text-right",children:e.jsx(F,{variant:"secondary",className:"font-mono",children:t.count})}),e.jsx("td",{className:"px-5 py-3.5 text-right text-muted-foreground",children:l(s)}),e.jsx("td",{className:"px-5 py-3.5 text-right font-semibold text-foreground",children:l(r)})]},t.duration)})}),e.jsx("tfoot",{children:e.jsxs("tr",{className:"bg-primary/5 border-t border-primary/20",children:[e.jsx("td",{className:"px-5 py-4 font-bold text-foreground",children:"Gesamt"}),e.jsx("td",{className:"px-5 py-4 text-right",children:e.jsx(F,{className:"font-mono bg-primary/20 text-primary border-primary/30",children:L})}),e.jsx("td",{className:"px-5 py-4"}),e.jsx("td",{className:"px-5 py-4 text-right font-bold text-xl text-primary",children:l(U)})]})})]})})})]})]})}export{je 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.