diff --git a/app/routes/file_import.py b/app/routes/file_import.py index 9983308..c30b2bd 100644 --- a/app/routes/file_import.py +++ b/app/routes/file_import.py @@ -5,7 +5,8 @@ from app.utils.helpers import login_required file_import_bp = Blueprint("file_import", __name__, url_prefix="/file") -@file_import_bp.route("/import", methods=["GET", "POST"]) +# this is contractractor immport routes +@file_import_bp.route("/import_Subcontractor", methods=["GET", "POST"]) @login_required def import_file(): subcontractors = Subcontractor.query.all() @@ -21,13 +22,13 @@ def import_file(): flash(msg, "success" if success else "danger") return render_template( - "file_import.html", + "file_import_subcontractor.html", title="Sub-cont. File Import", subcontractors=subcontractors ) -# this route import client files +# this is client import routes @file_import_bp.route("/import_client", methods=["GET", "POST"]) @login_required def client_import_file(): diff --git a/app/routes/file_report.py b/app/routes/file_report.py index bed133d..5846ab3 100644 --- a/app/routes/file_report.py +++ b/app/routes/file_report.py @@ -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) \ No newline at end of file diff --git a/app/static/downloads/format/subcontractor_format.xlsx b/app/static/downloads/format/subcontractor_format.xlsx index 1a24522..b82cc4d 100644 Binary files a/app/static/downloads/format/subcontractor_format.xlsx and b/app/static/downloads/format/subcontractor_format.xlsx differ diff --git a/app/templates/base.html b/app/templates/base.html index 9d20ef5..e2fe209 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -68,12 +68,12 @@