(function(){ // ——— TABELAS ANUAIS IRPF ——— // DIRPF 2026 (exercicio 2026, ano-calendario 2025) // Fonte: gov.br/receitafederal — Tributacao de 2025 var T26={ f:[ {ate:28467.20,a:0,d:0}, {ate:33919.80,a:.075,d:2135.04}, {ate:45012.60,a:.15,d:4679.03}, {ate:55976.16,a:.225,d:8054.97}, {ate:1e15,a:.275,d:10853.78} ], ds:16754.34, dd:2275.08, red:false }; // DIRPF 2027 (exercicio 2027, ano-calendario 2026) // Fonte: gov.br/receitafederal — Tributacao de 2026 // Inclui reducao Lei 15.270/2025 var T27={ f:[ {ate:29145.60,a:0,d:0}, {ate:33919.80,a:.075,d:2185.92}, {ate:45012.60,a:.15,d:4729.91}, {ate:55976.16,a:.225,d:8105.85}, {ate:1e15,a:.275,d:10904.66} ], ds:17640.00, dd:2275.08, red:true, rLi:60000, rLr:88200 }; var ndep=0,anoDecSel=0; function getTab(){return anoDecSel>=2027?T27:T26} // ——— ROTACAO DE ANOS ——— function buildYearOptions(){ var c=document.getElementById('sim-year-row'); if(!c)return; var cy=new Date().getFullYear(); if(anoDecSel===0)anoDecSel=cy; c.innerHTML=''; [cy,cy+1].forEach(function(ano){ var b=document.createElement('button'); b.className='sim-year-btn'+(anoDecSel===ano?' active':''); b.innerHTML= ''+ano+''+ 'renda de '+(ano-1)+''+ (ano===cy?'declara\u00e7\u00e3o atual':''); b.onclick=function(){ anoDecSel=ano; c.querySelectorAll('.sim-year-btn').forEach(function(x){x.classList.remove('active')}); b.classList.add('active'); }; c.appendChild(b); }); } // ——— CALCULO ——— function calcTab(base,t){ if(base<=0)return 0; for(var i=0;i1?p[1].substring(0,2):null; var f=parseInt(ip||'0').toLocaleString('pt-BR'); if(dp!==null)f+=','+dp; el.value=f; var diff=el.value.length-len0; el.setSelectionRange(pos+diff,pos+diff); }; window.simFocusRaw=function(el){ var v=el.value.replace(/\./g,'').replace(',','.'); el.value=(v==='0'||v==='0.00'||v==='')?'':v; setTimeout(function(){el.select()},0); }; window.simBlur=function(el){ var v=el.value.replace(/\./g,'').replace(',','.'); var n=parseFloat(v); if(isNaN(n)||v==='')el.value=''; else el.value=n.toLocaleString('pt-BR',{minimumFractionDigits:2,maximumFractionDigits:2}); }; function gVal(){ var v=document.getElementById('sim-valor').value.replace(/\./g,'').replace(',','.'); return parseFloat(v)||0; } // ——— CALCULAR ——— window.simCalc=function(){ var rm=gVal(); if(rm<=0){alert('Informe a renda mensal para continuar.');return} var t=getTab(); var ra=rm*12; // Desconto simplificado: 20% da renda anual, limitado ao teto do ano var ds=Math.min(ra*0.20,t.ds); // Deducao por dependentes (anual) var dd=ndep*t.dd; // Base de calculo anual var ba=Math.max(0,ra-ds-dd); // Imposto pela tabela progressiva anual var impTab=calcTab(ba,t); // Reducao Lei 15.270/2025 (DIRPF 2027+) var red=0; if(t.red){ if(ra<=t.rLi){ red=impTab; } else if(ra<=t.rLr){ var fator=(t.rLr-ra)/(t.rLr-t.rLi); red=Math.max(0,impTab*fator); } } var imp=Math.max(0,Math.round((impTab-red)*100)/100); var isento=(imp===0); var ef=ra>0?imp/ra:0; // Faixa nominal var fn,fc; if(ba<=t.f[0].ate){fn='Isento';fc='faixa-isento'} else if(ba<=t.f[1].ate){fn='7,5%';fc='faixa-7'} else if(ba<=t.f[2].ate){fn='15%';fc='faixa-15'} else if(ba<=t.f[3].ate){fn='22,5%';fc='faixa-22'} else{fn='27,5%';fc='faixa-27'} if(isento){ fc='faixa-isento'; if(ba<=t.f[0].ate)fn='Isento (tabela)'; else if(t.red)fn='Isento (Lei 15.270/2025)'; } // Motivo isencao var mi=''; if(isento){ if(ba<=t.f[0].ate){ mi='Base de c\u00e1lculo abaixo do limite de isen\u00e7\u00e3o da tabela progressiva.'; } else if(t.red){ mi='Redu\u00e7\u00e3o da Lei 15.270/2025 \u2014 rendimentos at\u00e9 R$ 5.000/m\u00eas resultam em imposto zero.'; } } // Parcelamento var ph=''; if(!isento){ var mp=Math.min(8,Math.floor(imp/50)); if(mp<1)mp=1; if(imp<100){ ph='

Pagamento em cota \u00fanica — vencimento 30/04/'+anoDecSel+'

'; } else if(mp>1){ ph='

Pode parcelar em at\u00e9 '+mp+'x de '+fmt(imp/mp)+' via d\u00e9bito em conta
1\u00aa cota at\u00e9 30/04/'+anoDecSel+'

'; } else { ph='

Pagamento em cota \u00fanica — vencimento 30/04/'+anoDecSel+'

'; } } // ——— RENDERIZA ——— var hi=document.getElementById('sim-hero-imposto'); var he=document.getElementById('sim-hero-isento'); if(hi)hi.style.display=isento?'none':'block'; if(he)he.style.display=isento?'block':'none'; if(!isento){ var vn=document.getElementById('sim-val-num'); if(vn)vn.textContent=fmt(imp).replace('R$ ',''); var pb=document.getElementById('sim-parcelas-box'); if(pb)pb.innerHTML=ph; } var im=document.getElementById('sim-isencao-motivo'); if(im)im.textContent=mi; function s(id,v){var e=document.getElementById(id);if(e)e.textContent=v} function sh(id,v){var e=document.getElementById(id);if(e)e.innerHTML=v} s('sim-r-bruto',fmt(ra)); s('sim-r-desc','- '+fmt(ds)); var rd=document.getElementById('sim-row-dep'); if(rd)rd.style.display=ndep>0?'flex':'none'; s('sim-r-dep','- '+fmt(dd)+' ('+ndep+' dep.)'); s('sim-r-base',fmt(ba)); sh('sim-r-faixa',''+fn+''); s('sim-r-imposto',fmt(imp)); s('sim-r-efetiva',isento?'0,00%':pct(ef)); s('sim-r-mensal',fmt(imp/12)+'/m\u00eas'); var re=document.getElementById('sim-result'); if(re)re.style.display='block'; setTimeout(function(){ var r=document.getElementById('sim-result'); if(r)r.scrollIntoView({behavior:'smooth',block:'start'}); },100); }; // ——— INIT ——— function init(){buildYearOptions()} if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init)} else{init()} })();