renames of report html files

This commit is contained in:
2026-01-17 14:01:15 +05:30
parent dd4b494435
commit a07c1ddf8a
8 changed files with 21 additions and 21 deletions

View File

@@ -74,7 +74,7 @@ class SubcontractorBill:
df.drop(columns=drop_cols, errors="ignore", inplace=True)
# --- subcontractor report only ---
@file_report_bp.route("/report", methods=["GET", "POST"])
@file_report_bp.route("/Subcontractor_report", methods=["GET", "POST"])
@login_required
def report_file():
subcontractors = Subcontractor.query.all()
@@ -122,7 +122,6 @@ def report_file():
return send_file(output, download_name=file_name, as_attachment=True)
# We add bootstrap classes directly to the pandas output
# table_classes = "table table-hover table-bordered table-striped"
table_classes = "table table-bordered table-striped table-hover table-sm mb-0"
tables = {
"tr": bill_gen.df_tr.to_html(classes=table_classes, index=False),
@@ -133,7 +132,7 @@ def report_file():
selected_sc_id = subcontractor_id
return render_template(
"report.html",
"subcontractor_report.html",
subcontractors=subcontractors,
tables=tables,
selected_sc_id=selected_sc_id,
@@ -141,8 +140,8 @@ def report_file():
download_all=download_all
)
# --- client comparison ---
@file_report_bp.route("/client_vs_subcont", methods=["GET", "POST"])
# --- client report only ---
@file_report_bp.route("/client_report", methods=["GET", "POST"])
@login_required
def client_vs_all_subcontractor():
tables = {"tr": None, "mh": None, "dc": None}
@@ -183,7 +182,7 @@ def client_vs_all_subcontractor():
# Aggregate data
df_sub_tr_grp = aggregate_df(contractorBill.df_tr, ["Location", "MH_NO"], qty_cols)
df_sub_mh_grp = aggregate_df(contractorBill.df_mh, ["Location", "MH_NO"], qty_cols)
df_sub_dc_grp = aggregate_df(contractorBill.df_dc, ["Location", "Node_No"], mh_dc_qty_cols)
df_sub_dc_grp = aggregate_df(contractorBill.df_dc, ["Location", "MH_NO"], mh_dc_qty_cols)
# --- FINAL MERGE LOGIC ---
# We check if "Location" exists in the client data. If not, we add it to prevent the KeyError.
@@ -194,17 +193,17 @@ def client_vs_all_subcontractor():
try:
df_tr_cmp = clientBill.df_tr.merge(df_sub_tr_grp, on=["Location", "MH_NO"], how="left", suffixes=("_Client", "_Sub"))
df_mh_cmp = clientBill.df_mh.merge(df_sub_mh_grp, on=["Location", "MH_NO"], how="left", suffixes=("_Client", "_Sub"))
df_dc_cmp = clientBill.df_dc.merge(df_sub_dc_grp, on=["Location", "Node_No"], how="left", suffixes=("_Client", "_Sub"))
df_dc_cmp = clientBill.df_dc.merge(df_sub_dc_grp, on=["Location", "MH_NO"], how="left", suffixes=("_Client", "_Sub"))
except KeyError as e:
flash(f"Merge Error: Missing column {str(e)}. Check if 'Location' is defined in your database models.", "danger")
return render_template("generate_comparison_client_vs_subcont.html", tables=tables, ra_val=ra_val)
# ... (Rest of your calculation and download logic) ...
# Convert to HTML for preview
tables["tr"] = df_tr_cmp.to_html(classes='table table-striped table-hover table-sm', index=False)
tables["mh"] = df_mh_cmp.to_html(classes='table table-striped table-hover table-sm', index=False)
tables["dc"] = df_dc_cmp.to_html(classes='table table-striped table-hover table-sm', index=False)
return render_template("generate_comparison_client_vs_subcont.html", tables=tables, ra_val=ra_val)
return render_template("client_report.html", tables=tables, ra_val=ra_val)