# Tax calculation

## Calculating net and gross values for prices

> Supports the following calculation operations for prices:\
> \* Net to gross values\
> \* Gross to net values\
> \* Gross values in one country to gross values in another country\
> \
> \*\*Note\*\*: This endpoint calculates net and gross values for prices based on existing tax configurations. To use this endpoint, you need to create tax configurations first.\
> &#x20; \* To calculate gross values beetween countries, you need to create tax configurations for both countries.

```json
{"openapi":"3.0.0","info":{"title":"Tax Service","version":"0.0.1"},"tags":[{"name":"Tax calculation"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"tax.tax_manage":"Needed to create, update, and delete tax configurations.","tax.tax_read":"Needed to retrieve tax configurations."}}}}},"schemas":{"taxCalculationResponse":{"title":"","type":"object","description":"","properties":{"commandUuid":{"type":"string","description":"Calculation command's unique identifier."},"input":{"type":"object","description":"Information based on which the price was calculated.","properties":{"sourceLocation":{"description":"Country for which the provided price was originally defined.","allOf":[{"$ref":"#/components/schemas/location"}]},"sourceTaxClass":{"type":"string","description":"Tax class originally applied to the provided price."},"targetLocation":{"description":"Country for which the price was calculated.","allOf":[{"$ref":"#/components/schemas/location"}]},"targetTaxClass":{"type":"string","description":"Tax class that was applied when calculating the price."},"includesTax":{"type":"boolean","description":"Flag indicating whether the price provided in the request was expressed as net or gross.\n\n| Value | Description |\n| --- | --- |\n| `true` | Prices will be expressed as gross values. |\n| `false` | Prices will be expressed as net values. |"},"price":{"type":"number","description":"Original price value."}}},"output":{"type":"object","description":"Calculation results.","properties":{"netPrice":{"type":"number","description":"Calculated net price."},"grossPrice":{"type":"number","description":"Calculated gross price."},"sourceTaxRate":{"type":"number","description":"Tax rate originally applied to the provided price."},"targetTaxRate":{"type":"number","description":"Tax rate that was applied when calculating the price."}}}}},"location":{"type":"object","description":"","properties":{"countryCode":{"type":"string","description":"Code of the country for which the tax classes are specified, as defined in the Country Service."}},"required":["countryCode"]},"errorMessage":{"title":"error","description":"Schema for API specified errors.","type":"object","properties":{"taxConfigurationCode":{"type":"string","description":"link to documentation to investigate further and finding support"},"code":{"description":"classification of the error type, lower case with underscore eg validation_failure","type":"integer"},"status":{"description":"original HTTP error code, should be consistent with the response HTTP code","type":"string"},"message":{"description":"descriptive error message for debugging","type":"string"},"details":{"description":"list of problems causing this error","type":"array","items":{"title":"errorDetail","description":"schema for specific error cause","type":"string"}}},"required":["code","status"]},"taxCalculationRequest":{"title":"","type":"object","description":"","properties":{"commandUuid":{"type":"string","description":"Calculation command's unique identifier.\n\n**Note**: This field is optional. If not specified, the `commandUuid` will be generated by the server."},"input":{"type":"object","description":"Information based on which the price will be calculated.","required":["targetTaxClass","targetLocation","price"],"properties":{"sourceLocation":{"description":"Country for which the provided price is originally defined.\n\n**Note**: This field is only mandatory if the `includesTax` field is set to `true`.","allOf":[{"$ref":"#/components/schemas/location"}]},"sourceTaxClass":{"type":"string","description":"Tax class originally applied to the provided price.\n\n**Note**: This field is only mandatory if the `includesTax` field is set to `true`."},"targetLocation":{"description":"Country for which the price should be calculated.","allOf":[{"$ref":"#/components/schemas/location"}]},"targetTaxClass":{"type":"string","description":"Tax class that should be applied when calculating the price."},"includesTax":{"type":"boolean","description":"Flag indicating whether the value provided in the `price` field is expressed as net or gross.\n\n| Value | Description |\n| --- | --- |\n| `true` | Prices are expressed as gross values. |\n| `false` | Prices are expressed as net values. |"},"price":{"type":"number","description":"Original price value.\n\nThis field should contain by a number where the cent part is separated by a dot sign - such as `12.99`.\n\n**Note**: The cent part of the price is not limited to two digits. You can specify the price with any precision."}}}},"required":["input"]}},"responses":{"BadRequest_400":{"description":"Request was syntactically incorrect. Details will be provided in the response payload.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorMessage"}}}},"Unauthorized_401":{"description":"Given request is unauthorized - the authorization token is invalid or has expired. Details will be provided in the response payload.","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Forbidden_403":{"description":"Given authorization scopes are not sufficient and do not match scopes required by the endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorMessage"}}}},"InternalServiceError_500":{"description":"Internal Service Error occurred.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/errorMessage"}}}}}},"paths":{"/tax/{tenant}/taxes/calculation-commands":{"put":{"summary":"Calculating net and gross values for prices","operationId":"PUT-tax-calculate-commands","responses":{"200":{"description":"The request was successful. The calculated value is returned.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/taxCalculationResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest_400"},"401":{"$ref":"#/components/responses/Unauthorized_401"},"403":{"$ref":"#/components/responses/Forbidden_403"},"500":{"$ref":"#/components/responses/InternalServiceError_500"}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/taxCalculationRequest"}}}},"description":"Supports the following calculation operations for prices:\n* Net to gross values\n* Gross to net values\n* Gross values in one country to gross values in another country\n\n**Note**: This endpoint calculates net and gross values for prices based on existing tax configurations. To use this endpoint, you need to create tax configurations first.\n  * To calculate gross values beetween countries, you need to create tax configurations for both countries.","tags":["Tax calculation"]}}}}
```
