Browse Source

CLDC-4162: Update BU test file generate buttons

CLDC-4162-add-2026-bulk-upload
Samuel Young 2 weeks ago
parent
commit
0d900060d8
  1. 8
      app/components/create_log_actions_component.html.erb
  2. 10
      app/controllers/test_data_controller.rb
  3. 4
      config/routes.rb

8
app/components/create_log_actions_component.html.erb

@ -25,15 +25,15 @@
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path> <path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z"></path>
</svg> </svg>
<% end %> <% end %>
<%= govuk_button_link_to create_test_bulk_upload_href(2024), class: "govuk-button govuk-button--secondary" do %> <%= govuk_button_link_to create_test_bulk_upload_href(2025), class: "govuk-button govuk-button--secondary" do %>
24/25 BU test file 25/26 BU test file
<svg class="govuk-button__start-icon bi bi-download" xmlns="http://www.w3.org/2000/svg" width="18" height="19" fill="currentColor" viewBox="0 0 16 16" stroke="currentColor" stroke-width="1.4"> <svg class="govuk-button__start-icon bi bi-download" xmlns="http://www.w3.org/2000/svg" width="18" height="19" fill="currentColor" viewBox="0 0 16 16" stroke="currentColor" stroke-width="1.4">
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5" /> <path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5" />
<path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z" /> <path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z" />
</svg> </svg>
<% end %> <% end %>
<%= govuk_button_link_to create_test_bulk_upload_href(2025), class: "govuk-button govuk-button--secondary" do %> <%= govuk_button_link_to create_test_bulk_upload_href(2026), class: "govuk-button govuk-button--secondary" do %>
25/26 BU test file 26/27 BU test file
<svg class="govuk-button__start-icon bi bi-download" xmlns="http://www.w3.org/2000/svg" width="18" height="19" fill="currentColor" viewBox="0 0 16 16" stroke="currentColor" stroke-width="1.4"> <svg class="govuk-button__start-icon bi bi-download" xmlns="http://www.w3.org/2000/svg" width="18" height="19" fill="currentColor" viewBox="0 0 16 16" stroke="currentColor" stroke-width="1.4">
<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5" /> <path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5" />
<path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z" /> <path d="M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z" />

10
app/controllers/test_data_controller.rb

