human-essentials icon indicating copy to clipboard operation
human-essentials copied to clipboard

Allow a hard limit on number of specific items per request.

Open cielf opened this issue 5 months ago • 11 comments

Summary

Provide a way to put a hard limit on the number of specific items per request

Why?

Making the requests more realistic in light of what the banks can actually provide

Details

Add a "Request Limit" field to each item.
If the item has custom units, we'd need a request limit for each custom unit.

When a request is being saved, the amount of the item requested will be checked against its request limit. If the request limit is provided, and the amount requested is higher than the request limit, an error

"[Item name]: You requested [amount requested] [units if applicable], but are limited to [request limit][units if applicable].

will be displayed, and the request not saved.

This is considered advanced due to familiarity with the current system, and design work

Criteria for completion

  • [ ] behaviour as described
  • [ ] automated tests for behaviour
  • [ ] update user guide for behaviour

cielf avatar Jul 06 '25 14:07 cielf

Completed:

  1. Request limit field added to ChecklistItem
  2. Validation to prevent negative values
  3. Specs written and passing (checklist_item_spec.rb)

In Progress:

  1. Enforcement of hard limit during request creation
  2. Working on controller/service logic and associated specs

nprude avatar Jul 12 '25 19:07 nprude

"Checklistitem"? I'm not familiar with "CheckListItem". Do you mean "Item"?

cielf avatar Jul 12 '25 20:07 cielf

"Checklistitem"? I'm not familiar with "CheckListItem". Do you mean "Item"?

Just to confirm, the model handling request limits is ChecklistItem. It maps to the checklist_items table and is already wired with validation for request_limit. Let me know if there's a more general Item model in use elsewhere that I should be coordinating with — happy to adjust if needed. grep -r "Item" spec/:

  • spec/views/checklist_items/new.html.erb_spec.rb: assign :checklist_item, ChecklistItem.new
  • spec/views/checklist_items/edit.html.erb_spec.rb: assign :checklist_item, ChecklistItem.new
  • spec/policies/checklist_item_policy_spec.rb: RSpec.describe ChecklistItemPolicy do
  • spec/models/checklist_item_spec.rb: RSpec.describe ChecklistItem, type: :model do
  • spec/requests/checklist_items_spec.rb: RSpec.describe "ChecklistItems", type: :request do
  • spec/requests/checklist_items_spec.rb: expect(ChecklistItem.count).to eq 1
  • spec/requests/checklist_items_spec.rb: expect(ChecklistItem.count).to eq 0
  • spec/requests/checklist_items_spec.rb: expect(ChecklistItem.count).to eq 1
  • spec/components/dropdown_menu_component_spec.rb: render_inline(...) { "Example Item" }
  • spec/components/dropdown_menu_component_spec.rb: expect(page).to have_css(".dropdown-menu", text: "Example Item")
  • spec/components/form/multiple_select/item_component_spec.rb: RSpec.describe Form::MultipleSelect::ItemComponent, type: :component do

All references in spec files either use ChecklistItem directly or mention "Item" in non-model UI components. There’s no standalone Item model being tested or referenced. Work and tests are based on ChecklistItem, which reflects the active implementation

nprude avatar Jul 12 '25 20:07 nprude

I just pulled an up-to-date copy of the main branch and do not see any "ChecklistItem" references in it.

(poles around a bit more)

This is a human-essentials issue -- I can see ChecklistItem in the casa codebase -- are you possibly working in the wrong codecase for this issue?

cielf avatar Jul 13 '25 09:07 cielf

I just realized that I was still in the casa codebase and not human essentials. My mistake! I will pivot and reapply logic. Thank you.

nprude avatar Jul 13 '25 18:07 nprude

Hey team,

Thanks for all the support and context so far. I’ve spent some time digging into the snapshot structure and storage locations, but I’m currently prioritizing a Python course that’s taking up most of my bandwidth. Given the time commitment required to fully resolve this, I’d like to step back from this issue for now.

If someone else wants to pick it up, I’m happy to share what I’ve learned so far:

The snapshot loads correctly, but the items hashes in all storage locations are empty.

This likely means the snapshot was taken when no inventory was present.

I started exploring other event types (e.g., PurchaseEvent, DonationEvent) to trace inventory flow, but haven’t gone deep yet.

Appreciate your understanding!

nprude avatar Aug 02 '25 02:08 nprude

Our interpretation on the units is that banks are not required to have a request limit on each applicable unit but they should be able to enter a different limit for every unit e.g. they can have a limit of 5 packs of wipes but no limit on individual wipes

embarnard avatar Sep 12 '25 15:09 embarnard

If this ticket is still truly unassigned, I'd like to take a stab at it!

awdjob avatar Oct 05 '25 00:10 awdjob

I think @awwaiid is reviewing a PR for this.

dorner avatar Oct 05 '25 14:10 dorner

This issue is marked as stale due to no activity within 30 days. If no further activity is detected within 7 days, it will be unassigned.

github-actions[bot] avatar Nov 05 '25 00:11 github-actions[bot]

Automatically unassigned after 7 days of inactivity.

github-actions[bot] avatar Nov 13 '25 00:11 github-actions[bot]