Use prices from an ERP system
This section explains how to fetch list prices from a ERP system "real-time". If this method is implemented, for each price fetch, the ERP system will be queried. Consider performance considerations if you opt for this method.
To fetch list prices from a ERP system, override the IPriceCalculator.
Step 1: Create a class librabry project in Visual Studio, and reference Litium.Studio.dll
Step 2: Add a class that extend the PriceCalculator and override method GetListPrices() (see below example).
using Litium.Foundation.Modules.ProductCatalog.Plugins.PriceCalculator;
using System.Collections.Generic;
using System;
namespace Litum.Studio.KC.Samples.ERPPricing
{
public class ERPPriceCalculator:PriceCalculator
{
/// <summary>
/// Get the list price from ERP system, instead of using LitiumStudio price lists.
/// </summary>
/// <param name="priceCalculatorArgs">Contains details of article for which prices are needed.</param>
/// <returns>dictionary of prices, with article id as key.</returns>
public override IDictionary<Guid, ListPriceResult> GetListPrices(params PriceCalculatorArgs[] priceCalculatorArgs)
{
var listPricesFromERP = new Dictionary<Guid, ListPriceResult>();
//TODO: Call the ERP system to get list prices for each item in priceCalculatorArgs
//for this example, we simply set the price to 7 before VAT !
foreach (var item in priceCalculatorArgs)
{
//note that the price you will see is 8.75 with VAT (from 7 x 1.25)
var listPrice = new ListPriceResult() { ListPrice = 7, VatPercentage = 0.25M };
listPricesFromERP.Add(item.ArticleID, listPrice);
}
return listPricesFromERP;
}
}
}