EzXml Connector - Send Order To Backoffice
The EzXml connector is responsible for transferring App4Sales orders to an external ERP system, typically via FTP. This process involves preparing the order data, converting it into a specific XML or CSV format based on connector settings, generating a unique order number, and then uploading the formatted order file to a predefined FTP folder. The system handles order headers, order lines, and freight costs, ensuring data is normalized for compatibility with the EzXml system.
Data Source Configuration
The primary data source for sending orders is the internal App4Sales OrderDb object, which encapsulates all details of an order placed within App4Sales. The prepared order data is then transmitted as a file (XML or CSV) to a configured FTP server.
Source: Internal App4Sales
OrderDbobject.Target: An FTP server directory specified by the
FtpOrderExportFoldersetting.Format: Can be XML (default and Reflecta) or CSV, determined by the
OrderFormatconnector setting.
Data Mapping Table - Order Header (Default XML Format)
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Unique order number generated by the connector, combining order type and a sequential numeric ID. |
|
| If |
| Hardcoded | Hardcoded value: "Default". |
|
| Direct mapping. |
|
| Direct mapping. |
|
| The latest delivery date found among all order lines. |
|
| Direct mapping from the associated customer. |
|
| Direct mapping from the associated customer. |
|
| Direct mapping from the associated customer. |
|
| Direct mapping from the associated customer. |
|
| Full name of the main contact person for the customer. |
|
| Direct mapping. |
|
| Direct mapping. |
|
| Consumer name if provided. |
|
| Consumer email if provided. |
|
| Consumer phone number if provided. |
|
| First line of the alternate delivery address. |
|
| Postal code of the alternate delivery address. |
|
| City of the alternate delivery address. |
|
| State/province of the alternate delivery address. |
|
| ISO2 country code of the alternate delivery address. |
|
| "1" if an alternate delivery address is provided, "0" otherwise. |
|
| Total order amount excluding VAT, rounded to 2 decimal places. |
|
| Total VAT amount for the order, rounded to 2 decimal places. |
|
| Total order amount including VAT, rounded to 2 decimal places. |
|
| Freight costs including VAT, rounded to 2 decimal places. |
|
| Hardcoded to "7" (for Mollie) if the order is marked as paid. Otherwise, |
|
| If the order is marked as paid, the payment ID is retrieved from |
|
| Hardcoded to "SUCCESS" if the order is marked as paid. Otherwise, |
Data Mapping Table - Order Lines (Default XML Format)
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
| Loop index | Sequential ID for each line, starting from 0. |
|
| Order line quantity. Rounded to a whole number before mapping. |
|
| Direct mapping. |
|
| Direct mapping. |
|
| If |
| Calculated | Same as the calculated |
| Calculated | Same as the calculated |
|
| Calculated as the product of the line's price and quantity, formatted using invariant culture. |
|
| EAN code of the item. |
|
| VAT percentage for the line, rounded to 2 decimal places. |
|
| Direct mapping. |
|
| Item code for the variant. |
|
| Description of the item model. |
|
| Last available stock for the item, rounded to 2 decimal places. |
| Calculated | Same as the calculated |
| Hardcoded | Hardcoded value: 0. |
|
| If the item is a matrix child, its color description is mapped. |
|
| If the item is a matrix child, its style number is mapped. |
|
| If the item is a matrix child, its color sorting sequence is mapped. |
Data Mapping Table - Order (CSV Format)
For the CSV format, header-level information is duplicated on each order line.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| If |
|
| Current date and time, formatted as "yyyyMMdd HH:mm". |
|
| Direct mapping. |
|
| Direct mapping. |
| Hardcoded | Hardcoded value: "Inv". |
|
| First line of the alternate delivery address. |
|
| Second line of the alternate delivery address. |
|
| City of the alternate delivery address. |
|
| Postal code of the alternate delivery address. |
|
| ISO2 country code of the alternate delivery address. |
|
| State/province of the alternate delivery address. |
|
| Uses consumer email if available, otherwise customer email. |
|
| Uses consumer name if available, otherwise customer name. |
|
| Direct mapping. |
|
| Direct mapping. |
|
| Total order amount excluding VAT. |
|
| Total order amount including VAT. |
| Hardcoded | Hardcoded as an empty string. |
|
| Total VAT amount for the order. |
|
| Total order amount excluding invoice discount (same as total excluding VAT). |
|
| Item code for the variant. |
|
| Order line quantity. Rounded to a whole number before mapping. |
|
| Direct mapping. |
|
| Order line price. Rounded to 2 decimal places and adjusted for VAT before mapping. |
|
| Calculated as quantity multiplied by price. |
|
| If the item is a matrix child, its color description is mapped. |
|
| If the item is a matrix child, its style number is mapped. |
Data Mapping Table - Order Header (Reflecta XML Format)
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| If |
|
| Mapped from connector settings. |
|
| Mapped from connector settings. |
|
| Mapped from connector settings. |
|
| Mapped from connector settings. |
|
| Formatted as "dd-MM-yyyy". |
|
| Direct mapping. |
|
| Uses ISO currency code from the customer's price list if available, otherwise the general currency code from the price list. |
|
| Direct mapping. |
|
| Direct mapping. |
|
| Mapped from connector settings. |
|
| Mapped from connector settings. |
|
| Mapped from connector settings. |
|
| If |
|
| Shipping costs excluding VAT, formatted to "0.00". |
Address Fields (within Header) |
| If an alternate address is present, these fields are populated from it, with street, house number, and addition parsed from |
Data Mapping Table - Order Lines (Reflecta XML Format)
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
| Loop index | Sequential line number, starting from 1. |
|
| Direct mapping of the item code. |
|
| Ordered quantity. Rounded to a whole number before mapping. |
|
| Sales price amount. Rounded to 2 decimal places and adjusted for VAT before mapping. |
Special Logic & Filters
Data Normalization: All total amounts, VAT amounts, sub-totals, and individual line prices/quantities are rounded to 2 decimal places. Order line quantities are further rounded to whole numbers due to EzXml system limitations.
Order Number Generation: A unique order number is generated by combining the order type (defaulting to "Default" or "Inv" for CSV) with a sequentially incremented numeric order ID. The numeric ID is managed to ensure it always increases, even across system restarts or if external systems assign numbers.
Price Calculation: For default XML and Reflecta, if a price excluding VAT is not explicitly provided, and the original price includes VAT, the price is recalculated to remove the VAT component, ensuring the exported price is always exclusive of VAT.
Conditional Formatting: The output format (Default XML, CSV, or Reflecta XML) is dynamically selected based on the
OrderFormatconnector setting.Alternate Address Parsing: For the Reflecta XML format, if an alternate delivery address is provided,
AddressUtils.ParseAddressis used to extract street, house number, and addition from the first address line.Consumer vs. Customer Data: For certain fields like Email, Name, and Phone in CSV and Reflecta formats, consumer-provided values (from
OrderDb.ConsumerEmail, etc.) are prioritized over the general customer contact information.Matrix Item Enrichment: For default XML and CSV formats, if an order line item is a matrix child, additional details such as
Color,StyleNumber/StyleNo, andColorSortingare populated from theMatrixChildrenContext.
Domain Specifics
Order Header Logic
Order Numbering: The generated order number can optionally use an internal order number from App4Sales if the
UseInternalOrdersAsWebOrderNrsetting is enabled. Otherwise, a sequentially generated number prefixed by the order type is used.Order Type Routing: The default XML format uses "Default" as the order type, while the CSV format hardcodes "Inv". The Reflecta format uses connector settings for
OrderOriginCode,SeasonCode, andSalesDepartmentCodeto categorize the order.Payment Information: For the default XML format, if an order is paid, the
PaymentmethodIdis hardcoded to "7" (for Mollie), and thePayment_idis retrieved fromPaymentDetailsContext. ThePaidfield is set to "SUCCESS".Delivery Terms (Reflecta): The
SalDeliveryTermCodeis conditionally set based on whether shipping costs are present and if a specific delivery term code for zero shipping costs is configured.
Line & Pricing Logic
Quantity Handling: All order line quantities are rounded to whole numbers before being sent to the EzXml system, as it does not support decimal quantities.
Price Precision: All prices (unit, sales, list) are rounded to 2 decimal places to meet EzXml system requirements.
VAT Adjustment: Prices are consistently adjusted to be exclusive of VAT when sent to the external system, even if the original App4Sales price included VAT.
Discount Representation: In the default XML format, the
GivenDiscountAmountfor order lines is currently hardcoded to 0. In CSV and Reflecta, direct discount fields are present at the line level.Matrix Items: Detailed matrix item attributes like color and style are exported in default XML and CSV formats, enhancing product identification.
Charges & Attachments
Freight Costs: Freight charges are mapped as
Freight_costs(including VAT) in the default XML format andFreightChargesAmt(excluding VAT, formatted to "0.00") in the Reflecta XML format.Other Charges: There is no explicit mapping for other types of surcharges or charge lines beyond freight costs in the reviewed code.
Attachments: The reviewed code does not show explicit handling or mapping for attachments (e.g., PDFs, images) to be sent alongside the order.
Responses & Error Handling
Order Number Update: Upon successful transmission, the App4Sales internal order is updated with the generated external order number.
Last Order Number Persistence: The last used numeric order number is saved and persisted via
KeySettingsContextto ensure continuity in order number generation.Error Logging: Exceptions during the send order process are caught and logged, returning a generic
ERROR_Unhandledmessage to App4Sales. The specific external system response for order numbers, quote numbers, or other status indicators is not directly parsed and mapped within the converters themselves but would be handled at a higher level if returned by the FTP process.
Related Settings & Prerequisites
The following connector settings influence the behavior of the "Send Order To Backoffice" function:
OrderFormat: Determines the output format of the order file (e.g., "CSV", "Reflecta", or default XML).UseInternalOrdersAsWebOrderNr: (Boolean) If true, uses the App4Sales internal order number as the primary order identifier in the external system.FtpOrderExportFolder: (String) The specific FTP directory where the generated order files will be uploaded. Defaults to "export" if not specified.ReflectaProviderCode: (String, only for Reflecta format) Code identifying the provider in Reflecta.ReflectaContextCode: (String, only for Reflecta format) Code identifying the context in Reflecta.ReflectaCompanyCode: (String, only for Reflecta format) Code identifying the company in Reflecta.ReflectaWarehouseGroupCode: (String, only for Reflecta format) Code identifying the warehouse group in Reflecta.ReflectaOrderOriginCode: (String, only for Reflecta format) Code identifying the origin of the order in Reflecta.ReflectaSeasonCode: (String, only for Reflecta format) Code identifying the season in Reflecta.ReflectaSalesDepartmentCode: (String, only for Reflecta format) Code identifying the sales department in Reflecta.ReflectaDeliveryTermCode: (String, only for Reflecta format) The default delivery term code for Reflecta orders.ReflectaDeliveryTermCodeWhenTheOrderHasNoShippingCosts: (String, only for Reflecta format) A specific delivery term code to use when an order has no shipping costs.
Known Limitations
Payment Method Support (Default XML): Only Mollie is explicitly supported for payment method identification, with a hardcoded ID "7". Support for other payment methods is not apparent.
Discount Granularity (Default XML): The
GivenDiscountAmountfor individual order lines in the default XML format is always 0, indicating that item-level discounts might not be fully transferred or interpreted by the EzXml system.Shipment Date (CSV): The
ShipmentDatefield in the CSV format is always an empty string.Order Type (CSV): The
OrderTypefield in the CSV format is hardcoded to "Inv".Limited Line Details (Reflecta XML): The Reflecta XML format contains fewer details per order line compared to the default XML, lacking explicit fields for discount percentage, VAT percentage, or extensive item descriptions beyond the item code.
Missing Charges/Attachments Handling: Beyond freight costs, there is no explicit handling or mapping for other types of surcharges, charge lines, or attachments (e.g., PDFs, images) within the reviewed order conversion logic for any format.
Response Detail: The connector logs unhandled exceptions during the send process, but the current implementation doesn't appear to parse and map detailed ERP-specific order acknowledgment responses (like external order numbers or specific error messages beyond a generic "unhandled error") back into App4Sales. The generated order number is the primary identifier updated in App4Sales.