RestJson Connector - SendOrderToBackoffice
This document describes the process of sending an order from App4Sales to a backoffice system using the RestJson connector. The process involves validating the order, mapping the App4Sales order object to a JSON payload, and sending it to the backoffice via a REST API.
Data Source Configuration
The RestJson connector sends orders to a RESTful API endpoint. The specific endpoint for sending orders is configured in the connector's settings and is typically something like /api/Orders. The connector uses a POST request to send the order data in JSON format.
Order Header Logic
The order header contains general information about the order, such as the customer, order date, and total amounts. The following table shows the mapping of App4Sales order header fields to the JSON payload.
App4Sales Field | Source Field (JSON) | Logic/Notes |
Id |
| The |
Number |
| The order number from the App4Sales |
Customer |
| The GUID of the customer. |
CustomerCode |
| The code of the customer. |
Created |
| The current date and time when the order is being processed. |
Date |
| The order date from the App4Sales |
IsOpen |
| Hardcoded to |
Notes |
| The notes from the App4Sales |
Description1 |
| The |
Description2 |
| The |
Description3 |
| The |
Reference |
| The |
SubTotal |
| The total amount excluding VAT. |
Total |
| The total amount of the order. |
VatTotal |
| The total VAT amount. |
YourReference |
| The |
Username |
| The username of the sales representative. |
Warehouse |
| The warehouse of the sales representative. This is only set if the |
Signature |
| The signature from the App4Sales |
DeliveryMethodCode |
| The code of the delivery method. |
OrderType |
| The value of the order type that should be sent to the backoffice. This is only set if |
DeliveryAddress |
| The alternate delivery address. This is only set if an alternate address is provided and the |
Line & Pricing Logic
The order lines contain information about the individual products in the order. The following table shows the mapping of App4Sales order line fields to the JSON payload.
App4Sales Field | Source Field (JSON) | Logic/Notes |
Id |
| A new GUID is generated for each order line. |
Customer |
| The GUID of the customer. |
Discount |
| The discount percentage for the order line. |
TotalDiscount |
| The total discount amount for the order line. |
ItemCode |
| The item code for the order line. |
Quantity |
| The quantity of the item. |
QuantityDelivered |
| The delivered quantity of the item. |
VatPercentage |
| The VAT percentage for the item. |
PriceExcl |
| The price of the item, excluding VAT. |
PriceIncl |
| The price of the item, including VAT, calculated using |
DefaultPrice |
| The default price of the item. |
LineNumber |
| The line number of the order line. |
Instruction |
| The instruction for the order line. |
ItemDescription |
| The description of the item. |
DeliveryDate |
| The delivery date for the order line. |
Charges & Attachments
The RestJson connector does not currently support sending separate charges or attachments with an order. Any charges, such as freight or payment fees, must be added as order lines.
Responses & Error Handling
The backoffice system is expected to return a JSON response containing the order number of the newly created order. The connector will then update the order in App4Sales with this order number. In case of an error, the connector will log the error and return an error message to the user. The connector has specific handling for RestException and RequestException, and a general exception handler for other types of errors.
Related Settings & Prerequisites
ValidateOrderBeforeSending: If enabled, the connector will check if the order already exists in the backoffice before sending it.DontSendAlternativeAddressOnOrder: If enabled, the connector will not send the alternative address on the order to the backoffice.UseResultsTagForRequest: If enabled, the connector will wrap the request in aBaseResponse2object. This is a setting that is typically hidden and used for specific implementations.FilterNonIso88591Characters: If enabled, the connector will remove non-ISO-8859-1 characters from the order. This is a setting that is typically hidden and used for specific implementations.UseWarehouseFromUser: If enabled, the connector will use the warehouse from the user.