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)); }
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)); }