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

GL-385: Create the first two steps of the Check Moving Requirement user journey #1897

Merged
merged 14 commits into from
May 24, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ BETA_SEARCH_SWITCHING_ENABLED=true
DUTY_CALCULATOR=true
DUTY_CALCULATOR_BASE_URL=http://localhost:3002/duty-calculator
FRONTEND_HOST=http://localhost
GREEN_LANES_ENABLED=true
HTTPARTY_READ_TIMEOUT=661
PERMUTATIONS=true
PORT=3001
Expand All @@ -28,4 +29,3 @@ TARIFF_SUPPORT_EMAIL=support@example.com
UPDATED_NAVIGATION=true
WEBCHAT_URL='test-online-services-helpdesk'
WELSH=true
ALLOW_GREEN_LANE=true
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cf 7.1.0
yarn 1.22.10
nodejs 16.13.1
nodejs 20.8.0
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def ca_search_params
end

def check_allowed
raise TradeTariffFrontend::FeatureUnavailable unless TradeTariffFrontend.green_lane_allowed?
raise TradeTariffFrontend::FeatureUnavailable unless TradeTariffFrontend.green_lanes_enabled?
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module GreenLanes
class CheckMovingRequirementsController < ApplicationController
before_action :check_moving_requirements,
:disable_switch_service_banner,
:disable_search_form

def start
@commodity_code = params[:code]
render 'start'
end

def edit
@commodity_code = params[:code]
@check_moving_requirements_form = CheckMovingRequirementsForm.new(commodity_code: @commodity_code)

render 'edit'
end

def update
@check_moving_requirements_form = CheckMovingRequirementsForm.new(check_moving_requirements_params)

if @check_moving_requirements_form.valid?
redirect_to result_green_lanes_check_moving_requirements_path
else
render 'edit', status: :unprocessable_entity
end
end

private

def check_moving_requirements_params
params.require(:green_lanes_check_moving_requirements_form).permit(
:commodity_code,
:country_of_origin,
:moving_date,
)
end

def check_moving_requirements
unless TradeTariffFrontend.green_lanes_enabled?
raise TradeTariffFrontend::FeatureUnavailable
end
end
end
end
17 changes: 17 additions & 0 deletions app/forms/green_lanes/check_moving_requirements_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module GreenLanes
class CheckMovingRequirementsForm
include ActiveModel::Model
include ActiveModel::Attributes
include ActiveRecord::AttributeAssignment

attribute :commodity_code, :string
attribute :country_of_origin, :string
attribute :moving_date, :date

validates :commodity_code, length: { is: 10 },
format: { with: /\A\d+\z/, message: :only_numbers }

validates :country_of_origin, presence: true
validates :moving_date, presence: true
end
end
68 changes: 68 additions & 0 deletions app/views/green_lanes/check_moving_requirements/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<%= back_link start_green_lanes_check_moving_requirements_path %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<header>
<span class="govuk-caption-xl">
Check arrangements for internal market movements
</span>

<h1 class="govuk-heading-l">
Tell us about your movement of goods
</h1>
</header>

<%= form_for @check_moving_requirements_form, builder: GOVUKDesignSystemFormBuilder::FormBuilder,
method: :put,
url: green_lanes_check_moving_requirements_path do |f| %>

<%= f.govuk_error_summary %>

<p>Details provided will help us display specific requirements for your goods.</p>

<%= f.govuk_text_field :commodity_code, maxlength: 10,
label: { text: "What is your commodity code?", size: 's'},
hint: { text: "Commodity codes are internationally recognised reference numbers that describe specific goods." \
"Search the Online Trade Tariff if you're unsure of your commodity code.",
},
style: "width:330px"
%>

<%= f.govuk_collection_select :country_of_origin,
GreenLanes::CategoryAssessmentSearch.country_options,
:id,
:long_description,
options: { include_blank: '' },
label: { text: "What is the origin of your goods?", size: 's' },
hint: { text: "Origin allows for various policy measures to be implemented and for duties" \
"to be calculated. Find out more about origin if you're unsure which country to select.",
},
style: "width:330px"
%>

