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-139 End Date report added with new flag #1821

Closed
wants to merge 2 commits into from
Closed
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
46 changes: 20 additions & 26 deletions app/lib/reporting/differences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,34 +129,28 @@ def generate(only: [])
add_missing_from_uk_worksheet
add_missing_from_xi_worksheet
add_indentation_worksheet
add_hierarchy_worksheet
add_endline_worksheet
add_start_date_worksheet
add_end_date_worksheet
add_mfn_missing_worksheet
add_mfn_duplicated_worksheet
add_misapplied_action_code_worksheet
add_incomplete_measure_condition_worksheet
add_me32_worksheet
add_seasonal_worksheet
add_omitted_duty_measures_worksheet
add_missing_vat_measure_worksheet
add_missing_quota_origins_worksheet
add_measure_quota_coverage_worksheet
add_bad_quota_association_worksheet
add_quota_exclusion_misalignment_worksheet
add_missing_supplementary_units_from_uk_worksheet
add_missing_supplementary_units_from_xi_worksheet
add_candidate_supplementary_units
add_me16_worksheet
add_overview_worksheet
]
# methods = %i[
# add_missing_from_uk_worksheet
# add_missing_from_xi_worksheet
# add_indentation_worksheet
# add_hierarchy_worksheet
# add_endline_worksheet
# add_start_date_worksheet
# add_end_date_worksheet
# add_mfn_missing_worksheet
# add_mfn_duplicated_worksheet
# add_misapplied_action_code_worksheet
# add_incomplete_measure_condition_worksheet
# add_me32_worksheet
# add_seasonal_worksheet
# add_omitted_duty_measures_worksheet
# add_missing_vat_measure_worksheet
# add_missing_quota_origins_worksheet
# add_measure_quota_coverage_worksheet
# add_bad_quota_association_worksheet
# add_quota_exclusion_misalignment_worksheet
# add_missing_supplementary_units_from_uk_worksheet
# add_missing_supplementary_units_from_xi_worksheet
# add_candidate_supplementary_units
# add_me16_worksheet
# add_overview_worksheet
# ]

methods = (methods & only) if only.any?

Expand Down
41 changes: 36 additions & 5 deletions app/lib/reporting/differences/goods_nomenclature_end_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class GoodsNomenclatureEndDate
:centered_style,
:uk_goods_nomenclatures,
:xi_goods_nomenclatures,
:uk_goods_nomenclatures_for_comparison,
:xi_goods_nomenclatures_for_comparison,
to: :report

WORKSHEET_NAME = 'End date differences'.freeze
Expand All @@ -15,6 +17,7 @@ class GoodsNomenclatureEndDate
'Commodity code (PLS)',
'UK end date',
'EU end date',
'New',
].freeze

TAB_COLOR = 'cc0000'.freeze
Expand All @@ -25,6 +28,7 @@ class GoodsNomenclatureEndDate
20, # Commodity code (PLS)
20, # UK start date
20, # EU start date
20, # New
].freeze

FROZEN_VIEW_STARTING_CELL = 'A2'.freeze
Expand All @@ -45,6 +49,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 @@ -73,17 +80,29 @@ def build_row_for(matching)
matching_uk_goods_nomenclature = uk_goods_nomenclature_ids[matching]
matching_xi_goods_nomenclature = xi_goods_nomenclature_ids[matching]

uk_start_date = matching_uk_goods_nomenclature['End date']&.to_date&.strftime('%d/%m/%Y')
eu_start_date = matching_xi_goods_nomenclature['End date']&.to_date&.strftime('%d/%m/%Y')
uk_end_date = matching_uk_goods_nomenclature['End date']&.to_date&.strftime('%d/%m/%Y')
Copy link
Member

Choose a reason for hiding this comment

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

🙌

eu_end_date = matching_xi_goods_nomenclature['End date']&.to_date&.strftime('%d/%m/%Y')

return nil if uk_start_date == eu_start_date
return nil if uk_end_date == eu_end_date

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]

if matching_uk_goods_nomenclature_for_comparison.present? && matching_xi_goods_nomenclature_for_comparison.present?
uk_end_date_for_comparison = matching_uk_goods_nomenclature_for_comparison['End date']&.to_date&.strftime('%d/%m/%Y')
eu_end_date_for_comparison = matching_xi_goods_nomenclature_for_comparison['End date']&.to_date&.strftime('%d/%m/%Y')
new_issue = uk_end_date_for_comparison == eu_end_date_for_comparison
else
new_issue = true
end

[
"#{item_id} (#{pls})",
uk_start_date,
eu_start_date,
uk_end_date,
eu_end_date,
new_issue,
]
end

Expand All @@ -98,6 +117,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