lib/economic/proxies/debtor_proxy.rb in rconomic-0.7.1 vs lib/economic/proxies/debtor_proxy.rb in rconomic-0.7.2
- old
+ new
@@ -16,10 +16,18 @@
# Returns the next available debtor number
def next_available_number
request :get_next_available_number
end
+ def get_current_invoices(debtor_handle)
+ response = fetch_response(:get_current_invoices, debtor_handle)
+ build_entities_from_response(
+ Economic::CurrentInvoice,
+ response[:current_invoice_handle]
+ )
+ end
+
def get_debtor_contacts(debtor_handle)
response = fetch_response(:get_debtor_contacts, debtor_handle)
build_entities_from_response(
Economic::DebtorContact,
response[:debtor_contact_handle]
@@ -50,12 +58,22 @@
[handles].flatten.map do |handle|
entity = entity_class.new(:session => session)
entity.partial = true
entity.persisted = true
entity.handle = handle
- entity.number = handle[:id].to_i
+ entity = add_id_to_entity(entity, handle[:id].to_i)
entity
end
+ end
+
+ def add_id_to_entity(entity, id)
+ if entity.respond_to?(:number=)
+ entity.number = id
+ else
+ entity.id = id
+ end
+
+ entity
end
def fetch_response(operation, debtor_handle)
request(
operation,