testing code and modify commit.

This commit is contained in:
2025-12-03 10:49:31 +05:30
parent 3cf258ba0d
commit 21eb55d4b4
7 changed files with 95 additions and 53 deletions

80
main.py
View File

@@ -84,8 +84,6 @@ def uploaded_file(filename):
# @app.route('/itr', methods=['GET', 'POST'])
# def itr_form():
# if request.method == 'POST':
@@ -639,11 +637,9 @@ def add_itat():
# return redirect(url_for('display_itat'))
# (You will also need to add update_itat and delete_itat functions later)
@app.route('/cit', methods=['GET', 'POST'])
def cit_form():
# -------------------- i dont use -------------------------
# @app.route('/cit', methods=['GET', 'POST'])
# def cit_form():
if request.method == 'POST':
data = {key: request.form.get(key, 0) for key in request.form}
conn = mysql.connector.connect(**db_config)
@@ -689,31 +685,31 @@ def cit_form():
return render_template('cit_form.html')
@app.route('/itat', methods=['GET', 'POST'])
def itat_form():
if request.method == 'POST':
mat_tax_credit = request.form['mat_tax_credit']
surcharge = request.form['surcharge']
cess = request.form['cess']
total_credit = request.form['total_credit']
year=request.form['year']
conn = mysql.connector.connect(**db_config)
cursor = conn.cursor()
cursor.execute("""
INSERT INTO itat (year, mat_tax_credit, surcharge, cess, total_credit)
VALUES (%s,%s, %s, %s, %s)
""", (year,mat_tax_credit, surcharge, cess, total_credit))
conn.commit()
cursor.close()
conn.close()
return redirect(url_for('index'))
return render_template('itat_form.html')
# -------------------- i dont use -------------------------
# @app.route('/itat', methods=['GET', 'POST'])
# def itat_form():
# if request.method == 'POST':
# mat_tax_credit = request.form['mat_tax_credit']
# surcharge = request.form['surcharge']
# cess = request.form['cess']
# total_credit = request.form['total_credit']
# year=request.form['year']
# conn = mysql.connector.connect(**db_config)
# cursor = conn.cursor()
# cursor.execute("""
# INSERT INTO itat (year, mat_tax_credit, surcharge, cess, total_credit)
# VALUES (%s,%s, %s, %s, %s)
# """, (year,mat_tax_credit, surcharge, cess, total_credit))
# conn.commit()
# cursor.close()
# conn.close()
# return redirect(url_for('index'))
# return render_template('itat_form.html')
def get_db_connection():
connection = mysql.connector.connect(**db_config)
return connection
# def get_db_connection():
# connection = mysql.connector.connect(**db_config)
# return connection
@app.route('/reports')
def reports():
@@ -1000,21 +996,21 @@ def itat_report():
# finally:
# connection.close()
# -------------------- i dont use -------------------------
# @app.route('/download/<int:doc_id>')
# def download_report(doc_id):
# conn = get_db_connection()
# cursor = conn.cursor(dictionary=True)
@app.route('/download/<int:doc_id>')
def download_report(doc_id):
conn = get_db_connection()
cursor = conn.cursor(dictionary=True)
# cursor.execute("SELECT * FROM documents WHERE id = %s", (doc_id,))
# document = cursor.fetchone()
# conn.close()
cursor.execute("SELECT * FROM documents WHERE id = %s", (doc_id,))
document = cursor.fetchone()
conn.close()
# if not document:
# return "Document not found", 404
if not document:
return "Document not found", 404
file_path = os.path.join('static', 'uploads', document['filename']) # adjust as per your storage
return send_from_directory(directory='static/uploads', path=document['filename'], as_attachment=True)
# file_path = os.path.join('static', 'uploads', document['filename']) # adjust as per your storage
# return send_from_directory(directory='static/uploads', path=document['filename'], as_attachment=True)
# @app.route('/summary_report', methods=['GET'])