SnelStart Connector - Send Order To Backoffice
The SendOrderToBackoffice function in the SnelStart connector is responsible for taking an App4Sales order and transmitting it to the SnelStart ERP system. It handles the conversion of order header information, order lines, and applies discounts before sending the order to SnelStart. Upon successful transmission, it updates the App4Sales order with the order number provided by SnelStart.
Data Source Configuration
The primary data source is the App4Sales order object. The connector also utilizes configuration settings from Administrations.ConnectorSettings.SnelStart (referred to as 'Settings'), country lookup data via LookupCountry, and pre-fetched SnelStart order templates (SnelStartOrderTemplate) to prepare the order for transmission. Data is pushed to the SnelStart API.
Data Mapping Table - Order Header
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
DeliveryAddress |
| Mapped via |
InvoiceAddress |
| Mapped via |
Description |
| Direct mapping. |
PaymentReference |
| Direct mapping. |
CustomerId |
| The |
OrderDate |
| Direct mapping. |
ModifiedOn |
| Set to the current timestamp when the order is sent. |
VatType |
| Hardcoded: Orders are always sent with prices excluding VAT to SnelStart. |
OrderLines |
| Mapped via |
Type |
| The |
Notes |
| Direct mapping. |
TemplateId |
| Derived from the |
Data Mapping Table - Delivery Address
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Street |
| Direct mapping from the alternate address. |
PostalCode |
| Direct mapping from the alternate address. |
City |
| Direct mapping from the alternate address. |
CountryId |
| Looks up the SnelStart country ID based on the ISO2 code from the alternate address using |
ContactName |
| If |
Data Mapping Table - Invoice Address
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Street |
| Direct mapping from the customer's main visit address. |
PostalCode |
| Direct mapping from the customer's main visit address. |
City |
| Direct mapping from the customer's main visit address. |
CountryId |
| Looks up the SnelStart country ID based on the ISO2 code from the customer's main visit address using |
ContactName |
| If |
Data Mapping Table - Order Lines
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
Description |
| If |
ItemId |
| The |
Quantity |
| Direct mapping. If |
UnitPrice |
| If |
DiscountPercentage |
| If |
Special Logic & Filters
Webshop Discount:
order.ApplyWebshopDiscountOnOrderLines(Constants.Client.Portal4Sales)applies discounts specific to the webshop to each order line before the order is converted.Order Type and Template Selection: The
order.OrderType.ValueToBackofficesetting in App4Sales allows administrators to specify both the SnelStart order type (e.g., "Order", "Quote") and an optional SnelStart order template ID. The template is resolved from pre-fetchedSnelStartOrderTemplateentities.VAT Type: The
VatTypeis always set toSnelStartVatType.Exclusief, indicating that all prices are sent excluding VAT to SnelStart. SnelStart is expected to handle the VAT calculation.Customer Discount Compensation: The
GetItemPricehelper function adjusts the order line price to compensate for customer discounts. This prevents SnelStart from applying the discount twice, as SnelStart treats customer discounts as "invoice discounts" rather than "order line discounts." Items identified as shipping costs are exempt from this discount compensation.Error Handling: If the API
Postoperation to SnelStart encounters an error, the method returns a descriptive error string.Order Number Update: Upon successful order creation in SnelStart, the returned SnelStart
OrderNumberis used to update the corresponding App4Sales order's internal order ID.
Domain Specifics
Order Header Logic
Customer Selection: The App4Sales
CustomerCodeis used to retrieve the corresponding internal SnelStart customer ID (GUID) for the order.Numbering: Order numbers are generated by SnelStart. The connector updates the App4Sales order with this external SnelStart order number.
Order-Type Routing: The
ValueToBackofficeproperty of the App4Sales order type dictates the SnelStart order type (e.g., "Order", "Quote") and can optionally specify a SnelStart order template by using a colon-separated value (e.g., "Order:StandardTemplate").Payment/Shipping Fields: The
PaymentReferencefield is mapped fromorder.YourReference. Delivery and Invoice addresses are derived from alternate addresses and customer main addresses respectively, with country lookups and contact name logic applied.
Line & Pricing Logic
Source fields for items: The App4Sales
orderLine.Item.InternalItemCodeis used to identify the item in SnelStart. The line description is constructed fromorderLine.Item.Descriptionand optionallyorderLine.Instruction.Quantities: The
orderLine.Quantityfrom App4Sales is directly mapped to the SnelStart order line quantity.Prices: The unit price sent to SnelStart depends on the
SendDiscountInsteadOfPricesetting. It can either be the originalorderLine.Item.SalesPriceor a calculated price that has been adjusted to account for customer discounts to prevent double discounting.Discounts: The
DiscountPercentageis either explicitly calculated (ifSendDiscountInsteadOfPriceis true) or set to 100% if the effective line price is zero to ensure SnelStart doesn't apply a default sales price.VAT Adjustments: All order prices are transmitted as excluding VAT, with SnelStart responsible for applying the correct VAT rates.
Charges & Attachments
Freight/Payment Surcharges: Items configured as shipping costs within App4Sales are handled specifically; their prices are transferred without the customer discount compensation that applies to regular product lines. This ensures shipping costs are not inadvertently discounted.
PDF/JSON Exports: The current implementation of the
SendOrderToBackofficemethod does not include explicit logic for handling or transmitting PDF/JSON exports, signature images, or other attachments alongside the order to SnelStart.
Responses & Error Handling
Returned Order Numbers: After successfully posting an order to SnelStart, the ERP returns a unique order number. This number is then used to update the corresponding order record within the App4Sales system.
Duplicate Detection: The provided code does not explicitly contain logic for detecting duplicate orders before submission to SnelStart. Errors reported by the SnelStart API are directly returned by the connector.
Retry/Backoff Strategies: The
SendOrderToBackofficemethod does not implement automated retry or backoff strategies in case of transient API errors.
Related Settings & Prerequisites
Send discount instead of price: This setting (
Administrations.ConnectorSettings.SnelStart.SendDiscountInsteadOfPrice) controls whether the connector sends the actual unit price or the original sales price along with a separate discount percentage for each order line.Order Templates: If the
ValueToBackofficeproperty of an App4Sales order type specifies a SnelStart template (e.g., "Order:MyTemplate"), that template must exist and be correctly configured within SnelStart for the order to be processed as intended.
Known Limitations
The connector explicitly sends all order prices to SnelStart excluding VAT. SnelStart is expected to handle the calculation and application of VAT based on its internal configuration.
There is no explicit functionality within the
SendOrderToBackofficemethod for transmitting attachments (such as PDFs, XML files, signature images, or other supplementary documents) to SnelStart alongside the order.The order sending process does not include explicit logic for detecting and preventing duplicate order submissions to SnelStart.