add auto-calculation of CIT form commit

This commit is contained in:
2025-12-04 21:09:07 +05:30
parent 4fce58adec
commit 7ee2376455
2 changed files with 90 additions and 0 deletions

89
static/js/cit_calc.js Normal file
View File

@@ -0,0 +1,89 @@
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];
return el ? parseFloat(el.value) || 0 : 0;
}
function setVal(id, value) {
let el = document.getElementsByName(id)[0];
if (el) el.value = Number(value).toFixed(2);
}
function calculate() {
// Base values
let gross_total_income = getVal("gross_total_income");
let disallowance_14a = getVal("disallowance_14a");
let 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");
// Net Taxable Income
let 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;
setVal("tax_30_percent", tax_30_percent);
// Book profit tax (user input)
let tax_payable = getVal("tax_book_profit_18_5");
setVal("tax_payable", tax_payable);
// Surcharge 12%
let surcharge_12 = tax_payable * 0.12;
setVal("surcharge_12", surcharge_12);
// Education Cess 3%
let 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;
setVal("total_tax_payable", total_tax_payable);
// MAT + Interest
let mat_credit = getVal("mat_credit");
let interest_234c = getVal("interest_234c");
// Total Tax
let 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");
let tax_on_assessment = advance_tax + tds + tcs;
setVal("tax_on_assessment", tax_on_assessment);
// Refund (or payable)
let 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);
});
});

View File

@@ -4,6 +4,7 @@
<head>
<title>CIT Form Entry</title>
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
<script src="/static/js/cit_calc.js"></script>
<style>
/* ...existing styles... (no changes needed) */
* {