@dyedurham/search-and-file-widget 1.6.16 → 1.6.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dnd-filing-shell.js +662 -468
  2. package/package.json +1 -1
@@ -56029,6 +56029,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
56029
56029
  IRFormControls2["OfficerPosition"] = "OfficerPosition";
56030
56030
  IRFormControls2["OfficerPositionName"] = "OfficerPositionName";
56031
56031
  IRFormControls2["OfficerPositionSpecified"] = "OfficerPositionSpecified";
56032
+ IRFormControls2["Contact"] = "contact";
56032
56033
  IRFormControls2["CountryTelephoneCode"] = "CountryTelephoneCode";
56033
56034
  IRFormControls2["AreaCode"] = "AreaCode";
56034
56035
  IRFormControls2["TelephoneNumber"] = "TelephoneNumber";
@@ -56039,6 +56040,9 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
56039
56040
  IRFormControls2["Fax"] = "Fax";
56040
56041
  IRFormControls2["AffiliationAddressType"] = "affiliationAddressType";
56041
56042
  IRFormControls2["AffiliationType"] = "AffiliationType";
56043
+ IRFormControls2["CurrentName"] = "currentName";
56044
+ IRFormControls2["IsThisChangeToAnExistingEntity"] = "isThisChangeToAnExistingEntity";
56045
+ IRFormControls2["IsThisChangeToAnExistingEntityVisible"] = "isThisChangeToAnExistingEntityVisible";
56042
56046
  })(IRFormControls || (IRFormControls = {}));
56043
56047
  (function(FormationFormGroups2) {
56044
56048
  FormationFormGroups2["ReferenceNumbers"] = "Reference Numbers";
@@ -56056,6 +56060,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
56056
56060
  InitialReturnFillingFormGroups2["Directors"] = "Directors";
56057
56061
  InitialReturnFillingFormGroups2["Officers"] = "Officers";
56058
56062
  InitialReturnFillingFormGroups2["CertifiedBy"] = "Certified By";
56063
+ InitialReturnFillingFormGroups2["Contact"] = "Contact";
56059
56064
  })(InitialReturnFillingFormGroups || (InitialReturnFillingFormGroups = {}));
56060
56065
  }
56061
56066
  });
@@ -56957,14 +56962,16 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
56957
56962
  } else if (country === "US") {
56958
56963
  provinceState = USStateToCode(address.province_state) || address.province_state;
56959
56964
  }
56965
+ const isCanadianAddress = country === "CA";
56966
+ const mappedStreetName = isCanadianAddress ? deltaData?.streetName ?? StreetName : streetOnly ?? "";
56960
56967
  return __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, careOf && { CareOf: careOf }), {
56961
56968
  AddressStandardLot: "Standard",
56962
- StreetNumber: streetNumber,
56963
- StreetName: deltaData?.streetName ?? StreetName,
56964
- CanadianStreetType: deltaData?.streetType ?? (StreetType2 ? mapStreetType(StreetType2) : void 0),
56965
- CanadianStreetDirectionType: deltaData?.streetDirection ?? (StreetDirection2 ? mapStreetDirection(StreetDirection2) : null)
56969
+ StreetNumber: deltaData?.streetNumber ?? streetNumber,
56970
+ StreetName: mappedStreetName,
56971
+ CanadianStreetType: isCanadianAddress ? deltaData?.streetType ?? (StreetType2 ? mapStreetType(StreetType2) : void 0) : null,
56972
+ CanadianStreetDirectionType: isCanadianAddress ? deltaData?.streetDirection ?? (StreetDirection2 ? mapStreetDirection(StreetDirection2) : null) : null
56966
56973
  }), suite && { UnitNumber: suite }), {
56967
- CanadianUnitType: deltaData?.unitType ?? null,
56974
+ CanadianUnitType: isCanadianAddress ? deltaData?.unitType ?? null : null,
56968
56975
  UnitNumber: deltaData?.unitNumber ?? null,
56969
56976
  City: address.city,
56970
56977
  ProvinceState: provinceState,
@@ -56998,17 +57005,21 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
56998
57005
  function transformIncorporators(incorporators, deltaData) {
56999
57006
  return incorporators?.map((incorporator) => {
57000
57007
  const isEntity = incorporator.type?.toLowerCase() === "entity";
57008
+ const id = incorporator.profileID?.toString();
57009
+ const incorporatorDelta = id ? deltaData.incorporators?.[id] : void 0;
57001
57010
  if (isEntity) {
57002
- return {
57011
+ return __spreadProps(__spreadValues({
57003
57012
  FirstName: incorporator.signatory_first_name,
57004
57013
  LastName: incorporator.signatory_last_name,
57005
- IncorporatorType: ECoreIncorporatorType.BodyCorporate,
57014
+ IncorporatorType: ECoreIncorporatorType.NonRegCorporate,
57006
57015
  Title: incorporator.signatory_title,
57016
+ CompanyName: incorporator.incorporator_name
57017
+ }, incorporator.incorporator_reg_number && {
57007
57018
  CompanyNumber: incorporator.incorporator_reg_number
57008
- };
57019
+ }), {
57020
+ Address: transformAddress(incorporator, incorporatorDelta?.address)
57021
+ });
57009
57022
  } else {
57010
- const id = incorporator.profileID?.toString();
57011
- const incorporatorDelta = id ? deltaData.incorporators?.[id] : void 0;
57012
57023
  return __spreadProps(__spreadValues({
57013
57024
  FirstName: incorporator.firstName,
57014
57025
  LastName: incorporator.lastName
@@ -57064,8 +57075,10 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
57064
57075
  const legalEnding = entityDetails?.legalIdentifier ?? "";
57065
57076
  const incorporatorIds = new Set(task._ext._incorporators?.map((inc) => inc.profileID?.toString()).filter(Boolean) ?? []);
57066
57077
  const registeredOfficeAddress = findRegisteredOfficeAddress(task);
57078
+ const directorIds = new Set(task.entity.affiliations.filter((aff) => aff.kind === "PrincipalAffiliationV3" && aff.role.role_name === DirectorRole.DIRECTOR).map((aff) => aff.participant._id).filter(Boolean));
57079
+ const incorporatorsNotDirectors = (task._ext._incorporators ?? []).filter((inc) => !directorIds.has(inc.profileID?.toString() ?? ""));
57067
57080
  const directors = transformDirectors(task.entity.affiliations, incorporatorIds, deltaData);
57068
- const incorporators = transformIncorporators(task._ext._incorporators ?? [], deltaData);
57081
+ const incorporators = transformIncorporators(incorporatorsNotDirectors, deltaData);
57069
57082
  const officialBusinessEmail = registeredOfficeAddress?.communications?.find((c) => c.type === "Business Email")?.value;
57070
57083
  const naicsData = task.entity._profile?.naics;
57071
57084
  const requestedDate = task._ext._future_filing_date ? new Date(task._ext._future_filing_date).toISOString().split("T")[0] : (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
@@ -57102,6 +57115,15 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
57102
57115
  });
57103
57116
  return eCorePayload;
57104
57117
  }
57118
+ function getPhoneData(phone) {
57119
+ const resultNumber = phone.length === 11 ? phone.slice(1) : phone;
57120
+ return {
57121
+ countryCode: "1",
57122
+ areaCode: resultNumber.slice(0, 3),
57123
+ number: resultNumber.slice(3),
57124
+ fullNumber: phone
57125
+ };
57126
+ }
57105
57127
  var ECoreIncorporationType, ECoreDirectorNumberType, ECoreEffectiveType, ECoreDirectorResidencyType, ECoreIncorporatorType, ECoreStreetType, ECoreCanadianStreetDirectionType, ECoreCanadianUnitType;
57106
57128
  var init_transform_utils = __esm({
57107
57129
  "src/app/utils/transform.utils.ts"() {
@@ -57895,6 +57917,9 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
57895
57917
  }
57896
57918
  return d.length >= 10 ? d.slice(0, 10) : d;
57897
57919
  }
57920
+ if (isNaN(d.getTime())) {
57921
+ return "Not specified";
57922
+ }
57898
57923
  return d.toISOString().slice(0, 10);
57899
57924
  }
57900
57925
  function isPrincipalAffiliation2(affiliation) {
@@ -57970,7 +57995,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
57970
57995
  return task.entity._compliance.home_jurisdiction === "Ontario";
57971
57996
  }
57972
57997
  function buildValidateError(httpStatus, r) {
57973
- const msgs = (r.Errors ?? []).map((e) => e.Message || e["message"] || e.Code || JSON.stringify(e)).filter(Boolean);
57998
+ const msgs = (r.Errors ?? []).map((e) => e["ErrorMessage"] || e.Message || e["message"] || e.Code || JSON.stringify(e)).filter(Boolean);
57974
57999
  const status = r.Status ? String(r.Status) : "ValidationFailed";
57975
58000
  return new Error(msgs.length ? `eCore validation failed (HTTP ${httpStatus}, ${status}): ${msgs.join(" | ")}` : `eCore validation failed (HTTP ${httpStatus}, ${status}).`);
57976
58001
  }
@@ -58025,7 +58050,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
58025
58050
  }
58026
58051
  function getCurrentAddressPreview(data) {
58027
58052
  const unitType = data.unitType;
58028
- const unitTypeValue = UNIT_TYPE_OPTIONS.find((option) => option.value === unitType)?.label;
58053
+ const unitTypeValue = UNIT_TYPE_OPTIONS.find((option) => option.value?.toString() === unitType?.toString())?.label;
58029
58054
  const unitNumber = data.unitNumber;
58030
58055
  const careOf = data.careOf;
58031
58056
  const streetType = data.streetType;
@@ -58039,7 +58064,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
58039
58064
  }
58040
58065
  function getAddressPreview(data) {
58041
58066
  const unitType = data[FormationFormControls.UnitType];
58042
- const unitTypeValue = UNIT_TYPE_OPTIONS.find((option) => option.value === unitType)?.label;
58067
+ const unitTypeValue = UNIT_TYPE_OPTIONS.find((option) => option.value?.toString() === unitType?.toString())?.label;
58043
58068
  const unitNumber = data[FormationFormControls.UnitNumber];
58044
58069
  const careOf = data[FormationFormControls.CareOf];
58045
58070
  const streetType = data[FormationFormControls.StreetType];
@@ -58097,6 +58122,21 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
58097
58122
  return "";
58098
58123
  return str.toLowerCase().replace(/(?:^|\s|[-/])\S/g, (match) => match.toUpperCase());
58099
58124
  }
58125
+ function generateAffiliationKey(affiliation) {
58126
+ const person = affiliation.participant;
58127
+ const firstName = person._profile.firstName || "";
58128
+ const lastName = person._profile.lastName || "";
58129
+ const middleName = person._profile.middleName || "";
58130
+ const role = affiliation.role.static_title || "";
58131
+ return [firstName.toLowerCase(), middleName.toLowerCase(), lastName.toLowerCase(), role.toLowerCase()].filter(Boolean).join(" ");
58132
+ }
58133
+ function generateAffiliationFullName(affiliation) {
58134
+ const person = affiliation.participant;
58135
+ const firstName = person._profile.firstName || "";
58136
+ const lastName = person._profile.lastName || "";
58137
+ const middleName = person._profile.middleName || "";
58138
+ return [firstName, middleName, lastName].filter(Boolean).join(" ");
58139
+ }
58100
58140
  var init_common_utils = __esm({
58101
58141
  "src/app/utils/common.utils.ts"() {
58102
58142
  init_app_constants();
@@ -59111,16 +59151,34 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
59111
59151
  init_app_enums();
59112
59152
  init_ontario_formation_form_constants();
59113
59153
  OntarioUpdateMaintainFormHelper = class _OntarioUpdateMaintainFormHelper {
59114
- static generateInitialForm(task) {
59154
+ static normalizePersonKey(value) {
59155
+ return (value ?? "").toLowerCase().replace(/\s+/g, " ").trim();
59156
+ }
59157
+ static getCurrentPersonData(comparisonData, affiliation) {
59158
+ const lookupName = _OntarioUpdateMaintainFormHelper.normalizePersonKey(generateAffiliationFullName(affiliation));
59159
+ if (!lookupName || !comparisonData?.persons?.size) {
59160
+ return void 0;
59161
+ }
59162
+ for (const [personKey, personData] of comparisonData.persons.entries()) {
59163
+ const normalizedKey = _OntarioUpdateMaintainFormHelper.normalizePersonKey(personKey);
59164
+ if (normalizedKey === lookupName || normalizedKey.startsWith(`${lookupName} -`)) {
59165
+ return personData;
59166
+ }
59167
+ }
59168
+ return void 0;
59169
+ }
59170
+ static generateInitialForm(task, comparisonData) {
59115
59171
  const config2 = {};
59116
- const { _ext, incomingAffiliations, outgoingAffiliations, editedAffiliations = [] } = task;
59172
+ const { _ext, incomingAffiliations, outgoingAffiliations } = task;
59117
59173
  const deltaData = task.deltaData;
59118
- const addedOfficers = incomingAffiliations?.filter((aff) => isPrincipalAffiliation(aff) && aff.role.role_name === "Officer") || [];
59174
+ const addedOfficers = incomingAffiliations?.filter((aff) => {
59175
+ return isPrincipalAffiliation(aff) && aff.role.role_name === "Officer";
59176
+ }) || [];
59119
59177
  const ceasedOfficers = outgoingAffiliations?.filter((aff) => isPrincipalAffiliation(aff) && aff.role.role_name === "Officer") || [];
59120
- const editedOfficers = editedAffiliations?.filter((aff) => isPrincipalAffiliation(aff) && aff.role.role_name === "Officer") || [];
59121
- const addedDirectors = incomingAffiliations?.filter((aff) => isPrincipalAffiliation(aff) && aff.role.role_name === "Director") || [];
59178
+ const addedDirectors = incomingAffiliations?.filter((aff) => {
59179
+ return isPrincipalAffiliation(aff) && aff.role.role_name === "Director";
59180
+ }) || [];
59122
59181
  const ceasedDirectors = outgoingAffiliations?.filter((aff) => isPrincipalAffiliation(aff) && aff.role.role_name === "Director") || [];
59123
- const editedDirectors = editedAffiliations?.filter((aff) => isPrincipalAffiliation(aff) && aff.role.role_name === "Director") || [];
59124
59182
  const address = findRegisteredOffice(task.entity.affiliations);
59125
59183
  const cert = _ext.certified;
59126
59184
  config2[InitialReturnFillingFormGroups.General] = _OntarioUpdateMaintainFormHelper.generateGeneralInfo(task);
@@ -59132,30 +59190,27 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
59132
59190
  const directorDeltaData = deltaData?.directors ?? {};
59133
59191
  config2[InitialReturnFillingFormGroups.Directors] = new FormArray([
59134
59192
  ...addedDirectors.map((admin) => {
59135
- const form = _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Add, directorDeltaData[admin._id]);
59193
+ const form = _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Add, comparisonData, directorDeltaData[admin._id]);
59136
59194
  form.addControl(IRFormControls.IsCanadianResident, new FormControl(directorDeltaData[admin._id]?.residentCanadian ?? false));
59137
59195
  return form;
59138
59196
  }),
59139
59197
  ...ceasedDirectors.map((admin) => {
59140
- const form = _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Ceased, directorDeltaData[admin._id]);
59141
- form.addControl(IRFormControls.IsCanadianResident, new FormControl(directorDeltaData[admin._id]?.residentCanadian ?? false));
59142
- return form;
59143
- }),
59144
- ...editedDirectors.map((admin) => {
59145
- const form = _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Update, directorDeltaData[admin._id]);
59198
+ const form = _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Ceased, comparisonData, directorDeltaData[admin._id]);
59146
59199
  form.addControl(IRFormControls.IsCanadianResident, new FormControl(directorDeltaData[admin._id]?.residentCanadian ?? false));
59147
59200
  return form;
59148
59201
  })
59149
59202
  ]);
59150
59203
  const officerDeltaData = deltaData?.officers ?? {};
59151
59204
  config2[InitialReturnFillingFormGroups.Officers] = new FormArray([
59152
- ...addedOfficers.map((admin) => _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Add, officerDeltaData[admin._id])),
59153
- ...ceasedOfficers.map((admin) => _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Ceased, officerDeltaData[admin._id])),
59154
- ...editedOfficers.map((admin) => _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Update, officerDeltaData[admin._id]))
59205
+ ...addedOfficers.map((admin) => _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Add, comparisonData, officerDeltaData[admin._id])),
59206
+ ...ceasedOfficers.map((admin) => _OntarioUpdateMaintainFormHelper.generateAffiliationForm(admin, IRAffiliationType.Ceased, comparisonData, officerDeltaData[admin._id]))
59155
59207
  ]);
59156
59208
  if (cert) {
59157
59209
  config2[InitialReturnFillingFormGroups.CertifiedBy] = _OntarioUpdateMaintainFormHelper.generateCertification(cert, deltaData?.certifiedBy);
59158
59210
  }
59211
+ config2[InitialReturnFillingFormGroups.Contact] = new FormGroup({
59212
+ [IRFormControls.Contact]: new FormControl(deltaData?.contactUid ?? "", Validators.required)
59213
+ });
59159
59214
  return config2;
59160
59215
  }
59161
59216
  static generateGeneralInfo(task) {
@@ -59182,6 +59237,27 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
59182
59237
  [IRFormControls.AffiliationName]: new FormControl(cert.incorporator_name)
59183
59238
  }, this.generateAddressFormConfig(cert.address, _OntarioUpdateMaintainFormHelper.mapAddressDelta(deltaData?.address))));
