1import{g as ya,j as a,F as ha,G as ga,r as u,t as b,a as T,K as A,N as J,B as m,E as Ha,z as Sa,D as V,c as O,d as B,e as _,f as y,I as w,m as U,P as ea,T as wa}from"./index-DB2ytUq7.js";import{A as Ea}from"./AdminLayout-BqlAVscQ.js";import{T as Ta,a as Ia,b as G,c as $}from"./tabs-BsJGkeUP.js";import{T as K,a as Z,b as D,c as o,d as W,e as n}from"./table-C9sZlgbQ.js";import{S as ta,a as sa,b as la,c as ca,d as E}from"./select-6Szl-XTm.js";import{T as Aa}from"./textarea-0uasqO59.js";import{M}from"./MiniStat-BtW1Np5B.js";import{D as oa}from"./DateRangeSelector-Cj0HQh87.js";import{S as ua}from"./SearchInput-BAe_-u5W.js";import{E as X}from"./EmptyState-DhTuhvBM.js";import{S as q}from"./EboliSkeleton-_53SODGI.js";import{B as aa}from"./book-open-DREZI19c.js";import{C as z}from"./chart-no-axes-column-CPoLfMeH.js";import{D as Da}from"./download-B4ZfWx_h.js";import{F as ka}from"./file-check-BKKRF9uK.js";import"./useAuth-Hx975xMR.js";import"./index-B1zjMINU.js";import"./index-5O81lHuZ.js";import"./index-CyMelAOu.js";import"./index-BdQq_4o_.js";import"./index-BUwK5LrS.js";import"./chevron-up-CthelI4b.js";import"./trending-down-Dr25XCER.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const xa=ya("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]),va={generada:{label:"Generada",cls:"bg-amber-100 text-amber-800"},enviada:{label:"Enviada",cls:"bg-blue-100 text-blue-800"},cobrada:{label:"Cobrada",cls:"bg-green-100 text-green-800"},anulada:{label:"Anulada",cls:"bg-red-100 text-red-800"},abonada:{label:"Abonada",cls:"bg-gray-100 text-gray-600"}},Na={factura:{label:"Factura",cls:"bg-slate-100 text-slate-700"},abono:{label:"Abono",cls:"bg-rose-100 text-rose-700"},proforma:{label:"Pro forma",cls:"bg-purple-100 text-purple-700"},estimacion:{label:"Estimación",cls:"bg-orange-100 text-orange-700"},rectificativa:{label:"Rectificativa",cls:"bg-pink-100 text-pink-700"}},Ma={pending:{label:"Pendiente",cls:"bg-amber-100 text-amber-700"},sent:{label:"Enviada",cls:"bg-blue-100 text-blue-700"},accepted:{label:"Aceptada",cls:"bg-green-100 text-green-700"},rejected:{label:"Rechazada",cls:"bg-red-100 text-red-700"}},za={invoice:{label:"Factura",cls:"bg-blue-100 text-blue-700"},payment:{label:"Cobro",cls:"bg-green-100 text-green-700"},credit_note:{label:"Abono",cls:"bg-rose-100 text-rose-700"},expense:{label:"Gasto",cls:"bg-orange-100 text-orange-700"},adjustment:{label:"Ajuste",cls:"bg-gray-100 text-gray-700"}};function Q({map:c,value:i}){if(!i)return a.jsx("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:63",className:"text-xs text-muted-foreground",children:"â"});const r=c[i]??{label:i,cls:"bg-gray-100 text-gray-700"};return a.jsx("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:66",className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${r.cls}`,children:r.label})}function R(c){const i=typeof c=="string"?Number(c):c;return new Intl.NumberFormat("es-ES",{style:"currency",currency:"EUR"}).format(i)}function S(c){return new Intl.NumberFormat("es-ES",{style:"currency",currency:"EUR"}).format(c/100)}function pa(c){return c?(c instanceof Date?c:new Date(c)).toLocaleDateString("es-ES"):"â"}function ma(){return new Date().toISOString().split("T")[0]}function Y(){const c=new Date,i=new Date(c.getFullYear(),c.getMonth(),1).toISOString().split("T")[0],r=new Date(c.getFullYear(),c.getMonth()+1,0).toISOString().split("T")[0];return{from:i,to:r}}function fa({invoiceId:c,onClose:i}){const{data:r}=b.hotelInvoices.getInvoiceHtml.useQuery({invoiceId:c},{enabled:!0});return a.jsx(V,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:105",open:!0,onOpenChange:d=>!d&&i(),children:a.jsxs(O,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:106",className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[a.jsx(B,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:107",children:a.jsx(_,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:108",children:r?.invoiceNumber??"Factura"})}),a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:110",className:"min-h-96",children:r?a.jsx("iframe",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:112",title:"Factura",srcDoc:r.html,className:"w-full h-[70vh] rounded border bg-white"}):a.jsx(q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:118",height:400,radius:8})}),a.jsx(U,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:121",children:a.jsxs(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:122",variant:"outline",disabled:!r,onClick:()=>
6{if(!r)return;const d=window.open("","_blank","width=900,height=1000");d&&(d.document.open(),d.document.write(r.html),d.document.close())},children:[a.jsx(ha,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:134",className:"mr-2 h-4 w-4"})," Abrir en ventana"]})})]})})}function Ra({invoice:c,onClose:i}){const[r,d]=u.useState(""),j=b.useUtils(),H=b.hotelInvoices.createCreditNote.useMutation({onSuccess:x=>{T.success(`Abono creado: ${x.invoiceNumber}`),j.hotelInvoices.listAll.invalidate(),i()},onError:x=>T.error("Error al crear abono",{description:x.message})});return a.jsx(V,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:159",open:!0,onOpenChange:x=>!x&&i(),children:a.jsxs(O,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:160",children:[a.jsx(B,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:161",children:a.jsxs(_,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:162",children:["Crear abono â ",c.invoiceNumber]})}),a.jsx("p",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:164",className:"text-sm text-muted-foreground",children:"Se generará una factura rectificativa por el importe negado. La original quedará marcada como «abonada»."}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:167",className:"mt-2 space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:168",children:"Motivo del abono"}),a.jsx(Aa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:169",rows:3,placeholder:"Explica el motivo de la rectificaciónâ¦",value:r,onChange:x=>d(x.target.value)})]}),a.jsxs(U,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:176",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:177",variant:"outline",onClick:i,children:"Cancelar"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:178",disabled:r.trim().length<3||H.isPending,onClick:()=>H.mutate({invoiceId:c.id,reason:r.trim()}),children:H.isPending?"Creandoâ¦":"Crear abono"})]})]})})}function La(){const[c,i]=u.useState(1),[r,d]=u.useState("all"),[j,H]=u.useState(Y().from),[x,F]=u.useState(Y().to),[g,f]=u.useState(""),[k,v]=u.useState(null),[P,C]=u.useState(null),[I,p]=u.useState(ma()),[e,l]=u.useState(!1),N=b.useUtils(),t=["factura","abono","rectificativa"],{data:h,isLoading:na}=b.hotelInvoices.listAll.useQuery({page:c,pageSize:50,status:null,invoiceTypes:r==="all"?[...t]:void 0,invoiceType:r!=="all"?r:void 0,fromDate:j||null,toDate:x||null,search:g.trim()||null}),Fa=b.hotelInvoices.sendEmail.useMutation({onSuccess:s=>T.success(`Email enviado a ${s.recipient}`),onError:s=>T.error("Error al enviar email",{description:s.message})}),ia=b.hotelInvoices.bulkInvoice.useMutation({onSuccess:s=>{T.success(`Generadas ${s.generated.length} facturas. Omitidas: ${s.skipped.length}.`),N.hotelInvoices.listAll.invalidate(),l(!1)},onError:s=>T.error("Error",{description:s.message})}),ba=b.hotelInvoices.exportCsv.useQuery({invoiceTypes:[...t],fromDate:j||null,toDate:x||null},{enabled:!1});async function Ca(){const s=await ba.refetch();if(s.data){const L=new Blob([s.data],{type:"text/csv;charset=utf-8;"}),Pa=URL.createObjectURL(L),da=document.createElement("a");da.href=Pa,da.download="facturas.csv",da.click(),URL.revokeObjectURL(Pa)}}const ra=h?Math.max(1,Math.ceil(h.total/h.pageSize)):1;return a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:253",className:"space-y-4",children:[a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:255",children:a.jsx(J,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:256",className:"pt-4",children:a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:257",className:"flex flex-wrap items-end gap-3",children:[a.jsx(oa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:258",from:j,to:x,onChange:(s,L)=>{H(s),F(L),i(1)}}),a.jsxs(ta,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:263",value:r,onValueChange:s=>{d(s),i(1)},children:[a.jsx(sa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:264",className:"w-40",children:a.jsx(la,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:265",placeholder:"Tipo"})}),a.jsxs(ca,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:267",children:[a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:268",value:"all",children:"Todos los fiscales"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:269",value:"factura",children:"Factura"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:270",value:"abono",children:"Abono"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:271",value:"rectificativa",children:"Rectificativa"})]})]}),a.jsx(ua,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:274",value:g,onChange:s=>{f(s),i(1)},placeholder:"Cliente o nº facturaâ¦",className:"w-52"}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:280",className:"ml-auto flex gap-2",children:[a.jsxs(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:281",variant:"outline",size:"sm",onClick:Ca,children:[a.jsx(Da,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:282",className:"mr-1.5 h-4 w-4"})," Exportar CSV"]}),a.jsxs(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:284",size:"sm",onClick:()=>l(!0),children:[a.jsx(ka,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:285",className:"mr-1.5 h-4 w-4"})," Facturación masiva"]})]})]})})}),a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:293",className:"overflow-hidden p-0",children:na?a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:295",className:"space-y-2 p-4",children:Array.from({length:8}).map((s,L)=>a.jsx(q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:296",height:44,radiu
6s:6},L))}):!h||h.rows.length===0?a.jsx(X,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:299",icon:xa,title:"Sin facturas",description:"No se encontraron facturas con los filtros actuales.",className:"m-4"}):a.jsxs(a.Fragment,{children:[a.jsxs(K,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:302",children:[a.jsx(Z,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:303",children:a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:304",children:[a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:305",children:"Nº Factura"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:306",children:"Fecha"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:307",children:"Cliente"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:308",children:"NIF"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:309",className:"text-right",children:"Subtotal"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:310",className:"text-right",children:"IVA"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:311",className:"text-right",children:"Total"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:312",children:"Tipo"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:313",children:"Verifactu"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:314",className:"text-right",children:"Acciones"})]})}),a.jsx(W,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:317",children:h.rows.map(s=>a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:319",className:"cursor-pointer hover:bg-muted/50",onClick:()=>v(s.id),children:[a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:320",className:"font-mono font-semibold text-xs",children:s.invoiceNumber}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:321",className:"text-xs",children:pa(s.issuedAt)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:322",className:"font-medium text-sm",children:s.clientName}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:323",className:"font-mono text-xs text-muted-foreground",children:s.clientNif||"â"}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:324",className:"text-right text-xs font-mono",children:R(s.subtotal)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:325",className:"text-right text-xs font-mono",children:R(s.taxAmount)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:326",className:`text-right text-sm font-semibold font-mono ${Number(s.total)<0?"text-rose-600":""}`,children:R(s.total)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:329",children:a.jsx(Q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:329",map:Na,value:s.invoiceType})}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:330",children:a.jsx(Q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:330",map:Ma,value:s.verifactuStatus})}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:331",className:"text-right",onClick:L=>L.stopPropagation(),children:a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:332",className:"flex justify-end gap-1",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:333",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(s.id),title:"Ver factura",children:a.jsx(Ha,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:334",className:"h-3.5 w-3.5"})}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:336",variant:"ghost",size:"icon",className:"h-7 w-7",disabled:Fa.isPending,onClick:()=>Fa.mutate({invoiceId:s.id}),title:"Enviar por email",children:a.jsx(Sa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:342",className:"h-3.5 w-3.5"})}),s.invoiceType==="factura"&&!["anulada","abonada","generada"].includes(s.status)&&a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:345",variant:"ghost",size:"icon",className:"h-7 w-7 text-rose-600 hover:text-rose-700",onClick:()=>C({id:s.id,invoiceNumber:s.invoiceNumber}),title:"Crear abono",children:a.jsx(xa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:350",className:"h-3.5 w-3.5"})})]})})]},s.id))})]}),ra>1&&a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:360",className:"flex items-center justify-between border-t px-4 py-3 text-xs text-muted-foreground",children:[a.jsxs("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:361",children:["Página ",h.page," de ",ra," · ",h.total," facturas"]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:362",className:"flex gap-2",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:363",variant:"outline",size:"sm",disabled:c<=1,onClick:()=>i(s=>s-1),children:"â Anterior"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:364",variant:"outline",size:"sm",disabled:c>=ra,onClick:()=>i(s=>s+1),children:"Siguiente â"})]})]})]})}),k!==null&&a.jsx(fa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:373",invoiceId:k,onClose:()=>v(null)}),P&&a.jsx(Ra,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:374",invoice:P,onClose:()=>C(null)}),a.jsx(V,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:377",open:e,onOpenChange:s=>!s&&l(!1),children:a.jsxs(O,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:378",children:[a.jsx(B,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:379",children:a.jsx(_,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:380",children:"Facturación masiva por fecha de salida"})}),a.jsx("p",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:382",className:"text-sm text-muted-foreground",children:"Genera facturas para todas las estancias con check-out en la fecha seleccionad
6a que aún no tienen factura."}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:385",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:386",children:"Fecha de salida"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:387",type:"date",value:I,onChange:s=>p(s.target.value)})]}),a.jsxs(U,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:389",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:390",variant:"outline",onClick:()=>l(!1),children:"Cancelar"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:391",disabled:!I||ia.isPending,onClick:()=>ia.mutate({date:I}),children:ia.isPending?"Generandoâ¦":"Generar facturas"})]})]})})]})}function Va(){const[c,i]=u.useState(1),[r,d]=u.useState(Y().from),[j,H]=u.useState(Y().to),[x,F]=u.useState(""),[g,f]=u.useState(null),[k,v]=u.useState(!1),[P,C]=u.useState(""),I=b.useUtils(),{data:p,isLoading:e}=b.hotelInvoices.listAll.useQuery({page:c,pageSize:50,invoiceType:"proforma",fromDate:r||null,toDate:j||null,search:x.trim()||null}),l=b.hotelInvoices.createProforma.useMutation({onSuccess:t=>{T.success(`Pro forma creada: ${t.invoiceNumber}`),I.hotelInvoices.listAll.invalidate(),v(!1),C("")},onError:t=>T.error("Error",{description:t.message})}),N=p?Math.max(1,Math.ceil(p.total/p.pageSize)):1;return a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:439",className:"space-y-4",children:[a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:440",children:a.jsx(J,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:441",className:"pt-4",children:a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:442",className:"flex flex-wrap items-end gap-3",children:[a.jsx(oa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:443",from:r,to:j,onChange:(t,h)=>{d(t),H(h),i(1)}}),a.jsx(ua,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:444",value:x,onChange:t=>{F(t),i(1)},placeholder:"Cliente o nºâ¦",className:"w-52"}),a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:445",className:"ml-auto",children:a.jsxs(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:446",size:"sm",onClick:()=>v(!0),children:[a.jsx(ea,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:447",className:"mr-1.5 h-4 w-4"})," Nueva pro forma"]})})]})})}),a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:454",className:"overflow-hidden p-0",children:e?a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:456",className:"space-y-2 p-4",children:Array.from({length:6}).map((t,h)=>a.jsx(q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:457",height:44,radius:6},h))}):!p||p.rows.length===0?a.jsx(X,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:460",icon:ha,title:"Sin pro formas",description:"No hay pro formas para este perÃodo.",className:"m-4"}):a.jsxs(a.Fragment,{children:[a.jsxs(K,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:463",children:[a.jsx(Z,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:464",children:a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:465",children:[a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:466",children:"Nº"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:467",children:"Fecha"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:468",children:"Cliente"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:469",children:"NIF"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:470",className:"text-right",children:"Total"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:471",children:"Estado"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:472",className:"text-right",children:"Acciones"})]})}),a.jsx(W,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:475",children:p.rows.map(t=>a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:477",className:"cursor-pointer hover:bg-muted/50",onClick:()=>f(t.id),children:[a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:478",className:"font-mono text-xs font-semibold",children:t.invoiceNumber}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:479",className:"text-xs",children:pa(t.issuedAt)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:480",className:"font-medium text-sm",children:t.clientName}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:481",className:"font-mono text-xs text-muted-foreground",children:t.clientNif||"â"}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:482",className:"text-right font-mono text-sm font-semibold",children:R(t.total)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:483",children:a.jsx(Q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:483",map:va,value:t.status})}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:484",className:"text-right",onClick:h=>h.stopPropagation(),children:a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:485",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(t.id),children:a.jsx(Ha,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:486",className:"h-3.5 w-3.5"})})})]},t.id))})]}),N>1&&a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:494",className:"flex items-center justify-between border-t px-4 py-3 text-xs text-muted-foreground",children:[a.jsxs("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:495",children:["Página ",p.page," de ",N]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:496",className:"flex gap-2",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:497",variant:"outline",size:"sm",disabled:c<=1,onClick:()=>i(t=>t-1),children:"â Anterior"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:498",variant:"outline",size:"sm",disabled:c>=N,onClick:()=>i(t=>t+1),children:"Siguiente â"})]})]})]})}),g!==null&&a.jsx(fa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:506",invoiceId:g,onClose:()=>f(null)}),a.jsx(V,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:508",open:k,onOpenChange:t=>!t&&v(!1),children:a.jsxs(O,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:509",children:[a.jsx(B,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:510",children:a.jsx(_,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:511",children:"Nueva pro forma desde estancia"})}),a.jsx("p",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:513",className:"text-sm text-muted-foreground",children:"Introduce el ID de estancia para generar la pro forma con sus cargos actuales."}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:514",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:515",children:"ID de estancia"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:516",type:"number",placeholder:"p. ej. 42",value:P,onChange:t=>C(t.target.value)})]}),a.jsxs(U,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:523",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:524",variant:"outline",onClick:()=>v(!1),children:"Cancelar"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:525",disabled:!P||l.isPending,onClick:()=>l.mutate({stayId:Number(P)}),children:l.isPending?"Creandoâ¦":"Crear pro forma"})]})]})})]})}const Oa={clientName:"",clientEmail:"",clientNif:"",clientAddress:"",clientPhone:"",lines:[{description:"",quantity:1,unitPrice:0,ivaRate:21}]};function ja({initialData:c,estimateId:i,onClose:r}){const[d,j]=u.useState(c??Oa),H=b.useUtils(),x=b.hotelInvoices.createEstimate.useMutation({onSuccess:e=>{T.success(`Estimación creada: ${e.invoiceNumber}`),H.hotelInvoices.listEstimates.invalidate(),r()},onError:e=>T.error("Error",{description:e.message})}),F=b.hotelInvoices.updateEstimate.useMutation({onSuccess:()=>{T.success("Estimación actualizada"),H.hotelInvoices.listEstimates.invalidate(),r()},onError:e=>T.error("Error",{description:e.message})}),g=!!i,f=x.isPending||F.isPending;function k(){j(e=>({...e,lines:[...e.lines,{description:"",quantity:1,unitPrice:0,ivaRate:21}]}))}function v(e){j(l=>({...l,lines:l.lines.filter((N,t)=>t!==e)}))}function P(e,l,N){j(t=>({...t,lines:t.lines.map((h,na)=>na===e?{...h,[l]:N}
6:h)}))}const C=d.lines.reduce((e,l)=>e+l.unitPrice*l.quantity,0),I=d.lines.reduce((e,l)=>{const N=l.unitPrice*l.quantity,t=l.ivaRate>0?N/(1+l.ivaRate/100):N;return e+(N-t)},0);function p(){const e={clientName:d.clientName.trim(),clientEmail:d.clientEmail.trim()||null,clientNif:d.clientNif.trim()||null,clientAddress:d.clientAddress.trim()||null,clientPhone:d.clientPhone.trim()||null,lines:d.lines};g&&i?F.mutate({estimateId:i,...e}):x.mutate({...e,clientEmail:e.clientEmail??void 0})}return a.jsx(V,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:630",open:!0,onOpenChange:e=>!e&&r(),children:a.jsxs(O,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:631",className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[a.jsx(B,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:632",children:a.jsx(_,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:633",children:g?"Editar estimación":"Nueva estimación"})}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:635",className:"space-y-4",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:637",className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:638",className:"col-span-2 space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:639",children:"Cliente *"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:640",value:d.clientName,onChange:e=>j(l=>({...l,clientName:e.target.value})),placeholder:"Nombre del cliente"})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:642",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:643",children:"Email"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:644",type:"email",value:d.clientEmail,onChange:e=>j(l=>({...l,clientEmail:e.target.value})),placeholder:"[email protected]"})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:646",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:647",children:"NIF / CIF"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:648",value:d.clientNif,onChange:e=>j(l=>({...l,clientNif:e.target.value})),placeholder:"12345678A"})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:650",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:651",children:"Teléfono"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:652",value:d.clientPhone,onChange:e=>j(l=>({...l,clientPhone:e.target.value}))})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:654",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:655",children:"Dirección"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:656",value:d.clientAddress,onChange:e=>j(l=>({...l,clientAddress:e.target.value}))})]})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:661",className:"space-y-2",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:662",className:"flex items-center justify-between",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:663",children:"LÃneas de concepto"}),a.jsxs(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:664",type:"button",variant:"outline",size:"sm",onClick:k,children:[a.jsx(ea,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:665",className:"mr-1 h-3.5 w-3.5"})," Añadir lÃnea"]})]}),a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:668",className:"space-y-2",children:d.lines.map((e,l)=>a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:670",className:"flex items-start gap-2 rounded-md border p-2",children:[a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:671",className:"flex-1 space-y-1",children:a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:672",placeholder:"Descripción",value:e.description,onChange:N=>P(l,"description",N.target.value)})}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:678",className:"w-16 space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:679",className:"text-xs text-muted-foreground",children:"Cant."}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:680",type:"number",min:.01,step:.
601,value:e.quantity,onChange:N=>P(l,"quantity",Number(N.target.value))})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:688",className:"w-24 space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:689",className:"text-xs text-muted-foreground",children:"P. unitario"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:690",type:"number",min:0,step:.01,value:e.unitPrice,onChange:N=>P(l,"unitPrice",Number(N.target.value))})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:698",className:"w-20 space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:699",className:"text-xs text-muted-foreground",children:"IVA %"}),a.jsxs(ta,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:700",value:String(e.ivaRate),onValueChange:N=>P(l,"ivaRate",Number(N)),children:[a.jsx(sa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:701",children:a.jsx(la,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:702"})}),a.jsxs(ca,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:704",children:[a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:705",value:"0",children:"0%"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:706",value:"10",children:"10%"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:707",value:"21",children:"21%"})]})]})]}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:711",type:"button",variant:"ghost",size:"icon",className:"mt-5 h-8 w-8 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>v(l),disabled:d.lines.length<=1,children:a.jsx(wa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:719",className:"h-4 w-4"})})]},l))})]}),a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:727",className:"flex justify-end",children:a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:728",className:"w-52 space-y-1 rounded-md border p-3 text-sm",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:729",className:"flex justify-between text-muted-foreground",children:[a.jsx("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:730",children:"Base imponible"}),a.jsx("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:731",children:R(C-I)})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:733",className:"flex justify-between text-muted-foreground",children:[a.jsx("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:734",children:"IVA"}),a.jsx("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:735",children:R(I)})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:737",className:"flex justify-between font-semibold",children:[a.jsx("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:738",children:"Total"}),a.jsx("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:739",children:R(C)})]})]})})]}),a.jsxs(U,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:744",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:745",variant:"outline",onClick:r,children:"Cancelar"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:746",disabled:!d.clientName.trim()||d.lines.some(e=>!e.description.trim())||f,onClick:p,children:f?"Guardandoâ¦":g?"Guardar cambios":"Crear estimación"})]})]})})}function Ba(){const[c,i]=u.useState(1),[r,d]=u.useState(""),[j,H]=u.useState(!1),[x,F]=u.useState(null),[g,f]=u.useState(null),k=b.useUtils(),{data:v,isLoading:P}=b.hotelInvoices.listEstimates.useQuery({page:c,pageSize:50,search:r.trim()||null}),C=b.hotelInvoices.convertEstimateToInvoice.useMutation({onSuccess:e=>{T.success(`Convertida a factura: ${e.invoiceNumber}`),k.hotelInvoices.listEstimates.invalidate(),k.hotelInvoices.listAll.invalidate(),f(null)},onError:e=>T.error("Error",{description:e.message})}),I=v?Math.max(1,Math.ceil(v.total/v.pageSize)):1,p=x!=null?v?.rows.find(e=>e.id===x):void 0;return a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:787",className:"space-y-4",children:[a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:788",children:a.jsx(J,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:789",className:"pt-4",children:a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:790",className:"flex flex-wrap items-end gap-3",children:[a.jsx(ua,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:791",value:r,onChange:e=>{d(e),i(1)},placeholder:"Cliente o nºâ¦",className:"w-52"}),a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:792",className:"ml-auto",children:a.jsxs(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:793",size:"sm",onClick:()=>H(!0),children:[a.jsx(ea,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:794",className:"mr-1.5 h-4 w-4"})," Nueva estimación"]})})]})})}),a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:801",className:"overflow-hidden p-0",children:P?a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:803",className:"space-y-2 p-4",children:Array.from({length:6}).map((e,l)=>a.jsx(q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:804",height:44,radiu
6s:6},l))}):!v||v.rows.length===0?a.jsx(X,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:807",icon:aa,title:"Sin estimaciones",description:"Crea una estimación para un cliente.",className:"m-4"}):a.jsxs(a.Fragment,{children:[a.jsxs(K,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:810",children:[a.jsx(Z,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:811",children:a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:812",children:[a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:813",children:"Nº"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:814",children:"Fecha"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:815",children:"Cliente"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:816",children:"NIF"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:817",className:"text-right",children:"Total"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:818",children:"Estado"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:819",className:"text-right",children:"Acciones"})]})}),a.jsx(W,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:822",children:v.rows.map(e=>a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:824",className:"hover:bg-muted/50",children:[a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:825",className:"font-mono text-xs font-semibold",children:e.invoiceNumber}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:826",className:"text-xs",children:pa(e.issuedAt)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:827",className:"font-medium text-sm",children:e.clientName}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:828",className:"font-mono text-xs text-muted-foreground",children:e.clientNif||"â"}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:829",className:"text-right font-mono text-sm font-semibold",children:R(e.total)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:830",children:a.jsx(Q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:830",map:va,value:e.status})}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:831",className:"text-right",children:a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:832",className:"flex justify-end gap-1",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:833",variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>F(e.id),children:"Editar"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:836",variant:"default",size:"sm",className:"h-7 text-xs",disabled:C.isPending&&g===e.id,onClick:()=>f(e.id),children:"Convertir a factura"})]})})]},e.id))})]}),I>1&&a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:850",className:"flex items-center justify-between border-t px-4 py-3 text-xs text-muted-foreground",children:[a.jsxs("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:851",children:["Página ",v.page," de ",I]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:852",className:"flex gap-2",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:853",variant:"outline",size:"sm",disabled:c<=1,onClick:()=>i(e=>e-1),children:"â Anterior"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:854",variant:"outline",size:"sm",disabled:c>=I,onClick:()=>i(e=>e+1),children:"Siguiente â"})]})]})]})}),j&&a.jsx(ja,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:862",onClose:()=>H(!1)}),x!==null&&p&&a.jsx(ja,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:864",estimateId:x,initialData:{clientName:p.clientName,clientEmail:p.clientEmail??"",clientNif:p.clientNif??"",clientAddress:p.clientAddress??"",clientPhone:p.clientPhone??"",lines:p.itemsJson.map(e=>({description:e.description,quantity:e.quantity,unitPrice:e.unitPrice,ivaRate:e.ivaRate??21}))},onClose:()=>F(null)}),a.jsx(V,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:884",open:g!==null,onOpenChange:e=>!e&&f(null),children:a.jsxs(O,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:885",children:[a.jsx(B,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:886",children:a.jsx(_,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:886",children:"Convertir estimación a factura"})}),a.jsx("p",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:887",className:"text-sm text-muted-foreground",children:"La estimación pasará a ser una factura en estado «Generada». Podrás emitirla cuando esté lista."}),a.jsxs(U,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:890",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:891",variant:"outline",onClick:()=>f(null),children:"Cancelar"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:892",disabled:C.isPending,onClick:()=>
6g!=null&&C.mutate({estimateId:g}),children:C.isPending?"Convirtiendoâ¦":"Convertir"})]})]})})]})}function _a(){const c=Math.ceil((new Date().getMonth()+1)/3),[i,r]=u.useState(c),[d,j]=u.useState(new Date().getFullYear()),{data:H,isLoading:x}=b.hotelInvoices.getIvaReport.useQuery({quarter:i,year:d});return a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:915",className:"space-y-4",children:[a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:917",children:a.jsx(J,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:918",className:"pt-4",children:a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:919",className:"flex flex-wrap items-end gap-3",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:920",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:921",children:"Trimestre"}),a.jsxs(ta,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:922",value:String(i),onValueChange:F=>r(Number(F)),children:[a.jsx(sa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:923",className:"w-44",children:a.jsx(la,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:924"})}),a.jsxs(ca,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:926",children:[a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:927",value:"1",children:"T1 â Enero a Marzo"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:928",value:"2",children:"T2 â Abril a Junio"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:929",value:"3",children:"T3 â Julio a Septiembre"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:930",value:"4",children:"T4 â Octubre a Diciembre"})]})]})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:934",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:935",children:"Año"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:936",type:"number",className:"w-24",value:d,min:2020,max:2100,onChange:F=>j(Number(F.target.value))})]})]})})}),x?a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:944",className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-5",children:Array.from({length:5}).map((F,g)=>a.jsx(q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:945",height:88,radius:8},g))}):H?a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:949",className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-5",children:[a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:950",label:"Base 10%",value:S(H.base10Cents),icon:z}),a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:951",label:"Cuota 10%",value:S(H.iva10Cents),icon:z}),a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:952",label:"Base 21%",value:S(H.base21Cents),icon:z}),a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:953",label:"Cuota 21%",value:S(H.iva21Cents),icon:z}),a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:954",label:"Total IVA",value:S(H.totalIvaCents),icon:z})]}),a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:957",className:"overflow-hidden p-0",children:H.invoices.length===0?a.jsx(X,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:959",icon:z,title:"Sin facturas en este perÃodo",className:"m-4"}):a.jsxs(K,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:961",children:[a.jsx(Z,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:962",children:a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:963",children:[a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:964",children:"Nº Factura"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:965",children:"Fecha"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:966",children:"Cliente"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:967",children:"Tipo"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:968",className:"text-right",children:"Base 10%"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:969",className:"text-right",children:"IVA 10%"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:970",className:"text-right",children:"Base 21%"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:971",className:"text-right",children:"IVA 21%"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:972",className:"text-right",children:"Total"})]})}),a.jsx(W,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:975",children:H.invoices.map(F=>
6a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:977",className:"hover:bg-muted/50",children:[a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:978",className:"font-mono text-xs font-semibold",children:F.invoiceNumber}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:979",className:"text-xs",children:F.issuedAt}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:980",className:"text-sm",children:F.clientName}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:981",children:a.jsx(Q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:981",map:Na,value:F.invoiceType})}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:982",className:"text-right font-mono text-xs",children:S(F.base10)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:983",className:"text-right font-mono text-xs",children:S(F.iva10)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:984",className:"text-right font-mono text-xs",children:S(F.base21)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:985",className:"text-right font-mono text-xs",children:S(F.iva21)}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:986",className:"text-right font-mono text-sm font-semibold",children:S(F.total)})]},F.id))})]})})]}):null]})}function Ua(){const{from:c,to:i}=Y(),[r,d]=u.useState(c),[j,H]=u.useState(i),[x,F]=u.useState(""),[g,f]=u.useState(1),[k,v]=u.useState(!1),[P,C]=u.useState({date:ma(),type:"payment",description:"",debitCents:0,creditCents:0,category:""}),I=b.useUtils(),{data:p,isLoading:e}=b.hotelInvoices.getAccountingJournal.useQuery({fromDate:r,toDate:j,category:x.trim()||null,page:g,pageSize:100}),l=b.hotelInvoices.createAccountingEntry.useMutation({onSuccess:()=>{T.success("Asiento creado"),I.hotelInvoices.getAccountingJournal.invalidate(),v(!1),C({date:ma(),type:"payment",description:"",debitCents:0,creditCents:0,category:""})},onError:t=>T.error("Error",{description:t.message})}),N=p?Math.max(1,Math.ceil(p.total/p.pageSize)):1;return a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1040",className:"space-y-4",children:[a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1041",children:a.jsx(J,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1042",className:"pt-4",children:a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1043",className:"flex flex-wrap items-end gap-3",children:[a.jsx(oa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1044",from:r,to:j,onChange:(t,h)=>{d(t),H(h),f(1)}}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1045",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1046",children:"CategorÃa"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1047",className:"w-36",placeholder:"Filtrarâ¦",value:x,onChange:t=>{F(t.target.value),f(1)}})]}),a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1054",className:"ml-auto",children:a.jsxs(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1055",size:"sm",onClick:()=>v(!0),children:[a.jsx(ea,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1056",className:"mr-1.5 h-4 w-4"})," Nuevo asiento"]})})]})})}),p&&a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1065",className:"grid grid-cols-2 gap-4 sm:grid-cols-3",children:[a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1066",label:"Total Debe",value:S(p.totalDebitCents),icon:z}),a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1067",label:"Total Haber",value:S(p.totalCreditCents),icon:z}),a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1068",label:"Asientos",value:p.total,icon:aa})]}),a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1072",className:"overflow-hidden p-0",children:e?a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1074",className:"space-y-2 p-4",children:Array.from({length:8}).map((t,h)=>a.jsx(q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1075",height:44,radiu
6s:6},h))}):!p||p.rows.length===0?a.jsx(X,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1078",icon:aa,title:"Sin asientos",description:"No hay asientos en este perÃodo.",className:"m-4"}):a.jsxs(a.Fragment,{children:[a.jsxs(K,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1081",children:[a.jsx(Z,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1082",children:a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1083",children:[a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1084",children:"Fecha"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1085",children:"Tipo"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1086",children:"Descripción"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1087",className:"text-right",children:"Debe"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1088",className:"text-right",children:"Haber"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1089",children:"CategorÃa"})]})}),a.jsx(W,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1092",children:p.rows.map(t=>a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1094",className:"hover:bg-muted/50",children:[a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1095",className:"text-xs",children:t.date}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1096",children:a.jsx(Q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1096",map:za,value:t.type})}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1097",className:"text-sm",children:t.description}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1098",className:`text-right font-mono text-xs ${t.debitCents>0?"font-semibold":"text-muted-foreground"}`,children:t.debitCents>0?S(t.debitCents):"â"}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1101",className:`text-right font-mono text-xs ${t.creditCents>0?"font-semibold":"text-muted-foreground"}`,children:t.creditCents>0?S(t.creditCents):"â"}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1104",className:"text-xs text-muted-foreground",children:t.category||"â"})]},t.id))})]}),N>1&&a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1110",className:"flex items-center justify-between border-t px-4 py-3 text-xs text-muted-foreground",children:[a.jsxs("span",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1111",children:["Página ",p.page," de ",N]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1112",className:"flex gap-2",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1113",variant:"outline",size:"sm",disabled:g<=1,onClick:()=>f(t=>t-1),children:"â Anterior"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1114",variant:"outline",size:"sm",disabled:g>=N,onClick:()=>f(t=>t+1),children:"Siguiente â"})]})]})]})}),a.jsx(V,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1122",open:k,onOpenChange:t=>!t&&v(!1),children:a.jsxs(O,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1123",children:[a.jsx(B,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1124",children:a.jsx(_,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1124",children:"Nuevo asiento manual"})}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1125",className:"space-y-3",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1126",className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1127",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1128",children:"Fecha *"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1129",type:"date",value:P.date,onChange:t=>C(h=>({...h,date:t.target.value}))})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1131",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1132",children:"Tipo *"}),a.jsxs(ta,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1133",value:P.type,onValueChange:t=>C(h=>({...h,type:t})),children:[a.jsx(sa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1137",children:a.jsx(la,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1137"})}),a.jsxs(ca,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1138",children:[a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1139",value:"invoice",children:"Factura"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1140",value:"payment",children:"Cobro"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1141",value:"credit_note",children:"Abono"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1142",value:"expense",children:"Gasto"}),a.jsx(E,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1143",value:"adjustment",children:"Ajuste"})]})]})]})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1148",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1149",children:"Descripción *"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1150",value:P.description,onChange:t=>C(h=>({...h,description:t.target.value}))})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1152",className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1153",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1154",children:"Debe (cents)"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1155",type:"number",min:0,value:P.debitCents,onChange:t=>C(h=>({...h,debitCents:Number(t.target.value)}))})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1157",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1158",children:"Haber (cents)"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1159",type:"number",min:0,value:P.credit
6Cents,onChange:t=>C(h=>({...h,creditCents:Number(t.target.value)}))})]})]}),a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1162",className:"space-y-1",children:[a.jsx(y,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1163",children:"CategorÃa"}),a.jsx(w,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1164",value:P.category,onChange:t=>C(h=>({...h,category:t.target.value})),placeholder:"p. ej. alojamiento, serviciosâ¦"})]})]}),a.jsxs(U,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1167",children:[a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1168",variant:"outline",onClick:()=>v(!1),children:"Cancelar"}),a.jsx(m,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1169",disabled:!P.description.trim()||!P.date||l.isPending,onClick:()=>l.mutate({date:P.date,type:P.type,description:P.description,debitCents:P.debitCents,creditCents:P.creditCents,category:P.category.trim()||null}),children:l.isPending?"Guardandoâ¦":"Crear asiento"})]})]})})]})}const qa={efectivo:"Efectivo",tarjeta:"Tarjeta",transferencia:"Transferencia",redsys:"Redsys",otro:"Otro"};function Ga(){const{from:c,to:i}=Y(),[r,d]=u.useState(c),[j,H]=u.useState(i),{data:x,isLoading:F}=b.hotelInvoices.getPaymentsReport.useQuery({fromDate:r,toDate:j});return a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1207",className:"space-y-4",children:[a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1208",children:a.jsx(J,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1209",className:"pt-4",children:a.jsx(oa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1210",from:r,to:j,onChange:(g,f)=>{d(g),H(f)}})})}),F?a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1215",className:"grid grid-cols-2 gap-4 sm:grid-cols-4",children:Array.from({length:4}).map((g,f)=>a.jsx(q,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1216",height:88,radius:8},f))}):x?a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1221",className:"grid grid-cols-2 gap-4 sm:grid-cols-4",children:x.byMethod.length>0?x.byMethod.map(g=>a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1224",label:qa[g.method]??g.method,value:S(g.totalCents),icon:ga},g.method)):a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1232",className:"col-span-4",children:a.jsx(X,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1233",icon:ga,title:"Sin cobros en este perÃodo",className:"py-8"})})}),x.byChannel.length>0&&a.jsx("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1240",className:"grid grid-cols-2 gap-4 sm:grid-cols-4",children:x.byChannel.map(g=>a.jsx(M,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1242",label:`Canal: ${g.channel}`,value:S(g.totalCents)},g.channel))}),x.byDay.length>0&&a.jsx(A,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1249",className:"overflow-hidden p-0",children:a.jsxs(K,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1250",children:[a.jsx(Z,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1251",children:a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1252",children:[a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1253",children:"Fecha"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1254",className:"text-right",children:"Nº cobros"}),a.jsx(o,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1255",className:"text-right",children:"Total"})]})}),a.jsx(W,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1258",children:x.byDay.map(g=>a.jsxs(D,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1260",className:"hover:bg-muted/50",children:[a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1261",className:"text-sm",children:g.date}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1262",className:"text-right text-sm",children:g.count}),a.jsx(n,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1263",className:"text-right font-mono text-sm font-semibold",children:S(g.totalCents)})]},g.date))})]})})]}):null]})}function ue(){return a.jsxs(Ea,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1280",title:"Facturación hotel",children:[a.jsxs("div",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1281",className:"mb-4",children:[a.jsx("h1",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1282",className:"text-2xl font-semibold tracking-tight",children:"Facturación hotel"}),a.jsx("p",{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1283",className:"text-sm text-muted-foreground",children:"Facturas, estimaciones, informes IVA y diario contable."})]}),a.jsxs(Ta,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1286",defaultValue:"facturas",className:"space-y-4",children:[a.jsxs(Ia,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1287",className:"flex h-auto flex-wrap gap-0.5",children:[a.jsxs(G,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1288",value:"facturas",className:"gap-1.5",children:[a.jsx(xa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1289",className:"h-3.5 w-3.5"})," Facturas"]}),a.jsxs(G,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1291",value:"proforma",className:"gap-1.5",children:[a.jsx(ha,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1292",className:"h-3.5 w-3.5"})," Pro Forma"]}),a.jsxs(G,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1294",value:"estimaciones",className:"gap-1.5",children:[a.jsx(aa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1295",className:"h-3.5 w-3.5"})," Estimaciones"]}),a.jsxs(G,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1297",value:"iva",className:"gap-1.5",children:[a.jsx(z,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1298",className:"h-3.5 w-3.5"})," Informe IVA"]}),a.jsxs(G,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1300",value:"diario",className:"gap-1.5",children:[a.jsx(aa,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1301",className:"h-3.5 w-3.5"})," Diario contable"]}),a.jsxs(G,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1303",value:"pagos",className:"gap-1.5",children:[a.jsx(ga,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1304",className:"h-3.5 w-3.5"})," Pagos"]})]}),a.jsx($,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1308",value:"facturas",children:a.jsx(La,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1308"})}),a.jsx($,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1309",value:"proforma",children:a.jsx(Va,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1309"})}),a.jsx($,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1310",value:"estimaciones",children:a.jsx(Ba,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1310"})}),a.jsx($,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1311",value:"iva",children:a.jsx(_a,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1311"})}),a.jsx($,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1312",value:"diario",children:a.jsx(Ua,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1312"})}),a.jsx($,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1313",value:"pagos",children:a.jsx(Ga,{"data-loc":"client/src/pages/admin/hotel/FacturasHotelPage.tsx:1313"})})]})]})}export{ue 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.