GST Release Display Chages
This commit is contained in:
@@ -6,7 +6,6 @@ import config
|
||||
import re
|
||||
import mysql.connector
|
||||
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# Mapping Class
|
||||
# ----------------------------------------------------------
|
||||
@@ -23,10 +22,11 @@ class itemCRUDMapping:
|
||||
self.name = "Hold Type"
|
||||
elif itemType is ItemCRUDType.Subcontractor:
|
||||
self.name = "Subcontractor"
|
||||
elif itemType.name == "GSTRelease":
|
||||
self.name = "GSTRelease"
|
||||
else:
|
||||
self.name = "Item"
|
||||
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# Generic CRUD Class
|
||||
# ----------------------------------------------------------
|
||||
@@ -93,13 +93,47 @@ class ItemCRUD:
|
||||
|
||||
try:
|
||||
# ======================================================
|
||||
# SUBCONTRACTOR (MULTI-FIELD)
|
||||
# GSTRelease MULTI-FIELD
|
||||
# ======================================================
|
||||
if data:
|
||||
if self.itemCRUDType.name == "GSTRelease" and data:
|
||||
|
||||
# Duplicate check (PMC_No + Invoice_No)
|
||||
if storedprocfetch:
|
||||
cursor.callproc(storedprocfetch, (data['PMC_No'], data['Invoice_No']))
|
||||
existing_item = None
|
||||
for rs in cursor.stored_results():
|
||||
existing_item = rs.fetchone()
|
||||
if existing_item:
|
||||
self.isSuccess = False
|
||||
self.resultMessage = HtmlHelper.json_response(
|
||||
ResponseHandler.already_exists(self.itemCRUDMapping.name), 409
|
||||
)
|
||||
return
|
||||
|
||||
# Insert GSTRelease
|
||||
cursor.callproc(storedprocadd, (
|
||||
data['PMC_No'],
|
||||
data['Invoice_No'],
|
||||
data['Basic_Amount'],
|
||||
data['Final_Amount'],
|
||||
data['Total_Amount'],
|
||||
data['UTR'],
|
||||
data['Contractor_ID']
|
||||
))
|
||||
connection.commit()
|
||||
|
||||
self.isSuccess = True
|
||||
self.resultMessage = HtmlHelper.json_response(
|
||||
ResponseHandler.add_success(self.itemCRUDMapping.name), 200
|
||||
)
|
||||
return
|
||||
|
||||
# ======================================================
|
||||
# SUBCONTRACTOR MULTI-FIELD
|
||||
# ======================================================
|
||||
if self.itemCRUDType.name == "Subcontractor" and data:
|
||||
|
||||
# Duplicate check
|
||||
cursor.callproc(storedprocfetch, (data['Contractor_Name'],))
|
||||
|
||||
existing_item = None
|
||||
for rs in cursor.stored_results():
|
||||
existing_item = rs.fetchone()
|
||||
@@ -111,7 +145,6 @@ class ItemCRUD:
|
||||
)
|
||||
return
|
||||
|
||||
# Insert
|
||||
cursor.callproc(storedprocadd, (
|
||||
data['Contractor_Name'],
|
||||
data['Address'],
|
||||
@@ -123,17 +156,16 @@ class ItemCRUD:
|
||||
data['GST_No'],
|
||||
data['Contractor_password']
|
||||
))
|
||||
|
||||
connection.commit()
|
||||
|
||||
self.isSuccess = True
|
||||
self.resultMessage = HtmlHelper.json_response(
|
||||
ResponseHandler.add_success(self.itemCRUDMapping.name), 200
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
# ======================================================
|
||||
# NORMAL (Village / Block / State)
|
||||
# NORMAL SINGLE-FIELD (Village / Block / State)
|
||||
# ======================================================
|
||||
if not re.match(RegEx.patternAlphabetOnly, childname):
|
||||
self.isSuccess = False
|
||||
@@ -142,7 +174,6 @@ class ItemCRUD:
|
||||
)
|
||||
return
|
||||
|
||||
# Duplicate check
|
||||
if parentid is None:
|
||||
cursor.callproc(storedprocfetch, (childname,))
|
||||
else:
|
||||
@@ -159,17 +190,14 @@ class ItemCRUD:
|
||||
)
|
||||
return
|
||||
|
||||
# Insert
|
||||
if parentid is None:
|
||||
cursor.callproc(storedprocadd, (childname,))
|
||||
else:
|
||||
cursor.callproc(storedprocadd, (childname, parentid))
|
||||
|
||||
connection.commit()
|
||||
|
||||
self.isSuccess = True
|
||||
self.resultMessage = HtmlHelper.json_response(
|
||||
|
||||
ResponseHandler.add_success(self.itemCRUDMapping.name), 200
|
||||
)
|
||||
|
||||
@@ -199,9 +227,33 @@ class ItemCRUD:
|
||||
|
||||
try:
|
||||
# ======================================================
|
||||
# SUBCONTRACTOR (MULTI-FIELD)
|
||||
# GSTRelease MULTI-FIELD
|
||||
# ======================================================
|
||||
if data:
|
||||
if self.itemCRUDType.name == "GSTRelease" and data:
|
||||
|
||||
cursor.callproc(storedprocupdate, (
|
||||
childid,
|
||||
data['PMC_No'],
|
||||
data['Invoice_No'],
|
||||
data['Basic_Amount'],
|
||||
data['Final_Amount'],
|
||||
data['Total_Amount'],
|
||||
data['UTR'],
|
||||
data['Contractor_ID']
|
||||
))
|
||||
connection.commit()
|
||||
|
||||
self.isSuccess = True
|
||||
self.resultMessage = HtmlHelper.json_response(
|
||||
ResponseHandler.update_success(self.itemCRUDMapping.name), 200
|
||||
)
|
||||
return
|
||||
|
||||
# ======================================================
|
||||
# SUBCONTRACTOR MULTI-FIELD
|
||||
# ======================================================
|
||||
if self.itemCRUDType.name == "Subcontractor" and data:
|
||||
|
||||
cursor.callproc(storedprocupdate, (
|
||||
childid,
|
||||
data['Contractor_Name'],
|
||||
@@ -214,9 +266,7 @@ class ItemCRUD:
|
||||
data['GST_No'],
|
||||
data['Contractor_password']
|
||||
))
|
||||
|
||||
connection.commit()
|
||||
|
||||
self.isSuccess = True
|
||||
self.resultMessage = HtmlHelper.json_response(
|
||||
ResponseHandler.update_success(self.itemCRUDMapping.name), 200
|
||||
@@ -224,7 +274,7 @@ class ItemCRUD:
|
||||
return
|
||||
|
||||
# ======================================================
|
||||
# NORMAL
|
||||
# NORMAL SINGLE-FIELD
|
||||
# ======================================================
|
||||
if not re.match(RegEx.patternAlphabetOnly, childname):
|
||||
self.isSuccess = False
|
||||
@@ -237,7 +287,6 @@ class ItemCRUD:
|
||||
cursor.callproc(storedprocupdate, (childid, parentid, childname))
|
||||
|
||||
connection.commit()
|
||||
|
||||
self.isSuccess = True
|
||||
self.resultMessage = ResponseHandler.update_success(self.itemCRUDMapping.name)['message']
|
||||
|
||||
@@ -259,20 +308,15 @@ class ItemCRUD:
|
||||
|
||||
data = []
|
||||
connection = config.get_db_connection()
|
||||
|
||||
if not connection:
|
||||
return []
|
||||
|
||||
cursor = connection.cursor()
|
||||
|
||||
try:
|
||||
cursor.callproc(storedproc)
|
||||
|
||||
for result in cursor.stored_results():
|
||||
data = result.fetchall()
|
||||
|
||||
self.isSuccess = True
|
||||
|
||||
except mysql.connector.Error as e:
|
||||
print(f"Error fetching {self.itemCRUDMapping.name}: {e}")
|
||||
self.isSuccess = False
|
||||
@@ -280,7 +324,6 @@ class ItemCRUD:
|
||||
ResponseHandler.fetch_failure(self.itemCRUDMapping.name), 500
|
||||
)
|
||||
return []
|
||||
|
||||
finally:
|
||||
cursor.close()
|
||||
connection.close()
|
||||
@@ -298,13 +341,10 @@ class ItemCRUD:
|
||||
|
||||
try:
|
||||
cursor.callproc(storedproc, (id,))
|
||||
|
||||
for rs in cursor.stored_results():
|
||||
data = rs.fetchone()
|
||||
|
||||
except mysql.connector.Error as e:
|
||||
print(f"Error fetching {self.itemCRUDMapping.name}: {e}")
|
||||
|
||||
finally:
|
||||
cursor.close()
|
||||
connection.close()
|
||||
@@ -353,7 +393,6 @@ class ItemCRUD:
|
||||
return HtmlHelper.json_response(
|
||||
ResponseHandler.fetch_failure(self.itemCRUDMapping.name), 500
|
||||
)
|
||||
|
||||
finally:
|
||||
cursor.close()
|
||||
connection.close()
|
||||
@@ -8,7 +8,7 @@ class ItemCRUDType(Enum):
|
||||
State = 4
|
||||
HoldType = 5
|
||||
Subcontractor = 6
|
||||
|
||||
GSTRelease = 7
|
||||
|
||||
class RegEx:
|
||||
patternAlphabetOnly = "^[A-Za-z ]+$"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,109 +1,8 @@
|
||||
# from flask import request
|
||||
# from model.ItemCRUD import ItemCRUD
|
||||
# from model.Utilities import ItemCRUDType
|
||||
|
||||
# class GSTRelease:
|
||||
# """CRUD operations for GST Release using ItemCRUD"""
|
||||
|
||||
# def __init__(self):
|
||||
# self.isSuccess = False
|
||||
# self.resultMessage = ""
|
||||
|
||||
# # ------------------- Add GST Release -------------------
|
||||
# def AddGSTRelease(self, request):
|
||||
# pmc_no = request.form.get('PMC_No', '').strip()
|
||||
# invoice_no = request.form.get('invoice_No', '').strip()
|
||||
|
||||
# gst = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||
# gst.AddItem(
|
||||
# request=request,
|
||||
# parentid=None,
|
||||
# childname=f"{pmc_no}-{invoice_no}",
|
||||
# storedprocfetch="CheckGSTReleaseExists",
|
||||
# storedprocadd="AddGSTReleaseFromExcel" # your stored procedure handles extra fields
|
||||
# )
|
||||
|
||||
# self.isSuccess = gst.isSuccess
|
||||
# self.resultMessage = str(gst.resultMessage)
|
||||
|
||||
# # ------------------- Get All GST Releases -------------------
|
||||
# def GetAllGSTReleases(self):
|
||||
# gst = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||
# # Pass request=None for fetch
|
||||
# rows = gst.GetAllData(request=None, storedproc="GetAllGSTReleases")
|
||||
|
||||
# self.isSuccess = gst.isSuccess
|
||||
# self.resultMessage = str(gst.resultMessage)
|
||||
|
||||
# data = []
|
||||
# for row in rows:
|
||||
# data.append({
|
||||
# "gst_release_id": row[0],
|
||||
# "pmc_no": row[1],
|
||||
# "invoice_no": row[2],
|
||||
# "basic_amount": row[3],
|
||||
# "final_amount": row[4],
|
||||
# "total_amount": row[5],
|
||||
# "utr": row[6],
|
||||
# "contractor_id": row[7]
|
||||
# })
|
||||
# return data
|
||||
|
||||
# # ------------------- Get GST Release By ID -------------------
|
||||
# def GetGSTReleaseByID(self, gst_release_id):
|
||||
# gst = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||
# row = gst.GetDataByID(gst_release_id, request=None, storedproc="GetGSTReleaseById")
|
||||
|
||||
# self.isSuccess = gst.isSuccess
|
||||
# self.resultMessage = str(gst.resultMessage)
|
||||
|
||||
# if row:
|
||||
# return {
|
||||
# "gst_release_id": row[0],
|
||||
# "pmc_no": row[1],
|
||||
# "invoice_no": row[2],
|
||||
# "basic_amount": row[3],
|
||||
# "final_amount": row[4],
|
||||
# "total_amount": row[5],
|
||||
# "utr": row[6],
|
||||
# "contractor_id": row[7]
|
||||
# }
|
||||
# return None
|
||||
|
||||
# # ------------------- Edit GST Release -------------------
|
||||
# def EditGSTRelease(self, request, gst_release_id):
|
||||
# pmc_no = request.form.get('PMC_No', '').strip()
|
||||
# invoice_no = request.form.get('invoice_No', '').strip()
|
||||
|
||||
# gst = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||
# gst.EditItem(
|
||||
# request=request,
|
||||
# childid=gst_release_id,
|
||||
# parentid=None,
|
||||
# childname=f"{pmc_no}-{invoice_no}",
|
||||
# storedprocupdate="UpdateGSTRelease" # stored procedure handles extra fields
|
||||
# )
|
||||
|
||||
# self.isSuccess = gst.isSuccess
|
||||
# self.resultMessage = str(gst.resultMessage)
|
||||
|
||||
# # ------------------- Delete GST Release -------------------
|
||||
# def DeleteGSTRelease(self, gst_release_id):
|
||||
# gst = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||
# gst.DeleteItem(
|
||||
# itemID=gst_release_id,
|
||||
# request=None,
|
||||
# storedprocDelete="DeleteGSTReleaseById"
|
||||
# )
|
||||
|
||||
# self.isSuccess = gst.isSuccess
|
||||
# self.resultMessage = str(gst.resultMessage)
|
||||
|
||||
# model/gst_release.py
|
||||
from flask import request, jsonify
|
||||
from model.ItemCRUD import ItemCRUD
|
||||
from model.Utilities import ItemCRUDType
|
||||
|
||||
|
||||
class GSTRelease:
|
||||
|
||||
def __init__(self):
|
||||
@@ -125,12 +24,19 @@ class GSTRelease:
|
||||
"Contractor_ID": int(request.form.get("Contractor_ID", 0) or 0)
|
||||
}
|
||||
|
||||
# Add GST Release
|
||||
gst.AddItem(
|
||||
request=request,
|
||||
data=data,
|
||||
storedprocfetch="CheckGSTReleaseExists",
|
||||
storedprocadd="AddGSTReleaseFromExcel"
|
||||
)
|
||||
|
||||
# Check if addition was successful
|
||||
if gst.isSuccess:
|
||||
print(f"GST Release Added: {data}")
|
||||
else:
|
||||
print(f"Failed to add GST Release: {gst.resultMessage}")
|
||||
|
||||
self.isSuccess = gst.isSuccess
|
||||
self.resultMessage = str(gst.resultMessage)
|
||||
@@ -198,7 +104,6 @@ class GSTRelease:
|
||||
def GetAllGSTReleases(self):
|
||||
try:
|
||||
gst = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||
|
||||
rows = gst.GetAllData(None, "GetAllGSTReleases")
|
||||
|
||||
data = []
|
||||
@@ -224,7 +129,6 @@ class GSTRelease:
|
||||
def GetGSTReleaseByID(self, gst_release_id):
|
||||
try:
|
||||
gst = ItemCRUD(itemType=ItemCRUDType.GSTRelease)
|
||||
|
||||
row = gst.GetDataByID(gst_release_id, "GetGSTReleaseById")
|
||||
|
||||
if row:
|
||||
|
||||
Reference in New Issue
Block a user