-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use in-memory objects in OrderUpdater and remove Adjustment callbacks #1389
Changes from 1 commit
929cb02
601fecc
1ed8dbe
164971b
5e58d10
3aecbe9
d198e84
09c5f69
1da229b
c87129d
70dbeab
847a33d
6e74000
b160c9b
4da7e8a
cb302fb
0ca63c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,7 +155,7 @@ | |
inventory_unit_2.line_item.reload # UnitCancel#compute_amount needs updated amounts | ||
order.cancellations.short_ship([inventory_unit_2]) | ||
line_item.reload | ||
expect(line_item.adjustments.non_tax.sum(:amount)).to eq(-1.67) | ||
expect(line_item.adjustments.map(&:amount)).to match_array([0.01, -0.83, -0.84]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
and that 0.01 is the tax adjustment above 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a little strange, as the three values now add up to -1.66. Is there a tax adjustment hidden there? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. Don't answer, Line 144-152 explain it all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mamhoff I went ahead and updated a bit because this spec was hard for me to follow when I first read it and @jhawthorn also left a comment similar to yours. |
||
expect(line_item.total).to eq 0 | ||
end | ||
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.
This and the change above it are unfortunate. :( See the commit message for details.
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.
Here's an idea for getting OrderUpdater to operate on in-memory objects, to try to avoid problems like the above.
Two risks I can think of:
ItemAdjustments#update
on all shipments & line items, even if they don't currently have any adjustments on them. That will result in an extraselect * from spree_adjustments where adjustable_id = ?
for every line item/shipment that doesn't have at least one adjustment (extra compared to the existing code).Any thoughts?
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 really want to do this.
I don't think we should concern ourselves with someone attaching adjustments to something other than LineItems and Shipments, since the rest of the methods in
OrderUpdater
won't take that into account.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.
@jhawthorn great point. Here's a PR (against this PR) to do that: jordan-brough#7 Shall I merge that into this PR?
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.
👍