Skip to main content

NewBase - Item sync

NewBase Connector - ItemUpdate The ItemUpdate function synchronizes product information, including prices, stock, and various attributes...

Updated over a week ago

NewBase Connector - ItemUpdate

The ItemUpdate function synchronizes product information, including prices, stock, and various attributes, from the NewBase ERP system to the App4Sales platform. This process runs whenever a full item synchronization is triggered within App4Sales. The connector supports both API Version 2 (V2) and API Version 4 (V4) of the NewBase API, with slight variations in data retrieval and processing logic.

Data Source Configuration

The App4Sales connector pulls data from the NewBase ERP system via its REST API. Authentication details (API keys, base URLs) are configured within the connector settings. The specific API version used (V2 or V4) is determined by the 'ApiVersion' setting in the connector configuration.

  • Endpoints: Various NewBase API endpoints are called to retrieve product details, product groups, product properties, prices, currency rates, and stock information.

  • Data Format: JSON responses from the NewBase API.

Data Mapping Tables

App4Sales Item Mapping

App4Sales Field

Source Field (API/Excel/DB)

Logic/Notes

ItemCode

NewBaseProduct.ItemCode

Direct mapping. Used to identify the product in App4Sales.

InternalItemCode

NewBaseProduct.InternalId

Direct mapping. Unique internal identifier for the product in NewBase.

CreatedDate

NewBaseProduct.CreatedDate

Direct mapping.

SalesPrice

NewBaseProduct.SalesPrice, NewBaseProductPriceBreak.PriceSales

For V2: Direct mapping from NewBaseProduct.SalesPrice. For V4: Derived from NewBaseProductPriceBreak entities. If multiple prices exist, the price can be selected as maximum or minimum based on the 'Select maximum price for product' setting. If discounts are applied, the NewBaseProduct.SalesPrice is used as base for calculation.

EanCode

NewBaseProduct.EanCode

Direct mapping.

Currency

NewBaseProduct.Currency, NewBaseProductPriceBreak.Currency

For V2: Direct mapping from NewBaseProduct.Currency. For V4: Derived from NewBaseProductPriceBreak.Currency.

VatIncluded

Hardcoded

Always set to 'E' (Exclusive).

VatPercentage

NewBaseProduct.VatCode

The VatCode from NewBaseProduct is converted to a VAT percentage based on application settings (HighVatNL or LowVatNL). If the code does not match, it defaults to 0.

FreeSortField

NewBaseProduct.Remark

If 'Use product remark as free sort field' setting is enabled, NewBaseProduct.Remark is parsed as an integer and used as a free sort field. Otherwise, defaults to 0.

LastAvailableStock

NewBaseStock.TechnicalStock

For V2: Retrieved via the GetStock method in the connector, potentially adjusted by prefixes and warehouse settings. For V4: Retrieved via NewbaseStockProvider, potentially including composition product calculations. If 'Do not use exact stock values' setting is enabled, values are converted to 1 (if > 0), -1 (if < 0), or 0 (if = 0).

Description, Description2, ..., Description5

NewBaseProduct.Description, NewBaseProduct.Name, NewbaseProductDescription.ProductDescr

For V2: NewBaseProduct.Description is mapped based on product.DescriptionLanguage (or default 'nl'). If Description is null, it falls back to NewBaseProduct.Name. Up to 5 languages are supported. For V4: NewbaseProductDescription.ProductDescr entities are used, allowing for more granular multi-language descriptions. Up to 5 languages are supported.

PicturesBytes

NewBaseProduct.ImageUrl

If 'Do not sync item pictures' setting is disabled, an image is downloaded from the URL provided by NewBaseProduct.ImageUrl and stored.

App4Sales PriceList Mapping

App4Sales Field

Source Field (API/Excel/DB)

Logic/Notes

Id

NewBasePriceList.PriceListId, Currency

Generated identifier based on the NewBase PriceList ID and currency code.

Code

NewBasePriceList.Code, Currency

Generated code based on the NewBase PriceList Code and currency code.

Description

NewBasePriceList.Name, Currency

Formatted as "{NewBasePriceList Name} - {Currency}".

Currency

Currency

The currency for which this PriceList is valid.

Selectable

Hardcoded

Always set to true.

ExternalId

NewBasePriceList.PriceListId

The original identifier from NewBase for external referencing.

App4Sales PriceListPrice Mapping

App4Sales Field

Source Field (API/Excel/DB)

Logic/Notes

ItemCode

NewBaseProductPrice.ProductCode

Direct mapping.

Price

NewBaseProductPrice.SalesPrice

Direct mapping of the calculated sales price.

PriceListId

NewBaseProductPrice.PriceListId, NewBaseProductPrice.Currency

Generated identifier based on the PriceList ID and currency code, ensuring the price is linked to the correct App4Sales PriceList.

App4Sales ItemClass and ItemClassValue Mapping

App4Sales Field

Source Field (API/Excel/DB)

Logic/Notes

ItemClass.Id

