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

Connect shipping rates to shipments earlier in Stock::Coordinator #965

Merged

Conversation

jordan-brough
Copy link
Contributor

This will give the estimator the information it needs to calculate
taxes correctly in the pending tax work.

See comments in #904 (diff)

@mamhoff
Copy link
Contributor

mamhoff commented Mar 4, 2016

❤️ Can you look at the last failing test, and then I'll rebase #904.

@jhawthorn
Copy link
Contributor

This will give the estimator the information it needs to calculate taxes correctly in the pending tax work.

If this is the case we need a spec for that

@jordan-brough
Copy link
Contributor Author

@mamhoff & @jhawthorn updated. Look good? I don't love the spec I added but lmk what you think. Any ideas are definitely welcome.

@mamhoff
Copy link
Contributor

mamhoff commented Mar 7, 2016

I tried rebasing this onto #904. My work then breaks a gazillion other things, and I think the ugly spec and this failure are related somehow: https://circleci.com/gh/solidusio/solidus/2473. I'm not so sure how to remedy this, but essentially our spec setup/our factories are set up in such a way that with this change AND my changes in, 700 specs break because apparently lots of shipping rates have no shipment when they're created. 😿

@jordan-brough
Copy link
Contributor Author

@mamhoff it's this commit where things fall apart right? I'm happy to try to help take a look when I have a few minutes. I think it'd be very good to avoid the attr_accessor :order on the shipping rate if possible in PR 904 and I think it'd be good to understand what's breaking here.

Re the spec I added in 86e4dd8: I think it's a not-great spec because really it's testing internal implementation rather than the public API of the class. There's probably a better way to approach a spec but I'm not sure if there's a pragmatic one. I'll think about that some more when I have a minute (open to ideas!).

@jordan-brough
Copy link
Contributor Author

FYI I chatted briefly with @mamhoff on this and I'm going to take some time tomorrow morning to code up a fix and improve the specs.

@@ -55,15 +56,16 @@ def calculate_shipping_rates(package)
end

def shipping_methods(package)
# TODO: Try changing this to shipment.address

Choose a reason for hiding this comment

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

Incorrect indentation detected (column 10 instead of 8).

@jordan-brough jordan-brough force-pushed the add-rates-to-shipments-earlier branch 2 times, most recently from 6217608 to 79b2914 Compare March 8, 2016 13:48
@jordan-brough
Copy link
Contributor Author

@mamhoff @jhawthorn I've added a couple of commits which broaden the scope of this PR a bit but I think it's worth it. Thoughts?

These changes fix the errors that @mamhoff's commit was seeing.

There is some change to the public API so I've added a changelog for that.

@mamhoff you'll want to omit this change to core/spec/models/spree/stock/estimator_spec.rb if you rebase on top of this.

@jhawthorn
Copy link
Contributor

👍

This will give the estimator the information it needs to calculate
taxes correctly in the pending tax work.
- The package passed to Spree::Stock::Estimator#shipping_rates must
  have its shipment assigned and that shipment must have its order
  assigned. This is needed for some upcoming tax work in to calculate
  taxes correctly.

- Spree::Stock::Estimator.new no longer accepts an order argument. The
  order will be fetched from the shipment.
This was being done immediately after calling #to_shipment and it
makes more sense to do it inside #to_shipment.
@jordan-brough jordan-brough force-pushed the add-rates-to-shipments-earlier branch from 79b2914 to 2842412 Compare March 9, 2016 17:48
@mamhoff
Copy link
Contributor

mamhoff commented Mar 9, 2016

I said so before in real life, but this is a change that will make my life a lot easier. Thank you @jordan-brough!

@gmacdougall
Copy link
Member

Great work @jordan-brough

👍

@jordan-brough
Copy link
Contributor Author

Thanks everyone!

jordan-brough added a commit that referenced this pull request Mar 9, 2016
…lier

Connect shipping rates to shipments earlier in Stock::Coordinator
@jordan-brough jordan-brough merged commit f386357 into solidusio:master Mar 9, 2016
@jordan-brough jordan-brough deleted the add-rates-to-shipments-earlier branch March 9, 2016 20:38
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.

5 participants