@@ -9,10 +9,7 @@ def quantity
9
9
end
10
10
11
11
def index
12
- if Event . read_events? ( current_organization )
13
- @inventory = View ::Inventory . new ( current_organization . id )
14
- end
15
-
12
+ @inventory = View ::Inventory . new ( current_organization . id )
16
13
@selected_item_category = filter_params [ :containing ]
17
14
@items = StorageLocation . items_inventoried ( current_organization , @inventory )
18
15
@include_inactive_storage_locations = params [ :include_inactive_storage_locations ] . present?
@@ -33,21 +30,7 @@ def index
33
30
respond_to do |format |
34
31
format . html
35
32
format . csv do
36
- if Event . read_events? ( current_organization )
37
- send_data StorageLocation . generate_csv_from_inventory ( @storage_locations , @inventory ) , filename : "StorageLocations-#{ Time . zone . today } .csv"
38
- else
39
- active_inventory_item_names = [ ]
40
- @storage_locations . each do |storage_location |
41
- active_inventory_item_names <<
42
- storage_location
43
- . active_inventory_items
44
- . joins ( :item )
45
- . select ( 'distinct items.name' )
46
- . pluck ( :name )
47
- end
48
- active_inventory_item_names = active_inventory_item_names . flatten . uniq . sort
49
- send_data StorageLocation . generate_csv ( @storage_locations , active_inventory_item_names ) , filename : "StorageLocations-#{ Time . zone . today } .csv"
50
- end
33
+ send_data StorageLocation . generate_csv_from_inventory ( @storage_locations , @inventory ) , filename : "StorageLocations-#{ Time . zone . today } .csv"
51
34
end
52
35
end
53
36
end
@@ -78,16 +61,14 @@ def show
78
61
@items_out_total = ItemsOutTotalQuery . new ( organization : current_organization , storage_location : @storage_location ) . call
79
62
@items_in = ItemsInQuery . new ( organization : current_organization , storage_location : @storage_location ) . call
80
63
@items_in_total = ItemsInTotalQuery . new ( organization : current_organization , storage_location : @storage_location ) . call
81
- if Event . read_events? ( current_organization )
82
- if View ::Inventory . within_snapshot? ( current_organization . id , params [ :version_date ] )
83
- @inventory = View ::Inventory . new ( current_organization . id , event_time : params [ :version_date ] )
84
- else
85
- @legacy_inventory = View ::Inventory . legacy_inventory_for_storage_location (
86
- current_organization . id ,
87
- @storage_location . id ,
88
- params [ :version_date ]
89
- )
90
- end
64
+ if View ::Inventory . within_snapshot? ( current_organization . id , params [ :version_date ] )
65
+ @inventory = View ::Inventory . new ( current_organization . id , event_time : params [ :version_date ] )
66
+ else
67
+ @legacy_inventory = View ::Inventory . legacy_inventory_for_storage_location (
68
+ current_organization . id ,
69
+ @storage_location . id ,
70
+ params [ :version_date ]
71
+ )
91
72
end
92
73
93
74
respond_to do |format |
@@ -154,22 +135,10 @@ def destroy
154
135
end
155
136
156
137
def inventory
157
- if Event . read_events? ( current_organization )
158
- @items = View ::Inventory . items_for_location ( StorageLocation . find ( params [ :id ] ) ,
159
- include_omitted : params [ :include_omitted_items ] == "true" )
160
- respond_to do |format |
161
- format . json { render :event_inventory }
162
- end
163
- else
164
- @inventory_items = current_organization . storage_locations
165
- . includes ( inventory_items : :item )
166
- . find ( params [ :id ] )
167
- . inventory_items
168
- . active
169
-
170
- @inventory_items += include_omitted_items ( @inventory_items . collect ( &:item_id ) ) if params [ :include_omitted_items ] == "true"
171
- @inventory_items . to_a . sort_by! { |inventory_item | inventory_item . item . name . downcase }
172
- respond_to :json
138
+ @items = View ::Inventory . items_for_location ( StorageLocation . find ( params [ :id ] ) ,
139
+ include_omitted : params [ :include_omitted_items ] == "true" )
140
+ respond_to do |format |
141
+ format . json { render :event_inventory }
173
142
end
174
143
end
175
144
0 commit comments