Browse Documentation
POST Create invoice

Create a new Invoice

POST /invoices

Create a new invoice.

Parameters

  Parameter
  Type
 Description
 client_id | required
  String
date _issued
  Date YYYY-MM-DD
 The date the invoice was issued. Is not supplied it will default to the current date.
 date_due
  Date YYYY-MM-DD
 The expiration date of the invoice. If not supplied the number of days due of the default invoice template will be applied.
 template_id
  String
 reference
  String
 Any name that you wish to use as a reference
 status
  String
 Status of the invoice. This can either be "draft" or "approved". If no status is defined it defaults to draft. The moment an invoice is set to approved the journal entries are generated and no changes can be made anymore to the invoice object.
 Items | required
  Array[object]
 Items to be added to the invoice
 items[title] | required
  String
 Item title
 items[description] 
  String
 Description of the item
 items[quantity] | required
  Numeric Item Quantity
 items[price] | required
  Numeric Item Price
 items[tax_id] | required
  String
 Item Tax ID 
 items[tax_included
  Bool
 Enter 1 if you want the tax to be included and 0 if the tax  to be excluded
 items[gl_account_id] | required
  String
 GL Account

A POST request is expected to be sent to the above endpoint where the content body must be JSON string containing all parameters that are needed to create a new invoice. The below example demonstrates how to create a new Invoice.

Request

    
curl -s -H "Content-Type: application/json" -H "Authorization: Bearer token" \
-XPOST \
-d '{
    "invoice": {
        "client_id": "1615c6926a25a72b31ee320d0889e82f6395511c",
        "date_issued": "2017-04-24",
        "items": [
        {
            "title": "item 01",
            "quantity": 1,
            "price": 100,
            "tax_id": "fd62ee6c1d65e4729da41f85cdd328dfc816d161",
            "gl_account_id": "c94409c9c4ac843cc16a265b6c2423237b5a8f76"
        },
        {
            "title": "item 02",
            "quantity": 1,
            "price": 100,
            "tax_id": "fd62ee6c1d65e4729da41f85cdd328dfc816d161",
            "tax_included": true,
            "gl_account_id": "c94409c9c4ac843cc16a265b6c2423237b5a8f76"
        }
        ]
    }
}' \
https://dev.accounteer.com/api/v0.1/invoices/
    

Response

{
    "id": "ba775d2a3f9612ab288489f20ceab582f7f62fd5",
    "organization_id": "daa71f0644647c0d82dd2d03d0b29779644b1a48",
    "document_number": "-",
    "client_id": "1615c6926a25a72b31ee320d0889e82f6395511c",
    "template_id": "6510e39e71217f262c39b3525831f2a5405fc5e8",
    "total_amount": 221,
    "total_base_amount": 182.64,
    "total_tax_amount": 38.36,
    "currency": "EUR",
    "date_issued": "2017-04-24",
    "date_due": "2017-08-23",
    "date_created": "2017-07-24",
    "date_updated": "2017-07-24",
    "status": "draft",
    "reference": null,
    "items": [{
        "id": "2417f43fb9ec75daa3abad35f0ab9a42eebc1910",
        "title": "item 01",
        "description": null,
        "quantity": 1,
        "item_base_amount": 100,
        "tax_id": "fd62ee6c1d65e4729da41f85cdd328dfc816d161",
        "tax_name": "VAT 21%",
        "tax_percentage": 21,
        "line_base_amount": 100,
        "line_tax_amount": 21,
        "line_total_amount": 121,
        "tax_included": false,
        "price": 100,
        "gl_account": {
            "id": "aefb526889e1059a61ecce700a3363c388a93335",
            "code": "7000000",
            "title": "Sales",
            "description": null
        }
    }, {
        "id": "b92f3b4c8013d092acf7d8b56a8eef19bbea6613",
        "title": "item 02",
        "description": null,
        "quantity": 1,
        "item_base_amount": 82.644628099174,
        "tax_id": "fd62ee6c1d65e4729da41f85cdd328dfc816d161",
        "tax_name": "VAT 21%",
        "tax_percentage": 21,
        "line_base_amount": 82.64,
        "line_tax_amount": 17.36,
        "line_total_amount": 100,
        "tax_included": true,
        "price": 82.64,
        "gl_account": {
            "id": "aefb526889e1059a61ecce700a3363c388a93335",
            "code": "7000000",
            "title": "Sales",
            "description": null
        }
   }]
}

In this example request, the effect of the include_tax indicator is visible. 

For item 01 we didn't set the indicator which causes it to default to false. When the indicator is false it means the price supplied is the item price excluding sales tax. Sales tax will be added to the price. The item_base_amount will be equal to the price, being 100. 21 sales tax is added causing the total of one item to be 121.

For item 02 we set the include_tax indicator to true. This means the price already includes sales tax. Here the base amount is equal to 100 / 1.21 = 82.64. Sales tax on the base amount is 82.64 * 21% = 17.36 resulting in a total price for one item of 100.