Skip to content

Commit

Permalink
Emad/identity confirm (#1431)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
esdd1995 authored Sep 24, 2024
1 parent 80f8d92 commit 1b938b2
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/Spd.Manager.Licence/BizLicAppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ public async Task<BizLicAppCommandResponse> Handle(BizLicAppSubmitCommand cmd, C
//move files from transient bucket to main bucket when app status changed to Submitted.
await MoveFilesAsync((Guid)cmd.BizLicAppUpsertRequest.LicenceAppId, cancellationToken);

decimal cost = await CommitApplicationAsync(cmd.BizLicAppUpsertRequest, cmd.BizLicAppUpsertRequest.LicenceAppId.Value, cancellationToken, false, cmd.BizLicAppUpsertRequest.SoleProprietorSWLAppId);
decimal cost = await CommitApplicationAsync(cmd.BizLicAppUpsertRequest, cmd.BizLicAppUpsertRequest.LicenceAppId.Value, cancellationToken,
HasSwl90DayLicence: false,
cmd.BizLicAppUpsertRequest.SoleProprietorSWLAppId);
return new BizLicAppCommandResponse { LicenceAppId = response.LicenceAppId, Cost = cost };
}

Expand Down
5 changes: 3 additions & 2 deletions src/Spd.Manager.Licence/ControllingMemberCrcAppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ await ValidateInviteIdAsync(cmd.ControllingMemberCrcAppSubmitRequest.InviteId,
await UploadNewDocsAsync(request.DocumentExpiredInfos, cmd.LicAppFileInfos, response.ControllingMemberAppId, response.ContactId, null, null, null, null, null, ct);

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

return _mapper.Map<ControllingMemberCrcAppCommandResponse>(response);
Expand All @@ -187,10 +187,11 @@ await UpdateDocumentsAsync(
public async Task<ControllingMemberCrcAppCommandResponse> Handle(ControllingMemberCrcSubmitCommand cmd, CancellationToken ct)
{
ValidateFilesForNewAppAuthenticated(cmd);
var request = cmd.ControllingMemberCrcUpsertRequest;
var response = await this.Handle((ControllingMemberCrcUpsertCommand)cmd, ct);
//move files from transient bucket to main bucket when app status changed to PaymentPending.
await MoveFilesAsync(response.ControllingMemberAppId, ct);
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.PaymentPending, null, ct);
await CommitApplicationAsync(new LicenceAppBase() { ApplicationTypeCode = request.ApplicationTypeCode, ApplicationOriginTypeCode = request.ApplicationOriginTypeCode }, response.ControllingMemberAppId, ct);
await DeactiveInviteAsync(cmd.ControllingMemberCrcAppUpsertRequest.InviteId, ct);
return new ControllingMemberCrcAppCommandResponse { ControllingMemberAppId = response.ControllingMemberAppId };
}
Expand Down
22 changes: 15 additions & 7 deletions src/Spd.Manager.Licence/LicenceAppManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,25 @@ protected async Task<decimal> CommitApplicationAsync(LicenceAppBase licAppBase,
HasValidSwl90DayLicence = HasSwl90DayLicence
}, ct);
LicenceFeeResp? licenceFee = price?.LicenceFees.FirstOrDefault();

//applications with portal origin type are considered authenticated, otherwise not.
bool IsAuthenticated = licAppBase.ApplicationOriginTypeCode == Shared.ApplicationOriginTypeCode.Portal ? true : false;
bool isNewOrRenewal = licAppBase.ApplicationTypeCode == Shared.ApplicationTypeCode.New || licAppBase.ApplicationTypeCode == Shared.ApplicationTypeCode.Renewal;
ApplicationStatusEnum status;

if (licenceFee == null || licenceFee.Amount == 0)
{
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.Submitted, null, ct);
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.Submitted, null, ct);
}
status = isNewOrRenewal && !IsAuthenticated ? ApplicationStatusEnum.ApplicantVerification : ApplicationStatusEnum.Submitted;
else
status = ApplicationStatusEnum.PaymentPending;

// Commit the companion application if it exists
//companionAppId is the swl for sole proprietor which the business would pay for it, therefore the licence fee should be null here.
if (companionAppId != null)
{
//companionAppId is the swl for sole proprietor which the business would pay for it, therefore the licence fee should be null here.
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.PaymentPending, null, ct);
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.PaymentPending, licenceFee.Amount, ct);
await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.PaymentPending, null, ct);
}
// Commit the main licence application
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, status, licenceFee?.Amount, ct);

