Sha256: 8343cf865e66516a80b8c4ce301eb83d71e9905a5e60a424f2b7ad91bd3b1eb9

Contents?: true

Size: 1.48 KB

Versions: 13

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module SolidusBactracs
  module Spree
    module ShipmentDecorator
      def self.prepended(base)
        base.singleton_class.prepend ClassMethods
      end

      def verify_bactracs_sync!
        if bactracs_sync_verified_at.nil?
          # API call to verify RMAs of shipments
          if BactracsService.new.rma_was_synced?(self)
            self.update_column(:bactracs_sync_verified_at, Time.now)
          else
            self.update_column(:bactracs_synced_at, nil)
          end
        end
      rescue => e
        Rails.logger.error({ message: "#{e.message}, file: shipment_decorator.rb", shipment_number: number })
      end

      module ClassMethods
        def exportable
          ::Spree::Deprecation.warn <<~DEPRECATION
            `Spree::Shipment.exportable` is deprecated and will be removed in a future version
            of solidus_bactracs. Please use `SolidusBactracs::Shipment::ExportableQuery.apply`.
          DEPRECATION

          SolidusBactracs::Shipment::ExportableQuery.apply(self)
        end

        def between(from, to)
          ::Spree::Deprecation.warn <<~DEPRECATION
            `Spree::Shipment.between` is deprecated and will be removed in a future version
            of solidus_bactracs. Please use `SolidusBactracs::Shipment::BetweenQuery.apply`.
          DEPRECATION

          SolidusBactracs::Shipment::BetweenQuery.apply(self, from: from, to: to)
        end
      end

      ::Spree::Shipment.prepend self
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
solidus_bactracs-4.0.1 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-4.0.0 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.5.2 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.5.1 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.5.0 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.4.0 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.3.2 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.3.1 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.3.0 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.2.2 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.2.1 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.2.0 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb
solidus_bactracs-3.1.2 app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb