Skip to main content

Csv - Send order

CSV Connector - Send Order This document describes how the CSV connector processes and exports App4Sales orders. The connector can generat...

Updated over a week ago

CSV Connector - Send Order

This document describes how the CSV connector processes and exports App4Sales orders. The connector can generate a CSV file in two different formats, depending on the configuration. The generated CSV file contains the order header and order line information. The export can be a "standard" fixed-format export, or a "custom" export that is configurable via a template in App4Sales.

Data Source Configuration

The order data is retrieved from the App4Sales database. The output is a CSV file. The connector does not send the file to a specific location. Instead, it generates the CSV content as a byte array, which is then handled by the App4Sales framework to be downloaded by the user or sent to an FTP server, depending on the context of the action.

Data Mapping

There are two possible export formats, controlled by the 'Download custom CSV export' setting.

Standard CSV Export

This export is used when the 'Download custom CSV export' setting is disabled. It generates a CSV file with 'HEAD' records for orders and 'LINE' records for order lines.

Order Header (HEAD)

Order Header (HEAD)

Order Header (HEAD)

CSV Column

Source Field

Logic/Notes

1

"HEAD"

A hardcoded value indicating that the record is an order header.

2

Order.OrderNr

The order number.

3

Order.Customer.CustomerCode

The code of the customer who placed the order.

4

Order.OrderDate

The date of the order, formatted as 'dd-MM-yyyy'.

5

Order.Customer.CustomerName

The name of the customer.

6

Order.OrderType.ValueToBackoffice

The backoffice value of the order type.

Order Lines (LINE)

Order Lines (LINE)

Order Lines (LINE)

CSV Column

Source Field

Logic/Notes

1

"LINE"

A hardcoded value indicating that the record is an order line.

2

(sequential)

A sequential number for each line, starting from 1.

3

OrderLine.ItemCode

The item code for the ordered item.

4

OrderLine.Quantity

The ordered quantity, formatted to 3 decimal places.

5

OrderLine.Price

The price per unit, formatted to 3 decimal places.

6

OrderLine.Unit

The unit of the ordered item (e.g., 'piece', 'box').

7

OrderLine.Discount

The discount percentage for the order line, formatted to 3 decimal places.

8

OrderLine.Description

The description of the order line.

9

OrderLine.Instruction

Any special instructions for the order line.

10

OrderLine.Item.EanCode

The EAN code of the item.

Custom CSV Export

This export is used when the 'Download custom CSV export' setting is enabled. The structure of this export is not fixed and is determined by an export definition template that can be configured in the App4Sales portal. The following fields are prepared by the connector and can be used in the template.

Order Header

Order Header

Order Header

App4Sales Field

Source Field

Logic/Notes

UID

Order.OrderID

The internal ID of the order.

Customer

Order.Customer.CustomerName

The name of the customer.

OrderDate

Order.OrderDate

The date of the order.

SysCreated

Order.SysCreated

The creation date of the order in the database.

SubTotal

Order.TotalAmount

The total amount of the order. Defaults to 0 if not set.

CurrencyFormat

PriceList.Currency

The currency is retrieved from the customer's assigned pricelist.

CustomerCode

Order.Customer.CustomerCode

The code of the customer.

YourRef

Order.YourReference

The customer's reference for the order.

CustomerRef

Order.Reference

The internal reference for the order.

SalesRep

Order.Salesrep

The sales representative for the order.

Delivered

Order.Delivered

Indicates if the order has been delivered.

Source

Order.Source

The source of the order. The value "Mood4Sales" is replaced with "App4Customers".

Note

Order.Notes

The notes for the order.

ErrorMessage

Order.ErrorMessage

Any error message associated with the order.

OrderType

Order.OrderType.Name

The name of the order type.

Order Lines

Order Lines

Order Lines

The fields for order lines in the custom export are not predefined in the connector. Instead, they are based on the export definition configured in the App4Sales portal. All fields from the OrderLine model are available for mapping in the template.

The fields for order lines in the custom export are not predefined in the connector. Instead, they are based on the export definition configured in the App4Sales portal. All fields from the OrderLine model are available for mapping in the template.

The fields for order lines in the custom export are not predefined in the connector. Instead, they are based on the export definition configured in the App4Sales portal. All fields from the OrderLine model are available for mapping in the template.

Domain Specifics

Order Header Logic

The header data is mapped differently based on the 'Download custom CSV export' setting. The standard export uses a fixed set of fields, while the custom export provides a richer set of data that can be mapped in a template.

Line & Pricing Logic

For the standard export, `Quantity`, `Price`, and `Discount` are formatted to 3 decimal places. For the custom export, the line mapping is entirely controlled by the export definition in App4Sales, and values are taken directly from the order lines.

Charges & Attachments

The analyzed code does not show any specific handling for charges (surcharges) or attachments. These are likely not supported by this connector's order export.

Responses & Error Handling

The connector's role is to generate a CSV file for export. It does not handle responses from an ERP system. If an order does not have a customer assigned, the export process will fail with an error.

Related Settings & Prerequisites

The following setting affects the order export process:

  • Download custom CSV export: A checkbox in the connector settings. If checked, the custom export format is used, which relies on a `CsvExportDefinition` template configured in the portal. If unchecked, the standard, fixed-format CSV is generated.

Known Limitations

  • The connector does not appear to support charges or attachments for orders.

  • The standard export format is rigid and includes a fixed set of columns in a specific order. Customizations require using the custom export feature.

  • The `SendOrderToBackoffice` implementation in this connector is a basic placeholder and is not involved in the CSV generation process. The actual logic resides in the `GetOrdersExportData` method, which is called during the file export process.

Did this answer your question?