59184
59239
  }
59240
+ static generateContact(contactAffiliation) {
59241
+ const contactProfile = contactAffiliation?.participant._profile ?? {};
59242
+ const communications = contactAffiliation?.participant.communications;
59243
+ const contactEmailAddress = communications?.find((item) => item.type.toLowerCase().includes("email"))?.value ?? "";
59244
+ const contactPhone = communications?.find((item) => item.type.toLowerCase().includes("phone"))?.value ?? "";
59245
+ const { countryCode, areaCode, number } = getPhoneData(contactPhone.replace(/\D/g, ""));
59246
+ return {
59247
+ EmailAddress: contactEmailAddress,
59248
+ PersonName: {
59249
+ FirstName: contactProfile?.firstName,
59250
+ LastName: contactProfile?.lastName,
59251
+ MiddleName: contactProfile?.middleName
59252
+ },
59253
+ PhoneNumber: {
59254
+ AreaCode: areaCode,
59255
+ CountryTelephoneCode: countryCode,
59256
+ Extension: "",
59257
+ TelephoneNumber: number
59258
+ }
59259
+ };
59260
+ }
59185
59261
  static generateAddressFormConfig(address, delta) {
59186
59262
  const config2 = {};
59187
59263
  if (address) {
@@ -59227,27 +59303,45 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
59227
59303
  config2[IRFormControls.AffiliationAddressType] = new FormControl(AffiliationAddressType.CanadianSuite);
59228
59304
  return config2;
59229
59305
  }
59230
- static generateAffiliationForm(affiliation, affiliationType, deltaData) {
59306
+ static generateAffiliationForm(affiliation, affiliationType, comparisonData, deltaData) {
59231
59307
  const address = affiliation.addresses.at(0) || affiliation.parent_affiliation?.addresses?.at(0);
59232
59308
  const communications = affiliation.participant.communications;
59233
59309
  const emailAddress = affiliation.participant.communicationEmail ?? communications?.find((item) => item.type.toLowerCase().includes("email"))?.value;
59234
- const person = affiliation.participant;
59235
- const firstName = person._profile.firstName || "";
59236
- const lastName = person._profile.lastName || "";
59237
- const middleName = person._profile.middleName || "";
59238
- const name = [firstName, middleName, lastName].filter(Boolean).join(" ");
59310
+ const name = generateAffiliationFullName(affiliation);
59311
+ const key = generateAffiliationKey(affiliation).toLowerCase();
59312
+ const currentData = _OntarioUpdateMaintainFormHelper.getCurrentPersonData(comparisonData, affiliation);
59313
+ let correctedAffiliationType = affiliationType;
59314
+ let isThisChangeToAnExistingEntity = false;
59315
+ let isThisChangeToAnExistingEntityVisible = false;
59316
+ if (deltaData) {
59317
+ if (deltaData.currentName) {
59318
+ isThisChangeToAnExistingEntity = true;
59319
+ isThisChangeToAnExistingEntityVisible = true;
59320
+ }
59321
+ correctedAffiliationType = IRAffiliationType.Update;
59322
+ } else {
59323
+ if (currentData) {
59324
+ correctedAffiliationType = IRAffiliationType.Update;
59325
+ } else {
59326
+ isThisChangeToAnExistingEntity = false;
59327
+ isThisChangeToAnExistingEntityVisible = true;
59328
+ }
59329
+ }
59239
59330
  const config2 = {
59240
59331
  [IRFormControls.ID]: new FormControl(affiliation._id),
59241
59332
  [IRFormControls.AffiliationName]: new FormControl(name),
59242
59333
  [IRFormControls.Role]: new FormControl(affiliation.role.static_title),
59243
- [IRFormControls.EffectiveDate]: new FormControl(affiliation.start_date),
59334
+ [IRFormControls.EffectiveDate]: new FormControl(affiliation.start_date ? toYyyyMmDd(affiliation.start_date) : ""),
59244
59335
  [IRFormControls.CeaseDate]: new FormControl(affiliation.end_date ? toYyyyMmDd(affiliation.end_date) : ""),
59245
59336
  [IRFormControls.Email]: new FormControl(emailAddress ?? ""),
59246
- [IRFormControls.AffiliationType]: new FormControl(affiliationType)
59337
+ [IRFormControls.AffiliationType]: new FormControl(correctedAffiliationType),
59338
+ [IRFormControls.CurrentName]: new FormControl(deltaData ? deltaData.currentName : IRAffiliationType.Update === correctedAffiliationType ? key : "", requiredIf(IRFormControls.IsThisChangeToAnExistingEntity)),
59339
+ [IRFormControls.IsThisChangeToAnExistingEntity]: new FormControl(isThisChangeToAnExistingEntity),
59340
+ [IRFormControls.IsThisChangeToAnExistingEntityVisible]: new FormControl(isThisChangeToAnExistingEntityVisible)
59247
59341
  };
59248
59342
  const form = new FormGroup(__spreadValues(__spreadValues({}, config2), this.generateAddressFormConfig(address, _OntarioUpdateMaintainFormHelper.mapAddressDelta(deltaData?.address))));
59249
59343
  const affiliationAddressType = form.get(IRFormControls.AffiliationAddressType)?.value;
59250
- updateFormControlsEnableState(form, addressEnabledFieldsMap[affiliationAddressType]);
59344
+ updateFormControlsEnableState(form, [...addressEnabledFieldsMap[affiliationAddressType], IRFormControls.CurrentName, IRFormControls.IsThisChangeToAnExistingEntity]);
59251
59345
  return form;
59252
59346
  }
59253
59347
  static mapAddressDelta(addr) {
@@ -78518,7 +78612,11 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
78518
78612
  \u0275\u0275restoreView(_r6);
78519
78613
  \u0275\u0275nextContext();
78520
78614
  const control_r7 = \u0275\u0275readContextLet(4);
78521
- return \u0275\u0275resetView(control_r7 == null ? null : control_r7.reset());
78615
+ const field_r3 = \u0275\u0275nextContext(2).$implicit;
78616
+ \u0275\u0275nextContext();
78617
+ const form_r4 = \u0275\u0275readContextLet(1);
78618
+ control_r7 == null ? null : control_r7.reset();
78619
+ return \u0275\u0275resetView(field_r3.onChange && field_r3.onChange(form_r4));
78522
78620
  });
78523
78621
  \u0275\u0275elementStart(2, "mat-icon");
78524
78622
  \u0275\u0275text(3, "close");
@@ -79215,7 +79313,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
79215
79313
  \r
79216
79314
  @if (control?.value && !control?.disabled) {\r
79217
79315
  <div matSuffix class="suffix-container">\r
79218
- <button mat-icon-button (click)="control?.reset()">\r
79316
+ <button mat-icon-button (click)="control?.reset(); field.onChange && field.onChange(form)">\r
79219
79317
  <mat-icon>close</mat-icon>\r
79220
79318
  </button>\r
79221
79319
  \r
@@ -80991,7 +81089,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
80991
81089
  });
80992
81090
 
80993
81091
  // src/app/constants/initial-return-form.constants.ts
80994
- var personFullAddressFormField, fullAddressFormField, certifiedByAddressFormField, checkboxFormField, ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_NO_SUIT, ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_SUIT, ONTARIO_INITIAL_RETURN_FORM_GENERAL_FIELDS, ONTARIO_INITIAL_RETURN_CARD_FORM_ADDRESS_FIELDS_MAP, generatePersonFields, ONTARIO_INITIAL_RETURN_FORM_DIRECTORS_FIELDS_MAP, ONTARIO_INITIAL_RETURN_FORM_OFFICER_FIELDS_MAP, generateCertifiedByFields, ONTARIO_INITIAL_RETURN_FORM_CERTIFIED_BY_FIELDS_MAP;
81092
+ var personFullAddressFormField, fullAddressFormField, currentNameFields, certifiedByAddressFormField, checkboxFormField, ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_NO_SUIT, ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_SUIT, ONTARIO_INITIAL_RETURN_FORM_GENERAL_FIELDS, ONTARIO_INITIAL_RETURN_CARD_FORM_ADDRESS_FIELDS_MAP, generatePersonFields, generateOntarioInitialReturnFormDirectorsFieldsMap, generateOntarioInitialReturnFormOfficerFieldsMap, generateCertifiedByFields, ONTARIO_INITIAL_RETURN_FORM_CERTIFIED_BY_FIELDS_MAP, generateOntarioInitialReturnFormContactControl;
80995
81093
  var init_initial_return_form_constants = __esm({
80996
81094
  "src/app/constants/initial-return-form.constants.ts"() {
80997
81095
  init_form_enums();
@@ -81010,7 +81108,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81010
81108
  if (!prevValueMap) {
81011
81109
  return baseResult;
81012
81110
  }
81013
- const key = formValue[IRFormControls.AffiliationName];
81111
+ const key = formValue[IRFormControls.CurrentName];
81014
81112
  const prevValue = prevValueMap.get(key);
81015
81113
  if (!prevValue) {
81016
81114
  return baseResult;
@@ -81046,6 +81144,35 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81046
81144
  },
81047
81145
  class: "span-12"
81048
81146
  };
81147
+ currentNameFields = (label, options) => [
81148
+ {
81149
+ type: FormType.Checkbox,
81150
+ label: `Is this a change to an existing ${label}?`,
81151
+ class: "span-12",
81152
+ formControlName: IRFormControls.IsThisChangeToAnExistingEntity,
81153
+ isVisible: (form) => {
81154
+ return form.get(IRFormControls.IsThisChangeToAnExistingEntityVisible)?.value;
81155
+ },
81156
+ onChange: (form) => {
81157
+ const val = form.get(IRFormControls.IsThisChangeToAnExistingEntity)?.value;
81158
+ form.get(IRFormControls.AffiliationType)?.setValue(val ? IRAffiliationType.Update : IRAffiliationType.Add);
81159
+ if (!val) {
81160
+ form.get(IRFormControls.CurrentName)?.setValue("");
81161
+ }
81162
+ }
81163
+ },
81164
+ {
81165
+ type: FormType.Select,
81166
+ label: `Existing ${label}`,
81167
+ formControlName: IRFormControls.CurrentName,
81168
+ required: true,
81169
+ dynamicOptions: (form) => options.filter((option) => option.label.toLowerCase().includes(form.get(IRFormControls.AffiliationName)?.value.toLowerCase())),
81170
+ isVisible: (form) => {
81171
+ return form.get(IRFormControls.AffiliationType)?.value !== IRAffiliationType.Ceased && form.get(IRFormControls.IsThisChangeToAnExistingEntity)?.value;
81172
+ },
81173
+ class: "span-6"
81174
+ }
81175
+ ];
81049
81176
  certifiedByAddressFormField = {
81050
81177
  type: FormType.Text,
81051
81178
  label: "",
@@ -81210,7 +81337,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81210
81337
  const prevValueData = prevValue;
81211
81338
  const result = `<span class="body-1-semibold">${t("Primary Activity")}:</span> ${primaryActivity}`;
81212
81339
  if (prevValueData?.primaryActivity) {
81213
- if (prevValueData.primaryActivity !== primaryActivity) {
81340
+ if (prevValueData.primaryActivity?.toLowerCase() !== primaryActivity?.toLowerCase()) {
81214
81341
  return result + `<span class="grey-mid"><br/><span class="body-1-semibold">${t("Previous Activity")}:</span> ${prevValueData.primaryActivity}</span>`;
81215
81342
  }
81216
81343
  }
@@ -81294,7 +81421,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81294
81421
  if (!prevValueMap || !isUpdate) {
81295
81422
  return baseEmail ? baseResult : "";
81296
81423
  }
81297
- const key = formValue[IRFormControls.AffiliationName];
81424
+ const key = formValue[IRFormControls.CurrentName];
81298
81425
  const prevValue = prevValueMap.get(key);
81299
81426
  if (!prevValue) {
81300
81427
  return baseEmail ? baseResult : "";
@@ -81307,18 +81434,18 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81307
81434
  }
81308
81435
  }
81309
81436
  ];
81310
- ONTARIO_INITIAL_RETURN_FORM_DIRECTORS_FIELDS_MAP = {
81311
- [AffiliationAddressType.CanadianNoSuite]: generatePersonFields([...ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_NO_SUIT, checkboxFormField, personFullAddressFormField]),
81312
- [AffiliationAddressType.CanadianSuite]: generatePersonFields([...ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_SUIT, checkboxFormField, personFullAddressFormField]),
81313
- [AffiliationAddressType.InternationalNoSuite]: generatePersonFields([checkboxFormField, personFullAddressFormField]),
81314
- [AffiliationAddressType.InternationalSuite]: generatePersonFields([checkboxFormField, personFullAddressFormField])
81315
- };
81316
- ONTARIO_INITIAL_RETURN_FORM_OFFICER_FIELDS_MAP = {
81317
- [AffiliationAddressType.CanadianNoSuite]: generatePersonFields([...ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_NO_SUIT, personFullAddressFormField]),
81318
- [AffiliationAddressType.CanadianSuite]: generatePersonFields([...ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_SUIT, personFullAddressFormField]),
81319
- [AffiliationAddressType.InternationalNoSuite]: generatePersonFields([personFullAddressFormField]),
81320
- [AffiliationAddressType.InternationalSuite]: generatePersonFields([personFullAddressFormField])
81321
- };
81437
+ generateOntarioInitialReturnFormDirectorsFieldsMap = (currentNameOptions) => ({
81438
+ [AffiliationAddressType.CanadianNoSuite]: generatePersonFields([...ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_NO_SUIT, checkboxFormField, personFullAddressFormField, ...currentNameFields("Director", currentNameOptions)]),
81439
+ [AffiliationAddressType.CanadianSuite]: generatePersonFields([...ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_SUIT, checkboxFormField, personFullAddressFormField, ...currentNameFields("Director", currentNameOptions)]),
81440
+ [AffiliationAddressType.InternationalNoSuite]: generatePersonFields([checkboxFormField, personFullAddressFormField, ...currentNameFields("Director", currentNameOptions)]),
81441
+ [AffiliationAddressType.InternationalSuite]: generatePersonFields([checkboxFormField, personFullAddressFormField, ...currentNameFields("Director", currentNameOptions)])
81442
+ });
81443
+ generateOntarioInitialReturnFormOfficerFieldsMap = (currentNameOptions) => ({
81444
+ [AffiliationAddressType.CanadianNoSuite]: generatePersonFields([...ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_NO_SUIT, personFullAddressFormField, ...currentNameFields("Officer", currentNameOptions)]),
81445
+ [AffiliationAddressType.CanadianSuite]: generatePersonFields([...ONTARIO_DELTA_CARD_FORM_AFFILIATION_FIELDS_CANADIAN_SUIT, personFullAddressFormField, ...currentNameFields("Officer", currentNameOptions)]),
81446
+ [AffiliationAddressType.InternationalNoSuite]: generatePersonFields([personFullAddressFormField, ...currentNameFields("Officer", currentNameOptions)]),
81447
+ [AffiliationAddressType.InternationalSuite]: generatePersonFields([personFullAddressFormField, ...currentNameFields("Officer", currentNameOptions)])
81448
+ });
81322
81449
  generateCertifiedByFields = (fields) => [
81323
81450
  {
81324
81451
  type: FormType.Text,
@@ -81334,6 +81461,36 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81334
81461
  [AffiliationAddressType.InternationalNoSuite]: generateCertifiedByFields([certifiedByAddressFormField]),
81335
81462
  [AffiliationAddressType.InternationalSuite]: generateCertifiedByFields([certifiedByAddressFormField])
81336
81463
  };
81464
+ generateOntarioInitialReturnFormContactControl = (contacts) => {
81465
+ const contactsOptions = contacts.map((contact) => ({
81466
+ label: contact.participant._profile.name ?? "",
81467
+ value: contact._id
81468
+ }));
81469
+ return [
81470
+ {
81471
+ type: FormType.Select,
81472
+ label: "Contact",
81473
+ formControlName: IRFormControls.Contact,
81474
+ required: true,
81475
+ options: contactsOptions,
81476
+ class: "span-12"
81477
+ },
81478
+ {
81479
+ type: FormType.Text,
81480
+ dynamicLabel: (form, t) => {
81481
+ const id = form.get(IRFormControls.Contact)?.value;
81482
+ const contact = contacts.find((item) => item._id === id);
81483
+ const email = contact?.participant?.communications?.find((c) => c.type.toLowerCase().includes("email"))?.value;
81484
+ const phone = contact?.participant?.communications?.find((c) => c.type.toLowerCase().includes("phone"))?.value;
81485
+ return `<span class="body-1-semibold">${t("Contact Details")}:</span> ${getContactDetailsPreview(email, phone, t)}`;
81486
+ },
81487
+ formControlName: "",
81488
+ required: false,
81489
+ isVisible: (form) => form.get(IRFormControls.Contact)?.value,
81490
+ class: "span-12"
81491
+ }
81492
+ ];
81493
+ };
81337
81494
  }
81338
81495
  });
