Sha256: d7a7edb1f4fe590a60913b9930a11d525c0bebf8d759893578674920a812b05c

Contents?: true

Size: 1.34 KB

Versions: 18

Compression:

Stored size: 1.34 KB

Contents

module Economic
  class Line < Base
    field :lineNumber
    field :description
    field :sortKey
    field :quantity
    field :unitNetPrice
    field :discountPercentage
    field :unitCostPrice
    field :marginInBaseCurrency
    field :marginPercentage
    field :totalNetAmount

    relation :product, fields: [:productNumber]
    relation :unit, fields: [:unitNumber, :name]
    relation :delivery, fields: [:address, :zip, :city, :country, :deliveryDate]

    def self.build_from_soap_api(data)
      # This is not instantiated with the hash, as lines are never pulled out by themselves, but always as part of
      # a invoice or order
      {
        "lineNumber" => data[:number].to_i,
        "description" => data[:description],
        "quantity" => data[:quantity].to_f,
        "unitNetPrice" => data[:unit_net_price].to_f,
        "discountPercentage" => data[:discount_as_percent].to_f,
        "unitCostPrice" => data[:unit_cost_price].to_f,
        "totalNetAmount" => data[:total_net_amount].to_f,
        "marginPercentage" => data[:margin_as_percent].to_f,
        "marginInBaseCurrency" => data[:total_margin].to_f,
        "product" => {"productNumber" => data[:product_handle][:number]},
        # Unmapped values in soap
        # delivery_date
        # :accrual_start_date => nil,
        # :accrual_end_date => nil
      }
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
economic-rest-0.5.10 lib/economic/line.rb
economic-rest-0.5.9 lib/economic/line.rb
economic-rest-0.5.8 lib/economic/line.rb
economic-rest-0.5.7 lib/economic/line.rb
economic-rest-0.5.6 lib/economic/line.rb
economic-rest-0.5.5 lib/economic/line.rb
economic-rest-0.5.4 lib/economic/line.rb
economic-rest-0.5.3 lib/economic/line.rb
economic-rest-0.5.2 lib/economic/line.rb
economic-rest-0.5.1 lib/economic/line.rb
economic-rest-0.5.0 lib/economic/line.rb
economic-rest-0.4.7 lib/economic/line.rb
economic-rest-0.4.6 lib/economic/line.rb
economic-rest-0.4.4 lib/economic/line.rb
economic-rest-0.4.3 lib/economic/line.rb
economic-rest-0.4.2 lib/economic/line.rb
economic-rest-0.4.1 lib/economic/line.rb
economic-rest-0.4.0 lib/economic/line.rb