Skip to content

Commit 0e25f91

Browse files
committed
design fixes
1 parent 02f8930 commit 0e25f91

14 files changed

Lines changed: 996 additions & 56 deletions

File tree

app.py

Lines changed: 247 additions & 56 deletions
Large diffs are not rendered by default.

llm_sections.py

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,149 @@ def detect_tax_regime(deductions_claimed: List[Dict[str, Any]], total_deductions
14041404
return "regime_unclear"
14051405

14061406

1407+
def compute_regime_comparison(
1408+
gross_income: float,
1409+
deductions_80c: float = 0,
1410+
deductions_80d: float = 0,
1411+
deductions_nps: float = 0,
1412+
hra_exemption: float = 0,
1413+
other_deductions: float = 0
1414+
) -> Dict[str, Any]:
1415+
"""
1416+
Compare Old vs New tax regime for FY 2024-25.
1417+
1418+
Old Regime (FY 2024-25):
1419+
- 0-2.5L: Nil
1420+
- 2.5-5L: 5%
1421+
- 5-10L: 20%
1422+
- >10L: 30%
1423+
- Standard deduction: 50,000
1424+
- All deductions (80C, 80D, HRA, etc.) allowed
1425+
1426+
New Regime (FY 2024-25):
1427+
- 0-3L: Nil
1428+
- 3-7L: 5%
1429+
- 7-10L: 10%
1430+
- 10-12L: 15%
1431+
- 12-15L: 20%
1432+
- >15L: 30%
1433+
- Standard deduction: 75,000
1434+
- NO deductions allowed (except standard deduction)
1435+
1436+
Returns dict with:
1437+
- old_regime: {taxable_income, tax_liability, effective_rate}
1438+
- new_regime: {taxable_income, tax_liability, effective_rate}
1439+
- better_regime: "old" or "new"
1440+
- savings: amount saved by choosing better regime
1441+
- recommendation: text recommendation
1442+
"""
1443+
if gross_income <= 0:
1444+
return {
1445+
"old_regime": {"taxable_income": 0, "tax_liability": 0, "effective_rate": 0},
1446+
"new_regime": {"taxable_income": 0, "tax_liability": 0, "effective_rate": 0},
1447+
"better_regime": "new",
1448+
"savings": 0,
1449+
"recommendation": "No income to tax."
1450+
}
1451+
1452+
# OLD REGIME CALCULATION
1453+
old_std_deduction = 50000
1454+
total_deductions_old = (
1455+
min(deductions_80c, 150000) + # 80C capped at 1.5L
1456+
min(deductions_nps, 50000) + # 80CCD(1B) capped at 50K
1457+
min(deductions_80d, 75000) + # 80D capped at 75K (self + parents)
1458+
hra_exemption +
1459+
other_deductions +
1460+
old_std_deduction
1461+
)
1462+
1463+
taxable_old = max(0, gross_income - total_deductions_old)
1464+
1465+
# Old regime tax calculation
1466+
tax_old = 0
1467+
if taxable_old > 1000000:
1468+
tax_old = 112500 + (taxable_old - 1000000) * 0.30
1469+
elif taxable_old > 500000:
1470+
tax_old = 12500 + (taxable_old - 500000) * 0.20
1471+
elif taxable_old > 250000:
1472+
tax_old = (taxable_old - 250000) * 0.05
1473+
1474+
# Rebate u/s 87A for old regime (if taxable income <= 5L)
1475+
if taxable_old <= 500000:
1476+
tax_old = max(0, tax_old - 12500)
1477+
1478+
# Add 4% cess
1479+
tax_old_with_cess = tax_old * 1.04
1480+
1481+
# NEW REGIME CALCULATION
1482+
new_std_deduction = 75000
1483+
taxable_new = max(0, gross_income - new_std_deduction)
1484+
1485+
# New regime tax calculation (FY 2024-25 slabs)
1486+
tax_new = 0
1487+
if taxable_new > 1500000:
1488+
tax_new = 150000 + (taxable_new - 1500000) * 0.30
1489+
elif taxable_new > 1200000:
1490+
tax_new = 90000 + (taxable_new - 1200000) * 0.20
1491+
elif taxable_new > 1000000:
1492+
tax_new = 60000 + (taxable_new - 1000000) * 0.15
1493+
elif taxable_new > 700000:
1494+
tax_new = 30000 + (taxable_new - 700000) * 0.10
1495+
elif taxable_new > 300000:
1496+
tax_new = (taxable_new - 300000) * 0.05
1497+
1498+
# Rebate u/s 87A for new regime (if taxable income <= 7L, full rebate up to 25K)
1499+
if taxable_new <= 700000:
1500+
tax_new = max(0, tax_new - 25000)
1501+
1502+
# Add 4% cess
1503+
tax_new_with_cess = tax_new * 1.04
1504+
1505+
# Determine better regime (prefer New when equal - simpler compliance)
1506+
if tax_new_with_cess < tax_old_with_cess:
1507+
better = "new"
1508+
savings = tax_old_with_cess - tax_new_with_cess
1509+
elif tax_old_with_cess < tax_new_with_cess:
1510+
better = "old"
1511+
savings = tax_new_with_cess - tax_old_with_cess
1512+
else:
1513+
# Equal taxes - prefer New Regime (simpler, government default)
1514+
better = "new"
1515+
savings = 0
1516+
1517+
# Generate recommendation
1518+
if gross_income <= 700000:
1519+
recommendation = "With income ≤ ₹7L, New Regime is better (full rebate, zero tax)."
1520+
elif gross_income <= 1200000:
1521+
if total_deductions_old - old_std_deduction >= 150000:
1522+
recommendation = f"With ₹{total_deductions_old - old_std_deduction:,.0f} in deductions, Old Regime saves ₹{savings:,.0f}." if better == "old" else f"Even with deductions, New Regime saves ₹{savings:,.0f}."
1523+
else:
1524+
recommendation = "With limited deductions, New Regime is likely better."
1525+
else:
1526+
if total_deductions_old - old_std_deduction >= 375000: # Max 80C + NPS + 80D + some HRA
1527+
recommendation = f"With significant deductions (₹{total_deductions_old - old_std_deduction:,.0f}), Old Regime saves ₹{savings:,.0f}."
1528+
else:
1529+
recommendation = f"{'Old' if better == 'old' else 'New'} Regime saves ₹{savings:,.0f}. Consider maximizing deductions to review."
1530+
1531+
return {
1532+
"old_regime": {
1533+
"taxable_income": round(taxable_old, 0),
1534+
"total_deductions": round(total_deductions_old, 0),
1535+
"tax_liability": round(tax_old_with_cess, 0),
1536+
"effective_rate": round((tax_old_with_cess / gross_income) * 100, 2) if gross_income > 0 else 0
1537+
},
1538+
"new_regime": {
1539+
"taxable_income": round(taxable_new, 0),
1540+
"standard_deduction": new_std_deduction,
1541+
"tax_liability": round(tax_new_with_cess, 0),
1542+
"effective_rate": round((tax_new_with_cess / gross_income) * 100, 2) if gross_income > 0 else 0
1543+
},
1544+
"better_regime": better,
1545+
"savings": round(savings, 0),
1546+
"recommendation": recommendation
1547+
}
1548+
1549+
14071550
def compute_effective_tax_rate(tax_paid: float, gross_income: float) -> float:
14081551
"""Calculate effective tax rate as percentage."""
14091552
if gross_income <= 0:

output/index.db

4 KB
Binary file not shown.

0 commit comments

Comments
 (0)