-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable inactivating item with inventory and don't show inactive item… #4179
Conversation
@dorner Hrm. That's not quite what I expected. The storage location should show active items with 0 inventory (if it's ever had them -- I'm not sure if we currently show inventory levels in an SL if it's never had the items) just not inactive ones. |
It should still show them on the storage location page because it explicitly includes them in the query. |
It's still letting me inactivate with non-zero inventory, too. |
After inactivating a couple, I got this on signing in again: View::Inventory::ViewInventoryItem#name delegated to db_item.name, but db_item is nil: #<View::Inventory::ViewInventoryItem item_id=1 quantity=0 storage_location_id=1 db_item=nil>" Edit: I'll see if i can recreate this. |
Well, I did an inventory adjustment of AB L/XL down to 0, and it disappeared from the SL page. Checked the current behaviour on the production branch -- it doesn't disappear. |
Hmm... not sure what happened here then. Will take this back. |
Please make this one your first priority, coding-wise, as it will hold up the release. Danke. |
@cielf Pushed a fix to show the 0-inventory items. I haven't been able to recreate the other two things you mentioned. |
Ignore the comment from 2:28 or so. Didn't have the very latest. Am trying to recreate again. |
Well, the first part is definitely still happening on my local, without read_events: |
I'm getting the same results with read_events enabled. |
@cielf deleting an item is not the same as making it inactive. There is a checkbox in the "edit" page that does that. |
Hrm. Um - but it shows up again if I click 'Also include inactive items" So what is the difference? (We may have a terminology inconsistency) |
Also - on the read_events side, after deleting the item, I got the error I mentioned (View::Inventory::ViewInventoryItem#name delegated to db_item.name, but db_item is nil: #<View::Inventory::ViewInventoryItem item_id=1 quantity=699 storage_location_id=1 db_item=nil>) If I tried to view the storage location after the above steps. |
... Thanks - will look again tomorrow. |
The delete calls item.destroy , which is overriden to call deactivate if the item has history def destroy |
This is a footgun just waiting to go off. Looks like there is already an issue because one code path will deactivate an associated kit and the other won't. @cielf any issues with removing one or the other paths? I think it'll be simpler to require users to click the "Delete" button to deactivate the item, and remove the checkbox from the update path. We can update the wording on the item to "Deactivate" if it has history. Thoughts? |
If we're only to keep one, I would keep the button in the list. I like the idea of changing the wording. We can probably 'sell' it as a simplification. |
@cielf finally got this done Item page will show "Delete" if it has no history at all, "Deactivate" if it has history but no inventory/kits, and a disabled "Deactivate" button if it has either of those and hence can't even be deactivated. Removed the "Item Is Active?" field from the edit page. Not sure if some tests will fail, will wait to see. |
Finally good to go here I think! |
From functional test: If you have an active item that been in a storage location but is now 0 there, the storage location should show in the list in the item view (Inventory | Items & Inventory | view the item in question). It isn't appearing if read_events is enabled. |
Here is a shortish path to the error: If I restore the item, the error goes away. |
So. It looks good to me, functionally, when read_events is not enabled, but is not ready for prime time when read_events is enabled. FWIW, This sequence was not in my event source testing list. So this problem may have already been there. |
I checked against the production branch, though, and I didn't get the error. That was unexpected. EDIT: Seems ok on main too!? |
@dorner It appears to me that StorageLocation.items_inventoried is doing things with all items, but trips over its shoelaces on the inactive item. Given the removal of the filter on Storage Locations, I posit that items_inventoried should only be looking at active items. Does that make sense? (or is that the wrong place to fix this) EDIT: Nope -- it's also dying in much the same way on the dashboard, so either the place to fix it is further 'down' the chain, or we need to fix it in multiple places. |
I think I was being dumb with the |
|
||
it "should show all active items with corresponding buttons" do | ||
get items_path(default_params) | ||
page = Nokogiri::HTML(response.body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I was looking for this the other day for another spec, heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I walked through and also did some interactive testing as well, focusing on the non-event branches. Looks like you just fixed the event-branch issue, and the fix makes sense. All of this look good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We reviewed the event-based part together and it looks good/safe.
@dorner: Your PR |
…s on storage location.
Might have some failing tests here as I updated the
inventory_for
to stop showing zero-inventory items, so might need to fix other expectations.