CTC Calculator

CTC Bifurcation Calculator body { font-family: Arial, sans-serif; padding: 20px; background: #f5f5f5; } h1 { text-align: center; color: #2c3e50; } .container { max-width: 800px; margin: auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0,0,0,0.1); } label { font-weight: bold; display: block; margin-top: 15px; } input { width: 100%; padding: 10px; margin-top: 5px; margin-bottom: 15px; border: 1px solid #ccc; border-radius: 4px; } button { padding: 10px 20px; background: #2c3e50; color: #fff; border: none; border-radius: 4px; cursor: pointer; margin-right: 10px; } table { width: 100%; border-collapse: collapse; margin-top: 20px; } th, td { padding: 10px; border: 1px solid #ddd; text-align: left; } th { background: #2c3e50; color: white; } .highlight { background-color: #2c3e50; color: white; font-weight: bold; } .error { color: red; font-weight: bold; text-align: center; margin-top: 10px; }

CTC Bifurcation Calculator

function calculateCTC() { const ctc = parseFloat(document.getElementById('ctc').value); const basicPercent = parseFloat(document.getElementById('basicPercent').value); const hraPercent = parseFloat(document.getElementById('hraPercent').value); const pfPercent = parseFloat(document.getElementById('pfPercent').value); const bonus = parseFloat(document.getElementById('bonus').value); const flexi = parseFloat(document.getElementById('flexi').value); const taxAmount = parseFloat(document.getElementById('taxAmount').value); const pt = parseFloat(document.getElementById('ptAmount').value); const errorDiv = document.getElementById('error'); errorDiv.textContent = ""; if (isNaN(ctc) || ctc <= 0) { errorDiv.textContent = "Please enter a valid CTC."; return; } const basic = (basicPercent / 100) * ctc; const hra = (hraPercent / 100) * basic; const employeePF = (pfPercent / 100) * basic; const employerPF = employeePF; let employeeESIC = 0; let employerESIC = 0; const gross = basic + hra + flexi + bonus; if ((gross / 12) < 21001) { employeeESIC = 0.0075 * gross; employerESIC = 0.0325 * gross; } const specialAllowance = ctc - (basic + hra + bonus + flexi + employerPF + employerESIC); if (specialAllowance < 0) { errorDiv.textContent = "Special Allowance cannot be negative. Adjust your inputs."; document.getElementById('result').innerHTML = ""; return; } const finalGross = basic + hra + bonus + flexi + specialAllowance; const totalCTC = finalGross + employerPF + employerESIC; const totalDeductions = employeePF + employeeESIC + pt + taxAmount; const netSalary = finalGross - totalDeductions; const resultTable = `
ComponentAnnual (₹)Monthly (₹)
Total CTC₹${ctc.toFixed(2)}₹${(ctc / 12).toFixed(2)}
Basic₹${basic.toFixed(2)}₹${(basic / 12).toFixed(2)}
HRA₹${hra.toFixed(2)}₹${(hra / 12).toFixed(2)}
Bonus₹${bonus.toFixed(2)}₹${(bonus / 12).toFixed(2)}
Flexi Pay₹${flexi.toFixed(2)}₹${(flexi / 12).toFixed(2)}
Special Allowance₹${specialAllowance.toFixed(2)}₹${(specialAllowance / 12).toFixed(2)}
Gross Salary₹${finalGross.toFixed(2)}₹${(finalGross / 12).toFixed(2)}
Employer PF₹${employerPF.toFixed(2)}₹${(employerPF / 12).toFixed(2)}
Employer ESIC₹${employerESIC.toFixed(2)}₹${(employerESIC / 12).toFixed(2)}
Total CTC (Recalculated)₹${totalCTC.toFixed(2)}₹${(totalCTC / 12).toFixed(2)}
Employee PF₹${employeePF.toFixed(2)}₹${(employeePF / 12).toFixed(2)}
Employee ESIC₹${employeeESIC.toFixed(2)}₹${(employeeESIC / 12).toFixed(2)}
Professional Tax (PT)₹${pt.toFixed(2)}₹${(pt / 12).toFixed(2)}
Tax Amount₹${taxAmount.toFixed(2)}₹${(taxAmount / 12).toFixed(2)}
Net Salary₹${netSalary.toFixed(2)}₹${(netSalary / 12).toFixed(2)}
`; document.getElementById('result').innerHTML = resultTable; } function downloadExcel() { const resultTable = document.querySelector('#result table'); if (!resultTable) { alert("Please calculate the CTC first."); return; } const wb = XLSX.utils.book_new(); const ws = XLSX.utils.table_to_sheet(resultTable); XLSX.utils.book_append_sheet(wb, ws, "CTC Calculation"); XLSX.writeFile(wb, "CTC_Bifurcation.xlsx"); }