Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4283 period supplies #4582

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2b945e8
Add distributed_period_supplies_from_kits method modified from aquesi…
jadekstewart3 Apr 26, 2024
73e757c
Begin test set up for period supplies in kits
jadekstewart3 Apr 26, 2024
0e70618
Modify test set up to include distributions containing period supply …
jadekstewart3 Apr 26, 2024
392b434
Fix kit creation in the test set up so it returns the correct integer
jadekstewart3 May 9, 2024
65c47a1
Modify normal value report to report total period supplies including …
jadekstewart3 May 9, 2024
9b3c42c
Complete metric: Period supplies per adult per month
jadekstewart3 Jun 4, 2024
deed965
Create dontated items from kits method. Still need testing for this m…
jadekstewart3 Jun 4, 2024
2d64b4c
Create test data and testing for calculating the number of period sup…
jadekstewart3 Jun 4, 2024
b413e36
Add purchased_kits method and add a simple test for the method. Needs…
jadekstewart3 Jun 4, 2024
16e2da4
Fix method counting purchased kits
jadekstewart3 Aug 6, 2024
ca9831d
Added a method to calculate the number of purchased period supplies w…
jadekstewart3 Aug 6, 2024
7d0ae93
Fix calculations for period supply report, and modify test to reflect…
jadekstewart3 Aug 6, 2024
038e4cf
add the :with_items back in on creation of organization
jadekstewart3 Aug 6, 2024
e3240ed
Merge branch 'main' into 4238_period_supplies
jadekstewart3 Aug 6, 2024
bf472aa
Rubocop
jadekstewart3 Aug 6, 2024
46b2fcf
Merge branch '4238_period_supplies' of github.com:jadekstewart3/human…
jadekstewart3 Aug 6, 2024
87ac6af
Fix errors within spec
jadekstewart3 Aug 6, 2024
11ce2f7
Rubocop
jadekstewart3 Aug 6, 2024
daa09b0
Added specificity to kit_items_calculation by ensuring diaper and clo…
jadekstewart3 Aug 19, 2024
9528c08
Added another distribution with a total of 200 items to see if expect…
jadekstewart3 Aug 19, 2024
3cf19e1
Fix spelling error
jadekstewart3 Aug 28, 2024
552bbfc
Modify period supplies per adult per month calculations to ensure onl…
jadekstewart3 Sep 10, 2024
fc10668
Modify expect statement to align with new calculations
jadekstewart3 Sep 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/reports/period_supply_report_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def kit_items_calculation(itemizable_type, string_itemizable_type)
INNER JOIN base_items ON base_items.partner_key = kit_items.partner_key
WHERE #{itemizable_type}.organization_id = ?
AND EXTRACT(year FROM issued_at) = ?
AND LOWER(base_items.category) LIKE '%menstral supplies%'
AND LOWER(base_items.category) LIKE '%menstrual supplies%'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've got two spaces instead of one between menstrual and supplies. I checked that out on local, and it makes my initial test work for the Period supplies distributed.

AND NOT (LOWER(base_items.category) LIKE '%diaper%' OR LOWER(base_items.name) LIKE '%cloth%')
AND kit_line_items.itemizable_type = 'Kit';
SQL
Expand Down
10 changes: 5 additions & 5 deletions spec/services/reports/period_supply_report_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
purchased_period_supply_kit = create(:kit, :with_item, organization: organization)
pad_and_tampon_kit = create(:kit, :with_item, organization: organization)

create(:base_item, name: "Adult Pads", partner_key: "adult pads", category: "Menstral Supplies")
create(:base_item, name: "Adult Tampons", partner_key: "adult tampons", category: "Menstral Supplies")
create(:base_item, name: "Adult Pads", partner_key: "adult pads", category: "Menstrual Supplies")
create(:base_item, name: "Adult Tampons", partner_key: "adult tampons", category: "Menstrual Supplies")

period_supplies_kit_item = create(:item, name: "Adult Pads", partner_key: "adult pads")
another_period_supplies_kit_item = create(:item, name: "Adult Tampons", partner_key: "adult tampons")
Expand Down Expand Up @@ -140,14 +140,14 @@

expect(report.report[:name]).to eq("Period Supplies")
expect(report.report[:entries]).to match(hash_including({
"% period supplies bought" => "66%",
"% period supplies donated" => "34%",
"% period supplies bought" => "67%",
"% period supplies donated" => "33%",
"Period supplies distributed" => "2,300",
"Period supplies per adult per month" => 20,
"Money spent purchasing period supplies" => "$40.00"
}))
expect(report.report[:entries]["Period supplies"].split(", "))
.to contain_exactly("Tampons", "Pads", "Liners (Menstrual)")
.to contain_exactly("Adult Pads", "Adult Tampons", "Liners", "Liners (Menstrual)", "Pads", "Tampons")
end

it "returns the correct quantity of period supplies from kits" do
Expand Down
Loading