Skip to content

Commit

Permalink
Update the mangement report to remove the buyer details if the bueyer…
Browse files Browse the repository at this point in the history
… has not opted in
  • Loading branch information
tim-s-ccs committed Apr 26, 2023
1 parent 0ba473f commit f20b273
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Admin::ProcurementCsvExport
'Buyer contact job title',
'Buyer contact email address',
'Buyer contact telephone number',
'Buyer opted in to be contacted',
'Services',
'Regions',
'Annual contract cost',
Expand Down Expand Up @@ -42,10 +43,11 @@ def self.create_procurement_row(procurement)
procurement.user.buyer_detail.organisation_name,
procurement.user.buyer_detail.full_organisation_address,
procurement.user.buyer_detail.central_government ? 'Central government' : 'Wider public sector',
procurement.user.buyer_detail.full_name,
procurement.user.buyer_detail.job_title, # 10
procurement.user.email,
string_as_formula(procurement.user.buyer_detail.telephone_number),
procurement.user.buyer_detail.contact_opt_in ? procurement.user.buyer_detail.full_name : '',
procurement.user.buyer_detail.job_title,
procurement.user.buyer_detail.contact_opt_in ? procurement.user.email : '',
procurement.user.buyer_detail.contact_opt_in ? string_as_formula(procurement.user.buyer_detail.telephone_number) : '',
procurement.user.buyer_detail.contact_opt_in ? 'Yes' : 'No',
expand_services(procurement.service_codes),
expand_regions(procurement.region_codes),
delimited_contract_value(procurement.annual_contract_value),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</p>
<% end %>
<p>
<%= t('.date_range_of_report', start_date: @management_report.start_date.strftime('%d/%-m/%Y'), end_date: @management_report.end_date.strftime('%d/%-m/%Y')) %>
<%= t('.date_range_of_report', start_date: @management_report.start_date.strftime('%d/%m/%Y'), end_date: @management_report.end_date.strftime('%d/%m/%Y')) %>
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
end

Then('the management report has the correct date range') do
date_range = "The date range for this report is: #{Time.zone.yesterday.strftime('%d/%-m/%Y')} - #{Time.zone.today.strftime('%d/%-m/%Y')}"
date_range = "The date range for this report is: #{Time.zone.yesterday.strftime('%d/%m/%Y')} - #{Time.zone.today.strftime('%d/%m/%Y')}"

expect(admin_page.management_report_date).to have_content(date_range)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
let(:user_1) { create(:user, :with_detail) }
let(:user_2) { create(:user) }

let(:buyer_detail) { create(:buyer_detail, user: user_2, full_name: 'Obi-Wan Kenobi', job_title: 'Jedi', telephone_number: '0750050607', organisation_name: 'The Jedi Council', organisation_address_line_1: 'The Jedi Temple', organisation_address_line_2: nil, organisation_address_town: 'Coruscant', organisation_address_county: nil, organisation_address_postcode: 'SW1R 0TS', central_government: false) }
let(:buyer_detail) { create(:buyer_detail, user: user_2, full_name: 'Obi-Wan Kenobi', job_title: 'Jedi', telephone_number: '0750050607', organisation_name: 'The Jedi Council', organisation_address_line_1: 'The Jedi Temple', organisation_address_line_2: nil, organisation_address_town: 'Coruscant', organisation_address_county: nil, organisation_address_postcode: 'SW1R 0TS', central_government: false, contact_opt_in: true) }

let(:procurement_1) { create(:facilities_management_rm6232_procurement_what_happens_next, user: user_1, created_at: 3.days.ago, contract_name: 'Procurement 1') }
let(:procurement_2) { create(:facilities_management_rm6232_procurement_what_happens_next, user: user_2, created_at: 2.days.ago, contract_name: 'Procurement 2', contract_number: 'RM6232-000002-2022') }
Expand Down Expand Up @@ -95,15 +95,36 @@
let(:generated_csv) { CSV.parse(management_report.management_report_csv.download) }

