From a32293283ff7b4fc92792d0baafcc6d8db814a0f Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 25 Jan 2017 11:25:41 -0800 Subject: [PATCH] Remove expedited exchanges --- core/app/models/spree/app_configuration.rb | 15 ---------- core/app/models/spree/return_authorization.rb | 28 ------------------- 2 files changed, 43 deletions(-) diff --git a/core/app/models/spree/app_configuration.rb b/core/app/models/spree/app_configuration.rb index 1d2d4f22e91..0bc754a18ef 100644 --- a/core/app/models/spree/app_configuration.rb +++ b/core/app/models/spree/app_configuration.rb @@ -128,21 +128,6 @@ class AppConfiguration < Preferences::Configuration # prices are entered in the backend (default: nil) preference :admin_vat_country_iso, :string, default: nil - # @!attribute [rw] expedited_exchanges - # Kicks off an exchange shipment upon return authorization save. - # charge customer if they do not return items within timely manner. - # @note this requires payment profiles to be supported on your gateway of - # choice as well as a delayed job handler to be configured with - # activejob. - # @return [Boolean] Use expidited exchanges (default: +false+) - preference :expedited_exchanges, :boolean, default: false - - # @!attribute [rw] expedited_exchanges_days_window - # @return [Integer] Number of days the customer has to return their item - # after the expedited exchange is shipped in order to avoid being - # charged (default: +14+) - preference :expedited_exchanges_days_window, :integer, default: 14 - # @!attribute [rw] generate_api_key_for_all_roles # @return [Boolean] Allow generating api key automatically for user # at role_user creation for all roles. (default: +false+) diff --git a/core/app/models/spree/return_authorization.rb b/core/app/models/spree/return_authorization.rb index b69858c593f..1e757700a51 100644 --- a/core/app/models/spree/return_authorization.rb +++ b/core/app/models/spree/return_authorization.rb @@ -13,8 +13,6 @@ class ReturnAuthorization < Spree::Base before_create :generate_number - after_save :generate_expedited_exchange_reimbursements - accepts_nested_attributes_for :return_items, allow_destroy: true validates :order, presence: true @@ -22,11 +20,6 @@ class ReturnAuthorization < Spree::Base validate :must_have_shipped_units, on: :create validate :no_previously_exchanged_inventory_units, on: :create - # These are called prior to generating expedited exchanges shipments. - # Should respond to a "call" method that takes the list of return items - class_attribute :pre_expedited_exchange_hooks - self.pre_expedited_exchange_hooks = [] - state_machine initial: :authorized do before_transition to: :canceled, do: :cancel_return_items @@ -88,26 +81,5 @@ def no_previously_exchanged_inventory_units def cancel_return_items return_items.each { |item| item.cancel! if item.can_cancel? } end - - def generate_expedited_exchange_reimbursements - return unless Spree::Config[:expedited_exchanges] - - items_to_exchange = return_items.select(&:exchange_required?) - items_to_exchange.each(&:attempt_accept) - items_to_exchange.select!(&:accepted?) - - return if items_to_exchange.blank? - - pre_expedited_exchange_hooks.each { |h| h.call items_to_exchange } - - reimbursement = Spree::Reimbursement.new(return_items: items_to_exchange, order: order) - - if reimbursement.save - reimbursement.perform! - else - errors.add(:base, reimbursement.errors.full_messages) - raise ActiveRecord::RecordInvalid.new(self) - end - end end end