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

Display return versions in view licence setup tab #1054

Merged
merged 46 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
aec28f8
View licence set up returns for requirements
jonathangoulding May 28, 2024
d35336a
feat: add fetch returns structure
jonathangoulding May 29, 2024
07ccd8f
Merge remote-tracking branch 'origin/main' into feature-view-licence-…
jonathangoulding Jun 10, 2024
a238beb
feat: add fetch to return versions
jonathangoulding Jun 10, 2024
df3e3ea
chore: rename to returnVersions
jonathangoulding Jun 10, 2024
ccb3b9f
test: return versions
jonathangoulding Jun 11, 2024
65a2b03
test: return versions
jonathangoulding Jun 11, 2024
8bab828
Merge branch 'main' into feature-view-licence-returns-requirements
jonathangoulding Jun 11, 2024
18f84ad
fix: view file bad merge
jonathangoulding Jun 11, 2024
feebe7f
chore: pre pr
jonathangoulding Jun 11, 2024
08d919e
chore: pre pr
jonathangoulding Jun 11, 2024
fe74e4a
fix: button should be vertical
jonathangoulding Jun 11, 2024
cd660f1
refactor: toggle into config
jonathangoulding Jun 11, 2024
005839c
feat: order return versions by start date
jonathangoulding Jun 11, 2024
a1f50e4
fix: pre pr
jonathangoulding Jun 11, 2024
9727a06
test: toggle
jonathangoulding Jun 11, 2024
74cc3d3
Merge branch 'main' into feature-view-licence-returns-requirements
jonathangoulding Jun 12, 2024
371d42e
Update app/views/licences/tabs/set-up.njk
jonathangoulding Jun 12, 2024
1170b31
fix: move buttons behind flag
jonathangoulding Jun 12, 2024
2be0f9f
Update test/presenters/licences/set-up.presenter.test.js
jonathangoulding Jun 12, 2024
af1ab45
Update app/presenters/licences/set-up.presenter.js
jonathangoulding Jun 12, 2024
97b499e
fix: test undefined
jonathangoulding Jun 12, 2024
0c95818
Update app/presenters/licences/set-up.presenter.js
jonathangoulding Jun 12, 2024
d4eb69e
fix: use status mapper for return version status
jonathangoulding Jun 12, 2024
39a1286
chore: add ENABLE_REQUIREMENTS_FOR_RETURNS flag to env example
jonathangoulding Jun 12, 2024
b2a2cf3
refactor: setup heads into the components
jonathangoulding Jun 12, 2024
aadb1b9
chore: remove only tag
jonathangoulding Jun 12, 2024
48d5c60
test: fix service test status map
jonathangoulding Jun 12, 2024
e460d53
Merge branch 'main' into feature-view-licence-returns-requirements
jonathangoulding Jun 12, 2024
8bf5f57
test: fix service test status map
jonathangoulding Jun 12, 2024
14b7562
test: fix feature flag test with stub
jonathangoulding Jun 12, 2024
1bc85da
Update app/presenters/licences/set-up.presenter.js
jonathangoulding Jun 12, 2024
01cd54b
refactor: feature toggle into the presenter logic
jonathangoulding Jun 12, 2024
7972fa3
Merge branch 'main' into feature-view-licence-returns-requirements
jonathangoulding Jun 12, 2024
21b2b10
Merge branch 'main' into feature-view-licence-returns-requirements
jonathangoulding Jun 12, 2024
189c99b
Merge branch 'main' into feature-view-licence-returns-requirements
jonathangoulding Jun 13, 2024
56e4d77
Update app/services/licences/fetch-return-versions.service.js
jonathangoulding Jun 13, 2024
8d54263
fix: unnecessary double if to if else
jonathangoulding Jun 13, 2024
c725de6
Merge remote-tracking branch 'origin/feature-view-licence-returns-req…
jonathangoulding Jun 13, 2024
1637876
fix: feature flag location
jonathangoulding Jun 13, 2024
de0608f
fix: feature flag in service test
jonathangoulding Jun 13, 2024
2f245b5
fix: feature flag in service test
jonathangoulding Jun 13, 2024
e6ccb57
Merge branch 'main' into feature-view-licence-returns-requirements
jonathangoulding Jun 13, 2024
d49b1e1
chore: nit function alpha order
jonathangoulding Jun 13, 2024
2d92bb7
chore: sinon restore
jonathangoulding Jun 13, 2024
ee0b663
Merge branch 'main' into feature-view-licence-returns-requirements
jonathangoulding Jun 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions app/presenters/licences/set-up.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,38 @@ const agreementDescriptions = {
*
* @param {module:ChargeVersionModel[]} chargeVersions - All charge versions records for the licence
* @param {module:WorkflowModel[]} workflows - All in-progress workflow records for the licence
* @param {module:LicenceAgreements[]} agreements - All agreements records for the licence
* @param {module:LicenceAgreementModel[]} agreements - All agreements records for the licence
* @param {module:ReturnVersionModel[]} returnVersions - All returns version records for the licence
* @param {Object} auth - The auth object taken from `request.auth` containing user details
* @param {Object} commonData - Licence data already formatted for the view's shared elements
* @param {boolean} enableRequirementsForReturns - feature toggle for the return versions links
*
* @returns {Object} The data formatted for the view template
*/
function go (chargeVersions, workflows, agreements, returnVersions, auth, commonData) {
function go (chargeVersions, workflows, agreements, returnVersions, auth, commonData, enableRequirementsForReturns) {
jonathangoulding marked this conversation as resolved.
Show resolved Hide resolved
return {
links: {
chargeInformation: _chargeInformationLinks(auth, commonData),
agreements: _agreementLinks(auth, commonData),
returnVersions: {
returnsRequired: `/system/licences/${commonData.licenceId}/returns-required`,
noReturnsRequired: `/system/licences/${commonData.licenceId}/no-returns-required`
}
returnVersions: _returnVersionsLinks(commonData, enableRequirementsForReturns)
},
agreements: _agreements(commonData, agreements, auth),
chargeInformation: _chargeInformation(chargeVersions, workflows, auth),
returnVersions: _returnsVersions(returnVersions)
returnVersions: _returnVersions(returnVersions)
}
}

function _returnVersionsLinks (commonData, enableRequirementsForReturns) {
if (enableRequirementsForReturns) {
return {
returnsRequired: `/system/licences/${commonData.licenceId}/returns-required`,
noReturnsRequired: `/system/licences/${commonData.licenceId}/no-returns-required`
}
}

return {}
}
jonathangoulding marked this conversation as resolved.
Show resolved Hide resolved

function _agreements (commonData, agreements, auth) {
return agreements.map((agreement) => {
return {
Expand Down Expand Up @@ -170,7 +179,7 @@ function _financialAgreementCode (agreement) {
return agreement.financialAgreements[0].financialAgreementCode
}

function _returnsVersions (returnVersions = [{}]) {
function _returnVersions (returnVersions = [{}]) {
return returnVersions.map((returnVersion) => {
return {
action: [{
Expand Down
5 changes: 2 additions & 3 deletions app/services/licences/view-licence-set-up.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ async function go (licenceId, auth) {
const returnVersions = await FetchReturnVersionsService.go(licenceId)

const licenceSetUpData = SetUpPresenter
.go(chargeVersions, workflows, agreements, returnVersions, auth, commonData)
.go(chargeVersions, workflows, agreements, returnVersions, auth, commonData, FeatureFlagsConfig.enableRequirementsForReturns)

return {
activeTab: 'set-up',
...commonData,
...licenceSetUpData,
enableRequirementsForReturns: FeatureFlagsConfig.enableRequirementsForReturns
...licenceSetUpData
}
}

Expand Down
3 changes: 1 addition & 2 deletions app/views/licences/tabs/set-up.njk
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
rows: returnVersionsTableRows
}) }}
{% endif %}
{% if enableRequirementsForReturns %}

{% if links.returnVersions.returnsRequired %}
<p>
{{ govukButton({
Expand All @@ -82,7 +82,6 @@
}) }}
</p>
{% endif %}
{% endif %}

<h3 class="govuk-heading-m"> Charge information </h3>

Expand Down
2 changes: 0 additions & 2 deletions test/controllers/licences.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ describe('Licences controller', () => {
activeTab: 'set-up',
agreements: [],
chargeInformation: [],
enableRequirementsForReturns: true,
returnVersions: []
})
})
Expand All @@ -378,7 +377,6 @@ describe('Licences controller', () => {
activeTab: 'set-up',
agreements: [],
chargeInformation: [],
enableRequirementsForReturns: false,
returnVersions: []
})
})
Expand Down
Loading
Loading