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

[BUG] able to enter negative values in distributions and donations. Shouldn't be able to

Open cielf opened this issue 1 year ago • 14 comments

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.

cielf avatar Jun 30 '24 14:06 cielf

Can I work on this @cielf ?

mgrigoriev8109 avatar Jul 01 '24 17:07 mgrigoriev8109

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.

topeogunleye avatar Jul 02 '24 09:07 topeogunleye

@mgrigoriev8109 Please do!

cielf avatar Jul 02 '24 13:07 cielf

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.

mgrigoriev8109 avatar Jul 02 '24 14:07 mgrigoriev8109

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.

topeogunleye avatar Jul 02 '24 14:07 topeogunleye

@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] )

  1. When adding a New Partner Agency under Partner Agencies → All Partners, should the user be allowed to enter a negative quota?
  2. 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 )
  3. For kit allocations, should the user be allowed to enter a negative kit value and a negative quantity?
  4. When adding a new barcode item, should user be allowed to enter negative quantity?
  5. 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.

mgrigoriev8109 avatar Jul 02 '24 15:07 mgrigoriev8109

Thanks for catching these -- most are out of out of scope for this change,

cielf avatar Jul 02 '24 17:07 cielf

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.

cielf avatar Jul 02 '24 17:07 cielf

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

cielf avatar Jul 02 '24 17:07 cielf

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

mgrigoriev8109 avatar Jul 02 '24 19:07 mgrigoriev8109

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 Aug 02 '24 00:08 github-actions[bot]

Have checked the above, and added those that are not right to our deep backlog of issues to be written up.

cielf avatar Aug 06 '24 18:08 cielf

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 Sep 06 '24 00:09 github-actions[bot]

Automatically unassigned after 7 days of inactivity.

github-actions[bot] avatar Sep 13 '24 00:09 github-actions[bot]

If no one is working on this, I’d like to take it on.

nozomirin avatar Dec 29 '24 06:12 nozomirin

You've got it

cielf avatar Dec 29 '24 13:12 cielf

I tested the functionalities you mentioned. The server-side validations are functioning, except for the following issues:

  1. The Package Size can be negative when creating a new item.
  2. 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?

nozomirin avatar Dec 30 '24 02:12 nozomirin

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.

cielf avatar Dec 30 '24 13:12 cielf

REopening -- the pr associated with this only partially solved the issue. (Can still enter donations negative. You'll need to check distributions, requests, audits)

cielf avatar Jan 12 '25 14:01 cielf

Somehow I missed donation. The others are checked. distribution new image

distribution edit image

request image

audit image

nozomirin avatar Jan 13 '25 08:01 nozomirin