diff --git a/AppCode/AOHandler.py b/AppCode/AOHandler.py index b5dd22d..2cc8177 100644 --- a/AppCode/AOHandler.py +++ b/AppCode/AOHandler.py @@ -108,7 +108,7 @@ class AOHandler: "deduction_sec37_disallowance": "On Sec 37 Disallowance", "deduction_80g": "Less: Deduction u/s 80G", "net_taxable_income": "Net Taxable Income", - "-" : "-", + "--" : "-", "per_tax_a" : "Per% Tax @(A)", "tax_a_cal" : "Tax cal(A)", "per_surcharge_a" : "Per% surcharge @(A)", @@ -116,7 +116,7 @@ class AOHandler: "per_cess_a" : "Per% cess(A)", "edu_cess_a_cal" : "Edu cess cal(A)", "sum_of_a" : "Sum of tax_cal(A)", - "-" : "-", + "---" : "-", "per_tax_b" : "Per% Tax @(B)", "tax_b_cal" : "Tax cal(B)", "per_surcharge_b" : "Per% surcharge @(B)", diff --git a/AppCode/CITHandler.py b/AppCode/CITHandler.py index 50d4c79..d3930c3 100644 --- a/AppCode/CITHandler.py +++ b/AppCode/CITHandler.py @@ -103,7 +103,7 @@ class CITHandler: "deduction_sec37_disallowance": "On Sec 37 Disallowance", "deduction_80g": "Less: Deduction u/s 80G", "net_taxable_income": "Net Taxable Income", - "-" : "-", + "--" : "-", "per_tax_a" : "Per% Tax @(A)", "tax_a_cal" : "Tax cal(A)", "per_surcharge_a" : "Per% surcharge @(A)", @@ -111,7 +111,7 @@ class CITHandler: "per_cess_a" : "Per% cess(A)", "edu_cess_a_cal" : "Edu cess cal(A)", "sum_of_a" : "Sum of tax_cal(A)", - "-" : "-", + "---" : "-", "per_tax_b" : "Per% Tax @(B)", "tax_b_cal" : "Tax cal(B)", "per_surcharge_b" : "Per% surcharge @(B)", diff --git a/AppCode/DocumentHandler.py b/AppCode/DocumentHandler.py index b264735..14bcf8c 100644 --- a/AppCode/DocumentHandler.py +++ b/AppCode/DocumentHandler.py @@ -1,6 +1,4 @@ -from flask import ( - render_template, request, send_file, jsonify -) +from flask import render_template, request, send_file, jsonify from werkzeug.utils import secure_filename import pandas as pd import os @@ -111,10 +109,7 @@ class DocumentHandler: file.save(filepath) - cursor.callproc( - 'InsertDocument', - [filename, filepath, extension, year, stage] - ) + cursor.callproc('InsertDocument',[filename, filepath, extension, year, stage]) connection.commit() cursor.close() @@ -124,9 +119,7 @@ class DocumentHandler: # Summary Preview (JSON) # ========================= def Summary_preview(self, request): - """ - Returns JSON preview of summary report for selected year. - """ + year_raw = request.args.get("year") year = self.parse_year(year_raw) @@ -403,26 +396,9 @@ class DocumentHandler: workbook = writer.book worksheet = writer.sheets[sheet_name] - title = workbook.add_format({ - 'bold': True, - 'font_size': 14, - 'align': 'center' - }) - - worksheet.merge_range( - 0, 0, 0, len(df.columns) - 1, - "Laxmi Civil Engineering Services Pvt Ltd", - title - ) - - header = workbook.add_format({ - 'bold': True, - 'align': 'center', - 'bg_color': '#007bff', - 'font_color': 'white', - 'border': 1 - }) - + title = workbook.add_format({'bold': True,'font_size': 14,'align': 'center'}) + worksheet.merge_range(0, 0, 0, len(df.columns) - 1,"Laxmi Civil Engineering Services Pvt Ltd",title) + header = workbook.add_format({'bold': True,'align': 'center', 'bg_color': '#007bff','font_color': 'white','border': 1 }) cell = workbook.add_format({'border': 1}) for col_num, col_name in enumerate(df.columns): diff --git a/AppCode/ITATHandler.py b/AppCode/ITATHandler.py index aef05d9..432d89d 100644 --- a/AppCode/ITATHandler.py +++ b/AppCode/ITATHandler.py @@ -98,7 +98,7 @@ class ITATHandler: "deduction_sec37_disallowance": "On Sec 37 Disallowance", "deduction_80g": "Less: Deduction u/s 80G", "net_taxable_income": "Net Taxable Income", - "-" : "-", + "--" : "-", "per_tax_a" : "Per% Tax @(A)", "tax_a_cal" : "Tax cal(A)", "per_surcharge_a" : "Per% surcharge @(A)", @@ -106,7 +106,7 @@ class ITATHandler: "per_cess_a" : "Per% cess(A)", "edu_cess_a_cal" : "Edu cess cal(A)", "sum_of_a" : "Sum of tax_cal(A)", - "-" : "-", + "---" : "-", "per_tax_b" : "Per% Tax @(B)", "tax_b_cal" : "Tax cal(B)", "per_surcharge_b" : "Per% surcharge @(B)", diff --git a/AppCode/ITRHandler.py b/AppCode/ITRHandler.py index 3fc83fb..7713f59 100644 --- a/AppCode/ITRHandler.py +++ b/AppCode/ITRHandler.py @@ -1,11 +1,8 @@ import mysql.connector import pandas as pd import io -from flask import send_file, render_template, request - from AppCode.Config import DBConfig - class ITRHandler: def __init__(self): @@ -25,16 +22,13 @@ class ITRHandler: 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 @@ -51,10 +45,10 @@ class ITRHandler: ] values = [data.get(col, 0) for col in columns] - # Call your stored procedure self.cursor.callproc("InsertITR", values) self.conn.commit() + except Exception as e: self.conn.rollback() raise e @@ -112,7 +106,7 @@ class ITRHandler: "deduction_sec37_disallowance": "On Sec 37 Disallowance", "deduction_80g": "Less: Deduction u/s 80G", "net_taxable_income": "Net Taxable Income", - "-" : "-", + "--" : "-", "per_tax_a" : "Per% Tax @(A)", "tax_a_cal" : "Tax cal(A)", "per_surcharge_a" : "Per% surcharge @(A)", @@ -120,7 +114,7 @@ class ITRHandler: "per_cess_a" : "Per% cess(A)", "edu_cess_a_cal" : "Edu cess cal(A)", "sum_of_a" : "Sum of tax_cal(A)", - "-" : "-", + "---" : "-", "per_tax_b" : "Per% Tax @(B)", "tax_b_cal" : "Tax cal(B)", "per_surcharge_b" : "Per% surcharge @(B)", @@ -145,7 +139,7 @@ class ITRHandler: "interest_244a_per143" : "Add : Interest u/s 244A as per 143", "refund_received" : "Less : Refund Received on", "balance_receivable" : "Balance Receivable", - "Remarks" : "Remarks" + "remarks" : "Remarks" } # Convert to vertical structures @@ -164,13 +158,8 @@ class ITRHandler: writer.sheets["ITR Report"] = worksheet # Formats - title_fmt = workbook.add_format({ - "bold": True, "align": "center", "valign": "vcenter", - "font_size": 14 - }) - header_fmt = workbook.add_format({ - "bold": True, "border": 1, "align": "center" - }) + title_fmt = workbook.add_format({"bold": True, "align": "center", "valign": "vcenter","font_size": 14}) + header_fmt = workbook.add_format({"bold": True, "border": 1, "align": "center"}) cell_fmt = workbook.add_format({"border": 1}) num_fmt = workbook.add_format({"border": 1, "num_format": "#,##0.00"}) diff --git a/AppCode/LoginAuth.py b/AppCode/LoginAuth.py index 39d8655..263cbf7 100644 --- a/AppCode/LoginAuth.py +++ b/AppCode/LoginAuth.py @@ -19,37 +19,50 @@ class LoginAuth: # ------------------------------- # LOGIN ROUTE # ------------------------------- + # @self.bp.route('/login', methods=['GET', 'POST']) + # def login(): + # if request.method == 'POST': + # username = request.form.get("username") + # password = request.form.get("password") + # if not username or not password: + # flash("Username and password are required!", "danger") + # return render_template("login.html") + # user_dn = f"uid={username},{self.BASE_DN}" + # server = Server(self.LDAP_SERVER, get_info=ALL) + # try: + # # Attempt LDAP bind + # conn = Connection(server, user=user_dn, password=password, auto_bind=True) + # if conn.bound: + # session['user'] = username + # flash(f"Login successful! Welcome {username}", "success") + # return redirect(url_for('welcome')) + # else: + # flash("Invalid username or password!", "danger") + # except LDAPException as e: + # flash(f"LDAP login failed: {str(e)}", "danger") + # finally: + # if 'conn' in locals(): + # conn.unbind() + # # GET request: show login form + # return render_template("login.html") + + + # LOGIN ROUTE @self.bp.route('/login', methods=['GET', 'POST']) def login(): if request.method == 'POST': username = request.form.get("username") password = request.form.get("password") - - if not username or not password: - flash("Username and password are required!", "danger") - return render_template("login.html") - - user_dn = f"uid={username},{self.BASE_DN}" - server = Server(self.LDAP_SERVER, get_info=ALL) - - try: - # Attempt LDAP bind - conn = Connection(server, user=user_dn, password=password, auto_bind=True) - if conn.bound: - session['user'] = username - flash(f"Login successful! Welcome {username}", "success") - return redirect(url_for('welcome')) - else: - flash("Invalid username or password!", "danger") - except LDAPException as e: - flash(f"LDAP login failed: {str(e)}", "danger") - finally: - if 'conn' in locals(): - conn.unbind() - - # GET request: show login form + # Dummy validation — REPLACE with DB check later + if username == "admin" and password == "admin123": + session['user'] = username + flash("Login successful!", "success") + return redirect(url_for('welcome')) + else: + flash("Invalid username or password!", "danger") return render_template("login.html") - + + # ------------------------------- # LOGOUT ROUTE # ------------------------------- diff --git a/AppCode/MatCreditHandler.py b/AppCode/MatCreditHandler.py index e31ea66..360a02f 100644 --- a/AppCode/MatCreditHandler.py +++ b/AppCode/MatCreditHandler.py @@ -38,8 +38,9 @@ class MatCreditHandler: ( data["financial_year"], data["mat_credit"], + data["opening_balance"], data["balance"], - data.get("remarks", "") + data.get("remarks", "update on manually on mat credit from ui") ) ) @@ -68,20 +69,21 @@ class MatCreditHandler: # AUTO SAVE MAT FROM ITR (MAIN LOGIC) # -------------------------------------------------- @staticmethod - def save_from_itr(year, mat_created, mat_utilized, remarks="Auto from"): + def save_from_itr(year, mat_created, opening_balance, mat_utilized, remarks): conn = DBConfig.get_db_connection() cur = conn.cursor(dictionary=True) try: mat_created = float(mat_created or 0) + opening_balance = float(mat_created or 0) mat_utilized = float(mat_utilized or 0) - balance = mat_created - mat_utilized + balance = opening_balance + mat_created - mat_utilized # Save / Update MAT Credit cur.callproc( "SaveOrUpdateMatCredit", - (year, mat_created, balance, remarks) + (year, mat_created, opening_balance, balance, remarks) ) mat_id = None diff --git a/main.py b/main.py index 28750b1..2d3b0cd 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,7 @@ -from flask import Flask, render_template, request, redirect, url_for, send_from_directory, abort, flash,send_file ,jsonify +from flask import Flask, render_template, request, redirect, url_for, flash,send_file ,jsonify import os -from dotenv import load_dotenv +from dotenv import load_dotenv load_dotenv() -import pandas as pd from werkzeug.utils import secure_filename from datetime import date from AppCode.Config import DBConfig @@ -15,14 +14,13 @@ from AppCode.AOHandler import AOHandler from AppCode.CITHandler import CITHandler from AppCode.ITATHandler import ITATHandler from AppCode.MatCreditHandler import MatCreditHandler -import subprocess - # Server app = Flask(__name__) app.secret_key=os.getenv("SECRET_KEY") +# login auth auth = LoginAuth() app.register_blueprint(auth.bp) @@ -77,7 +75,7 @@ def uploaded_file(filename): # pdf if file_ext == 'pdf': return send_file(filepath, mimetype='application/pdf') - # Word + # Word elif file_ext in ['doc', 'docx']: return send_file(filepath, as_attachment=True) # Excel @@ -122,9 +120,10 @@ def add_itr(): mat.save_from_itr( year=request.form["year"], mat_created=float(request.form.get("mat_credit_created", 0)), + opening_balance=float(request.form.get("opening_balance", 0)), mat_utilized=float(request.form.get("mat_credit_utilized", 0)), remarks="Created via ITR" - ) + ) # flash("ITR record added successfully!", "success") flash("ITR record and documents uploaded successfully!", "success") @@ -158,8 +157,6 @@ def update_itr(id): return render_template('update_itr.html', record=record, current_date=date.today().isoformat()) - - ## =============================================== ## AO (Assessing Officer) Routes ## =============================================== @@ -192,6 +189,7 @@ def add_ao(): mat.save_from_itr( year=request.form["year"], mat_created=float(request.form.get("mat_credit_created", 0)), + opening_balance=float(request.form.get("opening_balance", 0)), mat_utilized=float(request.form.get("mat_credit_utilized", 0)), remarks="Created via ao" ) @@ -264,6 +262,7 @@ def add_cit(): mat.save_from_itr( year=request.form["year"], mat_created=float(request.form.get("mat_credit_created", 0)), + opening_balance=float(request.form.get("opening_balance", 0)), mat_utilized=float(request.form.get("mat_credit_utilized", 0)), remarks="Created via cit" ) @@ -335,6 +334,7 @@ def add_itat(): mat.save_from_itr( year=request.form["year"], mat_created=float(request.form.get("mat_credit_created", 0)), + opening_balance=float(request.form.get("opening_balance", 0)), mat_utilized=float(request.form.get("mat_credit_utilized", 0)), remarks="Created via ITR" ) @@ -524,7 +524,7 @@ def download_summary(): # table_name = data.get("table") # year = data.get("year") -# check_year_obj = YearGet() +# check_year_obj = YearGet()ss # result = check_year_obj.CheckYearExists(table_name, year) # check_year_obj.close() # return result diff --git a/requirements.txt b/requirements.txt index 094b0db..6196a9f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,5 @@ openpyxl==3.1.2 xlrd==2.0.1 gunicorn==21.2.0 + +XlsxWriter==3.2.0 diff --git a/static/css/report_model.css b/static/css/report_model.css index 12fbb48..b42d5a8 100644 --- a/static/css/report_model.css +++ b/static/css/report_model.css @@ -1,132 +1,3 @@ -/* ================= RESET ================= */ -* { - box-sizing: border-box; - margin: 0; - padding: 0; -} - -/* ================= BODY ================= */ -body { - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; - background-color: #f4f7f9; - height: 100vh; - overflow: hidden; - /* no scroll desktop */ -} - -/* ================= LINKS ================= */ -a { - text-decoration: none !important; - color: #007bff; -} - -/* ================= NAVBAR ================= */ -.navbar { - width: 100%; - height: 60px; - background-color: #007bff; - display: flex; - justify-content: space-between; - align-items: center; - padding: 0 20px; - position: fixed; - top: 0; - left: 0; - color: white; - z-index: 1000; - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); -} - -.nav-left { - display: flex; - align-items: center; - gap: 15px; -} - -.nav-logo { - height: 70px; - filter: brightness(0) invert(1); -} - -.toggle-btn { - font-size: 26px; - cursor: pointer; -} - -/* ================= SIDEBAR ================= */ -.sidebar { - width: 250px; - background: white; - height: calc(100vh - 60px); - position: fixed; - top: 60px; - left: 0; - padding-top: 20px; - border-right: 1px solid #d6d6d6; - display: flex; - flex-direction: column; -} - -.sidebar.hide { - left: -250px; -} - -.menu-items { - flex: 1; - display: flex; - flex-direction: column; -} - -.menu-btn { - padding: 14px 20px; - font-size: 16px; - color: #007bff; - font-weight: 600; - cursor: pointer; - border-bottom: 1px solid #e5e5e5; -} - -.menu-btn:hover { - background: #e9f3ff; -} - -.submenu { - display: none; - background: #f4faff; -} - -.submenu a { - padding: 12px 35px; - display: block; - color: #0056b3; -} - -/* ================= MAIN ================= */ -.main { - margin-left: 250px; - margin-top: 60px; - width: calc(100% - 250px); - height: calc(100vh - 60px); - display: flex; - align-items: center; - /* ✅ vertical center */ - justify-content: center; - /* ✅ horizontal center */ - padding: 30px; -} - -/* ================= CONTAINER ================= */ -.container { - width: 100%; - max-width: 680px; - /* 🔥 laptop & desktop size */ - background: #ffffff; - padding: 45px 55px; - border-radius: 14px; - box-shadow: 0 14px 40px rgba(0, 0, 0, 0.12); - text-align: center; -} - /* ================= HEADING ================= */ .container h2 { font-size: 28px; diff --git a/static/js/mat_credit.js b/static/js/mat_credit.js index 0aa99b5..1327b12 100644 --- a/static/js/mat_credit.js +++ b/static/js/mat_credit.js @@ -62,6 +62,7 @@ function addRow() { tr.innerHTML = ` + ${utilizedCols} @@ -88,6 +89,7 @@ function saveRow(btn) { let payload = { financial_year: financialYear, mat_credit: inputs[0].value || 0, + opening_balance: inputs[1].value || 0, balance: inputs[inputs.length - 1].value || 0, utilization: [] }; diff --git a/templates/add_ao.html b/templates/add_ao.html index 79ea0a1..4e631ef 100644 --- a/templates/add_ao.html +++ b/templates/add_ao.html @@ -9,7 +9,7 @@ {% block content %}
-

