Saf-t PT Suportado

InvoiceXpress API

credit_notes.update

Updates a credit note.

It also allows you to create a new client and/or items in the same request.
If the client name does not exist a new client is created.

Regarding item taxes, if the tax name is not found, no tax will be applied to that item.
If item does not exist with the given name, a new one will be created.
If item exists it will be updated with the new values

Be careful when updating the document items, any missing items from the original document will be deleted.

You call this method by submitting a HTTP PUT request to the following URL with the document updates on xml format in the request body:

https://screen-name.invoicexpress.net/credit_notes/:credit-note-id.xml

Example xml to be submitted with the updated invoice data:

<?xml version="1.0" encoding="UTF-8"?>
<credit_note>
 <date>19/10/2009</date>
 <due_date>19/10/2009</date>
 <reference>123456</reference>
 <observations>Computer processed</observations>
 <retention>5</retention>
 <client>
  <name>Client</name>
  <code>Code</code>
  <email>client@email.com</email>
 </client>
 <items type="array">
  <item>
   <name>Product 1</name>
   <description>Cleaning product</description>
   <unit_price>10.0</unit_price>
   <quantity>1.0</quantity>
   <unit>unit</unit>
   <discount>10.0</discount>
  </item>
  <item>
   <name>Product 2</name>
   <description>Beauty product</description>
   <unit_price>5.0</unit_price>
   <quantity>1.0</quantity>
   <unit>unit</unit>
   <tax>
    <name>IVA20</name>
   </tax>
   <discount>0.0</discount>
  </item>
 </items>
</credit_note>

Parameters

Parameters are the data you will pass with the call.

api_key

Your secret identifier. You find your API Key under Account Overview in the Account section.
Rules: Required

credit-note-id

ID of the credit note to update.
Rules: Required

date

Credit note date.
Rules: Optional. The date format should be dd/mm/yyyy. Ex: 01/09/2010

due_date

Credit note due date.
Rules: Optional. The date format should be dd/mm/yyyy. Ex: 01/09/2010

reference

Reference, usually a purchase order.
Rules: Optional

observations

Observations, these will be printed with the document.
Rules: Optional

retention

Withholding tax (%)
Rules: Optional

client / name

Client name.
If client doesn’t exist a new one is created.
If its an existing one the remaining client fields are ignored.
Rules: Required

client / code

Client code.
If client doesn’t exist a new one is created.
If its an existing one the remaining client fields are ignored.
Rules: Optional

client / email

Client email.
Rules: Optional. Must be a valid email address ex:foo@bar.com

client / address

Client address, normally used for a company address.
Rules:Optional.

client / postal_code

Client postal code, normally used for a company postal code.
Rules: Optional.

client / fiscal_id

Client fiscal id.
Rules: Optional.

client / website

Client website.
Rules: Optional.

client / phone

Client phone number, normally used for a company phone number.
Rules: Optional.

client / fax

Client fax number, normally used for a company fax number.
Rules: Optional.

items

An array of invoice items.
When updating a document you should send all items, as any missing items from the original document will be deleted.
If no item with the given name exists a new item is created.
If the item name already exists it is updated with the new values.

Rules: At least one item is required.

item / name

Item name.
Rules: Required

item / description

Item description.
Rules: Optional

item / unit_price

Item unit price.
Rules: Required. Needs to be greater than 0.0.

item / quantity

Item quantity.
Rules: Required. Needs to be greater than 0.0.

item / unit

Item unit of measure.
Rules: Required.

item / discount

The item discount.
Rules: Optional. Defaults to 0.0. If present needs to be greater or equal than 0.0.

item / tax

Item tax.
Rules: Optional. If not present no tax is applied to the item

item / tax / name

Item tax name.
Rules: Optional. If not found no tax is applied to the item

Return Values

This is the result that will be passed back to you when you have sent a call.

Success

HTTP: 200 OK

Error

HTTP: 401 Access denied
The API Key parameter is missing or is incorrectly entered.


HTTP: 404 Not Found
The :credit-note-id supplied doesn’t match any existing invoice.


HTTP: 422 Unprocessable Entity
Some of the parameters sent were incorrect.

Possible errors:

<?xml version="1.0" encoding="UTF-8"?>
<errors>
 <error>Retention must be a number between 0 and 99.99</error>
 <error>Invoice items is invalid</error>
 <error>Client is invalid</error>
 <error>email must be an email address</error>
 <error>discount is not a number</error>
 <error>quantity must be a number greater than 0</error>
 <error>unit_price must be a number</error>
 <error>Unit kg is not included in the list of accepted units</error>
 <error>Unit is not included in the list of accepted units</error>
</errors>

<?xml version="1.0" encoding="UTF-8"?>
<errors>
 <error>Document can't be edited.</error>
</errors>