<%= f.label :commodity_code, "When is the movement of goods taking place?", class: 'govuk-heading-s',
for: 'green_lanes_check_moving_requirements_form_moving_date_3i' %>

<%= f.govuk_date_field :moving_date,
maxlength_enabled: true,
hint: { text: "Arrangements can change over time. If you are unsure of the date of " \
"movement and want to check arrangements currently in place, enter today's date.",
class: 'govuk-body-l'
},
legend: nil %>

<%= f.submit "Continue", class: "govuk-button" %>
<% end %>

<p class="govuk-heading-s govuk-!-static-margin-top-5">If you need help using this tool</p>
<p>
Contact xxxxxxx ...
</p>
<ul class="govuk-list govuk-list--bullet">
<li>aaaaa</i>
<li>bbbbb</i>
<li>ccccc</i>
</ul>
</div>
</div>
15 changes: 15 additions & 0 deletions app/views/green_lanes/check_moving_requirements/result.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% content_for :top_breadcrumbs do %>
<%= generate_breadcrumbs(
"Check measures for movements from GB to NI",
[
[t('breadcrumb.home'), home_path],
["Section", browse_sections_path],
]
) %>
<% end %>

<%= page_header do %>
<h1 class="govuk-heading-l">
Requirements for your movement of goods
</h1>
<% end %>
80 changes: 80 additions & 0 deletions app/views/green_lanes/check_moving_requirements/start.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<%= back_link home_path %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<header>
<h1 class="govuk-heading-l">
Check arrangements for internal market movements
</h1>
</header>

<p>
Use this tool if you are a trader moving goods from Great Britain to Northern Ireland and believe that your goods are 'not of risk' of onward movement to the EU.
<p>

<p>
For eligible goods moving from Great Britain to Northern Ireland, traders can benefit from a simplified process for internal market movements.
</p>

<p>
If you're based anywhere in the UK, you can join the UK Internal Market Scheme (UKIMS) to access the simplified process and benefit from reduced customs duties and checks.
</p>

<p>
Use this tool to:
<ul class="govuk-list govuk-list--bullet">
<li>check if your goods could be eligible for the simplified process for internal market movements</li>
<li>check measures, criteria and exemptions for the movements of goods from Great Britain to Northern Ireland</li>
<li>find information required for your necessary form submissions</li>
</ul>

<h3 class="govuk-heading-s">Before you start</h3>
<p>
You'll need to know:
<ul class="govuk-list govuk-list--bullet">
<li>that your goods are 'not at risk' of onward movement to the EU</li>
<li>the commodity code of the goods</li>
<li>the non-preferential origin of your goods</li>
<li>when the movement of goods is taking place</li>
</ul>
</p>

<%= button_to edit_green_lanes_check_moving_requirements_path,
method: :get,
params: { code: @commodity_code },
class: "govuk-button govuk-button--start" do %>

<span>Start now</span>
<%= render 'shared/start_arrow' %>
<% end %>

<p class="govuk-heading-s govuk-!-static-margin-top-5">If you need help using this tool</p>
<p>
Contact xxxxxxx ...
</p>
<ul class="govuk-list govuk-list--bullet">
<li>aaaaa</i>
<li>bbbbb</i>
<li>ccccc</i>
</ul>
</div>

<div class="govuk-grid-column-one-third">
<div class="gem-c-related-navigation">
<h2 class="gem-c-related-navigation__main-heading">
Subsections
</h2>

<nav class="gem-c-related-navigation__nav-section">
<ul class="gem-c-related-navigation__link-list">
<li class="gem-c-related-navigation__link">
<%= link_to 'Related Link 1', 'link1' %>
</li>
<li class="gem-c-related-navigation__link">
<%= link_to 'Related Link 2', 'link2' %>
</li>
</ul>
</nav>
</div>
</div>
</div>
4 changes: 1 addition & 3 deletions app/views/meursing_lookup/steps/_start.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@

<a href=<%= meursing_lookup_step_path('starch') %> role="button" draggable="false" class="govuk-button govuk-!-margin-top-2 govuk-!-margin-bottom-8 govuk-button--start" data-module="govuk-button">
Start now
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
</svg>
<%= render 'shared/start_arrow' %>
</a>

