Commit 3c77112
PIL-2855: Display Multiple Accounting Periods on Manage Group Details (#648)
Migrates the frontend to use the new **Read Subscription V2** endpoint
(which returns an array of accounting periods) behind the
`amendMultipleAccountingPeriods` feature flag, while retaining full
backward compatibility with the existing V1 flow.
ETMP are introducing a breaking change to the Display Subscription API.
Replacing a singular accounting period with an array of accounting
periods. This PR introduces a V2 path on the frontend that consumes the
new response shape, converts it to the existing `SubscriptionLocalData`
cache model, and allows both V1 and V2 data to coexist without
invalidating any user's cache.
This also adds the first page of the new **amend multiple accounting
periods** journey -the Manage Group Details summary page now renders a
multi-period view with individual period cards when the feature flag is
enabled.
Additionally, this work exposed a pre-existing bug in the BTN flow where
the confirmation page and submission payload were using the accounting
period from the subscription data rather than the period the user
actually selected during the journey. This has been fixed so the entire
BTN flow now consistently uses the user's chosen period.
## What changed
### Models
- **`SubscriptionDataV2`** — New model representing the V2 API response
with `Seq[DisplayAccountingPeriod]` (each period includes
`canAmendStartDate`/`canAmendEndDate` flags).
- **`DisplayAccountingPeriod`** — New model for individual accounting
periods in the V2 response, with a `toAccountingPeriod` conversion
helper.
- **`SubscriptionLocalData`** — Two new optional fields added with
defaults for backward compatibility:
- `accountingPeriods: Option[Seq[DisplayAccountingPeriod]]` — populated
from V2 data.
- `registrationDate: Option[LocalDate]` — populated from V2
`upeDetails`. This was added so the homepage can display the
registration date through the V2 path without requiring a separate
homepage-specific model or a second API call (in the V1 flow, this value
comes directly from `SubscriptionData.upeDetails.registrationDate`).
- `subAccountingPeriod` changed from `AccountingPeriod` to
`Option[AccountingPeriod] = None` — V2 data no longer synthesises a fake
singular period; V1 cached data continues to populate it as `Some`.
### Connector
- **`readSubscriptionV2`** — New method on `SubscriptionConnector`
calling the backend V2 endpoint. Handles `404` as `NoResultFound`
(consistent with V1 pattern), `422` as `UnprocessableEntityError`, and
`5xx` with the existing retryable gateway error logic.
### Service
- **`readSubscriptionV2AndSave`** — New method on `SubscriptionService`
that calls `readSubscriptionV2`, converts the response to
`SubscriptionLocalData` (populating `accountingPeriods`,
`registrationDate`, and leaving `subAccountingPeriod = None`), and saves
to the user-cache.
- **`subscriptionDataV2ToLocalData`** — Private conversion from
`SubscriptionDataV2` to `SubscriptionLocalData`.
- **`amendGroupOrContactDetails`** — Updated to handle optional
`subAccountingPeriod`, falling back to `currentData.accountingPeriod`
from the V1 `SubscriptionData` when `None`.
### Homepage
- **`HomepageController.onPageLoad`** — When
`amendMultipleAccountingPeriods` is enabled, calls
`readSubscriptionV2AndSave` and renders the homepage from
`SubscriptionLocalData` fields. When disabled, retains the original V1
`maybeReadSubscription` + `cacheSubscription` flow.
### Manage Group Details
- **`ManageGroupDetailsCheckYourAnswersController`** — When the flag is
enabled, fetches V2 data and renders a multi-period summary view with
individual period cards showing amendable date ranges.
- **`ManageGroupDetailsMultiPeriodView`** — New view template for
rendering multiple accounting periods with Change links.
### BTN Flow
Decoupled the BTN flow from `subAccountingPeriod` entirely — all BTN
controllers now source the accounting period from the user's chosen
period (`BTNChooseAccountingPeriodPage` in user answers):
- **`BTNConfirmationController`** — Confirmation page dates come from
the chosen period, not subscription data.
- **`CheckYourAnswersController`** — Both `onPageLoad` (summary display)
and `onSubmit` (BTN payload) use the chosen period. Falls back to
`subAccountingPeriod` only on the CYA summary as a last resort, with
`JourneyRecovery` redirect if neither is available.
- **`BTNAccountingPeriodController`** — Audit event uses the period from
`selectAccountingPeriod` context directly.
- **`BTNStatusAction`** — Reads `BTNChooseAccountingPeriodPage` from
user answers for the already-submitted audit.
## Feature flag
All V2 behaviour is gated behind
`features.amendMultipleAccountingPeriods` (defaults to `false`). When
`false`, the frontend behaves identically to before this PR.
---------
Co-authored-by: JamesMMiller <7511223+JamesMMiller@users.noreply.github.com>1 parent bacd31d commit 3c77112
File tree
29 files changed
+1802
-188
lines changed- app
- connectors
- controllers
- actions
- btn
- subscription/manageAccount
- models/subscription
- services
- views/subscriptionview/manageAccount
- conf
- test
- connectors
- controllers
- actions
- btn
- subscription/manageAccount
- helpers
- models
- subscription
- services
- views/subscriptionview/manageAccount
29 files changed
+1802
-188
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
100 | 123 | | |
101 | 124 | | |
102 | 125 | | |
| |||
105 | 128 | | |
106 | 129 | | |
107 | 130 | | |
108 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
109 | 137 | | |
110 | 138 | | |
111 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
31 | 33 | | |
32 | | - | |
33 | | - | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
106 | 133 | | |
107 | 134 | | |
108 | 135 | | |
| |||
123 | 150 | | |
124 | 151 | | |
125 | 152 | | |
126 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
127 | 159 | | |
128 | 160 | | |
129 | | - | |
130 | | - | |
| 161 | + | |
131 | 162 | | |
132 | 163 | | |
133 | 164 | | |
| |||
155 | 186 | | |
156 | 187 | | |
157 | 188 | | |
158 | | - | |
159 | | - | |
| 189 | + | |
| 190 | + | |
160 | 191 | | |
161 | 192 | | |
162 | 193 | | |
| |||
168 | 199 | | |
169 | 200 | | |
170 | 201 | | |
171 | | - | |
172 | 202 | | |
173 | 203 | | |
174 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
39 | 42 | | |
40 | 43 | | |
| |||
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
93 | 70 | | |
94 | 71 | | |
95 | 72 | | |
| |||
100 | 77 | | |
101 | 78 | | |
102 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
103 | 124 | | |
104 | 125 | | |
105 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
65 | 62 | | |
66 | 63 | | |
67 | 64 | | |
68 | 65 | | |
69 | 66 | | |
70 | 67 | | |
71 | | - | |
72 | | - | |
| 68 | + | |
| 69 | + | |
73 | 70 | | |
74 | 71 | | |
75 | 72 | | |
76 | 73 | | |
77 | | - | |
| 74 | + | |
78 | 75 | | |
79 | 76 | | |
80 | 77 | | |
| |||
0 commit comments