mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-08-16 21:24:09 +00:00
156 lines
5.5 KiB
Python
156 lines
5.5 KiB
Python
import json
|
|
import os
|
|
|
|
from initOnboarding import initialize_onboarding
|
|
from validatedUploadedFiles import run_file_validation
|
|
from onboardFundsDummy import onboardFunds
|
|
from onboardPartners import process_all_partners
|
|
from onboardBankTransactions import process_bank_transactions
|
|
from onboardFinancials import process_financials
|
|
from onboardJournals import process_journals
|
|
from onboardPerformance import process_fund_performance
|
|
from backendAPIs import get_all_role
|
|
from file_processor import lpa_amendment , side_letter_doc
|
|
from backendAPIs import load_partner_data
|
|
|
|
|
|
def lambda_handler(event):
|
|
|
|
# Extract the 'id'
|
|
onboarding_id = json.loads(event)['id']
|
|
|
|
print(f"Received onboarding id from Q: {onboarding_id}")
|
|
if not onboarding_id:
|
|
return {
|
|
'statusCode': 400,
|
|
'body': json.dumps('Missing onboarding_id')
|
|
}
|
|
|
|
os.environ["ONBOARDING_ID"] = onboarding_id
|
|
print(f"Onboarding id set to {onboarding_id} in the environment")
|
|
print(f"Received onboarding id from Q: {onboarding_id}")
|
|
if not onboarding_id:
|
|
return {
|
|
'statusCode': 400,
|
|
'body': json.dumps('Missing onboarding_id')
|
|
}
|
|
|
|
os.environ["ONBOARDING_ID"] = onboarding_id
|
|
print(f"Onboarding id set to {onboarding_id} in the environment")
|
|
|
|
print("0. Initialising...")
|
|
response = initialize_onboarding()
|
|
if response is False:
|
|
print("Initialization failed, terminating onboarding...")
|
|
return False
|
|
|
|
print("1. Validating input files...")
|
|
found_files ,pdf_files = run_file_validation()
|
|
if not isinstance(found_files, dict):
|
|
print(found_files)
|
|
error_message = found_files
|
|
return {
|
|
'statusCode': 400,
|
|
'body': json.dumps(error_message)
|
|
}
|
|
|
|
print("2. Running fund onboarding...")
|
|
onboardFunds(found_files["partner"])
|
|
|
|
print("3. Running partner onboarding...")
|
|
process_all_partners(found_files["partner"])
|
|
|
|
print("4. Running financial onboarding...")
|
|
process_financials(found_files["financials"]) # use Roll Forward ->column B->Security type and from rollforward need to make.
|
|
|
|
print("5. Running bank transactions onboarding...")
|
|
process_bank_transactions(found_files["bankTransactions"])
|
|
|
|
print("6. Running journal onboarding...")
|
|
process_journals(found_files["journals"]) # issue with missing account types
|
|
|
|
print("7. Running fund performance onboarding...")
|
|
process_fund_performance(found_files["fund_performance"]) #
|
|
|
|
# start processing PDF files related to GP based on the type of the document
|
|
#
|
|
# print("Start processing the PDF files related to GP")
|
|
#
|
|
# # give list of the files to classifier function to classify them
|
|
#
|
|
# role_data = get_all_role()
|
|
#
|
|
# print("GET ALL role data")
|
|
#
|
|
# print(role_data)
|
|
#
|
|
# classified_pdf_files = pdf_classifier(pdf_files)
|
|
#
|
|
# print("Processing the LPA and its Amendments")
|
|
#
|
|
# side_letter_files = set()
|
|
#
|
|
# for file_category , file_names in classified_pdf_files.items():
|
|
#
|
|
# for file_name in file_names:
|
|
#
|
|
# output_json = None
|
|
#
|
|
# pdf_string = get_pdf_details(file_name)
|
|
#
|
|
# print(f"Started processing the file : {file_name}")
|
|
#
|
|
# for role_id in role_data:
|
|
#
|
|
# print(f"Start processing the file :{file_name} for the role id :{role_id['_id']}")
|
|
#
|
|
#
|
|
# if file_category.strip() == "LPA(Limited Partner Agreement)":
|
|
#
|
|
# if output_json is None:
|
|
# output_json = lpa_amendment(pdf_string)
|
|
#
|
|
# response = load_partner_data("LPA", os.environ["ENTITY_ID"], role_id['_id'], output_json)
|
|
#
|
|
# if not response:
|
|
# print(
|
|
# f"Issue encouneted in file processing of {file_name} for the role id : {role_id['_id']}")
|
|
# else:
|
|
# print(f"Successfully processed : {file_name} for the role id : {role_id['_id']}")
|
|
#
|
|
# if file_category.strip() == "LPA-Amendment(Limited Partner Agreement-Amendment)":
|
|
# #
|
|
# if output_json is None:
|
|
# output_json = lpa_amendment(pdf_string)
|
|
#
|
|
# response = load_partner_data("Amendment", os.environ["ENTITY_ID"], role_id['_id'], output_json)
|
|
#
|
|
# if not response:
|
|
# print(
|
|
# f"Issue encouneted in file processing of {file_name} for the role id : {role_id['_id']}")
|
|
# else:
|
|
# print(f"Successfully processed : {file_name} for the role id : {role_id['_id']}")
|
|
#
|
|
# if file_category.strip() == "Side Letter":
|
|
# side_letter_files = file_names
|
|
#
|
|
# ### lets start the file processing for side letter because its different for each LP and each role id need to seperated
|
|
#
|
|
# for side_letter_file in side_letter_files:
|
|
#
|
|
# print(side_letter_file)
|
|
#
|
|
# pdf_string = get_pdf_details(side_letter_file)
|
|
#
|
|
# status , role_id = side_letter_doc("Side Letter",os.environ["ENTITY_ID"],pdf_string,role_data)
|
|
#
|
|
# if not status:
|
|
# print(f"Issue encouneted in file processing of side letter {side_letter_file} and related role id : {role_id}")
|
|
#
|
|
# else:
|
|
# print(f"Side letter file : {side_letter_file} was processed successfully and related role id : {role_id}")
|
|
|
|
|
|
return
|
|
|