<h2 class="govuk-heading-m">Documents to download</h2>
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_feedback_useful_banner.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="feedback-useful-container">
<div class="govuk-footer__meta">
<div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
<p>is this page useful?</p>
<p>Is this page useful?</p>
<li class="govuk-footer__inline-list-item">
<%= link_to 'Yes', feedback_path(page_useful: 'yes'), class: 'govuk-button govuk-button--secondary' %>
</li>
Expand Down
3 changes: 3 additions & 0 deletions app/views/shared/_start_arrow.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
</svg>
10 changes: 10 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,16 @@ en:
rule:
inclusion: Select whether your goods meet any of these rules

green_lanes/check_moving_requirements_form:
attributes:
moving_date:
blank: Enter a valid date
country_of_origin:
blank: Select the country of origin
commodity_code:
wrong_length: Commodity code must have 10 digits
only_numbers: Commodity code must only contain numbers

helpers:
legend:
rules_of_origin_steps_scheme:
Expand Down
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@
scope constraints: ->(_req) { TradeTariffFrontend::ServiceChooser.uk? } do
namespace :green_lanes do
resource :category_assessments, only: %i[create show]

resource :check_moving_requirements, only: %i[update edit] do
get 'start'
get 'result'
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/trade_tariff_frontend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def legacy_results_to_show
ENV.fetch('LEGACY_RESULTS_TO_SHOW', '5').to_i
end

def green_lane_allowed?
ENV['ALLOW_GREEN_LANE'].to_s == 'true'
def green_lanes_enabled?
ENV['GREEN_LANES_ENABLED'].to_s == 'true'
end

def green_lanes_api_token
Expand Down
4 changes: 2 additions & 2 deletions spec/features/feedback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
expect(page).to have_css 'a', text: 'Yes'
expect(page).to have_css 'a', text: 'No'
expect(page).to have_css 'a', text: 'Report a problem with this page'
expect(page).to have_css 'p', text: 'is this page useful?'
expect(page).to have_css 'p', text: 'Is this page useful?'

click_on 'Yes'
expect(page).not_to have_css 'a', text: 'Yes'
expect(page).not_to have_css 'a', text: 'No'
expect(page).not_to have_css 'a', text: 'Report a problem with this page'
expect(page).not_to have_css 'p', text: 'is this page useful?'
expect(page).not_to have_css 'p', text: 'Is this page useful?'
end

scenario 'feedback banner is not shown on feedback page' do
Expand Down
35 changes: 35 additions & 0 deletions spec/forms/green_lanes/check_moving_requirements_form_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper'

RSpec.describe GreenLanes::CheckMovingRequirementsForm, type: :model do
describe 'validations' do
subject(:form) { described_class.new(params) }

before { form.valid? }

context 'when all the attributes are correct' do
let(:params) do
{
commodity_code: '1234567890',
country_of_origin: 'IT',
moving_date: { 1 => 1998, 2 => 12, 3 => 25 },
}
end

it { expect(form.errors).to be_empty }
end

context 'when the attributes are incorrect' do
let(:params) do
{
commodity_code: '12345AAA',
country_of_origin: '',
moving_date: { 1 => 1998, 2 => 12, 3 => nil },
}
end

it { expect(form.errors[:commodity_code]).to eq(['Commodity code must have 10 digits', 'Commodity code must only contain numbers']) }
it { expect(form.errors[:country_of_origin]).to eq(['Select the country of origin']) }
it { expect(form.errors[:moving_date]).to eq(['Enter a valid date']) }
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
subject { make_request && response }

before do
allow(TradeTariffFrontend).to receive(:green_lane_allowed?).and_return true
allow(TradeTariffFrontend).to receive(:green_lanes_enabled?).and_return true
allow(TradeTariffFrontend).to receive(:green_lanes_api_token).and_return ''
allow(GeographicalArea).to receive(:all).and_return countries
end
Expand Down Expand Up @@ -94,7 +94,7 @@

context 'when green lanes is not allowed' do
before do
allow(TradeTariffFrontend).to receive(:green_lane_allowed?).and_return false
allow(TradeTariffFrontend).to receive(:green_lanes_enabled?).and_return false
end

let(:make_request) { get green_lanes_category_assessments_path }
Expand Down