Prerequisites
You should have
- an user-account enabled for api access & order management access
- an api-client
Quick Infos
Some generic helpful infos on invoice-data within Hublify
- Invoices have "materialized data" stored.
Means, even if you change connected Person / Customer data, or Order or Delivery data your invoice data stays the same. - Hublify uses one or multiple programmable counters to auto-create unique Invoice-Codes (IDs).
- Credit Memos are basically invoices - just with negative item-prices / negative final sum
- An invoice can refer (definitely recommended) to a Person / Customer record to which it belongs.
- An invoice can refer to an Order record.
One Order can be referred to by many Invoices / Credit Memos at the same time. - Payment / Money Transfers are not really represented by an Invoice but by Transactions.
Many single Transactions can refer to an Order or Invoice - all at the same time. - Invoices have a basic state: DONE / OPEN.
- An Invoice - PDF Document is just a live (template-) rendered PDF from current Invoice data.
- ... There is lot more Invoicing within Hublify which is described in other places. This article is focussed on creating invoices via API.
Creating a new invoice
Some quick infos what happens usually inside Hublify whenever you create (aka inject) an invoice / credit memo.
- Hublify creates an invoice-record ...
- with a Hublify internal unique (counter-based) invoice-code
- with all the other data you provide
- Hublify calculates the total amount for the invoice based on all your provided items
Attention: The mandatory and available optional fields can vary depending on the targeted Hublify's system.
... manually
Manually means in this context, that you basically provide all invoice- (items-) data within your api-call.
There other comfortable functions within Hublify to create invoices based on other data from within Hublify (e.g. from an existing "order").
"inject" vs. "create"
In the Hublify there a several functions and api endpoints that are named "inject". These inject-functions typically provide & execute more comfortable sub-functions than a standard "data_create".
We recommend to preferably use the inject-functions!
General benefits are ...
- possibly less subsequent api-calls
- sometimes easier parameter-interface. sometimes richer.
- often integrated "data auto-learn"-mode of related datasets
minimal
The very minimum of data necessary to create an invoice is basically
- customer invoice-address
- one invoice item
Request URL
https://{your hublify url}/api/eos_10/invoice_inject
Request parameter
{
"fields": {
"inv_gender": "male",
"inv_firstname": "Max",
"inv_lastname": "Muster",
"inv_street": "Example Street",
"inv_housenr": "1c",
"inv_zip": "12345",
"inv_town": "Demo Town",
"inv_country": "DE",
"inv_email": "max.muster@hublify.io", // only needed, if you want to send the invoice via email to the customer
"items": [
{
"invi_pcode": "FL00015", // alphanumeric code representing the item.
"invi_name": "Example Itemname", // Human readable name for the item.
"invi_quantity": 2,
"invi_vat_pct": 19,
"invi_price_single_brutto": 123.45 // price for a single item incl. taxes,
// you can also "invi_price_single_netto" for the net value of this item
}
]
}
}
Response
If your request was successful, you receive the hublify ids for the invoice.
In this example, you created a standalone invoice without any additional references to a person- or PIM-record.
The invoice date is set to the current date.
{
"status": true,
"meta": {
"insert_key": "inv_id",
"primary_key": "inv_id",
"insert_id": 2148,
"primary_value": 2148
},
"data": {
"inv_id": 2148,
"inv_code": "R123456"
}
}
more data
Example with more details provided
- customer invoice-address
- fixed data for invoice-code and -date
- additional details for commercial invoices (B2B) and different countries
- reference to a pre-existing Hublify person-record
- one invoice item with a defined performance period and additional details
- additional fields that can be used to enrich the invoice document
Request URL
https://{your hublify url}/api/eos_10/invoice_inject
Request parameter
{
"fields": {
"inv_time_invoice": "2024-02-01", // in case you want to set a specific date for the invoice (default: today)
"inv_code": "R123456", // a specific invoice-code - will only be used if unique
"inv_gender": "male",
"inv_company": "Company Ltd.",
"inv_firstname": "Max",
"inv_lastname": "Muster",
"inv_street": "Example Street",
"inv_addrextra": "Additional Addressline",
"inv_housenr": "1c",
"inv_zip": "12345",
"inv_town": "Demo Town",
"inv_country": "DE",
"inv_email": "max.muster@hublify.io",
"inv_type": "commercial", // for B2B
"inv_taxidentnumber": "UstIDExample", // TaxIdentNr for the customer
"inv_taxident_status": "valid_confirmed", // Status of the TaxIdentNr.
"inv_deliver_country": "AT", // if the invoiced items were delivered to a different country
"inv_tax_country": "AT", // Country you pay taxed on this invoice (default: same as inv_country)
"inv_txt_title": "Title for this invoice", // A specific headline for the invoice document
"inv_txt_header": "Intro text", // Additional HTML-text that can be displayed in the invoice-document
"inv_txt_footer": "Some more text", // Additional HTML-text that can be displayed in the invoice-document
"fk_inv_persid": 123, // Reference to a pre-existing person-record
// The Hublify internal id of the person-record (persid) is used
"items": [
{
"invi_pcode": "FL00015",
"invi_type": "product", // Type of item: "product" | "shipping" | "coupon" | "document"
"invi_name": "Example Itemname",
"invi_text": "Addtional Text for Item", // If you need some additional text to describe the item
"invi_quantity": 2,
"invi_vat_pct": 19,
"invi_vesting_period_from": "2024-01-01", // Start of the delivery/performance-period
"invi_vesting_period_to": "2024-01-31", // End of the delivery/performance-period
"invi_price_single_netto": 123.45 // net value of one item
}
]
}
}
Response
If your request was successful, you receive the hublify ids for the invoice.
In this example, you create an invoice that references a person/customer-record.
Your provided invoice-code was checked against the existing database.
As it was already in use, a new one was created based on the configured counter.
{
"status": true,
"meta": {
"insert_key": "inv_id",
"primary_key": "inv_id",
"insert_id": 2149,
"primary_value": 2149
},
"data": {
"inv_id": 2149,
"inv_code": "R123457"
},
"msg": [
{
"type": "WARNING",
"i18n": {
"string": "inv_code_exists_already_creating_new",
"params": {
"inv_code": "R123456",
"new_inv_code": "R123457"
}
}
}
]
}
If generating a unique invoice code fails, the invoice inject fails and you receive an error.
Check your counter-configuration before trying again.
{
"status": false,
"msg": [
{
"type": "ERROR",
"i18n": {
"string": "inv_code_exists_already",
"params": {
"inv_code": "R123457"
}
}
}
]
}