New AO Form

+

New Assessing Officer(AO) Form

diff --git a/templates/add_itat.html b/templates/add_itat.html index fea8529..3597dd2 100644 --- a/templates/add_itat.html +++ b/templates/add_itat.html @@ -9,7 +9,7 @@ {% block content %}
-

New Income Tax Appellate Tribunal Form

+

New Income Tax Appellate Tribunal(ITAT) Form

diff --git a/templates/add_itr.html b/templates/add_itr.html index fd03430..b82f348 100644 --- a/templates/add_itr.html +++ b/templates/add_itr.html @@ -172,7 +172,7 @@
- +
diff --git a/templates/ao_reports.html b/templates/ao_reports.html index cea0f14..09dd58c 100644 --- a/templates/ao_reports.html +++ b/templates/ao_reports.html @@ -8,7 +8,7 @@ {% block content %}
-

Download AO Report

+

Download Assessing Officer(AO) Report


diff --git a/templates/itr_reports.html b/templates/itr_reports.html index 0698681..3a53c02 100644 --- a/templates/itr_reports.html +++ b/templates/itr_reports.html @@ -8,7 +8,7 @@ {% block content %}
-

Download ITR Report

+

Download Income Tax Return(ITR) Report


+ {% for y in added_years %} diff --git a/templates/reports.html b/templates/reports.html index 2e7333c..6f7c715 100644 --- a/templates/reports.html +++ b/templates/reports.html @@ -8,10 +8,10 @@ {% endblock %} \ No newline at end of file diff --git a/templates/stage_reports.html b/templates/stage_reports.html deleted file mode 100644 index 2aa4bb9..0000000 --- a/templates/stage_reports.html +++ /dev/null @@ -1,169 +0,0 @@ - - - - - {{ stage }} Reports - - - - - -
- -

