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

Upgrade path for shipping rate tax data #1068

Merged
merged 1 commit into from Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
The shipping rate taxer class can be exchanged for a custom estimator class
using the new Spree::Appconfiguration.shipping_rate_taxer_class preference.

Shipping rates for completed orders before this change will, unfortunately, not be shown
with their taxes from Solidus 1.3 onwards. If you do change the shipping rate on an
old order, its taxes will be calculated correctly, though.

https://github.com/solidusio/solidus/pull/904

In order to convert your historical shipping rate taxation data, please run
`rake solidus:upgrade:one_point_three` - this will create persisted taxation notes
for historical shipping rates. Be aware though that these taxation notes are
estimations and should not be used for accounting purposes.

https://github.com/solidusio/solidus/pull/1068

* Deprecate setting a line item's currency by hand

Previously, a line item's currency could be set directly, and differently from the line item's
Expand Down

This file was deleted.

17 changes: 17 additions & 0 deletions core/lib/tasks/migrations/migrate_shipping_rate_taxes.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace :solidus do
namespace :migrations do
namespace :migrate_shipping_rate_taxes do
task up: :environment do
puts "Adding persisted tax notes to historic shipping rates"
Spree::ShippingRate.where.not(tax_rate_id: nil).find_each do |shipping_rate|
tax_rate = Spree::TaxRate.unscoped.find(shipping_rate.tax_rate_id)
shipping_rate.taxes.find_or_create_by!(
tax_rate: tax_rate,
amount: tax_rate.compute_amount(shipping_rate)
)
end
Spree::ShippingRate.where.not(tax_rate_id: nil).update_all(tax_rate: nil)
Copy link
Member

Choose a reason for hiding this comment

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

This seems odd to have inside the loop. Should this just be updating shipping_rate or should this be outside the loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is outside the loop :)

Copy link
Member

Choose a reason for hiding this comment

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

Sorry. Must have been looking at my monitor cross eyed...

end
end
end
end
3 changes: 2 additions & 1 deletion core/lib/tasks/upgrade.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ namespace :solidus do
namespace :upgrade do
desc "Upgrade Solidus to version 1.3"
task one_point_three: [
'solidus:migrations:assure_store_on_orders:up'
'solidus:migrations:assure_store_on_orders:up',
'solidus:migrations:migrate_shipping_rate_taxes:up'
] do
puts "Your Solidus install is ready for Solidus 1.3."
end
Expand Down