Files
MyClub/frontend/build/static/js/266.e18a46b8.chunk.js
T
Tomas Dvorak 84a8acf944 update
2026-03-02 20:20:56 +01:00

2 lines
24 KiB
JavaScript

"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[266],{9266:(e,s,n)=>{n.r(s),n.d(s,{default:()=>ae});var i=n(89379),t=n(65043),a=n(96870),l=n(30502),r=n(98939),c=n(10202),o=n(5371),d=n(28846),h=n(98662),u=n(83169),x=n(24330),j=n(73212),p=n(73225),v=n(76668),m=n(45973),y=n(29244),g=n(35699),b=n(61724),k=n(22107),f=n(80511),C=n(3313),z=n(55395),D=n(83201),S=n(82595),A=n(67813),M=n(39081),w=n(87139),P=n(96148),T=n(99956),F=n(42703),Z=n(78460),E=n(11054),O=n(85421),I=n(15071),J=n(35929),N=n(67516),W=n(19077),L=n(82459),H=n(97569),R=n(56529),V=n(26201),$=n(76659),q=n(88787),G=n(85871),K=n(12730),U=n(12733),_=n(55206),B=n(99973);const Q=(0,n(14010).w)({d:"M11.2857,6.05714 L10.08571,4.85714 L7.85714,7.14786 L7.85714,1 L6.14286,1 L6.14286,7.14786 L3.91429,4.85714 L2.71429,6.05714 L7,10.42857 L11.2857,6.05714 Z M1,11.2857 L1,13 L13,13 L13,11.2857 L1,11.2857 Z",displayName:"DownloadIcon",viewBox:"0 0 14 14"});var X=n(92835),Y=n(58584),ee=n(69023),se=n(6175),ne=n(46291),ie=n(6583),te=n(70579);const ae=()=>{const[e,s]=(0,t.useState)([]),[n,ae]=(0,t.useState)([]),[le,re]=(0,t.useState)(null),[ce,oe]=(0,t.useState)(!1),[de,he]=(0,t.useState)(""),[ue,xe]=(0,t.useState)("all"),[je,pe]=(0,t.useState)(!1),[ve,me]=(0,t.useState)(!1),[ye,ge]=(0,t.useState)(!1),[be,ke]=(0,t.useState)(!1),[fe,Ce]=(0,t.useState)(!1),[ze,De]=(0,t.useState)([]),[Se,Ae]=(0,t.useState)({customerId:"",issueDate:(0,ee.GP)(new Date,"yyyy-MM-dd"),dueDate:(0,ee.GP)(new Date(Date.now()+12096e5),"yyyy-MM-dd"),currency:"CZK",note:"",paymentMethod:"bank_transfer"}),[Me,we]=(0,t.useState)({name:"",ico:"",dic:"",address:"",city:"",zip:"",country:"\u010cesk\xe1 republika",email:"",phone:"",bankAccount:"",iban:"",swift:""}),[Pe,Te]=(0,t.useState)(!1),[Fe,Ze]=(0,t.useState)(!1),{isOpen:Ee,onOpen:Oe,onClose:Ie}=(0,a.j)(),Je=(0,l.d)();(0,t.useEffect)(()=>{Ne(),We()},[]);const Ne=async()=>{try{oe(!0);const e=await ne.FH.get("/admin/invoices");s(e.data.invoices||[])}catch(e){Je({title:"Chyba p\u0159i na\u010d\xedt\xe1n\xed faktur",description:"Nepoda\u0159ilo se na\u010d\xedst seznam faktur",status:"error",duration:3e3})}finally{oe(!1)}},We=async()=>{try{const e=await ne.FH.get("/admin/invoices/customers");ae(e.data.customers||[])}catch(e){console.error("Error loading customers:",e)}},Le=(e,s)=>{we((0,i.A)((0,i.A)({},Me),{},{[e]:s}))},He=async e=>{try{const s=await ne.FH.post("/admin/invoices/".concat(e,"/generate-pdf"));Je({title:"PDF vygenerov\xe1no",description:"PDF faktura byla \xfasp\u011b\u0161n\u011b vygenerov\xe1na",status:"success",duration:3e3}),window.open(s.data.filePath,"_blank")}catch(i){var s,n;Je({title:"Chyba p\u0159i generov\xe1n\xed PDF",description:(null===i||void 0===i||null===(s=i.response)||void 0===s||null===(n=s.data)||void 0===n?void 0:n.message)||"Nepoda\u0159ilo se vygenerovat PDF",status:"error",duration:3e3})}},Re=async e=>{try{await ne.FH.post("/admin/invoices/".concat(e,"/send")),Je({title:"Faktura odesl\xe1na",description:"Faktura byla \xfasp\u011b\u0161n\u011b odesl\xe1na emailem",status:"success",duration:3e3})}catch(i){var s,n;Je({title:"Chyba p\u0159i odes\xedl\xe1n\xed faktury",description:(null===i||void 0===i||null===(s=i.response)||void 0===s||null===(n=s.data)||void 0===n?void 0:n.message)||"Nepoda\u0159ilo se odeslat fakturu",status:"error",duration:3e3})}},Ve=(e,s,n)=>{De(ze.map(t=>{if(t.id===e){const e=(0,i.A)((0,i.A)({},t),{},{[s]:n});return"quantity"!==s&&"unitPrice"!==s&&"vatRate"!==s||(e.totalPrice=e.quantity*e.unitPrice,e.vatAmount=e.totalPrice*(e.vatRate/100),e.totalWithVat=e.totalPrice+e.vatAmount),e}return t}))},$e=()=>{Ae({customerId:"",issueDate:(0,ee.GP)(new Date,"yyyy-MM-dd"),dueDate:(0,ee.GP)(new Date(Date.now()+12096e5),"yyyy-MM-dd"),currency:"CZK",note:"",paymentMethod:"bank_transfer"}),De([]),re(null)},qe=async e=>{try{const s=await ne.FH.get("/admin/invoices/".concat(e));De(s.data.invoice.items||[])}catch(s){console.error("Error loading invoice items:",s)}},Ge=e=>{switch(e){case"draft":default:return"gray";case"sent":return"blue";case"paid":return"green";case"overdue":return"red";case"cancelled":return"orange"}},Ke=e=>{switch(e){case"draft":return"N\xe1vrh";case"sent":return"Odesl\xe1na";case"paid":return"Zaplacena";case"overdue":return"Po splatnosti";case"cancelled":return"Zru\u0161ena";default:return e}},Ue=e.filter(e=>{const s=e.customerName.toLowerCase().includes(de.toLowerCase())||e.invoiceNumber.toLowerCase().includes(de.toLowerCase()),n="all"===ue||e.status===ue;return s&&n});return(0,te.jsx)(ie.A,{children:(0,te.jsx)(r.m,{maxW:"container.xl",py:8,children:(0,te.jsxs)(c.T,{spacing:6,align:"stretch",children:[(0,te.jsxs)(o.s,{justify:"space-between",align:"center",children:[(0,te.jsx)(d.D,{size:"lg",children:"Fakturace"}),(0,te.jsx)(h.$,{leftIcon:(0,te.jsx)(K.R,{}),colorScheme:"blue",onClick:()=>{$e(),pe(!0)},children:"Nov\xe1 faktura"})]}),(0,te.jsx)(u.Z,{children:(0,te.jsx)(x.b,{children:(0,te.jsxs)(j.r,{columns:{base:1,md:3},spacing:4,children:[(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"Vyhled\xe1v\xe1n\xed"}),(0,te.jsxs)(m.M,{children:[(0,te.jsx)(y.W,{children:(0,te.jsx)(U.W,{})}),(0,te.jsx)(g.p,{placeholder:"Hledat podle \u010d\xedsla faktury nebo odb\u011bratele...",value:de,onChange:e=>he(e.target.value)})]})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"Stav"}),(0,te.jsxs)(b.l,{value:ue,onChange:e=>xe(e.target.value),children:[(0,te.jsx)("option",{value:"all",children:"V\u0161echny stavy"}),(0,te.jsx)("option",{value:"draft",children:"N\xe1vrh"}),(0,te.jsx)("option",{value:"sent",children:"Odesl\xe1na"}),(0,te.jsx)("option",{value:"paid",children:"Zaplacena"}),(0,te.jsx)("option",{value:"overdue",children:"Po splatnosti"}),(0,te.jsx)("option",{value:"cancelled",children:"Zru\u0161ena"})]})]}),(0,te.jsx)(k.a,{})]})})}),(0,te.jsx)(u.Z,{overflow:"hidden",children:(0,te.jsx)(k.a,{overflowX:"auto",children:(0,te.jsxs)(f.X,{variant:"simple",children:[(0,te.jsx)(C.d,{children:(0,te.jsxs)(z.Tr,{children:[(0,te.jsx)(D.Th,{children:"\u010c\xedslo faktury"}),(0,te.jsx)(D.Th,{children:"Datum vystaven\xed"}),(0,te.jsx)(D.Th,{children:"Datum splatnosti"}),(0,te.jsx)(D.Th,{children:"Odb\u011bratel"}),(0,te.jsx)(D.Th,{children:"\u010c\xe1stka"}),(0,te.jsx)(D.Th,{children:"Stav"}),(0,te.jsx)(D.Th,{children:"Akce"})]})}),(0,te.jsx)(S.N,{children:Ue.map(e=>(0,te.jsxs)(z.Tr,{children:[(0,te.jsx)(A.Td,{fontWeight:"medium",children:e.invoiceNumber}),(0,te.jsx)(A.Td,{children:(0,ee.GP)(new Date(e.issueDate),"dd.MM.yyyy",{locale:se.cs})}),(0,te.jsx)(A.Td,{children:(0,ee.GP)(new Date(e.dueDate),"dd.MM.yyyy",{locale:se.cs})}),(0,te.jsx)(A.Td,{children:(0,te.jsxs)(c.T,{align:"start",spacing:0,children:[(0,te.jsx)(M.E,{fontWeight:"medium",children:e.customerName}),(0,te.jsx)(M.E,{fontSize:"sm",color:"gray.600",children:e.customerICO})]})}),(0,te.jsxs)(A.Td,{fontWeight:"medium",children:[e.totalAmountVAT.toFixed(2)," ",e.currency]}),(0,te.jsx)(A.Td,{children:(0,te.jsx)(w.E,{colorScheme:Ge(e.status),children:Ke(e.status)})}),(0,te.jsx)(A.Td,{children:(0,te.jsxs)(P.z,{spacing:2,children:[(0,te.jsx)(T.m,{label:"Zobrazit",children:(0,te.jsx)(F.K,{icon:(0,te.jsx)(_.t,{}),variant:"ghost",size:"sm",onClick:()=>{re(e),qe(e.id),ge(!0)},"aria-label":"Zobrazit fakturu"})}),(0,te.jsx)(T.m,{label:"Upravit",children:(0,te.jsx)(F.K,{icon:(0,te.jsx)(B.q,{}),variant:"ghost",size:"sm",onClick:()=>(e=>{re(e),Ae({customerId:e.customerICO||"",issueDate:e.issueDate,dueDate:e.dueDate,currency:e.currency,note:e.note||"",paymentMethod:e.paymentMethod||"bank_transfer"}),qe(e.id),me(!0)})(e),"aria-label":"Upravit fakturu"})}),(0,te.jsx)(T.m,{label:"Generovat PDF",children:(0,te.jsx)(F.K,{icon:(0,te.jsx)(Q,{}),variant:"ghost",size:"sm",onClick:()=>He(e.id),"aria-label":"Generovat PDF faktury"})}),(0,te.jsx)(T.m,{label:"Odeslat emailem",children:(0,te.jsx)(F.K,{icon:(0,te.jsx)(X.a,{}),variant:"ghost",size:"sm",onClick:()=>Re(e.id),"aria-label":"Odeslat fakturu emailem"})}),(0,te.jsx)(T.m,{label:"Smazat",children:(0,te.jsx)(F.K,{icon:(0,te.jsx)(Y.d,{}),variant:"ghost",size:"sm",colorScheme:"red",onClick:()=>{re(e),ke(!0)},"aria-label":"Smazat fakturu"})})]})})]},e.id))})]})})}),(0,te.jsxs)(Z.aF,{isOpen:je||ve,onClose:()=>{pe(!1),me(!1),$e()},size:"4xl",children:[(0,te.jsx)(E.m,{}),(0,te.jsxs)(O.$,{children:[(0,te.jsx)(I.r,{children:je?"Vytvo\u0159it fakturu":"Upravit fakturu"}),(0,te.jsx)(J.s,{}),(0,te.jsx)(N.c,{children:(0,te.jsxs)(c.T,{spacing:4,align:"stretch",children:[(0,te.jsxs)(j.r,{columns:{base:1,md:3},spacing:4,children:[(0,te.jsxs)(p.MJ,{isRequired:!0,children:[(0,te.jsx)(v.l,{children:"Odb\u011bratel"}),(0,te.jsx)(b.l,{value:Se.customerId,onChange:e=>Ae((0,i.A)((0,i.A)({},Se),{},{customerId:e.target.value})),placeholder:"Vyberte odb\u011bratele",children:n.map(e=>(0,te.jsxs)("option",{value:e.id,children:[e.name," (",e.ico,")"]},e.id))})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"M\u011bna"}),(0,te.jsxs)(b.l,{value:Se.currency,onChange:e=>Ae((0,i.A)((0,i.A)({},Se),{},{currency:e.target.value})),children:[(0,te.jsx)("option",{value:"CZK",children:"CZK"}),(0,te.jsx)("option",{value:"EUR",children:"EUR"}),(0,te.jsx)("option",{value:"USD",children:"USD"})]})]}),(0,te.jsx)(p.MJ,{display:"flex",alignItems:"flex-end",children:(0,te.jsx)(h.$,{leftIcon:(0,te.jsx)(K.R,{}),colorScheme:"green",onClick:()=>Ce(!0),width:"full",children:"P\u0159idat odb\u011bratele"})})]}),(0,te.jsxs)(j.r,{columns:{base:1,md:2},spacing:4,children:[(0,te.jsxs)(p.MJ,{isRequired:!0,children:[(0,te.jsx)(v.l,{children:"Datum vystaven\xed"}),(0,te.jsx)(g.p,{type:"date",value:Se.issueDate,onChange:e=>Ae((0,i.A)((0,i.A)({},Se),{},{issueDate:e.target.value}))})]}),(0,te.jsxs)(p.MJ,{isRequired:!0,children:[(0,te.jsx)(v.l,{children:"Datum splatnosti"}),(0,te.jsx)(g.p,{type:"date",value:Se.dueDate,onChange:e=>Ae((0,i.A)((0,i.A)({},Se),{},{dueDate:e.target.value}))})]})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"Zp\u016fsob platby"}),(0,te.jsxs)(b.l,{value:Se.paymentMethod,onChange:e=>Ae((0,i.A)((0,i.A)({},Se),{},{paymentMethod:e.target.value})),children:[(0,te.jsx)("option",{value:"bank_transfer",children:"Bankovn\xed p\u0159evod"}),(0,te.jsx)("option",{value:"cash",children:"Hotov\u011b"}),(0,te.jsx)("option",{value:"card",children:"Kartou"}),(0,te.jsx)("option",{value:"other",children:"Jin\xfd"})]})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"Pozn\xe1mka"}),(0,te.jsx)(W.T,{value:Se.note,onChange:e=>Ae((0,i.A)((0,i.A)({},Se),{},{note:e.target.value})),placeholder:"Pozn\xe1mka k faktu\u0159e...",rows:3})]}),(0,te.jsx)(L.c,{}),(0,te.jsxs)(o.s,{justify:"space-between",align:"center",children:[(0,te.jsx)(d.D,{size:"md",children:"Polo\u017eky faktury"}),(0,te.jsx)(h.$,{leftIcon:(0,te.jsx)(K.R,{}),colorScheme:"blue",size:"sm",onClick:()=>{const e={id:Date.now().toString(),description:"",quantity:1,unitPrice:0,vatRate:21,totalPrice:0,vatAmount:0,totalWithVat:0};De([...ze,e])},children:"P\u0159idat polo\u017eku"})]}),(0,te.jsx)(c.T,{spacing:3,align:"stretch",children:ze.map((e,s)=>(0,te.jsx)(u.Z,{size:"sm",children:(0,te.jsx)(x.b,{children:(0,te.jsxs)(j.r,{columns:{base:1,md:6},spacing:3,alignItems:"end",children:[(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{fontSize:"sm",children:"Popis"}),(0,te.jsx)(g.p,{value:e.description,onChange:s=>Ve(e.id,"description",s.target.value),placeholder:"Popis polo\u017eky...",size:"sm"})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{fontSize:"sm",children:"Mno\u017estv\xed"}),(0,te.jsxs)(H.Q7,{value:e.quantity,onChange:s=>Ve(e.id,"quantity",parseFloat(s)||0),min:0,step:1,size:"sm",children:[(0,te.jsx)(H.OO,{}),(0,te.jsxs)(H.lw,{children:[(0,te.jsx)(H.Q0,{}),(0,te.jsx)(H.Sh,{})]})]})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{fontSize:"sm",children:"Cena/jedn."}),(0,te.jsxs)(H.Q7,{value:e.unitPrice,onChange:s=>Ve(e.id,"unitPrice",parseFloat(s)||0),min:0,step:.01,size:"sm",children:[(0,te.jsx)(H.OO,{}),(0,te.jsxs)(H.lw,{children:[(0,te.jsx)(H.Q0,{}),(0,te.jsx)(H.Sh,{})]})]})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{fontSize:"sm",children:"DPH %"}),(0,te.jsxs)(b.l,{value:e.vatRate,onChange:s=>Ve(e.id,"vatRate",parseFloat(s.target.value)),size:"sm",children:[(0,te.jsx)("option",{value:"0",children:"0%"}),(0,te.jsx)("option",{value:"21",children:"21%"}),(0,te.jsx)("option",{value:"15",children:"15%"}),(0,te.jsx)("option",{value:"10",children:"10%"})]})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{fontSize:"sm",children:"Celkem s DPH"}),(0,te.jsx)(g.p,{value:e.totalWithVat.toFixed(2),isReadOnly:!0,size:"sm",textAlign:"right"})]}),(0,te.jsx)(F.K,{icon:(0,te.jsx)(Y.d,{}),variant:"ghost",size:"sm",colorScheme:"red",onClick:()=>{return s=e.id,void De(e=>e.filter(e=>e.id!==s));var s},"aria-label":"Smazat polo\u017eku faktury"})]})})},e.id))}),ze.length>0&&(0,te.jsx)(u.Z,{children:(0,te.jsx)(x.b,{children:(0,te.jsxs)(o.s,{justify:"space-between",align:"center",children:[(0,te.jsx)(M.E,{fontWeight:"bold",children:"Celkov\xe1 \u010d\xe1stka:"}),(0,te.jsxs)(M.E,{fontSize:"xl",fontWeight:"bold",children:[ze.reduce((e,s)=>e+s.totalWithVat,0).toFixed(2)," ",Se.currency]})]})})})]})}),(0,te.jsxs)(R.j,{children:[(0,te.jsx)(h.$,{variant:"outline",mr:3,onClick:()=>{pe(!1),me(!1),$e()},children:"Zru\u0161it"}),(0,te.jsx)(h.$,{colorScheme:"blue",onClick:je?async()=>{if(Se.customerId)if(0!==ze.length)try{await ne.FH.post("/admin/invoices",(0,i.A)((0,i.A)({},Se),{},{items:ze})),Je({title:"Faktura vytvo\u0159ena",description:"Faktura byla \xfasp\u011b\u0161n\u011b vytvo\u0159ena",status:"success",duration:3e3}),pe(!1),$e(),Ne()}catch(n){var e,s;Je({title:"Chyba p\u0159i vytv\xe1\u0159en\xed faktury",description:(null===n||void 0===n||null===(e=n.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.message)||"Nepoda\u0159ilo se vytvo\u0159it fakturu",status:"error",duration:3e3})}else Je({title:"Chyba",description:"P\u0159idejte alespo\u0148 jednu polo\u017eku",status:"error",duration:3e3});else Je({title:"Chyba",description:"Vyberte odb\u011bratele",status:"error",duration:3e3})}:async()=>{if(le)try{await ne.FH.put("/admin/invoices/".concat(le.id),(0,i.A)((0,i.A)({},Se),{},{items:ze})),Je({title:"Faktura aktualizov\xe1na",description:"Faktura byla \xfasp\u011b\u0161n\u011b aktualizov\xe1na",status:"success",duration:3e3}),me(!1),$e(),Ne()}catch(n){var e,s;Je({title:"Chyba p\u0159i aktualizaci faktury",description:(null===n||void 0===n||null===(e=n.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.message)||"Nepoda\u0159ilo se aktualizovat fakturu",status:"error",duration:3e3})}},isLoading:ce,children:je?"Vytvo\u0159it":"Ulo\u017eit"})]})]})]}),(0,te.jsxs)(Z.aF,{isOpen:ye,onClose:()=>ge(!1),size:"4xl",children:[(0,te.jsx)(E.m,{}),(0,te.jsxs)(O.$,{children:[(0,te.jsxs)(I.r,{children:["Faktura \u010d. ",null===le||void 0===le?void 0:le.invoiceNumber]}),(0,te.jsx)(J.s,{}),(0,te.jsx)(N.c,{children:le&&(0,te.jsxs)(c.T,{spacing:4,align:"stretch",children:[(0,te.jsxs)(j.r,{columns:{base:1,md:2},spacing:4,children:[(0,te.jsxs)(u.Z,{children:[(0,te.jsx)(V.a,{children:(0,te.jsx)(d.D,{size:"sm",children:"Dodavatel"})}),(0,te.jsx)(x.b,{children:(0,te.jsxs)(c.T,{align:"start",spacing:1,children:[(0,te.jsx)(M.E,{fontWeight:"bold",children:le.supplierName}),(0,te.jsxs)(M.E,{children:["I\u010cO: ",le.supplierICO]}),(0,te.jsx)(M.E,{children:le.supplierAddress}),(0,te.jsxs)(M.E,{children:[le.supplierZIP," ",le.supplierCity]})]})})]}),(0,te.jsxs)(u.Z,{children:[(0,te.jsx)(V.a,{children:(0,te.jsx)(d.D,{size:"sm",children:"Odb\u011bratel"})}),(0,te.jsx)(x.b,{children:(0,te.jsxs)(c.T,{align:"start",spacing:1,children:[(0,te.jsx)(M.E,{fontWeight:"bold",children:le.customerName}),(0,te.jsxs)(M.E,{children:["I\u010cO: ",le.customerICO]}),(0,te.jsx)(M.E,{children:le.customerAddress}),(0,te.jsxs)(M.E,{children:[le.customerZIP," ",le.customerCity]})]})})]})]}),(0,te.jsxs)(j.r,{columns:{base:1,md:3},spacing:4,children:[(0,te.jsx)(u.Z,{children:(0,te.jsx)(x.b,{children:(0,te.jsxs)(c.T,{align:"start",spacing:1,children:[(0,te.jsx)(M.E,{fontSize:"sm",color:"gray.600",children:"\u010c\xedslo faktury"}),(0,te.jsx)(M.E,{fontWeight:"bold",children:le.invoiceNumber})]})})}),(0,te.jsx)(u.Z,{children:(0,te.jsx)(x.b,{children:(0,te.jsxs)(c.T,{align:"start",spacing:1,children:[(0,te.jsx)(M.E,{fontSize:"sm",color:"gray.600",children:"Datum vystaven\xed"}),(0,te.jsx)(M.E,{fontWeight:"bold",children:(0,ee.GP)(new Date(le.issueDate),"dd.MM.yyyy",{locale:se.cs})})]})})}),(0,te.jsx)(u.Z,{children:(0,te.jsx)(x.b,{children:(0,te.jsxs)(c.T,{align:"start",spacing:1,children:[(0,te.jsx)(M.E,{fontSize:"sm",color:"gray.600",children:"Datum splatnosti"}),(0,te.jsx)(M.E,{fontWeight:"bold",children:(0,ee.GP)(new Date(le.dueDate),"dd.MM.yyyy",{locale:se.cs})})]})})})]}),(0,te.jsxs)(u.Z,{children:[(0,te.jsx)(V.a,{children:(0,te.jsx)(d.D,{size:"sm",children:"Polo\u017eky faktury"})}),(0,te.jsx)(x.b,{children:(0,te.jsxs)(f.X,{variant:"simple",size:"sm",children:[(0,te.jsx)(C.d,{children:(0,te.jsxs)(z.Tr,{children:[(0,te.jsx)(D.Th,{children:"Popis"}),(0,te.jsx)(D.Th,{textAlign:"right",children:"Mno\u017estv\xed"}),(0,te.jsx)(D.Th,{textAlign:"right",children:"Cena/jedn."}),(0,te.jsx)(D.Th,{textAlign:"right",children:"DPH %"}),(0,te.jsx)(D.Th,{textAlign:"right",children:"Celkem s DPH"})]})}),(0,te.jsx)(S.N,{children:ze.map(e=>(0,te.jsxs)(z.Tr,{children:[(0,te.jsx)(A.Td,{children:e.description}),(0,te.jsx)(A.Td,{textAlign:"right",children:e.quantity}),(0,te.jsxs)(A.Td,{textAlign:"right",children:[e.unitPrice.toFixed(2)," ",le.currency]}),(0,te.jsxs)(A.Td,{textAlign:"right",children:[e.vatRate,"%"]}),(0,te.jsxs)(A.Td,{textAlign:"right",children:[e.totalWithVat.toFixed(2)," ",le.currency]})]},e.id))})]})})]}),(0,te.jsx)(u.Z,{children:(0,te.jsx)(x.b,{children:(0,te.jsxs)(o.s,{justify:"space-between",align:"center",children:[(0,te.jsxs)(c.T,{align:"start",spacing:1,children:[(0,te.jsx)(M.E,{fontWeight:"bold",children:"Celkem bez DPH:"}),(0,te.jsx)(M.E,{fontWeight:"bold",children:"DPH:"}),(0,te.jsx)(M.E,{fontSize:"lg",fontWeight:"bold",children:"Celkem k \xfahrad\u011b:"})]}),(0,te.jsxs)(c.T,{align:"end",spacing:1,children:[(0,te.jsxs)(M.E,{children:[(le.totalAmountWithoutVAT||0).toFixed(2)," ",le.currency]}),(0,te.jsxs)(M.E,{children:[(le.totalVAT||0).toFixed(2)," ",le.currency]}),(0,te.jsxs)(M.E,{fontSize:"lg",fontWeight:"bold",children:[le.totalAmountVAT.toFixed(2)," ",le.currency]})]})]})})}),le.note&&(0,te.jsxs)(u.Z,{children:[(0,te.jsx)(V.a,{children:(0,te.jsx)(d.D,{size:"sm",children:"Pozn\xe1mka"})}),(0,te.jsx)(x.b,{children:(0,te.jsx)(M.E,{children:le.note})})]})]})}),(0,te.jsxs)(R.j,{children:[(0,te.jsx)(h.$,{variant:"outline",mr:3,onClick:()=>ge(!1),children:"Zav\u0159\xedt"}),le&&(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(h.$,{leftIcon:(0,te.jsx)(Q,{}),colorScheme:"blue",mr:3,onClick:()=>He(le.id),children:"Generovat PDF"}),(0,te.jsx)(h.$,{leftIcon:(0,te.jsx)(X.a,{}),colorScheme:"green",onClick:()=>Re(le.id),children:"Odeslat emailem"})]})]})]})]}),(0,te.jsxs)(Z.aF,{isOpen:fe,onClose:()=>Ce(!1),size:"2xl",children:[(0,te.jsx)(E.m,{}),(0,te.jsxs)(O.$,{children:[(0,te.jsx)(I.r,{children:"P\u0159idat nov\xe9ho odb\u011bratele"}),(0,te.jsx)(J.s,{}),(0,te.jsx)(N.c,{children:(0,te.jsxs)(c.T,{spacing:4,align:"stretch",children:[(0,te.jsxs)(j.r,{columns:{base:1,md:2},spacing:4,children:[(0,te.jsxs)(p.MJ,{isRequired:!0,children:[(0,te.jsx)(v.l,{children:"N\xe1zev firmy"}),(0,te.jsx)(g.p,{value:Me.name,onChange:e=>Le("name",e.target.value),placeholder:"N\xe1zev firmy"})]}),(0,te.jsxs)(p.MJ,{isRequired:!0,children:[(0,te.jsx)(v.l,{children:"I\u010cO"}),(0,te.jsxs)(m.M,{children:[(0,te.jsx)(g.p,{value:Me.ico,onChange:e=>{const s=e.target.value.replace(/\D/g,"").slice(0,8);Le("ico",s),8===s.length&&(async e=>{if(e&&8===e.length)try{Ze(!0);const s=await fetch("https://ares.gov.cz/ekonomicke-subjekty-v-be/rest/ekonomicke-subjekty/".concat(e));if(!s.ok)throw new Error("Company not found");const n=await s.json();n&&(we(e=>(0,i.A)((0,i.A)({},e),{},{name:n.obchodniJmeno||e.name,dic:n.dic||e.dic,address:n.sidlo&&n.sidlo.textovaAdresa?n.sidlo.textovaAdresa:e.address,city:n.sidlo&&n.sidlo.nazevObce?n.sidlo.nazevObce:e.city,zip:n.sidlo&&n.sidlo.psc?n.sidlo.psc:e.zip,country:n.sidlo&&n.sidlo.nazevStatu?n.sidlo.nazevStatu:e.country})),Je({title:"\xdadaje nalezeny",description:"Spole\u010dnost ".concat(n.obchodniJmeno," byla automaticky vypln\u011bna"),status:"success",duration:3e3}))}catch(s){console.error("Error searching company:",s),Je({title:"Spole\u010dnost nenalezena",description:"Pro zadan\xe9 I\u010cO se nepoda\u0159ilo naj\xedt \xfadaje. Zkontrolujte I\u010cO nebo vypl\u0148te \xfadaje ru\u010dn\u011b.",status:"warning",duration:3e3})}finally{Ze(!1)}})(s)},placeholder:"12345678",maxLength:8}),Fe&&(0,te.jsx)(y.t,{children:(0,te.jsx)($.y,{size:"sm"})})]})]})]}),(0,te.jsxs)(j.r,{columns:{base:1,md:2},spacing:4,children:[(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"DI\u010c"}),(0,te.jsx)(g.p,{value:Me.dic,onChange:e=>Le("dic",e.target.value),placeholder:"CZ1234567890"})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"St\xe1t"}),(0,te.jsx)(g.p,{value:Me.country,onChange:e=>Le("country",e.target.value),placeholder:"\u010cesk\xe1 republika"})]})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"Adresa"}),(0,te.jsx)(g.p,{value:Me.address,onChange:e=>Le("address",e.target.value),placeholder:"Adresa"})]}),(0,te.jsxs)(j.r,{columns:{base:1,md:2},spacing:4,children:[(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"M\u011bsto"}),(0,te.jsx)(g.p,{value:Me.city,onChange:e=>Le("city",e.target.value),placeholder:"M\u011bsto"})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"PS\u010c"}),(0,te.jsx)(g.p,{value:Me.zip,onChange:e=>Le("zip",e.target.value),placeholder:"123 45"})]})]}),(0,te.jsxs)(j.r,{columns:{base:1,md:2},spacing:4,children:[(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"Email"}),(0,te.jsx)(g.p,{type:"email",value:Me.email,onChange:e=>Le("email",e.target.value),placeholder:"email@firma.cz"})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"Telefon"}),(0,te.jsx)(g.p,{value:Me.phone,onChange:e=>Le("phone",e.target.value),placeholder:"+420 123 456 789"})]})]}),(0,te.jsxs)(j.r,{columns:{base:1,md:3},spacing:4,children:[(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"\u010c\xedslo \xfa\u010dtu"}),(0,te.jsx)(g.p,{value:Me.bankAccount,onChange:e=>Le("bankAccount",e.target.value),placeholder:"123456789/0300"})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"IBAN"}),(0,te.jsx)(g.p,{value:Me.iban,onChange:e=>Le("iban",e.target.value),placeholder:"CZ12345678901234567890123456"})]}),(0,te.jsxs)(p.MJ,{children:[(0,te.jsx)(v.l,{children:"SWIFT/BIC"}),(0,te.jsx)(g.p,{value:Me.swift,onChange:e=>Le("swift",e.target.value),placeholder:"GIBACZPX"})]})]})]})}),(0,te.jsxs)(R.j,{children:[(0,te.jsx)(h.$,{variant:"outline",mr:3,onClick:()=>Ce(!1),children:"Zru\u0161it"}),(0,te.jsx)(h.$,{colorScheme:"green",onClick:async()=>{if(Me.name&&Me.ico)try{var e;Te(!0);const s=await ne.FH.post("/admin/invoices/customers",Me);Je({title:"Odb\u011bratel vytvo\u0159en",description:"Odb\u011bratel ".concat(Me.name," byl \xfasp\u011b\u0161n\u011b vytvo\u0159en"),status:"success",duration:3e3}),we({name:"",ico:"",dic:"",address:"",city:"",zip:"",country:"\u010cesk\xe1 republika",email:"",phone:"",bankAccount:"",iban:"",swift:""}),Ce(!1),await We(),null!==(e=s.data.customer)&&void 0!==e&&e.id&&Ae((0,i.A)((0,i.A)({},Se),{},{customerId:s.data.customer.id}))}catch(t){var s,n;Je({title:"Chyba p\u0159i vytv\xe1\u0159en\xed odb\u011bratele",description:(null===t||void 0===t||null===(s=t.response)||void 0===s||null===(n=s.data)||void 0===n?void 0:n.message)||"Nepoda\u0159ilo se vytvo\u0159it odb\u011bratele",status:"error",duration:3e3})}finally{Te(!1)}else Je({title:"Chyba",description:"Vypl\u0148te n\xe1zev a I\u010cO odb\u011bratele",status:"error",duration:3e3})},isLoading:Pe,children:"Vytvo\u0159it odb\u011bratele"})]})]})]}),(0,te.jsxs)(Z.aF,{isOpen:Ee,onClose:Ie,children:[(0,te.jsx)(E.m,{}),(0,te.jsxs)(O.$,{children:[(0,te.jsx)(I.r,{children:"Smazat fakturu"}),(0,te.jsx)(J.s,{}),(0,te.jsx)(N.c,{children:(0,te.jsxs)(q.F,{status:"warning",children:[(0,te.jsx)(G._,{}),"Opravdu chcete smazat fakturu \u010d. ",null===le||void 0===le?void 0:le.invoiceNumber,"? Tuto akci nelze vr\xe1tit zp\u011bt."]})}),(0,te.jsxs)(R.j,{children:[(0,te.jsx)(h.$,{variant:"outline",mr:3,onClick:Ie,children:"Zru\u0161it"}),(0,te.jsx)(h.$,{colorScheme:"red",onClick:()=>le&&(async e=>{try{await ne.FH.delete("/admin/invoices/".concat(e)),Je({title:"Faktura smaz\xe1na",description:"Faktura byla \xfasp\u011b\u0161n\u011b smaz\xe1na",status:"success",duration:3e3}),Ie(),Ne()}catch(i){var s,n;Je({title:"Chyba p\u0159i maz\xe1n\xed faktury",description:(null===i||void 0===i||null===(s=i.response)||void 0===s||null===(n=s.data)||void 0===n?void 0:n.message)||"Nepoda\u0159ilo se smazat fakturu",status:"error",duration:3e3})}})(le.id),children:"Smazat"})]})]})]})]})})})}}}]);
//# sourceMappingURL=266.e18a46b8.chunk.js.map