year check valid or not All form commit
This commit is contained in:
@@ -1,15 +1,5 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
// All fields that must trigger calculation
|
||||
const fields = [
|
||||
"gross_total_income", "disallowance_14a", "disallowance_37",
|
||||
"deduction_80ia_business", "deduction_sec37_disallowance", "deduction_80g",
|
||||
"net_taxable_income", "tax_30_percent", "tax_book_profit_18_5",
|
||||
"surcharge_12", "edu_cess_3", "total_tax_payable", "mat_credit",
|
||||
"interest_234c", "total_tax", "advance_tax", "tds", "tcs",
|
||||
"tax_on_assessment", "refund"
|
||||
];
|
||||
|
||||
function getVal(id) {
|
||||
return parseFloat(document.getElementsByName(id)[0].value) || 0;
|
||||
}
|
||||
@@ -18,23 +8,22 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementsByName(id)[0].value = Number(value).toFixed(2);
|
||||
}
|
||||
|
||||
function calculate() {
|
||||
window.calculate = function () {
|
||||
|
||||
// 1️ Base Values
|
||||
// Base Values
|
||||
let gross_total_income = getVal("gross_total_income");
|
||||
let disallowance_14a = getVal("disallowance_14a");
|
||||
let disallowance_37 = getVal("disallowance_37");
|
||||
|
||||
// 2️ Deductions
|
||||
// Deductions
|
||||
let d80_business = getVal("deduction_80ia_business");
|
||||
let deduction_sec37 = getVal("deduction_sec37_disallowance");
|
||||
let deduction_80g = getVal("deduction_80g");
|
||||
|
||||
// 3️ Formula: TOTAL DEDUCTION
|
||||
// Total Deduction
|
||||
let total_deductions = d80_business + deduction_sec37;
|
||||
// (deduction_80ia_business + deduction_sec37_disallowance)
|
||||
|
||||
// 4️ Net Taxable Income
|
||||
// Net Taxable Income
|
||||
let net_taxable_income =
|
||||
(gross_total_income + disallowance_14a + disallowance_37)
|
||||
- total_deductions
|
||||
@@ -42,35 +31,30 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
setVal("net_taxable_income", net_taxable_income);
|
||||
|
||||
// 5️ Tax @ 30%
|
||||
// Tax @ 30%
|
||||
let tax_30_percent = net_taxable_income * 0.30;
|
||||
setVal("tax_30_percent", tax_30_percent);
|
||||
|
||||
// 6️ Book Profit – Tax Payable
|
||||
let tax_payable = getVal("tax_book_profit_18_5");
|
||||
// (tax_payable = tax_book_profit_18_5)
|
||||
|
||||
// 7️ Surcharge
|
||||
// Surcharge @ 12%
|
||||
let surcharge_12 = tax_30_percent * 0.12;
|
||||
setVal("surcharge_12", surcharge_12);
|
||||
|
||||
// 8️ Education Cess
|
||||
// Education Cess @ 3%
|
||||
let edu_cess_3 = (tax_30_percent + surcharge_12) * 0.03;
|
||||
setVal("edu_cess_3", edu_cess_3);
|
||||
|
||||
// 9️ Total Tax Payable
|
||||
// Total Tax Payable
|
||||
let total_tax_payable = tax_30_percent + surcharge_12 + edu_cess_3;
|
||||
setVal("total_tax_payable", total_tax_payable);
|
||||
|
||||
// MAT Credit & Interest
|
||||
// MAT, Interest
|
||||
let mat_credit = getVal("mat_credit");
|
||||
let interest_234c = getVal("interest_234c");
|
||||
|
||||
// 1️1️ Total Tax
|
||||
let total_tax = total_tax_payable + mat_credit + interest_234c;
|
||||
setVal("total_tax", total_tax);
|
||||
|
||||
// 1️2️ Assessment side – Advance Tax, TDS, TCS
|
||||
// Advance, TDS, TCS
|
||||
let advance_tax = getVal("advance_tax");
|
||||
let tds = getVal("tds");
|
||||
let tcs = getVal("tcs");
|
||||
@@ -78,16 +62,8 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
let tax_on_assessment = advance_tax + tds + tcs;
|
||||
setVal("tax_on_assessment", tax_on_assessment);
|
||||
|
||||
// 1️3️ Refund / Payable
|
||||
// Refund / Payablesss
|
||||
let refund = total_tax - tax_on_assessment;
|
||||
setVal("refund", refund);
|
||||
}
|
||||
|
||||
// Attach input listeners
|
||||
fields.forEach(id => {
|
||||
let input = document.getElementsByName(id)[0];
|
||||
if (input) {
|
||||
input.addEventListener("input", calculate);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,89 +1,74 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
|
||||
const fields = [
|
||||
"gross_total_income", "disallowance_14a", "disallowance_37",
|
||||
"deduction_80ia_business", "deduction_sec37_disallowance", "deduction_80g",
|
||||
"net_taxable_income", "tax_30_percent", "tax_book_profit_18_5",
|
||||
"tax_payable", "surcharge_12", "edu_cess_3", "total_tax_payable",
|
||||
"mat_credit", "interest_234c", "total_tax",
|
||||
"advance_tax", "tds", "tcs", "tax_on_assessment", "refund"
|
||||
];
|
||||
|
||||
function getVal(id) {
|
||||
let el = document.getElementsByName(id)[0];
|
||||
var el = document.getElementsByName(id)[0];
|
||||
return el ? parseFloat(el.value) || 0 : 0;
|
||||
}
|
||||
|
||||
function setVal(id, value) {
|
||||
let el = document.getElementsByName(id)[0];
|
||||
var el = document.getElementsByName(id)[0];
|
||||
if (el) el.value = Number(value).toFixed(2);
|
||||
}
|
||||
|
||||
function calculate() {
|
||||
// MAIN CALC FUNCTION
|
||||
window.calculate = function () {
|
||||
|
||||
// Base values
|
||||
let gross_total_income = getVal("gross_total_income");
|
||||
let disallowance_14a = getVal("disallowance_14a");
|
||||
let disallowance_37 = getVal("disallowance_37");
|
||||
// BASIC VALUES
|
||||
var gross_total_income = getVal("gross_total_income");
|
||||
var disallowance_14a = getVal("disallowance_14a");
|
||||
var disallowance_37 = getVal("disallowance_37");
|
||||
|
||||
// Deductions
|
||||
let d80_business = getVal("deduction_80ia_business");
|
||||
let deduction_sec37 = getVal("deduction_sec37_disallowance");
|
||||
let deduction_80g = getVal("deduction_80g");
|
||||
var d80_business = getVal("deduction_80ia_business");
|
||||
var deduction_sec37 = getVal("deduction_sec37_disallowance");
|
||||
var deduction_80g = getVal("deduction_80g");
|
||||
|
||||
// Net Taxable Income
|
||||
let net_taxable_income =
|
||||
// NET TAXABLE INCOME
|
||||
var net_taxable_income =
|
||||
(gross_total_income + disallowance_14a + disallowance_37)
|
||||
- (d80_business + deduction_sec37)
|
||||
- deduction_80g;
|
||||
|
||||
setVal("net_taxable_income", net_taxable_income);
|
||||
|
||||
// 30% tax
|
||||
let tax_30_percent = net_taxable_income * 0.30;
|
||||
// TAX @ 30%
|
||||
var tax_30_percent = net_taxable_income * 0.30;
|
||||
setVal("tax_30_percent", tax_30_percent);
|
||||
|
||||
// Book profit tax (user input)
|
||||
let tax_payable = getVal("tax_book_profit_18_5");
|
||||
// TAX PAYABLE = 18.5% BOOK PROFIT (user enters)
|
||||
var tax_payable = getVal("tax_book_profit_18_5");
|
||||
setVal("tax_payable", tax_payable);
|
||||
|
||||
// Surcharge 12%
|
||||
let surcharge_12 = tax_payable * 0.12;
|
||||
// SURCHARGE
|
||||
var surcharge_12 = tax_payable * 0.12;
|
||||
setVal("surcharge_12", surcharge_12);
|
||||
|
||||
// Education Cess 3%
|
||||
let edu_cess_3 = (tax_payable + surcharge_12) * 0.03;
|
||||
// CESS
|
||||
var edu_cess_3 = (tax_payable + surcharge_12) * 0.03;
|
||||
setVal("edu_cess_3", edu_cess_3);
|
||||
|
||||
// Total Tax Payable
|
||||
let total_tax_payable = tax_payable + surcharge_12 + edu_cess_3;
|
||||
// TOTAL TAX PAYABLE
|
||||
var total_tax_payable = tax_payable + surcharge_12 + edu_cess_3;
|
||||
setVal("total_tax_payable", total_tax_payable);
|
||||
|
||||
// MAT + Interest
|
||||
let mat_credit = getVal("mat_credit");
|
||||
let interest_234c = getVal("interest_234c");
|
||||
// OTHER VALUES
|
||||
var mat_credit = getVal("mat_credit");
|
||||
var interest_234c = getVal("interest_234c");
|
||||
|
||||
// Total Tax
|
||||
let total_tax = total_tax_payable + mat_credit + interest_234c;
|
||||
// FINAL TAX
|
||||
var total_tax = total_tax_payable + mat_credit + interest_234c;
|
||||
setVal("total_tax", total_tax);
|
||||
|
||||
// Assessment → Advance Tax + TDS + TCS
|
||||
let advance_tax = getVal("advance_tax");
|
||||
let tds = getVal("tds");
|
||||
let tcs = getVal("tcs");
|
||||
// PAYMENTS
|
||||
var advance_tax = getVal("advance_tax");
|
||||
var tds = getVal("tds");
|
||||
var tcs = getVal("tcs");
|
||||
|
||||
let tax_on_assessment = advance_tax + tds + tcs;
|
||||
var tax_on_assessment = advance_tax + tds + tcs;
|
||||
setVal("tax_on_assessment", tax_on_assessment);
|
||||
|
||||
// Refund (or payable)
|
||||
let refund = total_tax - tax_on_assessment;
|
||||
// REFUND
|
||||
var refund = total_tax - tax_on_assessment;
|
||||
setVal("refund", refund);
|
||||
}
|
||||
|
||||
// Attach listeners
|
||||
fields.forEach(id => {
|
||||
let el = document.getElementsByName(id)[0];
|
||||
if (el) el.addEventListener("input", calculate);
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
@@ -1,83 +1,72 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const fields = [
|
||||
"gross_total_income", "disallowance_14a", "disallowance_37",
|
||||
"deduction_80ia_business", "deduction_80ia_misc", "deduction_80ia_other",
|
||||
"deduction_sec37_disallowance", "deduction_80g", "net_taxable_income",
|
||||
"tax_30_percent", "tax_book_profit_18_5", "tax_payable", "surcharge_12",
|
||||
"edu_cess_3", "total_tax_payable", "mat_credit", "interest_234c",
|
||||
"total_tax", "advance_tax", "tds", "tcs", "tax_on_assessment", "refund"
|
||||
];
|
||||
|
||||
function getValue(id) {
|
||||
return parseFloat(document.getElementsByName(id)[0].value) || 0;
|
||||
var el = document.getElementsByName(id)[0];
|
||||
return el ? parseFloat(el.value) || 0 : 0;
|
||||
}
|
||||
|
||||
function setValue(id, val) {
|
||||
document.getElementsByName(id)[0].value = val.toFixed(2);
|
||||
var el = document.getElementsByName(id)[0];
|
||||
if (el) el.value = Number(val).toFixed(2);
|
||||
}
|
||||
|
||||
function calculate() {
|
||||
window.calculate = function () {
|
||||
|
||||
let gross_total_income = getValue("gross_total_income");
|
||||
let disallowance_14a = getValue("disallowance_14a");
|
||||
let disallowance_37 = getValue("disallowance_37");
|
||||
// --- BASIC INPUTS ---
|
||||
var gross_total_income = getValue("gross_total_income");
|
||||
var disallowance_14a = getValue("disallowance_14a");
|
||||
var disallowance_37 = getValue("disallowance_37");
|
||||
|
||||
// FORMULAS
|
||||
// // Auto-calculations (your logic)
|
||||
setValue("gross_total_income", disallowance_37 + gross_total_income);
|
||||
setValue("disallowance_37", disallowance_14a + disallowance_37);
|
||||
|
||||
// Deductions
|
||||
let d80_business = getValue("deduction_80ia_business");
|
||||
let d80_misc = getValue("deduction_80ia_misc");
|
||||
let d80_other = getValue("deduction_80ia_other");
|
||||
// --- DEDUCTIONS ---
|
||||
var d80_business = getValue("deduction_80ia_business");
|
||||
var d80_misc = getValue("deduction_80ia_misc");
|
||||
var d80_other = getValue("deduction_80ia_other");
|
||||
|
||||
let deduction_sec37 = d80_business + d80_misc + d80_other - 1.35;
|
||||
var deduction_sec37 = d80_business + d80_misc + d80_other - 1.35;
|
||||
setValue("deduction_sec37_disallowance", deduction_sec37);
|
||||
|
||||
let deduction_80g = getValue("deduction_80g");
|
||||
var deduction_80g = getValue("deduction_80g");
|
||||
|
||||
// Net taxable income
|
||||
let net_taxable_income = gross_total_income - deduction_sec37 - deduction_80g;
|
||||
// --- NET TAXABLE INCOME ---
|
||||
var net_taxable_income = gross_total_income - deduction_sec37 - deduction_80g;
|
||||
setValue("net_taxable_income", net_taxable_income);
|
||||
|
||||
// Tax calculations
|
||||
// --- TAX 30% ---
|
||||
setValue("tax_30_percent", net_taxable_income * 0.30);
|
||||
|
||||
let tax_book_profit = getValue("tax_book_profit_18_5");
|
||||
setValue("tax_payable", tax_book_profit);
|
||||
// --- TAX PAYABLE (18.5%) ---
|
||||
var tax_book = getValue("tax_book_profit_18_5");
|
||||
setValue("tax_payable", tax_book);
|
||||
|
||||
let surcharge = tax_book_profit * 0.12;
|
||||
var surcharge = tax_book * 0.12;
|
||||
setValue("surcharge_12", surcharge);
|
||||
|
||||
let edu_cess = (tax_book_profit + surcharge) * 0.03;
|
||||
var edu_cess = (tax_book + surcharge) * 0.03;
|
||||
setValue("edu_cess_3", edu_cess);
|
||||
|
||||
let total_tax_payable = tax_book_profit + surcharge + edu_cess;
|
||||
var total_tax_payable = tax_book + surcharge + edu_cess;
|
||||
setValue("total_tax_payable", total_tax_payable);
|
||||
|
||||
let mat_credit = getValue("mat_credit");
|
||||
let interest_234c = getValue("interest_234c");
|
||||
// --- FINAL TAX ---
|
||||
var mat_credit = getValue("mat_credit");
|
||||
var interest_234c = getValue("interest_234c");
|
||||
|
||||
let total_tax = total_tax_payable + mat_credit + interest_234c;
|
||||
var total_tax = total_tax_payable + mat_credit + interest_234c;
|
||||
setValue("total_tax", total_tax);
|
||||
|
||||
// Assessment
|
||||
let adv_tax = getValue("advance_tax");
|
||||
let tds = getValue("tds");
|
||||
let tcs = getValue("tcs");
|
||||
// --- ASSESSMENT ---
|
||||
var adv_tax = getValue("advance_tax");
|
||||
var tds = getValue("tds");
|
||||
var tcs = getValue("tcs");
|
||||
|
||||
let tax_on_assessment = adv_tax + tds + tcs;
|
||||
var tax_on_assessment = adv_tax + tds + tcs;
|
||||
setValue("tax_on_assessment", tax_on_assessment);
|
||||
|
||||
let refund = total_tax - tax_on_assessment;
|
||||
var refund = total_tax - tax_on_assessment;
|
||||
setValue("refund", refund);
|
||||
}
|
||||
|
||||
// Attach event listeners
|
||||
fields.forEach(id => {
|
||||
const element = document.getElementsByName(id)[0];
|
||||
if (element) {
|
||||
element.addEventListener("input", calculate);
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,23 +1,51 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const yearDropdown = document.getElementById("year");
|
||||
const errorDiv = document.getElementById("yearError");
|
||||
|
||||
// Get the form dynamically
|
||||
const form = document.querySelector("form"); // get from id as table name
|
||||
|
||||
// Dynamic table name = form id
|
||||
const tableName = form.id.toLowerCase();
|
||||
|
||||
const currentYear = new Date().getFullYear();
|
||||
const startYear = 1990;
|
||||
|
||||
// Fill Year dropdown
|
||||
for (let y = currentYear; y >= startYear; y--) {
|
||||
let nextYear = y + 1;
|
||||
|
||||
let option = document.createElement("option");
|
||||
|
||||
// Backend receives only first year (example 2024)
|
||||
option.value = y;
|
||||
|
||||
// User sees (example AY 2024–2025)
|
||||
option.textContent = `AY ${y}-${nextYear}`;
|
||||
|
||||
yearDropdown.appendChild(option);
|
||||
}
|
||||
|
||||
// Validate selected year
|
||||
yearDropdown.addEventListener("change", function () {
|
||||
let selectedYear = parseInt(this.value);
|
||||
|
||||
fetch("/check_year", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
table: tableName, // dynamic table name
|
||||
year: selectedYear
|
||||
})
|
||||
})
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
if (data.exists) {
|
||||
errorDiv.style.display = "block";
|
||||
errorDiv.innerText = `Year ${selectedYear} already exists!`;
|
||||
|
||||
// Block submission
|
||||
form.onsubmit = function () { return false; };
|
||||
} else {
|
||||
errorDiv.style.display = "none";
|
||||
form.onsubmit = null; // Allow submit
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user