Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Spd.Manager.Licence/ControllingMemberCrcAppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task<ControllingMemberCrcAppCommandResponse> Handle(ControllingMemb
await _controllingMemberCrcRepository.GetCrcApplicationAsync((Guid)cmd.ControllingMemberCrcAppRequest.ControllingMemberAppId, ct);

ChangeSpec changes = await AddDynamicTasks(originalApp, request, cmd.LicAppFileInfos, ct);

//update application
var response = await _controllingMemberCrcRepository.SaveControllingMemberCrcApplicationAsync(saveCmd, ct);

Expand All @@ -112,7 +112,7 @@ await UploadNewDocsAsync(request.DocumentExpiredInfos,
null,
null,
ct);
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, ct);
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, null, ct);
return _mapper.Map<ControllingMemberCrcAppCommandResponse>(response);
}
#region anonymous new
Expand All @@ -128,7 +128,7 @@ await ValidateInviteIdAsync(cmd.ControllingMemberCrcAppSubmitRequest.InviteId,
//create contact for applicant
CreateContactCmd contactCmd = _mapper.Map<CreateContactCmd>(request);
ContactResp contact = await _contactRepository.ManageAsync(contactCmd, ct);

//save the application
SaveControllingMemberCrcAppCmd createApp = _mapper.Map<SaveControllingMemberCrcAppCmd>(request);
createApp.ContactId = contact.Id;
Expand All @@ -139,7 +139,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.Submitted, ct);
await _licAppRepository.CommitLicenceApplicationAsync(response.ControllingMemberAppId, ApplicationStatusEnum.Submitted, null, ct);
await DeactiveInviteAsync(cmd.ControllingMemberCrcAppSubmitRequest.InviteId, ct);

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

}
14 changes: 8 additions & 6 deletions src/Spd.Manager.Licence/LicenceAppManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ protected async Task<decimal> CommitApplicationAsync(LicenceAppBase licAppBase,
WorkerLicenceTypeEnum = licAppBase.WorkerLicenceTypeCode == null ? null : Enum.Parse<WorkerLicenceTypeEnum>(licAppBase.WorkerLicenceTypeCode.ToString()),
HasValidSwl90DayLicence = HasSwl90DayLicence
}, ct);
if (price?.LicenceFees.FirstOrDefault() == null || price?.LicenceFees.FirstOrDefault()?.Amount == 0)
LicenceFeeResp? licenceFee = price?.LicenceFees.FirstOrDefault();
if (licenceFee == null || licenceFee.Amount == 0)
{
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.Submitted, ct);
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.Submitted, ct);
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.Submitted, null, ct);
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.Submitted, null, ct);
}
else
{
if (companionAppId != null) await _licAppRepository.CommitLicenceApplicationAsync((Guid)companionAppId, ApplicationStatusEnum.PaymentPending, ct);
await _licAppRepository.CommitLicenceApplicationAsync(licenceAppId, ApplicationStatusEnum.PaymentPending, ct);
//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);
}

return price?.LicenceFees.FirstOrDefault()?.Amount ?? 0;
return licenceFee?.Amount ?? 0;
}

//upload file from cache to main bucket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task CommitLicenceApplicationAsync_ForApplicant_Run_Correctly()
await _context.SaveChangesAsync();

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

//Assert
Assert.NotNull(resp);
Expand All @@ -65,7 +65,7 @@ public async Task CommitLicenceApplicationAsync_ForBusiness_Run_Correctly()
await _context.SaveChangesAsync();

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

//Assert
Assert.NotNull(resp);
Expand Down
2 changes: 1 addition & 1 deletion src/Spd.Resource.Repository/LicApp/Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public partial interface ILicAppRepository
{
public Task<IEnumerable<LicenceAppListResp>> QueryAsync(LicenceAppQuery qry, CancellationToken cancellationToken);
//connect spd_application with spd_contact and update application to correct status
public Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid applicationId, ApplicationStatusEnum status, CancellationToken ct);
public Task<LicenceApplicationCmdResp> CommitLicenceApplicationAsync(Guid applicationId, ApplicationStatusEnum status, decimal? price, CancellationToken ct);
}

public record LicenceAppQuery(Guid? ApplicantId, Guid? BizId, List<WorkerLicenceTypeEnum>? ValidWorkerLicenceTypeCodes, List<ApplicationPortalStatusEnum>? ValidPortalStatus);
Expand Down
4 changes: 3 additions & 1 deletion src/Spd.Resource.Repository/LicApp/LicAppRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public LicAppRepository(IDynamicsContextFactory ctx, IMapper mapper)
}

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

app.spd_submittedon = DateTimeOffset.Now;
app.spd_portalmodifiedon = DateTimeOffset.Now;
if (price is > 0)
app.spd_licencefee = price;
_context.UpdateObject(app);
await _context.SaveChangesAsync(ct);

Expand Down
Loading