Sha256: 3444d8bfd534e1e27040007f725e1f3dfa1730cacafd806fd29b3accd3abc37b

Contents?: true

Size: 869 Bytes

Versions: 1

Compression:

Stored size: 869 Bytes

Contents

module Skr

    class VoLine < Skr::Model

        acts_as_uom

        is_sku_loc_line parent: 'voucher'

        belongs_to :voucher
        belongs_to :sku_vendor
        belongs_to :po_line
        has_one :sku, :through => :sku_vendor, export: true

        validates :sku_vendor, :voucher,   set: true
        validates :sku_code, :description, :presence => true

        validate :qty, numericality: { gt: 0 }

        before_validation :set_defaults, one: :create

        private

        def set_defaults
            if po_line
                self.sku_vendor = po_line.sku.sku_vendors.for_vendor( self.voucher.vendor )
                %w{ price sku_code part_code description uom_code uom_size }.each do | attr |
                    self[ attr ] ||= po_line[ attr ]
                end
            end
            true
        end
    end


end # Skr module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stockor-core-0.2 lib/skr/vo_line.rb