Profit Connector - Send Order to Backoffice
The SendOrderToBackoffice function is responsible for processing and transmitting App4Sales orders to the Profit ERP system. This includes handling order headers, order lines, alternative delivery addresses, and conditional routing for quotations or direct delivery notes. The process ensures data consistency by applying decimal precision to prices and validating warehouse permissions based on order line instructions. The function supports sending both sales orders and quotations and can optionally create a delivery note in Profit after an order has been successfully sent.
Data Source Configuration
The connector retrieves order data from the internal App4Sales database objects (Order object). It interacts with the Profit ERP system via various update connectors and get connectors for data retrieval and submission. Specific configuration settings within the connector control aspects like alternative address creation, order line instruction processing, and delivery note creation.
Special Logic & Filters
Alternative Address Handling
The system attempts to retrieve or create a delivery address in Profit for the order's alternative address.
If the setting Create alternative address (of an order) on the customer is enabled and an alternative address is provided with the order:
The system first checks if the alternative address already exists in the system.
If the address is new, it will be added to Profit, and the identifier will be associated with the order.
If there is an error during the process of adding a new delivery address, the order will not be accepted, and an error message will be returned.
The retrieved or newly created address identifier is then assigned to the
AddressIdproperty of the order's alternative address.
Order Line Instructions and Warehouse Permissions
The connector processes instructions embedded within the order lines. If the setting Set orderline property on instruction is enabled:
Instructions starting with "War:" are interpreted as warehouse codes.
The system verifies that the sales representative associated with the order has permission to use the specified warehouse.
If permissions are insufficient, the order submission is aborted, and an error message indicating the lack of warehouse permission is returned.
Price Decimal Precision
To prevent errors related to excessive decimal places in Profit (e.g., "Too many digits to the right of the decimal point for field 'Prijs per eenheid'"), if the Decimal Precision Prices setting (configured in the general Connector Base Settings) is greater than zero, all prices on order lines are automatically rounded to the specified number of decimal places before being sent to Profit.
Order Type Routing
The system routes orders based on their type:
Skip Order: If the order type is configured to skip the order creation process (e.g., designated as 'DeliveryNoteSkipOrder'), the order is converted directly into a delivery note and sent to Profit. The resulting delivery note number or an error message is returned.
Quotation: If the order is identified as a quotation, it is transmitted to Profit as a sales quotation.
Standard Order: All other order types are sent to Profit as standard sales orders.
Post-Order Delivery Note Creation
After a sales order has been successfully sent to Profit, a delivery note may be created under the following conditions:
If the setting Create a delivery note in Profit only for Portal4Sales is enabled AND the order originated from the Portal4Sales application.
OR if the order type is specifically configured to create a delivery note.
This additional step is only performed if the initial order submission to Profit was successful.
If an error occurs during the creation of this subsequent delivery note, an error message will be returned indicating that the order was sent, but the delivery note creation failed.
SendSalesEntry Method
The SendSalesEntry method is a generic function used for transmitting both sales orders and quotations to Profit. Its main steps are:
Duplicate Check: It first checks if an order or quotation with the same unique identifier (
OrderGuid) already exists in Profit. This prevents the creation of duplicate sales entries.Transmission: If no existing entry is found, the relevant order or quotation data is sent to Profit using the designated update connector.
Response: Upon successful transmission, the Profit order number is returned. In case of an error during transmission, an appropriate error message is returned.