A client-side JavaScript implementation of the Professional Tax Calculator for Indian states. This version can be deployed to GitHub Pages and runs entirely in the browser without requiring a backend server.
- π± Client-Side Calculation: Runs entirely in the browser
- π GitHub Pages Ready: Deploy to GitHub Pages with zero configuration
- π 39 States & UTs: Complete coverage of Indian states and union territories
- π° 100+ Tax Slabs: Comprehensive PTax rules and calculations
- π₯ Gender-Specific Rules: Different tax slabs for male/female employees
- π Multiple Collection Modes: Monthly, Quarterly, Half-Yearly, and Yearly
- π± Responsive Design: Mobile-friendly interface
- β‘ Fast Performance: Instant calculations with local data
Visit the live calculator: https://frontlook-admin.github.io/PTaxApi-JS/
Simply visit the live demo link above - no installation required!
-
Clone the repository
git clone https://github.com/frontlook-admin/PTaxApi-JS.git cd PTaxApi-JS
-
Install dependencies (optional, for development)
npm install
-
Start local server
# Using npm (if you installed dependencies) npm start # Or using Python (if you have Python installed) python -m http.server 3000 # Or simply open index.html in your browser
-
Open in browser
http://localhost:3000
PTaxApi-JS/
βββ index.html # Main HTML file
βββ css/
β βββ style.css # Custom styles
βββ js/
β βββ ptax-calculator.js # Core calculation engine
β βββ app.js # UI application logic
βββ data/
β βββ states.json # Indian states data
β βββ ptax-slabs.json # PTax rules and slabs
βββ package.json # Project configuration
βββ README.md # This file
// Initialize calculator
const calculator = new PTaxCalculator();
await calculator.init();
// Calculate PTax for Assam, βΉ25,000 salary, Male
const result = calculator.calculatePTax(18, 25000, 'Male');
console.log(result);
// Output: { monthlyPTax: 180, yearlyPTax: 2160, ... }
const states = calculator.getStates();
console.log(states.length); // 39 states and UTs
const slabs = calculator.getPTaxSlabsByStateId(18); // Assam
console.log(slabs);
Method | Description | Parameters | Returns |
---|---|---|---|
init() |
Initialize calculator with data | None | Promise |
calculatePTax(stateId, salary, gender) |
Calculate PTax | stateId, salary, gender | Object |
getStates() |
Get all states | None | Array |
getPTaxSlabsByStateId(stateId) |
Get tax slabs for state | stateId | Array |
getStatesWithPTax() |
Get states with PTax | None | Array |
{
stateName: "Assam",
stateCode: "AS",
salary: 25000,
gender: "Male",
monthlyPTax: 180,
yearlyPTax: 2160,
collectionMode: "MONTHLY",
applicableSlab: { ... },
breakdown: { ... }
}
-
Fork this repository or create your own
-
Enable GitHub Pages
- Go to repository Settings
- Scroll to Pages section
- Source: Deploy from branch
- Branch: main (or master)
- Folder: / (root)
-
Your calculator will be live at:
https://yourusername.github.io/PTaxApi-JS/
The PTax data is stored in JSON files in the data/
directory:
states.json
- Indian states and union territoriesptax-slabs.json
- PTax rules and tax slabs
To update the data:
- Edit the JSON files
- Commit and push changes
- GitHub Pages will automatically update
Edit css/style.css
to customize the appearance:
:root {
--primary-color: #0066cc;
--secondary-color: #ffc107;
/* ... other custom properties */
}
Extend the calculator by modifying:
js/ptax-calculator.js
- Core calculation logicjs/app.js
- UI interactions and display
- β Chrome 80+
- β Firefox 75+
- β Safari 13+
- β Edge 80+
- β Mobile browsers
- Semantic HTML structure
- Open Graph meta tags
- Descriptive page titles
- Mobile-responsive design
- Fast loading times
- Check browser console for errors
- Ensure you're serving the files via HTTP (not file://)
- Verify JSON files are accessible
- Check the data in
ptax-slabs.json
- Verify state ID mapping in
states.json
- Review calculation logic in
ptax-calculator.js
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- PTaxApi (.NET) - Backend API version
- PTax Documentation - Comprehensive documentation
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π§ Email: Create an issue for support
If this project helps you, please give it a β on GitHub!
Built with β€οΈ for the Indian developer community