Hardcoded

Always set to 100.

ItemClass.Description

ConnectorSettings.NewBase.ProductGroupName

Uses the value from the 'Product group name' setting. Defaults to "Productgroep" if the setting is empty.

ItemClassValue.ItemClassId

ItemClass.Id

References the ID of the parent ItemClass (100).

ItemClassValue.ItemCode

NewBaseProduct.ItemCode

Direct mapping of the product's item code.

ItemClassValue.Value

NewBaseProductGroupInfo.ItemClassValue (V2), NewBaseProductGroupInfo.ProductGroupName (V4)

For V2: Retrieved from the ItemClassValue property of the corresponding NewBaseProductGroupInfo for the item. For V4: Retrieved from the ProductGroupName property of the corresponding NewBaseProductGroupInfo based on the product's group ID.

App4Sales ItemCategory Mapping

App4Sales Field

Source Field (API/Excel/DB)

Logic/Notes

ItemCategory (Key)

"Extra description"

Category for NewBaseProduct.ExtraDescription, if not null/empty.

ItemCategory (Value)

NewBaseProduct.ExtraDescription

The value of the product's extra description.

ItemCategory (Key)

"Remark"

Category for NewBaseProduct.Remark, if not null/empty.

ItemCategory (Value)

NewBaseProduct.Remark

The value of the product's remark.

ItemCategory (Key)

"Remark composition"

Category for NewBaseProduct.RemarkComposition, if not null/empty.

ItemCategory (Value)

NewBaseProduct.RemarkComposition

The value of the product's remark composition.

ItemCategory (Key)

ProductPropertyCategories.DisplayText + "_" + ProductProperties.DisplayText

For each NewBaseProductProperty associated with the product, a category is created using the display texts of its category and property from NewBaseValueList.

ItemCategory (Value)

NewBaseProductProperty.PropertyValue

The value of the product property.

ItemCategory (Key)

"Extra description {LanguageProductDescr}" (V4 only)

For V4, if NewbaseProductDescription.ProductDescrExtra is not empty and LanguageDefault is not 1, an extra description category is added with the language code.

ItemCategory (Value)

NewbaseProductDescription.ProductDescrExtra (V4 only)

The value of the extra description for a specific language.

Special Logic & Filters

  • Product Validation: Items are only processed if they are valid according to the IsProductValid logic. A product is valid if it is not marked as 'Blocked' in NewBase and if its 'TimeStart' and 'TimeEnd' (if set) indicate that the current date falls within the active period.

  • Product Filtering:

    • Products marked as 'Blocked' in NewBase are skipped.

    • If 'Skip discontinued products' is enabled, products with Discontinued = true are skipped.

    • If 'Skip products without sales price' is enabled, products with SalesPrice = null are skipped.

    • If 'Skip products with name prefix' is configured, products whose name starts with any of the specified prefixes are skipped.

    • V4 Specific: If 'Sync only products with subscription types' is configured, only products with matching subscription types are synced.

    • V4 Specific: If 'Sync only service products' is enabled, only products where IsServiceProduct = 1 are synced.

    • Products with empty ItemCode after conversion are skipped.

  • Stock Retrieval:

    • The stock retrieval process can adjust the item code sent to NewBase using 'Item prefix to remove for stock' and 'Item prefix to use for stock' settings.

    • It targets a specific warehouse based on 'Warehouse ID for stock' or defaults to warehouse '1'.

    • A fallback mechanism is in place: if an item with a prefixed item code yields no stock, a second attempt is made with the original item code.

  • Multi-language Descriptions: The connector attempts to map descriptions to different language fields (Description, Description2, etc.) in App4Sales based on the language information provided by NewBase or the default language setting. A maximum of 5 distinct language descriptions are supported.

Domain Specifics (Expanded)

Price Logic

The connector retrieves comprehensive pricing information from NewBase, including base prices, price breaks, and debtor-specific rebates.

  • Base Price: NewBaseProduct.SalesPrice provides the fundamental sales price.

  • Price Breaks and Rebates: NewBaseProductPriceBreak and NewBaseDebtorRebate entities are fetched. These can define:

    • Specific prices for individual products.

    • Discounts for individual products (percentage off the base sales price).

    • Prices for product rebate groups.

    • Discounts for product rebate groups.

  • Discount Application: Discounts defined in NewBase are applied to the base sales price during the synchronization process if the 'Apply discounts during sync item prices call' setting is enabled.

  • Price Selection (V4): For NewBase API V4, if multiple price breaks apply to a single product, the connector can be configured (via the 'Select maximum price for product' setting) to either select the highest or lowest applicable sales price.

  • Currency Handling: Price lists are generated for each configured currency, with currency rates fetched from NewBase. The 'Used currency codes' setting allows filtering which currencies are processed.

Image Handling

The connector synchronizes product images from NewBase to App4Sales.

  • Source: Images are referenced by a URL provided in NewBaseProduct.ImageUrl.

  • Process: The connector downloads the image from the specified URL.

  • Control: The 'Do not sync item pictures' setting can be used to disable image synchronization.

