Sha256: 8783c6684df321d2ecf8cab5c8b7984ede52e99529fdb545134cd009d3e7577a

Contents?: true

Size: 423 Bytes

Versions: 2

Compression:

Stored size: 423 Bytes

Contents

module SpreeAvataxOfficial
  module HasUuid
    AVATAX_CODES = {
      'LineItem' => 'LI',
      'Shipment' => 'FR'
    }.freeze

    def self.included(base)
      base.before_create :generate_uuid
    end

    def avatax_number
      "#{AVATAX_CODES[self.class.name.demodulize]}-#{avatax_uuid}"
    end

    private

    def generate_uuid
      self.avatax_uuid = SecureRandom.uuid if avatax_uuid.blank?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_avatax_official-1.8.0 app/models/spree_avatax_official/has_uuid.rb
spree_avatax_official-1.7.1 app/models/spree_avatax_official/has_uuid.rb