81339
81496
 
@@ -81368,12 +81525,12 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81368
81525
  \u0275\u0275elementEnd()();
81369
81526
  }
81370
81527
  if (rf & 2) {
81371
- let tmp_9_0;
81528
+ let tmp_10_0;
81372
81529
  const ctx_r0 = \u0275\u0275nextContext();
81373
81530
  const generalInfoForm_r3 = \u0275\u0275readContextLet(4);
81374
81531
  \u0275\u0275property("title", ctx_r0.groups.General)("isStatusIcon", !ctx_r0.readonly());
81375
81532
  \u0275\u0275advance();
81376
- \u0275\u0275property("isSubmitted", ctx_r0.isSubmitted())("prevData", (tmp_9_0 = ctx_r0.prevData()) == null ? null : tmp_9_0.corporationInfo)("form", generalInfoForm_r3)("config", ctx_r0.generalCardFields)("label", ctx_r0.groups.General);
81533
+ \u0275\u0275property("isSubmitted", ctx_r0.isSubmitted())("prevData", (tmp_10_0 = ctx_r0.prevData()) == null ? null : tmp_10_0.corporationInfo)("form", generalInfoForm_r3)("config", ctx_r0.generalCardFields)("label", ctx_r0.groups.General);
81377
81534
  }
81378
81535
  }
81379
81536
  function OntarioUpdateMaintainFormComponent_Conditional_7_Template(rf, ctx) {
@@ -81388,13 +81545,13 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81388
81545
  \u0275\u0275elementEnd()();
81389
81546
  }
81390
81547
  if (rf & 2) {
81391
- let tmp_9_0;
81392
- let tmp_12_0;
81548
+ let tmp_10_0;
81549
+ let tmp_13_0;
81393
81550
  const ctx_r0 = \u0275\u0275nextContext();
81394
81551
  const registeredOfficeAddress_r5 = \u0275\u0275readContextLet(6);
81395
81552
  \u0275\u0275property("isStatusIcon", !ctx_r0.readonly())("isValid", ctx_r0.sectionValidity["registeredOffice"])("title", ctx_r0.groups.RegisteredOfficeAddress);
81396
81553
  \u0275\u0275advance();
81397
- \u0275\u0275property("prevData", (tmp_9_0 = ctx_r0.prevData()) == null ? null : tmp_9_0.corporationInfo)("isSubmitted", ctx_r0.isSubmitted())("form", registeredOfficeAddress_r5)("config", ctx_r0.addressFieldsMap[(tmp_12_0 = registeredOfficeAddress_r5.get(ctx_r0.controls.AffiliationAddressType)) == null ? null : tmp_12_0.value]);
81554
+ \u0275\u0275property("prevData", (tmp_10_0 = ctx_r0.prevData()) == null ? null : tmp_10_0.corporationInfo)("isSubmitted", ctx_r0.isSubmitted())("form", registeredOfficeAddress_r5)("config", ctx_r0.addressFieldsMap[(tmp_13_0 = registeredOfficeAddress_r5.get(ctx_r0.controls.AffiliationAddressType)) == null ? null : tmp_13_0.value]);
81398
81555
  }
81399
81556
  }
81400
81557
  function OntarioUpdateMaintainFormComponent_Conditional_9_Template(rf, ctx) {
@@ -81410,13 +81567,13 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81410
81567
  \u0275\u0275elementEnd();
81411
81568
  }
81412
81569
  if (rf & 2) {
81413
- let tmp_6_0;
81414
81570
  let tmp_7_0;
81571
+ let tmp_8_0;
81415
81572
  const ctx_r0 = \u0275\u0275nextContext();
81416
81573
  const directorsArray_r7 = \u0275\u0275readContextLet(8);
81417
- const isOpen_r8 = ((tmp_6_0 = directorsArray_r7 == null ? null : directorsArray_r7.length) !== null && tmp_6_0 !== void 0 ? tmp_6_0 : 0) <= ctx_r0.initiallyOpenCardsCount;
81574
+ const isOpen_r8 = ((tmp_7_0 = directorsArray_r7 == null ? null : directorsArray_r7.length) !== null && tmp_7_0 !== void 0 ? tmp_7_0 : 0) <= ctx_r0.initiallyOpenCardsCount;
81418
81575
  \u0275\u0275advance();
81419
- \u0275\u0275property("prevData", (tmp_7_0 = ctx_r0.prevData()) == null ? null : tmp_7_0.directors)("isSubmitted", ctx_r0.isSubmitted())("isValid", ctx_r0.sectionValidity["directors"])("areItemsOpen", isOpen_r8)("isStatusIcon", !ctx_r0.readonly())("config", ctx_r0.directorsFieldsMap)("configKey", ctx_r0.controls.AffiliationAddressType)("formArray", directorsArray_r7)("title", ctx_r0.groups.Directors);
81576
+ \u0275\u0275property("prevData", (tmp_8_0 = ctx_r0.prevData()) == null ? null : tmp_8_0.persons)("isSubmitted", ctx_r0.isSubmitted())("isValid", ctx_r0.sectionValidity["directors"])("areItemsOpen", isOpen_r8)("isStatusIcon", !ctx_r0.readonly())("config", ctx_r0.directorsFieldsMap)("configKey", ctx_r0.controls.AffiliationAddressType)("formArray", directorsArray_r7)("title", ctx_r0.groups.Directors);
81420
81577
  }
81421
81578
  }
81422
81579
  function OntarioUpdateMaintainFormComponent_Conditional_10_Template(rf, ctx) {
@@ -81446,13 +81603,13 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81446
81603
  \u0275\u0275elementEnd();
81447
81604
  }
81448
81605
  if (rf & 2) {
81449
- let tmp_6_0;
81450
81606
  let tmp_7_0;
81607
+ let tmp_8_0;
81451
81608
  const ctx_r0 = \u0275\u0275nextContext();
81452
81609
  const officersArray_r10 = \u0275\u0275readContextLet(11);
81453
- const isOpen_r11 = ((tmp_6_0 = officersArray_r10 == null ? null : officersArray_r10.length) !== null && tmp_6_0 !== void 0 ? tmp_6_0 : 0) <= ctx_r0.initiallyOpenCardsCount;
81610
+ const isOpen_r11 = ((tmp_7_0 = officersArray_r10 == null ? null : officersArray_r10.length) !== null && tmp_7_0 !== void 0 ? tmp_7_0 : 0) <= ctx_r0.initiallyOpenCardsCount;
81454
81611
  \u0275\u0275advance();
81455
- \u0275\u0275property("prevData", (tmp_7_0 = ctx_r0.prevData()) == null ? null : tmp_7_0.officers)("isSubmitted", ctx_r0.isSubmitted())("areItemsOpen", isOpen_r11)("isStatusIcon", !ctx_r0.readonly())("config", ctx_r0.officersFieldsMap)("configKey", ctx_r0.controls.AffiliationAddressType)("formArray", officersArray_r10)("title", ctx_r0.groups.Officers)("isValid", ctx_r0.sectionValidity["officers"]);
81612
+ \u0275\u0275property("prevData", (tmp_8_0 = ctx_r0.prevData()) == null ? null : tmp_8_0.persons)("isSubmitted", ctx_r0.isSubmitted())("areItemsOpen", isOpen_r11)("isStatusIcon", !ctx_r0.readonly())("config", ctx_r0.officersFieldsMap)("configKey", ctx_r0.controls.AffiliationAddressType)("formArray", officersArray_r10)("title", ctx_r0.groups.Officers)("isValid", ctx_r0.sectionValidity["officers"]);
81456
81613
  }
81457
81614
  }
81458
81615
  function OntarioUpdateMaintainFormComponent_Conditional_13_Template(rf, ctx) {
@@ -81481,11 +81638,11 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81481
81638
  \u0275\u0275elementEnd();
81482
81639
  }
81483
81640
  if (rf & 2) {
81484
- let tmp_6_0;
81485
- let tmp_9_0;
81641
+ let tmp_7_0;
81642
+ let tmp_10_0;
81486
81643
  const ctx_r0 = \u0275\u0275nextContext();
81487
81644
  const certifiedBy_r13 = \u0275\u0275readContextLet(14);
81488
- \u0275\u0275property("prevData", (tmp_6_0 = ctx_r0.prevData()) == null ? null : tmp_6_0.corporationInfo)("isSubmitted", ctx_r0.isSubmitted())("form", certifiedBy_r13)("config", ctx_r0.certifiedByFieldsMap[(tmp_9_0 = certifiedBy_r13.get(ctx_r0.controls.AffiliationAddressType)) == null ? null : tmp_9_0.value]);
81645
+ \u0275\u0275property("prevData", (tmp_7_0 = ctx_r0.prevData()) == null ? null : tmp_7_0.corporationInfo)("isSubmitted", ctx_r0.isSubmitted())("form", certifiedBy_r13)("config", ctx_r0.certifiedByFieldsMap[(tmp_10_0 = certifiedBy_r13.get(ctx_r0.controls.AffiliationAddressType)) == null ? null : tmp_10_0.value]);
81489
81646
  }
81490
81647
  }
81491
81648
  function OntarioUpdateMaintainFormComponent_Conditional_17_Template(rf, ctx) {
@@ -81500,6 +81657,25 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81500
81657
  \u0275\u0275textInterpolate(\u0275\u0275pipeBind1(2, 1, "Not specified"));
81501
81658
  }
81502
81659
  }
81660
+ function OntarioUpdateMaintainFormComponent_Conditional_19_Template(rf, ctx) {
81661
+ if (rf & 1) {
81662
+ const _r14 = \u0275\u0275getCurrentView();
81663
+ \u0275\u0275elementStart(0, "expandable-card", 5)(1, "filing-form-group", 15);
81664
+ \u0275\u0275listener("visiblyValidChange", function OntarioUpdateMaintainFormComponent_Conditional_19_Template_filing_form_group_visiblyValidChange_1_listener($event) {
81665
+ \u0275\u0275restoreView(_r14);
81666
+ const ctx_r0 = \u0275\u0275nextContext();
81667
+ return \u0275\u0275resetView(ctx_r0.onSectionValidChange("contact", $event));
81668
+ });
81669
+ \u0275\u0275elementEnd()();
81670
+ }
81671
+ if (rf & 2) {
81672
+ const ctx_r0 = \u0275\u0275nextContext();
81673
+ const contact_r15 = \u0275\u0275readContextLet(18);
81674
+ \u0275\u0275property("isStatusIcon", !ctx_r0.readonly())("isValid", ctx_r0.sectionValidity["contact"])("title", ctx_r0.groups.Contact);
81675
+ \u0275\u0275advance();
81676
+ \u0275\u0275property("isSubmitted", ctx_r0.isSubmitted())("form", contact_r15)("config", ctx_r0.contactsFields);
81677
+ }
81678
+ }
81503
81679
  var OntarioUpdateMaintainFormComponent;
