Skip to content

Commit 5ed01cf

Browse files
Merge branch 'main' into validation-error-status-change-5569
2 parents db8fefb + 3b24d37 commit 5ed01cf

68 files changed

Lines changed: 542 additions & 250 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Only take multiple issues if they are related and you can solve all of them at t
198198
Users that are frequent contributors and are involved in discussion (join the slack channel! :)) may be given direct Contributor access to the Repo so they can submit Pull Requests directly instead of Forking first.
199199

200200
## Debugging
201-
If starting server directly, via `rail s` or `rail console`, or built-in debugger in RubyMine, or running `bundle exec rspec path/to/spec.rb:line_no`, then you can use `binding.pry` to debug. Drop the pry where you want the execution to pause.
201+
If starting server directly, via `rails s` or `rails console`, or built-in debugger in RubyMine, or running `bundle exec rspec path/to/spec.rb:line_no`, then you can use `binding.pry` to debug. Drop the pry where you want the execution to pause.
202202

203203
If starting via Procfile with `bin/start`, then drop a ``binding.remote_pry`` into the line where you want execution to pause at. Then run ``pry-remote`` in the terminal to connect to it.
204204
https://github.com/Mon-Ouie/pry-remote

Gemfile.lock

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,20 @@ GEM
8484
execjs (~> 2)
8585
awesome_print (1.9.2)
8686
aws-eventstream (1.4.0)
87-
aws-partitions (1.1233.0)
88-
aws-sdk-core (3.244.0)
87+
aws-partitions (1.1255.0)
88+
aws-sdk-core (3.250.0)
8989
aws-eventstream (~> 1, >= 1.3.0)
9090
aws-partitions (~> 1, >= 1.992.0)
9191
aws-sigv4 (~> 1.9)
9292
base64
9393
bigdecimal
9494
jmespath (~> 1, >= 1.6.1)
9595
logger
96-
aws-sdk-kms (1.123.0)
97-
aws-sdk-core (~> 3, >= 3.244.0)
96+
aws-sdk-kms (1.128.0)
97+
aws-sdk-core (~> 3, >= 3.248.0)
9898
aws-sigv4 (~> 1.5)
99-
aws-sdk-s3 (1.218.0)
100-
aws-sdk-core (~> 3, >= 3.244.0)
99+
aws-sdk-s3 (1.224.0)
100+
aws-sdk-core (~> 3, >= 3.248.0)
101101
aws-sdk-kms (~> 1)
102102
aws-sigv4 (~> 1.5)
103103
aws-sigv4 (1.12.1)
@@ -111,7 +111,7 @@ GEM
111111
net-http-persistent (~> 4.0)
112112
nokogiri (~> 1, >= 1.10.8)
113113
base64 (0.3.0)
114-
bcrypt (3.1.21)
114+
bcrypt (3.1.22)
115115
benchmark (0.5.0)
116116
better_errors (2.10.1)
117117
erubi (>= 1.0.0)
@@ -128,7 +128,7 @@ GEM
128128
bindex (0.8.1)
129129
binding_of_caller (2.0.0)
130130
debug_inspector (>= 1.2.0)
131-
bootsnap (1.24.1)
131+
bootsnap (1.24.5)
132132
msgpack (~> 1.2)
133133
bootstrap (5.2.3)
134134
autoprefixer-rails (>= 9.1.0)
@@ -139,7 +139,7 @@ GEM
139139
bugsnag (6.30.0)
140140
concurrent-ruby (~> 1.0)
141141
builder (3.3.0)
142-
bullet (8.1.0)
142+
bullet (8.1.2)
143143
activesupport (>= 3.0.0)
144144
uniform_notifier (~> 1.11)
145145
capybara (3.40.0)
@@ -156,7 +156,7 @@ GEM
156156
launchy
157157
childprocess (5.0.0)
158158
choice (0.2.0)
159-
clockwork (3.0.2)
159+
clockwork (4.0.1)
160160
activesupport
161161
tzinfo
162162
coderay (1.1.3)
@@ -189,13 +189,13 @@ GEM
189189
delayed_job (> 2.0.3)
190190
rack-protection (>= 1.5.5)
191191
sinatra (>= 1.4.4)
192-
devise (5.0.2)
192+
devise (5.0.4)
193193
bcrypt (~> 3.0)
194194
orm_adapter (~> 0.1)
195195
railties (>= 7.0)
196196
responders
197197
warden (~> 1.2.3)
198-
devise_invitable (2.0.11)
198+
devise_invitable (2.0.12)
199199
actionmailer (>= 5.0)
200200
devise (>= 4.6)
201201
diff-lcs (1.6.2)
@@ -229,7 +229,7 @@ GEM
229229
dry-inflector (~> 1.0)
230230
dry-logic (~> 1.4)
231231
zeitwerk (~> 2.6)
232-
erb (6.0.2)
232+
erb (6.0.4)
233233
erb_lint (0.9.0)
234234
activesupport
235235
better_html (>= 2.0.1)
@@ -277,11 +277,12 @@ GEM
277277
concurrent-ruby (~> 1.1)
278278
webrick (~> 1.7)
279279
websocket-driver (~> 0.7)
280+
ffi (1.17.4)
280281
ffi (1.17.4-arm64-darwin)
281282
ffi (1.17.4-x86_64-darwin)
282283
ffi (1.17.4-x86_64-linux-gnu)
283284
filterrific (5.2.7)
284-
flipper (1.4.1)
285+
flipper (1.4.2)
285286
concurrent-ruby (< 2)
286287
flipper-active_record (1.4.1)
287288
activerecord (>= 4.2, < 9)
@@ -333,12 +334,12 @@ GEM
333334
activesupport (>= 6.0.0)
334335
railties (>= 6.0.0)
335336
io-console (0.8.2)
336-
irb (1.17.0)
337+
irb (1.18.0)
337338
pp (>= 0.6.0)
338339
prism (>= 1.3.0)
339340
rdoc (>= 4.0.0)
340341
reline (>= 0.4.2)
341-
jbuilder (2.14.1)
342+
jbuilder (2.15.1)
342343
actionview (>= 7.0.0)
343344
activesupport (>= 7.0.0)
344345
jmespath (1.6.2)
@@ -386,7 +387,8 @@ GEM
386387
pry
387388
pry-stack_explorer
388389
rails (>= 5.0)
389-
mail (2.8.1)
390+
mail (2.9.0)
391+
logger
390392
mini_mime (>= 0.1.1)
391393
net-imap
392394
net-pop
@@ -398,6 +400,7 @@ GEM
398400
memory_profiler (1.1.0)
399401
method_source (1.1.0)
400402
mini_mime (1.1.5)
403+
mini_portile2 (2.8.9)
401404
minitest (6.0.6)
402405
drb (~> 2.0)
403406
prism (~> 1.5)
@@ -411,7 +414,7 @@ GEM
411414
monetize (~> 2.0)
412415
money (~> 7.0)
413416
railties (>= 7.0)
414-
msgpack (1.8.0)
417+
msgpack (1.8.1)
415418
multi_xml (0.8.1)
416419
bigdecimal (>= 3.1, < 5)
417420
multipart-post (2.4.1)
@@ -420,7 +423,7 @@ GEM
420423
nenv (0.3.0)
421424
net-http-persistent (4.0.8)
422425
connection_pool (>= 2.2.4, < 4)
423-
net-imap (0.5.9)
426+
net-imap (0.6.4)
424427
date
425428
net-protocol
426429
net-pop (0.1.2)
@@ -429,9 +432,12 @@ GEM
429432
timeout
430433
net-smtp (0.5.1)
431434
net-protocol
432-
newrelic_rpm (10.2.0)
435+
newrelic_rpm (10.5.0)
433436
logger
434437
nio4r (2.7.5)
438+
nokogiri (1.19.0)
439+
mini_portile2 (~> 2.8.2)
440+
racc (~> 1.4)
435441
nokogiri (1.19.0-arm64-darwin)
436442
racc (~> 1.4)
437443
nokogiri (1.19.0-x86_64-darwin)
@@ -483,6 +489,7 @@ GEM
483489
hashery (~> 2.0)
484490
ruby-rc4
485491
ttfunk
492+
pg (1.6.3)
486493
pg (1.6.3-arm64-darwin)
487494
pg (1.6.3-x86_64-darwin)
488495
pg (1.6.3-x86_64-linux)
@@ -577,7 +584,7 @@ GEM
577584
thor (~> 1.0, >= 1.2.2)
578585
zeitwerk (~> 2.6)
579586
rainbow (3.1.1)
580-
rake (13.3.1)
587+
rake (13.4.2)
581588
rb-fsevent (0.11.2)
582589
rb-inotify (0.11.1)
583590
ffi (~> 1.0)
@@ -755,10 +762,11 @@ GEM
755762
xpath (3.2.0)
756763
nokogiri (~> 1.8)
757764
yard (0.9.38)
758-
zeitwerk (2.7.5)
765+
zeitwerk (2.8.2)
759766

