Skip to content

Commit b3de13a

Browse files
authored
Merge branch 'main' into 5231-cancel-requests-deactivated-partners
2 parents 82d8787 + 16c088c commit b3de13a

File tree

108 files changed

+1732
-560
lines changed

Some content is hidden

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

108 files changed

+1732
-560
lines changed

.github/workflows/ruby_lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
- name: lint
2828
run: bundle exec rubocop
2929
- name: lint erb files
30-
run: bundle exec erblint --lint-all
30+
run: bundle exec erb_lint --lint-all

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ gem 'bootsnap', require: false
107107
# specific versions for compatibility reasons.
108108
gem "nokogiri", ">= 1.10.4"
109109
gem "sprockets", "~> 4.2.2"
110+
gem "prawn", "~> 2.4.0"
111+
gem "matrix" # Used by prawn
112+
gem "ttfunk", "~>1.7.0"
110113

111114
group :production, :staging do
112115
# Reduce the noise of logs and include custom fields to it for easier access

Gemfile.lock

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,30 @@ GEM
7676
addressable (2.8.7)
7777
public_suffix (>= 2.0.2, < 7.0)
7878
afm (0.2.2)
79-
annotaterb (4.14.0)
79+
annotaterb (4.16.0)
80+
activerecord (>= 6.0.0)
81+
activesupport (>= 6.0.0)
8082
ast (2.4.3)
8183
autoprefixer-rails (10.4.13.0)
8284
execjs (~> 2)
8385
awesome_print (1.9.2)
84-
aws-eventstream (1.3.1)
85-
aws-partitions (1.1050.0)
86-
aws-sdk-core (3.218.1)
86+
aws-eventstream (1.4.0)
87+
aws-partitions (1.1123.0)
88+
aws-sdk-core (3.226.1)
8789
aws-eventstream (~> 1, >= 1.3.0)
8890
aws-partitions (~> 1, >= 1.992.0)
8991
aws-sigv4 (~> 1.9)
9092
base64
9193
jmespath (~> 1, >= 1.6.1)
92-
aws-sdk-kms (1.98.0)
93-
aws-sdk-core (~> 3, >= 3.216.0)
94+
logger
95+
aws-sdk-kms (1.106.0)
96+
aws-sdk-core (~> 3, >= 3.225.0)
9497
aws-sigv4 (~> 1.5)
95-
aws-sdk-s3 (1.181.0)
96-
aws-sdk-core (~> 3, >= 3.216.0)
98+
aws-sdk-s3 (1.191.0)
99+
aws-sdk-core (~> 3, >= 3.225.0)
97100
aws-sdk-kms (~> 1)
98101
aws-sigv4 (~> 1.5)
99-
aws-sigv4 (1.11.0)
102+
aws-sigv4 (1.12.1)
100103
aws-eventstream (~> 1, >= 1.0.2)
101104
azure-storage-blob (2.0.3)
102105
azure-storage-common (~> 2.0)
@@ -120,7 +123,7 @@ GEM
120123
erubi (~> 1.4)
121124
parser (>= 2.4)
122125
smart_properties
123-
bigdecimal (3.2.1)
126+
bigdecimal (3.2.2)
124127
bindex (0.8.1)
125128
binding_of_caller (1.0.1)
126129
debug_inspector (>= 1.2.0)
@@ -135,7 +138,7 @@ GEM
135138
bugsnag (6.27.1)
136139
concurrent-ruby (~> 1.0)
137140
builder (3.3.0)
138-
bullet (8.0.5)
141+
bullet (8.0.8)
139142
activesupport (>= 3.0.0)
140143
uniform_notifier (~> 1.11)
141144
capybara (3.40.0)
@@ -235,11 +238,11 @@ GEM
235238
smart_properties
236239
erubi (1.13.1)
237240
execjs (2.10.0)
238-
factory_bot (6.5.0)
239-
activesupport (>= 5.0.0)
240-
factory_bot_rails (6.4.4)
241+
factory_bot (6.5.4)
242+
activesupport (>= 6.1.0)
243+
factory_bot_rails (6.5.0)
241244
factory_bot (~> 6.5)
242-
railties (>= 5.0.0)
245+
railties (>= 6.1.0)
243246
faker (3.5.1)
244247
i18n (>= 1.8.11, < 2)
245248
faraday (1.10.4)
@@ -277,11 +280,11 @@ GEM
277280
ffi (1.17.2-x86_64-darwin)
278281
ffi (1.17.2-x86_64-linux-gnu)
279282
filterrific (5.2.7)
280-
flipper (1.3.4)
283+
flipper (1.3.5)
281284
concurrent-ruby (< 2)
282-
flipper-active_record (1.3.4)
285+
flipper-active_record (1.3.5)
283286
activerecord (>= 4.2, < 9)
284-
flipper (~> 1.3.4)
287+
flipper (~> 1.3.5)
285288
flipper-ui (1.3.4)
286289
erubi (>= 1.0.0, < 2.0.0)
287290
flipper (~> 1.3.4)
@@ -334,7 +337,7 @@ GEM
334337
activesupport (>= 5.0.0)
335338
jmespath (1.6.2)
336339
json (2.11.3)
337-
jwt (2.10.1)
340+
jwt (3.1.2)
338341
base64
339342
kaminari (1.2.2)
340343
activesupport (>= 4.1.0)
@@ -463,7 +466,7 @@ GEM
463466
parser (3.3.8.0)
464467
ast (~> 2.4.1)
465468
racc
466-
pdf-core (0.10.0)
469+
pdf-core (0.9.0)
467470
pdf-reader (2.14.1)
468471
Ascii85 (>= 1.0, < 3.0, != 2.0.0)
469472
afm (~> 0.2.1)
@@ -474,10 +477,9 @@ GEM
474477
popper_js (2.11.8)
475478
pp (0.6.2)
476479
prettyprint
477-
prawn (2.5.0)
478-
matrix (~> 0.4)
479-
pdf-core (~> 0.10.0)
480-
ttfunk (~> 1.8)
480+
prawn (2.4.0)
481+
pdf-core (~> 0.9.0)
482+
ttfunk (~> 1.7)
481483
prawn-rails (1.6.0)
482484
actionview (>= 3.1.0)
483485
activesupport (>= 3.1.0)
@@ -510,8 +512,8 @@ GEM
510512
puma (6.6.0)
511513
nio4r (~> 2.0)
512514
racc (1.8.1)
513-
rack (3.1.15)
514-
rack-mini-profiler (3.3.1)
515+
rack (3.1.16)
516+
rack-mini-profiler (4.0.0)
515517
rack (>= 1.2.0)
516518
rack-protection (4.1.1)
517519
base64 (>= 0.1.0)
@@ -567,7 +569,7 @@ GEM
567569
rb-fsevent (0.11.2)
568570
rb-inotify (0.10.1)
569571
ffi (~> 1.0)
570-
rdoc (6.14.0)
572+
rdoc (6.14.1)
571573
erb
572574
psych (>= 4.0.0)
573575
recaptcha (5.19.0)
@@ -707,17 +709,16 @@ GEM
707709
thor (1.3.2)
708710
tilt (2.2.0)
709711
timeout (0.4.3)
710-
ttfunk (1.8.0)
711-
bigdecimal (~> 3.1)
712-
turbo-rails (2.0.13)
712+
ttfunk (1.7.0)
713+
turbo-rails (2.0.16)
713714
actionpack (>= 7.1.0)
714715
railties (>= 7.1.0)
715716
tzinfo (2.0.6)
716717
concurrent-ruby (~> 1.0)
717718
unicode-display_width (3.1.4)
718719
unicode-emoji (~> 4.0, >= 4.0.4)
719720
unicode-emoji (4.0.4)
720-
uniform_notifier (1.16.0)
721+
uniform_notifier (1.17.0)
721722
uri (1.0.3)
722723
useragent (0.16.11)
723724
version_gem (1.1.8)
@@ -794,6 +795,7 @@ DEPENDENCIES
794795
listen (~> 3.9.0)
795796
lograge
796797
magic_test
798+
matrix
797799
memory_profiler
798800
money-rails
799801
newrelic_rpm
@@ -805,6 +807,7 @@ DEPENDENCIES
805807
paper_trail
806808
pdf-reader
807809
pg (~> 1.5.9)
810+
prawn (~> 2.4.0)
808811
prawn-rails
809812
pry-doc
810813
pry-nav
@@ -834,9 +837,10 @@ DEPENDENCIES
834837
stimulus-rails
835838
strong_migrations
836839
terser
840+
ttfunk (~> 1.7.0)
837841
turbo-rails
838842
web-console
839843
webmock (~> 3.25)
840844

