From a870299cedc4c314bf10ae93f11b54b1ffa8bcd6 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 21 Feb 2019 13:26:46 +0000 Subject: [PATCH] Delete preferences and adjustments related to account invoices --- ...622_delete_account_invoices_preferences.rb | 22 +++++++++++++++++++ ...741_delete_account_invoices_adjustments.rb | 11 ++++++++++ db/schema.rb | 8 +++---- 3 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20190221131622_delete_account_invoices_preferences.rb create mode 100644 db/migrate/20190221131741_delete_account_invoices_adjustments.rb diff --git a/db/migrate/20190221131622_delete_account_invoices_preferences.rb b/db/migrate/20190221131622_delete_account_invoices_preferences.rb new file mode 100644 index 0000000000..e55a61f721 --- /dev/null +++ b/db/migrate/20190221131622_delete_account_invoices_preferences.rb @@ -0,0 +1,22 @@ +class DeleteAccountInvoicesPreferences < ActiveRecord::Migration + def up + Spree::Preference + .where( key: ['spree/app_configuration/accounts_distributor_id', + 'spree/app_configuration/default_accounts_payment_method_id', + 'spree/app_configuration/default_accounts_shipping_method_id', + 'spree/app_configuration/auto_update_invoices', + 'spree/app_configuration/auto_finalize_invoices', + 'spree/app_configuration/account_invoices_monthly_fixed', + 'spree/app_configuration/account_invoices_monthly_rate', + 'spree/app_configuration/account_invoices_monthly_cap', + 'spree/app_configuration/account_invoices_tax_rate', + 'spree/app_configuration/shop_trial_length_days', + 'spree/app_configuration/minimum_billable_turnover']) + .destroy_all + end + + def down + # If these preferences are re-added to app/models/spree/app_configuration_decorator.rb + # these DB entries will be regenerated + end +end diff --git a/db/migrate/20190221131741_delete_account_invoices_adjustments.rb b/db/migrate/20190221131741_delete_account_invoices_adjustments.rb new file mode 100644 index 0000000000..f8baa0e5bf --- /dev/null +++ b/db/migrate/20190221131741_delete_account_invoices_adjustments.rb @@ -0,0 +1,11 @@ +class DeleteAccountInvoicesAdjustments < ActiveRecord::Migration + def up + Spree::Adjustment + .where(:source_type => 'BillablePeriod') + .destroy_all + end + + def down + # This data does not need to be recovered + end +end diff --git a/db/schema.rb b/db/schema.rb index 696182139d..0f3f29f08c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20181128054803) do +ActiveRecord::Schema.define(:version => 20190221131741) do create_table "account_invoices", :force => true do |t| t.integer "user_id", :null => false @@ -533,9 +533,9 @@ ActiveRecord::Schema.define(:version => 20181128054803) do t.datetime "updated_at", :null => false t.integer "max_quantity" t.string "currency" - t.decimal "distribution_fee", :precision => 10, :scale => 2 - t.decimal "final_weight_volume", :precision => 10, :scale => 2 - t.decimal "cost_price", :precision => 8, :scale => 2 + t.decimal "distribution_fee", :precision => 10, :scale => 2 + t.decimal "final_weight_volume", :precision => 10, :scale => 2 + t.decimal "cost_price", :precision => 8, :scale => 2 t.integer "tax_category_id" end