Allow a hard limit on number of specific items per request.
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
Completed:
- Request limit field added to ChecklistItem
- Validation to prevent negative values
- Specs written and passing (checklist_item_spec.rb)
In Progress:
- Enforcement of hard limit during request creation
- Working on controller/service logic and associated specs
"Checklistitem"? I'm not familiar with "CheckListItem". Do you mean "Item"?
"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
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?
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.
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!
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
If this ticket is still truly unassigned, I'd like to take a stab at it!
I think @awwaiid is reviewing a PR for this.
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.
Automatically unassigned after 7 days of inactivity.