Skip to content

Commit 917f4ad

Browse files
authored
#4990 - Items Quantity and Location tab and Item Inventory tab, highlight the bank-wide items that are below their minimum (#5123)
* Added condition to highlight items with below minimum quantity * Updated documentation * Added spec * Updated screenshots * Added requests spec and removed feature spec
1 parent 4b1cb83 commit 917f4ad

File tree

7 files changed

+34
-2
lines changed

7 files changed

+34
-2
lines changed

app/helpers/items_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ def selected_item_request_units(item)
1919
item_request_unit_names = item.persisted? ? item.request_units.pluck(:name) : []
2020
current_organization.request_units.select { |unit| item_request_unit_names.include?(unit.name) }.pluck(:id)
2121
end
22+
23+
def quantity_below_minimum?(row_item)
24+
row_item[:quantity] < row_item[:item_on_hand_minimum_quantity]
25+
end
2226
end

app/views/items/_item_row_inventory.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<tr data-widget="expandable-table" aria-expanded="false">
33
<td><i class="fa" /></td>
44
<td><%= link_to(row_item[:item_name], item_url(row_item[:item_id])) %></td>
5-
<td class="numeric"><%= row_item[:quantity] %></td>
5+
<td class="numeric <%= "text-danger font-weight-bold" if quantity_below_minimum?(row_item) %>" data-column="total"><%= row_item[:quantity] %></td>
66
<td class="numeric"><%= row_item[:item_on_hand_minimum_quantity] %></td>
77
<td class="numeric"><%= row_item[:item_on_hand_recommended_quantity] %></td>
88
</tr>

app/views/items/_item_row_quantity_and_storages.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
<% end %>
88
<td class="numeric"><%= row_item[:item_on_hand_minimum_quantity] %></td>
99
<td class="numeric"><%= row_item[:item_on_hand_recommended_quantity] %></td>
10-
<td class="numeric"><%= row_item[:quantity] %></td>
10+
<td class="numeric <%= "text-danger font-weight-bold" if quantity_below_minimum?(row_item) %>" data-column="total"><%= row_item[:quantity] %></td>
1111
</tr>
748 KB
Loading
884 KB
Loading

docs/user_guide/bank/inventory_items.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,20 @@ This tab shows all the Item inventory across all the storage locations, along wi
152152

153153
![Navigation to Items, Quantity, and Location](images/inventory/inventory_item_location_navigation.png)
154154

155+
If the total quantity of an item is below the minimum quantity expected, it will be highlighted as shown below:
156+
157+
![Highlighting inventory shortage](images/inventory/item_quantity_location_inventory_shortage.png)
158+
155159
### Item Inventory tab
156160

157161
This tab shows the bank-wide inventory for each Item. Clicking the + beside the Item name will show the breakdown of that inventory by storage area.
158162

159163
![Navigation to Item Inventory tab](images/inventory/inventory_items_inventory_navigation.png)
160164

165+
If the total quantity of an item is below the minimum quantity expected, it will be highlighted as shown below:
166+
167+
![Highlighting inventory shortage](images/inventory/item_inventory_shortage.png)
168+
161169
### Kits tab
162170
This shows the same information as the main [Kits](inventory_kits.md) list.
163171
![Navigation to the Kits tab ](images/inventory/inventory_items_kits_navigation.png)

spec/requests/items_requests_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@
1717
let(:response_format) { 'html' }
1818

1919
it { is_expected.to be_successful }
20+
21+
it "highlights total quantity if it is below minimum quantity" do
22+
item_pullups = create(:item, name: "the most wonderful magical pullups that truly potty train", category: "Magic Toddlers", on_hand_minimum_quantity: 100)
23+
item_tampons = create(:item, name: "blackbeard's rugged tampons", category: "Menstrual Products", on_hand_minimum_quantity: 100)
24+
storage_name = "the poop catcher warehouse"
25+
num_pullups_in_donation = 666
26+
num_pullups_second_donation = 15
27+
storage = create(:storage_location, :with_items, item: item_pullups, item_quantity: num_pullups_in_donation, name: storage_name)
28+
aux_storage = create(:storage_location, :with_items, item: item_pullups, item_quantity: num_pullups_second_donation, name: "a secret secondary location")
29+
num_tampons_in_donation = 42
30+
num_tampons_second_donation = 17
31+
create(:donation, :with_items, storage_location: storage, item_quantity: num_tampons_in_donation, item: item_tampons)
32+
create(:donation, :with_items, storage_location: aux_storage, item_quantity: num_tampons_second_donation, item: item_tampons)
33+
34+
get items_path(format: response_format)
35+
# Inside Item Inventory Tab
36+
expect(response.body).to match(/<div[^>]*id="custom-tabs-three-inventory"[^>]*>.*<td class="numeric text-danger font-weight-bold" data-column="total">59<\/td>.*<\/div>/m)
37+
# Inside Items, Quantity and Location Tab
38+
expect(response.body).to match(/<div[^>]*id="custom-tabs-three-profile"[^>]*>.*<td class="numeric text-danger font-weight-bold" data-column="total">59<\/td>.*<\/div>/m)
39+
end
2040
end
2141

2242
context "csv" do

0 commit comments

Comments
 (0)