Skip to content

Commit 233dd10

Browse files
authored
Merge branch 'main' into 5249-inventory-flow-tab
2 parents bfd1db6 + 5d4ca69 commit 233dd10

104 files changed

Lines changed: 2927 additions & 408 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.

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**

Gemfile.lock

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,28 @@ GEM
7676
addressable (2.8.7)
7777
public_suffix (>= 2.0.2, < 7.0)
7878
afm (0.2.2)
79-
annotaterb (4.16.0)
79+
annotaterb (4.19.0)
8080
activerecord (>= 6.0.0)
8181
activesupport (>= 6.0.0)
8282
ast (2.4.3)
8383
autoprefixer-rails (10.4.13.0)
8484
execjs (~> 2)
8585
awesome_print (1.9.2)
8686
aws-eventstream (1.4.0)
87-
aws-partitions (1.1123.0)
88-
aws-sdk-core (3.226.1)
87+
aws-partitions (1.1168.0)
88+
aws-sdk-core (3.233.0)
8989
aws-eventstream (~> 1, >= 1.3.0)
9090
aws-partitions (~> 1, >= 1.992.0)
9191
aws-sigv4 (~> 1.9)
9292
base64
93+
bigdecimal
9394
jmespath (~> 1, >= 1.6.1)
9495
logger
95-
aws-sdk-kms (1.106.0)
96-
aws-sdk-core (~> 3, >= 3.225.0)
96+
aws-sdk-kms (1.113.0)
97+
aws-sdk-core (~> 3, >= 3.231.0)
9798
aws-sigv4 (~> 1.5)
98-
aws-sdk-s3 (1.191.0)
99-
aws-sdk-core (~> 3, >= 3.225.0)
99+
aws-sdk-s3 (1.199.1)
100+
aws-sdk-core (~> 3, >= 3.231.0)
100101
aws-sdk-kms (~> 1)
101102
aws-sigv4 (~> 1.5)
102103
aws-sigv4 (1.12.1)
@@ -123,7 +124,7 @@ GEM
123124
erubi (~> 1.4)
124125
parser (>= 2.4)
125126
smart_properties
126-
bigdecimal (3.2.2)
127+
bigdecimal (3.2.3)
127128
bindex (0.8.1)
128129
binding_of_caller (1.0.1)
129130
debug_inspector (>= 1.2.0)
@@ -169,9 +170,9 @@ GEM
169170
cuprite (0.17)
170171
capybara (~> 3.0)
171172
ferrum (~> 0.17.0)
172-
database_cleaner-active_record (2.2.0)
173+
database_cleaner-active_record (2.2.2)
173174
activerecord (>= 5.a)
174-
database_cleaner-core (~> 2.0.0)
175+
database_cleaner-core (~> 2.0)
175176
database_cleaner-core (2.0.1)
176177
date (3.4.1)
177178
debug (1.11.0)
@@ -238,9 +239,9 @@ GEM
238239
smart_properties
239240
erubi (1.13.1)
240241
execjs (2.10.0)
241-
factory_bot (6.5.4)
242+
factory_bot (6.5.5)
242243
activesupport (>= 6.1.0)
243-
factory_bot_rails (6.5.0)
244+
factory_bot_rails (6.5.1)
244245
factory_bot (~> 6.5)
245246
railties (>= 6.1.0)
246247
faker (3.5.1)
@@ -340,7 +341,7 @@ GEM
340341
actionview (>= 5.0.0)
341342
activesupport (>= 5.0.0)
342343
jmespath (1.6.2)
343-
json (2.12.2)
344+
json (2.15.1)
344345
jwt (3.1.2)
345346
base64
346347
kaminari (1.2.2)
@@ -355,7 +356,7 @@ GEM
355356
activerecord
356357
kaminari-core (= 1.2.2)
357358
kaminari-core (1.2.2)
358-
knapsack_pro (8.3.3)
359+
knapsack_pro (8.4.0)
359360
rake
360361
language_server-protocol (3.17.0.5)
361362
launchy (3.0.0)
@@ -394,7 +395,6 @@ GEM
394395
memory_profiler (1.1.0)
395396
method_source (1.1.0)
396397
mini_mime (1.1.5)
397-
mini_portile2 (2.8.9)
398398
minitest (5.25.5)
399399
monetize (1.12.0)
400400
money (~> 6.12)
@@ -423,11 +423,8 @@ GEM
423423
timeout
424424
net-smtp (0.5.1)
425425
net-protocol
426-
newrelic_rpm (9.20.0)
426+
newrelic_rpm (9.21.0)
427427
nio4r (2.7.4)
428-
nokogiri (1.18.9)
429-
mini_portile2 (~> 2.8.2)
430-
racc (~> 1.4)
431428
nokogiri (1.18.9-arm64-darwin)
432429
racc (~> 1.4)
433430
nokogiri (1.18.9-x86_64-darwin)
@@ -469,7 +466,7 @@ GEM
469466
activerecord (>= 6.1)
470467
request_store (~> 1.4)
471468
parallel (1.27.0)
472-
parser (3.3.8.0)
469+
parser (3.3.9.0)
473470
ast (~> 2.4.1)
474471
racc
475472
pdf-core (0.9.0)
@@ -496,7 +493,7 @@ GEM
496493
prawn-table (0.2.2)
497494
prawn (>= 1.3.0, < 3.0.0)
498495
prettyprint (0.2.0)
499-
prism (1.4.0)
496+
prism (1.5.2)
500497
pry (0.14.2)
501498
coderay (~> 1.1)
502499
method_source (~> 1.0)
@@ -517,7 +514,7 @@ GEM
517514
date
518515
stringio
519516
public_suffix (6.0.2)
520-
puma (6.6.0)
517+
puma (7.0.4)
521518
nio4r (~> 2.0)
522519
racc (1.8.1)
523520
rack (3.2.1)
@@ -581,7 +578,7 @@ GEM
581578
erb
582579
psych (>= 4.0.0)
583580
recaptcha (5.20.1)
584-
regexp_parser (2.11.2)
581+
regexp_parser (2.11.3)
585582
reline (0.6.2)
586583
io-console (~> 0.5)
587584
request_store (1.7.0)
@@ -613,18 +610,18 @@ GEM
613610
rspec-mocks (~> 3.13)
614611
rspec-support (~> 3.13)
615612
rspec-support (3.13.4)
616-
rubocop (1.75.8)
613+
rubocop (1.80.2)
617614
json (~> 2.3)
618615
language_server-protocol (~> 3.17.0.2)
619616
lint_roller (~> 1.1.0)
620617
parallel (~> 1.10)
621618
parser (>= 3.3.0.2)
622619
rainbow (>= 2.2.2, < 4.0)
623620
regexp_parser (>= 2.9.3, < 3.0)
624-
rubocop-ast (>= 1.44.0, < 2.0)
621+
rubocop-ast (>= 1.46.0, < 2.0)
625622
ruby-progressbar (~> 1.7)
626623
unicode-display_width (>= 2.4.0, < 4.0)
627-
rubocop-ast (1.45.1)
624+
rubocop-ast (1.47.1)
628625
parser (>= 3.3.7.2)
629626
prism (~> 1.4)
630627
rubocop-performance (1.25.0)
@@ -692,10 +689,10 @@ GEM
692689
activesupport (>= 5.2)
693690
sprockets (>= 3.0.0)
694691
stackprof (0.2.27)
695-
standard (1.50.0)
692+
standard (1.51.1)
696693
language_server-protocol (~> 3.17.0.2)
697694
lint_roller (~> 1.0)
698-
rubocop (~> 1.75.5)
695+
rubocop (~> 1.80.2)
699696
standard-custom (~> 1.0.0)
700697
standard-performance (~> 1.8)
701698
standard-custom (1.0.2)
@@ -718,14 +715,14 @@ GEM
718715
tilt (2.2.0)
719716
timeout (0.4.3)
720717
ttfunk (1.7.0)
721-
turbo-rails (2.0.16)
718+
turbo-rails (2.0.17)
722719
actionpack (>= 7.1.0)
723720
railties (>= 7.1.0)
724721
tzinfo (2.0.6)
725722
concurrent-ruby (~> 1.0)
726-
unicode-display_width (3.1.4)
727-
unicode-emoji (~> 4.0, >= 4.0.4)
728-
unicode-emoji (4.0.4)
723+
unicode-display_width (3.2.0)
724+
unicode-emoji (~> 4.1)
725+
unicode-emoji (4.1.0)
729726
uniform_notifier (1.17.0)
730727
uri (1.0.3)
731728
useragent (0.16.11)
@@ -753,7 +750,6 @@ GEM
753750

