Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

...
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
12 app/models/concerns/declarable.rb
View
@@ -29,16 +29,14 @@ def code
end
def third_country_duty_measures
- import_measures.select(&:third_country_duty)
- end
-
- def third_country_duty
- third_country_duty_measures.sort_by(&:additional_code_code)
- .last
+ import_measures.select(&:third_country)
end
def third_country_duty_rate
- third_country_duty.try(:duty_expression)
+ third_country_duty_measures.select(&:third_country_duty)
+ .sort_by(&:additional_code_code)
+ .last
+ .try(:duty_expression)
end
end
end
2  app/views/measures/_measures.html.erb
View
@@ -22,7 +22,7 @@
<h1 class="visuallyhidden">Overview</h1>
<h2>Import</h2>
<p>The commodity code for importing is <em><%= declarable.code %></em>.</p>
- <% if declarable.third_country_duty.present? %>
+ <% if declarable.third_country_duty_rate.present? %>
<p>Importing from outside the EU is subject to a third country duty of <em><%= declarable.third_country_duty_rate %></em>.</p>
<% else %>
<p>Importing from outside the EU is subject to <em>variable</em> third country duty.</p>
10 spec/models/commodity_spec.rb
View
@@ -84,9 +84,9 @@
end
describe 'third country duty rate fetch' do
- let(:measure1) { attributes_for :measure, :third_country, measure_type_description: 'abc', additional_code: { code: '123' } }
- let(:measure2) { attributes_for :measure, :third_country, measure_type_description: 'def', additional_code: { code: '456' } }
- let(:measure3) { attributes_for :measure, measure_type_id: '911', measure_type_description: 'xyz' }
+ let(:measure1) { attributes_for :measure, :third_country, measure_type_description: 'abc', measure_components: [duty_amount: "10", duty_expression_id: "1"], additional_code: { code: '123' } }
+ let(:measure2) { attributes_for :measure, :third_country, measure_type_description: 'def', measure_components: [duty_amount: "20", duty_expression_id: "1"], additional_code: { code: '456' } }
+ let(:measure3) { attributes_for :measure, measure_type_id: '911', measure_type_description: 'xyz', geographical_area: attributes_for(:geographical_area) }
let(:measures) { [measure1, measure2, measure3] }
let(:commodity) { Commodity.new(attributes_for :commodity, import_measures: measures) }
@@ -101,9 +101,9 @@
end
end
- describe '#third_country_duty' do
+ describe '#third_country_duty_rate' do
it 'sorts commodities by additional code and picks the last one' do
- commodity.third_country_duty.measure_type_description.should eq 'def'
+ commodity.third_country_duty_rate.should eq '20.00 %'
end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.