## 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...
96 lines
2.7 KiB
JavaScript
96 lines
2.7 KiB
JavaScript
import {
|
|
resolveRepresentationWindow,
|
|
isRepresentationWindowOpen,
|
|
isRepresentationWindowClosed,
|
|
canShowRepresentationButtonForAppealType,
|
|
canStartHouseholderRepresentation,
|
|
canStartCpoRepresentation
|
|
} from "../../../../lib/domain/representation-policy";
|
|
|
|
export function showRepsLocal(startDate, endDate) {
|
|
return isRepresentationWindowOpen(startDate, endDate);
|
|
}
|
|
|
|
export function showRepsEndedLocal(startDate, endDate) {
|
|
return isRepresentationWindowClosed(startDate, endDate);
|
|
}
|
|
|
|
export function isConsultationWindowOpen(detailsObj) {
|
|
return showRepsLocal(
|
|
detailsObj.pinswg_consultationopen,
|
|
detailsObj.pinswg_consultationclose
|
|
);
|
|
}
|
|
|
|
export function isGeneralRepresentationWindowOpen(detailsObj) {
|
|
return resolveRepresentationWindow(detailsObj).isOpen;
|
|
}
|
|
|
|
export function canShowRepButtonForAppealType({
|
|
appealType,
|
|
isLPA,
|
|
searchDetailsObj
|
|
}) {
|
|
if (!canShowRepresentationButtonForAppealType(appealType)) {
|
|
return false;
|
|
}
|
|
|
|
switch (appealType) {
|
|
case 846040004:
|
|
return canStartHouseholderRepresentation(appealType, isLPA);
|
|
|
|
case 846040015:
|
|
return searchDetailsObj[0].value[0].pinswg_specialistcaseprocess ==
|
|
846040001
|
|
? showRepsLocal(
|
|
searchDetailsObj[0].value[0].pinswg_startdate,
|
|
searchDetailsObj[0].value[0].pinswg_finalcommentsduedate
|
|
)
|
|
: true;
|
|
|
|
case 846040018:
|
|
let shouldShow =
|
|
searchDetailsObj[0].value[0].pinswg_speacialistcaseprocess ==
|
|
846040000 && isLPA
|
|
? true
|
|
: searchDetailsObj[0].value[0]
|
|
.pinswg_speacialistcaseprocess == 846040001
|
|
? true
|
|
: false;
|
|
|
|
return shouldShow;
|
|
|
|
case 846040019:
|
|
return canStartCpoRepresentation(
|
|
appealType,
|
|
searchDetailsObj[0].value[0]
|
|
);
|
|
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
|
|
export function getEntryCtaLabelKey(appealType) {
|
|
return appealType == 846040002
|
|
? "case:summary-make-consultation-label"
|
|
: "case:summary-make-representation-label";
|
|
}
|
|
|
|
export function shouldSuppressBlockedMessage({ appealType, isLPA }) {
|
|
return !isLPA && appealType == 846040004;
|
|
}
|
|
|
|
export function getGeneralBlockedEndDate(detailsObj, appealType) {
|
|
return appealType == 846040019
|
|
? detailsObj.pinswg_statementduedate
|
|
: detailsObj.pinswg_finalcommentsduedate;
|
|
}
|
|
|
|
export function isRepresentationPeriodEnded(detailsObj) {
|
|
return showRepsEndedLocal(
|
|
detailsObj.pinswg_startdate,
|
|
detailsObj.pinswg_finalcommentsduedate
|
|
);
|
|
}
|