Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Con 2237 amend eligibility logic to check for agreement version #2114

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
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ public EmployerFeatureAuthorisationHandlerTestsFixture SetMediatorResponse(int a
StatusId = agreementStatus,
AccountLegalEntity = new AccountLegalEntity
{
SignedAgreementVersion = agreementVersion
SignedAgreementVersion = agreementStatus == EmployerAgreementStatus.Signed ? (int?)agreementVersion : null,
PendingAgreementVersion = agreementStatus == EmployerAgreementStatus.Pending ? (int?)agreementVersion : null
}

}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,9 @@ public async Task<AuthorizationResult> GetAuthorizationResult(IReadOnlyCollectio
var (accountId, _) = authorizationContext.GetEmployerFeatureValues();

var agreements = await _mediator.SendAsync(new GetEmployerAgreementsByAccountIdRequest { AccountId = accountId.GetValueOrDefault(0) }).ConfigureAwait(false);
var minAgreementVersion = agreements.EmployerAgreements.Select(ea => ea.AccountLegalEntity.SignedAgreementVersion.GetValueOrDefault(0)).Min();

var minAgreementVersion = agreements.EmployerAgreements.
Where(a => a.StatusId == Models.EmployerAgreement.EmployerAgreementStatus.Signed &&
a.AccountLegalEntity.SignedAgreementVersion.GetValueOrDefault(0) > 0).Select(b => b.AccountLegalEntity.SignedAgreementVersion ?? 0)
.DefaultIfEmpty()
.Min();

if (minAgreementVersion < featureToggle.EnabledByAgreementVersion || agreements.EmployerAgreements.Any(a => a.StatusId == Models.EmployerAgreement.EmployerAgreementStatus.Pending))
if (minAgreementVersion < featureToggle.EnabledByAgreementVersion)
{
authorizationResult.AddError(new EmployerFeatureAgreementNotSigned());
}
Expand Down