ITR model update code
This commit is contained in:
95
AppCode/AOHandler.py
Normal file
95
AppCode/AOHandler.py
Normal file
@@ -0,0 +1,95 @@
|
||||
from AppCode.Config import DBConfig
|
||||
import mysql.connector
|
||||
|
||||
|
||||
|
||||
class AOHandler:
|
||||
|
||||
def __init__(self):
|
||||
self.conn = DBConfig.get_db_connection()
|
||||
self.cursor = self.conn.cursor(dictionary=True)
|
||||
|
||||
|
||||
# GET ALL AO RECORDS using stored procedure "GetAllItr"
|
||||
def get_all_ao(self):
|
||||
|
||||
self.cursor.callproc("GetAllAO")
|
||||
records = []
|
||||
|
||||
for result in self.cursor.stored_results():
|
||||
records = result.fetchall()
|
||||
|
||||
return records
|
||||
|
||||
|
||||
def get_ao_by_id(self, id):
|
||||
# Call stored procedure
|
||||
self.cursor.callproc('GetAORById', [id])
|
||||
|
||||
# Fetch result
|
||||
records = []
|
||||
for result in self.cursor.stored_results():
|
||||
records = result.fetchall()
|
||||
|
||||
if records:
|
||||
print(records[0])
|
||||
return records[0] # return single record
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
||||
# INSERT ITR RECORD using procedure "add_itr"
|
||||
# def add_itr(self, data):
|
||||
|
||||
# columns = [
|
||||
# 'year', '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'
|
||||
# ]
|
||||
|
||||
# values = [data.get(col, 0) for col in columns]
|
||||
|
||||
# # Call your stored procedure
|
||||
# self.cursor.callproc("InsertITR", values)
|
||||
# self.conn.commit()
|
||||
|
||||
|
||||
# UPDATE ITR RECORD by ITR id
|
||||
# def update(self, id, data):
|
||||
|
||||
# columns = [
|
||||
# 'year', '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'
|
||||
# ]
|
||||
|
||||
# set_clause = ", ".join([f"{col}=%s" for col in columns])
|
||||
|
||||
# query = f"UPDATE itr SET {set_clause} WHERE id = %s"
|
||||
|
||||
# values = [data.get(col, 0) for col in columns]
|
||||
# values.append(id)
|
||||
|
||||
# self.cursor.execute(query, tuple(values))
|
||||
# self.conn.commit()
|
||||
|
||||
|
||||
# # DELETE RECORD by ITR id
|
||||
# def delete_itr_by_id(self, id):
|
||||
# # Call the stored procedure
|
||||
# self.cursor.callproc('DeleteITRById', [id])
|
||||
# self.conn.commit()
|
||||
|
||||
|
||||
# CLOSE CONNECTION
|
||||
def close(self):
|
||||
self.cursor.close()
|
||||
self.conn.close()
|
||||
21
AppCode/Config.py
Normal file
21
AppCode/Config.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import mysql.connector
|
||||
import os
|
||||
|
||||
class DBConfig:
|
||||
# Database credentials (can also be read from environment variables)
|
||||
MYSQL_HOST = os.getenv("MYSQL_HOST", "127.0.0.1")
|
||||
MYSQL_USER = os.getenv("MYSQL_USER", "root")
|
||||
MYSQL_PASSWORD = os.getenv("MYSQL_PASSWORD", "root")
|
||||
MYSQL_DB = os.getenv("MYSQL_DB", "income_tax")
|
||||
|
||||
@staticmethod
|
||||
def get_db_connection():
|
||||
"""
|
||||
Returns a MySQL connection object.
|
||||
"""
|
||||
return mysql.connector.connect(
|
||||
host=DBConfig.MYSQL_HOST,
|
||||
user=DBConfig.MYSQL_USER,
|
||||
password=DBConfig.MYSQL_PASSWORD,
|
||||
database=DBConfig.MYSQL_DB
|
||||
)
|
||||
99
AppCode/DocumentHandler.py
Normal file
99
AppCode/DocumentHandler.py
Normal file
@@ -0,0 +1,99 @@
|
||||
import os
|
||||
from AppCode.Config import DBConfig
|
||||
from AppCode.FileHandler import FileHandler
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
class DocumentHandler:
|
||||
|
||||
def __init__(self):
|
||||
self.years = []
|
||||
self.documents = []
|
||||
self.isSuccess = False
|
||||
self.resultMessage = ""
|
||||
|
||||
# VIEW DOCUMENTS
|
||||
def View(self, request):
|
||||
year = request.args.get('year', '')
|
||||
stage = request.args.get('stage', '')
|
||||
|
||||
dbconfig = DBConfig()
|
||||
connection = dbconfig.get_db_connection()
|
||||
|
||||
if not connection:
|
||||
self.isSuccess = False
|
||||
return
|
||||
|
||||
cursor = connection.cursor(dictionary=True)
|
||||
|
||||
# --- FILTER QUERY ---
|
||||
query = "SELECT * FROM documents WHERE 1=1"
|
||||
params = []
|
||||
|
||||
if year != "":
|
||||
query += " AND year = %s"
|
||||
params.append(year)
|
||||
|
||||
if stage != "":
|
||||
query += " AND stage = %s"
|
||||
params.append(stage)
|
||||
|
||||
|
||||
cursor.execute(query, params)
|
||||
self.documents = cursor.fetchall()
|
||||
|
||||
# ---- GET YEARS FROM STORED PROCEDURE ----
|
||||
cursor.callproc("GetYear")
|
||||
|
||||
for result in cursor.stored_results():
|
||||
year_rows = result.fetchall()
|
||||
break # only first result set
|
||||
|
||||
self.years = [row['year'] for row in year_rows]
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
self.isSuccess = True
|
||||
|
||||
# UPLOAD DOCUMENTS
|
||||
def Upload(self, request):
|
||||
"""Log user actions with timestamp, user, action, and details."""
|
||||
|
||||
dbconfig = DBConfig()
|
||||
connection = dbconfig.get_db_connection()
|
||||
|
||||
if connection:
|
||||
cursor = connection.cursor()
|
||||
files = request.files.getlist('documents')
|
||||
year = request.form['year']
|
||||
stage = request.form['stage']
|
||||
|
||||
for file in files:
|
||||
if file is not FileHandler.ALLOWED_EXTENSIONS:
|
||||
continue
|
||||
|
||||
|
||||
filename = secure_filename(file.filename)
|
||||
filepath = os.path.join(FileHandler.UPLOAD_FOLDER, filename)
|
||||
extension = file.filename.rsplit('.', 1)[1]
|
||||
# Need to Check whetehr all three items are required
|
||||
|
||||
file.save(filepath)
|
||||
|
||||
# cursor.execute("""
|
||||
# INSERT INTO documents (filename, filepath, filetype, year, stage)
|
||||
# VALUES (%s, %s, %s, %s, %s)
|
||||
# """, (filename, filepath, file.filename.rsplit('.', 1)[1], year, stage))
|
||||
|
||||
|
||||
cursor.callproc('InsertDocument', [
|
||||
filename,
|
||||
filepath,
|
||||
extension,
|
||||
year,
|
||||
stage
|
||||
])
|
||||
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
connection.close()
|
||||
# return redirect(url_for('view_documents'))
|
||||
12
AppCode/FileHandler.py
Normal file
12
AppCode/FileHandler.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import os
|
||||
|
||||
class FileHandler:
|
||||
ALLOWED_EXTENSIONS = {'pdf', 'docx', 'doc', 'xlsx', 'xls'}
|
||||
UPLOAD_FOLDER = os.path.join('static', 'uploads')
|
||||
|
||||
|
||||
@staticmethod
|
||||
def CHeckExistingOrCreateNewUploadFolder():
|
||||
#Wheteher path exists
|
||||
os.makedirs(FileHandler.UPLOAD_FOLDER, exist_ok=True)
|
||||
return
|
||||
96
AppCode/ITRHandler.py
Normal file
96
AppCode/ITRHandler.py
Normal file
@@ -0,0 +1,96 @@
|
||||
from AppCode.Config import DBConfig
|
||||
import mysql.connector
|
||||
|
||||
|
||||
|
||||
class ITRHandler:
|
||||
|
||||
def __init__(self):
|
||||
self.conn = DBConfig.get_db_connection()
|
||||
self.cursor = self.conn.cursor(dictionary=True)
|
||||
|
||||
|
||||
# GET ALL ITR RECORDS using stored procedure "GetAllItr"
|
||||
def get_all_itr(self):
|
||||
# self.cursor = conn.cursor(dictionary=True)
|
||||
|
||||
self.cursor.callproc("GetAllItr")
|
||||
records = []
|
||||
|
||||
for result in self.cursor.stored_results():
|
||||
records = result.fetchall()
|
||||
|
||||
return records
|
||||
|
||||
|
||||
def get_itr_by_id(self, id):
|
||||
# Call stored procedure
|
||||
self.cursor.callproc('GetITRById', [id])
|
||||
|
||||
# Fetch result
|
||||
records = []
|
||||
for result in self.cursor.stored_results():
|
||||
records = result.fetchall()
|
||||
|
||||
if records:
|
||||
print(records[0])
|
||||
return records[0] # return single record
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
||||
# INSERT ITR RECORD using procedure "add_itr"
|
||||
def add_itr(self, data):
|
||||
|
||||
columns = [
|
||||
'year', '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'
|
||||
]
|
||||
|
||||
values = [data.get(col, 0) for col in columns]
|
||||
|
||||
# Call your stored procedure
|
||||
self.cursor.callproc("InsertITR", values)
|
||||
self.conn.commit()
|
||||
|
||||
|
||||
# UPDATE ITR RECORD by ITR id
|
||||
def update(self, id, data):
|
||||
|
||||
columns = [
|
||||
'year', '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'
|
||||
]
|
||||
|
||||
set_clause = ", ".join([f"{col}=%s" for col in columns])
|
||||
|
||||
query = f"UPDATE itr SET {set_clause} WHERE id = %s"
|
||||
|
||||
values = [data.get(col, 0) for col in columns]
|
||||
values.append(id)
|
||||
|
||||
self.cursor.execute(query, tuple(values))
|
||||
self.conn.commit()
|
||||
|
||||
|
||||
# DELETE RECORD by ITR id
|
||||
def delete_itr_by_id(self, id):
|
||||
# Call the stored procedure
|
||||
self.cursor.callproc('DeleteITRById', [id])
|
||||
self.conn.commit()
|
||||
|
||||
|
||||
# CLOSE CONNECTION
|
||||
def close(self):
|
||||
self.cursor.close()
|
||||
self.conn.close()
|
||||
25
AppCode/Log.py
Normal file
25
AppCode/Log.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, flash, jsonify, json
|
||||
from flask import current_app
|
||||
|
||||
from datetime import datetime
|
||||
from flask_login import LoginManager, UserMixin, login_user, logout_user, login_required, current_user
|
||||
|
||||
import os
|
||||
|
||||
class LogHelper:
|
||||
@staticmethod
|
||||
def log_action(action, details=""):
|
||||
"""Log user actions with timestamp, user, action, and details."""
|
||||
logData = LogData()
|
||||
logData.WriteLog(action, details="")
|
||||
|
||||
|
||||
|
||||
class LogData:
|
||||
|
||||
filepath = ""
|
||||
timestamp = None
|
||||
|
||||
def __init__(self):
|
||||
self.filepath = os.path.join(current_app.root_path, 'activity.log')
|
||||
self.timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
58
AppCode/Utiliies.py
Normal file
58
AppCode/Utiliies.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from flask import flash, jsonify, json
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class RegEx:
|
||||
patternAlphabetOnly = "^[A-Za-z ]+$"
|
||||
|
||||
|
||||
class ResponseHandler:
|
||||
@staticmethod
|
||||
def invalid_name(entity):
|
||||
return {'status': 'error', 'message': f'Invalid {entity} name. Only letters are allowed!'}
|
||||
|
||||
@staticmethod
|
||||
def already_exists(entity):
|
||||
return {'status': 'exists', 'message': f'{entity.capitalize()} already exists!'}
|
||||
|
||||
@staticmethod
|
||||
def add_success(entity):
|
||||
return {'status': 'success', 'message': f'{entity.capitalize()} added successfully!'}
|
||||
|
||||
@staticmethod
|
||||
def add_failure(entity):
|
||||
return {'status': 'error', 'message': f'Failed to add {entity}.'}
|
||||
|
||||
@staticmethod
|
||||
def is_available(entity):
|
||||
return {'status': 'available', 'message': f'{entity.capitalize()} name is available!'}
|
||||
|
||||
@staticmethod
|
||||
def delete_success(entity):
|
||||
return {'status': 'success', 'message': f'{entity.capitalize()} deleted successfully!'}
|
||||
|
||||
@staticmethod
|
||||
def delete_failure(entity):
|
||||
return {'status': 'error', 'message': f'Failed to delete {entity}.'}
|
||||
|
||||
@staticmethod
|
||||
def update_success(entity):
|
||||
return {'status': 'success', 'message': f'{entity.capitalize()} updated successfully!'}
|
||||
|
||||
@staticmethod
|
||||
def update_failure(entity):
|
||||
return {'status': 'error', 'message': f'Failed to update {entity}.'}
|
||||
|
||||
@staticmethod
|
||||
def fetch_failure(entity):
|
||||
return {'status': 'error', 'message': f'Failed to fetch {entity}.'}
|
||||
|
||||
|
||||
class HtmlHelper:
|
||||
# Helper: JSON Response Formatter
|
||||
|
||||
@staticmethod
|
||||
def json_response(message_obj, status_code):
|
||||
return jsonify(message_obj), status_code
|
||||
#May need to refactor further
|
||||
|
||||
BIN
AppCode/__pycache__/AOHandler.cpython-313.pyc
Normal file
BIN
AppCode/__pycache__/AOHandler.cpython-313.pyc
Normal file
Binary file not shown.
BIN
AppCode/__pycache__/Config.cpython-313.pyc
Normal file
BIN
AppCode/__pycache__/Config.cpython-313.pyc
Normal file
Binary file not shown.
BIN
AppCode/__pycache__/DocumentHandler.cpython-313.pyc
Normal file
BIN
AppCode/__pycache__/DocumentHandler.cpython-313.pyc
Normal file
Binary file not shown.
BIN
AppCode/__pycache__/FileHandler.cpython-313.pyc
Normal file
BIN
AppCode/__pycache__/FileHandler.cpython-313.pyc
Normal file
Binary file not shown.
BIN
AppCode/__pycache__/ITRHandler.cpython-313.pyc
Normal file
BIN
AppCode/__pycache__/ITRHandler.cpython-313.pyc
Normal file
Binary file not shown.
8
IncomeTaxSystem.code-workspace
Normal file
8
IncomeTaxSystem.code-workspace
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
Binary file not shown.
BIN
__pycache__/config.cpython-314.pyc
Normal file
BIN
__pycache__/config.cpython-314.pyc
Normal file
Binary file not shown.
@@ -1,7 +1,8 @@
|
||||
db_config = {
|
||||
'host': 'localhost',
|
||||
'user': 'root',
|
||||
'password': 'admin',
|
||||
'password': 'root',
|
||||
'database': 'income_tax',
|
||||
'port': 3306
|
||||
}
|
||||
|
||||
|
||||
562
main.py
562
main.py
@@ -1,13 +1,22 @@
|
||||
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, abort
|
||||
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, abort, flash,send_file
|
||||
import os
|
||||
import mysql.connector
|
||||
from werkzeug.utils import secure_filename
|
||||
from AppCode.FileHandler import FileHandler
|
||||
from AppCode.DocumentHandler import DocumentHandler
|
||||
from AppCode.ITRHandler import ITRHandler
|
||||
from AppCode.AOHandler import AOHandler
|
||||
from config import db_config
|
||||
from AppCode.Config import DBConfig
|
||||
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['UPLOAD_FOLDER'] = os.path.join('static', 'uploads')
|
||||
ALLOWED_EXTENSIONS = {'pdf', 'docx', 'doc', 'xlsx', 'xls'}
|
||||
app.secret_key="secret1234"
|
||||
app.config['UPLOAD_FOLDER'] = FileHandler.UPLOAD_FOLDER
|
||||
#ALLOWED_EXTENSIONS = {'pdf', 'docx', 'doc', 'xlsx', 'xls'}
|
||||
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def welcome():
|
||||
@@ -18,38 +27,19 @@ def index():
|
||||
return render_template('index.html') # Your dashboard page
|
||||
|
||||
# Ensure folder exists
|
||||
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
||||
|
||||
|
||||
def allowed_file(filename):
|
||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||
return '.' in filename and filename.rsplit('.', 1)[1].lower() in FileHandler.ALLOWED_EXTENSIONS
|
||||
|
||||
|
||||
# Upload route
|
||||
@app.route('/upload', methods=['GET', 'POST'])
|
||||
def upload_file():
|
||||
|
||||
if request.method == 'POST':
|
||||
files = request.files.getlist('documents')
|
||||
year = request.form['year']
|
||||
stage = request.form['stage']
|
||||
|
||||
conn = mysql.connector.connect(**db_config)
|
||||
cursor = conn.cursor()
|
||||
|
||||
for file in files:
|
||||
if file and allowed_file(file.filename):
|
||||
filename = secure_filename(file.filename)
|
||||
filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename)
|
||||
file.save(filepath)
|
||||
|
||||
cursor.execute("""
|
||||
INSERT INTO documents (filename, filepath, filetype, year, stage)
|
||||
VALUES (%s, %s, %s, %s, %s)
|
||||
""", (filename, filepath, file.filename.rsplit('.', 1)[1], year, stage))
|
||||
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
FileHandler.CHeckExistingOrCreateNewUploadFolder()
|
||||
docHandler = DocumentHandler()
|
||||
docHandler.Upload(request=request)
|
||||
return redirect(url_for('view_documents'))
|
||||
|
||||
return render_template('upload.html')
|
||||
@@ -58,37 +48,13 @@ def upload_file():
|
||||
# View all documents with filters
|
||||
@app.route('/documents')
|
||||
def view_documents():
|
||||
year = request.args.get('year')
|
||||
stage = request.args.get('stage')
|
||||
|
||||
conn = mysql.connector.connect(**db_config)
|
||||
cursor = conn.cursor(dictionary=True)
|
||||
|
||||
query = "SELECT * FROM documents WHERE 1=1"
|
||||
params = []
|
||||
|
||||
if year:
|
||||
query += " AND year = %s"
|
||||
params.append(year)
|
||||
if stage:
|
||||
query += " AND stage = %s"
|
||||
params.append(stage)
|
||||
|
||||
cursor.execute(query, params)
|
||||
documents = cursor.fetchall()
|
||||
|
||||
cursor.execute("SELECT DISTINCT year FROM documents ORDER BY year DESC")
|
||||
years = [row['year'] for row in cursor.fetchall()]
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
|
||||
return render_template('view_docs.html', documents=documents, years=years)
|
||||
docHandler = DocumentHandler()
|
||||
docHandler.View(request=request)
|
||||
return render_template('view_docs.html', documents=docHandler.documents, years=docHandler.years)
|
||||
|
||||
|
||||
# Serve uploaded file
|
||||
from flask import send_file
|
||||
|
||||
# Upload file documents
|
||||
@app.route('/uploads/<filename>')
|
||||
def uploaded_file(filename):
|
||||
mode = request.args.get('mode', 'view')
|
||||
@@ -117,47 +83,61 @@ def uploaded_file(filename):
|
||||
|
||||
## 1. READ/DISPLAY all ITR records
|
||||
# This page will show all records in a table with Edit and Delete buttons.
|
||||
@app.route('/itr_records')
|
||||
def display_itr():
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor(dictionary=True)
|
||||
cursor.execute("SELECT * FROM itr ORDER BY year DESC, id DESC")
|
||||
records = cursor.fetchall()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return render_template('display_itr.html', records=records)
|
||||
# @app.route('/itr_records')
|
||||
# def display_itr():
|
||||
# conn = get_db_connection()
|
||||
# cursor = conn.cursor(dictionary=True)
|
||||
# # cursor.execute("SELECT * FROM itr ORDER BY year DESC, id DESC")
|
||||
# # records = cursor.fetchall()
|
||||
|
||||
# cursor.callproc("GetAllItr")
|
||||
# records = []
|
||||
# for result in cursor.stored_results():
|
||||
# records = result.fetchall()
|
||||
|
||||
|
||||
# cursor.close()
|
||||
# conn.close()
|
||||
# return render_template('display_itr.html', records=records)
|
||||
|
||||
|
||||
|
||||
|
||||
## 2. CREATE/ADD a new ITR record
|
||||
# This route handles both showing the blank form and saving the new data.
|
||||
@app.route('/itr/add', methods=['GET', 'POST'])
|
||||
def add_itr():
|
||||
if request.method == 'POST':
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
# @app.route('/itr/add', methods=['GET', 'POST'])
|
||||
# def add_itr():
|
||||
# if request.method == 'POST':
|
||||
# conn = get_db_connection()
|
||||
# cursor = conn.cursor()
|
||||
|
||||
# A list of all columns in your form and database table
|
||||
columns = [
|
||||
'year', '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'
|
||||
]
|
||||
# # A list of all columns in your form and database table
|
||||
# columns = [
|
||||
# 'year', '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'
|
||||
# ]
|
||||
|
||||
query = f"INSERT INTO itr ({', '.join(columns)}) VALUES ({', '.join(['%s'] * len(columns))})"
|
||||
values = [request.form.get(col, 0) for col in columns]
|
||||
# values = [request.form.get(col, 0) for col in columns]
|
||||
# # query = f"INSERT INTO itr ({', '.join(columns)}) VALUES ({', '.join(['%s'] * len(columns))})"
|
||||
|
||||
cursor.execute(query, tuple(values))
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
# After adding, redirect to the page that shows all records
|
||||
return redirect(url_for('display_itr'))
|
||||
|
||||
# If it's a GET request, just show the blank form to add a record
|
||||
return render_template('add_itr.html')
|
||||
# # cursor.execute(query, tuple(values))
|
||||
|
||||
# cursor.callproc('InsertITR', values)
|
||||
|
||||
# conn.commit()
|
||||
# cursor.close()
|
||||
# conn.close()
|
||||
# flash("ITAT record added successfully!", "success")
|
||||
# # After adding, redirect to the page that shows all records
|
||||
# return redirect(url_for('display_itr'))
|
||||
|
||||
# # If it's a GET request, just show the blank form to add a record
|
||||
# return render_template('add_itr.html')
|
||||
|
||||
|
||||
## 3. UPDATE an existing ITR record
|
||||
@@ -201,52 +181,86 @@ def update_itr(id):
|
||||
|
||||
## 4. DELETE an ITR record
|
||||
# This route also needs an ID to know which record to delete.
|
||||
# @app.route('/itr/delete/<int:id>', methods=['POST'])
|
||||
# def delete_itr(id):
|
||||
# conn = get_db_connection()
|
||||
# cursor = conn.cursor()
|
||||
# cursor.execute("DELETE FROM itr WHERE id = %s", (id,))
|
||||
# conn.commit()
|
||||
# cursor.close()
|
||||
# conn.close()
|
||||
# # After deleting, redirect back to the display page
|
||||
# return redirect(url_for('display_itr'))
|
||||
|
||||
|
||||
# @app.route('/itr', methods=['GET', 'POST'])
|
||||
# def itr_form():
|
||||
# if request.method == 'POST':
|
||||
# data = {key: request.form.get(key, 0) for key in request.form}
|
||||
# conn = mysql.connector.connect(**db_config)
|
||||
# cursor = conn.cursor()
|
||||
# query = """
|
||||
# INSERT INTO itr (
|
||||
# year, 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
|
||||
# ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
# """
|
||||
# values = tuple([
|
||||
# int(data.get('year', 0))
|
||||
# ] + [
|
||||
# float(data.get(col, 0)) for col in [
|
||||
# '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'
|
||||
# ]
|
||||
# ])
|
||||
# cursor.execute(query, values)
|
||||
# conn.commit()
|
||||
# flash("ITR record deleted successfully!", "success")
|
||||
# cursor.close()
|
||||
# conn.close()
|
||||
# return redirect(url_for('index'))
|
||||
# return render_template('itr_form.html')
|
||||
|
||||
|
||||
# new new ---
|
||||
@app.route('/itr_records')
|
||||
def display_itr():
|
||||
itr = ITRHandler()
|
||||
records = itr.get_all_itr()
|
||||
itr.close()
|
||||
return render_template('display_itr.html', records=records)
|
||||
|
||||
|
||||
# new new ---
|
||||
@app.route('/itr/add', methods=['GET', 'POST'])
|
||||
def add_itr():
|
||||
if request.method == 'POST':
|
||||
|
||||
itr = ITRHandler()
|
||||
itr.add_itr(request.form)
|
||||
itr.close()
|
||||
flash("ITR record added successfully!", "success")
|
||||
return redirect(url_for('display_itr'))
|
||||
|
||||
return render_template('add_itr.html')
|
||||
|
||||
# new new ---
|
||||
@app.route('/itr/delete/<int:id>', methods=['POST'])
|
||||
def delete_itr(id):
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM itr WHERE id = %s", (id,))
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
# After deleting, redirect back to the display page
|
||||
itr = ITRHandler()
|
||||
itr.delete_itr_by_id(id=id)
|
||||
itr.close()
|
||||
return redirect(url_for('display_itr'))
|
||||
|
||||
|
||||
@app.route('/itr', methods=['GET', 'POST'])
|
||||
def itr_form():
|
||||
if request.method == 'POST':
|
||||
data = {key: request.form.get(key, 0) for key in request.form}
|
||||
conn = mysql.connector.connect(**db_config)
|
||||
cursor = conn.cursor()
|
||||
query = """
|
||||
INSERT INTO itr (
|
||||
year, 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
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
"""
|
||||
values = tuple([
|
||||
int(data.get('year', 0))
|
||||
] + [
|
||||
float(data.get(col, 0)) for col in [
|
||||
'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'
|
||||
]
|
||||
])
|
||||
cursor.execute(query, values)
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return redirect(url_for('index'))
|
||||
return render_template('itr_form.html')
|
||||
|
||||
|
||||
#
|
||||
@@ -258,17 +272,25 @@ def itr_form():
|
||||
## ===============================================
|
||||
|
||||
# DISPLAY all AO records
|
||||
# @app.route('/ao_records')
|
||||
# def display_ao():
|
||||
# conn = get_db_connection()
|
||||
# cursor = conn.cursor(dictionary=True) # dictionary=True to access fields by name
|
||||
# cursor.execute("SELECT * FROM ao ORDER BY year DESC, id DESC")
|
||||
# ao_records = cursor.fetchall()
|
||||
# cursor.close()
|
||||
# conn.close()
|
||||
# return render_template('display_ao.html', ao_records=ao_records)
|
||||
|
||||
@app.route('/ao_records')
|
||||
def display_ao():
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor(dictionary=True)
|
||||
# Note: Querying the 'ao' table
|
||||
cursor.execute("SELECT * FROM ao ORDER BY year DESC, id DESC")
|
||||
records = cursor.fetchall()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
# Note: Rendering the 'display_ao.html' template
|
||||
return render_template('display_ao.html', records=records)
|
||||
ao = AOHandler()
|
||||
ao_records = ao.get_all_ao()
|
||||
ao.close()
|
||||
return render_template('display_ao.html', ao_records=ao_records)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ADD a new AO record
|
||||
@@ -277,8 +299,6 @@ def add_ao():
|
||||
if request.method == 'POST':
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Define the columns for the 'ao' table
|
||||
columns = [
|
||||
'year', 'gross_total_income', 'disallowance_14a', 'disallowance_37',
|
||||
'deduction_80ia_business', 'deduction_sec37_disallowance', 'deduction_80g',
|
||||
@@ -286,75 +306,82 @@ def add_ao():
|
||||
'surcharge_12', 'edu_cess_3', 'total_tax_payable', 'mat_credit',
|
||||
'interest_234c', 'total_tax', 'advance_tax', 'tds', 'tcs',
|
||||
'tax_on_assessment', 'refund'
|
||||
] # Make sure these match your 'ao' table columns!
|
||||
|
||||
# Note: Inserting into the 'ao' table
|
||||
query = f"INSERT INTO ao ({', '.join(columns)}) VALUES ({', '.join(['%s'] * len(columns))})"
|
||||
]
|
||||
values = [request.form.get(col, 0) for col in columns]
|
||||
|
||||
query = f"INSERT INTO ao ({', '.join(columns)}) VALUES ({', '.join(['%s'] * len(columns))})"
|
||||
cursor.execute(query, tuple(values))
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
# Note: Redirecting to the 'display_ao' function
|
||||
|
||||
flash("AO record added successfully!", "success")
|
||||
return redirect(url_for('display_ao'))
|
||||
|
||||
# Note: Rendering the 'add_ao.html' template
|
||||
return render_template('add_ao.html')
|
||||
|
||||
|
||||
|
||||
# (You will also need to add update_ao and delete_ao functions later)
|
||||
# UPDATE AO record
|
||||
@app.route('/ao/update/<int:id>', methods=['GET', 'POST'])
|
||||
def update_ao(id):
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor(dictionary=True)
|
||||
cursor.execute("SELECT * FROM ao WHERE id = %s", (id,))
|
||||
ao_record = cursor.fetchone()
|
||||
|
||||
if not ao_record:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return "AO record not found", 404
|
||||
|
||||
@app.route('/ao', methods=['GET', 'POST'])
|
||||
def ao_form():
|
||||
if request.method == 'POST':
|
||||
data = {key: request.form.get(key, 0) for key in request.form}
|
||||
conn = mysql.connector.connect(**db_config)
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = """
|
||||
INSERT INTO ao (
|
||||
year, 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
|
||||
) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
"""
|
||||
|
||||
values = tuple([
|
||||
data.get('year'),
|
||||
float(data.get('gross_total_income', 0)),
|
||||
float(data.get('disallowance_14a', 0)),
|
||||
float(data.get('disallowance_37', 0)),
|
||||
float(data.get('deduction_80ia_business', 0)),
|
||||
float(data.get('deduction_sec37_disallowance', 0)),
|
||||
float(data.get('deduction_80g', 0)),
|
||||
float(data.get('net_taxable_income', 0)),
|
||||
float(data.get('tax_30_percent', 0)),
|
||||
float(data.get('tax_book_profit_18_5', 0)),
|
||||
float(data.get('surcharge_12', 0)),
|
||||
float(data.get('edu_cess_3', 0)),
|
||||
float(data.get('total_tax_payable', 0)),
|
||||
float(data.get('mat_credit', 0)),
|
||||
float(data.get('interest_234c', 0)),
|
||||
float(data.get('total_tax', 0)),
|
||||
float(data.get('advance_tax', 0)),
|
||||
float(data.get('tds', 0)),
|
||||
float(data.get('tcs', 0)),
|
||||
float(data.get('tax_on_assessment', 0)),
|
||||
float(data.get('refund', 0)),
|
||||
])
|
||||
|
||||
cursor.execute(query, values)
|
||||
columns = [
|
||||
'year', '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'
|
||||
]
|
||||
values = [request.form.get(col, 0) for col in columns]
|
||||
set_clause = ", ".join([f"{col}=%s" for col in columns])
|
||||
query = f"UPDATE ao SET {set_clause} WHERE id=%s"
|
||||
cursor.execute(query, tuple(values) + (id,))
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return redirect(url_for('index'))
|
||||
flash("AO record updated successfully!", "success")
|
||||
return redirect(url_for('display_ao'))
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return render_template('update_ao.html', record=ao_record)
|
||||
|
||||
|
||||
|
||||
# DELETE AO record safely
|
||||
@app.route('/ao/delete/<int:id>', methods=['POST'])
|
||||
def delete_ao(id):
|
||||
try:
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
# Delete dependent CIT records first
|
||||
cursor.execute("DELETE FROM ao WHERE id = %s", (id,))
|
||||
|
||||
|
||||
# Then delete AO record
|
||||
cursor.execute("DELETE FROM ao WHERE id = %s", (id,))
|
||||
conn.commit()
|
||||
flash("AO record deleted successfully!", "success")
|
||||
except Exception as err:
|
||||
flash(f"Error deleting AO: {err}", "danger")
|
||||
finally:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return redirect(url_for('display_ao'))
|
||||
|
||||
|
||||
return render_template('ao_form.html')
|
||||
|
||||
|
||||
#
|
||||
@@ -370,13 +397,12 @@ def ao_form():
|
||||
def display_cit():
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor(dictionary=True)
|
||||
# Querying the 'cit' table
|
||||
cursor.execute("SELECT * FROM cit ORDER BY year DESC, id DESC")
|
||||
records = cursor.fetchall()
|
||||
cit_records = cursor.fetchall()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
# Rendering the 'display_cit.html' template
|
||||
return render_template('display_cit.html', records=records)
|
||||
return render_template('display_cit.html', cit_records=cit_records)
|
||||
|
||||
|
||||
|
||||
# ADD a new CIT record
|
||||
@@ -386,28 +412,71 @@ def add_cit():
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
|
||||
# IMPORTANT: These columns match your 'cit' table structure
|
||||
columns = [
|
||||
'year', 'gross_total_income', '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'
|
||||
"year", "gross_total_income", "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"
|
||||
]
|
||||
|
||||
# Inserting into the 'cit' table
|
||||
query = f"INSERT INTO cit ({', '.join(columns)}) VALUES ({', '.join(['%s'] * len(columns))})"
|
||||
values = [request.form.get(col, 0) for col in columns]
|
||||
|
||||
query = f"INSERT INTO cit ({', '.join(columns)}) VALUES ({', '.join(['%s']*len(columns))})"
|
||||
cursor.execute(query, tuple(values))
|
||||
conn.commit()
|
||||
flash("ITAT record added successfully!", "success")
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return redirect(url_for('display_cit'))
|
||||
|
||||
return render_template('add_cit.html')
|
||||
|
||||
@app.route('/cit/update/<int:id>', methods=['GET', 'POST'])
|
||||
def update_cit(id):
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor(dictionary=True)
|
||||
cursor.execute("SELECT * FROM cit WHERE id=%s", (id,))
|
||||
record = cursor.fetchone()
|
||||
if not record:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return "CIT record not found", 404
|
||||
|
||||
if request.method == 'POST':
|
||||
columns = [
|
||||
"year", "gross_total_income", "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"
|
||||
]
|
||||
values = [request.form.get(col, 0) for col in columns]
|
||||
set_clause = ", ".join([f"{col}=%s" for col in columns])
|
||||
query = f"UPDATE cit SET {set_clause} WHERE id=%s"
|
||||
cursor.execute(query, tuple(values)+(id,))
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return redirect(url_for('display_cit'))
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return render_template('add_cit.html', record=record)
|
||||
|
||||
|
||||
@app.route('/cit/delete/<int:id>', methods=['POST'])
|
||||
def delete_cit(id):
|
||||
try:
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM cit WHERE id=%s", (id,))
|
||||
conn.commit()
|
||||
flash("ITR record deleted successfully!", "success")
|
||||
except Exception as err:
|
||||
print(f"Error deleting CIT record: {err}")
|
||||
finally:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
# Redirecting to the 'display_cit' function
|
||||
return redirect(url_for('display_cit'))
|
||||
|
||||
# Rendering the 'add_cit.html' template
|
||||
return render_template('add_cit.html')
|
||||
|
||||
|
||||
# (You will also need to add update_cit and delete_cit functions later)
|
||||
@@ -438,28 +507,83 @@ def display_itat():
|
||||
# ADD a new ITAT record
|
||||
@app.route('/itat/add', methods=['GET', 'POST'])
|
||||
def add_itat():
|
||||
if request.method == 'POST':
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
cursor = conn.cursor(dictionary=True)
|
||||
|
||||
# NOTE: These are the specific columns for your 'itat' table
|
||||
columns = [
|
||||
'year', 'mat_tax_credit', 'surcharge', 'cess', 'total_credit'
|
||||
]
|
||||
# Fetch all CIT records to choose from
|
||||
cursor.execute("SELECT id, year FROM cit ORDER BY year DESC")
|
||||
cit_records = cursor.fetchall()
|
||||
|
||||
# Inserting into the 'itat' table
|
||||
if request.method == 'POST':
|
||||
cit_id = request.form.get('cit_id') # selected parent CIT id
|
||||
columns = ['id', 'year','mat_tax_credit', 'surcharge', 'cess', 'total_credit']
|
||||
values = [cit_id,
|
||||
request.form.get('year', 0),
|
||||
request.form.get('mat_tax_credit', 0),
|
||||
request.form.get('surcharge', 0),
|
||||
request.form.get('cess', 0),
|
||||
request.form.get('total_credit', 0)]
|
||||
query = f"INSERT INTO itat ({', '.join(columns)}) VALUES ({', '.join(['%s'] * len(columns))})"
|
||||
values = [request.form.get(col, 0) for col in columns]
|
||||
|
||||
cursor.execute(query, tuple(values))
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
# Redirecting to the 'display_itat' function
|
||||
flash("ITAT record added successfully!", "success")
|
||||
return redirect(url_for('display_itat'))
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return render_template('add_itat.html', cit_records=cit_records)
|
||||
|
||||
|
||||
@app.route('/itat/update/<int:id>', methods=['GET', 'POST'])
|
||||
def update_itat(id):
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor(dictionary=True)
|
||||
|
||||
# Fetch the existing record
|
||||
cursor.execute("SELECT * FROM itat WHERE id=%s", (id,))
|
||||
record = cursor.fetchone()
|
||||
|
||||
if not record:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
flash("ITAT record not found!", "danger")
|
||||
return redirect(url_for('display_itat'))
|
||||
|
||||
if request.method == 'POST':
|
||||
columns = ['year', 'mat_tax_credit', 'surcharge', 'cess', 'total_credit']
|
||||
values = [request.form.get(col, 0) for col in columns]
|
||||
set_clause = ", ".join([f"{col}=%s" for col in columns])
|
||||
query = f"UPDATE itat SET {set_clause} WHERE id=%s"
|
||||
cursor.execute(query, tuple(values) + (id,))
|
||||
conn.commit()
|
||||
cursor.close()
|
||||
conn.close()
|
||||
flash("ITAT record updated successfully!", "success")
|
||||
return redirect(url_for('display_itat'))
|
||||
|
||||
cursor.close()
|
||||
conn.close()
|
||||
# Render a template with existing values filled in
|
||||
return render_template('update_itat.html', record=record)
|
||||
|
||||
|
||||
@app.route('/itat/delete/<int:id>', methods=['POST'])
|
||||
def delete_itat(id):
|
||||
try:
|
||||
conn = get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM itat WHERE id=%s", (id,))
|
||||
conn.commit()
|
||||
flash("ITAT record deleted successfully!", "success")
|
||||
except Exception as err:
|
||||
flash(f"Error deleting ITAT: {err}", "danger")
|
||||
finally:
|
||||
cursor.close()
|
||||
conn.close()
|
||||
return redirect(url_for('display_itat'))
|
||||
|
||||
# Rendering the 'add_itat.html' template
|
||||
return render_template('add_itat.html')
|
||||
|
||||
|
||||
# (You will also need to add update_itat and delete_itat functions later)
|
||||
|
||||
BIN
static/uploads/AY_18-19_REfund_Working.xlsx
Normal file
BIN
static/uploads/AY_18-19_REfund_Working.xlsx
Normal file
Binary file not shown.
BIN
static/uploads/ITR_Report_2001_4.xlsx
Normal file
BIN
static/uploads/ITR_Report_2001_4.xlsx
Normal file
Binary file not shown.
BIN
static/uploads/LaxmiBrochure_Concept_VishalMistry_17Nov.pdf
Normal file
BIN
static/uploads/LaxmiBrochure_Concept_VishalMistry_17Nov.pdf
Normal file
Binary file not shown.
127
templates/add_ao.html
Normal file
127
templates/add_ao.html
Normal file
@@ -0,0 +1,127 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>AO Form Entry</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||
<style>
|
||||
/* Reset and base styles */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f5f7fa;
|
||||
color: #333;
|
||||
padding: 30px 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
margin: auto;
|
||||
background-color: #fff;
|
||||
padding: 40px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
font-size: 28px;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
label {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
input[type="number"]:focus {
|
||||
border-color: #007BFF;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
margin-top: 30px;
|
||||
padding: 12px;
|
||||
background-color: #007BFF;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
button[type="submit"]:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>AO Form Entry</h2>
|
||||
<form method="POST" onsubmit="return showSuccessMessage()">
|
||||
<label>Year:</label>
|
||||
<input type="number" name="year" required>
|
||||
{% for field in [
|
||||
"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"
|
||||
] %}
|
||||
<label for="{{ field }}">{{ field.replace("_", " ").title() }}:</label>
|
||||
<input type="number" name="{{ field }}" step="0.01" required>
|
||||
{% endfor %}
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- JavaScript Alert -->
|
||||
<script>
|
||||
function showSuccessMessage() {
|
||||
alert("Form submitted successfully!");
|
||||
return true; // allow form to submit after showing alert
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
124
templates/add_cit.html
Normal file
124
templates/add_cit.html
Normal file
@@ -0,0 +1,124 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>CIT Form Entry</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||
<style>
|
||||
/* ...existing styles... (no changes needed) */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f5f7fa;
|
||||
color: #333;
|
||||
padding: 30px 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
margin: auto;
|
||||
background-color: #fff;
|
||||
padding: 40px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
font-size: 28px;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
label {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
input[type="number"]:focus {
|
||||
border-color: #007BFF;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
margin-top: 30px;
|
||||
padding: 12px;
|
||||
background-color: #007BFF;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button[type="submit"]:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>CIT Form Entry</h2>
|
||||
<form method="POST">
|
||||
<label>Year:</label>
|
||||
<input type="number" name="year" required value="{{ record.year if record else '' }}">
|
||||
|
||||
{% for field in [
|
||||
"gross_total_income", "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"
|
||||
] %}
|
||||
<label for="{{ field }}">{{ field.replace("_", " ").title() }}:</label>
|
||||
<input type="number" name="{{ field }}" step="0.01" required value="{{ record[field] if record else '' }}">
|
||||
{% endfor %}
|
||||
<button type="submit">{{ 'Update' if record else 'Submit' }}</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showSuccessMessage() {
|
||||
alert("Form submitted successfully!");
|
||||
return true; // continue with form submission
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
126
templates/add_itat.html
Normal file
126
templates/add_itat.html
Normal file
@@ -0,0 +1,126 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>ITAT Form Entry</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||
<style>
|
||||
/* Same styling for layout */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f5f7fa;
|
||||
color: #333;
|
||||
padding: 30px 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 90%;
|
||||
max-width: 700px;
|
||||
margin: auto;
|
||||
background-color: #fff;
|
||||
padding: 40px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
font-size: 28px;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
label {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 6px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 6px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
input[type="number"]:focus {
|
||||
border-color: #007BFF;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
margin-top: 30px;
|
||||
padding: 12px;
|
||||
background-color: #007BFF;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button[type="submit"]:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>ITAT Form Entry</h2>
|
||||
<form method="POST" onsubmit="return showSuccessMessage()">
|
||||
<label>Year:</label>
|
||||
<input type="number" name="year" step="0.01" required>
|
||||
|
||||
<label>MAT Tax Credit:</label>
|
||||
<input type="number" name="mat_tax_credit" step="0.01" required>
|
||||
|
||||
<label>Surcharge:</label>
|
||||
<input type="number" name="surcharge" step="0.01" required>
|
||||
|
||||
<label>Cess:</label>
|
||||
<input type="number" name="cess" step="0.01" required>
|
||||
|
||||
<label>Total Credit:</label>
|
||||
<input type="number" name="total_credit" step="0.01" required>
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showSuccessMessage() {
|
||||
alert("Form submitted successfully!");
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,8 +1,116 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Add New Income Tax Return Record</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
||||
background: #eef2f7;
|
||||
margin: 0;
|
||||
padding: 40px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 900px;
|
||||
margin: auto;
|
||||
background: #fff;
|
||||
padding: 40px 50px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 6px 25px rgba(0, 0, 0, 0.1);
|
||||
transition: box-shadow 0.3s ease;
|
||||
}
|
||||
|
||||
.container:hover {
|
||||
box-shadow: 0 10px 35px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
margin-bottom: 35px;
|
||||
font-size: 30px;
|
||||
color: #2c3e50;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
form {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20px 30px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
label {
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
color: #555;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
input[type="number"] {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid #ccd1d9;
|
||||
border-radius: 6px;
|
||||
font-size: 15px;
|
||||
background-color: #fafafa;
|
||||
transition: all 0.25s ease-in-out;
|
||||
}
|
||||
|
||||
input[type="number"]:focus {
|
||||
border-color: #007BFF;
|
||||
background: #fff;
|
||||
box-shadow: 0 0 8px rgba(0, 123, 255, 0.25);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
grid-column: span 2;
|
||||
margin-top: 25px;
|
||||
padding: 15px;
|
||||
background: linear-gradient(135deg, #007BFF, #0056b3);
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
color: #fff;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s, background 0.3s;
|
||||
}
|
||||
|
||||
button[type="submit"]:hover {
|
||||
background: linear-gradient(135deg, #0056b3, #00408f);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Add New Income Tax Return Record</h2>
|
||||
<form method="POST" action="{{ url_for('add_itr') }}">
|
||||
<div class="form-group">
|
||||
<label>Year:</label>
|
||||
<input type="number" name="year" required>
|
||||
</div>
|
||||
|
||||
{% for field in [
|
||||
"gross_total_income", "disallowance_14a", "disallowance_37",
|
||||
"deduction_80ia_business", "deduction_80ia_misc", "deduction_80ia_other",
|
||||
@@ -11,9 +119,15 @@
|
||||
"edu_cess_3", "total_tax_payable", "mat_credit", "interest_234c",
|
||||
"total_tax", "advance_tax", "tds", "tcs", "tax_on_assessment", "refund"
|
||||
] %}
|
||||
<div class="form-group">
|
||||
<label>{{ field.replace("_", " ").title() }}:</label>
|
||||
<input type="number" name="{{ field }}" step="any" value="0.00" required>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
78
templates/display_ao.html
Normal file
78
templates/display_ao.html
Normal file
@@ -0,0 +1,78 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>AO Records</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: #f8f9fa; padding: 20px; color: #333; }
|
||||
.container { max-width: 95%; margin: auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
|
||||
h2 { text-align: center; margin-bottom: 20px; }
|
||||
.btn { padding: 8px 15px; border-radius: 5px; text-decoration: none; color: white; border: none; cursor: pointer; font-size: 14px; }
|
||||
.btn-add { background-color: #28a745; display: inline-block; margin-bottom: 20px; }
|
||||
.btn-update { background-color: #007bff; }
|
||||
.btn-delete { background-color: #dc3545; }
|
||||
.action-cell form { display: inline-block; margin-left: 5px; }
|
||||
.table-wrapper { overflow-x: auto; }
|
||||
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
|
||||
th, td { padding: 12px; border: 1px solid #dee2e6; text-align: right; white-space: nowrap; }
|
||||
th { background-color: #343a40; color: white; text-align: center; }
|
||||
tr:nth-child(even) { background-color: #f2f2f2; }
|
||||
td:first-child, th:first-child { text-align: left; }
|
||||
.alert { padding: 10px 15px; margin-bottom: 20px; border-radius: 5px; }
|
||||
.alert-success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
|
||||
.alert-danger { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Assessing Officer Records 👨💼</h2>
|
||||
|
||||
<!-- Flash Messages -->
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ category }}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<a href="{{ url_for('add_ao') }}" class="btn btn-add">➕ Add AO Record</a>
|
||||
|
||||
{% if ao_records %}
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Year</th>
|
||||
<th>Gross Total Income</th>
|
||||
<th>Net Taxable Income</th>
|
||||
<th>Total Tax</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ao in ao_records %}
|
||||
<tr>
|
||||
<td>{{ ao.id }}</td>
|
||||
<td>{{ ao.year }}</td>
|
||||
<td>{{ ao.gross_total_income }}</td>
|
||||
<td>{{ ao.net_taxable_income }}</td>
|
||||
<td>{{ ao.total_tax }}</td>
|
||||
<td class="action-cell">
|
||||
<a href="{{ url_for('update_ao', id=ao.id) }}" class="btn btn-update">Edit</a>
|
||||
<form action="{{ url_for('delete_ao', id=ao.id) }}" method="POST" style="display:inline;">
|
||||
<button type="submit" class="btn btn-delete" onclick="return confirm('Are you sure you want to delete this AO?');">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p style="text-align: center; margin-top: 20px;">No AO records found. Add one above!</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
66
templates/display_cit.html
Normal file
66
templates/display_cit.html
Normal file
@@ -0,0 +1,66 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>CIT Records</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: #f8f9fa; padding: 20px; color: #333; }
|
||||
.container { max-width: 95%; margin: auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
|
||||
h2 { text-align: center; margin-bottom: 20px; }
|
||||
.btn { padding: 8px 15px; border-radius: 5px; text-decoration: none; color: white; border: none; cursor: pointer; font-size: 14px; }
|
||||
.btn-add { background-color: #28a745; display: inline-block; margin-bottom: 20px; }
|
||||
.btn-update { background-color: #007bff; }
|
||||
.btn-delete { background-color: #dc3545; }
|
||||
.action-cell form { display: inline-block; margin-left: 5px; }
|
||||
.table-wrapper { overflow-x: auto; }
|
||||
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
|
||||
th, td { padding: 12px; border: 1px solid #dee2e6; text-align: right; white-space: nowrap; }
|
||||
th { background-color: #343a40; color: white; text-align: center; }
|
||||
tr:nth-child(even) { background-color: #f2f2f2; }
|
||||
td:first-child, th:first-child { text-align: left; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>CIT Records 🧾</h2>
|
||||
<a href="{{ url_for('add_cit') }}" class="btn btn-add">➕ Add New Record</a>
|
||||
|
||||
{% if cit_records %}
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Year</th>
|
||||
<th>Gross Total Income</th>
|
||||
<th>Net Taxable Income</th>
|
||||
<th>Total Tax Payable</th>
|
||||
<th>Refund</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for record in cit_records %}
|
||||
<tr>
|
||||
<td>{{ record.year }}</td>
|
||||
<td>{{ "{:,.2f}".format(record.gross_total_income) }}</td>
|
||||
<td>{{ "{:,.2f}".format(record.net_taxable_income) }}</td>
|
||||
<td>{{ "{:,.2f}".format(record.total_tax_payable) }}</td>
|
||||
<td>{{ "{:,.2f}".format(record.refund) }}</td>
|
||||
<td class="action-cell">
|
||||
<a href="{{ url_for('update_cit', id=record.id) }}" class="btn btn-update">Edit</a>
|
||||
|
||||
<form action="{{ url_for('delete_cit', id=record.id) }}" method="post" onsubmit="return confirm('Are you sure you want to delete this record?');">
|
||||
<button type="submit" class="btn btn-delete">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p style="text-align: center; margin-top: 20px;">No records found. Click the button above to add one!</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
75
templates/display_itat.html
Normal file
75
templates/display_itat.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>ITAT Records</title>
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: #f8f9fa; padding: 20px; color: #333; }
|
||||
.container { max-width: 95%; margin: auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
|
||||
h2 { text-align: center; margin-bottom: 20px; }
|
||||
.btn { padding: 8px 15px; border-radius: 5px; text-decoration: none; color: white; border: none; cursor: pointer; font-size: 14px; }
|
||||
.btn-add { background-color: #28a745; display: inline-block; margin-bottom: 20px; }
|
||||
.btn-update { background-color: #007bff; }
|
||||
.btn-delete { background-color: #dc3545; }
|
||||
.action-cell form { display: inline-block; margin-left: 5px; }
|
||||
.table-wrapper { overflow-x: auto; }
|
||||
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
|
||||
th, td { padding: 12px; border: 1px solid #dee2e6; text-align: right; white-space: nowrap; }
|
||||
th { background-color: #343a40; color: white; text-align: center; }
|
||||
tr:nth-child(even) { background-color: #f2f2f2; }
|
||||
td:first-child, th:first-child { text-align: left; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>ITAT Records 📄</h2>
|
||||
<a href="{{ url_for('add_itat') }}" class="btn btn-add">➕ Add New Record</a>
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ category }}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% if records %}
|
||||
<div class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Year</th>
|
||||
<th>MAT Tax Credit</th>
|
||||
<th>Surcharge</th>
|
||||
<th>Cess</th>
|
||||
<th>Total Credit</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for record in records %}
|
||||
<tr>
|
||||
<td>{{ record.year }}</td>
|
||||
<td>{{ "{:,.2f}".format(record.mat_tax_credit) }}</td>
|
||||
<td>{{ "{:,.2f}".format(record.surcharge) }}</td>
|
||||
<td>{{ "{:,.2f}".format(record.cess) }}</td>
|
||||
<td>{{ "{:,.2f}".format(record.total_credit) }}</td>
|
||||
<td class="action-cell">
|
||||
<a href="{{ url_for('update_itat', id=record.id) }}" class="btn btn-update">Edit</a>
|
||||
|
||||
|
||||
<form action="{{ url_for('delete_itat', id=record.id) }}" method="post" onsubmit="return confirm('Are you sure you want to delete this record?');">
|
||||
<button type="submit" class="btn btn-delete">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p style="text-align: center; margin-top: 20px;">No ITAT records found. Click the button above to add one!</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,7 +9,6 @@
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||
|
||||
<style>
|
||||
|
||||
/* Existing CSS here... */
|
||||
|
||||
* {
|
||||
@@ -185,7 +184,6 @@ font-size: 16px;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
30
templates/update_ao.html
Normal file
30
templates/update_ao.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Update AO Record</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: #f8f9fa; padding: 20px; color: #333; }
|
||||
.container { max-width: 600px; margin: auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
|
||||
h2 { text-align: center; margin-bottom: 20px; }
|
||||
label { display: block; margin-top: 10px; font-weight: bold; }
|
||||
input { width: 100%; padding: 8px; margin-top: 5px; border-radius: 5px; border: 1px solid #ccc; }
|
||||
button { margin-top: 20px; padding: 10px 15px; border: none; border-radius: 5px; background-color: #007bff; color: white; cursor: pointer; font-size: 16px; }
|
||||
button:hover { background-color: #0056b3; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Update AO Record for Year {{ record.year }}</h2>
|
||||
<form method="POST" action="{{ url_for('update_ao', id=record.id) }}">
|
||||
{% for field in record.keys() if field != 'id' %}
|
||||
<label>{{ field.replace("_", " ").title() }}:</label>
|
||||
<input type="number" step="any" name="{{ field }}" value="{{ record[field] }}" required>
|
||||
{% endfor %}
|
||||
<button type="submit">Update Record</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
29
templates/update_cit.html
Normal file
29
templates/update_cit.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Update CIT Record</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||
<style>
|
||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background-color: #f8f9fa; padding: 20px; color: #333; }
|
||||
.container { max-width: 700px; margin: auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
|
||||
h2 { text-align: center; margin-bottom: 20px; }
|
||||
label { display: block; margin-top: 15px; font-weight: bold; }
|
||||
input[type="number"] { width: 100%; padding: 10px; margin-top: 5px; border: 1px solid #ccc; border-radius: 5px; }
|
||||
button[type="submit"] { margin-top: 20px; padding: 12px 20px; background-color: #007bff; color: white; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
|
||||
button[type="submit"]:hover { background-color: #0056b3; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Update CIT Record for Year {{ record.year }}</h2>
|
||||
<form method="POST" action="{{ url_for('update_cit', id=record.id) }}">
|
||||
{% for field in record.keys() if field != 'id' %}
|
||||
<label>{{ field.replace("_", " ").title() }}:</label>
|
||||
<input type="number" name="{{ field }}" step="0.01" value="{{ record[field] }}" required>
|
||||
{% endfor %}
|
||||
<button type="submit">Update Record</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
30
templates/update_itat.html
Normal file
30
templates/update_itat.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Update ITAT Record</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Update ITAT Record for Year {{ record.year }}</h2>
|
||||
<form method="POST" action="{{ url_for('update_itat', id=record.id) }}">
|
||||
<label>Year:</label>
|
||||
<input type="number" name="year" step="1" value="{{ record.year }}" required>
|
||||
|
||||
<label>MAT Tax Credit:</label>
|
||||
<input type="number" name="mat_tax_credit" step="0.01" value="{{ record.mat_tax_credit }}" required>
|
||||
|
||||
<label>Surcharge:</label>
|
||||
<input type="number" name="surcharge" step="0.01" value="{{ record.surcharge }}" required>
|
||||
|
||||
<label>Cess:</label>
|
||||
<input type="number" name="cess" step="0.01" value="{{ record.cess }}" required>
|
||||
|
||||
<label>Total Credit:</label>
|
||||
<input type="number" name="total_credit" step="0.01" value="{{ record.total_credit }}" required>
|
||||
|
||||
<button type="submit">Update Record</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>View Documents</title>
|
||||
<style>
|
||||
@@ -72,7 +73,8 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
th, td {
|
||||
th,
|
||||
td {
|
||||
padding: 12px 15px;
|
||||
border: 1px solid #ddd;
|
||||
text-align: center;
|
||||
@@ -108,6 +110,7 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2>Document Records</h2>
|
||||
@@ -154,11 +157,13 @@
|
||||
<td>{{ doc.year }}</td>
|
||||
<td>{{ doc.uploaded_at }}</td>
|
||||
<td><a href="{{ url_for('uploaded_file', filename=doc.filename) }}?mode=download">Download</a></td>
|
||||
<td><a href="{{ url_for('uploaded_file', filename=doc.filename) }}?mode=view" target="_blank">View</a></td>
|
||||
<td><a href="{{ url_for('uploaded_file', filename=doc.filename) }}?mode=view"
|
||||
target="_blank">View</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
103
test.py
Normal file
103
test.py
Normal file
@@ -0,0 +1,103 @@
|
||||
import os
|
||||
from AppCode.Config import DBConfig
|
||||
from AppCode.FileHandler import FileHandler
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
class DocumentHandler:
|
||||
|
||||
years = ""
|
||||
documents = ""
|
||||
isSuccess = False
|
||||
resultMessage = ""
|
||||
|
||||
def View(self,request):
|
||||
year = request.args.get('year')
|
||||
stage = request.args.get('stage')
|
||||
dbconfig = DBConfig()
|
||||
connection = dbconfig.get_db_connection()
|
||||
|
||||
if not connection:
|
||||
self.isSuccess = False
|
||||
return
|
||||
cursor = connection.cursor()
|
||||
|
||||
params = []
|
||||
query = "SELECT * FROM documents WHERE 1=1"
|
||||
|
||||
if year:
|
||||
query += " AND year = %s"
|
||||
params.append(year)
|
||||
if stage:
|
||||
query += " AND stage = %s"
|
||||
params.append(stage)
|
||||
|
||||
|
||||
cursor.execute(query, params)
|
||||
documentsdata = cursor.fetchall()
|
||||
print("*************")
|
||||
print(documentsdata)
|
||||
cursor.callproc("GetYear")
|
||||
|
||||
# records = []
|
||||
# for result in cursor.stored_results():
|
||||
# records = result.fetchall()
|
||||
|
||||
yearsdata = ""
|
||||
for res in cursor.stored_results():
|
||||
yearsdata = res.fetchall()
|
||||
print(yearsdata)
|
||||
|
||||
self.years = yearsdata
|
||||
self.documents = documentsdata
|
||||
self.isSuccess = True
|
||||
|
||||
print("document --",documentsdata)
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
|
||||
def Upload(self, request):
|
||||
"""Log user actions with timestamp, user, action, and details."""
|
||||
|
||||
dbconfig = DBConfig()
|
||||
connection = dbconfig.get_db_connection()
|
||||
|
||||
if connection:
|
||||
cursor = connection.cursor()
|
||||
files = request.files.getlist('documents')
|
||||
year = request.form['year']
|
||||
stage = request.form['stage']
|
||||
|
||||
for file in files:
|
||||
if file is not FileHandler.ALLOWED_EXTENSIONS:
|
||||
continue
|
||||
|
||||
|
||||
filename = secure_filename(file.filename)
|
||||
filepath = os.path.join(FileHandler.UPLOAD_FOLDER, filename)
|
||||
extension = file.filename.rsplit('.', 1)[1]
|
||||
# Need to Check whetehr all three items are required
|
||||
|
||||
file.save(filepath)
|
||||
|
||||
# cursor.execute("""
|
||||
# INSERT INTO documents (filename, filepath, filetype, year, stage)
|
||||
# VALUES (%s, %s, %s, %s, %s)
|
||||
# """, (filename, filepath, file.filename.rsplit('.', 1)[1], year, stage))
|
||||
|
||||
|
||||
cursor.callproc('InsertDocument', [
|
||||
filename,
|
||||
filepath,
|
||||
extension,
|
||||
year,
|
||||
stage
|
||||
])
|
||||
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
connection.close()
|
||||
# return redirect(url_for('view_documents'))
|
||||
|
||||
#return render_template('upload.html')
|
||||
Reference in New Issue
Block a user