Skip to content

Commit 89062f4

Browse files
Emad/populate licence fee lic apps (#1398)
# Description modified CommitApplicationAsync, in LicenceAppManagerBase.cs to set the field spd_licencefee in spd_application. This PR includes the following proposed change(s): these references are affected: -`BizLicAppManager`, -`PermitAppManager`, -`SecurityWorkerAppManager` Note: cm crc doesn't have cost, so it is not going to update it --------- Co-authored-by: Peggy <peggy.zhang@quartech.com>
1 parent 2022fb8 commit 89062f4

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

src/Spd.Manager.Licence/ControllingMemberCrcAppManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public async Task<ControllingMemberCrcAppCommandResponse> Handle(ControllingMemb
9393
await _controllingMemberCrcRepository.GetCrcApplicationAsync((Guid)cmd.ControllingMemberCrcAppRequest.ControllingMemberAppId, ct);
9494

9595
ChangeSpec changes = await AddDynamicTasks(originalApp, request, cmd.LicAppFileInfos, ct);
96-
96+
9797
//update application
9898
var response = await _controllingMemberCrcRepository.SaveControllingMemberCrcApplicationAsync(saveCmd, ct);
9999

@@ -112,7 +112,7 @@ await UploadNewDocsAsync(request.DocumentExpiredInfos,
112112
null,
113113
null,
114114
ct);
115-
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, ct);
115+
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, null, ct);
116116
return _mapper.Map<ControllingMemberCrcAppCommandResponse>(response);
117117
}
118118
#region anonymous new
@@ -128,7 +128,7 @@ await ValidateInviteIdAsync(cmd.ControllingMemberCrcAppSubmitRequest.InviteId,
128128
//create contact for applicant
129129
CreateContactCmd contactCmd = _mapper.Map<CreateContactCmd>(request);
130130
ContactResp contact = await _contactRepository.ManageAsync(contactCmd, ct);
131-
131+
132132
//save the application
133133
SaveControllingMemberCrcAppCmd createApp = _mapper.Map<SaveControllingMemberCrcAppCmd>(request);
134134
createApp.ContactId = contact.Id;
@@ -139,7 +139,7 @@ await ValidateInviteIdAsync(cmd.ControllingMemberCrcAppSubmitRequest.InviteId,
139139
await UploadNewDocsAsync(request.DocumentExpiredInfos, cmd.LicAppFileInfos, response.ControllingMemberAppId, response.ContactId, null, null, null, null, null, ct);
140140

141141
//commit app
142-
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, ct);
142+
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, null, ct);
143143
await DeactiveInviteAsync(cmd.ControllingMemberCrcAppSubmitRequest.InviteId, ct);
144144

145145
return _mapper.Map<ControllingMemberCrcAppCommandResponse>(response);
@@ -169,7 +169,7 @@ public async Task<ControllingMemberCrcAppCommandResponse> Handle(ControllingMemb
169169
var response = await this.Handle((ControllingMemberCrcUpsertCommand)cmd, ct);
170170
//move files from transient bucket to main bucket when app status changed to Submitted.
171171
await MoveFilesAsync(response.ControllingMemberAppId, ct);
172-
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, ct);
172+
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, null, ct);
173173
await DeactiveInviteAsync(cmd.ControllingMemberCrcAppUpsertRequest.InviteId, ct);
174174
return new ControllingMemberCrcAppCommandResponse { ControllingMemberAppId = response.ControllingMemberAppId };
175175
}
@@ -362,5 +362,5 @@ private static void ValidateFilesForUpdateAppAsync(ControllingMemberCrcAppUpdate
362362
throw new ApiException(HttpStatusCode.BadRequest, "Missing ProofOfFingerprint file.");
363363
}
364364
}
365-
365+
366366
}