760767
PLATFORMS
761768
arm64-darwin
769+
ruby
762770
x86_64-darwin
763771
x86_64-linux
764772
x86_64-linux-gnu

app/controllers/donations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def donation_item_params
134134
def filter_params
135135
return {} unless params.key?(:filters)
136136

137-
params.require(:filters).permit(:at_storage_location, :by_source, :from_donation_site, :by_product_drive, :by_product_drive_participant, :from_manufacturer, :by_category)
137+
params.require(:filters).permit(:at_storage_location, :by_source, :from_donation_site, :by_product_drive, :by_product_drive_participant, :from_manufacturer, :by_item_id, :by_category)
138138
end
139139

140140
# Omits donation_site_id or product_drive_participant_id if those aren't selected as source

app/controllers/items_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def index
1111
@items = @items.active unless params[:include_inactive_items]
1212

1313
@item_categories = current_organization.item_categories.includes(:items).order('name ASC')
14-
@kits = current_organization.kits.includes(item: {line_items: :item})
14+
@kits = current_organization.kits.includes(kit_item: {line_items: :item})
1515
@storages = current_organization.storage_locations.active.order(id: :asc)
1616

1717
@include_inactive_items = params[:include_inactive_items]

app/controllers/kits_controller.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def show
44
end
55

66
def index
7-
@kits = current_organization.kits.includes(item: {line_items: :item}).class_filter(filter_params)
7+
@kits = current_organization.kits.includes(kit_item: {line_items: :item}).class_filter(filter_params)
88
@inventory = View::Inventory.new(current_organization.id)
99
unless params[:include_inactive_items]
1010
@kits = @kits.active
@@ -16,8 +16,8 @@ def new
1616
load_form_collections
1717

