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

OTT-136 Hierarchy report added with new flag #1812

Open
wants to merge 5 commits into
base: OTT-124-Differences-Report-Feature
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions app/lib/reporting/differences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def generate(only: [])
add_missing_from_uk_worksheet
add_missing_from_xi_worksheet
add_indentation_worksheet
add_hierarchy_worksheet
add_overview_worksheet
]
# methods = %i[
Expand Down
25 changes: 25 additions & 0 deletions app/lib/reporting/differences/hierarchy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Hierarchy
:bold_style,
:uk_goods_nomenclatures,
:xi_goods_nomenclatures,
:uk_goods_nomenclatures_for_comparison,
:xi_goods_nomenclatures_for_comparison,
to: :report

WORKSHEET_NAME = 'Hierarchy differences'.freeze
Expand All @@ -14,6 +16,7 @@ class Hierarchy
'Commodity code (PLS)',
'UK hiearchy',
'EU hierarchy',
'New',
].freeze

TAB_COLOR = 'cc0000'.freeze
Expand All @@ -24,6 +27,7 @@ class Hierarchy
20, # Commodity code (PLS)
20, # UK hierarchy
20, # EU hierarchy
20, # New
].freeze

FROZEN_VIEW_STARTING_CELL = 'A2'.freeze
Expand All @@ -44,6 +48,9 @@ def add_worksheet

rows.compact.each do |row|
report.increment_count(name)
if row.last # last value in a row array is new_issue
report.increment_new_issue_count(name)
end
sheet.add_row(row, types: CELL_TYPES, style: regular_style)
end

Expand Down Expand Up @@ -79,10 +86,16 @@ def build_row_for(matching)

item_id, pls = matching_uk_goods_nomenclature['ItemIDPlusPLS'].split('_')

matching_uk_goods_nomenclature_for_comparison = uk_goods_nomenclature_ids_for_comparison[matching]
matching_xi_goods_nomenclature_for_comparison = xi_goods_nomenclature_ids_for_comparison[matching]

new_issue = matching_uk_goods_nomenclature_for_comparison.nil? || matching_xi_goods_nomenclature_for_comparison.nil? || matching_uk_goods_nomenclature_for_comparison['Hierarchy'] == matching_xi_goods_nomenclature_for_comparison['Hierarchy']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new_issue = matching_uk_goods_nomenclature_for_comparison.nil? || matching_xi_goods_nomenclature_for_comparison.nil? || matching_uk_goods_nomenclature_for_comparison['Hierarchy'] == matching_xi_goods_nomenclature_for_comparison['Hierarchy']
new_issue = matching_uk_goods_nomenclature_for_comparison.present? &&
matching_xi_goods_nomenclature_for_comparison.present? &&
matching_uk_goods_nomenclature_for_comparison['Hierarchy'] == matching_xi_goods_nomenclature_for_comparison['Hierarchy']


[
"#{item_id} (#{pls})",
matching_uk_goods_nomenclature['Hierarchy'],
matching_xi_goods_nomenclature['Hierarchy'],
new_issue,
]
end

Expand All @@ -97,6 +110,18 @@ def xi_goods_nomenclature_ids
goods_nomenclature['ItemIDPlusPLS']
end
end

def uk_goods_nomenclature_ids_for_comparison
@uk_goods_nomenclature_ids_for_comparison ||= uk_goods_nomenclatures_for_comparison.index_by do |goods_nomenclature|
goods_nomenclature['ItemIDPlusPLS']
end
end

def xi_goods_nomenclature_ids_for_comparison
@xi_goods_nomenclature_ids_for_comparison ||= xi_goods_nomenclatures_for_comparison.index_by do |goods_nomenclature|
goods_nomenclature['ItemIDPlusPLS']
end
end
end
end
end