Skip to content

Commit 1b938b2

Browse files
authored
Emad/identity confirm (#1431)
# Description This PR includes the following proposed change(s): SPDBT-2978](https://jag.gov.bc.ca/jira/browse/SPDBT-2978 - refactored `CommitApplicationAsync` - using spd_origin, defining spd_Identityconfirmed.
1 parent 80f8d92 commit 1b938b2

File tree

10 files changed

+36
-20
lines changed

10 files changed

+36
-20
lines changed

src/Spd.Manager.Licence/BizLicAppManager.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ public async Task<BizLicAppCommandResponse> Handle(BizLicAppSubmitCommand cmd, C
124124
//move files from transient bucket to main bucket when app status changed to Submitted.
125125
await MoveFilesAsync((Guid)cmd.BizLicAppUpsertRequest.LicenceAppId, cancellationToken);
126126

127-
decimal cost = await CommitApplicationAsync(cmd.BizLicAppUpsertRequest, cmd.BizLicAppUpsertRequest.LicenceAppId.Value, cancellationToken, false, cmd.BizLicAppUpsertRequest.SoleProprietorSWLAppId);
127+
decimal cost = await CommitApplicationAsync(cmd.BizLicAppUpsertRequest, cmd.BizLicAppUpsertRequest.LicenceAppId.Value, cancellationToken,
128+
HasSwl90DayLicence: false,
129+
cmd.BizLicAppUpsertRequest.SoleProprietorSWLAppId);
128130
return new BizLicAppCommandResponse { LicenceAppId = response.LicenceAppId, Cost = cost };
129131
}
130132

src/Spd.Manager.Licence/ControllingMemberCrcAppManager.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ await ValidateInviteIdAsync(cmd.ControllingMemberCrcAppSubmitRequest.InviteId,
160160
await UploadNewDocsAsync(request.DocumentExpiredInfos, cmd.LicAppFileInfos, response.ControllingMemberAppId, response.ContactId, null, null, null, null, null, ct);
161161

162162
//commit app
163-
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.PaymentPending, null, ct);
163+
await CommitApplicationAsync(new LicenceAppBase() { ApplicationTypeCode = request.ApplicationTypeCode, ApplicationOriginTypeCode = request.ApplicationOriginTypeCode}, response.ControllingMemberAppId, ct);
164164
await DeactiveInviteAsync(cmd.ControllingMemberCrcAppSubmitRequest.InviteId, ct);
165165

166166
return _mapper.Map<ControllingMemberCrcAppCommandResponse>(response);
@@ -187,10 +187,11 @@ await UpdateDocumentsAsync(
187187
public async Task<ControllingMemberCrcAppCommandResponse> Handle(ControllingMemberCrcSubmitCommand cmd, CancellationToken ct)
188188
{
189189
ValidateFilesForNewAppAuthenticated(cmd);
190+
var request = cmd.ControllingMemberCrcUpsertRequest;
190191
var response = await this.Handle((ControllingMemberCrcUpsertCommand)cmd, ct);
191192
//move files from transient bucket to main bucket when app status changed to PaymentPending.
192193
await MoveFilesAsync(response.ControllingMemberAppId, ct);
193-
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.PaymentPending, null, ct);
194+
await CommitApplicationAsync(new LicenceAppBase() { ApplicationTypeCode = request.ApplicationTypeCode, ApplicationOriginTypeCode = request.ApplicationOriginTypeCode }, response.ControllingMemberAppId, ct);
194195
await DeactiveInviteAsync(cmd.ControllingMemberCrcAppUpsertRequest.InviteId, ct);
195196
return new ControllingMemberCrcAppCommandResponse { ControllingMemberAppId = response.ControllingMemberAppId };
196197
}

src/Spd.Manager.Licence/LicenceAppManagerBase.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,25 @@ protected async Task<decimal> CommitApplicationAsync(LicenceAppBase licAppBase,
5151
HasValidSwl90DayLicence = HasSwl90DayLicence
5252
}, ct);
5353
LicenceFeeResp? licenceFee = price?.LicenceFees.FirstOrDefault();
54+
55+
//applications with portal origin type are considered authenticated, otherwise not.
56+
bool IsAuthenticated = licAppBase.ApplicationOriginTypeCode == Shared.ApplicationOriginTypeCode.Portal ? true : false;
57+
bool isNewOrRenewal = licAppBase.ApplicationTypeCode == Shared.ApplicationTypeCode.New || licAppBase.ApplicationTypeCode == Shared.ApplicationTypeCode.Renewal;
58+
ApplicationStatusEnum status;
59+
5460
if (licenceFee == null || licenceFee.Amount == 0)
55-
{
56-
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.Submitted, null, ct);
57-
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.Submitted, null, ct);
58-
}
61+
status = isNewOrRenewal && !IsAuthenticated ? ApplicationStatusEnum.ApplicantVerification : ApplicationStatusEnum.Submitted;
5962
else
63+
status = ApplicationStatusEnum.PaymentPending;
64+
65+
// Commit the companion application if it exists
66+
//companionAppId is the swl for sole proprietor which the business would pay for it, therefore the licence fee should be null here.
67+
if (companionAppId != null)
6068
{
61-
//companionAppId is the swl for sole proprietor which the business would pay for it, therefore the licence fee should be null here.
62-
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.PaymentPending, null, ct);
63-
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.PaymentPending, licenceFee.Amount, ct);
69+
await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.PaymentPending, null, ct);
6470
}
71+
// Commit the main licence application
72+
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, status, licenceFee?.Amount, ct);
6573

6674
return licenceFee?.Amount ?? 0;
6775
}

