Rest API: Receiving orders, delivery notes and/or validating purchase invoices in tspoonlab
tspoonlab is a perfect environment to generate orders from the kitchen to your suppliers. There are several ways to generate them: based on a plan, based on stock, or through templates. In every case the app records what you are going to order and sends it to the supplier by WhatsApp, email or phone. Receiving orders is the same as entering delivery notes, and it has implications beyond cost or accounting control: it also lets you record reception control points and the batch numbers of the order received, generate a store entry, and check that the quantity served and the prices match what was requested. We therefore recommend carrying out reception/delivery-note entry from tspoonlab. Once orders are received, they can be sent to external management systems where invoices can be validated against delivery notes and all accounting processes started.
From the tspoonlab suppliers screen you can also validate invoices against the delivery notes received. In that process an invoice is created and its delivery notes are associated with it. From there, the invoice, the taxes and the payment must be handled by a billing system. So, for purchases, you can send the delivery notes or the invoices. To avoid sending them again once the external system has processed them, they must be marked as processed in tspoonlab so they are not sent again.
System login
To make calls to our APIs, the first thing you need is to authenticate through a login call. That call returns a token that you must then attach to every subsequent call.
This shell script shows how to authenticate using curl:
[email protected]
password=XXXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
On later calls, add the token received from the login call to your headers:
curl -X PUT -v -H "$(cat rememberme.txt)" $url/integration/llamada
Rest API: Select a cost center/restaurant
The requests described in the following sections refer to a cost center, which in most cases corresponds to a restaurant. To retrieve the list of cost centers and their identifiers, see the REST API: Cost centers article. The cost center identifier corresponds to the idOrderCenter field of the UserOrderCenter class. Once you have the identifier, add it to the headers so it is used on subsequent calls:
echo -n 'order:351583444167656299610202XXXXXXXXXXXX' >> rememberme.txt
So in your request headers you must specify both the token returned by login and the cost center identifier:
rememberme:aGVucnkudXBzYWxsLmRAZXXXXXXXXXXXXXXXXXX
order:351583444167656299610202XXXXXXXXXXXX
Rest API: Retrieving purchase orders not marked as processed
To retrieve the purchase orders not marked as processed, make this call:
GET: https://app.tspoonlab.com/recipes/api/integration/purchases/orders/pending?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&includeInternal=true&idVendor=XXXXX
You must pass the following request parameters:
startDate (String), the date from which data is retrieved.
endDate (String), the date up to which data is retrieved.
includeInternal (Boolean), also include delivery notes from suppliers marked as internal (optional, default true).
idVendor (Id), optional supplier id, it retrieves only the data linked to that supplier (see the REST API: Suppliers article to get the supplier id).
Dates must be in YYYY-MM-DD format and are inclusive of startDate and endDate.
It returns an array of the PurchaseOrder class and a 200 code.
class PurchaseOrder {
String id; // Order id
String numOrder; // Order number
String idVendor; // Supplier id
String vendor; // Supplier name
String codeVendor; // Supplier code
String accountVendor; // Supplier ledger account number
String nif; // Supplier tax ID
Date date; // Order date
String dateFormatted; // Order date in YYYY/MM/DD
Date dateReception; // Reception date
String sentBy; // Sent by
String dateReceptionFormatted; // Reception date in YYYY/MM/DD
Double total; // Total amount
List<PurchaseOrderLine> listOrders; // Order line detail
}
The detail lines:
public class PurchaseOrderLine {
String id; // Detail line id
int position; // Position within the delivery note
String codeComponent; // Product code
String idComponent; // Ingredient/material id
String codeVendorComponent; // Product code for the supplier
String component; // Ingredient/material description
String comment; // Comment
// Values in the ingredient's base unit
Double quantity; // Quantity
String idUnit; // Unit id
String unit; // Unit
Double cost; // Unit cost
// If purchased with a format
boolean hasFormat; // true if it has format information
Double quantityFormat; // Format quantity
String idUnitFormat; // Format unit id
String unitFormat; // Format unit
Double costFormat; // Format unit cost
Double iva; // VAT rate applied to the line
String idCostType; // Analysis account id
String costType; // Analysis account description
String codeCostType; // Analysis account code
String accountCostType; // Ledger account of the analysis account
String accountAuxCostType; // Ledger account of the analysis account
String idBusinessLine; // Business line id
String businessLine; // Business line description
String codeBusinessLine; // Business line code
List<LineType> listTypes; // Component type list.
}
For each type in the type/category list:
class LineType {
String id; // Tax id for the invoice
String descr; // Type description
}
Here is an example call:
[email protected]
password=XXXXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X GET -v -H "$(cat rememberme.txt)" $url/integration/purchases/orders/pending | python -m json.tool
Rest API: Mark purchase orders as processed
Once you have transferred the purchase delivery notes to the external system, you can mark them as processed in tspoonlab so they are not resent in later requests.
PUT:
https://app.tspoonlab.com/recipes/api/integration/purchases/orders/processed
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to mark:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/purchases/orders/processed
Rest API: Retrieving purchase delivery notes not marked as processed
To retrieve the purchase delivery notes not marked as accounted, make this call:
GET: https://app.tspoonlab.com/recipes/api/integration/purchases/deliveries/pending?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&includeInternal=true&idVendor=XXXXX
You must pass the following request parameters:
startDate (String), the date from which data is retrieved.
endDate (String), the date up to which data is retrieved.
includeInternal (Boolean), also include delivery notes from suppliers marked as internal (optional, default true).
idVendor (Id), optional supplier id â it retrieves only the data linked to that supplier (see the REST API: Suppliers article to get the supplier id).
Dates must be in YYYY-MM-DD format and are inclusive of startDate and endDate. It returns an array of the PurchaseDelivery class and a 200 code.
public class PurchaseDelivery {
private String id; // Delivery note id
private String idVendor; // Supplier id
private String vendor; // Supplier name
private String codeVendor; // Supplier code
private String accountVendor; // Supplier ledger account number
private String nif; // Supplier tax ID
private String deliveryNum ; // Delivery note number
private String deliveryFor;
// Delivery note reference. Usually the order number
private Date date; // Delivery note date in time_t format
private String dateFormatted; // Delivery note date in
// YYYY/MM/DD format
private Date dateSent; // Order send date
private String dateSentFormatted; // Send date of the
// order in YYYY/MM/DD
private String sentBy; // Sent by
private String receivedBy; // Received by
private Double baseCalculated; // Delivery note base amount
// rounded to 5 decimals
private Double base; // Delivery note base amount
private Double taxes; // Tax amount
private Double total; // Total amount
private String idCostType; // Analysis account id
// (If the whole delivery note is allocated; if it doesn't appear it may
// be allocated per delivery-note line)
private String costType; // Analysis account description
// (If the whole delivery note is allocated; if it doesn't appear it may
// be allocated per delivery-note line)
private String codeCostType; // Analysis account code
// (If the whole delivery note is allocated; if it doesn't appear it may
// be allocated per delivery-note line)
private String accountCostType; // Ledger account
// of the analysis account
// (If the whole delivery note is allocated; if it doesn't appear it may
// be allocated per delivery-note line)
private String accountAuxCostType; // Ledger account
// of the analysis account
// (If the whole delivery note is allocated; if it doesn't appear it may
// be allocated per delivery-note line)
private String idBusinessLine; // Business line id
private String businessLine; // Business line description
private String codeBusinessLine; // Business line code
private String vendorType; // supplier type
private String vendorTypeCode; // Supplier type code
private boolean vendorTypeInternal;
// Indicates whether the supplier is internal
private List<DeliveryTax> listTaxes; // Tax detail
private List<PurchaseDeliveryLine> listDeliveries;
// Delivery note line detail
private List<PurchaseDeliverySentLine> listSent;
// Order line detail
}
public class DeliveryTax {
private String id; // Tax id for the delivery note
private short type; // Tax type
// (0: VAT, 1: Transport, 2: Discounts, 3: Others, -1: Discount on base)
private Double base; // Base can be null
// for Transport, Discounts and others
private Double percent; // Type/Percentage can be null
// for Transport, Discounts and others
private Double total; // Total tax or transport
// or discount or others
}
The detail lines:
public class PurchaseDeliveryLine {
private String id; // Detail line id
private int position; // Position within the delivery note
private String idComponent; // Product id
private String codeComponent; // Product code
private String component; // Product name
private String codeVendorComponent;
// Product code for the supplier
private String comment; // Comment
private boolean recibido; // Whether it has been received or not
// Values in the ingredient's base unit
private Double quantity; // Quantity
private String idUnit; // Unit id
private String unit; // Unit
private Double cost; // Unit cost
// If purchased with a format
private boolean hasFormat; // true if it has format information private Double quantityFormat; // Format quantity
private String idUnitFormat; // Format unit id
private String unitFormat; // Format unit
private Double costFormat; // Format unit cost
private Double iva; // VAT rate applied to the line
private String idCostType; // Id of the
// analysis account
private String costType; // Description of the
// analysis account
private String codeCostType; // Code of the
// analysis account
private String accountCostType; // Ledger account of the
// analysis account
private String accountAuxCostType; // Ledger account of the
// analysis account
private String idBusinessLine; // Business line id
private String businessLine; // Business line description
private String codeBusinessLine; // Business line code
private List<LineType> listTypes; // Component type list.
private String idStore; // Store id
private String store; // Store
}
For each type in the type/category list:
public class LineType {
private String id; // Tax id for the invoice
private String descr; // Type description
}
The order lines:
public class PurchaseDeliverySentLine {
private String id; // Detail line id
private int position; // Position within the delivery note
private String codeComponent; // Product code
private String idComponent; // Ingredient/material id
private String codeVendorComponent;
// Product code for the supplier
private String component; // Ingredient/material description
private String comment; // Comment
// Values in the ingredient's base unit
private Double quantity; // Quantity
private String idUnit; // Unit id
private String unit; // Unit
private Double cost; // Unit cost
// If purchased with a format
private boolean hasFormat; // true if it has format information
private Double quantityFormat; // Format quantity
private String idUnitFormat; // Format unit id
private String unitFormat; // Format unit
private Double costFormat; // Format unit cost
}
Here is an example call:
[email protected]
password=XXXXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X GET -v -H "$(cat rememberme.txt)" $url/integration/purchases/deliveries/pending | python -m json.tool
To retrieve all purchases, whether processed or not, make this call:
GET: https://app.tspoonlab.com/recipes/api/integration/purchases/deliveries/all?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&includeInternal=true&idVendor=XXXX
Rest API: Mark purchase delivery notes as processed
Once you have transferred the purchase delivery notes to the external system, you can mark them as processed in tspoonlab so they are not resent in later requests:
PUT:
https://app.tspoonlab.com/recipes/api/integration/purchases/deliveries/processed?lock=true
The lock parameter indicates whether, besides marking the delivery note as processed, you also lock it. The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to mark as accounted:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/purchases/deliveries/processed
Rest API: Mark purchase delivery notes as locked
To mark delivery notes as locked in tspoonlab:
PUT:
https://app.tspoonlab.com/recipes/api/integration/purchases/deliveries/lock
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to lock:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/purchases/deliveries/lock
Rest API: Retrieving purchase invoices not accounted
To retrieve the purchase invoices pending accounting, make this call:
GET: https://app.tspoonlab.com/recipes/api/integration/purchases/invoices/pending?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&includeInternal=true&onlyValidated=true&idVendor=XXXXX
You must pass the following request parameters:
startDate (String), the date from which data is retrieved.
endDate (String), the date up to which data is retrieved.
includeInternal (Boolean, optional, default true).
onlyValidated (Boolean), include only invoices from suppliers marked as validated (optional, default false).
idVendor (Id, optional).
Dates must be YYYY-MM-DD and inclusive. It returns an array of the PurchaseInvoice class and a 200 code.
public class PurchaseInvoice {
String id; // Invoice id
String idVendor; // Supplier id
String vendor; // Supplier name
String codeVendor; // Supplier code
String accountVendor; // Supplier ledger account number
String nif; // Supplier tax ID
boolean inEuropeanUnion; // Whether it is an intra-community supplier
boolean inVies; // Whether it is registered in the VIES system
String country; // The supplier's country if set. ISO 3166-1 alpha-2
String documentNum; // Document number
String invoiceNum; // Invoice number
boolean paid; // Whether it is already paid
boolean validated; // Whether it is validated
String comment; // Invoice comment
Date date; // Invoice date
Date dateAccounting; // Accounting date; if null, use date
Date dateDue; // Due date
String codePaymentType; // Payment method code
String idCostTypeVendor; // Supplier analysis account id
String costTypeVendor; // Supplier analysis account description
String codeCostTypeVendor; // Supplier analysis account code
String accountCostTypeVendor; // Ledger account of the supplier analysis account
String accountAuxCostTypeVendor; // Other ledger account of the supplier analysis account
String idDocument; // Id of the document associated with the invoice
String extDocument; // Extension of the document associated with the invoice
String idBusinessLine; // Business line id
String businessLine; // Business line description
String codeBusinessLine; // Business line code
Double total; // Invoice total
Double base; // Total taxable base
Double taxes; // Total taxes
List<InvoiceTax> listTaxes; // Tax detail
List<CostTypeTax> listCostTypeTaxes; // Tax detail by analysis account
List<PurchaseDelivery> listDeliveries; // Delivery note detail
}
public class InvoiceTax {
private String id; // Tax id for the invoice
private short type; // Tax type
// (0: VAT, 1: Transport, 2: Discounts, 3: Others, -1: Discount on base)
private Double base; // Base can be null
// for Transport, Discounts and others
private Double percent; // Type/Percentage
// can be null for Transport, Discounts and others
private Double total; // Total tax or transport or discount or others
}
The delivery note is represented by the PurchaseDelivery class, as documented earlier.
Here is an example call:
[email protected]
password=XXXXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X GET -v -H "$(cat rememberme.txt)" $url/integration/purchases/invoices/pending | python -m json.tool
To retrieve all invoices, whether accounted or not, make this call:
GET: https://app.tspoonlab.com/recipes/api/integration/purchases/invoices/all?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&includeInternal=true&onlyValidated=false&idVendor=XXXX
To retrieve the document associated with the invoice, make this call:
https://app.tspoonlab.com/recipes/api/exportFileBoundFile/{idDocument}.{extDocument}?id={idDocument}&rememberme={rememberme}
listCostTypeTaxes returns the tax detail per analysis account for the invoice:
class CostTypeTax {
String id; // Analysis account id
String descr; // Analysis account description
List<OrderVendorVat> listTaxes;
}
class OrderVendorVat {
Double base; // taxable base
Double percent; // VAT percentage
Double total; // VAT amount
}
Rest API: Mark purchase invoices as accounted
Once you have transferred the purchase invoices to accounting, you can mark them as accounted in tspoonlab so they are not resent in later requests.
PUT:
https://app.tspoonlab.com/recipes/api/integration/purchases/invoices/accounted?lock=true
The lock parameter indicates whether, besides marking the invoice as accounted, you also lock it. The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to mark as accounted:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/purchases/invoices/accounted
Rest API: Mark purchase invoices as not accounted
To mark invoices in tspoonlab as not accounted again:
PUT:
https://app.tspoonlab.com/recipes/api/integration/purchases/invoices/not/accounted
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to mark:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/purchases/invoices/not/accounted
Rest API: Mark purchase invoices as locked
To mark invoices in tspoonlab as locked:
PUT:
https://app.tspoonlab.com/recipes/api/integration/purchases/invoices/lock
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to lock:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/purchases/invoices/lock
Rest API: Sales in tspoonlab
In restaurants, tspoonlab can integrate with the POS (Point of Sale) system. You can retrieve POS sales and use them in tspoonlab to manage stores and calculate the theoretical Food Cost. That scenario is not the subject of this article, which describes how to send tspoonlab sales to an external system; with POS systems the opposite happens.
If you have an online shop with Shopify, you would retrieve the sales requests and manage the productions from tspoonlab. Once you send the sale, it is considered done and could be sent back to Shopify or to a management system.
Finally, if you run a production center, requests and product shipments are generated â from the clients (usually group restaurants) to the production center and from the production center to the clients â where integrating with the tspoonlab sales module is especially useful.
System login
To make calls to our APIs, the first thing you need is to authenticate through a login call. That call returns a token that you must then attach to every subsequent call.
This shell script shows how to authenticate using curl:
[email protected]
password=XXXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
On later calls, add the token received from the login call to your headers:
curl -X PUT -v -H "$(cat rememberme.txt)" $url/integration/llamada
Rest API: Select a cost center/restaurant
The requests described in the following sections refer to a cost center, which in most cases corresponds to a restaurant. To retrieve the list of cost centers and their identifiers, see the REST API: Cost centers article. The cost center identifier corresponds to the idOrderCenter field of the UserOrderCenter class. Once you have the identifier, add it to the headers so it is used on subsequent calls:
echo -n 'order:351583444167656299610202XXXXXXXXXXXX' >> rememberme.txt
So in your request headers you must specify both the token returned by login and the cost center identifier:
rememberme:aGVucnkudXBzYWxsLmRAZXXXXXXXXXXXXXXXXXX
order:351583444167656299610202XXXXXXXXXXXX
Rest API: Retrieving sales delivery notes not accounted
To retrieve the sales delivery notes pending accounting, make this call:
GET: https://app.tspoonlab.com/recipes/api/integration/sales/deliveries/pending?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&includeInternal=true
You must pass the following request parameters:
startDate (String).
endDate (String).
includeInternal (Boolean, optional, default true).
Dates must be YYYY-MM-DD and inclusive.
It returns an array of the SalesDelivery class and a 200 code.
public class SalesDelivery {
private String id; // Invoice id
private String idCustomer; // Client id
private String customer; // Client name
private String customerCode; // client code
private String address; // address
private String cp; // postcode
private String city; // city
private String nif; // Supplier tax ID
private String contact; // contact name
private String phone; // phone
private String contactAux; // other contact name
private String phoneAux; // other phone
private String mail; // email
private String mailAux; // other email
private String mailCC; // copy email
private String web; // client URL
private String customerType; // client type
private String customerTypeCode; // Client type code
private boolean customerTypeInternal;
// Indicates whether the client is internal
private String invoiceNum; // Invoice number
private Date date; // Invoice date
private Double base; // Total taxable base
private List<SalesDeliveryLine> listLines;
private List<SalesDeliveryLine> listLinesPending;
}
The detail lines appear in listLines and listLinesPending: listLines has all the sent ones and listLinesPending the ones pending to send.
public class SalesDeliveryLine {
private String id; // Detail line id
private int position; // Position within the delivery note
// Will have a value if we send a product; otherwise null
private String idComponent; // Product id
private String component; // Product description
private String codeComponent; // Product code
// Will have a value if we send a menu; otherwise null
private String idMenu; // Menu id
private String menu; // Menu description
private String codeMenu; // Menu code
private String codeCustomerProduct;
// Sales code of the component/menu
private String comment; // Comment
private boolean sent; // Whether it has been received or not
private Double quantity; // Quantity
private String idUnit; // Unit id
private String unit; // Unit
private Double cost; // Unit sale price excluding VAT
private Double costRecipe; // Recipe-costing unit cost
private Double iva; // VAT rate applied to the line
private List<LineType> listTypes; // Component type list.
private String idCustomerGroup; // Product's product group
private String customerGroup; // Product group name
}
Here is an example call:
[email protected]
password=XXXXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X GET -v -H "$(cat rememberme.txt)" $url/integration/sales/deliveries/pending | python -m json.tool
To retrieve all sales delivery notes, whether processed or not:
GET: https://app.tspoonlab.com/recipes/api/integration/sales/deliveries/all?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&includeInternal=true
Rest API: Mark sales delivery notes as accounted
Once you have transferred the sales delivery notes to accounting, you can mark them as accounted in tspoonlab so they are not resent in later requests:
PUT:
https://app.tspoonlab.com/recipes/api/integration/sales/deliveries/accounted
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to mark:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/sales/deliveries/accounted
Rest API: Mark sales delivery notes as not accounted
To mark sales delivery notes in tspoonlab as not accounted again:
PUT:
https://app.tspoonlab.com/recipes/api/integration/sales/deliveries/not/accounted
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to mark:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/sales/deliveries/not/accounted
Rest API: Mark sales delivery notes as locked
To mark delivery notes in tspoonlab as locked:
PUT:
https://app.tspoonlab.com/recipes/api/integration/sales/deliveries/lock
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to lock:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/sales/deliveries/lock
Rest API: Retrieving sales invoices not accounted
To retrieve the sales invoices pending accounting, make this call:
GET: https://app.tspoonlab.com/recipes/api/integration/sales/invoices/pending?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&includeInternal=true
You must pass startDate, endDate and includeInternal as above. It returns an array of the SalesInvoice class and a 200 code.
public class SalesInvoice {
private String id; // Invoice id
private String idCustomer; // Client id
private String customer; // Client name
private String codeCustomer; // Client code
private String accountCustomer; // Client ledger account number
private String nif; // Client tax ID
private String documentNum; // Document number
private String invoiceNum; // Invoice number
private boolean paid; // Whether it is already paid
private String comment; // Invoice comment
private Date date; // Invoice date
private Date dateAccounting; // Accounting date; if null, use date
private Date dateDue; // Due date
private String codePaymentType; // Payment method code
private String idCostTypeVendor;
// Client analysis account id
private String costTypeVendor;
// Client analysis account description
private String codeCostTypeVendor;
// Client analysis account code
private String accountCostTypeVendor;
// Ledger account of the client analysis account
private String accountAuxCostTypeVendor;
// Ledger account of the client analysis account private String idDocument;
// Id of the document associated with the invoice
private String extDocument; /
/ ExtensiĂłn del documento asociado a la factura
private Double total; // Invoice total
private Double base; // Total taxable base
private Double taxes; // Total taxes
private List<InvoiceTax> listTaxes; // Tax detail
private List<CostTypeTax> listCostTypeTaxes;
// Tax detail by analysis account
private List<SalesDelivery> listDeliveries;
// Delivery note detail
}
The InvoiceTax, CostTypeTax and SalesDelivery classes have already been explained in earlier sections.
Rest API: Mark sales invoices as accounted
Once you have transferred the sales invoices to accounting, you can mark them as accounted in tspoonlab so they are not resent in later requests.
PUT:
https://app.tspoonlab.com/recipes/api/integration/sales/invoices/accounted
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to mark:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/sales/invoices/accounted
Rest API: Mark sales invoices as not accounted
To mark sales invoices in tspoonlab as not accounted again:
PUT:
https://app.tspoonlab.com/recipes/api/integration/sales/invoices/not/accounted
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to mark:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/sales/invoices/not/accounted
Rest API: Mark sales invoices as locked
To mark sales invoices in tspoonlab as locked:
PUT:
https://app.tspoonlab.com/recipes/api/integration/sales/invoices/lock
The request returns a 200 code if it executed correctly. In the request body you pass this structure with the list of invoice ids you want to lock:
public class NewListIds {
private List<String> listIds;
}
Here is an example call:
username= [email protected]
password=XXXXXX
url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password
echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt
curl -X PUT -d '{"listIds":["idFactura1", "idFactura2"]}' -H "$(cat rememberme.txt)" -H 'Content-Type: application/json' $url/integration/sales/invoices/lock
Rest API: Creating purchase orders in tspoonlab
To create orders in tspoonlab, the first thing to do is get a supplier id.
Identify the supplier
Call the function:
GET:
https://app.tspoonlab.com/recipes/api/listVendorsPaged
This call is documented in the REST API: Suppliers article. In an environment with a production center where your supplier is linked to a client of the production center, the orderCenter field will hold the cost center you are going to order from. From the response, select the id of the supplier you will place the order with.
Create order
To create an order, call:
POST:
https://app.tspoonlab.com/recipes/api/integration/purchases/orders
In the body you specify all the information for the order you want to create:
NewPurchaseOrder {
String idVendor; // Supplier id
String codeVendor; // Supplier code
Date dateSend; // Send date
Date dateReception; // Reception date
List<NewPurchaseOrderLine> listLines; // Order line detail
}
NewPurchaseOrderLine {
String idComponent; // Ingredient/material id
String codeComponent; // Supplier code
double quantity; // Quantity. Cannot be null
String idUnit; // Unit id
String unit; // Unit name
}
Rest API: Create order from identifiers:
Where:
idVendor is the supplier id from the previous section.
dateSend and dateReception are the order send date and expected reception date.
listLines is the list of items to buy, with the idComponent and the quantity (quantity).
To get the idComponent, check the supplierâs sale products (the field appears in the VendorComponent class, see REST API: Suppliers).
To get the idUnit, check the unit list (check REST API: Units). The code and unit fields are not required.
Rest API: Create order from codes:
Where:
codeVendor is the supplier code and codeComponent the supplierâs item code.
unit is the unit description. If the component or unit are not associated with the supplier, an error is generated because the purchase cannot be created; to validate whether the unit is valid, the componentâs and the formatâs units are checked.
If codeVendor does not exist in the cost center, an error is also generated.
The identifier fields are not required.
The response is a structure with the order id:
IdWrapper {
String id; // Order id
}
Mark the order as sent
Once the order is created, you must send it to the supplier and then mark it as sent:
PUT:
https://app.tspoonlab.com/recipes/api/vendorOrder/{idProvCom}/sent
idProvCom is the order id from the previous section. It returns no data, only a 200 code if sent correctly.
Mark the order as received (delivery note)
When the goods arrive, you must mark the order as received and generate a delivery note:
PUT:
https://app.tspoonlab.com/recipes/api/vendorOrder/{idProvCom}/received/date
idProvCom is the order id from the previous section. In the body you specify the reception date and the delivery note number.
public class NewOrderReceiveParams {
Date date; // Reception date
String deliveryNum; // Delivery note number
}
It returns no data, only a 200 code if received correctly.
Rest API: Creating sales orders in tspoonlab
To create sales orders in tspoonlab, the first thing to do is get a client id.
Identify the client
Call the function:
GET:
https://app.tspoonlab.com/recipes/api/listCustomersPaged
This call is documented in the REST API: Clients article. From the response, select the id of the client you will place the order with.
Create order
To create an order, call:
POST:
https://app.tspoonlab.com/recipes/api/integration/sales/orders
In the body you specify all the information for the order you want to create:
NewSaleOrder {
String idCustomer; // Client id
String codeCustomer; // Client code
Date dateSend; // Date the order was generated
Date dateReception; // Order send/reception date
List<NewPurchaseSaleLine> listLines; // Order line detail
}
NewPurchaseSaleLine {
String idComponent; // Sales product id
String codeComponent; // Product code at the client
double quantity; // Quantity. Cannot be null
String idUnit; // Unit id
String unit; // Unit name
}
Rest API: Create order from identifiers:
idCustomer is the client id from the previous section.
dateSend and dateReception are the order generation date and expected send/reception date.
listLines is the list of items to buy, with the idComponent and the quantity (quantity).
To get the idComponent, check the clientâs sale products (see REST API: Clients).
To get the idUnit, check the unit list (see REST API: Units). The code fields are not required.
Rest API: Create order from codes:
Where:
codeCustomer is the client code and codeComponent the clientâs product code.
unit is the unit description.
The identifier fields are not required.
The response is a structure with the order id:
IdWrapper {
String id; // Order id
}
If the component or unit are not associated with the client, an error is generated because the sale cannot be created. If codeCustomer does not exist in the cost center, an error is also generated.
Rest API: Query purchase totals by status
To query the total amounts of purchases by status over a period of time, call the function:
GET:
https://app.tspoonlab.com/recipes/api/integration/purchases/totals?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD&type=0
You must pass the following request parameters:
startDate (String). Required.
endDate (String). Required.
type (short), the total type.
Dates must be YYYY-MM-DD and inclusive.
The numeric type can take these values:
0 vendorOrderTypeNotSent (orders not sent).
1 vendorOrderTypeNotReceived (orders not received).
2 vendorOrderTypeReceivedNotInvoice (orders received not in an invoice).
3 vendorOrderTypeReceivedInvoice (orders received in an invoice).
4 vendorOrderTypeReceivedInvoiceAccounted (received in an invoice and accounted).
5 vendorOrderTypeReceivedInvoiceNotAccounted (received in an invoice and not accounted).
6 vendorOrderTypePendingApproval (pending approval).
7 vendorOrderTypePendingReview (pending review).
8 vendorOrderTypeScanPendingValidate (scanned, pending validation).
9 vendorOrderTypeReceived (received).
10 vendorOrderTypeReceivedInvoiceValidated (received in validated invoices).
11 vendorOrderTypeReceivedInvoiceNotValidated (received in non-validated invoices).
It returns the total amount:
class ValueWrapper {
Double value;
}
Did you find this article helpful?
If you need further assistance, contact support by clicking the built-in Support Chat in the bottom-right corner of your screen.
