Invoice Line Items

This endpoint allows you to create, update and delete line items that belong to customer invoices or supplier invoices.

Line items only exist in the context of a specific invoice. So whenever you want to list or interact the line items for an invoice, you have to keep the type of invoice in mind and construct the endpoint's path from there. When referring to an endpoint's path below, whenever there's a {invoice_path}/line_items, you have to adapt the path to the type of invoice you're dealing with. For example the path to listing line items for a customer invoice is /api/v1/customer_invoices/{customer_invoice_id}/line_items while the respective path for a supplier invoice is /api/v1/supplier_invoices/{supplier_invoice_id}/line_items.

Attributes of a Line Item

accounting category Object The name and number of the accounting category that has been assigned to this line item
description string The line item description
discount decimal Discount rate that applies to this line item's price. This means this field is to be interpreted as a percentage, but formatted as a decimal number.
discounted_net_total Money The discounted net price of this line item, which is calculated by reducing the line item's net_total by the discount.
gross_total Money The gross total amount of the line item
net Money The net price of one unit of this line item
net_total Money The net total amount of all units of this line item
order_number string The order number of this line item, a free-form text.
qty integer The line item quantity
tax Tax The line item tax amount
unit string The line item unit

Attributes you send to Keyline to Create or Update a Line Item

description string The line item description
qty integer The line item quantity
unit string The line item unit, a free-form string. Keyline internally works with the following units, so if you use them, they will be recognized by the Web UI of Keyline.
pdf piece, plate, sheet, folded_sheet, meter, sqmeter, sqmillimeter, millimeter, liter, milliliter, gram, kilogram, ream
net decimal The line item net price in cents
tax_rate decimal The line item tax rate, the value has to be one of the following: 0.0, 0.07 or 0.19

Actions

Listing an Invoice's Line Items

GET
{invoice_path}/line_items

Example Request

$ curl -i -H "Authorization: Bearer a2d16d24dd8adf0e843e6b143b54dbf800ce7ef12d431927ef63f" \
  https://api.keyline-mis.com/api/v1/customer_invoices/3609/line_items

$ curl -i -H "Authorization: Bearer a2d16d24dd8adf0e843e6b143b54dbf800ce7ef12d431927ef63f" \
  https://api.keyline-mis.com/api/v1/supplier_invoices/3607/line_items

Fetching a single Invoice's Line Item

GET
{invoice_path}/line_items/{line_item_id}

Example Request

$ curl -i -H "Authorization: Bearer a2d16d24dd8adf0e843e6b143b54dbf800ce7ef12d431927ef63f" \
  https://api.keyline-mis.com/api/v1/customer_invoices/3609/line_items/4923

Creating an Invoice Line Item

Line Items can be created for invoices as long as the invoice is not billed or checked yet.

POST
{invoice_path}/line_items

Example request

$ curl -X POST -H "Authorization: Bearer 4b00c2cbffba2d16d24dd8adf0e843e6b143b54dbf800ce7ef12d431927ef63f"\
-H "Content-Type: application/json"\
-d '{"line_item": {
       "description": "printing ink",
       "qty": 3,
       "unit": "drum",
       "net": 2.5,
       "tax_rate": 0.19}
       }'
"https://api.keyline-mis.com/api/v1/customer_invoices/123/line_items"

Updating an invoice line item

Line Items can be updated as long as the invoice is not billed or checked yet.

PATCH
{invoice_path}/line_items/{line_item_id}

Example request

$ curl -X PATCH -H "Authorization: Bearer 4b00c2cbffba2d16d24dd8adf0e843e6b143b54dbf800ce7ef12d431927ef63f"\
-H "Content-Type: application/json"\
-d '{"line_item": { "qty": 10 }'
https://api.keyline-mis.com/api/v1/customer_invoices/3609/line_items/4923

Deleting an invoice line item

Line Items can be deleted as long as the invoice is not billed or checked yet.

DELETE
{invoice_path}/line_items/{line_item_id}

Example request

$ curl -X DELETE -H "Authorization: Bearer 4b00c2cbffba2d16d24dd8adf0e843e6b143b54dbf800ce7ef12d431927ef63f"\
-H "Content-Type: application/json"\
https://api.keyline-mis.com/api/v1/customer_invoices/3609/line_items/4923