PageSourceSearch

https://hintermoos.at/assets/VendorDetail-tbecmRAF.js

js hintermoos.at collected 2026-10-09 22:02:20 UTC 11,296 bytes, 1 lines download raw bytes

1import{E as Q,a as ee,u as te,r as i,s as E,j as e,m as se,B as ae,w as h,K as u,N as x,x as g}from"./index-MoAbC8_9.js";import{L as P}from"./Layout-jB2m3rBw.js";import{B as re}from"./badge-BHbYeRgi.js";import{T as ne,a as oe,b as H,c as j,d as ce,e as y}from"./table-BNHSYido.js";import{a as ie,b as le,c as B,d as z,e as K,f as de,B as me}from"./breadcrumb-CmKLwRya.js";import{C as O}from"./Header-CnJGZ8vQ.js";import{A as he}from"./arrow-left-CZKmX_Y-.js";import{E as ue}from"./euro-Cc6O9qjZ.js";import{R as xe}from"./receipt-DnGXta2k.js";import{F as Y}from"./file-text-Bif0RP8Y.js";import{T as V}from"./trending-up-Cg9WFJWB.js";import{T as ge}from"./trending-down-EHPUNHPt.js";import{M as fe}from"./minus-Dry52jGc.js";import{R as $,C as pe,X as je,Y as ye,T as G,B as ve,a as Ne}from"./generateCategoricalChart-C2b_mvpD.js";import{B as be}from"./BarChart-FFUEJ1QK.js";import{P as we,a as ke}from"./PieChart-C9_Ud7Rw.js";import{C as Ce}from"./calendar-CnsXUgOr.js";import{A as M}from"./arrow-up-down-D7o6PKMM.js";import{T as De,d as Be}from"./de-Ihp2MKUo.js";import{i as T,p as Me,q as Te,r as _e,s as Ie}from"./en-US-CQ3IMwMG.js";import{f as Re}from"./format-Beid_ZIk.js";import{c as Ae}from"./cs-DzBP63t1.js";import"./mountain-BHfTfCFy.js";import"./user-Cvsz7Lm_.js";import"./index-Dh4i1-J3.js";const Fe={full:"EEEE, d MMMM yyyy",long:"d MMMM yyyy",medium:"d MMM yyyy",short:"dd/MM/yyyy"},Le={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Se={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Ee={date:T({formats:Fe,defaultWidth:"full"}),time:T({formats:Le,defaultWidth:"full"}),dateTime:T({formats:Se,defaultWidth:"full"})},Pe={code:"en-GB",formatDistance:Me,formatLong:Ee,formatRelative:Te,localize:_e,match:Ie,options:{weekStartsOn:1,firstWeekContainsDate:4}},dt=()=>{const{vendor:_}=Q(),v=ee(),{language:N}=te(),[o,I]=i.useState([]),[U,R]=i.useState(!0),[b,W]=i.useState("date"),[A,F]=i.useState("desc"),f=_?decodeURIComponent(_):"";i.useEffect(()=>{f&&q()},[f]);const q=async()=>{if(!f)return;R(!0);const{data:t}=await E.from("house_cost_items").select("id, description, amount, item_date, invoice_number, house_cost_id").eq("vendor",f).order("item_date",{ascending:!1});if(t&&t.length>0){const s=[...new Set(t.map(n=>n.house_cost_id).filter(Boolean))],{data:a}=await E.from("house_costs").select("id, category, subcategory, year").in("id",s),c=new Map((a==null?void 0:a.map(n=>[n.id,n]))||[]),D=t.map(n=>{const l=n.house_cost_id?c.get(n.house_cost_id):null;return{id:n.id,description:n.description,amount:Number(n.amount),item_date:n.item_date,invoice_number:n.invoice_number,category:(l==null?void 0:l.category)||"Unknown",subcategory:(l==null?void 0:l.subcategory)||null,year:(l==null?void 0:l.year)||new Date().getFullYear()}});I(D)}else I([]);R(!1)},p=t=>new Intl.NumberFormat(N==="de"?"de-DE":"en-GB",{style:"currency",currency:"EUR",maximumFractionDigits:2}).format(t),X=t=>{if(!t)return"-";const s=N,a=s==="cs"?Ae:s==="de"?Be:Pe;return Re(new Date(t),"dd.MM.yyyy",{locale:a})},w=i.useMemo(()=>o.reduce((t,s)=>t+s.amount,0),[o]),Z=i.useMemo(()=>o.length>0?w/o.length:0,[w,o.length]),d=i.useMemo(()=>{const t=new Map;return o.forEach(s=>{const a=t.get(s.year)||{total:0,count:0};t.set(s.year,{total:a.total+s.amount,count:a.count+1})}),Array.from(t.entries()).map(([s,a])=>({year:s,...a})).sort((s,a)=>s.year-a.year)},[o]),k=i.useMemo(()=>{const t=new Map;return o.forEach(s=>{const a=s.subcategory||s.category,c=t.get(a)||{value:0,count:0};t.set(a,{value:c.value+s.amount,count:c.count+1})}),Array.from(t.entries()).map(([s,a])=>({name:s,...a})).sort((s,a)=>a.value-s.value)},[o]),m=i.useMemo(()=>{if(d.length<2)return null;const t=d[d.length-1],s=d[d.length-2],a=t.total-s.total,c=s.total>0?(t.total-s.total)/s.total*100:0;return{change:a,changePercent:c,lastYear:t.year,prevYear:s.year}},[d]),J=i.useMemo(()=>{const t=[...o];return t.sort((s,a)=>{let c=0;switch(b){case"date":const D=s.item_date?new Date(s.item_date).getTime():0,n=a.item_date?new Date(a.item_date).getTime():0;c=D-n;break;case"amount":c=s.amount-a.amount;break;case"category":c=s.category.localeCompare(a.category);break}return A==="desc"?-c:c}),t},[o,b,A]),C=t=>{b===t?F(s=>s==="asc"?"desc":"asc"):(W(t),F("desc"))},L={cs:{title:"Detail dodavatele",totalSpent:"Celkem vyplaceno",invoiceCount:"Počet faktur",avgInvoice:"Průměrná faktura",trend:"Trend",yearlyOverview:"Přehled po letech",categoryBreakdown:"Rozdělení podle kategorií",allInvoices:"Všechny faktury",date:"Datum",description:"Popis",category:"Kategorie",amount:"Částka",invoiceNo:"Č. faktury",noData:"Žádná data",compared:"oproti",back:"Zpět",costs:"Náklady",vendors:"Dodavatelé"},de:{title:"Lieferantendetails",totalSpent:"Gesamt ausgegeben",invoiceCount:"Anzahl Rechnungen",avgInvoice:"Ø Rechnung",trend:"Trend",yearlyOverview:"Jahresübersicht",categoryBreakdown:"Kategorienverteilung",allInvoices:"Alle Rechnungen",date:"Datum",description:"Beschreibung",category:"Kategorie",amount:"Betrag",invoiceNo:"Rech.Nr.",noData:"Keine Daten",compared:"gegenüber",back:"Zurück",costs:"Kosten",vendors:"Lieferanten"},en:{title:"Vendor Details",totalSpent:"Total Spent",invoiceCount:"Invoice Count",avgInvoice:"Avg Invoice",trend:"Trend",yearlyOverview:"Yearly Overview",categoryBreakdown:"Category Breakdown",allInvoices:"All Invoices",date:"Date",description:"Description",category:"Category",amount:"Amount",invoiceNo:"Invoice #",noData:"No data",compared:"vs",back:"Back",costs:"Costs",vendors:"Vendors"}},r=L[N]||L.de,S=["hsl(var(--primary))","hsl(var(--accent))","hsl(var(--alpine-sunset))","#8884d8","#82ca9d","#ffc658"];return U?e.jsx(P,{children:e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsx(se,{className:"h-8 w-8 animate-spin text-primary"})})}):e.jsxs(P,{children:[e.jsx("section",{className:"py-8 bg-muted/30 border-b",children:e.jsxs("div",{className:"container",children:[e.jsx(ie,{className:"mb-4",children:e.jsxs(le,{children:[e.jsx(B,{children:e.jsx(z,{href:"/costs",onClick:t=>{t.preventDefault(),v("/costs?tab=house")},className:"cursor-pointer",children:r.costs})}),e.jsx(K,{children:e.jsx(O,{className:"h-4 w-4"})}),e.jsx(B,{children:e.jsx(z,{href:"/costs?tab=house",onClick:t=>{t.preventDefault(),v("/costs?tab=house")},className:"cursor-pointer",children:r.vendors})}),e.jsx(K,{children:e.jsx(O,{className:"h-4 w-4"})}),e.jsx(B,{children:e.jsx(de,{children:f})})]})}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ae,{variant:"outline",size:"icon",onClick:()=>v("/costs?tab=house"),children:e.jsx(he,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"font-serif text-2xl md:text-3xl font-bold text-foreground flex items-center gap-3",children:[e.jsx(me,{className:"h-7 w-7 text-primary"}),f]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:r.title})]})]})]})}),e.jsx("section",{className:"py-8",children:e.jsx("div",{className:"container",children:o.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:r.noData}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"grid gap-4 grid-cols-2 md:grid-cols-4",children:[e.jsxs(h,{children:[e.jsx(u,{className:"pb-2",children:e.jsxs(x,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),r.totalSpent]})}),e.jsx(g,{children:e.jsx("div",{className:"text-2xl font-bold text-primary",children:p(w)})})]}),e.jsxs(h,{children:[e.jsx(u,{className:"pb-2",children:e.jsxs(x,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),r.invoiceCount]})}),e.jsx(g,{children:e.jsx("div",{className:"text-2xl font-bold",children:o.length})})]}),e.jsxs(h,{children:[e.jsx(u,{className:"pb-2",children:e.jsxs(x,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4"}),r.avgInvoice]})}),e.jsx(g,{children:e.jsx("div",{className:"text-2xl font-bold",children:p(Z)})})]}),e.jsxs(h,{children:[e.jsx(u,{className:"pb-2",children:e.jsxs(x,{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(V,{className:"h-4 w-4"}),r.trend]})}),e.jsx(g,{children:m?e.jsxs("div",{className:`flex items-center gap-1 text-2xl font-bold ${m.change>0?"text-destructive":m.change<0?"text-green-600":""}`,children:[m.change>0?e.jsx(V,{className:"h-5 w-5"}):m.change<0?e.jsx(ge,{className:"h-5 w-5"}):e.jsx(fe,{className:"h-5 w-5"}),m.changePercent>0?"+":"",m.changePercent.toFixed(0),"%"]}):e.jsx("div",{className:"text-2xl font-bold text-muted-foreground",children:"-"})})]})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[d.length>0&&e.jsxs(h,{children:[e.jsx(u,{children:e.jsx(x,{className:"font-serif",children:r.yearlyOverview})}),e.jsx(g,{children:e.jsx($,{width:"100%",height:300,children:e.jsxs(be,{data:d,children:[e.jsx(pe,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(je,{dataKey:"year"}),e.jsx(ye,{tickFormatter:t=>`€${(t/1e3).toFixed(0)}k`}),e.jsx(G,{formatter:t=>p(t)}),e.jsx(ve,{dataKey:"total",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})})})]}),k.length>0&&e.jsxs(h,{children:[e.jsx(u,{children:e.jsx(x,{className:"font-serif",children:r.categoryBreakdown})}),e.jsx(g,{children:e.jsx($,{width:"100%",height:300,children:e.jsxs(we,{children:[e.jsx(ke,{data:k,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,fill:"#8884d8",dataKey:"value",label:({name:t,percent:s})=>`${t.substring(0,12)}${t.length>12?"...":""} ${(s*100).toFixed(0)}%`,labelLine:!1,children:k.map((t,s)=>e.jsx(Ne,{fill:S[s%S.length]},`cell-${s}`))}),e.jsx(G,{formatter:t=>p(t)})]})})})]})]}),e.jsxs(h,{children:[e.jsx(u,{children:e.jsxs(x,{className:"font-serif flex items-center gap-2",children:[e.jsx(Y,{className:"h-5 w-5"}),r.allInvoices]})}),e.jsx(g,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(ne,{children:[e.jsx(oe,{children:e.jsxs(H,{
1children:[e.jsx(j,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>C("date"),children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ce,{className:"h-4 w-4"}),r.date,e.jsx(M,{className:"h-3 w-3"})]})}),e.jsx(j,{children:r.description}),e.jsx(j,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>C("category"),children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(De,{className:"h-4 w-4"}),r.category,e.jsx(M,{className:"h-3 w-3"})]})}),e.jsx(j,{children:r.invoiceNo}),e.jsx(j,{className:"text-right cursor-pointer hover:bg-muted/50",onClick:()=>C("amount"),children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[r.amount,e.jsx(M,{className:"h-3 w-3"})]})})]})}),e.jsx(ce,{children:J.map(t=>e.jsxs(H,{children:[e.jsx(y,{className:"font-mono text-sm",children:X(t.item_date)}),e.jsx(y,{className:"max-w-[300px]",title:t.description,children:t.description}),e.jsx(y,{children:e.jsx(re,{variant:"outline",className:"text-xs",children:t.subcategory||t.category})}),e.jsx(y,{className:"text-sm text-muted-foreground",children:t.invoice_number||"-"}),e.jsx(y,{className:"text-right font-semibold",children:p(t.amount)})]},t.id))})]})})})]})]})})})]})};export{dt 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.