Profit Connector - ItemUpdate Function
The ItemUpdate function in the Profit Connector is responsible for synchronizing item data from the Profit ERP system into the App4Sales platform. This process involves retrieving various item-related details such as general item information, prices, stock levels, delivery dates, images, item classifications (ItemClasses, Free Fields, Assortments), and handling of matrix/variant items. The synchronized data is then mapped to App4Sales' internal item structure and updated in the App4Sales database. The function is designed to run periodically to keep item information up-to-date.
Data Source Configuration
The connector retrieves item data from the Profit system through various GetConnectors (APIs). The data is pulled from Profit and mapped to the App4Sales internal database objects.
General Item Information: Retrieved from Profit's item GetConnector, specifically
Routes.Get.ItemsorRoutes.Get.Items2. The choice between these two is controlled by the connector settingUseGetConnectorForSecondAdministration.Mapped Languages: Retrieved from
Routes.Get.MappedLanguage.Item Classes: Retrieved from Profit's item class GetConnector, specifically
Routes.Get.ItemClassesV1. The name of this GetConnector can be prefixed by the connector settingPrefixFreeFieldConnectorAndItemClasses. Additionally, ifItemDimensionFreeFieldsAndClassesis enabled, item class dimensions are retrieved fromRoutes.Get.ItemClassDimension.Free Fields: Retrieved from Profit's free field GetConnectors, specifically
Routes.Get.FreeFields1andRoutes.Get.FreeFields2. The names of these GetConnectors can be prefixed by the connector settingPrefixFreeFieldConnectorAndItemClasses. Additionally, ifItemDimensionFreeFieldsAndClassesis enabled, free field dimensions are retrieved fromRoutes.Get.FreeFieldDimension.Item Descriptions: Retrieved from
Routes.Get.DifferentLanguageItemDescriptions.Delivery Dates: Retrieved from the
DeliveryDateRepository.Item Prices: Retrieved via
GetAfasItemPrices(), which internally uses a Profit item price GetConnector (e.g.,Routes.Get.ItemPrices). This is active if the connector settingGetPriceListsis enabled.Sales Discounts per Price Group: Retrieved from
Routes.Get.SalesDiscount_per_PriceGroupif the connector settingCreatePriceListsOnDiscountgroupsis enabled. This data is used to dynamically create additional price lists.Item Pictures:
Single Pictures: Retrieved from
Routes.Get.ItemPictures.Multiple Pictures: Retrieved from
Routes.Get.MultiplePictures, with batching controlled bySettings.MultiplePicturesBatch.
Picture retrieval is conditional on
ExcludePicturesand the PIM settings.Item Stock: Retrieved from Profit's item stock GetConnector, specifically
Routes.Get.ItemStock. This occurs within theGetStockResultshelper method.Stock Period Information:
Stock Delivered: Retrieved from
Routes.Get.StockDelivered.Stock Received: Retrieved from
Routes.Get.StockReceived.
These are used within the
GetStockPeriodhelper method if the connector settingGetStockPeriodis enabled.Item Assortments: Retrieved from
Routes.Get.ItemAssortmentif the connector settingSetCustomerFixedItemFilteris enabled.Dimension Translations (for matrix items): Retrieved from
Routes.Get.DimensionTranslationif the connector settingUseMatrixTranslationsis enabled.
Data Mapping Table - Item Entity
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Direct mapping, whitespace trimmed. |
|
| Direct mapping. |
| Hardcoded | Set to "EUR". |
| Hardcoded | Set to 'E'. |
|
| Concatenation of these three fields, separated by " - ", from Profit. |
|
| Direct mapping, converted to decimal. This value can be overridden by an Action Price if identified. |
|
| Mapped from the item's creation date, converted from string to DateTime. |
|
| Mapped if connector setting |
|
| Direct mapping. |
|
| Direct mapping (typically represents barcode, GTIN, or UPC). |
|
| Calculated based on |
| Derived from | Calculated using a stock formula from various stock fields from Profit. If |
| Derived from | An integer value calculated based on the stock formula. |
|
| Initially set to the inverse of |
|
| Direct mapping. |
|
| Converted from string to integer. |
|
| Direct mapping. |
|
| Direct mapping. |
|
| The nearest future delivery date for the item is selected. This is active if |
| Derived from Price Lists | Set to |
Data Mapping Table - Item Classes
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| The key of the key-value pair representing the item class. |
|
| The value of the key-value pair, with transformations: "false" becomes "Nee", "true" becomes "Ja", dates formatted to "dd-MM-yyyy". |
| Hardcoded | Set to "Assortment" if |
|
| Direct mapping. |
|
| Can be constructed with dimensions based on |
Data Mapping Table - Free Fields
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
| Hardcoded | Set to "Free item info". |
|
| The key of the key-value pair representing the free field. Excludes "itemcode". |
|
| The value of the key-value pair, with transformations: "false" becomes "Nee", "true" becomes "Ja", dates formatted to "dd-MM-yyyy". Sanitized for XML. |
Data Mapping Table - Price Lists
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
| Derived from | Hash code generated from the price list code. |
|
| Base code is |
|
| If from Profit price list, direct mapping. For discount-based price lists, same as |
|
| Direct mapping from Profit price list. For default price list, uses the administration's currency symbol. |
| Application Settings | For default price list, uses the administration's currency symbol. |
| Hardcoded | For discount-based price lists, set to |
Data Mapping Table - Price List Prices
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Base is |
|
| Converted from string to decimal. If a sales discount is applied, the price is adjusted based on percentage or amount. Null prices are logged as warnings and skipped. |
| Derived from | Hash code generated from the price list code (same logic as |
Data Mapping Table - Item Pictures
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| For single pictures, Base64 string from |
|
| If |
Special Logic & Filters
Item Retrieval Strategy: The connector can retrieve items using two different Profit GetConnectors (
Routes.Get.ItemsorRoutes.Get.Items2) based on theUseGetConnectorForSecondAdministrationsetting. This allows for flexibility in handling multiple Profit administrations or specific data layouts.Price List Activation: Price list synchronization is only performed if the
GetPriceListssetting is enabled.Dynamic Price List Creation: If
CreatePriceListsOnDiscountgroupsis enabled, additional price lists are dynamically generated based on customer discount groups found in Profit. This involves retrieving customer and sales discount data. These dynamically created price lists are marked as non-selectable (Selectable = false) in App4Sales.Action Price Handling:
If an item has an "Action Price" (determined by a boolean flag in Profit's price data), its
SalesPricein App4Sales can be updated to this action price, and theIsActionItemflag is set totrue.If
RemovePricesForActionItemsis enabled, all specific price list entries for items identified as action items are removed, effectively forcing them to use a fallback price.A warning is logged if
DefaultPriceListForActionPriceis set but no matching price list is found in App4Sales.
Delivery Date Synchronization: Item delivery dates are only synchronized if the
SyncNextDeliveryDatesetting is enabled. The system identifies and stores the nearest future delivery date for each item.Item Dimension Handling:
If
UseItemDimensionsis enabled, the connector processes items with dimensions (variants). This affects how item codes are constructed for prices and stock.Images for matrix parents are handled separately, and matrix translations can be synchronized if
UseMatrixTranslationsis enabled.Item dimensions for free fields and item classes can be retrieved separately if
ItemDimensionFreeFieldsAndClassesis enabled.
Picture Retrieval:
Picture synchronization is bypassed if
ExcludePicturesis true or if App4Sales is configured to use images exclusively from a PIM system.Base64 decoding of images is handled with error catching; malformed images are skipped.
Multiple pictures for an item are retrieved in batches, with the batch size configurable via
MultiplePicturesBatch.
Stock Calculation:
If
GetStockPeriodAsLastAvailableStockis enabled, theLastAvailableStockis calculated using a complex formula that considers various stock figures from Profit.The
StockIndicatoris also derived from these calculations.Detailed stock period information (delivered and received stock for future weeks) is processed if
GetStockPeriodis enabled.CheckStockhelper ensures stock values are non-negative and correctly reflect "economic stock" where applicable.If
GetAllStockValuesFromProfitis true, the connector retrieves all stock values without filtering by item code, which might impact performance.
Item Assortments: If
SetCustomerFixedItemFilteris enabled, item assortments from Profit are mapped as ItemClasses in App4Sales, potentially at the parent or variant level based onSetAssortmentOnParentLevel.Data Cleaning/Validation:
Whitespace is trimmed from item codes.
"false" / "true" strings are converted to "Nee" / "Ja" for certain fields.
Dates are formatted to "dd-MM-yyyy" where appropriate.
Duplicate free fields are removed.
XML serialization is used for free item fields, implying string sanitization.
Domain Specifics (Expanded)
Price Logic
The connector processes item pricing from Profit, including base sales prices, price lists, and discounts.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Directly mapped from Profit's sales price. Can be overridden by an action price if configured. |
|
| Calculated based on VAT group and connector settings. Fallback to default application VAT rates if specific settings are zero. |
|
| Initially the inverse of Profit's discount allowed flag. Can be overridden to |
Price Lists (`PriceList`) and Price List Prices (`PriceListPrice`) Mapping:
Refer to the "Data Mapping Table - Price Lists" and "Data Mapping Table - Price List Prices" sections for detailed field mappings.
Default Price List: A default price list with code "*****" and description "Default" is created if not already present.
Currency-Based Price Lists: If
PriceListBasedOnCurrencyCodeis enabled, price lists are created uniquely per currency code.Discount Group Price Lists: If
CreatePriceListsOnDiscountgroupsis enabled, price lists are generated based on customer discount groups. These price lists are not selectable in App4Sales.Action Prices: Items identified with action prices can have their main sales price overridden, and the
IsActionItemflag is set. IfRemovePricesForActionItemsis true, all specific price list entries for these items are removed.
Image Handling
The connector supports synchronizing single and multiple images for items from Profit.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Image data (Base64 string) from Profit is decoded to byte arrays. Images are added with a hash check to prevent duplicates. |
Matrix Parent Image |
| If |
Conditional Sync: Image synchronization is skipped if
ExcludePicturesis true or if App4Sales is configured to use an external PIM system for images.Base64 Encoding: Images are expected to be Base64 encoded strings in Profit. Decoding errors are caught, and affected images are skipped.
Batch Processing: Multiple images are fetched and processed in configurable batches (
MultiplePicturesBatch).
Stock & Availability
The connector retrieves various stock figures from Profit and calculates the available stock and stock indicator for App4Sales.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Calculated based on a formula using various stock components from Profit. Uses |
| Derived from stock calculations | An integer value representing the stock status, calculated based on the available stock. |
Detailed Stock Retrieval: If
GetStockPeriodAsLastAvailableStockis enabled, the available stock is calculated using a formula that aggregates "Shelf Stock", "To Be Delivered", and "To Be Received" quantities.Stock Period Overview: If
GetStockPeriodis enabled, the connector provides a weekly overview of stock movements (deliveries and receipts).Dimension-Specific Stock: If
UseItemDimensionsis enabled, stock can be tracked and displayed at the individual item dimension level.Stock Filters: Stock data can be filtered by item code and dimensions. The
GetAllStockValuesFromProfitsetting can disable these filters, retrieving all stock data.Negative Stock Handling: The
CheckStockhelper ensures that stock values do not fall below zero, displaying 0 in such cases. It also accounts for "economic stock".
Matrix & Attributes
The connector handles matrix items (variants) by recognizing parent-child relationships and mapping various attributes.
App4Sales Field | Source Field (API/Excel/DB) | Logic/Notes |
|
| Mapped from Profit's item class data. Assortments can also be mapped as item classes. Values can be transformed (e.g., "true" to "Ja"). |
|
| Mapped from Profit's free field data, excluding "itemcode". Values can be transformed and are XML serialized. |
Matrix Item Identification: Matrix items are identified by the presence of
HeaderId,MatrixChildId, andMatrixParentIdin the App4SalesItemobject, often indicated by specific patterns in the item code (e.g.,PARENTCODE_DIMENSION1_DIMENSION2).Dimension Mapping: Item dimensions affect how price list entries and stock records are associated with specific variants.
Matrix Translations: If
UseMatrixTranslationsis enabled, translations for matrix headers and children are fetched from Profit and updated in App4Sales, enabling localized display of variant attributes.Parent-Level Assortments: The
SetAssortmentOnParentLevelsetting controls whether item assortments are applied to the main parent item or to individual variants when dimensions are in use.
Related Settings & Prerequisites
UseGetConnectorForSecondAdministration: (Boolean) If enabled, uses an alternative Profit GetConnector for retrieving items.AssignItemPriceToAnItem: (Boolean) If enabled, allows assignment of specific item prices based on a dedicated Profit field.GetPriceLists: (Boolean) Enables synchronization of price lists and item prices from Profit.CreatePriceListsOnDiscountgroups: (Boolean) If enabled, price lists are dynamically created in App4Sales based on customer discount groups from Profit. RequiresGetPriceListsto be true.RemovePricesForActionItems: (Boolean) If enabled, price list entries for items marked as "action items" will be removed.DefaultPriceListForActionPrice: (String) Specifies the code or description of a default price list to consider for action prices.SyncNextDeliveryDate: (Boolean) Enables synchronization of next available delivery dates for items.ItemDimensionFreeFieldsAndClasses: (Boolean) If enabled, separate item class and free field dimensions are retrieved from Profit.ExcludePictures: (Boolean) If enabled, item picture synchronization is skipped entirely.UseItemDimensions: (Boolean) Enables the processing of items with dimensions (variants), impacting how prices, stock, and images are handled.GetStockPeriodAsLastAvailableStock: (Boolean) If enabled,LastAvailableStockis calculated using a formula involving various stock fields from Profit.SetDiscountAllowedBasedOnPriceLists: (Boolean) If enabled, an item's ability to accept default discounts is determined by its association with action price lists.SetCustomerFixedItemFilter: (Boolean) If enabled, item assortments from Profit are synchronized as item classes.MultiplePictures: (Boolean) If enabled, the connector attempts to retrieve multiple pictures per item.MultiplePicturesBatch: (Integer) Defines the batch size for retrieving multiple pictures. A value of 0 processes all at once.PrefixFreeFieldConnectorAndItemClasses: (String) A prefix applied to GetConnector names for item classes and free fields.SetPurchasePackageSize: (Boolean) If enabled, the purchase package size is mapped from Profit.VatPercentageForVatliableGroup1: (Decimal) Custom VAT percentage for Profit VAT group "1".VatPercentageForVatliableGroup2: (Decimal) Custom VAT percentage for other Profit VAT groups.GetAllStockValuesFromProfit: (Boolean) If enabled, retrieves all stock values from Profit without item code filtering, potentially impacting performance.GetStockPeriod: (Boolean) If enabled, detailed stock period information (delivered and received quantities) is synchronized.UseMatrixTranslations: (Boolean) If enabled, translations for matrix headers and children are synchronized.SetAssortmentOnParentLevel: (Boolean) Controls whether item assortments are applied to the parent item or individual variants when dimensions are in use.PIM Integration: If App4Sales is configured to use images exclusively from an external PIM system (
AdministrationSession.CurrentSession.PimSettings.UseImagesOnlyFromPIM), image synchronization via the connector is skipped.Profit GetConnectors: The Profit environment must have the necessary GetConnectors configured and accessible for the various data points (items, prices, stock, images, etc.).
Known Limitations
Limited Barcode Mapping: Only a single EAN Code is explicitly mapped; support for multiple barcodes or alternative barcode types is not apparent.
Hardcoded Currency: The primary item currency is hardcoded to "EUR" for basic item information, though specific price lists can carry different currencies.
Generic Stock Formula: The documentation references a "stock formula" for calculating
LastAvailableStockandStockIndicator, but the specifics of this formula are abstracted and not detailed in this documentation.Performance with Full Stock Sync: Enabling
GetAllStockValuesFromProfitcan lead to performance degradation as it retrieves all stock data without filtering.Date Created as Last Modified:
Sysmodifiedin App4Sales maps toProfitItemBase.DateCreated. This implies that the last modification date in App4Sales reflects the creation date in Profit, not necessarily the last actual modification date.Absence of Explicit Categories: There is no direct mapping for a generic "ItemCategory" field; categories appear to be handled implicitly via "ItemClasses" (e.g., assortments).