@ -17,12 +17,13 @@ class TestDataController < ApplicationController
redirect_to lettings_log_path(log) redirect_to lettings_log_path(log)
end end
%w[2024 2025].each do |year| %w[2025 2026].each do |year|
define_method("create_#{year}_test_lettings_bulk_upload") do define_method("create_#{year}_test_lettings_bulk_upload") do
return render_not_found unless FeatureToggle.create_test_logs_enabled? return render_not_found unless FeatureToggle.create_test_logs_enabled?
file = Tempfile.new("#{year}_test_lettings_log.csv") file = Tempfile.new("#{year}_test_lettings_log.csv")
log = FactoryBot.create(:lettings_log, :completed, assigned_to: current_user, ppostcode_full: "SW1A 1AA", startdate: generate_different_date_within_collection_year(Time.zone.local(year.to_i, 4, 1), end_date_override: Time.zone.now + 14.days)) end_date_override = year == current_collection_start_year ? Time.zone.now + 14.days : collection_start_date(Time.zone.local(year.to_i, 4, 1)) + 14.days
log = FactoryBot.create(:lettings_log, :completed, assigned_to: current_user, ppostcode_full: "SW1A 1AA", startdate: generate_different_date_within_collection_year(Time.zone.local(year.to_i, 4, 1), end_date_override:))
log_to_csv = BulkUpload::LettingsLogToCsv.new(log:, line_ending: "\n", overrides: { organisation_id: "ORG#{log.owning_organisation_id}", managing_organisation_id: "ORG#{log.owning_organisation_id}" }) log_to_csv = BulkUpload::LettingsLogToCsv.new(log:, line_ending: "\n", overrides: { organisation_id: "ORG#{log.owning_organisation_id}", managing_organisation_id: "ORG#{log.owning_organisation_id}" })
file.write(log_to_csv.default_field_numbers_row) file.write(log_to_csv.default_field_numbers_row)
file.write(log_to_csv.to_csv_row) file.write(log_to_csv.to_csv_row)
@ -53,12 +54,13 @@ class TestDataController < ApplicationController
redirect_to sales_log_path(log) redirect_to sales_log_path(log)
end end
%w[2024 2025].each do |year| %w[2025 2026].each do |year|
define_method("create_#{year}_test_sales_bulk_upload") do define_method("create_#{year}_test_sales_bulk_upload") do
return render_not_found unless FeatureToggle.create_test_logs_enabled? return render_not_found unless FeatureToggle.create_test_logs_enabled?
file = Tempfile.new("#{year}_test_sales_log.csv") file = Tempfile.new("#{year}_test_sales_log.csv")
log = FactoryBot.create(:sales_log, :completed, assigned_to: current_user, value: 180_000, deposit: 150_000, county: "Somerset", saledate: generate_different_date_within_collection_year(Time.zone.local(year.to_i, 4, 1), end_date_override: Time.zone.now + 14.days)) end_date_override = year == current_collection_start_year ? Time.zone.now + 14.days : collection_start_date(Time.zone.local(year.to_i, 4, 1)) + 14.days
log = FactoryBot.create(:sales_log, :completed, assigned_to: current_user, value: 180_000, deposit: 150_000, county: "Somerset", saledate: generate_different_date_within_collection_year(Time.zone.local(year.to_i, 4, 1), end_date_override:))
log_to_csv = BulkUpload::SalesLogToCsv.new(log:, line_ending: "\n", overrides: { organisation_id: "ORG#{log.owning_organisation_id}", managing_organisation_id: "ORG#{log.owning_organisation_id}" }) log_to_csv = BulkUpload::SalesLogToCsv.new(log:, line_ending: "\n", overrides: { organisation_id: "ORG#{log.owning_organisation_id}", managing_organisation_id: "ORG#{log.owning_organisation_id}" })
file.write(log_to_csv.default_field_numbers_row) file.write(log_to_csv.default_field_numbers_row)
file.write(log_to_csv.to_csv_row) file.write(log_to_csv.to_csv_row)

4
config/routes.rb

@ -406,11 +406,11 @@ Rails.application.routes.draw do
if FeatureToggle.create_test_logs_enabled? if FeatureToggle.create_test_logs_enabled?
get "create-test-lettings-log", to: "test_data#create_test_lettings_log" get "create-test-lettings-log", to: "test_data#create_test_lettings_log"
get "create-setup-test-lettings-log", to: "test_data#create_setup_test_lettings_log" get "create-setup-test-lettings-log", to: "test_data#create_setup_test_lettings_log"
get "create-2024-test-lettings-bulk-upload", to: "test_data#create_2024_test_lettings_bulk_upload"
get "create-2025-test-lettings-bulk-upload", to: "test_data#create_2025_test_lettings_bulk_upload" get "create-2025-test-lettings-bulk-upload", to: "test_data#create_2025_test_lettings_bulk_upload"
get "create-2026-test-lettings-bulk-upload", to: "test_data#create_2026_test_lettings_bulk_upload"
get "create-test-sales-log", to: "test_data#create_test_sales_log" get "create-test-sales-log", to: "test_data#create_test_sales_log"
get "create-setup-test-sales-log", to: "test_data#create_setup_test_sales_log" get "create-setup-test-sales-log", to: "test_data#create_setup_test_sales_log"
get "create-2024-test-sales-bulk-upload", to: "test_data#create_2024_test_sales_bulk_upload"
get "create-2025-test-sales-bulk-upload", to: "test_data#create_2025_test_sales_bulk_upload" get "create-2025-test-sales-bulk-upload", to: "test_data#create_2025_test_sales_bulk_upload"
get "create-2026-test-sales-bulk-upload", to: "test_data#create_2026_test_sales_bulk_upload"
end end
end end

Loading…
Cancel
Save