754751
PLATFORMS
755752
arm64-darwin
756-
ruby
757753
x86_64-darwin
758754
x86_64-linux
759755
x86_64-linux-gnu

app/assets/stylesheets/custom.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,7 @@
112112
max-width: 100%;
113113
}
114114
}
115+
116+
.cursor-default {
117+
cursor: default !important;
118+
}

app/controllers/admin/users_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ def add_role
8787
redirect_back(fallback_location: admin_users_path, notice: "Role added!")
8888
end
8989

90+
def resend_invitation
91+
user = User.find(params[:user_id])
92+
user.invite!
93+
redirect_back(fallback_location: admin_users_path, notice: "#{user.name} reinvited!")
94+
end
95+
9096
def remove_role
9197
RemoveRoleService.call(user_id: params[:user_id], role_id: params[:role_id])
9298
redirect_back(fallback_location: admin_users_path, notice: "Role removed!")

app/controllers/audits_controller.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ def index
77
@selected_location = filter_params[:at_location]
88
@audits = current_organization.audits.includes(:line_items, :storage_location).class_filter(filter_params)
99
@storage_locations = StorageLocation.with_audits_for(current_organization).select(:id, :name)
10+
11+
respond_to do |format|
12+
format.html
13+
format.csv do
14+
send_data Audit.generate_csv(@audits), filename: "Audits-#{Time.zone.today}.csv"
15+
end
16+
end
1017
end
1118