841845
BUNDLED WITH
842-
2.6.7
846+
2.6.9

app/controllers/item_categories_controller.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ def update
3333
end
3434
end
3535

36+
def destroy
37+
@item_category = current_organization.item_categories.find_by(id: params[:id])
38+
if @item_category.items.exists?
39+
flash[:alert] = "Cannot delete item category because it has associated items."
40+
else
41+
@item_category.destroy
42+
flash[:notice] = "#{@item_category.name} has been deleted."
43+
end
44+
redirect_to items_path
45+
end
46+
3647
private
3748

3849
def item_category_params

app/javascript/utils/donations.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,14 @@ $(function() {
108108
)
109109

110110
const large_donation_boundary = 100000;
111-
$(document).on("submit", "form#new_donation", (e, _) =>
111+
$(document).on("click", "form#new_donation button[type='submit']", (e, _) =>
112112
$(".quantity").each(function(_, q) {
113113
const quantity = parseInt(q.value, 10);
114114
if (quantity > large_donation_boundary) {
115-
confirm(
115+
const answer_confirm = confirm(
116116
`${quantity} items is a large donation! Are you sure you want to submit?`
117-
);
117+
)
118+
answer_confirm === false && e.preventDefault();
118119
}
119120
})
120121
);

app/models/item.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# active :boolean default(TRUE)
77
# additional_info :text
88
# barcode_count :integer
9-
# category :string
109
# distribution_quantity :integer
1110
# name :string
1211
# on_hand_minimum_quantity :integer default(0), not null

app/models/item_category.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,16 @@ class ItemCategory < ApplicationRecord
1616

1717
belongs_to :organization
1818
has_many :items, -> { order(name: :asc) }, inverse_of: :item_category, dependent: :nullify
19-
has_many :partner_groups, dependent: :nullify
19+
has_and_belongs_to_many :partner_groups, dependent: :nullify
20+
21+
before_destroy :ensure_no_associated_partner_groups
22+
23+
private
24+
25+
def ensure_no_associated_partner_groups
26+
if partner_groups.exists?
27+
errors.add(:base, "Cannot delete item category with associated partner groups")
28+
throw(:abort)
29+
end
30+
end
2031
end

app/models/partner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def families_served_count
146146
end
147147

148148
def children_served_count
149-
children.count
149+
children.count { |child| !child.archived? }
150150
end
151151

152152
def family_zipcodes_count

app/pdfs/picklists_pdf.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ def compute_and_render
7676
font_size 10
7777
end
7878

79+
# Add quota information only if quota is set and greater than 0
80+
quota = request.partner.quota
81+
if quota && quota > 0
82+
move_down 5
83+
text "Quota:", style: :bold, align: :right
84+
font_size 12
85+
text quota.to_s, align: :right
86+
font_size 10
87+
end
88+
7989
move_down 10
8090
text "Comments:", style: :bold
8191
font_size 12

app/services/reports/diaper_report_service.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ def report
3232
"% disposable diapers purchased" => "#{percent_disposable_diapers_purchased.round}%",
3333
"% cloth diapers purchased" => "#{percent_cloth_diapers_purchased.round}%",
3434
"Money spent purchasing diapers" => number_to_currency(money_spent_on_diapers),
35-
"Purchased from" => purchased_from,
36-
"Vendors diapers purchased through" => vendors_purchased_from
35+
"Purchased from" => combined_purchased_from
3736
}}
3837
end
3938

