Sha256: 6219819b09832789b259221de275a9fe61199ed17c2ac0976b0e3d544df88f41

Contents?: true

Size: 665 Bytes

Versions: 41

Compression:

Stored size: 665 Bytes

Contents

namespace :solidus do
  namespace :migrations do
    namespace :migrate_shipping_rate_taxes do
      task up: :environment do
        print "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_id: nil)
        puts "Success."
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
solidus_core-2.5.2 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.5.1 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.5.0 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.5.0.rc1 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.5.0.beta2 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.5.0.beta1 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.4.2 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.3.1 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.4.1 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.2.2 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.1.1 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.0.3 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-1.4.2 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-1.3.2 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.4.0 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.4.0.rc1 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.4.0.beta1 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.3.0 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.3.0.rc3 lib/tasks/migrations/migrate_shipping_rate_taxes.rake
solidus_core-2.3.0.rc2 lib/tasks/migrations/migrate_shipping_rate_taxes.rake