Exemplo n.º 1
0
        public static decimal[] CalculateTestPrice(SampleTest sampleTest, SmartCollection<ClientPricing> discounts, Priority priority, SmartCollection<PricingRule> matrixItems, int analytes, decimal basePrice)
        {
            decimal[] pricingArray = new decimal[2];

            // PricingArray[0] = Total Price
            // PricingArray[1] = RUSH Only additional charge for invoicing only not used in calculations

            decimal price = 0; // Calculated set and returned
            decimal testPrice = 0;
            decimal priorityPriceAdjustment = 0;
            decimal matrixPrice = 0;
            decimal discount = 0;

            if (sampleTest.DiscountAllowedYN) {
                if (matrixItems.Count > 0) {
                    matrixPrice = testPrice * matrixItems.Sum(x => x.PriceAdjustment);
                    if (matrixPrice <= 0) matrixPrice = 0;
                }
            }

            if (discounts.Count > 0) {
                discount = (matrixPrice + testPrice) * (decimal)discounts.Sum(x => x.Discount);
                if (!sampleTest.DiscountAllowedYN) discount = 0;
                //if (discount <= 0) discount = 0;
            }
            priorityPriceAdjustment = testPrice * priority.PriceAdjustment;

            //if (priority.DiscountAllowedYN) {
                //Might need to create line item detail here for invoicing.
                //if (discounts.Count > 0) {
                    //priorityPriceAdjustment = priorityPriceAdjustment - (priorityPriceAdjustment * (decimal)discounts.Sum(x => x.Discount));
                    //if (priorityPriceAdjustment <= 0) priorityPriceAdjustment = 0;
                //}
            //}

            if (priority.PriorityName.ToUpper().Contains("RUSH"))
                pricingArray[1] = priorityPriceAdjustment;

            price = (testPrice + matrixPrice + priorityPriceAdjustment) - discount;

            if (price <= 0) price = 0;

            pricingArray[0] = Math.Round(price, 2);

            return pricingArray;
        }