{{ stage }} Reports

- - - - - - - - {% if documents %} - - - - - - - - - {% for doc in documents %} - - - - - {% endfor %} - -
YearAction
{{ doc.year }} - Download -
- {% else %} -

No reports found for this selection.

- {% endif %} -
- - - \ No newline at end of file diff --git a/templates/update_ao.html b/templates/update_ao.html index 72114e1..6ad9ba7 100644 --- a/templates/update_ao.html +++ b/templates/update_ao.html @@ -8,7 +8,7 @@ {% block content %}
-

Update AO Record for Year {{ record.year }} - {{ record.year + 1 }}

+

Update Assessing Officer(AO) Record for Year {{ record.year }} - {{ record.year + 1 }}

diff --git a/templates/update_itat.html b/templates/update_itat.html index 2c160cc..68b083e 100644 --- a/templates/update_itat.html +++ b/templates/update_itat.html @@ -7,7 +7,7 @@ {% block content %}
-

Update ITAT Record for Year {{ record.year }}

+

Update Income Tax Appellate Tribunal(ITAT) Record for Year {{ record.year }}

diff --git a/templates/update_itr.html b/templates/update_itr.html index 79082fd..8949aa9 100644 --- a/templates/update_itr.html +++ b/templates/update_itr.html @@ -8,7 +8,7 @@ {% block content %}
-

Update ITR Record for Year {{record.year}} - {{record.year+1}}

+

Update Income Tax Return (ITR) Record for Year {{record.year}} - {{record.year+1}}