Esempio n. 1
0
        public override void Inspect()
        {
            decimal       dummy2;
            DiscountEntry de           = Phase2Inspect(out dummy2);
            LineItem      discountItem = null;

            if (de != null)
            {
                discountItem = new LineItem(this.Name, 1, -de.Discount, this.taxable, this.revenueGroup, "", null);
            }
            Purchase.SetDiscount(this.Name, discountItem);
        }
Esempio n. 2
0
        public override void Inspect()
        {
            decimal       dollars;
            DiscountEntry de           = Phase2Inspect(out dollars);
            LineItem      discountItem = null;

            if (de != null)
            {
                discountItem = new LineItem(this.Name + " " + Utilities.PercentageString(de.Discount, 0) + "%", 1,
                                            -Math.Round(de.Discount * dollars, 2, MidpointRounding.AwayFromZero), this.taxable, this.revenueGroup, "", null);
            }
            Purchase.SetDiscount(this.Name, discountItem);
        }
Esempio n. 3
0
        static public void Setup()
        {
            DiscountManager.discounts = new List <DiscountBase>();

            int discountCount = int.Parse(ConfigurationManager.AppSettings["DiscountCount"]);

            for (int i = 1; i <= discountCount; i++)
            {
                string discountType         = ConfigurationManager.AppSettings["Discount" + i.ToString() + "Type"];
                string discountName         = ConfigurationManager.AppSettings["Discount" + i.ToString() + "Name"];
                string discountRevenueGroup = ConfigurationManager.AppSettings["Discount" + i.ToString() + "Revgrp"];
                int    discountEntries      = int.Parse(ConfigurationManager.AppSettings["Discount" + i.ToString() + "Entries"]);

                List <DiscountEntry> entries = new List <DiscountEntry>();
                for (int j = 1; j <= discountEntries; j++)
                {
                    DiscountEntry de = new DiscountEntry();
                    de.GreaterOrEqual = decimal.Parse(ConfigurationManager.AppSettings["Discount" + i.ToString() + "Entry" + j.ToString() + "Low"]);
                    de.LessThan       = decimal.Parse(ConfigurationManager.AppSettings["Discount" + i.ToString() + "Entry" + j.ToString() + "High"]);
                    de.Discount       = decimal.Parse(ConfigurationManager.AppSettings["Discount" + i.ToString() + "Entry" + j.ToString() + "Discount"]);
                    entries.Add(de);
                }

                switch (discountType.ToLower())
                {
                case "fixedbycount":
                    DiscountManager.discounts.Add(new FixedByCountDiscount(discountName, entries, GetTaxable(i), discountRevenueGroup));
                    break;

                case "fixedbydollars":
                    DiscountManager.discounts.Add(new FixedByDollarsDiscount(discountName, entries, GetTaxable(i), discountRevenueGroup));
                    break;

                case "percentbycount":
                    DiscountManager.discounts.Add(new PercentByCountDiscount(discountName, entries, GetTaxable(i), discountRevenueGroup));
                    break;

                case "percentbydollars":
                    DiscountManager.discounts.Add(new PercentByDollarsDiscount(discountName, entries, GetTaxable(i), discountRevenueGroup));
                    break;

                default:
                    System.Windows.Forms.MessageBox.Show(String.Format("{0} in discount {1}", discountType, i), "Unknown discount type",
                                                         System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Stop);
                    break;
                }
            }
        }
Esempio n. 4
0
        protected DiscountEntry Phase2Inspect(out decimal dollars)
        {
            decimal count;

            Phase1Inspect(out count, out dollars);

            DiscountEntry retval = null;

            foreach (DiscountEntry de in this.discounts)
            {
                if ((dollars >= de.GreaterOrEqual) && (dollars < de.LessThan))
                {
                    retval = de;
                    break;
                }
            }

            return(retval);
        }