Profit Connector - Live Stock
This document describes how the Profit connector retrieves and calculates live stock information. This functionality is triggered when a user views item details or validates an order in the App4Sales application.
Activation & Sources
The live stock functionality is implemented in the OptA4SGetStockForItem method within the Profit connector. The data is fetched from the AFAS Profit ERP system using specific "GetConnectors" (web services).
Data Source | GetConnector Name | Description |
Live Stock |
| Retrieves real-time stock quantities for a given item. |
Future Stock (Deliveries) |
| Retrieves planned deliveries for items, used for future stock calculations. |
Future Stock (Receipts) |
| Retrieves planned receipts of items, used for future stock calculations. |
Warehouses |
| Retrieves warehouse information. |
Request & Settings
The request to the backoffice contains the item code for which the stock is requested. Several connector settings can influence the behavior of the live stock retrieval:
Setting | Description | Default | Impact on stock |
| If enabled, the stock is retrieved for a specific item variant (dimension). | false | When enabled, the stock of a specific matrix variant is shown, otherwise the stock of the main item is shown. |
| If enabled, the connector fetches all stock for all items at once, which can be slow. | false | This setting can cause performance issues and timeouts in large environments. |
| If enabled, the connector calculates future stock levels for the upcoming weeks. | false | When enabled, the app will show not only the current stock, but also the projected stock for the upcoming weeks. |
Calculation Logic
The connector calculates the available stock using the following logic:
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| The available stock is calculated with the formula: |
Future Stock |
| If |
Output & UX
The live stock information is displayed in the App4Sales application on the item detail screen. The user will see the current available stock, and if enabled, the future stock levels. If an error occurs during stock retrieval, a "No backoffice" error is shown.
Error Handling
Scenario | Behavior | User impact |
AFAS Profit API is unreachable | The connector will throw an exception. | The user will see a "No backoffice" error message in the app. |
Item not found in AFAS Profit | The connector will return an empty result. | The user will see a stock level of 0 in the app. |