1219
def show

app/controllers/distributions_controller.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ def print
2727
end
2828

2929
def destroy
30-
result = DistributionDestroyService.new(params[:id]).call
30+
service = DistributionDestroyService.new(params[:id])
31+
result = service.call
3132

3233
if result.success?
3334
flash[:notice] = "Distribution #{params[:id]} has been reclaimed!"
3435
else
35-
flash[:error] = "Could not destroy distribution #{params[:id]}. Please contact technical support."
36+
flash[:error] = result.error.message
3637
end
3738

3839
redirect_to distributions_path
@@ -185,9 +186,10 @@ def edit
185186
@request = @distribution.request
186187
@items = current_organization.items.active.alphabetized
187188
@partner_list = current_organization.partners.alphabetized
189+
@changes_disallowed = SnapshotEvent.intervening(@distribution).present?
188190
@audit_warning = current_organization.audits
189191
.where(storage_location_id: @distribution.storage_location_id)
190-
.where("updated_at > ?", @distribution.created_at).any?
192+
.where("updated_at > ?", @distribution.created_at).any? && !@changes_disallowed
191193
inventory = View::Inventory.new(@distribution.organization_id)
192194
@storage_locations = current_organization.storage_locations.active.alphabetized.select do |storage_loc|
193195
!inventory.quantity_for(storage_location: storage_loc.id).negative?

app/controllers/donation_sites_controller.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ def create
1818
@donation_site = current_organization.donation_sites.new(donation_site_params)
1919
respond_to do |format|
2020
if @donation_site.save
21+
format.turbo_stream
2122
format.html do
2223
redirect_to donation_sites_path,
2324
notice: "Donation site #{@donation_site.name} added!"
2425
end
2526
else
27+
flash.now[:error] = "Something didn't work quite right -- try again?"
28+
if request.format.turbo_stream?
29+
format.html { render partial: "donation_sites/new_modal", status: :unprocessable_entity }
30+
end
31+
2632
format.html do
27-
flash.now[:error] = "Something didn't work quite right -- try again?"
2833
render action: :new
2934
end
3035
end
@@ -33,6 +38,11 @@ def create
3338

3439
def new
3540
@donation_site = current_organization.donation_sites.new
41+
if turbo_frame_request?
42+
render partial: "donation_sites/new_modal", layout: false
43+
else
44+
render :new
45+
end
3646
end
3747

3848
def edit

app/controllers/donations_controller.rb

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,14 @@ def print
1818
def index
1919
setup_date_range_picker
2020

