Skip to content
This repository has been archived by the owner on Nov 22, 2017. It is now read-only.

Commit

Permalink
Headings have producline suffix of 80
Browse files Browse the repository at this point in the history
This is not document anywhere, but 6308000000 is a good example. There
are two headings with this goods code. The one with product line suffix
of 10 is wrapping/grouping heading and one with 80 is real one.
  • Loading branch information
saulius committed Sep 9, 2013
1 parent 4f1955a commit 00e1239
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/commodity.rb
Expand Up @@ -16,6 +16,7 @@ class Commodity < GoodsNomenclature
one_to_one :heading, dataset: -> {
actual_or_relevant(Heading)
.filter("goods_nomenclatures.goods_nomenclature_item_id LIKE ?", heading_id)
.filter(producline_suffix: 80)
}

one_to_one :chapter, dataset: -> {
Expand Down
25 changes: 25 additions & 0 deletions spec/models/commodity_spec.rb
Expand Up @@ -39,6 +39,31 @@
}
end
end

context 'heading with sub-headings' do
# Example from real world scenario
# https://www.pivotaltracker.com/story/show/55703384

let!(:sub_heading) { create :heading, goods_nomenclature_item_id: '6308000000',
goods_nomenclature_sid: 43837,
producline_suffix: '10',
validity_start_date: Date.new(1972,1,1) }
let!(:heading) { create :heading, goods_nomenclature_item_id: '6308000000',
goods_nomenclature_sid: 43838,
producline_suffix: '80',
validity_start_date: Date.new(1972,1,1) }
let!(:commodity) { create :commodity, :with_indent,
:with_description,
indents: 1,
goods_nomenclature_sid: 91335,
goods_nomenclature_item_id: '6308000015',
producline_suffix: '80',
validity_start_date: Date.new(2009,7,1) }

it 'correctly identifies heading' do
expect(commodity.heading).to eq heading
end
end
end

describe 'chapter' do
Expand Down

0 comments on commit 00e1239

Please sign in to comment.