Sha256: 7de2ad265e3c1d5949cb8928dc954331993e32b1cec1bb8ae1dd5563314cf9a9

Contents?: true

Size: 767 Bytes

Versions: 4

Compression:

Stored size: 767 Bytes

Contents

module Skr

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

        has_code_identifier :from=>'name'

        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

        # @return [Location] the location that's specified by {Skr::Core::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

4 entries across 4 versions & 1 rubygems

Version Path
stockor-0.1.9 lib/skr/models/location.rb
stockor-0.1.8 lib/skr/models/location.rb
stockor-0.1.7 lib/skr/models/location.rb
stockor-0.1.5 lib/skr/models/location.rb