Invoices
GET <qbench-url>/qbench/api/v1/invoice/{invoiceId}
Will retrieve an invoice by its ID. Retrieving a single invoice will display a list of any line items for the invoice. Each invoice item will be one of the following item types:
- INVOICE_ITEM
- A standard invoice line item
- FLAT_SURCHARGE
- A surcharge of a flat dollar amount.
- FLAT_DISCOUNT
- A discount of a flat dollar amount.
- PERCENT_SURCHARGE
- A surcharge that is a percentage of a previous subtotal.
- PERCENT_DISCOUNT
- A discount that is a percentage of a previous subtotal.
- SUBTOTAL
- A subtotal of any previous line items.
The intended order of the line items is indicated by the sort_order field of each item.
Example request:
GET /qbench/api/v1/invoice/10 HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url>
Example response:
{
"custom_formatted_id": "JCOR-20180516-155-10",
"date_created": "05/16/2018",
"date_emailed": null,
"due_date": null,
"email_to": null,
"emailed": false,
"emailed_by_id": null,
"external_id": "AE-1526496377",
"id": 10,
"invoice_date": "05/16/2018",
"invoice_items": [
{
"amount": 200,
"assay_id": 10,
"base_price": 100,
"discount": 0,
"id": 40,
"invoice_id": 10,
"invoice_item_type": "INVOICE_ITEM",
"name": "Aluminum",
"quantity": 2,
"sort_order": 0
},
{
"amount": 250,
"assay_id": 12,
"base_price": 125,
"discount": 0,
"id": 41,
"invoice_id": 10,
"invoice_item_type": "INVOICE_ITEM",
"name": "Ammonia",
"quantity": 2,
"sort_order": 1
},
{
"amount": 450,
"assay_id": null,
"base_price": 450,
"discount": null,
"id": 42,
"invoice_id": 10,
"invoice_item_type": "SUBTOTAL",
"name": "Subtotal",
"quantity": null,
"sort_order": 2
}
],
"notes": null,
"order_id": 155,
"paid": false,
"status": "DRAFT",
"total": 450
}
GET <qbench-url>/qbench/api/v1/invoice/{invoiceId}/pdf
Will retrieve a link to download a PDF of an invoice.
Example request:
GET /qbench/api/v1/invoice/10/pdf HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url>
Example response:
{
"url": "https://qbench-dev.s3.amazonaws.com/example/invoices/10.pdf?AWSAccessKey
Id=AKIAIWFV4IZLVC7FRBVA&Expires=1527788403&Signature=IY%2FEYYsQA8bfxCOg0e
Qmg02HeAg%3D"
}
GET <qbench-url>/qbench/api/v1/invoice?page_num={pageNum}&page_size={pageSize}
Will retrieve a paginated list of invoices. Maximum page size is 50.
Example request:
GET /qbench/api/v1/invoice?page_num=1&page_size=50 HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url>
Example response:
{
"total_count": 6,
"total_pages": 1,
"data": [
{
"custom_formatted_id": "JCOR-20180517-156-11",
"date_created": "05/23/2018",
"date_emailed": null,
"due_date": null,
"email_to": null,
"emailed": false,
"emailed_by_id": null,
"external_id": null,
"id": 11,
"invoice_date": "05/23/2018",
"notes": "Testing.",
"order_id": 156,
"paid": false,
"status": "DRAFT",
"total": 67.5
},
{
"custom_formatted_id": "JCOR-20180516-155-10",
"date_created": "05/16/2018",
"date_emailed": null,
"due_date": null,
"email_to": null,
"emailed": false,
"emailed_by_id": null,
"external_id": "AE-1526496377",
"id": 10,
"invoice_date": "05/16/2018",
"notes": "Testing notes",
"order_id": 155,
"paid": false,
"status": "DRAFT",
"total": 450
},
...
]
}
POST <qbench-url>/qbench/api/v1/invoice
Will create a new invoice. Order ID is required. When creating an invoice, you can also include a list of invoice items. Each invoice item must have an invoice_item_type (INVOICE_ITEM, SUBTOTAL, FLAT_SURCHARGE, FLAT_DISCOUNT, PERCENT_SURCHARGE, PERCENT_DISCOUNT). If the item is of type INVOICE_ITEM, it must include a name and base_price. You can optionally update any assay at this time by including additional assay fields in the JSON body.
Example request:
POST /qbench/api/v1/invoice HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url>
Content-Type: application/json
{
"invoice_date": "05/16/2018",
"invoice_items": [
{
"amount": 200,
"assay_id": 10,
"base_price": 100,
"discount": 0,
"invoice_item_type": "INVOICE_ITEM",
"name": "Aluminum",
"quantity": 2,
"sort_order": 0
},
{
"amount": 250,
"assay_id": 12,
"base_price": 125,
"discount": 0,
"invoice_item_type": "INVOICE_ITEM",
"name": "Ammonia",
"quantity": 2,
"sort_order": 1
},
{
"amount": 450,
"assay_id": null,
"base_price": 450,
"discount": null,
"invoice_item_type": "SUBTOTAL",
"name": "Subtotal",
"quantity": null,
"sort_order": 2
}
],
"notes": "Notes",
"order_id": 154,
"status": "DRAFT",
"total": 450
}
Example response:
{"id":10}
POST <qbench-url>/qbench/api/v1/invoice/{invoiceId}
Will update an existing invoice. When updating an invoice, if a list of invoice items is included it will overwrite the previous list of invoice items. You can optionally include an ID with each invoice item if you would like to update it.
Example request:
PUT /qbench/api/v1/invoice/10 HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url>
Content-Type: application/json
{
"invoice_date": "05/16/2018",
"invoice_items": [
{
"amount": 200,
"assay_id": 10,
"base_price": 100,
"discount": 0,
"id": 40,
"invoice_item_type": "INVOICE_ITEM",
"name": "Aluminum",
"quantity": 2,
"sort_order": 0
},
{
"amount": 250,
"assay_id": 12,
"base_price": 125,
"discount": 0,
"id": 41,
"invoice_item_type": "INVOICE_ITEM",
"name": "Ammonia",
"quantity": 2,
"sort_order": 1
},
{
"amount": 450,
"assay_id": null,
"base_price": 450,
"discount": null,
"id": 42,
"invoice_item_type": "SUBTOTAL",
"name": "Subtotal",
"quantity": null,
"sort_order": 2
}
],
"paid": true,
"status": "COMPLETED",
"total": 450
}
Example response:
{"message":"OK"}
DELETE <qbench-url>/qbench/api/v1/invoice/{invoiceId}
Will delete an invoice.
Example request:
DELETE /qbench/api/v1/invoice/10 HTTP/1.1
Authorization: Bearer 63ff42c5-49e6-42e2-bc3f-04fbfc22bbcb
Host: <qbench-url>
Example response:
{"message":"OK"}
Comments
0 comments
Please sign in to leave a comment.