Merged PR 2375: update representation policy

## Summary

Introduces a new `representation-policy` domain boundary and incrementally extracts low-risk representation entry policy logic while preserving existing behaviour.

This PR intentionally stops before extracting ROW and Advert entry rules because characterization uncovered behavioural differences between consumers that require a separate business decision.

## What Changed

Added:

```text
lib/domain/representation-policy/
```

Including:

- `resolveRepresentationWindow(...)`
- `isRepresentationWindowOpen(...)`
- `isRepresentationWindowClosed(...)`
- `canShowRepresentationButtonForAppealType(...)`
- `canStartHouseholderRepresentation(...)`
- `canStartCpoRepresentation(...)`

Updated consumers:

```text
components/case/summary/utils/representationEntry.js
components/search/repsonresults.js
```

## Extracted Behaviour

### Representation Window Calculation
Centralised shared representation window logic and adopted it in both consumers.

### Appeal Type Entry Gating
Centralised excluded appeal-type logic while preserving existing behaviour.

### Householder Rule
Centralised Householder (`846040004`) entry rule.

Preserved behaviour:

```text
Householder representations can only be started by LPAs.
```

### CPO Rule
Centralised CPO (`846040019`) entry rule.

Preserved behaviour using:

```text
pinswg_startdate
pinswg_statementduedate
```

No fallback date broadening introduced.

## Characterization Added

### ROW (`846040015`)
Documented:
- hearing vs non-hearing behaviour
- specialist-process field behaviour
- date gating
- appeal-type coercion behaviour

### Advert (`846040018`)
Documented:
- LPA/non-LPA behaviour
- specialist-process behaviour
- appeal-type coercion behaviour

## Important Findings

### ROW Divergence
Summary and Search consumers currently behave differently when only:

```text
pinswg_speacialistcaseprocess
```

exists.

### Advert Divergence
Summary and Search consumers currently use different specialist-process resolution paths.

### CRM Compatibility
Both fields remain in production use and must be preserved:

```text
pinswg_specialistcaseprocess
pinswg_speacialistcaseprocess
```

## Documentation

Added:

```text
lib/domain/representation-policy/README.md
```

Documenting:
- ownership
- non-goals
- CRM compatibility requirements
- ROW divergence
- Advert divergence
- future extraction constraints

## Validation

Executed during the slice series:

```bash
node tests/phase22/representation-window.test.cjs
node tests/phase22/representation-appeal-type-entry-gating.test.cjs
node tests/phase22/representation-householder-entry-rule.test.cjs
node tests/phase22/representation-cpo-entry-rule.test.cjs
node tests/phase22/representation-row-entry-rule.test.cjs
node tests/phase22/representation-advert-entry-rule.test.cjs
npm run lint
```

All passing.

## Out of Scope

No changes to:

- submission/finalisation
- uploads
- dashboards
- CRM/OData queries
- API routes
- Redux state
- translations
- blocked-message rendering
- CTA l...
This commit is contained in:
Robert Bond
2026-06-08 10:51:02 +00:00
parent 9595ad86df
commit c39e4bcc9a
14 changed files with 1725 additions and 81 deletions
@@ -1,18 +1,18 @@
export function showRepsLocal(startDate, endDate) {
let date = new Date();
date = new Date(date.toDateString());
const start = new Date(startDate);
const end = new Date(endDate);
import {
resolveRepresentationWindow,
isRepresentationWindowOpen,
isRepresentationWindowClosed,
canShowRepresentationButtonForAppealType,
canStartHouseholderRepresentation,
canStartCpoRepresentation
} from "../../../../lib/domain/representation-policy";
return date >= start && date <= end ? true : false;
export function showRepsLocal(startDate, endDate) {
return isRepresentationWindowOpen(startDate, endDate);
}
export function showRepsEndedLocal(startDate, endDate) {
let date = new Date();
date = new Date(date.toDateString());
const start = new Date(startDate);
const end = new Date(endDate);
return date > start && date > end ? true : false;
return isRepresentationWindowClosed(startDate, endDate);
}
export function isConsultationWindowOpen(detailsObj) {
@@ -23,24 +23,7 @@ export function isConsultationWindowOpen(detailsObj) {
}
export function isGeneralRepresentationWindowOpen(detailsObj) {
return (
(Object.prototype.hasOwnProperty.call(detailsObj, "pinswg_startdate") ||
Object.prototype.hasOwnProperty.call(
detailsObj,
"pinswg_applicationacceptedasvalid"
) ||
Object.prototype.hasOwnProperty.call(
detailsObj,
"pinswg_startdates"
)) &&
showRepsLocal(
detailsObj.pinswg_startdate ||
detailsObj.pinswg_startdates ||
detailsObj.pinswg_applicationacceptedasvalid,
detailsObj.pinswg_finalcommentsduedate ||
detailsObj.pinswg_endofrepresentationperiod
)
);
return resolveRepresentationWindow(detailsObj).isOpen;
}
export function canShowRepButtonForAppealType({
@@ -48,18 +31,13 @@ export function canShowRepButtonForAppealType({
isLPA,
searchDetailsObj
}) {
if (!canShowRepresentationButtonForAppealType(appealType)) {
return false;
}
switch (appealType) {
case 846040012:
case 846040013:
case 846040014:
//for ROW case 846040015:
case 846040020:
case 846040021:
case 846040023:
case 846040024:
return false;
case 846040004:
return isLPA ? true : false;
return canStartHouseholderRepresentation(appealType, isLPA);
case 846040015:
return searchDetailsObj[0].value[0].pinswg_specialistcaseprocess ==
@@ -83,9 +61,9 @@ export function canShowRepButtonForAppealType({
return shouldShow;
case 846040019:
return showRepsLocal(
searchDetailsObj[0].value[0].pinswg_startdate,
searchDetailsObj[0].value[0].pinswg_statementduedate
return canStartCpoRepresentation(
appealType,
searchDetailsObj[0].value[0]
);
default: