commit 45388d0b5ef4a004623a1091f57f7253be588fd3 Author: dev-lcepl-git Date: Thu Jun 19 23:04:49 2025 +0530 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14f61be --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +venv/ +*.pyc +__pycache__/ +.env +.uploads +static/download/ + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..11a5d8e --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +main.py \ No newline at end of file diff --git a/.idea/ManagementApplicationt.iml b/.idea/ManagementApplicationt.iml new file mode 100644 index 0000000..b6731d8 --- /dev/null +++ b/.idea/ManagementApplicationt.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a310890 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..a851b58 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..411d674 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Use official Python image +FROM python:3.9 + +# Set working directory inside container +WORKDIR /app + +# Copy all files to container +COPY . . + +# Install dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Expose Flask's default port +EXPOSE 5000 + +# Run Flask app +CMD ["python", "main.py"] + diff --git a/README.md b/README.md new file mode 100644 index 0000000..52a42d7 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# MA07-05-2025 diff --git a/app.log b/app.log new file mode 100644 index 0000000..e126126 --- /dev/null +++ b/app.log @@ -0,0 +1,114 @@ +2025-02-15 11:07:16,100 - INFO - Logging is set up. +2025-02-15 11:07:16,100 - INFO - Logging is set up. +2025-02-15 11:07:16,131 - WARNING - * Debugger is active! +2025-02-15 11:07:16,131 - WARNING - * Debugger is active! +2025-02-15 11:07:16,137 - INFO - * Debugger PIN: 558-213-972 +2025-02-15 11:07:16,137 - INFO - * Debugger PIN: 558-213-972 +2025-02-15 11:13:26,290 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET / HTTP/1.1" 200 - +2025-02-15 11:13:26,290 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET / HTTP/1.1" 200 - +2025-02-15 11:13:26,315 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /static/css/index.css HTTP/1.1" 304 - +2025-02-15 11:13:26,315 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /static/css/index.css HTTP/1.1" 304 - +2025-02-15 11:13:26,504 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:13:26,504 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:13:26,626 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /static/js/validateFileInput.js HTTP/1.1" 304 - +2025-02-15 11:13:26,626 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /static/js/validateFileInput.js HTTP/1.1" 304 - +2025-02-15 11:13:26,633 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /static/js/searchContractor.js HTTP/1.1" 304 - +2025-02-15 11:13:26,633 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /static/js/searchContractor.js HTTP/1.1" 304 - +2025-02-15 11:13:26,950 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /favicon.ico HTTP/1.1" 404 - +2025-02-15 11:13:26,950 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:26] "GET /favicon.ico HTTP/1.1" 404 - +2025-02-15 11:13:28,623 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET / HTTP/1.1" 200 - +2025-02-15 11:13:28,623 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET / HTTP/1.1" 200 - +2025-02-15 11:13:28,933 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET /static/css/index.css HTTP/1.1" 304 - +2025-02-15 11:13:28,933 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET /static/css/index.css HTTP/1.1" 304 - +2025-02-15 11:13:28,952 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET /static/js/validateFileInput.js HTTP/1.1" 304 - +2025-02-15 11:13:28,952 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET /static/js/validateFileInput.js HTTP/1.1" 304 - +2025-02-15 11:13:28,954 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET /static/js/searchContractor.js HTTP/1.1" 304 - +2025-02-15 11:13:28,955 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:13:28,954 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET /static/js/searchContractor.js HTTP/1.1" 304 - +2025-02-15 11:13:28,955 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:28] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:13:31,608 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:31] "GET /add_state HTTP/1.1" 200 - +2025-02-15 11:13:31,608 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:31] "GET /add_state HTTP/1.1" 200 - +2025-02-15 11:13:31,639 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:31] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:13:31,639 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:31] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:13:31,649 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:31] "GET /static/images/icons/pen_blue_icon.png HTTP/1.1" 304 - +2025-02-15 11:13:31,649 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:31] "GET /static/images/icons/pen_blue_icon.png HTTP/1.1" 304 - +2025-02-15 11:13:31,967 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:31] "GET /static/images/icons/bin_red_icon.png HTTP/1.1" 304 - +2025-02-15 11:13:31,967 - INFO - 127.0.0.1 - - [15/Feb/2025 11:13:31] "GET /static/images/icons/bin_red_icon.png HTTP/1.1" 304 - +2025-02-15 11:15:01,349 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:01] "POST /check_state HTTP/1.1" 409 - +2025-02-15 11:15:01,349 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:01] "POST /check_state HTTP/1.1" 409 - +2025-02-15 11:15:21,783 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:21] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:21,783 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:21] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:22,127 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:22] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:22,127 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:22] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:22,151 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:22] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:22,151 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:22] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:22,391 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:22] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:22,391 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:22] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:22,440 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:22] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:22,440 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:22] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:15:24,266 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:24] "POST /add_state HTTP/1.1" 200 - +2025-02-15 11:15:24,266 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:24] "POST /add_state HTTP/1.1" 200 - +2025-02-15 11:15:25,418 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:25] "GET /add_state HTTP/1.1" 200 - +2025-02-15 11:15:25,418 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:25] "GET /add_state HTTP/1.1" 200 - +2025-02-15 11:15:25,716 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:25] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:15:25,716 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:25] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:15:25,749 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:25] "GET /static/images/icons/pen_blue_icon.png HTTP/1.1" 304 - +2025-02-15 11:15:25,749 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:25] "GET /static/images/icons/pen_blue_icon.png HTTP/1.1" 304 - +2025-02-15 11:15:25,752 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:25] "GET /static/images/icons/bin_red_icon.png HTTP/1.1" 304 - +2025-02-15 11:15:25,752 - INFO - 127.0.0.1 - - [15/Feb/2025 11:15:25] "GET /static/images/icons/bin_red_icon.png HTTP/1.1" 304 - +2025-02-15 11:16:46,338 - INFO - * Detected change in 'C:\\Users\\ADMIN\\PycharmProjects\\ManagementApplicationt\\main.py', reloading +2025-02-15 11:16:46,338 - INFO - * Detected change in 'C:\\Users\\ADMIN\\PycharmProjects\\ManagementApplicationt\\main.py', reloading +2025-02-15 11:16:48,798 - INFO - Logging is set up. +2025-02-15 11:16:48,798 - INFO - Logging is set up. +2025-02-15 11:16:48,843 - WARNING - * Debugger is active! +2025-02-15 11:16:48,843 - WARNING - * Debugger is active! +2025-02-15 11:16:48,847 - INFO - * Debugger PIN: 558-213-972 +2025-02-15 11:16:48,847 - INFO - * Debugger PIN: 558-213-972 +2025-02-15 11:16:52,045 - DEBUG - Fetched state data successfully. +2025-02-15 11:16:52,045 - DEBUG - Fetched state data successfully. +2025-02-15 11:16:52,054 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:52] "GET /add_state HTTP/1.1" 200 - +2025-02-15 11:16:52,054 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:52] "GET /add_state HTTP/1.1" 200 - +2025-02-15 11:16:52,076 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:52] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:16:52,076 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:52] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:16:52,078 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:52] "GET /static/images/icons/pen_blue_icon.png HTTP/1.1" 304 - +2025-02-15 11:16:52,078 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:52] "GET /static/images/icons/pen_blue_icon.png HTTP/1.1" 304 - +2025-02-15 11:16:52,377 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:52] "GET /static/images/icons/bin_red_icon.png HTTP/1.1" 304 - +2025-02-15 11:16:52,377 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:52] "GET /static/images/icons/bin_red_icon.png HTTP/1.1" 304 - +2025-02-15 11:16:54,758 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:54] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:16:54,758 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:54] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:16:54,992 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:54] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:16:54,992 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:54] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:16:55,016 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:55] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:16:55,016 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:55] "POST /check_state HTTP/1.1" 200 - +2025-02-15 11:16:55,669 - INFO - State 'sss' added successfully. +2025-02-15 11:16:55,669 - INFO - 'State 'sss added successfully. +2025-02-15 11:16:55,670 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:55] "POST /add_state HTTP/1.1" 200 - +2025-02-15 11:16:55,670 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:55] "POST /add_state HTTP/1.1" 200 - +2025-02-15 11:16:57,235 - DEBUG - Fetched state data successfully. +2025-02-15 11:16:57,235 - DEBUG - Fetched state data successfully. +2025-02-15 11:16:57,239 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:57] "GET /add_state HTTP/1.1" 200 - +2025-02-15 11:16:57,239 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:57] "GET /add_state HTTP/1.1" 200 - +2025-02-15 11:16:57,263 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:57] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:16:57,263 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:57] "GET /static/css/style.css HTTP/1.1" 304 - +2025-02-15 11:16:57,483 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:57] "GET /static/images/icons/pen_blue_icon.png HTTP/1.1" 304 - +2025-02-15 11:16:57,483 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:57] "GET /static/images/icons/pen_blue_icon.png HTTP/1.1" 304 - +2025-02-15 11:16:57,567 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:57] "GET /static/images/icons/bin_red_icon.png HTTP/1.1" 304 - +2025-02-15 11:16:57,567 - INFO - 127.0.0.1 - - [15/Feb/2025 11:16:57] "GET /static/images/icons/bin_red_icon.png HTTP/1.1" 304 - +2025-02-15 11:20:55,547 - INFO - * Detected change in 'C:\\Users\\ADMIN\\PycharmProjects\\ManagementApplicationt\\main.py', reloading +2025-02-15 11:20:55,547 - INFO - * Detected change in 'C:\\Users\\ADMIN\\PycharmProjects\\ManagementApplicationt\\main.py', reloading +2025-02-15 11:20:56,800 - INFO - Logging is set up. +2025-02-15 11:20:56,800 - INFO - Logging is set up. +2025-02-15 11:20:56,835 - WARNING - * Debugger is active! +2025-02-15 11:20:56,835 - WARNING - * Debugger is active! +2025-02-15 11:20:56,837 - INFO - * Debugger PIN: 558-213-972 +2025-02-15 11:20:56,837 - INFO - * Debugger PIN: 558-213-972 +2025-02-15 11:21:04,060 - INFO - * Detected change in 'C:\\Users\\ADMIN\\PycharmProjects\\ManagementApplicationt\\main.py', reloading +2025-02-15 11:21:04,060 - INFO - * Detected change in 'C:\\Users\\ADMIN\\PycharmProjects\\ManagementApplicationt\\main.py', reloading +2025-02-15 11:21:05,429 - INFO - Logging is set up. +2025-02-15 11:21:05,429 - INFO - Logging is set up. +2025-02-15 11:21:05,461 - WARNING - * Debugger is active! +2025-02-15 11:21:05,461 - WARNING - * Debugger is active! +2025-02-15 11:21:05,463 - INFO - * Debugger PIN: 558-213-972 +2025-02-15 11:21:05,463 - INFO - * Debugger PIN: 558-213-972 +2025-02-15 11:21:17,911 - INFO - * Detected change in 'C:\\Users\\ADMIN\\PycharmProjects\\ManagementApplicationt\\main.py', reloading +2025-02-15 11:21:17,911 - INFO - * Detected change in 'C:\\Users\\ADMIN\\PycharmProjects\\ManagementApplicationt\\main.py', reloading diff --git a/config.py b/config.py new file mode 100644 index 0000000..e7b4fa9 --- /dev/null +++ b/config.py @@ -0,0 +1,18 @@ + +import mysql.connector +import os + +# Get MySQL credentials from environment variables +MYSQL_HOST = os.getenv("MYSQL_HOST", "127.0.0.1") +MYSQL_USER = os.getenv("MYSQL_USER", "root") +MYSQL_PASSWORD = os.getenv("MYSQL_PASSWORD", "admin") +MYSQL_DB = os.getenv("MYSQL_DB", "test") + +# Connect to MySQL +def get_db_connection(): + return mysql.connector.connect( + host=MYSQL_HOST, + user=MYSQL_USER, + password=MYSQL_PASSWORD, + database=MYSQL_DB + ) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2a3c49d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +version: "3.8" + +services: + flask-app: + build: . + ports: + - "5000:5000" + depends_on: + - mysql + environment: + - MYSQL_HOST=mysql + - MYSQL_USER=root + - MYSQL_PASSWORD=root + - MYSQL_DB=test + networks: + - mynetwork + + mysql: + image: mysql:8.0 + restart: always + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: test + ports: + - "3306:3306" + volumes: + - mysql-data:/var/lib/mysql + networks: + - mynetwork + +volumes: + mysql-data: + +networks: + mynetwork: diff --git a/main.py b/main.py new file mode 100644 index 0000000..b5a03bd --- /dev/null +++ b/main.py @@ -0,0 +1,7453 @@ + +from decimal import Decimal + +from flask import Flask, render_template, request, redirect, url_for, send_from_directory, flash, jsonify, json +import mysql.connector +from mysql.connector import Error +import config +import openpyxl +import os +import re +import ast +from datetime import datetime +import pandas as pd +from openpyxl.styles import Font + +# this is server +app = Flask(__name__) +app.secret_key = '9f2a1b8c4d6e7f0123456789abcdef01' + +str_pattern_reg = "^[A-Za-z ]+$" + + +class ResponseHandler: + @staticmethod + def invalid_name(entity): + return {'status': 'error', 'message': f'Invalid {entity} name. Only letters are allowed!'} + + @staticmethod + def already_exists(entity): + return {'status': 'exists', 'message': f'{entity.capitalize()} already exists!'} + + @staticmethod + def add_success(entity): + return {'status': 'success', 'message': f'{entity.capitalize()} added successfully!'} + + @staticmethod + def add_failure(entity): + return {'status': 'error', 'message': f'Failed to add {entity}.'} + + @staticmethod + def is_available(entity): + return {'status': 'available', 'message': f'{entity.capitalize()} name is available!'} + + @staticmethod + def delete_success(entity): + return {'status': 'success', 'message': f'{entity.capitalize()} deleted successfully!'} + + @staticmethod + def delete_failure(entity): + return {'status': 'error', 'message': f'Failed to delete {entity}.'} + + @staticmethod + def update_success(entity): + return {'status': 'success', 'message': f'{entity.capitalize()} updated successfully!'} + + @staticmethod + def update_failure(entity): + return {'status': 'error', 'message': f'Failed to update {entity}.'} + + @staticmethod + def fetch_failure(entity): + return f"Failed to fetch {entity}" + + +# Helper: JSON Response Formatter +def json_response(message_obj, status_code): + return jsonify(message_obj), status_code + + +# this is Index page OR Home page.. +@app.route('/') +def index(): + return render_template('index.html') + + +# this is Profile page .. +@app.route('/admin_profile', methods=['GET', 'POST']) +def admin_profile(): + return render_template('admin_profile.html') + + +# ------------------------- State controller ------------------------------------------ +@app.route('/add_state', methods=['GET', 'POST']) +def add_state(): + connection = config.get_db_connection() + statedata = [] + + if connection: + cursor = connection.cursor() + if request.method == 'POST': + state_name = request.form['state_Name'].strip() + + if not re.match(str_pattern_reg, state_name): + return json_response(ResponseHandler.invalid_name("state"), 400) + + try: + # cursor.execute("SELECT * FROM states WHERE State_Name = %s", (state_name,)) + # if cursor.fetchone(): + # return json_response(ResponseHandler.already_exists("state"), 409) + + cursor.callproc("CheckStateExists", (state_name,)) + for data in cursor.stored_results(): + existing_state = data.fetchone() + + if existing_state: + return json_response(ResponseHandler.already_exists("state"), 409) + + # cursor.execute("call SaveState (%s)", (state_name,)) + cursor.callproc("SaveState", (state_name,)) + connection.commit() + return json_response(ResponseHandler.add_success("state"), 200) + + except mysql.connector.Error as e: + print(f"Error inserting state: {e}") + return json_response(ResponseHandler.add_failure("state"), 500) + + try: + # cursor.execute("SELECT State_ID, State_Name FROM states") + # statedata = cursor.fetchall() + cursor.callproc("GetAllStates") + for res in cursor.stored_results(): + statedata = res.fetchall() + except mysql.connector.Error as e: + print(f"Error fetching states: {e}") + return ResponseHandler.fetch_failure("states"), 500 + finally: + cursor.close() + connection.close() + + return render_template('add_state.html', statedata=statedata) + + +# AJAX route to check state existence +@app.route('/check_state', methods=['POST']) +def check_state(): + connection = config.get_db_connection() + + if connection: + cursor = connection.cursor() + state_name = request.json.get('state_Name', '').strip() + + if not re.match(str_pattern_reg, state_name): + return json_response(ResponseHandler.invalid_name("state"), 400) + + try: + # cursor.execute("SELECT * FROM states WHERE State_Name = %s", (state_name,)) + # existing_state = cursor.fetchone() + + cursor.callproc("CheckStateExists", (state_name,)) + for data in cursor.stored_results(): + existing_state = data.fetchone() + + if existing_state: + return json_response(ResponseHandler.already_exists("state"), 409) + else: + return json_response(ResponseHandler.is_available("state"), 200) + + except mysql.connector.Error as e: + print(f"Error checking state: {e}") + return json_response(ResponseHandler.add_failure("state"), 500) + finally: + cursor.close() + connection.close() + + +# Delete State +@app.route('/delete_state/', methods=['GET']) +def deleteState(id): + connection = config.get_db_connection() + cursor = connection.cursor() + + try: + # cursor.execute("DELETE FROM states WHERE State_ID = %s", (id,)) + cursor.callproc('DeleteState', (id,)) + connection.commit() + # For API response + # return json_response(ResponseHandler.delete_success("state"), 200) + + except mysql.connector.Error as e: + print(f"Error deleting data: {e}") + return json_response(ResponseHandler.delete_failure("state"), 500) + + finally: + cursor.close() + connection.close() + + return redirect(url_for('add_state')) + + +# Edit State +@app.route('/edit_state/', methods=['GET', 'POST']) +def editState(id): + connection = config.get_db_connection() + cursor = connection.cursor() + # str_pattern_reg = r"^[A-Za-z\s]+$" + + if request.method == 'POST': + state_name = request.form['state_Name'].strip() + + if not re.match(str_pattern_reg, state_name): + return ResponseHandler.invalid_name("state"), 400 + + try: + # cursor.execute("UPDATE states SET State_Name = %s WHERE State_ID = %s", (state_name, id)) + cursor.callproc("UpdateStateById", (id, state_name)) + connection.commit() + return redirect(url_for('add_state')) + except mysql.connector.Error as e: + print(f"Error updating data: {e}") + return ResponseHandler.add_failure("state"), 500 + finally: + cursor.close() + connection.close() + + try: + # cursor.execute("SELECT * FROM states WHERE State_ID = %s", (id,)) + # state = cursor.fetchone() + cursor.callproc("GetStateByID", (id,)) + for result in cursor.stored_results(): + state = result.fetchone() + if state is None: + return "State not found", 404 + except mysql.connector.Error as e: + print(f"Error retrieving data: {e}") + return ResponseHandler.fetch_failure("state"), 500 + finally: + cursor.close() + connection.close() + + return render_template('edit_state.html', state=state) + + +# -------- end State controller ----------- + +# ------------------------- District controller ------------------------------------------ +@app.route('/add_district', methods=['GET', 'POST']) +def add_district(): + connection = config.get_db_connection() + districtdata = [] + states = [] + + if connection: + cursor = connection.cursor() + + try: + # cursor.execute("SELECT State_ID, State_Name FROM states") + # states = cursor.fetchall() + cursor.callproc("GetAllStates") + for res in cursor.stored_results(): + states = res.fetchall() + + except mysql.connector.Error as e: + print(f"Error fetching states: {e}") + return ResponseHandler.fetch_failure("states"), 500 + + if request.method == 'POST': + district_name = request.form['district_Name'].strip() + state_id = request.form['state_Id'] + + if not re.match(str_pattern_reg, district_name): + return json_response(ResponseHandler.invalid_name("district"), 400) + + try: + # cursor.execute("SELECT * FROM districts WHERE District_Name = %s AND State_Id = %s", + # (district_name, state_id)) + cursor.callproc("GetDistrictByNameAndState", (district_name, state_id)) + for data in cursor.stored_results(): + rs = data.fetchone() + if rs: + return json_response(ResponseHandler.already_exists("district"), 409) + + cursor.callproc('SaveDistrict', (district_name, state_id)) + connection.commit() + + return json_response(ResponseHandler.add_success("district"), 200) + + except mysql.connector.Error as e: + print(f"Error inserting district: {e}") + return json_response(ResponseHandler.add_failure("district"), 500) + + try: + # cursor.execute("SELECT d.District_id, d.District_Name, s.State_Name, s.State_Id FROM districts d JOIN states s ON d.State_Id = s.State_ID") + # districtdata = cursor.fetchall() + cursor.callproc("GetAllDistricts") + for dis in cursor.stored_results(): + districtdata = dis.fetchall() + except mysql.connector.Error as e: + print(f"Error fetching districts: {e}") + return ResponseHandler.fetch_failure("districts"), 500 + finally: + cursor.close() + connection.close() + + return render_template('add_district.html', districtdata=districtdata, states=states) + + +# AJAX route to check district existence +@app.route('/check_district', methods=['POST']) +def check_district(): + connection = config.get_db_connection() + + if connection: + cursor = connection.cursor() + district_name = request.json.get('district_Name', '').strip() + state_id = request.json.get('state_Id', '') + + if not re.match(str_pattern_reg, district_name): + return json_response(ResponseHandler.invalid_name("district"), 400) + + try: + # cursor.execute("SELECT * FROM districts WHERE District_Name = %s AND State_Id = %s", + # (district_name, state_id)) + # existing_district = cursor.fetchone() + cursor.callproc("GetDistrictByNameAndState", (district_name, state_id,)) + for result in cursor.stored_results(): + existing_district = result.fetchone() + + if existing_district: + return json_response(ResponseHandler.already_exists("district"), 409) + else: + return json_response(ResponseHandler.is_available("district"), 200) + + except mysql.connector.Error as e: + print(f"Error checking district: {e}") + return json_response(ResponseHandler.add_failure("district"), 500) + finally: + cursor.close() + connection.close() + + +# this is delete District method by id.. +@app.route('/delete_district/', methods=['GET', 'POST']) +def delete_district(district_id): + connection = config.get_db_connection() + + if connection: + cursor = connection.cursor() + try: + # cursor.execute("DELETE FROM districts WHERE District_id = %s", (district_id,)) + cursor.callproc("DeleteDistrict", (district_id,)) + connection.commit() + except mysql.connector.Error as e: + print(f"Error deleting district: {e}") + return json_response(ResponseHandler.delete_failure("district"), 500) + finally: + cursor.close() + connection.close() + + return redirect('/add_district') + + +# this is update District page by id .. +@app.route('/edit_district/', methods=['GET', 'POST']) +def edit_district(district_id): + connection = config.get_db_connection() + districtdata = [] + states = [] + + if connection: + cursor = connection.cursor() + + # Retrieve all states for dropdown + try: + # cursor.execute("SELECT State_ID, State_Name FROM states") + # states = cursor.fetchall() + cursor.callproc("GetAllStates") + for res in cursor.stored_results(): + states = res.fetchall() + + except mysql.connector.Error as e: + print(f"Error fetching states: {e}") + return ResponseHandler.fetch_failure("states"), 500 + + # Retrieve district info + try: + # cursor.execute("SELECT District_Name, State_Id FROM districts WHERE District_id = %s", (district_id,)) + # districtdata = cursor.fetchone() + cursor.callproc("GetDistrictDataByID", (district_id,)) + for rs in cursor.stored_results(): + districtdata = rs.fetchone() + except mysql.connector.Error as e: + print(f"Error fetching district data: {e}") + return ResponseHandler.fetch_failure("district"), 500 + + # Handle update + if request.method == 'POST': + district_name = request.form['district_Name'] + state_id = request.form['state_Id'] + + try: + # cursor.execute( "UPDATE districts SET District_Name = %s, State_Id = %s WHERE District_id = %s", + # (district_name, state_id, district_id) ) + + cursor.callproc("UpdateDistrict", (district_id, state_id, district_name,)) + connection.commit() + except mysql.connector.Error as e: + print(f"Error updating district: {e}") + return ResponseHandler.update_failure("district"), 500 + return redirect('/add_district') + + return render_template('edit_district.html', districtdata=districtdata, states=states) + + +# --------- end District controller ------------- + +# ------------------------- Block controller ------------------------------------------ +@app.route('/add_block', methods=['GET', 'POST']) +def add_block(): + connection = config.get_db_connection() + block_data = [] + states = [] + + if connection: + cursor = connection.cursor() + try: + # cursor.execute("SELECT State_ID, State_Name FROM states") + # states = cursor.fetchall() + cursor.callproc("GetAllStates") + for res in cursor.stored_results(): + states = res.fetchall() + + except mysql.connector.Error as e: + print(f"Error fetching states: {e}") + return json_response(ResponseHandler.fetch_failure("states"), 500) + + if request.method == 'POST': + block_name = request.form['block_Name'].strip() + district_id = request.form['district_Id'] + + if not re.match(str_pattern_reg, block_name): + return json_response(ResponseHandler.invalid_name("block"), 400) + + try: + # cursor.execute("SELECT * FROM blocks WHERE Block_Name = %s AND District_id = %s", + # (block_name, district_id)) + # existing_block = cursor.fetchone() + cursor.callproc("GetBlockByNameAndDistrict", (block_name, district_id,)) + for rs in cursor.stored_results(): + existing_block = rs.fetchone() + + if existing_block: + return json_response(ResponseHandler.already_exists("block"), 409) + + cursor.callproc('SaveBlock', (block_name, district_id)) + connection.commit() + + return json_response(ResponseHandler.add_success("block"), 200) + + except mysql.connector.Error as e: + print(f"Error adding block: {e}") + return json_response(ResponseHandler.add_failure("block"), 500) + + # Fetch all blocks to display + try: + # cursor.execute( + # """SELECT b.Block_Id, b.Block_Name, d.District_Name + # FROM blocks b + # JOIN districts d ON b.District_id = d.District_id""" + # ) + # block_data = cursor.fetchall() + cursor.callproc("GetAllBlocks") + for blocks in cursor.stored_results(): + block_data = blocks.fetchall() + + except mysql.connector.Error as e: + print(f"Error fetching blocks: {e}") + return json_response(ResponseHandler.fetch_failure("blocks"), 500) + finally: + cursor.close() + connection.close() + return render_template('add_block.html', block_data=block_data, states=states) + + +# check block +@app.route('/check_block', methods=['POST']) +def check_block(): + connection = config.get_db_connection() + cursor = connection.cursor() + block_name = request.json.get('block_Name', '').strip() + district_id = request.json.get('district_Id', '') + + if not re.match(str_pattern_reg, block_name): + return json_response(ResponseHandler.invalid_name("block"), 400) + + # cursor.execute("SELECT * FROM blocks WHERE Block_Name = %s AND District_id = %s", (block_name, district_id)) + # existing_block = cursor.fetchone() + cursor.callproc("GetBlockByNameAndDistrict", (block_name, district_id)) + for rs in cursor.stored_results(): + existing_block = rs.fetchone() + + if existing_block: + return json_response(ResponseHandler.already_exists("block"), 409) + + return json_response(ResponseHandler.is_available("block"), 200) + + +# update block by id +# @app.route('/edit_block/', methods=['GET', 'POST']) +# def edit_block(block_id): +# connection = config.get_db_connection() +# block_data, states, districts = [], [], [] +# +# if connection: +# cursor = connection.cursor() +# try: +# # cursor.execute("SELECT State_ID, State_Name FROM states") +# # states = cursor.fetchall() +# cursor.callproc("GetAllStates") +# for res in cursor.stored_results(): +# states = res.fetchall() +# +# # cursor.execute("SELECT Block_Name, District_id FROM blocks WHERE Block_Id = %s", (block_id,)) +# # block_data = cursor.fetchone() +# cursor.callproc("GetBlockById",(block_id,)) +# for block in cursor.stored_results(): +# block_data = block.fetchone() +# +# except mysql.connector.Error as e: +# print(f"Error fetching block data: {e}") +# return json_response(ResponseHandler.fetch_failure("block data"), 500) +# +# if request.method == 'POST': +# block_name = request.form['block_Name'] +# district_id = request.form['district_Id'] +# +# try: +# # cursor.execute("UPDATE blocks SET Block_Name = %s, District_id = %s WHERE Block_Id = %s", +# # (block_name, district_id, block_id)) +# +# cursor.callproc("UpdateBlock",(block_id,block_name, district_id)) +# connection.commit() +# except mysql.connector.Error as e: +# print(f"Error updating block: {e}") +# return json_response(ResponseHandler.update_failure("block"), 500) +# +# return redirect('/add_block') +# +# try: +# # cursor.execute("SELECT District_id, District_Name FROM districts") +# # districts = cursor.fetchall() +# +# cursor.callproc("GetAllDistricts") +# for dis in cursor.stored_results(): +# districts = dis.fetchall() +# +# except mysql.connector.Error as e: +# print(f"Error fetching districts: {e}") +# return json_response(ResponseHandler.fetch_failure("districts"), 500) +# +# return render_template('edit_block.html', block_data=block_data, states=states, districts=districts) + +@app.route('/edit_block/', methods=['GET', 'POST']) +def edit_block(block_id): + connection = config.get_db_connection() + block_data = [] + states = [] + districts = [] + + if connection: + cursor = connection.cursor() + # Retrieve all states + try: + # cursor.execute("SELECT State_ID, State_Name FROM states") + # states = cursor.fetchall() + cursor.callproc("GetAllStates") + for rs in cursor.stored_results(): + states = rs.fetchall() + except mysql.connector.Error as e: + print(f"Error fetching states: {e}") + return "Failed to fetch states", 500 + + # Retrieve block data + try: + # cursor.execute("SELECT Block_Name, District_id FROM blocks WHERE Block_Id = %s", (block_id,)) + # block_data = cursor.fetchone() + cursor.callproc("GetBlockDataByID", (block_id,)) + for rs in cursor.stored_results(): + block_data = rs.fetchone() + except mysql.connector.Error as e: + print(f"Error fetching block data: {e}") + return "Failed to fetch block data", 500 + + # Handle POST request + if request.method == 'POST': + block_name = request.form['block_Name'] + district_id = request.form['district_Id'] + try: + # cursor.execute("UPDATE blocks SET Block_Name = %s, District_id = %s WHERE Block_Id = %s", + # (block_name, district_id, block_id)) + cursor.callproc("UpdateBlockById", (block_name, district_id, block_id,)) + connection.commit() + flash("Block updated successfully!", "success") + return redirect(url_for('add_block', block_id=block_id)) + except mysql.connector.Error as e: + print(f"Error updating blocks: {e}") + return "Failed to update blocks", 500 + + # Retrieve districts for the dropdown + try: + # cursor.execute("SELECT District_id, District_Name FROM districts") + # districts = cursor.fetchall() + cursor.callproc("GetAllDistrictsData") + for rs in cursor.stored_results(): + districts = rs.fetchall() + except mysql.connector.Error as e: + print(f"Error fetching districts: {e}") + return "Failed to fetch districts", 500 + + return render_template('edit_block.html', block_data=block_data, states=states, districts=districts) + + + + + + +# delete block by id +@app.route('/delete_block/', methods=['GET', 'POST']) +def delete_block(block_id): + connection = config.get_db_connection() + + if connection: + cursor = connection.cursor() + try: + # cursor.execute("DELETE FROM blocks WHERE Block_Id = %s", (block_id,)) + cursor.callproc("DeleteBlock", (block_id,)) + connection.commit() + except mysql.connector.Error as e: + print(f"Error deleting block: {e}") + return json_response(ResponseHandler.add_failure("block"), 500) + finally: + cursor.close() + connection.close() + + return redirect('/add_block') + + +# this is get district all data by using state id .. +@app.route('/get_districts/', methods=['GET']) +def get_districts(state_id): + connection = config.get_db_connection() + districts = [] + + if connection: + cursor = connection.cursor() + try: + # cursor.execute("SELECT District_id, District_Name FROM districts WHERE State_Id = %s", (state_id,)) + # districts = cursor.fetchall() + + cursor.callproc("GetDistrictsByStateId", (state_id,)) + for dis in cursor.stored_results(): + districts = dis.fetchall() + except mysql.connector.Error as e: + print(f"Error fetching districts: {e}") + return json_response(ResponseHandler.fetch_failure("districts"), 500) + finally: + cursor.close() + connection.close() + + return jsonify({ + "districts": [{"District_id": d[0], "District_Name": d[1]} for d in districts] + }) + + +# ----------- end Block controller ----------------- + +# ------------------------- Village controller ------------------------------------------ +# Route to add a village +@app.route('/add_village', methods=['GET', 'POST']) +def add_village(): + connection = config.get_db_connection() + cursor = connection.cursor() + states = [] + villages = [] + + try: + # Fetch all states + # cursor.execute("SELECT State_ID, State_Name FROM states") + # states = cursor.fetchall() + + cursor.callproc("GetAllStates") + for res in cursor.stored_results(): + states = res.fetchall() + + # Fetch all villages with their block names + # cursor.execute(""" + # SELECT v.Village_Id, v.Village_Name, b.Block_Name + # FROM villages v + # JOIN blocks b ON v.Block_Id = b.Block_Id + # """) + # villages = cursor.fetchall() + cursor.callproc("GetAllVillages") + for result in cursor.stored_results(): + villages = result.fetchall() + + if request.method == 'POST': + block_id = request.form.get('block_Id') + village_name = request.form.get('Village_Name', '').strip() + + if not block_id: + return json_response(ResponseHandler.add_failure("block"), 400) + + if not re.match(str_pattern_reg, village_name): + return json_response(ResponseHandler.invalid_name("village"), 400) + + # Check if the village already exists in the block + # cursor.execute("SELECT * FROM villages WHERE Village_Name = %s AND Block_Id = %s", (village_name, block_id)) + # existing_village = cursor.fetchone() + cursor.callproc("GetVillageByNameAndBlock", (village_name, block_id,)) + for rs in cursor.stored_results(): + existing_village = rs.fetchone() + if existing_village: + return json_response(ResponseHandler.already_exists("village"), 409) + + # Insert new village + cursor.callproc('SaveVillage', (village_name, block_id)) + connection.commit() + + return json_response(ResponseHandler.add_success("village"), 200) + + except mysql.connector.Error as e: + print(f"Database Error: {e}") + return json_response(ResponseHandler.add_failure("village"), 500) + finally: + cursor.close() + connection.close() + + return render_template('add_village.html', states=states, villages=villages) + + +# get block by district id +@app.route('/get_blocks/', methods=['GET']) +def get_blocks(district_id): + connection = config.get_db_connection() + cursor = connection.cursor() + blocks = [] + + try: + # cursor.execute("SELECT Block_Id, Block_Name FROM blocks WHERE District_id = %s", (district_id,)) + # blocks = cursor.fetchall() + cursor.callproc("GetBlocksByDistrict", (district_id,)) + for rs in cursor.stored_results(): + blocks = rs.fetchall() + except mysql.connector.Error as e: + print(f"Error fetching blocks: {e}") + return json_response({"error": "Failed to fetch blocks"}, 500) + finally: + cursor.close() + connection.close() + + return jsonify({"blocks": [{"Block_Id": block[0], "Block_Name": block[1]} for block in blocks]}) + + +# check village +@app.route('/check_village', methods=['POST']) +def check_village(): + connection = config.get_db_connection() + cursor = connection.cursor() + + block_id = request.form.get('block_Id') + village_name = request.form.get('Village_Name', '').strip() + + # Validate village name + if not re.match(str_pattern_reg, village_name): + return json_response(ResponseHandler.invalid_name("village"), 400) + + if not block_id or not village_name: + return json_response({'status': 'error', 'message': 'Block and Village Name are required!'}, 400) + + # cursor.execute("SELECT * FROM villages WHERE Village_Name = %s AND Block_Id = %s", (village_name, block_id)) + # existing_village = cursor.fetchone() + cursor.callproc("GetVillageByNameAndBlocks", (village_name, block_id)) + for rs in cursor.stored_results(): + existing_village = rs.fetchone() + + cursor.close() + connection.close() + + if existing_village: + return json_response(ResponseHandler.already_exists("village"), 409) + else: + return json_response(ResponseHandler.is_available("village"), 200) + + +# update village +# @app.route('/edit_village/', methods=['GET', 'POST']) +# def edit_village(village_id): +# connection = config.get_db_connection() +# village_data = None +# blocks = [] +# +# try: +# cursor = connection.cursor() +# # Fetch village details +# # cursor.execute("SELECT Village_Name, Block_Id FROM villages WHERE Village_Id = %s", (village_id,)) +# # village_data = cursor.fetchone() +# cursor.callproc("GetVillageById", (village_id,)) +# for result in cursor.stored_results(): +# village_data = result.fetchone() +# +# # Fetch all blocks for dropdown +# # cursor.execute("SELECT Block_Id, Block_Name FROM blocks") +# # blocks = cursor.fetchall() +# +# cursor.callproc("GetAllBlocks") +# for result in cursor.stored_results(): +# blocks = result.fetchall() +# +# if request.method == 'POST': +# village_name = request.form['Village_Name'] +# block_id = request.form['block_Id'] +# +# if not re.match(str_pattern_reg, village_name): +# return json_response(ResponseHandler.invalid_name("village"), 400) +# +# # cursor.execute("UPDATE villages SET Village_Name = %s, Block_Id = %s WHERE Village_Id = %s", +# # (village_name, block_id, village_id)) +# +# cursor.callproc("UpdateVillage", (village_id, village_name, block_id,)) +# +# connection.commit() +# return json_response(ResponseHandler.update_success("village"), 200) +# +# except mysql.connector.Error as e: +# print(f"Error: {e}") +# return json_response(ResponseHandler.update_failure("village"), 500) +# finally: +# if cursor: +# cursor.close() +# if connection: +# connection.close() +# +# return render_template('edit_village.html', village_data=village_data, blocks=blocks) + +@app.route('/edit_village/', methods=['GET', 'POST']) +def edit_village(village_id): + connection = config.get_db_connection() + village_data = None + blocks = [] + + try: + cursor = connection.cursor() + # # Fetch village details + # cursor.execute("SELECT Village_Name, Block_Id FROM villages WHERE Village_Id = %s", (village_id,)) + # village_data = cursor.fetchone() + cursor.callproc("GetVillageDetailsById", (village_id,)) + for rs in cursor.stored_results(): + village_data = rs.fetchone() + # Fetch all blocks for dropdown + # cursor.execute("SELECT Block_Id, Block_Name FROM blocks") + # blocks = cursor.fetchall() + cursor.callproc('GetAllBlocks') + for result in cursor.stored_results(): + blocks = result.fetchall() + + if request.method == 'POST': + village_name = request.form['Village_Name'] + block_id = request.form['block_Id'] + + if not re.match("^[A-Za-z ]+$", village_name): + flash("Invalid village name! Only letters and spaces allowed.", "error") + return redirect(url_for('edit_village', village_id=village_id)) + + cursor.execute("UPDATE villages SET Village_Name = %s, Block_Id = %s WHERE Village_Id = %s", + (village_name, block_id, village_id)) + connection.commit() + flash("Village updated successfully!", "success") + return redirect(url_for('edit_village', village_id=village_id)) + + except mysql.connector.Error as e: + print(f"Error: {e}") + return "Failed to process request", 500 + finally: + if cursor: + cursor.close() + if connection: + connection.close() + + return render_template('edit_village.html', village_data=village_data, blocks=blocks) + + +# delete village +@app.route('/delete_village/', methods=['GET', 'POST']) +def delete_village(village_id): + connection = config.get_db_connection() + cursor = connection.cursor() + + try: + # cursor.execute("DELETE FROM villages WHERE Village_Id = %s", (village_id,)) + cursor.callproc("DeleteVillage", (village_id,)) + connection.commit() + # return json_response(ResponseHandler.delete_success("village"), 200) + except mysql.connector.Error as e: + print(f"Error: {e}") + return json_response(ResponseHandler.add_failure("village"), 500) + finally: + if cursor: + cursor.close() + if connection: + connection.close() + + return redirect(url_for('add_village')) + + +# ---- end Village controller --------------------- + + +# -------------------------------- Invoice controller ------------------------------------------ +@app.route('/add_invoice', methods=['GET', 'POST']) +def add_invoice(): + connection = config.get_db_connection() + if not connection: + return jsonify({"status": "error", "message": "Database connection failed"}), 500 + + if request.method == 'POST': + try: + cursor = connection.cursor(dictionary=True) + + # Get the village name from the form + village_name = request.form.get('village') + print("village name", village_name) + + # Query the database to get the corresponding Village_Id based on the village name + # cursor.execute("SELECT Village_Id FROM villages WHERE Village_Name = %s", (village_name,)) + # village_result = cursor.fetchone() + cursor.callproc("GetVillageIdByName", (village_name,)) + for rs in cursor.stored_results(): + village_result = rs.fetchone() + + if not village_result: + return jsonify({"status": "error", "message": f"Village '{village_name}' not found"}), 400 + + village_id = village_result['Village_Id'] + + # Fetch form data + pmc_no = request.form.get('pmc_no') + work_type = request.form.get('work_type') + invoice_details = request.form.get('invoice_details') + invoice_date = request.form.get('invoice_date') + invoice_no = request.form.get('invoice_no') + basic_amount = request.form.get('basic_amount') + debit_amount = request.form.get('debit_amount') + after_debit_amount = request.form.get('after_debit_amount') + amount = request.form.get('amount') + gst_amount = request.form.get('gst_amount') + tds_amount = request.form.get('tds_amount') + sd_amount = request.form.get('sd_amount') + on_commission = request.form.get('on_commission') + hydro_testing = request.form.get('hydro_testing') + gst_sd_amount = request.form.get('gst_sd_amount') + final_amount = request.form.get('final_amount') + + # insert_invoice_query = ''' + # INSERT INTO invoice ( + # PMC_No, Village_Id, Work_Type, Invoice_Details, Invoice_Date, Invoice_No, + # Basic_Amount, Debit_Amount, After_Debit_Amount, Amount, GST_Amount, TDS_Amount, + # SD_Amount, On_Commission, Hydro_Testing, GST_SD_Amount, Final_Amount + # ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) + # ''' + # invoice_values = ( + # pmc_no, village_id, work_type, invoice_details, invoice_date, invoice_no, + # basic_amount, debit_amount, after_debit_amount, amount, gst_amount, tds_amount, + # sd_amount, on_commission, hydro_testing, gst_sd_amount, final_amount + # ) + # cursor.execute(insert_invoice_query, invoice_values) + # connection.commit() + # invoice_id = cursor.lastrowid + cursor.callproc('InsertInvoice', [ + pmc_no, village_id, work_type, invoice_details, invoice_date, invoice_no, + basic_amount, debit_amount, after_debit_amount, amount, gst_amount, tds_amount, + sd_amount, on_commission, hydro_testing, gst_sd_amount, final_amount]) + + for result in cursor.stored_results(): + invoice_id = result.fetchone()['invoice_id'] + connection.commit() + + print("This is the invocie id from the invoice table ", invoice_id) + + # Insert into assign_subcontractors table + # subcontractor_id = request.form.get('subcontractor_id') + # insert_assign_query = ''' + # INSERT INTO assign_subcontractors (PMC_no, Contractor_Id, Village_Id) + # VALUES (%s, %s, %s) + # ''' + # cursor.execute(insert_assign_query, (pmc_no, subcontractor_id, village_id)) + # connection.commit() + subcontractor_id = request.form.get('subcontractor_id') + cursor.callproc('AssignSubcontractor', [pmc_no, subcontractor_id, village_id]) + connection.commit() + + # Insert Hold Amounts into invoice_subcontractor_hold_join table + hold_types = request.form.getlist('hold_type[]') + hold_amounts = request.form.getlist('hold_amount[]') + hold_count = 0 + + for hold_type, hold_amount in zip(hold_types, hold_amounts): + # cursor.execute("SELECT hold_type_id FROM hold_types WHERE hold_type = %s", (hold_type,)) + # hold_type_result = cursor.fetchone() + cursor.callproc('GetHoldTypeIdByName', [hold_type]) + for result in cursor.stored_results(): + hold_type_result = result.fetchone() + print("hold type from invoice ", hold_type_result) + if not hold_type_result: + return jsonify({"status": "error", "message": f"Invalid Hold Type: {hold_type}"}), 400 + hold_type_id = hold_type_result['hold_type_id'] + # insert_hold_query = ''' + # INSERT INTO invoice_subcontractor_hold_join (Contractor_Id, Invoice_Id, hold_type_id, hold_amount) + # VALUES (%s, %s, %s, %s) + # ''' + # cursor.execute(insert_hold_query, (subcontractor_id, invoice_id, hold_type_id, hold_amount)) + # hold_count += 1 + + # connection.commit() + cursor.callproc('InsertInvoiceSubcontractorHold', [ + subcontractor_id, invoice_id, hold_type_id, hold_amount + ]) + connection.commit() + hold_count += 1 + print("Hold count from the invoice", hold_count) + connection.commit() + + return jsonify({"status": "success", "message": "Invoice added successfully"}), 201 + + except mysql.connector.Error as e: + connection.rollback() + return jsonify({"status": "error", "message": f"Failed to add invoice: {str(e)}"}), 500 + finally: + cursor.close() + connection.close() + + # GET request: fetch and display all invoices (all fields) along with the form + try: + cursor = connection.cursor(dictionary=True) + # cursor.execute("SELECT * FROM view_invoice_details") + # invoices = cursor.fetchall() + cursor.callproc('GetAllInvoiceDetails') + for result in cursor.stored_results(): + invoices = result.fetchall() + + villages = [] + cursor.callproc("GetAllVillages") + for result in cursor.stored_results(): + villages = result.fetchall() + + except mysql.connector.Error as e: + print(f"Error: {e}") + invoices = [] + finally: + cursor.close() + connection.close() + + return render_template('add_invoice.html', invoices=invoices, villages=villages) + + +# search subcontraactor to assing invoice +@app.route('/search_subcontractor', methods=['POST']) +def search_subcontractor(): + connection = config.get_db_connection() + if not connection: + return json_response(ResponseHandler.fetch_failure("database connection"), 500) + + sub_query = request.form.get("query") + try: + cursor = connection.cursor(dictionary=True) + # cursor.execute( + # "SELECT Contractor_Id, Contractor_Name FROM subcontractors WHERE Contractor_Name LIKE %s", + # (f"%{sub_query}%",) + # ) + # results = cursor.fetchall() + cursor.callproc('SearchContractorsByName', [sub_query]) + for result in cursor.stored_results(): + results = result.fetchall() + print(results) + if not results: + return "
  • No subcontractor found
  • " + + output = "".join( + f"
  • {row['Contractor_Name']}
  • " + for row in results + ) + print("Ajax Call for subcontractor", output) + return output + + except mysql.connector.Error as e: + return json_response(ResponseHandler.fetch_failure(f"Search failed: {str(e)}"), 500) + + finally: + cursor.close() + connection.close() + + +# get hold types +@app.route('/get_hold_types', methods=['GET']) +def get_hold_types(): + connection = config.get_db_connection() + try: + cursor = connection.cursor(dictionary=True) + # cursor.execute("SELECT hold_type_id, hold_type FROM hold_types") + # hold_types = cursor.fetchall() + + cursor.callproc("GetAllHoldTypes") + for hold in cursor.stored_results(): + hold_types = hold.fetchall() + + return jsonify(hold_types) + except mysql.connector.Error as e: + return ResponseHandler.fetch_failure({str(e)}), 500 + # return jsonify({"status": "error", "message": f"Failed to fetch hold types: {str(e)}"}), 500 + finally: + cursor.close() + connection.close() + + +# update invoice by id + +@app.route('/edit_invoice/', methods=['GET', 'POST']) +def edit_invoice(invoice_id): + connection = config.get_db_connection() + if not connection: + return jsonify({"status": "error", "message": "Database connection failed"}), 500 + + cursor = connection.cursor(dictionary=True) + + if request.method == 'POST': + try: + # Fetch updated form data + subcontractor_id = request.form.get('subcontractor_id', '').strip() + subcontractor_id = int(subcontractor_id) if subcontractor_id else None + + village_name = request.form.get('village') + # cursor.execute("SELECT Village_Id FROM villages WHERE Village_Name = %s", (village_name,)) + # village_result = cursor.fetchone() + cursor.callproc("GetVillageIdByName", (village_name,)) + for rs in cursor.stored_results(): + village_result = rs.fetchone() + if not village_result: + return jsonify({"status": "error", "message": "Invalid Village Name"}), 400 + village_id = village_result['Village_Id'] + + pmc_no = request.form.get('pmc_no') + work_type = request.form.get('work_type') + invoice_details = request.form.get('invoice_details') + invoice_date = request.form.get('invoice_date') + invoice_no = request.form.get('invoice_no') + + # Convert numeric fields properly + numeric_fields = { + "basic_amount": request.form.get('basic_amount'), + "debit_amount": request.form.get('debit_amount'), + "after_debit_amount": request.form.get('after_debit_amount'), + "amount": request.form.get('amount'), + "gst_amount": request.form.get('gst_amount'), + "tds_amount": request.form.get('tds_amount'), + "sd_amount": request.form.get('sd_amount'), + "on_commission": request.form.get('on_commission'), + "hydro_testing": request.form.get('hydro_testing'), + "gst_sd_amount": request.form.get('gst_sd_amount'), + "final_amount": request.form.get('final_amount'), + } + numeric_fields = {k: float(v) if v else 0 for k, v in numeric_fields.items()} + + # # Update invoice + # update_invoice_query = ''' + # UPDATE invoice + # SET PMC_No=%s, Village_Id=%s, Work_Type=%s, Invoice_Details=%s, Invoice_Date=%s, + # Invoice_No=%s, Basic_Amount=%s, Debit_Amount=%s, After_Debit_Amount=%s, + # Amount=%s, GST_Amount=%s, TDS_Amount=%s, SD_Amount=%s, On_Commission=%s, + # Hydro_Testing=%s, GST_SD_Amount=%s, Final_Amount=%s + # WHERE Invoice_Id=%s + # ''' + # invoice_values = ( + # pmc_no, village_id, work_type, invoice_details, invoice_date, invoice_no, + # *numeric_fields.values(), invoice_id + # ) + # cursor.execute(update_invoice_query, invoice_values) + # connection.commit() + cursor.callproc('UpdateInvoice', [ + pmc_no, village_id, work_type, invoice_details, invoice_date, invoice_no, + *numeric_fields.values(), invoice_id + ]) + connection.commit() + + # Handle holds + hold_types = request.form.getlist('hold_type[]') + hold_amounts = request.form.getlist('hold_amount[]') + + for hold_type, hold_amount in zip(hold_types, hold_amounts): + if not hold_type: + continue # skip empty hold types + + # Get or insert hold type + # cursor.execute("SELECT hold_type_id FROM hold_types WHERE hold_type = %s", (hold_type,)) + # hold_type_result = cursor.fetchone() + cursor.callproc('GetHoldTypeIdByName', [hold_type]) + for result in cursor.stored_results(): + hold_type_result = result.fetchone() + + # if not hold_type_result: + # cursor.execute("INSERT INTO hold_types (hold_type) VALUES (%s)", (hold_type,)) + # connection.commit() + # hold_type_id = cursor.lastrowid + # else: + # hold_type_id = hold_type_result['hold_type_id'] + + if not hold_type_result: + # Call stored procedure to insert and return new ID + cursor.callproc('InsertHoldType', [hold_type, 0]) + for result in cursor.stored_results(): + pass # advance past any results + cursor.execute("SELECT @_InsertHoldType_1") + hold_type_id = cursor.fetchone()[0] + print("if not hold type result anish:", hold_type_id) + else: + hold_type_id = hold_type_result['hold_type_id'] + print("if hold type result anish:", hold_type_id) + + hold_amount = float(hold_amount) if hold_amount else 0 + + # Check if join exists + # cursor.execute(""" + # SELECT join_id FROM invoice_subcontractor_hold_join + # WHERE Invoice_Id = %s AND Contractor_Id = %s AND hold_type_id = %s + # """, (invoice_id, subcontractor_id, hold_type_id)) + # join_result = cursor.fetchone() + cursor.callproc('GetHoldJoinId', [invoice_id, subcontractor_id, hold_type_id]) + for result in cursor.stored_results(): + join_result = result.fetchone() + + if join_result: + # cursor.execute(""" + # UPDATE invoice_subcontractor_hold_join + # SET hold_amount = %s + # WHERE join_id = %s + # """, (hold_amount, join_result['join_id'])) + cursor.callproc('UpdateHoldAmountByJoinId', [hold_amount, join_result['join_id']]) + connection.commit() + + else: + # cursor.execute(""" + # INSERT INTO invoice_subcontractor_hold_join (Contractor_Id, Invoice_Id, hold_type_id, hold_amount) + # VALUES (%s, %s, %s, %s) + # """, (subcontractor_id, invoice_id, hold_type_id, hold_amount)) + cursor.callproc('InsertInvoiceSubcontractorHold', [ + subcontractor_id, invoice_id, hold_type_id, hold_amount + ]) + connection.commit() + + connection.commit() + return jsonify({"status": "success", "message": "Invoice updated successfully"}), 200 + + except mysql.connector.Error as e: + connection.rollback() + return jsonify({"status": "error", "message": f"Failed to update invoice: {str(e)}"}), 500 + finally: + cursor.close() + connection.close() + + # ------------------ GET Request ------------------ + + try: + # Fetch invoice data + # cursor.execute( + # """SELECT i.*, s.Contractor_Name, v.Village_Name + # FROM invoice i + # LEFT JOIN assign_subcontractors a ON i.PMC_No = a.PMC_no AND i.Village_Id = a.Village_Id + # LEFT JOIN subcontractors s ON a.Contractor_Id = s.Contractor_Id + # LEFT JOIN villages v ON i.Village_Id = v.Village_Id + # WHERE i.Invoice_Id = %s""", (invoice_id,) + # ) + # invoice = cursor.fetchone() + cursor.callproc('GetInvoiceDetailsById', [invoice_id]) + for result in cursor.stored_results(): + invoice = result.fetchone() + + if not invoice: + return jsonify({"status": "error", "message": "Invoice not found"}), 404 + + # Important! Clear unread result issue + while cursor.nextset(): + pass + + # Fetch hold amounts + # cursor.execute( + # """SELECT h.hold_type, ihj.hold_amount + # FROM invoice_subcontractor_hold_join ihj + # JOIN hold_types h ON ihj.hold_type_id = h.hold_type_id + # WHERE ihj.Invoice_Id = %s""", (invoice_id,) + # ) + # hold_amounts = cursor.fetchall() + # invoice["hold_amounts"] = hold_amounts + cursor.callproc('GetHoldAmountsByInvoiceId', [invoice_id]) + for result in cursor.stored_results(): + hold_amounts = result.fetchall() + + invoice["hold_amounts"] = hold_amounts + + + except mysql.connector.Error as e: + return jsonify({"status": "error", "message": f"Database error: {str(e)}"}), 500 + finally: + cursor.close() + connection.close() + + return render_template('edit_invoice.html', invoice=invoice) + + +# delete invoice by id +@app.route('/delete_invoice/', methods=['GET']) +def delete_invoice(invoice_id): + connection = config.get_db_connection() + if not connection: + return json_response(ResponseHandler.fetch_failure("invoice"), 500) + + try: + cursor = connection.cursor() + # cursor.execute("DELETE FROM invoice WHERE Invoice_Id = %s", (invoice_id,)) + + cursor.callproc("DeleteInvoice", (invoice_id,)) + connection.commit() + + # Check if the invoice was actually deleted + if cursor.rowcount == 0: + return json_response(ResponseHandler.fetch_failure("invoice"), 404) + + return redirect(url_for('add_invoice')) + + except mysql.connector.Error as e: + print("Error deleting invoice:", e) + return json_response(ResponseHandler.delete_failure("invoice"), 500) + + finally: + cursor.close() + connection.close() + + +# ---------- end Invoice controller ------------------ + + +# ----------------------------- Payment controller ------------------------------------------ +# this is Payment Page to add data +# @app.route('/add_payment', methods=['GET', 'POST']) +# def add_payment(): +# connection = config.get_db_connection() +# payments = [] # List to hold payment history +# +# if not connection: +# return json_response(ResponseHandler.fetch_failure("payment"), 500) +# +# try: +# cursor = connection.cursor() +# +# # Retrieve payment history +# # cursor.execute( +# # "SELECT Payment_Id, PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR FROM payment" +# # ) +# # payments = cursor.fetchall() +# cursor.callproc("GetAllPayments") +# for result in cursor.stored_results(): +# payments = result.fetchall() +# +# except mysql.connector.Error as e: +# print(f"Error fetching payment history: {e}") +# return json_response(ResponseHandler.fetch_failure("payment"), 500) +# finally: +# cursor.close() +# +# if request.method == 'POST': +# pmc_no = request.form['PMC_No'] +# invoice_no = request.form['invoice_No'] +# amount = request.form['Payment_Amount'] +# tds_amount = request.form['TDS_Payment_Amount'] +# total_amount = request.form['total_amount'] +# utr = request.form['utr'] +# +# try: +# cursor = connection.cursor() +# cursor.callproc('SavePayment', ( +# pmc_no, invoice_no, amount, tds_amount, total_amount, utr +# )) +# connection.commit() +# return redirect(url_for('add_payment')) # Redirect to add_payment page to reload the form +# except mysql.connector.Error as e: +# print(f"Error inserting payment: {e}") +# return json_response(ResponseHandler.add_failure("payment"), 500) +# finally: +# cursor.close() +# connection.close() +# +# return render_template('add_payment.html', payments=payments) + +@app.route('/add_payment', methods=['GET', 'POST']) +def add_payment(): + connection = config.get_db_connection() + payments = [] + + if connection: + cursor = connection.cursor() + + try: + # cursor.execute( + # "SELECT Payment_Id, PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR FROM payment" + # ) + # payments = cursor.fetchall() + cursor.callproc('GetAllPayments') + for result in cursor.stored_results(): + payments = result.fetchall() + + except mysql.connector.Error as e: + print(f"Error fetching payment history: {e}") + return "Failed to fetch payment history", 500 + finally: + cursor.close() + + if request.method == 'POST': + pmc_no = request.form['PMC_No'] + invoice_no = request.form['invoice_No'] + amount = request.form['Payment_Amount'] + tds_amount = request.form['TDS_Payment_Amount'] + total_amount = request.form['total_amount'] + utr = request.form['utr'] + + try: + cursor = connection.cursor() + # cursor.execute('''INSERT INTO payment (PMC_No, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR) + # VALUES (%s, %s, %s, %s, %s, %s)''', + # (pmc_no, invoice_no, amount, tds_amount, total_amount, utr)) + # connection.commit() + cursor.callproc('InsertPayments', [ + pmc_no, invoice_no, amount, tds_amount, total_amount, utr + ]) + connection.commit() + + return redirect(url_for('add_payment')) + + except mysql.connector.Error as e: + print(f"Error inserting payment: {e}") + return "Failed to add payment", 500 + finally: + cursor.close() + connection.close() + + return render_template('add_payment.html', payments=payments) + + +@app.route('/get_pmc_nos_by_subcontractor/') +def get_pmc_nos_by_subcontractor(subcontractorId): + connection = config.get_db_connection() + cur = connection.cursor() + print(subcontractorId) + # query = """ + # SELECT DISTINCT i.PMC_No + # FROM invoice i + # JOIN assign_subcontractors a ON i.PMC_No = a.PMC_no + # JOIN subcontractors s ON a.Contractor_Id = s.Contractor_Id + # WHERE s.Contractor_Id=%s; + # """ + # cur.execute(query, (subcontractorId,)) + # results = cur.fetchall() + cur.callproc('GetDistinctPMCNoByContractorId', [subcontractorId]) + for result in cur.stored_results(): + results = result.fetchall() + + print(results) + pmc_nos = [row[0] for row in results] + cur.close() + return jsonify({'pmc_nos': pmc_nos}) + + +# Edit Payment Route +@app.route('/edit_payment/', methods=['GET', 'POST']) +def edit_payment(payment_id): + connection = config.get_db_connection() + payment_data = {} # To hold the payment data for the given ID + + if not connection: + return json_response(ResponseHandler.fetch_failure("payment"), 500) + + try: + cursor = connection.cursor() + + # Fetch the existing payment data for the given payment_id + # cursor.execute( + # "SELECT Payment_Id, PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR FROM payment WHERE Payment_Id = %s", + # (payment_id,) + # ) + # payment_data = cursor.fetchone() + + cursor.callproc("GetPaymentById", (payment_id,)) + for result in cursor.stored_results(): + payment_data = result.fetchone() + + # Handle POST request to update the payment + if request.method == 'POST': + pmc_no = request.form['PMC_No'] + invoice_no = request.form['invoice_No'] + amount = request.form['Payment_Amount'] + tds_amount = request.form['TDS_Payment_Amount'] + total_amount = request.form['total_amount'] + utr = request.form['utr'] + + try: + # cursor.execute('''UPDATE payment SET PMC_No=%s, Invoice_No=%s, Payment_Amount=%s, TDS_Payment_Amount=%s, + # Total_Amount=%s, UTR=%s WHERE Payment_Id=%s''', + # (pmc_no, invoice_no, amount, tds_amount, total_amount, utr, payment_id)) + + cursor.callproc("UpdatePayment", + (payment_id, pmc_no, invoice_no, amount, tds_amount, total_amount, utr,)) + connection.commit() + + return redirect(url_for('add_payment')) # Redirect to add_payment page to view the updated list + except mysql.connector.Error as e: + print(f"Error updating payment: {e}") + return json_response(ResponseHandler.update_failure("payment"), 500) + + except mysql.connector.Error as e: + print(f"Error fetching payment data: {e}") + return json_response(ResponseHandler.fetch_failure("payment"), 500) + finally: + cursor.close() + connection.close() + + return render_template('edit_payment.html', payment_data=payment_data) + + +# Delete Payment Route +@app.route('/delete_payment/', methods=['GET', 'POST']) +def delete_payment(payment_id): + connection = config.get_db_connection() + if not connection: + return json_response(ResponseHandler.fetch_failure("payment"), 500) + try: + cursor = connection.cursor() + # cursor.execute("DELETE FROM payment WHERE Payment_Id = %s", (payment_id,)) + + cursor.callproc("DeletePayment", (payment_id,)) + connection.commit() + # Check if any rows were deleted + if cursor.rowcount == 0: + return json_response(ResponseHandler.fetch_failure("payment"), 404) + return redirect(url_for('add_payment')) # Redirect back to the add_payment page + + except mysql.connector.Error as e: + print(f"Error deleting payment: {e}") + return json_response(ResponseHandler.delete_failure("payment"), 500) + finally: + cursor.close() + connection.close() + + +# --- end Payment controller ----------- + +# ------------------------- GST Release controller ------------------------------------------ +@app.route('/add_gst_release', methods=['GET', 'POST']) +def add_gst_release(): + connection = config.get_db_connection() + gst_releases = [] # List to hold GST Release history + invoices = [] # List to hold invoices for the dropdown + + if not connection: + return json_response(ResponseHandler.fetch_failure("GST Release"), 500) + + try: + cursor = connection.cursor() + + # Retrieve GST Release history + # cursor.execute("SELECT GST_Release_Id, PMC_No, Invoice_No, Basic_Amount, Final_Amount FROM gst_release") + # gst_releases = cursor.fetchall() + + cursor.callproc("GetAllGSTReleases") + for result in cursor.stored_results(): + gst_releases = result.fetchall() + + if request.method == 'POST': + pmc_no = request.form['PMC_No'] + invoice_no = request.form['invoice_No'] + basic_amount = request.form['basic_amount'] + final_amount = request.form['final_amount'] + + cursor.callproc('SaveGSTRelease', ( + pmc_no, invoice_no, basic_amount, final_amount + )) + connection.commit() + + return redirect(url_for('add_gst_release')) # Redirect to add_gst_release page + + except mysql.connector.Error as e: + print(f"Error: {e}") + return json_response(ResponseHandler.add_failure("GST Release"), 500) + + finally: + cursor.close() + connection.close() + + return render_template('add_gst_release.html', invoices=invoices, gst_releases=gst_releases) + + +# update gst Release by id +@app.route('/edit_gst_release/', methods=['GET', 'POST']) +def edit_gst_release(gst_release_id): + connection = config.get_db_connection() + gst_release_data = {} # To hold the GST release data for the given ID + invoices = [] # List to hold invoices for the dropdown + + if not connection: + return json_response(ResponseHandler.fetch_failure("GST Release"), 500) + + try: + cursor = connection.cursor() + + # Fetch the existing GST release data for the given gst_release_id + # cursor.execute( + # "SELECT GST_Release_Id, PMC_No, Invoice_No, Basic_Amount, Final_Amount FROM gst_release WHERE GST_Release_Id = %s", + # (gst_release_id,) + # ) + # gst_release_data = cursor.fetchone() + + cursor.callproc("GetGSTReleaseById", (gst_release_id,)) + for result in cursor.stored_results(): + gst_release_data = result.fetchone() + + if request.method == 'POST': + pmc_id = request.form['PMC_No'] + invoice_no = request.form['invoice_No'] + basic_amount = request.form['basic_amount'] + final_amount = request.form['final_amount'] + + try: + # cursor.execute('''UPDATE gst_release SET PMC_No=%s, Invoice_No=%s, Basic_Amount=%s, Final_Amount=%s + # WHERE GST_Release_Id=%s''', + # (pmc_id, invoice_no, basic_amount, final_amount, gst_release_id)) + + cursor.callproc("UpdateGSTRelease", (gst_release_id, pmc_id, invoice_no, basic_amount, final_amount)) + + connection.commit() + + return redirect(url_for('add_gst_release')) # Redirect to the page to view the updated list + + except mysql.connector.Error as e: + print(f"Error updating GST Release: {e}") + return json_response(ResponseHandler.update_failure("GST Release"), 500) + + except mysql.connector.Error as e: + print(f"Error fetching GST Release data: {e}") + return json_response(ResponseHandler.fetch_failure("GST Release"), 500) + + finally: + cursor.close() + connection.close() + + return render_template('edit_gst_release.html', gst_release_data=gst_release_data, invoices=invoices) + + +# delete gst release by id +@app.route('/delete_gst_release/', methods=['GET', 'POST']) +def delete_gst_release(gst_release_id): + connection = config.get_db_connection() + if not connection: + return json_response(ResponseHandler.fetch_failure("GST Release"), 500) + try: + cursor = connection.cursor() + # cursor.execute("DELETE FROM gst_release WHERE GST_Release_Id = %s", (gst_release_id,)) + cursor.callproc("DeleteGSTRelease", (gst_release_id,)) + connection.commit() + # Check if any rows were deleted + if cursor.rowcount == 0: + return json_response(ResponseHandler.fetch_failure("GST Release"), 404) + return redirect(url_for('add_gst_release')) # Redirect to the add_gst_release page + except mysql.connector.Error as e: + print(f"Error deleting GST Release: {e}") + return json_response(ResponseHandler.delete_failure("GST Release"), 500) + finally: + cursor.close() + connection.close() + + +# --- end GST Release controller ----- + +# ------------------------- Subcontractor controller ------------------------------------------ +@app.route('/subcontractor', methods=['GET', 'POST']) +def subcontract(): + connection = config.get_db_connection() + subcontractor = [] + + if not connection: + return json_response(ResponseHandler.fetch_failure("Subcontractor"), 500) + + try: + cursor = connection.cursor() + + if request.method == 'GET': + try: + # cursor.execute('SELECT * FROM subcontractors;') + # subcontractor = cursor.fetchall() # Fetch the current subcontractor list + # connection.commit() + cursor.callproc('GetAllSubcontractors') + for result in cursor.stored_results(): + subcontractor = result.fetchall() + + except Error as e: + print(f"Error fetching data: {e}") + return json_response(ResponseHandler.fetch_failure("Subcontractor"), 500) + + if request.method == 'POST': + contractor_data = { + 'Contractor_Name': request.form['Contractor_Name'], + 'Address': request.form['Address'], + 'Mobile_No': request.form['Mobile_No'], + 'PAN_No': request.form['PAN_No'], + 'Email': request.form['Email'], + 'Gender': request.form['Gender'], + 'GST_Registration_Type': request.form['GST_Registration_Type'], + 'GST_No': request.form['GST_No'], + 'Contractor_password': request.form['Contractor_password'], + } + + try: + cursor.callproc('SaveContractor', ( + contractor_data['Contractor_Name'], + contractor_data['Address'], + contractor_data['Mobile_No'], + contractor_data['PAN_No'], + contractor_data['Email'], + contractor_data['Gender'], + contractor_data['GST_Registration_Type'], + contractor_data['GST_No'], + contractor_data['Contractor_password'] + )) + connection.commit() + + # Re-fetch subcontractors after inserting the new one + # cursor.execute('SELECT * FROM subcontractors') + # subcontractor = cursor.fetchall() + cursor.callproc('GetAllSubcontractors') + for result in cursor.stored_results(): + subcontractor = result.fetchall() + + + except Error as e: + print(f"Error inserting data: {e}") + return json_response(ResponseHandler.add_failure("Subcontractor"), 500) + + except Error as e: + print(f"Error handling subcontractor data: {e}") + return json_response(ResponseHandler.fetch_failure("Subcontractor"), 500) + + finally: + cursor.close() + connection.close() + + return render_template('add_subcontractor.html', subcontractor=subcontractor) + + +# update subcontractor by id +@app.route('/edit_subcontractor/', methods=['GET', 'POST']) +def edit_subcontractor(id): + connection = config.get_db_connection() + + if not connection: + return json_response(ResponseHandler.fetch_failure("Subcontractor"), 500) + + try: + cursor = connection.cursor() + subcontractor = None + + # Fetch existing subcontractor data by ID + # cursor.execute('SELECT * FROM subcontractors WHERE Contractor_Id = %s', (id,)) + # subcontractor = cursor.fetchone() + + cursor.callproc("GetSubcontractorById", (id,)) + for contractors in cursor.stored_results(): + subcontractor = contractors.fetchone() + + if not subcontractor: + return json_response(ResponseHandler.fetch_failure("Subcontractor"), 404) + + if request.method == 'POST': + updated_data = { + 'Contractor_Name': request.form['Contractor_Name'], + 'Address': request.form['Address'], + 'Mobile_No': request.form['Mobile_No'], + 'PAN_No': request.form['PAN_No'], + 'Email': request.form['Email'], + 'Gender': request.form['Gender'], + 'GST_Registration_Type': request.form['GST_Registration_Type'], + 'GST_No': request.form['GST_No'], + 'Contractor_password': request.form['Contractor_password'], + 'id': id + } + + try: + # cursor.execute("""UPDATE subcontractors SET + # Contractor_Name=%(Contractor_Name)s, + # Address=%(Address)s, + # Mobile_No=%(Mobile_No)s, + # PAN_No=%(PAN_No)s, + # Email=%(Email)s, + # Gender=%(Gender)s, + # GST_Registration_Type=%(GST_Registration_Type)s, + # GST_No=%(GST_No)s, + # Contractor_password=%(Contractor_password)s + # WHERE Contractor_Id=%(id)s""", updated_data) + + cursor.callproc("UpdateSubcontractor", ( + id, + updated_data['Contractor_Name'], + updated_data['Address'], + updated_data['Mobile_No'], + updated_data['PAN_No'], + updated_data['Email'], + updated_data['Gender'], + updated_data['GST_Registration_Type'], + updated_data['GST_No'], + updated_data['Contractor_password'] + )) + connection.commit() + return redirect(url_for('subcontract')) + + except Error as e: + print(f"Error updating subcontractor: {e}") + return json_response(ResponseHandler.update_failure("Subcontractor"), 500) + + except Error as e: + print(f"Error fetching subcontractor data: {e}") + return json_response(ResponseHandler.fetch_failure("Subcontractor"), 500) + + finally: + cursor.close() + connection.close() + + return render_template('edit_subcontractor.html', subcontractor=subcontractor) + + +# delete Sub-Contractor methods by id .. +# @app.route('/deleteSubContractor/', methods=['GET', 'POST']) +# def deleteSubContractor(id): +# connection = config.get_db_connection() + +# if not connection: +# return json_response(ResponseHandler.fetch_failure("Subcontractor"), 500) + +# try: +# cursor = connection.cursor() + +# # cursor.execute("DELETE FROM subcontractors WHERE Contractor_Id = %s", (id,)) +# cursor.callproc("DeleteSubcontractor", (id,)) +# connection.commit() + +# # Check if any row was deleted (subcontractor found) +# if cursor.rowcount == 0: +# return json_response(ResponseHandler.fetch_failure("Subcontractor"), 404) + +# except Error as e: +# print(f"Error deleting subcontractor: {e}") +# return json_response(ResponseHandler.delete_failure("Subcontractor"), 500) + +# finally: +# cursor.close() +# connection.close() + +# return redirect(url_for('subcontract')) +@app.route('/deleteSubContractor/', methods=['GET', 'POST']) +def deleteSubContractor(id): + connection = config.get_db_connection() + + if not connection: + return json_response(ResponseHandler.fetch_failure("Subcontractor"), 500) + + try: + cursor = connection.cursor() + + # Optional: check if subcontractor exists before attempting delete + cursor.execute("SELECT 1 FROM subcontractors WHERE Contractor_Id = %s", (id,)) + if cursor.fetchone() is None: + return json_response(ResponseHandler.fetch_failure("Subcontractor not found"), 404) + + # Call stored procedure to delete subcontractor and related records + cursor.callproc("DeleteSubcontractor", (id,)) + connection.commit() + + # Retrieve result from procedure (SELECT ROW_COUNT()) + affected_rows = 0 + for result in cursor.stored_results(): + row = result.fetchone() + affected_rows = row[0] if row else 0 + + if affected_rows == 0: + return json_response(ResponseHandler.fetch_failure("Subcontractor not deleted"), 404) + + except Error as e: + print(f"Error deleting subcontractor: {e}") + return json_response(ResponseHandler.delete_failure("Subcontractor"), 500) + + finally: + cursor.close() + connection.close() + + return redirect(url_for('subcontract')) # redirect to subcontractor list page + + +# ------------------------------- Show Report Subcontractor --------------------- + +UPLOAD_FOLDER = 'uploads' +app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER + +if not os.path.exists(UPLOAD_FOLDER): + os.makedirs(UPLOAD_FOLDER) + + +# Upload Excel file html page +@app.route('/upload_excel_file', methods=['GET', 'POST']) +def upload(): + if request.method == 'POST': + file = request.files['file'] + if file and file.filename.endswith('.xlsx'): + filepath = os.path.join(app.config['UPLOAD_FOLDER'], file.filename) + file.save(filepath) + return redirect(url_for('show_table', filename=file.filename)) + return render_template('uploadExcelFile.html') + + +# Show excel data in tables6 +# @app.route('/show_table/') +# def show_table(filename): +# global data +# data = [] +# +# filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename) +# wb = openpyxl.load_workbook(filepath, data_only=True) +# sheet = wb.active +# +# # Extract key file information from the first 4 rows +# file_info = { +# "Subcontractor": sheet.cell(row=1, column=2).value, +# "State": sheet.cell(row=2, column=2).value, +# "District": sheet.cell(row=3, column=2).value, +# "Block": sheet.cell(row=4, column=2).value, +# } +# +# errors = [] +# subcontractor_data = None +# state_data = None +# district_data = None +# block_data = None +# +# # Database connection +# connection = config.get_db_connection() +# if connection: +# try: +# cursor = connection.cursor(dictionary=True) +# +# # Validate State +# # cursor.execute("SELECT State_ID, State_Name FROM states WHERE State_Name = %s", (file_info['State'],)) +# # state_data = cursor.fetchone() +# cursor.callproc('GetStateByName', [file_info['State']]) +# for result in cursor.stored_results(): +# state_data = result.fetchone() +# +# if not state_data: +# errors.append(f"State '{file_info['State']}' is not valid. Please add it.") +# +# # Validate District +# if state_data: +# # cursor.execute( +# # "SELECT District_ID, District_Name FROM districts WHERE District_Name = %s AND State_ID = %s", +# # (file_info['District'], state_data['State_ID']) +# # ) +# # district_data = cursor.fetchone() +# cursor.callproc('GetDistrictByNameAndStates', [file_info['District'], state_data['State_ID']]) +# for result in cursor.stored_results(): +# district_data = result.fetchone() +# +# if not district_data: +# errors.append( +# f"District '{file_info['District']}' is not valid under state '{file_info['State']}'.") +# +# # Validate Block +# if district_data: +# # cursor.execute( +# # "SELECT Block_Id, Block_Name FROM blocks WHERE Block_Name = %s AND District_ID = %s", +# # (file_info['Block'], district_data['District_ID']) +# # ) +# # block_data = cursor.fetchone() +# cursor.callproc('GetBlockByNameAndDistricts', [file_info['Block'], district_data['District_ID']]) +# for result in cursor.stored_results(): +# block_data = result.fetchone() +# +# if not block_data: +# errors.append( +# f"Block '{file_info['Block']}' is not valid under district '{file_info['District']}'.") +# +# # old code +# # # Validate Subcontractor +# # cursor.execute("SELECT Contractor_Id, Contractor_Name FROM SubContractors WHERE Contractor_Name = %s", +# # (file_info['Subcontractor'],)) +# # subcontractor_data = cursor.fetchone() +# cursor.callproc('GetSubcontractorByName', [file_info['Subcontractor']]) +# for result in cursor.stored_results(): +# subcontractor_data = result.fetchone() +# +# if not subcontractor_data: +# # cursor.execute("INSERT INTO subcontractors (Contractor_Name) VALUES (%s)", +# # (file_info['Subcontractor'],)) +# # connection.commit() +# cursor.callproc('InsertSubcontractor', [file_info['Subcontractor']]) +# connection.commit() +# +# # cursor.execute("SELECT Contractor_Id, Contractor_Name FROM SubContractors WHERE Contractor_Name = %s", +# # (file_info['Subcontractor'],)) +# # subcontractor_data = cursor.fetchone() +# cursor.callproc('GetSubcontractorByName', [file_info['Subcontractor']]) +# for result in cursor.stored_results(): +# subcontractor_data = result.fetchone() +# +# # new code +# # cursor.callproc('ValidateAndInsertSubcontractor', (file_info['Subcontractor'], 0, '')) +# # +# # for con in cursor.stored_results(): +# # subcontractor_data = con.fetchone() +# # print("subcon:",subcontractor_data) +# # +# # print("subcontractor_data",subcontractor_data) +# +# # Get hold types data from database (for faster lookup) +# # cursor.execute("SELECT hold_type_id, hold_type FROM hold_types") +# # hold_types_data = cursor.fetchall() +# +# cursor.callproc("GetAllHoldTypes") +# for ht in cursor.stored_results(): +# hold_types_data = ht.fetchall() +# +# hold_types_lookup = {row['hold_type'].lower(): row['hold_type_id'] for row in hold_types_data if +# row['hold_type']} +# +# cursor.close() +# except mysql.connector.Error as e: +# print(f"Database error: {e}") +# return "Database operation failed", 500 +# finally: +# connection.close() +# +# # Extract dynamic variable names from row 5 and detect "hold" columns +# variables = {} +# hold_columns = [] +# hold_counter = 0 +# +# for j in range(1, sheet.max_column + 1): +# col_value = sheet.cell(row=5, column=j).value +# if col_value: +# variables[col_value] = j # Store column name with its position +# +# # Check if the column header contains the word 'hold' +# if 'hold' in str(col_value).lower(): +# hold_counter += 1 +# # Lookup hold type id from database +# hold_type_key = str(col_value).lower().strip() +# hold_type_id = hold_types_lookup.get(hold_type_key, None) +# hold_columns.append({ +# 'column_name': col_value, +# 'column_number': j, +# 'hold_type_id': hold_type_id +# }) +# +# # Extract data dynamically based on row numbers +# for i in range(6, sheet.max_row + 1): +# row_data = {} +# if sheet.cell(row=i, column=1).value: +# row_data["Row Number"] = i # Store row number +# for var_name, col_num in variables.items(): +# row_data[var_name] = sheet.cell(row=i, column=col_num).value +# # Check if at least 4 non-empty cells exist in the row +# if sum(1 for value in row_data.values() if value) >= 4: +# data.append(row_data) +# +# # For debugging or console output, you can print the hold columns info +# for hold in hold_columns: +# if hold['hold_type_id']: +# print( +# f" if Column: {hold['column_name']}, Column Number: {hold['column_number']}, Hold Type ID: {hold['hold_type_id']}") +# else: +# errors.append( +# f"Hold Type not added ! Column name '{hold['column_name']}'.") +# print( +# f" else Column: {hold['column_name']}, Column Number: {hold['column_number']}, Hold Type ID: {hold['hold_type_id']}") +# +# return render_template( +# 'show_excel_file.html', +# file_info=file_info, +# variables=variables, +# data=data, +# subcontractor_data=subcontractor_data, +# state_data=state_data, +# district_data=district_data, +# block_data=block_data, +# errors=errors, +# hold_columns=hold_columns, +# hold_counter=hold_counter +# ) + +@app.route('/show_table/') +def show_table(filename): + global data + data = [] + + filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename) + wb = openpyxl.load_workbook(filepath, data_only=True) + sheet = wb.active + + file_info = { + "Subcontractor": sheet.cell(row=1, column=2).value, + "State": sheet.cell(row=2, column=2).value, + "District": sheet.cell(row=3, column=2).value, + "Block": sheet.cell(row=4, column=2).value, + } + + errors = [] + subcontractor_data = None + state_data = None + district_data = None + block_data = None + + connection = config.get_db_connection() + if connection: + try: + cursor = connection.cursor(dictionary=True) + + print(f"Calling GetStateByName with: {file_info['State']}") + cursor.callproc('GetStateByName', [file_info['State']]) + for result in cursor.stored_results(): + state_data = result.fetchone() + + if not state_data: + errors.append(f"State '{file_info['State']}' is not valid. Please add it.") + + if state_data: + print(f"Calling GetDistrictByNameAndStates with: {file_info['District']}, {state_data['State_ID']}") + cursor.callproc('GetDistrictByNameAndStates', [file_info['District'], state_data['State_ID']]) + for result in cursor.stored_results(): + district_data = result.fetchone() + + if not district_data: + errors.append(f"District '{file_info['District']}' is not valid under state '{file_info['State']}'.") + + if district_data: + print(f"Calling GetBlockByNameAndDistricts with: {file_info['Block']}, {district_data['District_ID']}") + cursor.callproc('GetBlockByNameAndDistricts', [file_info['Block'], district_data['District_ID']]) + for result in cursor.stored_results(): + block_data = result.fetchone() + + if not block_data: + errors.append(f"Block '{file_info['Block']}' is not valid under district '{file_info['District']}'.") + + print(f"Calling GetSubcontractorByName with: {file_info['Subcontractor']}") + cursor.callproc('GetSubcontractorByName', [file_info['Subcontractor']]) + for result in cursor.stored_results(): + subcontractor_data = result.fetchone() + + if not subcontractor_data: + print(f"Inserting subcontractor: {file_info['Subcontractor']}") + cursor.callproc('InsertSubcontractor', [file_info['Subcontractor']]) + connection.commit() + print(f"Calling GetSubcontractorByName again with: {file_info['Subcontractor']}") + cursor.callproc('GetSubcontractorByName', [file_info['Subcontractor']]) + for result in cursor.stored_results(): + subcontractor_data = result.fetchone() + + print("Calling GetAllHoldTypes") + cursor.callproc("GetAllHoldTypes") + hold_types_data = [] + for ht in cursor.stored_results(): + hold_types_data = ht.fetchall() + + hold_types_lookup = {row['hold_type'].lower(): row['hold_type_id'] for row in hold_types_data if row['hold_type']} + + cursor.close() + except mysql.connector.Error as e: + print(f"Database error: {e}") + return f"Database operation failed: {e}", 500 + finally: + connection.close() + + variables = {} + hold_columns = [] + hold_counter = 0 + + for j in range(1, sheet.max_column + 1): + col_value = sheet.cell(row=5, column=j).value + if col_value: + variables[col_value] = j + if 'hold' in str(col_value).lower(): + hold_counter += 1 + hold_type_key = str(col_value).lower().strip() + hold_type_id = hold_types_lookup.get(hold_type_key, None) + hold_columns.append({ + 'column_name': col_value, + 'column_number': j, + 'hold_type_id': hold_type_id + }) + + for i in range(6, sheet.max_row + 1): + row_data = {} + if sheet.cell(row=i, column=1).value: + row_data["Row Number"] = i + for var_name, col_num in variables.items(): + row_data[var_name] = sheet.cell(row=i, column=col_num).value + if sum(1 for value in row_data.values() if value) >= 4: + data.append(row_data) + + for hold in hold_columns: + if hold['hold_type_id']: + print(f" if Column: {hold['column_name']}, Column Number: {hold['column_number']}, Hold Type ID: {hold['hold_type_id']}") + else: + errors.append(f"Hold Type not added ! Column name '{hold['column_name']}'.") + print(f" else Column: {hold['column_name']}, Column Number: {hold['column_number']}, Hold Type ID: {hold['hold_type_id']}") + + return render_template( + 'show_excel_file.html', + file_info=file_info, + variables=variables, + data=data, + subcontractor_data=subcontractor_data, + state_data=state_data, + district_data=district_data, + block_data=block_data, + errors=errors, + hold_columns=hold_columns, + hold_counter=hold_counter + ) + +# Show excel data in tables6 +# @app.route('/show_table/') +# def show_table(filename): +# global data +# data = [] +# +# filepath = os.path.join(app.config['UPLOAD_FOLDER'], filename) +# wb = openpyxl.load_workbook(filepath, data_only=True) +# sheet = wb.active +# +# # Extract key file information from the first 4 rows +# file_info = { +# "Subcontractor": sheet.cell(row=1, column=2).value, +# "State": sheet.cell(row=2, column=2).value, +# "District": sheet.cell(row=3, column=2).value, +# "Block": sheet.cell(row=4, column=2).value, +# } +# +# errors = [] +# subcontractor_data = None +# state_data = None +# district_data = None +# block_data = None +# +# # Database connection +# connection = config.get_db_connection() +# if connection: +# try: +# cursor = connection.cursor(dictionary=True) +# +# # Validate State +# cursor.execute("SELECT State_ID, State_Name FROM states WHERE State_Name = %s", (file_info['State'],)) +# state_data = cursor.fetchone() +# if not state_data: +# errors.append(f"State '{file_info['State']}' is not valid. Please add it.") +# +# # Validate District +# if state_data: +# cursor.execute( +# "SELECT District_ID, District_Name FROM districts WHERE District_Name = %s AND State_ID = %s", +# (file_info['District'], state_data['State_ID']) +# ) +# district_data = cursor.fetchone() +# if not district_data: +# errors.append( +# f"District '{file_info['District']}' is not valid under state '{file_info['State']}'.") +# +# # Validate Block +# if district_data: +# cursor.execute( +# "SELECT Block_Id, Block_Name FROM blocks WHERE Block_Name = %s AND District_ID = %s", +# (file_info['Block'], district_data['District_ID']) +# ) +# block_data = cursor.fetchone() +# if not block_data: +# errors.append( +# f"Block '{file_info['Block']}' is not valid under district '{file_info['District']}'.") +# +# +# # old code +# # # Validate Subcontractor +# cursor.execute("SELECT Contractor_Id, Contractor_Name FROM subcontractors WHERE Contractor_Name = %s", +# (file_info['Subcontractor'],)) +# subcontractor_data = cursor.fetchone() +# +# if not subcontractor_data: +# cursor.execute("INSERT INTO subcontractors (Contractor_Name) VALUES (%s)", +# (file_info['Subcontractor'],)) +# connection.commit() +# cursor.execute("SELECT Contractor_Id, Contractor_Name FROM subcontractors WHERE Contractor_Name = %s", +# (file_info['Subcontractor'],)) +# subcontractor_data = cursor.fetchone() +# +# # new code +# # cursor.callproc('ValidateAndInsertSubcontractor', (file_info['Subcontractor'], 0, '')) +# # +# # for con in cursor.stored_results(): +# # subcontractor_data = con.fetchone() +# # print("subcon:",subcontractor_data) +# # +# # print("subcontractor_data",subcontractor_data) +# +# # Get hold types data from database (for faster lookup) +# # cursor.execute("SELECT hold_type_id, hold_type FROM hold_types") +# # hold_types_data = cursor.fetchall() +# +# cursor.callproc("GetAllHoldTypes") +# for ht in cursor.stored_results(): +# hold_types_data = ht.fetchall() +# +# +# hold_types_lookup = {row['hold_type'].lower(): row['hold_type_id'] for row in hold_types_data if row['hold_type']} +# +# +# cursor.close() +# except mysql.connector.Error as e: +# print(f"Database error: {e}") +# +# # return "Database operation failed", 500 +# return f"{e}",500 +# finally: +# connection.close() +# +# # Extract dynamic variable names from row 5 and detect "hold" columns +# variables = {} +# hold_columns = [] +# hold_counter = 0 +# +# for j in range(1, sheet.max_column + 1): +# col_value = sheet.cell(row=5, column=j).value +# if col_value: +# variables[col_value] = j # Store column name with its position +# +# # Check if the column header contains the word 'hold' +# if 'hold' in str(col_value).lower(): +# hold_counter += 1 +# # Lookup hold type id from database +# hold_type_key = str(col_value).lower().strip() +# hold_type_id = hold_types_lookup.get(hold_type_key, None) +# hold_columns.append({ +# 'column_name': col_value, +# 'column_number': j, +# 'hold_type_id': hold_type_id +# }) +# +# # Extract data dynamically based on row numbers +# for i in range(6, sheet.max_row + 1): +# row_data = {} +# if sheet.cell(row=i, column=1).value: +# row_data["Row Number"] = i # Store row number +# for var_name, col_num in variables.items(): +# row_data[var_name] = sheet.cell(row=i, column=col_num).value +# # Check if at least 4 non-empty cells exist in the row +# if sum(1 for value in row_data.values() if value) >= 4: +# data.append(row_data) +# +# # For debugging or console output, you can print the hold columns info +# for hold in hold_columns: +# if hold['hold_type_id']: +# print( +# f" if Column: {hold['column_name']}, Column Number: {hold['column_number']}, Hold Type ID: {hold['hold_type_id']}") +# else: +# errors.append( +# f"Hold Type not added ! Column name '{hold['column_name']}'.") +# print( +# f" else Column: {hold['column_name']}, Column Number: {hold['column_number']}, Hold Type ID: {hold['hold_type_id']}") +# +# return render_template( +# 'show_excel_file.html', +# file_info=file_info, +# variables=variables, +# data=data, +# subcontractor_data=subcontractor_data, +# state_data=state_data, +# district_data=district_data, +# block_data=block_data, +# errors=errors, +# hold_columns=hold_columns, +# hold_counter=hold_counter +# ) + +# save Excel data +@app.route('/save_data', methods=['POST']) +def save_data(): + # Extract form data + subcontractor_id = request.form.get("subcontractor_data") + state_id = request.form.get("state_data") + district_id = request.form.get("district_data") + block_id = request.form.get("block_data") + + variables = request.form.getlist('variables[]') + hold_columns = request.form.get("hold_columns") + hold_counter = request.form.get("hold_counter") + + # print("Info: ", subcontractor_id, state_id, district_id, block_id) + + if not data: + return jsonify({"error": "No data provided to save"}), 400 + + if data: + # print("Total number of entries in data:", len(data)) + + connection = config.get_db_connection() + cursor = connection.cursor() + + try: + for entry in data: + save_data = { + "PMC_No": entry.get("PMC_No"), + "Invoice_Details": entry.get("Invoice_Details", ''), + "Work_Type": 'none', + "Invoice_Date": entry.get("Invoice_Date").strftime('%Y-%m-%d') if entry.get( + "Invoice_Date") else None, + "Invoice_No": entry.get("Invoice_No", ''), + "Basic_Amount": entry.get("Basic_Amount", 0.00), + "Debit_Amount": entry.get("Debit_Amount", 0.00), + "After_Debit_Amount": entry.get("After_Debit_Amount", 0.00), + "Amount": entry.get("Amount", 0.00), + "GST_Amount": entry.get("GST_Amount", 0.00), + "TDS_Amount": entry.get("TDS_Amount", 0.00), + "SD_Amount": entry.get("SD_Amount", 0.00), + "On_Commission": entry.get("On_Commission", 0.00), + "Hydro_Testing": entry.get("Hydro_Testing", 0.00), + "Hold_Amount": 0, + "GST_SD_Amount": entry.get("GST_SD_Amount", 0.00), + "Final_Amount": entry.get("Final_Amount", 0.00), + "Payment_Amount": entry.get("Payment_Amount", 0.00), + "Total_Amount": entry.get("Total_Amount", 0.00), + "TDS_Payment_Amount": entry.get("TDS_Payment_Amount", 0.00), + "UTR": entry.get("UTR", ''), + } + + village_name, work_type = None, None + village_id = 0 + + PMC_No = save_data.get('PMC_No') + Invoice_Details = save_data.get('Invoice_Details') + Invoice_Date = save_data.get('Invoice_Date') + Invoice_No = save_data.get('Invoice_No') + Basic_Amount = save_data.get('Basic_Amount') + Debit_Amount = save_data.get('Debit_Amount') + After_Debit_Amount = save_data.get('After_Debit_Amount') + Amount = save_data.get('Amount') + GST_Amount = save_data.get('GST_Amount') + TDS_Amount = save_data.get('TDS_Amount') + SD_Amount = save_data.get('SD_Amount') + On_Commission = save_data.get('On_Commission') + Hydro_Testing = save_data.get('Hydro_Testing') + GST_SD_Amount = save_data.get('GST_SD_Amount') + Final_Amount = save_data.get('Final_Amount') + + Payment_Amount = save_data.get('Payment_Amount') + Total_Amount = save_data.get('Total_Amount') + TDS_Payment_Amount = save_data.get('TDS_Payment_Amount') + UTR = save_data.get('UTR') + + if Invoice_Details: + words = Invoice_Details.lower().split() + if 'village' in words: + village_pos = words.index('village') + village_name = " ".join(words[:village_pos]) + if 'work' in words: + work_pos = words.index('work') + if village_name: + work_type = " ".join(words[village_pos + 1:work_pos + 1]) + else: + work_type = " ".join(words[:work_pos + 1]) + + if Invoice_Details and 'village' in Invoice_Details.lower() and 'work' in Invoice_Details.lower(): + print("village_name ::", village_name, "|| work_type ::", work_type) + if block_id and village_name: + village_id = None + # cursor.execute("SELECT Village_Id FROM villages WHERE Block_Id = %s AND Village_Name = %s",(block_id, village_name)) + # result = cursor.fetchone() + cursor.callproc("GetVillageId", (block_id, village_name)) + for result in cursor.stored_results(): + result = result.fetchone() + village_id = result[0] if result else None + + if not village_id: + # cursor.execute("INSERT INTO villages (Village_Name, Block_Id) VALUES (%s, %s)", (village_name, block_id)) + + cursor.callproc("SaveVillage", (village_name, block_id)) + # cursor.execute("SELECT Village_Id FROM villages WHERE Block_Id = %s AND Village_Name = %s",(block_id, village_name)) + # result = cursor.fetchone() + cursor.callproc("GetVillageId", (block_id, village_name)) + for result in cursor.stored_results(): + result = result.fetchone() + village_id = result[0] if result else None + + print("village_id :", village_id) + print("block_id :", block_id) + print("invoice :", PMC_No, village_id, work_type, Invoice_Details, Invoice_Date, Invoice_No, + Basic_Amount, Debit_Amount, After_Debit_Amount, Amount, GST_Amount, TDS_Amount, + SD_Amount, On_Commission, Hydro_Testing, GST_SD_Amount, Final_Amount) + # + # cursor.execute("SET @p_invoice_id = 0") + # cursor.callproc("SaveInvoice", ( + # PMC_No, village_id, work_type, Invoice_Details, Invoice_Date, Invoice_No, + # Basic_Amount, Debit_Amount, After_Debit_Amount, Amount, GST_Amount, TDS_Amount, + # SD_Amount, On_Commission, Hydro_Testing, GST_SD_Amount, Final_Amount, + # subcontractor_id, "@p_invoice_id" + # )) + # cursor.execute("SELECT @p_invoice_id") + # invoice_id = cursor.fetchone()[0] + + args = ( + PMC_No, village_id, work_type, Invoice_Details, Invoice_Date, Invoice_No, + Basic_Amount, Debit_Amount, After_Debit_Amount, Amount, GST_Amount, TDS_Amount, + SD_Amount, On_Commission, Hydro_Testing, GST_SD_Amount, Final_Amount, + subcontractor_id, 0 + ) + # for result in cursor.stored_results(): + # invoice_id = result.fetchone()['invoice_id'] + results = cursor.callproc('SaveInvoice', args) + # cursor.callproc("SaveInvoice",args) + # for re in cursor.stored_results(): + invoice_id = results[-1] + + print("invoice id from the excel ", invoice_id) + + if isinstance(hold_columns, str): + hold_columns = ast.literal_eval(hold_columns) + + # Check if hold_columns is actually a list of dictionaries + if isinstance(hold_columns, list) and all(isinstance(hold, dict) for hold in hold_columns): + for hold in hold_columns: + print(f"Processing hold: {hold}") + hold_column_name = hold.get('column_name') # Get column name + hold_type_id = hold.get('hold_type_id') # Get hold_type_id + + if hold_column_name: + hold_amount = entry.get( + hold_column_name) # Get the value for that specific hold column + if hold_amount is not None: + print(f"Processing hold type: {hold_column_name}, Hold Amount: {hold_amount}") + + # Insert into the invoice_subcontractor_hold_join table + hold_join_data = { + "Contractor_Id": subcontractor_id, + "Invoice_Id": invoice_id, + "hold_type_id": hold_type_id, + "hold_amount": hold_amount + } + + # insert_hold_query = """INSERT INTO invoice_subcontractor_hold_join (Contractor_Id, Invoice_Id, hold_type_id, hold_amount) + # VALUES (%(Contractor_Id)s, %(Invoice_Id)s, %(hold_type_id)s, %(hold_amount)s); + # """ + # cursor.execute(insert_hold_query, hold_join_data) + # print(f"Inserted hold join data: {hold_join_data}") + cursor.callproc('InsertHoldJoinData', [ + hold_join_data['Contractor_Id'], hold_join_data['Invoice_Id'], + hold_join_data['hold_type_id'], hold_join_data['hold_amount'] + ]) + connection.commit() + print(f"Inserted hold join data: {hold_join_data}") + + + else: + print(f"Invalid hold entry: {hold}") + else: + print("Hold columns data is not a valid list of dictionaries.") +#---------------------------------------------Credit Note--------------------------------------------------------------------------- + elif any(keyword in Invoice_Details.lower() for keyword in ['credit note']): + print("Credit note found:", PMC_No, Invoice_No, Basic_Amount, Debit_Amount, Final_Amount, + After_Debit_Amount, GST_Amount, Amount, Final_Amount, Payment_Amount, Total_Amount, UTR, Invoice_No) + cursor.execute( + """INSERT INTO credit_note (PMC_No, Invoice_Details, Basic_Amount, Debit_Amount, After_Debit_Amount, GST_Amount, Amount, Final_Amount, Payment_Amount, Total_Amount, UTR, Contractor_Id, invoice_no) VALUES (%s,%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s)""", + ( PMC_No, Invoice_Details, Basic_Amount, Debit_Amount, After_Debit_Amount, GST_Amount, Amount, Final_Amount, Payment_Amount, Total_Amount, UTR, subcontractor_id, Invoice_No)) +#-----------------------------------------------Hold Amount---------------------------------------------------------------------- + elif Invoice_Details and any(keyword in Invoice_Details.lower() for keyword in + ['excess hold', 'ht', 'hold release amount']): + + cursor.execute(""" + INSERT INTO hold_release ( + PMC_No, Invoice_No, Invoice_Details, Basic_Amount, Total_Amount, UTR,Contractor_Id + ) VALUES (%s, %s, %s, %s, %s, %s,%s) + """, ( + PMC_No, Invoice_No, Invoice_Details, Basic_Amount, Final_Amount, UTR, subcontractor_id)) + print("Hold amount release from excel file:", PMC_No, Invoice_Details) + #------------------------------------------------------------------------------------------------------------------ + elif Invoice_Details and any( + keyword in Invoice_Details.lower() for keyword in ['gst', 'release', 'note']): + print("Gst rels :", PMC_No, Invoice_No, Basic_Amount, Final_Amount) + cursor.callproc("SaveGSTRelease", (PMC_No, Invoice_No, Basic_Amount, Final_Amount)) + # cursor.execute( + # """INSERT INTO gst_release (PMC_No, Invoice_No, Basic_Amount, Final_Amount) VALUES (%s,%s, %s, %s)""", + # (PMC_No, Invoice_No, Basic_Amount, Final_Amount)) + + # insert_payment = """INSERT INTO payment (PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR) VALUES (%s, %s, %s, %s, %s, %s)""" + # cursor.execute(insert_payment, + # (PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR)) + + if PMC_No and Total_Amount and UTR: + print("Payment :", PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR) + # insert_payment = """INSERT INTO payment (PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR) VALUES (%s, %s, %s, %s, %s, %s)""" + # cursor.execute(insert_payment, + # (PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR)) + + cursor.callproc("SavePayment", + (PMC_No, Invoice_No, Payment_Amount, TDS_Payment_Amount, Total_Amount, UTR)) + + connection.commit() + return jsonify({"success": "Data saved successfully!"}), 200 + # return render_template('uploadExcelFile.html') + except Exception as e: + connection.rollback() + return jsonify({"error": f"An unexpected error occurred: {e}"}), 500 + finally: + cursor.close() + connection.close() + + return render_template('index.html') + + +# ---------------------- Report -------------------------------- +# call repor page +@app.route('/report') +def report_page(): + return render_template('report.html') + + +# Search list multiples input and search reports +@app.route('/search_contractor', methods=['POST']) +def search_contractor(): + connection = config.get_db_connection() + cursor = connection.cursor(dictionary=True) + + subcontractor_name = request.form.get('subcontractor_name') + pmc_no = request.form.get('pmc_no') + state = request.form.get('state') + district = request.form.get('district') + block = request.form.get('block') + village = request.form.get('village') + year_from = request.form.get('year_from') + year_to = request.form.get('year_to') + + conditions = [] + params = [] + + if subcontractor_name: + conditions.append("LOWER(s.Contractor_Name) LIKE LOWER(%s)") + params.append(f"%{subcontractor_name}%") + if pmc_no: + conditions.append("i.PMC_No = %s") + params.append(pmc_no) + if state: + conditions.append("LOWER(st.State_Name) LIKE LOWER(%s)") + params.append(f"%{state}%") + if district: + conditions.append("LOWER(d.District_Name) LIKE LOWER(%s)") + params.append(f"%{district}%") + if block: + conditions.append("LOWER(b.Block_Name) LIKE LOWER(%s)") + params.append(f"%{block}%") + if village: + conditions.append("LOWER(v.Village_Name) LIKE LOWER(%s)") + params.append(f"%{village}%") + if year_from and year_to: + conditions.append("i.Invoice_Date BETWEEN %s AND %s") + params.append(year_from) + params.append(year_to) + + if not conditions: + return jsonify({"error": "At least one field is required for search."}), 400 + + # query = f""" + # SELECT DISTINCT s.Contractor_Id, s.Contractor_Name, i.PMC_No, st.State_Name, + # d.District_Name, b.Block_Name, v.Village_Name + # FROM subcontractors s + # INNER JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id + # INNER JOIN villages v ON asg.Village_Id = v.Village_Id + # INNER JOIN invoice i ON i.Village_Id = asg.Village_Id AND i.PMC_No = asg.PMC_No + # LEFT JOIN blocks b ON v.Block_Id = b.Block_Id + # LEFT JOIN districts d ON b.District_id = d.District_id + # LEFT JOIN states st ON d.State_Id = st.State_Id + # WHERE {' AND '.join(conditions)} + # ORDER BY s.Contractor_Name ASC, i.PMC_No ASC + # """ + # cursor.execute(query, tuple(params)) + # data = cursor.fetchall() + cursor.callproc("search_contractor_info", [ + subcontractor_name or None, + pmc_no or None, + state or None, + district or None, + block or None, + village or None, + year_from or None, + year_to or None + ]) + + for result in cursor.stored_results(): + data = result.fetchall() + + return jsonify(data) + + + +# @app.route('/contractor_report/') +# def contractor_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True, buffered=True) +# +# try: +# # Fetch contractor details +# cursor.execute(""" +# SELECT DISTINCT s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, +# s.Mobile_No, s.GST_Registration_Type, s.GST_No,s.PAN_No,s.Email,s.Address +# FROM subcontractors s +# LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id +# LEFT JOIN villages v ON asg.Village_Id = v.Village_Id +# LEFT JOIN blocks b ON v.Block_Id = b.Block_Id +# LEFT JOIN districts d ON b.District_id = d.District_id +# LEFT JOIN states st ON d.State_Id = st.State_Id +# WHERE s.Contractor_Id = %s +# """, (contractor_id,)) +# contInfo = cursor.fetchone() +# +# # cursor.callproc('GetContractorInfoById', [contractor_id]) +# # contInfo = next(cursor.stored_results()).fetchone() +# +# # Fetch distinct hold types present in invoices for the contractor +# cursor.execute(""" +# SELECT DISTINCT ht.hold_type_id, ht.hold_type +# FROM invoice_subcontractor_hold_join h +# JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# JOIN invoice i ON h.Invoice_Id = i.Invoice_Id +# WHERE h.Contractor_Id = %s +# """, (contractor_id,)) +# hold_types = cursor.fetchall() +# # cursor.callproc('GetHoldTypesByContId', [contractor_id]) +# # hold_types = next(cursor.stored_results()).fetchall() +# +# # Fetch all invoices for the contractor, with optional hold information +# query = """ +# SELECT DISTINCT i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, +# i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, +# i.After_Debit_Amount, i.Amount, i.GST_Amount, i.TDS_Amount, i.SD_Amount, +# i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, +# i.Final_Amount, h.hold_amount, ht.hold_type +# FROM invoice i +# LEFT JOIN villages v ON i.Village_Id = v.Village_Id +# LEFT JOIN assign_subcontractors asg ON v.Village_Id = asg.Village_Id +# LEFT JOIN subcontractors s ON asg.Contractor_Id = s.Contractor_Id +# LEFT JOIN invoice_subcontractor_hold_join h ON i.Invoice_Id = h.Invoice_Id AND h.Contractor_Id = s.Contractor_Id +# LEFT JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# WHERE s.Contractor_Id = %s +# ORDER BY i.PMC_No ASC; +# """ +# cursor.execute(query, (contractor_id,)) +# invoices = cursor.fetchall() +# +# # cursor.callproc('GetInvoicesWithHoldByContId', [contractor_id]) +# # invoices = next(cursor.stored_results()).fetchall() +# +# gst_query = """select pmc_no,invoice_no,basic_amount,final_amount from gst_release where pmc_no in +# (select distinct pmc_no from assign_subcontractors where Contractor_Id= %s ) ORDER BY pmc_no ASC """ +# cursor.execute(gst_query, (contractor_id,)) +# gst_rel = cursor.fetchall() +# +# # cursor.callproc('GetGstReleaseBycontId', [contractor_id]) +# # gst_rel = next(cursor.stored_results()).fetchall() +# +# pay_query = """select pmc_no,invoice_no,Payment_Amount,TDS_Payment_Amount,Total_amount,utr from payment where pmc_no in +# (select distinct pmc_no from assign_subcontractors where Contractor_Id=%s ) ORDER BY pmc_no ASC """ +# cursor.execute(pay_query, (contractor_id,)) +# payments = cursor.fetchall() +# # cursor.callproc('GetPaymentsByContId', [contractor_id]) +# # payments = next(cursor.stored_results()).fetchall() +# +# total = { +# "sum_invo_basic_amt": float(sum(row['Basic_Amount'] or 0 for row in invoices)), +# "sum_invo_debit_amt": float(sum(row['Debit_Amount'] or 0 for row in invoices)), +# "sum_invo_after_debit_amt": float(sum(row['After_Debit_Amount'] or 0 for row in invoices)), +# "sum_invo_amt": float(sum(row['Amount'] or 0 for row in invoices)), +# "sum_invo_gst_amt": float(sum(row['GST_Amount'] or 0 for row in invoices)), +# "sum_invo_tds_amt": float(sum(row['TDS_Amount'] or 0 for row in invoices)), +# "sum_invo_ds_amt": float(sum(row['SD_Amount'] or 0 for row in invoices)), +# "sum_invo_on_commission": float(sum(row['On_Commission'] or 0 for row in invoices)), +# "sum_invo_hydro_test": float(sum(row['Hydro_Testing'] or 0 for row in invoices)), +# "sum_invo_gst_sd_amt": float(sum(row['GST_SD_Amount'] or 0 for row in invoices)), +# "sum_invo_final_amt": float(sum(row['Final_Amount'] or 0 for row in invoices)), +# "sum_invo_hold_amt": float(sum(row['hold_amount'] or 0 for row in invoices)), +# +# "sum_gst_basic_amt": float(sum(row['basic_amount'] or 0 for row in gst_rel)), +# "sum_gst_final_amt": float(sum(row['final_amount'] or 0 for row in gst_rel)), +# +# "sum_pay_payment_amt": float(sum(row['Payment_Amount'] or 0 for row in payments)), +# "sum_pay_tds_payment_amt": float(sum(row['TDS_Payment_Amount'] or 0 for row in payments)), +# "sum_pay_total_amt": float(sum(row['Total_amount'] or 0 for row in payments)) +# } +# current_date = datetime.now().strftime('%Y-%m-%d') +# +# except Exception as e: +# print(f"Error fetching contractor report: {e}") +# return "An error occurred while fetching contractor report", 500 +# +# finally: +# cursor.close() +# connection.close() +# +# return render_template('subcontractor_report.html', contInfo=contInfo, contractor_id=contractor_id, +# invoices=invoices, +# hold_types=hold_types, gst_rel=gst_rel, payments=payments, total=total, +# current_date=current_date) + +# @app.route('/contractor_report/') +# def contractor_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True, buffered=True) + +# try: +# # Fetch contractor details +# cursor.execute(""" +# SELECT DISTINCT s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, +# s.Mobile_No, s.GST_Registration_Type, s.GST_No,s.PAN_No,s.Email,s.Address +# FROM subcontractors s +# LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id +# LEFT JOIN villages v ON asg.Village_Id = v.Village_Id +# LEFT JOIN blocks b ON v.Block_Id = b.Block_Id +# LEFT JOIN districts d ON b.District_id = d.District_id +# LEFT JOIN states st ON d.State_Id = st.State_Id +# WHERE s.Contractor_Id = %s +# """, (contractor_id,)) +# contInfo = cursor.fetchone() + +# # # Fetch distinct hold types present in invoices for the contractor +# cursor.execute(""" +# SELECT DISTINCT ht.hold_type_id, ht.hold_type +# FROM invoice_subcontractor_hold_join h +# JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# JOIN invoice i ON h.Invoice_Id = i.Invoice_Id +# WHERE h.Contractor_Id = %s +# """, (contractor_id,)) +# hold_types = cursor.fetchall() +# # cursor.callproc('GetDistinctHoldTypesInInvoicesByContractor', [contractor_id]) + +# # for result in cursor.stored_results(): +# # hold_types = result.fetchall() + +# # # Fetch all invoices for the contractor, with optional hold information + +# query = """ +# SELECT DISTINCT i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, +# i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, +# i.After_Debit_Amount, i.Amount, i.GST_Amount, i.TDS_Amount, i.SD_Amount, +# i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, +# i.Final_Amount, h.hold_amount, ht.hold_type +# FROM assign_subcontractors asg +# INNER JOIN villages v ON asg.Village_Id = v.Village_Id +# INNER JOIN invoice i ON i.Village_Id = v.Village_Id AND i.PMC_No = asg.PMC_No +# LEFT JOIN subcontractors s ON asg.Contractor_Id = s.Contractor_Id +# LEFT JOIN invoice_subcontractor_hold_join h ON i.Invoice_Id = h.Invoice_Id AND h.Contractor_Id = asg.Contractor_Id +# LEFT JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# WHERE asg.Contractor_Id = %s +# ORDER BY i.PMC_No ASC; +# """ +# cursor.execute(query, (contractor_id,)) +# invoices = cursor.fetchall() + +# # cursor.callproc("GetInvoicesWithHoldInfoByContractor", [contractor_id]) +# # for result in cursor.stored_results(): +# # invoices = result.fetchall() + +# gst_query = """select pmc_no,invoice_no,basic_amount,final_amount from gst_release where pmc_no in +# (select distinct pmc_no from assign_subcontractors where Contractor_Id= %s ) ORDER BY pmc_no ASC """ +# cursor.execute(gst_query, (contractor_id,)) +# gst_rel = cursor.fetchall() +# # cursor.callproc('GetGSTReleasesByContractor', [contractor_id]) + +# # for result in cursor.stored_results(): +# # gst_rel = result.fetchall() + +# pay_query = """select pmc_no,invoice_no,Payment_Amount,TDS_Payment_Amount,Total_amount,utr from payment where pmc_no in +# (select distinct pmc_no from assign_subcontractors where Contractor_Id=%s ) ORDER BY pmc_no ASC """ +# cursor.execute(pay_query, (contractor_id,)) +# payments = cursor.fetchall() +# # cursor.callproc('GetPaymentsByContractor', [contractor_id]) + +# # for result in cursor.stored_results(): +# # payments = result.fetchall() + +# total = { +# "sum_invo_basic_amt": float(sum(row['Basic_Amount'] or 0 for row in invoices)), +# "sum_invo_debit_amt": float(sum(row['Debit_Amount'] or 0 for row in invoices)), +# "sum_invo_after_debit_amt": float(sum(row['After_Debit_Amount'] or 0 for row in invoices)), +# "sum_invo_amt": float(sum(row['Amount'] or 0 for row in invoices)), +# "sum_invo_gst_amt": float(sum(row['GST_Amount'] or 0 for row in invoices)), +# "sum_invo_tds_amt": float(sum(row['TDS_Amount'] or 0 for row in invoices)), +# "sum_invo_ds_amt": float(sum(row['SD_Amount'] or 0 for row in invoices)), +# "sum_invo_on_commission": float(sum(row['On_Commission'] or 0 for row in invoices)), +# "sum_invo_hydro_test": float(sum(row['Hydro_Testing'] or 0 for row in invoices)), +# "sum_invo_gst_sd_amt": float(sum(row['GST_SD_Amount'] or 0 for row in invoices)), +# "sum_invo_final_amt": float(sum(row['Final_Amount'] or 0 for row in invoices)), +# "sum_invo_hold_amt": float(sum(row['hold_amount'] or 0 for row in invoices)), + +# "sum_gst_basic_amt": float(sum(row['basic_amount'] or 0 for row in gst_rel)), +# "sum_gst_final_amt": float(sum(row['final_amount'] or 0 for row in gst_rel)), + +# "sum_pay_payment_amt": float(sum(row['Payment_Amount'] or 0 for row in payments)), +# "sum_pay_tds_payment_amt": float(sum(row['TDS_Payment_Amount'] or 0 for row in payments)), +# "sum_pay_total_amt": float(sum(row['Total_amount'] or 0 for row in payments)) +# } +# current_date = datetime.now().strftime('%Y-%m-%d') + +# except Exception as e: +# print(f"Error fetching contractor report: {e}") +# return "An error occurred while fetching contractor report", 500 + +# finally: +# cursor.close() +# connection.close() + +# return render_template('subcontractor_report.html', contInfo=contInfo, contractor_id=contractor_id, +# invoices=invoices, +# hold_types=hold_types, gst_rel=gst_rel, payments=payments, total=total, +# current_date=current_date) + +from flask import render_template +from datetime import datetime +import config + +@app.route('/contractor_report/') +def contractor_report(contractor_id): + connection = config.get_db_connection() + cursor = connection.cursor(dictionary=True, buffered=True) + + try: + # Contractor details + cursor.execute(""" + SELECT DISTINCT s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, + s.Mobile_No, s.GST_Registration_Type, s.GST_No, s.PAN_No, s.Email, s.Address + FROM subcontractors s + LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id + LEFT JOIN villages v ON asg.Village_Id = v.Village_Id + LEFT JOIN blocks b ON v.Block_Id = b.Block_Id + LEFT JOIN districts d ON b.District_id = d.District_id + LEFT JOIN states st ON d.State_Id = st.State_Id + WHERE s.Contractor_Id = %s + """, (contractor_id,)) + contInfo = cursor.fetchone() + + # Hold types + cursor.execute(""" + SELECT DISTINCT ht.hold_type_id, ht.hold_type + FROM invoice_subcontractor_hold_join h + JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id + JOIN invoice i ON h.Invoice_Id = i.Invoice_Id + WHERE h.Contractor_Id = %s + """, (contractor_id,)) + hold_types = cursor.fetchall() + + # Invoices + cursor.execute(""" + SELECT DISTINCT i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, + i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, + i.After_Debit_Amount, i.Amount, i.GST_Amount, i.TDS_Amount, i.SD_Amount, + i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, + i.Final_Amount, h.hold_amount, ht.hold_type + FROM assign_subcontractors asg + INNER JOIN villages v ON asg.Village_Id = v.Village_Id + INNER JOIN invoice i ON i.Village_Id = v.Village_Id AND i.PMC_No = asg.PMC_No + LEFT JOIN invoice_subcontractor_hold_join h ON i.Invoice_Id = h.Invoice_Id AND h.Contractor_Id = asg.Contractor_Id + LEFT JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id + WHERE asg.Contractor_Id = %s + ORDER BY i.PMC_No ASC + """, (contractor_id,)) + invoices = cursor.fetchall() + + # GST Release + cursor.execute(""" + SELECT gr.pmc_no, gr.invoice_no, gr.basic_amount, gr.final_amount + FROM gst_release gr + INNER JOIN ( + SELECT DISTINCT i.PMC_No, i.Invoice_No + FROM invoice i + JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No AND i.Village_Id = a.Village_Id + WHERE a.Contractor_Id = %s + ) x ON gr.pmc_no = x.PMC_No AND gr.invoice_no = x.Invoice_No + ORDER BY gr.pmc_no ASC + """, (contractor_id,)) + gst_rel = cursor.fetchall() + #Hold + # Hold Release + cursor.execute("SELECT * FROM hold_release WHERE Contractor_Id=%s", (contractor_id,)) + hold_release = cursor.fetchall() + print(hold_release) + + #Credit Note + + cursor.execute("select * from credit_note where Contractor_Id=%s",(contractor_id,)) + credit_note=cursor.fetchall() + print(credit_note) + # Payments (include valid matches and payments with pmc_no but invoice_no is NULL) + cursor.execute(""" + SELECT p.pmc_no, p.invoice_no, p.Payment_Amount, p.TDS_Payment_Amount, p.Total_amount, p.utr + FROM payment p + WHERE + EXISTS ( + SELECT 1 + FROM invoice i + JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No AND i.Village_Id = a.Village_Id + WHERE a.Contractor_Id = %s + AND i.PMC_No = p.pmc_no AND i.Invoice_No = p.invoice_no + ) + OR ( + p.invoice_no IS NULL + AND EXISTS ( + SELECT 1 + FROM assign_subcontractors a + WHERE a.Contractor_Id = %s + AND a.PMC_No = p.pmc_no + ) + ) + ORDER BY p.pmc_no ASC + """, (contractor_id, contractor_id)) + payments = cursor.fetchall() + + # Totals + total = { + "sum_invo_basic_amt": float(sum(row['Basic_Amount'] or 0 for row in invoices)), + "sum_invo_debit_amt": float(sum(row['Debit_Amount'] or 0 for row in invoices)), + "sum_invo_after_debit_amt": float(sum(row['After_Debit_Amount'] or 0 for row in invoices)), + "sum_invo_amt": float(sum(row['Amount'] or 0 for row in invoices)), + "sum_invo_gst_amt": float(sum(row['GST_Amount'] or 0 for row in invoices)), + "sum_invo_tds_amt": float(sum(row['TDS_Amount'] or 0 for row in invoices)), + "sum_invo_ds_amt": float(sum(row['SD_Amount'] or 0 for row in invoices)), + "sum_invo_on_commission": float(sum(row['On_Commission'] or 0 for row in invoices)), + "sum_invo_hydro_test": float(sum(row['Hydro_Testing'] or 0 for row in invoices)), + "sum_invo_gst_sd_amt": float(sum(row['GST_SD_Amount'] or 0 for row in invoices)), + "sum_invo_final_amt": float(sum(row['Final_Amount'] or 0 for row in invoices)), + "sum_invo_hold_amt": float(sum(row['hold_amount'] or 0 for row in invoices)), + + "sum_gst_basic_amt": float(sum(row['basic_amount'] or 0 for row in gst_rel)), + "sum_gst_final_amt": float(sum(row['final_amount'] or 0 for row in gst_rel)), + + "sum_pay_payment_amt": float(sum(row['Payment_Amount'] or 0 for row in payments)), + "sum_pay_tds_payment_amt": float(sum(row['TDS_Payment_Amount'] or 0 for row in payments)), + "sum_pay_total_amt": float(sum(row['Total_amount'] or 0 for row in payments)) + } + + current_date = datetime.now().strftime('%Y-%m-%d') + + except Exception as e: + print(f"Error fetching contractor report: {e}") + return "An error occurred while fetching contractor report", 500 + + finally: + cursor.close() + connection.close() + + return render_template('subcontractor_report.html', + contInfo=contInfo, + contractor_id=contractor_id, + invoices=invoices, + hold_types=hold_types, + gst_rel=gst_rel, + payments=payments, + credit_note=credit_note, + hold_release=hold_release, + total=total, + current_date=current_date) + + + + + + +# -----------------------------download contractor report--------------------------------- +# @app.route('/download_report/') +# def download_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True) +# +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"Contractor_Report_{contractor_id}.xlsx") +# +# if not os.path.exists(output_folder): +# os.makedirs(output_folder) +# +# try: +# # Fetch Contractor Details +# # cursor.execute(""" +# # SELECT DISTINCT s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, +# # s.Mobile_No, s.GST_Registration_Type, s.GST_No, s.PAN_No, s.Email, s.Address +# # FROM subcontractors s +# # LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id +# # LEFT JOIN villages v ON asg.Village_Id = v.Village_Id +# # LEFT JOIN blocks b ON v.Block_Id = b.Block_Id +# # LEFT JOIN districts d ON b.District_id = d.District_id +# # LEFT JOIN states st ON d.State_Id = st.State_Id +# # WHERE s.Contractor_Id = %s +# # """, (contractor_id,)) +# # contInfo = cursor.fetchone() +# cursor.callproc('GetContractorInfoById', [contractor_id]) +# contInfo = next(cursor.stored_results()).fetchone() +# +# if not contInfo: +# return "No contractor found", 404 +# +# # Fetch distinct hold types present for the contractor +# cursor.execute(""" +# SELECT DISTINCT ht.hold_type_id, ht.hold_type +# FROM invoice_subcontractor_hold_join h +# JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# WHERE h.Contractor_Id = %s +# """, (contractor_id,)) +# hold_types = cursor.fetchall() +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} +# +# # Fetch Invoices & GST Releases +# cursor.execute(""" +# SELECT DISTINCT i.Invoice_Id, i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, +# i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, +# i.After_Debit_Amount, i.GST_Amount, i.Amount, i.TDS_Amount, i.SD_Amount, +# i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, i.Final_Amount, +# g.pmc_no AS gst_pmc_no, g.invoice_no AS gst_invoice_no, +# g.basic_amount AS gst_basic_amount, g.final_amount AS gst_final_amount +# FROM invoice i +# LEFT JOIN assign_subcontractors asg ON i.PMC_No = asg.PMC_No +# LEFT JOIN villages v ON i.Village_Id = v.Village_Id +# LEFT JOIN gst_release g ON i.PMC_No = g.pmc_no AND i.Invoice_No = g.invoice_no +# WHERE asg.Contractor_Id = %s +# """, (contractor_id,)) +# invoices = cursor.fetchall() +# +# # Fetch Hold Amounts separately +# cursor.execute(""" +# SELECT h.Invoice_Id, ht.hold_type_id, h.hold_amount +# FROM invoice_subcontractor_hold_join h +# JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# WHERE h.Contractor_Id = %s +# """, (contractor_id,)) +# hold_amounts = cursor.fetchall() +# +# # Create a mapping of invoice_id to hold amounts by type +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] +# +# # Extract unique PMC numbers for payments +# pmc_numbers = tuple(set(inv['PMC_No'] for inv in invoices if inv['PMC_No'] is not None)) +# +# # Fetch all Payments for the PMC numbers (including those with null invoice_no) +# payments_map = {} +# extra_payments_map = {} # Now using a map to organize extra payments by PMC +# if pmc_numbers: +# # First get payments with invoice_no +# query = f""" +# SELECT pmc_no, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_amount, UTR +# FROM payment +# WHERE pmc_no IN ({','.join(['%s'] * len(pmc_numbers))}) +# AND invoice_no IS NOT NULL +# ORDER BY pmc_no, invoice_no +# """ +# cursor.execute(query, pmc_numbers) +# payments = cursor.fetchall() +# +# # Organize payments by PMC No & Invoice No +# for pay in payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# if key not in payments_map: +# payments_map[key] = [] +# payments_map[key].append(pay) +# +# # Then get extra payments (null invoice_no) and organize by PMC +# query = f""" +# SELECT pmc_no, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_amount, UTR +# FROM payment +# WHERE pmc_no IN ({','.join(['%s'] * len(pmc_numbers))}) +# AND invoice_no IS NULL +# ORDER BY pmc_no +# """ +# cursor.execute(query, pmc_numbers) +# extra_payments = cursor.fetchall() +# +# for pay in extra_payments: +# if pay['pmc_no'] not in extra_payments_map: +# extra_payments_map[pay['pmc_no']] = [] +# extra_payments_map[pay['pmc_no']].append(pay) +# +# # Create Excel workbook +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "Contractor Report" +# +# # Write Contractor Details +# sheet.append(["", "", "Laxmi Civil Engineering Services PVT. LTD.", "", ""]) +# sheet.append( +# ["Contractor Name", contInfo["Contractor_Name"], " ", "GST No", contInfo["GST_No"], " ", "GST Type", +# contInfo["GST_Registration_Type"]]) +# sheet.append( +# ["State", contInfo["State_Name"], " ", "PAN No", contInfo["PAN_No"], " ", "Address", contInfo["Address"]]) +# sheet.append(["District", contInfo["District_Name"], " ", "Mobile No", contInfo["Mobile_No"]]) +# sheet.append(["Block", contInfo["Block_Name"], " ", "Email", contInfo["Email"]]) +# sheet.append([]) +# +# # Table Headers - include all hold types as separate columns +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] +# +# hold_headers = [ht['hold_type'] for ht in hold_types] +# +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] +# +# sheet.append(base_headers + hold_headers + payment_headers) +# +# seen_invoices = set() +# seen_gst_notes = set() +# processed_payments = set() # Track which payments we've processed +# +# # Process invoices grouped by PMC No +# pmc_groups = {} +# for inv in invoices: +# pmc_no = inv["PMC_No"] +# if pmc_no not in pmc_groups: +# pmc_groups[pmc_no] = [] +# pmc_groups[pmc_no].append(inv) +# +# # Process each PMC group separately +# for pmc_no, pmc_invoices in pmc_groups.items(): +# # Process all invoices for this PMC first +# for inv in pmc_invoices: +# invoice_no = inv["Invoice_No"] +# payments = payments_map.get((pmc_no, invoice_no), []) +# +# # Process invoice row with first payment (if exists) +# if (pmc_no, invoice_no) not in seen_invoices: +# seen_invoices.add((pmc_no, invoice_no)) +# first_payment = payments[0] if len(payments) > 0 else None +# +# # Base invoice data +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] +# +# # Add hold amounts for each hold type +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map.keys(): +# row.append(invoice_holds.get(ht_id, "")) +# +# # Add payment information +# row += [ +# inv["Final_Amount"], +# first_payment["Payment_Amount"] if first_payment else "", +# first_payment["TDS_Payment_Amount"] if first_payment else "", +# first_payment["Total_amount"] if first_payment else "", +# first_payment["UTR"] if first_payment else "" +# ] +# +# sheet.append(row) +# +# if first_payment: +# payment_id = f"{pmc_no}-{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}" +# processed_payments.add(payment_id) +# +# # Process GST release if exists (only if we have a matching GST record) +# if inv["gst_pmc_no"] and (inv["gst_pmc_no"], inv["gst_invoice_no"]) not in seen_gst_notes: +# seen_gst_notes.add((inv["gst_pmc_no"], inv["gst_invoice_no"])) +# +# # Find the payment that matches this GST release +# gst_payment = None +# for payment in payments[1:]: # Skip first payment (already used for invoice) +# if payment['invoice_no'] == inv["gst_invoice_no"]: +# gst_payment = payment +# break +# +# # GST release row +# row = [ +# pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], +# inv["gst_basic_amount"], "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for GST release +# row += ["" for _ in hold_headers] +# +# # Add payment information +# row += [ +# inv["gst_final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["UTR"] if gst_payment else "" +# ] +# +# sheet.append(row) +# +# if gst_payment: +# payment_id = f"{pmc_no}-{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}" +# processed_payments.add(payment_id) +# +# # Process remaining payments as extra payments +# for payment in payments[1:]: +# payment_id = f"{pmc_no}-{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", payment['invoice_no'], +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for extra payments +# row += ["" for _ in hold_headers] +# +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# +# sheet.append(row) +# processed_payments.add(payment_id) +# +# # Process extra payments for this PMC (null invoice_no) immediately after the PMC's invoices +# if pmc_no in extra_payments_map: +# for payment in extra_payments_map[pmc_no]: +# payment_id = f"{pmc_no}-null-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", "", +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for null invoice payments +# row += ["" for _ in hold_headers] +# +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# +# sheet.append(row) +# processed_payments.add(payment_id) +# +# workbook.save(output_file) +# workbook.close() +# finally: +# cursor.close() +# connection.close() +# from openpyxl.styles import Font +# +# # Initialize totals +# total_basic_amount = 0 +# total_tds_amount = 0 +# total_sd_amount = 0 +# total_on_commission = 0 +# total_hold_amount = 0 +# total_final_amount = 0 +# total_total_amount = 0 # Sum of all Total Amounts from payment data +# +# # Iterate through rows to calculate totals +# for row in sheet.iter_rows(min_row=2, max_row=sheet.max_row, values_only=True): +# try: +# total_basic_amount += float(row[6] or 0) # Basic_Amount +# total_tds_amount += float(row[11] or 0) # TDS_Amount +# total_sd_amount += float(row[12] or 0) # SD_Amount +# total_on_commission += float(row[13] or 0) # On_Commission +# total_final_amount += float(row[-5] or 0) # Final_Amount +# total_total_amount += float(row[-2] or 0) # Total_Amount (from payments) +# +# # Sum of hold amounts (dynamically calculated based on hold_headers) +# hold_start_col = len(base_headers) # First column where hold types start +# hold_end_col = hold_start_col + len(hold_headers) # Last column where hold types end +# total_hold_amount += sum(float(row[i] or 0) for i in range(hold_start_col, hold_end_col)) +# +# except ValueError: +# continue # Skip if non-numeric values cause errors +# +# # Append the totals row at the bottom of the sheet +# totals_row = [ +# "TOTAL", "", "", "", "", "", # Empty values for non-numeric columns +# total_basic_amount, "", "", "", "", total_tds_amount, total_sd_amount, +# total_on_commission, "", "", # Empty GST SD Amount +# ] +# +# # Add empty placeholders for hold types +# totals_row += [total_hold_amount] + [""] * (len(hold_headers) - 1) +# +# # Add totals for Final Amount and Total Amount +# totals_row += [ +# total_final_amount, "", "", total_total_amount, "" # UTR column remains empty +# ] +# +# # Append totals row to sheet +# sheet.append([]) +# sheet.append(totals_row) +# +# # Make the totals row bold +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# +# sheet.append([]) +# sheet.append([]) +# sheet.append([]) +# sheet.append([]) +# sheet.append(["This is Generated by LCEPL Application.."]) +# +# # Save workbook after modifications +# workbook.save(output_file) +# workbook.close() +# +# return send_from_directory(output_folder, f"Contractor_Report_{contractor_id}.xlsx", as_attachment=True) +from openpyxl import Workbook + +# # Download report by contractor id +# # Download report by contractor id +from flask import send_from_directory + +import config + + +# -----------------------PMC Report--------------------------- +# @app.route('/download_report/') +# def download_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True) + +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"Contractor_Report_{contractor_id}.xlsx") + +# if not os.path.exists(output_folder): +# os.makedirs(output_folder) + +# try: +# # Fetch Contractor Details +# cursor.execute(""" +# SELECT DISTINCT s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, +# s.Mobile_No, s.GST_Registration_Type, s.GST_No, s.PAN_No, s.Email, s.Address +# FROM subcontractors s +# LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id +# LEFT JOIN villages v ON asg.Village_Id = v.Village_Id +# LEFT JOIN blocks b ON v.Block_Id = b.Block_Id +# LEFT JOIN districts d ON b.District_id = d.District_id +# LEFT JOIN states st ON d.State_Id = st.State_Id +# WHERE s.Contractor_Id = %s +# """, (contractor_id,)) +# contInfo = cursor.fetchone() + +# if not contInfo: +# return "No contractor found", 404 + +# # # Fetch distinct hold types present for the contractor +# # cursor.execute(""" +# # SELECT DISTINCT ht.hold_type_id, ht.hold_type +# # FROM invoice_subcontractor_hold_join h +# # JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# # WHERE h.Contractor_Id = %s +# # """, (contractor_id,)) +# # hold_types = cursor.fetchall() +# cursor.callproc('GetDistinctHoldTypesByContractor', [contractor_id]) + +# for result in cursor.stored_results(): +# hold_types = result.fetchall() + +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} + +# # # Fetch Invoices & GST Releases +# # cursor.execute(""" +# # SELECT DISTINCT i.Invoice_Id, i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, +# # i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, +# # i.After_Debit_Amount, i.GST_Amount, i.Amount, i.TDS_Amount, i.SD_Amount, +# # i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, i.Final_Amount, +# # g.pmc_no AS gst_pmc_no, g.invoice_no AS gst_invoice_no, +# # g.basic_amount AS gst_basic_amount, g.final_amount AS gst_final_amount +# # FROM invoice i +# # LEFT JOIN assign_subcontractors asg ON i.PMC_No = asg.PMC_No +# # LEFT JOIN villages v ON i.Village_Id = v.Village_Id +# # LEFT JOIN gst_release g ON i.PMC_No = g.pmc_no AND i.Invoice_No = g.invoice_no +# # WHERE asg.Contractor_Id = %s +# # """, (contractor_id,)) +# # invoices = cursor.fetchall() +# cursor.callproc('GetInvoicesAndGSTReleasesByContractor', [contractor_id]) + +# for result in cursor.stored_results(): +# invoices = result.fetchall() + +# # # Fetch Hold Amounts separately +# # cursor.execute(""" +# # SELECT h.Invoice_Id, ht.hold_type_id, h.hold_amount +# # FROM invoice_subcontractor_hold_join h +# # JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# # WHERE h.Contractor_Id = %s +# # """, (contractor_id,)) +# # hold_amounts = cursor.fetchall() +# cursor.callproc('GetHoldAmountsByContractors', [contractor_id]) + +# for result in cursor.stored_results(): +# hold_amounts = result.fetchall() + +# # Create a mapping of invoice_id to hold amounts by type +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] + +# # Extract unique PMC numbers for payments +# pmc_numbers = tuple(set(inv['PMC_No'] for inv in invoices if inv['PMC_No'] is not None)) + +# # Fetch all Payments for the PMC numbers (including those with null invoice_no) +# payments_map = {} +# extra_payments_map = {} # Now using a map to organize extra payments by PMC +# if pmc_numbers: +# # First get payments with invoice_no +# query = f""" +# SELECT pmc_no, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_amount, UTR +# FROM payment +# WHERE pmc_no IN ({','.join(['%s'] * len(pmc_numbers))}) +# AND invoice_no IS NOT NULL +# ORDER BY pmc_no, invoice_no +# """ +# cursor.execute(query, pmc_numbers) +# payments = cursor.fetchall() + +# # Organize payments by PMC No & Invoice No +# for pay in payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# if key not in payments_map: +# payments_map[key] = [] +# payments_map[key].append(pay) + +# # Then get extra payments (null invoice_no) and organize by PMC +# query = f""" +# SELECT pmc_no, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_amount, UTR +# FROM payment +# WHERE pmc_no IN ({','.join(['%s'] * len(pmc_numbers))}) +# AND invoice_no IS NULL +# ORDER BY pmc_no +# """ +# cursor.execute(query, pmc_numbers) +# extra_payments = cursor.fetchall() + +# for pay in extra_payments: +# if pay['pmc_no'] not in extra_payments_map: +# extra_payments_map[pay['pmc_no']] = [] +# extra_payments_map[pay['pmc_no']].append(pay) + +# # Create Excel workbook +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "Contractor Report" + +# # Write Contractor Details +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["State", contInfo["State_Name"]]) +# sheet.append(["District", contInfo["District_Name"]]) +# sheet.append(["Block", contInfo["Block_Name"]]) +# sheet.append(["Mobile No", contInfo["Mobile_No"]]) +# sheet.append(["GST Type", contInfo["GST_Registration_Type"]]) +# sheet.append(["GST No", contInfo["GST_No"]]) +# sheet.append(["PAN No", contInfo["PAN_No"]]) +# sheet.append(["Email", contInfo["Email"]]) +# sheet.append(["Address", contInfo["Address"]]) +# sheet.append([]) + +# # Table Headers - include all hold types as separate columns +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] + +# hold_headers = [ht['hold_type'] for ht in hold_types] + +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] + +# sheet.append(base_headers + hold_headers + payment_headers) + +# seen_invoices = set() +# seen_gst_notes = set() +# processed_payments = set() # Track which payments we've processed + +# # Process invoices grouped by PMC No +# pmc_groups = {} +# for inv in invoices: +# pmc_no = inv["PMC_No"] +# if pmc_no not in pmc_groups: +# pmc_groups[pmc_no] = [] +# pmc_groups[pmc_no].append(inv) + +# # Process each PMC group separately +# for pmc_no, pmc_invoices in pmc_groups.items(): +# # Process all invoices for this PMC first +# for inv in pmc_invoices: +# invoice_no = inv["Invoice_No"] +# payments = payments_map.get((pmc_no, invoice_no), []) + +# # Process invoice row with first payment (if exists) +# if (pmc_no, invoice_no) not in seen_invoices: +# seen_invoices.add((pmc_no, invoice_no)) +# first_payment = payments[0] if len(payments) > 0 else None + +# # Base invoice data +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] + +# # Add hold amounts for each hold type +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map.keys(): +# row.append(invoice_holds.get(ht_id, "")) + +# # Add payment information +# row += [ +# inv["Final_Amount"], +# first_payment["Payment_Amount"] if first_payment else "", +# first_payment["TDS_Payment_Amount"] if first_payment else "", +# first_payment["Total_amount"] if first_payment else "", +# first_payment["UTR"] if first_payment else "" +# ] + +# sheet.append(row) + +# if first_payment: +# payment_id = f"{pmc_no}-{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}" +# processed_payments.add(payment_id) + +# # Process GST release if exists (only if we have a matching GST record) +# if inv["gst_pmc_no"] and (inv["gst_pmc_no"], inv["gst_invoice_no"]) not in seen_gst_notes: +# seen_gst_notes.add((inv["gst_pmc_no"], inv["gst_invoice_no"])) + +# # Find the payment that matches this GST release +# gst_payment = None +# for payment in payments[1:]: # Skip first payment (already used for invoice) +# if payment['invoice_no'] == inv["gst_invoice_no"]: +# gst_payment = payment +# break + +# # GST release row +# row = [ +# pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], +# inv["gst_basic_amount"], "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] + +# # Empty holds for GST release +# row += ["" for _ in hold_headers] + +# # Add payment information +# row += [ +# inv["gst_final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["UTR"] if gst_payment else "" +# ] + +# sheet.append(row) + +# if gst_payment: +# payment_id = f"{pmc_no}-{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}" +# processed_payments.add(payment_id) + +# # Process remaining payments as extra payments +# for payment in payments[1:]: +# payment_id = f"{pmc_no}-{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", payment['invoice_no'], +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] + +# # Empty holds for extra payments +# row += ["" for _ in hold_headers] + +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] + +# sheet.append(row) +# processed_payments.add(payment_id) + +# # Process extra payments for this PMC (null invoice_no) immediately after the PMC's invoices +# if pmc_no in extra_payments_map: +# for payment in extra_payments_map[pmc_no]: +# payment_id = f"{pmc_no}-null-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", "", +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] + +# # Empty holds for null invoice payments +# row += ["" for _ in hold_headers] + +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] + + +# sheet.append(row) +# processed_payments.add(payment_id) + +# workbook.save(output_file) +# workbook.close() +# finally: +# cursor.close() +# connection.close() +# from openpyxl.styles import Font + +# # Initialize totals +# total_basic_amount = 0 +# total_tds_amount = 0 +# total_sd_amount = 0 +# total_on_commission = 0 +# total_hold_amount = 0 +# total_final_amount = 0 +# total_total_amount = 0 # Sum of all Total Amounts from payment data + +# # Iterate through rows to calculate totals +# for row in sheet.iter_rows(min_row=2, max_row=sheet.max_row, values_only=True): +# try: +# total_basic_amount += float(row[6] or 0) # Basic_Amount +# total_tds_amount += float(row[11] or 0) # TDS_Amount +# total_sd_amount += float(row[12] or 0) # SD_Amount +# total_on_commission += float(row[13] or 0) # On_Commission +# total_final_amount += float(row[-5] or 0) # Final_Amount +# total_total_amount += float(row[-2] or 0) # Total_Amount (from payments) + +# # Sum of hold amounts (dynamically calculated based on hold_headers) +# hold_start_col = len(base_headers) # First column where hold types start +# hold_end_col = hold_start_col + len(hold_headers) # Last column where hold types end +# total_hold_amount += sum(float(row[i] or 0) for i in range(hold_start_col, hold_end_col)) + +# except ValueError: +# continue # Skip if non-numeric values cause errors + +# # Append the totals row at the bottom of the sheet +# totals_row = [ +# "TOTAL", "", "", "", "", "", # Empty values for non-numeric columns +# total_basic_amount, "", "", "", "", total_tds_amount, total_sd_amount, +# total_on_commission, "", "", # Empty GST SD Amount +# ] + +# # Add empty placeholders for hold types +# totals_row += [total_hold_amount] + [""] * (len(hold_headers) - 1) + +# # Add totals for Final Amount and Total Amount +# totals_row += [ +# total_final_amount, "", "", total_total_amount, "" # UTR column remains empty +# ] + +# # Append totals row to sheet +# sheet.append([]) +# sheet.append(totals_row) + +# # Make the totals row bold +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) + +# # Save workbook after modifications +# workbook.save(output_file) +# workbook.close() + +# return send_from_directory(output_folder, f"Contractor_Report_{contractor_id}.xlsx", as_attachment=True) + +# @app.route('/download_report/') +# def download_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True) +# +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"Contractor_Report_{contractor_id}.xlsx") +# +# if not os.path.exists(output_folder): +# os.makedirs(output_folder) +# +# try: +# # Fetch Contractor Details +# # cursor.execute(""" +# # SELECT DISTINCT s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, +# # s.Mobile_No, s.GST_Registration_Type, s.GST_No, s.PAN_No, s.Email, s.Address +# # FROM subcontractors s +# # LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id +# # LEFT JOIN villages v ON asg.Village_Id = v.Village_Id +# # LEFT JOIN blocks b ON v.Block_Id = b.Block_Id +# # LEFT JOIN districts d ON b.District_id = d.District_id +# # LEFT JOIN states st ON d.State_Id = st.State_Id +# # WHERE s.Contractor_Id = %s +# # """, (contractor_id,)) +# # contInfo = cursor.fetchone() +# cursor.callproc('GetContractorInfoId', [contractor_id]) +# for result in cursor.stored_results(): +# contInfo = result.fetchone() +# +# if not contInfo: +# return "No contractor found", 404 +# +# # # Fetch distinct hold types present for the contractor +# # cursor.execute(""" +# # SELECT DISTINCT ht.hold_type_id, ht.hold_type +# # FROM invoice_subcontractor_hold_join h +# # JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# # WHERE h.Contractor_Id = %s +# # """, (contractor_id,)) +# # hold_types = cursor.fetchall() +# cursor.callproc('GetDistinctHoldTypesByContractor', [contractor_id]) +# +# for result in cursor.stored_results(): +# hold_types = result.fetchall() +# +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} +# +# # # Fetch Invoices & GST Releases +# # cursor.execute(""" +# # SELECT DISTINCT i.Invoice_Id, i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, +# # i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, +# # i.After_Debit_Amount, i.GST_Amount, i.Amount, i.TDS_Amount, i.SD_Amount, +# # i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, i.Final_Amount, +# # g.pmc_no AS gst_pmc_no, g.invoice_no AS gst_invoice_no, +# # g.basic_amount AS gst_basic_amount, g.final_amount AS gst_final_amount +# # FROM invoice i +# # LEFT JOIN assign_subcontractors asg ON i.PMC_No = asg.PMC_No +# # LEFT JOIN villages v ON i.Village_Id = v.Village_Id +# # LEFT JOIN gst_release g ON i.PMC_No = g.pmc_no AND i.Invoice_No = g.invoice_no +# # WHERE asg.Contractor_Id = %s +# # """, (contractor_id,)) +# # invoices = cursor.fetchall() +# cursor.callproc('GetInvoicesAndGSTReleasesByContractor', [contractor_id]) +# +# for result in cursor.stored_results(): +# invoices = result.fetchall() +# +# # # Fetch Hold Amounts separately +# # cursor.execute(""" +# # SELECT h.Invoice_Id, ht.hold_type_id, h.hold_amount +# # FROM invoice_subcontractor_hold_join h +# # JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# # WHERE h.Contractor_Id = %s +# # """, (contractor_id,)) +# # hold_amounts = cursor.fetchall() +# cursor.callproc('GetHoldAmountsByContractors', [contractor_id]) +# +# for result in cursor.stored_results(): +# hold_amounts = result.fetchall() +# +# # Create a mapping of invoice_id to hold amounts by type +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] +# +# # Extract unique PMC numbers for payments +# pmc_numbers = tuple(set(inv['PMC_No'] for inv in invoices if inv['PMC_No'] is not None)) +# +# # Fetch all Payments for the PMC numbers (including those with null invoice_no) +# payments_map = {} +# extra_payments_map = {} # Now using a map to organize extra payments by PMC +# if pmc_numbers: +# # # First get payments with invoice_no +# # query = f""" +# # SELECT pmc_no, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_amount, UTR +# # FROM payment +# # WHERE pmc_no IN ({','.join(['%s'] * len(pmc_numbers))}) +# # AND invoice_no IS NOT NULL +# # ORDER BY pmc_no, invoice_no +# # """ +# # cursor.execute(query, pmc_numbers) +# # payments = cursor.fetchall() +# +# pmc_list_str = ','.join(str(pmc) for pmc in pmc_numbers) +# # e.g. 'PMC001,PMC002,PMC003' +# cursor.callproc('GetPaymentsByPmcNosWithInvoice', [pmc_list_str]) +# +# for result in cursor.stored_results(): +# payments = result.fetchall() +# +# print("payments by procedure:", payments) +# # Organize payments by PMC No & Invoice No +# for pay in payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# if key not in payments_map: +# payments_map[key] = [] +# payments_map[key].append(pay) +# +# # Then get extra payments (null invoice_no) and organize by PMC +# # query = f""" +# # SELECT pmc_no, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_amount, UTR +# # FROM payment +# # WHERE pmc_no IN ({','.join(['%s'] * len(pmc_numbers))}) +# # AND invoice_no IS NULL +# # ORDER BY pmc_no +# # """ +# # cursor.execute(query, pmc_numbers) +# # extra_payments = cursor.fetchall() +# pmc_list_str = ','.join(str(pmc) for pmc in pmc_numbers) +# cursor.callproc('GetExtraPaymentsByPmcNos', [pmc_list_str]) +# +# for result in cursor.stored_results(): +# extra_payments = result.fetchall() +# print( +# "-----------------------------------------------------------------------------------------Extra Payment---------------------------------------------------------------") +# print("Extra payment from produre", extra_payments) +# +# for pay in extra_payments: +# if pay['pmc_no'] not in extra_payments_map: +# extra_payments_map[pay['pmc_no']] = [] +# extra_payments_map[pay['pmc_no']].append(pay) +# print( +# "-----------------------------------------------------------------------------------------Extra Payment MAP --------------------------------------------------------------") +# print("Extra payment MAp from produre", extra_payments_map) +# # Create Excel workbook +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "Contractor Report" +# +# # Write Contractor Details +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["State", contInfo["State_Name"]]) +# sheet.append(["District", contInfo["District_Name"]]) +# sheet.append(["Block", contInfo["Block_Name"]]) +# sheet.append(["Mobile No", contInfo["Mobile_No"]]) +# sheet.append(["GST Type", contInfo["GST_Registration_Type"]]) +# sheet.append(["GST No", contInfo["GST_No"]]) +# sheet.append(["PAN No", contInfo["PAN_No"]]) +# sheet.append(["Email", contInfo["Email"]]) +# sheet.append(["Address", contInfo["Address"]]) +# sheet.append([]) +# +# # Table Headers - include all hold types as separate columns +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] +# +# hold_headers = [ht['hold_type'] for ht in hold_types] +# +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] +# +# sheet.append(base_headers + hold_headers + payment_headers) +# +# seen_invoices = set() +# seen_gst_notes = set() +# processed_payments = set() # Track which payments we've processed +# +# # Process invoices grouped by PMC No +# pmc_groups = {} +# for inv in invoices: +# pmc_no = inv["PMC_No"] +# if pmc_no not in pmc_groups: +# pmc_groups[pmc_no] = [] +# pmc_groups[pmc_no].append(inv) +# +# # Process each PMC group separately +# for pmc_no, pmc_invoices in pmc_groups.items(): +# # Process all invoices for this PMC first +# for inv in pmc_invoices: +# invoice_no = inv["Invoice_No"] +# payments = payments_map.get((pmc_no, invoice_no), []) +# +# # Process invoice row with first payment (if exists) +# if (pmc_no, invoice_no) not in seen_invoices: +# seen_invoices.add((pmc_no, invoice_no)) +# first_payment = payments[0] if len(payments) > 0 else None +# +# # Base invoice data +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] +# +# # Add hold amounts for each hold type +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map.keys(): +# row.append(invoice_holds.get(ht_id, "")) +# +# # Add payment information +# row += [ +# inv["Final_Amount"], +# first_payment["Payment_Amount"] if first_payment else "", +# first_payment["TDS_Payment_Amount"] if first_payment else "", +# first_payment["Total_amount"] if first_payment else "", +# first_payment["UTR"] if first_payment else "" +# ] +# +# sheet.append(row) +# +# if first_payment: +# payment_id = f"{pmc_no}-{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}" +# processed_payments.add(payment_id) +# +# # Process GST release if exists (only if we have a matching GST record) +# if inv["gst_pmc_no"] and (inv["gst_pmc_no"], inv["gst_invoice_no"]) not in seen_gst_notes: +# seen_gst_notes.add((inv["gst_pmc_no"], inv["gst_invoice_no"])) +# +# # Find the payment that matches this GST release +# gst_payment = None +# for payment in payments[1:]: # Skip first payment (already used for invoice) +# if payment['invoice_no'] == inv["gst_invoice_no"]: +# gst_payment = payment +# break +# +# # GST release row +# row = [ +# pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], +# inv["gst_basic_amount"], "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for GST release +# row += ["" for _ in hold_headers] +# +# # Add payment information +# row += [ +# inv["gst_final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["UTR"] if gst_payment else "" +# ] +# +# sheet.append(row) +# +# if gst_payment: +# payment_id = f"{pmc_no}-{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}" +# processed_payments.add(payment_id) +# +# # Process remaining payments as extra payments +# for payment in payments[1:]: +# payment_id = f"{pmc_no}-{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", payment['invoice_no'], +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for extra payments +# row += ["" for _ in hold_headers] +# +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# +# sheet.append(row) +# processed_payments.add(payment_id) +# +# # Process extra payments for this PMC (null invoice_no) immediately after the PMC's invoices +# if pmc_no in extra_payments_map: +# for payment in extra_payments_map[pmc_no]: +# payment_id = f"{pmc_no}-null-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", "", +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for null invoice payments +# row += ["" for _ in hold_headers] +# +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# +# sheet.append(row) +# processed_payments.add(payment_id) +# +# workbook.save(output_file) +# workbook.close() +# finally: +# cursor.close() +# connection.close() +# from openpyxl.styles import Font +# +# # Initialize totals +# total_basic_amount = 0 +# total_tds_amount = 0 +# total_sd_amount = 0 +# total_on_commission = 0 +# total_hold_amount = 0 +# total_final_amount = 0 +# total_total_amount = 0 # Sum of all Total Amounts from payment data +# +# # Iterate through rows to calculate totals +# for row in sheet.iter_rows(min_row=2, max_row=sheet.max_row, values_only=True): +# try: +# total_basic_amount += float(row[6] or 0) # Basic_Amount +# total_tds_amount += float(row[11] or 0) # TDS_Amount +# total_sd_amount += float(row[12] or 0) # SD_Amount +# total_on_commission += float(row[13] or 0) # On_Commission +# total_final_amount += float(row[-5] or 0) # Final_Amount +# total_total_amount += float(row[-2] or 0) # Total_Amount (from payments) +# +# # Sum of hold amounts (dynamically calculated based on hold_headers) +# hold_start_col = len(base_headers) # First column where hold types start +# hold_end_col = hold_start_col + len(hold_headers) # Last column where hold types end +# total_hold_amount += sum(float(row[i] or 0) for i in range(hold_start_col, hold_end_col)) +# +# except ValueError: +# continue # Skip if non-numeric values cause errors +# +# # Append the totals row at the bottom of the sheet +# totals_row = [ +# "TOTAL", "", "", "", "", "", # Empty values for non-numeric columns +# total_basic_amount, "", "", "", "", total_tds_amount, total_sd_amount, +# total_on_commission, "", "", # Empty GST SD Amount +# ] +# if hold_headers: +# totals_row += [total_hold_amount] + [""] * (len(hold_headers) - 1) +# +# # Add empty placeholders for hold types +# # totals_row += [total_hold_amount] + [""] * (len(hold_headers) - 1) +# +# # Add totals for Final Amount and Total Amount +# totals_row += [ +# total_final_amount, "", "", total_total_amount, "" # UTR column remains empty +# ] +# +# # Append totals row to sheet +# sheet.append([]) +# sheet.append(totals_row) +# total_hold_amount=Decimal('0.00') +# for d in invoices: +# total_hold_amount = total_hold_amount + d.get('SD_Amount', Decimal('0.00')) + d.get('On_Commission', +# Decimal( +# '0.00')) + d.get( +# 'Hydro_Testing', Decimal('0.00')) +# #new coded for summary chart added +# for data in hold_amounts: +# total_hold_amount = total_hold_amount + data.get('hold_amount', Decimal('0.00')) +# print("Total Hold Amount after adding the hold amount ", total_hold_amount) +# +# +# from datetime import datetime +# +# # Add payment information +# +# # Get today's date with weekday +# today_date = datetime.today().strftime('%A, %Y-%m-%d') +# +# # Add headers (optional) +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["Date", today_date]) +# sheet.append(["Description", "Amount"]) +# +# # Add your values +# sheet.append(["Advance/Surplus", str( total_final_amount - total_total_amount)]) +# sheet.append(["Total Hold Amount", str(total_hold_amount)]) +# sheet.append(["Amount With TDS", str(total_tds_amount)]) +# #new added code end here for summary chart +# +# # Make the totals row bold +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# +# # Save workbook after modifications +# workbook.save(output_file) +# workbook.close() +# +# return send_from_directory(output_folder, f"Contractor_Report_{contractor_id}.xlsx", as_attachment=True) + +from flask import send_from_directory +import os +import openpyxl +from openpyxl.styles import Font, PatternFill +from decimal import Decimal +from datetime import datetime + +from flask import send_from_directory +import os +import openpyxl +from openpyxl.styles import Font, PatternFill +from decimal import Decimal +from datetime import datetime + +# @app.route('/download_report/') +# def download_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True) + +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"Contractor_Report_{contractor_id}.xlsx") + +# if not os.path.exists(output_folder): +# os.makedirs(output_folder) + +# try: +# # Fetch Contractor Info +# cursor.callproc('GetContractorInfoId', [contractor_id]) +# for result in cursor.stored_results(): +# contInfo = result.fetchone() +# if not contInfo: +# return "No contractor found", 404 + +# # Fetch Hold Types +# cursor.callproc('GetDistinctHoldTypesByContractor', [contractor_id]) +# for result in cursor.stored_results(): +# hold_types = result.fetchall() +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} + +# # Fetch Invoices +# cursor.callproc('GetInvoicesAndGSTReleasesByContractor', [contractor_id]) +# for result in cursor.stored_results(): +# invoices = result.fetchall() + +# # Fetch Hold Amounts +# cursor.callproc('GetHoldAmountsByContractors', [contractor_id]) +# for result in cursor.stored_results(): +# hold_amounts = result.fetchall() +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] + +# # Extract PMC numbers +# pmc_numbers = tuple(set(inv['PMC_No'] for inv in invoices if inv['PMC_No'] is not None)) + +# payments_map = {} +# extra_payments_map = {} +# if pmc_numbers: +# pmc_list_str = ','.join(str(pmc) for pmc in pmc_numbers) +# cursor.callproc('GetPaymentsByPmcNosWithInvoice', [pmc_list_str]) +# for result in cursor.stored_results(): +# payments = result.fetchall() +# for pay in payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# payments_map.setdefault(key, []).append(pay) + +# cursor.callproc('GetExtraPaymentsByPmcNos', [pmc_list_str]) +# for result in cursor.stored_results(): +# extra_payments = result.fetchall() +# for pay in extra_payments: +# extra_payments_map.setdefault(pay['pmc_no'], []).append(pay) + +# # Create Excel Workbook +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "Contractor Report" + +# # Write Contractor Info +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["State", contInfo["State_Name"]]) +# sheet.append(["District", contInfo["District_Name"]]) +# sheet.append(["Block", contInfo["Block_Name"]]) +# sheet.append(["Mobile No", contInfo["Mobile_No"]]) +# sheet.append(["GST Type", contInfo["GST_Registration_Type"]]) +# sheet.append(["GST No", contInfo["GST_No"]]) +# sheet.append(["PAN No", contInfo["PAN_No"]]) +# sheet.append(["Email", contInfo["Email"]]) +# sheet.append(["Address", contInfo["Address"]]) +# sheet.append([]) + +# # Table Headers +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] +# hold_headers = [ht['hold_type'] for ht in hold_types] +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] +# all_headers = base_headers + hold_headers + payment_headers + +# sheet.append(all_headers) + +# # Style the headers +# header_fill = PatternFill(start_color="ADD8E6", end_color="ADD8E6", fill_type="solid") +# header_font = Font(bold=True) +# for cell in sheet[sheet.max_row]: +# cell.font = header_font +# cell.fill = header_fill + +# seen_invoices = set() +# seen_gst_notes = set() +# processed_payments = set() +# pmc_groups = {} +# for inv in invoices: +# pmc_groups.setdefault(inv["PMC_No"], []).append(inv) + +# for pmc_no, pmc_invoices in pmc_groups.items(): +# for inv in pmc_invoices: +# invoice_no = inv["Invoice_No"] +# payments = payments_map.get((pmc_no, invoice_no), []) + +# if (pmc_no, invoice_no) not in seen_invoices: +# seen_invoices.add((pmc_no, invoice_no)) +# first_payment = payments[0] if payments else None +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map: +# row.append(invoice_holds.get(ht_id, "")) + +# row += [ +# inv["Final_Amount"], +# first_payment["Payment_Amount"] if first_payment else "", +# first_payment["TDS_Payment_Amount"] if first_payment else "", +# first_payment["Total_amount"] if first_payment else "", +# first_payment["UTR"] if first_payment else "" +# ] +# sheet.append(row) +# if first_payment: +# payment_id = f"{pmc_no}-{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}" +# processed_payments.add(payment_id) + +# # GST Notes +# if inv["gst_pmc_no"] and (inv["gst_pmc_no"], inv["gst_invoice_no"]) not in seen_gst_notes: +# seen_gst_notes.add((inv["gst_pmc_no"], inv["gst_invoice_no"])) +# gst_payment = None +# for payment in payments[1:]: +# if payment['invoice_no'] == inv["gst_invoice_no"]: +# gst_payment = payment +# break +# row = [pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], +# inv["gst_basic_amount"], "", "", "", "", "", "", "", "", ""] +# row += ["" for _ in hold_headers] +# row += [ +# inv["gst_final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["UTR"] if gst_payment else "" +# ] +# sheet.append(row) +# if gst_payment: +# payment_id = f"{pmc_no}-{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}" +# processed_payments.add(payment_id) + +# for payment in payments[1:]: +# payment_id = f"{pmc_no}-{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [pmc_no, "", "", "", "", payment['invoice_no'], "", "", "", "", "", "", "", "", "", ""] +# row += ["" for _ in hold_headers] +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# sheet.append(row) +# processed_payments.add(payment_id) + +# # Extra payments (null invoice) +# for payment in extra_payments_map.get(pmc_no, []): +# payment_id = f"{pmc_no}-null-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [pmc_no, "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] +# row += ["" for _ in hold_headers] +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# sheet.append(row) +# processed_payments.add(payment_id) + +# # Totals Calculation +# total_basic_amount = total_tds_amount = total_sd_amount = total_on_commission = 0 +# total_hold_amount = total_final_amount = total_total_amount = 0 + +# for row in sheet.iter_rows(min_row=13, max_row=sheet.max_row, values_only=True): +# try: +# total_basic_amount += float(row[6] or 0) +# total_tds_amount += float(row[11] or 0) +# total_sd_amount += float(row[12] or 0) +# total_on_commission += float(row[13] or 0) +# total_final_amount += float(row[-5] or 0) +# total_total_amount += float(row[-2] or 0) +# hold_start_col = len(base_headers) +# hold_end_col = hold_start_col + len(hold_headers) +# total_hold_amount += sum(float(row[i] or 0) for i in range(hold_start_col, hold_end_col)) +# except ValueError: +# continue + +# # Totals Row +# sheet.append([]) +# totals_row = [ +# "TOTAL", "", "", "", "", "", total_basic_amount, "", "", "", "", total_tds_amount, +# total_sd_amount, total_on_commission, "", "" +# ] +# if total_hold_amount: +# totals_row += [total_hold_amount] + [""] * (len(hold_headers) - 1) + +# totals_row += [total_final_amount, "", "", total_total_amount, ""] +# sheet.append(totals_row) + +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) + +# # Summary Section +# today_date = datetime.today().strftime('%A, %Y-%m-%d') +# sheet.append([]) +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["Date", today_date]) +# sheet.append(["Description", "Amount"]) +# sheet.append(["Advance/Surplus", str(total_final_amount - total_total_amount)]) +# sheet.append(["Total Hold Amount", str(Decimal(total_hold_amount))]) +# sheet.append(["Amount With TDS", str(total_tds_amount)]) + +# # Auto adjust column widths +# for col in sheet.columns: +# max_length = 0 +# col_letter = openpyxl.utils.get_column_letter(col[0].column) +# for cell in col: +# try: +# if cell.value: +# max_length = max(max_length, len(str(cell.value))) +# except: +# pass +# sheet.column_dimensions[col_letter].width = max_length + 2 + +# workbook.save(output_file) +# workbook.close() + +# finally: +# cursor.close() +# connection.close() + +# return send_from_directory(output_folder, f"Contractor_Report_{contractor_id}.xlsx", as_attachment=True) +from flask import send_from_directory +from decimal import Decimal +from datetime import datetime +import os +import openpyxl +from openpyxl.styles import Font, PatternFill +import config + + +# @app.route('/download_report/') +# def download_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True, buffered=True) +# +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"Contractor_Report_{contractor_id}.xlsx") +# os.makedirs(output_folder, exist_ok=True) +# +# try: +# # Contractor Info +# cursor.execute(""" +# SELECT DISTINCT s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, +# s.Mobile_No, s.GST_Registration_Type, s.GST_No, s.PAN_No, s.Email, s.Address +# FROM subcontractors s +# LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id +# LEFT JOIN villages v ON asg.Village_Id = v.Village_Id +# LEFT JOIN blocks b ON v.Block_Id = b.Block_Id +# LEFT JOIN districts d ON b.District_id = d.District_id +# LEFT JOIN states st ON d.State_Id = st.State_Id +# WHERE s.Contractor_Id = %s +# """, (contractor_id,)) +# contInfo = cursor.fetchone() +# if not contInfo: +# return "No contractor found", 404 +# +# # Hold Types +# cursor.execute(""" +# SELECT DISTINCT ht.hold_type_id, ht.hold_type +# FROM invoice_subcontractor_hold_join h +# JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# JOIN invoice i ON h.Invoice_Id = i.Invoice_Id +# WHERE h.Contractor_Id = %s +# """, (contractor_id,)) +# hold_types = cursor.fetchall() +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} +# +# # Invoices +# cursor.execute(""" +# SELECT DISTINCT i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, +# i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, +# i.After_Debit_Amount, i.GST_Amount, i.Amount, i.TDS_Amount, i.SD_Amount, +# i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, +# i.Final_Amount, i.Invoice_Id +# FROM assign_subcontractors asg +# INNER JOIN villages v ON asg.Village_Id = v.Village_Id +# INNER JOIN invoice i ON i.Village_Id = v.Village_Id AND i.PMC_No = asg.PMC_No +# WHERE asg.Contractor_Id = %s +# ORDER BY i.PMC_No ASC, i.Invoice_No ASC +# """, (contractor_id,)) +# invoices = cursor.fetchall() +# +# # Hold Amounts +# cursor.execute(""" +# SELECT h.Invoice_Id, h.hold_type_id, h.hold_amount +# FROM invoice_subcontractor_hold_join h +# JOIN invoice i ON h.Invoice_Id = i.Invoice_Id +# WHERE h.Contractor_Id = %s +# """, (contractor_id,)) +# hold_amounts = cursor.fetchall() +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] +# +# # GST Release query - Modified to get all GST releases for the contractor +# cursor.execute(""" +# SELECT gr.pmc_no, gr.invoice_no, gr.basic_amount, gr.final_amount +# FROM gst_release gr +# WHERE gr.pmc_no IN ( +# SELECT DISTINCT a.PMC_No +# FROM assign_subcontractors a +# WHERE a.Contractor_Id = %s +# ) +# ORDER BY gr.pmc_no ASC +# """, (contractor_id,)) +# gst_rel = cursor.fetchall() +# +# gst_rel_map = {} +# for gr in gst_rel: +# invoice_nos = [] +# if gr['invoice_no']: +# if ',' in gr['invoice_no']: +# invoice_nos = [x.strip() for x in gr['invoice_no'].replace(' ', '').split(',')] +# elif '&' in gr['invoice_no']: +# invoice_nos = [x.strip() for x in gr['invoice_no'].split('&')] +# else: +# invoice_nos = [gr['invoice_no'].strip()] +# +# # Map each individual invoice to the GST release +# for inv_no in invoice_nos: +# key = (gr['pmc_no'], inv_no) +# if key not in gst_rel_map: +# gst_rel_map[key] = { +# 'basic_amount': gr['basic_amount'], +# 'final_amount': gr['final_amount'], +# 'invoice_no': gr['invoice_no'], +# 'all_invoice_nos': invoice_nos +# } +# +# # Also map the combined invoice number if it's a combined release +# if len(invoice_nos) > 1: +# combined_key = (gr['pmc_no'], gr['invoice_no']) +# gst_rel_map[combined_key] = { +# 'basic_amount': gr['basic_amount'], +# 'final_amount': gr['final_amount'], +# 'invoice_no': gr['invoice_no'], +# 'all_invoice_nos': invoice_nos +# } +# +# # GST Release Payments - Updated to include Payment_Amount and TDS_Payment_Amount +# cursor.execute(""" +# SELECT p.pmc_no, p.invoice_no, p.Payment_Amount, p.TDS_Payment_Amount, p.Total_amount, p.utr +# FROM payment p +# JOIN gst_release gr ON p.pmc_no = gr.pmc_no AND ( +# p.invoice_no = gr.invoice_no +# OR (gr.invoice_no LIKE '%,%' AND FIND_IN_SET(p.invoice_no, REPLACE(gr.invoice_no, ' ', '')) > 0) +# OR (gr.invoice_no LIKE '%&%' AND ( +# p.invoice_no = SUBSTRING_INDEX(gr.invoice_no, '&', 1) +# OR p.invoice_no = SUBSTRING_INDEX(gr.invoice_no, '&', -1) +# OR (gr.invoice_no LIKE '%&%&%' AND p.invoice_no = SUBSTRING_INDEX(SUBSTRING_INDEX(gr.invoice_no, '&', 2), '&', -1)) +# )) +# ) +# WHERE gr.pmc_no IN ( +# SELECT DISTINCT i.PMC_No +# FROM invoice i +# JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No AND i.Village_Id = a.Village_Id +# WHERE a.Contractor_Id = %s +# ) +# AND p.Total_amount != 0 +# """, (contractor_id,)) +# gst_payments = cursor.fetchall() +# +# gst_payment_map = {} +# for pay in gst_payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# gst_payment_map[key] = { +# 'Payment_Amount': pay['Payment_Amount'], +# 'TDS_Payment_Amount': pay['TDS_Payment_Amount'], +# 'Total_amount': pay['Total_amount'], +# 'utr': pay['utr'] +# } +# # Also map to the combined invoice number if it exists +# for gr_key, gr_val in gst_rel_map.items(): +# if pay['pmc_no'] == gr_key[0] and pay['invoice_no'] in gr_val['all_invoice_nos']: +# combined_key = (pay['pmc_no'], gr_val['invoice_no']) +# gst_payment_map[combined_key] = { +# 'Payment_Amount': pay['Payment_Amount'], +# 'TDS_Payment_Amount': pay['TDS_Payment_Amount'], +# 'Total_amount': pay['Total_amount'], +# 'utr': pay['utr'] +# } +# +# # Invoice Payments - Updated to include Payment_Amount and TDS_Payment_Amount +# cursor.execute(""" +# SELECT p.pmc_no, p.invoice_no, p.Payment_Amount, p.TDS_Payment_Amount, p.Total_amount, p.utr +# FROM payment p +# INNER JOIN ( +# SELECT DISTINCT i.PMC_No, i.Invoice_No +# FROM invoice i +# JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No AND i.Village_Id = a.Village_Id +# WHERE a.Contractor_Id = %s +# ) x ON p.pmc_no = x.PMC_No AND p.invoice_no = x.Invoice_No +# ORDER BY p.pmc_no ASC +# """, (contractor_id,)) +# payments = cursor.fetchall() +# payments_map = {} +# for pay in payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# payments_map.setdefault(key, []).append({ +# 'Payment_Amount': pay['Payment_Amount'], +# 'TDS_Payment_Amount': pay['TDS_Payment_Amount'], +# 'Total_amount': pay['Total_amount'], +# 'utr': pay['utr'] +# }) +# +# # Extra Payments (no invoice_no) - Updated to include Payment_Amount and TDS_Payment_Amount +# cursor.execute(""" +# SELECT pmc_no, Payment_Amount, TDS_Payment_Amount, Total_amount, utr +# FROM payment +# WHERE (invoice_no IS NULL OR invoice_no = '') +# AND Total_amount != 0 +# AND pmc_no IS NOT NULL +# """) +# extra_payments_raw = cursor.fetchall() +# extra_payments_map = {} +# for pay in extra_payments_raw: +# extra_payments_map.setdefault(pay['pmc_no'], []).append({ +# 'Payment_Amount': pay['Payment_Amount'], +# 'TDS_Payment_Amount': pay['TDS_Payment_Amount'], +# 'Total_amount': pay['Total_amount'], +# 'utr': pay['utr'] +# }) +# +# # Credit Note +# # Credit Note Fetch +# cursor.execute(""" +# SELECT PMC_No, Invoice_Details, Basic_Amount, Debit_Amount, After_Debit_Amount, +# GST_Amount, Amount, Final_Amount, Payment_Amount, Total_Amount, UTR, Invoice_No +# FROM credit_note +# WHERE Contractor_Id = %s +# """, (contractor_id,)) +# +# credit_notes = cursor.fetchall() +# +# # Build map by (PMC_No, Invoice_No) +# credit_note_map = {} +# for cn in credit_notes: +# key = (cn["PMC_No"], cn["Invoice_No"]) # Use correct casing! +# credit_note_map.setdefault(key, []).append(cn) +# +# # Track already appended credit notes +# appended_credit_keys = set() +# +# # Excel Workbook +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "Contractor Report" +# +# # Contractor Info section +# for field, value in contInfo.items(): +# sheet.append([field.replace("_", " "), value]) +# sheet.append([]) +# +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] +# hold_headers = [ht['hold_type'] for ht in hold_types] +# # Updated payment headers to include Payment Amount and TDS Payment +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] +# all_headers = base_headers + hold_headers + payment_headers +# sheet.append(all_headers) +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# cell.fill = PatternFill(start_color="ADD8E6", end_color="ADD8E6", fill_type="solid") +# +# # Track which GST releases we've already processed +# processed_gst_releases = set() +# +# # Data Rows +# for inv in invoices: +# pmc_no = inv["PMC_No"] +# invoice_no = inv["Invoice_No"] +# +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] +# +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map: +# row.append(invoice_holds.get(ht_id, "")) +# +# payment = payments_map.get((pmc_no, invoice_no), [None])[0] +# row += [ +# inv["Final_Amount"], +# payment["Payment_Amount"] if payment else "", +# payment["TDS_Payment_Amount"] if payment else "", +# payment["Total_amount"] if payment else "", +# payment["utr"] if payment and payment["utr"] else "" +# ] +# sheet.append(row) +# +# # GST Release row - only show after the last invoice in the sequence +# if (pmc_no, invoice_no) in gst_rel_map: +# gr = gst_rel_map[(pmc_no, invoice_no)] +# +# # Check if this is the last invoice in the sequence +# if invoice_no == gr['all_invoice_nos'][-1] and gr['invoice_no'] not in processed_gst_releases: +# processed_gst_releases.add(gr['invoice_no']) +# +# # Find matching payment if it exists +# gst_payment = gst_payment_map.get((pmc_no, gr['invoice_no']), None) +# if not gst_payment: +# # Try matching with individual invoice numbers +# for inv_no in gr['all_invoice_nos']: +# if (pmc_no, inv_no) in gst_payment_map: +# gst_payment = gst_payment_map[(pmc_no, inv_no)] +# break +# +# gst_row = [ +# pmc_no, "", "", "GST Release Note", "", gr["invoice_no"], +# gr["basic_amount"], "", "", "", "", "", "", "", "", "" +# ] +# gst_row += ["" for _ in hold_headers] +# gst_row += [ +# gr["final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["utr"] if gst_payment and gst_payment.get("utr") else "" +# ] +# sheet.append(gst_row) +# +# # Extra Payments (once per pmc_no) +# if pmc_no in extra_payments_map: +# for extra in extra_payments_map[pmc_no]: +# extra_row = [ +# pmc_no, "", "", " ", "", "", "", "", "", "", "", "", "", "", "", "" +# ] +# extra_row += ["" for _ in hold_headers] +# extra_row += [ +# "", +# extra['Payment_Amount'], +# extra['TDS_Payment_Amount'], +# extra['Total_amount'], +# extra['utr'] if extra['utr'] else "" +# ] +# sheet.append(extra_row) +# del extra_payments_map[pmc_no] +# +# # Now add any GST releases that weren't associated with any invoices +# for gr in gst_rel: +# if gr['invoice_no'] not in processed_gst_releases: +# pmc_no = gr['pmc_no'] +# invoice_no = gr['invoice_no'] +# +# # Find matching payment if it exists +# gst_payment = gst_payment_map.get((pmc_no, invoice_no), None) +# +# gst_row = [ +# pmc_no, "", "", "GST Release Note", "", invoice_no, +# gr["basic_amount"], "", "", "", "", "", "", "", "", "" +# ] +# gst_row += ["" for _ in hold_headers] +# gst_row += [ +# gr["final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["utr"] if gst_payment and gst_payment.get("utr") else "" +# ] +# sheet.append(gst_row) +# processed_gst_releases.add(invoice_no) +# # Credit Note row(s) +# +# # Track already appended credit notes +# appended_credit_keys = set() +# +# # While writing invoices +# key = (pmc_no, invoice_no) +# if key in credit_note_map and key not in appended_credit_keys: +# for cn in credit_note_map[key]: +# credit_row = [ +# pmc_no, "", "", cn.get("Invoice_Details", "Credit Note"), "", cn.get("Invoice_No", ""), +# cn.get("Basic_Amount", ""), cn.get("Debit_Amount", ""), +# cn.get("After_Debit_Amount", ""), cn.get("GST_Amount", ""), cn.get("Amount", ""), "", "", +# "", +# "", "" +# ] +# credit_row += ["" for _ in hold_headers] +# credit_row += [ +# cn.get("Final_Amount", ""), +# cn.get("Total_Amount", ""), +# cn.get("UTR", "") +# ] +# sheet.append(credit_row) +# appended_credit_keys.add(key) +# +# # Totals row (NO UTR totals, UTR blank) +# total_basic_amount = total_tds_amount = total_sd_amount = total_on_commission = 0 +# total_final_amount = total_total_amount = total_hold_amount = 0 +# for row in sheet.iter_rows(min_row=13, max_row=sheet.max_row, values_only=True): +# try: +# desc = row[3] +# if desc == " ": +# total_total_amount += float(row[-2] or 0) +# continue +# +# total_basic_amount += float(row[6] or 0) +# total_tds_amount += float(row[11] or 0) +# total_sd_amount += float(row[12] or 0) +# total_on_commission += float(row[13] or 0) +# total_final_amount += float(row[-5] or 0) # Changed to -5 for Final Amount +# total_total_amount += float(row[-2] or 0) +# # sum holds +# total_hold_amount += sum( +# float(row[i] or 0) for i in range(len(base_headers), len(base_headers) + len(hold_headers))) +# except Exception: +# pass +# +# totals_row = [ +# "Total", "", "", "", "", "", total_basic_amount, "", "", "", "", total_tds_amount, +# total_sd_amount, total_on_commission, "", "" +# ] +# totals_row += [total_hold_amount for _ in hold_headers] +# totals_row += [total_final_amount, "", "", total_total_amount, +# ""] # UTR blank, Payment Amount and TDS Payment blank +# sheet.append([]) +# sheet.append(totals_row) +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# +# # Summary Section +# today_date = datetime.today().strftime('%A, %Y-%m-%d') +# sheet.append([]) +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["Date", today_date]) +# sheet.append(["Description", "Amount"]) +# sheet.append(["Advance/Surplus", str(total_final_amount - total_total_amount)]) +# sheet.append(["Total Hold Amount", str(Decimal(total_hold_amount))]) +# sheet.append(["Amount With TDS", str(total_tds_amount)]) +# +# # Auto adjust column widths +# for col in sheet.columns: +# max_length = 0 +# col_letter = openpyxl.utils.get_column_letter(col[0].column) +# for cell in col: +# try: +# if cell.value: +# max_length = max(max_length, len(str(cell.value))) +# except: +# pass +# sheet.column_dimensions[col_letter].width = max_length + 2 +# +# workbook.save(output_file) +# workbook.close() +# +# finally: +# cursor.close() +# connection.close() +# +# return send_from_directory(output_folder, f"Contractor_Report_{contractor_id}.xlsx", as_attachment=True) +@app.route('/download_report/') +def download_report(contractor_id): + connection = config.get_db_connection() + cursor = connection.cursor(dictionary=True, buffered=True) + + output_folder = "static/download" + output_file = os.path.join(output_folder, f"Contractor_Report_{contractor_id}.xlsx") + os.makedirs(output_folder, exist_ok=True) + + try: + # Contractor Info + cursor.execute(""" + SELECT DISTINCT s.Contractor_Name, + st.State_Name, + d.District_Name, + b.Block_Name, + s.Mobile_No, + s.GST_Registration_Type, + s.GST_No, + s.PAN_No, + s.Email, + s.Address + FROM subcontractors s + LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id + LEFT JOIN villages v ON asg.Village_Id = v.Village_Id + LEFT JOIN blocks b ON v.Block_Id = b.Block_Id + LEFT JOIN districts d ON b.District_id = d.District_id + LEFT JOIN states st ON d.State_Id = st.State_Id + WHERE s.Contractor_Id = %s + """, (contractor_id,)) + contInfo = cursor.fetchone() + if not contInfo: + return "No contractor found", 404 + + # Hold Types + cursor.execute(""" + SELECT DISTINCT ht.hold_type_id, ht.hold_type + FROM invoice_subcontractor_hold_join h + JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id + JOIN invoice i ON h.Invoice_Id = i.Invoice_Id + WHERE h.Contractor_Id = %s + """, (contractor_id,)) + hold_types = cursor.fetchall() + hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} + + # Invoices + cursor.execute(""" + SELECT DISTINCT i.PMC_No, + v.Village_Name, + i.Work_Type, + i.Invoice_Details, + i.Invoice_Date, + i.Invoice_No, + i.Basic_Amount, + i.Debit_Amount, + i.After_Debit_Amount, + i.GST_Amount, + i.Amount, + i.TDS_Amount, + i.SD_Amount, + i.On_Commission, + i.Hydro_Testing, + i.GST_SD_Amount, + i.Final_Amount, + i.Invoice_Id + FROM assign_subcontractors asg + INNER JOIN villages v ON asg.Village_Id = v.Village_Id + INNER JOIN invoice i ON i.Village_Id = v.Village_Id AND i.PMC_No = asg.PMC_No + WHERE asg.Contractor_Id = %s + ORDER BY i.PMC_No ASC, i.Invoice_No ASC + """, (contractor_id,)) + invoices = cursor.fetchall() + + # Hold Amounts + cursor.execute(""" + SELECT h.Invoice_Id, h.hold_type_id, h.hold_amount + FROM invoice_subcontractor_hold_join h + JOIN invoice i ON h.Invoice_Id = i.Invoice_Id + WHERE h.Contractor_Id = %s + """, (contractor_id,)) + hold_amounts = cursor.fetchall() + hold_data = {} + for h in hold_amounts: + hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] + + # GST Release query - Modified to get all GST releases for the contractor + cursor.execute(""" + SELECT gr.pmc_no, gr.invoice_no, gr.basic_amount, gr.final_amount + FROM gst_release gr + WHERE gr.pmc_no IN (SELECT DISTINCT a.PMC_No + FROM assign_subcontractors a + WHERE a.Contractor_Id = %s) + ORDER BY gr.pmc_no ASC + """, (contractor_id,)) + gst_rel = cursor.fetchall() + + gst_rel_map = {} + for gr in gst_rel: + invoice_nos = [] + if gr['invoice_no']: + if ',' in gr['invoice_no']: + invoice_nos = [x.strip() for x in gr['invoice_no'].replace(' ', '').split(',')] + elif '&' in gr['invoice_no']: + invoice_nos = [x.strip() for x in gr['invoice_no'].split('&')] + else: + invoice_nos = [gr['invoice_no'].strip()] + + # Map each individual invoice to the GST release + for inv_no in invoice_nos: + key = (gr['pmc_no'], inv_no) + if key not in gst_rel_map: + gst_rel_map[key] = { + 'basic_amount': gr['basic_amount'], + 'final_amount': gr['final_amount'], + 'invoice_no': gr['invoice_no'], + 'all_invoice_nos': invoice_nos + } + + # Also map the combined invoice number if it's a combined release + if len(invoice_nos) > 1: + combined_key = (gr['pmc_no'], gr['invoice_no']) + gst_rel_map[combined_key] = { + 'basic_amount': gr['basic_amount'], + 'final_amount': gr['final_amount'], + 'invoice_no': gr['invoice_no'], + 'all_invoice_nos': invoice_nos + } + + # GST Release Payments - Updated to include Payment_Amount and TDS_Payment_Amount + cursor.execute(""" + SELECT p.pmc_no, p.invoice_no, p.Payment_Amount, p.TDS_Payment_Amount, p.Total_amount, p.utr + FROM payment p + JOIN gst_release gr ON p.pmc_no = gr.pmc_no AND ( + p.invoice_no = gr.invoice_no + OR + (gr.invoice_no LIKE '%,%' AND FIND_IN_SET(p.invoice_no, REPLACE(gr.invoice_no, ' ', '')) > 0) + OR (gr.invoice_no LIKE '%&%' AND ( + p.invoice_no = SUBSTRING_INDEX(gr.invoice_no, '&', 1) + OR p.invoice_no = SUBSTRING_INDEX(gr.invoice_no, '&', -1) + OR (gr.invoice_no LIKE '%&%&%' AND + p.invoice_no = SUBSTRING_INDEX(SUBSTRING_INDEX(gr.invoice_no, '&', 2), '&', -1)) + )) + ) + WHERE gr.pmc_no IN (SELECT DISTINCT i.PMC_No + FROM invoice i + JOIN assign_subcontractors a + ON i.PMC_No = a.PMC_No AND i.Village_Id = a.Village_Id + WHERE a.Contractor_Id = %s) + AND p.Total_amount != 0 + """, (contractor_id,)) + gst_payments = cursor.fetchall() + + gst_payment_map = {} + for pay in gst_payments: + key = (pay['pmc_no'], pay['invoice_no']) + gst_payment_map[key] = { + 'Payment_Amount': pay['Payment_Amount'], + 'TDS_Payment_Amount': pay['TDS_Payment_Amount'], + 'Total_amount': pay['Total_amount'], + 'utr': pay['utr'] + } + # Also map to the combined invoice number if it exists + for gr_key, gr_val in gst_rel_map.items(): + if pay['pmc_no'] == gr_key[0] and pay['invoice_no'] in gr_val['all_invoice_nos']: + combined_key = (pay['pmc_no'], gr_val['invoice_no']) + gst_payment_map[combined_key] = { + 'Payment_Amount': pay['Payment_Amount'], + 'TDS_Payment_Amount': pay['TDS_Payment_Amount'], + 'Total_amount': pay['Total_amount'], + 'utr': pay['utr'] + } + + # Invoice Payments - Updated to include Payment_Amount and TDS_Payment_Amount + cursor.execute(""" + SELECT p.pmc_no, p.invoice_no, p.Payment_Amount, p.TDS_Payment_Amount, p.Total_amount, p.utr + FROM payment p + INNER JOIN (SELECT DISTINCT i.PMC_No, i.Invoice_No + FROM invoice i + JOIN assign_subcontractors a + ON i.PMC_No = a.PMC_No AND i.Village_Id = a.Village_Id + WHERE a.Contractor_Id = %s) x + ON p.pmc_no = x.PMC_No AND p.invoice_no = x.Invoice_No + ORDER BY p.pmc_no ASC + """, (contractor_id,)) + payments = cursor.fetchall() + payments_map = {} + for pay in payments: + key = (pay['pmc_no'], pay['invoice_no']) + payments_map.setdefault(key, []).append({ + 'Payment_Amount': pay['Payment_Amount'], + 'TDS_Payment_Amount': pay['TDS_Payment_Amount'], + 'Total_amount': pay['Total_amount'], + 'utr': pay['utr'] + }) + # Fetch hold_release data + cursor.execute(""" + SELECT * + FROM hold_release + WHERE Contractor_Id = %s + """, (contractor_id,)) + hold_releases = cursor.fetchall() + hold_release_map = {} + for hr in hold_releases: + invoice_nos = [i.strip() for i in str(hr['Invoice_No']).split('&')] + for inv_no in invoice_nos: + key = (hr['PMC_No'], inv_no) + hold_release_map.setdefault(key, []).append(hr) + # Credit Note + # Credit Note Fetch + cursor.execute(""" + SELECT PMC_No, + Invoice_Details, + Basic_Amount, + Debit_Amount, + After_Debit_Amount, + GST_Amount, + Amount, + Final_Amount, + Payment_Amount, + Total_Amount, + UTR, + Invoice_No + FROM credit_note + WHERE Contractor_Id = %s + """, (contractor_id,)) + + credit_notes = cursor.fetchall() + + # Build map by (PMC_No, Invoice_No) + credit_note_map = {} + for cn in credit_notes: + key = (cn["PMC_No"], cn["Invoice_No"]) # Use correct casing! + credit_note_map.setdefault(key, []).append(cn) + print("Credit_note_map:",credit_note_map) + # Track already appended credit notes + appended_credit_keys = set() + #print("appended_credit_keys",appended_credit_keys) + + + # Extra Payments (no invoice_no) - Updated to include Payment_Amount and TDS_Payment_Amount + cursor.execute(""" + SELECT pmc_no, Payment_Amount, TDS_Payment_Amount, Total_amount, utr + FROM payment + WHERE (invoice_no IS NULL OR invoice_no = '') + AND Total_amount != 0 + AND pmc_no IS NOT NULL + """) + extra_payments_raw = cursor.fetchall() + extra_payments_map = {} + for pay in extra_payments_raw: + extra_payments_map.setdefault(pay['pmc_no'], []).append({ + 'Payment_Amount': pay['Payment_Amount'], + 'TDS_Payment_Amount': pay['TDS_Payment_Amount'], + 'Total_amount': pay['Total_amount'], + 'utr': pay['utr'] + }) + + # Excel Workbook + workbook = openpyxl.Workbook() + sheet = workbook.active + sheet.title = "Contractor Report" + + # Contractor Info section + for field, value in contInfo.items(): + sheet.append([field.replace("_", " "), value]) + sheet.append([]) + + base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", + "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", + "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] + hold_headers = [ht['hold_type'] for ht in hold_types] + # Updated payment headers to include Payment Amount and TDS Payment + payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] + all_headers = base_headers + hold_headers + payment_headers + sheet.append(all_headers) + for cell in sheet[sheet.max_row]: + cell.font = Font(bold=True) + cell.fill = PatternFill(start_color="ADD8E6", end_color="ADD8E6", fill_type="solid") + + # Track which GST releases we've already processed + processed_gst_releases = set() + + # Data Rows + for inv in invoices: + pmc_no = inv["PMC_No"] + invoice_no = inv["Invoice_No"] + + row = [ + pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], + inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], + inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], + inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] + ] + + invoice_holds = hold_data.get(inv["Invoice_Id"], {}) + for ht_id in hold_type_map: + row.append(invoice_holds.get(ht_id, "")) + + payment = payments_map.get((pmc_no, invoice_no), [None])[0] + row += [ + inv["Final_Amount"], + payment["Payment_Amount"] if payment else "", + payment["TDS_Payment_Amount"] if payment else "", + payment["Total_amount"] if payment else "", + payment["utr"] if payment and payment["utr"] else "" + ] + sheet.append(row) + + # GST Release row - only show after the last invoice in the sequence + if (pmc_no, invoice_no) in gst_rel_map: + gr = gst_rel_map[(pmc_no, invoice_no)] + + # Check if this is the last invoice in the sequence + if invoice_no == gr['all_invoice_nos'][-1] and gr['invoice_no'] not in processed_gst_releases: + processed_gst_releases.add(gr['invoice_no']) + + # Find matching payment if it exists + gst_payment = gst_payment_map.get((pmc_no, gr['invoice_no']), None) + if not gst_payment: + # Try matching with individual invoice numbers + for inv_no in gr['all_invoice_nos']: + if (pmc_no, inv_no) in gst_payment_map: + gst_payment = gst_payment_map[(pmc_no, inv_no)] + break + + gst_row = [ + pmc_no, "", "", "GST Release Note", "", gr["invoice_no"], + gr["basic_amount"], "", "", "", "", "", "", "", "", "" + ] + gst_row += ["" for _ in hold_headers] + gst_row += [ + gr["final_amount"], + gst_payment["Payment_Amount"] if gst_payment else "", + gst_payment["TDS_Payment_Amount"] if gst_payment else "", + gst_payment["Total_amount"] if gst_payment else "", + gst_payment["utr"] if gst_payment and gst_payment.get("utr") else "" + ] + sheet.append(gst_row) + # Hold Release row(s) + if (pmc_no, invoice_no) in hold_release_map: + for hr in hold_release_map[(pmc_no, invoice_no)]: + hr_row = [ + pmc_no, "", "", hr["Invoice_Details"], "", hr["Invoice_No"], + hr.get("Basic_Amount", ""), "", "", "", "", "", "", "", "", "","","" + ] + hr_row += ["" for _ in hold_headers] + hr_row += [ + hr.get("Final_Amount", ""), + hr.get("Total_Amount", ""), + hr.get("UTR", "") + ] + sheet.append(hr_row) + # Extra Payments (once per pmc_no) + if pmc_no in extra_payments_map: + for extra in extra_payments_map[pmc_no]: + extra_row = [ + pmc_no, "", "", " ", "", "", "", "", "", "", "", "", "", "", "", "" + ] + extra_row += ["" for _ in hold_headers] + extra_row += [ + "", + extra['Payment_Amount'], + extra['TDS_Payment_Amount'], + extra['Total_amount'], + extra['utr'] if extra['utr'] else "" + ] + sheet.append(extra_row) + del extra_payments_map[pmc_no] + + # Now add any GST releases that weren't associated with any invoices + for gr in gst_rel: + if gr['invoice_no'] not in processed_gst_releases: + pmc_no = gr['pmc_no'] + invoice_no = gr['invoice_no'] + + # Find matching payment if it exists + gst_payment = gst_payment_map.get((pmc_no, invoice_no), None) + + gst_row = [ + pmc_no, "", "", "GST Release Note", "", invoice_no, + gr["basic_amount"], "", "", "", "", "", "", "", "", "" + ] + gst_row += ["" for _ in hold_headers] + gst_row += [ + gr["final_amount"], + gst_payment["Payment_Amount"] if gst_payment else "", + gst_payment["TDS_Payment_Amount"] if gst_payment else "", + gst_payment["Total_amount"] if gst_payment else "", + gst_payment["utr"] if gst_payment and gst_payment.get("utr") else "" + ] + sheet.append(gst_row) + processed_gst_releases.add(invoice_no) + # Credit Note row(s) + + # # Track already appended credit notes + appended_credit_keys = set() + + sheet.append(row) + + # ➕ Add this block right here: + key = (pmc_no, invoice_no) + if key in credit_note_map and key not in appended_credit_keys: + for cn in credit_note_map[key]: + credit_row = [ + pmc_no, "", "", cn.get("Invoice_Details", "Credit Note"), "", cn.get("Invoice_No", ""), + cn.get("Basic_Amount", ""), cn.get("Debit_Amount", ""), + cn.get("After_Debit_Amount", ""), cn.get("GST_Amount", ""), cn.get("Amount", ""), "", "", "", + "", "" + ] + credit_row += ["" for _ in hold_headers] + credit_row += [ + cn.get("Final_Amount", ""), "", "", cn.get("Total_Amount", ""), + cn.get("UTR", "") + ] + sheet.append(credit_row) + appended_credit_keys.add(key) + + + + + # Totals row (NO UTR totals, UTR blank) + total_basic_amount = total_tds_amount = total_sd_amount = total_on_commission = 0 + total_final_amount = total_total_amount = total_hold_amount = 0 + for row in sheet.iter_rows(min_row=13, max_row=sheet.max_row, values_only=True): + try: + desc = row[3] + if desc == " ": + total_total_amount += float(row[-2] or 0) + continue + + total_basic_amount += float(row[6] or 0) + total_tds_amount += float(row[11] or 0) + total_sd_amount += float(row[12] or 0) + total_on_commission += float(row[13] or 0) + total_final_amount += float(row[-5] or 0) # Changed to -5 for Final Amount + total_total_amount += float(row[-2] or 0) + # sum holds + total_hold_amount += sum( + float(row[i] or 0) for i in range(len(base_headers), len(base_headers) + len(hold_headers))) + except Exception: + pass + + totals_row = [ + "Total", "", "", "", "", "", total_basic_amount, "", "", "", "", total_tds_amount, + total_sd_amount, total_on_commission, "", "" + ] + totals_row += [total_hold_amount for _ in hold_headers] + totals_row += [total_final_amount, "", "", total_total_amount, + ""] # UTR blank, Payment Amount and TDS Payment blank + sheet.append([]) + sheet.append(totals_row) + for cell in sheet[sheet.max_row]: + cell.font = Font(bold=True) + + # Summary Section + today_date = datetime.today().strftime('%A, %Y-%m-%d') + sheet.append([]) + sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) + sheet.append(["Date", today_date]) + sheet.append(["Description", "Amount"]) + sheet.append(["Advance/Surplus", str(total_final_amount - total_total_amount)]) + sheet.append(["Total Hold Amount", str(Decimal(total_hold_amount))]) + sheet.append(["Amount With TDS", str(total_tds_amount)]) + + # Auto adjust column widths + for col in sheet.columns: + max_length = 0 + col_letter = openpyxl.utils.get_column_letter(col[0].column) + for cell in col: + try: + if cell.value: + max_length = max(max_length, len(str(cell.value))) + except: + pass + sheet.column_dimensions[col_letter].width = max_length + 2 + + workbook.save(output_file) + workbook.close() + + finally: + cursor.close() + connection.close() + + return send_from_directory(output_folder, f"Contractor_Report_{contractor_id}.xlsx", as_attachment=True) +# @app.route('/download_report/') +# def download_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True, buffered=True) +# +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"Contractor_Report_{contractor_id}.xlsx") +# os.makedirs(output_folder, exist_ok=True) +# +# try: +# # Contractor Info +# cursor.execute(""" +# SELECT DISTINCT s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, +# s.Mobile_No, s.GST_Registration_Type, s.GST_No, s.PAN_No, s.Email, s.Address +# FROM subcontractors s +# LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id +# LEFT JOIN villages v ON asg.Village_Id = v.Village_Id +# LEFT JOIN blocks b ON v.Block_Id = b.Block_Id +# LEFT JOIN districts d ON b.District_id = d.District_id +# LEFT JOIN states st ON d.State_Id = st.State_Id +# WHERE s.Contractor_Id = %s +# """, (contractor_id,)) +# contInfo = cursor.fetchone() +# if not contInfo: +# return "No contractor found", 404 +# +# # Hold Types +# cursor.execute(""" +# SELECT DISTINCT ht.hold_type_id, ht.hold_type +# FROM invoice_subcontractor_hold_join h +# JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# JOIN invoice i ON h.Invoice_Id = i.Invoice_Id +# WHERE h.Contractor_Id = %s +# """, (contractor_id,)) +# hold_types = cursor.fetchall() +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} +# +# # Invoices +# cursor.execute(""" +# SELECT DISTINCT i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, +# i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, +# i.After_Debit_Amount, i.GST_Amount, i.Amount, i.TDS_Amount, i.SD_Amount, +# i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, +# i.Final_Amount, i.Invoice_Id +# FROM assign_subcontractors asg +# INNER JOIN villages v ON asg.Village_Id = v.Village_Id +# INNER JOIN invoice i ON i.Village_Id = v.Village_Id AND i.PMC_No = asg.PMC_No +# WHERE asg.Contractor_Id = %s +# ORDER BY i.PMC_No ASC +# """, (contractor_id,)) +# invoices = cursor.fetchall() +# +# # Hold Amounts +# cursor.execute(""" +# SELECT h.Invoice_Id, h.hold_type_id, h.hold_amount +# FROM invoice_subcontractor_hold_join h +# JOIN invoice i ON h.Invoice_Id = i.Invoice_Id +# WHERE h.Contractor_Id = %s +# """, (contractor_id,)) +# hold_amounts = cursor.fetchall() +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] +# +# # GST Release +# cursor.execute(""" +# SELECT gr.pmc_no, gr.invoice_no, gr.basic_amount, gr.final_amount +# FROM gst_release gr +# INNER JOIN ( +# SELECT DISTINCT i.PMC_No, i.Invoice_No +# FROM invoice i +# JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No AND i.Village_Id = a.Village_Id +# WHERE a.Contractor_Id = %s +# ) x ON gr.pmc_no = x.PMC_No AND gr.invoice_no = x.Invoice_No +# ORDER BY gr.pmc_no ASC +# """, (contractor_id,)) +# gst_rel = cursor.fetchall() +# gst_rel_map = {(gr['pmc_no'], gr['invoice_no']): gr for gr in gst_rel} +# # +# +# +# +# +# +# #Credit Note +# # Credit Note Fetch +# cursor.execute(""" +# SELECT PMC_No, Invoice_Details, Basic_Amount, Debit_Amount, After_Debit_Amount, +# GST_Amount, Amount, Final_Amount, Payment_Amount, Total_Amount, UTR, Invoice_No +# FROM credit_note +# WHERE Contractor_Id = %s +# """, (contractor_id,)) +# +# credit_notes = cursor.fetchall() +# +# # Build map by (PMC_No, Invoice_No) +# credit_note_map = {} +# for cn in credit_notes: +# key = (cn["PMC_No"], cn["Invoice_No"]) # Use correct casing! +# credit_note_map.setdefault(key, []).append(cn) +# +# # Track already appended credit notes +# appended_credit_keys = set() +# +# +# +# +# +# +# # Invoice Payments +# cursor.execute(""" +# SELECT p.pmc_no, p.invoice_no, p.Total_amount, p.utr +# FROM payment p +# INNER JOIN ( +# SELECT DISTINCT i.PMC_No, i.Invoice_No +# FROM invoice i +# JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No AND i.Village_Id = a.Village_Id +# WHERE a.Contractor_Id = %s +# ) x ON p.pmc_no = x.PMC_No AND p.invoice_no = x.Invoice_No +# ORDER BY p.pmc_no ASC +# """, (contractor_id,)) +# payments = cursor.fetchall() +# payments_map = {} +# for pay in payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# payments_map.setdefault(key, []).append(pay) +# +# #Credit Note Fetch----------------------------------------------------------------------------- +# +# +# # GST Release Payments +# cursor.execute(""" +# SELECT p.pmc_no, p.invoice_no, p.Total_amount, p.utr +# FROM payment p +# INNER JOIN gst_release gr ON p.pmc_no = gr.pmc_no AND p.invoice_no = gr.invoice_no +# WHERE gr.invoice_no IS NOT NULL AND gr.pmc_no IS NOT NULL +# AND p.Total_amount != 0 +# """) +# gst_payments = cursor.fetchall() +# gst_payment_map = {} +# for pay in gst_payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# gst_payment_map[key] = pay +# +# # Extra Payments (no invoice_no) +# cursor.execute(""" +# SELECT pmc_no, Total_amount, utr +# FROM payment +# WHERE (invoice_no IS NULL OR invoice_no = '') +# AND Total_amount != 0 +# AND pmc_no IS NOT NULL +# """) +# extra_payments_raw = cursor.fetchall() +# extra_payments_map = {} +# for pay in extra_payments_raw: +# extra_payments_map.setdefault(pay['pmc_no'], []).append(pay) +# +# # Excel Workbook +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "Contractor Report" +# +# # Contractor Info section +# for field, value in contInfo.items(): +# sheet.append([field.replace("_", " "), value]) +# sheet.append([]) +# +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] +# hold_headers = [ht['hold_type'] for ht in hold_types] +# payment_headers = ["Final Amount", "Total Paid", "UTR"] +# all_headers = base_headers + hold_headers + payment_headers +# sheet.append(all_headers) +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# cell.fill = PatternFill(start_color="ADD8E6", end_color="ADD8E6", fill_type="solid") +# +# # Data Rows +# for inv in invoices: +# pmc_no = inv["PMC_No"] +# invoice_no = inv["Invoice_No"] +# +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] +# +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map: +# row.append(invoice_holds.get(ht_id, "")) +# +# payment = payments_map.get((pmc_no, invoice_no), [None])[0] +# row += [ +# inv["Final_Amount"], +# payment["Total_amount"] if payment else "", +# payment["utr"] if payment and payment["utr"] else "" # UTR only display, no total +# ] +# sheet.append(row) +# +# # GST Release row +# if (pmc_no, invoice_no) in gst_rel_map: +# gr = gst_rel_map[(pmc_no, invoice_no)] +# gst_payment = gst_payment_map.get((pmc_no, invoice_no)) +# +# gst_row = [ +# pmc_no, "", "", "GST Release Note", "", gr["invoice_no"], +# gr["basic_amount"], "", "", "", "", "", "", "", "", "" +# ] +# gst_row += ["" for _ in hold_headers] +# gst_row += [ +# gr["final_amount"], +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["utr"] if gst_payment and gst_payment["utr"] else "" +# ] +# sheet.append(gst_row) +# # Credit Note row(s) +# +# # Track already appended credit notes +# appended_credit_keys = set() +# +# # While writing invoices +# key = (pmc_no, invoice_no) +# if key in credit_note_map and key not in appended_credit_keys: +# for cn in credit_note_map[key]: +# credit_row = [ +# pmc_no, "", "", cn.get("Invoice_Details", "Credit Note"), "", cn.get("Invoice_No",""), +# cn.get("Basic_Amount", ""), cn.get("Debit_Amount", ""), +# cn.get("After_Debit_Amount", ""), cn.get("GST_Amount", ""), cn.get("Amount", ""), "", "", "", +# "", "" +# ] +# credit_row += ["" for _ in hold_headers] +# credit_row += [ +# cn.get("Final_Amount", ""), +# cn.get("Total_Amount", ""), +# cn.get("UTR", "") +# ] +# sheet.append(credit_row) +# appended_credit_keys.add(key) +# +# +# # Extra Payments (once per pmc_no) +# if pmc_no in extra_payments_map: +# for extra in extra_payments_map[pmc_no]: +# extra_row = [ +# pmc_no, "", "", " ", "", "", "", "", "", "", "", "", "", "", "", "" +# ] +# extra_row += ["" for _ in hold_headers] +# extra_row += ["", extra['Total_amount'], extra['utr'] if extra['utr'] else ""] +# sheet.append(extra_row) +# del extra_payments_map[pmc_no] +# +# # Totals row (NO UTR totals, UTR blank) +# total_basic_amount = total_tds_amount = total_sd_amount = total_on_commission = 0 +# total_final_amount = total_total_amount = total_hold_amount = 0 +# for row in sheet.iter_rows(min_row=13, max_row=sheet.max_row, values_only=True): +# try: +# desc = row[3] +# if desc == " ": +# total_total_amount += float(row[-2] or 0) +# continue +# +# total_basic_amount += float(row[6] or 0) +# total_tds_amount += float(row[11] or 0) +# total_sd_amount += float(row[12] or 0) +# total_on_commission += float(row[13] or 0) +# total_final_amount += float(row[-3] or 0) +# total_total_amount += float(row[-2] or 0) +# # sum holds +# total_hold_amount += sum(float(row[i] or 0) for i in range(len(base_headers), len(base_headers) + len(hold_headers))) +# +# # DO NOT sum UTR column (row[-1]) — skip it +# except Exception: +# pass +# +# totals_row = [ +# "Total", "", "", "", "", "", total_basic_amount, "", "", "", "", total_tds_amount, +# total_sd_amount, total_on_commission, "", "" +# ] +# totals_row += [total_hold_amount for _ in hold_headers] +# totals_row += [total_final_amount, total_total_amount, ""] # UTR blank +# sheet.append([]) +# sheet.append(totals_row) +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# +# # Summary Section +# today_date = datetime.today().strftime('%A, %Y-%m-%d') +# sheet.append([]) +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["Date", today_date]) +# sheet.append(["Description", "Amount"]) +# sheet.append(["Advance/Surplus", str(total_final_amount - total_total_amount)]) +# sheet.append(["Total Hold Amount", str(Decimal(total_hold_amount))]) +# sheet.append(["Amount With TDS", str(total_tds_amount)]) +# +# # Auto adjust column widths +# for col in sheet.columns: +# max_length = 0 +# col_letter = openpyxl.utils.get_column_letter(col[0].column) +# for cell in col: +# try: +# if cell.value: +# max_length = max(max_length, len(str(cell.value))) +# except: +# pass +# sheet.column_dimensions[col_letter].width = max_length + 2 +# +# workbook.save(output_file) +# workbook.close() +# +# finally: +# cursor.close() +# connection.close() +# +# return send_from_directory(output_folder, f"Contractor_Report_{contractor_id}.xlsx", as_attachment=True) +# @app.route('/download_report/') +# def download_report(contractor_id): +# connection = config.get_db_connection() +# cursor = connection.cursor(dictionary=True) +# +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"Contractor_Report_{contractor_id}.xlsx") +# +# if not os.path.exists(output_folder): +# os.makedirs(output_folder) +# +# try: +# # Fetch Contractor Info +# cursor.callproc('GetContractorInfoId', [contractor_id]) +# for result in cursor.stored_results(): +# contInfo = result.fetchone() +# if not contInfo: +# return "No contractor found", 404 +# +# # Fetch Hold Types +# cursor.callproc('GetDistinctHoldTypesByContractor', [contractor_id]) +# for result in cursor.stored_results(): +# hold_types = result.fetchall() +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} +# +# # Fetch Invoices +# cursor.callproc('GetInvoicesAndGSTReleasesByContractor', [contractor_id]) +# for result in cursor.stored_results(): +# invoices = result.fetchall() +# +# # Fetch Hold Amounts +# cursor.callproc('GetHoldAmountsByContractors', [contractor_id]) +# for result in cursor.stored_results(): +# hold_amounts = result.fetchall() +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] +# +# # Extract PMC numbers +# pmc_numbers = tuple(set(inv['PMC_No'] for inv in invoices if inv['PMC_No'] is not None)) +# +# payments_map = {} +# extra_payments_map = {} +# if pmc_numbers: +# pmc_list_str = ','.join(str(pmc) for pmc in pmc_numbers) +# cursor.callproc('GetPaymentsByPmcNosWithInvoice', [pmc_list_str]) +# for result in cursor.stored_results(): +# payments = result.fetchall() +# for pay in payments: +# key = (pay['pmc_no'], pay['invoice_no']) +# payments_map.setdefault(key, []).append(pay) +# +# cursor.callproc('GetExtraPaymentsByPmcNos', [pmc_list_str]) +# for result in cursor.stored_results(): +# extra_payments = result.fetchall() +# for pay in extra_payments: +# extra_payments_map.setdefault(pay['pmc_no'], []).append(pay) +# +# # Create Excel Workbook +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "Contractor Report" +# +# # Write Contractor Info +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["State", contInfo["State_Name"]]) +# sheet.append(["District", contInfo["District_Name"]]) +# sheet.append(["Block", contInfo["Block_Name"]]) +# sheet.append(["Mobile No", contInfo["Mobile_No"]]) +# sheet.append(["GST Type", contInfo["GST_Registration_Type"]]) +# sheet.append(["GST No", contInfo["GST_No"]]) +# sheet.append(["PAN No", contInfo["PAN_No"]]) +# sheet.append(["Email", contInfo["Email"]]) +# sheet.append(["Address", contInfo["Address"]]) +# sheet.append([]) +# +# # Table Headers +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] +# hold_headers = [ht['hold_type'] for ht in hold_types] +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] +# all_headers = base_headers + hold_headers + payment_headers +# +# sheet.append(all_headers) +# +# # Style the headers +# header_fill = PatternFill(start_color="ADD8E6", end_color="ADD8E6", fill_type="solid") +# header_font = Font(bold=True) +# for cell in sheet[sheet.max_row]: +# cell.font = header_font +# cell.fill = header_fill +# +# seen_invoices = set() +# seen_gst_notes = set() +# processed_payments = set() +# pmc_groups = {} +# for inv in invoices: +# pmc_groups.setdefault(inv["PMC_No"], []).append(inv) +# +# for pmc_no, pmc_invoices in pmc_groups.items(): +# for inv in pmc_invoices: +# invoice_no = inv["Invoice_No"] +# payments = payments_map.get((pmc_no, invoice_no), []) +# +# if (pmc_no, invoice_no) not in seen_invoices: +# seen_invoices.add((pmc_no, invoice_no)) +# first_payment = payments[0] if payments else None +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map: +# row.append(invoice_holds.get(ht_id, "")) +# +# row += [ +# inv["Final_Amount"], +# first_payment["Payment_Amount"] if first_payment else "", +# first_payment["TDS_Payment_Amount"] if first_payment else "", +# first_payment["Total_amount"] if first_payment else "", +# first_payment["UTR"] if first_payment else "" +# ] +# sheet.append(row) +# if first_payment: +# payment_id = f"{pmc_no}-{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}" +# processed_payments.add(payment_id) +# +# # GST Notes +# if inv["gst_pmc_no"] and (inv["gst_pmc_no"], inv["gst_invoice_no"]) not in seen_gst_notes: +# seen_gst_notes.add((inv["gst_pmc_no"], inv["gst_invoice_no"])) +# gst_payment = None +# for payment in payments[1:]: +# if payment['invoice_no'] == inv["gst_invoice_no"]: +# gst_payment = payment +# break +# row = [pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], +# inv["gst_basic_amount"], "", "", "", "", "", "", "", "", ""] +# row += ["" for _ in hold_headers] +# row += [ +# inv["gst_final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["UTR"] if gst_payment else "" +# ] +# sheet.append(row) +# if gst_payment: +# payment_id = f"{pmc_no}-{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}" +# processed_payments.add(payment_id) +# +# for payment in payments[1:]: +# payment_id = f"{pmc_no}-{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [pmc_no, "", "", "", "", payment['invoice_no'], "", "", "", "", "", "", "", "", "", ""] +# row += ["" for _ in hold_headers] +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# sheet.append(row) +# processed_payments.add(payment_id) +# +# # Extra payments (null invoice) +# for payment in extra_payments_map.get(pmc_no, []): +# payment_id = f"{pmc_no}-null-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [pmc_no, "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] +# row += ["" for _ in hold_headers] +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# sheet.append(row) +# processed_payments.add(payment_id) +# +# # Totals Calculation +# total_basic_amount = total_tds_amount = total_sd_amount = total_on_commission = 0 +# total_hold_amount = total_final_amount = total_total_amount = 0 +# +# for row in sheet.iter_rows(min_row=13, max_row=sheet.max_row, values_only=True): +# try: +# total_basic_amount += float(row[6] or 0) +# total_tds_amount += float(row[11] or 0) +# total_sd_amount += float(row[12] or 0) +# total_on_commission += float(row[13] or 0) +# total_final_amount += float(row[-5] or 0) +# total_total_amount += float(row[-2] or 0) +# hold_start_col = len(base_headers) +# hold_end_col = hold_start_col + len(hold_headers) +# total_hold_amount += sum(float(row[i] or 0) for i in range(hold_start_col, hold_end_col)) +# except ValueError: +# continue +# +# # Totals Row +# sheet.append([]) +# totals_row = [ +# "TOTAL", "", "", "", "", "", total_basic_amount, "", "", "", "", total_tds_amount, +# total_sd_amount, total_on_commission, "", "" +# ] +# totals_row += [total_hold_amount] + [""] * (len(hold_headers) - 1) +# totals_row += [total_final_amount, "", "", total_total_amount, ""] +# sheet.append(totals_row) +# +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# +# # Summary Section +# today_date = datetime.today().strftime('%A, %Y-%m-%d') +# sheet.append([]) +# sheet.append(["Contractor Name", contInfo["Contractor_Name"]]) +# sheet.append(["Date", today_date]) +# sheet.append(["Description", "Amount"]) +# sheet.append(["Advance/Surplus", str(total_final_amount - total_total_amount)]) +# sheet.append(["Total Hold Amount", str(Decimal(total_hold_amount))]) +# sheet.append(["Amount With TDS", str(total_tds_amount)]) +# +# # Auto adjust column widths +# for col in sheet.columns: +# max_length = 0 +# col_letter = openpyxl.utils.get_column_letter(col[0].column) +# for cell in col: +# try: +# if cell.value: +# max_length = max(max_length, len(str(cell.value))) +# except: +# pass +# sheet.column_dimensions[col_letter].width = max_length + 2 +# +# workbook.save(output_file) +# workbook.close() +# +# finally: +# cursor.close() +# connection.close() +# +# return send_from_directory(output_folder, f"Contractor_Report_{contractor_id}.xlsx", as_attachment=True) + + +# show report by pmc no + + +@app.route('/pmc_report/') +def pmc_report(pmc_no): + connection = config.get_db_connection() + cursor = connection.cursor(dictionary=True, buffered=True) + + try: + # 1. Fetch PMC info using stored procedure + # cursor.execute(""" + # SELECT DISTINCT a.PMC_No, a.Village_Id, v.Village_Name, b.Block_Name, + # d.District_Name, s.State_Name, sc.Contractor_Id, sc.Contractor_Name, + # sc.Address, sc.Mobile_No, sc.PAN_No, sc.Email, sc.Gender, + # sc.GST_Registration_Type, sc.GST_No + # FROM assign_subcontractors a + # INNER JOIN villages v ON a.Village_Id = v.Village_Id + # INNER JOIN blocks b ON v.Block_Id = b.Block_Id + # INNER JOIN districts d ON b.District_id = d.District_id + # INNER JOIN states s ON d.State_Id = s.State_Id + # INNER JOIN subcontractors sc ON a.Contractor_Id = sc.Contractor_Id + # WHERE a.pmc_no = %s + # """, (pmc_no,)) + # pmc_info = cursor.fetchone() + + cursor.callproc("GetContractorInfoByPmcNo", (pmc_no,)) + pmc_info = next(cursor.stored_results()).fetchone() + + if not pmc_info: + return "No PMC found with this number", 404 + + # 2. Fetch hold types using stored procedure + # cursor.execute(""" + # SELECT DISTINCT ht.hold_type_id, ht.hold_type + # FROM invoice_subcontractor_hold_join h + # JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id + # JOIN invoice i ON h.Invoice_Id = i.Invoice_Id + # JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No + # WHERE a.PMC_No = %s AND a.Contractor_Id = %s + # """, (pmc_no, pmc_info["Contractor_Id"])) + # hold_types = cursor.fetchall() + cursor.callproc("Get_pmc_hold_types", (pmc_no, pmc_info["Contractor_Id"])) + hold_types = next(cursor.stored_results()).fetchall() + hold_type_ids = [ht['hold_type_id'] for ht in hold_types] + + # 3. Initialize invoice data + invoices = [] + hold_amount_total = 0 + + # 4. Build invoice query + if hold_type_ids: + placeholders = ','.join(['%s'] * len(hold_type_ids)) + query = f""" + SELECT DISTINCT i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, + i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, + i.After_Debit_Amount, i.Amount, i.GST_Amount, i.TDS_Amount, i.SD_Amount, + i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, + i.Final_Amount, h.hold_amount, ht.hold_type + FROM invoice i + LEFT JOIN villages v ON i.Village_Id = v.Village_Id + LEFT JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No + LEFT JOIN invoice_subcontractor_hold_join h ON i.Invoice_Id = h.Invoice_Id + LEFT JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id + WHERE a.PMC_No = %s AND a.Contractor_Id = %s + AND (ht.hold_type_id IS NULL OR ht.hold_type_id IN ({placeholders})) + ORDER BY i.Invoice_Date, i.Invoice_No + """ + params = [pmc_no, pmc_info["Contractor_Id"]] + hold_type_ids + else: + query = """ + SELECT DISTINCT i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, + i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, + i.After_Debit_Amount, i.Amount, i.GST_Amount, i.TDS_Amount, i.SD_Amount, + i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, i.Final_Amount + FROM invoice i + LEFT JOIN villages v ON i.Village_Id = v.Village_Id + LEFT JOIN assign_subcontractors a ON i.PMC_No = a.PMC_No + WHERE a.PMC_No = %s AND a.Contractor_Id = %s + ORDER BY i.Invoice_Date, i.Invoice_No + """ + params = [pmc_no, pmc_info["Contractor_Id"]] + + cursor.execute(query, params) + invoices = cursor.fetchall() + + if hold_type_ids: + hold_amount_total = sum(row.get('hold_amount', 0) or 0 for row in invoices) + + # 5. Totals from invoices + total_invo_final = sum(row.get('Final_Amount', 0) or 0 for row in invoices) + + # 6. GST release + cursor.execute(""" + SELECT pmc_no, invoice_no, basic_amount, final_amount + FROM gst_release + WHERE pmc_no = %s + ORDER BY invoice_no ASC + """, (pmc_no,)) + gst_rel = cursor.fetchall() + # gst_rel = cursor.fetchall() + # cursor.callproc('GetGSTReleaseByPMC', [pmc_no]) + # + # # Fetch results + # for result in cursor.stored_results(): + # gst_rel = result.fetchall() + + total_gst_basic = sum(row.get('basic_amount', 0) or 0 for row in gst_rel) + total_gst_final = sum(row.get('final_amount', 0) or 0 for row in gst_rel) + + # Hold Release Amount + cursor.execute("""select * from hold_release where pmc_no=%s""", (pmc_no,)) + hold_release = cursor.fetchall() + print("All Hold Release ", hold_release) + + # Credit Note + + cursor.execute("select * from credit_note where pmc_no=%s", (pmc_no,)) + credit_note = cursor.fetchall() + print(credit_note) + + # 7. Payments + cursor.execute(""" + SELECT pmc_no, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_amount, utr + FROM payment + WHERE pmc_no = %s + ORDER BY invoice_no ASC + """, (pmc_no,)) + payments = cursor.fetchall() + # cursor.callproc('GetPaymentByPMC', [pmc_no]) + # + # for result in cursor.stored_results(): + # payments = result.fetchall() + + total_pay_amount = sum(row.get('Payment_Amount', 0) or 0 for row in payments) + total_pay_total = sum(row.get('Total_amount', 0) or 0 for row in payments) + + # 8. Final totals dictionary + totals = { + "sum_invo_basic_amt": sum(row.get('Basic_Amount', 0) or 0 for row in invoices), + "sum_invo_debit_amt": sum(row.get('Debit_Amount', 0) or 0 for row in invoices), + "sum_invo_after_debit_amt": sum(row.get('After_Debit_Amount', 0) or 0 for row in invoices), + "sum_invo_amt": sum(row.get('Amount', 0) or 0 for row in invoices), + "sum_invo_gst_amt": sum(row.get('GST_Amount', 0) or 0 for row in invoices), + "sum_invo_tds_amt": sum(row.get('TDS_Amount', 0) or 0 for row in invoices), + "sum_invo_ds_amt": sum(row.get('SD_Amount', 0) or 0 for row in invoices), + "sum_invo_on_commission": sum(row.get('On_Commission', 0) or 0 for row in invoices), + "sum_invo_hydro_test": sum(row.get('Hydro_Testing', 0) or 0 for row in invoices), + "sum_invo_gst_sd_amt": sum(row.get('GST_SD_Amount', 0) or 0 for row in invoices), + "sum_invo_final_amt": total_invo_final, + "sum_invo_hold_amt": hold_amount_total, + "sum_gst_basic_amt": total_gst_basic, + "sum_gst_final_amt": total_gst_final, + "sum_pay_payment_amt": total_pay_amount, + "sum_pay_tds_payment_amt": sum(row.get('TDS_Payment_Amount', 0) or 0 for row in payments), + "sum_pay_total_amt": total_pay_total + } + + except Exception as e: + print(f"Error fetching PMC report: {e}") + return "An error occurred while fetching PMC report", 500 + + finally: + cursor.close() + connection.close() + + return render_template( + 'pmc_report.html', + info=pmc_info, + invoices=invoices, + hold_types=hold_types, + gst_rel=gst_rel, + payments=payments, + credit_note=credit_note, + hold_release=hold_release, + total=totals + ) + + +# # Download report by PMC No +# @app.route('/download_pmc_report/') +# def download_pmc_report(pmc_no): +# connection = config.get_db_connection() +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"PMC_Report_{pmc_no}.xlsx") + +# if not os.path.exists(output_folder): +# os.makedirs(output_folder) + +# cursor = connection.cursor(dictionary=True) + +# try: +# # # Fetch Contractor Details using PMC No +# # cursor.execute(""" +# # SELECT DISTINCT s.Contractor_Id, s.Contractor_Name, st.State_Name, d.District_Name, b.Block_Name, +# # s.Mobile_No, s.GST_Registration_Type, s.GST_No, s.PAN_No, s.Email, s.Address +# # FROM subcontractors s +# # LEFT JOIN assign_subcontractors asg ON s.Contractor_Id = asg.Contractor_Id +# # LEFT JOIN villages v ON asg.Village_Id = v.Village_Id +# # LEFT JOIN blocks b ON v.Block_Id = b.Block_Id +# # LEFT JOIN districts d ON b.District_id = d.District_id +# # LEFT JOIN states st ON d.State_Id = st.State_Id +# # WHERE asg.PMC_No = %s +# # """, (pmc_no,)) +# # contractor_info = cursor.fetchone() +# cursor.callproc('GetContractorDetailsByPMC', [pmc_no]) + +# # Now fetch the result: +# for result in cursor.stored_results(): +# contractor_info = result.fetchone() + +# if not contractor_info: +# return "No contractor found for this PMC No", 404 + +# # # Fetch distinct hold types present for the contractor +# # cursor.execute(""" +# # SELECT DISTINCT ht.hold_type_id, ht.hold_type +# # FROM invoice_subcontractor_hold_join h +# # JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# # WHERE h.Contractor_Id = %s +# # """, (contractor_info["Contractor_Id"],)) +# # hold_types = cursor.fetchall() +# cursor.callproc('GetHoldTypesByContractor', [contractor_info["Contractor_Id"]]) + +# for result in cursor.stored_results(): +# hold_types = result.fetchall() + +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} + +# # # # Fetch Invoices & GST Releases +# # cursor.execute(""" +# # SELECT DISTINCT i.Invoice_Id, i.PMC_No, v.Village_Name, i.Work_Type, i.Invoice_Details, +# # i.Invoice_Date, i.Invoice_No, i.Basic_Amount, i.Debit_Amount, +# # i.After_Debit_Amount, i.GST_Amount, i.Amount, i.TDS_Amount, i.SD_Amount, +# # i.On_Commission, i.Hydro_Testing, i.GST_SD_Amount, i.Final_Amount, +# # g.pmc_no AS gst_pmc_no, g.invoice_no AS gst_invoice_no, +# # g.basic_amount AS gst_basic_amount, g.final_amount AS gst_final_amount +# # FROM invoice i +# # LEFT JOIN assign_subcontractors asg ON i.PMC_No = asg.PMC_No +# # LEFT JOIN villages v ON i.Village_Id = v.Village_Id +# # LEFT JOIN gst_release g ON i.PMC_No = g.pmc_no AND i.Invoice_No = g.invoice_no +# # WHERE asg.PMC_No = %s +# # ORDER BY i.Invoice_Date, i.Invoice_No +# # """, (pmc_no,)) +# # invoices = cursor.fetchall() + +# cursor.callproc('GetInvoicesAndGstReleaseByPmcNo', [pmc_no]) + +# for result in cursor.stored_results(): +# invoices = result.fetchall() +# print("pmc_report invoice data:",invoices) + +# # cursor.callproc('GetInvoicesAndGSTReleasesByPMC', [pmc_no]) + +# # for result in cursor.stored_results(): +# # invoices = result.fetchall() + +# # # Fetch Hold Amounts separately +# # cursor.execute(""" +# # SELECT h.Invoice_Id, ht.hold_type_id, h.hold_amount +# # FROM invoice_subcontractor_hold_join h +# # JOIN hold_types ht ON h.hold_type_id = ht.hold_type_id +# # WHERE h.Contractor_Id = %s +# # """, (contractor_info["Contractor_Id"],)) +# # hold_amounts = cursor.fetchall() +# cursor.callproc('GetHoldAmountsByContractor', [contractor_info["Contractor_Id"]]) + +# for result in cursor.stored_results(): +# hold_amounts = result.fetchall() + +# # Create a mapping of invoice_id to hold amounts by type +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] + +# # # Fetch all Payments for the PMC number +# # cursor.execute(""" +# # SELECT pmc_no, invoice_no, Payment_Amount, TDS_Payment_Amount, Total_amount, UTR +# # FROM payment +# # WHERE pmc_no = %s +# # ORDER BY invoice_no +# # """, (pmc_no,)) +# # all_payments = cursor.fetchall() +# cursor.callproc('GetAllPaymentsByPMC', [pmc_no]) + +# for result in cursor.stored_results(): +# all_payments = result.fetchall() + +# # Organize payments by Invoice No (both regular and GST release notes) +# payments_map = {} +# extra_payments = [] +# for pay in all_payments: +# if pay['invoice_no']: +# key = pay['invoice_no'] +# if key not in payments_map: +# payments_map[key] = [] +# payments_map[key].append(pay) +# else: +# extra_payments.append(pay) + +# # Create Excel workbook +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "PMC Report" + +# # Write Contractor Details +# sheet.append(["", "", "Laxmi Civil Engineering Services PVT. LTD.", "", ""]) +# sheet.append( +# ["Contractor Name", contractor_info["Contractor_Name"], " ", "GST No", contractor_info["GST_No"], " ", +# "GST Type", contractor_info["GST_Registration_Type"]]) +# sheet.append(["State", contractor_info["State_Name"], " ", "PAN No", contractor_info["PAN_No"], " ", "Address", +# contractor_info["Address"]]) +# sheet.append(["District", contractor_info["District_Name"], " ", "Mobile No", contractor_info["Mobile_No"]]) +# sheet.append(["Block", contractor_info["Block_Name"], " ", "Email", contractor_info["Email"]]) +# sheet.append([]) + +# # Table Headers - include all hold types as separate columns +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] + +# hold_headers = [ht['hold_type'] for ht in hold_types] + +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] + +# sheet.append(base_headers + hold_headers + payment_headers) + +# seen_invoices = set() +# seen_gst_notes = set() +# processed_payments = set() + +# # Process invoices +# for inv in invoices: +# invoice_no = inv["Invoice_No"] +# payments = payments_map.get(invoice_no, []) + +# # Process invoice row with first payment (if exists) +# if invoice_no not in seen_invoices: +# seen_invoices.add(invoice_no) +# first_payment = payments[0] if len(payments) > 0 else None + +# # Base invoice data +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] + +# # Add hold amounts for each hold type +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map.keys(): +# row.append(invoice_holds.get(ht_id, "")) + +# # Add payment information +# row += [ +# inv["Final_Amount"], +# first_payment["Payment_Amount"] if first_payment else "", +# first_payment["TDS_Payment_Amount"] if first_payment else "", +# first_payment["Total_amount"] if first_payment else "", +# first_payment["UTR"] if first_payment else "" +# ] + +# sheet.append(row) + +# if first_payment: +# payment_id = f"{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}" +# processed_payments.add(payment_id) + +# # Process GST release if exists (only if we have a matching GST record) +# if inv["gst_pmc_no"] and inv["gst_invoice_no"] and inv["gst_invoice_no"] not in seen_gst_notes: +# seen_gst_notes.add(inv["gst_invoice_no"]) + +# # Find the payment that matches this GST release +# gst_payment = None +# for payment in payments[1:]: # Skip first payment (already used for invoice) +# if payment['invoice_no'] == inv["gst_invoice_no"]: +# gst_payment = payment +# break + +# # If no payment found in the invoice's payments, check all payments +# if not gst_payment: +# gst_payments = payments_map.get(inv["gst_invoice_no"], []) +# if gst_payments: +# gst_payment = gst_payments[0] + +# # GST release row +# row = [ +# pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], +# inv["gst_basic_amount"], "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] + +# # Empty holds for GST release +# row += ["" for _ in hold_headers] + +# # Add payment information +# row += [ +# inv["gst_final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["UTR"] if gst_payment else "" +# ] + +# sheet.append(row) + +# if gst_payment: +# payment_id = f"{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}" +# processed_payments.add(payment_id) + +# # Process remaining payments as extra payments +# for payment in payments[1:]: +# payment_id = f"{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", payment['invoice_no'], +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] + +# # Empty holds for extra payments +# row += ["" for _ in hold_headers] + +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] + +# sheet.append(row) +# processed_payments.add(payment_id) + +# # Process extra payments (null invoice_no) +# for payment in extra_payments: +# payment_id = f"null-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", "", +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] + +# # Empty holds for null invoice payments +# row += ["" for _ in hold_headers] + +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] + +# sheet.append(row) +# processed_payments.add(payment_id) + +# # Calculate totals +# total_basic_amount = 0 +# total_tds_amount = 0 +# total_sd_amount = 0 +# total_on_commission = 0 +# total_hold_amount = 0 +# total_final_amount = 0 +# total_payment_amount = 0 +# total_tds_payment_amount = 0 +# total_total_paid = 0 + +# for row in sheet.iter_rows(min_row=2, max_row=sheet.max_row, values_only=True): +# try: +# total_basic_amount += float(row[6] or 0) # Basic_Amount +# total_tds_amount += float(row[11] or 0) # TDS_Amount +# total_sd_amount += float(row[12] or 0) # SD_Amount +# total_on_commission += float(row[13] or 0) # On_Commission +# total_final_amount += float(row[-5] or 0) # Final_Amount +# total_payment_amount += float(row[-4] or 0) # Payment_Amount +# total_tds_payment_amount += float(row[-3] or 0) # TDS_Payment +# total_total_paid += float(row[-2] or 0) # Total_Paid + +# # Sum of hold amounts +# hold_start_col = len(base_headers) +# hold_end_col = hold_start_col + len(hold_headers) +# total_hold_amount += sum(float(row[i] or 0) for i in range(hold_start_col, hold_end_col)) +# except (ValueError, IndexError, TypeError): +# continue + +# # Append totals row +# totals_row = [ +# "TOTAL", "", "", "", "", "", +# total_basic_amount, "", "", "", "", total_tds_amount, total_sd_amount, +# total_on_commission, "", "", # Empty GST SD Amount +# ] + +# # Add hold totals +# totals_row += [total_hold_amount] + [""] * (len(hold_headers) - 1) + +# # Add payment totals +# totals_row += [ +# total_final_amount, +# total_payment_amount, +# total_tds_payment_amount, +# total_total_paid, +# "" # UTR column remains empty +# ] + +# sheet.append([]) +# sheet.append(totals_row) + +# # Make totals row bold +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) + +# # Save Excel file +# workbook.save(output_file) +# workbook.close() + +# finally: +# cursor.close() +# connection.close() + +# return send_from_directory(output_folder, f"PMC_Report_{pmc_no}.xlsx", as_attachment=True) + + + +# @app.route('/download_pmc_report/') +# def download_pmc_report(pmc_no): +# connection = config.get_db_connection() +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"PMC_Report_{pmc_no}.xlsx") +# +# if not os.path.exists(output_folder): +# os.makedirs(output_folder) +# +# cursor = connection.cursor(dictionary=True) +# +# try: +# cursor.callproc('GetContractorDetailsByPMC', [pmc_no]) +# +# for result in cursor.stored_results(): +# contractor_info = result.fetchone() +# +# if not contractor_info: +# return "No contractor found for this PMC No", 404 +# +# cursor.callproc('GetHoldTypesByContractor', [contractor_info["Contractor_Id"]]) +# +# for result in cursor.stored_results(): +# hold_types = result.fetchall() +# +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} +# +# cursor.callproc('GetInvoicesAndGstReleaseByPmcNo', [pmc_no]) +# +# for result in cursor.stored_results(): +# invoices = result.fetchall() +# total_tds=Decimal('0.00') +# final_amount=Decimal('0.00') +# # total_hold_amount=Decimal('0.00') +# for data in invoices: +# total_tds=total_tds+data.get('TDS_Amount',Decimal('0.00')) +# final_amount=final_amount+data.get('Final_Amount',Decimal('0.00')) +# +# cursor.callproc('GetHoldAmountsByContractor', [contractor_info["Contractor_Id"]]) +# +# for result in cursor.stored_results(): +# hold_amounts = result.fetchall() +# +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] +# +# cursor.callproc('GetAllPaymentsByPMC', [pmc_no]) +# +# for result in cursor.stored_results(): +# all_payments = result.fetchall() +# total_amount=Decimal('0.00') +# for d in all_payments: +# total_amount=total_amount+ d.get('Total_Amount',Decimal('0.00')) +# total_amount_paid= final_amount- total_amount; +# payments_map = {} +# extra_payments = [] +# for pay in all_payments: +# if pay['invoice_no']: +# key = pay['invoice_no'] +# if key not in payments_map: +# payments_map[key] = [] +# payments_map[key].append(pay) +# else: +# extra_payments.append(pay) +# +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "PMC Report" +# +# # Write Contractor Details +# sheet.append(["", "", "Laxmi Civil Engineering Services PVT. LTD.", "", ""]) +# sheet.append( +# ["Contractor Name", contractor_info["Contractor_Name"], " ", "GST No", contractor_info["GST_No"], " ", +# "GST Type", contractor_info["GST_Registration_Type"]]) +# sheet.append(["State", contractor_info["State_Name"], " ", "PAN No", contractor_info["PAN_No"], " ", "Address", +# contractor_info["Address"]]) +# sheet.append(["District", contractor_info["District_Name"], " ", "Mobile No", contractor_info["Mobile_No"]]) +# sheet.append(["Block", contractor_info["Block_Name"], " ", "Email", contractor_info["Email"]]) +# sheet.append([]) +# +# # Table Headers - include all hold types as separate columns +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] +# +# hold_headers = [ht['hold_type'] for ht in hold_types] +# +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] +# +# sheet.append(base_headers + hold_headers + payment_headers) +# +# seen_invoices = set() +# seen_gst_notes = set() +# processed_payments = set() +# +# # Process invoices +# for inv in invoices: +# invoice_no = inv["Invoice_No"] +# payments = payments_map.get(invoice_no, []) +# +# # Process invoice row with first payment (if exists) +# if invoice_no not in seen_invoices: +# seen_invoices.add(invoice_no) +# first_payment = payments[0] if len(payments) > 0 else None +# +# # Base invoice data +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] +# +# # Add hold amounts for each hold type +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map.keys(): +# row.append(invoice_holds.get(ht_id, "")) +# +# # Add payment information +# row += [ +# inv["Final_Amount"], +# first_payment["Payment_Amount"] if first_payment else "", +# first_payment["TDS_Payment_Amount"] if first_payment else "", +# first_payment["Total_amount"] if first_payment else "", +# first_payment["UTR"] if first_payment else "" +# ] +# +# sheet.append(row) +# +# if first_payment: +# payment_id = f"{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}" +# processed_payments.add(payment_id) +# +# # Process GST release if exists (only if we have a matching GST record) +# if inv["gst_pmc_no"] and inv["gst_invoice_no"] and inv["gst_invoice_no"] not in seen_gst_notes: +# seen_gst_notes.add(inv["gst_invoice_no"]) +# +# # Find the payment that matches this GST release +# gst_payment = None +# for payment in payments[1:]: # Skip first payment (already used for invoice) +# if payment['invoice_no'] == inv["gst_invoice_no"]: +# gst_payment = payment +# break +# +# # If no payment found in the invoice's payments, check all payments +# if not gst_payment: +# gst_payments = payments_map.get(inv["gst_invoice_no"], []) +# if gst_payments: +# gst_payment = gst_payments[0] +# +# # GST release row (this will be in the same row, after the invoice information) +# gst_row = [ +# pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], +# inv["gst_basic_amount"], "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for GST release +# gst_row += ["" for _ in hold_headers] +# +# # Add GST payment information (same columns as invoice payment information) +# gst_row += [ +# inv["gst_final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["UTR"] if gst_payment else "" +# ] +# +# sheet.append(gst_row) +# +# if gst_payment: +# payment_id = f"{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}" +# processed_payments.add(payment_id) +# +# # Process remaining payments as extra payments (if any) +# for payment in payments[1:]: +# payment_id = f"{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", payment['invoice_no'], +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for extra payments +# row += ["" for _ in hold_headers] +# +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# +# sheet.append(row) +# processed_payments.add(payment_id) +# +# # Process extra payments (null invoice_no) +# for payment in extra_payments: +# payment_id = f"null-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [ +# pmc_no, "", "", "", "", "", +# "", "", "", "", "", "", "", "", "", "" # Empty GST SD Amount +# ] +# +# # Empty holds for null invoice payments +# row += ["" for _ in hold_headers] +# +# # Add payment information +# row += [ +# "", +# payment["Payment_Amount"], +# payment["TDS_Payment_Amount"], +# payment["Total_amount"], +# payment["UTR"] +# ] +# +# sheet.append(row) +# processed_payments.add(payment_id) +# +# # Calculate totals +# total_basic_amount = 0 +# total_tds_amount = 0 +# total_sd_amount = 0 +# total_on_commission = 0 +# total_hold_amount = 0 +# total_final_amount = 0 +# total_payment_amount = 0 +# total_tds_payment_amount = 0 +# total_total_paid = 0 +# +# for row in sheet.iter_rows(min_row=2, max_row=sheet.max_row, values_only=True): +# try: +# total_basic_amount += float(row[6] or 0) # Basic_Amount +# total_tds_amount += float(row[11] or 0) # TDS_Amount +# total_sd_amount += float(row[12] or 0) # SD_Amount +# total_on_commission += float(row[13] or 0) # On_Commission +# total_final_amount += float(row[-5] or 0) # Final_Amount +# total_payment_amount += float(row[-4] or 0) # Payment_Amount +# total_tds_payment_amount += float(row[-3] or 0) # TDS_Payment +# total_total_paid += float(row[-2] or 0) # Total_Paid +# +# # Sum of hold amounts +# hold_start_col = len(base_headers) +# hold_end_col = hold_start_col + len(hold_headers) +# total_hold_amount += sum(float(row[i] or 0) for i in range(hold_start_col, hold_end_col)) +# except (ValueError, IndexError, TypeError): +# continue +# +# # Append totals row +# totals_row = [ +# "TOTAL", "", "", "", "", "", +# total_basic_amount, "", "", "", "", total_tds_amount, total_sd_amount, +# total_on_commission, "", "", # Empty GST SD Amount +# ] +# if hold_headers: +# totals_row += [total_hold_amount] + [""] * (len(hold_headers) - 1) +# +# # Add payment totals +# totals_row += [ +# total_final_amount, +# total_payment_amount, +# total_tds_payment_amount, +# total_total_paid, +# "" # UTR column remains empty +# ] +# +# sheet.append([]) +# sheet.append(totals_row) +# #new code added for small chart---summary +# total_hold_amount=Decimal('0.00') +# for d in invoices: +# total_hold_amount = total_hold_amount + d.get('SD_Amount', Decimal('0.00')) + d.get('On_Commission', +# Decimal( +# '0.00')) + d.get( +# 'Hydro_Testing', Decimal('0.00')) +# for data in hold_amounts: +# total_hold_amount = total_hold_amount + data.get('hold_amount', Decimal('0.00')) +# print("Total Hold Amount after adding the hold amount ", total_hold_amount) +# +# # Add payment information +# # Get today's date +# today_date = datetime.today().strftime('%A,%Y-%m-%d') +# # Add headers (optional) +# sheet.append(["Contractor Name", contractor_info["Contractor_Name"]]) +# sheet.append(["Date", today_date]) +# sheet.append(["Description", "Amount"]) +# # Add your values +# sheet.append(["Advance/Surplus", str(total_final_amount-total_payment_amount)]) +# sheet.append(["Total Hold Amount", str(total_hold_amount)]) +# sheet.append(["Amount With TDS", str(total_tds_payment_amount)]) +# # new coded ended here for summary chart +# # Make totals row bold +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# +# # Save Excel file +# workbook.save(output_file) +# workbook.close() +# +# finally: +# cursor.close() +# connection.close() +# +# return send_from_directory(output_folder, f"PMC_Report_{pmc_no}.xlsx", as_attachment=True) + +# @app.route('/download_pmc_report/') +# def download_pmc_report(pmc_no): +# connection = config.get_db_connection() +# output_folder = "static/download" +# output_file = os.path.join(output_folder, f"PMC_Report_{pmc_no}.xlsx") +# +# if not os.path.exists(output_folder): +# os.makedirs(output_folder) +# +# cursor = connection.cursor(dictionary=True) +# +# try: +# cursor.callproc('GetContractorDetailsByPMC', [pmc_no]) +# contractor_info = next(cursor.stored_results()).fetchone() +# +# if not contractor_info: +# return "No contractor found for this PMC No", 404 +# +# cursor.callproc('GetHoldTypesByContractor', [contractor_info["Contractor_Id"]]) +# hold_types = next(cursor.stored_results()).fetchall() +# hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} +# +# cursor.callproc('GetInvoicesAndGstReleaseByPmcNo', [pmc_no]) +# invoices = next(cursor.stored_results()).fetchall() +# +# cursor.callproc('GetHoldAmountsByContractor', [contractor_info["Contractor_Id"]]) +# hold_amounts = next(cursor.stored_results()).fetchall() +# hold_data = {} +# for h in hold_amounts: +# hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] +# +# cursor.callproc('GetAllPaymentsByPMC', [pmc_no]) +# all_payments = next(cursor.stored_results()).fetchall() +# +# payments_map = {} +# extra_payments = [] +# for pay in all_payments: +# if pay['invoice_no']: +# payments_map.setdefault(pay['invoice_no'], []).append(pay) +# else: +# extra_payments.append(pay) +# +# workbook = openpyxl.Workbook() +# sheet = workbook.active +# sheet.title = "PMC Report" +# +# # Write contractor header +# sheet.append(["", "", "Laxmi Civil Engineering Services PVT. LTD."]) +# sheet.append(["Contractor Name", contractor_info["Contractor_Name"], "", "GST No", contractor_info["GST_No"], "", "GST Type", contractor_info["GST_Registration_Type"]]) +# sheet.append(["State", contractor_info["State_Name"], "", "PAN No", contractor_info["PAN_No"], "", "Address", contractor_info["Address"]]) +# sheet.append(["District", contractor_info["District_Name"], "", "Mobile No", contractor_info["Mobile_No"]]) +# sheet.append(["Block", contractor_info["Block_Name"], "", "Email", contractor_info["Email"]]) +# sheet.append([]) +# +# base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", +# "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", +# "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] +# +# hold_headers = [ht['hold_type'] for ht in hold_types] +# payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] +# sheet.append(base_headers + hold_headers + payment_headers) +# # Style the headers +# header_fill=PatternFill(start_color="ADD8E6",end_color="ADD8E6",fill_type="solid") +# header_font=Font(bold=True) +# for cell in sheet[sheet.max_row]: +# cell.font=header_font +# cell.fill=header_fill +# +# seen_invoices = set() +# seen_gst_notes = set() +# processed_payments = set() +# +# for inv in invoices: +# invoice_no = inv["Invoice_No"] +# payments = payments_map.get(invoice_no, []) +# +# if invoice_no not in seen_invoices: +# seen_invoices.add(invoice_no) +# first_payment = payments[0] if payments else None +# +# row = [ +# pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], +# inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], +# inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], +# inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] +# ] +# +# invoice_holds = hold_data.get(inv["Invoice_Id"], {}) +# for ht_id in hold_type_map.keys(): +# row.append(invoice_holds.get(ht_id, "")) +# +# row += [ +# inv["Final_Amount"], +# first_payment["Payment_Amount"] if first_payment else "", +# first_payment["TDS_Payment_Amount"] if first_payment else "", +# first_payment["Total_amount"] if first_payment else "", +# first_payment["UTR"] if first_payment else "" +# ] +# +# sheet.append(row) +# +# if first_payment: +# processed_payments.add(f"{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}") +# +# if inv["gst_pmc_no"] and inv["gst_invoice_no"] and inv["gst_invoice_no"] not in seen_gst_notes: +# seen_gst_notes.add(inv["gst_invoice_no"]) +# gst_payment = None +# for payment in payments[1:]: +# if payment['invoice_no'] == inv["gst_invoice_no"]: +# gst_payment = payment +# break +# if not gst_payment: +# gst_payment = payments_map.get(inv["gst_invoice_no"], [None])[0] +# +# gst_row = [ +# pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], +# inv["gst_basic_amount"], "", "", "", "", "", "", "", "", "" +# ] +# gst_row += ["" for _ in hold_headers] +# gst_row += [ +# inv["gst_final_amount"], +# gst_payment["Payment_Amount"] if gst_payment else "", +# gst_payment["TDS_Payment_Amount"] if gst_payment else "", +# gst_payment["Total_amount"] if gst_payment else "", +# gst_payment["UTR"] if gst_payment else "" +# ] +# sheet.append(gst_row) +# if gst_payment: +# processed_payments.add(f"{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}") +# +# for payment in payments[1:]: +# payment_id = f"{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" +# if payment_id not in processed_payments: +# row = [pmc_no, "", "", "", "", payment['invoice_no']] + [""] * 10 +# row += ["" for _ in hold_headers] +# row += [ +# "", payment["Payment_Amount"], payment["TDS_Payment_Amount"], +# payment["Total_amount"], payment["UTR"] +# ] +# sheet.append(row) +# processed_payments.add(payment_id) +# +# for payment in extra_payments: +# row = [pmc_no, "", "", "", "", ""] + [""] * 10 +# row += ["" for _ in hold_headers] +# row += [ +# "", payment["Payment_Amount"], payment["TDS_Payment_Amount"], +# payment["Total_amount"], payment["UTR"] +# ] +# sheet.append(row) +# +# # Totals +# total_basic_amount = Decimal('0.00') +# total_tds_amount = Decimal('0.00') +# total_sd_amount = Decimal('0.00') +# total_on_commission = Decimal('0.00') +# total_final_amount = Decimal('0.00') +# total_payment_amount = Decimal('0.00') +# total_tds_payment_amount = Decimal('0.00') +# total_total_paid = Decimal('0.00') +# total_hold_amount_dynamic = Decimal('0.00') +# +# for row in sheet.iter_rows(min_row=8, max_row=sheet.max_row, values_only=True): +# try: +# total_basic_amount += Decimal(str(row[6] or 0)) +# total_tds_amount += Decimal(str(row[11] or 0)) +# total_sd_amount += Decimal(str(row[12] or 0)) +# total_on_commission += Decimal(str(row[13] or 0)) +# total_final_amount += Decimal(str(row[-5] or 0)) +# total_payment_amount += Decimal(str(row[-4] or 0)) +# total_tds_payment_amount += Decimal(str(row[-3] or 0)) +# total_total_paid += Decimal(str(row[-2] or 0)) +# +# for i in range(len(base_headers), len(base_headers) + len(hold_headers)): +# total_hold_amount_dynamic += Decimal(str(row[i] or 0)) +# except: +# continue +# +# totals_row = [ +# "TOTAL", "", "", "", "", "", +# total_basic_amount, "", "", "", "", total_tds_amount, total_sd_amount, +# total_on_commission, "", "" +# ] +# totals_row += [total_hold_amount_dynamic] + [""] * (len(hold_headers) - 1) +# totals_row += [ +# total_final_amount, +# total_payment_amount, +# total_tds_payment_amount, +# total_total_paid, +# "" +# ] +# +# sheet.append([]) +# sheet.append(totals_row) +# +# # Summary +# summary_hold = Decimal('0.00') +# for d in invoices: +# summary_hold += Decimal(str(d.get('SD_Amount', 0.00))) + Decimal(str(d.get('On_Commission', 0.00))) + Decimal(str(d.get('Hydro_Testing', 0.00))) +# for h in hold_amounts: +# summary_hold += Decimal(str(h.get('hold_amount', 0.00))) +# +# sheet.append([]) +# today = datetime.today().strftime('%A, %Y-%m-%d') +# sheet.append(["Contractor Name", contractor_info["Contractor_Name"]]) +# sheet.append(["Date", today]) +# sheet.append(["Description", "Amount"]) +# sheet.append(["Advance/Surplus", str(total_final_amount - total_payment_amount)]) +# sheet.append(["Total Hold Amount", str(summary_hold)]) +# sheet.append(["Amount With TDS", str(total_payment_amount + total_tds_payment_amount)]) +# +# for cell in sheet[sheet.max_row]: +# cell.font = Font(bold=True) +# +# workbook.save(output_file) +# workbook.close() +# +# finally: +# cursor.close() +# connection.close() +# +# return send_from_directory(output_folder, f"PMC_Report_{pmc_no}.xlsx", as_attachment=True) + + +@app.route('/download_pmc_report/') +def download_pmc_report(pmc_no): + connection = config.get_db_connection() + output_folder = "static/download" + output_file = os.path.join(output_folder, f"PMC_Report_{pmc_no}.xlsx") + + if not os.path.exists(output_folder): + os.makedirs(output_folder) + + cursor = connection.cursor(dictionary=True) + + try: + cursor.callproc('GetContractorDetailsByPMC', [pmc_no]) + contractor_info = next(cursor.stored_results()).fetchone() + + if not contractor_info: + return "No contractor found for this PMC No", 404 + + cursor.callproc('GetHoldTypesByContractor', [contractor_info["Contractor_Id"]]) + hold_types = next(cursor.stored_results()).fetchall() + hold_type_map = {ht['hold_type_id']: ht['hold_type'] for ht in hold_types} + + cursor.callproc('GetInvoicesAndGstReleaseByPmcNo', [pmc_no]) + invoices = next(cursor.stored_results()).fetchall() + + # Credit Note + # Credit Note Fetch + cursor.execute(""" + SELECT PMC_No, Invoice_Details, Basic_Amount, Debit_Amount, After_Debit_Amount, + GST_Amount, Amount, Final_Amount, Payment_Amount, Total_Amount, UTR, Invoice_No + FROM credit_note + WHERE Contractor_Id = %s + """, (pmc_no,)) + + credit_notes = cursor.fetchall() + + + # Build map by (PMC_No, Invoice_No) + credit_note_map = {} + for cn in credit_notes: + key = (cn["PMC_No"], cn["Invoice_No"]) # Use correct casing! + credit_note_map.setdefault(key, []).append(cn) + + # Track already appended credit notes + appended_credit_keys = set() + + cursor.callproc('GetHoldAmountsByContractor', [contractor_info["Contractor_Id"]]) + hold_amounts = next(cursor.stored_results()).fetchall() + hold_data = {} + for h in hold_amounts: + hold_data.setdefault(h['Invoice_Id'], {})[h['hold_type_id']] = h['hold_amount'] + + cursor.callproc('GetAllPaymentsByPMC', [pmc_no]) + all_payments = next(cursor.stored_results()).fetchall() + + + payments_map = {} + extra_payments = [] + for pay in all_payments: + if pay['invoice_no']: + payments_map.setdefault(pay['invoice_no'], []).append(pay) + else: + extra_payments.append(pay) + + + + workbook = openpyxl.Workbook() + sheet = workbook.active + sheet.title = "PMC Report" + + # Write contractor header + sheet.append(["", "", "Laxmi Civil Engineering Services PVT. LTD."]) + sheet.append(["Contractor Name", contractor_info["Contractor_Name"], "", "GST No", contractor_info["GST_No"], "", "GST Type", contractor_info["GST_Registration_Type"]]) + sheet.append(["State", contractor_info["State_Name"], "", "PAN No", contractor_info["PAN_No"], "", "Address", contractor_info["Address"]]) + sheet.append(["District", contractor_info["District_Name"], "", "Mobile No", contractor_info["Mobile_No"]]) + sheet.append(["Block", contractor_info["Block_Name"], "", "Email", contractor_info["Email"]]) + sheet.append([]) + + base_headers = ["PMC No", "Village", "Work Type", "Invoice Details", "Invoice Date", "Invoice No", + "Basic Amount", "Debit", "After Debit Amount", "GST (18%)", "Amount", "TDS (1%)", + "SD (5%)", "On Commission", "Hydro Testing", "GST SD Amount"] + + hold_headers = [ht['hold_type'] for ht in hold_types] + payment_headers = ["Final Amount", "Payment Amount", "TDS Payment", "Total Paid", "UTR"] + sheet.append(base_headers + hold_headers + payment_headers) + # Style the headers + header_fill=PatternFill(start_color="ADD8E6",end_color="ADD8E6",fill_type="solid") + header_font=Font(bold=True) + for cell in sheet[sheet.max_row]: + cell.font=header_font + cell.fill=header_fill + + seen_invoices = set() + seen_gst_notes = set() + processed_payments = set() + + for inv in invoices: + invoice_no = inv["Invoice_No"] + payments = payments_map.get(invoice_no, []) + + if invoice_no not in seen_invoices: + seen_invoices.add(invoice_no) + first_payment = payments[0] if payments else None + + row = [ + pmc_no, inv["Village_Name"], inv["Work_Type"], inv["Invoice_Details"], + inv["Invoice_Date"], invoice_no, inv["Basic_Amount"], inv["Debit_Amount"], + inv["After_Debit_Amount"], inv["GST_Amount"], inv["Amount"], inv["TDS_Amount"], + inv["SD_Amount"], inv["On_Commission"], inv["Hydro_Testing"], inv["GST_SD_Amount"] + ] + + invoice_holds = hold_data.get(inv["Invoice_Id"], {}) + for ht_id in hold_type_map.keys(): + row.append(invoice_holds.get(ht_id, "")) + + row += [ + inv["Final_Amount"], + first_payment["Payment_Amount"] if first_payment else "", + first_payment["TDS_Payment_Amount"] if first_payment else "", + first_payment["Total_amount"] if first_payment else "", + first_payment["UTR"] if first_payment else "" + ] + + sheet.append(row) + + if first_payment: + processed_payments.add(f"{invoice_no}-{first_payment['Payment_Amount']}-{first_payment.get('UTR', '')}") + + if inv["gst_pmc_no"] and inv["gst_invoice_no"] and inv["gst_invoice_no"] not in seen_gst_notes: + seen_gst_notes.add(inv["gst_invoice_no"]) + gst_payment = None + for payment in payments[1:]: + if payment['invoice_no'] == inv["gst_invoice_no"]: + gst_payment = payment + break + if not gst_payment: + gst_payment = payments_map.get(inv["gst_invoice_no"], [None])[0] + + gst_row = [ + pmc_no, "", "", "GST Release Note", "", inv["gst_invoice_no"], + inv["gst_basic_amount"], "", "", "", "", "", "", "", "", "" + ] + gst_row += ["" for _ in hold_headers] + gst_row += [ + inv["gst_final_amount"], + gst_payment["Payment_Amount"] if gst_payment else "", + gst_payment["TDS_Payment_Amount"] if gst_payment else "", + gst_payment["Total_amount"] if gst_payment else "", + gst_payment["UTR"] if gst_payment else "" + ] + sheet.append(gst_row) + if gst_payment: + processed_payments.add(f"{inv['gst_invoice_no']}-{gst_payment['Payment_Amount']}-{gst_payment.get('UTR', '')}") + + for payment in payments[1:]: + payment_id = f"{payment['invoice_no']}-{payment['Payment_Amount']}-{payment.get('UTR', '')}" + if payment_id not in processed_payments: + row = [pmc_no, "", "", "", "", payment['invoice_no']] + [""] * 10 + row += ["" for _ in hold_headers] + row += [ + "", payment["Payment_Amount"], payment["TDS_Payment_Amount"], + payment["Total_amount"], payment["UTR"] + ] + sheet.append(row) + processed_payments.add(payment_id) + + for payment in extra_payments: + row = [pmc_no, "", "", "", "", ""] + [""] * 10 + row += ["" for _ in hold_headers] + row += [ + "", payment["Payment_Amount"], payment["TDS_Payment_Amount"], + payment["Total_amount"], payment["UTR"] + ] + sheet.append(row) + + # Credit Note row(s) + + # Track already appended credit notes + appended_credit_keys = set() + + # While writing invoices + key = (pmc_no, invoice_no) + if key in credit_note_map and key not in appended_credit_keys: + for cn in credit_note_map[key]: + credit_row = [ + pmc_no, "", "", cn.get("Invoice_Details", "Credit Note"), "", cn.get("Invoice_No", ""), + cn.get("Basic_Amount", ""), cn.get("Debit_Amount", ""), + cn.get("After_Debit_Amount", ""), cn.get("GST_Amount", ""), cn.get("Amount", ""), "", "", "", + "", "" + ] + credit_row += ["" for _ in hold_headers] + credit_row += [ + cn.get("Final_Amount", ""), + cn.get("Total_Amount", ""), + cn.get("UTR", "") + ] + + sheet.append(credit_row) + + appended_credit_keys.add(key) + + # Totals + total_basic_amount = Decimal('0.00') + total_tds_amount = Decimal('0.00') + total_sd_amount = Decimal('0.00') + total_on_commission = Decimal('0.00') + total_final_amount = Decimal('0.00') + total_payment_amount = Decimal('0.00') + total_tds_payment_amount = Decimal('0.00') + total_total_paid = Decimal('0.00') + total_hold_amount_dynamic = Decimal('0.00') + + for row in sheet.iter_rows(min_row=8, max_row=sheet.max_row, values_only=True): + try: + total_basic_amount += Decimal(str(row[6] or 0)) + total_tds_amount += Decimal(str(row[11] or 0)) + total_sd_amount += Decimal(str(row[12] or 0)) + total_on_commission += Decimal(str(row[13] or 0)) + total_final_amount += Decimal(str(row[-5] or 0)) + total_payment_amount += Decimal(str(row[-4] or 0)) + total_tds_payment_amount += Decimal(str(row[-3] or 0)) + total_total_paid += Decimal(str(row[-2] or 0)) + + for i in range(len(base_headers), len(base_headers) + len(hold_headers)): + total_hold_amount_dynamic += Decimal(str(row[i] or 0)) + except: + continue + + totals_row = [ + "TOTAL", "", "", "", "", "", + total_basic_amount, "", "", "", "", total_tds_amount, total_sd_amount, + total_on_commission, "", "" + ] + if total_hold_amount_dynamic: + totals_row += [total_hold_amount_dynamic] + [""] * (len(hold_headers) - 1) + totals_row += [ + total_final_amount, + total_payment_amount, + total_tds_payment_amount, + total_total_paid, + "" + ] + + sheet.append([]) + sheet.append(totals_row) + + # Summary + # summary_hold = Decimal('0.00') + # for d in invoices: + # summary_hold += Decimal(str(d.get('SD_Amount', 0))) + Decimal(str(d.get('On_Commission', 0))) + Decimal(str(d.get('Hydro_Testing', 0))) + # for h in hold_amounts: + # summary_hold += Decimal(str(h.get('hold_amount', 0))) + + sheet.append([]) + today = datetime.today().strftime('%A, %Y-%m-%d') + sheet.append(["Contractor Name", contractor_info["Contractor_Name"]]) + sheet.append(["Date", today]) + sheet.append(["Description", "Amount"]) + sheet.append(["Advance/Surplus", str(total_final_amount - total_total_paid)]) + sheet.append(["Total Hold Amount", str(total_hold_amount_dynamic)]) + sheet.append(["Amount With TDS", str(total_tds_amount)]) + + for cell in sheet[sheet.max_row]: + cell.font = Font(bold=True) + + workbook.save(output_file) + workbook.close() + + finally: + cursor.close() + connection.close() + + return send_from_directory(output_folder, f"PMC_Report_{pmc_no}.xlsx", as_attachment=True) + +# --------- Hold Types Controller -------------------------------------------- +# Route to Add a New Hold Type +@app.route('/add_hold_type', methods=['POST', 'GET']) +def add_hold_type(): + connection = config.get_db_connection() + cursor = connection.cursor(dictionary=True) + + try: + # Fetch all hold types using the stored procedure + cursor.callproc("GetAllHoldTypes") + hold_types = [] + for hold in cursor.stored_results(): + hold_types = hold.fetchall() + + if request.method == 'POST': + hold_type = request.form.get('hold_type', '').strip() + + # Validation: Must start with a letter + if not hold_type or not hold_type[0].isalpha(): + return jsonify({"status": "error", "message": "Hold Type must start with a letter."}), 400 + + # Validation: Check if it already exists (case-insensitive) + # cursor.execute("SELECT COUNT(*) AS count FROM hold_types WHERE LOWER(hold_type) = LOWER(%s)", (hold_type,)) + # if cursor.fetchone()['count'] > 0: + # return jsonify({"status": "error", "message": "This Hold Type already exists."}), 400 + # Call the procedure to check if the hold_type exists + + cursor.callproc('CheckHoldTypeExists', [hold_type]) + + try: + # Insert new hold type into the database + # cursor.execute("INSERT INTO hold_types (hold_type) VALUES (%s)", (hold_type,)) + # connection.commit() + cursor.callproc('SaveHoldType', [hold_type]) + connection.commit() + + return jsonify({"status": "success", "message": "Hold Type added successfully!"}), 201 + except mysql.connector.Error as e: + connection.rollback() + return jsonify({"status": "error", "message": f"Database error: {str(e)}"}), 500 + + except mysql.connector.Error as e: + return jsonify({"status": "error", "message": f"Database error: {str(e)}"}), 500 + + finally: + cursor.close() + connection.close() + + return render_template('add_hold_type.html', Hold_Types_data=hold_types) + + +# Route to Update Hold Type +# @app.route('/update_hold_type/', methods=['POST', 'GET']) +# def update_hold_type(id): +# # GET request: Show the form with the current hold type +# if request.method == 'GET': +# connection = config.get_db_connection() +# cursor = connection.cursor() +# # cursor.execute("SELECT * FROM hold_types WHERE hold_type_id = %s", (id,)) +# # hold_type = cursor.fetchone() +# +# cursor.callproc("GetHoldTypesById", (id,)) +# for hold in cursor.stored_results(): +# hold_type = hold.fetchone() +# +# cursor.close() +# connection.close() +# +# if not hold_type: +# return jsonify({'status': 'error', 'message': 'Hold Type not found.'}), 404 +# +# return render_template('edit_hold_type.html', hold_type=hold_type) +# +# # POST request: Update the hold type +# if request.method == 'POST': +# new_hold_type = request.form.get('hold_type').strip() +# +# # Validation: Must start with a letter +# if not new_hold_type or not new_hold_type[0].isalpha(): +# return jsonify(ResponseHandler.invalid_name('Hold Type')), 400 +# +# connection = config.get_db_connection() +# cursor = connection.cursor() +# +# try: +# # Check if the hold type exists before updating +# # cursor.execute("SELECT * FROM hold_types WHERE hold_type_id = %s", (id,)) +# # hold_type = cursor.fetchone() +# cursor.callproc("GetHoldTypesById", (id,)) +# for hold in cursor.stored_results(): +# hold_type = hold.fetchone() +# +# if not hold_type: +# return jsonify({'status': 'error', 'message': 'Hold Type not found.'}), 404 +# +# # Update the hold type +# # cursor.execute("UPDATE hold_types SET hold_type = %s WHERE hold_type_id = %s", (new_hold_type, id)) +# cursor.callproc("UpdateHoldTypeById", (id,new_hold_type)) +# connection.commit() +# return jsonify(ResponseHandler.update_success('Hold Type')) +# +# except mysql.connector.Error as e: +# connection.rollback() +# return jsonify(ResponseHandler.update_failure('Hold Type')), 500 +# finally: +# cursor.close() +# connection.close() + + +@app.route('/update_hold_type/', methods=['GET', 'POST']) +def update_hold_type(id): + connection = config.get_db_connection() + cursor = connection.cursor() + + if request.method == 'GET': + cursor.callproc("GetHoldTypesById", (id,)) + for hold in cursor.stored_results(): + hold_type = hold.fetchone() + cursor.close() + connection.close() + + if not hold_type: + flash('Hold Type not found.', 'error') + return redirect(url_for('add_hold_type')) + + return render_template('edit_hold_type.html', hold_type=hold_type) + + elif request.method == 'POST': + new_hold_type = request.form.get('hold_type', '').strip() + + if not new_hold_type or not new_hold_type[0].isalpha(): + flash('Invalid hold type name. Must start with a letter.', 'error') + return redirect(url_for('add_hold_type')) + + try: + cursor.callproc("GetHoldTypesById", (id,)) + for h in cursor.stored_results(): + hold_type = h.fetchone() + + if not hold_type: + flash('Hold Type not found.', 'error') + return redirect(url_for('add_hold_type')) + + cursor.callproc("UpdateHoldTypeById", (id, new_hold_type)) + connection.commit() + flash('Hold Type updated successfully!', 'success') + + except mysql.connector.Error as e: + connection.rollback() + flash('Failed to update Hold Type.', 'error') + + finally: + cursor.close() + connection.close() + + return redirect(url_for('add_hold_type')) + + + +# Route to Delete Hold Type +@app.route('/delete_hold_type/', methods=['POST']) +def delete_hold_type(id): + connection = config.get_db_connection() + cursor = connection.cursor() + + try: + # cursor.execute("SELECT * FROM hold_types WHERE hold_type_id = %s", (id,)) + # hold_type = cursor.fetchone() + cursor.callproc("GetHoldTypesById", (id,)) + for hold in cursor.stored_results(): + hold_type = hold.fetchone() + + if not hold_type: + return jsonify({'status': 'error', 'message': 'Hold Type not found.'}), 404 + + # Proceed with deletion + # cursor.execute("DELETE FROM hold_types WHERE hold_type_id = %s", (id,)) + cursor.callproc("DeleteHoldType", (id,)) + connection.commit() + return jsonify(ResponseHandler.delete_success('Hold Type')) + + except mysql.connector.Error as e: + return jsonify(ResponseHandler.delete_failure('Hold Type')), 500 + finally: + cursor.close() + connection.close() + + +# -- end hold types controlller -------------------- + + +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000, debug=True) + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..61475b0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +Flask +mysql-connector-python +openpyxl +pandas diff --git a/static/css/base.css b/static/css/base.css new file mode 100644 index 0000000..9094baf --- /dev/null +++ b/static/css/base.css @@ -0,0 +1,89 @@ +body { + margin: 0; + font-family: Arial, sans-serif; + background-color: #f5f5f5; + display: flex; + } + + /* Sidebar */ + .sidebar { + width: 250px; + height: 100vh; + background-color: #ffffff; + position: fixed; + left: -250px; + transition: left 0.3s ease; + box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1); + padding-top: 20px; + } + .sidebar.open { + left: 0; + } + + /* Sidebar Navigation */ + .nav-menu { + list-style: none; + padding: 0; + margin: 0; + } + + .nav-item { + width: 100%; + } + + .nav-link { + display: flex; + align-items: center; + text-decoration: none; + color: #333; + padding: 15px 20px; + font-size: 16px; + transition: background-color 0.3s, color 0.3s; + } + + .nav-link i { + margin-right: 10px; + font-size: 18px; + } + + .nav-link:hover, .nav-link.active { + background-color: #e6f7ff; + color: #007bff; + } + + /* Menu Button */ + .menu-icon { + position: absolute; + top: 15px; + left: 15px; + font-size: 24px; + cursor: pointer; + background: none; + border: none; + } + + /* Content Area */ + .content { + margin-left: 0; + padding: 20px; + width: 100%; + transition: margin-left 0.3s ease; + } + .content.shift { + margin-left: 250px; + } +@media (max-width: 768px) { + .sidebar { + width: 200px; + left: -200px; + } + + .sidebar.open { + left: 0; + } + + .content.shift { + margin-left: 200px; + } +} + diff --git a/static/css/index.css b/static/css/index.css new file mode 100644 index 0000000..1c22a93 --- /dev/null +++ b/static/css/index.css @@ -0,0 +1,226 @@ +body { + margin: 0; + font-family: Arial, sans-serif; + display: flex; + flex-direction: column; + background-color: #f5f5f5; + } + + /* Sidebar */ + .sidebar { + width: 250px; + height: 100%; + background-color: #ffffff; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + display: flex; + flex-direction: column; + align-items: center; + padding-top: 20px; + position: fixed; + } + .logo { + width: 80px; + margin-bottom: 20px; + } + .nav-menu { + width: 100%; + list-style: none; + padding: 0; + margin: 0; + } + .nav-item { + width: 100%; + } + .nav-link { + display: flex; + align-items: center; + text-decoration: none; + color: #333; + padding: 15px 20px; + font-size: 16px; + transition: background-color 0.3s, color 0.3s; + } + .nav-link:hover, + .nav-link.active { + background-color: #e6f7ff; + color: #007bff; + } + .nav-link i { + margin-right: 10px; + font-size: 18px; + } + .user-section { + margin-top: auto; + width: 100%; + padding: 20px; + display: flex; + align-items: center; + border-top: 1px solid #eee; + } + .user-section img { + width: 50px; + height: 50px; + border-radius: 50%; + margin-right: 10px; + } + .user-info { + display: flex; + flex-direction: column; + } + .user-info span { + font-size: 14px; + color: #333; + } + + + /* Main content area */ + .content { + margin-left: 250px; + padding: 20px; + width: calc(100% - 250px); + } + + /* Menu Cards */ + .menu { + display: flex; + flex-wrap: wrap; + gap: 20px; + } + .card { + background-color: #fff; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + border-radius: 8px; + padding: 20px; + text-align: center; + flex: 1 1 calc(30% - 20px); + max-width: calc(30% - 20px); + + } + .card h2 { + margin: 0 0 10px; + font-size: 20px; + } + .btn { + display: inline-block; + padding: 10px 20px; + color: #fff; + background-color: #007bff; + border-radius: 4px; + text-decoration: none; + font-size: 14px; + transition: background-color 0.3s; + } + .btn:hover { + background-color: #0056b3; + } + +/* Company Info */ +.company-info { + text-align: center; + padding: 20px; + background-color: Whitesmoke; + color: blue; + margin-left: 250px; +} + +.company-name { + font-size: 30px; + font-weight: bold; + margin: 0; +} + +.app-name { + font-weight: bold; + app-name-shadow:0 2px 4px rgba(0, 0, 0, 0.1); + font-size: 24px; + margin: 5px 0 0; +} + + + + /* Responsive Design */ +@media screen and (max-width: 768px) { + .sidebar { + width: 100%; + height: auto; + position: static; + } + .content { + margin-left: 0; + width: 100%; + } + .menu { + flex-direction: column; + align-items: center; + } + .card { + flex: 1 1 100%; + max-width: 100%; + min-width: 50%; + } +} + +@media screen and (max-width: 480px) { + .nav-link { + font-size: 14px; + padding: 10px 15px; + } + .btn { + font-size: 12px; + padding: 8px 15px; + } +} + +@media screen and (max-width: 768px) { + .sidebar { + width: 100%; + height: auto; + position: static; + } + + .content { + margin-left: 0; + width: 100%; + } + + .menu { + flex-direction: column; + align-items: center; + } + + .card { + flex: 1 1 100%; + max-width: 100%; + min-width: 50%; + } + + .company-info { + margin-left: 0; + } +} + +@media screen and (max-width: 480px) { + .nav-link { + font-size: 14px; + padding: 10px 15px; + } + + .btn { + font-size: 12px; + padding: 8px 15px; + } + + .user-section { + flex-direction: column; + align-items: flex-start; + gap: 10px; + } + + .user-section img { + margin-right: 0; + } + + .card { + min-width: 90%; + } +} diff --git a/static/css/invoice.css b/static/css/invoice.css new file mode 100644 index 0000000..ecf18e0 --- /dev/null +++ b/static/css/invoice.css @@ -0,0 +1,395 @@ +/* General Styles */ + +h2 { + text-align: center; + font-size: 24px; + color: #333; + margin-bottom: 20px; +} + +/* Form Styling */ +form { + width:50%; + background: #fff; + padding: 20px; + border-radius: 8px; + box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); + display: flex; + flex-direction: column; + gap: 15px; +} + +/* Responsive Form Layout */ +.row1, +.row2, +.row3 { + display: grid; + gap: 15px; +} + +.row2, +.row3 { + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); +} + +label { + font-weight: bold; + display: block; + margin-bottom: 6px; +} + +input, +textarea, +select { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 6px; + font-size: 16px; + box-sizing: border-box; +} + +/* Button Styling */ +.button { + padding: 12px; + background-color: #007bff; + color: white; + border: none; + border-radius: 6px; + font-size: 18px; + cursor: pointer; + transition: background-color 0.3s ease-in-out; +} + +.button:hover { + background-color: #0056b3; +} + +/* Dynamic Hold Amount Fields */ +.hold-row { + display: flex; + flex-wrap: wrap; + gap: 10px; +} + +.hold-amount-field { + display: flex; + align-items: center; + gap: 10px; + padding: 10px; + background-color: #f9f9f9; + border: 1px solid #ddd; + border-radius: 4px; + flex-wrap: wrap; +} + +.hold-amount-field select, +.hold-amount-field input { + flex: 1; + min-width: 100px; +} + +.hold-amount-field button { + background-color: red; + color: white; + font-size: 14px; + padding: 8px 10px; + border: none; + border-radius: 4px; + cursor: pointer; +} + +.hold-amount-field button:hover { + background-color: #c0392b; +} + +/* Success Alert Box */ +.success-alert { + position: fixed; + top: 20px; + left: 50%; + transform: translateX(-50%); + background-color: #4CAF50; + color: #fff; + padding: 15px 25px; + border-radius: 5px; + box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); + opacity: 0; + visibility: hidden; + transition: opacity 0.5s ease, visibility 0.5s ease; + z-index: 1000; +} + +.success-alert.show { + opacity: 1; + visibility: visible; +} + +/* Table Styles */ +.invoice-table { + width: 100%; + border-collapse: collapse; + margin-top: 20px; + overflow-x: auto; +} + +.invoice-table th, +.invoice-table td { + border: 1px solid #ddd; + padding: 10px; + text-align: left; + font-size: 14px; + word-break: break-word; +} + +.invoice-table th { + background-color: #007bff; + color: #fff; +} + +.invoice-table tr:nth-child(even) { + background-color: #f9f9f9; +} + +.invoice-table tr:hover { + background-color: #f1f1f1; +} + + + +/* icon */ + .icon { + width: 20px; + height: 20px; + cursor: pointer; + transition: transform 0.2s ease-in-out, opacity 0.2s ease-in-out; + } + + .icon:hover { + transform: scale(1.5); + opacity: 0.8; + } + + .edit-icon:hover { + filter: drop-shadow(0 0 5px #007bff); /* Blue glow for edit */ + } + + .delete-icon:hover { + filter: drop-shadow(0 0 5px #ff0000); /* Red glow for delete */ + } + + +/* Center the buttons and apply consistent styling */ +.button-container { + display: flex; + justify-content: center; /* Center buttons horizontally */ + gap: 10px; /* Space between buttons */ + margin-top: 20px; /* Add some top margin */ +} + +.action-button { + background-color: #007BFF; /* Blue background */ + color: white; /* White text */ + padding: 15px 30px; /* Larger padding for bigger buttons */ + border: none; /* Remove border */ + border-radius: 5px; /* Rounded corners */ + cursor: pointer; /* Pointer cursor on hover */ + font-size: 18px; /* Larger font size */ + text-align: center; /* Center text */ + text-decoration: none; /* Remove underline */ + transition: background-color 0.3s ease; /* Smooth hover transition */ +} + +.action-button:hover { + background-color: #0056b3; /* Darker blue on hover */ +} + +#addStateForm, #stateTable { + display: none; /* Initially hide both the form and the table */ +} + +/* Success Popup */ +.success-popup { + display: none; + color: green; + font-size: 1.2em; + margin-top: 10px; +} + +/* Sorting buttons */ +.sortable .sort-buttons { + margin-left: 5px; +} + + +.sortable { + cursor: pointer; + user-select: none; + } +.sort-buttons a { + text-decoration: none; + color: black; + font-weight: bold; + margin-left: 5px; + margin-right: 5px; +} +.sort-buttons a:hover { + text-decoration: underline; + } + .back-button { + display: inline-block; + margin-top: 20px; + padding: 8px 15px; + background-color: #28a745; + color: white; + border-radius: 5px; + text-decoration: none; + font-size: 16px; + } + .back-button:hover { + background-color: #218838; + } + + + + + +span .sort-desc:hover{ +cursor: pointer; +} + +span .sort-asc:hover{ +cursor: pointer; +} + + +/* Responsive Design */ +@media (max-width: 1024px) { + form { + padding: 15px; + } + + .row2, + .row3 { + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + } + + .invoice-table th, + .invoice-table td { + font-size: 12px; + padding: 8px; + } +} + +@media (max-width: 768px) { + .row1, + .row2, + .row3 { + grid-template-columns: 1fr; + } + + .hold-amount-field { + flex-direction: column; + gap: 5px; + align-items: flex-start; + } + + .hold-amount-field select, + .hold-amount-field input { + width: 100%; + } + + .invoice-table { + display: block; + overflow-x: auto; + white-space: nowrap; + } +} + +@media (max-width: 480px) { + body { + max-width: 100%; + padding: 10px; + } + + form { + padding: 10px; + } + + .invoice-table th, + .invoice-table td { + font-size: 12px; + padding: 5px; + } + + button { + font-size: 16px; + padding: 10px; + } +} +/* Additional Media Queries */ + +/* For tablets and medium devices */ +@media (max-width: 992px) { + form { + width: 90%; + } + + .button-container { + flex-direction: column; + align-items: center; + } + + .action-button { + width: 100%; + max-width: 300px; + } +} + +/* For smaller tablets and large phones */ +@media (max-width: 600px) { + .button-container { + flex-direction: column; + align-items: stretch; + } + + .action-button { + width: 100%; + } + + .icon { + width: 16px; + height: 16px; + } + + .success-alert { + width: 90%; + font-size: 14px; + padding: 10px 15px; + } +} + +/* For very small phones */ +@media (max-width: 360px) { + h2 { + font-size: 20px; + } + + .back-button { + width: 100%; + text-align: center; + font-size: 14px; + padding: 8px 10px; + } + + .sort-buttons a { + font-size: 12px; + } + + .invoice-table th, + .invoice-table td { + font-size: 10px; + padding: 4px; + } +} + diff --git a/static/css/invoice1.css b/static/css/invoice1.css new file mode 100644 index 0000000..11d9e52 --- /dev/null +++ b/static/css/invoice1.css @@ -0,0 +1,313 @@ +/* General Styling */ +body { + font-family: Arial, sans-serif; + margin: 20px; + background-color: #f9f9f9; + color: #333; +} + +/* Header Styling */ +h1, h2, h3 { + color: #0056b3; + text-align: center; +} + +/* Table Styling */ +table { + width: 100%; + border-collapse: collapse; + margin: 20px 0; +} + +table th, table td { + border: 1px solid #ddd; + padding: 8px; + text-align: center; +} + +table th { + background-color: #007bff; + color: white; + font-weight: bold; + cursor: pointer; + position: relative; +} + +table tr:nth-child(even) { + background-color: #f2f2f2; +} + +table tr:hover { + background-color: #ddd; +} + +/* Sort Dropdown */ +.sort-options { + display: none; + position: absolute; + background: white; + border: 1px solid black; + padding: 5px; + z-index: 100; + width: 120px; + text-align: center; +} + +.sort-options button { + display: block; + width: 100%; + border: none; + background: none; + padding: 5px; + cursor: pointer; +} + +.sort-options button:hover { + background-color: #f0f0f0; +} + +/* Form Styling */ +form { + max-width: 700px; + margin: 0 auto; + padding: 20px; + background: #fff; + border: 1px solid #ddd; + border-radius: 5px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +form label { + display: block; + margin-bottom: 5px; + font-weight: bold; +} + +form input[type="text"], +form input[type="number"], +form input[type="date"], +form input[type="email"], +form textarea, +select { + width: 100%; + padding: 10px; + margin-bottom: 15px; + border: 1px solid #ddd; + border-radius: 5px; + box-sizing: border-box; +} + +form textarea { + resize: vertical; +} + +/* Button Styling */ +.button, form button { + width: 100%; + padding: 10px; + background-color: #007bff; + color: white; + border: none; + border-radius: 5px; + cursor: pointer; + font-size: 16px; + text-align: center; +} + +.button:hover, form button:hover { + background-color: #0056b3; +} + +/* Back Button */ +.back-button { + background-color: red; + color: white; + padding: 10px 20px; + text-decoration: none; + font-weight: bold; + border-radius: 5px; + display: inline-block; + margin-top: 20px; + text-align: center; +} + +.back-button:hover { + background-color: darkred; +} + +/* Success Alert */ +.success-alert { + display: none; + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background-color: #d4edda; + color: #155724; + padding: 20px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + text-align: center; + font-size: 18px; + font-weight: bold; +} + +.success-popup i { + color: green; + font-size: 30px; + margin-right: 10px; +} + +/* Error Message */ +.error-message { + color: red; + font-size: 14px; + margin-top: 5px; +} + +/* Table Icons */ +td img { + width: 20px; /* Adjust as needed */ + height: 20px; /* Adjust as needed */ + transition: transform 0.3s ease; /* Smooth transition for hover effect */ +} + +td img:hover { + transform: scale(1.2); /* Slight zoom effect on hover */ +} + +/* Select Dropdown */ +select { + width: 100%; + padding: 12px 15px; + margin: 10px 0; + border: 1px solid #ccc; + border-radius: 5px; + font-size: 14px; + background-color: #fff; + box-sizing: border-box; + appearance: none; +} + +/* Custom Dropdown Arrow */ +select::-ms-expand { + display: none; +} + +select:focus { + outline: none; + border-color: #4CAF50; +} + +select option { + padding: 12px 15px; + font-size: 14px; +} + +option[disabled] { + color: #aaa; + font-style: italic; +} + +/* Save Button */ +.save-button { + background-color: green; + color: white; + padding: 15px; + text-decoration: none; + font-weight: bold; + border-radius: 5px; + display: flex; + justify-content: center; + align-items: center; + margin: 20px auto; + text-align: center; +} + +.save-button:hover { + background-color: darkgreen; +} + +/* Responsive Design */ +@media (max-width: 768px) { + form { + max-width: 100%; + padding: 15px; + } + + table th, table td { + padding: 6px; + font-size: 14px; + } + + .button, form button { + font-size: 14px; + padding: 8px; + } +} +/* Additional Media Queries */ + +/* For tablets and medium-sized screens */ +@media (max-width: 992px) { + form { + padding: 18px; + } + + table th, table td { + font-size: 14px; + padding: 6px; + } + + .save-button, .back-button, .button, form button { + font-size: 15px; + } +} + +/* For smaller tablets and large phones */ +@media (max-width: 600px) { + body { + margin: 10px; + } + + h1, h2, h3 { + font-size: 20px; + } + + table th, table td { + font-size: 13px; + padding: 5px; + } + + .success-alert { + width: 90%; + font-size: 16px; + padding: 15px; + } + + .button, form button, .save-button, .back-button { + padding: 10px; + font-size: 14px; + } +} + +/* For very small phones */ +@media (max-width: 360px) { + h1, h2, h3 { + font-size: 18px; + } + + .save-button, .back-button { + width: 100%; + font-size: 13px; + padding: 10px; + } + + table th, table td { + font-size: 12px; + padding: 4px; + } + + form input, form select, form textarea { + font-size: 14px; + } +} diff --git a/static/css/report.css b/static/css/report.css new file mode 100644 index 0000000..686905d --- /dev/null +++ b/static/css/report.css @@ -0,0 +1,181 @@ +h2 { + text-align: center; + font-size: 24px; + color: #333; + margin-bottom: 20px; +} + +/* Form Styling */ +.info { + width: 60%; + background: #fff; + padding: 20px; + border-radius: 8px; + box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); + display: flex; + flex-direction: column; + gap: 15px; +} + +/* Responsive Form Layout */ +.row1, +.row2, +.row3 { + display: grid; + gap: 15px; +} + +.row2, +.row3 { + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); +} + +label { + font-weight: bold; + display: block; + margin-bottom: 6px; +} + +input, +textarea, +select { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 6px; + font-size: 16px; + box-sizing: border-box; +} + +/* Table styling */ +.table-wrapper { + overflow-x: auto; +} + +table { + width: 100%; + border-collapse: collapse; + margin: 20px 0; +} + +table th, table td { + border: 1px solid #ddd; + padding: 8px; + text-align: center; +} + +table th { + background-color: #007bff; + color: white; + font-weight: bold; +} + +table tr:nth-child(even) { + background-color: #f2f2f2; +} + +table tr:hover { + background-color: #ddd; +} + +.download-btn { + display: inline-block; + padding: 10px 15px; + background-color: #28a745; + color: white; + text-decoration: none; + border-radius: 5px; + margin-top: 15px; +} + +.total-table { + width: 35%; +} + +/* Responsive Design */ +@media (max-width: 1024px) { + .info { + padding: 15px; + } + + .row2, + .row3 { + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + } + + .invoice-table th, + .invoice-table td { + font-size: 12px; + padding: 8px; + } +} + +@media (max-width: 768px) { + .row1, + .row2, + .row3 { + grid-template-columns: 1fr; + } +} + +@media (max-width: 480px) { + body { + max-width: 100%; + padding: 10px; + } + + .info { + padding: 10px; + } + + table th, + table td { + font-size: 10px; + padding: 6px; + } +} + +/* Ensure table responsiveness */ +@media (max-width: 600px) { + .table-wrapper { + overflow-x: auto; + } + + table { + min-width: 600px; + } +} +/* Extra Small Devices (max-width: 360px) */ +@media (max-width: 360px) { + h2 { + font-size: 20px; + margin-bottom: 15px; + } + + .info { + width: 100%; + padding: 8px; + } + + input, + textarea, + select { + font-size: 14px; + padding: 8px; + } + + .download-btn { + font-size: 14px; + padding: 8px 12px; + } + + table th, + table td { + font-size: 9px; + padding: 5px; + } + + .total-table { + width: 100%; + } +} diff --git a/static/css/show_excel.css b/static/css/show_excel.css new file mode 100644 index 0000000..9563d2a --- /dev/null +++ b/static/css/show_excel.css @@ -0,0 +1,212 @@ + /* General Styles */ +body { + font-family: Arial, sans-serif; + margin: 20px; + padding: 20px; + background-color: #f4f4f9; + color: #333; +} + +/* Headings */ +h1, h2 { + color: #2c3e50; +} + +/* File Information Section */ +ul { + list-style-type: none; + padding: 0; +} + +ul li { + background: #ecf0f1; + margin: 5px 0; + padding: 10px; + border-radius: 5px; +} + +/* Error Messages */ +.errors { + background-color: #ffdddd; + border: 1px solid #ff4d4d; + padding: 15px; + margin-bottom: 20px; + border-radius: 5px; +} + +.errors h2 { + color: #ff4d4d; +} + +.error { + color: #d8000c; + font-weight: bold; +} + +/* Table Styles */ +.table-container { + max-width: 100%; + overflow-x: auto; /* Allows horizontal scrolling */ + margin-bottom: 20px; + border: 1px solid #ddd; /* Optional for better visibility */ +} + +table { + width: 100%; + border-collapse: collapse; + background-color: white; + table-layout: auto; /* Let the columns adjust based on content */ +} + +th, td { + padding: 10px; + border: 1px solid #ddd; + text-align: left; + word-wrap: break-word; /* Prevents text from overflowing */ +} + +th { + background-color: #3498db; + color: white; +} + +tr:nth-child(even) { + background-color: #f2f2f2; +} + +/* Set input width to 100px */ +input[type="text"] { + width: 200px; /* Set a fixed width of 100px */ + padding: 8px; + border: 1px solid #ccc; + border-radius: 4px; + box-sizing: border-box; /* Ensures padding is included in width calculation */ + white-space: nowrap; /* Prevent line breaks */ + overflow: hidden; /* Prevents overflow */ + text-overflow: ellipsis; /* Shows ellipsis if the content is too long */ +} + +/* Buttons */ +button { + display: inline-block; + background-color: #27ae60; + color: white; + padding: 10px 15px; + text-decoration: none; + border: none; + cursor: pointer; + border-radius: 5px; + transition: background 0.3s ease; + font-size: 16px; + width: 100%; /* Ensures button is centered */ +} + +.back-button { + display: inline-block; + background-color: #27ae60; + color: white; + padding: 10px 15px; + text-decoration: none; + border: none; + cursor: pointer; + border-radius: 5px; + transition: background 0.3s ease; + font-size: 16px; + width: 10%; /* Ensures button is centered */ +} + +/* Hover Effects */ +button:hover, .back-button:hover { + background-color: #219150; +} + +button:disabled { + background-color: #95a5a6; + cursor: not-allowed; +} + +/* Back Button */ +.back-button { + background-color: #e74c3c; +} + +.back-button:hover { + background-color: #c0392b; +} + +/* Center Save Data Button */ +form { + display: flex; + flex-direction: column; + align-items: center; +} + +.save-button { + margin-top: 20px; + width: 50%; +} + +/* Responsive Design */ +@media (max-width: 768px) { + .table-container { + display: block; + overflow-x: auto; + white-space: nowrap; + } + + table { + width: 100%; + table-layout: auto; /* Let the table adjust to fit its content */ + } + + input[type="text"] { + width: 100px; /* Fixed width of 100px */ + padding: 6px; /* Smaller padding on mobile */ + } + + button, .back-button { + width: 100%; + text-align: center; + } +} +@media (max-width: 480px) { + body { + margin: 10px; + padding: 10px; + } + + h1, h2 { + font-size: 20px; + text-align: center; + } + + input[type="text"] { + width: 80px; + font-size: 14px; + } + + th, td { + font-size: 12px; + padding: 6px; + } + + .save-button { + width: 100%; + } + + .back-button { + width: 100%; + font-size: 14px; + } + + button { + font-size: 14px; + padding: 8px 12px; + } + + .errors { + font-size: 14px; + padding: 10px; + } +} + diff --git a/static/css/style.css b/static/css/style.css new file mode 100644 index 0000000..1e4ea1d --- /dev/null +++ b/static/css/style.css @@ -0,0 +1,448 @@ + /* General styling */ +body { + font-family: Arial, sans-serif; + margin: 20px; + background-color: #f9f9f9; + color: #333; +} + +/* Header styling */ +h1 { + color: back; + text-align: center; +} +h2 { + color: #0056b3; + text-align: center; +} +h3 { + color: #0056b3; +} + +/* Table styling */ +table { + width: 100%; + border-collapse: collapse; + margin: 20px 0; +} + +table th, table td { + border: 1px solid #ddd; + padding: 8px; + text-align: center; +} + +table th { + background-color: #007bff; + color: white; + font-weight: bold; +} + +table tr:nth-child(even) { + background-color: #f2f2f2; +} + +table tr:hover { + background-color: #ddd; +} + + + +/* Form styling */ +form { + max-width: 600px; + margin: 0 auto; + padding: 20px; + background: #fff; + border: 1px solid #ddd; + border-radius: 5px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +form label { + display: block; + margin-bottom: 5px; + font-weight: bold; +} + + + +form input[type="text"], form input[type="number"], form input[type="date"],form input[type="email"], form textarea { + width: 100%; + padding: 10px; + margin-bottom: 15px; + border: 1px solid #ddd; + border-radius: 5px; + box-sizing: border-box; +} + +form textarea { + resize: vertical; +} + + +form button { + width: 100%; + padding: 10px; + background-color: #007bff; + color: white; + border: none; + border-radius: 5px; + cursor: pointer; + font-size: 16px; +} + +form button:hover { + background-color: #0056b3; +} + +/* Style the

    elements to display inline */ +h1 { + display: inline-block; + margin-right: 10px; /* Spacing between buttons */ +} + +/* Style the tags to look like buttons */ +.button { + text-decoration: none; /* Remove underline */ + padding: 10px 20px; /* Add padding for size */ + background-color: #4CAF50; /* Green background color */ + color: white; /* White text */ + font-size: 16px; /* Font size */ + border-radius: 5px; /* Rounded corners */ + border: none; /* Remove default border */ + cursor: pointer; /* Cursor style */ + transition: background-color 0.3s ease; /* Smooth transition for hover */ +} + +/* Change background color on hover */ +.button:hover { + background-color: #45a049; +} + +/* Style for the Back Button */ +.back-button { + background-color: red; + color: white; + padding: 10px 20px; + text-decoration: none; + font-weight: bold; + border-radius: 5px; + display: inline-block; + margin-top: 20px; + text-align: center; +} + +.back-button:hover { + background-color: darkred; +} + +/* Styling for the select dropdown */ +select { + width: 100%; /* Use full width for better responsiveness */ + padding: 12px 15px; /* Increased padding for better spacing */ + margin: 10px 0; /* Spacing above and below */ + border: 1px solid #ccc; /* Border color */ + border-radius: 5px; /* Rounded corners */ + font-size: 14px; /* Font size for text */ + background-color: #fff; /* White background */ + box-sizing: border-box; /* Ensures padding and border are included in width */ + appearance: none; /* Remove default dropdown arrow for custom styling */ +} + +/* Custom dropdown arrow */ +select::-ms-expand { + display: none; /* Remove the default arrow for IE/Edge */ +} + +select:focus { + outline: none; /* Remove outline when focused */ + border-color: #4CAF50; /* Change border color when focused */ +} + +/* Option styling for the select */ +select option { + padding: 12px 15px; /* Padding for each option */ + font-size: 14px; /* Font size */ +} + +/* Style the placeholder (default) option */ +option[disabled] { + color: #aaa; /* Light grey color for disabled option */ + font-style: italic; /* Italicize the disabled option */ +} + +/* Label styling */ +label { + font-size: 16px; + font-weight: bold; + margin-bottom: 5px; + display: block; +} + + + + +.save-button { + background-color: Green; + color: white; + padding: 15px; + text-decoration: none; + font-weight: bold; + border-radius: 5px; + display:flex; + justify-content: center; + align-item: center; + margin: 20px; + text-align: center; + +} + +.save-button:hover { + background-color: darkGreen; +} + + +.success-popup { + display: none; + position: fixed; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + background-color: #d4edda; + color: #155724; + padding: 20px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + text-align: center; + font-size: 18px; + font-weight: bold; +} +.success-popup i { + color: green; + font-size: 30px; + margin-right: 10px; +} + + .error-message { + color: red; + font-size: 14px; + margin-top: 5px; + } + + + .icon { + width: 20px; + height: 20px; + cursor: pointer; + transition: transform 0.2s ease-in-out, opacity 0.2s ease-in-out; + } + + .icon:hover { + transform: scale(1.5); + opacity: 0.8; + } + + .edit-icon:hover { + filter: drop-shadow(0 0 5px #007bff); /* Blue glow for edit */ + } + + .delete-icon:hover { + filter: drop-shadow(0 0 5px #ff0000); /* Red glow for delete */ + } + + /* Search Bar Container */ +.search-container { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 10px; +} + +/* Search Bar Input */ +#searchBar { + padding: 8px; + font-size: 14px; + border: 1px solid #ccc; + border-radius: 5px; + width: 200px; + transition: 0.3s; +} + +/* Search Bar Focus Effect */ +#searchBar:focus { + border-color: #007bff; + outline: none; + box-shadow: 0 0 5px rgba(0, 123, 255, 0.5); +} + + + + + +/* Center the buttons and apply consistent styling */ +.button-container { + display: flex; + justify-content: center; /* Center buttons horizontally */ + gap: 10px; /* Space between buttons */ + margin-top: 20px; /* Add some top margin */ +} + +.action-button { + background-color: #007BFF; /* Blue background */ + color: white; /* White text */ + padding: 15px 30px; /* Larger padding for bigger buttons */ + border: none; /* Remove border */ + border-radius: 5px; /* Rounded corners */ + cursor: pointer; /* Pointer cursor on hover */ + font-size: 18px; /* Larger font size */ + text-align: center; /* Center text */ + text-decoration: none; /* Remove underline */ + transition: background-color 0.3s ease; /* Smooth hover transition */ +} + +.action-button:hover { + background-color: #0056b3; /* Darker blue on hover */ +} + +#addStateForm, #stateTable { + display: none; /* Initially hide both the form and the table */ +} + +/* Success Popup */ +.success-popup { + display: none; + color: green; + font-size: 1.2em; + margin-top: 10px; +} + +/* Sorting buttons */ +.sortable .sort-buttons { + margin-left: 5px; +} + + +.sortable { + cursor: pointer; + user-select: none; + } +.sort-buttons a { + text-decoration: none; + color: black; + font-weight: bold; + margin-left: 5px; + margin-right: 5px; +} +.sort-buttons a:hover { + text-decoration: underline; + } + .back-button { + display: inline-block; + margin-top: 20px; + padding: 8px 15px; + background-color: #28a745; + color: white; + border-radius: 5px; + text-decoration: none; + font-size: 16px; + } + .back-button:hover { + background-color: #218838; + } + + + + +span .sort-desc:hover{ +cursor: pointer; +} + +span .sort-asc:hover{ +cursor: pointer; +} +.sortable select { + background-color: #007BFF; /* Blue background */ + color: white; /* White text */ + border: none; + border-radius: 4px; + padding: 5px 10px; + font-size: 14px; + cursor: pointer; + appearance: none; /* Remove default browser styling */ + background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-caret-down-fill' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658c-.566-.63-.106-1.658.753-1.658h9.592c.86 0 1.32 1.027.753 1.658L8.753 11.14a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); + background-repeat: no-repeat; + background-position: right 10px center; + background-size: 12px; +} + +.sortable select:focus { + outline: none; + background-color: #0056b3; /* Darker blue on focus */ +} +.download-btn { + display: inline-block; + padding: 10px 15px; + background-color: #28a745; + color: white; + text-decoration: none; + border-radius: 5px; + margin-top: 15px; + } +@media (max-width: 480px) { + body { + margin: 10px; + padding: 10px; + } + + h1, h2, h3 { + font-size: 18px; + text-align: center; + } + + table th, table td { + font-size: 12px; + padding: 6px; + } + + form { + padding: 10px; + max-width: 100%; + } + + form input[type="text"], + form input[type="number"], + form input[type="date"], + form input[type="email"], + form textarea, + select { + padding: 8px; + font-size: 14px; + } + + form button, + .button, + .back-button, + .save-button, + .action-button { + font-size: 14px; + padding: 10px; + width: 100%; + } + + .button-container { + flex-direction: column; + gap: 10px; + } + + #searchBar { + width: 100%; + font-size: 14px; + } + + .sortable select { + font-size: 14px; + padding: 8px 10px; + background-position: right 8px center; + } +} diff --git a/static/css/subcontractor_report.css b/static/css/subcontractor_report.css new file mode 100644 index 0000000..b7ab1ff --- /dev/null +++ b/static/css/subcontractor_report.css @@ -0,0 +1,199 @@ +/* Global box-sizing for predictable sizing */ +*, *::before, *::after { + box-sizing: border-box; +} + +h2 { + text-align: center; + /* Fluid font size between 20px and 24px */ + font-size: clamp(20px, 3vw, 24px); + color: #333; + margin-bottom: 20px; +} + +/* Form Styling */ +.info { + width: 60%; + max-width: 900px; /* optional max-width */ + background: #fff; + padding: 20px; + border-radius: 8px; + box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); + display: flex; + flex-direction: column; + gap: 15px; + margin: 0 auto; /* center horizontally */ +} + +/* Responsive Form Layout */ +.row1, +.row2, +.row3 { + display: grid; + gap: 15px; +} + +.row2, +.row3 { + grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); +} + +label { + font-weight: bold; + display: block; + margin-bottom: 6px; +} + +input, +textarea, +select { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 6px; + /* Fluid font size between 14px and 16px */ + font-size: clamp(14px, 1.5vw, 16px); +} + +/* Table styling */ +.table-wrapper { + overflow-x: auto; +} + +table { + width: 100%; + border-collapse: collapse; + margin: 20px 0; +} + +table th, +table td { + border: 1px solid #ddd; + padding: 8px; + text-align: center; + /* Fluid font size between 10px and 14px */ + font-size: clamp(10px, 1vw, 14px); +} + +table th { + background-color: #007bff; + color: white; + font-weight: bold; +} + +table tr:nth-child(even) { + background-color: #f2f2f2; +} + +table tr:hover { + background-color: #ddd; +} + +.download-btn { + display: inline-block; + padding: 10px 15px; + background-color: #28a745; + color: white; + text-decoration: none; + border-radius: 5px; + margin-top: 15px; + /* Fluid font size between 12px and 16px */ + font-size: clamp(12px, 1.5vw, 16px); +} + +.total-table { + width: 35%; +} + +/* Responsive Design */ +@media (max-width: 1024px) { + .info { + padding: 15px; + width: 80%; + } + + .row2, + .row3 { + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + } + + .invoice-table th, + .invoice-table td { + font-size: 12px; + padding: 8px; + } +} + +@media (max-width: 768px) { + .info { + width: 90%; + } + .row1, + .row2, + .row3 { + grid-template-columns: 1fr; + } +} + +@media (max-width: 600px) { + .table-wrapper { + overflow-x: auto; + } + + table { + min-width: 600px; + } +} + +@media (max-width: 480px) { + body { + max-width: 100%; + padding: 10px; + } + + .info { + padding: 10px; + width: 100%; + } + + table th, + table td { + font-size: 10px; + padding: 6px; + } +} + +@media (max-width: 360px) { + h2 { + font-size: 20px; + margin-bottom: 15px; + } + + .info { + width: 100%; + padding: 8px; + gap: 10px; + } + + input, + textarea, + select { + font-size: 14px; + padding: 8px; + } + + table th, + table td { + font-size: 8px; + padding: 4px; + } + + .total-table { + width: 100%; + } + + .download-btn { + padding: 8px 12px; + font-size: 14px; + } +} diff --git a/static/css/upload_excel_file.css b/static/css/upload_excel_file.css new file mode 100644 index 0000000..e9bc1b6 --- /dev/null +++ b/static/css/upload_excel_file.css @@ -0,0 +1,111 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + padding: 0; + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + background-color: #f9f9f9; +} + +.container { + max-width: 500px; + width: 90%; + background: #ffffff; + padding: 20px; + border-radius: 8px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); + text-align: center; +} + +h1 { + margin-bottom: 20px; + color: #333; +} + +form { + margin-bottom: 20px; +} + +input[type="file"] { + display: block; + margin: 0 auto 15px auto; + font-size: 18px; + padding: 10px; + cursor: pointer; + border: 2px solid #007bff; + border-radius: 5px; + background-color: #f4f4f4; +} + +input[type="file"]:hover { + border-color: #0056b3; +} + +button { + background-color: #4CAF50; + color: white; + border: none; + padding: 15px 25px; + font-size: 18px; + border-radius: 5px; + cursor: pointer; +} + +button:hover { + background-color: #45a049; +} + +/* Style for the Back Button */ +.back-button { + background-color: red; + color: white; + padding: 10px 20px; + text-decoration: none; + font-weight: bold; + border-radius: 5px; + display: inline-block; + margin-top: 20px; + text-align: center; +} + +.back-button:hover { + background-color: darkred; +} + +@media screen and (max-width: 600px) { + .container { + padding: 15px; + } + h1 { + font-size: 20px; + } + input[type="file"] { + font-size: 16px; + padding: 8px; + } + button, .back-button { + font-size: 14px; + padding: 10px 20px; + } +} +@media screen and (max-width: 360px) { + .container { + width: 95%; + padding: 10px; + } + h1 { + font-size: 18px; + margin-bottom: 15px; + } + input[type="file"] { + font-size: 14px; + padding: 6px; + } + button, .back-button { + font-size: 12px; + padding: 8px 16px; + } +} + diff --git a/static/images/icons/bin_red_icon.png b/static/images/icons/bin_red_icon.png new file mode 100644 index 0000000..ca80068 Binary files /dev/null and b/static/images/icons/bin_red_icon.png differ diff --git a/static/images/icons/pen_blue_icon.png b/static/images/icons/pen_blue_icon.png new file mode 100644 index 0000000..2f0bf5f Binary files /dev/null and b/static/images/icons/pen_blue_icon.png differ diff --git a/static/js/block.js b/static/js/block.js new file mode 100644 index 0000000..801f38d --- /dev/null +++ b/static/js/block.js @@ -0,0 +1,87 @@ +window.onload = function () { + document.getElementById('block_Name').focus(); + }; + + +$(document).ready(function () { + $("#block_Name").on("input", function () { + let blockName = $(this).val(); + let cleanedName = blockName.replace(/[^A-Za-z ]/g, ""); + $(this).val(cleanedName); + }); + + $("#block_Name, #district_Id").on("input change", function () { + let blockName = $("#block_Name").val().trim(); + let districtId = $("#district_Id").val(); + + if (blockName === "" || districtId === "") { + $("#blockMessage").text("").css("color", ""); + $("#submitButton").prop("disabled", true); + return; + } + + $.ajax({ + url: "/check_block", + type: "POST", + contentType: "application/json", + data: JSON.stringify({ block_Name: blockName, district_Id: districtId }), + success: function (response) { + if (response.status === "available") { + $("#blockMessage").text(response.message).css("color", "green"); + $("#submitButton").prop("disabled", false); + } + }, + error: function (xhr) { + if (xhr.status === 409) { + $("#blockMessage").text("Block already exists!").css("color", "red"); + $("#submitButton").prop("disabled", true); + } else if (xhr.status === 400) { + $("#blockMessage").text("Invalid block name! Only letters are allowed.").css("color", "red"); + $("#submitButton").prop("disabled", true); + } + } + }); + }); + + $("#blockForm").on("submit", function (event) { + event.preventDefault(); + $.ajax({ + url: "/add_block", + type: "POST", + data: $(this).serialize(), + success: function (response) { + alert(response.message); + location.reload(); + }, + error: function (xhr) { + alert(xhr.responseJSON.message); + } + }); + }); + + $('#state_Id').change(function() { + var stateId = $(this).val(); + if (stateId) { + $.ajax({ + url: '/get_districts/' + stateId, + type: 'GET', + success: function(data) { + var districtDropdown = $('#district_Id'); + districtDropdown.empty(); + districtDropdown.append(''); + + data.districts.forEach(function(district) { + districtDropdown.append(''); + }); + + districtDropdown.prop('disabled', false); + }, + error: function() { + alert('Error fetching districts. Please try again.'); + } + }); + } else { + $('#district_Id').prop('disabled', true); + } + }); + }); \ No newline at end of file diff --git a/static/js/district.js b/static/js/district.js new file mode 100644 index 0000000..d466a57 --- /dev/null +++ b/static/js/district.js @@ -0,0 +1,62 @@ + window.onload = function () { + document.getElementById('district_Name').focus(); + }; + + + $(document).ready(function () { + $("#district_Name").on("input", function () { + let districtName = $(this).val(); + // Remove numbers and special characters automatically + let cleanedName = districtName.replace(/[^A-Za-z ]/g, ""); + $(this).val(cleanedName); + }); + + $("#district_Name, #state_Id").on("input change", function () { + let districtName = $("#district_Name").val().trim(); + let stateId = $("#state_Id").val(); + + if (districtName === "" || stateId === "") { + $("#districtMessage").text("").css("color", ""); + $("#submitButton").prop("disabled", true); + return; + } + + $.ajax({ + url: "/check_district", + type: "POST", + contentType: "application/json", + data: JSON.stringify({ district_Name: districtName, state_Id: stateId }), + success: function (response) { + if (response.status === "available") { + $("#districtMessage").text(response.message).css("color", "green"); + $("#submitButton").prop("disabled", false); + } + }, + error: function (xhr) { + if (xhr.status === 409) { + $("#districtMessage").text("District already exists!").css("color", "red"); + $("#submitButton").prop("disabled", true); + } else if (xhr.status === 400) { + $("#districtMessage").text("Invalid district name! Only letters are allowed.").css("color", "red"); + $("#submitButton").prop("disabled", true); + } + } + }); + }); + + $("#districtForm").on("submit", function (event) { + event.preventDefault(); + $.ajax({ + url: "/add_district", + type: "POST", + data: $(this).serialize(), + success: function (response) { + alert(response.message); + location.reload(); + }, + error: function (xhr) { + alert(xhr.responseJSON.message); + } + }); + }); + }); \ No newline at end of file diff --git a/static/js/edit_hold_type.js b/static/js/edit_hold_type.js new file mode 100644 index 0000000..2e3175e --- /dev/null +++ b/static/js/edit_hold_type.js @@ -0,0 +1,18 @@ + $("#updateHoldTypeForm").on("submit", function(event) { + event.preventDefault(); + let holdTypeId = $("#hold_type_id").val(); + let newHoldType = $("#edit_hold_type").val().trim(); + let reg = /^[A-Za-z]/; + + if (!reg.test(newHoldType)) { + alert("Hold Type must start with a letter."); + return; + } + + $.post(`/update_hold_type/${holdTypeId}`, { hold_type: newHoldType }, function(response) { + alert(response.message); + window.location.href = "/"; + }).fail(function(xhr) { + alert(xhr.responseJSON.message); + }); + }); \ No newline at end of file diff --git a/static/js/holdAmount.js b/static/js/holdAmount.js new file mode 100644 index 0000000..76aff10 --- /dev/null +++ b/static/js/holdAmount.js @@ -0,0 +1,95 @@ +$(document).ready(function () { + // Create a module to manage hold amounts + window.holdAmountModule = { + holdCount: 0, + holdTypes: [], + + init: function() { + this.loadHoldTypes(); + this.setupEventListeners(); + }, + + loadHoldTypes: function() { + $.ajax({ + url: '/get_hold_types', + method: 'GET', + dataType: 'json', + success: (data) => { + this.holdTypes = data; + $("#add_hold_amount").prop('disabled', false); + }, + error: (err) => { + console.error('Failed to load hold types', err); + } + }); + }, + + setupEventListeners: function() { + $("#add_hold_amount").click(() => this.addHoldAmountField()); + $(document).on("click", ".remove-hold", (e) => this.removeHoldAmountField(e)); + $(document).on("change", ".hold-type-dropdown", () => this.refreshDropdowns()); + $(document).on("input", "input[name='hold_amount[]']", () => this.triggerHoldAmountChanged()); + }, + + addHoldAmountField: function() { + this.holdCount++; + $("#hold_amount_container").append(` +
    + + + +
    + `); + this.refreshDropdowns(); + this.triggerHoldAmountChanged(); + }, + + removeHoldAmountField: function(e) { + const id = $(e.target).attr("data-id"); + $(`#${id}`).remove(); + this.refreshDropdowns(); + this.triggerHoldAmountChanged(); + }, + + generateOptions: function(selectedForThisDropdown = '') { + const selectedValues = $("select[name='hold_type[]']").map(function() { + return $(this).val(); + }).get(); + + let options = ''; + this.holdTypes.forEach((type) => { + if (!selectedValues.includes(type.hold_type) || type.hold_type === selectedForThisDropdown) { + options += ``; + } + }); + return options; + }, + + refreshDropdowns: function() { + $("select[name='hold_type[]']").each(function() { + const currentVal = $(this).val(); + $(this).html(window.holdAmountModule.generateOptions(currentVal)); + $(this).val(currentVal); + }); + }, + + getTotalHoldAmount: function() { + let total = 0; + $("input[name='hold_amount[]']").each(function() { + total += parseFloat($(this).val()) || 0; + }); + return total; + }, + + triggerHoldAmountChanged: function() { + const event = new Event('holdAmountChanged'); + document.dispatchEvent(event); + } + }; + + // Initialize the module + window.holdAmountModule.init(); +}); \ No newline at end of file diff --git a/static/js/hold_types.js b/static/js/hold_types.js new file mode 100644 index 0000000..47f7e18 --- /dev/null +++ b/static/js/hold_types.js @@ -0,0 +1,39 @@ +$(document).ready(function () { + $("#hold_type").on("input", function () { + let holdType = $(this).val().replace(/^\s+/, ""); + $(this).val(holdType); + + let reg = /^[A-Za-z]/; + + if (!reg.test(holdType)) { + $("#holdTypeMessage").text("Hold Type must start with a letter.").css("color", "red"); + $("#addButton").prop("disabled", true); + return; + } else { + $("#holdTypeMessage").text("").css("color", ""); + $("#addButton").prop("disabled", false); + } + }); + + $("#holdTypeForm").on("submit", function (event) { + event.preventDefault(); + $.post("/add_hold_type", $(this).serialize(), function (response) { + alert(response.message); + location.reload(); + }).fail(function (xhr) { + alert(xhr.responseJSON.message); + }); + }); + + $(".delete-button").on("click", function () { + let id = $(this).data("id"); + if (confirm("Are you sure?")) { + $.post(`/delete_hold_type/${id}`, function (response) { + alert(response.message); + location.reload(); + }).fail(function (xhr) { + alert(xhr.responseJSON.message); + }); + } + }); +}); diff --git a/static/js/invoice.js b/static/js/invoice.js new file mode 100644 index 0000000..9b3f2a0 --- /dev/null +++ b/static/js/invoice.js @@ -0,0 +1,62 @@ +// Subcontractor autocomplete functionality + $(document).ready(function () { + $("#subcontractor").keyup(function () { + let query = $(this).val(); + if (query !== "") { + $.ajax({ + url: "/search_subcontractor", + method: "POST", + data: { query: query }, + success: function (data) { + $("#subcontractor_list").fadeIn().html(data); + } + }); + } else { + $("#subcontractor_list").fadeOut(); + } + }); + + $(document).on("click", "li", function () { + $("#subcontractor").val($(this).text()); + $("#subcontractor_id").val($(this).attr("data-id")); + $("#subcontractor_list").fadeOut(); + }); + }); + + // Success Alert: show alert and reload after 3 seconds + function showSuccessAlert() { + const alertBox = document.getElementById("invoiceSuccessAlert"); + alertBox.classList.add("show"); + setTimeout(() => { + alertBox.classList.remove("show"); + // Reload page or redirect after alert hides + window.location.href = '/add_invoice'; + }, 3000); + } + + // Submit form via AJAX + $("#invoiceForm").on("submit", function (e) { + e.preventDefault(); + let formData = $(this).serialize(); + $.ajax({ + url: '/add_invoice', + method: 'POST', + data: formData, + success: function (response) { + if(response.status === "success") { + showSuccessAlert(); + } else { + alert(response.message); + } + }, + error: function (xhr, status, error) { + alert("Submission failed: " + error); + } + }); + }); + + + +window.onload = function () { + document.getElementById('subcontractor').focus(); + }; \ No newline at end of file diff --git a/static/js/save_data_success.js b/static/js/save_data_success.js new file mode 100644 index 0000000..d3a570e --- /dev/null +++ b/static/js/save_data_success.js @@ -0,0 +1,39 @@ +document.addEventListener('DOMContentLoaded', function () { + const form = document.getElementById('saveForm'); + + form.addEventListener('submit', function (e) { + e.preventDefault(); // Prevent normal form submission + + const formData = new FormData(form); + + fetch('/save_data', { + method: 'POST', + body: formData, + }).then(response => response.json()).then(data => { + if (data.success) { + Swal.fire({ + icon: 'success', + title: 'Success!', + text: data.success, + showConfirmButton: true, + confirmButtonText: 'OK' + }).then(() => { + const redirectUrl = "{{ url_for('upload_excel_file') }}"; // Redirect after success pop + }); + } else if (data.error) { + Swal.fire({ + icon: 'error', + title: 'Error!', + text: data.error, + }); + } + }).catch(error => { + Swal.fire({ + icon: 'error', + title: 'Error!', + text: 'An unexpected error occurred.', + }); + console.error('Error:', error); + }); + }); +}); \ No newline at end of file diff --git a/static/js/save_excel_file.js b/static/js/save_excel_file.js new file mode 100644 index 0000000..a670d69 --- /dev/null +++ b/static/js/save_excel_file.js @@ -0,0 +1,21 @@ +$("#saveForm").on("submit", function (event) { + event.preventDefault(); + $.ajax({ + url: "/save_data", + type: "POST", + data: $(this).serialize(), + success: function (response) { + if (response.success) { + alert("Success: " + response.success); // Show success alert + window.location.href = "/upload_excel_file"; // Redirect to the upload page + } + }, + error: function (xhr) { + if (xhr.responseJSON && xhr.responseJSON.error) { + alert("Error: " + xhr.responseJSON.error); + } else { + alert("An unexpected error occurred. Please try again."); + } + } + }); + }); \ No newline at end of file diff --git a/static/js/searchContractor.js b/static/js/searchContractor.js new file mode 100644 index 0000000..bb0251c --- /dev/null +++ b/static/js/searchContractor.js @@ -0,0 +1,43 @@ +$(document).ready(function () { + function fetchResults() { + let formData = $('#search-form').serialize(); + + $.ajax({ + type: 'POST', + url: '/search_contractor', + data: formData, + success: function (data) { + let tableBody = $('#result-table tbody'); + tableBody.empty(); + + if (data.length === 0) { + tableBody.append('No data found'); + } else { + data.forEach(function (row) { + tableBody.append(` + +
    ${row.Contractor_Name} + ${row.PMC_No} + ${row.State_Name} + ${row.District_Name} + ${row.Block_Name} + ${row.Village_Name} + + `); + }); + } + }, + error: function (xhr) { + alert(xhr.responseJSON.error); + } + }); + } + + $('#search-form input').on('keyup change', function () { + fetchResults(); + }); + }); + +window.onload = function () { + document.getElementById('subcontractor_name').focus(); + }; \ No newline at end of file diff --git a/static/js/search_on_table.js b/static/js/search_on_table.js new file mode 100644 index 0000000..de2f886 --- /dev/null +++ b/static/js/search_on_table.js @@ -0,0 +1,108 @@ + +// Search on table using search inpute options +function searchTable() { + let input = document.getElementById("searchBar").value.toLowerCase(); + let rows = document.querySelectorAll("table tbody tr"); + + rows.forEach(row => { + let blockName = row.cells[1].textContent.toLowerCase(); + let districtName = row.cells[2].textContent.toLowerCase(); + let villageName = row.cells[3].textContent.toLowerCase(); + + if (blockName.includes(input) || districtName.includes(input)|| villageName.includes(input)) { + row.style.display = ""; + } else { + row.style.display = "none"; + } + }); +} + + + + + +// Common Sorting Script for Tables +function sortTable(n, dir) { + var table, rows, switching, i, x, y, shouldSwitch; + table = document.getElementById("sortableTable"); // Ensure your table has this ID + switching = true; + + while (switching) { + switching = false; + rows = table.rows; + + for (i = 1; i < (rows.length - 1); i++) { + shouldSwitch = false; + x = rows[i].getElementsByTagName("TD")[n]; + y = rows[i + 1].getElementsByTagName("TD")[n]; + + if (dir == "asc") { + if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { + shouldSwitch = true; + break; + } + } else if (dir == "desc") { + if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { + shouldSwitch = true; + break; + } + } + } + + if (shouldSwitch) { + rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); + switching = true; + } + } +} + +// Attach sorting functionality to all sortable tables +document.addEventListener("DOMContentLoaded", function() { + // Find all elements with the class "sortable-header" + var sortableHeaders = document.querySelectorAll(".sortable-header"); + + sortableHeaders.forEach(function(header) { + // Attach click event for ascending sort + if (header.querySelector(".sort-asc")) { + header.querySelector(".sort-asc").addEventListener("click", function() { + var columnIndex = Array.from(header.parentNode.children).indexOf(header); + sortTable(columnIndex, "asc"); + }); + } + + // Attach click event for descending sort + if (header.querySelector(".sort-desc")) { + header.querySelector(".sort-desc").addEventListener("click", function() { + var columnIndex = Array.from(header.parentNode.children).indexOf(header); + sortTable(columnIndex, "desc"); + }); + } + }); +}); + + +// ADD & Dispaly screen show +document.addEventListener("DOMContentLoaded", function () { + const addButton = document.getElementById("addButton"); + const displayButton = document.getElementById("displayButton"); + const addForm = document.getElementById("addForm"); + const addTable = document.getElementById("addTable"); + + // Show "Add State" form by default + addForm.style.display = "block"; + addButton.classList.add("active-button"); // Optional: Add styling for active button + + addButton.addEventListener("click", function () { + addForm.style.display = "block"; + addTable.style.display = "none"; + addButton.classList.add("active-button"); + displayButton.classList.remove("active-button"); + }); + + displayButton.addEventListener("click", function () { + addForm.style.display = "none"; + addTable.style.display = "block"; + displayButton.classList.add("active-button"); + addButton.classList.remove("active-button"); + }); +}); \ No newline at end of file diff --git a/static/js/showSuccessAlert.js b/static/js/showSuccessAlert.js new file mode 100644 index 0000000..7adcf0c --- /dev/null +++ b/static/js/showSuccessAlert.js @@ -0,0 +1,8 @@ +function showSuccessAlert(event) { + event.preventDefault(); // Prevent form submission + document.getElementById("successPopup").style.display = "block"; + setTimeout(function() { + document.getElementById("successPopup").style.display = "none"; + event.target.submit(); // Submit the form after showing the message + }, 2000); + } \ No newline at end of file diff --git a/static/js/sorting.js b/static/js/sorting.js new file mode 100644 index 0000000..933f8d9 --- /dev/null +++ b/static/js/sorting.js @@ -0,0 +1,66 @@ +$(document).ready(function () { + function fetchResults(sortBy = '', sortOrder = '') { + let formData = $('#search-form').serialize(); + formData += &sort_by=${sortBy}&sort_order=${sortOrder}; + + $.ajax({ + type: 'POST', + url: '/search_contractor', + data: formData, + success: function (data) { + let tableBody = $('#result-table tbody'); + tableBody.empty(); + + if (data.length === 0) { + tableBody.append('No data found'); + } else { + data.forEach(function (row) { + tableBody.append(` + + ${row.Contractor_Name} + ${row.PMC_No} + ${row.State_Name} + ${row.District_Name} + ${row.Block_Name} + ${row.Village_Name} + + `); + }); + } + }, + error: function (xhr) { + alert(xhr.responseJSON.error); + } + }); + } + + $('#search-form input').on('keyup change', function () { + fetchResults(); + }); + + function showSortOptions(thElement, column) { + let sortMenu = $('#sort-options'); + let offset = $(thElement).position(); + let thHeight = $(thElement).outerHeight(); + + sortMenu.html(` + + + `); + + sortMenu.css({ + display: 'block', + top: offset.top + thHeight + 'px', + left: offset.left + 'px' + }); + } + + $(document).click(function(event) { + if (!$(event.target).closest('.sort-options, th').length) { + $('#sort-options').hide(); + } + }); + + window.fetchResults = fetchResults; + window.showSortOptions = showSortOptions; + }); \ No newline at end of file diff --git a/static/js/state.js b/static/js/state.js new file mode 100644 index 0000000..21625f8 --- /dev/null +++ b/static/js/state.js @@ -0,0 +1,61 @@ + window.onload = function () { + document.getElementById('state_Name').focus(); + }; + + +$(document).ready(function () { + $("#state_Name").on("input", function () { + let stateName = $(this).val(); + // Remove numbers and special characters automatically + let cleanedName = stateName.replace(/[^A-Za-z ]/g, ""); + $(this).val(cleanedName); + }); + + $("#state_Name").on("input", function () { + let stateName = $("#state_Name").val().trim(); + + if (stateName === "") { + $("#stateMessage").text("").css("color", ""); + $("#submitButton").prop("disabled", true); + return; + } + + $.ajax({ + url: "/check_state", + type: "POST", + contentType: "application/json", + data: JSON.stringify({ state_Name: stateName }), + success: function (response) { + if (response.status === "available") { + $("#stateMessage").text(response.message).css("color", "green"); + $("#submitButton").prop("disabled", false); + } + }, + error: function (xhr) { + if (xhr.status === 409) { + $("#stateMessage").text("State already exists!").css("color", "red"); + $("#submitButton").prop("disabled", true); + } else if (xhr.status === 400) { + $("#stateMessage").text("Invalid state name! Only letters are allowed.").css("color", "red"); + $("#submitButton").prop("disabled", true); + } + } + }); + }); + + $("#stateForm").on("submit", function (event) { + event.preventDefault(); + $.ajax({ + url: "/add_state", + type: "POST", + data: $(this).serialize(), + success: function (response) { + alert(response.message); + location.reload(); + }, + error: function (xhr) { + alert(xhr.responseJSON.message); + } + }); + }); +}); \ No newline at end of file diff --git a/static/js/subcontractor.js b/static/js/subcontractor.js new file mode 100644 index 0000000..33cdb43 --- /dev/null +++ b/static/js/subcontractor.js @@ -0,0 +1,49 @@ +function validateInput() { + let isValid = true; + + // Get form elements + let contractorName = document.getElementById("Contractor_Name").value; + let mobileNo = document.getElementById("Mobile_No").value; + let panNo = document.getElementById("PAN_No").value; + let email = document.getElementById("Email").value; + let passwordField = document.getElementById("Contractor_password"); + let submitBtn = document.getElementById("submitBtn"); + + // Validation patterns + let mobileRegex = /^[0-9]{10}$/; + let panRegex = /^[A-Z0-9]{10}$/; + let emailRegex = /^[a-z]+@[a-z]+\.[a-z]{2,6}$/; + + // Validate Mobile No + if (!mobileNo.match(mobileRegex)) { + document.getElementById("mobileError").innerText = "Mobile No must be exactly 10 digits."; + isValid = false; + } else { + document.getElementById("mobileError").innerText = ""; + } + + // Validate PAN No + if (!panNo.match(panRegex)) { + document.getElementById("panError").innerText = "PAN No must be uppercase letters or digits (10 chars)."; + isValid = false; + } else { + document.getElementById("panError").innerText = ""; + } + + // Validate Email + if (!email.match(emailRegex)) { + document.getElementById("emailError").innerText = "Email must be lowercase, contain '@' and '.'"; + isValid = false; + } else { + document.getElementById("emailError").innerText = ""; + } + + + + // Enable or disable the submit button + submitBtn.disabled = !isValid; + } + +window.onload = function () { + document.getElementById('Contractor_Name').focus(); + }; \ No newline at end of file diff --git a/static/js/validateFileInput.js b/static/js/validateFileInput.js new file mode 100644 index 0000000..ab6b9ad --- /dev/null +++ b/static/js/validateFileInput.js @@ -0,0 +1,12 @@ +function validateFileInput() { + const fileInput = document.querySelector('input[type="file"]'); + const filePath = fileInput.value; + const allowedExtensions = /(\.xlsx|\.xls)$/i; + + if (!allowedExtensions.exec(filePath)) { + alert("Please upload a valid Excel file (.xlsx or .xls only)."); + fileInput.value = ''; + return false; + } + return true; + } \ No newline at end of file diff --git a/static/js/village.js b/static/js/village.js new file mode 100644 index 0000000..7bcefcf --- /dev/null +++ b/static/js/village.js @@ -0,0 +1,102 @@ + +window.onload = function () { + document.getElementById('Village_Name').focus(); + }; + +$(document).ready(function () { + $('#state_Id').change(function () { + var stateId = $(this).val(); + if (stateId) { + $.ajax({ + url: '/get_districts/' + stateId, + type: 'GET', + success: function (data) { + var districtDropdown = $('#district_Id'); + districtDropdown.empty().append(''); + data.districts.forEach(function (district) { + districtDropdown.append(''); + }); + districtDropdown.prop('disabled', false); + } + }); + } + }); + + $('#district_Id').change(function () { + var districtId = $(this).val(); + if (districtId) { + $.ajax({ + url: '/get_blocks/' + districtId, + type: 'GET', + success: function (data) { + var blockDropdown = $('#block_Id'); + blockDropdown.empty().append(''); + data.blocks.forEach(function (block) { + blockDropdown.append(''); + }); + blockDropdown.prop('disabled', false); + } + }); + } + }); + + $('#Village_Name').on('input', function () { + var villageName = $(this).val(); + var validPattern = /^[A-Za-z ]*$/; + + if (!validPattern.test(villageName)) { + $('#villageMessage').text('Only letters and spaces are allowed!').css('color', 'red'); + $('#submitVillage').prop('disabled', true); + } else { + $('#villageMessage').text(''); + $('#submitVillage').prop('disabled', false); + } + }); + + $('#Village_Name, #block_Id').on('change keyup', function () { + var blockId = $('#block_Id').val(); + var villageName = $('#Village_Name').val().trim(); + + if (blockId && villageName) { + $.ajax({ + url: '/check_village', + type: 'POST', + data: { block_Id: blockId, Village_Name: villageName }, + success: function (response) { + if (response.status === 'exists') { + $('#villageMessage').text(response.message).css('color', 'red'); + $('#submitVillage').prop('disabled', true); + } else { + $('#villageMessage').text(response.message).css('color', 'green'); + $('#submitVillage').prop('disabled', false); + } + }, + error: function () { + $('#villageMessage').text('Error checking village name').css('color', 'red'); + $('#submitVillage').prop('disabled', true); + } + }); + } + }); + + $('#villageForm').submit(function (event) { + event.preventDefault(); // Prevent default form submission + + $.ajax({ + url: '/add_village', + type: 'POST', + data: $(this).serialize(), + success: function (response) { + if (response.status === 'success') { + alert('Village added successfully!'); + location.reload(); // Refresh the page to show the updated list + } else { + alert('Error adding village. Please try again.'); + } + }, + error: function () { + alert('An error occurred. Please try again.'); + } + }); + }); + }); \ No newline at end of file diff --git a/templates/add_block.html b/templates/add_block.html new file mode 100644 index 0000000..e3ba5e4 --- /dev/null +++ b/templates/add_block.html @@ -0,0 +1,97 @@ +{% extends 'base.html' %} +{% block content %} + + + + Add Block + + + + + + + +
    + + +
    + + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/add_district.html b/templates/add_district.html new file mode 100644 index 0000000..0b34622 --- /dev/null +++ b/templates/add_district.html @@ -0,0 +1,85 @@ +{% extends 'base.html' %} +{% block content %} + + Add District + + + + + + + +
    + + +
    + + + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/add_gst_release.html b/templates/add_gst_release.html new file mode 100644 index 0000000..62a19bd --- /dev/null +++ b/templates/add_gst_release.html @@ -0,0 +1,165 @@ +{% extends 'base.html' %} +{% block content %} + + + + Add GST Release + + + + + + + +
    + + +
    + + + + +
    + {% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} + {% for category, message in messages %} +
    + {{ message }} +
    + {% endfor %} + {% endif %} + {% endwith %} +
    + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/add_hold_type.html b/templates/add_hold_type.html new file mode 100644 index 0000000..7c0b246 --- /dev/null +++ b/templates/add_hold_type.html @@ -0,0 +1,59 @@ +{% extends 'base.html' %} +{% block content %} + + Manage Hold Types + + + + + + + +
    + + +
    + + + + + +{% endblock %} + diff --git a/templates/add_invoice.html b/templates/add_invoice.html new file mode 100644 index 0000000..db4654c --- /dev/null +++ b/templates/add_invoice.html @@ -0,0 +1,369 @@ +{% extends 'base.html' %} +{% block content %} + + + + Add Invoice + + + + + + +{% if success == 'true' %} + +{% endif %} + + + +{% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} +
    + {% for category, message in messages %} +
    {{ message }}
    + {% endfor %} +
    + {% endif %} +{% endwith %} + +
    + + +
    + + + + + + +{% endblock %} diff --git a/templates/add_payment.html b/templates/add_payment.html new file mode 100644 index 0000000..c3ce409 --- /dev/null +++ b/templates/add_payment.html @@ -0,0 +1,182 @@ +{% extends 'base.html' %} +{% block content %} + + + + Add Payment + + + + + + +
    + + +
    + + + +
    + Payment added successfully! +
    + + + + + + + + + + +{% endblock %} diff --git a/templates/add_state.html b/templates/add_state.html new file mode 100644 index 0000000..11857c9 --- /dev/null +++ b/templates/add_state.html @@ -0,0 +1,69 @@ +{% extends 'base.html' %} +{% block content %} + + Add State + + + + + + + +
    + + +
    + + + + + + + +{% endblock %} diff --git a/templates/add_subcontractor.html b/templates/add_subcontractor.html new file mode 100644 index 0000000..9932652 --- /dev/null +++ b/templates/add_subcontractor.html @@ -0,0 +1,127 @@ +{% extends 'base.html' %} +{% block content %} + + + SubContractor + + + + + + + + +
    + + +
    + + + + + +{% endblock %} diff --git a/templates/add_village.html b/templates/add_village.html new file mode 100644 index 0000000..70c22b5 --- /dev/null +++ b/templates/add_village.html @@ -0,0 +1,99 @@ +{% extends 'base.html' %} +{% block content %} + + + + Village Management + + + + + + + +
    + + +
    + + + + + + +{% endblock %} diff --git a/templates/admin_profile.html b/templates/admin_profile.html new file mode 100644 index 0000000..fbd60ca --- /dev/null +++ b/templates/admin_profile.html @@ -0,0 +1,49 @@ +{% extends 'base.html' %} +{% block content %} + + + + Admin Profile + + +
    +

    Admin Profile

    + {% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} + {% for category, message in messages %} +

    {{ message }}

    + {% endfor %} + {% endif %} + {% endwith %} +
    +
    + + +
    + + + + + + + + + + + +
    +
    + + +{% endblock %} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..bb52864 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,97 @@ + + + + + + {% block title %}Payment Reconciliation{% endblock %} + + + + + + + + + + + + + +
    + {% block content %}{% endblock %} +
    + + + + + \ No newline at end of file diff --git a/templates/edit_block.html b/templates/edit_block.html new file mode 100644 index 0000000..86a5059 --- /dev/null +++ b/templates/edit_block.html @@ -0,0 +1,60 @@ + + + +{% extends 'base.html' %} +{% block content %} + + Edit Block + + + + + +

    Edit Block

    + + +{% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} + {% for category, message in messages %} + + {% endfor %} + {% endif %} +{% endwith %} + + +
    + +

    + + +

    + + +

    + + +
    + + +{% endblock %} diff --git a/templates/edit_district.html b/templates/edit_district.html new file mode 100644 index 0000000..c028514 --- /dev/null +++ b/templates/edit_district.html @@ -0,0 +1,26 @@ +{% extends 'base.html' %} +{% block content %} + + Edit District + + + +

    Edit District

    + +
    + + + + + +
    + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/edit_gst_release.html b/templates/edit_gst_release.html new file mode 100644 index 0000000..b7a4787 --- /dev/null +++ b/templates/edit_gst_release.html @@ -0,0 +1,37 @@ +{% extends 'base.html' %} +{% block content %} + + + + Edit GST Release + + + +

    Edit GST Release

    + +
    + + + +
    +

    + +
    +

    + + +
    +

    + +
    +

    + + +
    + + + +{% endblock %} \ No newline at end of file diff --git a/templates/edit_hold_type.html b/templates/edit_hold_type.html new file mode 100644 index 0000000..7239231 --- /dev/null +++ b/templates/edit_hold_type.html @@ -0,0 +1,62 @@ + +{% extends 'base.html' %} + +{% block content %} + + Edit Hold Type + + + + + +

    Edit Hold Type

    +
    + + + + + +
    + + + +{% endblock %} + + + + + diff --git a/templates/edit_invoice.html b/templates/edit_invoice.html new file mode 100644 index 0000000..287c4b0 --- /dev/null +++ b/templates/edit_invoice.html @@ -0,0 +1,207 @@ +{% extends 'base.html' %} +{% block content %} + + + + + Edit Invoice + + + + + + + +
    +

    Edit Invoice

    + + + + +
    + + +
    +
    + + + + +
    +
    + + +
    +
    + + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    + {% set seen_types = [] %} + {% for hold in invoice.hold_amounts %} + {% if hold.hold_type not in seen_types %} + {% set _ = seen_types.append(hold.hold_type) %} +
    + + + + + +
    + {% endif %} + {% endfor %} +
    + + +
    + +
    + + +
    +
    + + +
    +
    + + +
    +
    + + + +
    +
    + + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/edit_payment.html b/templates/edit_payment.html new file mode 100644 index 0000000..9b7fb3c --- /dev/null +++ b/templates/edit_payment.html @@ -0,0 +1,49 @@ +{% extends 'base.html' %} +{% block content %} + + + + Edit Payment + + + + +

    Edit Payment

    + +
    + + + + + + + + + +
    +

    + +
    +

    + + +
    +

    + +
    +

    + +
    +

    + +
    +

    + + +
    + + +{% endblock %} diff --git a/templates/edit_state.html b/templates/edit_state.html new file mode 100644 index 0000000..144fdfe --- /dev/null +++ b/templates/edit_state.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} +{% block content %} + + Edit State + + + +

    Edit State

    + +
    + + +
    + + + +{% endblock %} \ No newline at end of file diff --git a/templates/edit_subcontractor.html b/templates/edit_subcontractor.html new file mode 100644 index 0000000..3238527 --- /dev/null +++ b/templates/edit_subcontractor.html @@ -0,0 +1,50 @@ +{% extends 'base.html' %} +{% block content %} + + + Edit SubContractor + + + + +

    Edit Sub-Contractor

    +
    + + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + + +{% endblock %} \ No newline at end of file diff --git a/templates/edit_village.html b/templates/edit_village.html new file mode 100644 index 0000000..c4e7afe --- /dev/null +++ b/templates/edit_village.html @@ -0,0 +1,52 @@ +{% extends 'base.html' %} +{% block content %} + + + + Edit Village + + + + +
    +
    +

    Edit Village

    +
    + + + + + + + + +
    +
    + + + {% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} + {% for category, message in messages %} + + {% endfor %} + {% endif %} + {% endwith %} +
    + + + +{% endblock %} diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..880d02c --- /dev/null +++ b/templates/index.html @@ -0,0 +1,105 @@ + + + + + + Payment Reconciliation + + + + + +
    + +

    Laxmi Civil Engineering Services Pvt. Ltd.

    +
    +

    Payment Reconciliation

    +
    +
    + +
    + + + diff --git a/templates/pmc_report.html b/templates/pmc_report.html new file mode 100644 index 0000000..c218c5f --- /dev/null +++ b/templates/pmc_report.html @@ -0,0 +1,340 @@ + + +{% extends 'base.html' %} +{% block content %} + + + + PMC Report + + + + + +
    +

    PMC Report

    + +
    +

    Contractor Details

    +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + + +
    +
    + + +
    +
    +

    PMC Report for PMC No: {{ info.PMC_No}}

    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +

    Invoice Details

    + + + + + + + + + + + + + + + + + + + + + {% set hold_types = invoices | map(attribute='hold_type') | reject('none') | unique | list %} + {% for hold in hold_types %} + + {% endfor %} + + + + + + + {% if invoices %} + {% for invoice in invoices %} + + + + + + + + + + + + + + + + + + + {% for hold in hold_types %} + + {% endfor %} + + + + + + {% endfor %} + + + + + + + + + + + + {% set hold_types = invoices | map(attribute='hold_type') | unique | list %} + {% for hold in hold_types %} + + {% endfor %} + + + + + {% else %} + + + + {% endif %} + +
    PMC NoVillage NameWork TypeInvoice DetailsInvoice DateInvoice NoBasic AmountDebitAfter Debit AmtGST (18%)AmountTDS (1%)SD (5%)On CommissionHydro Testing{{ hold }}GST SD (18%)Final Amount
    {{ invoice.PMC_No }}{{ invoice.Village_Name.capitalize() }}{{ invoice.Work_Type }}{{ invoice.Invoice_Details }}{{ invoice.Invoice_Date }}{{ invoice.Invoice_No }}{{ invoice.Basic_Amount }}{{ invoice.Debit_Amount }}{{ invoice.After_Debit_Amount }}{{ invoice.GST_Amount }}{{ invoice.Amount }}{{ invoice.TDS_Amount }}{{ invoice.SD_Amount }}{{ invoice.On_Commission }}{{ invoice.Hydro_Testing }} + {% if invoice.hold_type == hold %} + {{ invoice.hold_amount }} + {% else %} + 0 + {% endif %} + {{ invoice.GST_SD_Amount }}{{ invoice.Final_Amount }}
    Total{{total["sum_invo_basic_amt"]}}{{total["sum_invo_debit_amt"]}}{{total["sum_invo_after_debit_amt"]}}{{total["sum_invo_gst_amt"]}}{{total["sum_invo_amt"]}}{{total["sum_invo_tds_amt"]}}{{total["sum_invo_ds_amt"]}}{{total["sum_invo_on_commission"]}}{{total["sum_invo_hydro_test"]}}{{total["sum_invo_hold_amt"]}}{{total["sum_invo_gst_sd_amt"]}}{{total["sum_invo_final_amt"]}}
    No invoices found.
    +

    Hold Release

    + + + + + + + + + + + + + {%if hold_release%} + {%for hold in hold_release%} + + + + + + + + + {%endfor%} + {%else%} + + + + {%endif%} + +
    PMC NoInvoice NoInvoice DetailsBasic AmountTotal AmountUTR
    {{ hold['PMC_No'] }}{{ hold['Invoice_No'] }}{{ hold['Invoice_Details'] }}{{ hold['Basic_Amount'] }}{{ hold['Total_Amount'] }}{{ hold['UTR'] }}
    No data present
    + +
    +

    GST Release Note Details

    + + + + + + + + + + + {% if gst_rel %} + {% for gst in gst_rel %} + + + + + + + {% endfor %} + + + + + + + {% else %} + + + + {% endif %} + +
    PMC NoInvoice NoBasic AmountFinal Amount
    {{ gst.pmc_no }}{{ gst.invoice_no }}{{ gst.basic_amount }}{{ gst.final_amount }}
    Total{{total["sum_gst_basic_amt"]}}{{total["sum_gst_final_amt"]}}
    No GST release found.
    + + +

    Credit Details

    + + + + + + + + + + + + + + + + + + + {% if credit_note %} + {% for credit in credit_note %} + + + + + + + + + + + + + + + + {% endfor %} + + {% else %} + + + + {% endif %} + + + +
    PMC NoInvoice DetailsBasic AmountDebitAfter Debit AmtGST AmountAmountFinal AmountPayment AmountTotal AmountUTR
    {{ credit["PMC_No"] }}{{ credit["Invoice_Details"] }}{{ credit["Basic_Amount"] }}{{ credit["Debit_Amount"] }}{{ credit["After_Debit_Amount"] }}{{ credit["GST_Amount"] }}{{ credit["Amount"] }}{{ credit["Final_Amount"] }}{{ credit["Payment_Amount"] }}{{ credit["Total_Amount"] }}{{ credit["UTR"] }}
    No Credit note found.
    + +
    +

    Payment Details

    + + + + + + + + + + + + + {% if payments %} + {% for pay in payments %} + + + + + + + + + {% endfor %} + + + + + + + + {% else %} + + + + + {% endif %} + + +
    PMC NoInvoice NoAmountTDS Amount @ 1% on BASIC AMOUNTTotal Amount PaidUTR
    {{ pay.pmc_no }}{{ pay.invoice_no }}{{ pay.Payment_Amount }}{{ pay.TDS_Payment_Amount }}{{ pay.Total_amount }}{{ pay.utr}}
    Total{{total["sum_pay_payment_amt"]}}{{total["sum_pay_tds_payment_amt"]}}{{total["sum_pay_total_amt"]}}
    No payment found.
    + + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/report.html b/templates/report.html new file mode 100644 index 0000000..de53ef8 --- /dev/null +++ b/templates/report.html @@ -0,0 +1,108 @@ +{% extends 'base.html' %} +{% block content %} + + + + Contractor Search + + + + + +
    +

    Search Contractor Report

    +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    + +

    Contractor List

    + + + + + + + + + + + + + + +
    Contractor Name + + PMC NoState + + District + + Block + + Village + +
    +
    +
    + + +{% endblock %} \ No newline at end of file diff --git a/templates/show_excel_file.html b/templates/show_excel_file.html new file mode 100644 index 0000000..19b8903 --- /dev/null +++ b/templates/show_excel_file.html @@ -0,0 +1,85 @@ + + + + Excel Data + + + + + + + + +

    Excel Data

    + +

    File Information:

    +
      +
    • Subcontractor: {{ file_info['Subcontractor'] }}
    • +
    • State: {{ file_info['State'] }}
    • +
    • District: {{ file_info['District'] }}
    • +
    • Block: {{ file_info['Block'] }}
    • +
    + +{% if errors %} +
    +

    Validation Errors:

    +
      + {% for error in errors %} +
    • {{ error }}
    • + {% endfor %} +
    +
    +{% endif %} + +

    Data Table:

    +
    +
    + + + + + {% for var in variables %} + + {% endfor %} + + + + {% for row in data %} + + + {% for var in variables %} + + {% endfor %} + + {% endfor %} + +
    Row No{{ var }}
    {{ row['Row Number'] }}
    +
    + + + + + + + + + + + + + + + + + + + + +
    + +Back to Dashboard + + + + + \ No newline at end of file diff --git a/templates/subcontractor_report.html b/templates/subcontractor_report.html new file mode 100644 index 0000000..56acff9 --- /dev/null +++ b/templates/subcontractor_report.html @@ -0,0 +1,372 @@ + + + +{% extends 'base.html' %} +{% block content %} + + + + Contractor Report + + + + +
    +

    Contractor Report

    + +
    +

    Contractor Details

    +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    +
    + + + +
    +
    + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    + +

    Total

    + + + + + + + + + + + + + {% if hold_types %} + + {% for hold in hold_types %} + + + {% endfor %} + + {% endif %} + + + + +
    {{current_date}}
    Advance / Suplus{{total["sum_invo_final_amt"]+total["sum_gst_final_amt"]-total["sum_pay_total_amt"]}}
    {{ hold.hold_type }}{{total["sum_invo_hold_amt"]}}
    Amount With TDS{{total["sum_invo_tds_amt"]}}
    + + + + + + + + + + + +

    Invoice Details

    + + + + + + + + + + + + + + + + + + + + + {% set hold_types = invoices | map(attribute='hold_type') | unique | list %} + {% for hold in hold_types %} + + {% endfor %} + + + + + + + {% if invoices %} + {% for invoice in invoices %} + + + + + + + + + + + + + + + + + + + {% set hold_types = invoices | map(attribute='hold_type') | unique | list %} + {% for hold in hold_types %} + + {% endfor %} + + + + + + {% endfor %} + + + + + + + + + + + + + + {% set hold_types = invoices | map(attribute='hold_type') | unique | list %} + {% for hold in hold_types %} + + {% endfor %} + + + + + + {% else %} + + + + {% endif %} + +
    PMC NoVillage NameWork TypeInvoice DetailsInvoice DateInvoice NoBasic AmountDebitAfter Debit AmtGST (18%)AmountTDS (1%)SD (5%)On CommissionHydro Testing{{ hold }}GST SD (18%)Final Amount
    {{ invoice.PMC_No }}{{ invoice.Village_Name.capitalize() }}{{ invoice.Work_Type }}{{ invoice.Invoice_Details }}{{ invoice.Invoice_Date }}{{ invoice.Invoice_No }}{{ invoice.Basic_Amount }}{{ invoice.Debit_Amount }}{{ invoice.After_Debit_Amount }}{{ invoice.GST_Amount }}{{ invoice.Amount }}{{ invoice.TDS_Amount }}{{ invoice.SD_Amount }}{{ invoice.On_Commission }}{{ invoice.Hydro_Testing }} + {% if invoice.hold_type == hold %} + {{ invoice.hold_amount }} + {% else %} + 0.00 + {% endif %} + {{ invoice.GST_SD_Amount }}{{ invoice.Final_Amount }}
    Total{{total["sum_invo_basic_amt"]}}{{total["sum_invo_debit_amt"]}}{{total["sum_invo_after_debit_amt"]}}{{total["sum_invo_gst_amt"]}}{{total["sum_invo_amt"]}}{{total["sum_invo_tds_amt"]}}{{total["sum_invo_ds_amt"]}}{{total["sum_invo_on_commission"]}}{{total["sum_invo_hydro_test"]}}{{total["sum_invo_hold_amt"]}}{{total["sum_invo_gst_sd_amt"]}}{{total["sum_invo_final_amt"]}}
    No invoices found.
    + +

    Hold Release

    + + + + + + + + + + + + + {% if hold_release %} + {% for hold in hold_release %} + + + + + + + + + {% endfor %} + {% else %} + + + + {% endif %} + +
    PMC NoInvoice NoInvoice DetailsBasic AmountTotal AmountUTR
    {{ hold['PMC_No'] }}{{ hold['Invoice_No'] }}{{ hold['Invoice_Details'] }}{{ hold['Basic_Amount'] }}{{ hold['Total_Amount'] }}{{ hold['UTR'] }}
    No data present
    +
    + + + +

    Credit Details

    + + + + + + + + + + + + + + + + + + + {% if credit_note %} + {% for credit in credit_note %} + + + + + + + + + + + + + + + + {% endfor %} + + {% else %} + + + + {% endif %} + + + +
    PMC NoInvoice DetailsBasic AmountDebitAfter Debit AmtGST AmountAmountFinal AmountPayment AmountTotal AmountUTR
    {{ credit["PMC_No"] }}{{ credit["Invoice_Details"] }}{{ credit["Basic_Amount"] }}{{ credit["Debit_Amount"] }}{{ credit["After_Debit_Amount"] }}{{ credit["GST_Amount"] }}{{ credit["Amount"] }}{{ credit["Final_Amount"] }}{{ credit["Payment_Amount"] }}{{ credit["Total_Amount"] }}{{ credit["UTR"] }}
    No Credit note found.
    +

    GST Release Note Details

    + + + + + + + + + + + + + {% if gst_rel %} + {% for gst in gst_rel %} + + + + + + + {% endfor %} + + + + + + + {% else %} + + + + {% endif %} + +
    PMC NoInvoice NoBasic AmountFinal Amount
    {{ gst.pmc_no }}{{ gst.invoice_no }}{{ gst.basic_amount }}{{ gst.final_amount }}
    Total{{total["sum_gst_basic_amt"]}}{{total["sum_gst_final_amt"]}}
    No GST release found.
    + + +
    +

    Payment Details

    + + + + + + + + + + + + + {% if payments %} + {% for pay in payments %} + + + + + + + + + {% endfor %} + + + + + + + + + {% else %} + + + + + {% endif %} + + +
    PMC NoInvoice NoAmountTDS Amount @ 1% on BASIC AMOUNTTotal Amount PaidUTR
    {{ pay.pmc_no }}{{ pay.invoice_no }}{{ pay.Payment_Amount }}{{ pay.TDS_Payment_Amount }}{{ pay.Total_amount }}{{ pay.utr}}
    Total{{total["sum_pay_payment_amt"]}}{{total["sum_pay_tds_payment_amt"]}}{{total["sum_pay_total_amt"]}}
    No payment found.
    + + + Download Report +
    + +{% endblock %} \ No newline at end of file diff --git a/templates/uploadExcelFile.html b/templates/uploadExcelFile.html new file mode 100644 index 0000000..47c3a5b --- /dev/null +++ b/templates/uploadExcelFile.html @@ -0,0 +1,24 @@ +{% extends 'base.html' %} +{% block content %} + + + + Upload Excel File + + + + + +

    Upload Excel File

    +
    +
    + +

    + +
    +
    + + + +{% endblock %} diff --git a/uploads/(DONE) 51491 - Payment Reconcilation - Supernetics Infratech India Pvt. Ltd. - Gagour & Bedkheri Village, Shamli- Pipeline laying work.xlsx b/uploads/(DONE) 51491 - Payment Reconcilation - Supernetics Infratech India Pvt. Ltd. - Gagour & Bedkheri Village, Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..a4e6e7c Binary files /dev/null and b/uploads/(DONE) 51491 - Payment Reconcilation - Supernetics Infratech India Pvt. Ltd. - Gagour & Bedkheri Village, Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/(DONE) 54246- Payment Reconcilation - hariom contractor-Darghapur-Pump house work-Shamali.xlsx b/uploads/(DONE) 54246- Payment Reconcilation - hariom contractor-Darghapur-Pump house work-Shamali.xlsx new file mode 100644 index 0000000..2d71e5f Binary files /dev/null and b/uploads/(DONE) 54246- Payment Reconcilation - hariom contractor-Darghapur-Pump house work-Shamali.xlsx differ diff --git a/uploads/(DONE) 56722 - Payment Reconcilation -hari om construction -Manakpur Yunispur Village -Shamali- Pump House work.xlsx b/uploads/(DONE) 56722 - Payment Reconcilation -hari om construction -Manakpur Yunispur Village -Shamali- Pump House work.xlsx new file mode 100644 index 0000000..af66317 Binary files /dev/null and b/uploads/(DONE) 56722 - Payment Reconcilation -hari om construction -Manakpur Yunispur Village -Shamali- Pump House work.xlsx differ diff --git a/uploads/(DONE) 59154-SWSM-SHAMLI-Ms Gaffar remove borepipe miyan kasba.xlsx b/uploads/(DONE) 59154-SWSM-SHAMLI-Ms Gaffar remove borepipe miyan kasba.xlsx new file mode 100644 index 0000000..5c8762d Binary files /dev/null and b/uploads/(DONE) 59154-SWSM-SHAMLI-Ms Gaffar remove borepipe miyan kasba.xlsx differ diff --git a/uploads/(DONE) 59527 - WESTIN INFRA.xlsx b/uploads/(DONE) 59527 - WESTIN INFRA.xlsx new file mode 100644 index 0000000..69ba0e1 Binary files /dev/null and b/uploads/(DONE) 59527 - WESTIN INFRA.xlsx differ diff --git a/uploads/(DONE) A J Contractor.xlsx b/uploads/(DONE) A J Contractor.xlsx new file mode 100644 index 0000000..546bcba Binary files /dev/null and b/uploads/(DONE) A J Contractor.xlsx differ diff --git a/uploads/(DONE) A one machinery store.xlsx b/uploads/(DONE) A one machinery store.xlsx new file mode 100644 index 0000000..348b78a Binary files /dev/null and b/uploads/(DONE) A one machinery store.xlsx differ diff --git a/uploads/(DONE) A.K. Enterprises.xlsx b/uploads/(DONE) A.K. Enterprises.xlsx new file mode 100644 index 0000000..6982cb4 Binary files /dev/null and b/uploads/(DONE) A.K. Enterprises.xlsx differ diff --git a/uploads/(DONE) A.K. Fabrication.xlsx b/uploads/(DONE) A.K. Fabrication.xlsx new file mode 100644 index 0000000..bd13307 Binary files /dev/null and b/uploads/(DONE) A.K. Fabrication.xlsx differ diff --git a/uploads/(DONE) Aarham Enterprises.xlsx b/uploads/(DONE) Aarham Enterprises.xlsx new file mode 100644 index 0000000..2844693 Binary files /dev/null and b/uploads/(DONE) Aarham Enterprises.xlsx differ diff --git a/uploads/(DONE) Aashirwad Enterprises.xlsx b/uploads/(DONE) Aashirwad Enterprises.xlsx new file mode 100644 index 0000000..7fd4e58 Binary files /dev/null and b/uploads/(DONE) Aashirwad Enterprises.xlsx differ diff --git a/uploads/(DONE) Ajay Kumar contractor.xlsx b/uploads/(DONE) Ajay Kumar contractor.xlsx new file mode 100644 index 0000000..acbf80b Binary files /dev/null and b/uploads/(DONE) Ajay Kumar contractor.xlsx differ diff --git a/uploads/(DONE) Akram.xlsx b/uploads/(DONE) Akram.xlsx new file mode 100644 index 0000000..21e834c Binary files /dev/null and b/uploads/(DONE) Akram.xlsx differ diff --git a/uploads/(DONE) Alaf Enterprises.xlsx b/uploads/(DONE) Alaf Enterprises.xlsx new file mode 100644 index 0000000..464aad5 Binary files /dev/null and b/uploads/(DONE) Alaf Enterprises.xlsx differ diff --git a/uploads/(DONE) Alam Energy and construction.xlsx b/uploads/(DONE) Alam Energy and construction.xlsx new file mode 100644 index 0000000..b6a7fbb Binary files /dev/null and b/uploads/(DONE) Alam Energy and construction.xlsx differ diff --git a/uploads/1.Rajdhani Service Error (1).xlsx b/uploads/1.Rajdhani Service Error (1).xlsx new file mode 100644 index 0000000..3849dcb Binary files /dev/null and b/uploads/1.Rajdhani Service Error (1).xlsx differ diff --git a/uploads/1.Rajdhani Service Error.xlsx b/uploads/1.Rajdhani Service Error.xlsx new file mode 100644 index 0000000..3849dcb Binary files /dev/null and b/uploads/1.Rajdhani Service Error.xlsx differ diff --git a/uploads/50411 - Payment Reconcilation - Prashi Technologies - Karori Mehrampur Village, Shamli- Pipeline laying work.xlsx b/uploads/50411 - Payment Reconcilation - Prashi Technologies - Karori Mehrampur Village, Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..23a6ff1 Binary files /dev/null and b/uploads/50411 - Payment Reconcilation - Prashi Technologies - Karori Mehrampur Village, Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/50747 - Payment Reconcilation - Rana Security - MZN.xlsx b/uploads/50747 - Payment Reconcilation - Rana Security - MZN.xlsx new file mode 100644 index 0000000..2032feb Binary files /dev/null and b/uploads/50747 - Payment Reconcilation - Rana Security - MZN.xlsx differ diff --git a/uploads/50931 - Payment Reconcilation - Frotech Services -RTU Panel-Shamli.xlsx b/uploads/50931 - Payment Reconcilation - Frotech Services -RTU Panel-Shamli.xlsx new file mode 100644 index 0000000..19809a7 Binary files /dev/null and b/uploads/50931 - Payment Reconcilation - Frotech Services -RTU Panel-Shamli.xlsx differ diff --git a/uploads/50938 - Payment Reconcilation -Sumstar Management Pipe Line Laying Work At Chokda Village.xlsx b/uploads/50938 - Payment Reconcilation -Sumstar Management Pipe Line Laying Work At Chokda Village.xlsx new file mode 100644 index 0000000..92f2337 Binary files /dev/null and b/uploads/50938 - Payment Reconcilation -Sumstar Management Pipe Line Laying Work At Chokda Village.xlsx differ diff --git a/uploads/51215 - Payment Reconcilation - Janta Boring Engineering Works - MZN- Pea Gravel supplier.xlsx b/uploads/51215 - Payment Reconcilation - Janta Boring Engineering Works - MZN- Pea Gravel supplier.xlsx new file mode 100644 index 0000000..95b6164 Binary files /dev/null and b/uploads/51215 - Payment Reconcilation - Janta Boring Engineering Works - MZN- Pea Gravel supplier.xlsx differ diff --git a/uploads/51241- Payment Reconcilation -Harminder Singh- Bhaisani VILLAGE- MZN.xlsx b/uploads/51241- Payment Reconcilation -Harminder Singh- Bhaisani VILLAGE- MZN.xlsx new file mode 100644 index 0000000..e559aa2 Binary files /dev/null and b/uploads/51241- Payment Reconcilation -Harminder Singh- Bhaisani VILLAGE- MZN.xlsx differ diff --git a/uploads/51471 - Payment Reconcilation -KRISH ENTERPRISES -Mandi Village,mzn- Drilling work.xlsx b/uploads/51471 - Payment Reconcilation -KRISH ENTERPRISES -Mandi Village,mzn- Drilling work.xlsx new file mode 100644 index 0000000..17c75c7 Binary files /dev/null and b/uploads/51471 - Payment Reconcilation -KRISH ENTERPRISES -Mandi Village,mzn- Drilling work.xlsx differ diff --git a/uploads/51491 - Payment Reconcilation - Supernetics Infratech India Pvt. Ltd. - Gagour & Bedkheri Village, Shamli- Pipeline laying work.xlsx b/uploads/51491 - Payment Reconcilation - Supernetics Infratech India Pvt. Ltd. - Gagour & Bedkheri Village, Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..a4e6e7c Binary files /dev/null and b/uploads/51491 - Payment Reconcilation - Supernetics Infratech India Pvt. Ltd. - Gagour & Bedkheri Village, Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/51700 - Payment Reconcilation - Technocrat Drillers - Muzaffarnagar MZN- Drilling work.xlsx b/uploads/51700 - Payment Reconcilation - Technocrat Drillers - Muzaffarnagar MZN- Drilling work.xlsx new file mode 100644 index 0000000..e51d664 Binary files /dev/null and b/uploads/51700 - Payment Reconcilation - Technocrat Drillers - Muzaffarnagar MZN- Drilling work.xlsx differ diff --git a/uploads/52160-SWSM-SHAMLI-Rama Traders-Supply Of Chain Blocks.xlsx b/uploads/52160-SWSM-SHAMLI-Rama Traders-Supply Of Chain Blocks.xlsx new file mode 100644 index 0000000..cdc1531 Binary files /dev/null and b/uploads/52160-SWSM-SHAMLI-Rama Traders-Supply Of Chain Blocks.xlsx differ diff --git a/uploads/52162 - Payment Reconcilation - Kanha Construtction - Kelashikarpur - Village, Shamli - Pipeline laying work.xlsx b/uploads/52162 - Payment Reconcilation - Kanha Construtction - Kelashikarpur - Village, Shamli - Pipeline laying work.xlsx new file mode 100644 index 0000000..bf38ecb Binary files /dev/null and b/uploads/52162 - Payment Reconcilation - Kanha Construtction - Kelashikarpur - Village, Shamli - Pipeline laying work.xlsx differ diff --git a/uploads/52273 - Payment Reconcilation - Sahzad Contractor - Dhanena Village, Shamli- Drilling work.xlsx b/uploads/52273 - Payment Reconcilation - Sahzad Contractor - Dhanena Village, Shamli- Drilling work.xlsx new file mode 100644 index 0000000..52bf9fb Binary files /dev/null and b/uploads/52273 - Payment Reconcilation - Sahzad Contractor - Dhanena Village, Shamli- Drilling work.xlsx differ diff --git a/uploads/52656 - Payment Reconcilation - J R Enterprises - Ulhani BinaMazra Village, Shamli- Pipeline laying work.xlsx b/uploads/52656 - Payment Reconcilation - J R Enterprises - Ulhani BinaMazra Village, Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..41413cf Binary files /dev/null and b/uploads/52656 - Payment Reconcilation - J R Enterprises - Ulhani BinaMazra Village, Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/52700 - Payment Reconcilation - U N Construction - Kherki Village - SHA- Pump House work.xlsx b/uploads/52700 - Payment Reconcilation - U N Construction - Kherki Village - SHA- Pump House work.xlsx new file mode 100644 index 0000000..fa45ea3 Binary files /dev/null and b/uploads/52700 - Payment Reconcilation - U N Construction - Kherki Village - SHA- Pump House work.xlsx differ diff --git a/uploads/52708 - Payment Reconcilation - Indraj Tractor Trolly - Shamli- Tractor hiring charges. (1).xlsx b/uploads/52708 - Payment Reconcilation - Indraj Tractor Trolly - Shamli- Tractor hiring charges. (1).xlsx new file mode 100644 index 0000000..1b1644e Binary files /dev/null and b/uploads/52708 - Payment Reconcilation - Indraj Tractor Trolly - Shamli- Tractor hiring charges. (1).xlsx differ diff --git a/uploads/52747 - Payment Reconcilation - Malik Ji Traders - Kasiyara Village - MZN- Pipe laying work.xlsx b/uploads/52747 - Payment Reconcilation - Malik Ji Traders - Kasiyara Village - MZN- Pipe laying work.xlsx new file mode 100644 index 0000000..0a5940b Binary files /dev/null and b/uploads/52747 - Payment Reconcilation - Malik Ji Traders - Kasiyara Village - MZN- Pipe laying work.xlsx differ diff --git a/uploads/52819 - Payment Reconcilation - Vardhan Enterprises - Khera Kurtan Village, Shamli- Pipeline laying work.xlsx b/uploads/52819 - Payment Reconcilation - Vardhan Enterprises - Khera Kurtan Village, Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..d4a9f7b Binary files /dev/null and b/uploads/52819 - Payment Reconcilation - Vardhan Enterprises - Khera Kurtan Village, Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/52885 - Payment Reconcilation - Rav Cement Agency - Jharkheri Village, Shamli- Pipeline laying work.xlsx b/uploads/52885 - Payment Reconcilation - Rav Cement Agency - Jharkheri Village, Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..473d187 Binary files /dev/null and b/uploads/52885 - Payment Reconcilation - Rav Cement Agency - Jharkheri Village, Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/53037 - Payment Reconcilation - krishna construction -Tana-Pump house work-shamali.xlsx b/uploads/53037 - Payment Reconcilation - krishna construction -Tana-Pump house work-shamali.xlsx new file mode 100644 index 0000000..53dafc2 Binary files /dev/null and b/uploads/53037 - Payment Reconcilation - krishna construction -Tana-Pump house work-shamali.xlsx differ diff --git a/uploads/53083 - Payment Reconciliation - ROAD RESTORATION WORK AT BALWAKHEDI - SHIV SATRING.xlsx b/uploads/53083 - Payment Reconciliation - ROAD RESTORATION WORK AT BALWAKHEDI - SHIV SATRING.xlsx new file mode 100644 index 0000000..f9ad19d Binary files /dev/null and b/uploads/53083 - Payment Reconciliation - ROAD RESTORATION WORK AT BALWAKHEDI - SHIV SATRING.xlsx differ diff --git a/uploads/53293- Payment Reconcilation -Shri Raj construction-samuli Village - MZN- Pipe laying work.xlsx b/uploads/53293- Payment Reconcilation -Shri Raj construction-samuli Village - MZN- Pipe laying work.xlsx new file mode 100644 index 0000000..3ddbbec Binary files /dev/null and b/uploads/53293- Payment Reconcilation -Shri Raj construction-samuli Village - MZN- Pipe laying work.xlsx differ diff --git a/uploads/53526 - Payment Reconcilation - M K Traders - Dhatera Village, Shamli - Balance Pipeline laying work updated.xlsx b/uploads/53526 - Payment Reconcilation - M K Traders - Dhatera Village, Shamli - Balance Pipeline laying work updated.xlsx new file mode 100644 index 0000000..2641369 Binary files /dev/null and b/uploads/53526 - Payment Reconcilation - M K Traders - Dhatera Village, Shamli - Balance Pipeline laying work updated.xlsx differ diff --git a/uploads/53671 - Payment Reconcilation -JSR ENGINEERING SERVICES - AMBETHA RIDAAN - Shamli- Pipe laying work.xlsx b/uploads/53671 - Payment Reconcilation -JSR ENGINEERING SERVICES - AMBETHA RIDAAN - Shamli- Pipe laying work.xlsx new file mode 100644 index 0000000..50410c6 Binary files /dev/null and b/uploads/53671 - Payment Reconcilation -JSR ENGINEERING SERVICES - AMBETHA RIDAAN - Shamli- Pipe laying work.xlsx differ diff --git a/uploads/53794 - Payment Reconcilation - BPM Security & Manpower Services - Shamli- Security work.xlsx b/uploads/53794 - Payment Reconcilation - BPM Security & Manpower Services - Shamli- Security work.xlsx new file mode 100644 index 0000000..27706c9 Binary files /dev/null and b/uploads/53794 - Payment Reconcilation - BPM Security & Manpower Services - Shamli- Security work.xlsx differ diff --git a/uploads/53820 - Payment Reconcilation - Ravindra Pal Singh Contractor - Subri Thali Village, Shamli- Pipeline laying work.xlsx b/uploads/53820 - Payment Reconcilation - Ravindra Pal Singh Contractor - Subri Thali Village, Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..1323bea Binary files /dev/null and b/uploads/53820 - Payment Reconcilation - Ravindra Pal Singh Contractor - Subri Thali Village, Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/53869 - Payment Reconcilation -Saini contractor - Loharipur Village -Shamali- Pump House work.xlsx b/uploads/53869 - Payment Reconcilation -Saini contractor - Loharipur Village -Shamali- Pump House work.xlsx new file mode 100644 index 0000000..37404a9 Binary files /dev/null and b/uploads/53869 - Payment Reconcilation -Saini contractor - Loharipur Village -Shamali- Pump House work.xlsx differ diff --git a/uploads/53886 - Payment Reconcilation - Parveen kumar thekedar - Rohana khurd village - MZN- Pipe laying work.xlsx b/uploads/53886 - Payment Reconcilation - Parveen kumar thekedar - Rohana khurd village - MZN- Pipe laying work.xlsx new file mode 100644 index 0000000..8d9f158 Binary files /dev/null and b/uploads/53886 - Payment Reconcilation - Parveen kumar thekedar - Rohana khurd village - MZN- Pipe laying work.xlsx differ diff --git a/uploads/53888 - Payment Reconcilation - R R system - MZN- Khalwara Village - Pipe laying work.xlsx b/uploads/53888 - Payment Reconcilation - R R system - MZN- Khalwara Village - Pipe laying work.xlsx new file mode 100644 index 0000000..a87f7ad Binary files /dev/null and b/uploads/53888 - Payment Reconcilation - R R system - MZN- Khalwara Village - Pipe laying work.xlsx differ diff --git a/uploads/53888 - Payment Reconcilation - R R system - invoice number 1 &2 storing in data base but feacing issue in downloading.xlsx b/uploads/53888 - Payment Reconcilation - R R system - invoice number 1 &2 storing in data base but feacing issue in downloading.xlsx new file mode 100644 index 0000000..23abc9a Binary files /dev/null and b/uploads/53888 - Payment Reconcilation - R R system - invoice number 1 &2 storing in data base but feacing issue in downloading.xlsx differ diff --git a/uploads/54216 - Payment Reconcilation -Balaji Enterprises- Badhupura-Pump house work-shamali.xlsx b/uploads/54216 - Payment Reconcilation -Balaji Enterprises- Badhupura-Pump house work-shamali.xlsx new file mode 100644 index 0000000..9edf019 Binary files /dev/null and b/uploads/54216 - Payment Reconcilation -Balaji Enterprises- Badhupura-Pump house work-shamali.xlsx differ diff --git a/uploads/54241- Payment Reconcilation -Panchal technology engineers- Mwi non Ahatmal Village - shamli- Pipe laying work.xlsx b/uploads/54241- Payment Reconcilation -Panchal technology engineers- Mwi non Ahatmal Village - shamli- Pipe laying work.xlsx new file mode 100644 index 0000000..af2db60 Binary files /dev/null and b/uploads/54241- Payment Reconcilation -Panchal technology engineers- Mwi non Ahatmal Village - shamli- Pipe laying work.xlsx differ diff --git a/uploads/54246- Payment Reconcilation - hariom contractor-Darghapur-Pump house work-Shamali.xlsx b/uploads/54246- Payment Reconcilation - hariom contractor-Darghapur-Pump house work-Shamali.xlsx new file mode 100644 index 0000000..2d71e5f Binary files /dev/null and b/uploads/54246- Payment Reconcilation - hariom contractor-Darghapur-Pump house work-Shamali.xlsx differ diff --git a/uploads/54369 - Payment Reconcilation - vinayak associates - Muzaffarnagar MZN- Pea gravel.xlsx b/uploads/54369 - Payment Reconcilation - vinayak associates - Muzaffarnagar MZN- Pea gravel.xlsx new file mode 100644 index 0000000..2583a6e Binary files /dev/null and b/uploads/54369 - Payment Reconcilation - vinayak associates - Muzaffarnagar MZN- Pea gravel.xlsx differ diff --git a/uploads/54996- Payment Reconcilation -Ifra construction -Parai Village -MZN- OHT Constrution.xlsx b/uploads/54996- Payment Reconcilation -Ifra construction -Parai Village -MZN- OHT Constrution.xlsx new file mode 100644 index 0000000..6bb4827 Binary files /dev/null and b/uploads/54996- Payment Reconcilation -Ifra construction -Parai Village -MZN- OHT Constrution.xlsx differ diff --git a/uploads/55358 - Payment Reconcilation - B R contractor - Chourawala village - MZN- Pipe laying work.xlsx b/uploads/55358 - Payment Reconcilation - B R contractor - Chourawala village - MZN- Pipe laying work.xlsx new file mode 100644 index 0000000..69d21f1 Binary files /dev/null and b/uploads/55358 - Payment Reconcilation - B R contractor - Chourawala village - MZN- Pipe laying work.xlsx differ diff --git a/uploads/55436- Payment Reconcilation -Maanuday global PVT LTD-Kaserwa khurd Village - shamli- Pipe laying work.xlsx b/uploads/55436- Payment Reconcilation -Maanuday global PVT LTD-Kaserwa khurd Village - shamli- Pipe laying work.xlsx new file mode 100644 index 0000000..7c60244 Binary files /dev/null and b/uploads/55436- Payment Reconcilation -Maanuday global PVT LTD-Kaserwa khurd Village - shamli- Pipe laying work.xlsx differ diff --git a/uploads/55649 - Payment Reconcilation - Harsh Contractor - Haidarnagar Jamalpur Village - MZN- Pump House work.xlsx b/uploads/55649 - Payment Reconcilation - Harsh Contractor - Haidarnagar Jamalpur Village - MZN- Pump House work.xlsx new file mode 100644 index 0000000..bef1567 Binary files /dev/null and b/uploads/55649 - Payment Reconcilation - Harsh Contractor - Haidarnagar Jamalpur Village - MZN- Pump House work.xlsx differ diff --git a/uploads/55778- Payment Reconcilation - Jai Nityanand Construction-Ratanpuri-OHT (2).xlsx b/uploads/55778- Payment Reconcilation - Jai Nityanand Construction-Ratanpuri-OHT (2).xlsx new file mode 100644 index 0000000..84de69e Binary files /dev/null and b/uploads/55778- Payment Reconcilation - Jai Nityanand Construction-Ratanpuri-OHT (2).xlsx differ diff --git a/uploads/56004 - Payment Reconcilation - R.K. contractor- Saidipur raju Village - MZN- Pipe laying work.xlsx b/uploads/56004 - Payment Reconcilation - R.K. contractor- Saidipur raju Village - MZN- Pipe laying work.xlsx new file mode 100644 index 0000000..ec2c251 Binary files /dev/null and b/uploads/56004 - Payment Reconcilation - R.K. contractor- Saidipur raju Village - MZN- Pipe laying work.xlsx differ diff --git a/uploads/56246 - Payment Reconcilation -Khatu ji construction -DG platform work-shamli.xlsx b/uploads/56246 - Payment Reconcilation -Khatu ji construction -DG platform work-shamli.xlsx new file mode 100644 index 0000000..3b8a2df Binary files /dev/null and b/uploads/56246 - Payment Reconcilation -Khatu ji construction -DG platform work-shamli.xlsx differ diff --git a/uploads/56255 - Payment Reconcilation - Jayaram Rai-Abhishek Upadhay - Shamli - DG foundation.xlsx b/uploads/56255 - Payment Reconcilation - Jayaram Rai-Abhishek Upadhay - Shamli - DG foundation.xlsx new file mode 100644 index 0000000..4d8ec92 Binary files /dev/null and b/uploads/56255 - Payment Reconcilation - Jayaram Rai-Abhishek Upadhay - Shamli - DG foundation.xlsx differ diff --git a/uploads/56328 JB Constructions - MZN- Pea Gravel Purchase.xlsx b/uploads/56328 JB Constructions - MZN- Pea Gravel Purchase.xlsx new file mode 100644 index 0000000..30ccf19 Binary files /dev/null and b/uploads/56328 JB Constructions - MZN- Pea Gravel Purchase.xlsx differ diff --git a/uploads/56707 - Payment Reconcilation - Pradeep kumar managal-Gate purchase-shamali.xlsx b/uploads/56707 - Payment Reconcilation - Pradeep kumar managal-Gate purchase-shamali.xlsx new file mode 100644 index 0000000..1f35ed9 Binary files /dev/null and b/uploads/56707 - Payment Reconcilation - Pradeep kumar managal-Gate purchase-shamali.xlsx differ diff --git a/uploads/56714 - Payment Reconcilation - Subodh tyagi construction- shamali- Jalalpur Village - OHT Construction work.xlsx b/uploads/56714 - Payment Reconcilation - Subodh tyagi construction- shamali- Jalalpur Village - OHT Construction work.xlsx new file mode 100644 index 0000000..d207394 Binary files /dev/null and b/uploads/56714 - Payment Reconcilation - Subodh tyagi construction- shamali- Jalalpur Village - OHT Construction work.xlsx differ diff --git a/uploads/56722 - Payment Reconcilation -hari om construction -Manakpur Yunispur Village -Shamali- Pump House work.xlsx b/uploads/56722 - Payment Reconcilation -hari om construction -Manakpur Yunispur Village -Shamali- Pump House work.xlsx new file mode 100644 index 0000000..af66317 Binary files /dev/null and b/uploads/56722 - Payment Reconcilation -hari om construction -Manakpur Yunispur Village -Shamali- Pump House work.xlsx differ diff --git a/uploads/57281 - Payment Reconcilation - Rafe khan-Kasauli- Village -Morna - MZN- Pipe laying work.xlsx b/uploads/57281 - Payment Reconcilation - Rafe khan-Kasauli- Village -Morna - MZN- Pipe laying work.xlsx new file mode 100644 index 0000000..f642db6 Binary files /dev/null and b/uploads/57281 - Payment Reconcilation - Rafe khan-Kasauli- Village -Morna - MZN- Pipe laying work.xlsx differ diff --git a/uploads/57451- Payment Reconcilation - MAA DURGA ENTERPRISES- SANPALA Village, Shamli- Pipeline laying work.xlsx b/uploads/57451- Payment Reconcilation - MAA DURGA ENTERPRISES- SANPALA Village, Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..6ebadfe Binary files /dev/null and b/uploads/57451- Payment Reconcilation - MAA DURGA ENTERPRISES- SANPALA Village, Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/57577 - Payment Reconciliation -PIPE LINE WORK WORK MULLAPUR VILLAGE -SHAMLI-R K CONTRACTOR.xlsx b/uploads/57577 - Payment Reconciliation -PIPE LINE WORK WORK MULLAPUR VILLAGE -SHAMLI-R K CONTRACTOR.xlsx new file mode 100644 index 0000000..ec8db7d Binary files /dev/null and b/uploads/57577 - Payment Reconciliation -PIPE LINE WORK WORK MULLAPUR VILLAGE -SHAMLI-R K CONTRACTOR.xlsx differ diff --git a/uploads/57644 - Payment Reconcilation - S.K.Tubewell Engineers and Construction - Bamnoli Village, Shamli - Tubrwell debvelopment work.xlsx b/uploads/57644 - Payment Reconcilation - S.K.Tubewell Engineers and Construction - Bamnoli Village, Shamli - Tubrwell debvelopment work.xlsx new file mode 100644 index 0000000..c5cf6b4 Binary files /dev/null and b/uploads/57644 - Payment Reconcilation - S.K.Tubewell Engineers and Construction - Bamnoli Village, Shamli - Tubrwell debvelopment work.xlsx differ diff --git a/uploads/57795- Payment Reconcilation - VIDESHI LAL VERMA - ISSOPUR TEEL Village - Shamli- Pipeline laying work.xlsx b/uploads/57795- Payment Reconcilation - VIDESHI LAL VERMA - ISSOPUR TEEL Village - Shamli- Pipeline laying work.xlsx new file mode 100644 index 0000000..0a77db3 Binary files /dev/null and b/uploads/57795- Payment Reconcilation - VIDESHI LAL VERMA - ISSOPUR TEEL Village - Shamli- Pipeline laying work.xlsx differ diff --git a/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work --issue.xlsx b/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work --issue.xlsx new file mode 100644 index 0000000..efe7b41 Binary files /dev/null and b/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work --issue.xlsx differ diff --git a/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work 1.xlsx b/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work 1.xlsx new file mode 100644 index 0000000..1372d66 Binary files /dev/null and b/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work 1.xlsx differ diff --git a/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work.xlsx b/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work.xlsx new file mode 100644 index 0000000..e9b3930 Binary files /dev/null and b/uploads/57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work.xlsx differ diff --git a/uploads/57936- Payment Reconcilation -SHAKUMBARI ENTERPRISES - Air Compressor and OP unit work-shamli.xlsx b/uploads/57936- Payment Reconcilation -SHAKUMBARI ENTERPRISES - Air Compressor and OP unit work-shamli.xlsx new file mode 100644 index 0000000..fef1956 Binary files /dev/null and b/uploads/57936- Payment Reconcilation -SHAKUMBARI ENTERPRISES - Air Compressor and OP unit work-shamli.xlsx differ diff --git a/uploads/58062 - Payment Reconcilation -Rana Constcuction- Adampur Village- SHAMLI- Pipeline laying work.xlsx b/uploads/58062 - Payment Reconcilation -Rana Constcuction- Adampur Village- SHAMLI- Pipeline laying work.xlsx new file mode 100644 index 0000000..0d44111 Binary files /dev/null and b/uploads/58062 - Payment Reconcilation -Rana Constcuction- Adampur Village- SHAMLI- Pipeline laying work.xlsx differ diff --git a/uploads/58093- Payment Reconcilation -Lokesh Kumar- AMBETHARIDAN Village -Shamali- Pump House work.xlsx b/uploads/58093- Payment Reconcilation -Lokesh Kumar- AMBETHARIDAN Village -Shamali- Pump House work.xlsx new file mode 100644 index 0000000..a67ae12 Binary files /dev/null and b/uploads/58093- Payment Reconcilation -Lokesh Kumar- AMBETHARIDAN Village -Shamali- Pump House work.xlsx differ diff --git a/uploads/58182- Payment Reconciliation -BALANCE WORK OF ROAD REINSTATEMENT AT AMBEPUR MATHEDI BLOCK - KHATAULI -MZN- Mahadev Traders.xlsx b/uploads/58182- Payment Reconciliation -BALANCE WORK OF ROAD REINSTATEMENT AT AMBEPUR MATHEDI BLOCK - KHATAULI -MZN- Mahadev Traders.xlsx new file mode 100644 index 0000000..2918843 Binary files /dev/null and b/uploads/58182- Payment Reconciliation -BALANCE WORK OF ROAD REINSTATEMENT AT AMBEPUR MATHEDI BLOCK - KHATAULI -MZN- Mahadev Traders.xlsx differ diff --git a/uploads/58576 - Payment Reconcilation - Dushyant Kunar -Sikhreda Village - MZN- Pipe laying work.xlsx b/uploads/58576 - Payment Reconcilation - Dushyant Kunar -Sikhreda Village - MZN- Pipe laying work.xlsx new file mode 100644 index 0000000..5d03f89 Binary files /dev/null and b/uploads/58576 - Payment Reconcilation - Dushyant Kunar -Sikhreda Village - MZN- Pipe laying work.xlsx differ diff --git a/uploads/58644 - Payment Reconcilation -R K Traders - Athai village - MZN- Road restoration work invoice number 1,3.xlsx b/uploads/58644 - Payment Reconcilation -R K Traders - Athai village - MZN- Road restoration work invoice number 1,3.xlsx new file mode 100644 index 0000000..ceffebd Binary files /dev/null and b/uploads/58644 - Payment Reconcilation -R K Traders - Athai village - MZN- Road restoration work invoice number 1,3.xlsx differ diff --git a/uploads/58644 - Payment Reconcilation -R K Traders - Athai village - MZN- Road restoration work.xlsx b/uploads/58644 - Payment Reconcilation -R K Traders - Athai village - MZN- Road restoration work.xlsx new file mode 100644 index 0000000..ceffebd Binary files /dev/null and b/uploads/58644 - Payment Reconcilation -R K Traders - Athai village - MZN- Road restoration work.xlsx differ diff --git a/uploads/58729- Payment Reconcilation - Shourya Traders - Shamli - Wifi Connection.xlsx b/uploads/58729- Payment Reconcilation - Shourya Traders - Shamli - Wifi Connection.xlsx new file mode 100644 index 0000000..307c415 Binary files /dev/null and b/uploads/58729- Payment Reconcilation - Shourya Traders - Shamli - Wifi Connection.xlsx differ diff --git a/uploads/58886 Lavishh Contractor - NaunagaliVILLAGE- Pipe Line Work- Shamli.xlsx b/uploads/58886 Lavishh Contractor - NaunagaliVILLAGE- Pipe Line Work- Shamli.xlsx new file mode 100644 index 0000000..7bc86f2 Binary files /dev/null and b/uploads/58886 Lavishh Contractor - NaunagaliVILLAGE- Pipe Line Work- Shamli.xlsx differ diff --git a/uploads/58937 - Payment Reconcilation -Lokesh Kumar- AMBETHA RIDAN Village -Shamali- Boundarywall work - Copy.xlsx b/uploads/58937 - Payment Reconcilation -Lokesh Kumar- AMBETHA RIDAN Village -Shamali- Boundarywall work - Copy.xlsx new file mode 100644 index 0000000..3752d97 Binary files /dev/null and b/uploads/58937 - Payment Reconcilation -Lokesh Kumar- AMBETHA RIDAN Village -Shamali- Boundarywall work - Copy.xlsx differ diff --git a/uploads/58938 - Payment Reconcilation -Lokesh Kumar-Ambita Village -Shamali- D.G.Foundation work.xlsx b/uploads/58938 - Payment Reconcilation -Lokesh Kumar-Ambita Village -Shamali- D.G.Foundation work.xlsx new file mode 100644 index 0000000..99242e4 Binary files /dev/null and b/uploads/58938 - Payment Reconcilation -Lokesh Kumar-Ambita Village -Shamali- D.G.Foundation work.xlsx differ diff --git a/uploads/59154-SWSM-SHAMLI-Ms Gaffar remove borepipe miyan kasba.xlsx b/uploads/59154-SWSM-SHAMLI-Ms Gaffar remove borepipe miyan kasba.xlsx new file mode 100644 index 0000000..5c8762d Binary files /dev/null and b/uploads/59154-SWSM-SHAMLI-Ms Gaffar remove borepipe miyan kasba.xlsx differ diff --git a/uploads/59191- Payment Reconcilation -DN engineering - KUTUBPUR Village -MZN- Drilling Work.xlsx b/uploads/59191- Payment Reconcilation -DN engineering - KUTUBPUR Village -MZN- Drilling Work.xlsx new file mode 100644 index 0000000..3df0b0d Binary files /dev/null and b/uploads/59191- Payment Reconcilation -DN engineering - KUTUBPUR Village -MZN- Drilling Work.xlsx differ diff --git a/uploads/59267 - Payment Reconcilation - S,K construction- SHAMLI.xlsx b/uploads/59267 - Payment Reconcilation - S,K construction- SHAMLI.xlsx new file mode 100644 index 0000000..f343c1d Binary files /dev/null and b/uploads/59267 - Payment Reconcilation - S,K construction- SHAMLI.xlsx differ diff --git a/uploads/59276 - Payment Reconcilation - Om India Enterprises - Pipe Laying Work- SHAMLI.xlsx b/uploads/59276 - Payment Reconcilation - Om India Enterprises - Pipe Laying Work- SHAMLI.xlsx new file mode 100644 index 0000000..bc010d3 Binary files /dev/null and b/uploads/59276 - Payment Reconcilation - Om India Enterprises - Pipe Laying Work- SHAMLI.xlsx differ diff --git a/uploads/59291- Payment Reconciliation -BALANCE WORK OF ROAD REINSTATEMENT AT BADKALI VILLAGE -MZN- MOHD.SHAHID.xlsx b/uploads/59291- Payment Reconciliation -BALANCE WORK OF ROAD REINSTATEMENT AT BADKALI VILLAGE -MZN- MOHD.SHAHID.xlsx new file mode 100644 index 0000000..4a77fff Binary files /dev/null and b/uploads/59291- Payment Reconciliation -BALANCE WORK OF ROAD REINSTATEMENT AT BADKALI VILLAGE -MZN- MOHD.SHAHID.xlsx differ diff --git a/uploads/59339 - Payment Reconcilation -Rao Jishan Contractor- peer khra Village- SHAMLI- Pipeline laying work.xlsx b/uploads/59339 - Payment Reconcilation -Rao Jishan Contractor- peer khra Village- SHAMLI- Pipeline laying work.xlsx new file mode 100644 index 0000000..15326e6 Binary files /dev/null and b/uploads/59339 - Payment Reconcilation -Rao Jishan Contractor- peer khra Village- SHAMLI- Pipeline laying work.xlsx differ diff --git a/uploads/59481 - Payment Reconcilation - SS constructions- Thanabhawan Village - SHAMLI - Pipe Laying Work.xlsx b/uploads/59481 - Payment Reconcilation - SS constructions- Thanabhawan Village - SHAMLI - Pipe Laying Work.xlsx new file mode 100644 index 0000000..dc90774 Binary files /dev/null and b/uploads/59481 - Payment Reconcilation - SS constructions- Thanabhawan Village - SHAMLI - Pipe Laying Work.xlsx differ diff --git a/uploads/59527 - WESTIN INFRA.xlsx b/uploads/59527 - WESTIN INFRA.xlsx new file mode 100644 index 0000000..69ba0e1 Binary files /dev/null and b/uploads/59527 - WESTIN INFRA.xlsx differ diff --git a/uploads/59744- Payment Reconcilation - S,T Entrprises- SHAMLI.xlsx b/uploads/59744- Payment Reconcilation - S,T Entrprises- SHAMLI.xlsx new file mode 100644 index 0000000..38457f9 Binary files /dev/null and b/uploads/59744- Payment Reconcilation - S,T Entrprises- SHAMLI.xlsx differ diff --git a/uploads/60059 - Payment Reconcilation - Shiv Shakti Enterprises -Nanheri Village - MZN- Pipe laying work - Copy.xlsx b/uploads/60059 - Payment Reconcilation - Shiv Shakti Enterprises -Nanheri Village - MZN- Pipe laying work - Copy.xlsx new file mode 100644 index 0000000..9bb60aa Binary files /dev/null and b/uploads/60059 - Payment Reconcilation - Shiv Shakti Enterprises -Nanheri Village - MZN- Pipe laying work - Copy.xlsx differ diff --git a/uploads/60066 - Payment Reconciliation -PIPE LINE WORK WORK khorsama VILLAGE -SHAMLI- Saddam CONTRACTOR.xlsx b/uploads/60066 - Payment Reconciliation -PIPE LINE WORK WORK khorsama VILLAGE -SHAMLI- Saddam CONTRACTOR.xlsx new file mode 100644 index 0000000..8c9eb7d Binary files /dev/null and b/uploads/60066 - Payment Reconciliation -PIPE LINE WORK WORK khorsama VILLAGE -SHAMLI- Saddam CONTRACTOR.xlsx differ diff --git a/uploads/60860-SWSM Shamli Service Charge MS Pipe Cutting Work Ms Gaffar.xlsx b/uploads/60860-SWSM Shamli Service Charge MS Pipe Cutting Work Ms Gaffar.xlsx new file mode 100644 index 0000000..5657da9 Binary files /dev/null and b/uploads/60860-SWSM Shamli Service Charge MS Pipe Cutting Work Ms Gaffar.xlsx differ diff --git a/uploads/A & S Enterprises.xlsx b/uploads/A & S Enterprises.xlsx new file mode 100644 index 0000000..861edc1 Binary files /dev/null and b/uploads/A & S Enterprises.xlsx differ diff --git a/uploads/A A enterprises.xlsx b/uploads/A A enterprises.xlsx new file mode 100644 index 0000000..2d9b84b Binary files /dev/null and b/uploads/A A enterprises.xlsx differ diff --git a/uploads/A J Contractor.xlsx b/uploads/A J Contractor.xlsx new file mode 100644 index 0000000..546bcba Binary files /dev/null and b/uploads/A J Contractor.xlsx differ diff --git a/uploads/A K Contractor.xlsx b/uploads/A K Contractor.xlsx new file mode 100644 index 0000000..acb7965 Binary files /dev/null and b/uploads/A K Contractor.xlsx differ diff --git a/uploads/A P Enterprises.xlsx b/uploads/A P Enterprises.xlsx new file mode 100644 index 0000000..bf2ee77 Binary files /dev/null and b/uploads/A P Enterprises.xlsx differ diff --git a/uploads/A P enterprises N.xlsx b/uploads/A P enterprises N.xlsx new file mode 100644 index 0000000..a0e622f Binary files /dev/null and b/uploads/A P enterprises N.xlsx differ diff --git a/uploads/A V A Enterprises.xlsx b/uploads/A V A Enterprises.xlsx new file mode 100644 index 0000000..a19b6a7 Binary files /dev/null and b/uploads/A V A Enterprises.xlsx differ diff --git a/uploads/A one machinery store.xlsx b/uploads/A one machinery store.xlsx new file mode 100644 index 0000000..348b78a Binary files /dev/null and b/uploads/A one machinery store.xlsx differ diff --git a/uploads/A.K. Enterprises.xlsx b/uploads/A.K. Enterprises.xlsx new file mode 100644 index 0000000..6982cb4 Binary files /dev/null and b/uploads/A.K. Enterprises.xlsx differ diff --git a/uploads/A.K. Fabrication.xlsx b/uploads/A.K. Fabrication.xlsx new file mode 100644 index 0000000..bd13307 Binary files /dev/null and b/uploads/A.K. Fabrication.xlsx differ diff --git a/uploads/A.K. Saini Construction.xlsx b/uploads/A.K. Saini Construction.xlsx new file mode 100644 index 0000000..072525f Binary files /dev/null and b/uploads/A.K. Saini Construction.xlsx differ diff --git a/uploads/AAR Infratech.xlsx b/uploads/AAR Infratech.xlsx new file mode 100644 index 0000000..4e40bd4 Binary files /dev/null and b/uploads/AAR Infratech.xlsx differ diff --git a/uploads/AARHAM INTERNATIONAL.xlsx b/uploads/AARHAM INTERNATIONAL.xlsx new file mode 100644 index 0000000..344eb69 Binary files /dev/null and b/uploads/AARHAM INTERNATIONAL.xlsx differ diff --git a/uploads/AH Rao Contractor.xlsx b/uploads/AH Rao Contractor.xlsx new file mode 100644 index 0000000..e5c430e Binary files /dev/null and b/uploads/AH Rao Contractor.xlsx differ diff --git a/uploads/AK Contractor.xlsx b/uploads/AK Contractor.xlsx new file mode 100644 index 0000000..ac3b884 Binary files /dev/null and b/uploads/AK Contractor.xlsx differ diff --git a/uploads/ANS CONSTRUCTION.xlsx b/uploads/ANS CONSTRUCTION.xlsx new file mode 100644 index 0000000..5801671 Binary files /dev/null and b/uploads/ANS CONSTRUCTION.xlsx differ diff --git a/uploads/ARS Infrastructure.xlsx b/uploads/ARS Infrastructure.xlsx new file mode 100644 index 0000000..0a23bba Binary files /dev/null and b/uploads/ARS Infrastructure.xlsx differ diff --git a/uploads/ASHWINI KUMAR PANDEY COMBINED SHEET.xlsx b/uploads/ASHWINI KUMAR PANDEY COMBINED SHEET.xlsx new file mode 100644 index 0000000..372edbb Binary files /dev/null and b/uploads/ASHWINI KUMAR PANDEY COMBINED SHEET.xlsx differ diff --git a/uploads/Aadi Shakti Construction.xlsx b/uploads/Aadi Shakti Construction.xlsx new file mode 100644 index 0000000..1d40d3b Binary files /dev/null and b/uploads/Aadi Shakti Construction.xlsx differ diff --git a/uploads/Aarav Civil Works.xlsx b/uploads/Aarav Civil Works.xlsx new file mode 100644 index 0000000..1373859 Binary files /dev/null and b/uploads/Aarav Civil Works.xlsx differ diff --git a/uploads/Aarham Enterprises.xlsx b/uploads/Aarham Enterprises.xlsx new file mode 100644 index 0000000..2844693 Binary files /dev/null and b/uploads/Aarham Enterprises.xlsx differ diff --git a/uploads/Aarya Chaudhary Construction.xlsx b/uploads/Aarya Chaudhary Construction.xlsx new file mode 100644 index 0000000..fcc9f82 Binary files /dev/null and b/uploads/Aarya Chaudhary Construction.xlsx differ diff --git a/uploads/Aashirwad Enterprises.xlsx b/uploads/Aashirwad Enterprises.xlsx new file mode 100644 index 0000000..b2ab6c6 Binary files /dev/null and b/uploads/Aashirwad Enterprises.xlsx differ diff --git a/uploads/Aashvi Enterprises.xlsx b/uploads/Aashvi Enterprises.xlsx new file mode 100644 index 0000000..6d9bb88 Binary files /dev/null and b/uploads/Aashvi Enterprises.xlsx differ diff --git a/uploads/Abdul Salam Raising Main.xlsx b/uploads/Abdul Salam Raising Main.xlsx new file mode 100644 index 0000000..26dddd7 Binary files /dev/null and b/uploads/Abdul Salam Raising Main.xlsx differ diff --git a/uploads/Abhinandini Enterprises.xlsx b/uploads/Abhinandini Enterprises.xlsx new file mode 100644 index 0000000..d57e896 Binary files /dev/null and b/uploads/Abhinandini Enterprises.xlsx differ diff --git a/uploads/Abhinisha infra MZN .xlsx b/uploads/Abhinisha infra MZN .xlsx new file mode 100644 index 0000000..d210e55 Binary files /dev/null and b/uploads/Abhinisha infra MZN .xlsx differ diff --git a/uploads/Aiva Engineering Pvt. Ltd. - Shamli .xlsx b/uploads/Aiva Engineering Pvt. Ltd. - Shamli .xlsx new file mode 100644 index 0000000..707abc3 Binary files /dev/null and b/uploads/Aiva Engineering Pvt. Ltd. - Shamli .xlsx differ diff --git a/uploads/Ajay Kumar contractor.xlsx b/uploads/Ajay Kumar contractor.xlsx new file mode 100644 index 0000000..acbf80b Binary files /dev/null and b/uploads/Ajay Kumar contractor.xlsx differ diff --git a/uploads/Akiriti Construction.xlsx b/uploads/Akiriti Construction.xlsx new file mode 100644 index 0000000..8a062fc Binary files /dev/null and b/uploads/Akiriti Construction.xlsx differ diff --git a/uploads/Akram.xlsx b/uploads/Akram.xlsx new file mode 100644 index 0000000..21e834c Binary files /dev/null and b/uploads/Akram.xlsx differ diff --git a/uploads/Al Amman Borewell Contractors.xlsx b/uploads/Al Amman Borewell Contractors.xlsx new file mode 100644 index 0000000..a3cd13c Binary files /dev/null and b/uploads/Al Amman Borewell Contractors.xlsx differ diff --git a/uploads/Alaf Enterprises.xlsx b/uploads/Alaf Enterprises.xlsx new file mode 100644 index 0000000..464aad5 Binary files /dev/null and b/uploads/Alaf Enterprises.xlsx differ diff --git a/uploads/Alam Energy and construction.xlsx b/uploads/Alam Energy and construction.xlsx new file mode 100644 index 0000000..b6a7fbb Binary files /dev/null and b/uploads/Alam Energy and construction.xlsx differ diff --git a/uploads/Alam Enterprises.xlsx b/uploads/Alam Enterprises.xlsx new file mode 100644 index 0000000..52d20e7 Binary files /dev/null and b/uploads/Alam Enterprises.xlsx differ diff --git a/uploads/Ali Construction.xlsx b/uploads/Ali Construction.xlsx new file mode 100644 index 0000000..e4b90ce Binary files /dev/null and b/uploads/Ali Construction.xlsx differ diff --git a/uploads/All Max India.xlsx b/uploads/All Max India.xlsx new file mode 100644 index 0000000..5cda2cd Binary files /dev/null and b/uploads/All Max India.xlsx differ diff --git a/uploads/Altruist Geotechnical Services Pvt Ltd Shamli.xlsx b/uploads/Altruist Geotechnical Services Pvt Ltd Shamli.xlsx new file mode 100644 index 0000000..109dd6f Binary files /dev/null and b/uploads/Altruist Geotechnical Services Pvt Ltd Shamli.xlsx differ diff --git a/uploads/Aman Enterprises.xlsx b/uploads/Aman Enterprises.xlsx new file mode 100644 index 0000000..38f28bd Binary files /dev/null and b/uploads/Aman Enterprises.xlsx differ diff --git a/uploads/Aman Traders & Contractor.xlsx b/uploads/Aman Traders & Contractor.xlsx new file mode 100644 index 0000000..8c96e7c Binary files /dev/null and b/uploads/Aman Traders & Contractor.xlsx differ diff --git a/uploads/Amaron RMC payment reconciliation.xlsx b/uploads/Amaron RMC payment reconciliation.xlsx new file mode 100644 index 0000000..391f1b7 Binary files /dev/null and b/uploads/Amaron RMC payment reconciliation.xlsx differ diff --git a/uploads/Amaron RMC.xlsx b/uploads/Amaron RMC.xlsx new file mode 100644 index 0000000..bec7628 Binary files /dev/null and b/uploads/Amaron RMC.xlsx differ diff --git a/uploads/Ambe Machine Tools and Control.xlsx b/uploads/Ambe Machine Tools and Control.xlsx new file mode 100644 index 0000000..c2ecd20 Binary files /dev/null and b/uploads/Ambe Machine Tools and Control.xlsx differ diff --git a/uploads/Amir Construction .xlsx b/uploads/Amir Construction .xlsx new file mode 100644 index 0000000..8123d0e Binary files /dev/null and b/uploads/Amir Construction .xlsx differ diff --git a/uploads/Amir.xlsx b/uploads/Amir.xlsx new file mode 100644 index 0000000..19d1b9a Binary files /dev/null and b/uploads/Amir.xlsx differ diff --git a/uploads/Amit Kumar ctr and supplier.xlsx b/uploads/Amit Kumar ctr and supplier.xlsx new file mode 100644 index 0000000..3cb90bf Binary files /dev/null and b/uploads/Amit Kumar ctr and supplier.xlsx differ diff --git a/uploads/Anand Construction.xlsx b/uploads/Anand Construction.xlsx new file mode 100644 index 0000000..5b8220f Binary files /dev/null and b/uploads/Anand Construction.xlsx differ diff --git a/uploads/Anglo Tech Energy Pvt. Ltd..xlsx b/uploads/Anglo Tech Energy Pvt. Ltd..xlsx new file mode 100644 index 0000000..f3a408d Binary files /dev/null and b/uploads/Anglo Tech Energy Pvt. Ltd..xlsx differ diff --git a/uploads/Anil Kumar Combined Sheet.xlsx b/uploads/Anil Kumar Combined Sheet.xlsx new file mode 100644 index 0000000..3beed5e Binary files /dev/null and b/uploads/Anil Kumar Combined Sheet.xlsx differ diff --git a/uploads/Anil associates.xlsx b/uploads/Anil associates.xlsx new file mode 100644 index 0000000..84bee01 Binary files /dev/null and b/uploads/Anil associates.xlsx differ diff --git a/uploads/Anish.xlsx b/uploads/Anish.xlsx new file mode 100644 index 0000000..76972f3 Binary files /dev/null and b/uploads/Anish.xlsx differ diff --git a/uploads/Anivarti Infra ENgineers Pvt Ltd.xlsx b/uploads/Anivarti Infra ENgineers Pvt Ltd.xlsx new file mode 100644 index 0000000..84ea419 Binary files /dev/null and b/uploads/Anivarti Infra ENgineers Pvt Ltd.xlsx differ diff --git a/uploads/Ankita Infratech.xlsx b/uploads/Ankita Infratech.xlsx new file mode 100644 index 0000000..3db98d3 Binary files /dev/null and b/uploads/Ankita Infratech.xlsx differ diff --git a/uploads/Ankshari Infracon pvt. ltd. - Checked - Pune & Site diff.xlsx b/uploads/Ankshari Infracon pvt. ltd. - Checked - Pune & Site diff.xlsx new file mode 100644 index 0000000..f24f076 Binary files /dev/null and b/uploads/Ankshari Infracon pvt. ltd. - Checked - Pune & Site diff.xlsx differ diff --git a/uploads/Arham Enterprises.xlsx b/uploads/Arham Enterprises.xlsx new file mode 100644 index 0000000..3f193f9 Binary files /dev/null and b/uploads/Arham Enterprises.xlsx differ diff --git a/uploads/Arora Construction.xlsx b/uploads/Arora Construction.xlsx new file mode 100644 index 0000000..f260820 Binary files /dev/null and b/uploads/Arora Construction.xlsx differ diff --git a/uploads/Arun Pipe leakage work.xlsx b/uploads/Arun Pipe leakage work.xlsx new file mode 100644 index 0000000..beaf066 Binary files /dev/null and b/uploads/Arun Pipe leakage work.xlsx differ diff --git a/uploads/Ashish Contractor.xlsx b/uploads/Ashish Contractor.xlsx new file mode 100644 index 0000000..705fc0a Binary files /dev/null and b/uploads/Ashish Contractor.xlsx differ diff --git a/uploads/Ashvi Enterprises.xlsx b/uploads/Ashvi Enterprises.xlsx new file mode 100644 index 0000000..e4022f9 Binary files /dev/null and b/uploads/Ashvi Enterprises.xlsx differ diff --git a/uploads/Ayansh Infratech.xlsx b/uploads/Ayansh Infratech.xlsx new file mode 100644 index 0000000..dd5ccf8 Binary files /dev/null and b/uploads/Ayansh Infratech.xlsx differ diff --git a/uploads/BALAJI CONTRACTOR.xlsx b/uploads/BALAJI CONTRACTOR.xlsx new file mode 100644 index 0000000..ff4454e Binary files /dev/null and b/uploads/BALAJI CONTRACTOR.xlsx differ diff --git a/uploads/BALAJI ENTERPRISES Dushyant Kumar Combined Sheet.xlsx b/uploads/BALAJI ENTERPRISES Dushyant Kumar Combined Sheet.xlsx new file mode 100644 index 0000000..5996a4c Binary files /dev/null and b/uploads/BALAJI ENTERPRISES Dushyant Kumar Combined Sheet.xlsx differ diff --git a/uploads/BT Contractor.xlsx b/uploads/BT Contractor.xlsx new file mode 100644 index 0000000..b5ac560 Binary files /dev/null and b/uploads/BT Contractor.xlsx differ diff --git a/uploads/Balaji Constructions - Manju.xlsx b/uploads/Balaji Constructions - Manju.xlsx new file mode 100644 index 0000000..b53bef0 Binary files /dev/null and b/uploads/Balaji Constructions - Manju.xlsx differ diff --git a/uploads/Balaji construction.xlsx b/uploads/Balaji construction.xlsx new file mode 100644 index 0000000..db3d659 Binary files /dev/null and b/uploads/Balaji construction.xlsx differ diff --git a/uploads/Bharti Brothers.xlsx b/uploads/Bharti Brothers.xlsx new file mode 100644 index 0000000..c50a020 Binary files /dev/null and b/uploads/Bharti Brothers.xlsx differ diff --git a/uploads/Bhaskar Engineering Works.xlsx b/uploads/Bhaskar Engineering Works.xlsx new file mode 100644 index 0000000..855ed2d Binary files /dev/null and b/uploads/Bhaskar Engineering Works.xlsx differ diff --git a/uploads/Bhatia Cad & Designing shamli.xlsx b/uploads/Bhatia Cad & Designing shamli.xlsx new file mode 100644 index 0000000..fde038f Binary files /dev/null and b/uploads/Bhatia Cad & Designing shamli.xlsx differ diff --git a/uploads/Bibhan Constructions .xlsx b/uploads/Bibhan Constructions .xlsx new file mode 100644 index 0000000..44e06d5 Binary files /dev/null and b/uploads/Bibhan Constructions .xlsx differ diff --git a/uploads/Blue stone manpower.xlsx b/uploads/Blue stone manpower.xlsx new file mode 100644 index 0000000..248ec77 Binary files /dev/null and b/uploads/Blue stone manpower.xlsx differ diff --git a/uploads/Book1.xlsx b/uploads/Book1.xlsx new file mode 100644 index 0000000..923f866 Binary files /dev/null and b/uploads/Book1.xlsx differ diff --git a/uploads/CHOUDHARY CONSTRUCTION CO..xlsx b/uploads/CHOUDHARY CONSTRUCTION CO..xlsx new file mode 100644 index 0000000..5c444db Binary files /dev/null and b/uploads/CHOUDHARY CONSTRUCTION CO..xlsx differ diff --git a/uploads/CRICKET INTERNATIONAL.xlsx b/uploads/CRICKET INTERNATIONAL.xlsx new file mode 100644 index 0000000..f1f92db Binary files /dev/null and b/uploads/CRICKET INTERNATIONAL.xlsx differ diff --git a/uploads/CSE Infra.xlsx b/uploads/CSE Infra.xlsx new file mode 100644 index 0000000..b148f0d Binary files /dev/null and b/uploads/CSE Infra.xlsx differ diff --git a/uploads/Chand Machinery Store.xlsx b/uploads/Chand Machinery Store.xlsx new file mode 100644 index 0000000..cfa3322 Binary files /dev/null and b/uploads/Chand Machinery Store.xlsx differ diff --git a/uploads/Chandan Kumar Gupta- shamli- Asadpur Village - OHT.xlsx b/uploads/Chandan Kumar Gupta- shamli- Asadpur Village - OHT.xlsx new file mode 100644 index 0000000..6c12646 Binary files /dev/null and b/uploads/Chandan Kumar Gupta- shamli- Asadpur Village - OHT.xlsx differ diff --git a/uploads/Charu Construction Combined Sheet.xlsx b/uploads/Charu Construction Combined Sheet.xlsx new file mode 100644 index 0000000..6e1e452 Binary files /dev/null and b/uploads/Charu Construction Combined Sheet.xlsx differ diff --git a/uploads/Chauhan Construction & Supplier .xlsx b/uploads/Chauhan Construction & Supplier .xlsx new file mode 100644 index 0000000..d547e35 Binary files /dev/null and b/uploads/Chauhan Construction & Supplier .xlsx differ diff --git a/uploads/Chauhan Construction .xlsx b/uploads/Chauhan Construction .xlsx new file mode 100644 index 0000000..2dd1457 Binary files /dev/null and b/uploads/Chauhan Construction .xlsx differ diff --git a/uploads/Chauhan Contractor.xlsx b/uploads/Chauhan Contractor.xlsx new file mode 100644 index 0000000..cd38d05 Binary files /dev/null and b/uploads/Chauhan Contractor.xlsx differ diff --git a/uploads/Choudhary Enterprises.xlsx b/uploads/Choudhary Enterprises.xlsx new file mode 100644 index 0000000..2bfcd00 Binary files /dev/null and b/uploads/Choudhary Enterprises.xlsx differ diff --git a/uploads/Civil Infra Solution.xlsx b/uploads/Civil Infra Solution.xlsx new file mode 100644 index 0000000..5048cee Binary files /dev/null and b/uploads/Civil Infra Solution.xlsx differ diff --git a/uploads/Clockwise communication.xlsx b/uploads/Clockwise communication.xlsx new file mode 100644 index 0000000..dd3ea8c Binary files /dev/null and b/uploads/Clockwise communication.xlsx differ diff --git a/uploads/Copy of 50938 - Payment Reconcilation -Sumstar Management Pipe Line Laying Work At Chokda Village.xlsx b/uploads/Copy of 50938 - Payment Reconcilation -Sumstar Management Pipe Line Laying Work At Chokda Village.xlsx new file mode 100644 index 0000000..146245f Binary files /dev/null and b/uploads/Copy of 50938 - Payment Reconcilation -Sumstar Management Pipe Line Laying Work At Chokda Village.xlsx differ diff --git a/uploads/Copy of 57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work.xlsx b/uploads/Copy of 57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work.xlsx new file mode 100644 index 0000000..d56241b Binary files /dev/null and b/uploads/Copy of 57822 - Payment Reconcilation -prashant kumar - MZN- Bolero Hiring work.xlsx differ diff --git a/uploads/Copy of Al Amman Borewell Contractors.xlsx b/uploads/Copy of Al Amman Borewell Contractors.xlsx new file mode 100644 index 0000000..c193424 Binary files /dev/null and b/uploads/Copy of Al Amman Borewell Contractors.xlsx differ diff --git a/uploads/Copy of D M Residential Malik Contr..xlsx b/uploads/Copy of D M Residential Malik Contr..xlsx new file mode 100644 index 0000000..1a5ba59 Binary files /dev/null and b/uploads/Copy of D M Residential Malik Contr..xlsx differ diff --git a/uploads/Copy of EarthwaterSolution - Solar Mounting Structure.xlsx b/uploads/Copy of EarthwaterSolution - Solar Mounting Structure.xlsx new file mode 100644 index 0000000..7859ee4 Binary files /dev/null and b/uploads/Copy of EarthwaterSolution - Solar Mounting Structure.xlsx differ diff --git a/uploads/Copy of Ground Water Survey Consultancy Shamli.xlsx b/uploads/Copy of Ground Water Survey Consultancy Shamli.xlsx new file mode 100644 index 0000000..c0d861c Binary files /dev/null and b/uploads/Copy of Ground Water Survey Consultancy Shamli.xlsx differ diff --git a/uploads/Copy of Meenakshi Associates.xlsx b/uploads/Copy of Meenakshi Associates.xlsx new file mode 100644 index 0000000..5d5eb3c Binary files /dev/null and b/uploads/Copy of Meenakshi Associates.xlsx differ diff --git a/uploads/Copy of Rahul construction - Shamli (1).xlsx b/uploads/Copy of Rahul construction - Shamli (1).xlsx new file mode 100644 index 0000000..0325579 Binary files /dev/null and b/uploads/Copy of Rahul construction - Shamli (1).xlsx differ diff --git a/uploads/Copy of Rahul construction - Shamli.xlsx b/uploads/Copy of Rahul construction - Shamli.xlsx new file mode 100644 index 0000000..583339a Binary files /dev/null and b/uploads/Copy of Rahul construction - Shamli.xlsx differ diff --git a/uploads/Copy of Rao Builders - Copy.xlsx b/uploads/Copy of Rao Builders - Copy.xlsx new file mode 100644 index 0000000..e1786d5 Binary files /dev/null and b/uploads/Copy of Rao Builders - Copy.xlsx differ diff --git a/uploads/Copy of Rao Builders.xlsx b/uploads/Copy of Rao Builders.xlsx new file mode 100644 index 0000000..50248b0 Binary files /dev/null and b/uploads/Copy of Rao Builders.xlsx differ diff --git a/uploads/Copy of Swaroopa Enterprises (1).xlsx b/uploads/Copy of Swaroopa Enterprises (1).xlsx new file mode 100644 index 0000000..0470f47 Binary files /dev/null and b/uploads/Copy of Swaroopa Enterprises (1).xlsx differ diff --git a/uploads/Copy of Swaroopa Enterprises.xlsx b/uploads/Copy of Swaroopa Enterprises.xlsx new file mode 100644 index 0000000..3b6d34e Binary files /dev/null and b/uploads/Copy of Swaroopa Enterprises.xlsx differ diff --git a/uploads/D M Residential Malik Contr..xlsx b/uploads/D M Residential Malik Contr..xlsx new file mode 100644 index 0000000..a90fcc7 Binary files /dev/null and b/uploads/D M Residential Malik Contr..xlsx differ diff --git a/uploads/D S Construction.xlsx b/uploads/D S Construction.xlsx new file mode 100644 index 0000000..504b090 Binary files /dev/null and b/uploads/D S Construction.xlsx differ diff --git a/uploads/DNA Enterprises.xlsx b/uploads/DNA Enterprises.xlsx new file mode 100644 index 0000000..554c3ca Binary files /dev/null and b/uploads/DNA Enterprises.xlsx differ diff --git a/uploads/DVR traders.xlsx b/uploads/DVR traders.xlsx new file mode 100644 index 0000000..4a7203a Binary files /dev/null and b/uploads/DVR traders.xlsx differ diff --git a/uploads/Daniyal enterprises.xlsx b/uploads/Daniyal enterprises.xlsx new file mode 100644 index 0000000..d2182f4 Binary files /dev/null and b/uploads/Daniyal enterprises.xlsx differ diff --git a/uploads/Dev Constrcution Sachin Kumar.xlsx b/uploads/Dev Constrcution Sachin Kumar.xlsx new file mode 100644 index 0000000..b774a05 Binary files /dev/null and b/uploads/Dev Constrcution Sachin Kumar.xlsx differ diff --git a/uploads/Dev Constrcution.xlsx b/uploads/Dev Constrcution.xlsx new file mode 100644 index 0000000..aad0c50 Binary files /dev/null and b/uploads/Dev Constrcution.xlsx differ diff --git a/uploads/Dhanvi Construction - SHamli.xlsx b/uploads/Dhanvi Construction - SHamli.xlsx new file mode 100644 index 0000000..175239c Binary files /dev/null and b/uploads/Dhanvi Construction - SHamli.xlsx differ diff --git a/uploads/EarthwaterSolution - Solar Mounting Structure.xlsx b/uploads/EarthwaterSolution - Solar Mounting Structure.xlsx new file mode 100644 index 0000000..3852820 Binary files /dev/null and b/uploads/EarthwaterSolution - Solar Mounting Structure.xlsx differ diff --git a/uploads/F S Construction.xlsx b/uploads/F S Construction.xlsx new file mode 100644 index 0000000..9f2faa5 Binary files /dev/null and b/uploads/F S Construction.xlsx differ diff --git a/uploads/Frotech Services.xlsx b/uploads/Frotech Services.xlsx new file mode 100644 index 0000000..b15d155 Binary files /dev/null and b/uploads/Frotech Services.xlsx differ diff --git a/uploads/GAYATRI ENTERPRISES.xlsx b/uploads/GAYATRI ENTERPRISES.xlsx new file mode 100644 index 0000000..d85ba44 Binary files /dev/null and b/uploads/GAYATRI ENTERPRISES.xlsx differ diff --git a/uploads/GM Infrastructure.xlsx b/uploads/GM Infrastructure.xlsx new file mode 100644 index 0000000..1b36a58 Binary files /dev/null and b/uploads/GM Infrastructure.xlsx differ diff --git a/uploads/GNB Bhojawani.xlsx b/uploads/GNB Bhojawani.xlsx new file mode 100644 index 0000000..eda1469 Binary files /dev/null and b/uploads/GNB Bhojawani.xlsx differ diff --git a/uploads/GURTEZ INFRABUILD LLP - MZN 1.xlsx b/uploads/GURTEZ INFRABUILD LLP - MZN 1.xlsx new file mode 100644 index 0000000..ac1bdb9 Binary files /dev/null and b/uploads/GURTEZ INFRABUILD LLP - MZN 1.xlsx differ diff --git a/uploads/GURTEZ INFRABUILD LLP - MZN.xlsx b/uploads/GURTEZ INFRABUILD LLP - MZN.xlsx new file mode 100644 index 0000000..9e6609c Binary files /dev/null and b/uploads/GURTEZ INFRABUILD LLP - MZN.xlsx differ diff --git a/uploads/Gannu Enterprises.xlsx b/uploads/Gannu Enterprises.xlsx new file mode 100644 index 0000000..1f16482 Binary files /dev/null and b/uploads/Gannu Enterprises.xlsx differ diff --git a/uploads/Ganpati Enterprises - Copy.xlsx b/uploads/Ganpati Enterprises - Copy.xlsx new file mode 100644 index 0000000..bfe7fee Binary files /dev/null and b/uploads/Ganpati Enterprises - Copy.xlsx differ diff --git a/uploads/Ganpati Enterprises.xlsx b/uploads/Ganpati Enterprises.xlsx new file mode 100644 index 0000000..ac99be0 Binary files /dev/null and b/uploads/Ganpati Enterprises.xlsx differ diff --git a/uploads/Gaurav Kumar Combined Sheet.xlsx b/uploads/Gaurav Kumar Combined Sheet.xlsx new file mode 100644 index 0000000..2e464fa Binary files /dev/null and b/uploads/Gaurav Kumar Combined Sheet.xlsx differ diff --git a/uploads/Gautam Engineering.xlsx b/uploads/Gautam Engineering.xlsx new file mode 100644 index 0000000..5235f68 Binary files /dev/null and b/uploads/Gautam Engineering.xlsx differ diff --git a/uploads/Golden Key Construcion MZN.xlsx b/uploads/Golden Key Construcion MZN.xlsx new file mode 100644 index 0000000..ee6d35d Binary files /dev/null and b/uploads/Golden Key Construcion MZN.xlsx differ diff --git a/uploads/Govind Singh Rana.xlsx b/uploads/Govind Singh Rana.xlsx new file mode 100644 index 0000000..e5564f9 Binary files /dev/null and b/uploads/Govind Singh Rana.xlsx differ diff --git a/uploads/Grace Infra.xlsx b/uploads/Grace Infra.xlsx new file mode 100644 index 0000000..4055293 Binary files /dev/null and b/uploads/Grace Infra.xlsx differ diff --git a/uploads/Gurmeet Kaur Combined Sheet.xlsx b/uploads/Gurmeet Kaur Combined Sheet.xlsx new file mode 100644 index 0000000..3b28cf0 Binary files /dev/null and b/uploads/Gurmeet Kaur Combined Sheet.xlsx differ diff --git a/uploads/Gurunanak Engineers .xlsx b/uploads/Gurunanak Engineers .xlsx new file mode 100644 index 0000000..0bca937 Binary files /dev/null and b/uploads/Gurunanak Engineers .xlsx differ diff --git a/uploads/Gurunanak Engineers.xlsx b/uploads/Gurunanak Engineers.xlsx new file mode 100644 index 0000000..0dc3065 Binary files /dev/null and b/uploads/Gurunanak Engineers.xlsx differ diff --git a/uploads/H D Construction.xlsx b/uploads/H D Construction.xlsx new file mode 100644 index 0000000..926e951 Binary files /dev/null and b/uploads/H D Construction.xlsx differ diff --git a/uploads/H K Group.xlsx b/uploads/H K Group.xlsx new file mode 100644 index 0000000..e6d1db9 Binary files /dev/null and b/uploads/H K Group.xlsx differ diff --git a/uploads/HC Construction.xlsx b/uploads/HC Construction.xlsx new file mode 100644 index 0000000..6993d34 Binary files /dev/null and b/uploads/HC Construction.xlsx differ diff --git a/uploads/Harinam Gold.xlsx b/uploads/Harinam Gold.xlsx new file mode 100644 index 0000000..d2fdd2c Binary files /dev/null and b/uploads/Harinam Gold.xlsx differ diff --git a/uploads/Harsh Enterprises .xlsx b/uploads/Harsh Enterprises .xlsx new file mode 100644 index 0000000..1f395ae Binary files /dev/null and b/uploads/Harsh Enterprises .xlsx differ diff --git a/uploads/Hasan contractor.xlsx b/uploads/Hasan contractor.xlsx new file mode 100644 index 0000000..96c93ac Binary files /dev/null and b/uploads/Hasan contractor.xlsx differ diff --git a/uploads/Hi Tech Construction.xlsx b/uploads/Hi Tech Construction.xlsx new file mode 100644 index 0000000..0529bec Binary files /dev/null and b/uploads/Hi Tech Construction.xlsx differ diff --git a/uploads/Highrise Engineering -Badhai Kalan - MZN- OHT Constrution.xlsx b/uploads/Highrise Engineering -Badhai Kalan - MZN- OHT Constrution.xlsx new file mode 100644 index 0000000..08cf568 Binary files /dev/null and b/uploads/Highrise Engineering -Badhai Kalan - MZN- OHT Constrution.xlsx differ diff --git a/uploads/Hydel Laboratories P Ltd_MZN.xlsx b/uploads/Hydel Laboratories P Ltd_MZN.xlsx new file mode 100644 index 0000000..d5c9b30 Binary files /dev/null and b/uploads/Hydel Laboratories P Ltd_MZN.xlsx differ diff --git a/uploads/INTAJAR CONTRACTOR.xlsx b/uploads/INTAJAR CONTRACTOR.xlsx new file mode 100644 index 0000000..d93dd18 Binary files /dev/null and b/uploads/INTAJAR CONTRACTOR.xlsx differ diff --git a/uploads/Indian Contractor.xlsx b/uploads/Indian Contractor.xlsx new file mode 100644 index 0000000..6ada93e Binary files /dev/null and b/uploads/Indian Contractor.xlsx differ diff --git a/uploads/Inshad Construction.xlsx b/uploads/Inshad Construction.xlsx new file mode 100644 index 0000000..f61d0f0 Binary files /dev/null and b/uploads/Inshad Construction.xlsx differ diff --git a/uploads/Irfan Construction.xlsx b/uploads/Irfan Construction.xlsx new file mode 100644 index 0000000..fad66e4 Binary files /dev/null and b/uploads/Irfan Construction.xlsx differ diff --git a/uploads/Irfan.xlsx b/uploads/Irfan.xlsx new file mode 100644 index 0000000..28a277f Binary files /dev/null and b/uploads/Irfan.xlsx differ diff --git a/uploads/Irshad Construction.xlsx b/uploads/Irshad Construction.xlsx new file mode 100644 index 0000000..35388ab Binary files /dev/null and b/uploads/Irshad Construction.xlsx differ diff --git a/uploads/Islam Contractors.xlsx b/uploads/Islam Contractors.xlsx new file mode 100644 index 0000000..265dbf4 Binary files /dev/null and b/uploads/Islam Contractors.xlsx differ diff --git a/uploads/Islam.xlsx b/uploads/Islam.xlsx new file mode 100644 index 0000000..6347aec Binary files /dev/null and b/uploads/Islam.xlsx differ diff --git a/uploads/J B construction.xlsx b/uploads/J B construction.xlsx new file mode 100644 index 0000000..5710d19 Binary files /dev/null and b/uploads/J B construction.xlsx differ diff --git a/uploads/J.S.S CONTRACTOR.xlsx b/uploads/J.S.S CONTRACTOR.xlsx new file mode 100644 index 0000000..1988811 Binary files /dev/null and b/uploads/J.S.S CONTRACTOR.xlsx differ diff --git a/uploads/JASBIR BORING CO..xlsx b/uploads/JASBIR BORING CO..xlsx new file mode 100644 index 0000000..1abe1bd Binary files /dev/null and b/uploads/JASBIR BORING CO..xlsx differ diff --git a/uploads/JMD Tubwell .xlsx b/uploads/JMD Tubwell .xlsx new file mode 100644 index 0000000..116ebc9 Binary files /dev/null and b/uploads/JMD Tubwell .xlsx differ diff --git a/uploads/Jagdamba Construction.xlsx b/uploads/Jagdamba Construction.xlsx new file mode 100644 index 0000000..df93f64 Binary files /dev/null and b/uploads/Jagdamba Construction.xlsx differ diff --git a/uploads/Jai Nityanand Construction.xlsx b/uploads/Jai Nityanand Construction.xlsx new file mode 100644 index 0000000..1cac454 Binary files /dev/null and b/uploads/Jai Nityanand Construction.xlsx differ diff --git a/uploads/Jai Tara Contractors.xlsx b/uploads/Jai Tara Contractors.xlsx new file mode 100644 index 0000000..b58d689 Binary files /dev/null and b/uploads/Jai Tara Contractors.xlsx differ diff --git a/uploads/Jai.xlsx b/uploads/Jai.xlsx new file mode 100644 index 0000000..4d6980f Binary files /dev/null and b/uploads/Jai.xlsx differ diff --git a/uploads/Jaitron communication Pvt Ltd -Datiyana Village - MZN.xlsx b/uploads/Jaitron communication Pvt Ltd -Datiyana Village - MZN.xlsx new file mode 100644 index 0000000..a1e5ecf Binary files /dev/null and b/uploads/Jaitron communication Pvt Ltd -Datiyana Village - MZN.xlsx differ diff --git a/uploads/Janta Boring Engineer Works.xlsx b/uploads/Janta Boring Engineer Works.xlsx new file mode 100644 index 0000000..012b529 Binary files /dev/null and b/uploads/Janta Boring Engineer Works.xlsx differ diff --git a/uploads/Javed Contractor.xlsx b/uploads/Javed Contractor.xlsx new file mode 100644 index 0000000..ece564f Binary files /dev/null and b/uploads/Javed Contractor.xlsx differ diff --git a/uploads/Jishan Construction.xlsx b/uploads/Jishan Construction.xlsx new file mode 100644 index 0000000..446e0ae Binary files /dev/null and b/uploads/Jishan Construction.xlsx differ diff --git a/uploads/K & K Engineering.xlsx b/uploads/K & K Engineering.xlsx new file mode 100644 index 0000000..94ce25c Binary files /dev/null and b/uploads/K & K Engineering.xlsx differ diff --git a/uploads/KAMALVIR VERMA & SONS.xlsx b/uploads/KAMALVIR VERMA & SONS.xlsx new file mode 100644 index 0000000..c231e68 Binary files /dev/null and b/uploads/KAMALVIR VERMA & SONS.xlsx differ diff --git a/uploads/KARTIK CONSTRUCTION.xlsx b/uploads/KARTIK CONSTRUCTION.xlsx new file mode 100644 index 0000000..a845269 Binary files /dev/null and b/uploads/KARTIK CONSTRUCTION.xlsx differ diff --git a/uploads/KRISH ENTERPRISES.xlsx b/uploads/KRISH ENTERPRISES.xlsx new file mode 100644 index 0000000..4087963 Binary files /dev/null and b/uploads/KRISH ENTERPRISES.xlsx differ diff --git a/uploads/KRISHANPAL SINGH.xlsx b/uploads/KRISHANPAL SINGH.xlsx new file mode 100644 index 0000000..33dea44 Binary files /dev/null and b/uploads/KRISHANPAL SINGH.xlsx differ diff --git a/uploads/Kanishka Manpower Solution.xlsx b/uploads/Kanishka Manpower Solution.xlsx new file mode 100644 index 0000000..7b14865 Binary files /dev/null and b/uploads/Kanishka Manpower Solution.xlsx differ diff --git a/uploads/Kasko Infrastructure.xlsx b/uploads/Kasko Infrastructure.xlsx new file mode 100644 index 0000000..296effb Binary files /dev/null and b/uploads/Kasko Infrastructure.xlsx differ diff --git a/uploads/Khurshid.xlsx b/uploads/Khurshid.xlsx new file mode 100644 index 0000000..a2a3ab2 Binary files /dev/null and b/uploads/Khurshid.xlsx differ diff --git a/uploads/Komal Civil Works Combinded Payment Reconciliation.xlsx b/uploads/Komal Civil Works Combinded Payment Reconciliation.xlsx new file mode 100644 index 0000000..48fa66b Binary files /dev/null and b/uploads/Komal Civil Works Combinded Payment Reconciliation.xlsx differ diff --git a/uploads/Krishna Contractor.xlsx b/uploads/Krishna Contractor.xlsx new file mode 100644 index 0000000..ee36d42 Binary files /dev/null and b/uploads/Krishna Contractor.xlsx differ diff --git a/uploads/LCC projects PVT LTD.xlsx b/uploads/LCC projects PVT LTD.xlsx new file mode 100644 index 0000000..782442c Binary files /dev/null and b/uploads/LCC projects PVT LTD.xlsx differ diff --git a/uploads/Laxmi Associates - MZN - Payment reconciliation.xlsx b/uploads/Laxmi Associates - MZN - Payment reconciliation.xlsx new file mode 100644 index 0000000..5f5cb28 Binary files /dev/null and b/uploads/Laxmi Associates - MZN - Payment reconciliation.xlsx differ diff --git a/uploads/Liyakat Contractor Company -comb. sheet.xlsx b/uploads/Liyakat Contractor Company -comb. sheet.xlsx new file mode 100644 index 0000000..ba8ed7e Binary files /dev/null and b/uploads/Liyakat Contractor Company -comb. sheet.xlsx differ diff --git a/uploads/M A Enterprises.xlsx b/uploads/M A Enterprises.xlsx new file mode 100644 index 0000000..81ea329 Binary files /dev/null and b/uploads/M A Enterprises.xlsx differ diff --git a/uploads/M A Infraa.xlsx b/uploads/M A Infraa.xlsx new file mode 100644 index 0000000..1914fbe Binary files /dev/null and b/uploads/M A Infraa.xlsx differ diff --git a/uploads/M A PUNDIR Enterprises.xlsx b/uploads/M A PUNDIR Enterprises.xlsx new file mode 100644 index 0000000..8d2ea24 Binary files /dev/null and b/uploads/M A PUNDIR Enterprises.xlsx differ diff --git a/uploads/M J Enterprises.xlsx b/uploads/M J Enterprises.xlsx new file mode 100644 index 0000000..49a916a Binary files /dev/null and b/uploads/M J Enterprises.xlsx differ diff --git a/uploads/MAA JAGDUMBEY IMPEX.xlsx b/uploads/MAA JAGDUMBEY IMPEX.xlsx new file mode 100644 index 0000000..f8839a1 Binary files /dev/null and b/uploads/MAA JAGDUMBEY IMPEX.xlsx differ diff --git a/uploads/MALIK JI TREDERS.xlsx b/uploads/MALIK JI TREDERS.xlsx new file mode 100644 index 0000000..f543640 Binary files /dev/null and b/uploads/MALIK JI TREDERS.xlsx differ diff --git a/uploads/MAV ENTERPRISES -.xlsx b/uploads/MAV ENTERPRISES -.xlsx new file mode 100644 index 0000000..36d5614 Binary files /dev/null and b/uploads/MAV ENTERPRISES -.xlsx differ diff --git a/uploads/MS Construction.xlsx b/uploads/MS Construction.xlsx new file mode 100644 index 0000000..58f13f8 Binary files /dev/null and b/uploads/MS Construction.xlsx differ diff --git a/uploads/MS Lala Dharam payment reconciliation.xlsx b/uploads/MS Lala Dharam payment reconciliation.xlsx new file mode 100644 index 0000000..3de0b53 Binary files /dev/null and b/uploads/MS Lala Dharam payment reconciliation.xlsx differ diff --git a/uploads/MS contractor.xlsx b/uploads/MS contractor.xlsx new file mode 100644 index 0000000..bbc647a Binary files /dev/null and b/uploads/MS contractor.xlsx differ diff --git a/uploads/Maa Bhawani Associates.xlsx b/uploads/Maa Bhawani Associates.xlsx new file mode 100644 index 0000000..062ecf5 Binary files /dev/null and b/uploads/Maa Bhawani Associates.xlsx differ diff --git a/uploads/Maa Pundir Enterprises.xlsx b/uploads/Maa Pundir Enterprises.xlsx new file mode 100644 index 0000000..b40c48b Binary files /dev/null and b/uploads/Maa Pundir Enterprises.xlsx differ diff --git a/uploads/Maa jamuni enterprices.xlsx b/uploads/Maa jamuni enterprices.xlsx new file mode 100644 index 0000000..3f353f4 Binary files /dev/null and b/uploads/Maa jamuni enterprices.xlsx differ diff --git a/uploads/Maa jamuni.xlsx b/uploads/Maa jamuni.xlsx new file mode 100644 index 0000000..4f6f2ef Binary files /dev/null and b/uploads/Maa jamuni.xlsx differ diff --git a/uploads/Mahadeva Infra Combined Sheet.xlsx b/uploads/Mahadeva Infra Combined Sheet.xlsx new file mode 100644 index 0000000..cdf5573 Binary files /dev/null and b/uploads/Mahadeva Infra Combined Sheet.xlsx differ diff --git a/uploads/Mahesh Kumar Tyagi Combined Sheet.xlsx b/uploads/Mahesh Kumar Tyagi Combined Sheet.xlsx new file mode 100644 index 0000000..5990fcc Binary files /dev/null and b/uploads/Mahesh Kumar Tyagi Combined Sheet.xlsx differ diff --git a/uploads/Malik Construction.xlsx b/uploads/Malik Construction.xlsx new file mode 100644 index 0000000..18f81e5 Binary files /dev/null and b/uploads/Malik Construction.xlsx differ diff --git a/uploads/Masoon Raja Zaidi.xlsx b/uploads/Masoon Raja Zaidi.xlsx new file mode 100644 index 0000000..9eb9bd2 Binary files /dev/null and b/uploads/Masoon Raja Zaidi.xlsx differ diff --git a/uploads/Maya Combinded Payment Reconciliation.xlsx b/uploads/Maya Combinded Payment Reconciliation.xlsx new file mode 100644 index 0000000..e815e4c Binary files /dev/null and b/uploads/Maya Combinded Payment Reconciliation.xlsx differ diff --git a/uploads/Meena Enterprises MZN.xlsx b/uploads/Meena Enterprises MZN.xlsx new file mode 100644 index 0000000..a81383a Binary files /dev/null and b/uploads/Meena Enterprises MZN.xlsx differ diff --git a/uploads/Meena Enterprises.xlsx b/uploads/Meena Enterprises.xlsx new file mode 100644 index 0000000..3e68f3c Binary files /dev/null and b/uploads/Meena Enterprises.xlsx differ diff --git a/uploads/Mehrab.xlsx b/uploads/Mehrab.xlsx new file mode 100644 index 0000000..9948ce7 Binary files /dev/null and b/uploads/Mehrab.xlsx differ diff --git a/uploads/Mittal contractor.xlsx b/uploads/Mittal contractor.xlsx new file mode 100644 index 0000000..ecee505 Binary files /dev/null and b/uploads/Mittal contractor.xlsx differ diff --git a/uploads/Mohit contractor.xlsx b/uploads/Mohit contractor.xlsx new file mode 100644 index 0000000..460ac1d Binary files /dev/null and b/uploads/Mohit contractor.xlsx differ diff --git a/uploads/Ms DEV CONSTRUCTION (1).xlsx b/uploads/Ms DEV CONSTRUCTION (1).xlsx new file mode 100644 index 0000000..4b808d9 Binary files /dev/null and b/uploads/Ms DEV CONSTRUCTION (1).xlsx differ diff --git a/uploads/Ms DEV CONSTRUCTION.xlsx b/uploads/Ms DEV CONSTRUCTION.xlsx new file mode 100644 index 0000000..926b4ff Binary files /dev/null and b/uploads/Ms DEV CONSTRUCTION.xlsx differ diff --git a/uploads/Ms Mubarik.xlsx b/uploads/Ms Mubarik.xlsx new file mode 100644 index 0000000..c72e376 Binary files /dev/null and b/uploads/Ms Mubarik.xlsx differ diff --git a/uploads/Ms Nitin.xlsx b/uploads/Ms Nitin.xlsx new file mode 100644 index 0000000..44449b4 Binary files /dev/null and b/uploads/Ms Nitin.xlsx differ diff --git a/uploads/Naresh Kumar Contractor.xlsx b/uploads/Naresh Kumar Contractor.xlsx new file mode 100644 index 0000000..a897df4 Binary files /dev/null and b/uploads/Naresh Kumar Contractor.xlsx differ diff --git a/uploads/Naseem Praveen.xlsx b/uploads/Naseem Praveen.xlsx new file mode 100644 index 0000000..bb937d8 Binary files /dev/null and b/uploads/Naseem Praveen.xlsx differ diff --git a/uploads/Naveen Kumar Combinded Payment Reconciliation.xlsx b/uploads/Naveen Kumar Combinded Payment Reconciliation.xlsx new file mode 100644 index 0000000..5df5fd0 Binary files /dev/null and b/uploads/Naveen Kumar Combinded Payment Reconciliation.xlsx differ diff --git a/uploads/New Bharat Construction work.xlsx b/uploads/New Bharat Construction work.xlsx new file mode 100644 index 0000000..ca7bad1 Binary files /dev/null and b/uploads/New Bharat Construction work.xlsx differ diff --git a/uploads/New India Network Enterprise.xlsx b/uploads/New India Network Enterprise.xlsx new file mode 100644 index 0000000..7e482ce Binary files /dev/null and b/uploads/New India Network Enterprise.xlsx differ diff --git a/uploads/New Microsoft Excel Worksheet (2).xlsx b/uploads/New Microsoft Excel Worksheet (2).xlsx new file mode 100644 index 0000000..170bffd Binary files /dev/null and b/uploads/New Microsoft Excel Worksheet (2).xlsx differ diff --git a/uploads/New Microsoft Excel Worksheet BUWARA KALAN (1).xlsx b/uploads/New Microsoft Excel Worksheet BUWARA KALAN (1).xlsx new file mode 100644 index 0000000..0baf349 Binary files /dev/null and b/uploads/New Microsoft Excel Worksheet BUWARA KALAN (1).xlsx differ diff --git a/uploads/New Microsoft Excel Worksheet.xlsx b/uploads/New Microsoft Excel Worksheet.xlsx new file mode 100644 index 0000000..170bffd Binary files /dev/null and b/uploads/New Microsoft Excel Worksheet.xlsx differ diff --git a/uploads/ONS Enterprises Combined Payment Reconciliation.xlsx b/uploads/ONS Enterprises Combined Payment Reconciliation.xlsx new file mode 100644 index 0000000..ed59c30 Binary files /dev/null and b/uploads/ONS Enterprises Combined Payment Reconciliation.xlsx differ diff --git a/uploads/PUNDIR CONTRACTOR.xlsx b/uploads/PUNDIR CONTRACTOR.xlsx new file mode 100644 index 0000000..209aab0 Binary files /dev/null and b/uploads/PUNDIR CONTRACTOR.xlsx differ diff --git a/uploads/PVD Enterprises.xlsx b/uploads/PVD Enterprises.xlsx new file mode 100644 index 0000000..745a080 Binary files /dev/null and b/uploads/PVD Enterprises.xlsx differ diff --git a/uploads/Pal Construction.xlsx b/uploads/Pal Construction.xlsx new file mode 100644 index 0000000..e869c83 Binary files /dev/null and b/uploads/Pal Construction.xlsx differ diff --git a/uploads/Pankaj Kumar Contractor Shamli.xlsx b/uploads/Pankaj Kumar Contractor Shamli.xlsx new file mode 100644 index 0000000..d29defb Binary files /dev/null and b/uploads/Pankaj Kumar Contractor Shamli.xlsx differ diff --git a/uploads/Pankaj Kumar.xlsx b/uploads/Pankaj Kumar.xlsx new file mode 100644 index 0000000..51ca899 Binary files /dev/null and b/uploads/Pankaj Kumar.xlsx differ diff --git a/uploads/Pankaj kumar contractor MZN.xlsx b/uploads/Pankaj kumar contractor MZN.xlsx new file mode 100644 index 0000000..fa2aacf Binary files /dev/null and b/uploads/Pankaj kumar contractor MZN.xlsx differ diff --git a/uploads/Parbeen enterprises.xlsx b/uploads/Parbeen enterprises.xlsx new file mode 100644 index 0000000..578adea Binary files /dev/null and b/uploads/Parbeen enterprises.xlsx differ diff --git a/uploads/Pawanputra Construction Combined Sheet.xlsx b/uploads/Pawanputra Construction Combined Sheet.xlsx new file mode 100644 index 0000000..06af605 Binary files /dev/null and b/uploads/Pawanputra Construction Combined Sheet.xlsx differ diff --git a/uploads/Pawanputra Construction.xlsx b/uploads/Pawanputra Construction.xlsx new file mode 100644 index 0000000..d4dd8e3 Binary files /dev/null and b/uploads/Pawanputra Construction.xlsx differ diff --git a/uploads/Payment Reconcilation rishal construction.xlsx b/uploads/Payment Reconcilation rishal construction.xlsx new file mode 100644 index 0000000..d199dcb Binary files /dev/null and b/uploads/Payment Reconcilation rishal construction.xlsx differ diff --git a/uploads/Payment Reconcilation - Hammer project pvt ltd.xlsx b/uploads/Payment Reconcilation - Hammer project pvt ltd.xlsx new file mode 100644 index 0000000..a3345f2 Binary files /dev/null and b/uploads/Payment Reconcilation - Hammer project pvt ltd.xlsx differ diff --git a/uploads/Payment Reconcilation - Jai Kumar - Dholari Village - MZN- Pump House work - Copy.xlsx b/uploads/Payment Reconcilation - Jai Kumar - Dholari Village - MZN- Pump House work - Copy.xlsx new file mode 100644 index 0000000..4856c46 Binary files /dev/null and b/uploads/Payment Reconcilation - Jai Kumar - Dholari Village - MZN- Pump House work - Copy.xlsx differ diff --git a/uploads/Payment Reconcilation - Jai Kumar - Dholari Village - MZN- Pump House work .xlsx b/uploads/Payment Reconcilation - Jai Kumar - Dholari Village - MZN- Pump House work .xlsx new file mode 100644 index 0000000..6c8ecec Binary files /dev/null and b/uploads/Payment Reconcilation - Jai Kumar - Dholari Village - MZN- Pump House work .xlsx differ diff --git a/uploads/Payment Reconcilation - SD Construction.xlsx b/uploads/Payment Reconcilation - SD Construction.xlsx new file mode 100644 index 0000000..66c69de Binary files /dev/null and b/uploads/Payment Reconcilation - SD Construction.xlsx differ diff --git a/uploads/Payment Reconcilation -SUHKHWINDAR SINGH.xlsx b/uploads/Payment Reconcilation -SUHKHWINDAR SINGH.xlsx new file mode 100644 index 0000000..c4565eb Binary files /dev/null and b/uploads/Payment Reconcilation -SUHKHWINDAR SINGH.xlsx differ diff --git a/uploads/Pea Gravel Payment Reconciliation Shamli.xlsx b/uploads/Pea Gravel Payment Reconciliation Shamli.xlsx new file mode 100644 index 0000000..18a34e1 Binary files /dev/null and b/uploads/Pea Gravel Payment Reconciliation Shamli.xlsx differ diff --git a/uploads/Perfect Innovation Shamli.xlsx b/uploads/Perfect Innovation Shamli.xlsx new file mode 100644 index 0000000..17c3398 Binary files /dev/null and b/uploads/Perfect Innovation Shamli.xlsx differ diff --git a/uploads/Popin Kumar.xlsx b/uploads/Popin Kumar.xlsx new file mode 100644 index 0000000..78edb76 Binary files /dev/null and b/uploads/Popin Kumar.xlsx differ diff --git a/uploads/Pradhan Ji Construction & supplier- Shamli.xlsx b/uploads/Pradhan Ji Construction & supplier- Shamli.xlsx new file mode 100644 index 0000000..d014347 Binary files /dev/null and b/uploads/Pradhan Ji Construction & supplier- Shamli.xlsx differ diff --git a/uploads/Pramod Contractor.xlsx b/uploads/Pramod Contractor.xlsx new file mode 100644 index 0000000..7dd9fed Binary files /dev/null and b/uploads/Pramod Contractor.xlsx differ diff --git a/uploads/Praveen kumar Contractor -Payment Reconcilation.xlsx b/uploads/Praveen kumar Contractor -Payment Reconcilation.xlsx new file mode 100644 index 0000000..17f3097 Binary files /dev/null and b/uploads/Praveen kumar Contractor -Payment Reconcilation.xlsx differ diff --git a/uploads/Pundir Construction.xlsx b/uploads/Pundir Construction.xlsx new file mode 100644 index 0000000..bb170ae Binary files /dev/null and b/uploads/Pundir Construction.xlsx differ diff --git a/uploads/Pushkar Combined Sheet.xlsx b/uploads/Pushkar Combined Sheet.xlsx new file mode 100644 index 0000000..ae8c223 Binary files /dev/null and b/uploads/Pushkar Combined Sheet.xlsx differ diff --git a/uploads/R M controls and Automations.xlsx b/uploads/R M controls and Automations.xlsx new file mode 100644 index 0000000..a3e937e Binary files /dev/null and b/uploads/R M controls and Automations.xlsx differ diff --git a/uploads/R S Construction.xlsx b/uploads/R S Construction.xlsx new file mode 100644 index 0000000..2eb2977 Binary files /dev/null and b/uploads/R S Construction.xlsx differ diff --git a/uploads/RAJESH KUMAR GUPTA.xlsx b/uploads/RAJESH KUMAR GUPTA.xlsx new file mode 100644 index 0000000..668d5c0 Binary files /dev/null and b/uploads/RAJESH KUMAR GUPTA.xlsx differ diff --git a/uploads/RAJPAL CONTRACTOR.xlsx b/uploads/RAJPAL CONTRACTOR.xlsx new file mode 100644 index 0000000..470e744 Binary files /dev/null and b/uploads/RAJPAL CONTRACTOR.xlsx differ diff --git a/uploads/RRR Construction.xlsx b/uploads/RRR Construction.xlsx new file mode 100644 index 0000000..39b223d Binary files /dev/null and b/uploads/RRR Construction.xlsx differ diff --git a/uploads/Radha Govind Constrution.xlsx b/uploads/Radha Govind Constrution.xlsx new file mode 100644 index 0000000..7a1aaf9 Binary files /dev/null and b/uploads/Radha Govind Constrution.xlsx differ diff --git a/uploads/Radhey construction.xlsx b/uploads/Radhey construction.xlsx new file mode 100644 index 0000000..1fd7f58 Binary files /dev/null and b/uploads/Radhey construction.xlsx differ diff --git a/uploads/Raghuvanshi RMC Payment reconciliation.xlsx b/uploads/Raghuvanshi RMC Payment reconciliation.xlsx new file mode 100644 index 0000000..b2f9327 Binary files /dev/null and b/uploads/Raghuvanshi RMC Payment reconciliation.xlsx differ diff --git a/uploads/Raghuver Singh & Sons.xlsx b/uploads/Raghuver Singh & Sons.xlsx new file mode 100644 index 0000000..a158b37 Binary files /dev/null and b/uploads/Raghuver Singh & Sons.xlsx differ diff --git a/uploads/Rahat Construction Payment data not get stored in the data base.xlsx b/uploads/Rahat Construction Payment data not get stored in the data base.xlsx new file mode 100644 index 0000000..ab07ce7 Binary files /dev/null and b/uploads/Rahat Construction Payment data not get stored in the data base.xlsx differ diff --git a/uploads/Rahat Construction.xlsx b/uploads/Rahat Construction.xlsx new file mode 100644 index 0000000..1b4a18a Binary files /dev/null and b/uploads/Rahat Construction.xlsx differ diff --git a/uploads/Rahul Kumar Contractor.xlsx b/uploads/Rahul Kumar Contractor.xlsx new file mode 100644 index 0000000..ce6e85e Binary files /dev/null and b/uploads/Rahul Kumar Contractor.xlsx differ diff --git a/uploads/Rahul construction - Shamli.xlsx b/uploads/Rahul construction - Shamli.xlsx new file mode 100644 index 0000000..34d2508 Binary files /dev/null and b/uploads/Rahul construction - Shamli.xlsx differ diff --git a/uploads/Rais Mohammad data not get stored in data base.xlsx b/uploads/Rais Mohammad data not get stored in data base.xlsx new file mode 100644 index 0000000..d6fd1dd Binary files /dev/null and b/uploads/Rais Mohammad data not get stored in data base.xlsx differ diff --git a/uploads/Rais Mohammad.xlsx b/uploads/Rais Mohammad.xlsx new file mode 100644 index 0000000..7f31b4c Binary files /dev/null and b/uploads/Rais Mohammad.xlsx differ diff --git a/uploads/Raja Tenders Combined Payment Reconciliation.xlsx b/uploads/Raja Tenders Combined Payment Reconciliation.xlsx new file mode 100644 index 0000000..d0f781f Binary files /dev/null and b/uploads/Raja Tenders Combined Payment Reconciliation.xlsx differ diff --git a/uploads/Raja Tenders.xlsx b/uploads/Raja Tenders.xlsx new file mode 100644 index 0000000..be0cc56 Binary files /dev/null and b/uploads/Raja Tenders.xlsx differ diff --git a/uploads/Rajbeer Campus development.xlsx b/uploads/Rajbeer Campus development.xlsx new file mode 100644 index 0000000..8f0ffe1 Binary files /dev/null and b/uploads/Rajbeer Campus development.xlsx differ diff --git a/uploads/Rajdhani Service.xlsx b/uploads/Rajdhani Service.xlsx new file mode 100644 index 0000000..f69938f Binary files /dev/null and b/uploads/Rajdhani Service.xlsx differ diff --git a/uploads/Rajendra Kumar.xlsx b/uploads/Rajendra Kumar.xlsx new file mode 100644 index 0000000..f266ff6 Binary files /dev/null and b/uploads/Rajendra Kumar.xlsx differ diff --git a/uploads/Rajesh Contractor (1).xlsx b/uploads/Rajesh Contractor (1).xlsx new file mode 100644 index 0000000..24fe62c Binary files /dev/null and b/uploads/Rajesh Contractor (1).xlsx differ diff --git a/uploads/Rajesh Contractor.xlsx b/uploads/Rajesh Contractor.xlsx new file mode 100644 index 0000000..24fe62c Binary files /dev/null and b/uploads/Rajesh Contractor.xlsx differ diff --git a/uploads/Rakesh Biswas.xlsx b/uploads/Rakesh Biswas.xlsx new file mode 100644 index 0000000..555bb2e Binary files /dev/null and b/uploads/Rakesh Biswas.xlsx differ diff --git a/uploads/Rakesh Kumar Combined Sheet.xlsx b/uploads/Rakesh Kumar Combined Sheet.xlsx new file mode 100644 index 0000000..cceeee6 Binary files /dev/null and b/uploads/Rakesh Kumar Combined Sheet.xlsx differ diff --git a/uploads/Rakesh Singh.xlsx b/uploads/Rakesh Singh.xlsx new file mode 100644 index 0000000..516176e Binary files /dev/null and b/uploads/Rakesh Singh.xlsx differ diff --git a/uploads/Rakhi Rani.xlsx b/uploads/Rakhi Rani.xlsx new file mode 100644 index 0000000..dc8c7e6 Binary files /dev/null and b/uploads/Rakhi Rani.xlsx differ diff --git a/uploads/Rana Builders PR.xlsx b/uploads/Rana Builders PR.xlsx new file mode 100644 index 0000000..326d997 Binary files /dev/null and b/uploads/Rana Builders PR.xlsx differ diff --git a/uploads/Rana Builders updated.xlsx b/uploads/Rana Builders updated.xlsx new file mode 100644 index 0000000..b44f93d Binary files /dev/null and b/uploads/Rana Builders updated.xlsx differ diff --git a/uploads/Rana Builders.xlsx b/uploads/Rana Builders.xlsx new file mode 100644 index 0000000..df76aea Binary files /dev/null and b/uploads/Rana Builders.xlsx differ diff --git a/uploads/Rana Builders1 Two invoice number 1,3.xlsx b/uploads/Rana Builders1 Two invoice number 1,3.xlsx new file mode 100644 index 0000000..1fea06c Binary files /dev/null and b/uploads/Rana Builders1 Two invoice number 1,3.xlsx differ diff --git a/uploads/Rana Builders1.xlsx b/uploads/Rana Builders1.xlsx new file mode 100644 index 0000000..47a5aaa Binary files /dev/null and b/uploads/Rana Builders1.xlsx differ diff --git a/uploads/Rana Contractor - Talib.xlsx b/uploads/Rana Contractor - Talib.xlsx new file mode 100644 index 0000000..1e7f0e7 Binary files /dev/null and b/uploads/Rana Contractor - Talib.xlsx differ diff --git a/uploads/Rana Contractor .xlsx b/uploads/Rana Contractor .xlsx new file mode 100644 index 0000000..0589527 Binary files /dev/null and b/uploads/Rana Contractor .xlsx differ diff --git a/uploads/Rana Contractor.xlsx b/uploads/Rana Contractor.xlsx new file mode 100644 index 0000000..d180a55 Binary files /dev/null and b/uploads/Rana Contractor.xlsx differ diff --git a/uploads/Rana Trading Company.xlsx b/uploads/Rana Trading Company.xlsx new file mode 100644 index 0000000..a701177 Binary files /dev/null and b/uploads/Rana Trading Company.xlsx differ diff --git a/uploads/Rana.xlsx b/uploads/Rana.xlsx new file mode 100644 index 0000000..f7c58c3 Binary files /dev/null and b/uploads/Rana.xlsx differ diff --git a/uploads/Ratan Singh & Lala Dharam - Material & payment reconciliation.xlsx b/uploads/Ratan Singh & Lala Dharam - Material & payment reconciliation.xlsx new file mode 100644 index 0000000..4b262c7 Binary files /dev/null and b/uploads/Ratan Singh & Lala Dharam - Material & payment reconciliation.xlsx differ diff --git a/uploads/RathodConstruction.xlsx b/uploads/RathodConstruction.xlsx new file mode 100644 index 0000000..ec70d2a Binary files /dev/null and b/uploads/RathodConstruction.xlsx differ diff --git a/uploads/Rathor Construction.xlsx b/uploads/Rathor Construction.xlsx new file mode 100644 index 0000000..ec70d2a Binary files /dev/null and b/uploads/Rathor Construction.xlsx differ diff --git a/uploads/Rawal Construction.xlsx b/uploads/Rawal Construction.xlsx new file mode 100644 index 0000000..45e35e2 Binary files /dev/null and b/uploads/Rawal Construction.xlsx differ diff --git a/uploads/Rinku Dubey Combined Payment Reconciliation.xlsx b/uploads/Rinku Dubey Combined Payment Reconciliation.xlsx new file mode 100644 index 0000000..00ebee7 Binary files /dev/null and b/uploads/Rinku Dubey Combined Payment Reconciliation.xlsx differ diff --git a/uploads/Royal Buildcon Bhamela - CopyTest.xlsx b/uploads/Royal Buildcon Bhamela - CopyTest.xlsx new file mode 100644 index 0000000..bb06f77 Binary files /dev/null and b/uploads/Royal Buildcon Bhamela - CopyTest.xlsx differ diff --git a/uploads/Royal Buildcon Bhamela.xlsx b/uploads/Royal Buildcon Bhamela.xlsx new file mode 100644 index 0000000..ee201af Binary files /dev/null and b/uploads/Royal Buildcon Bhamela.xlsx differ diff --git a/uploads/S & N enterprises-Rohana kalan Village - MZN- Pipe laying work.xlsx b/uploads/S & N enterprises-Rohana kalan Village - MZN- Pipe laying work.xlsx new file mode 100644 index 0000000..044350b Binary files /dev/null and b/uploads/S & N enterprises-Rohana kalan Village - MZN- Pipe laying work.xlsx differ diff --git a/uploads/S J CONSTRUCTION.xlsx b/uploads/S J CONSTRUCTION.xlsx new file mode 100644 index 0000000..a4ded65 Binary files /dev/null and b/uploads/S J CONSTRUCTION.xlsx differ diff --git a/uploads/S J Construction .xlsx b/uploads/S J Construction .xlsx new file mode 100644 index 0000000..086852c Binary files /dev/null and b/uploads/S J Construction .xlsx differ diff --git a/uploads/S K Engineering.xlsx b/uploads/S K Engineering.xlsx new file mode 100644 index 0000000..056ee27 Binary files /dev/null and b/uploads/S K Engineering.xlsx differ diff --git a/uploads/S S Enterprises MZN.xlsx b/uploads/S S Enterprises MZN.xlsx new file mode 100644 index 0000000..8f198ab Binary files /dev/null and b/uploads/S S Enterprises MZN.xlsx differ diff --git a/uploads/S S Enterprises Sajid Khan.xlsx b/uploads/S S Enterprises Sajid Khan.xlsx new file mode 100644 index 0000000..fdac620 Binary files /dev/null and b/uploads/S S Enterprises Sajid Khan.xlsx differ diff --git a/uploads/S S Infrastructure Combined Payment Reconciliation.xlsx b/uploads/S S Infrastructure Combined Payment Reconciliation.xlsx new file mode 100644 index 0000000..30fad0e Binary files /dev/null and b/uploads/S S Infrastructure Combined Payment Reconciliation.xlsx differ diff --git a/uploads/S S Infrastructure.xlsx b/uploads/S S Infrastructure.xlsx new file mode 100644 index 0000000..e3f9f03 Binary files /dev/null and b/uploads/S S Infrastructure.xlsx differ diff --git a/uploads/S S enterprises - Shamli.xlsx b/uploads/S S enterprises - Shamli.xlsx new file mode 100644 index 0000000..8654d97 Binary files /dev/null and b/uploads/S S enterprises - Shamli.xlsx differ diff --git a/uploads/SAHARAWAT CONST.& SUPPLIERS.xlsx b/uploads/SAHARAWAT CONST.& SUPPLIERS.xlsx new file mode 100644 index 0000000..e8e8614 Binary files /dev/null and b/uploads/SAHARAWAT CONST.& SUPPLIERS.xlsx differ diff --git a/uploads/SAMAR ENGINEERING.xlsx b/uploads/SAMAR ENGINEERING.xlsx new file mode 100644 index 0000000..c9e6444 Binary files /dev/null and b/uploads/SAMAR ENGINEERING.xlsx differ diff --git a/uploads/SAMAR ENTERPRICES.xlsx b/uploads/SAMAR ENTERPRICES.xlsx new file mode 100644 index 0000000..5b3cbd1 Binary files /dev/null and b/uploads/SAMAR ENTERPRICES.xlsx differ diff --git a/uploads/SARESH TRADERS Payment Reconciliation (1).xlsx b/uploads/SARESH TRADERS Payment Reconciliation (1).xlsx new file mode 100644 index 0000000..c2378fc Binary files /dev/null and b/uploads/SARESH TRADERS Payment Reconciliation (1).xlsx differ diff --git a/uploads/SBR Enterprises .xlsx b/uploads/SBR Enterprises .xlsx new file mode 100644 index 0000000..44d8442 Binary files /dev/null and b/uploads/SBR Enterprises .xlsx differ diff --git a/uploads/SD Construction.xlsx b/uploads/SD Construction.xlsx new file mode 100644 index 0000000..7bfe595 Binary files /dev/null and b/uploads/SD Construction.xlsx differ diff --git a/uploads/SM Bharat construction co..xlsx b/uploads/SM Bharat construction co..xlsx new file mode 100644 index 0000000..0956c69 Binary files /dev/null and b/uploads/SM Bharat construction co..xlsx differ diff --git a/uploads/SR Enterprises.xlsx b/uploads/SR Enterprises.xlsx new file mode 100644 index 0000000..c0df1a4 Binary files /dev/null and b/uploads/SR Enterprises.xlsx differ diff --git a/uploads/SS Constraction Company.xlsx b/uploads/SS Constraction Company.xlsx new file mode 100644 index 0000000..0c7f86c Binary files /dev/null and b/uploads/SS Constraction Company.xlsx differ diff --git a/uploads/SSK Enterprises.xlsx b/uploads/SSK Enterprises.xlsx new file mode 100644 index 0000000..7ef93e4 Binary files /dev/null and b/uploads/SSK Enterprises.xlsx differ diff --git a/uploads/ST Enterprises.xlsx b/uploads/ST Enterprises.xlsx new file mode 100644 index 0000000..f0171a0 Binary files /dev/null and b/uploads/ST Enterprises.xlsx differ diff --git a/uploads/SURENDAR KUMAR.xlsx b/uploads/SURENDAR KUMAR.xlsx new file mode 100644 index 0000000..27a409a Binary files /dev/null and b/uploads/SURENDAR KUMAR.xlsx differ diff --git a/uploads/SWSM - MZN - MS Gaffar.xlsx b/uploads/SWSM - MZN - MS Gaffar.xlsx new file mode 100644 index 0000000..b74f822 Binary files /dev/null and b/uploads/SWSM - MZN - MS Gaffar.xlsx differ diff --git a/uploads/Sagar Construction Combined Sheet.xlsx b/uploads/Sagar Construction Combined Sheet.xlsx new file mode 100644 index 0000000..404642d Binary files /dev/null and b/uploads/Sagar Construction Combined Sheet.xlsx differ diff --git a/uploads/Sahzaad Contractor - MZN- OHT Construction work.xlsx b/uploads/Sahzaad Contractor - MZN- OHT Construction work.xlsx new file mode 100644 index 0000000..e0a327a Binary files /dev/null and b/uploads/Sahzaad Contractor - MZN- OHT Construction work.xlsx differ diff --git a/uploads/Sai Solar Power Traders Combined Sheet.xlsx b/uploads/Sai Solar Power Traders Combined Sheet.xlsx new file mode 100644 index 0000000..a618d19 Binary files /dev/null and b/uploads/Sai Solar Power Traders Combined Sheet.xlsx differ diff --git a/uploads/Saima Construction.xlsx b/uploads/Saima Construction.xlsx new file mode 100644 index 0000000..8fcf6da Binary files /dev/null and b/uploads/Saima Construction.xlsx differ diff --git a/uploads/Saloni Verma Combined Payment Reconciliation.xlsx b/uploads/Saloni Verma Combined Payment Reconciliation.xlsx new file mode 100644 index 0000000..bcd4832 Binary files /dev/null and b/uploads/Saloni Verma Combined Payment Reconciliation.xlsx differ diff --git a/uploads/Sandeep Kumar Company.xlsx b/uploads/Sandeep Kumar Company.xlsx new file mode 100644 index 0000000..49dca84 Binary files /dev/null and b/uploads/Sandeep Kumar Company.xlsx differ diff --git a/uploads/Sangatpura tubewell company.xlsx b/uploads/Sangatpura tubewell company.xlsx new file mode 100644 index 0000000..7ba548c Binary files /dev/null and b/uploads/Sangatpura tubewell company.xlsx differ diff --git a/uploads/Sarvda Traders.xlsx b/uploads/Sarvda Traders.xlsx new file mode 100644 index 0000000..01dcdc0 Binary files /dev/null and b/uploads/Sarvda Traders.xlsx differ diff --git a/uploads/Sarvodaya.xlsx b/uploads/Sarvodaya.xlsx new file mode 100644 index 0000000..8e03f97 Binary files /dev/null and b/uploads/Sarvodaya.xlsx differ diff --git a/uploads/Sarvodaya1.xlsx b/uploads/Sarvodaya1.xlsx new file mode 100644 index 0000000..4517c92 Binary files /dev/null and b/uploads/Sarvodaya1.xlsx differ diff --git a/uploads/Satvic foods.xlsx b/uploads/Satvic foods.xlsx new file mode 100644 index 0000000..8a8d6f3 Binary files /dev/null and b/uploads/Satvic foods.xlsx differ diff --git a/uploads/Satya Prakash.xlsx b/uploads/Satya Prakash.xlsx new file mode 100644 index 0000000..ca62bb6 Binary files /dev/null and b/uploads/Satya Prakash.xlsx differ diff --git a/uploads/Shah Alam Combined Sheet.xlsx b/uploads/Shah Alam Combined Sheet.xlsx new file mode 100644 index 0000000..8fd6f47 Binary files /dev/null and b/uploads/Shah Alam Combined Sheet.xlsx differ diff --git a/uploads/Shahin Payment Reconciliation.xlsx b/uploads/Shahin Payment Reconciliation.xlsx new file mode 100644 index 0000000..a73e2e5 Binary files /dev/null and b/uploads/Shahin Payment Reconciliation.xlsx differ diff --git a/uploads/Shahrukh.xlsx b/uploads/Shahrukh.xlsx new file mode 100644 index 0000000..12ca477 Binary files /dev/null and b/uploads/Shahrukh.xlsx differ diff --git a/uploads/Shamli Payment Reconcilation Rishal construction.xlsx b/uploads/Shamli Payment Reconcilation Rishal construction.xlsx new file mode 100644 index 0000000..f96181e Binary files /dev/null and b/uploads/Shamli Payment Reconcilation Rishal construction.xlsx differ diff --git a/uploads/Shan Contractor.xlsx b/uploads/Shan Contractor.xlsx new file mode 100644 index 0000000..47191fb Binary files /dev/null and b/uploads/Shan Contractor.xlsx differ diff --git a/uploads/Sharafat Enterprises Combined Sheet.xlsx b/uploads/Sharafat Enterprises Combined Sheet.xlsx new file mode 100644 index 0000000..0723137 Binary files /dev/null and b/uploads/Sharafat Enterprises Combined Sheet.xlsx differ diff --git a/uploads/Sharafat Enterprises.xlsx b/uploads/Sharafat Enterprises.xlsx new file mode 100644 index 0000000..ab5771c Binary files /dev/null and b/uploads/Sharafat Enterprises.xlsx differ diff --git a/uploads/Shiv Enterprises - Shamli.xlsx b/uploads/Shiv Enterprises - Shamli.xlsx new file mode 100644 index 0000000..f1772b1 Binary files /dev/null and b/uploads/Shiv Enterprises - Shamli.xlsx differ diff --git a/uploads/Shiv Enterprises MZN .xlsx b/uploads/Shiv Enterprises MZN .xlsx new file mode 100644 index 0000000..fe49a45 Binary files /dev/null and b/uploads/Shiv Enterprises MZN .xlsx differ diff --git a/uploads/Shiv Shakti Enterprises MZN - Copy - Copy.xlsx b/uploads/Shiv Shakti Enterprises MZN - Copy - Copy.xlsx new file mode 100644 index 0000000..6050d06 Binary files /dev/null and b/uploads/Shiv Shakti Enterprises MZN - Copy - Copy.xlsx differ diff --git a/uploads/Shiv Shakti Enterprises MZN - Copy.xlsx b/uploads/Shiv Shakti Enterprises MZN - Copy.xlsx new file mode 100644 index 0000000..72fb884 Binary files /dev/null and b/uploads/Shiv Shakti Enterprises MZN - Copy.xlsx differ diff --git a/uploads/Shivalik Enterprises RMC payment reconciliation.xlsx b/uploads/Shivalik Enterprises RMC payment reconciliation.xlsx new file mode 100644 index 0000000..51e84e5 Binary files /dev/null and b/uploads/Shivalik Enterprises RMC payment reconciliation.xlsx differ diff --git a/uploads/Shravya Construction.xlsx b/uploads/Shravya Construction.xlsx new file mode 100644 index 0000000..ce77005 Binary files /dev/null and b/uploads/Shravya Construction.xlsx differ diff --git a/uploads/Shree Balaji contractor .xlsx b/uploads/Shree Balaji contractor .xlsx new file mode 100644 index 0000000..e2dc081 Binary files /dev/null and b/uploads/Shree Balaji contractor .xlsx differ diff --git a/uploads/Shree Krishna Traders.xlsx b/uploads/Shree Krishna Traders.xlsx new file mode 100644 index 0000000..69d9f0a Binary files /dev/null and b/uploads/Shree Krishna Traders.xlsx differ diff --git a/uploads/Shree Laxmi Enterprises.xlsx b/uploads/Shree Laxmi Enterprises.xlsx new file mode 100644 index 0000000..b12f67c Binary files /dev/null and b/uploads/Shree Laxmi Enterprises.xlsx differ diff --git a/uploads/Shree Raj construction & Co. Combined Sheet.xlsx b/uploads/Shree Raj construction & Co. Combined Sheet.xlsx new file mode 100644 index 0000000..fa322fe Binary files /dev/null and b/uploads/Shree Raj construction & Co. Combined Sheet.xlsx differ diff --git a/uploads/Shree Ram Infrastructures - MZN .xlsx b/uploads/Shree Ram Infrastructures - MZN .xlsx new file mode 100644 index 0000000..745ca12 Binary files /dev/null and b/uploads/Shree Ram Infrastructures - MZN .xlsx differ diff --git a/uploads/Shree Ram Infrastructures Shamli-issue.xlsx b/uploads/Shree Ram Infrastructures Shamli-issue.xlsx new file mode 100644 index 0000000..f5387c7 Binary files /dev/null and b/uploads/Shree Ram Infrastructures Shamli-issue.xlsx differ diff --git a/uploads/Shree Ram Infrastructures Shamli.xlsx b/uploads/Shree Ram Infrastructures Shamli.xlsx new file mode 100644 index 0000000..f93186b Binary files /dev/null and b/uploads/Shree Ram Infrastructures Shamli.xlsx differ diff --git a/uploads/Shree Shyam Construction.xlsx b/uploads/Shree Shyam Construction.xlsx new file mode 100644 index 0000000..f6b125b Binary files /dev/null and b/uploads/Shree Shyam Construction.xlsx differ diff --git a/uploads/Shree Shyam Enterprises.xlsx b/uploads/Shree Shyam Enterprises.xlsx new file mode 100644 index 0000000..29fd59c Binary files /dev/null and b/uploads/Shree Shyam Enterprises.xlsx differ diff --git a/uploads/Shree Shyam Ji Traders.xlsx b/uploads/Shree Shyam Ji Traders.xlsx new file mode 100644 index 0000000..7c18497 Binary files /dev/null and b/uploads/Shree Shyam Ji Traders.xlsx differ diff --git a/uploads/Shree mangalam construction co. - sardhan Village - All work.xlsx b/uploads/Shree mangalam construction co. - sardhan Village - All work.xlsx new file mode 100644 index 0000000..11f94d6 Binary files /dev/null and b/uploads/Shree mangalam construction co. - sardhan Village - All work.xlsx differ diff --git a/uploads/Shri Balaji Construction.xlsx b/uploads/Shri Balaji Construction.xlsx new file mode 100644 index 0000000..388f9c8 Binary files /dev/null and b/uploads/Shri Balaji Construction.xlsx differ diff --git a/uploads/Shri Balaji Trader.xlsx b/uploads/Shri Balaji Trader.xlsx new file mode 100644 index 0000000..ce1729f Binary files /dev/null and b/uploads/Shri Balaji Trader.xlsx differ diff --git a/uploads/Shri Khatu Shyam Enterpises .xlsx b/uploads/Shri Khatu Shyam Enterpises .xlsx new file mode 100644 index 0000000..030954b Binary files /dev/null and b/uploads/Shri Khatu Shyam Enterpises .xlsx differ diff --git a/uploads/Shri Krishna Enterprises Combined Sheet.xlsx b/uploads/Shri Krishna Enterprises Combined Sheet.xlsx new file mode 100644 index 0000000..7ec5682 Binary files /dev/null and b/uploads/Shri Krishna Enterprises Combined Sheet.xlsx differ diff --git a/uploads/Shri Mantai Mahate Construction.xlsx b/uploads/Shri Mantai Mahate Construction.xlsx new file mode 100644 index 0000000..22b9e1f Binary files /dev/null and b/uploads/Shri Mantai Mahate Construction.xlsx differ diff --git a/uploads/Shri Sai Constructions.xlsx b/uploads/Shri Sai Constructions.xlsx new file mode 100644 index 0000000..32d2c60 Binary files /dev/null and b/uploads/Shri Sai Constructions.xlsx differ diff --git a/uploads/Shri Shyam Enterpsise.xlsx b/uploads/Shri Shyam Enterpsise.xlsx new file mode 100644 index 0000000..7086490 Binary files /dev/null and b/uploads/Shri Shyam Enterpsise.xlsx differ diff --git a/uploads/Shri shri Balaji contractor.xlsx b/uploads/Shri shri Balaji contractor.xlsx new file mode 100644 index 0000000..cf02ed4 Binary files /dev/null and b/uploads/Shri shri Balaji contractor.xlsx differ diff --git a/uploads/Shubham Kumar.xlsx b/uploads/Shubham Kumar.xlsx new file mode 100644 index 0000000..7b7a2d8 Binary files /dev/null and b/uploads/Shubham Kumar.xlsx differ diff --git a/uploads/Shubham gurjar.xlsx b/uploads/Shubham gurjar.xlsx new file mode 100644 index 0000000..4ca31c6 Binary files /dev/null and b/uploads/Shubham gurjar.xlsx differ diff --git a/uploads/Shubhash Combined Sheet.xlsx b/uploads/Shubhash Combined Sheet.xlsx new file mode 100644 index 0000000..e31db25 Binary files /dev/null and b/uploads/Shubhash Combined Sheet.xlsx differ diff --git a/uploads/Siddhi Groups & Constructions-Machhrauli-VILLAGE Payment Reconcilation -.xlsx b/uploads/Siddhi Groups & Constructions-Machhrauli-VILLAGE Payment Reconcilation -.xlsx new file mode 100644 index 0000000..a1cf757 Binary files /dev/null and b/uploads/Siddhi Groups & Constructions-Machhrauli-VILLAGE Payment Reconcilation -.xlsx differ diff --git a/uploads/Sirohi Builders & Construction.xlsx b/uploads/Sirohi Builders & Construction.xlsx new file mode 100644 index 0000000..3349e67 Binary files /dev/null and b/uploads/Sirohi Builders & Construction.xlsx differ diff --git a/uploads/Skyline Airconditioning Engineers PVT LTD.xlsx b/uploads/Skyline Airconditioning Engineers PVT LTD.xlsx new file mode 100644 index 0000000..526eaf1 Binary files /dev/null and b/uploads/Skyline Airconditioning Engineers PVT LTD.xlsx differ diff --git a/uploads/Skyline air-conditioning Engineers PVT LTD.xlsx b/uploads/Skyline air-conditioning Engineers PVT LTD.xlsx new file mode 100644 index 0000000..3301d64 Binary files /dev/null and b/uploads/Skyline air-conditioning Engineers PVT LTD.xlsx differ diff --git a/uploads/Sonam Pipe leakage & repair work.xlsx b/uploads/Sonam Pipe leakage & repair work.xlsx new file mode 100644 index 0000000..c61379f Binary files /dev/null and b/uploads/Sonam Pipe leakage & repair work.xlsx differ diff --git a/uploads/Sonu Prasad Gupta.xlsx b/uploads/Sonu Prasad Gupta.xlsx new file mode 100644 index 0000000..f356083 Binary files /dev/null and b/uploads/Sonu Prasad Gupta.xlsx differ diff --git a/uploads/Sonu Sunil Saini Cement Agency - Road Restoration work.xlsx b/uploads/Sonu Sunil Saini Cement Agency - Road Restoration work.xlsx new file mode 100644 index 0000000..e21cf2d Binary files /dev/null and b/uploads/Sonu Sunil Saini Cement Agency - Road Restoration work.xlsx differ diff --git a/uploads/Sun Rise Contractor.xlsx b/uploads/Sun Rise Contractor.xlsx new file mode 100644 index 0000000..f03dc27 Binary files /dev/null and b/uploads/Sun Rise Contractor.xlsx differ diff --git a/uploads/Sun Rise Infra Associates.xlsx b/uploads/Sun Rise Infra Associates.xlsx new file mode 100644 index 0000000..9b85f69 Binary files /dev/null and b/uploads/Sun Rise Infra Associates.xlsx differ diff --git a/uploads/Sundar Balyan.xlsx b/uploads/Sundar Balyan.xlsx new file mode 100644 index 0000000..b3ac8a4 Binary files /dev/null and b/uploads/Sundar Balyan.xlsx differ diff --git a/uploads/Surya Enterprises.xlsx b/uploads/Surya Enterprises.xlsx new file mode 100644 index 0000000..19fa422 Binary files /dev/null and b/uploads/Surya Enterprises.xlsx differ diff --git a/uploads/Suryadev Tiles payment reconciliation.xlsx b/uploads/Suryadev Tiles payment reconciliation.xlsx new file mode 100644 index 0000000..752d9e0 Binary files /dev/null and b/uploads/Suryadev Tiles payment reconciliation.xlsx differ diff --git a/uploads/Swaroopa Enterprises - MZN .xlsx b/uploads/Swaroopa Enterprises - MZN .xlsx new file mode 100644 index 0000000..ef09312 Binary files /dev/null and b/uploads/Swaroopa Enterprises - MZN .xlsx differ diff --git a/uploads/THE MAA BISHAN DEVI.xlsx b/uploads/THE MAA BISHAN DEVI.xlsx new file mode 100644 index 0000000..4748b99 Binary files /dev/null and b/uploads/THE MAA BISHAN DEVI.xlsx differ diff --git a/uploads/Tahseen Rana Constcuction- SHAMLI.xlsx b/uploads/Tahseen Rana Constcuction- SHAMLI.xlsx new file mode 100644 index 0000000..6e9d938 Binary files /dev/null and b/uploads/Tahseen Rana Constcuction- SHAMLI.xlsx differ diff --git a/uploads/Tarachand.xlsx b/uploads/Tarachand.xlsx new file mode 100644 index 0000000..7f3f4c1 Binary files /dev/null and b/uploads/Tarachand.xlsx differ diff --git a/uploads/Tarun TyagiCombined Sheet.xlsx b/uploads/Tarun TyagiCombined Sheet.xlsx new file mode 100644 index 0000000..0234d5c Binary files /dev/null and b/uploads/Tarun TyagiCombined Sheet.xlsx differ diff --git a/uploads/Thakur Ji Infra project.xlsx b/uploads/Thakur Ji Infra project.xlsx new file mode 100644 index 0000000..eb49368 Binary files /dev/null and b/uploads/Thakur Ji Infra project.xlsx differ diff --git a/uploads/Umarnawaj.xlsx b/uploads/Umarnawaj.xlsx new file mode 100644 index 0000000..899d386 Binary files /dev/null and b/uploads/Umarnawaj.xlsx differ diff --git a/uploads/Unique Construction.xlsx b/uploads/Unique Construction.xlsx new file mode 100644 index 0000000..9b0a72a Binary files /dev/null and b/uploads/Unique Construction.xlsx differ diff --git a/uploads/Unique Production Services Combined Payment Reconciliation.xlsx b/uploads/Unique Production Services Combined Payment Reconciliation.xlsx new file mode 100644 index 0000000..b11644c Binary files /dev/null and b/uploads/Unique Production Services Combined Payment Reconciliation.xlsx differ diff --git a/uploads/V K nterprises.xlsx b/uploads/V K nterprises.xlsx new file mode 100644 index 0000000..2f77bf1 Binary files /dev/null and b/uploads/V K nterprises.xlsx differ diff --git a/uploads/V P Enterprises - Combined Payment Reconcilation - Pipe laying work.xlsx b/uploads/V P Enterprises - Combined Payment Reconcilation - Pipe laying work.xlsx new file mode 100644 index 0000000..bb49434 Binary files /dev/null and b/uploads/V P Enterprises - Combined Payment Reconcilation - Pipe laying work.xlsx differ diff --git a/uploads/VAYOM GC PVT LTD.xlsx b/uploads/VAYOM GC PVT LTD.xlsx new file mode 100644 index 0000000..00b9dd2 Binary files /dev/null and b/uploads/VAYOM GC PVT LTD.xlsx differ diff --git a/uploads/VDS Enterprises.xlsx b/uploads/VDS Enterprises.xlsx new file mode 100644 index 0000000..877b218 Binary files /dev/null and b/uploads/VDS Enterprises.xlsx differ diff --git a/uploads/VINOD ENGINEERING -shamli.xlsx b/uploads/VINOD ENGINEERING -shamli.xlsx new file mode 100644 index 0000000..33ae674 Binary files /dev/null and b/uploads/VINOD ENGINEERING -shamli.xlsx differ diff --git a/uploads/Vaishanvi Construction.xlsx b/uploads/Vaishanvi Construction.xlsx new file mode 100644 index 0000000..a33bc33 Binary files /dev/null and b/uploads/Vaishanvi Construction.xlsx differ diff --git a/uploads/Vandata Organic.xlsx b/uploads/Vandata Organic.xlsx new file mode 100644 index 0000000..c2671af Binary files /dev/null and b/uploads/Vandata Organic.xlsx differ diff --git a/uploads/Vansh Const..xlsx b/uploads/Vansh Const..xlsx new file mode 100644 index 0000000..f121f79 Binary files /dev/null and b/uploads/Vansh Const..xlsx differ diff --git a/uploads/Vansh Industries.xlsx b/uploads/Vansh Industries.xlsx new file mode 100644 index 0000000..4a3d788 Binary files /dev/null and b/uploads/Vansh Industries.xlsx differ diff --git a/uploads/Vikash Kumar Combined Sheet.xlsx b/uploads/Vikash Kumar Combined Sheet.xlsx new file mode 100644 index 0000000..81815e6 Binary files /dev/null and b/uploads/Vikash Kumar Combined Sheet.xlsx differ diff --git a/uploads/Vikash.xlsx b/uploads/Vikash.xlsx new file mode 100644 index 0000000..1f9d8bb Binary files /dev/null and b/uploads/Vikash.xlsx differ diff --git a/uploads/Vineet Kumar Combined Sheet.xlsx b/uploads/Vineet Kumar Combined Sheet.xlsx new file mode 100644 index 0000000..7fde4de Binary files /dev/null and b/uploads/Vineet Kumar Combined Sheet.xlsx differ diff --git a/uploads/Vinit khatiyan enterprises.xlsx b/uploads/Vinit khatiyan enterprises.xlsx new file mode 100644 index 0000000..f268c25 Binary files /dev/null and b/uploads/Vinit khatiyan enterprises.xlsx differ diff --git a/uploads/Vinod Kumar .xlsx b/uploads/Vinod Kumar .xlsx new file mode 100644 index 0000000..4d7d34d Binary files /dev/null and b/uploads/Vinod Kumar .xlsx differ diff --git a/uploads/WAHE GURU TRADERS.xlsx b/uploads/WAHE GURU TRADERS.xlsx new file mode 100644 index 0000000..d4b89b8 Binary files /dev/null and b/uploads/WAHE GURU TRADERS.xlsx differ diff --git a/uploads/Welcome construction & Company.xlsx b/uploads/Welcome construction & Company.xlsx new file mode 100644 index 0000000..ef475e3 Binary files /dev/null and b/uploads/Welcome construction & Company.xlsx differ diff --git a/uploads/YUVRAJ CONSTRUCTION.xlsx b/uploads/YUVRAJ CONSTRUCTION.xlsx new file mode 100644 index 0000000..c75443b Binary files /dev/null and b/uploads/YUVRAJ CONSTRUCTION.xlsx differ diff --git a/uploads/Yashank Enterprises.xlsx b/uploads/Yashank Enterprises.xlsx new file mode 100644 index 0000000..749ff20 Binary files /dev/null and b/uploads/Yashank Enterprises.xlsx differ diff --git a/uploads/Yashpal Singh.xlsx b/uploads/Yashpal Singh.xlsx new file mode 100644 index 0000000..095f6ef Binary files /dev/null and b/uploads/Yashpal Singh.xlsx differ diff --git a/uploads/choudhary traders.xlsx b/uploads/choudhary traders.xlsx new file mode 100644 index 0000000..71d2d72 Binary files /dev/null and b/uploads/choudhary traders.xlsx differ diff --git a/uploads/lokvinayak infrastructure.xlsx b/uploads/lokvinayak infrastructure.xlsx new file mode 100644 index 0000000..61967d8 Binary files /dev/null and b/uploads/lokvinayak infrastructure.xlsx differ diff --git a/uploads/sharda construction.xlsx b/uploads/sharda construction.xlsx new file mode 100644 index 0000000..bdcbc4b Binary files /dev/null and b/uploads/sharda construction.xlsx differ diff --git a/uploads/shiv suraj power network.xlsx b/uploads/shiv suraj power network.xlsx new file mode 100644 index 0000000..eb019e3 Binary files /dev/null and b/uploads/shiv suraj power network.xlsx differ diff --git a/uploads/shree ganesh enterprises.xlsx b/uploads/shree ganesh enterprises.xlsx new file mode 100644 index 0000000..489a926 Binary files /dev/null and b/uploads/shree ganesh enterprises.xlsx differ diff --git a/uploads/soray pratap contractor-shamli.xlsx b/uploads/soray pratap contractor-shamli.xlsx new file mode 100644 index 0000000..5297207 Binary files /dev/null and b/uploads/soray pratap contractor-shamli.xlsx differ diff --git a/uploads/unique production & Construction Services.xlsx b/uploads/unique production & Construction Services.xlsx new file mode 100644 index 0000000..c72be59 Binary files /dev/null and b/uploads/unique production & Construction Services.xlsx differ diff --git a/uploads/vani associate.xlsx b/uploads/vani associate.xlsx new file mode 100644 index 0000000..d91c743 Binary files /dev/null and b/uploads/vani associate.xlsx differ diff --git a/uploads/worldwide cargo solutions.xlsx b/uploads/worldwide cargo solutions.xlsx new file mode 100644 index 0000000..e6f336d Binary files /dev/null and b/uploads/worldwide cargo solutions.xlsx differ diff --git a/uploads/~$Gaffar.xlsx b/uploads/~$Gaffar.xlsx new file mode 100644 index 0000000..ef4b64a Binary files /dev/null and b/uploads/~$Gaffar.xlsx differ