This commit is contained in:
2026-03-31 16:24:58 +05:30
parent 4e5887b160
commit cd16c284ce
10 changed files with 529 additions and 75 deletions

View File

@@ -24,39 +24,39 @@ class ContractorInfo:
if connection.is_connected():
connection.close()
def fetchalldata(self):
"""Fetch hold types and invoices for contractor."""
data = {}
try:
connection = config.get_db_connection()
with connection.cursor(dictionary=True, buffered=True) as cursor:
# Fetch Hold Types
cursor.callproc('GetHoldTypesByContractor', [self.ID])
hold_types = []
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}
data['hold_types'] = hold_type_map
# def fetchalldata(self):
# """Fetch hold types and invoices for contractor."""
# data = {}
# try:
# connection = config.get_db_connection()
# with connection.cursor(dictionary=True, buffered=True) as cursor:
# # Fetch Hold Types
# cursor.callproc('GetHoldAmountsAndHoldTypeByCtr', [self.ID])
# hold_types = []
# 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}
# data['hold_types'] = hold_type_map
# Fetch Invoices
cursor.callproc('GetInvoicesByContractor', [self.ID])
invoices = []
for result in cursor.stored_results():
invoices = result.fetchall()
# # Fetch Invoices
# cursor.callproc('GetInvoicesByContractor', [self.ID])
# invoices = []
# for result in cursor.stored_results():
# invoices = result.fetchall()
# Remove duplicate invoices
seen_ids = set()
unique_invoices = []
for inv in invoices:
if inv['Invoice_Id'] not in seen_ids:
seen_ids.add(inv['Invoice_Id'])
unique_invoices.append(inv)
data['invoices'] = unique_invoices
# # Remove duplicate invoices
# seen_ids = set()
# unique_invoices = []
# for inv in invoices:
# if inv['Invoice_Id'] not in seen_ids:
# seen_ids.add(inv['Invoice_Id'])
# unique_invoices.append(inv)
# data['invoices'] = unique_invoices
except Error as e:
print(f"Error fetching contractor data: {e}")
finally:
if connection.is_connected():
connection.close()
# except Error as e:
# print(f"Error fetching contractor data: {e}")
# finally:
# if connection.is_connected():
# connection.close()
return data
# return data

View File

@@ -121,7 +121,7 @@ class PmcReport:
# ================= DATA FETCH =================
contractor_info = ReportHelper.execute_sp(
cursor, 'GetContractorDetailsByPMC', [pmc_no]
cursor, 'GetContractorInfoByPmcNo', [pmc_no]
)
contractor_info = contractor_info[0] if contractor_info else None

View File

@@ -103,7 +103,7 @@ class ReportHelper:
# Hold Release
hold_release = ReportHelper.execute_sp(cursor, 'GetHoldRelease', [contractor_id])
# Credit Note
credit_note = ReportHelper.execute_sp(cursor, 'GetCreditNote', [contractor_id])
credit_note = ReportHelper.execute_sp(cursor, 'GetCreditNotesByContractor', [contractor_id])
# Payments
payments = ReportHelper.execute_sp(cursor, 'GetPayments', [contractor_id])
@@ -356,7 +356,7 @@ class ReportHelper:
for cn in credit_note_raw:
# key = (
# str(cn['PMC_No']).strip(),
# str(cn['Invoice_No']).replace(" ", "") if cn['Invoice_No'] else ""
# str(cn['Invoice_No']).replace(" ", "") if cn['Invoice_No'] else ""
# )
key = (
str(cn['PMC_No']).strip()

View File

@@ -144,7 +144,7 @@ class Paymentmodel:
try:
cursor = connection.cursor(dictionary=True)
# Fetch PMC & Invoice before deleting
cursor.callproc('GetPaymentPMCInvoiceById', [payment_id])
cursor.callproc('GetPaymentById', [payment_id])
record = {}
for result in cursor.stored_results():
record = result.fetchone() or {}