Sha256: 1a27059d86895a8e32eb0095ef2cbc3e34fdb3f061e48afcae56be29ce692839

Contents?: true

Size: 829 Bytes

Versions: 70

Compression:

Stored size: 829 Bytes

Contents

module Xsys
  module Model
    class SaleItem
      def self.attr_list
        [:sale_code, :position, :transaction_number, :shop_code, :product_id, :quantity,
        :taxed_unit_price, :vat_unit_price, :total_unit_price, :taxed_amount, :vat_amount,
        :total_amount, :vat_rate]
      end

      attr_reader *attr_list

      def initialize(attributes={})
        decimal_fields = ['taxed_unit_price', 'vat_unit_price', 'total_unit_price',
          'taxed_amount', 'vat_amount', 'total_amount', 'vat_rate']

        attributes.each do |k, v|
          if decimal_fields.include?(k.to_s)
            self.send("#{k}=", BigDecimal.new(v)) unless v.nil?
          else
            self.send("#{k}=", v) if self.respond_to?(k)
          end
        end
      end

      private

      attr_writer *attr_list
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
xsys-0.47.0 lib/xsys/model/sale_item.rb
xsys-0.46.0 lib/xsys/model/sale_item.rb
xsys-0.45.0 lib/xsys/model/sale_item.rb
xsys-0.44.0 lib/xsys/model/sale_item.rb
xsys-0.43.0 lib/xsys/model/sale_item.rb
xsys-0.42.0 lib/xsys/model/sale_item.rb
xsys-0.41.0 lib/xsys/model/sale_item.rb
xsys-0.40.0 lib/xsys/model/sale_item.rb
xsys-0.39.0 lib/xsys/model/sale_item.rb
xsys-0.38.0 lib/xsys/model/sale_item.rb
xsys-0.37.0 lib/xsys/model/sale_item.rb
xsys-0.36.0 lib/xsys/model/sale_item.rb
xsys-0.35.0 lib/xsys/model/sale_item.rb
xsys-0.34.0 lib/xsys/model/sale_item.rb
xsys-0.33.0 lib/xsys/model/sale_item.rb
xsys-0.32.0 lib/xsys/model/sale_item.rb
xsys-0.31.0 lib/xsys/model/sale_item.rb
xsys-0.30.0 lib/xsys/model/sale_item.rb
xsys-0.28.0 lib/xsys/model/sale_item.rb
xsys-0.27.0 lib/xsys/model/sale_item.rb