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

Include inactive storage locations in csv #5026

Merged
merged 2 commits into from
Feb 20, 2025
Merged
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
3 changes: 2 additions & 1 deletion app/controllers/storage_locations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ def index
@inventory = View::Inventory.new(current_organization.id)
@selected_item_category = filter_params[:containing]
@items = StorageLocation.items_inventoried(current_organization, @inventory)
@include_inactive_storage_locations = params[:include_inactive_storage_locations].present?
@include_inactive_storage_locations = params[:include_inactive_storage_locations]
@storage_locations = current_organization.storage_locations.alphabetized

if filter_params[:containing].present?
containing_ids = @inventory.storage_locations.keys.select do |sl|
@inventory.quantity_for(item_id: filter_params[:containing], storage_location: sl).positive?
Expand Down
2 changes: 1 addition & 1 deletion app/views/storage_locations/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<%= clear_filter_button %>
<span class="float-right">
<%= modal_button_to("#csvImportModal", {icon: "upload", text: "Import Storage Locations"}) if @storage_locations.empty? %>
<%= download_button_to(storage_locations_path(format: :csv, filters: filter_params.merge(date_range: date_range_params)), {text: "Export Storage Locations", size: "md"}) if @storage_locations.any? %>
<%= download_button_to(storage_locations_path(format: :csv, include_inactive_storage_locations: @include_inactive_storage_locations, filters: filter_params.merge(date_range: date_range_params)), {text: "Export Storage Locations", size: "md"}) if @storage_locations.any? %>
<%= new_button_to new_storage_location_path, {text: "New Storage Location"} %>
</span>
</div>
Expand Down
41 changes: 41 additions & 0 deletions spec/requests/storage_locations_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,46 @@
CSV
expect(response.body).to eq(csv)
end

context "when include inactive storage locations checkbox is checked" do
let(:inactive_storage_location) {
create(
:storage_location,
name: "Inactive Storage Location",
address: "123 Donation Site Way",
warehouse_type: StorageLocation::WAREHOUSE_TYPES.first,
discarded_at: 5.months.ago
)
}

before do
TestInventory.create_inventory(
inactive_storage_location.organization, {
inactive_storage_location.id => {
item1.id => 1,
item2.id => 1,
item3.id => 1
}
}
)
end

it "generates csv with Storage Locations that are inactive" do
get storage_locations_path(include_inactive_storage_locations: "1", format: response_format)

csv = <<~CSV
Name,Address,Square Footage,Warehouse Type,Total Inventory,A,B,C,D
Inactive Storage Location,123 Donation Site Way,100,Residential space used,3,1,1,1,0
Storage Location with Duplicate Items,"1500 Remount Road, Front Royal, VA 22630",100,Residential space used,1,0,0,1,0
Storage Location with Items,123 Donation Site Way,100,Residential space used,3,1,1,1,0
Storage Location with Unique Items,Smithsonian Conservation Center new,100,Residential space used,5,0,0,0,5
Test Storage Location,123 Donation Site Way,100,Residential space used,0,0,0,0,0
Test Storage Location 1,123 Donation Site Way,100,Residential space used,0,0,0,0,0
CSV

expect(response.body).to eq(csv)
end
end
end
end

Expand Down Expand Up @@ -255,6 +295,7 @@
end
end
end

describe "GET #show" do
let(:item) { create(:item, name: "Test Item") }
let(:item2) { create(:item, name: "Test Item2") }
Expand Down