Initial commit
This commit is contained in:
BIN
__pycache__/compare_gst_excel.cpython-313.pyc
Normal file
BIN
__pycache__/compare_gst_excel.cpython-313.pyc
Normal file
Binary file not shown.
42
app.py
Normal file
42
app.py
Normal file
@@ -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)
|
||||||
64
compare_gst_excel.py
Normal file
64
compare_gst_excel.py
Normal file
@@ -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
|
||||||
BIN
outputs/unmatched_GSTR_2_and_GSTR_2B.xlsx
Normal file
BIN
outputs/unmatched_GSTR_2_and_GSTR_2B.xlsx
Normal file
Binary file not shown.
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
flask
|
||||||
|
pandas
|
||||||
|
openpyxl
|
||||||
BIN
static/logo_gst.jpg
Normal file
BIN
static/logo_gst.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
static/new_logo.jpg
Normal file
BIN
static/new_logo.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.9 KiB |
97
templates/upload.html
Normal file
97
templates/upload.html
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>GST Reconciliation</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
background: #f0f4f8;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
height: 100vh;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 30px 40px;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
|
||||||
|
text-align: center;
|
||||||
|
width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header img {
|
||||||
|
width: 80px;
|
||||||
|
height: auto;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: 20px;
|
||||||
|
margin: 0;
|
||||||
|
color: #007bff;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="file"] {
|
||||||
|
padding: 8px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border: 1px solid #cccccc;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: #fafafa;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #007bff;
|
||||||
|
color: #ffffff;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<img src="{{ url_for('static', filename='new_logo.jpg') }}" alt="Laxmi Civil Engineering Logo" height="60">
|
||||||
|
|
||||||
|
<h1>Laxmi Civil Engineering Services Pvt. Ltd.</h1>
|
||||||
|
</div>
|
||||||
|
<h2>Upload GST Excel File</h2>
|
||||||
|
<form action="/upload" method="post" enctype="multipart/form-data">
|
||||||
|
<input type="file" name="excel_file" accept=".xlsx" required>
|
||||||
|
<button type="submit">Upload and Compare</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
BIN
unmatched_result.xlsx
Normal file
BIN
unmatched_result.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user