Create, update and delete VAT accounts through the REST APIs

Create, update and delete VAT accounts through the REST APIs

Today we’re happy to introduce new functionalities for the /vat-accounts endpoint. It is now possible to create, update and delete VAT accounts using the REST APIs. VAT accounts is the REST nickname for VAT codes. The same functionalities can be achieved in the application by going to Settings > All Settings > Finance > VAT Codes.

Create

We will now try to create a new VAT code with a 99% rate. It’s as simple as making a POST request to the collection.

POST /vat-accounts

{
    "account": {
        "accountNumber": 1314011
    },
    "name": "99% VAT",
    "ratePercentage": 99,
    "vatReportSetup": {
        "vatReportSetupNumber": 12101
    },
    "vatType": {
        "vatTypeNumber": 1
    },
    "vatCode": "V99"
}

A few words about the object:

  • vatReportSetup is the same as the “Rate type” in the UI
  • vatCode, vatType, vatReportSetup, account and ratePercentage are all required fields
  • Different vatReportSetups might be available under different vatTypes

Update

We will now update the object, changing the vatType and the vatReportSetupNumber.

PUT /vat-accounts/:vatCode

{
    "account": {
        "accountNumber": 1314011
    },
    "name": "99% VAT",
    "ratePercentage": 99,
    "vatReportSetup": {
        "vatReportSetupNumber": 12201
    },
    "vatType": {
        "vatTypeNumber": 2
    },
    "vatCode": "V99"
}

Note that the vatCode specified in the URL will overwrite the one in the object. If there isn’t any VAT account with said vatCode, then a new one will be created.

Delete

We can also delete any existing VAT account by making a DELETE request to the resource. One important thing to keep in mind is that the VAT account must not be referenced by any other entity (customers, vouchers, etc.). This also applies when setting barred to true on a PUT request.

DELETE /vat-accounts/:vatCode

Feel free to contact us at api@reviso.com.

Leave a reply