1818
@kit = current_organization.kits.new
19-
@kit.item = current_organization.items.new
20-
@kit.item.line_items.build
19+
@kit.kit_item = KitItem.new(organization: current_organization)
20+
@kit.kit_item.line_items.build
2121
end
2222

2323
def create
@@ -36,8 +36,9 @@ def create
3636
kit_only_params = kit_params.except(:line_items_attributes)
3737
@kit = Kit.new(kit_only_params)
3838
load_form_collections
39-
@kit.item ||= current_organization.items.new(kit_params.slice(:line_items_attributes))
40-
@kit.item.line_items.build if @kit.item.line_items.empty?
39+
@kit.kit_item ||= KitItem.new(organization: current_organization,
40+
**kit_params.slice(:line_items_attributes))
41+
@kit.kit_item.line_items.build if @kit.kit_item.line_items.empty?
4142

4243
render :new
4344
end
@@ -96,7 +97,7 @@ def kit_params
9697
:visible_to_partners,
9798
:value_in_dollars
9899
)
99-
item_params = params.require(:item)
100+
item_params = params.require(:kit_item)
100101
.permit(line_items_attributes: [:item_id, :quantity, :_destroy])
101102
kit_params.to_h.merge(item_params.to_h)
102103
end

app/events/kit_allocate_event.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class KitAllocateEvent < Event
22
def self.event_line_items(kit, storage_location, quantity)
3-
items = kit.item.line_items.map do |item|
3+
items = kit.kit_item.line_items.map do |item|
44
EventTypes::EventLineItem.new(
55
quantity: item.quantity * quantity,
66
item_id: item.item_id,
@@ -11,8 +11,8 @@ def self.event_line_items(kit, storage_location, quantity)
1111
end
1212
items.push(EventTypes::EventLineItem.new(
1313
quantity: quantity,
14-
item_id: kit.item.id,
15-
item_value_in_cents: kit.item.value_in_cents,
14+
item_id: kit.kit_item.id,
15+
item_value_in_cents: kit.kit_item.value_in_cents,
1616
to_storage_location: storage_location,
1717
from_storage_location: nil
1818
))

app/events/kit_deallocate_event.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class KitDeallocateEvent < Event
22
def self.event_line_items(kit, storage_location, quantity)
3-
items = kit.item.line_items.map do |item|
3+
items = kit.kit_item.line_items.map do |item|
44
EventTypes::EventLineItem.new(
55
quantity: item.quantity * quantity,
66
item_id: item.item_id,
@@ -11,8 +11,8 @@ def self.event_line_items(kit, storage_location, quantity)
1111
end
1212
items.push(EventTypes::EventLineItem.new(
1313
quantity: quantity,
14-
item_id: kit.item.id,
15-
item_value_in_cents: kit.item.value_in_cents,
14+
item_id: kit.kit_item.id,
15+
item_value_in_cents: kit.kit_item.value_in_cents,
1616
from_storage_location: storage_location,
1717
to_storage_location: nil
1818
))

app/helpers/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,6 @@ def storage_location_for_source(source_object)
126126
end
127127

128128
def default_location(source_object)
129-
current_organization.default_storage_location || source_object.storage_location_id.presence || current_organization.intake_location
129+
source_object.storage_location_id.presence || current_organization.default_storage_location || current_organization.intake_location
130130
end
131131
end

app/models/concrete_item.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# == Schema Information
2+
#
3+
# Table name: items
4+
#
5+
# id :integer not null, primary key
6+
# active :boolean default(TRUE)
7+
# additional_info :text
8+
# barcode_count :integer
9+
# distribution_quantity :integer
10+
# name :string
11+
# on_hand_minimum_quantity :integer default(0), not null
12+
# on_hand_recommended_quantity :integer
13+
# package_size :integer
14+
# partner_key :string
15+
# reporting_category :string
16+
# type :string default("ConcreteItem"), not null
17+
# value_in_cents :integer default(0)
18+
# visible_to_partners :boolean default(TRUE), not null
19+
# created_at :datetime not null
20+
# updated_at :datetime not null
21+
# item_category_id :integer
22+
# kit_id :integer
23+
# organization_id :integer
24+
#
25+
class ConcreteItem < Item
26+
end

app/models/donation.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Donation < ApplicationRecord
5252
where(manufacturer_id: manufacturer_id)
5353
}
5454

55+
scope :by_item_id, ->(item_id) { joins(:items).where(items: { id: item_id }).distinct }
5556
scope :by_category, ->(item_category) {
5657
joins(line_items: {item: :item_category}).where("item_categories.name ILIKE ?", item_category)
5758
}

0 commit comments

Comments
 (0)