Sha256: db3f72d1f24082cf489bcc5ab06ce16727254bc419a09679a1ef3b487d60f1a4

Contents?: true

Size: 991 Bytes

Versions: 2

Compression:

Stored size: 991 Bytes

Contents

module Skr

    # A location that holds inventory
    class Location < Skr::Model

        has_code_identifier :from=>'name'

        has_one :logo, as: :owner, :class_name=>'Lanes::Asset', export: { writable: false }, :dependent => :destroy

        belongs_to :address, export: { writable: true }

        has_many :sku_locs

        validates :gl_branch_code, :presence => true, :numericality=>true, :length=>{:is=>2}

        locked_fields :gl_branch_code

        before_validation :set_defaults, :on=>:create

        def get_logo
            self.logo.present? ? self.logo : Lanes::SystemSettings.config.logo
        end

        # @return [Location] the location that's specified by {Skr::Configuration#default_location_code}
        def self.default
            Location.find_by_code( Skr.config.default_location_code )
        end

      private

        def set_defaults
            self.gl_branch_code ||= Skr.config.default_branch_code
            true
        end

    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stockor-0.5.0 lib/skr/models/location.rb
stockor-0.4.0 lib/skr/models/location.rb