-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Conversation
# 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
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.
Some initial notes; I'll need to read through in particular the adjustment (increase/decrease) cleanup in detail
if @change_by.positive? | ||
KitAllocateEvent.publish(@kit, @storage_location.id, @change_by) | ||
else | ||
KitDeallocateEvent.publish(@kit, @storage_location.id, -@change_by) | ||
end |
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.
Much better
to_storage_location: storage_location.id, | ||
to_storage_location: storage_location, |
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.
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 |
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.
Very good
@@ -40,9 +37,6 @@ def items_below_minimum_quantity | |||
if @inventory |
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.
@dorner same, etc down
<% else %> | ||
<%= render partial: "inventory_item_row", | ||
collection: @storage_location.inventory_items.joins(:item).where(items: { active: true }), | ||
locals: { version_date: params[:version_date] } %> | ||
<% end %> |
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.
No longer need the else at all, and maybe don't need to elsif @legacy_inventory
block either?
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.
Heh I fell into that trap. We do need this because it tracks inventory from before event sourcing was introduced.
@dorner " It also removes Kit allocation and deallocation." |
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 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! |
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 we can remove this empty method altogether.
@@ -462,38 +462,6 @@ | |||
} | |||
)) | |||
end | |||
|
|||
it "should process a snapshot event" do |
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.
Should this be kept, or replaces with one that is an event-driven snapshot create?
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.
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 |
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 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 |
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.
Why was this needed?
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.
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) { [] } |
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.
Nice overall refactor in this spec
# storage_location_id :integer | ||
# | ||
|
||
RSpec.describe InventoryItem, type: :model do |
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.
Bold deletion, but I suppose true
@@ -34,13 +34,6 @@ | |||
</tr> | |||
<% end %> | |||
<% else %> | |||
<% kit.inventory_items.map do |inventory_item| %> |
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.
@dorner maybe I'll need a walk through of why we need the empty-else or the condition at all
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 don't think we do!
Pushed some fixes! |
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.
Code review looks great! I think a little manual testing on the Kit de-allocation is all we need before merging.
The kit stuff does seem to work. I do not know what I was looking at. |
@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? |
It's been merged! |
Light testing finds no issues. |
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.
Approved from a functional pov
@dorner: Your PR |
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.