diff --git a/app/queries/items_by_storage_collection_and_quantity_query.rb b/app/queries/items_by_storage_collection_and_quantity_query.rb index 266737b93c..6b97f6b759 100644 --- a/app/queries/items_by_storage_collection_and_quantity_query.rb +++ b/app/queries/items_by_storage_collection_and_quantity_query.rb @@ -18,15 +18,17 @@ def call @items_by_storage_collection.each do |row| unless @items_by_storage_collection_and_quantity.key?(row.id) @items_by_storage_collection_and_quantity[row.id] = { + item_id: row.id, item_name: row.name, item_on_hand_minimum_quantity: row.on_hand_minimum_quantity, item_on_hand_recommended_quantity: row.on_hand_recommended_quantity, item_value: row.value_in_cents, - item_barcode_count: row.barcode_count + item_barcode_count: row.barcode_count, + locations: {}, + quantity: 0 } end - @items_by_storage_collection_and_quantity[row.id][row.storage_id] = row.quantity - @items_by_storage_collection_and_quantity[row.id][:quantity] ||= 0 + @items_by_storage_collection_and_quantity[row.id][:locations][row.storage_name] = row.quantity @items_by_storage_collection_and_quantity[row.id][:quantity] += row.quantity || 0 end diff --git a/app/views/items/_item_row_inventory.html.erb b/app/views/items/_item_row_inventory.html.erb new file mode 100644 index 0000000000..af435b4664 --- /dev/null +++ b/app/views/items/_item_row_inventory.html.erb @@ -0,0 +1,14 @@ +<% row_item = row.last %> + + <%= link_to(row_item[:item_name], item_url(row_item[:item_id])) %> + <%= row_item[:quantity] %> + <%= row_item[:item_on_hand_minimum_quantity] %> + <%= row_item[:item_on_hand_recommended_quantity] %> + + + + <% row_item[:locations].each do |location_name, quantity| %> +

<%= "#{location_name} - #{quantity} units" %>

+ <% end %> + + \ No newline at end of file diff --git a/app/views/items/_items_inventory.html.erb b/app/views/items/_items_inventory.html.erb new file mode 100644 index 0000000000..e718f31647 --- /dev/null +++ b/app/views/items/_items_inventory.html.erb @@ -0,0 +1,20 @@ +
+
+ <%= new_button_to new_item_path(organization_id: current_organization), {text: "New Item"} %> +
+ + + + + + + + + + + + <%= render partial: "item_row_inventory", collection: @items_by_storage_collection_and_quantity, as: :row %> + +
NameQuantityMinimum QuantityRecommended Quantity
+
+ diff --git a/app/views/items/index.html.erb b/app/views/items/index.html.erb index 696b2e5930..5aa5c72ba1 100644 --- a/app/views/items/index.html.erb +++ b/app/views/items/index.html.erb @@ -76,12 +76,16 @@ + @@ -92,6 +96,7 @@ <%= render partial: 'item_list', locals: { items: @items } %> <%= render partial: 'item_categories', locals: { item_categories: @item_categories } %> <%= render partial: 'items_quantity_and_location' %> + <%= render partial: 'items_inventory' %> <%= render partial: 'kits' %> diff --git a/spec/system/item_system_spec.rb b/spec/system/item_system_spec.rb index 90a092f23f..4a3d3a98ad 100644 --- a/spec/system/item_system_spec.rb +++ b/spec/system/item_system_spec.rb @@ -189,6 +189,22 @@ expect(tab_items_quantity_location_text).to have_content item_pullups.name expect(tab_items_quantity_location_text).to have_content item_tampons.name end + + it "should display items in separate tabs", js: true do + click_link "Item Inventory" # href="#sectionD" + tab_items_quantity_location_text = page.find(".table-items-location", visible: true).text + expect(tab_items_quantity_location_text).to have_content "Quantity" + expect(tab_items_quantity_location_text).to have_content storage_name + expect(tab_items_quantity_location_text).to have_content num_pullups_in_donation + expect(tab_items_quantity_location_text).to have_content num_pullups_second_donation + expect(tab_items_quantity_location_text).to have_content num_pullups_in_donation + num_pullups_second_donation + expect(tab_items_quantity_location_text).to have_content num_tampons_in_donation + expect(tab_items_quantity_location_text).to have_content num_tampons_second_donation + expect(tab_items_quantity_location_text).to have_content num_tampons_in_donation + num_tampons_second_donation + expect(tab_items_quantity_location_text).to have_content item_pullups.name + expect(tab_items_quantity_location_text).to have_content item_tampons.name + click_link item_pullups.name # href="#sectionD" + end end describe 'Item Category Management' do