function invoice.create

Raises an invoice or credit note. VAT is calculated automatically. The customer's account balance will be decreased (for invoices) or increased (for credit notes).

Invoices will automatically be emailed to the customer (email address derived from the supplied args).

Arguments:

argrequired?syntaxinfo
custIDYposintcustID of account being invoiced
itemsYarrayarray of invoice/creditnote items
invoicerIDNposintcustID of account raising the invoice (default is your own account)
invoicer_companyIDgrp1posintbilling company ID of billing company raising the invoice
invoicer_companygrp1stringname of billing company; alternative to using invoicer_companyID
inv_or_creditNenum:invoice|creditnoteSet to 'invoice' to raise an invoice, 'creditnote' to raise a credit note. Default = 'invoice'
expected_paymentNenum:card|manual|automated|direct debit|standing order|bacs|cheque|cash|postal orderType of payment expected (leave blank if you are unsure)
payment_dueNisodateif specified, overrides the default due date
enforce_dateNisodatedefaults to the current raise date
notify_when_paidNbooleanshould evaluate to true if needed; staff will be notified when an invoice has been paid.
ignore_credit_limitNbooleanif evaluates to true, allows the invoice generation to exceed the account credit limit. default: 1 (true)
addressNarrayaddress of invoicee (ie the address of customer custID)
attrNarrayextended attributes for the invoice
dry_runNbooleanIf specified and true, will not actually raise the invoice but will fully parse the arguments, and return the VAT calculation

Further argument information

items

A sub-array of invoice items. Each item is itself defined within an array consisting of the following elements:

invoicer_companyID

Within a parent account (identified by invoicerID) there may be several billing companies, eg one for ISP services, one for telecoms services, etc (see [billing_companies] element of login object on the invoicer account to see which companies exist, and see [custof] element of client login object to see which billing companies can raise invoices for this client).

You must supply this argument, or the invoicer_company argument. You cannot supply both.

expected_payment

When raising an invoice, you can define the expected payment type. This can effect certain automated processes such as a direct debit run, etc. Specify one of the following values:

enforce_date

This is the date at which the cart will use the invoice to enforce credit control.

address

Sub-array consting of the following elements. They are mostly optional but you should specify what is relevant:

If you don't supply the invoicee address, the default account address of the customer being invoice will be used.

attr

This will be a key/value pair of attributes. In most cases you won't need these.

The attributes available for use may vary, depending on which other arguments are supplied. Contact us for a list of attributes and their use.

Example

Perl example request:

POST https://live.apicontrol.co.uk/1/json
my $api = new CCclient($u, $p, $live); # this must be logging in to the parent account of the one being invoiced
my $items =
  [
    {
      'price' =>'3.23',
      'text' => 'Some bits',
    },
    {
      'price'=>'9.95',
      'domain'=>'mystuff.com',
      'datefrom'=>'2009-01-01',
      'dateto'=>'2009-12-31'
    },
  ];

my %invargs =
  (
    'invoicerID' => $api->custID,
    'custID' => 16526,
    'invoicer_company' => 'skycom',
    'ignore_credit_limit' => 1,
    'items' => $items,
    'address' =>
      {
        'contactname' => 'Mr Test',
        'companyname' => 'Tinkly Ltd',
        'addr1' => '81 Fothering Street',
        'addr2' => 'Tinkleton',
        'postcode' => 'N1 8QT',
        'email'=>'mrtest@mailme.tickles.org',
      },
  );


my $res = $api->invoice_create(%invargs);

XML example request:

POST https://live.apicontrol.co.uk/1/json

The response includes the following information:

Perl example response:

{
  'success' => '1',
  'vat' => '1.97',
  'payment_due' => '2009-07-20',
  'subtotal' => '13.18',
  'total' => '15.15',
  'errordiags' => '',
  'textID' => '201046',
  'invnum' => '127762',
  'error' => undef,
  'invoiceID' => '108239',
  'errornum' => '',
  'seq' => '34',
  'oldbalancepence' => '-2006',
  'results' => []
};

XML example response: