Skip to content

Commit

Permalink
update and fix ams related fields that are submitted
Browse files Browse the repository at this point in the history
  • Loading branch information
asinn134 committed Jan 3, 2025
1 parent 72979bd commit 21592b9
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 81 deletions.
13 changes: 13 additions & 0 deletions services/common/src/components/projectSummary/PaymentContact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export const PaymentContact = ({ isDisabled }) => {
}
}, [payment_contact?.party_type_code, payment_contact?.address]);

const paymentContactAddress = payment_contact?.address || [];
const isMailingInternational = paymentContactAddress[0]?.address_type_code === "INT";

return (
<div style={{ paddingTop: 12 }}>
<Title level={4}>Contact for Payment</Title>
Expand Down Expand Up @@ -105,11 +108,14 @@ export const PaymentContact = ({ isDisabled }) => {
disabled={isDisabled}
name="payment_contact.address[0].address_line_1"
label="Street"
required
validate={[required, maxLength(100)]}
component={RenderField}
/>
</Col>
<Col md={5} sm={24}>
<Field
validate={[maxLength(5)]}
disabled={isDisabled}
name="payment_contact.address[0].suite_no"
label="Unit #"
Expand All @@ -123,6 +129,8 @@ export const PaymentContact = ({ isDisabled }) => {
disabled={isDisabled}
name="payment_contact.address[0].address_type_code"
label="Country"
required
validate={[required]}
data={CONTACTS_COUNTRY_OPTIONS}
component={RenderSelect}
/>
Expand All @@ -132,6 +140,8 @@ export const PaymentContact = ({ isDisabled }) => {
disabled={isDisabled}
name="payment_contact.address[0].sub_division_code"
label="Province"
required={!isMailingInternational}
validate={!isMailingInternational ? [required] : []}
data={provinceOptions.filter(
(p) => p.subType === payment_contact?.address?.[0]?.address_type_code
)}
Expand All @@ -146,6 +156,8 @@ export const PaymentContact = ({ isDisabled }) => {
disabled={isDisabled}
name="payment_contact.address[0].city"
label="City"
required
validate={[required]}
component={RenderField}
/>
</Col>
Expand All @@ -155,6 +167,7 @@ export const PaymentContact = ({ isDisabled }) => {
name="payment_contact.address[0].post_code"
label="Postal Code"
component={RenderField}
required
validate={[
postalCodeWithCountry(payment_contact?.address?.[0]?.address_type_code),
maxLength(10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2534,18 +2534,14 @@ exports[`Applicant Component should render the component with expected fields 1`
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_line_1"
title=""
>
<div>
<div
style="width: 100%;"
>
Street
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand Down Expand Up @@ -2667,18 +2663,14 @@ exports[`Applicant Component should render the component with expected fields 1`
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_type_code"
title=""
>
<div>
<div
style="width: 100%;"
>
Country
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand All @@ -2692,6 +2684,7 @@ exports[`Applicant Component should render the component with expected fields 1`
class="ant-form-item-control-input-content"
>
<div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow ant-select-show-search"
data-cy="payment_contact.address[0].address_type_code"
>
Expand All @@ -2707,6 +2700,7 @@ exports[`Applicant Component should render the component with expected fields 1`
aria-controls="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_type_code_list"
aria-haspopup="listbox"
aria-owns="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_type_code_list"
aria-required="true"
autocomplete="off"
class="ant-select-selection-search-input"
id="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_type_code"
Expand Down Expand Up @@ -2781,18 +2775,14 @@ exports[`Applicant Component should render the component with expected fields 1`
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].sub_division_code"
title=""
>
<div>
<div
style="width: 100%;"
>
Province
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand All @@ -2806,6 +2796,7 @@ exports[`Applicant Component should render the component with expected fields 1`
class="ant-form-item-control-input-content"
>
<div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow ant-select-show-search"
data-cy="payment_contact.address[0].sub_division_code"
>
Expand All @@ -2821,6 +2812,7 @@ exports[`Applicant Component should render the component with expected fields 1`
aria-controls="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].sub_division_code_list"
aria-haspopup="listbox"
aria-owns="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].sub_division_code_list"
aria-required="true"
autocomplete="off"
class="ant-select-selection-search-input"
id="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].sub_division_code"
Expand Down Expand Up @@ -2900,18 +2892,14 @@ exports[`Applicant Component should render the component with expected fields 1`
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].city"
title=""
>
<div>
<div
style="width: 100%;"
>
City
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand Down Expand Up @@ -2964,18 +2952,14 @@ exports[`Applicant Component should render the component with expected fields 1`
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].post_code"
title=""
>
<div>
<div
style="width: 100%;"
>
Postal Code
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,14 @@ exports[`PaymentContact Component should render the component with expected fiel
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_line_1"
title=""
>
<div>
<div
style="width: 100%;"
>
Street
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand Down Expand Up @@ -489,18 +485,14 @@ exports[`PaymentContact Component should render the component with expected fiel
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_type_code"
title=""
>
<div>
<div
style="width: 100%;"
>
Country
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand All @@ -514,6 +506,7 @@ exports[`PaymentContact Component should render the component with expected fiel
class="ant-form-item-control-input-content"
>
<div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow ant-select-show-search"
data-cy="payment_contact.address[0].address_type_code"
>
Expand All @@ -529,6 +522,7 @@ exports[`PaymentContact Component should render the component with expected fiel
aria-controls="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_type_code_list"
aria-haspopup="listbox"
aria-owns="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_type_code_list"
aria-required="true"
autocomplete="off"
class="ant-select-selection-search-input"
id="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].address_type_code"
Expand Down Expand Up @@ -603,18 +597,14 @@ exports[`PaymentContact Component should render the component with expected fiel
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].sub_division_code"
title=""
>
<div>
<div
style="width: 100%;"
>
Province
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand All @@ -628,6 +618,7 @@ exports[`PaymentContact Component should render the component with expected fiel
class="ant-form-item-control-input-content"
>
<div
aria-required="true"
class="ant-select ant-select-in-form-item ant-select-single ant-select-allow-clear ant-select-show-arrow ant-select-show-search"
data-cy="payment_contact.address[0].sub_division_code"
>
Expand All @@ -643,6 +634,7 @@ exports[`PaymentContact Component should render the component with expected fiel
aria-controls="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].sub_division_code_list"
aria-haspopup="listbox"
aria-owns="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].sub_division_code_list"
aria-required="true"
autocomplete="off"
class="ant-select-selection-search-input"
id="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].sub_division_code"
Expand Down Expand Up @@ -722,18 +714,14 @@ exports[`PaymentContact Component should render the component with expected fiel
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].city"
title=""
>
<div>
<div
style="width: 100%;"
>
City
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand Down Expand Up @@ -786,18 +774,14 @@ exports[`PaymentContact Component should render the component with expected fiel
class="ant-col ant-form-item-label"
>
<label
class=""
class="ant-form-item-required"
for="ADD_EDIT_PROJECT_SUMMARY_payment_contact.address[0].post_code"
title=""
>
<div>
<div
style="width: 100%;"
>
Postal Code
<span
class="form-item-optional"
>
 (optional)
</span>
</div>
</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -876,10 +876,18 @@ def validate_project_summary(cls, data, is_historic):
if do_full_validation and applicant == None:
errors_found['applicant_info'].append('Applicant Information not provided')
elif applicant != None:
payment_contact = data.get('payment_contact', None)
applicant_validation = ProjectSummary.validate_project_party(applicant, 'applicant')
if applicant_validation != True:
errors_found['applicant_info'].append(applicant_validation)

if payment_contact['address'] == None:
errors_found['applicant_info'].append('Payment contact address info not provided')
else:
payment_contact_validation = ProjectSummary.validate_project_party(payment_contact, 'applicant')
if payment_contact_validation != True:
errors_found['applicant_info'].append(payment_contact_validation)

# Validate Agent
if do_full_validation and is_agent == None:
errors_found['agent'].append("Is applicant an agent not provided")
Expand Down Expand Up @@ -1088,6 +1096,17 @@ def update(self,
self.applicant_party_guid = applicant_party.party_guid

if payment_contact is not None:
if self.payment_contact != None and len(payment_contact['address']) == 1 and len(self.payment_contact.address) == 0:
temp_address = Address.create(
suite_no=None,
address_line_1=None,
city=None,
sub_division_code=None,
post_code=None,
address_type_code=None,
)

(self.payment_contact.address).append(temp_address)
payment_contact_party = self.create_or_update_party(payment_contact, 'PAY', self.payment_contact)
payment_contact_party.save()
self.payment_contact_party_guid = payment_contact_party.party_guid
Expand Down
Loading

0 comments on commit 21592b9

Please sign in to comment.