Sha256: 188f1883b7ba7a0a4474f19675e5f64ffdcd6e42ef9fe97814c763d1d4c99fb1
Contents?: true
Size: 696 Bytes
Versions: 34
Compression:
Stored size: 696 Bytes
Contents
# frozen_string_literal: true 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
34 entries across 34 versions & 2 rubygems