Stock & Availability

Stock levels are synchronized from NewBase, with options for specific warehouse filtering and handling of exact values.

  • Stock Source: Stock information is retrieved from the NewBase API.

  • Warehouse Specificity: The 'Warehouse ID for stock' setting allows administrators to specify a particular warehouse whose stock should be synchronized. If not set, a default warehouse (ID 1) is used.

  • Item Code Adjustment for Stock Calls: To accurately retrieve stock, the item code sent to NewBase can be modified using the 'Item prefix to remove for stock' and 'Item prefix to use for stock' settings. This is useful for ERP systems that use different item code formats for stock lookups.

  • Exact Stock Values: The 'Do not use exact stock values' setting allows for obfuscation of precise stock quantities. If enabled, any positive stock value will be represented as 1, any negative as -1, and zero as 0.

  • Composition Products (V4): For NewBase API V4, the 'Calculate stocks for composition products' setting influences how stock is calculated for products composed of multiple components.

Matrix & Attributes

The connector maps various product attributes and classifications to App4Sales ItemClasses and ItemCategories.

  • ItemClasses: A single ItemClass (ID 100) is created to represent the "Productgroep" (or custom name from setting). The value for this ItemClass is derived from NewBaseProductGroupInfo, which contains grouping information from NewBase.

  • ItemCategories: Several product details are mapped as ItemCategories:

    • "Extra description" from NewBaseProduct.ExtraDescription.

    • "Remark" from NewBaseProduct.Remark.

    • "Remark composition" from NewBaseProduct.RemarkComposition.

    • Custom categories are generated from NewBaseProductProperty entities, combining the display text of their category and property type.

    • V4 Specific: Additional "Extra description" categories are created for multi-language extra descriptions from NewbaseProductDescription.ProductDescrExtra.

  • Free Fields: The 'FreeSortField' can be populated from the product remark, offering a flexible way to transfer specific numerical attributes.

  • Matrix/Variant Handling: The current implementation does not explicitly define or handle parent-child relationships for matrix items (e.g., product variants like size/color combinations). Attributes like ItemClasses and ItemCategories serve to classify products, but a formal matrix structure for overriding data between parent and child items is not directly evident in the item update logic.

Related Settings & Prerequisites

  • ApiVersion: (Required) Determines which NewBase API version (V2 or V4) to use for data retrieval.

  • ProductGroupName: (Optional) Customizes the display name for the 'Productgroep' ItemClass. Defaults to "Productgroep".

  • SkipDiscontinuedProducts: (Boolean) If true, products marked as discontinued in NewBase will not be synchronized.

  • SkipProductsWithoutSalesPrice: (Boolean) If true, products without a sales price in NewBase will not be synchronized.

  • SkipProductsWithNamePrefix: (String) Comma-separated list of prefixes. Products whose names start with any of these prefixes will be skipped during synchronization.

  • UseProductRemarkAsFreeSort: (Boolean) If true, the product's remark from NewBase will be used as the App4Sales FreeSortField.

  • DoNotSyncItemPictures: (Boolean) If true, product images will not be downloaded or synchronized.

  • WarehouseIdForStock: (Integer) Specifies the ID of the NewBase warehouse from which stock levels should be retrieved. Defaults to 1 if not specified.

  • ItemPrefixToRemoveForStock: (String) A prefix to be removed from the App4Sales item code before querying NewBase for stock.

  • ItemPrefixToUseForStock: (String) A prefix to be added to the item code when querying NewBase for stock.

  • NoExactValuesForStock: (Boolean) If true, stock values will be generalized (1, -1, or 0) instead of showing exact quantities.

  • UsedCurrencyCodes: (String) Comma-separated list of currency codes. Only price lists and prices matching these currencies will be synchronized.

  • SelectMaximumPriceForProduct: (Boolean, V4 only) If true, for products with multiple applicable prices, the highest sales price will be selected. Otherwise, the lowest will be selected.

  • ApplyDiscountsDuringSyncItemPricesCall: (Boolean) If true, discounts defined in NewBase price breaks will be applied to product sales prices during synchronization.

  • SyncOnlyProductsWithSubscriptionTypes: (String, V4 only) Comma-separated list of subscription types. Only products with these subscription types will be synchronized.

  • SyncOnlyServiceProducts: (Boolean, V4 only) If true, only products marked as service products in NewBase will be synchronized.

Known Limitations

  • Matrix/Variant Handling: The current item update logic does not provide explicit mechanisms for managing complex matrix/variant product structures, such as distinct parent-child relationships where child items inherit and override specific attributes from a parent. ItemClasses and ItemCategories provide classification but not hierarchical variant management.

  • Image Limits: The connector downloads images one by one. Performance might be affected for items with a very large number of images.

  • Multi-language Description Limit: A maximum of 5 language-specific descriptions can be synchronized to App4Sales.

Did this answer your question?