rubyforgood / human-essentials

Human Essentials is an inventory management system for diaper, incontinence, and period-supply banks. It supports them in distributing to partners, tracking inventory, and reporting stats and analytics.
https://humanessentials.app
MIT License
436 stars 450 forks source link

Disable *deletion* of donations and purchases if they include an inactive item #4294

Closed cielf closed 1 month ago

cielf commented 2 months ago

Summary

Disable the deletion of donations and purchases if they include an inactive item

Why?

We're going to error out on this anyway, better to be up front about it. Also, on purchases, it's currently throwing an inventory error (which will be a 500 in production)

Details

This is in the view for the donations and purchase. We already disable the "make a correction" button if there are inactive items Do the same for the delete button Change the informational message regarding why the buttons are disabled to:

You can only delete or correct [donations/purchases] where all the items are active. If you need to delete this [donation / purchase] or make a correction, please make the following items active: <%= @distribution.inactive_items.map(&:name).join(", ") %> (replace distribution in the above with donation or purchase as appropriate)

Criteria for completion

pshong79 commented 2 months ago

May I take this one?

cielf commented 2 months ago

Go for it!