Sha256: 796ee02f4415eec56358bf8d2e9477bb2b153841ccbb67dd2d5ec8e5b633041b

Contents?: true

Size: 1.12 KB

Versions: 8

Compression:

Stored size: 1.12 KB

Contents

module Skr

    # Vendors is a companies you purchase goods and services from.
    # They have both a billing and shipping address,
    # a gl account that payables should be applied against, and a payment term.
    class Vendor < Skr::Model

        # Common code shared with {Customer}
        include BusinessEntity

        belongs_to :gl_payables_account, class_name: 'Skr::GlAccount', export: true
        belongs_to :gl_freight_account,  class_name: 'Skr::GlAccount', export: true

        has_many :purchase_orders, inverse_of: :vendor
        has_many :vouchers,        inverse_of: :vendor
        has_many :vendor_skus,     class_name: 'Skr::SkuVendor', inverse_of: :vendor

        delegate_and_export  :gl_payables_account_number
        validates :gl_payables_account, set: true

        has_many :sku_vendors

        private

        def set_defaults
            self.terms               ||= PaymentTerm.find_by_code(Skr.config.customer_terms_code)
            self.gl_payables_account ||= GlAccount.default_for( :ap )
            self.gl_freight_account  ||= GlAccount.default_for( :freight )
        end

    end

end # Skr module

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
stockor-0.5.0 lib/skr/models/vendor.rb
stockor-0.4.0 lib/skr/models/vendor.rb
stockor-0.3.0 lib/skr/models/vendor.rb
stockor-0.2 lib/skr/models/vendor.rb
stockor-0.1.9 lib/skr/models/vendor.rb
stockor-0.1.8 lib/skr/models/vendor.rb
stockor-0.1.7 lib/skr/models/vendor.rb
stockor-0.1.5 lib/skr/models/vendor.rb