return licenceFee?.Amount ?? 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Spd.Manager.Licence/PermitAppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public async Task<PermitAppCommandResponse> Handle(PermitAppRenewCommand cmd, Ca
await ValidateFilesForRenewUpdateAppAsync(cmd.LicenceAnonymousRequest,
cmd.LicAppFileInfos.ToList(),
cancellationToken);

CreateLicenceApplicationCmd createApp = _mapper.Map<CreateLicenceApplicationCmd>(request);
createApp.UploadedDocumentEnums = GetUploadedDocumentEnums(cmd.LicAppFileInfos, existingFiles);
LicenceApplicationCmdResp response = await _personLicAppRepository.CreateLicenceApplicationAsync(createApp, cancellationToken);
Expand Down
1 change: 1 addition & 0 deletions src/Spd.Resource.Repository/BizLicApplication/Mappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public Mappings()
.ForMember(d => d.spd_declaration, opt => opt.MapFrom(s => s.AgreeToCompleteAndAccurate))
.ForMember(d => d.spd_consent, opt => opt.MapFrom(s => s.AgreeToCompleteAndAccurate))
.ForMember(d => d.spd_declarationdate, opt => opt.MapFrom(s => GetDeclarationDate(s)))
.ForMember(d => d.spd_identityconfirmed, opt => opt.MapFrom(s => SharedMappingFuncs.GetIdentityConfirmed(s.ApplicationOriginTypeCode, s.ApplicationTypeCode)))
.ReverseMap()
.ForMember(d => d.WorkerLicenceTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetServiceType(s._spd_servicetypeid_value)))
.ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum<ApplicationOriginOptionSet, ApplicationOriginTypeCode>(s.spd_origin)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public Mappings()
.ForMember(d => d.spd_uploadeddocuments, opt => opt.MapFrom(s => SharedMappingFuncs.GetUploadedDocumentOptionSets(s.UploadedDocumentEnums)))
.ForMember(d => d.spd_criminalchargesconvictionsdetails, opt => opt.MapFrom(s => s.CriminalHistoryDetail))
.ForMember(d => d.spd_portalmodifiedon, opt => opt.MapFrom(s => DateTimeOffset.UtcNow))
.ForMember(d => d.spd_identityconfirmed, opt => opt.MapFrom(s => SharedMappingFuncs.GetIdentityConfirmed(s.ApplicationOriginTypeCode, s.ApplicationTypeCode)))
.ReverseMap()
.ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.spd_emailaddress1))
.ForMember(d => d.ApplicationOriginTypeCode, opt => opt.MapFrom(s => SharedMappingFuncs.GetEnum<ApplicationOriginOptionSet, ApplicationOriginTypeCode>(s.spd_origin)))
Expand Down
11 changes: 3 additions & 8 deletions src/Spd.Resource.Repository/LicApp/LicAppRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ public async Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid
if (app == null)
throw new ApiException(HttpStatusCode.BadRequest, "Invalid ApplicationId");

app.statuscode = (int)Enum.Parse<ApplicationStatusOptionSet>(status.ToString());

if (status == ApplicationStatusEnum.Submitted)
{
app.statuscode = (int)ApplicationStatusOptionSet.Submitted;
app.statecode = DynamicsConstants.StateCode_Inactive;
}
else
{
app.statuscode = (int)Enum.Parse<ApplicationStatusOptionSet>(status.ToString());
}


app.spd_submittedon = DateTimeOffset.Now;
app.spd_portalmodifiedon = DateTimeOffset.Now;
if (price is > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public Mappings()
.ForMember(d => d.spd_uploadeddocuments, opt => opt.MapFrom(s => SharedMappingFuncs.GetUploadedDocumentOptionSets(s.UploadedDocumentEnums)))
.ForMember(d => d.spd_criminalchargesconvictionsdetails, opt => opt.MapFrom(s => s.CriminalChargeDescription))
.ForMember(d => d.spd_portalmodifiedon, opt => opt.MapFrom(s => DateTimeOffset.UtcNow))
.ForMember(d => d.spd_identityconfirmed, opt => opt.MapFrom(s => SharedMappingFuncs.GetIdentityConfirmed(s.ApplicationOriginTypeCode, s.ApplicationTypeCode)))
.ReverseMap()
.ForMember(d => d.ContactEmailAddress, opt => opt.Ignore())
.ForMember(d => d.DateOfBirth, opt => opt.Ignore())
Expand Down
8 changes: 8 additions & 0 deletions src/Spd.Resource.Repository/SharedMappingFuncs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,12 @@ internal static IEnumerable<UploadedDocumentEnum> GetUploadedDocumentEnums(strin
return Enum.Parse<ContactRoleCode>(
DynamicsContextLookupHelpers.RoleGuidDictionary.FirstOrDefault(x => x.Value == role.spd_roleid).Key);
}
internal static bool GetIdentityConfirmed(ApplicationOriginTypeCode? origin, ApplicationTypeEnum type)
{
bool isNotPortal = origin != ApplicationOriginTypeCode.Portal;
bool isNewOrRenewal = type == ApplicationTypeEnum.New ||
type == ApplicationTypeEnum.Renewal;

return !(isNotPortal && isNewOrRenewal);
}
}
1 change: 0 additions & 1 deletion src/Spd.Resource.Repository/SharedRepositoryFuncs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ public static void LinkTeam(DynamicsContext _context, string teamGuidStr, spd_ap
).ToList();
return matchingAliases;
}

}

0 comments on commit 1b938b2

Please sign in to comment.