81504
81680
  var init_update_maintain_form_component = __esm({
81505
81681
  "src/app/components/ontario/update-maintain/update-maintain-form/update-maintain-form.component.ts"() {
@@ -81512,6 +81688,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81512
81688
  init_expandable_card_component();
81513
81689
  init_expandable_list_card_component();
81514
81690
  init_ngx_translate_core();
81691
+ init_common_utils();
81515
81692
  init_core();
81516
81693
  OntarioUpdateMaintainFormComponent = class _OntarioUpdateMaintainFormComponent {
81517
81694
  form = input.required();
@@ -81525,13 +81702,33 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81525
81702
  groups = InitialReturnFillingFormGroups;
81526
81703
  generalCardFields = ONTARIO_INITIAL_RETURN_FORM_GENERAL_FIELDS;
81527
81704
  addressFieldsMap = ONTARIO_INITIAL_RETURN_CARD_FORM_ADDRESS_FIELDS_MAP;
81528
- directorsFieldsMap = ONTARIO_INITIAL_RETURN_FORM_DIRECTORS_FIELDS_MAP;
81529
- officersFieldsMap = ONTARIO_INITIAL_RETURN_FORM_OFFICER_FIELDS_MAP;
81705
+ directorsFieldsMap = {};
81706
+ officersFieldsMap = {};
81530
81707
  certifiedByFieldsMap = ONTARIO_INITIAL_RETURN_FORM_CERTIFIED_BY_FIELDS_MAP;
81708
+ contactsFields = [];
81531
81709
  alertType = AlertType;
81532
81710
  controls = InitialReturnFormControls;
81533
81711
  sectionValidity = {};
81534
81712
  initiallyOpenCardsCount = 3;
81713
+ constructor() {
81714
+ effect(() => {
81715
+ const prevData = this.prevData();
81716
+ const personKeys = Array.from(prevData?.persons?.keys() ?? []);
81717
+ const options = personKeys.map((key) => {
81718
+ const person = prevData?.persons.get(key);
81719
+ return { label: `${person?.fullName}, ${toTitleCase(person?.position ?? "")}`.trim(), value: key };
81720
+ });
81721
+ this.directorsFieldsMap = generateOntarioInitialReturnFormDirectorsFieldsMap(options);
81722
+ this.officersFieldsMap = generateOntarioInitialReturnFormOfficerFieldsMap(options);
81723
+ });
81724
+ effect(() => {
81725
+ const task = this.task();
81726
+ if (task) {
81727
+ const contacts = task.entity.affiliations.filter((a) => a.role.role_name === "Contact");
81728
+ this.contactsFields = generateOntarioInitialReturnFormContactControl(contacts);
81729
+ }
81730
+ });
81731
+ }
81535
81732
  isVisiblyValid() {
81536
81733
  return Object.values(this.sectionValidity).every((v) => v);
81537
81734
  }
@@ -81548,7 +81745,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81548
81745
  static \u0275fac = function OntarioUpdateMaintainFormComponent_Factory(__ngFactoryType__) {
81549
81746
  return new (__ngFactoryType__ || _OntarioUpdateMaintainFormComponent)();
81550
81747
  };
81551
- static \u0275cmp = /* @__PURE__ */ \u0275\u0275defineComponent({ type: _OntarioUpdateMaintainFormComponent, selectors: [["ontario-update-maintain-form"]], inputs: { form: [1, "form"], task: [1, "task"], errors: [1, "errors"], isNote: [1, "isNote"], isSubmitted: [1, "isSubmitted"], readonly: [1, "readonly"], prevData: [1, "prevData"] }, outputs: { visiblyValidChange: "visiblyValidChange" }, decls: 18, vars: 15, consts: [[1, "ontario-update-maintain-form"], ["title", "Entity changed", "content", "A new draft needs to be generated as the Entity was changed since the last draft was produced.", 3, "type"], ["title", "The following issues need to be resolved before proceeding:", 3, "content"], [1, "ontario-update-maintain-form-content"], [3, "title", "isStatusIcon"], [3, "isStatusIcon", "isValid", "title"], [3, "prevData", "isSubmitted", "isValid", "areItemsOpen", "isStatusIcon", "config", "configKey", "formArray", "title"], [3, "title"], [3, "prevData", "isSubmitted", "areItemsOpen", "isStatusIcon", "config", "configKey", "formArray", "title", "isValid"], [3, "prevData", "isSubmitted", "form", "config"], [1, "body-1-regular"], [3, "visiblyValidChange", "isSubmitted", "prevData", "form", "config", "label"], [3, "visiblyValidChange", "prevData", "isSubmitted", "form", "config"], [3, "visiblyValidChange", "prevData", "isSubmitted", "isValid", "areItemsOpen", "isStatusIcon", "config", "configKey", "formArray", "title"], [3, "visiblyValidChange", "prevData", "isSubmitted", "areItemsOpen", "isStatusIcon", "config", "configKey", "formArray", "title", "isValid"]], template: function OntarioUpdateMaintainFormComponent_Template(rf, ctx) {
81748
+ static \u0275cmp = /* @__PURE__ */ \u0275\u0275defineComponent({ type: _OntarioUpdateMaintainFormComponent, selectors: [["ontario-update-maintain-form"]], inputs: { form: [1, "form"], task: [1, "task"], errors: [1, "errors"], isNote: [1, "isNote"], isSubmitted: [1, "isSubmitted"], readonly: [1, "readonly"], prevData: [1, "prevData"] }, outputs: { visiblyValidChange: "visiblyValidChange" }, decls: 20, vars: 17, consts: [[1, "ontario-update-maintain-form"], ["title", "Entity changed", "content", "A new draft needs to be generated as the Entity was changed since the last draft was produced.", 3, "type"], ["title", "The following issues need to be resolved before proceeding:", 3, "content"], [1, "ontario-update-maintain-form-content"], [3, "title", "isStatusIcon"], [3, "isStatusIcon", "isValid", "title"], [3, "prevData", "isSubmitted", "isValid", "areItemsOpen", "isStatusIcon", "config", "configKey", "formArray", "title"], [3, "title"], [3, "prevData", "isSubmitted", "areItemsOpen", "isStatusIcon", "config", "configKey", "formArray", "title", "isValid"], [3, "prevData", "isSubmitted", "form", "config"], [1, "body-1-regular"], [3, "visiblyValidChange", "isSubmitted", "prevData", "form", "config", "label"], [3, "visiblyValidChange", "prevData", "isSubmitted", "form", "config"], [3, "visiblyValidChange", "prevData", "isSubmitted", "isValid", "areItemsOpen", "isStatusIcon", "config", "configKey", "formArray", "title"], [3, "visiblyValidChange", "prevData", "isSubmitted", "areItemsOpen", "isStatusIcon", "config", "configKey", "formArray", "title", "isValid"], [3, "visiblyValidChange", "isSubmitted", "form", "config"]], template: function OntarioUpdateMaintainFormComponent_Template(rf, ctx) {
81552
81749
  if (rf & 1) {
81553
81750
  \u0275\u0275elementStart(0, "div", 0);
81554
81751
  \u0275\u0275template(1, OntarioUpdateMaintainFormComponent_Conditional_1_Template, 1, 1, "alert", 1)(2, OntarioUpdateMaintainFormComponent_Conditional_2_Template, 1, 1, "alert", 2);
@@ -81564,7 +81761,10 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81564
81761
  \u0275\u0275declareLet(14);
81565
81762
  \u0275\u0275elementStart(15, "expandable-card", 5);
81566
81763
  \u0275\u0275template(16, OntarioUpdateMaintainFormComponent_Conditional_16_Template, 1, 4, "filing-form-group", 9)(17, OntarioUpdateMaintainFormComponent_Conditional_17_Template, 3, 3, "h2", 10);
81567
- \u0275\u0275elementEnd()()();
81764
+ \u0275\u0275elementEnd();
81765
+ \u0275\u0275declareLet(18);
81766
+ \u0275\u0275template(19, OntarioUpdateMaintainFormComponent_Conditional_19_Template, 2, 6, "expandable-card", 5);
81767
+ \u0275\u0275elementEnd()();
81568
81768
  }
81569
81769
  if (rf & 2) {
81570
81770
  \u0275\u0275advance();
@@ -81572,27 +81772,31 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81572
81772
  \u0275\u0275advance();
81573
81773
  \u0275\u0275conditional(ctx.errors().length ? 2 : -1);
81574
81774
  \u0275\u0275advance(2);
81575
- const generalInfoForm_r14 = \u0275\u0275storeLet(ctx.getFormGroup(ctx.groups.General));
81775
+ const generalInfoForm_r16 = \u0275\u0275storeLet(ctx.getFormGroup(ctx.groups.General));
81576
81776
  \u0275\u0275advance();
81577
- \u0275\u0275conditional(generalInfoForm_r14 ? 5 : -1);
81777
+ \u0275\u0275conditional(generalInfoForm_r16 ? 5 : -1);
81578
81778
  \u0275\u0275advance();
81579
- const registeredOfficeAddress_r15 = \u0275\u0275storeLet(ctx.getFormGroup(ctx.groups.RegisteredOfficeAddress));
81779
+ const registeredOfficeAddress_r17 = \u0275\u0275storeLet(ctx.getFormGroup(ctx.groups.RegisteredOfficeAddress));
81580
81780
  \u0275\u0275advance();
81581
- \u0275\u0275conditional(registeredOfficeAddress_r15 ? 7 : -1);
81781
+ \u0275\u0275conditional(registeredOfficeAddress_r17 ? 7 : -1);
81582
81782
  \u0275\u0275advance();
81583
- const directorsArray_r16 = \u0275\u0275storeLet(ctx.getFormArray(ctx.groups.Directors));
81783
+ const directorsArray_r18 = \u0275\u0275storeLet(ctx.getFormArray(ctx.groups.Directors));
81584
81784
  \u0275\u0275advance();
81585
- \u0275\u0275conditional(directorsArray_r16 && directorsArray_r16.length ? 9 : 10);
81785
+ \u0275\u0275conditional(directorsArray_r18 && directorsArray_r18.length ? 9 : 10);
81586
81786
  \u0275\u0275advance(2);
81587
- const officersArray_r17 = \u0275\u0275storeLet(ctx.getFormArray(ctx.groups.Officers));
81787
+ const officersArray_r19 = \u0275\u0275storeLet(ctx.getFormArray(ctx.groups.Officers));
81588
81788
  \u0275\u0275advance();
81589
- \u0275\u0275conditional(officersArray_r17 && officersArray_r17.length ? 12 : 13);
81789
+ \u0275\u0275conditional(officersArray_r19 && officersArray_r19.length ? 12 : 13);
81590
81790
  \u0275\u0275advance(2);
81591
- const certifiedBy_r18 = \u0275\u0275storeLet(ctx.getFormGroup(ctx.groups.CertifiedBy));
81791
+ const certifiedBy_r20 = \u0275\u0275storeLet(ctx.getFormGroup(ctx.groups.CertifiedBy));
81792
+ \u0275\u0275advance();
81793
+ \u0275\u0275property("isStatusIcon", !ctx.readonly())("isValid", certifiedBy_r20 ? ctx.sectionValidity["certifiedBy"] : true)("title", ctx.groups.CertifiedBy);
81592
81794
  \u0275\u0275advance();
81593
- \u0275\u0275property("isStatusIcon", !ctx.readonly())("isValid", certifiedBy_r18 ? ctx.sectionValidity["certifiedBy"] : true)("title", ctx.groups.CertifiedBy);
81795
+ \u0275\u0275conditional(certifiedBy_r20 ? 16 : 17);
81796
+ \u0275\u0275advance(2);
81797
+ const contact_r21 = \u0275\u0275storeLet(ctx.getFormGroup(ctx.groups.Contact));
81594
81798
  \u0275\u0275advance();
81595
- \u0275\u0275conditional(certifiedBy_r18 ? 16 : 17);
81799
+ \u0275\u0275conditional(contact_r21 ? 19 : -1);
81596
81800
  }
81597
81801
  }, dependencies: [
81598
81802
  FilingFormGroupComponent,
@@ -81676,7 +81880,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81676
81880
  @let isOpen =\r
81677
81881
  (directorsArray?.length ?? 0) <= initiallyOpenCardsCount;\r
81678
81882
  <expandable-list-card\r
81679
- [prevData]="prevData()?.directors"\r
81883
+ [prevData]="prevData()?.persons"\r
81680
81884
  [isSubmitted]="isSubmitted()"\r
81681
81885
  [isValid]="sectionValidity['directors']"\r
81682
81886
  [areItemsOpen]="isOpen"\r
@@ -81701,7 +81905,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81701
81905
  (officersArray?.length ?? 0) <= initiallyOpenCardsCount;\r
81702
81906
  \r
81703
81907
  <expandable-list-card\r
81704
- [prevData]="prevData()?.officers"\r
81908
+ [prevData]="prevData()?.persons"\r
81705
81909
  [isSubmitted]="isSubmitted()"\r
81706
81910
  [areItemsOpen]="isOpen"\r
81707
81911
  [isStatusIcon]="!readonly()"\r
@@ -81741,13 +81945,29 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
81741
81945
  }\r
81742
81946
  \r
81743
81947
  </expandable-card>\r
81948
+ \r
81949
+ @let contact = getFormGroup(groups.Contact);\r
81950
+ @if (contact) {\r
81951
+ <expandable-card\r
81952
+ [isStatusIcon]="!readonly()"\r
81953
+ [isValid]="sectionValidity['contact']"\r
81954
+ [title]="groups.Contact"\r
81955
+ >\r
81956
+ <filing-form-group\r
81957
+ [isSubmitted]="isSubmitted()"\r
81958
+ [form]="contact"\r
81959
+ [config]="contactsFields"\r
81960
+ (visiblyValidChange)="onSectionValidChange('contact', $event)"\r
81961
+ />\r
81962
+ </expandable-card>\r
81963
+ }\r
81744
81964
  </div>\r
81745
81965
  </div>\r
81746
81966
  `, styles: ["/* src/app/components/ontario/update-maintain/update-maintain-form/update-maintain-form.component.scss */\n:host .ontario-update-maintain-form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n height: 100%;\n overflow-y: auto;\n}\n:host .ontario-update-maintain-form-content {\n display: flex;\n flex-direction: column;\n gap: 24px;\n}\n:host .ontario-update-maintain-form-section {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n:host .ontario-update-maintain-form-section-title {\n font-size: 14px;\n font-weight: 600;\n color: var(--filing-modal-color-dark-blue, #1a2e5a);\n margin: 0;\n padding-bottom: 8px;\n border-bottom: 1px solid var(--color-border, #e0e0e0);\n}\n:host .ontario-update-maintain-form-principal {\n padding: 12px 0;\n border-bottom: 1px solid var(--color-border, #e0e0e0);\n}\n:host .ontario-update-maintain-form-principal:last-child {\n border-bottom: none;\n}\n/*# sourceMappingURL=update-maintain-form.component.css.map */\n"] }]
81747
- }], null, null);
81967
+ }], () => [], null);
81748
81968
  })();
81749
81969
  (() => {
81750
- (typeof ngDevMode === "undefined" || ngDevMode) && \u0275setClassDebugInfo(OntarioUpdateMaintainFormComponent, { className: "OntarioUpdateMaintainFormComponent", filePath: "src/app/components/ontario/update-maintain/update-maintain-form/update-maintain-form.component.ts", lineNumber: 41 });
81970
+ (typeof ngDevMode === "undefined" || ngDevMode) && \u0275setClassDebugInfo(OntarioUpdateMaintainFormComponent, { className: "OntarioUpdateMaintainFormComponent", filePath: "src/app/components/ontario/update-maintain/update-maintain-form/update-maintain-form.component.ts", lineNumber: 44 });
81751
81971
  })();
81752
81972
  }
81753
81973
  });
@@ -82209,7 +82429,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
82209
82429
  this.formationInitialDeltaValue.set(this.generateFormationDeltaData());
82210
82430
  }
82211
82431
  if (task && isUpdateMaintain(task)) {
82212
- const fieldsConfig = OntarioUpdateMaintainFormHelper.generateInitialForm(task);
82432
+ const fieldsConfig = OntarioUpdateMaintainFormHelper.generateInitialForm(task, this.prevData());
82213
82433
  this.deltaForm.set(new FormGroup(fieldsConfig));
82214
82434
  this.initialReturnInitialDeltaValue.set(this.generateInitialReturnDeltaData());
82215
82435
  }
@@ -82226,13 +82446,10 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
82226
82446
  }
82227
82447
  }
82228
82448
  if (task && isUpdateMaintain(task) && deltaData) {
82229
- const fieldsConfig = OntarioUpdateMaintainFormHelper.generateInitialForm(task);
82449
+ const fieldsConfig = OntarioUpdateMaintainFormHelper.generateInitialForm(task, this.prevData());
82230
82450
  const form = new FormGroup(fieldsConfig);
82231
82451
  form.disable();
82232
82452
  this.previewForm.set(form);
82233
- if (untracked2(() => this.activeStep()) === Step.Validate) {
82234
- this.nextStep.emit();
82235
- }
82236
82453
  }
82237
82454
  });
82238
82455
  }
@@ -82263,42 +82480,90 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
82263
82480
  onIrSubmit(termsAndConditions) {
82264
82481
  this.irSubmit.emit();
82265
82482
  }
82483
+ isInternationalAddress(src, addressTypeControl, countryCodeControl) {
82484
+ const addressType = src?.[addressTypeControl];
82485
+ if (addressType === AffiliationAddressType.InternationalNoSuite || addressType === AffiliationAddressType.InternationalSuite) {
82486
+ return true;
82487
+ }
82488
+ const countryCode = (src?.[countryCodeControl] ?? "").toString().toUpperCase();
82489
+ return Boolean(countryCode) && !["CA", "US"].includes(countryCode);
82490
+ }
82491
+ mapAddressDelta(src, controls) {
82492
+ if (this.isInternationalAddress(src, controls.addressType, controls.countryCode)) {
82493
+ return {
82494
+ unitType: null,
82495
+ unitNumber: null,
82496
+ streetNumber: null,
82497
+ streetName: null,
82498
+ streetType: null,
82499
+ streetDirection: null
82500
+ };
82501
+ }
82502
+ return {
82503
+ unitType: src?.[controls.unitType] ?? null,
82504
+ unitNumber: src?.[controls.unitNumber] ?? null,
82505
+ streetNumber: src?.[controls.streetNumber] ?? null,
82506
+ streetName: src?.[controls.streetName] ?? null,
82507
+ streetType: src?.[controls.streetType] ?? null,
82508
+ streetDirection: src?.[controls.streetDirection] ?? null
82509
+ };
82510
+ }
82511
+ mapIRAddressDelta(src) {
82512
+ return this.mapAddressDelta(src, {
82513
+ unitType: IRFormControls.UnitType,
82514
+ unitNumber: IRFormControls.UnitNumber,
82515
+ streetNumber: IRFormControls.StreetNumber,
82516
+ streetName: IRFormControls.StreetName,
82517
+ streetType: IRFormControls.StreetType,
82518
+ streetDirection: IRFormControls.StreetDirection,
82519
+ addressType: IRFormControls.AffiliationAddressType,
82520
+ countryCode: IRFormControls.CountryCode
82521
+ });
82522
+ }
82523
+ mapFormationAddressDelta(src) {
82524
+ return this.mapAddressDelta(src, {
82525
+ unitType: FormationFormControls.UnitType,
82526
+ unitNumber: FormationFormControls.UnitNumber,
82527
+ streetNumber: FormationFormControls.StreetNumber,
82528
+ streetName: FormationFormControls.StreetName,
82529
+ streetType: FormationFormControls.StreetType,
82530
+ streetDirection: FormationFormControls.StreetDirection,
82531
+ addressType: FormationFormControls.AffiliationAddressType,
82532
+ countryCode: FormationFormControls.CountryCode
82533
+ });
82534
+ }
82266
82535
  generateInitialReturnDeltaData() {
82267
82536
  const formData = this.deltaForm().getRawValue();
82268
82537
  const generalInfo = formData[InitialReturnFillingFormGroups.General];
82269
82538
  const registeredOffice = formData[InitialReturnFillingFormGroups.RegisteredOfficeAddress];
82270
82539
  const certifiedBy = formData[InitialReturnFillingFormGroups.CertifiedBy];
82271
- const mapAddress3 = (src) => ({
82272
- unitType: src?.[IRFormControls.UnitType] ?? null,
82273
- unitNumber: src?.[IRFormControls.UnitNumber] ?? null,
82274
- streetNumber: src?.[IRFormControls.StreetNumber] ?? null,
82275
- streetName: src?.[IRFormControls.StreetName] ?? null,
82276
- streetType: src?.[IRFormControls.StreetType] ?? null,
82277
- streetDirection: src?.[IRFormControls.StreetDirection] ?? null
82278
- });
82540
+ const contact = formData[InitialReturnFillingFormGroups.Contact];
82279
82541
  const mapPersons = (items) => (items ?? []).reduce((acc, item) => {
82280
82542
  const id = item[IRFormControls.ID];
82281
82543
  if (id) {
82282
82544
  acc[id] = {
82283
- address: mapAddress3(item),
82545
+ address: this.mapIRAddressDelta(item),
82546
+ currentName: item[IRFormControls.CurrentName] ?? "",
82284
82547
  residentCanadian: item[IRFormControls.IsCanadianResident] ?? false
82285
82548
  };
82286
82549
  }
82287
82550
  return acc;
82288
82551
  }, {});
82289
- return __spreadValues({
82552
+ return __spreadProps(__spreadValues({
82290
82553
  referenceNumbers: {
82291
82554
  referenceNumber: generalInfo?.[IRFormControls.ClientMatterNumber] ?? null,
82292
82555
  docketNumber: generalInfo?.[IRFormControls.Docket] ?? null
82293
82556
  },
82294
- registeredOfficeAddress: mapAddress3(registeredOffice),
82557
+ registeredOfficeAddress: this.mapIRAddressDelta(registeredOffice),
82295
82558
  directors: mapPersons(formData[InitialReturnFillingFormGroups.Directors]),
82296
82559
  officers: mapPersons(formData[InitialReturnFillingFormGroups.Officers])
82297
82560
  }, certifiedBy ? {
82298
82561
  certifiedBy: {
82299
- address: mapAddress3(certifiedBy)
82562
+ address: this.mapIRAddressDelta(certifiedBy)
82300
82563
  }
82301
- } : {});
82564
+ } : {}), {
82565
+ contactUid: contact?.[IRFormControls.Contact] ?? null
82566
+ });
82302
82567
  }
82303
82568
  generateFormationDeltaData(termsAndConditions) {
82304
82569
  const formData = this.deltaForm().getRawValue();
@@ -82322,26 +82587,12 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
82322
82587
  nuansReportFrenchReferenceNumber: corpDetails?.[FormationFormControls.NuansReportReferenceFr] ?? null,
82323
82588
  nuansReportFrenchReferenceDate: corpDetails?.[FormationFormControls.NuansReportDateFr] ?? null
82324
82589
  },
82325
- registeredOfficeAddress: {
82326
- unitType: registeredOffice?.[FormationFormControls.UnitType] ?? null,
82327
- unitNumber: registeredOffice?.[FormationFormControls.UnitNumber] ?? null,
82328
- streetNumber: registeredOffice?.[FormationFormControls.StreetNumber] ?? null,
82329
- streetName: registeredOffice?.[FormationFormControls.StreetName] ?? null,
82330
- streetType: registeredOffice?.[FormationFormControls.StreetType] ?? null,
82331
- streetDirection: registeredOffice?.[FormationFormControls.StreetDirection] ?? null
82332
- },
82590
+ registeredOfficeAddress: this.mapFormationAddressDelta(registeredOffice),
82333
82591
  directors: (formData[FormationFormGroups.Directors] ?? []).reduce((acc, d) => {
82334
82592
  const id = d[FormationFormControls.Id];
82335
82593
  if (id) {
82336
82594
  acc[id] = {
82337
- address: {
82338
- unitType: d[FormationFormControls.UnitType] ?? null,
82339
- unitNumber: d[FormationFormControls.UnitNumber] ?? null,
82340
- streetNumber: d[FormationFormControls.StreetNumber] ?? null,
82341
- streetName: d[FormationFormControls.StreetName] ?? null,
82342
- streetType: d[FormationFormControls.StreetType] ?? null,
82343
- streetDirection: d[FormationFormControls.StreetDirection] ?? null
82344
- },
82595
+ address: this.mapFormationAddressDelta(d),
82345
82596
  residentCanadian: d[FormationFormControls.IsResident] ?? false
82346
82597
  };
82347
82598
  }
@@ -82351,14 +82602,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
82351
82602
  const id = inc[FormationFormControls.Id];
82352
82603
  if (id) {
82353
82604
  acc[id] = {
82354
- address: {
82355
- unitType: inc[FormationFormControls.UnitType] ?? null,
82356
- unitNumber: inc[FormationFormControls.UnitNumber] ?? null,
82357
- streetNumber: inc[FormationFormControls.StreetNumber] ?? null,
82358
- streetName: inc[FormationFormControls.StreetName] ?? null,
82359
- streetType: inc[FormationFormControls.StreetType] ?? null,
82360
- streetDirection: inc[FormationFormControls.StreetDirection] ?? null
82361
- },
82605
+ address: this.mapFormationAddressDelta(inc),
82362
82606
  residentCanadian: inc[FormationFormControls.IsResident] ?? false
82363
82607
  };
82364
82608
  }
@@ -82369,14 +82613,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
82369
82613
  data.legalOpinion = {
82370
82614
  wasLegalOpinionObtained: corpDetails?.[FormationFormControls.wasLegalOpinionObtained] ?? false,
82371
82615
  lawyerSigning: legalOpinionData?.[FormationFormControls.LawyerSigningOpinion] ?? null,
82372
- address: {
82373
- unitType: legalOpinionData?.[FormationFormControls.UnitType] ?? null,
82374
- unitNumber: legalOpinionData?.[FormationFormControls.UnitNumber] ?? null,
82375
- streetNumber: legalOpinionData?.[FormationFormControls.StreetNumber] ?? null,
82376
- streetName: legalOpinionData?.[FormationFormControls.StreetName] ?? null,
82377
- streetType: legalOpinionData?.[FormationFormControls.StreetType] ?? null,
82378
- streetDirection: legalOpinionData?.[FormationFormControls.StreetDirection] ?? null
82379
- }
82616
+ address: this.mapFormationAddressDelta(legalOpinionData)
82380
82617
  };
82381
82618
  }
82382
82619
  if (termsAndConditions) {
@@ -86831,14 +87068,15 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
86831
87068
  throw new Error(`submitInitialReturnValidationToECore: task is not InitialReturn (${signature.task?._taskType})`);
86832
87069
  }
86833
87070
  const fetchFn = opts?.fetchImpl ?? fetch;
87071
+ const entityKey = signature.task.entity._profile.registry_id;
86834
87072
  const CorporationInformation = {
86835
87073
  FilingFormType: _OntarioUpdateMaintainService.getFilingFormType(signature.task),
86836
87074
  Jurisdiction: "ON",
86837
- CorporationInformation: {
87075
+ CorporationInformation: __spreadValues({
86838
87076
  CorporationNumber: signature.task.entity._profile.corp_number,
86839
87077
  CorporationName: signature.task.entity._profile.name,
86840
87078
  IncorporationDate: signature.task.entity._compliance.incorporation_date
86841
- }
87079
+ }, entityKey ? { EntityKey: entityKey } : {})
86842
87080
  };
86843
87081
  const url = signature.proxyApiUrl;
86844
87082
  const resp = yield fetchFn(url, {
@@ -86854,15 +87092,25 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
86854
87092
  }, opts?.headers ?? {}),
86855
87093
  body: JSON.stringify(CorporationInformation)
86856
87094
  });
86857
- const data = yield resp.json();
86858
- return data["ServiceOrderId"];
87095
+ const raw = yield resp.text();
87096
+ const parsed = tryParseJson(raw);
87097
+ if (!parsed.ok) {
87098
+ throw new Error(`eCore returned ${resp.status} ${resp.statusText}: ${raw || "(empty body)"}`);
87099
+ }
87100
+ const data = parsed.value;
87101
+ if (!resp.ok || data?.Errors?.length) {
87102
+ const err = buildValidateError(resp.status, data);
87103
+ err.validateResult = data;
87104
+ throw err;
87105
+ }
87106
+ return data.ServiceOrderId ?? "";
86859
87107
  });
86860
87108
  }
86861
87109
  submitData(signature, id, opts) {
86862
87110
  return __async(this, null, function* () {
86863
87111
  const fetchFn = opts?.fetchImpl ?? fetch;
86864
87112
  const url = signature.proxyApiUrl;
86865
- yield fetchFn(url, {
87113
+ const resp = yield fetchFn(url, {
86866
87114
  method: "POST",
86867
87115
  headers: __spreadValues({
86868
87116
  "Content-Type": "application/json",
@@ -86874,6 +87122,15 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
86874
87122
  Cookie: "AWSALB=PpMRL+JDLimOntn4FPEpJ2ZX9rtRbn/7wOE1Ntyq9RGhYPgnJpjAN8xr8R5TyM4v1tBvC62q0YWVR2fQwDLLKWIIQm+U79VccsjiMHRffNr6an9tJNOOdpX94R53; AWSALBCORS=PpMRL+JDLimOntn4FPEpJ2ZX9rtRbn/7wOE1Ntyq9RGhYPgnJpjAN8xr8R5TyM4v1tBvC62q0YWVR2fQwDLLKWIIQm+U79VccsjiMHRffNr6an9tJNOOdpX94R53"
86875
87123
  }, opts?.headers ?? {})
86876
87124
  });
87125
+ const raw = yield resp.text();
87126
+ const parsed = tryParseJson(raw);
87127
+ const errors = parsed.ok ? parsed.value?.Errors : void 0;
87128
+ if (!resp.ok || errors?.length) {
87129
+ const result = parsed.ok ? parsed.value : { Errors: errors ?? [] };
87130
+ const err = buildValidateError(resp.status, result);
87131
+ err.validateResult = result;
87132
+ throw err;
87133
+ }
86877
87134
  });
86878
87135
  }
86879
87136
  getCurrentData(signature, id, opts) {
@@ -86999,6 +87256,19 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
86999
87256
  });
87000
87257
 
87001
87258
  // src/app/helpers/initial-return-payload.helper.ts
87259
+ function parseUnitTypeToEnumNumeric(raw) {
87260
+ if (raw === null || raw === void 0 || raw === "")
87261
+ return void 0;
87262
+ const numeric = Number(raw);
87263
+ if (!isNaN(numeric))
87264
+ return numeric;
87265
+ const upper = raw.toString().toUpperCase();
87266
+ const match = Object.entries(ECoreCanadianUnitType).find(([name]) => name.toUpperCase() === upper);
87267
+ if (!match)
87268
+ return void 0;
87269
+ const value = Number(match[1]);
87270
+ return isNaN(value) ? void 0 : value;
87271
+ }
87002
87272
  function irPersonPayloadToDeltaData(payload) {
87003
87273
  if (!payload) {
87004
87274
  return null;
@@ -87014,15 +87284,10 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87014
87284
  };
87015
87285
  }
87016
87286
  function extractAddressDeltaDataFromInitialReturnAdditionalDetails(details) {
87017
- const toNum = (v) => {
87018
- if (v === null || v === void 0 || v === "")
87019
- return void 0;
87020
- const n = Number(v);
87021
- return isNaN(n) ? void 0 : n;
87022
- };
87023
87287
  const region = details.RegionName ?? details.Region ?? details.Prov ?? "";
87024
87288
  const country = details.CountryCode ?? "";
87025
87289
  const province = country === "CA" ? CANCodeToProvince(region) : country === "US" ? USCodeToState(region) : region;
87290
+ const unitType = parseUnitTypeToEnumNumeric(details.UnitType);
87026
87291
  return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
87027
87292
  streetNumber: details.StreetNumber ?? "",
87028
87293
  streetName: details.StreetName ?? "",
@@ -87031,18 +87296,14 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87031
87296
  postalCode: details.PostCode ?? void 0,
87032
87297
  country,
87033
87298
  careOf: details.CareOf ?? void 0
87034
- }, details.StreetType != null && { streetType: details.StreetType }), details.StreetDirection != null && { streetDirection: details.StreetDirection }), toNum(details.UnitType) !== void 0 && { unitType: toNum(details.UnitType) }), details.UnitNumber != null && { unitNumber: details.UnitNumber });
87299
+ }, details.StreetType != null && { streetType: details.StreetType }), details.StreetDirection != null && { streetDirection: details.StreetDirection }), unitType !== void 0 && { unitType }), details.UnitNumber != null && { unitNumber: details.UnitNumber });
87035
87300
  }
87036
87301
  function extractAddressDeltaDataFromInitialReturnAddressContainer(postalAddress) {
87037
87302
  const { AddressLocale, AddressCA, AddressUS, AddressINTL } = postalAddress;
87038
- const toNum = (v) => {
87039
- if (v === null || v === void 0 || v === "")
87040
- return void 0;
87041
- const n = Number(v);
87042
- return isNaN(n) ? void 0 : n;
87043
- };
87044
87303
  if (AddressLocale === "CA" && AddressCA) {
87045
87304
  const region = AddressCA.RegionName ?? AddressCA.Region ?? "";
87305
+ const unitType = parseUnitTypeToEnumNumeric(AddressCA.UnitType);
87306
+ const unitNumber = AddressCA.Address3 ?? AddressCA.Suite ?? null;
87046
87307
  return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
87047
87308
  streetNumber: postalAddress.StreetNumber ?? AddressCA.Address1 ?? "",
87048
87309
  streetName: postalAddress.StreetName ?? AddressCA.Address2 ?? "",
@@ -87051,7 +87312,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87051
87312
  postalCode: postalAddress.PostCode ?? AddressCA.PostCode ?? void 0,
87052
87313
  country: postalAddress.CountryCode ?? AddressCA.CountryCode,
87053
87314
  careOf: postalAddress.CareOf ?? AddressCA.CareOf ?? void 0
87054
- }, AddressCA.StreetType !== void 0 && { streetType: AddressCA.StreetType ?? "" }), AddressCA.StreetDirection !== void 0 && { streetDirection: AddressCA.StreetDirection ?? "" }), toNum(AddressCA.UnitType) !== void 0 && { unitType: toNum(AddressCA.UnitType) }), AddressCA.Suite != null && { unitNumber: AddressCA.Suite });
87315
+ }, AddressCA.StreetType !== void 0 && { streetType: AddressCA.StreetType ?? "" }), AddressCA.StreetDirection !== void 0 && { streetDirection: AddressCA.StreetDirection ?? "" }), unitType !== void 0 && { unitType }), unitNumber != null && unitNumber !== "" && { unitNumber });
87055
87316
  }
87056
87317
  if (AddressLocale === "US" && AddressUS) {
87057
87318
  const region = AddressUS.RegionName ?? AddressUS.Region ?? "";
@@ -87065,6 +87326,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87065
87326
  };
87066
87327
  }
87067
87328
  if (AddressLocale === "INTL" && AddressINTL) {
87329
+ const unitNumber = AddressINTL.Suite ?? AddressINTL.Address3 ?? null;
87068
87330
  return __spreadValues({
87069
87331
  streetNumber: postalAddress.StreetNumber ?? AddressINTL.Address1 ?? "",
87070
87332
  streetName: postalAddress.StreetName ?? AddressINTL.Address2 ?? "",
@@ -87072,7 +87334,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87072
87334
  province: postalAddress.RegionName ?? AddressINTL.RegionName ?? AddressINTL.Region,
87073
87335
  postalCode: postalAddress.PostCode ?? AddressINTL.PostCode ?? void 0,
87074
87336
  country: postalAddress.CountryCode ?? AddressINTL.CountryCode
87075
- }, AddressINTL.Suite != null && { unitNumber: AddressINTL.Suite });
87337
+ }, unitNumber != null && unitNumber !== "" && { unitNumber });
87076
87338
  }
87077
87339
  return {
87078
87340
  streetNumber: postalAddress.StreetNumber ?? "",
@@ -87086,14 +87348,10 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87086
87348
  }
87087
87349
  function extractAddressDeltaData(postalAddress) {
87088
87350
  const { AddressLocale, AddressCA, AddressUS, AddressINTL } = postalAddress;
87089
- const toNum = (v) => {
87090
- if (v === null || v === void 0 || v === "")
87091
- return void 0;
87092
- const n = Number(v);
87093
- return isNaN(n) ? void 0 : n;
87094
- };
87095
87351
  if (AddressLocale === "CA" && AddressCA) {
87096
87352
  const region = AddressCA.RegionName ?? AddressCA.Region ?? "";
87353
+ const unitType = parseUnitTypeToEnumNumeric(AddressCA.UnitType);
87354
+ const unitNumber = AddressCA.Suite ?? AddressCA.Address3 ?? null;
87097
87355
  return __spreadValues(__spreadValues(__spreadValues(__spreadValues({
87098
87356
  streetNumber: AddressCA.Address1,
87099
87357
  streetName: AddressCA.Address2,
@@ -87102,7 +87360,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87102
87360
  postalCode: AddressCA.PostCode ?? void 0,
87103
87361
  country: AddressCA.CountryCode,
87104
87362
  careOf: AddressCA.CareOf ?? void 0
87105
- }, AddressCA.StreetType !== void 0 && { streetType: AddressCA.StreetType ?? "" }), AddressCA.StreetDirection !== void 0 && { streetDirection: AddressCA.StreetDirection ?? "" }), toNum(AddressCA.UnitType) !== void 0 && { unitType: toNum(AddressCA.UnitType) }), AddressCA.Suite != null && { unitNumber: AddressCA.Suite });
87363
+ }, AddressCA.StreetType !== void 0 && { streetType: AddressCA.StreetType ?? "" }), AddressCA.StreetDirection !== void 0 && { streetDirection: AddressCA.StreetDirection ?? "" }), unitType !== void 0 && { unitType }), unitNumber != null && unitNumber !== "" && { unitNumber });
87106
87364
  }
87107
87365
  if (AddressLocale === "US" && AddressUS) {
87108
87366
  const region = AddressUS.RegionName ?? AddressUS.Region ?? "";
@@ -87116,6 +87374,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87116
87374
  };
87117
87375
  }
87118
87376
  if (AddressLocale === "INTL" && AddressINTL) {
87377
+ const unitNumber = AddressINTL.Suite ?? AddressINTL.Address3 ?? null;
87119
87378
  return __spreadValues({
87120
87379
  streetNumber: AddressINTL.Address1,
87121
87380
  streetName: AddressINTL.Address2,
@@ -87123,60 +87382,44 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87123
87382
  province: AddressINTL.RegionName ?? AddressINTL.Region,
87124
87383
  postalCode: AddressINTL.PostCode ?? void 0,
87125
87384
  country: AddressINTL.CountryCode
87126
- }, AddressINTL.Suite != null && { unitNumber: AddressINTL.Suite });
87385
+ }, unitNumber != null && unitNumber !== "" && { unitNumber });
87127
87386
  }
87128
87387
  return { streetNumber: "", streetName: "" };
87129
87388
  }
87130
87389
  function corporationInfoToPersonnelDeltaData(corporationInfo) {
87131
- const directorsMap = /* @__PURE__ */ new Map();
87132
- const officersMap = /* @__PURE__ */ new Map();
87390
+ const personsMap = /* @__PURE__ */ new Map();
87133
87391
  if (!corporationInfo)
87134
- return { directors: directorsMap, officers: officersMap, corporationInfo: { primaryActivity: "", email: "" } };
87135
- const { ChangeDirectors: cd, ChangeOfficers: co } = corporationInfo.CurrentData;
87392
+ return { persons: personsMap, corporationInfo: { primaryActivity: "", email: "" } };
87393
+ const initialAdministrators = corporationInfo.CurrentData.InitialAdministrators;
87136
87394
  const fullName = (payload) => {
87137
87395
  return [
87138
- payload.PersonName.FirstName,
87139
- payload.PersonName.MiddleName,
87140
- payload.PersonName.LastName
87396
+ payload.PersonName.FirstName?.toLowerCase() ?? "",
87397
+ payload.PersonName.MiddleName?.toLowerCase() ?? "",
87398
+ payload.PersonName.LastName?.toLowerCase() ?? "",
87399
+ payload.OfficerPositionName?.toLowerCase() ?? ""
87141
87400
  ].filter(Boolean).join(" ");
87142
87401
  };
87143
- const populatePersonsMap = (lists, target) => {
87144
- for (const list of lists) {
87145
- for (const payload of list ?? []) {
87146
- if (!payload)
87147
- continue;
87148
- const deltaData = irPersonPayloadToDeltaData(payload);
87149
- if (!deltaData)
87150
- continue;
87151
- const email = ("EmailAddress" in payload ? payload.EmailAddress : "") ?? "";
87152
- const ceasedRoles = "CeasedAppointedRoles" in payload && Array.isArray(payload.CeasedAppointedRoles) ? payload.CeasedAppointedRoles.map((role) => `${role.PositionFullName} - ${role.CeasedDate} (Appointed ${role.AppointedDate})`) : void 0;
87153
- target.set(fullName(payload), __spreadProps(__spreadValues({}, deltaData), { email, ceasedRoles }));
87154
- }
87402
+ const populatePersonsMap = (list) => {
87403
+ for (const payload of list ?? []) {
87404
+ if (!payload)
87405
+ continue;
87406
+ const deltaData = irPersonPayloadToDeltaData(payload);
87407
+ if (!deltaData)
87408
+ continue;
87409
+ const email = ("EmailAddress" in payload ? payload.EmailAddress : "") ?? "";
87410
+ const ceasedRoles = "CeasedAppointedRoles" in payload && Array.isArray(payload.CeasedAppointedRoles) ? payload.CeasedAppointedRoles.map((role) => `${role.PositionFullName} - ${role.CeasedDate} (Appointed ${role.AppointedDate})`) : void 0;
87411
+ personsMap.set(fullName(payload), __spreadProps(__spreadValues({}, deltaData), { email, ceasedRoles }));
87155
87412
  }
87156
87413
  };
87157
- populatePersonsMap([
87158
- cd?.AddedDirectors,
87159
- cd?.CeasedDirectors,
87160
- cd?.EditedDirectors,
87161
- cd?.AddDirector,
87162
- cd?.CeaseDirector,
87163
- cd?.EditDirector
87164
- ], directorsMap);
87165
- populatePersonsMap([
87166
- co?.AddedOfficers,
87167
- co?.CeasedOfficers,
87168
- co?.EditedOfficers,
87169
- co?.AddOfficer,
87170
- co?.CeaseOfficer,
87171
- co?.EditOfficer
87172
- ], officersMap);
87414
+ populatePersonsMap(initialAdministrators);
87173
87415
  const primaryActivity = [corporationInfo?.CurrentData.PrimaryBusinessActivity.NAICSCode, corporationInfo?.CurrentData.PrimaryBusinessActivity.PrimaryActivity].join(" - ");
87174
87416
  const additionalDetails = corporationInfo?.CurrentData.AdditionalDetails;
87175
- return { directors: directorsMap, officers: officersMap, corporationInfo: { email: corporationInfo.CurrentData.OfficialEmail.Email, primaryActivity, registeredOfficeAddress: extractAddressDeltaDataFromInitialReturnAddressContainer(corporationInfo?.CurrentData.RegisteredHeadOfficeAddress), additionalInfo: additionalDetails ? extractAddressDeltaDataFromInitialReturnAdditionalDetails(additionalDetails) : null } };
87417
+ return { persons: personsMap, corporationInfo: { email: corporationInfo.CurrentData.OfficialEmail.Email, primaryActivity, registeredOfficeAddress: extractAddressDeltaDataFromInitialReturnAddressContainer(corporationInfo?.CurrentData.RegisteredHeadOfficeAddress), additionalInfo: additionalDetails ? extractAddressDeltaDataFromInitialReturnAdditionalDetails(additionalDetails) : null } };
87176
87418
  }
87177
87419
  var init_initial_return_payload_helper = __esm({
87178
87420
  "src/app/helpers/initial-return-payload.helper.ts"() {
87179
87421
  init_address_utils();
87422
+ init_transform_utils();
87180
87423
  }
87181
87424
  });
87182
87425
 
@@ -87345,13 +87588,13 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87345
87588
  }
87346
87589
  function transformIncorporator(incorporator) {
87347
87590
  const isIndividual = incorporator.type === "person";
87348
- const incorporationType = isIndividual ? ECoreIncorporatorType.Individual : ECoreIncorporatorType.BodyCorporate;
87591
+ const incorporationType = isIndividual ? ECoreIncorporatorType.Individual : ECoreIncorporatorType.NonRegCorporate;
87349
87592
  return {
87350
87593
  IncorporatorType: incorporationType,
87351
87594
  FirstName: isIndividual ? incorporator.firstName : void 0,
87352
87595
  MiddleName: isIndividual ? incorporator.middleName : void 0,
87353
87596
  LastName: isIndividual ? incorporator.lastName : void 0,
87354
- BodyCorporate: !isIndividual ? incorporator.incorporator_name : void 0,
87597
+ CompanyName: !isIndividual ? incorporator.incorporator_name : void 0,
87355
87598
  Signature: `${incorporator.signatory_first_name ?? ""} ${incorporator.signatory_last_name ?? ""}, ${incorporator.signatory_title ?? ""}`,
87356
87599
  Address: mapAddress(incorporator)
87357
87600
  };
@@ -87545,7 +87788,27 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87545
87788
  return ECoreFilingFormType.InitialReturn;
87546
87789
  }
87547
87790
  }
87548
- function buildOntarioUpdateMaintainValidationRequest(task, deltaData, serviceOrderId) {
87791
+ function buildOntarioUpdateMaintainValidationRequest(task, deltaData, serviceOrderId, corporationInfo) {
87792
+ const initialAdministrators = corporationInfo?.CurrentData.InitialAdministrators;
87793
+ const normalizePersonTitle = (name) => (name ?? "").trim().replace(/\s+/g, " ").toLowerCase();
87794
+ const getCurrentDataAdministrator = (name, isOfficer) => {
87795
+ if (!name || !initialAdministrators?.length) {
87796
+ return null;
87797
+ }
87798
+ const matchedOfficer = initialAdministrators.find((admin) => {
87799
+ if (!admin || Boolean(admin.IsDirector) === isOfficer) {
87800
+ return false;
87801
+ }
87802
+ const adminTitle = normalizePersonTitle([
87803
+ admin.PersonName?.FirstName?.toLowerCase(),
87804
+ admin.PersonName?.MiddleName?.toLowerCase(),
87805
+ admin.PersonName?.LastName?.toLowerCase(),
87806
+ admin.OfficerPositionName?.toLowerCase()
87807
+ ].filter(Boolean).join(" "));
87808
+ return adminTitle === name;
87809
+ });
87810
+ return matchedOfficer ?? null;
87811
+ };
87549
87812
  const getEmail = (aff) => aff.participant?.communications?.find((c) => c.type.toLowerCase().includes("email"))?.value ?? "";
87550
87813
  const buildPostalAddress = (entityAddress, deltaAddr) => {
87551
87814
  const country = normalizeCountryCode(entityAddress?.country ?? "");
@@ -87553,11 +87816,12 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87553
87816
  const Region = country === "CA" ? CANProvinceToCode(province) : country === "US" ? USStateToCode(province) : province;
87554
87817
  const streetOnly = getAddressComponent(entityAddress, "Street Only");
87555
87818
  const { StreetName, StreetType: StreetType2, StreetDirection: StreetDirection2 } = parseStreetAddress(streetOnly);
87819
+ const isCanadianAddress = country === "CA";
87556
87820
  const streetNumber = deltaAddr?.streetNumber ?? getAddressComponent(entityAddress, "Street Number Only") ?? "";
87557
- const streetName = deltaAddr?.streetName ?? StreetName ?? "";
87558
- const streetType = deltaAddr?.streetType ?? StreetType2 ?? null;
87559
- const streetDir = deltaAddr?.streetDirection ?? (StreetDirection2 ? StreetDirection2 : null);
87560
- const unitType = deltaAddr?.unitType ?? null;
87821
+ const streetName = isCanadianAddress ? deltaAddr?.streetName ?? StreetName ?? "" : streetOnly ?? "";
87822
+ const streetType = isCanadianAddress ? deltaAddr?.streetType ?? StreetType2 ?? null : null;
87823
+ const streetDir = isCanadianAddress ? deltaAddr?.streetDirection ?? (StreetDirection2 ? StreetDirection2 : null) : null;
87824
+ const unitType = isCanadianAddress ? deltaAddr?.unitType ?? null : null;
87561
87825
  const unitNumber = deltaAddr?.unitNumber ?? getAddressComponent(entityAddress, "Suite/Apartment") ?? null;
87562
87826
  const careOf = getAddressComponent(entityAddress, "Attention") || entityAddress?.attention || "";
87563
87827
  const AddressLocale = country === "CA" ? "CA" : country === "US" ? "US" : "INTL";
@@ -87576,7 +87840,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87576
87840
  RegionName: Region,
87577
87841
  CareOf: careOf,
87578
87842
  StreetNumberSuffix: "",
87579
- StreetType: streetType.toString(),
87843
+ StreetType: streetType?.toString(),
87580
87844
  StreetDirection: streetDir,
87581
87845
  UnitType: mapUnitTypeToEcore(unitType)
87582
87846
  } : null,
@@ -87611,92 +87875,106 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87611
87875
  const middleName = profile.middleName ?? "";
87612
87876
  const lastName = profile.lastName ?? "";
87613
87877
  const email = getEmail(aff);
87614
- const electedDate = toYyyyMmDd(new Date(aff.start_date)) ?? "";
87878
+ const electedDate = toYyyyMmDd(aff.start_date) ?? "";
87615
87879
  const ceaseDate = toYyyyMmDd(aff.end_date) ?? "";
87616
87880
  const residentCanadian = String(deltaEntry?.residentCanadian ?? false);
87617
87881
  const entityAddr = aff.addresses?.at(0) || aff.parent_affiliation?.addresses?.at(0);
87618
87882
  const PostalAddress = buildPostalAddress(entityAddr, deltaEntry?.address);
87619
87883
  const PersonName = { FirstName: firstName, MiddleName: middleName, LastName: lastName };
87620
- const position = isOfficer ? OFFICER_TITLE_TO_ECORE_POSITION_CODE[aff.role?.static_title ?? ""] ?? "" : "Director";
87621
- const positionName = ECORE_POSITION_CODE_TO_POSITION_NAME[position] ?? "Director";
87884
+ const position = isOfficer ? OFFICER_TITLE_TO_ECORE_POSITION_CODE[toTitleCase(aff.role?.static_title ?? "")] ?? "" : "Director";
87885
+ const matchingAdmin = getCurrentDataAdministrator(deltaEntry.currentName ?? "", isOfficer);
87886
+ const isCeaseAction = currentState === IRCurrentState.Ceased;
87887
+ const isDirectorFromRole = aff.role?.role_name === "Director";
87888
+ const mappedCurrentStateName = currentState === IRCurrentState.Added ? "Added" : currentState === IRCurrentState.Ceased ? "Ceased" : "Edited";
87889
+ const mappedId = matchingAdmin?.Id ?? "";
87890
+ const mappedRoleId = matchingAdmin?.RoleId ?? "";
87891
+ const personNameRoleId = isOfficer ? matchingAdmin?.RoleId ?? null : null;
87892
+ const mappedCeaseDate = currentState === IRCurrentState.Ceased ? ceaseDate : "";
87893
+ const mappedElectedDate = currentState === IRCurrentState.Added ? electedDate : "";
87894
+ const positionName = ECORE_POSITION_CODE_TO_POSITION_NAME[position?.toUpperCase()];
87622
87895
  if (!isOfficer) {
87623
87896
  switch (currentState) {
87624
87897
  case IRCurrentState.Added:
87625
87898
  return {
87626
- Id: 5,
87899
+ Id: "",
87900
+ RoleId: "",
87627
87901
  CeaseDate: "",
87628
87902
  CeasedAppointedRoles: [
87629
87903
  {
87630
- Id: aff._id,
87631
- Position: position,
87632
- PositionFullName: positionName,
87904
+ State: "",
87905
+ StateName: "",
87906
+ Position: "Director",
87907
+ PositionFullName: "Director",
87908
+ CeasedDate: "",
87633
87909
  AppointedDate: electedDate
87634
87910
  }
87635
87911
  ],
87636
- ElectedDate: electedDate,
87912
+ ElectedDate: mappedElectedDate,
87637
87913
  EmailAddress: email,
87638
- IsDirector: true,
87639
- PersonName: __spreadProps(__spreadValues({}, PersonName), { Position: null }),
87914
+ IsDirector: isDirectorFromRole,
87915
+ PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: personNameRoleId, Position: null }),
87640
87916
  OfficerPosition: "",
87641
87917
  OfficerPositionName: "",
87642
87918
  OfficerPositionSpecified: false,
87643
87919
  PostalAddress,
87644
87920
  ResidentCanadian: residentCanadian,
87645
87921
  IsInvalid: false,
87646
- CurrentState: currentState
87922
+ CurrentState: currentState,
87923
+ CurrentStateName: mappedCurrentStateName
87647
87924
  };
87648
87925
  case IRCurrentState.Ceased:
87649
87926
  return {
87650
- OfficerPosition: 0,
87927
+ OfficerPosition: "",
87651
87928
  OfficerPositionSpecified: false,
87652
87929
  OfficerId: null,
87930
+ CeaseDate: mappedCeaseDate,
87931
+ ElectedDate: mappedElectedDate,
87653
87932
  CeasedAppointedRoles: [
87654
87933
  {
87655
- State: IRCurrentState.Added,
87656
- StateName: "Changed",
87657
- Position: null,
87934
+ State: matchingAdmin && isCeaseAction ? IRCurrentState.Ceased : "",
87935
+ StateName: matchingAdmin && isCeaseAction ? "Ceased" : "",
87936
+ Position: "Director",
87658
87937
  PositionFullName: "Director",
87659
- CeasedDate: ceaseDate,
87660
- AppointedDate: electedDate,
87661
- AppointedDateSpecified: true,
87662
- EditAppointedDate: false
87938
+ CeasedDate: matchingAdmin && isCeaseAction ? ceaseDate : "",
87939
+ AppointedDate: ""
87663
87940
  }
87664
87941
  ],
87665
87942
  CurrentState: currentState,
87666
- CurrentStateName: "Unchanged",
87667
- OfficerPositionName: "Director",
87668
- Id: aff._id,
87669
- RoleId: aff.role?.role_name ?? "",
87670
- IsDirector: true,
87943
+ CurrentStateName: mappedCurrentStateName,
87944
+ OfficerPositionName: "",
87945
+ Id: mappedId,
87946
+ RoleId: mappedRoleId,
87947
+ IsDirector: isDirectorFromRole,
87671
87948
  ResidentCanadian: residentCanadian,
87672
- PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: aff.role?.role_name ?? "", Position: null })
87949
+ PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: personNameRoleId, Position: null }),
87950
+ PostalAddress,
87951
+ EmailAddress: email
87673
87952
  };
87674
87953
  case IRCurrentState.Changed:
87675
87954
  return {
87676
- OfficerPosition: 0,
87955
+ OfficerPosition: "",
87956
+ OfficerPositionSpecified: false,
87677
87957
  OfficerId: null,
87678
87958
  CeasedAppointedRoles: [
87679
87959
  {
87680
- State: 1,
87681
- StateName: "Unchanged",
87682
- Position: null,
87960
+ State: matchingAdmin && isCeaseAction ? IRCurrentState.Ceased : "",
87961
+ StateName: matchingAdmin && isCeaseAction ? "Ceased" : "",
87962
+ Position: "Director",
87683
87963
  PositionFullName: "Director",
87684
- CeasedDate: ceaseDate,
87685
- AppointedDate: electedDate,
87686
- AppointedDateSpecified: true,
87687
- EditAppointedDate: false
87964
+ CeasedDate: matchingAdmin && isCeaseAction ? ceaseDate : "",
87965
+ AppointedDate: ""
87688
87966
  }
87689
87967
  ],
87690
- CurrentState: 1,
87691
- CurrentStateName: "Unchanged",
87692
- OfficerPositionName: "Director",
87693
- Id: aff._id,
87694
- RoleId: aff.role?.role_name ?? "",
87695
- IsDirector: true,
87968
+ CurrentState: currentState,
87969
+ CurrentStateName: mappedCurrentStateName,
87970
+ OfficerPositionName: "",
87971
+ Id: mappedId,
87972
+ RoleId: mappedRoleId,
87973
+ IsDirector: isDirectorFromRole,
87696
87974
  ResidentCanadian: residentCanadian,
87697
- PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: aff.role?.role_name ?? "", Position: null }),
87698
- CeaseDate: "",
87699
- ElectedDate: "",
87975
+ PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: personNameRoleId, Position: null }),
87976
+ CeaseDate: mappedCeaseDate,
87977
+ ElectedDate: mappedElectedDate,
87700
87978
  CeasedDateSpecified: false,
87701
87979
  PostalAddress,
87702
87980
  EmailAddress: email,
@@ -87708,80 +87986,87 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87708
87986
  switch (currentState) {
87709
87987
  case IRCurrentState.Added:
87710
87988
  return {
87711
- Id: aff._id,
87989
+ Id: "",
87990
+ RoleId: "",
87991
+ OfficerId: "",
87712
87992
  CeaseDate: "",
87713
87993
  CeasedAppointedRoles: [
87714
87994
  {
87715
- Id: aff._id,
87995
+ State: "",
87996
+ StateName: "",
87716
87997
  Position: position,
87717
87998
  PositionFullName: positionName,
87999
+ CeasedDate: "",
87718
88000
  AppointedDate: electedDate
87719
88001
  }
87720
88002
  ],
87721
- ElectedDate: electedDate,
88003
+ ElectedDate: mappedElectedDate,
87722
88004
  EmailAddress: email,
87723
- IsDirector: false,
87724
- PersonName,
88005
+ IsDirector: isDirectorFromRole,
88006
+ PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: personNameRoleId }),
87725
88007
  OfficerPosition: position,
88008
+ Position: position,
88009
+ PositionName: positionName,
87726
88010
  OfficerPositionName: positionName,
87727
88011
  OfficerPositionSpecified: true,
87728
88012
  PostalAddress,
87729
88013
  ResidentCanadian: residentCanadian,
87730
88014
  IsInvalid: false,
87731
- CurrentState: 5
88015
+ CurrentState: currentState,
88016
+ CurrentStateName: mappedCurrentStateName
87732
88017
  };
87733
88018
  case IRCurrentState.Ceased:
87734
88019
  return {
87735
88020
  OfficerPosition: 0,
87736
88021
  OfficerPositionSpecified: true,
87737
- OfficerId: null,
88022
+ OfficerId: matchingAdmin?.Id ?? "",
88023
+ CeaseDate: mappedCeaseDate,
88024
+ ElectedDate: mappedElectedDate,
87738
88025
  CeasedAppointedRoles: [
87739
88026
  {
87740
- State: 2,
87741
- StateName: "Changed",
88027
+ State: matchingAdmin && isCeaseAction ? IRCurrentState.Ceased : "",
88028
+ StateName: matchingAdmin && isCeaseAction ? "Ceased" : "",
87742
88029
  Position: position,
87743
88030
  PositionFullName: positionName,
87744
- CeasedDate: ceaseDate,
87745
- AppointedDate: electedDate,
87746
- AppointedDateSpecified: true,
87747
- EditAppointedDate: false
88031
+ CeasedDate: matchingAdmin && isCeaseAction ? ceaseDate : "",
88032
+ AppointedDate: ""
87748
88033
  }
87749
88034
  ],
87750
88035
  CurrentState: IRCurrentState.Ceased,
87751
- CurrentStateName: "Unchanged",
88036
+ CurrentStateName: mappedCurrentStateName,
87752
88037
  OfficerPositionName: positionName,
87753
- Id: aff._id,
87754
- RoleId: aff.role?.role_name ?? "",
87755
- IsDirector: false,
88038
+ Id: mappedId,
88039
+ RoleId: mappedRoleId,
88040
+ IsDirector: isDirectorFromRole,
87756
88041
  ResidentCanadian: residentCanadian,
87757
- PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: aff.role?.role_name ?? "", Position: null })
88042
+ PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: personNameRoleId, Position: null }),
88043
+ PostalAddress,
88044
+ EmailAddress: email
87758
88045
  };
87759
88046
  case IRCurrentState.Changed:
87760
88047
  return {
87761
88048
  OfficerPosition: 0,
87762
- OfficerId: null,
88049
+ OfficerId: matchingAdmin?.Id ?? "",
87763
88050
  CeasedAppointedRoles: [
87764
88051
  {
87765
- State: 1,
87766
- StateName: "Unchanged",
88052
+ State: matchingAdmin && isCeaseAction ? IRCurrentState.Ceased : "",
88053
+ StateName: matchingAdmin && isCeaseAction ? "Ceased" : "",
87767
88054
  Position: position,
87768
88055
  PositionFullName: positionName,
87769
- CeasedDate: ceaseDate,
87770
- AppointedDate: electedDate,
87771
- AppointedDateSpecified: true,
87772
- EditAppointedDate: false
88056
+ CeasedDate: matchingAdmin && isCeaseAction ? ceaseDate : "",
88057
+ AppointedDate: ""
87773
88058
  }
87774
88059
  ],
87775
- CurrentState: 1,
87776
- CurrentStateName: "Unchanged",
88060
+ CurrentState: currentState,
88061
+ CurrentStateName: mappedCurrentStateName,
87777
88062
  OfficerPositionName: positionName,
87778
- Id: aff._id,
87779
- RoleId: aff.role?.role_name ?? "",
87780
- IsDirector: false,
88063
+ Id: mappedId,
88064
+ RoleId: mappedRoleId,
88065
+ IsDirector: isDirectorFromRole,
87781
88066
  ResidentCanadian: residentCanadian,
87782
- PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: aff.role?.role_name ?? "", Position: position }),
87783
- CeaseDate: ceaseDate,
87784
- ElectedDate: electedDate,
88067
+ PersonName: __spreadProps(__spreadValues({}, PersonName), { RoleId: personNameRoleId, Position: position }),
88068
+ CeaseDate: mappedCeaseDate,
88069
+ ElectedDate: mappedElectedDate,
87785
88070
  CeasedDateSpecified: false,
87786
88071
  PostalAddress,
87787
88072
  EmailAddress: email,
@@ -87792,18 +88077,30 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87792
88077
  }
87793
88078
  return null;
87794
88079
  };
87795
- const { incomingAffiliations = [], outgoingAffiliations = [], editedAffiliations = [] } = task;
88080
+ const { incomingAffiliations = [], outgoingAffiliations = [] } = task;
87796
88081
  const isDirectorAff = (aff) => isPrincipalAffiliation2(aff) && aff.role.role_name === "Director";
87797
88082
  const isOfficerAff = (aff) => isPrincipalAffiliation2(aff) && aff.role.role_name === "Officer";
88083
+ const hasCurrentName = (deltaEntry) => {
88084
+ const currentName = deltaEntry?.currentName;
88085
+ return typeof currentName === "string" && currentName.trim().length > 0;
88086
+ };
88087
+ const incomingDirectors = incomingAffiliations.filter(isDirectorAff);
88088
+ const outgoingDirectors = outgoingAffiliations.filter(isDirectorAff);
88089
+ const addedDirectors = incomingDirectors.filter((a) => !hasCurrentName(deltaData.directors?.[a._id]));
88090
+ const editedDirectors = incomingDirectors.filter((a) => hasCurrentName(deltaData.directors?.[a._id]));
88091
+ const incomingOfficers = incomingAffiliations.filter(isOfficerAff);
88092
+ const outgoingOfficers = outgoingAffiliations.filter(isOfficerAff);
88093
+ const addedOfficers = incomingOfficers.filter((a) => !hasCurrentName(deltaData.officers?.[a._id]));
88094
+ const editedOfficers = incomingOfficers.filter((a) => hasCurrentName(deltaData.officers?.[a._id]));
87798
88095
  const ChangeDirectors = {
87799
- AddedDirectors: incomingAffiliations.filter(isDirectorAff).map((a) => buildPersonPayload(a, IRCurrentState.Added, deltaData.directors[a._id])),
87800
- CeasedDirectors: outgoingAffiliations.filter(isDirectorAff).map((a) => buildPersonPayload(a, IRCurrentState.Ceased, deltaData.directors[a._id])),
87801
- EditedDirectors: editedAffiliations.filter(isDirectorAff).map((a) => buildPersonPayload(a, IRCurrentState.Changed, deltaData.directors[a._id]))
88096
+ AddedDirectors: addedDirectors.map((a) => buildPersonPayload(a, IRCurrentState.Added, deltaData.directors?.[a._id])),
88097
+ CeasedDirectors: outgoingDirectors.map((a) => buildPersonPayload(a, IRCurrentState.Ceased, deltaData.directors?.[a._id])),
88098
+ EditedDirectors: editedDirectors.map((a) => buildPersonPayload(a, IRCurrentState.Changed, deltaData.directors?.[a._id]))
87802
88099
  };
87803
88100
  const ChangeOfficers = {
87804
- AddedOfficers: incomingAffiliations.filter(isOfficerAff).map((a) => buildPersonPayload(a, IRCurrentState.Added, deltaData.officers[a._id], true)),
87805
- CeasedOfficers: outgoingAffiliations.filter(isOfficerAff).map((a) => buildPersonPayload(a, IRCurrentState.Ceased, deltaData.officers[a._id], true)),
87806
- EditedOfficers: editedAffiliations.filter(isOfficerAff).map((a) => buildPersonPayload(a, IRCurrentState.Changed, deltaData.officers[a._id], true))
88101
+ AddedOfficers: addedOfficers.map((a) => buildPersonPayload(a, IRCurrentState.Added, deltaData.officers?.[a._id], true)),
88102
+ CeasedOfficers: outgoingOfficers.map((a) => buildPersonPayload(a, IRCurrentState.Ceased, deltaData.officers?.[a._id], true)),
88103
+ EditedOfficers: editedOfficers.map((a) => buildPersonPayload(a, IRCurrentState.Changed, deltaData.officers?.[a._id], true))
87807
88104
  };
87808
88105
  const cert = task._ext?.certified ?? {};
87809
88106
  const certEntityAddr = cert.address;
@@ -87813,7 +88110,8 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87813
88110
  const isOfficerCert = cert.type !== "Director";
87814
88111
  const certDeltaAddr = deltaData.certifiedBy?.address;
87815
88112
  const certStreetOnly = getAddressComponent(certEntityAddr, "Street Only");
87816
- const { StreetType: certStreetType, StreetDirection: certStreetDir } = parseStreetAddress(certStreetOnly);
88113
+ const { StreetName: certStreetName, StreetType: certStreetType, StreetDirection: certStreetDir } = parseStreetAddress(certStreetOnly);
88114
+ const isCanadianCertifierAddress = certifierCountry === "CA";
87817
88115
  const certifier = {
87818
88116
  PersonName: {
87819
88117
  FirstName: cert.firstName,
@@ -87828,13 +88126,10 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87828
88126
  AddressType: "standard",
87829
88127
  StreetNumberSuffix: "",
87830
88128
  StreetNumber: certDeltaAddr?.streetNumber ?? getAddressComponent(certEntityAddr, "Street Number Only") ?? "",
87831
- StreetName: (() => {
87832
- const { StreetName } = parseStreetAddress(certStreetOnly);
87833
- return certDeltaAddr?.streetName ?? StreetName ?? "";
87834
- })(),
87835
- StreetType: certDeltaAddr?.streetType ?? certStreetType ?? null,
87836
- StreetDirection: certDeltaAddr?.streetDirection ?? (certStreetDir ? certStreetDir : null),
87837
- UnitType: mapUnitTypeToEcore((certDeltaAddr?.unitType ?? "").toString()) ?? null,
88129
+ StreetName: isCanadianCertifierAddress ? certDeltaAddr?.streetName ?? certStreetName ?? "" : certStreetOnly ?? "",
88130
+ StreetType: isCanadianCertifierAddress ? certDeltaAddr?.streetType ?? certStreetType ?? null : null,
88131
+ StreetDirection: isCanadianCertifierAddress ? certDeltaAddr?.streetDirection ?? (certStreetDir ? certStreetDir : null) : null,
88132
+ UnitType: isCanadianCertifierAddress ? mapUnitTypeToEcore((certDeltaAddr?.unitType ?? "").toString()) ?? null : null,
87838
88133
  UnitNumber: certDeltaAddr?.unitNumber ?? getAddressComponent(certEntityAddr, "Suite/Apartment") ?? null,
87839
88134
  CityTown: certEntityAddr?.city ?? null,
87840
88135
  PostCode: certEntityAddr?.postal_zip ?? null,
@@ -87848,16 +88143,19 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87848
88143
  const regRegion = regCountry === "CA" ? CANProvinceToCode(regProvince) : regCountry === "US" ? USStateToCode(regProvince) : regProvince;
87849
88144
  const regDelta = deltaData.registeredOfficeAddress;
87850
88145
  const initType = ["CA", "US"].includes(regCountry) ? `address${regCountry}` : "addressINTL";
88146
+ const regStreetOnly = getAddressComponent(regOfficeEntityAddr, "Street Only");
88147
+ const { StreetName: regStreetName, StreetType: regStreetType, StreetDirection: regStreetDirection } = parseStreetAddress(regStreetOnly);
88148
+ const isCanadianRegisteredOffice = regCountry === "CA";
87851
88149
  const RegisteredHeadOfficeAddress = {
87852
88150
  AddressStandardLot: "standard",
87853
88151
  CareOf: getAddressComponent(regOfficeEntityAddr, "Attention") || regOfficeEntityAddr?.attention || null,
87854
- UnitType: mapUnitTypeToEcore((regDelta?.unitType ?? "").toString()) ?? null,
87855
- UnitNumber: regDelta.unitNumber ?? null,
87856
- StreetNumber: regDelta.streetNumber,
88152
+ UnitType: isCanadianRegisteredOffice ? mapUnitTypeToEcore((regDelta?.unitType ?? "").toString()) ?? null : null,
88153
+ UnitNumber: regDelta?.unitNumber ?? null,
88154
+ StreetNumber: regDelta?.streetNumber,
87857
88155
  StreetNumberSuffix: "",
87858
- StreetName: regDelta.streetName,
87859
- StreetType: regDelta.streetType ?? null,
87860
- StreetDirection: regDelta.streetDirection ?? null,
88156
+ StreetName: isCanadianRegisteredOffice ? regDelta?.streetName ?? regStreetName ?? "" : regStreetOnly ?? "",
88157
+ StreetType: isCanadianRegisteredOffice ? regDelta?.streetType ?? regStreetType ?? null : null,
88158
+ StreetDirection: isCanadianRegisteredOffice ? regDelta?.streetDirection ?? regStreetDirection ?? null : null,
87861
88159
  StreetAddressContinued: getAddressComponent(regOfficeEntityAddr, "Suite/Apartment") ?? "",
87862
88160
  CityTown: regOfficeEntityAddr?.city ?? null,
87863
88161
  Region: regRegion,
@@ -87868,11 +88166,17 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87868
88166
  };
87869
88167
  const authorizationType = ["Director", "Officer"].includes(cert.type ?? "") ? AuthorizationType.DirectorOrOfficer : AuthorizationType.Other;
87870
88168
  const isOther = authorizationType === AuthorizationType.Other;
88169
+ const contactAffiliation = deltaData.contactUid ? task.entity.affiliations?.find((aff) => aff._id === deltaData.contactUid) : void 0;
88170
+ const ContactInformation = contactAffiliation ? OntarioUpdateMaintainFormHelper.generateContact(contactAffiliation) : null;
87871
88171
  const filingFormKey = getFilingFormKey(task);
87872
88172
  const filingFormType = getFilingFormType(task);
87873
88173
  const eCoreFilingFormType = getInnerECoreFilingFormType(task);
87874
88174
  const isAnnualReturn = isAnnualReturnTask(task);
87875
88175
  const annualReturnYear = isAnnualReturn ? (new Date(task._ext?._reference_date).getFullYear() || (/* @__PURE__ */ new Date()).getFullYear()).toString() : void 0;
88176
+ const officialBusinessEmail = regOfficeEntityAddr?.communications?.find((c) => c.type === "Business Email")?.value;
88177
+ const OfficialEmail = officialBusinessEmail ? { Email: officialBusinessEmail, ConfirmEmail: officialBusinessEmail } : corporationInfo?.CurrentData?.OfficialEmail ?? null;
88178
+ const naics = task.entity._profile?.naics;
88179
+ const PrimaryBusinessActivity = naics?.code ? { NAICSCode: naics.code, PrimaryActivity: naics.description } : corporationInfo?.CurrentData?.PrimaryBusinessActivity ?? null;
87876
88180
  return {
87877
88181
  Jurisdiction: "ON",
87878
88182
  FilingFormType: filingFormType,
@@ -87889,10 +88193,12 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87889
88193
  MiddleName: cert.middleName
87890
88194
  },
87891
88195
  CurrentData: __spreadProps(__spreadValues({
87892
- Reference: deltaData.referenceNumbers?.referenceNumber ?? null,
87893
- Docket: deltaData.referenceNumbers?.docketNumber ?? null,
88196
+ Reference: deltaData.referenceNumbers?.referenceNumber ?? corporationInfo?.CurrentData?.Reference ?? null,
88197
+ Docket: deltaData.referenceNumbers?.docketNumber ?? corporationInfo?.CurrentData?.Docket ?? null,
87894
88198
  EntityIdentifier: Number(task.entity._profile.corp_number)
87895
88199
  }, isAnnualReturn ? { AnnualReturnYear: annualReturnYear } : {}), {
88200
+ OfficialEmail,
88201
+ PrimaryBusinessActivity,
87896
88202
  ChangeCertification: {
87897
88203
  DirectorOfficerCertifier: !isOther ? __spreadProps(__spreadValues({}, certifier), {
87898
88204
  directorOrOfficer: isOfficerCert ? "officer" : "director"
@@ -87900,20 +88206,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87900
88206
  IndividualCertifier: isOther ? certifier : null,
87901
88207
  AuthorizationType: authorizationType
87902
88208
  },
87903
- ContactInformation: {
87904
- EmailAddress: "noreply@dyedurham.com",
87905
- PersonName: {
87906
- FirstName: "test",
87907
- LastName: "test",
87908
- MiddleName: "test"
87909
- },
87910
- PhoneNumber: {
87911
- AreaCode: "100",
87912
- CountryTelephoneCode: "0000000",
87913
- Extension: "",
87914
- TelephoneNumber: "0000000"
87915
- }
87916
- },
88209
+ ContactInformation,
87917
88210
  RegisteredHeadOfficeAddress,
87918
88211
  ChangeDirectors,
87919
88212
  ChangeOfficers
@@ -87932,6 +88225,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
87932
88225
  init_address_utils();
87933
88226
  init_common_models();
87934
88227
  init_initial_return_enums();
88228
+ init_ontario_update_maintain_helper();
87935
88229
  init_InitialReturnMapping();
87936
88230
  }
87937
88231
  });
@@ -88220,6 +88514,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
88220
88514
  isOntarioTask = isOntarioTask;
88221
88515
  ontario = viewChild(OntarioComponent);
88222
88516
  federal = viewChild(FederalComponent);
88517
+ currentData = null;
88223
88518
  _signature = computed(() => {
88224
88519
  const task = this.task();
88225
88520
  const config2 = this.config();
@@ -88308,33 +88603,44 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
88308
88603
  this.translate.use(this.language() || "en");
88309
88604
  }
88310
88605
  });
88311
- effect(() => {
88606
+ effect(() => __async(this, null, function* () {
88312
88607
  const task = this.task();
88313
88608
  const deltaData = task?.deltaData;
88314
88609
  if (!task) {
88315
88610
  return;
88316
88611
  }
88317
88612
  if (isUpdateMaintain(task) && isOntarioTask(task)) {
88613
+ yield this.getCurrentData();
88318
88614
  const serviceOrderId = deltaData?.serviceOrderId;
88319
88615
  if (serviceOrderId) {
88320
88616
  this.defineInitialStep();
88321
88617
  }
88322
88618
  if (serviceOrderId && !this.dataWasChanged()) {
88323
88619
  this.serviceOrderId = serviceOrderId;
88324
- } else {
88325
- this.isLoading.set(true);
88326
- this.getInitialReturnServiceId().then((id) => __async(this, null, function* () {
88327
- this.serviceOrderId = id;
88328
- const signature = this._signature();
88329
- if (signature) {
88330
- yield this.updateMaintainService.submitData(signature, id, this.validateOptions());
88331
- const data = yield this.updateMaintainService.getCurrentData(signature, id, this.validateOptions());
88332
- this.prevData.set(corporationInfoToPersonnelDeltaData(data));
88333
- this.isLoading.set(false);
88334
- }
88335
- }));
88336
88620
  }
88337
88621
  }
88622
+ }));
88623
+ }
88624
+ getCurrentData() {
88625
+ return __async(this, null, function* () {
88626
+ const signature = this._signature();
88627
+ if (!signature) {
88628
+ return;
88629
+ }
88630
+ this.isLoading.set(true);
88631
+ this.errors.set([]);
88632
+ try {
88633
+ if (!this.serviceOrderId) {
88634
+ this.serviceOrderId = yield this.getInitialReturnServiceId();
88635
+ yield this.updateMaintainService.submitData(signature, this.serviceOrderId, this.validateOptions());
88636
+ this.currentData = yield this.updateMaintainService.getCurrentData(signature, this.serviceOrderId, this.validateOptions());
88637
+ this.prevData.set(corporationInfoToPersonnelDeltaData(this.currentData));
88638
+ }
88639
+ } catch (error) {
88640
+ this.handleCatchError(error);
88641
+ } finally {
88642
+ this.isLoading.set(false);
88643
+ }
88338
88644
  });
88339
88645
  }
88340
88646
  onOntarioFormationValidate(deltaData) {
@@ -88595,7 +88901,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
88595
88901
  const signature = this._signature();
88596
88902
  if (signature) {
88597
88903
  try {
88598
- const requestBody = buildOntarioUpdateMaintainValidationRequest(task, deltaData, this.serviceOrderId);
88904
+ const requestBody = buildOntarioUpdateMaintainValidationRequest(task, deltaData, this.serviceOrderId, this.currentData);
88599
88905
  const response = yield this.updateMaintainService.submitInitialReturnValidationToECore(signature, requestBody, this.validateOptions());
88600
88906
  if (this.hasResponseErrors(response))
88601
88907
  return;
@@ -88631,8 +88937,8 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
88631
88937
  }
88632
88938
  onEditClick() {
88633
88939
  if (isUpdateMaintain(this.task())) {
88634
- this.activeStep.set(Step.Validate);
88635
- return;
88940
+ this.serviceOrderId = "";
88941
+ void this.getCurrentData();
88636
88942
  }
88637
88943
  this.activeStep.set(Step.Validate);
88638
88944
  }
@@ -88656,10 +88962,23 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
88656
88962
  */
88657
88963
  handleCatchError(response) {
88658
88964
  console.error(response);
88659
- const errors = JSON.parse(JSON.stringify(response))?.validateResult?.["Errors"];
88965
+ if (response instanceof Error) {
88966
+ this.errors.set([response.message]);
88967
+ return;
88968
+ }
88969
+ let parsed = response;
88970
+ try {
88971
+ parsed = JSON.parse(JSON.stringify(response));
88972
+ } catch {
88973
+ parsed = void 0;
88974
+ }
88975
+ const errors = parsed?.validateResult?.["Errors"];
88660
88976
  if (errors?.length) {
88661
88977
  this.errors.set(this.parseError(errors));
88978
+ return;
88662
88979
  }
88980
+ const fallbackMessage = parsed?.message || (typeof parsed === "string" ? parsed : "") || "An unexpected error occurred. Please try again.";
88981
+ this.errors.set([fallbackMessage]);
88663
88982
  }
88664
88983
  onClose() {
88665
88984
  const task = this.task();
@@ -88738,7 +89057,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
88738
89057
  if (!serviceOrderId) {
88739
89058
  return void 0;
88740
89059
  }
88741
- return buildOntarioUpdateMaintainValidationRequest(task, deltaData, serviceOrderId);
89060
+ return buildOntarioUpdateMaintainValidationRequest(task, deltaData, serviceOrderId, this.currentData);
88742
89061
  }
88743
89062
  if (isUpdateMaintain(task)) {
88744
89063
  return buildFederalUpdateMaintainValidationRequest(deltaData, task);
@@ -88887,7 +89206,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
88887
89206
  }], () => [], null);
88888
89207
  })();
88889
89208
  (() => {
88890
- (typeof ngDevMode === "undefined" || ngDevMode) && \u0275setClassDebugInfo(FilingComponent, { className: "FilingComponent", filePath: "src/app/components/filing/filing.component.ts", lineNumber: 83 });
89209
+ (typeof ngDevMode === "undefined" || ngDevMode) && \u0275setClassDebugInfo(FilingComponent, { className: "FilingComponent", filePath: "src/app/components/filing/filing.component.ts", lineNumber: 73 });
88891
89210
  })();
88892
89211
  }
88893
89212
  });
@@ -93616,132 +93935,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
93616
93935
  "Submit request": "Soumettre la demande",
93617
93936
  "UI Mode": "Mode d'interface",
93618
93937
  "UI mode": "Mode d'interface",
93619
- North: "Nord",
93620
- South: "Sud",
93621
- East: "Est",
93622
- West: "Ouest",
93623
- Northeast: "Nord-Est",
93624
- Northwest: "Nord-Ouest",
93625
- Southeast: "Sud-Est",
93626
- Southwest: "Sud-Ouest",
93627
93938
  None: "Aucun",
93628
- Limited: "Limit\xE9e",
93629
- Ltd: "Lt\xE9e",
93630
- Incorporated: "Incorpor\xE9e",
93631
- Inc: "Inc.",
93632
- Corporation: "Corporation",
93633
- Corp: "Corp.",
93634
- Abbey: "Abbaye",
93635
- Acres: "Acres",
93636
- Alley: "Ruelle",
93637
- Avenue: "Avenue",
93638
- Bay: "Baie",
93639
- Beach: "Plage",
93640
- Bend: "Courbe",
93641
- Boulevard: "Boulevard",
93642
- "By-pass": "Contournement",
93643
- Byway: "Chemin secondaire",
93644
- Campus: "Campus",
93645
- Cape: "Cap",
93646
- Centre: "Centre",
93647
- Chase: "All\xE9e",
93648
- Circle: "Cercle",
93649
- Circuit: "Circuit",
93650
- Close: "Fermer",
93651
- Common: "Terrain commun",
93652
- Concession: "Concession",
93653
- Corners: "Carrefour",
93654
- Court: "Cour",
93655
- Cove: "Anse",
93656
- Crescent: "Croissant",
93657
- Crossing: "Croisement",
93658
- "Cul-de-sac": "Cul-de-sac",
93659
- Dale: "Vall\xE9e",
93660
- Dell: "Vallon",
93661
- Diversion: "D\xE9viation",
93662
- Downs: "Collines",
93663
- Drive: "All\xE9e priv\xE9e",
93664
- Farm: "Ferme",
93665
- Field: "Champ",
93666
- Forest: "For\xEAt",
93667
- Freeway: "Autoroute",
93668
- Front: "Front",
93669
- Gardens: "Jardins",
93670
- Gate: "Portail",
93671
- Glade: "Clairi\xE8re",
93672
- Glen: "Vallon bois\xE9",
93673
- Green: "Vert",
93674
- Grounds: "Terrain",
93675
- Grove: "Bosquet",
93676
- Harbour: "Port",
93677
- Heath: "Lande",
93678
- Heights: "Hauteurs",
93679
- Highlands: "Hautes-terres",
93680
- Highway: "Route",
93681
- Hill: "Colline",
93682
- Hollow: "Creux",
93683
- Inlet: "Anse",
93684
- Island: "\xCEle",
93685
- Key: "Quai",
93686
- Knoll: "Monticule",
93687
- Landing: "D\xE9barcad\xE8re",
93688
- Lane: "Voie",
93689
- Limits: "Limites",
93690
- Line: "Ligne",
93691
- Link: "Liaison",
93692
- Lookout: "Belv\xE9d\xE8re",
93693
- Loop: "Boucle",
93694
- Mall: "Mail",
93695
- Manor: "Manoir",
93696
- Maze: "Labyrinthe",
93697
- Meadow: "Prairie",
93698
- Mews: "Ruelle",
93699
- Moor: "Lande",
93700
- Mount: "Mont",
93701
- Mountain: "Montagne",
93702
- Orchard: "Verger",
93703
- Parade: "Promenade",
93704
- Park: "Parc",
93705
- Parkway: "Promenade parc",
93706
- Passage: "Passage",
93707
- Path: "Sentier",
93708
- Pathway: "Sentier",
93709
- Pines: "Pins",
93710
- Place: "Place",
93711
- Plateau: "Plateau",
93712
- Plaza: "Plaza",
93713
- Point: "Pointe",
93714
- Port: "Port",
93715
- Private: "Priv\xE9e",
93716
- Promenade: "Promenade",
93717
- Quay: "Quai",
93718
- Ramp: "Rampe",
93719
- Ridge: "Cr\xEAte",
93720
- Rise: "Mont\xE9e",
93721
- Road: "Route",
93722
- Route: "Route",
93723
- Row: "Rang\xE9e",
93724
- Run: "Ruisseau",
93725
- Square: "Square",
93726
- Street: "Rue",
93727
- Subdivision: "Subdivision",
93728
- Terrace: "Terrasse",
93729
- Thicket: "Hallier",
93730
- Towers: "Tours",
93731
- Townline: "Limite de canton",
93732
- Trail: "Sentier",
93733
- Turnabout: "Rond-point",
93734
- Vale: "Val",
93735
- Via: "Via",
93736
- View: "Vue",
93737
- Village: "Village",
93738
- Villas: "Villas",
93739
- Vista: "Panorama",
93740
- Walk: "Promenade",
93741
- Way: "Voie",
93742
- Wharf: "Quai",
93743
- Wood: "Bois",
93744
- Wynd: "Ruelle",
93745
93939
  "Save Changes": "Enregistrer les modifications",
93746
93940
  "Supporting Documents": "Documents justificatifs",
93747
93941
  "Upload supporting documents, e.g. Consents": "T\xE9l\xE9verser des documents justificatifs, p. ex. des consentements",