Skip to content

Commit e95a562

Browse files
authored
Merge pull request #5393 from brodyf42/4118_add_total_value_to_storage_location_view_and_csv_export
[4118] Add total Fair Market Value to individual storage location view and CSV export
2 parents 8899390 + 675c627 commit e95a562

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

app/models/storage_location.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def validate_empty_inventory
159159
end
160160

161161
def self.csv_export_headers
162-
["Name", "Address", "Square Footage", "Warehouse Type", "Total Inventory"]
162+
["Name", "Address", "Square Footage", "Warehouse Type", "Total Inventory", "Fair Market Value"]
163163
end
164164

165165
# @param storage_locations [Array<StorageLocation>]
@@ -171,7 +171,7 @@ def self.generate_csv_from_inventory(storage_locations, inventory)
171171
CSV.generate(headers: true) do |csv|
172172
csv_data = storage_locations.map do |sl|
173173
total_quantity = inventory.quantity_for(storage_location: sl.id)
174-
attributes = [sl.name, sl.address, sl.square_footage, sl.warehouse_type, total_quantity] +
174+
attributes = [sl.name, sl.address, sl.square_footage, sl.warehouse_type, total_quantity, sl.inventory_total_value_in_dollars] +
175175
all_items.map { |i| inventory.quantity_for(storage_location: sl.id, item_id: i.item_id) }
176176
attributes.map { |attr| normalize_csv_attribute(attr) }
177177
end

app/views/storage_locations/show.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<th>Address</th>
3737
<th>Square Footage</th>
3838
<th>Warehouse Type</th>
39+
<th>Fair Market Value</th>
3940
</tr>
4041
</thead>
4142
<tbody>
@@ -44,6 +45,7 @@
4445
<td><%= @storage_location.address %></td>
4546
<td><%= @storage_location.square_footage %></td>
4647
<td><%= @storage_location.warehouse_type %></td>
48+
<td><%= number_to_currency @storage_location.inventory_total_value_in_dollars %></td>
4749
</tr>
4850
</tbody>
4951
</table>

docs/user_guide/bank/exports.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ For each Storage Location in the filtered list:
413413
- Address,
414414
- Square Footage,
415415
- Warehouse Type,
416-
- Total Inventory, and
416+
- Total Inventory,
417+
- Fair Market Value,
417418
- Quantity for each of the organization's Items.
418419

419420
## Transfers

spec/requests/storage_locations_requests_spec.rb

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
RSpec.describe "StorageLocations", type: :request do
2+
include ActionView::Helpers::NumberHelper
3+
24
let(:organization) { create(:organization) }
35
let(:user) { create(:user, organization: organization) }
46
let(:organization_admin) { create(:organization_admin, organization: organization) }
@@ -170,12 +172,12 @@
170172
get storage_locations_path(format: response_format)
171173
# The first address below is quoted since it contains commas
172174
csv = <<~CSV
173-
Name,Address,Square Footage,Warehouse Type,Total Inventory,A,B,C,D
174-
Storage Location with Duplicate Items,"1500 Remount Road, Front Royal, VA 22630",100,Residential space used,1,0,0,1,0
175-
Storage Location with Items,123 Donation Site Way,100,Residential space used,3,1,1,1,0
176-
Storage Location with Unique Items,Smithsonian Conservation Center new,100,Residential space used,5,0,0,0,5
177-
Test Storage Location,123 Donation Site Way,100,Residential space used,0,0,0,0,0
178-
Test Storage Location 1,123 Donation Site Way,100,Residential space used,0,0,0,0,0
175+
Name,Address,Square Footage,Warehouse Type,Total Inventory,Fair Market Value,A,B,C,D
176+
Storage Location with Duplicate Items,"1500 Remount Road, Front Royal, VA 22630",100,Residential space used,1,0.0,0,0,1,0
177+
Storage Location with Items,123 Donation Site Way,100,Residential space used,3,0.0,1,1,1,0
178+
Storage Location with Unique Items,Smithsonian Conservation Center new,100,Residential space used,5,0.0,0,0,0,5
179+
Test Storage Location,123 Donation Site Way,100,Residential space used,0,0.0,0,0,0,0
180+
Test Storage Location 1,123 Donation Site Way,100,Residential space used,0,0.0,0,0,0,0
179181
CSV
180182
expect(response.body).to eq(csv)
181183
end
@@ -208,13 +210,13 @@
208210
get storage_locations_path(include_inactive_storage_locations: "1", format: response_format)
209211

210212
csv = <<~CSV
211-
Name,Address,Square Footage,Warehouse Type,Total Inventory,A,B,C,D
212-
Inactive Storage Location,123 Donation Site Way,100,Residential space used,3,1,1,1,0
213-
Storage Location with Duplicate Items,"1500 Remount Road, Front Royal, VA 22630",100,Residential space used,1,0,0,1,0
214-
Storage Location with Items,123 Donation Site Way,100,Residential space used,3,1,1,1,0
215-
Storage Location with Unique Items,Smithsonian Conservation Center new,100,Residential space used,5,0,0,0,5
216-
Test Storage Location,123 Donation Site Way,100,Residential space used,0,0,0,0,0
217-
Test Storage Location 1,123 Donation Site Way,100,Residential space used,0,0,0,0,0
213+
Name,Address,Square Footage,Warehouse Type,Total Inventory,Fair Market Value,A,B,C,D
214+
Inactive Storage Location,123 Donation Site Way,100,Residential space used,3,0.0,1,1,1,0
215+
Storage Location with Duplicate Items,"1500 Remount Road, Front Royal, VA 22630",100,Residential space used,1,0.0,0,0,1,0
216+
Storage Location with Items,123 Donation Site Way,100,Residential space used,3,0.0,1,1,1,0
217+
Storage Location with Unique Items,Smithsonian Conservation Center new,100,Residential space used,5,0.0,0,0,0,5
218+
Test Storage Location,123 Donation Site Way,100,Residential space used,0,0.0,0,0,0,0
219+
Test Storage Location 1,123 Donation Site Way,100,Residential space used,0,0.0,0,0,0,0
218220
CSV
219221

220222
expect(response.body).to eq(csv)
@@ -414,6 +416,12 @@
414416
end
415417
end
416418
end
419+
420+
it "should include the inventory total market value" do
421+
get storage_location_path(storage_location, format: response_format)
422+
expect(response).to be_successful
423+
expect(response.body).to include(number_to_currency(storage_location.inventory_total_value_in_dollars))
424+
end
417425
end
418426

419427
context "csv" do

0 commit comments

Comments
 (0)