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

Add quarterly returns submissions to check return versions #1489

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 8 additions & 2 deletions app/presenters/return-versions/setup/check/check.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

const { formatLongDate } = require('../../../base.presenter.js')
const { isQuarterlyReturnSubmissions } = require('../../../../lib/dates.lib.js')
const { returnRequirementReasons } = require('../../../../lib/static-lookups.lib.js')

/**
Expand All @@ -16,15 +17,20 @@ const { returnRequirementReasons } = require('../../../../lib/static-lookups.lib
* @returns {object} The data formatted for the view template
*/
function go (session) {
const { multipleUpload, id: sessionId, journey, licence, note, reason } = session
const {
id: sessionId, journey, licence, multipleUpload, note, reason,
returnVersionStartDate, quarterlyReturns
} = session

const returnsRequired = journey === 'returns-required'

return {
multipleUpload,
licenceRef: licence.licenceRef,
multipleUpload,
note: _note(note),
pageTitle: `Check the requirements for returns for ${licence.licenceHolder}`,
quarterlyReturnSubmissions: isQuarterlyReturnSubmissions(returnVersionStartDate),
quarterlyReturns,
reason: returnRequirementReasons[reason],
reasonLink: _reasonLink(sessionId, returnsRequired),
sessionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
{
value: "quarterly-returns",
text: "Quarterly returns submissions",
text: "Quarterly return submissions",
checked: quarterlyReturns,
hint: {
text: "Allow water companies to submit daliy readings each quarter."
Expand Down
10 changes: 10 additions & 0 deletions app/views/return-versions/setup/check.njk
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,17 @@
value: {
text: 'Yes' if multipleUpload else "No"
}
},
{
classes: 'govuk-summary-list govuk-summary-list__row--no-border',
key: {
text: 'Quarterly return submissions',
classes: "govuk-body "
},
value: {
text: 'Yes' if quarterlyReturns else "No"
}
}if quarterlyReturnSubmissions
]
}) }}
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ describe('Return Versions Setup - Check presenter', () => {
text: 'No notes added'
},
pageTitle: 'Check the requirements for returns for Turbo Kid',
quarterlyReturnSubmissions: false,
quarterlyReturns: undefined,
reason: 'Major change',
reasonLink: '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/reason',
sessionId: '61e07498-f309-4829-96a9-72084a54996d',
Expand Down Expand Up @@ -80,6 +82,66 @@ describe('Return Versions Setup - Check presenter', () => {
})
})

describe('the "quarterlyReturns" property', () => {
describe('when there is a quarterlyReturns', () => {
beforeEach(() => {
session.quarterlyReturns = true
})

it('returns true', () => {
const result = CheckPresenter.go(session)

expect(result.quarterlyReturns).to.be.true()
})
})

describe('when there is not a quarterlyReturns', () => {
beforeEach(() => {
session.quarterlyReturns = false
})

it('returns false', () => {
const result = CheckPresenter.go(session)

expect(result.quarterlyReturns).to.be.false()
})
})

describe('when quarterlyReturns has not been set', () => {
it('returns undefined', () => {
const result = CheckPresenter.go(session)

expect(result.quarterlyReturns).to.be.undefined()
})
})
})

describe('the "quarterlyReturnSubmissions" property', () => {
describe('when the return version start date is for quarterly returns', () => {
beforeEach(() => {
session.returnVersionStartDate = '2025-04-01'
})

it('returns true', () => {
const result = CheckPresenter.go(session)

expect(result.quarterlyReturnSubmissions).to.be.true()
})
})

describe('when the return version start date is not for quarterly returns', () => {
beforeEach(() => {
session.returnVersionStartDate = '2001-01-01'
})

it('returns false', () => {
const result = CheckPresenter.go(session)

expect(result.quarterlyReturnSubmissions).to.be.false()
})
})
})

describe('the "note" property', () => {
describe('when the user has added a note', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ describe('Return Versions Setup - Check service', () => {
},
notification: undefined,
pageTitle: 'Check the requirements for returns for Turbo Kid',
quarterlyReturnSubmissions: false,
quarterlyReturns: undefined,
reason: 'Major change',
reasonLink: `/system/return-versions/setup/${session.id}/reason`,
requirements: [],
Expand Down
Loading