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

Returns required - Select an existing return requirement from basic page #746

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
20 changes: 20 additions & 0 deletions app/controllers/return-requirements.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ async function checkYourAnswers (request, h) {
})
}

async function existing (request, h) {
const { sessionId } = request.params

const session = await SessionModel.query().findById(sessionId)

return h.view('return-requirements/existing.njk', {
activeNavBar: 'search',
pageTitle: 'Select an existing return requirement from',
...session
})
}

async function frequencyCollected (request, h) {
const { sessionId } = request.params

Expand Down Expand Up @@ -213,6 +225,12 @@ async function submitCheckYourAnswers (request, h) {
return h.redirect(`/system/return-requirements/${licenceId}/approved`)
}

async function submitExisting (request, h) {
const { sessionId } = request.params

return h.redirect(`/system/return-requirements/${sessionId}/check-your-answers`)
}

async function submitFrequencyCollected (request, h) {
const { sessionId } = request.params

Expand Down Expand Up @@ -307,6 +325,7 @@ module.exports = {
agreementsExceptions,
approved,
checkYourAnswers,
existing,
frequencyCollected,
frequencyReported,
noReturnsRequired,
Expand All @@ -321,6 +340,7 @@ module.exports = {
submitAddNote,
submitAgreementsExceptions,
submitCheckYourAnswers,
submitExisting,
submitFrequencyCollected,
submitFrequencyReported,
submitNoReturnsRequired,
Expand Down
26 changes: 26 additions & 0 deletions app/routes/return-requirement.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,32 @@ const routes = [
description: 'Submit check your answers'
}
},
{
method: 'GET',
path: '/return-requirements/{sessionId}/existing',
handler: ReturnRequirementsController.existing,
options: {
auth: {
access: {
scope: ['billing']
}
},
description: 'Select an existing return requirement from'
}
},
{
method: 'POST',
path: '/return-requirements/{sessionId}/existing',
handler: ReturnRequirementsController.submitExisting,
options: {
auth: {
access: {
scope: ['billing']
}
},
description: 'Submit an existing return requirement from'
}
},
{
method: 'GET',
path: '/return-requirements/{sessionId}/frequency-collected',
Expand Down
28 changes: 28 additions & 0 deletions app/views/return-requirements/existing.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% extends 'layout.njk' %}
{% from "govuk/components/back-link/macro.njk" import govukBackLink %}
{% from "govuk/components/button/macro.njk" import govukButton %}

{% set rootLink = "/system/return-requirements/" + id %}

{% block breadcrumbs %}
{# Back link #}
{{
govukBackLink({
text: 'Back',
href: rootLink + "/setup"
})
}}
{% endblock %}

{% block content %}
{# Main heading #}
<div class="govuk-body">
<h1 class="govuk-heading-xl govuk-!-margin-bottom-3">{{ pageTitle }}</h1>
</div>

<form method="post">
<div class="govuk-body">
{{ govukButton({ text: "Continue" }) }}
</div>
</form>
{% endblock %}
11 changes: 11 additions & 0 deletions test/controllers/return-requirements.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ describe('Return requirements controller', () => {
})
})

describe('GET /return-requirements/{sessionId}/existing', () => {
describe('when the request succeeds', () => {
it('returns the page successfully', async () => {
const response = await server.inject(_options('existing'))

expect(response.statusCode).to.equal(200)
expect(response.payload).to.contain('Select an existing return requirement from')
})
})
})

describe('GET /return-requirements/{sessionId}/frequency-collected', () => {
describe('when the request succeeds', () => {
it('returns the page successfully', async () => {
Expand Down
Loading