tax-areas

tax-areas.find

Returns the tax areas that meet the given conditions.

JS
CR.api('commerce.tax-areas.find', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.tax-areas.find

request

{
  "conditions" : { // returns the tax areas …
    "isActive" : true, // … that are active or not - bool
    "isDefault" : false, // … that are the default tax area or not - bool
    "country" : "GB"    // … that have this country - string(2)
  },
  "fields" : [ "id", "name", … ], // fields to return - string
  "order" : [ "name" ], // sort order of returned tax areas, can contain "id", "-id", "name", "-name", "isActive", "-isActive",
                        // "taxCompanies", "-taxCompanies", "countries" and "-countries" - string
  "limit" : 10, // maximum number of tax areas to return - int(1…100)
  "first" : 0 // index of the first tax area to return - int(0…)
}

response


{
  "status" : "ok",
  "taxAreas" : [ {
    "id" : 5, // identifier - int(1…)
    "name" : "Europe", // name - string(0…60)
    "isDefault" : true, // indicates if it is the default tax area - bool
    "isActive" : true, // indicates if it is active - bool
    "taxCompanies" : true, // indicates if taxes are also applied to companies - bool
    "countries" : [ "FR", "GB", … ], // countries witch it is applied - string(2)
    "rates" : { // tax rate for each tax class - int(1…) -> decimal[4,2](0…100)
      "1" : 19.50,
      "3" : 0.00,
      "4" : 12.00
    }
  }, … ]
}

tax-areas.get

Returns a tax area given its identifier.

JS
CR.api('commerce.tax-areas.get', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.tax-areas.get

request

{
  "id" : 5, // identifier (required) - int(1…)
  "fields" : [ "id", "name", … ]  // fields to return - string
}

response

{
  "status" : "ok",
  "taxArea" : { // (can be null)
    "id" : 5, // identifier - int(1…)
    "name" : "Europe", // name - string(0…60)
    "isDefault" : true, // indicates if it is the default tax area - bool
    "isActive" : true, // indicates if it is active - bool
    "taxCompanies" : true, // indicates if taxes are also applied to companies - bool
    "countries" : [ "FR", "GB", … ], // countries witch it is applied - string(2)
    "rates" : { // tax rate for each tax class - int(1…) -> decimal[4,2](0…100)
      "1" : 19.50,
      "3" : 0.00,
      "4" : 12.00
    }
  }
}

tax-areas.count

Number of tax areas that meet the given conditions.

JS
CR.api('commerce.tax-areas.count', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.tax-areas.count

request

{
  "conditions" : { // counts the tax areas …
    "isActive" : true, // … that are active or not - bool
    "isDefault" : false, // … that are the default tax area or not - bool
    "country" : "GB" // … that have this country - string(2)
  }
}

response

{
  "status" : "ok",
  "count" : 6 // number of tax areas - int(0…)
}

tax-areas.create

Creates a new tax area.

JS
CR.api('commerce.tax-areas.create', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.tax-areas.create

request

{
  "taxArea" : { // tax area to create (required)
    "name" : "Europe", // name - string(0…60)
    "isDefault" : true, // indicates if it is the default tax area - bool
    "isActive" : true, // indicates if it is active - bool
    "taxCompanies" : true, // indicates if taxes are also applied to companies - bool
    "countries" : [ "FR", "GB", … ], // countries witch it is applied - string(2)
    "rates" : { // tax rate for each tax class - int(1…) -> decimal[4,2](0…100)
      "1" : 19.50,
      "3" : 0.00,
      "4" : 12.00
    }
  }
}

response

{
  "status" : "ok",
  "id" : 5 // identifier of the new tax area - int(1…)
}

Errors

Field Type Description
countries Malformed Country '<country>' is not a valid country code
countries InvalidValue Country code '<country>' does not exist
countries Repeted Repeated country code '<country>'
isActive Invalid Default tax area must be active
rates NotFound Tax class <taxClass> does not exist

tax-areas.update

Updates a tax area. Any fields left out of the request will remain unchanged.

JS
CR.api('commerce.tax-areas.update', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.tax-areas.update

request

{
  "id" : 5, // identifier of the tax area to update (required) - int(1…)
  "taxArea" : { // tax area's fields to update (required)
    "name" : "Europe", // name - string(0…60)
    "isDefault" : true, // indicates if it is the default tax area - bool
    "isActive" : true, // indicates if it is active - bool
    "taxCompanies" : true, // indicates if taxes are also applied to companies - bool
    "countries" : [ "FR", "GB", … ], // countries witch it is applied - string(2)
    "rates" : { // tax rate for each tax class - int(1…) -> decimal[4,2](0…100)
      "1" : 19.50,
      "3" : 0.00,
      "4" : 12.00
    }
  }
}

response

{
  "status" : "ok"
}

Errors

Field Type Description
countries Malformed Country '<country>' is not a valid country code
countries InvalidValue Country code '<country>' does not exist
countries Repeted Repeated country code '<country>'
id NotFound Tax area <id> does not exist
isActive InvalidValue Default tax area must be active
isDefault InvalidValue 'isDefault' can not be set to false for the default tax area
isDefault InvalidValue 'isDefault' can not be set to true for a not active tax area
rates NotFound Tax class <taxClass> does not exist

tax-areas.delete

Deletes one or more tax areas.

JS
CR.api('commerce.tax-areas.delete', request, function(response) { … });
HTTP
POST /open2b/api/v3/commerce.tax-areas.delete

request

{
  "ids" : [ 5, 1, 6, … ] // identifiers of the tax areas to delete (required) - int(1…)
}

response

{
  "status" : "ok"
}

Errors

Field Type Description
ids CannotDelete Default tax area <id> can not be deleted