39+
# Helper method to combine purchased_from and vendors_purchased_from
40+
def combined_purchased_from
41+
[purchased_from, vendors_purchased_from].compact_blank.join(", ")
42+
end
43+
4044
# @return [Integer]
4145
def distributed_loose_disposable_diapers
4246
@distributed_loose_disposable_diapers ||= organization
@@ -53,10 +57,10 @@ def distributed_disposable_diapers_from_kits
5357

5458
sql_query = <<-SQL
5559
SELECT SUM(line_items.quantity * kit_line_items.quantity)
56-
FROM distributions
57-
INNER JOIN line_items ON line_items.itemizable_type = 'Distribution' AND line_items.itemizable_id = distributions.id
58-
INNER JOIN items ON items.id = line_items.item_id
59-
INNER JOIN kits ON kits.id = items.kit_id
60+
FROM distributions
61+
INNER JOIN line_items ON line_items.itemizable_type = 'Distribution' AND line_items.itemizable_id = distributions.id
62+
INNER JOIN items ON items.id = line_items.item_id
63+
INNER JOIN kits ON kits.id = items.kit_id
6064
INNER JOIN line_items AS kit_line_items ON kits.id = kit_line_items.itemizable_id
6165
INNER JOIN items AS kit_items ON kit_items.id = kit_line_items.item_id
6266
WHERE distributions.organization_id = ?

0 commit comments

Comments
 (0)