1(function(){ 2 'use strict'; 3 4 function money(value){ 5 var n = Number.isFinite(value) ? value : 0; 6 return n.toLocaleString('pt-BR', {style:'currency', currency:'BRL'}); 7 } 8 9 function num(id){ 10 var el = document.getElementById(id); 11 if(!el) return 0; 12 var raw = String(el.value || '0').replace(',', '.'); 13 var value = parseFloat(raw); 14 return Number.isFinite(value) ? value : 0; 15 } 16 17 function checked(id){ 18 var el = document.getElementById(id); 19 return !!(el && el.checked); 20 } 21 22 function setResult(scope, key, text){ 23 var el = scope.querySelector('[data-key="' + key + '"]'); 24 if(el) el.textContent = text; 25 } 26 27 function percent(value){ return value / 100; } 28 29 function calc1(){ 30 var result = document.querySelector('[data-ora-results="calc1"]'); 31 if(!result) return; 32 var base = num('calc1_base'); 33 var hoursBase = Math.max(num('calc1_hours_base'), 1); 34 var benefits = num('calc1_benefits'); 35 var tax = percent(num('calc1_tax')); 36 var accounting = num('calc1_accounting'); 37 var risk = percent(num('calc1_risk')); 38 var fgts = percent(num('calc1_fgts')); 39 var vac13 = percent(num('calc1_vac13')); 40 var social = percent(num('calc1_social')); 41 var hoursReal = Math.max(num('calc1_hours_real'), 0); 42 var overtimeHours = Math.max(num('calc1_overtime_hours'), 0); 43 var standbyHours = Math.max(num('calc1_standby_hours'), 0); 44 var overtimePercent = percent(num('calc1_overtime_percent')); 45 var nightPercent = percent(num('calc1_night_percent')); 46 var offer = num('calc1_pj_offer'); 47 48 var hourValue = base / hoursBase; 49 var rightsCost = base * (fgts + vac13 + social); 50 var regularCost = base + rightsCost + benefits; 51 var overtimeCost = overtimeHours * hourValue * (1 + overtimePercent); 52 var standbyCost = standbyHours * hourValue * 0.3333; 53 var nightCost = hoursReal * hourValue * nightPercent; 54 var subtotal = regularCost + overtimeCost + standbyCost + nightCost + accounting; 55 var riskCost = subtotal * risk; 56 var beforeTax = subtotal + riskCost; 57 var pjMin = tax >= 0.95 ? beforeTax : beforeTax / (1 - tax); 58 var diff = offer > 0 ? (offer - pjMin) : 0; 59 60 setResult(result, 'base', money(base)); 61 setResult(result, 'hour', money(hourValue)); 62 setResult(result, 'regular', money(regularCost)); 63 setResult(result, 'pjmin', money(pjMin)); 64 setResult(result, 'diff', offer > 0 ? money(diff) : 'Informe o PJ oferecido para comparar'); 65 66 var alert = 'PJ mÃnimo calculado como estimativa de proteção contra redução de direitos.'; 67 if(offer > 0 && offer < pjMin){ 68 alert = 'Alerta: o PJ oferecido está abaixo do PJ mÃnimo estimado sem reduzir direitos.'; 69 } else if(offer > 0) { 70 alert = 'O PJ oferecido fica acima ou igual ao mÃnimo estimado, mas ainda exige análise do caso concreto.'; 71 } 72 setResult(result, 'alert', alert); 73 74 var memory = 'Base ' + money(base) + ' + direitos/encargos estimados ' + money(rightsCost) + ' + benefÃcios ' + money(benefits) + ' + horas extras ' + money(overtimeCost) + ' + sobreaviso/acionamento ' + money(standbyCost) + ' + adicional noturno estimado ' + money(nightCost) + ' + contador/custos PJ ' + money(accounting) + ' + reserva de risco ' + money(riskCost) + ' e ajuste de imposto PJ de ' + (tax*100).toFixed(2).replace('.', ',') + '%.'; 75 setResult(result, 'memory', memory); 76 } 77 78 function calc2(){ 79 var result = document.querySelector('[data-ora-results="calc2"]'); 80 if(!result) return; 81 var offer = num('calc2_pj_offer'); 82 var tax = percent(num('calc2_tax')); 83 var accounting = num('calc2_accounting'); 84 var benefits = num('calc2_benefits'); 85 var risk = percent(num('calc2_risk')); 86 var hoursBase = Math.max(num('calc2_hours_base'), 1); 87 var hoursReal = Math.max(num('calc2_hours_real'), 0); 88 var overtimeHours = Math.max(num('calc2_overtime_hours'), 0); 89 var standbyHours = Math.max(num('calc2_standby_hours'), 0); 90 var wrapHours = Math.max(num('calc2_wrap_hours'), 0); 91 var overtimePercent = percent(num('calc2_overtime_percent')); 92 var nightPercent = percent(num('calc2_night_percent')); 93 94 var taxCost = offer * tax; 95 var riskCost = offer * risk; 96 var assumedCosts = taxCost + accounting + benefits + riskCost; 97 var net = Math.max(offer - assumedCosts, 0); 98 99 var rightsFactor = 1 + 0.08 + 0.1944 + 0.20; 100 var cltEquivalent = net / rightsFactor; 101 var hourEquivalent = cltEquivalent / hoursBase; 102 var unpaidHours = overtimeHours + standbyHours + wrapHours + Math.max(hoursReal - hoursBase, 0); 103 var hoursLoss = (overtimeHours + wrapHours) * hourEquivalent * (1 + overtimePercent) + standbyHours * hourEquivalent * 0.3333 + hoursReal * hourEquivalent * nightPercent; 104 var rightsLoss = Math.max(net - cltEquivalent, 0); 105 106 setResult(result, 'offer', money(offer)); 107 setResult(result, 'costs', money(assumedCosts)); 108 setResult(result, 'net', money(net)); 109 setResult(result, 'equiv', money(cltEquivalent)); 110 setResult(result, 'rights', money(rightsLoss)); 111 setResult(result, 'hoursloss', money(hoursLoss)); 112 113 var risks = []; 114 if(checked('calc2_subordination')) risks.push('subordinação/chefia'); 115 if(checked('calc2_schedule')) risks.push('jornada/escala/controle de horário'); 116 if(checked('calc2_exclusivity')) risks.push('exclusividade prática ou dependência econômica'); 117 if(checked('calc2_rest')) risks.push('descanso ou interjornada insuficiente'); 118 if(unpaidHours > 0) risks.push('tempo de trabalho não pago'); 119 120 var alert = 'CLT equivalente estimado a partir do valor PJ informado.'; 121 if(risks.length){ 122 alert = 'Atenção: há indÃcios que exigem análise cuidadosa: ' + risks.join(', ') + '. O ORA aponta perguntas e padrões, não dá sentença sobre caso concreto.'; 123 } 124 setResult(result, 'alert', alert); 125 } 126 127 function toggleCalculadoras(button){ 128 var wrap = button.closest('[data-ora-calculadoras]'); 129 if(!wrap) return; 130 var body = wrap.querySelector('.ora-calc-body'); 131 if(!body) return; 132 var opening = body.hasAttribute('hidden'); 133 if(opening){ 134 body.removeAttribute('hidden'); 135 wrap.classList.remove('ora-calc-collapsed'); 136 button.setAttribute('aria-expanded', 'true'); 137 button.textContent = 'Ocultar calculadoras'; 138 calc1(); 139 calc2(); 140 } else { 141 body.setAttribute('hidden', 'hidden'); 142 wrap.classList.add('ora-calc-collapsed'); 143 button.setAttribute('aria-expanded', 'false'); 144 button.textContent = 'Abrir calculadoras'; 145 } 146 } 147 148 document.addEventListener('click', function(ev){ 149 var target = ev.target.closest('[data-ora-action]'); 150 if(!target) return; 151 ev.preventDefault(); 152 if(target.getAttribute('data-ora-action') === 'toggle-calculadoras') toggleCalculadoras(target); 153 if(target.getAttribute('data-ora-action') === 'calc1') calc1(); 154 if(target.getAttribute('data-ora-action') === 'calc2') calc2(); 155 }); 156 157 document.addEventListener('DOMContentLoaded', function(){ 158 if(document.querySelector('[data-ora-results="calc1"]')) calc1(); 159 if(document.querySelector('[data-ora-results="calc2"]')) calc2(); 160 }); 161})();
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.