PageSourceSearch

https://effervescent-cupcake-210607.netlify.app/assets/AdminBilling-CELkrDmc.js

js effervescent-cupcake-210607.netlify.app collected 2026-10-03 10:41:18 UTC 72,525 bytes, 111 lines download raw bytes

1import{r as C,j as a,s as D}from"./index-bMFZPluE.js";import{m as Xa,g as le,c as Na,r as Ia}from"./pricingEngine-DmHUGCKM.js";import{p as wa}from"./classRoster-DcgYT_RM.js";import{L as ze,c as Ca,A as ka}from"./laborCostReference-CzuQcRj4.js";import{t as Sa}from"./phoneFormatting-bIoASOCT.js";import{a as et}from"./familyReceiptPolicy-egdKJ3_6.js";import{g as at}from"./holidayCalendar-CjdTLo_H.js";import{l as tt}from"./laborAssignmentControls-PBEP3hIy.js";import"./educationCatalog-pqwMnMBs.js";const rt=c=>String(c||"").trim().toLowerCase(),st=c=>String(c||"").replace(/\D/g,""),ot=c=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c),J=c=>Array.from(new Set(c.map(F=>String(F||"").trim()).filter(Boolean))),nt=c=>{const F=String((c==null?void 0:c.student_status)||""),s=String((c==null?void 0:c.billing_source_class_id)||(c==null?void 0:c.billing_source_class_date)||"");return c!=null&&c.id?`${c.id}:${F}:${s}`:[c==null?void 0:c.class_date,c==null?void 0:c.start_time,c==null?void 0:c.end_time,c==null?void 0:c.subject,c==null?void 0:c.monitor_email,F,s].map(A=>String(A||"")).join(":")},He=(c=[])=>{const F=new Map;return c.forEach(s=>{const A=nt(s),P=J([...Array.isArray(s==null?void 0:s.billing_student_names)?s.billing_student_names:[],s==null?void 0:s.billing_student_name]),_=F.get(A);if(!_){F.set(A,{...s,student_name:P.join(", ")||(s==null?void 0:s.student_name)||"",billing_student_names:P,family_price:Number(s==null?void 0:s.family_price)||0,original_family_price:Number((s==null?void 0:s.original_family_price)??(s==null?void 0:s.family_price))||0});return}const H=J([..._.billing_student_names||[],...P]);_.billing_student_names=H,_.student_name=H.join(", ")||_.student_name,_.family_price=Number((Number(_.family_price||0)+Number((s==null?void 0:s.family_price)||0)).toFixed(2)),_.original_family_price=Number((Number(_.original_family_price||0)+Number((s==null?void 0:s.original_family_price)??(s==null?void 0:s.family_price)??0)).toFixed(2)),_.family_price_note=J([_.family_price_note,s==null?void 0:s.family_price_note]).join(" ")}),Array.from(F.values())},it=(c,F=0)=>{const s=rt((c==null?void 0:c.parent_email)||(c==null?void 0:c.email));if(ot(s))return`family_email=${s}`;const A=st(c==null?void 0:c.phone);return A.length>=9?`family_phone=${A}`:`student=${String((c==null?void 0:c.student_id)||(c==null?void 0:c.name)||F).trim().toLowerCase()}`},lt=(c=[])=>{const F=new Map;return c.forEach((s,A)=>{const P=it(s,A),_=String((s==null?void 0:s.name)||"").trim(),H=(V=[])=>V.map(R=>({...R,billing_student_name:_,billing_student_names:J([_]),student_name:_||(R==null?void 0:R.student_name)||""})),g=F.get(P);if(!g){F.set(P,{...s,family_receipt_key:P,student_ids:J([s==null?void 0:s.student_id]),student_names:J([_]),classes:H(s==null?void 0:s.classes),forecastClasses:H(s==null?void 0:s.forecastClasses)});return}g.student_ids=J([...g.student_ids,s==null?void 0:s.student_id]),g.student_names=J([...g.student_names,_]),g.classes.push(...H(s==null?void 0:s.classes)),g.forecastClasses.push(...H(s==null?void 0:s.forecastClasses)),g.amount=Number(g.amount||0)+Number((s==null?void 0:s.amount)||0),g.forecastAmount=Number(g.forecastAmount||0)+Number((s==null?void 0:s.forecastAmount)||0),g.count=Number(g.count||0)+Number((s==null?void 0:s.count)||0),g.completedCount=Number(g.completedCount||0)+Number((s==null?void 0:s.completedCount)||0),g.absentCount=Number(g.absentCount||0)+Number((s==null?void 0:s.absentCount)||0),g.justifiedAbsentCount=Number(g.justifiedAbsentCount||0)+Number((s==null?void 0:s.justifiedAbsentCount)||0),g.recoveryCount=Number(g.recoveryCount||0)+Number((s==null?void 0:s.recoveryCount)||0),g.allPaid=!!(g.allPaid&&(s!=null&&s.allPaid)),g.receiptUrl=g.receiptUrl||(s==null?void 0:s.receiptUrl)||null,g.excludedHolidays=[...g.excludedHolidays||[],...(s==null?void 0:s.excludedHolidays)||[]]}),Array.from(F.values()).map(s=>{const A=He(s.classes||[]),P=He(s.forecastClasses||[]),_=new Map;(s.excludedHolidays||[]).forEach(R=>{const W=`${(R==null?void 0:R.class_date)||""}:${(R==null?void 0:R.name)||""}`;_.has(W)||_.set(W,R)});const H=s.student_names.length,g=String(s.parent_name||"").trim(),V=g&&g.toLowerCase()!=="familia"?`Familia ${g}`:"Familia";return{...s,student_id:H===1?s.student_ids[0]||s.student_id:null,name:H>1?`${V} · ${H} alumnos`:s.student_names[0]||s.name,classes:A,forecastClasses:P,count:A.length,forecastCount:P.length,excludedHolidays:Array.from(_.values()),excludedHolidayCount:_.size}})},ht=({onBack:c,focusStudentName:F=null})=>{const[s,A]=C.useState("families"),[P,_]=C.useState([]),[H,g]=C.useState([]),[V,R]=C.useState(!0),[W,$a]=C.useState({incoming:0,outgoing:0,profit:0,totalClasses:0,scheduledIncoming:0,scheduledOutgoing:0,scheduledProfit:0,totalScheduledClasses:0}),[M,je]=C.useState(null),[S,ve]=C.useState(null),[O,Ne]=C.useState(null),[re,we]=C.useState(null),[Ce,We]=C.useState(""),[ke,Ue]=C.useState(""),[Oe,qe]=C.useState(!1),[j,de]=C.useState(new Date().getMonth()+1),[L,Ge]=C.useState(new Date().getFullYear()),[ce,Ve]=C.useState(""),[Ye,Ke]=C.useState(!1),[se,Je]=C.useState(!1),[oe,Ze]=C.useState(!1),[Qe,Xe]=C.useState(""),pe=L>2026||L===2026&&j>=9,Ie=pe?ka.hourly:7,Ea=pe?ze.companyCostHourly:Ie,ne=e=>pe&&!String((e==null?void 0:e.modality)||"").toLowerCase().includes("online"),ee=(F||"").trim().toLowerCase(),Se=e=>ee!==""&&((e==null?void 0:e.student_names)||[e==null?void 0:e.name]).some(r=>String(r||"").trim().toLowerCase()===ee),ea="🧾 RECIBO MENSUAL",Pa="💬 RECI
1BO WHATSAPP",me=e=>(e||"").trim().toLowerCase(),G=e=>String(e??"").replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;"),Ra=e=>{const r=String(e||"").trim().toLowerCase();return!(r.includes("info.profeencasa+familia-")||r.includes("+familia-"))&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)},$e=e=>e==="presente"||e==="falta_injustificada"||e==="falta_justificada",aa=e=>e==="prevista_pendiente"?"Prevision pendiente":e==="falta_injustificada"?"Falta no justificada":e==="falta_justificada"?"Falta justificada":e==="canjear_bono"?"Recuperacion":"",ue=e=>e==="prevista_pendiente"?"#2563eb":e==="falta_justificada"?"#16a34a":e==="falta_injustificada"?"#dc2626":e==="canjear_bono"?"#7c3aed":"#2563eb",Ee=e=>e==="falta_justificada"?"**":e==="falta_injustificada"?"***":e==="canjear_bono"?"****":"*",ta=(e,r,t)=>{if(e==="falta_justificada")return"Clase cobrada. Recuperable si hay hueco disponible.";if(e==="falta_injustificada")return"Clase cobrada. No genera recuperacion.";if(e==="canjear_bono"){const o=r?` Recupera la falta justificada del ${r.split("-").reverse().join("/")}.`:"",i=t?` ${t}`:"";return`Recuperacion sin cobro.${o}${i}`.trim()}return""},Z=e=>(e||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),ra=e=>{const r=Number(String((e==null?void 0:e.class_date)||"9999-12-31").replace(/-/g,""));return Number.isFinite(r)?r:99991231},sa=e=>{const[r=0,t=0]=String((e==null?void 0:e.start_time)||"00:00").split(":").map(o=>Number(o));return(Number.isFinite(r)?r:0)*60+(Number.isFinite(t)?t:0)},Fa=(e,r)=>{const t=ra(e)-ra(r);if(t!==0)return t;const o=sa(e)-sa(r);return o!==0?o:String((e==null?void 0:e.subject)||"").localeCompare(String((r==null?void 0:r.subject)||""),"es-ES")},Y=(e=[])=>[...e].sort(Fa),Pe=e=>String((e==null?void 0:e.student_name)||"").split(",").map(r=>r.trim()).filter(Boolean).length,oa=e=>{const r=e==null?void 0:e.recovery_students;return Array.isArray(r)?r.filter(t=>typeof t=="string"?t.trim():String((t==null?void 0:t.student_name)||"").trim()).length:0},Aa=e=>Math.max(1,Pe(e)+oa(e)),Ma=e=>{const r=e==null?void 0:e.family_price_by_student;return!r||typeof r!="object"?!1:Object.values(r).some(t=>!t||typeof t!="object"?!1:String(t.policy||"").includes("paid_group_extra")||Z(t.note).includes("clase extra en grupo"))},na=e=>String(e||"").slice(0,5),ia=e=>{const r=na(e==null?void 0:e.start_time),t=na(e==null?void 0:e.end_time);return r&&t?`${r}-${t}`:""},la=e=>{const r=Z(e||"");return r.includes("bach")?"Bachillerato":r.includes("eso")?"ESO":r.includes("primaria")?"Primaria":r.includes("adult")||r.includes("univers")?"Adultos":e||""},La=e=>(e==null?void 0:e.monitor_display_name)||(e==null?void 0:e.monitor_name)||(e==null?void 0:e.teacher_name)||(e==null?void 0:e.monitor_email)||"",da=e=>{const r=String((e==null?void 0:e.modality)||"").replace(/[⭐️]/g,"").trim(),t=Z(`${r} ${(e==null?void 0:e.family_price_note)||""} ${(e==null?void 0:e.student_billing_policy)||""} ${(e==null?void 0:e.opening_reason)||""}`),o=Aa(e),i=(e==null?void 0:e.student_status)==="canjear_bono"||oa(e)>0;if(t.includes("coordinacion")||t.includes("oficina"))return"Coordinacion / oficina";if((e==null?void 0:e.student_billing_policy)==="paid_group_extra"||Ma(e)||t.includes("clase extra en grupo"))return`Extra en grupo Profe a 3 (${o})`;if(t.includes("extra")&&t.includes("online"))return"Extra online";if(t.includes("clase extra puntual"))return"Extra puntual en centro";if(t.includes("online"))return o>1?`Online grupo (${o})`:"Online individual";if(t.includes("domicilio"))return"Domicilio";if(t.includes("academia")||t.includes("profe a 3")){const d=o>1?`Profe a 3 grupo (${o})`:"Profe a 3 individual";return i?`${d} + recuperacion`:d}return r||"Clase"},xe=e=>[da(e),la(e==null?void 0:e.level),La(e),ia(e)].filter(Boolean).join(" · "),Ta=e=>{const r=String((e==null?void 0:e.student_name)||"").split(",").map(i=>i.trim()).filter(Boolean),t=wa(e==null?void 0:e.recovery_students).map(i=>i.student_name).filter(Boolean),o=Array.from(new Set([...r,...t]));return o.length===0?"":o.length===1?`Alumno: ${o[0]}`:`Alumnos: ${o.join(", ")}`},ca=e=>
1[da(e),la(e==null?void 0:e.level),Ta(e),ia(e)].filter(Boolean).join(" - "),ae=e=>(e==null?void 0:e.student_status)==="prevista_pendiente"?"Prevision. Falta fichaje/valoracion del monitor.":(e==null?void 0:e.student_status)==="falta_justificada"?"Cobrada. Recuperable si hay hueco.":(e==null?void 0:e.student_status)==="falta_injustificada"?"Cobrada. No recuperable.":(e==null?void 0:e.student_status)==="canjear_bono"?e!=null&&e.billing_source_class_date?`Sin cobro. Recupera falta del ${String(e.billing_source_class_date).split("-").reverse().join("/")}.`:"Sin cobro. Recuperacion autorizada.":"",pa=e=>{const r=String((e==null?void 0:e.modality)||""),t=Z((e==null?void 0:e.modality)||""),o=t.includes("academia")||t.includes("profe a 3"),i=le(e==null?void 0:e.start_time,e==null?void 0:e.end_time),d=r.trim().startsWith("⭐")||r.includes("â­")||String((e==null?void 0:e.level)||"").toLowerCase()==="especial",m=o&&i>0&&i<1.25;return d||m},Re=(e,r,t,o,i=0)=>{if(e.status==="Pagado"&&Number(e.family_price)===0)return 0;const d=Math.max(1,r||1),m=Math.max(0,Math.round((Number(e.family_price)||0)*100)),h=Math.floor(m/d),w=m%d,$=(h+(i<w?1:0))/100,z=Z((e==null?void 0:e.modality)||""),Q=z.includes("academia")||z.includes("profe a 3"),ie=z.includes("clase extra puntual");if(pa(e)&&$>0)return Number($.toFixed(2));if(Q&&!ie){const K=Math.max(1,Pe(e)),X=Na({modality:e.modality,level:o||e.level,groupSize:K,startTime:e.start_time,endTime:e.end_time,pricingRules:t});if(X.familyPerStudent>0)return X.familyPerStudent}return Number($.toFixed(2))},ma=(e,r,t)=>{if(pa(e))return null;const o=Ia(e.family_price_by_student,r);return!o||t>0&&Number(o.amount)<t?null:o},Ba=(e,r)=>{if(ne(e))return Number((le(e==null?void 0:e.start_time,e==null?void 0:e.end_time)*ka.hourly).toFixed(2));const t=Number(e==null?void 0:e.monitor_price)||0;if(t>0)return t;const o=Math.max(1,Number(e==null?void 0:e.student_count)||Pe(e)||1),i=Na({modality:e==null?void 0:e.modality,level:e==null?void 0:e.level,groupSize:o,startTime:e==null?void 0:e.start_time,endTime:e==null?void 0:e.end_time,pricingRules:r});return Number((i.monitorTotal||0).toFixed(2))},Fe=C.useMemo(()=>ee?[...P].sort((e,r)=>{const t=Se(e)?1:0,o=Se(r)?1:0;return t!==o?o-t:(e.name||"").localeCompare(r.name||"")}):P,[P,ee]),Ae=C.useMemo(()=>{const e=Z(ce);return e?Fe.filter(r=>{var o,i,d;const t=[r.name,(o=r.student_names)==null?void 0:o.join(" "),r.parent_name,r.email,r.phone,(d=(i=r.siblingCandidate)==null?void 0:i.siblingNames)==null?void 0:d.join(" "),...(r.classes||[]).flatMap(m=>[m.subject,m.level,m.modality,m.student_name])].filter(Boolean).join(" ");return Z(t).includes(e)}):Fe},[Fe,ce]);C.useEffect(()=>{ee&&A("families")},[ee]);const Me=async()=>{R(!0);const e=`${L}-${String(j).padStart(2,"0")}`,r=new Date(L,j,0).getDate(),t=`${e}-01`,o=`${e}-${r}`,{data:i}=await D.from("students").select("student_id, name, email, parent_email, parent_name, phone"),d={};i&&i.forEach(v=>{d[v.name]=v});const{data:m}=await D.from("teachers").select("*");let h=[];try{h=(await tt({statuses:["verified"]})).controls}catch(v){console.warn("No se pudo cargar el control laboral para el cierre mensual.",v)}const{data:w}=await D.from("global_settings").select("setting_value").eq("id","pricing_rules").maybeSingle(),$=Xa(w==null?void 0:w.setting_value),{data:z,error:Q}=await D.from("holidays").select("name, start_date, end_date").lte("start_date",o);Q?(console.warn("No se pudo comprobar el calendario de festivos para los recibos.",Q),Xe(Q.message||"No se pudo comprobar el calendario de festivos.")):Xe("");const ie=(z||[]).filter(v=>(v.end_date||v.start_date)>=t),K=new Map;(m||[]).forEach(v=>{v!=null&&v.email&&K.set(String(v.email),v.name||v.email)});const{data:X,error:Be}=await D.from("classes").select("*").neq("status","Cancelada").gte("class_date",`${e}-01`).lte("class_date",`${e}-${r}`).is("deleted_at",null),y=X||[],I=(X||[]).filter(v=>["Completada","Pagado","Falta Injustificada"].includes(v.status)||!!v.validated&&["Pendiente","En Curso"].includes(v.status)),{data:ge}=await D.from("office_hours").select("*").gte("date",`${e}-01`).lte("date",`${e}-${r}`);if(I&&!Be){const v={};let De=0,fe=0,ya=0;const he=n=>{const x=d[n]||{};return v[n]||(v[n]={student_id:x.student_id,name:n,email:x.parent_email||x.email||"",parent_email:x.parent_email||"",parent_name:x.parent_name||"Familia",phone:x.phone||"",amount:0,forecastAmount:0,forecastCount:0,excludedHolidayCount:0,excludedHolidays:[],count:0,completedCount:0,absentCount:0,justifiedAbsentCount:0,recoveryCount:0,classes:[],forecastClasses:[],allPaid:!0,receiptUrl:null}),v[n]};I.forEach(n=>{ya++;const x=(n.student_name||"").split(",").map(p=>p.trim()).filter(p=>p!=="");let l=0;const f={},u={};x.forEach(p=>{const b=n.attendance_data&&n.attendance_data[p]?n.attendance_data[p]:n.status==="Falta Injustificada"?"falta_injustificada":"presente";f[p]=b,$e(b)&&(u[p]=l,l++)}),l===0&&(l=1);const E={};let B=0;x.forEach(p=>{var te;const b=f[p];if(!$e(b))return;const N=Re(n,l,$,(te=d[p])==null?void 0:te.level,u[p]||0),k=ma(n,p,N),_e=n.status==="Pagado"&&Number(n.family_price)===0?0:Number(((k==null?void 0:k.amount)??N).toFixed(2));E[p]={amount:_e,note:k==null?void 0:k.note,policy:k==null?void 0:k.policy},B+=_e}),B>0&&(De+=Number(B.toFixed(2))),fe+=ne(n)?Number((le(n.start_time,n.end_time)*ze.companyCostHourly).toFixed(2)):Number(n.monitor_price)||0,x.forEach(p=>{var va;const b=f[p],N=he(p);if(!$e(b))return;const k=E[p],_e=Re(n,l,$,(va=d[p])==null?void 0:va.level,u[p]||0),te=(k==null?void 0:k.amount)??(n.status==="Pagado"&&Number(n.family_price)===0?0:_e);N.amount+=te,N.count+=1,b==="falta_injustificada"?N.absentCount+=1:b==="falta_justificada"?N.justifiedAbsentCount+=1:N.completedCount+=1,N.classes.push({...n,monitor_display_name:K.get(String(n.monitor_email||""))||n.monitor_email||"",original_family_price:te,family_price:te,family_price_note:(k==null?void 0:k.note)||ta(b)||n.family_price_note||"",student_billing_policy:(k==null?void 0:k.policy)||"",student_status:b}),n.status!=="Pagado"&&(N.allPaid=!1),n.receipt_url&&(N.receiptUrl=n.receipt_url)}
1),wa(n.recovery_students).forEach(p=>{const b=p.student_name;if(!b)return;const N=he(b);N.count+=1,N.recoveryCount=(N.recoveryCount||0)+1,N.classes.push({...n,monitor_display_name:K.get(String(n.monitor_email||""))||n.monitor_email||"",original_family_price:0,family_price:0,family_price_note:ta("canjear_bono",p.source_class_date,p.note),student_billing_policy:"recovery_no_charge",student_status:"canjear_bono",billing_source_class_id:p.source_class_id||null,billing_source_class_date:p.source_class_date||null}),n.receipt_url&&(N.receiptUrl=n.receipt_url)})});const Ja=new Set((I||[]).map(n=>n.id).filter(Boolean));(y||[]).forEach(n=>{if(n.id&&Ja.has(n.id)||["Completada","Pagado","Falta Injustificada"].includes(n.status))return;const x=(n.student_name||"").split(",").map(f=>f.trim()).filter(Boolean);if(x.length===0)return;const l=at(String(n.class_date||""),ie);if(l){x.forEach(f=>{const u=he(f);u.excludedHolidayCount+=1,u.excludedHolidays.push({class_date:n.class_date,name:l.name||"Festivo o cierre"})});return}x.forEach((f,u)=>{var k;const E=he(f),B=Re(n,x.length,$,(k=d[f])==null?void 0:k.level,u),p=ma(n,f,B),b=Math.max(0,Number(((p==null?void 0:p.amount)??B).toFixed(2))),N=b<=0;E.forecastAmount+=b,E.forecastCount+=1,E.forecastClasses.push({...n,monitor_display_name:K.get(String(n.monitor_email||""))||n.monitor_email||"",original_family_price:b,family_price:b,family_price_note:N?"Prevision pendiente de fichaje y precio. Revisa tarifa antes de emitir recibo.":"Prevision pendiente de fichaje del monitor.",student_billing_policy:N?"forecast_pending_price":"forecast_pending_checkin",student_status:"prevista_pendiente",forecast_only:!0})})});const q={},ye=(n,x,l,f=null)=>{const u=n||"Sin asignar";return q[u]?(q[u].name=q[u].name||x||(l==null?void 0:l.name)||u,q[u].dni=q[u].dni||(l==null?void 0:l.dni)||"",q[u].iban=q[u].iban||(l==null?void 0:l.iban)||"",f&&(q[u].coordinator_id=f)):q[u]={email:u,name:x||(l==null?void 0:l.name)||u,dni:(l==null?void 0:l.dni)||"",iban:(l==null?void 0:l.iban)||"",totalEarned:0,totalPending:0,forecastEarned:0,forecastCount:0,count:0,officeHours:0,actualHours:0,payrollHours:0,estimatedPayrollNet:0,estimatedGross:0,companySocialSecurity:0,totalCompanyCost:0,hasPayrollWork:!1,hasProfessionalWork:!1,coordinator_id:f,classes:[],forecastClasses:[]},q[u]};(m||[]).forEach(n=>{n!=null&&n.email&&ye(n.email,n.name||n.email,n)}),I.forEach(n=>{const x=n.monitor_email||"Sin asignar",l=m==null?void 0:m.find(N=>N.email===x),f=(l==null?void 0:l.name)||x,u=ye(x,f,l),E=le(n.start_time,n.end_time),B=ne(n),p=B?Ca(E):null,b=(p==null?void 0:p.agreedNetReference)??(Number(n.monitor_price)||0);u.actualHours+=E,p?(u.hasPayrollWork=!0,u.payrollHours+=E,u.estimatedPayrollNet+=p.estimatedNet,u.estimatedGross+=p.estimatedGross,u.companySocialSecurity+=p.companySocialSecurity,u.totalCompanyCost+=p.totalCompanyCost):(u.hasProfessionalWork=!0,u.totalCompanyCost+=b),u.totalEarned+=b,n.monitor_paid!==!0&&(u.totalPending+=b),u.count+=1,u.classes.push({...n,monitor_price:b,teacher_reference_amount:b,uses_payroll_reference:B,payroll_estimated_net:(p==null?void 0:p.estimatedNet)??0,payroll_estimated_gross:(p==null?void 0:p.estimatedGross)??0,payroll_company_social_security:(p==null?void 0:p.companySocialSecurity)??0,payroll_total_company_cost:(p==null?void 0:p.totalCompanyCost)??b,monitor_display_name:f})});const Za=new Set((I||[]).map(n=>n.id).filter(Boolean));(y||[]).forEach(n=>{if(n.id&&Za.has(n.id)||["Completada","Pagado","Falta Injustificada"].includes(n.status))return;const x=n.monitor_email||"Sin asignar",l=m==null?void 0:m.find(p=>p.email===x),f=(l==null?void 0:l.name)||x,u=ye(x,f,l),E=ne(n),B=Ba(n,$);B<=0||(E?u.hasPayrollWork=!0:u.hasProfessionalWork=!0,u.forecastEarned+=B,u.forecastCount+=1,u.forecastClasses.push({...n,monitor_price:B,teacher_reference_amount:B,uses_payroll_reference:E,monitor_display_name:f,forecast_only:!0}))}),ge&&ge.forEach(n=>{const x=Number(n.duration)||0,l=pe?Ca(x):null,f=(l==null?void 0:l.agreedNetReference)??x*Ie,u=(l==null?void 0:l.totalCompanyCost)??x*Ea;fe+=u;const E=m==null?void 0:m.find(N=>N.id===n.coordinator_id),B=(E==null?void 0:E.email)||"Coordinador",p=(E==null?void 0:E.name)||"Coordinador",b=ye(B,p,E,n.coordinator_id);b.actualHours+=x,b.officeHours+=x,b.totalEarned+=f,n.paid!==!0&&(b.totalPending+=f),l?(b.hasPayrollWork=!0,b.payrollHours+=x,b.estimatedPayrollNet+=l.estimatedNet,b.estimatedGross+=l.estimatedGross,b.companySocialSecurity+=l.companySocialSecurity,b.totalCompanyCost+=l.totalCompanyCost):(b.hasProfessionalWork=!0,b.totalCompanyCost+=f),b.classes.push({class_date:n.date,subject:"Coordinación y Oficina",modality:"Coordinacion / oficina",student_name:"",monitor_display_name:p,duration:n.duration*60,monitor_price:f,teacher_reference_amount:f,uses_payroll_reference:!!l,payroll_estimated_net:(l==null?void 0:l.estimatedNet)??0,payroll_estimated_gross:(l==null?void 0:l.estimatedGross)??0,payroll_company_
1social_security:(l==null?void 0:l.companySocialSecurity)??0,payroll_total_company_cost:(l==null?void 0:l.totalCompanyCost)??f})});const _a=(y||[]).reduce((n,x)=>n+(Number(x.family_price)||0),0),ja=(y||[]).reduce((n,x)=>{const l=ne(x)?le(x.start_time,x.end_time)*ze.companyCostHourly:Number(x.monitor_price)||0;return n+l},0),Qa=(y||[]).length;_(lt(Object.values(v)).map(n=>({...n,classes:Y(n.classes),forecastClasses:Y(n.forecastClasses||[])})).sort((n,x)=>n.name.localeCompare(x.name,"es-ES"))),g(Object.values(q).map(n=>{const l=h.filter(f=>f.teacher_email===String(n.email||"").trim().toLowerCase()).sort((f,u)=>String(u.verified_at||u.updated_at).localeCompare(String(f.verified_at||f.updated_at)))[0]||null;return{...n,latestLaborControl:l,classes:Y(n.classes),forecastClasses:Y(n.forecastClasses||[])}}).sort((n,x)=>n.name.localeCompare(x.name,"es-ES"))),$a({incoming:De,outgoing:fe,profit:De-fe,totalClasses:ya,scheduledIncoming:_a,scheduledOutgoing:ja,scheduledProfit:_a-ja,totalScheduledClasses:Qa})}R(!1)};C.useEffect(()=>{Me()},[j,L]);const Da=async()=>{qe(!0);try{const{data:e,error:r}=await D.from("teachers").select("id").ilike("email",re.email).maybeSingle();if(r)throw r;if(e){const{error:t}=await D.from("teachers").update({dni:Ce,iban:ke}).eq("id",e.id);if(t)throw t}else{const{error:t}=await D.from("teachers").insert([{email:re.email,name:re.name,dni:Ce,iban:ke}]);if(t)throw t}alert("✅ Datos bancarios guardados correctamente."),we(null),Me()}catch(e){alert("Error al guardar: "+e.message)}qe(!1)},za=(e,r,t=0)=>{const o=T[j-1];let i=r>0?`🗓️ Sesiones impartidas: ${r}
2`:"";t>0&&(i+=`💼 Horas de oficina: ${t}h
3`);const d=`¡Hola! 👋 Te escribo desde la coordinación de *Profe en Casa*.
4
5Te confirmo que acabamos de realizar tu liquidación correspondiente al mes de *${o}*.
6
7${i}💶 Total transferido: *${e.toFixed(2)}€*
8
9¡Muchas gracias por tu excelente trabajo este mes! 🚀`;window.open(`https://wa.me/?text=${encodeURIComponent(d)}`,"_blank")},Ha=async e=>{R(!0);const r=`${L}-${String(j).padStart(2,"0")}`,t=new Date(L,j,0).getDate(),{error:o}=await D.from("classes").update({monitor_paid:!0}).eq("monitor_email",e.email).in("status",["Completada","Pagado","Falta Injustificada"]).gte("class_date",`${r}-01`).lte("class_date",`${r}-${t}`).is("deleted_at",null);let i=null,d=e.coordinator_id;if(!d&&e.email!=="Coordinador"&&e.email!=="Sin asignar"){const{data:m}=await D.from("teachers").select("id").eq("email",e.email).maybeSingle();m&&(d=m.id)}if(d){const{error:m}=await D.from("office_hours").update({paid:!0}).eq("coordinator_id",d).gte("date",`${r}-01`).lte("date",`${r}-${t}`);i=m}!o&&!i?(Ne(null),Me()):(alert("Error al liquidar. Detalles: "+((o==null?void 0:o.message)||"")+" "+((i==null?void 0:i.message)||"")),R(!1))},Wa=()=>{j===12?(de(1),Ge(e=>e+1)):de(e=>e+1)},Ua=()=>{j===1?(de(12),Ge(e=>e-1)):de(e=>e-1)},ua=(e,r)=>{const t=document.getElementById(e);if(!t)return;const o=window.open("","_blank");o?(o.document.write(`
10              <html>
11                  <head>
12                      <title>Documento_${r.replace(/\s+/g,"_")}_${T[j-1]}</title>
13                      <script src="https://cdn.tailwindcss.com"><\/script>
14                      <style>
15                          @page { margin: 20mm; }
16                          body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
17                      </style>
18                  </head>
19                  <body class="bg-white text-black font-sans p-8 max-w-2xl mx-auto">
20                      ${t.innerHTML}
21                  </body>
22              </html>
23          `),o.document.close(),o.focus(),setTimeout(()=>{o.print(),o.close()},1e3)):alert("⚠️ Por favor, permite las ventanas emergentes (pop-ups) en tu navegador para generar el PDF.")},Oa=e=>{const r=String((e==null?void 0:e.parent_name)||"Familia").trim();return!r||r.toLowerCase()==="familia"?"familia":r.split(" ")[0]},qa=e=>({finalAmount:e.amount,monthName:T[j-1],monthLabel:`${T[j-1]} ${L}`,parentFirstName:Oa(e)}),be=e=>e!=null&&e.family_receipt_key?String(e.family_receipt_key):e!=null&&e.student_id?`student_id=${Str
23ing(e.student_id).trim()}`:`student_name=${me(e==null?void 0:e.name)}`,Le=e=>{const r=new Set,t=Y(He([...(e==null?void 0:e.classes)||[],...(e==null?void 0:e.forecastClasses)||[]])).filter(i=>{const d=i!=null&&i.id?`${i.id}:${i.student_status||""}`:`${(i==null?void 0:i.class_date)||""}:${(i==null?void 0:i.start_time)||""}:${(i==null?void 0:i.subject)||""}:${(i==null?void 0:i.student_status)||""}`;return r.has(d)?!1:(r.add(d),!0)}),o=Number(t.reduce((i,d)=>i+Math.max(0,Number(d==null?void 0:d.family_price)||0),0).toFixed(2));return{...e,amount:o,classes:t,forecastClasses:[],allPaid:t.length>0&&t.every(i=>i.status==="Pagado"),isAdvanceReceipt:!0,hasPlannedClasses:t.some(i=>i.forecast_only||i.student_status==="prevista_pendiente")}},U=(e,r="email")=>{const t=Le(e),o=[];return Qe&&o.push("calendario de festivos no comprobado"),r==="email"&&!Ra(t.email)&&o.push("correo familiar ausente o invalido"),r==="whatsapp"&&!Sa(t.phone)&&o.push("telefono familiar ausente o invalido"),t.classes.length===0&&o.push("sin sesiones previstas"),t.amount<=0&&o.push("importe mensual igual a cero"),t.classes.some(i=>i.student_billing_policy==="forecast_pending_price")&&o.push("una o mas sesiones no tienen precio confirmado"),o},Te=(e,r="email")=>{const t=Le(e),o=U(t,r);if(o.length>0)throw new Error(`Recibo bloqueado: ${o.join("; ")}.`);const{finalAmount:i,monthName:d,monthLabel:m,parentFirstName:h}=qa(t),w=Y(t.classes||[]),$=w.map(y=>`
24        <div style="display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eee;">
25            <span style="font-size: 14px; line-height: 1.5;">
26                <span style="color:${ue(y.student_status)}; font-weight:900;">${Ee(y.student_status)}</span>
27                ${G(y.class_date.split("-").reverse().join("/"))} - ${G(y.subject)}
28                <br><span style="display:inline-block; margin-top:4px; color:#64748b; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.04em;">${G(xe(y))}</span>
29                ${ae(y)?`<br><span style="color:${ue(y.student_status)}; font-size:11px; font-weight:700;">${G(ae(y))}</span>`:""}
30            </span>
31            <strong style="white-space: nowrap;">${y.family_price.toFixed(2)}EUR</strong>
32        </div>
33    `).join(""),z=`
34        <div style="margin-top: 14px; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; color: #64748b; font-size: 11px; line-height: 1.7;">
35            <strong style="display:block; color:#475569; text-transform:uppercase; letter-spacing:.08em; font-size:10px; margin-bottom:4px;">Leyenda</strong>
36            <div><strong>*</strong> Sesion prevista y plaza reservada</div>
37            <div><strong>**</strong> Falta justificada: se mantiene en el recibo y puede recuperarse si hay hueco</div>
38            <div><strong>***</strong> Falta no justificada: se mantiene en el recibo y no es recuperable</div>
39            <div><strong>****</strong> Recuperacion sin segundo cobro</div>
40            <div style="margin-top:6px;"><strong>Festivos y cierres conocidos:</strong> ya estan descontados y no aparecen como sesiones cobrables.</div>
41        </div>
42    `,Q=w.map(y=>{const I=aa(y.student_status)?` (${aa(y.student_status)})`:"",ge=ae(y)?` · ${ae(y)}`:"";return`${Ee(y.student_status)} ${y.class_date.split("-").reverse().join("/")} · ${y.subject} · ${xe(y)}${I}${ge}: ${y.family_price.toFixed(2)}EUR`}).join(`
43`),ie=t.allPaid?'<div style="background-color: #dcfce7; border-left: 4px solid #22c55e; color: #166534; padding: 15px; border-radius: 4px; text-align: left; font-size: 14px;"><strong>Recibo pagado.</strong><br/>Esta mensualidad ya consta como abonada en nuestro sistema. Muchas gracias.</div>':`<div style="background-color: #fef3c7; border-left: 4px solid #f59e0b; color: #92400e; padding: 15px; border-radius: 4px; text-align: left; font-size: 14px;"><strong>Recibo mensual por adelantado.</strong><br/>El importe se calcula con las sesiones previstas y reservadas en el calendario de ${G(d)}. Los festivos y cierres conocidos ya estan descontados.</div>`,K=t.allPaid?`
44Esta mensualidad ya figura como abonada. Muchas gracias.`:`
45El pago se realiza al comenzar el mes, durante la primera semana.`,X=`
46        <div style="font-family: sans-serif; max-width: 600px; margin: 0 auto; color: #333; border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05);">
47            <div style="background-color: #1c74e9; padding: 30px 20px; text-align: center;">
48                <h1 style="color: white; margin: 0; font-size: 24px; font-style: italic; font-weight: 900;">Profe en Casa</h1>
49                <p style="color: #bfdbfe; font-size: 12px; text-transform: uppercase; letter-spacing: 2px; margin-top: 5px;">
49Recibo mensual por adelantado - ${G(m)}</p>
50            </div>
51            <div style="padding: 30px 20px;">
52                <p style="font-size: 16px;">Hola <strong>${G(h)}</strong>,</p>
53                <p style="font-size: 16px;">Te enviamos el recibo de <strong>${G(t.name)}</strong> correspondiente a ${G(d)}.</p>
54                <p style="font-size: 13px; line-height: 1.6; color: #64748b;">${G(et)}</p>
55                ${ie}
56                <div style="background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 15px; margin: 25px 0;">
57                    <h3 style="margin-top: 0; font-size: 14px; text-transform: uppercase; color: #6b7280; border-bottom: 2px solid #e5e7eb; padding-bottom: 10px;">Desglose de sesiones</h3>
58                    ${$}
59                    ${z}
60                    <div style="display: flex; justify-content: space-between; padding-top: 15px; margin-top: 10px; border-top: 2px solid #333; font-size: 18px;">
61                        <strong>TOTAL</strong>
62                        <strong>${i.toFixed(2)}EUR</strong>
63                    </div>
64                </div>
65            </div>
66        </div>
67    `,Be=`Hola ${h}, te enviamos el recibo mensual por adelantado de ${t.name} correspondiente a ${m}.
68El importe se calcula con las sesiones previstas y reservadas del calendario; los festivos y cierres conocidos ya estan descontados.
69
70${Q}
71
72TOTAL: ${i.toFixed(2)}EUR.${K}
73
74Gracias por confiar en Profe en Casa.`;return{to:t.email,subject:`Recibo mensual por adelantado - ${m} - ${t.name}`,html:X,whatsappText:Be,receiptInfo:t}},xa=async({to:e,subject:r,html:t})=>{const{error:o}=await D.functions.invoke("send-email",{body:{to:e,subject:r,html:t}});if(o)throw o},ba=async()=>{const e=`${T[j-1]} ${L}`,{data:r,error:t}=await D.from("parent_logs").select("student_name, notes").in("topic",[ea,"RECIBO MENSUAL","RESERVA MENSUAL"]);if(t)throw t;const o=new Set;return(r||[]).forEach(i=>{const d=String((i==null?void 0:i.notes)||"");if(d.includes(e)&&(i!=null&&i.student_name)){const m=d.match(/student_id=([^\s;]+)/i);m!=null&&m[1]&&o.add(`student_id=${m[1]}`);const h=d.match(/family_email=([^\s;]+)/i);h!=null&&h[1]&&o.add(`family_email=${h[1].toLowerCase()}`);const w=d.match(/family_phone=([^\s;]+)/i);w!=null&&w[1]&&o.add(`family_phone=${w[1]}`),o.add(`student_name=${me(i.student_name)}`)}}),o},ga=async(e,r)=>{const{error:t}=await D.from("parent_logs").insert([{student_name:e.name,topic:ea,notes:`Recibo mensual por adelantado envi
74ado (${T[j-1]} ${L}) [${r}]; ${be(e)}; destinatario=${e.email}.`,contact_date:new Date().toISOString().split("T")[0],coordinator_id:null}]);if(t)throw new Error(`El correo fue aceptado, pero fallo su registro interno: ${t.message}`)},Ga=async(e,r)=>{const{error:t}=await D.from("parent_logs").insert([{student_name:e.name,topic:Pa,notes:`Recibo mensual por adelantado preparado para compartir por WhatsApp (${T[j-1]} ${L}) [${r}]; ${be(e)}; familia=${e.parent_name||"familia"}.`,contact_date:new Date().toISOString().split("T")[0],coordinator_id:null}]);if(t)throw t},fa=async()=>{const e=await ba(),r={pending:[],alreadySent:[],missingEmail:[],blocked:[]},t=[...P].sort((o,i)=>(o.name||"").localeCompare(i.name||""));for(const o of t){const i=U(o);if(i.some(d=>d.includes("correo familiar"))){r.missingEmail.push(o);continue}if(e.has(be(o))||e.has(`student_name=${me(o.name)}`)){r.alreadySent.push(o);continue}if(i.length>0){r.blocked.push({student:o,reasons:i});continue}r.pending.push({student:o,payload:Te(o)})}return r},Va=async()=>{Je(!0);try{const e=await fa(),r=e.pending.reduce((t,o)=>t+o.payload.receiptInfo.amount,0);alert(`Resumen de recibos del mes:
75
76Pendientes de envio: ${e.pending.length}
77Importe total preparado: ${r.toFixed(2)} EUR
78Ya enviados para ${T[j-1]} ${L}: ${e.alreadySent.length}
79Sin email valido: ${e.missingEmail.length}
80Bloqueados para revision: ${e.blocked.length}`+(e.blocked.length>0?`
81
82Primeros bloqueos:
83- ${e.blocked.slice(0,5).map(t=>`${t.student.name}: ${t.reasons.join(", ")}`).join(`
84- `)}`:""))}catch(e){alert("Error al preparar el resumen de recibos: "+((e==null?void 0:e.message)||"Error desconocido"))}finally{Je(!1)}},Ya=async()=>{Ze(!0);try{const e=await fa();if(e.pending.length===0){alert(`No hay recibos pendientes para enviar ahora mismo.
85
86Ya enviados: ${e.alreadySent.length}
87Sin email valido: ${e.missingEmail.length}
88Bloqueados para revision: ${e.blocked.length}`);return}const r=e.pending.slice(0,6).map(h=>h.student.name).join(", "),t=e.pending.reduce((h,w)=>h+w.payload.receiptInfo.amount,0);if(!window.confirm(`Vas a enviar ${e.pending.length} recibos pendientes de ${T[j-1]} ${L}.
89
90Importe total: ${t.toFixed(2)} EUR
91Ya enviados: ${e.alreadySent.length}
92Sin email valido: ${e.missingEmail.length}
93Bloqueados para revision: ${e.blocked.length}
94
95Primeras familias: ${r}${e.pending.length>6?"...":""}
96
97Continuar con el envio global?`))return;let i=0;const d=[],m=[];for(const h of e.pending){let w=!1;try{await xa({to:h.payload.to,subject:h.payload.subject,html:h.payload.html}),w=!0,await ga(h.payload.receiptInfo,"global"),i+=1}catch($){const z=($==null?void 0:$.message)||"Error desconocido";w?m.push(`${h.student.name}: ${z}`):d.push(`${h.student.name}: ${z}`)}}alert(`Envio global de recibos terminado.
98
99Enviados: ${i}
100Aceptados sin registro interno: ${m.length}
101Fallidos antes del envio: ${d.length}`+(m.length>0?`
102
103No reenvies estos recibos hasta revisar la trazabilidad:
104- ${m.slice(0,5).join(`
105- `)}`:"")+(d.length>0?`
106
107Incidencias:
108- ${d.slice(0,5).join(`
109- `)}`:""))}catch(e){alert("Error al lanzar el envio global de recibos: "+((e==null?void 0:e.message)||"Error desconocido"))}finally{Ze(!1)}},ha=async e=>{try{const r=Te(e,"whatsapp"),t=Sa(r.receiptInfo.phone),o=t?`https://wa.me/${t}?text=${encodeURIComponent(r.whatsappText)}`:`https://wa.me/?text=${encodeURIComponent(r.whatsappText)}`;if(!window.open(o,"_blank")){alert("No se ha podido abrir WhatsApp. Revisa si el navegador ha bloqueado la ventana emergente.");return}await Ga(r.receiptInfo,"individual"),t||alert("El recibo esta preparado, pero la ficha no tiene un telefono valido. Selecciona manualmente la conversacion correcta en WhatsApp.")}catch(r){alert("Error al preparar el recibo por WhatsApp: "+((r==null?void 0:r.message)||"Error desconocido"))}},Ka=async e=>{Ke(!0);let r=!1;try{const t=await ba();if(t.has(be(e))||t.has(`student_name=${me(e.name)}`)){alert("Este alumno ya tiene un recibo mensual registrado para este mes. No se ha enviado de nuevo.");return}const o=Te(e);await xa({to:o.to,subject:o.subject,html:o.html}),r=!0,await ga(o.receiptInfo,"individual"),alert("Recibo enviado correctamente."),je(null)}catch(t){const o=(t==null?void 0:t.message)||"Error desconocido";alert(r?`El correo ha sido aceptado, pero no se ha podido registrar internamente. No lo reenvies hasta revisar la trazabilidad.
110
111${o}`:`Error al enviar el correo: ${o}`)}finally{Ke(!1)}},T=["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];return a.jsxs("div",{className:"max-w-md mx-auto w-full min-h-screen bg-[#F5F7FA] p-6 text-left pb-24 overflow-y-auto font-sans relative",children:[a.jsx("button",{onClick:c,className:"text-gray-500 text-[10px] font-black uppercase mb-4 flex items-center gap-2 no-print hover:text-gray-900 transition-colors",children:"← Volver al Panel"}),a.jsxs("div",{className:"flex justify-between items-center bg-white p-3 rounded-[20px] mb-6 shadow-sm border border-gray-100 no-print",children:[a.jsx("button",{onClick:Ua,className:"w-10 h-10 bg-gray-50 rounded-xl font-black text-gray-500 hover:bg-gray-100 transition-colors active:scale-95",children:"‹"}),a.jsxs("div",{className:"text-center",children:[a.jsx("h2",{className:"text-lg font-black text-gray-900 leading-none",children:T[j-1]}),a.jsx("p",{className:"text-[10px] font-bold text-gray-400 uppercase tracking-widest",children:L})]}),a.jsx("button",{onClick:Wa,className:"w-10 h-10 bg-gray-50 rounded-xl font-black text-gray-500 hover:bg-gray-100 transition-colors active:scale-95",children:"›"})]}),a.jsxs("div",{className:"bg-gradient-to-br from-[#1c74e9] to-blue-900 p-6 rounded-[32px] mb-8 shadow-xl relative overflow-hidden no-print",children:[a.jsxs("div",{className:"flex justify-between items-end relative z-10",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-blue-200 text-[9px] font-black uppercase tracking-widest mb-1",children:"Resultado confirmado"}),a.jsxs("p",{className:"text-white text-4xl font-black",children:[W.profit.toFixed(2),"€"]})]}),a.jsxs("div",{className:"text-right",children:[a.jsxs("p",{className:"text-blue-200 text-[9px] font-bold",children:["Ingresos: ",W.incoming.toFixed(0),"€"]}),a.jsxs("p",{className:"text-blue-200 text-[9px] font-bold",children:["Gastos: ",W.outgoing.toFixed(0),"€"]})]})]}),a.jsxs("div",{className:"mt-4 bg-white/10 backdrop-blur-md rounded-xl p-3 flex justify-between items-center border border-white/10 relative z-10",children:[a.jsx("span",{className:"text-blue-100 text-[10px] font-black uppercase tracking-widest",children:"Volumen de clases"}),a.jsx("span",{className:"bg-white text-[#1c74e9] px-2 py-0.5 rounded text-xs font-black",children:W.totalClasses})]}),a.jsxs("div",{className:"mt-3 bg-white/10 backdrop-blur-md rounded-xl p-3 border border-white/10 relative z-10 space-y-1",children:[a.jsxs("div",{className:"flex justify-between items-center",children:[a.jsx("span",{className:"text-blue-100 text-[10px] font-black uppercase tracking-widest",children:"Previsión programada"}),a.jsx("span",{className:"bg-white text-[#1c74e9] px-2 py-0.5 rounded text-xs font-black",children:W.totalScheduledClasses})]}),a.jsxs("div",{className:"flex justify-between items-center text-[10px] font-bold text-blue-100",children:[a.jsxs("span",{children:["Ingresos previstos: ",W.scheduledIncoming.toFixed(0),"€"]}),a.jsxs("span",{children:["Gastos previstos: ",W.scheduledOutgoing.toFixed(0),"€"]})]}),a.jsxs("p",{className:"text-[10px] font-bold text-white/90",children:["Beneficio previsto si se imparten: ",W.scheduledProfit.toFixed(2),"€"]}),W.totalClasses===0&&W.totalScheduledClasses>0&&a.jsx("p",{className:"text-[10px] leading-relaxed text-blue-100",children:"Todavía no hay clases realizadas este mes. El resultado confirmado sigue a cero, pero los recibos familiares se preparan por adelantado con la programación mensual."})]}),a.jsx("div",{className:"absolute right-[-20px] top-[-20px] text-8xl op
111acity-10 font-black italic text-white",children:"€"})]}),a.jsxs("div",{className:"flex bg-gray-100 p-1 rounded-2xl mb-6 border border-gray-200 no-print",children:[a.jsx("button",{onClick:()=>A("families"),className:`flex-1 py-3 rounded-xl text-[10px] font-black uppercase transition-all ${s==="families"?"bg-white text-[#1c74e9] shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"👨‍👩‍👧 Recibos Familias"}),a.jsx("button",{onClick:()=>A("monitors"),className:`flex-1 py-3 rounded-xl text-[10px] font-black uppercase transition-all ${s==="monitors"?"bg-white text-[#1c74e9] shadow-sm":"text-gray-500 hover:text-gray-700"}`,children:"👨‍🏫 Cierre Profes"})]}),V?a.jsx("p",{className:"text-[#1c74e9] animate-pulse text-center py-10 no-print font-bold",children:"Calculando caja..."}):a.jsx("div",{className:"space-y-4 no-print",children:s==="families"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[a.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-violet-600 text-[10px] font-black uppercase tracking-widest mb-1",children:"Recibos Del Mes"}),a.jsx("h2",{className:"text-gray-900 font-black text-lg leading-tight",children:"Envio global a familias"}),a.jsx("p",{className:"text-gray-500 text-xs mt-2 leading-relaxed",children:"Se calculan por adelantado con las sesiones reservadas del mes. Revisa bloqueos, festivos e importes antes de enviarlos sin repetir los ya registrados."})]}),a.jsx("div",{className:"w-12 h-12 rounded-2xl bg-violet-50 border border-violet-100 flex items-center justify-center text-2xl shrink-0",children:"🧾"})]}),Qe&&a.jsx("p",{className:"mb-4 rounded-2xl border border-red-200 bg-red-50 p-3 text-[10px] font-bold leading-relaxed text-red-700",children:"Envio bloqueado: no se ha podido comprobar el calendario de festivos. Recarga o revisa la conexion antes de preparar recibos."}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx("button",{onClick:Va,disabled:se||oe||V,className:`py-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all ${se||oe||V?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:se?"Calculando...":"Resumen Del Mes"}),a.jsx("button",{onClick:Ya,disabled:se||oe||V,className:`py-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all ${se||oe||V?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-violet-500 text-white shadow-lg shadow-violet-500/20 hover:bg-violet-600"}`,children:oe?"Enviando...":"Enviar Pendientes"})]})]}),a.jsxs("div",{className:"bg-white p-4 rounded-[24px] border border-blue-100 shadow-sm",children:[a.jsx("label",{className:"block text-[9px] font-black text-[#1c74e9] uppercase tracking-widest mb-2",children:"Buscar recibo familiar"}),a.jsxs("div",{className:"flex items-center gap-2 bg-gray-50 border border-gray-200 rounded-2xl px-3 py-2 focus-within:border-[#1c74e9] focus-within:ring-2 focus-within:ring-blue-100 transition-all",children:[a.jsxs("svg",{className:"w-4 h-4 text-blue-500 shrink-0",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[a.jsx("path",{d:"M10.5 18a7.5 7.5 0 1 1 5.3-12.8A7.5 7.5 0 0 1 10.5 18Z",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"m16 16 4.5 4.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),a.jsx("input",{type:"search",value:ce,onChange:e=>Ve(e.target.value),placeholder:"Alumno, familia, email, telefono...",className:"flex-1 bg-transparent outline-none text-sm font-bold text-gray-900 placeholder:text-gray-400"}),ce&&a.jsx("button",{type:"button",onClick:()=>Ve(""),className:"text-[9px] font-black uppercase text-gray-400 hover:text-red-500",children:"Limpiar"})]}),a.jsxs("p",{className:"text-[10px] text-gray-400 font-bold mt-2",children:[Ae.length," de ",P.length," recibo(s) visibles."]})]}),P.length===0?a.jsxs("div",{className:"text-center bg-white p-8 rounded-[32px] border border-gray-100 shadow-sm",children:[a.jsx("span",{className:"text-4xl block mb-2",children:"🏖️"}),a.jsxs("p",{className:"text-gray-900 font-bold text-sm",children:["Sin clases en ",T[j-1]]}),a.jsx("p",{className:"text-gray-400 text-xs mt-1",children:"Aún no hay sesiones facturables."})]}):Ae.length===0?a.jsxs("div",{className:"text-center bg-white p-8 rounded-[32px] border border-blue-100 shadow-sm",children:[a.jsx("p",{className:"text-gray-900 font-bold text-sm",children:"No encuentro ese recibo"}),a.jsx("p",{className:"text-gray-400 text-xs mt-1",children:"Prueba con nombre del alumno, familia, email o telefono."})]}):Ae.map((e,r)=>{const t=(Number(e.forecastAmount)||0)>0||(Number(e.forecastCount)||0)>0,o=Le(e),i=U(e,"email"),d=U(e,"whatsapp"),m=i.length>0&&d.length>0,h=Number(o.amount||0),w=m?"Revisar":o.allPaid?"Pagado":"Recibo adelantado",$=Se(e);return a.jsxs("div",{className:`bg-white p-5 rounded-[28px] border shadow-sm relative overflow-hidden ${$?"border-green-300 shadow-[0_0_0_2px_rgba(34,197,94,0.12)]":"border-gray-100"}`,children:[a.jsx("div",{className:`absolute top-0 right-0 px-4 py-1.5 rounded-bl-2xl text-[8px] font-black uppercase ${m?"bg-red-100 text-red-700":o.allPaid?"bg-green-100 text-green-600":"bg-blue-100 text-blue-700"}`,children:w}),$&&a.jsx("div",{className:"absolute top-0 left-0 px-4 py-1.5 rounded-br-2xl text-[8px] font-black uppercase bg-green-50 text-green-700 border-r border-b border-green-200",children:"Alumno enfocado"}),a.jsxs("div",{className:`flex justify-between items-start mb-4 ${$?"mt-8":"mt-2"}`,children:[a.jsxs("div",{className:"min-w-0 pr-2",children:[a.jsx("h3",{className:"text-gray-900 font-black text-base truncate mb-1",children:e.name}),a.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[a.jsxs("span",{className:"text-gray-400 text-[9px] font-black tracking-widest uppercase bg-gray-50 px-2 py-1 rounded-lg border border-gray-100",children:[e.completedCount," CLASES"]}),t&&a.jsxs("span",{className:"text-blue-700 text-[9px] font-black tracking-widest uppercase bg-blue-50 px-2 py-1 rounded-lg border border-blue-100",children:[e.forecastCount," PREVISTA(S)"]}),e.absentCount>0&&a.jsxs("span",{className:"text-white text-[9px] font-black tracking-widest uppercase bg-red-500 px-2 py-1 rounded-lg shadow-sm shadow-red-500/30",children:[e.absentCount," FALTAS"]}),e.justifiedAbsentCount>0&&a.jsxs("span",{className:"text-blue-700 text-[9px] font-black tracking-widest uppercase bg-blue-50 px-2 py-1 rounded-lg border border-blue-100",children:[e.justifiedAbsentCount," JUSTIFICADA(S)"]})]})]}),a.jsxs("div",{className:"text-right",children:[a.jsxs("p",{className:`text-2xl font-black leading-none ${m?"text-red-500":o.allPaid?"text-green-600":"text-[#1c74e9]"}`,children:[h.toFixed(2),"EUR"]}),a.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400 mt-1",children:"mes completo previsto"})]})]}),t&&a.jsxs("p",{className:"text-[10px] font-bold text-blue-700 bg-blue-50 border border-blue-100 rounded-xl px-3 py-2 mb-3 leading-relaxed",children:["Incluye ",e.forecastCount," sesion(es) prevista(s) aun no fichada(s), porque el recibo se prepara por adelantado con las plazas reservadas del mes."]}),(Number(e.excludedHolidayCount)||0)>0&&a.jsxs("p",{className:"text-[10px] font-bold text-emerald-700 bg-emerald-50 border border-emerald-100 rounded-xl px-3 py-2 mb-3 leading-relaxed",children:["Se han descontado ",e.excludedHolidayCount," sesion(es) por festivo o cierre conocido."]}),m&&a.jsxs("p",{className:"text-[10px] font-bold text-red-700 bg-red-50 border border-red-100 rounded-xl px-3 py-2 mb-3 leading-relaxed",children:["No se puede enviar: ",Array.from(new Set([...i,...d])).join("; "),"."]}),!m&&i.some(z=>
111z.includes("correo familiar"))&&a.jsx("p",{className:"text-[10px] font-bold text-amber-800 bg-amber-50 border border-amber-200 rounded-xl px-3 py-2 mb-3 leading-relaxed",children:"Correo familiar pendiente. El recibo se puede preparar por WhatsApp."}),a.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-gray-50 gap-2",children:[a.jsx("div",{className:"flex gap-2",children:a.jsx("button",{onClick:()=>je(o),className:"w-10 h-10 bg-white border border-gray-200 text-gray-600 flex items-center justify-center rounded-xl hover:bg-gray-50 transition-colors shadow-sm",title:"Ver recibo adelantado",children:"📄"})}),a.jsx("div",{className:"flex gap-2",children:!o.allPaid&&a.jsxs(a.Fragment,{children:[a.jsx("button",{disabled:d.length>0,onClick:()=>ha(o),className:"w-10 h-10 bg-[#25D366] text-white flex items-center justify-center rounded-xl shadow-lg active:scale-90 transition-transform disabled:opacity-40 disabled:cursor-not-allowed",title:d.length>0?"Corrige primero los datos del recibo":"Preparar recibo para WhatsApp",children:"💬"}),a.jsx("button",{onClick:()=>alert("El registro de pagos adelantados queda pendiente de separar del estado de las clases. No se ha modificado ningun dato."),className:"bg-amber-100 text-amber-800 border border-amber-200 px-3 h-10 rounded-xl text-[9px] font-black uppercase active:scale-95 transition-all",title:"Pendiente del registro de pagos separado",children:"Pago pendiente"})]})})]})]},r)})]}):H.length===0?a.jsxs("div",{className:"text-center bg-white p-8 rounded-[32px] border border-gray-100 shadow-sm",children:[a.jsx("span",{className:"text-4xl block mb-2",children:"🏖️"}),a.jsx("p",{className:"text-gray-900 font-bold text-sm",children:"Sin clases impartidas"}),a.jsxs("p",{className:"text-gray-400 text-xs mt-1",children:["Nadie ha dado clases en ",T[j-1],"."]})]}):H.map((e,r)=>{var z;const t=(Number(e.forecastEarned)||0)>0||(Number(e.forecastCount)||0)>0,o=(Number(e.totalEarned)||0)>0||e.count>0||e.officeHours>0,i=!e.hasPayrollWork&&o&&e.totalPending===0&&!t,d=e.count>0||e.officeHours>0,m=e.hasPayrollWork&&d?"Pendiente de cierre laboral":t?d?"Faltan fichajes":"Prevision sin fichar":i?"Liquidado":d?"Pendiente de Pago":"Sin movimiento",h=Number(d?e.totalEarned||0:e.forecastEarned||0),w=d?"confirmado":t?"prevision":"",$=d?e:{...e,totalEarned:Number(e.forecastEarned||0),classes:e.forecastClasses||[],isForecastReceipt:!0};return a.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-[0_4px_20px_rgba(0,0,0,0.03)] relative overflow-hidden transition-colors",children:[a.jsx("div",{className:`absolute top-0 right-0 px-3 py-1.5 rounded-bl-xl text-[8px] font-black uppercase border-b border-l ${t?"bg-blue-50 text-blue-700 border-blue-100":d?i?"bg-green-50 text-green-600 border-green-100":"bg-orange-50 text-orange-600 border-orange-100":"bg-gray-50 text-gray-500 border-gray-100"}`,children:m}),a.jsx("p",{className:"text-gray-500 text-[10px] font-black uppercase mb-1 mt-2 truncate w-[70%]",children:e.name}),a.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[a.jsx("span",{className:`text-[8px] font-mono px-2 py-1 rounded border ${e.iban?"bg-blue-50 text-blue-700 border-blue-100":"bg-red-50 text-red-600 border-red-100"}`,children:e.iban?"💳 IBAN REGISTRADO":"⚠️ FALTAN DATOS BANCARIOS"}),a.jsx("button",{onClick:()=>{we(e),We(e.dni||""),Ue(e.iban||"")},className:"text-[9px] font-bold text-gray-400 hover:text-[#1c74e9] transition-colors underline",children:"Editar"})]}),a.jsxs("div",{className:"flex justify-between items-end mb-4",children:[a.jsxs("div",{children:[t&&!d&&a.jsxs("p",{className:"font-black text-3xl text-[#1c74e9]",children:[h.toFixed(2),"EUR"]}),!(t&&!d)&&a.jsxs("p",{className:`font-black text-3xl ${i?"text-green-600":"text-gray-900"}`,children:[e.totalEarned.toFixed(2),"€"]}),a.jsxs("p",{className:"text-gray-400 font-bold text-[10px] uppercase tracking-widest mt-1",children:[e.count>0&&`${e.count} sesiones`,e.count>0&&e.officeHours>0&&" | ",e.officeHours>0&&a.jsxs("span",{className:"text-[#1c74e9]",children:[e.officeHours,"h oficina"]}),t&&a.jsxs("span",{className:"text-[#1c74e9]",children:[d?" | ":"",e.forecastCount," pendiente(s) de fichar"]})]}),w&&a.jsx("p",{className:`font-black text-[9px] uppercase tracking-widest mt-1 ${t&&!d?"text-[#1c74e9]":"text-gray-400"}`,children:e.hasPayrollWork?"referencia acordada 9,50 EUR/h":w}),e.hasPayrollWork&&d&&a.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3",children:[a.jsxs("div",{className:"rounded-xl border border-gray-100 bg-gray-50 px-3 py-2",children:[a.jsx("p",{className:"text-[7px] font-black uppercase tracking-widest text-gray-400",children:"Neto nomina est."}),a.jsxs("p",{className:"text-sm font-black text-gray-900 mt-1",children:[Number(e.estimatedPayrollNet||0).toFixed(2)," EUR"]})]}),a.jsxs("div",{className:"rounded-xl border border-orange-100 bg-orange-50 px-3 py-2",children:[a.jsx("p",{className:"text-[7px] font-black uppercase tracking-widest text-orange-500",children:"Coste empresa est."}),a.jsxs("p",{className:"text-sm font-black text-orange-900 mt-1",children:[Number(e.totalCompanyCost||0).toFixed(2)," EUR"]})]}),a.jsxs("p",{className:"col-span-2 text-[9px] font-bold text-amber-800 bg-amber-50 border border-amber-100 rounded-xl px-3 py-2 leading-relaxed",children:[Number(e.payrollHours||0).toFixed(1)," h laborales registradas en el mes.",((z=e.latestLaborControl)==null?void 0:z.resulting_weekly_hours)!=null?` Alta semanal verificada: ${Number(e.latestLaborControl.resulting_weekly_hours).toFixed(1)} h.`:" Alta semanal pendiente de localizar o revisar."," ","Falta conciliar nomina, cotizacion e incidencias antes de registrar cualquier pago."]})]}),t&&a.jsxs("p",{className:"text-[10px] font-bold text-blue-700 bg-blue-50 border border-blue-100 rounded-xl px-3 py-2 mt-3 leading-relaxed",children:[m,". Prevision de pago cuando se completen los fichajes: ",Number(e.forecastEarned||0).toFixed(2)," euros."]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>ve($),className:"w-10 h-10 bg-white border border-gray-200 text-gray-600 flex items-center justify-center rounded-xl hover:bg-gray-50 transition-colors shadow-sm",title:e.hasPayrollWork?"Ver resumen de horas":d?"Ver documento profesional":"Ver prevision",children:"📄"}),e.totalPending>0&&e.hasPayrollWork&&a.jsx("button",{onClick:()=>ve($),className:"bg-amber-500 hover:bg-amber-600 text-white px-4 h-10 rounded-xl text-[9px] font-black uppercase shadow-lg shadow-amber-500/20 active:scale-95 transition-all",children:"Revisar cierre"}),e.totalPending>0&&!e.hasPayrollWork&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>za(e.totalPending,e.count,e.officeHours),className:"w-10 h-10 bg-[#25D366] text-white flex items-center justify-center rounded-xl shadow-lg active:scale-90 transition-transform",title:"Avisar por WhatsApp",children:"💬"}),a.jsx("button",{onClick:()=>Ne(e),className:"bg-orange-500 hover:bg-orange-600 text-white px-5 h-10 rounded-xl text-[10px] font-black uppercase shadow-lg shadow-orange-500/30 active:scale-95 transition-all",children:"Pagar"})]})]})]})]},r)})}),re&&a.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm z-[10000] p-4 flex justify-center items-center no-print",children:a.jsxs("div",{className:"bg-white w-full max-w-sm rounded-[32px] p-6 shadow-2xl animate-in zoom-in-95 duration-200",children:[a.jsxs("div",{className:"flex justify-between items-center mb-4",children:[a.jsx("h3",{className:"text-xl font-black text-gray-900 leading-none",children:"Datos Bancarios"}),a.jsx("button",{onClick:()=>we(null),className:"w-8 h-8 bg-gray-100 rounded-full flex items-center justify-center text-gray-500 hover:bg-gray-200 font-black",children:"✕"})]}),a.jsx("p",{className:"text-[10px] uppercase font-bold text-gray-500 mb-6",children:re.name}),a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1 pl-1",children:"DNI / NIE"}),a.jsx("input",{type:"text",value:Ce,onChange:e=>We(e.target.value.toUpperCase()),placeholder:"Ej: 12345678Z",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-sm font-bold text-gray-900 focus:outline-none focus:border-[#1c74e9] focus:ring-1 focus:ring-[#1c74e9]"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-[9px] font-black text-gray-400 uppercase tracking-widest mb-1 pl-1",children:"IBAN (Cuenta Bancaria)"}),a.jsx("input",{type:"text",value:ke,onChange:e=>Ue(e.target.value.toUpperCase().replace(/\s/g,"")),placeholder:"Ej: ES1234567890123456789012",className:"w-full bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-sm font-bold text-gray-900 focus:outline-none focus:border-[#1c74e9] focus:ring-1 focus:ring-[#1c74e9]"})]})]}),a.jsx("button",{onClick:Da,disabled:Oe,className:"w-full py-4 bg-[#1c74e9] text-white font-black text-[10px] uppercase tracking-widest rounded-xl shadow-lg shadow-blue-500/30 hover:bg-blue-700 active:scale-95 transition-all disabled:opacity-50",children:Oe?"Guardando...":"💾 Guardar Datos"})]})}),O&&a.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm z-[10000] p-4 flex justify-center items-center no-print",children:a.jsxs("div",{className:"bg-white w-full max-w-sm rounded-[32px] p-6 shadow-2xl animate-in zoom-in-95 duration-200",children:[a.jsx("h3",{className:"text-xl font-black text-gray-900 mb-1",children:"Transferencia Bancaria"}),a.jsxs("p",{className:"text-[10px] uppercase font-bold text-gray-500 mb-6",children:["A favor de ",O.name]}),a.jsxs("div",{className:"space-y-3 mb-6",children:[a.jsxs("div",{className:"bg-gray-50 p-3 rounded-xl border border-gray-100 flex justify-between items-center",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-[9px] font-black uppercase text-gray-400",children:"Importe a Transferir"}),a.jsxs("p",{className:"text-lg font-black text-gray-900",children:[O.totalPending.toFixed(2),"€"]})]}),a.jsx("button",{onClick:()=>{navigator.clipboard.writeText(O.totalPending.toFixed(2)),alert("✅ Importe copiado: "+O.totalPending.toFixed(2)+"€")},className:"bg-white px-3 py-2 rounded-lg text-[10px] font-black uppercase border border-gray-200 shadow-sm hover:bg-gray-100 active:scale-95 transition-all",children:"Copiar"})]}),a.jsxs("div",{className:"bg-gray-50 p-3 rounded-xl border border-gray-100 flex justify-between items-center",children:[a.jsxs("div",{className:"w-[60%]",children:[a.jsx("p",{className:"text-[9px] font-black uppercase text-gray-400",children:"Concepto"}),a.jsxs("p",{className:"text-xs font-bold text-gray-900 truncate",children:["Abono ",T[j-1]," ",O.name.split(" ")[0]]})]}),a.jsx("button",{onClick:()=>{const e=`Abono ${T[j-1]} ${O.name.split(" ")[0]}`;navigator.clipboard.writeText(e),alert("✅ Concepto copiado: "+e)},className:"bg-white px-3 py-2 rounded-lg text-[10px] font-black uppercase border border-gray-200 shadow-sm hover:bg-gray-100 active:scale-95 transition-all",children:"Copiar"})]}),a.jsxs("div",{className:"bg-gray-50 p-3 rounded-xl border border-gray-100 flex justify-between items-center",children:[a.jsxs("div",{className:"w-[60%]",children:[a.jsx("p",{className:"text-[9px] font-black uppercase text-gray-400",children:"IBAN Destino"}),a.jsx("p",{className:"text-xs font-bold text-gray-900 truncate",children:O.iban||"No registrado"})]}),a.jsx("button",{disabled:!O.iban,onClick:()=>{navigator.clipboard.writeText(O.iban),alert("✅ IBAN copiado")},className:"bg-white px-3 py-2 rounded-lg text-[10px] font-black uppercase border border-gray-200 shadow-sm hover:bg-gray-100 active:scale-95 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:"Copiar"})]})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>Ne(null),className:"flex-1 py-3 bg-gray-100 text-gray-600 font-black text-[10px] uppercase tracking-widest rounded-xl hover:bg-gray-200 active:scale-95",children:"Cancelar"}),a.jsx("button",{onClick:()=>Ha(O),className:"flex-[2] py-3 bg-green-500 text-white font-black text-[10px] uppercase tracking-widest rounded-xl shadow-lg shadow-green-500/30 hover:bg-green-600 active:scale-95",children:"Confirmar Pago ✅"})]})]})}),M&&a.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm z-[9999] p-4 flex flex-col justify-center items-center overflow-y-auto pt-10 pb-20 no-print",children:a.jsxs("div",{className:"bg-white text-black w-full max-w-sm rounded-[32px] sm:rou
111nded-none shadow-2xl relative overflow-hidden flex flex-col max-h-[90vh]",children:[a.jsx("div",{className:"p-4 bg-gray-50 border-b border-gray-200 flex justify-between items-center no-print shrink-0",children:a.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Vista previa del recibo"})}),a.jsxs("div",{id:"printable-receipt-family",className:"p-8 font-mono overflow-y-auto flex-1",children:[a.jsxs("div",{className:"text-center mb-6 border-b-2 border-black/10 pb-6",children:[a.jsx("h2",{className:"text-2xl font-black uppercase tracking-tighter text-[#1c74e9]",children:"Profe en Casa"}),a.jsxs("p",{className:"text-[10px] font-bold tracking-widest uppercase text-gray-500",children:["Recibo mensual por adelantado - ",T[j-1]," ",L]})]}),a.jsxs("div",{className:"mb-6 text-sm text-gray-800",children:[a.jsxs("p",{className:"font-bold text-gray-900",children:["Alumno: ",a.jsx("span",{className:"text-[#1c74e9]",children:M.name})]}),a.jsxs("div",{className:"mt-4 space-y-2",children:[Y(M.classes||[]).map((e,r)=>a.jsx("div",{className:"flex justify-between items-start border-b border-gray-100 pb-3 gap-3",children:a.jsxs("div",{className:"flex items-start justify-between gap-2 min-w-0 flex-1",children:[a.jsx("span",{className:"text-sm leading-none mt-0.5",style:{color:ue(e.student_status)},children:Ee(e.student_status)}),a.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a.jsxs("span",{className:"text-[10px] text-gray-700 leading-snug break-words",title:e.subject,children:[e.class_date.split("-").reverse().join("/")," - ",e.subject]}),a.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest text-gray-500 mt-1 leading-relaxed break-words",title:xe(e),children:xe(e)}),!1,ae(e)&&a.jsx("span",{className:"text-[8px] font-bold mt-1 leading-relaxed break-words",style:{color:ue(e.student_status)},children:ae(e)}),!1,!1,!1,!1,!1,!1,!1]}),a.jsxs("span",{className:"font-bold text-xs whitespace-nowrap pt-0.5",children:[e.family_price.toFixed(2),"€"]})]})},r)),a.jsxs("div",{className:"mt-4 bg-gray-50 border border-gray-100 rounded-xl p-3 text-[8px] text-gray-500 font-bold leading-relaxed",children:[a.jsx("p",{className:"font-black uppercase tracking-widest text-gray-400 mb-1",children:"Leyenda"}),a.jsxs("p",{children:[a.jsx("span",{style:{color:"#2563eb"},children:"*"})," Sesion prevista y plaza reservada"]}),a.jsxs("p",{children:[a.jsx("span",{style:{color:"#16a34a"},children:"**"})," Falta justificada: se cobra y puede recuperarse si hay hueco"]}),a.jsxs("p",{children:[a.jsx("span",{style:{color:"#dc2626"},children:"***"})," Falta no justificada: se cobra y no es recuperable"]}),a.jsxs("p",{children:[a.jsx("span",{style:{color:"#7c3aed"},children:"****"})," Recuperacion sin segundo cobro"]}),a.jsx("p",{className:"mt-1",children:"Los festivos y cierres conocidos ya estan descontados."})]})]})]}),a.jsxs("div",{className:"flex justify-between items-end pt-4 border-t-2 border-gray-200 mt-4",children:[a.jsx("span",{className:"text-xs font-bold uppercase text-gray-500",children:"Total del mes previsto"}),a.jsxs("span",{className:"text-3xl font-black text-gray-900",children:[M.amount.toFixed(2),"€"]})]}),M.isAdvanceReceipt&&a.jsx("p",{className:"mt-3 text-[10px] font-bold text-blue-700 bg-blue-50 border border-blue-100 rounded-xl p-3 leading-relaxed",children:"Recibo preparado por adelantado con las sesiones reservadas del mes. Los festivos y cierres conocidos ya estan excluidos. Cualquier ajuste posterior debe quedar registrado de forma clara."}),U(M,"email").length>0&&U(M,"whatsapp").length>0&&a.jsxs("p",{className:"mt-3 text-[10px] font-bold text-red-700 bg-red-50 border border-red-100 rounded-xl p-3 leading-relaxed",children:["No se puede enviar: ",Array.from(new Set([...U(M,"email"),...U(M,"whatsapp")])).join("; "),"."]}),U(M,"email").some(e=>e.includes("correo familiar"))&&U(M,"whatsapp").length===0&&a.jsx("p",{className:"mt-3 text-[10px] font-bold text-amber-800 bg-amber-50 border border-amber-200 rounded-xl p-3 leading-relaxed",children:"Falta un correo familiar válido. Puedes compartir este recibo por WhatsApp."})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-3 p-6 bg-gray-50 border-t border-gray-100 no-print w-full max-w-sm shrink-0",children:[a.jsx("button",{onClick:()=>je(null),className:"col-span-2 py-3 bg-gray-200 text-gray-800 font-black uppercase text-[10px] tracking-widest rounded-xl hover:bg-gray-300 transition-colors",children:"Cerrar Visor"}),a.jsxs("button",{onClick:()=>ha(M),disabled:U(M,"whatsapp").length>0,className:"py-3 bg-[#25D366] text-white font-black uppercase text-[10px] tracking-widest rounded-xl shadow-lg shadow-green-500/30 active:scale-95 transition-transform flex justify-center items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:[a.jsx("span",{children:"💬"})," WhatsApp"]}),a.jsxs("button",{onClick:()=>ua("printable-receipt-family",M.name),className:"py-4 bg-[#1c74e9] text-white font-black uppercase text-[10px] tracking-widest rounded-xl shadow-lg shadow-blue-500/30 active:scale-95 transition-transform flex justify-center items-center gap-2",children:[a.jsx("span",{children:"🖨️"})," Imprimir"]}),a.jsx("button",{onClick:()=>Ka(M),disabled:Ye||U(M).length>0,className:"py-4 bg-emerald-500 text-white font-black uppercase text-[10px] tracking-widest rounded-xl shadow-lg shadow-emerald-500/30 active:scale-95 transition-transform flex justify-center items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:Ye?"Enviando...":a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"📧"}
111)," Enviar"]})})]})]})}),S&&a.jsx("div",{className:"fixed inset-0 bg-gray-900/60 backdrop-blur-sm z-[9999] p-4 flex flex-col justify-center items-center pt-10 pb-20 no-print",children:a.jsxs("div",{className:"bg-white text-black w-full max-w-sm rounded-[32px] sm:rounded-none shadow-2xl relative flex flex-col max-h-[90vh]",children:[a.jsxs("div",{id:"printable-receipt-monitor",className:"p-8 font-sans text-xs overflow-y-auto flex-1",children:[a.jsxs("div",{className:"text-center mb-8 border-b-2 border-black/10 pb-4",children:[a.jsx("h2",{className:"text-lg font-black uppercase tracking-tight text-gray-900",children:S.hasPayrollWork?"Resumen mensual de horas":"Documento de colaboracion profesional"}),a.jsxs("p",{className:"text-[10px] uppercase text-gray-500 mt-1",children:["Mes de devengo: ",T[j-1]," ",L]})]}),a.jsxs("div",{className:"flex justify-between items-start mb-6 gap-4",children:[a.jsxs("div",{className:"flex-1 bg-gray-50 p-3 rounded-lg border border-gray-100",children:[a.jsx("p",{className:"font-bold text-[8px] text-gray-400 uppercase tracking-widest mb-1",children:S.hasPayrollWork?"Persona trabajadora:":"Profesional:"}),a.jsx("p",{className:"font-black text-gray-900 text-[11px] uppercase",children:S.name}),a.jsxs("p",{className:"text-[10px] text-gray-600",children:["DNI/NIE: ",S.dni||"Pendiente"]}),a.jsx("p",{className:"text-[10px] text-gray-600 truncate",children:S.email})]}),a.jsxs("div",{className:"flex-1 p-3",children:[a.jsx("p",{className:"font-bold text-[8px] text-gray-400 uppercase tracking-widest mb-1",children:S.hasPayrollWork?"Empresa:":"Cliente:"}),a.jsx("p",{className:"font-black text-[#1c74e9] text-[11px] uppercase tracking-tighter",children:"Profe en Casa"}),a.jsx("p",{className:"text-[10px] text-gray-600",children:"Academia de Refuerzo"})]})]}),a.jsx("div",{className:"mb-6 text-[10px] text-gray-700 leading-relaxed text-justify",children:S.hasPayrollWork?"Resumen interno de las sesiones y horas registradas. Sirve para revisar la jornada y preparar el cierre laboral; no sustituye la nomina oficial ni acredita un pago.":"Resumen de los servicios profesionales registrados durante el periodo indicado. La factura o justificante fiscal correspondiente debe conservarse por separado."}),a.jsxs("div",{className:"mb-6 space-y-2",children:[a.jsx("p",{className:"font-bold text-[9px] text-gray-400 uppercase tracking-widest border-b border-gray-200 pb-1 mb-2",children:S.hasPayrollWork?"Desglose de horas:":"Desglose de servicios:"}),Y(S.classes||[]).map((e,r)=>a.jsxs("div",{className:"flex justify-between items-start border-b border-gray-50 pb-2 text-[10px] gap-3",children:[a.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[a.jsxs("span",{className:"text-gray-800 leading-snug break-words",title:e.subject,children:[e.class_date.split("-").reverse().join("/")," - ",e.subject]}),a.jsx("span",{className:"text-[8.5px] font-bold text-blue-700 leading-relaxed break-words",title:ca(e),children:ca(e)})]}),a.jsxs("span",{className:"font-bold whitespace-nowrap",children:[Number(e.monitor_price).toFixed(2),"€"]})]},r))]}),a.jsxs("div",{className:"pt-4 border-t-2 border-gray-200 mt-4 mb-8",children:[a.jsxs("div",{className:"flex justify-between items-end mb-3",children:[a.jsx("span",{className:"text-xs font-bold uppercase text-gray-500",children:S.hasPayrollWork?"Referencia acordada:":"Total profesional:"}),a.jsxs("span",{className:"text-2xl font-black text-gray-900",children:[S.totalEarned.toFixed(2),"€"]})]}),S.hasPayrollWork?a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{className:"bg-gray-50 p-2 rounded border border-gray-100",children:[a.jsx("p",{className:"text-[8px] font-black uppercase text-gray-400",children:"Neto nomina estimado"}),a.jsxs("p",{className:"text-sm font-black text-gray-900 mt-1",children:[Number(S.estimatedPayrollNet||0).toFixed(2)," EUR"]})]}),a.jsxs("div",{className:"bg-gray-50 p-2 rounded border border-gray-100",children:[a.jsx("p",{className:"text-[8px] font-black uppercase text-gray-400",children:"Bruto estimado"}),a.jsxs("p",{className:"text-sm font-black text-gray-900 mt-1",children:[Number(S.estimatedGross||0).toFixed(2)," EUR"]})]}),a.jsxs("div",{className:"bg-orange-50 p-2 rounded border border-orange-100",children:[a.jsx("p",{className:"text-[8px] font-black uppercase text-orange-500",children:"SS empresa estimada"}),a.jsxs("p",{className:"text-sm font-black text-orange-900 mt-1",children:[Number(S.companySocialSecurity||0).toFixed(2)," EUR"]})]}),a.jsxs("div",{className:"bg-orange-50 p-2 rounded border border-orange-100",children:[a.jsx("p",{className:"text-[8px] font-black uppercase text-orange-500",children:"Coste empresa estimado"}),a.jsxs("p",{className:"text-sm font-black text-orange-900 mt-1",children:[Number(S.totalCompanyCost||0).toFixed(2)," EUR"]})]}),a.jsx("p",{className:"col-span-2 bg-amber-50 p-2 rounded text-[9px] text-amber-900 border border-amber-100 font-bold leading-relaxed",children:"Pendiente de conciliar con la nomina oficial. El efectivo, si se utilizara como medio de pago, tambien requeriria nomina, justificante y registro contable; nunca compensa cobros familiares fuera del circuito."})]}):a.jsxs("div",{className:"bg-blue-50 p-2 rounded text-[9px] text-blue-800 border border-blue-100 flex items-center gap-2",children:[a.jsx("span",{className:"font-black uppercase",children:"IBAN:"}),a.jsx("span",{className:"font-mono font-bold tracking-wider",children:S.iban||"Pendiente de facilitar"})]})]}),a.jsx("div",{className:"mt-8 text-gray-500 text-[9px] text-justify pt-4 border-t border-gray-100 leading-relaxed",children:S.hasPayrollWork?"Documento informativo para el cierre mensual. No es una factura, un recibo salarial, una nomina ni una confirmacion de pago.":"Documento informativo de apoyo. No sustituye la factura profesional ni confirma por si solo que el pago se haya realizado."})]}),a.jsxs("div",{className:"grid grid-cols-1 gap-3 p-6 bg-gray-50 border-t border-gray-100 no-print w-full shrink-0",children:[a.jsxs("button",{onClick:()=>ua("printable-receipt-monitor",S.name),className:"py-4 bg-[#1c74e9] text-white font-black uppercase text-[10px] tracking-widest rounded-xl shadow-lg active:scale-95 transition-transform flex justify-center items-center gap-2",children:[a.jsx("span",{children:"🖨️"}
111)," ",S.hasPayrollWork?"Imprimir resumen":"Imprimir documento"]}),a.jsx("button",{onClick:()=>ve(null),className:"py-3 bg-gray-200 text-gray-800 font-black uppercase text-[10px] tracking-widest rounded-xl hover:bg-gray-300 transition-colors",children:"Cerrar Visor"})]})]})})]})};export{ht as AdminBilling};

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.