Skip to content

Commit

Permalink
fix renew on the last day (#1616)
Browse files Browse the repository at this point in the history
# Description

This PR includes the following proposed change(s):

- spdbt-3216(renew should be allowed on the last day )
  • Loading branch information
esdd1995 authored Oct 26, 2024
2 parents 60a51ea + b6d2a38 commit 974a642
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Spd.Manager.Licence/BizLicAppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public async Task<BizLicAppCommandResponse> Handle(BizLicAppRenewCommand cmd, Ca
throw new ArgumentException("cannot find the licence that needs to be renewed.");
// Check Renew your licence before it expires, within 90 days of the expiry date.
if (DateTime.UtcNow < originalLic.ExpiryDate.AddDays(-Constants.LicenceWith123YearsRenewValidBeforeExpirationInDays).ToDateTime(new TimeOnly(0, 0))
|| DateTime.UtcNow > originalLic.ExpiryDate.ToDateTime(new TimeOnly(0, 0)))
|| DateTime.UtcNow > originalLic.ExpiryDate.ToDateTime(new TimeOnly(23, 59, 59)))
throw new ArgumentException($"the application can only be renewed within {Constants.LicenceWith123YearsRenewValidBeforeExpirationInDays} days of the expiry date.");

var existingFiles = await GetExistingFileInfo(
Expand Down
6 changes: 2 additions & 4 deletions src/Spd.Manager.Licence/PermitAppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ public async Task<Guid> Handle(GetLatestPermitApplicationIdQuery query, Cancella
}
#endregion



public async Task<PermitLicenceAppResponse> Handle(GetPermitApplicationQuery query, CancellationToken cancellationToken)
{
var response = await _personLicAppRepository.GetLicenceApplicationAsync(query.LicenceApplicationId, cancellationToken);
Expand Down Expand Up @@ -182,7 +180,7 @@ public async Task<PermitAppCommandResponse> Handle(PermitAppRenewCommand cmd, Ca

//check Renew your existing permit before it expires, within 90 days of the expiry date.
if (DateTime.UtcNow < originalLic.ExpiryDate.AddDays(-Constants.LicenceWith123YearsRenewValidBeforeExpirationInDays).ToDateTime(new TimeOnly(0, 0))
|| DateTime.UtcNow > originalLic.ExpiryDate.ToDateTime(new TimeOnly(0, 0)))
|| DateTime.UtcNow > originalLic.ExpiryDate.ToDateTime(new TimeOnly(23, 59, 59)))
throw new ArgumentException($"the permit can only be renewed within {Constants.LicenceWith123YearsRenewValidBeforeExpirationInDays} days of the expiry date.");

var existingFiles = await GetExistingFileInfo(
Expand All @@ -192,7 +190,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
5 changes: 3 additions & 2 deletions src/Spd.Manager.Licence/SecurityWorkerAppManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,14 @@ public async Task<WorkerLicenceCommandResponse> Handle(WorkerLicenceAppRenewComm
throw new ArgumentException("cannot find the licence that needs to be renewed.");
if (originalLic.LicenceTermCode == LicenceTermEnum.NinetyDays)
{
if (DateTime.UtcNow < originalLic.ExpiryDate.AddDays(-Constants.LicenceWith90DaysRenewValidBeforeExpirationInDays).ToDateTime(new TimeOnly(0, 0)))
if (DateTime.UtcNow < originalLic.ExpiryDate.AddDays(-Constants.LicenceWith90DaysRenewValidBeforeExpirationInDays).ToDateTime(new TimeOnly(0, 0))
|| DateTime.UtcNow > originalLic.ExpiryDate.ToDateTime(new TimeOnly(23, 59, 59)))
throw new ArgumentException($"the licence can only be renewed within {Constants.LicenceWith90DaysRenewValidBeforeExpirationInDays} days of the expiry date.");
}
else
{
if (DateTime.UtcNow < originalLic.ExpiryDate.AddDays(-Constants.LicenceWith123YearsRenewValidBeforeExpirationInDays).ToDateTime(new TimeOnly(0, 0))
|| DateTime.UtcNow > originalLic.ExpiryDate.ToDateTime(new TimeOnly(0, 0)))
|| DateTime.UtcNow > originalLic.ExpiryDate.ToDateTime(new TimeOnly(23, 59, 59)))
throw new ArgumentException($"the licence can only be renewed within {Constants.LicenceWith123YearsRenewValidBeforeExpirationInDays} days of the expiry date.");
}
var existingFiles = await GetExistingFileInfo(cmd.LicenceAnonymousRequest.LatestApplicationId, cmd.LicenceAnonymousRequest.PreviousDocumentIds, cancellationToken);
Expand Down

0 comments on commit 974a642

Please sign in to comment.