I have just published the Invoice Address API (https://civicrm.org/extensions/invoice-address-api).
The development of the extension was funded by Domus Medica vzw. They are a membership organization specifically for GP's (general practitioner) in Flanders and Brussels.
Their members log in on the website and have to be able to renew their membership, buy a new membership, buy products and training, buy job adverts and register for events. When it comes to paying they need to be able to select an invoice address for this specific occassion. That could be their own private address, but also the address of their employer or the address of the co-operative group they are part of, or the address of their own company.
The extension provides an API: InvoiceAddress Get (with parameter contact_id) that will return all the available invoice addresses for the contact.
In the background the API will do the following:
* it will retrieve the billing addresses of the contact_id passed as parameter.
* it will retrieve all the relationships of the contact and check if the relationship type has been allowed as an invoice address relationship type (check the Settings section below).
* if the relationship is allowed, the billing addresses of the related contacts will be retrieved
* it will return all the found addresses
* the fields that will be returned depend on the settings (check the Settings section below)
The extension also introduces a specific relationship type Invoice Address From/For which can be used for exceptional cases where an address has to be available as an invoice address without any logical reason :-). Check further documentation at https://lab.civicrm.org/ErikHommel/invoiceaddressapi