Logic4 Connector - Send Order to Backoffice
This document describes the process by which App4Sales orders are sent to the Logic4 ERP system. The connector translates App4Sales order data, including header information, order lines, and associated addresses, into the Logic4 data structure and transmits it via the Logic4 API.
Order Header Logic
Order header information is primarily mapped directly from the App4Sales order object to the Logic4 Logic4NewOrder entity. Key fields such as customer ID (DebtorId), sales representative (UserId), and order notes are transferred. The order status and shipping method are configurable via connector settings, allowing administrators to define default values specific to their Logic4 setup.
Line & Pricing Logic
Each order line from App4Sales is translated into a Logic4OrderLine. The connector meticulously calculates gross and nett prices, taking into account any discounts applied in App4Sales. The warehouse associated with each order line is derived from a default setting within the connector, ensuring stock updates are directed to the correct location in Logic4. Product codes and EAN barcodes are directly mapped to facilitate item identification.
Charges & Attachments
Based on the current code analysis, there is no explicit handling for charges (e.g., freight, payment fees) or attachments (e.g., PDFs, images) when sending orders to Logic4. This implies that only core order header and line item data are transferred.
Responses & Error Handling
After sending an order, the connector expects to receive a unique order identifier (an integer ID) from Logic4. If this identifier is not returned, App4Sales will display a generic error message indicating that no order number was retrieved. Any exceptions encountered during the API call or data processing within the connector are caught, and their messages are communicated back to App4Sales, prefixed with a general error indicator.
The Logic4 connector uses the following endpoint to send order data:
API Endpoint:
https://api.logic4server.nl/v1.2/Orders/AddUpdateOrderHTTP Method: POST
Order Header Mapping
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Id | OrderNr | Mapped from |
CreationDate | SysCreated / OrderDate | Set based on the 'Set order order date as delivery date' setting. If enabled, uses |
DeliveryDate | OrderDate | Set based on the 'Set order order date as delivery date' setting. If enabled, uses |
OrderStatus | Configured Setting | Uses the 'Order status id for new orders' setting. Defaults to 1 if the setting is 0. |
Reference | YourReference / Reference | Set based on the 'Map your reference to reference' setting. If enabled, uses |
DebtorId | Customer.CustomerCode | Customer code is converted to an integer. |
UserId | Salesrep | Derived from the order's sales representative. Falls back to 'Default user id which should be used for retrieving data' setting if no salesrep is found or username is empty. |
Description | Description1 | |
Notes | Notes | |
ShippingMethod | Configured Setting | Uses the 'Shipping method id used for sending orders' setting. Defaults to 1 if the setting is 0. |
Order Line Mapping
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Description | Description | |
Quantity | Quantity | Defaults to 0 if null. |
DiscountPercent | Discount | Value from |
GrossPrice | Price | Calculated based on |
NettPrice | Price | Directly from |
OrderId | OrderNr | Converted to integer from |
Barcode | Item.EanCode | |
ProductCode | Item.ItemCode | |
QuantityDelivered | QuantityDelivered | Defaults to 0 if null. |
VATPercentage | VatPercentage | Defaults to 0 if null. |
WarehouseId | Configured Setting | Uses the 'Default warehouse id which is used for stock' setting. |
DebtorId | Customer.CustomerCode | Customer code is converted to an integer, defaults to 0 if null. |
Delivery Address Mapping
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Street | AddressLine1 | Parsed from |
HouseNumber | AddressLine1 | Parsed from |
HouseNumberAddition | AddressLine1 | Parsed from |
CountryCode | Country | |
City | City | |
PostalCode | PostCode | |
TelephoneNumber | Phone | |
ContactName | ContactPerson.FullName | Full name of the main contact person for the customer. |
Invoice Address Mapping
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Street | AddressLine1 | Parsed from |
HouseNumber | AddressLine1 | Parsed from |
HouseNumberAddition | AddressLine1 | Parsed from |
CountryCode | Country | |
City | City | |
PostalCode | PostCode | |
TelephoneNumber | Phone | |
ContactName | ContactPerson.FullName | Full name of the main contact person for the customer. |
Special Logic & Filters
User ID Retrieval: The Logic4 user ID is determined based on the App4Sales sales representative. If a sales representative is provided, the system attempts to retrieve their Logic4 user ID from the
SalesRepsContext. Otherwise, it falls back to the configured 'Default user id' setting. If the default user ID is less than 2,000,000, it also considers a value fromApplicationSettings.Logic4UserId.Order ID from Backoffice: Upon successful order transmission, the connector expects an integer order ID from Logic4. If no ID is returned, an error indicating an unknown order number is returned to App4Sales.
Error Handling: Any exceptions during the order sending process are caught, and the exception message is returned to App4Sales, prefixed with a generic error indicator.
Address Parsing: The connector attempts to parse the `AddressLine1` field into separate street, house number, and house number addition components. If the parsing logic cannot distinctly identify these parts, the entire content of `AddressLine1` is used as the street.
Related Settings & Prerequisites
Default warehouse id which is used for stock (
DefaultWarehouseId): Configures the default warehouse ID to be used for order lines when sending orders to Logic4.Order status id for new orders (
OrderStatusId): Specifies the Logic4 order status ID that new orders from App4Sales will be assigned.Shipping method id used for sending orders (
ShippingMethodId): Defines the Logic4 shipping method ID to be used for orders sent from App4Sales.Default user id which should be used for retrieving data (
DefaultUserId): Serves as a fallback user ID when a sales representative cannot be mapped to a Logic4 user for an order.Map your reference to reference (
MapYourReferenceToReference): A boolean setting that, if enabled, maps the App4Sales 'YourReference' field to the Logic4 'Reference' field. Otherwise, the App4Sales 'Reference' field is used.Set order order date as delivery date (
OrderDateAsDeliveryDate): A boolean setting that, if enabled, uses the App4Sales order date for both the creation date and delivery date in Logic4. If disabled, the Logic4 creation date usesSysCreatedand the delivery date is set to null.