diff --git a/__pycache__/compare_gst_excel.cpython-313.pyc b/__pycache__/compare_gst_excel.cpython-313.pyc new file mode 100644 index 0000000..d2bfc3d Binary files /dev/null and b/__pycache__/compare_gst_excel.cpython-313.pyc differ diff --git a/app.py b/app.py new file mode 100644 index 0000000..ff642bd --- /dev/null +++ b/app.py @@ -0,0 +1,42 @@ +from flask import Flask, render_template, request, send_file +import pandas as pd +from compare_gst_excel import find_unmatched_rows +import os +from werkzeug.utils import secure_filename + +app = Flask(__name__) +UPLOAD_FOLDER = 'uploads' +RESULT_FILE = 'unmatched_result.xlsx' + +if not os.path.exists(UPLOAD_FOLDER): + os.makedirs(UPLOAD_FOLDER) + +@app.route('/') +def index(): + return render_template('upload.html') + +@app.route('/upload', methods=['POST']) +def upload_file(): + file = request.files['excel_file'] + if not file: + return "No file uploaded.", 400 + + filename = secure_filename(file.filename) + filepath = os.path.join(UPLOAD_FOLDER, filename) + file.save(filepath) + + try: + # Read Excel with header in row 8 (0-indexed), so header=7 + df1 = pd.read_excel(filepath, sheet_name=0, header=7) + df2 = pd.read_excel(filepath, sheet_name=1, header=7) + + unmatched = find_unmatched_rows(df1, df2) + unmatched.to_excel(RESULT_FILE, index=False) + + return send_file(RESULT_FILE, as_attachment=True) + + except Exception as e: + return f"Error processing file: {e}", 500 + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000,debug=True) diff --git a/compare_gst_excel.py b/compare_gst_excel.py new file mode 100644 index 0000000..cda5a58 --- /dev/null +++ b/compare_gst_excel.py @@ -0,0 +1,64 @@ +# import pandas as pd + +# def normalize_row(row): +# return tuple( +# str(cell).strip().replace(".0", "") if isinstance(cell, float) and cell.is_integer() else str(cell).strip() +# for cell in row +# ) + +# def find_unmatched_rows(sheet1_df, sheet2_df): +# # Ensure column names are clean +# sheet1_df.columns = sheet1_df.columns.str.strip() +# sheet2_df.columns = sheet2_df.columns.str.strip() + +# # Normalize rows for comparison +# sheet1_normalized = sheet1_df.apply(normalize_row, axis=1) +# sheet2_normalized = sheet2_df.apply(normalize_row, axis=1) + +# # Find unmatched rows +# unmatched_in_sheet1 = sheet1_df[~sheet1_normalized.isin(sheet2_normalized)] +# unmatched_in_sheet2 = sheet2_df[~sheet2_normalized.isin(sheet1_normalized)] + +# # Mark source +# unmatched_in_sheet1["Source"] = "Sheet1" +# unmatched_in_sheet2["Source"] = "Sheet2" + +# # Combine +# unmatched_combined = pd.concat([unmatched_in_sheet1, unmatched_in_sheet2], ignore_index=True) +# return unmatched_combined +import pandas as pd + +def normalize_row(row): + return tuple( + str(cell).strip().replace(".0", "") if isinstance(cell, float) and cell.is_integer() else str(cell).strip() + for cell in row + ) + +def find_unmatched_rows(sheet1_df, sheet2_df): + # Clean column names + sheet1_df.columns = sheet1_df.columns.str.strip() + sheet2_df.columns = sheet2_df.columns.str.strip() + + # Choose the comparison columns + comparison_columns = ['Date', 'GSTIN/UIN'] + + # Ensure required columns exist + for col in comparison_columns: + if col not in sheet1_df.columns or col not in sheet2_df.columns: + raise ValueError(f"Missing column '{col}' in one of the sheets.") + + # Create keys for comparison + sheet1_keys = sheet1_df[comparison_columns].apply(normalize_row, axis=1) + sheet2_keys = sheet2_df[comparison_columns].apply(normalize_row, axis=1) + + # Find unmatched rows + unmatched_in_sheet1 = sheet1_df[~sheet1_keys.isin(sheet2_keys)].copy() + unmatched_in_sheet2 = sheet2_df[~sheet2_keys.isin(sheet1_keys)].copy() + + # Mark source + unmatched_in_sheet1["Source"] = "Sheet1" + unmatched_in_sheet2["Source"] = "Sheet2" + + # Combine + unmatched_combined = pd.concat([unmatched_in_sheet1, unmatched_in_sheet2], ignore_index=True) + return unmatched_combined diff --git a/outputs/unmatched_GSTR_2_and_GSTR_2B.xlsx b/outputs/unmatched_GSTR_2_and_GSTR_2B.xlsx new file mode 100644 index 0000000..6463616 Binary files /dev/null and b/outputs/unmatched_GSTR_2_and_GSTR_2B.xlsx differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..66cd5ab --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +flask +pandas +openpyxl diff --git a/static/logo_gst.jpg b/static/logo_gst.jpg new file mode 100644 index 0000000..85e3ed3 Binary files /dev/null and b/static/logo_gst.jpg differ diff --git a/static/new_logo.jpg b/static/new_logo.jpg new file mode 100644 index 0000000..a7b7450 Binary files /dev/null and b/static/new_logo.jpg differ diff --git a/templates/upload.html b/templates/upload.html new file mode 100644 index 0000000..026eb17 --- /dev/null +++ b/templates/upload.html @@ -0,0 +1,97 @@ + + + + + GST Reconciliation + + + +
+
+ Laxmi Civil Engineering Logo + +

Laxmi Civil Engineering Services Pvt. Ltd.

+
+

Upload GST Excel File

+
+ + +
+
+ + diff --git a/unmatched_result.xlsx b/unmatched_result.xlsx new file mode 100644 index 0000000..e28f586 Binary files /dev/null and b/unmatched_result.xlsx differ