final payment reconciliation
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
from mysql.connector import Error
|
||||
import config
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
class ContractorInfo:
|
||||
@@ -24,39 +23,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('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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user