it 'has the correct headers' do
expect(generated_csv.first).to eq ['Reference number', 'Contract name', 'Date created', 'Buyer organisation', 'Buyer organisation address', 'Buyer sector', 'Buyer contact name', 'Buyer contact job title', 'Buyer contact email address', 'Buyer contact telephone number', 'Services', 'Regions', 'Annual contract cost', 'Lot', 'Shortlisted Suppliers']
expect(generated_csv.first).to eq ['Reference number', 'Contract name', 'Date created', 'Buyer organisation', 'Buyer organisation address', 'Buyer sector', 'Buyer contact name', 'Buyer contact job title', 'Buyer contact email address', 'Buyer contact telephone number', 'Buyer opted in to be contacted', 'Services', 'Regions', 'Annual contract cost', 'Lot', 'Shortlisted Suppliers']
end

# rubocop:disable RSpec/MultipleExpectations
it 'has the correct data' do
expect(generated_csv[1][0..1] + generated_csv[1][3..]).to eq ['RM6232-000004-2022', 'Procurement 4', 'The Jedi Council', 'The Jedi Temple, Coruscant SW1R 0TS', 'Wider public sector', 'Obi-Wan Kenobi', 'Jedi', user_2.email, '="0750050607"', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKN01 Belfast;\n", '5,000,000.00', '2a', "Conn, Hayes and Lakin;\nDach Inc;\nDonnelly, Wiegand and Krajcik;\nEmard, Green and Zboncak;\nFeest Group;\nHowell, Sanford and Shanahan;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nSchulist-Wuckert;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurcotte and Sons;\nTurner-Pouros"]
expect(generated_csv[2][0..1] + generated_csv[2][3..]).to eq ['RM6232-000003-2022', 'Procurement 3', 'MyString', 'MyString, MyString, MyString, MyString SW1W 9SZ', 'Central government', 'MyString', 'MyString', user_1.email, '="07500404040"', "E.1 Mechanical and Electrical Engineering Maintenance;\nG.1 Hard Landscaping Services;\nJ.1 Mail Services;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '50,000,000.00', '1c', "Berge-Koepp;\nBernier, Luettgen and Bednar;\nBins, Yost and Donnelly;\nBlick, O'Kon and Larkin;\nBreitenberg-Mante;\nCummerata, Lubowitz and Ebert;\nGoyette Group;\nHarris LLC;\nHeidenreich Inc;\nLind, Stehr and Dickinson;\nLowe, Abernathy and Toy;\nMiller, Walker and Leffler;\nMuller Inc;\nRohan-Windler;\nSatterfield LLC;\nSchmeler Inc;\nSchmeler-Leffler;\nSchultz-Wilkinson;\nTerry-Greenholt;\nYost LLC;\nZboncak and Sons"]
expect(generated_csv[3][0..1] + generated_csv[3][3..]).to eq ['RM6232-000002-2022', 'Procurement 2', 'The Jedi Council', 'The Jedi Temple, Coruscant SW1R 0TS', 'Wider public sector', 'Obi-Wan Kenobi', 'Jedi', user_2.email, '="0750050607"', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '12,345.00', '2a', "Abshire, Schumm and Farrell;\nBrakus, Lueilwitz and Blanda;\nConn, Hayes and Lakin;\nDach Inc;\nFeest Group;\nHarber LLC;\nHudson, Spinka and Schuppe;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nO'Reilly, Emmerich and Reichert;\nRoob-Kessler;\nSchulist-Wuckert;\nSkiles LLC;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurner-Pouros"]
expect(generated_csv[4][0..1] + generated_csv[4][3..]).to eq ['RM6232-000001-2022', 'Procurement 1', 'MyString', 'MyString, MyString, MyString, MyString SW1W 9SZ', 'Central government', 'MyString', 'MyString', user_1.email, '="07500404040"', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '12,345.00', '2a', "Abshire, Schumm and Farrell;\nBrakus, Lueilwitz and Blanda;\nConn, Hayes and Lakin;\nDach Inc;\nFeest Group;\nHarber LLC;\nHudson, Spinka and Schuppe;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nO'Reilly, Emmerich and Reichert;\nRoob-Kessler;\nSchulist-Wuckert;\nSkiles LLC;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurner-Pouros"]
expect(generated_csv[1][0..1] + generated_csv[1][3..]).to eq ['RM6232-000004-2022', 'Procurement 4', 'The Jedi Council', 'The Jedi Temple, Coruscant SW1R 0TS', 'Wider public sector', 'Obi-Wan Kenobi', 'Jedi', user_2.email, '="0750050607"', 'Yes', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKN01 Belfast;\n", '5,000,000.00', '2a', "Conn, Hayes and Lakin;\nDach Inc;\nDonnelly, Wiegand and Krajcik;\nEmard, Green and Zboncak;\nFeest Group;\nHowell, Sanford and Shanahan;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nSchulist-Wuckert;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurcotte and Sons;\nTurner-Pouros"]
expect(generated_csv[2][0..1] + generated_csv[2][3..]).to eq ['RM6232-000003-2022', 'Procurement 3', 'MyString', 'MyString, MyString, MyString, MyString SW1W 9SZ', 'Central government', 'MyString', 'MyString', user_1.email, '="07500404040"', 'Yes', "E.1 Mechanical and Electrical Engineering Maintenance;\nG.1 Hard Landscaping Services;\nJ.1 Mail Services;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '50,000,000.00', '1c', "Berge-Koepp;\nBernier, Luettgen and Bednar;\nBins, Yost and Donnelly;\nBlick, O'Kon and Larkin;\nBreitenberg-Mante;\nCummerata, Lubowitz and Ebert;\nGoyette Group;\nHarris LLC;\nHeidenreich Inc;\nLind, Stehr and Dickinson;\nLowe, Abernathy and Toy;\nMiller, Walker and Leffler;\nMuller Inc;\nRohan-Windler;\nSatterfield LLC;\nSchmeler Inc;\nSchmeler-Leffler;\nSchultz-Wilkinson;\nTerry-Greenholt;\nYost LLC;\nZboncak and Sons"]
expect(generated_csv[3][0..1] + generated_csv[3][3..]).to eq ['RM6232-000002-2022', 'Procurement 2', 'The Jedi Council', 'The Jedi Temple, Coruscant SW1R 0TS', 'Wider public sector', 'Obi-Wan Kenobi', 'Jedi', user_2.email, '="0750050607"', 'Yes', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '12,345.00', '2a', "Abshire, Schumm and Farrell;\nBrakus, Lueilwitz and Blanda;\nConn, Hayes and Lakin;\nDach Inc;\nFeest Group;\nHarber LLC;\nHudson, Spinka and Schuppe;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nO'Reilly, Emmerich and Reichert;\nRoob-Kessler;\nSchulist-Wuckert;\nSkiles LLC;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurner-Pouros"]
expect(generated_csv[4][0..1] + generated_csv[4][3..]).to eq ['RM6232-000001-2022', 'Procurement 1', 'MyString', 'MyString, MyString, MyString, MyString SW1W 9SZ', 'Central government', 'MyString', 'MyString', user_1.email, '="07500404040"', 'Yes', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '12,345.00', '2a', "Abshire, Schumm and Farrell;\nBrakus, Lueilwitz and Blanda;\nConn, Hayes and Lakin;\nDach Inc;\nFeest Group;\nHarber LLC;\nHudson, Spinka and Schuppe;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nO'Reilly, Emmerich and Reichert;\nRoob-Kessler;\nSchulist-Wuckert;\nSkiles LLC;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurner-Pouros"]
end
# rubocop:enable RSpec/MultipleExpectations
end

context 'when the buyer has not opted into being contacted' do
let(:start_date) { 5.days.ago }
let(:end_date) { Time.zone.now }
let(:buyer_detail) { create(:buyer_detail, user: user_2, full_name: 'Obi-Wan Kenobi', job_title: 'Jedi', telephone_number: '0750050607', organisation_name: 'The Jedi Council', organisation_address_line_1: 'The Jedi Temple', organisation_address_line_2: nil, organisation_address_town: 'Coruscant', organisation_address_county: nil, organisation_address_postcode: 'SW1R 0TS', central_government: false, contact_opt_in: false) }

let(:generated_csv) { CSV.parse(management_report.management_report_csv.download) }

it 'has the correct headers' do
expect(generated_csv.first).to eq ['Reference number', 'Contract name', 'Date created', 'Buyer organisation', 'Buyer organisation address', 'Buyer sector', 'Buyer contact name', 'Buyer contact job title', 'Buyer contact email address', 'Buyer contact telephone number', 'Buyer opted in to be contacted', 'Services', 'Regions', 'Annual contract cost', 'Lot', 'Shortlisted Suppliers']
end

# rubocop:disable RSpec/MultipleExpectations
it 'has blank contact data for user 2' do
expect(generated_csv[1][0..1] + generated_csv[1][3..]).to eq ['RM6232-000004-2022', 'Procurement 4', 'The Jedi Council', 'The Jedi Temple, Coruscant SW1R 0TS', 'Wider public sector', '', 'Jedi', '', '', 'No', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKN01 Belfast;\n", '5,000,000.00', '2a', "Conn, Hayes and Lakin;\nDach Inc;\nDonnelly, Wiegand and Krajcik;\nEmard, Green and Zboncak;\nFeest Group;\nHowell, Sanford and Shanahan;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nSchulist-Wuckert;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurcotte and Sons;\nTurner-Pouros"]
expect(generated_csv[2][0..1] + generated_csv[2][3..]).to eq ['RM6232-000003-2022', 'Procurement 3', 'MyString', 'MyString, MyString, MyString, MyString SW1W 9SZ', 'Central government', 'MyString', 'MyString', user_1.email, '="07500404040"', 'Yes', "E.1 Mechanical and Electrical Engineering Maintenance;\nG.1 Hard Landscaping Services;\nJ.1 Mail Services;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '50,000,000.00', '1c', "Berge-Koepp;\nBernier, Luettgen and Bednar;\nBins, Yost and Donnelly;\nBlick, O'Kon and Larkin;\nBreitenberg-Mante;\nCummerata, Lubowitz and Ebert;\nGoyette Group;\nHarris LLC;\nHeidenreich Inc;\nLind, Stehr and Dickinson;\nLowe, Abernathy and Toy;\nMiller, Walker and Leffler;\nMuller Inc;\nRohan-Windler;\nSatterfield LLC;\nSchmeler Inc;\nSchmeler-Leffler;\nSchultz-Wilkinson;\nTerry-Greenholt;\nYost LLC;\nZboncak and Sons"]
expect(generated_csv[3][0..1] + generated_csv[3][3..]).to eq ['RM6232-000002-2022', 'Procurement 2', 'The Jedi Council', 'The Jedi Temple, Coruscant SW1R 0TS', 'Wider public sector', '', 'Jedi', '', '', 'No', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '12,345.00', '2a', "Abshire, Schumm and Farrell;\nBrakus, Lueilwitz and Blanda;\nConn, Hayes and Lakin;\nDach Inc;\nFeest Group;\nHarber LLC;\nHudson, Spinka and Schuppe;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nO'Reilly, Emmerich and Reichert;\nRoob-Kessler;\nSchulist-Wuckert;\nSkiles LLC;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurner-Pouros"]
expect(generated_csv[4][0..1] + generated_csv[4][3..]).to eq ['RM6232-000001-2022', 'Procurement 1', 'MyString', 'MyString, MyString, MyString, MyString SW1W 9SZ', 'Central government', 'MyString', 'MyString', user_1.email, '="07500404040"', 'Yes', "E.1 Mechanical and Electrical Engineering Maintenance;\nE.2 Ventilation and air conditioning systems maintenance;\n", "UKI4 Inner London - East;\nUKI5 Outer London - East and North East;\n", '12,345.00', '2a', "Abshire, Schumm and Farrell;\nBrakus, Lueilwitz and Blanda;\nConn, Hayes and Lakin;\nDach Inc;\nFeest Group;\nHarber LLC;\nHudson, Spinka and Schuppe;\nJenkins, Price and White;\nKirlin-Glover;\nMetz Inc;\nMoore Inc;\nO'Reilly, Emmerich and Reichert;\nRoob-Kessler;\nSchulist-Wuckert;\nSkiles LLC;\nTorphy Inc;\nTremblay, Jacobi and Kozey;\nTurner-Pouros"]
end
# rubocop:enable RSpec/MultipleExpectations
end
Expand Down

0 comments on commit f20b273

Please sign in to comment.