21-
@donations = current_organization.donations
22-
.includes(:storage_location, :donation_site, :product_drive, :product_drive_participant, :manufacturer, line_items: [:item])
23-
.order(created_at: :desc)
24-
.class_filter(filter_params)
25-
.during(helpers.selected_range)
26-
@item_categories = current_organization.item_categories.pluck(:name).uniq
27-
@paginated_donations = @donations.page(params[:page])
28-
29-
@product_drives = current_organization.product_drives.alphabetized
30-
@product_drive_participants = current_organization.product_drive_participants.alphabetized
31-
32-
# Are these going to be inefficient with large datasets?
33-
# Using the @donations allows drilling down instead of always starting with the total dataset
34-
@donations_quantity = @donations.collect(&:total_quantity).sum
35-
@paginated_donations_quantity = @paginated_donations.collect(&:total_quantity).sum
36-
@total_value_all_donations = total_value(@donations)
37-
@paginated_in_kind_value = total_value(@paginated_donations)
38-
@total_money_raised = total_money_raised(@donations)
39-
@storage_locations = @donations.filter_map { |donation| donation.storage_location if !donation.storage_location.discarded_at }.compact.uniq.sort
40-
@selected_storage_location = filter_params[:at_storage_location]
41-
@sources = @donations.collect(&:source).uniq.sort
42-
@selected_source = filter_params[:by_source]
43-
@selected_item_category = filter_params[:by_category]
44-
@donation_sites = @donations.collect(&:donation_site).compact.uniq.sort_by { |site| site.name.downcase }
45-
@selected_donation_site = filter_params[:from_donation_site]
46-
@selected_product_drive = filter_params[:by_product_drive]
47-
@selected_product_drive_participant = filter_params[:by_product_drive_participant]
48-
@manufacturers = @donations.collect(&:manufacturer).compact.uniq.sort
49-
@selected_manufacturer = filter_params[:from_manufacturer]
21+
@donation_info = View::Donations.from_params(params: params, organization: current_organization, helpers: helpers)
5022

5123
respond_to do |format|
5224
format.html
5325
format.csv do
54-
send_data Exports::ExportDonationsCSVService.new(donation_ids: @donations.map(&:id), organization: current_organization).generate_csv, filename: "Donations-#{Time.zone.today}.csv"
26+
send_data Exports::ExportDonationsCSVService.new(donation_ids: @donation_info.donations.map(&:id),
27+
organization: current_organization).generate_csv,
28+
filename: "Donations-#{Time.zone.today}.csv"
5529
end
5630
end
5731
end
@@ -81,7 +55,9 @@ def new
8155
def edit
8256
@donation = Donation.find(params[:id])
8357
@donation.line_items.build
84-
@audit_performed_and_finalized = Audit.finalized_since?(@donation, @donation.storage_location_id)
58+
@changes_disallowed = SnapshotEvent.intervening(@donation).present?
59+
@audit_performed_and_finalized = Audit.finalized_since?(@donation, @donation.storage_location_id) &&
60+
!@changes_disallowed
8561

8662
load_form_collections
8763
end
@@ -117,7 +93,7 @@ def destroy
11793
if service.success?
11894
flash[:notice] = "Donation #{params[:id]} has been removed!"
11995
else
120-
flash[:error] = "Donation #{params[:id]} failed to be removed because #{service.error}"
96+
flash[:error] = service.error.message
12197
end
12298

12399
redirect_to donations_path
@@ -177,16 +153,4 @@ def compact_line_items
177153
params[:donation][:line_items_attributes].delete_if { |_row, data| data["quantity"].blank? && data["item_id"].blank? }
178154
params
179155
end
180-
181-
def total_value(donations)
182-
total_value_all_donations = 0
183-
donations.each do |donation|
184-
total_value_all_donations += donation.value_per_itemizable
185-
end
186-
total_value_all_donations
187-
end
188-
189-
def total_money_raised(donations)
190-
donations.sum { |d| d.money_raised.to_i }
191-
end
192156
end

app/controllers/partners/family_requests_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module Partners
22
class FamilyRequestsController < BaseController
33
include Validatable
4+
45
before_action :verify_partner_is_active
56
before_action :authorize_verified_partners
67

0 commit comments

Comments
 (0)