Calculate sale totals
curl --request POST \
--url https://app.flextell.ai/api/v1/sales/calculate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"items": [
{
"quantity": 1.0001,
"unit_price": 1,
"discount_amount": 1,
"discount_percentage": 50,
"total_price": 1
}
],
"installment_count": 61,
"first_due_date": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://app.flextell.ai/api/v1/sales/calculate"
payload = {
"items": [
{
"quantity": 1.0001,
"unit_price": 1,
"discount_amount": 1,
"discount_percentage": 50,
"total_price": 1
}
],
"installment_count": 61,
"first_due_date": "2023-11-07T05:31:56Z"
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
items: [
{
quantity: 1.0001,
unit_price: 1,
discount_amount: 1,
discount_percentage: 50,
total_price: 1
}
],
installment_count: 61,
first_due_date: '2023-11-07T05:31:56Z'
})
};
fetch('https://app.flextell.ai/api/v1/sales/calculate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.flextell.ai/api/v1/sales/calculate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'quantity' => 1.0001,
'unit_price' => 1,
'discount_amount' => 1,
'discount_percentage' => 50,
'total_price' => 1
]
],
'installment_count' => 61,
'first_due_date' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Tenant: <x-tenant>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.flextell.ai/api/v1/sales/calculate"
payload := strings.NewReader("{\n \"items\": [\n {\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"total_price\": 1\n }\n ],\n \"installment_count\": 61,\n \"first_due_date\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tenant", "<x-tenant>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.flextell.ai/api/v1/sales/calculate")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"total_price\": 1\n }\n ],\n \"installment_count\": 61,\n \"first_due_date\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.flextell.ai/api/v1/sales/calculate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"total_price\": 1\n }\n ],\n \"installment_count\": 61,\n \"first_due_date\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"success": "<string>",
"data": {
"items": [
"<unknown>"
],
"sub_total": 123,
"total_discount": 123,
"total_tax": 123,
"total": 123,
"installments": [
{
"installment_number": "<string>",
"amount": 123,
"due_date": "<string>"
}
]
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"success": false,
"error_code": "SETUP_REQUIRED",
"message": "Complete the required setup steps to continue.",
"data": {
"next_step": "clinic_info"
}
}Satışlar ve teklifler
Calculate sale totals
Computes line and sale totals exactly as creating the sale would, plus an equal monthly installment plan when installment_count is given. Line figures are rounded for display; total is summed from the unrounded lines and rounded once, the same figure POST /sales checks an installment plan against. Nothing is saved.
POST
/
v1
/
sales
/
calculate
Calculate sale totals
curl --request POST \
--url https://app.flextell.ai/api/v1/sales/calculate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"items": [
{
"quantity": 1.0001,
"unit_price": 1,
"discount_amount": 1,
"discount_percentage": 50,
"total_price": 1
}
],
"installment_count": 61,
"first_due_date": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://app.flextell.ai/api/v1/sales/calculate"
payload = {
"items": [
{
"quantity": 1.0001,
"unit_price": 1,
"discount_amount": 1,
"discount_percentage": 50,
"total_price": 1
}
],
"installment_count": 61,
"first_due_date": "2023-11-07T05:31:56Z"
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
items: [
{
quantity: 1.0001,
unit_price: 1,
discount_amount: 1,
discount_percentage: 50,
total_price: 1
}
],
installment_count: 61,
first_due_date: '2023-11-07T05:31:56Z'
})
};
fetch('https://app.flextell.ai/api/v1/sales/calculate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.flextell.ai/api/v1/sales/calculate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'quantity' => 1.0001,
'unit_price' => 1,
'discount_amount' => 1,
'discount_percentage' => 50,
'total_price' => 1
]
],
'installment_count' => 61,
'first_due_date' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Tenant: <x-tenant>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.flextell.ai/api/v1/sales/calculate"
payload := strings.NewReader("{\n \"items\": [\n {\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"total_price\": 1\n }\n ],\n \"installment_count\": 61,\n \"first_due_date\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tenant", "<x-tenant>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.flextell.ai/api/v1/sales/calculate")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"total_price\": 1\n }\n ],\n \"installment_count\": 61,\n \"first_due_date\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.flextell.ai/api/v1/sales/calculate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"total_price\": 1\n }\n ],\n \"installment_count\": 61,\n \"first_due_date\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"success": "<string>",
"data": {
"items": [
"<unknown>"
],
"sub_total": 123,
"total_discount": 123,
"total_tax": 123,
"total": 123,
"installments": [
{
"installment_number": "<string>",
"amount": 123,
"due_date": "<string>"
}
]
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"success": false,
"error_code": "SETUP_REQUIRED",
"message": "Complete the required setup steps to continue.",
"data": {
"next_step": "clinic_info"
}
}Yetkilendirmeler
oauth2bearer
Başlıklar
Gövde
application/json
Nothing is stored, so anyone who may fill in the sale form may ask for its figures.