-
-
Notifications
You must be signed in to change notification settings - Fork 469
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
Adjustment inventory drift #3830
Conversation
@cielf this is the branch to build off of (or create a new branch off of |
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. |
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 |
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.
What does this comment mean? What should we not resave?
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.
REvised comment coming your way RSN
return true if @adjustment.errors.none? | ||
false |
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.
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 |
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.
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) |
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 store an error, and if so can we check it here?
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.
Yes. It'll take me a few minutes to figure out how to check that said error is stored
@@ -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 |
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.
lol this comment makes me so nervous
(revert-revert)