109 lines
3.7 KiB
C#
109 lines
3.7 KiB
C#
using Sarand.BusinessMgr.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using System;
|
|
|
|
namespace Sarand.BusinessMgr.Net.Standard.Base.Bus
|
|
{
|
|
//=======================================================================
|
|
public class SbmPriceCalculationParams
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Data members.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public SbmPriceCalculationParams(SbmPrice pPrice, Sbm.DiscountType eDiscount, decimal fRate)
|
|
{
|
|
Reset();
|
|
PopulatePriceSetParams(null, pPrice);
|
|
DiscountType = eDiscount;
|
|
DiscountRate = fRate;
|
|
}
|
|
public SbmPriceCalculationParams(Sbm.PriceType priceType, Sbm.PriceCalcMethod calculationMethod, decimal calculationValue)
|
|
{
|
|
Reset();
|
|
PriceType = priceType;
|
|
CalculationMethod = calculationMethod;
|
|
CalculationValue = calculationValue;
|
|
}
|
|
public SbmPriceCalculationParams(SbmAssociation association, SbmPrice price, String priceSetName)
|
|
{
|
|
Reset();
|
|
PriceSetName = priceSetName;
|
|
PopulatePriceSetParams(association, price);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Properties.
|
|
// Pricing attributes.
|
|
public bool IsSales { get; private set; }
|
|
public int CurrencyDecimals { get { return 2; } }
|
|
public bool IsPriceSetAvailable { get { return !StringUtil.IsEmpty(PriceSetName) || CalculationMethod > 0; } }
|
|
public bool IsPriceSetUsed { get; set; }
|
|
public bool IsDiscountAvailable { get { return Math.Abs(DiscountRate) > 0.001m; } }
|
|
public bool IsDiscountUsed { get; set; }
|
|
// Price set parameters.
|
|
public String PriceSetName { get; set; }
|
|
public Sbm.PriceType PriceType { get; private set; }
|
|
public Sbm.PriceCalcMethod CalculationMethod { get; private set; }
|
|
public decimal CalculationValue { get; private set; }
|
|
public Sbm.PriceRounderMethod RounderMethod { get; private set; }
|
|
public Sbm.PriceRounderDirection RounderDirection { get; private set; }
|
|
public decimal RounderMultipleOf { get; private set; }
|
|
public decimal RounderAdjustment { get; private set; }
|
|
// Account parameters.
|
|
public Sbm.DiscountType DiscountType { get; private set; }
|
|
public decimal DiscountRate { get; private set; }
|
|
|
|
//-------------------------------------------------------------------
|
|
// Population.
|
|
public void PopulatePriceSetParams(SbmAssociation association, SbmPrice price)
|
|
{
|
|
ResetPriceSetParams();
|
|
if (association != null)
|
|
{
|
|
IsSales = !association.IsSupplier();
|
|
DiscountType = association.DiscountType;
|
|
DiscountRate = association.DiscountRate;
|
|
}
|
|
if (price != null)
|
|
{
|
|
PriceType = price.PriceType;
|
|
CalculationMethod = price.CalculationMethod;
|
|
CalculationValue = price.CalculationValue;
|
|
RounderMethod = price.RounderMethod;
|
|
RounderDirection = price.RounderDirection;
|
|
RounderMultipleOf = price.RounderMultipleOf;
|
|
RounderAdjustment = price.RounderAdjustment;
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Reset parameters.
|
|
private void Reset()
|
|
{
|
|
IsPriceSetUsed = false;
|
|
IsDiscountUsed = false;
|
|
// Price set parameters:
|
|
ResetPriceSetParams();
|
|
// Account parameters:
|
|
DiscountType = Sbm.DiscountType.NoDiscount;
|
|
DiscountRate = 0.0m;
|
|
}
|
|
private void ResetPriceSetParams()
|
|
{
|
|
IsSales = false;
|
|
PriceType = Sbm.PriceType.Unknown;
|
|
CalculationMethod = Sbm.PriceCalcMethod.Unknown;
|
|
CalculationValue = 0.0m;
|
|
RounderMethod = Sbm.PriceRounderMethod.Unknown;
|
|
RounderDirection = Sbm.PriceRounderDirection.Unknown;
|
|
RounderMultipleOf = 0.0m;
|
|
RounderAdjustment = 0.0m;
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|