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

Conversation

jadekstewart3
Copy link
Contributor

Checklist:

  • I have performed a self-review of my own code,
  • I have commented my code, particularly in hard-to-understand areas,
  • I have made corresponding changes to the documentation,
  • I have added tests that prove my fix is effective or that my feature works,
  • New and existing unit tests pass locally with my changes ("bundle exec rake"),

-->

Resolves #4283

Description

Modify the Period supply report to include items from kits that are both donated and purchased.

Include anything else we should know about. -->

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Added unit tests within the test suit to individually test newly added methods.

jadekstewart3 and others added 16 commits April 26, 2024 10:11
…tion report service, currently returnin 0. Investigation required
…kits, and add test for distributed_period_supplies_from_kits method
… more test set up to ensure correct functionality
@cielf
Copy link
Collaborator

cielf commented Aug 6, 2024

@jadekstewart3 Yay! I think the failed test is unrelated, but please address the things Rubocop is unhappy with.

Don't expect my functional review until later in the week.

@cielf cielf requested review from dorner and cielf August 6, 2024 18:53
@jadekstewart3
Copy link
Contributor Author

@cielf @dorner There is a CI failure, but I checked out the file and it doesnt seem to be one that I touched

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

Hrm (scratches head) My initial test failed.
What I did:
Exported last year's report to have numbers to compare to.
Created a "pad and tampon kit" with 10 tampons, 10 pads and 5 other, allocating 50 to bulk storage location
created a distribution for 1 year ago, with 10 of the "pad and tampon kit", and 2 pads
Reports | Annual Survey | 2023 | Recalculate Report
I expected the Period supplies distributed to be 202 higher than the exported value from before the distribution, It was just 2 more.

@jadekstewart3 jadekstewart3 changed the title 4283 period supplies 4582 period supplies Aug 19, 2024
@jadekstewart3
Copy link
Contributor Author

@cielf I added another distribution to see if my expected would increase by 200, and it seems to be working. Would you mind taking a peek at my test set up to ensure I am creating the distribution properly? The new distribution is pad_and_tampon_kit_distribution, kit is names similarly. Thank you! Im not sure what is goin on so any insight would be much appreciated!

@jadekstewart3 jadekstewart3 changed the title 4582 period supplies 4283 period supplies Aug 19, 2024
@cielf
Copy link
Collaborator

cielf commented Aug 21, 2024

Yeah - I double-checked it. definitely just showing the pads. Have you tried the combination of loose and kitted period supplies.

@cielf I added another distribution to see if my expected would increase by 200, and it seems to be working. Would you mind taking a peek at my test set up to ensure I am creating the distribution properly? The new distribution is pad_and_tampon_kit_distribution, kit is names similarly. Thank you! Im not sure what is goin on so any insight would be much appreciated!

Before I dig in too much -- I noticed that you are misspelling "Menstrual" as "Menstral". That might be the whole problem?

@jadekstewart3
Copy link
Contributor Author

@cielf well that is embarrassing!

cielf
cielf previously requested changes Aug 29, 2024
Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

Ok -- a couple of things to look at. I'll want to really try to break it after these, but I think we'll be ok.

@@ -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.

"Period supplies distributed" => number_with_delimiter(distributed_supplies),
"Period supplies per adult per month" => monthly_supplies&.round || 0,
"Period supplies distributed" => number_with_delimiter(total_distributed_period_supplies),
"Period supplies per adult per month" => (monthly_supplies || 0 + distributed_period_supplies_from_kits_per_month)&.round,
Copy link
Collaborator

@cielf cielf Aug 29, 2024

Choose a reason for hiding this comment

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

This is just going to give you monthly_supplies.round, if you have any. I'm not sure why we had the "|| 0" in the original -- maybe it's nil if there's no period supplies at all ? We should probably check out that case for distributed_period_supplies_from_kits_per_month too.

@cielf cielf dismissed their stale review September 11, 2024 17:54

Works right now.

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

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

Hey @jadekstewart3 This is working much better. Thank you!

Alas, since you started this, we have found out that one of our basic assumptions is mistaken -- I had assumed that a kit would be enough supplies for a month , but because of regulations requiring clear backpacks in schools(!) in some states, the kits for at least one bank are smaller (so they can be contained by the largest opaque container allowed). Which means that our assumption of 1 kit per person is false.

So we need to take into account, for the supplies per person, that a person would get the item.distribution_quantity of kits, if provided, or 1.

Do you think you can apply that in this PR? Do you need some help sussing out what that actually means?

At first blush, I think it means that we need a value like the current monthly_supplies, just for the kits, to divide the distributed_period_supplies_from_kits_per_month by when figuring out the kits per person. So in the simple case where we have 1 kit that gets distributed 2 at a time, we would add half the distributed period supplies from kits per month to the kits per person.

Does that make sense?

If you don't think you can apply that in this PR, let me know.

@jadekstewart3
Copy link
Contributor Author

@cielf I think I have an idea of what youre asking, but Im not exactly sure. Are yall still holding office hours on sundays? Maybe I can chat with someone to help me get a better idea?

@cielf
Copy link
Collaborator

cielf commented Sep 19, 2024

Yes, we are . I'm probably the best person to talk it though with, and I intend to be there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include period supplies in kits in NDBN report values that are based on period supplies
2 participants