Sha256: 4742314d1060bfe12d9e0a573b076a24e626ccc19cb979599c0ab12e7cb7c837

Contents?: true

Size: 829 Bytes

Versions: 2

Compression:

Stored size: 829 Bytes

Contents

module Xsys
  module Model
    class Transaction
      attr_accessor :transaction_id, :shop_id, :transaction_kind_id,
        :receipt_number, :product_id, :client_id, :workshop_id,
        :product_provider_id, :transaction_status_id, :transaction_date,
        :logical_section_id, :physical_section_id, :seller_id, :user_id,
        :shop_code, :user, :items

      def initialize(attributes={})
        attributes.each do |k,v|
          if k.to_s == 'transaction_date'
            self.transaction_date = Date.parse(v) unless v.nil?
          elsif k.to_s == 'user'
            self.user = User.new(v)
          elsif k.to_s == 'items'
            self.items = v.map { |x| TransactionItem.new(x) }
          else
            self.send("#{k}=", v) if self.respond_to?(k)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
xsys-0.0.25 lib/xsys/model/transaction.rb
xsys-0.0.24 lib/xsys/model/transaction.rb