modification of report, froms, models

This commit is contained in:
2026-02-17 16:54:43 +05:30
parent b8c289294d
commit 0ba78a0bd1
25 changed files with 92 additions and 404 deletions

View File

@@ -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)",

View File

@@ -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)",

View File

@@ -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):

View File

@@ -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)",

View File

@@ -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"})

View File

@@ -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
# -------------------------------

View File

@@ -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