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

psp-8630 | Updated Leases and added renewals #4180

Merged
merged 14 commits into from
Jul 11, 2024

Conversation

FuriousLlama
Copy link
Collaborator

@FuriousLlama FuriousLlama commented Jul 10, 2024

Note: Backend tets will be added after verifying with one of our BAs in a live environment

@FuriousLlama FuriousLlama added the enhancement New feature or request label Jul 10, 2024
@FuriousLlama FuriousLlama self-assigned this Jul 10, 2024
Copy link
Contributor

✅ No secrets were detected in the code.

}

/// <summary>
/// Update the specified tenants on the passed lease.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what is this endpoint doing in this controller? this seems specific to tenants.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought I might need an update for the renewals, so left a stub. Its gone now

_logger.LogInformation("Getting renewals on lease {leaseId}", leaseId);
_user.ThrowIfNotAuthorized(Permissions.LeaseView);
var pimsUser = _userRepository.GetByKeycloakUserId(_user.GetUserKey());
pimsUser.ThrowInvalidAccessToLeaseFile(_leaseRepository.GetNoTracking(leaseId).RegionCode);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do for a non-existent lease id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the lease ID matches nothing it will return an empty collection

var agreementStart = lease.OrigStartDate.Value;
var agreementEnd = lease.OrigExpiryDate.Value;
currentEndDate = agreementEnd;
if (DateTime.Compare(agreementEnd, agreementStart) <= 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI C# supports comparing DateTimes with the regular < <= > >= operators.


if (DateTime.Compare(currentEndDate, startDate) >= 0)
{
throw new BusinessRuleViolationException("The commencement date of your renewal should be later than the previous expiry date (agreement or renewal)");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this satisfies the ac in abstract, but not on a 1-1 basis. Make sure there is a not on the story for Praveen so he doesn't fail this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, should the user be able to allow colliding renewal dates when the renewal is not exercised? currently I can.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a conversation with julian about this. A non-exercised renewal is functionally a draft, so no validation happens for those

namespace Pims.Dal.Repositories
{
/// <summary>
/// ILeaseRenewalRepository interface, provides functions to interact with lease tenants within the datasource.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: lease tenants.

<SectionField label="Expiry date">
<SectionField
label="Expiry"
required={statusTypeCode === ApiGen_CodeTypes_LeaseStatusTypes.ACTIVE}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this field is never required - this rule only applies to the commencement date on the agreement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was part of the conversation with Julian. Active leases must have a commencement and expiry dates

async (leaseId: number) => await getLeaseRenewals(leaseId),
[getLeaseRenewals],
),
requestName: 'getApiLeaseChecklist',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs updated name, and the error needs updating as well.

}
else
{
throw new BusinessRuleViolationException("Active leases must have commencement and expiry dates");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this true? I think they just need commencement dates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, confirmed by julian. Check above reply

@devinleighsmith
Copy link
Collaborator

I think commencement date and expiry date for the agreement or supposed to have tooltips (based on confluence).

{lease.fileStatusTypeCode.id === ApiGen_CodeTypes_LeaseStatusTypes.TERMINATED && (
<>
<SectionField label="Termination" labelWidth="3">
{lease.terminationDate}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should probably be pretty formatted.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I had it that way. Might have been part of the merge

</SectionField>
<Row>
<Col>
<SectionField label="Commencement" labelWidth="6">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm assuming that both view and edit should have the tooltips for the commencement, expiry, and termination?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was unclear to me. I can add them later once the BAs see the section live

<Row>
<Col xs="7">
<SectionField
label="Commencement"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooltips missing for commencement, expiry on read/edit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty odd. I remember adding them. Anyhow, they are there now.

@devinleighsmith
Copy link
Collaborator

It looks like the formik yup schema was not updated for the new business rules. So, for example, commencement/expiry date are listed as required for exercised renewals visually, but I can still save an exercised renewal without providing any dates.


private void ValidateRenewalDates(PimsLease lease, ICollection<PimsLeaseRenewal> renewals)
{
if (lease.LeaseStatusTypeCode != PimsLeaseStatusTypes.ACTIVE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this accurate? it seems like dates are optional when a lease is not active, but should the user be allowed to enter overlapping dates when not active?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats correct. Check reply above.

@devinleighsmith
Copy link
Collaborator

This modal message doesn't match jira:
The lease is no longer in Terminated state. The reason for doing so will be cleared from the file details and can only be viewed in the notes tab.
Do you want to proceed?

is there a mismatch in confluence or something?

@@ -78,13 +78,13 @@ export const LeaseDetailSubForm: React.FunctionComponent<ILeaseDetailsSubFormPro
};

return (
<Section>
<SectionField label="Ministry project" labelWidth="2">
<Section header="Original Aggreement">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aggreement -> Agreement

@devinleighsmith
Copy link
Collaborator

This modal message doesn't match jira: The lease is no longer in Terminated state. The reason for doing so will be cleared from the file details and can only be viewed in the notes tab. Do you want to proceed?

is there a mismatch in confluence or something?

Also, the message in the story mentions deleting the terminated date when the lease status is set to non-terminated, but I think right now only the termination reason is cleared.

Copy link
Collaborator

@devinleighsmith devinleighsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some changes before merge.

@FuriousLlama
Copy link
Collaborator Author

It looks like the formik yup schema was not updated for the new business rules. So, for example, commencement/expiry date are listed as required for exercised renewals visually, but I can still save an exercised renewal without providing any dates.

You should get a server error. The AC specifies that the validation happens on save

@FuriousLlama
Copy link
Collaborator Author

This modal message doesn't match jira: The lease is no longer in Terminated state. The reason for doing so will be cleared from the file details and can only be viewed in the notes tab. Do you want to proceed?

is there a mismatch in confluence or something?

TBH, took most of the text as a suggestion given there where ambiguities between the JIRA ticket, confluence and mokcup + a conversation with julian. At this point I rather fine tune this once the BAs use the application.

Copy link
Contributor

✅ No secrets were detected in the code.

Copy link
Contributor

✅ No secrets were detected in the code.

@devinleighsmith
Copy link
Collaborator

It looks like the formik yup schema was not updated for the new business rules. So, for example, commencement/expiry date are listed as required for exercised renewals visually, but I can still save an exercised renewal without providing any dates.

You should get a server error. The AC specifies that the validation happens on save

Hmm, I don't agree on this one, I can't think of any cases where we mark a field as required but allow the form to be submitted without that required field.

Copy link
Collaborator

@devinleighsmith devinleighsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the yup schema needs to be updated to enforce the max character limit on the new text fields.

@FuriousLlama
Copy link
Collaborator Author

It looks like the formik yup schema was not updated for the new business rules. So, for example, commencement/expiry date are listed as required for exercised renewals visually, but I can still save an exercised renewal without providing any dates.

You should get a server error. The AC specifies that the validation happens on save

Hmm, I don't agree on this one, I can't think of any cases where we mark a field as required but allow the form to be submitted without that required field.

It's debatable. Is this a PR blocker?

@devinleighsmith
Copy link
Collaborator

It looks like the formik yup schema was not updated for the new business rules. So, for example, commencement/expiry date are listed as required for exercised renewals visually, but I can still save an exercised renewal without providing any dates.

You should get a server error. The AC specifies that the validation happens on save

Hmm, I don't agree on this one, I can't think of any cases where we mark a field as required but allow the form to be submitted without that required field.

It's debatable. Is this a PR blocker?

no, just the comment about the max text lengths.

Copy link
Contributor

✅ No secrets were detected in the code.

1 similar comment
Copy link
Contributor

✅ No secrets were detected in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants