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

Adjustment inventory drift #3830

Merged
merged 3 commits into from
Aug 18, 2023

Conversation

awwaiid
Copy link
Collaborator

@awwaiid awwaiid commented Aug 13, 2023

(revert-revert)

@awwaiid
Copy link
Collaborator Author

awwaiid commented Aug 13, 2023

@cielf this is the branch to build off of (or create a new branch off of main)

@cielf
Copy link
Collaborator

cielf commented Aug 13, 2023

Noting that there is definitely a large refactoring opportunity in how the increasing and decreasing of inventory are handled. However, this should address the user-impacting issues.

@cielf cielf requested a review from dorner August 13, 2023 19:55
ActiveRecord::Base.transaction do
# Make the necessary changes in the db
@adjustment.save
# Split into positive and negative portions. NOTE -- THIS CHANGES THE ORIGINAL LINE ITEMS DO **NOT** RESAVE
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this comment mean? What should we not resave?

Copy link
Collaborator

Choose a reason for hiding this comment

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

REvised comment coming your way RSN

Comment on lines 49 to 50
return true if @adjustment.errors.none?
false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return true if @adjustment.errors.none?
false
@adjustment.errors.none?

These 2 lines can just read like this 😄

expect(adjustment.line_items[0].quantity).to eq(-5)
end

it "increases handles mixed adjustments to same item appropriately (total is positive version)" do
Copy link
Collaborator

Choose a reason for hiding this comment

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

First word is a typo?

"0": {item_id: item_1.id, quantity: quantity}
}}
subject.new(adjustment_params).call
end.to change { inventory_item_1.reload.quantity }.by(0)
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 store an error, and if so can we check it here?

Copy link
Collaborator

@cielf cielf Aug 18, 2023

Choose a reason for hiding this comment

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

Yes. It'll take me a few minutes to figure out how to check that said error is stored

@cielf cielf requested a review from dorner August 18, 2023 20:30
@@ -17,7 +17,8 @@ def call
ActiveRecord::Base.transaction do
# Make the necessary changes in the db
@adjustment.save
# Split into positive and negative portions. NOTE -- THIS CHANGES THE ORIGINAL LINE ITEMS DO **NOT** RESAVE
# Split into positive and negative portions.
# N.B. -- THIS CHANGES THE ORIGINAL LINE ITEMS ON @adjustment DO **NOT** RESAVE AS THAT WILL CHANGE ANY NEGATIVE LINE ITEMS ON THE ADJUSTMENT TO POSITIVES
Copy link
Collaborator

Choose a reason for hiding this comment

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

lol this comment makes me so nervous

@dorner dorner marked this pull request as ready for review August 18, 2023 20:36
@dorner dorner merged commit 48272d6 into main Aug 18, 2023
12 checks passed
@dorner dorner deleted the revert-3827-revert-3713-adjustment_inventory_drift branch August 18, 2023 20:37
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.

3 participants