public void ApplyTaxRates(IEnumerable <TaxRate> taxRates)
        {
            var productTaxRates = taxRates.Where(x => x.Line.Id.EqualsInvariant(ProductId));
            var taxRate         = productTaxRates.FirstOrDefault(x => x.Line.Quantity == 0);

            if (taxRate != null)
            {
                if (taxRate.PercentRate > 0)
                {
                    TaxPercentRate = taxRate.PercentRate;
                }
                else
                {
                    var amount = ActualPrice.Amount > 0 ? ActualPrice.Amount : SalePrice.Amount;
                    if (amount > 0)
                    {
                        TaxPercentRate = Math.Round(taxRate.Rate / amount, 4, MidpointRounding.AwayFromZero);
                    }
                }

                TaxDetails = taxRate.TaxDetails;
            }
            if (productTaxRates.Any())
            {
                TierPrices.Apply(x => x.ApplyTaxRates(productTaxRates));
            }
        }
 public void Collect(IEnumerable <int> productIds)
 {
     Attributes.Collect(productIds);
     AttributeCombinations.Collect(productIds);
     TierPrices.Collect(productIds);
     ProductCategories.Collect(productIds);
     AppliedDiscounts.Collect(productIds);
 }
        public override object Clone()
        {
            var result = MemberwiseClone() as ProductPrice;

            result.Currency       = Currency?.Clone() as Currency;
            result.DiscountAmount = DiscountAmount?.Clone() as Money;
            result.ListPrice      = ListPrice?.Clone() as Money;
            result.SalePrice      = SalePrice?.Clone() as Money;
            result.TierPrices     = TierPrices?.Select(x => x.Clone() as TierPrice).ToList();
            result.Discounts      = Discounts?.Select(x => x.Clone() as Discount).ToList();

            return(result);
        }
        /// <summary>
        /// If overriding don't forget to call base.Load() or make sure to
        /// assign the WrappedElement.
        /// </summary>
        /// <returns></returns>
        public override ILoadableComponent Load()
        {
            base.Load();
            GeneralInformation.Load();
            GiftCard.Load();
            DownloadableProduct.Load();
            RecurringProduct.Load();
            Rental.Load();
            Prices.Load();
            TierPrices.Load();
            AssociatedProducts.Load();
            Inventory.Load();
            Shipping.Load();
            Mapping.Load();
            AccessControlList.Load();
            RequireOtherProducts.Load();
            RelatedProducts.Load();

            return(this);
        }