src/Spd.Manager.Licence/PermitAppManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public async Task<PermitAppCommandResponse> Handle(PermitAppRenewCommand cmd, Ca
191191
await ValidateFilesForRenewUpdateAppAsync(cmd.LicenceAnonymousRequest,
192192
cmd.LicAppFileInfos.ToList(),
193193
cancellationToken);
194-
194+
195195
CreateLicenceApplicationCmd createApp = _mapper.Map<CreateLicenceApplicationCmd>(request);
196196
createApp.UploadedDocumentEnums = GetUploadedDocumentEnums(cmd.LicAppFileInfos, existingFiles);
197197
LicenceApplicationCmdResp response = await _personLicAppRepository.CreateLicenceApplicationAsync(createApp, cancellationToken);

src/Spd.Resource.Repository/BizLicApplication/Mappings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public Mappings()
3535
.ForMember(d => d.spd_declaration, opt => opt.MapFrom(s => s.AgreeToCompleteAndAccurate))
3636
.ForMember(d => d.spd_consent, opt => opt.MapFrom(s => s.AgreeToCompleteAndAccurate))
3737
.ForMember(d => d.spd_declarationdate, opt => opt.MapFrom(s => GetDeclarationDate(s)))
38+
.ForMember(d => d.spd_identityconfirmed, opt => opt.MapFrom(s => SharedMappingFuncs.GetIdentityConfirmed(s.ApplicationOriginTypeCode, s.ApplicationTypeCode)))
3839
.ReverseMap()
3940
.ForMember(d => d.WorkerLicenceTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetServiceType(s._spd_servicetypeid_value)))
4041
.ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum<ApplicationOriginOptionSet, ApplicationOriginTypeCode>(s.spd_origin)))

src/Spd.Resource.Repository/ControllingMemberCrcApplication/Mappings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public Mappings()
9090
.ForMember(d => d.spd_uploadeddocuments, opt => opt.MapFrom(s => SharedMappingFuncs.GetUploadedDocumentOptionSets(s.UploadedDocumentEnums)))
9191
.ForMember(d => d.spd_criminalchargesconvictionsdetails, opt => opt.MapFrom(s => s.CriminalHistoryDetail))
9292
.ForMember(d => d.spd_portalmodifiedon, opt => opt.MapFrom(s => DateTimeOffset.UtcNow))
93+
.ForMember(d => d.spd_identityconfirmed, opt => opt.MapFrom(s => SharedMappingFuncs.GetIdentityConfirmed(s.ApplicationOriginTypeCode, s.ApplicationTypeCode)))
9394
.ReverseMap()
9495
.ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.spd_emailaddress1))
9596
.ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum<ApplicationOriginOptionSet, ApplicationOriginTypeCode>(s.spd_origin)))

src/Spd.Resource.Repository/LicApp/LicAppRepository.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,11 @@ public async Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid
2424
if (app == null)
2525
throw new ApiException(HttpStatusCode.BadRequest, "Invalid ApplicationId");
2626

27+
app.statuscode = (int)Enum.Parse<ApplicationStatusOptionSet>(status.ToString());
28+
2729
if (status == ApplicationStatusEnum.Submitted)
28-
{
29-
app.statuscode = (int)ApplicationStatusOptionSet.Submitted;
3030
app.statecode = DynamicsConstants.StateCode_Inactive;
31-
}
32-
else
33-
{
34-
app.statuscode = (int)Enum.Parse<ApplicationStatusOptionSet>(status.ToString());
35-
}
36-
31+
3732
app.spd_submittedon = DateTimeOffset.Now;
3833
app.spd_portalmodifiedon = DateTimeOffset.Now;
3934
if (price is > 0)

src/Spd.Resource.Repository/PersonLicApplication/Mappings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public Mappings()
131131
.ForMember(d => d.spd_uploadeddocuments, opt => opt.MapFrom(s => SharedMappingFuncs.GetUploadedDocumentOptionSets(s.UploadedDocumentEnums)))
132132
.ForMember(d => d.spd_criminalchargesconvictionsdetails, opt => opt.MapFrom(s => s.CriminalChargeDescription))
133133
.ForMember(d => d.spd_portalmodifiedon, opt => opt.MapFrom(s => DateTimeOffset.UtcNow))
134+
.ForMember(d => d.spd_identityconfirmed, opt => opt.MapFrom(s => SharedMappingFuncs.GetIdentityConfirmed(s.ApplicationOriginTypeCode, s.ApplicationTypeCode)))
134135
.ReverseMap()
135136
.ForMember(d => d.ContactEmailAddress, opt => opt.Ignore())
136137
.ForMember(d => d.DateOfBirth, opt => opt.Ignore())

src/Spd.Resource.Repository/SharedMappingFuncs.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,12 @@ internal static IEnumerable<UploadedDocumentEnum> GetUploadedDocumentEnums(strin
205205
return Enum.Parse<ContactRoleCode>(
206206
DynamicsContextLookupHelpers.RoleGuidDictionary.FirstOrDefault(x => x.Value == role.spd_roleid).Key);
207207
}
208+
internal static bool GetIdentityConfirmed(ApplicationOriginTypeCode? origin, ApplicationTypeEnum type)
209+
{
210+
bool isNotPortal = origin != ApplicationOriginTypeCode.Portal;
211+
bool isNewOrRenewal = type == ApplicationTypeEnum.New ||
212+
type == ApplicationTypeEnum.Renewal;
213+
214+
return !(isNotPortal && isNewOrRenewal);
215+
}
208216
}

src/Spd.Resource.Repository/SharedRepositoryFuncs.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,4 @@ public static void LinkTeam(DynamicsContext _context, string teamGuidStr, spd_ap
6262
).ToList();
6363
return matchingAliases;
6464
}
65-
6665
}

0 commit comments

Comments
 (0)