Skip to content

PDJB-300: Add invitation lists to property page#1402

Open
samyou-softwire wants to merge 7 commits into
mainfrom
feat/PDJB-300-property-record-landlord-invite-details
Open

PDJB-300: Add invitation lists to property page#1402
samyou-softwire wants to merge 7 commits into
mainfrom
feat/PDJB-300-property-record-landlord-invite-details

Conversation

@samyou-softwire
Copy link
Copy Markdown
Contributor

@samyou-softwire samyou-softwire commented Jun 3, 2026

Ticket number

PDJB-300

Goal of change

adds lists of pending & expired invitations to the property details page

property details landlord tab with invitations

Description of main change(s)

adds logic to the property tab to show the invitations

adds database model to get invitations of a certain type

adds some useful methods to invitation entity

adds tests

Anything you'd like to highlight to the reviewer?

see comments

Checklist

Delete any that are not applicable, and add explanation below for any that are applicable but haven't been done

  • Screenshots of any UI changes have been added
  • Unit tests for new logic (e.g. new service methods) have been added
  • Controller tests for any new endpoints, including testing the relevant permissions
  • Single page integration tests have been added for any unhappy-flow UI features, e.g. validation errors
  • Test suite has been run in full locally and is passing
  • Branch has been rebased onto main and run locally, with everything working as expected (both for your new feature
    and any related functionality)
  • TODO comments referencing this JIRA ticket have been searched for and removed - if a future PR will address them,
    mention that here
  • QA instructions have been added to the ticket (particularly if this is the last PR required to complete the ticket)

@samyou-softwire samyou-softwire self-assigned this Jun 3, 2026
@samyou-softwire samyou-softwire force-pushed the feat/PDJB-300-property-record-landlord-invite-details branch from a222ca6 to cb0fc58 Compare June 3, 2026 10:23
model.addAttribute("complianceDetails", propertyComplianceDetails)
model.addAttribute("complianceInfoTabId", COMPLIANCE_INFO_FRAGMENT)
model.addAttribute("isLandlordView", false)
model.addAttribute("isJointLandlordsEnabled", false)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this may change - right now assuming that LCs won't be able to view pending/expired invites though design to input on what should happen here

th:text="#{propertyDetails.landlordDetails.invitations.pendingInvitations.sentOn(${invitation.sentDate})}">
Sent on 18 October 2025
</p>
<ul class="govuk-summary-list__actions-list">
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm suspicious of this - this is the simplest class that would give us the divider between actions but it's not a great use of GDS components. fine to keep as is or should we add our own copy of the relevant CSS?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, this feels unsafe to me. It might work now, but who knows what it'll be like when govuk-frontend updates another version or two. Owning our own copy has its own risks (we'll have to come and check this again for compatibility when we upgrade), but that feels a bit more explicit, at least.

@samyou-softwire samyou-softwire force-pushed the feat/PDJB-300-property-record-landlord-invite-details branch from 9d349fa to 3f74d30 Compare June 3, 2026 12:34
@samyou-softwire samyou-softwire force-pushed the feat/PDJB-300-property-record-landlord-invite-details branch from 3f74d30 to 856ec34 Compare June 3, 2026 12:43
invitingLandlord = MockLandlordData.createLandlord()
}

@Test
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the diff is weird here since the existing tests are now wrapped in a class

@samyou-softwire samyou-softwire marked this pull request as ready for review June 3, 2026 12:48
Comment on lines +95 to +102
val pendingInvitations =
jointLandlordInvitationService
.getPendingInvitations(propertyOwnership)
.map { InvitationViewModelBuilder.buildPendingViewModel(it) }
val expiredInvitations =
jointLandlordInvitationService
.getExpiredInvitations(propertyOwnership)
.map { InvitationViewModelBuilder.buildExpiredViewModel(it) }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is going to mean two identical queries to the database, and a tiny race condition between them. I think it might be better for the service to have a single getPendingAndExpiredInvitations() that ultimately does a single queries and then partitions in memory.

It's a tiny issue, but also hopefully not hard to fix?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good point, have changed this to partition

invitations:
pendingInvitations:
heading: 'Pending invitations ({0})'
expiresIn: 'Expires in {0} days ({1})'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to worry about "1 days" and "0 days"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

suspect we do, have added alternate copy for this

I don't think any of these other strings need a singular equivalent

th:text="#{propertyDetails.landlordDetails.invitations.pendingInvitations.sentOn(${invitation.sentDate})}">
Sent on 18 October 2025
</p>
<ul class="govuk-summary-list__actions-list">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, this feels unsafe to me. It might work now, but who knows what it'll be like when govuk-frontend updates another version or two. Owning our own copy has its own risks (we'll have to come and check this again for compatibility when we upgrade), but that feels a bit more explicit, at least.

Comment on lines +43 to +60
val expiryDate: Instant
get() = createdDate.plus(JOINT_LANDLORD_INVITATION_LIFETIME_IN_DAYS.toLong(), ChronoUnit.DAYS)

val daysUntilExpiry: Long
get() = ChronoUnit.DAYS.between(Instant.now(), expiryDate).coerceAtLeast(0)

val isExpired: Boolean
get() {
val dateTimeHelper = DateTimeHelper()

val expiresOnDate =
DateTimeHelper
.getDateInUK(createdDate.toKotlinInstant())
.plus(DatePeriod(days = JOINT_LANDLORD_INVITATION_LIFETIME_IN_DAYS))

return dateTimeHelper.getCurrentDateInUK() > expiresOnDate
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm just slightly nervous that we have some non-trivial date arithmetic here that all ought to agree. Might be worth some tests for this to check that they all behave as expected, and consistently with each other? Especially at common problem times, like near midnight or near a DST change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

see #1401 which I'll rebase in when it's merged, there will be some stringent tests for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants