Example #1
0
        private void computeDiscountsAgainst(ref SameDiscounts sameDiscounts, decimal amountAgainst)
        {
            foreach (Discount discount in sameDiscounts)
            {
                //one by one application

                decimal discountAmount = 0.00M;

                discountAmount = computeDiscountAmount(discount.Percent, amountAgainst);

                discount.Amount   = discountAmount;
                discount.Computed = true;

                amountAgainst -= discountAmount;
            }
        }
Example #2
0
        //change this
        private void recomputeDiscounts()
        {
            //reset discounts
            foreach (Discount d in appliedDiscounts)
            {
                d.Computed = false;
            }
            foreach (Discount d in availableDiscounts)
            {
                d.Computed = false;
            }
            //discounts computation engine
            int ctr = 0;

            while (ctr != appliedDiscounts.Count)
            {
                SameDiscounts sameDiscounts = null;
                sameDiscounts = new SameDiscounts();
                for (int i = 0; i <= appliedDiscounts.Count - 1; i++)
                {
                    if (appliedDiscounts.GetDiscount(i).Computed == false)
                    {
                        //System.Windows.Forms.MessageBox.Show("Individual: "
                        //    + appliedDiscounts.GetDiscount(i).ItemAppliedTo);
                        sameDiscounts.Add(appliedDiscounts.GetDiscount(i));
                    }
                }
                ctr += sameDiscounts.Count;

                //System.Windows.Forms.MessageBox.Show("Group: "
                //    + sameDiscounts.AppliedToItem);
                sameDiscounts.SortByPercentage();
                switch (sameDiscounts.AppliedToItem)
                {
                    case Constants.SUBTOTAL:
                        computeDiscountsAgainst(ref sameDiscounts, subtotal);
                        break;
                    case Constants.TUITIONFEES:
                        computeDiscountsAgainst(ref sameDiscounts, totalTuition);
                        break;
                    case Constants.MISCELLANEOUSFEES:
                        computeDiscountsAgainst(ref sameDiscounts, totalMiscellaneousFees);
                        break;
                    case Constants.DIRECTCOSTS:
                        computeDiscountsAgainst(ref sameDiscounts, totalDirectCosts);
                        break;
                    case Constants.ADDITIONALFEES:
                        computeDiscountsAgainst(ref sameDiscounts, totalAdditionalFees);
                        break;

                    default:
                        decimal amountAgainst;
                        if (this.items.GetItem(sameDiscounts.AppliedToItem) != null)
                        {
                            amountAgainst = this.items.GetItem
                            (sameDiscounts.AppliedToItem).ExtendedPrice;
                        }
                        else
                        {
                            amountAgainst = 0;
                        }
                        computeDiscountsAgainst(ref sameDiscounts, amountAgainst);
                        break;
                }
            }
        }
Example #3
0
        private void computeDiscountsAgainst(ref SameDiscounts sameDiscounts, decimal amountAgainst)
        {
            foreach (Discount discount in sameDiscounts)
            {
                //one by one application

                decimal discountAmount = 0.00M;

                discountAmount = computeDiscountAmount(discount.Percent, amountAgainst);

                discount.Amount = discountAmount;
                discount.Computed = true;

                amountAgainst -= discountAmount;
            }
        }
Example #4
0
        //change this
        private void recomputeDiscounts()
        {
            //reset discounts
            foreach (Discount d in appliedDiscounts)
            {
                d.Computed = false;
            }
            foreach (Discount d in availableDiscounts)
            {
                d.Computed = false;
            }
            //discounts computation engine
            int ctr = 0;

            while (ctr != appliedDiscounts.Count)
            {
                SameDiscounts sameDiscounts = null;
                sameDiscounts = new SameDiscounts();
                for (int i = 0; i <= appliedDiscounts.Count - 1; i++)
                {
                    if (appliedDiscounts.GetDiscount(i).Computed == false)
                    {
                        //System.Windows.Forms.MessageBox.Show("Individual: "
                        //    + appliedDiscounts.GetDiscount(i).ItemAppliedTo);
                        sameDiscounts.Add(appliedDiscounts.GetDiscount(i));
                    }
                }
                ctr += sameDiscounts.Count;

                //System.Windows.Forms.MessageBox.Show("Group: "
                //    + sameDiscounts.AppliedToItem);
                sameDiscounts.SortByPercentage();
                switch (sameDiscounts.AppliedToItem)
                {
                case Constants.SUBTOTAL:
                    computeDiscountsAgainst(ref sameDiscounts, subtotal);
                    break;

                case Constants.TUITIONFEES:
                    computeDiscountsAgainst(ref sameDiscounts, totalTuition);
                    break;

                case Constants.MISCELLANEOUSFEES:
                    computeDiscountsAgainst(ref sameDiscounts, totalMiscellaneousFees);
                    break;

                case Constants.DIRECTCOSTS:
                    computeDiscountsAgainst(ref sameDiscounts, totalDirectCosts);
                    break;

                case Constants.ADDITIONALFEES:
                    computeDiscountsAgainst(ref sameDiscounts, totalAdditionalFees);
                    break;

                default:
                    decimal amountAgainst;
                    if (this.items.GetItem(sameDiscounts.AppliedToItem) != null)
                    {
                        amountAgainst = this.items.GetItem
                                            (sameDiscounts.AppliedToItem).ExtendedPrice;
                    }
                    else
                    {
                        amountAgainst = 0;
                    }
                    computeDiscountsAgainst(ref sameDiscounts, amountAgainst);
                    break;
                }
            }
        }