class VertexClient::Response::QuotationFallback

Public Class Methods

new(payload) click to toggle source
# File lib/vertex_client/responses/quotation_fallback.rb, line 5
def initialize(payload)
  @body = payload.body
end

Public Instance Methods

subtotal() click to toggle source
# File lib/vertex_client/responses/quotation_fallback.rb, line 9
def subtotal
  @subtotal || line_items.sum(&:price)
end
total() click to toggle source
# File lib/vertex_client/responses/quotation_fallback.rb, line 17
def total
  @total ||= subtotal + total_tax
end
total_tax() click to toggle source
# File lib/vertex_client/responses/quotation_fallback.rb, line 13
def total_tax
  @total_tax ||= line_items.sum(&:total_tax).floor(2)
end

Private Instance Methods

product_for_line_item(product) click to toggle source
# File lib/vertex_client/responses/quotation_fallback.rb, line 23
def product_for_line_item(product)
  LineItemProduct.new(
    product_code:   product[:content!],
    product_class:  product[:@productClass],
  )
end
tax_amount(price, state) click to toggle source
# File lib/vertex_client/responses/quotation_fallback.rb, line 30
def tax_amount(price, state)
  if RATES.has_key?(state)
    price * BigDecimal.new(RATES[state])
  else
    BigDecimal.new('0.0')
  end
end
tax_for_line_item(line_item) click to toggle source
# File lib/vertex_client/responses/quotation_fallback.rb, line 38
def tax_for_line_item(line_item)
  price = BigDecimal.new(line_item[:extended_price].to_s)
  state = line_item[:customer][:destination][:main_division]
  tax_amount(price, state)
end