Sha256: 8cd549064bae08f121beddb02d4e09fb8f6eb7e907a828d4b9cb6bc519a10c13

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 KB

Contents

# encoding: utf-8
module EfoNelfo
  module V40
    class Order
      class Line < EfoNelfo::PostType
        POST_TYPES = {
          'BL' => 'Bestilling vareLinjepost',
          'IL' => 'Forespørsel vareLinjepost'
        }

        # It's important to list the property in the same order as specified in the specs
        property :post_type,         alias: :PostType,   limit: 2,   default: 'BL'
        property :index,             alias: :LinjeNr,    limit: 4,   type: :integer
        property :order_number,      alias: :BestNr,     limit: 10,  required: true
        property :item_type,         alias: :VareMrk,    limit: 1,   required: true, type: :integer
        property :item_number,       alias: :VareNr,     limit: 14,  required: true
        property :item_name,         alias: :VaBetg,     limit: 30,  required: true
        property :item_description,  alias: :VaBetg2,    limit: 30
        property :item_count,        alias: :Ant,        limit: 9,   required: true, type: :integer
        property :price_unit,        alias: :PrisEnhet,  limit: 3,   required: true
        property :buyer_item_number, alias: :KVareNr,    limit: 25
        property :delivery_date,     alias: :LevDato,    type: :date
        property :buyer_ref,         alias: :KjøpersRef, limit: 25
        property :splitable,         alias: :DelLev,     type: :boolean, default: true
        property :replacable,        alias: :AltKode,    type: :boolean, default: true

        attr_reader :text

        # Returns an array with one or more elements
        def to_a
          [ super, text.to_a ].reject(&:empty?)
        end

        def text=(txt)
          if txt.is_a? String
            @text = EfoNelfo::V40::Order::Text.new text: txt
          else
            @text = txt
          end
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
efo_nelfo-0.0.4 lib/efo_nelfo/v40/order/line.rb