Exemple #1
0
 public static decimal GetDiscountAmount(this tbl_Basket table)
 {
     if (table.tbl_Discount != null)
     {
         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;
         }
         return(PriceManager.GetDiscountAmount(table.tbl_Discount, totalPrice, totalTaxAmount, table.B_DomainID));
     }
     return(0);
 }
Exemple #2
0
        public static decimal GetPrice(this tbl_BasketContent table, bool?includeTax = null)
        {
            IDomain domainService                = (IDomain)DependencyResolver.Current.GetService <IDomain>();
            var     priceIncludesTax             = domainService.GetSettingsValueAsBool(SettingsKey.priceDisplayIncludesVAT, table.tbl_Basket.B_DomainID);
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table.tbl_ProductPrice, table.BC_Quantity);

            if (includeTax.HasValue)
            {
                if (includeTax.Value)
                {
                    return(priceIncludesTax ?
                           priceAndTax.Item1 :
                           priceAndTax.Item1 + priceAndTax.Item2);
                }
                return(priceIncludesTax ?
                       priceAndTax.Item1 - priceAndTax.Item2 :
                       priceAndTax.Item2);
            }
            return(priceAndTax.Item1);
        }
Exemple #3
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));
        }
Exemple #4
0
        public static decimal GetPrice(this tbl_ProductPrice table, int amount = 1)
        {
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table, amount);

            return(priceAndTax.Item1);
        }
Exemple #5
0
        public static string GetTaxAmountString(this tbl_ProductPrice table, int amount = 1)
        {
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table, amount);

            return(String.Format("{0:C}", priceAndTax.Item2));
        }
Exemple #6
0
        public static string GetPriceString(this tbl_ProductPrice table, int amount = 1, bool hideTax = false)
        {
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table, amount);

            return(PriceManager.FormatPrice(priceAndTax.Item1, priceAndTax.Item2, table.tbl_Products.tbl_SiteMap.SM_DomainID, hideTax));
        }
Exemple #7
0
        public static decimal GetTaxAmount(this tbl_OrderContent table)
        {
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table.tbl_ProductPrice, (int)table.OC_Quantity.GetValueOrDefault(0));

            return(priceAndTax.Item2);
        }
Exemple #8
0
        public static string GetTaxAmountString(this tbl_OrderContent table)
        {
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table.tbl_ProductPrice, (int)table.OC_Quantity.GetValueOrDefault(0));

            return(String.Format("{0:C}", priceAndTax.Item2));
        }
Exemple #9
0
        public static decimal GetTaxAmount(this tbl_BasketContent table)
        {
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table.tbl_ProductPrice, table.BC_Quantity);

            return(priceAndTax.Item2);
        }
Exemple #10
0
        public static string GetTaxAmountString(this tbl_BasketContent table)
        {
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table.tbl_ProductPrice, table.BC_Quantity);

            return(String.Format("{0:C}", priceAndTax.Item2));
        }
Exemple #11
0
        public static string GetItemPriceString(this tbl_BasketContent table, bool hideTax = false)
        {
            Tuple <decimal, decimal> priceAndTax = PriceManager.GetPriceAndTaxAmounts(table.tbl_ProductPrice, 1);

            return(PriceManager.FormatPrice(priceAndTax.Item1, priceAndTax.Item2, table.tbl_Basket.B_DomainID, hideTax));
        }