Пример #1
0
        private static Tuple <decimal, decimal> GetOrderPriceAndTax(tbl_Orders table)
        {
            if (table == null || table.tbl_OrderContent.Count == 0)
            {
                return(new Tuple <decimal, decimal>(0, 0));
            }

            decimal totalPrice = 0, totalTaxAmount = 0;

            foreach (var content in table.tbl_OrderContent)
            {
                Tuple <decimal, decimal> priceAndTax = PriceManager.GetPrice(content.OC_Price.GetValueOrDefault(), content.OC_Tax.GetValueOrDefault(0), (int)content.OC_Quantity.GetValueOrDefault(0), table.O_DomainID);
                totalPrice     += priceAndTax.Item1;
                totalTaxAmount += priceAndTax.Item2;
            }

            if (table.tbl_Discount != null)
            {
                Tuple <decimal, decimal> priceAndTax = PriceManager.AddDiscountToPrice(table.tbl_Discount, totalPrice, totalTaxAmount, table.O_DomainID);
                totalPrice     = priceAndTax.Item1;
                totalTaxAmount = priceAndTax.Item2;
            }

            if (table.tbl_Postage != null)
            {
                decimal maxTax = table.tbl_OrderContent.Max(bc => bc.GetTaxValue());
                Tuple <decimal, decimal> postagePriceAndTax = PriceManager.GetPostagePriceAndTax(table.tbl_Postage, maxTax, table.O_DomainID);
                totalPrice     += postagePriceAndTax.Item1;
                totalTaxAmount += postagePriceAndTax.Item2;
            }

            return(new Tuple <decimal, decimal>(totalPrice, totalTaxAmount));
        }
Пример #2
0
 public static decimal GetDeliveryTaxAmount(this tbl_Basket table)
 {
     if (table.tbl_Postage != null && table.tbl_BasketContent.Count > 0)
     {
         decimal maxTax = table.tbl_BasketContent.Max(bc => bc.GetTaxValue());
         Tuple <decimal, decimal> postagePriceAndTax = PriceManager.GetPostagePriceAndTax(table.tbl_Postage, maxTax, table.B_DomainID);
         return(postagePriceAndTax.Item2);
     }
     return(0);
 }
Пример #3
0
 public static string GetDeliveryTaxAmountString(this tbl_Basket table, bool hideTax = false)
 {
     if (table.tbl_Postage != null && table.tbl_BasketContent.Count > 0)
     {
         decimal maxTax = table.tbl_BasketContent.Max(bc => bc.GetTaxValue());
         Tuple <decimal, decimal> postagePriceAndTax = PriceManager.GetPostagePriceAndTax(table.tbl_Postage, maxTax, table.B_DomainID);
         return(String.Format("{0:C}", postagePriceAndTax.Item2));
     }
     return(String.Empty);
 }
Пример #4
0
        private static Tuple <decimal, decimal> GetBasketPriceAndTax(tbl_Basket table, bool onlyProductsPrice = false)
        {
            if (table == null || table.tbl_BasketContent.Count == 0)
            {
                return(new Tuple <decimal, decimal>(0, 0));
            }

            decimal totalPrice = 0, totalTaxAmount = 0;

            foreach (var content in table.tbl_BasketContent)
            {
                Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(content.tbl_ProductPrice, content.BC_Quantity);
                totalPrice     += priceAndTax.Item1;
                totalTaxAmount += priceAndTax.Item2;
            }

            if (onlyProductsPrice)
            {
                return(new Tuple <decimal, decimal>(totalPrice, totalTaxAmount));
            }

            if (table.tbl_Discount != null)
            {
                Tuple <decimal, decimal> priceAndTax = PriceManager.AddDiscountToPrice(table.tbl_Discount, totalPrice, totalTaxAmount, table.B_DomainID);
                totalPrice     = priceAndTax.Item1;
                totalTaxAmount = priceAndTax.Item2;
            }

            if (table.tbl_Postage != null)
            {
                decimal maxTax = table.tbl_BasketContent.Max(bc => bc.GetTaxValue());
                Tuple <decimal, decimal> postagePriceAndTax = PriceManager.GetPostagePriceAndTax(table.tbl_Postage, maxTax, table.B_DomainID);
                totalPrice     += postagePriceAndTax.Item1;
                totalTaxAmount += postagePriceAndTax.Item2;
            }

            return(new Tuple <decimal, decimal>(totalPrice, totalTaxAmount));
        }
Пример #5
0
        public static decimal GetDeliveryAmount(this tbl_Basket table, bool?includeTax = null)
        {
            if (table.tbl_Postage != null && table.tbl_BasketContent.Count > 0)
            {
                IDomain domainService    = (IDomain)DependencyResolver.Current.GetService <IDomain>();
                var     priceIncludesTax = domainService.GetSettingsValueAsBool(SettingsKey.priceDisplayIncludesVAT, table.B_DomainID);

                decimal maxTax = table.tbl_BasketContent.Max(bc => bc.GetTaxValue());
                Tuple <decimal, decimal> postagePriceAndTax = PriceManager.GetPostagePriceAndTax(table.tbl_Postage, maxTax, table.B_DomainID);

                if (includeTax.HasValue)
                {
                    if (includeTax.Value)
                    {
                        return(priceIncludesTax ? postagePriceAndTax.Item1 : postagePriceAndTax.Item1 + postagePriceAndTax.Item2);
                    }
                    return(priceIncludesTax ? postagePriceAndTax.Item1 - postagePriceAndTax.Item2 : postagePriceAndTax.Item1);
                }

                return(postagePriceAndTax.Item1);
            }
            return(0);
        }