[BUG] able to enter negative values in distributions and donations. Shouldn't be able to
Summary
Should not be able to have negative values for line items in distributions, donations, purchases, transfers, audits, kits
Why
Those values are just invalid in context.
Details
Note that there are line items where we should be able to have negative values, though. Specifically Inventory Adjustments and kit allocations. All other line items should not have negative values in them.
We consider this a high beginner difficulty -- manual testing it out will give you a lot of exercise of the system.
Criteria for completion
- [ ] Cannot save with negative quantities in distributions, donations, purchases, transfers, audits, kits
- [ ] Tests to confirm.
Can I work on this @cielf ?
Can I work on this @cielf ?
Hi @mgrigoriev8109, I would love to be able to join you on a video call, and see you work on this by sharing your screen. If we can collaborate, I'll love to do that also.
@mgrigoriev8109 Please do!
Sorry @topeogunleye , I don't have much bandwidth at the moment so I'm mostly trying to contribute asynchronously. Are you comfortable working in Ruby, or do you need some resources to familiarize yourself with the language?
In general open source projects are great learning opportunities - but it's helpful to have familiarity with a language before diving into a large codebase.
Hi @mgrigoriev8109, Yes!, I have more than a year of working with Ruby and Ruby on Rails and more than 6 months experience of being a code reviewer for Ruby and Ruby on Rails projects. With this experience, I feel more than comfortable with Ruby.
@cielf Figured I'd ask about the other inputs in the codebase since this issue mentions most of them already.
So these questions are when a user is logged in as an Organization Admin ( [email protected] )
- When adding a New Partner Agency under Partner Agencies → All Partners, should the user be allowed to enter a negative quota?
- When adding a New Item under Inventory → Item Types, should the user be allowed to enter negative values for any of the fields ( Value per item, Quantities, package size )
- For kit allocations, should the user be allowed to enter a negative kit value and a negative quantity?
- When adding a new barcode item, should user be allowed to enter negative quantity?
- When adding a new storage location should user be allowed to enter negative square footage?
And then the follow-up question is if these fields also require validation, if I should add it in the same PR, or do a new PR.
Thanks for catching these -- most are out of out of scope for this change,
Kit allocations should be allowed to have a negative quantity, though. This represents a bank de-constructing some kits and putting the components back into inventory. Doesn't happen very often at all, but it can.
The rest should not be negative.
And, I'll followup by checking the rest of those and putting any that aren't right in out backlog of issues (they'll mostly be Good First Issue fodder, I think.)
Sounds good. Just realized this issue only dealt with line items not being negative, some other ones can also be added to the backlog of issues might be:
- in http://localhost:3000/purchases/new as an Organization Admin the 5 different amounts a user can enter
- in http://localhost:3000/distributions/new the money_raised_in_dollars
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.
Have checked the above, and added those that are not right to our deep backlog of issues to be written up.
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.
If no one is working on this, I’d like to take it on.
You've got it
I tested the functionalities you mentioned. The server-side validations are functioning, except for the following issues:
- The Package Size can be negative when creating a new item.
- The Transfer Number can also be negative.
Are these two considered bugs?
Aside from those issues, everything else seems fine. Additionally, the money input field also shows a green checkmark even when a negative value is entered.
Should this issue focus on client-side validation?
Yes they are bugs, though the package size and money issues are out of scope for this issue. As it happens, they are both in our backlog of good first issues (we throttle them so that we are not overwhelmed on the reviewing side).
For clarity, the transfer is part of this issue. And, we usually handle these kinds of things on the model.
REopening -- the pr associated with this only partially solved the issue. (Can still enter donations negative. You'll need to check distributions, requests, audits)
Somehow I missed donation. The others are checked.
distribution new
distribution edit
request
audit