Sales Invoices (Deprecated)

Sales Invoices represent sales in the system.

WARNING: This endpoint is deprecated in favor of the more powerful and convenient 2.5 version of Invoices.

Fields

Getting Sales Invoices

GET (/api/v2/finance/sales_invoices/(int: id)

Using curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/sales_invoices/(int:id) \
    -v -u (login):(password)

Example response:

{
    total_tax: 20,
    account_id: 48806,
    total_net: 100,
    number: "7641",
    comments: "Test Invoice",
    company_id: 32,
    other_ref: "ref102",
    entries: [
        {
            description: "Test Item",
            quantity: 1,
            credit_account_id: 323,
            company_id: 32,
            currency: {
                html_code: "£",
                symbol: "£",
                code: "GBP",
                name: "Pounds Sterling",
                is_base: true
            },
            amount: 100,
            is_tax: false,
            debit_account_id: 6,
            group_id: 12553,
            item_id: 1,
            id: 80804,
            tax_id: 7
        },
        {
            description: "Test Item",
            quantity: 1,
            credit_account_id: 7,
            company_id: 32,
            currency: {
                html_code: "£",
                symbol: "£",
                code: "GBP",
                name: "Pounds Sterling",
                is_base: true
            },
            amount: 20,
            is_tax: true,
            debit_account_id: 6,
            group_id: 12553,
            item_id: 1,
            id: 80805,
            tax_id: 7
        }
    ],
    date: "2015-04-29T00:00:00",
    total: 120,
    customer_reference: "abc123",
    id: 12553
}
  • statuscode 200

    no error

  • statuscode 404

    does not exist

Creating Sales Invoices

Required fields

A sales invoice must contain the followin

  1. account_id
  2. company_id
  3. region_id
  4. currency_code
  5. date

Optional fields

Entries on a sales invoice may contain the following:

  1. tax_id
  2. event_id
  3. description
  4. service_date
  5. item_id
  6. custom_discount_id

Note: Whilst custom discounts are applied to the invoice as a whole, you can specify “is_discountable”: 0 against any individual entry to prevent the discount from applying from that line.

POST (/api/v2/finance/sales_invoices()

Using curl:

curl https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/sales_invoices \
    -v -u (login):(password) \
    -X POST \
    -H "Content-type: application/json" \
    -d '{"other_ref": "ref102", \
        "account_id": 48806, \
        "entries": [ \
           {"description": "Test Item", \
            "item_credit_account_id": 323, \
            "amount": 100, \
            "item_id": 1, \
            "tax_id": 7, \
            "service_date": "2015-04-29", \
            "quantity": 1 \
           } \
        ], \
        "date": "2015-04-29 00:00:00", \
        "comments": "Test Invoice", \
        "customer_reference": "abc123", \
        "company_id": 32, \
        "currency_code": "GBP", \
        "region_id": "UK" \
        "custom_discount_id": 1 \
       }'

Using php

<?php
$credentials = 'username:password';
$url = 'https://YOUR-SUBDOMAIN.administrateapp.com/api/v2/finance/sales_invoices';
$encoded = array();

$item = new stdObject();
$item->description = "Test Item";
$item->item_credit_account_id = 323;
$item->amount = 100;
$item->item_id = 1;
$item->tax_id = 7;
$item->service_date = "2015-04-29";
$item->quantity = 1;
$item->custom_discount_id = 1;

$post = array(
    "other_ref" => "ref102",
    "account_id" => 48806,
    "entries" => array(
        $item
    ),
    "date" => "2015-04-29 00:00:00",
    "comments" => "Test Invoice",
    "customer_reference" => "abc123",
    "company_id" => 32,
    "currency_code" => "GBP",
    "region_id" => "UK"
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, $credentials);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);
curl_close($ch);
echo $result;

Example response:

{
    total_tax: 20,
    account_id: 48806,
    total_net: 100,
    number: "7641",
    comments: "Test Invoice",
    company_id: 32,
    other_ref: "ref102",
    entries: [
        {
            description: "Test Item",
            quantity: 1,
            credit_account_id: 323,
            company_id: 32,
            currency: {
                html_code: "&pound;",
                symbol: "£",
                code: "GBP",
                name: "Pounds Sterling",
                is_base: true
            },
            amount: 100,
            is_tax: false,
            debit_account_id: 6,
            group_id: 12553,
            item_id: 1,
            id: 80804,
            tax_id: 7
        },
        {
            description: "Test Item",
            quantity: 1,
            credit_account_id: 7,
            company_id: 32,
            currency: {
                html_code: "&pound;",
                symbol: "£",
                code: "GBP",
                name: "Pounds Sterling",
                is_base: true
            },
            amount: 20,
            is_tax: true,
            debit_account_id: 6,
            group_id: 12553,
            item_id: 1,
            id: 80805,
            tax_id: 7
        }
    ],
    date: "2015-04-29T00:00:00",
    total: 120,
    customer_reference: "abc123",
    id: 12553
}
  • statuscode 200

    no error

  • statuscode 404

    could not create