Skip to content
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

4333 remove inventory items #4607

Merged
merged 21 commits into from
Nov 7, 2024
Merged

4333 remove inventory items #4607

merged 21 commits into from
Nov 7, 2024

Conversation

dorner
Copy link
Collaborator

@dorner dorner commented Aug 23, 2024

Resolves #4333

Description

Definitely do not merge this.

This removes InventoryItems and all associated functionality, with the exception of the records themselves and the basic associations. It also removes Kit allocation and deallocation.

Need to get all tests passing, and then do some exhaustive manual testing afterwards.

dorner added 17 commits May 10, 2024 16:54
# Conflicts:
#	app/controllers/storage_locations_controller.rb
#	app/models/item.rb
#	app/services/item_create_service.rb
#	spec/controllers/donations_controller_spec.rb
#	spec/models/inventory_item_spec.rb
#	spec/models/organization_stats_spec.rb
#	spec/requests/distributions_requests_spec.rb
#	spec/requests/purchases_requests_spec.rb
#	spec/requests/storage_locations_requests_spec.rb
#	spec/services/allocate_kit_inventory_service_spec.rb
#	spec/services/deallocate_kit_inventory_service_spec.rb
#	spec/system/distribution_system_spec.rb
# Conflicts:
#	app/controllers/distributions_controller.rb
#	spec/rails_helper.rb
@dorner dorner marked this pull request as ready for review October 13, 2024 21:08
Copy link
Collaborator

@awwaiid awwaiid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial notes; I'll need to read through in particular the adjustment (increase/decrease) cleanup in detail

app/controllers/audits_controller.rb Show resolved Hide resolved
Comment on lines +67 to +71
if @change_by.positive?
KitAllocateEvent.publish(@kit, @storage_location.id, @change_by)
else
KitDeallocateEvent.publish(@kit, @storage_location.id, -@change_by)
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better

app/controllers/kits_controller.rb Show resolved Hide resolved
to_storage_location: storage_location.id,
to_storage_location: storage_location,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Good looking.

@@ -207,16 +196,6 @@ def self.csv_export_headers
["Name", "Barcodes", "Base Item", "Quantity"]
end

# TODO remove this method once read_events? is true everywhere
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good

app/services/distribution_itemized_breakdown_service.rb Outdated Show resolved Hide resolved
app/services/donation_itemized_breakdown_service.rb Outdated Show resolved Hide resolved
@@ -40,9 +37,6 @@ def items_below_minimum_quantity
if @inventory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorner same, etc down

app/services/item_create_service.rb Show resolved Hide resolved
Comment on lines 112 to 113
<% else %>
<%= render partial: "inventory_item_row",
collection: @storage_location.inventory_items.joins(:item).where(items: { active: true }),
locals: { version_date: params[:version_date] } %>
<% end %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer need the else at all, and maybe don't need to elsif @legacy_inventory block either?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh I fell into that trap. We do need this because it tracks inventory from before event sourcing was introduced.

@cielf
Copy link
Collaborator

cielf commented Oct 26, 2024

@dorner " It also removes Kit allocation and deallocation."
Please tell me more about this --for instance, does that mean that we should be able to handle donating kits now? ( it's failing a test of donating kits where there were no kits allocated, then deallocating them -- but it would have before the change as well.)

Copy link
Collaborator

@awwaiid awwaiid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still can't find any issues; I'll ask a bit on our call about the views but really this is mergeable from what I've seen so far.

@@ -28,7 +28,5 @@ def transfer
end

def revert_inventory_transfer!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this empty method altogether.

@@ -462,38 +462,6 @@
}
))
end

it "should process a snapshot event" do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be kept, or replaces with one that is an event-driven snapshot create?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I guess the one below covers us

@@ -199,15 +199,6 @@
end

context "Methods >" do
describe "storage_locations_containing" do
it "retrieves all storage locations that contain an item" do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is deleteable mostly because it would need to be completely re-written. Ah -- and it is effectively covered by spec/models/view/inventory_spec.rb #storage_locations_for_item. OK cool.

@@ -113,19 +113,20 @@
it 'should return false' do
item = create(:item, :active, organization: organization, kit: kit)
storage_location = create(:storage_location, :with_items, organization: organization, item: item)
kit.reload
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this needed?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, probably for kit.item.id to work on the newly created item.

@@ -1,12 +1,7 @@
# == No Schema Information
#
RSpec.describe OrganizationStats, type: :model do
let(:partners) { [] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice overall refactor in this spec

# storage_location_id :integer
#

RSpec.describe InventoryItem, type: :model do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bold deletion, but I suppose true

@@ -34,13 +34,6 @@
</tr>
<% end %>
<% else %>
<% kit.inventory_items.map do |inventory_item| %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorner maybe I'll need a walk through of why we need the empty-else or the condition at all

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we do!

@dorner
Copy link
Collaborator Author

dorner commented Nov 3, 2024

Pushed some fixes!

Copy link
Collaborator

@awwaiid awwaiid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review looks great! I think a little manual testing on the Kit de-allocation is all we need before merging.

@cielf
Copy link
Collaborator

cielf commented Nov 4, 2024

The kit stuff does seem to work. I do not know what I was looking at.

@cielf cielf self-requested a review November 4, 2024 21:06
@cielf
Copy link
Collaborator

cielf commented Nov 6, 2024

@dorner I'm seeing if you put two items that are the same in a purchase, they stay as two lines in this branch, whereas they are combined in main. If I'm reading things correctly, it's been awhile since we've merged main into this. Could we reasonably do that for final testing?

@dorner
Copy link
Collaborator Author

dorner commented Nov 6, 2024

It's been merged!

@cielf
Copy link
Collaborator

cielf commented Nov 6, 2024

Light testing finds no issues.

Copy link
Collaborator

@cielf cielf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved from a functional pov

@cielf cielf merged commit b7a331c into main Nov 7, 2024
22 checks passed
@cielf cielf deleted the 4333-remove-inventory-items branch November 7, 2024 14:49
Copy link
Contributor

@dorner: Your PR 4333 remove inventory items is part of today's Human Essentials production release: 2024.11.10.
Thank you very much for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore disabling InventoryItem
3 participants