class Economic::CurrentInvoiceProxy

Public Instance Methods

all() click to toggle source

Fetches all entities from the API.

# File lib/economic/proxies/current_invoice_proxy.rb, line 11
def all
  if owner.is_a?(Economic::Debtor)
    owner.get_current_invoices
  else
    response = request(:get_all)
    handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) }
    get_data_for_handles(handles)

    self
  end
end

Private Instance Methods

initialize_properties_with_values_from_owner(invoice) click to toggle source

Initialize properties in invoice with values from owner

# File lib/economic/proxies/current_invoice_proxy.rb, line 26
def initialize_properties_with_values_from_owner(invoice)
  if owner.is_a?(Debtor)
    invoice.debtor = owner

    invoice.debtor_name         ||= owner.name
    invoice.debtor_address      ||= owner.address
    invoice.debtor_postal_code  ||= owner.postal_code
    invoice.debtor_city         ||= owner.city

    invoice.term_of_payment_handle  ||= owner.term_of_payment_handle
    invoice.layout_handle           ||= owner.layout_handle
    invoice.currency_handle         ||= owner.currency_handle
  end
end