Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
henryoforeh-dev committed Oct 21, 2024
1 parent ad29b1a commit 8682677
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
2 changes: 1 addition & 1 deletion services/common/src/components/projectSummary/Agent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export const Agent: FC = () => {
name="agent.address.suite_no"
label="Unit #"
component={RenderField}
validate={[required, maxLength(5)]}
validate={[maxLength(5)]}
disabled={isFieldDisabled(systemFlag, formValues?.status_code)}
/>
</Col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,23 @@ def put(self, project_guid, project_summary_guid):
trigger_notification(message, ActivityType.major_mine_desc_submitted, project.mine, 'ProjectSummary',
project_summary.project_summary_guid, extra_data)

if project_summary.status_code == 'OHD' or project_summary.status_code == 'WDN' or project_summary.status_code == 'COM':
if project_summary.status_code == 'OHD':
project_summary.send_project_summary_email(mine)
message = f'The status of the project description {project.project_title} has been updated for {project.mine_name}'
message = f'The project description {project.project_title} for {project.mine_name} has been updated to On Hold'
extra_data = {'project': {'project_guid': str(project.project_guid)}}
trigger_notification(message, ActivityType.major_mine_desc_submitted, project.mine, 'ProjectSummary',
project_summary.project_summary_guid, extra_data)

if project_summary.status_code == 'WDN':
project_summary.send_project_summary_email(mine)
message = f'The project description {project.project_title} for {project.mine_name} has been withdrawn'
extra_data = {'project': {'project_guid': str(project.project_guid)}}
trigger_notification(message, ActivityType.major_mine_desc_submitted, project.mine, 'ProjectSummary',
project_summary.project_summary_guid, extra_data)

if project_summary.status_code == 'COM':
project_summary.send_project_summary_email(mine)
message = f'The status of the project description {project.project_title} for {project.mine_name} has been completed'
extra_data = {'project': {'project_guid': str(project.project_guid)}}
trigger_notification(message, ActivityType.major_mine_desc_submitted, project.mine, 'ProjectSummary',
project_summary.project_summary_guid, extra_data)
Expand Down
42 changes: 40 additions & 2 deletions services/core-api/app/api/services/ams_api_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ def __set_contact_details(cls, contact):
}
return contact_details

@classmethod
def __set_additional_contact_details(cls, contact):
contact_details = {
'lastname': contact.get('last_name', ''),
'firstname': contact.get('first_name', ''),
'title': contact.get('job_title', ''),
'phonenumber': cls.__format_phone_number(contact.get('phone_number')),
'email': contact.get('email', ''),
'mailingaddress': cls.__create_full_address(
contact['address'].get('address_line_1', ''),
contact['address'].get('city', ''),
contact['address'].get('sub_division_code', ''),
contact['address'].get('post_code', ''),
contact['address'].get('suite_no', '')
) if contact.get('address') else ''
}
return contact_details

@classmethod
def __set_applicant_details(cls, applicant, company_alias, incorporation_number):
applicant_details = {
Expand Down Expand Up @@ -257,12 +275,12 @@ def create_new_ams_authorization(cls,
'name': nearest_municipality_name
},
'applicant': cls.__set_applicant_details(applicant, company_alias, incorporation_number),
'contact': cls.__set_contact_details(contacts[0]),
'agent': cls.__set_agent_details(agent),
'purposeofapplication': authorization.get('authorization_description', ''),
'preappexemptionrequest': cls.__boolean_to_yes_no(authorization.get('exemption_requested')),
'preappexemptionrequestreason': authorization.get('exemption_reason', ''),
'iscontaminatedsite': cls.__boolean_to_yes_no(authorization.get('is_contaminated')),
'contact': cls.__set_contact_details(contacts[0]),
'facilitytype': facility_type,
'facilitydescription': facility_desc,
'latitude': str(facility_latitude),
Expand Down Expand Up @@ -302,6 +320,12 @@ def create_new_ams_authorization(cls,
'mailingaddress': cls.__format_mailing_address(payment_contact)
}
}
# Dynamically add additional contacts as contact1, contact2, etc.
if(len(contacts)) > 1:
for i, contact in enumerate(contacts[1:], start=1):
contact_key = f'contact{i + 1}'
ams_authorization_data[contact_key] = cls.__set_additional_contact_details(contact)

payload = json.dumps(ams_authorization_data)
response = requests.post(Config.AMS_URL, data=payload, headers=headers)
ams_result = response.json()
Expand Down Expand Up @@ -450,8 +474,22 @@ def create_amendment_ams_authorization(cls,
'newlandowneremail': legal_land_owner_email_address,
'newistheapplicantthelandowner': cls.__boolean_to_yes_no(is_legal_land_owner),
'newlandfedorprov': cls.__boolean_to_yes_no(is_crown_land_federal_or_provincial),
'documents': cls.__get_ams_document_url(project_guid)
'documents': cls.__get_ams_document_url(project_guid),
'contactforpayment': {
'firstname': payment_contact.get('first_name', ''),
'lastname': payment_contact.get('party_name', ''),
'phonenumber': payment_contact.get('phone_no', ''),
'email': payment_contact.get('email', ''),
'mailingaddress': cls.__format_mailing_address(payment_contact)
}
}

# Dynamically add additional contacts as contact1, contact2, etc.
if (len(contacts)) > 1:
for i, contact in enumerate(contacts[1:], start=1):
contact_key = f'contact{i + 1}'
ams_authorization_data[contact_key] = cls.__set_additional_contact_details(contact)

payload = json.dumps(ams_authorization_data)
response = requests.post(Config.AMS_URL, data=payload, headers=headers)
ams_result = response.json()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ export const ProjectSummaryPage = () => {
let message = newActiveTab
? "Successfully updated the project description."
: "Successfully submitted a project description to the Province of British Columbia.";

let status_code = projectSummary.status_code;
let is_historic = projectSummary.is_historic;

if (status_code === "CHR") {
status_code = "UNR";
} else if (!status_code || !isEditMode) {
} else if ((!status_code || !isEditMode) && status_code !== "UNR") {
status_code = "DFT";
} else if (!newActiveTab) {
} else if (!newActiveTab && status_code !== "UNR") {
status_code = "SUB";
is_historic = false;
if (amsFeatureEnabled) {
Expand Down

0 comments on commit 8682677

Please sign in to comment.