first commit

This commit is contained in:
Pooja Fulari
2026-05-15 13:00:12 +05:30
parent 049f7e1c0a
commit 28c1894fde
3 changed files with 708 additions and 7 deletions

View File

@@ -8,7 +8,7 @@ from flask import Blueprint, request, render_template, redirect, url_for, jsonif
from model.Log import LogHelper
from model.FolderAndFile import FolderAndFile
from datetime import datetime
excel_bp = Blueprint('excel', __name__)
# ---------------- Upload Excel File ----------------
@@ -170,12 +170,29 @@ def save_data():
cursor = connection.cursor()
try:
for entry in data:
# ---- Fix Invoice Date ----
invoice_date = entry.get("Invoice_Date")
if invoice_date:
if hasattr(invoice_date, "strftime"):
invoice_date = invoice_date.strftime("%Y-%m-%d")
elif isinstance(invoice_date, str):
try:
invoice_date = datetime.strptime(
invoice_date.strip(),
"%d-%m-%Y"
).strftime("%Y-%m-%d")
except:
invoice_date = None
else:
invoice_date = None
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_Date": entry.get("Invoice_Date").strftime('%Y-%m-%d') if entry.get("Invoice_Date") else None,
"Invoice_Date": invoice_date,
"Invoice_No": entry.get("Invoice_No", ''),
"Basic_Amount": entry.get("Basic_Amount", 0.00),
"Debit_Amount": entry.get("Debit_Amount", 0.00),
@@ -267,8 +284,7 @@ def save_data():
invoice_id
)
)
if isinstance(hold_columns, str):
hold_columns = ast.literal_eval(hold_columns)
if isinstance(hold_columns, list) and all(isinstance(hold, dict) for hold in hold_columns):
@@ -339,10 +355,30 @@ def save_data():
# --------------------------------------
# If no village/work detected, only PMC/Payment
if not (Invoice_Details and 'village' in Invoice_Details.lower() and 'work' in Invoice_Details.lower()):
# if not (Invoice_Details and 'village' in Invoice_Details.lower() and 'work' in Invoice_Details.lower()):
details = (Invoice_Details or "").strip().lower()
keywords = [
'credit',
'debit',
'logging report',
'gst',
'release',
'gst release note',
'village',
'work'
]
if details == "" or details=='hold' or not any(k in details for k in keywords):
if Invoice_Details is None or Invoice_Details.strip() == "":
details = "" # add blank when None or empty
elif 'hold' in Invoice_Details.lower():
details = Invoice_Details
# ---------- Only PMC / Payment rows ----------
if PMC_No and not Invoice_No and UTR :
cursor.callproc("insertExtrapaymet",(PMC_No, subcontractor_id))
cursor.callproc("insertExtrapaymet",(PMC_No,details,subcontractor_id))
for result in cursor.stored_results():
row = result.fetchone()
invoice_id = row[0] if row else None