src/Spd.Manager.Licence/LicenceAppManagerBase.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,20 @@ protected async Task<decimal> CommitApplicationAsync(LicenceAppBase licAppBase,
5050
WorkerLicenceTypeEnum = licAppBase.WorkerLicenceTypeCode == null ? null : Enum.Parse<WorkerLicenceTypeEnum>(licAppBase.WorkerLicenceTypeCode.ToString()),
5151
HasValidSwl90DayLicence = HasSwl90DayLicence
5252
}, ct);
53-
if (price?.LicenceFees.FirstOrDefault() == null || price?.LicenceFees.FirstOrDefault()?.Amount == 0)
53+
LicenceFeeResp? licenceFee = price?.LicenceFees.FirstOrDefault();
54+
if (licenceFee == null || licenceFee.Amount == 0)
5455
{
55-
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.Submitted, ct);
56-
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.Submitted, ct);
56+
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.Submitted, null, ct);
57+
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.Submitted, null, ct);
5758
}
5859
else
5960
{
60-
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.PaymentPending, ct);
61-
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.PaymentPending, ct);
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);
6264
}
6365

64-
return price?.LicenceFees.FirstOrDefault()?.Amount ?? 0;
66+
return licenceFee?.Amount ?? 0;
6567
}
6668

6769
//upload file from cache to main bucket

src/Spd.Resource.Repository.IntegrationTest/LicAppRepositoryTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task CommitLicenceApplicationAsync_ForApplicant_Run_Correctly()
3838
await _context.SaveChangesAsync();
3939

4040
// Action
41-
LicenceApplicationCmdResp? resp = await _licAppRepository.CommitLicenceApplicationAsync(appId, ApplicationStatusEnum.Submitted, CancellationToken.None);
41+
LicenceApplicationCmdResp? resp = await _licAppRepository.CommitLicenceApplicationAsync(appId, ApplicationStatusEnum.Submitted, null, CancellationToken.None);
4242

4343
//Assert
4444
Assert.NotNull(resp);
@@ -65,7 +65,7 @@ public async Task CommitLicenceApplicationAsync_ForBusiness_Run_Correctly()
6565
await _context.SaveChangesAsync();
6666

6767
// Action
68-
LicenceApplicationCmdResp? resp = await _licAppRepository.CommitLicenceApplicationAsync(appId, ApplicationStatusEnum.Submitted, CancellationToken.None);
68+
LicenceApplicationCmdResp? resp = await _licAppRepository.CommitLicenceApplicationAsync(appId, ApplicationStatusEnum.Submitted, null, CancellationToken.None);
6969

7070
//Assert
7171
Assert.NotNull(resp);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public partial interface ILicAppRepository
66
{
77
public Task<IEnumerable<LicenceAppListResp>> QueryAsync(LicenceAppQuery qry, CancellationToken cancellationToken);
88
//connect spd_application with spd_contact and update application to correct status
9-
public Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid applicationId, ApplicationStatusEnum status, CancellationToken ct);
9+
public Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid applicationId, ApplicationStatusEnum status, decimal? price, CancellationToken ct);
1010
}
1111

1212
public record LicenceAppQuery(Guid? ApplicantId, Guid? BizId, List<WorkerLicenceTypeEnum>? ValidWorkerLicenceTypeCodes, List<ApplicationPortalStatusEnum>? ValidPortalStatus);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public LicAppRepository(IDynamicsContextFactory ctx, IMapper mapper)
1818
}
1919

2020
//for unauth, set applcation status to submitted.
21-
public async Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid applicationId, ApplicationStatusEnum status, CancellationToken ct)
21+
public async Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid applicationId, ApplicationStatusEnum status, decimal? price, CancellationToken ct)
2222
{
2323
spd_application? app = await _context.GetApplicationById(applicationId, ct);
2424
if (app == null)
@@ -36,6 +36,8 @@ public async Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid
3636

3737
app.spd_submittedon = DateTimeOffset.Now;
3838
app.spd_portalmodifiedon = DateTimeOffset.Now;
39+
if (price is > 0)
40+
app.spd_licencefee = price;
3941
_context.UpdateObject(app);
4042
await _context.SaveChangesAsync(ct);
4143

0 commit comments

Comments
 (0)