Exemple #1
0
        public static Adjustment CreateCharge(DateTime dt, int random)
        {
            var        rnd = new DeterministicRandom(random);
            Adjustment res = new Adjustment();

            res.date        = dt;
            res.description = rnd.GetRandomItem(bills);
            res.amount      = rnd.Random(10, 50) * 10;
            return(res);
        }
Exemple #2
0
        public static Adjustment CreateBalanceForward(DateTime dt, int random)
        {
            var        rnd = new DeterministicRandom(random);
            Adjustment res = new Adjustment();

            res.date        = dt;
            res.description = "Balance Forward";
            res.amount      = rnd.Random(10, 300) * 10;
            return(res);
        }
Exemple #3
0
        public static Adjustment CreatePayment(DateTime dt, int random)
        {
            var        rnd = new DeterministicRandom(random);
            Adjustment res = new Adjustment();

            res.date        = dt;
            res.description = "Payment";
            res.amount      = -rnd.Random(1, 40) * 10;
            return(res);
        }
Exemple #4
0
        public DataItem(int i)
        {
            var      rnd = new DeterministicRandom(i);
            Customer c   = rnd.GetRandomItem(Customer.Customers);

            CustomerID          = c.CustomerID;
            CompanyName         = c.CompanyName;
            ContactName         = c.ContactName;
            ContactTitle        = c.ContactTitle;
            Address             = c.Address;
            City                = c.City;
            PostalCode          = c.PostalCode;
            Region              = c.Region;
            Country             = c.Country;
            Phone               = c.Phone;
            Fax                 = c.Fax;
            Email               = ContactName.Split(' ')[0].Replace(' ', '.').ToLower() + "@" + CompanyName.Split(' ')[0].ToLower() + ".com";
            Invoice             = string.Format("{0}{1}-{2}", rnd.RandomLitera, rnd.Random(100, 1000), rnd.Random(100, 1000));
            CustomerAccount     = rnd.GetRandomItem(accountType);
            CustomerIdentifiers = string.Format("{0}-{1}", rnd.Random(1000, 10000), rnd.Random(10, 100));
            BillingPeriodStart  = rnd.RandomTime();
            BillingPeriodEnd    = rnd.RandomTime(BillingPeriodStart, 7 * 24, 30 * 24);
            BillingDate         = rnd.RandomTime(BillingPeriodEnd, 7 * 24, 30 * 24);
            Term term = rnd.GetRandomItem(Term.Terms);

            Terms = term.Name;

            int adjustmentsCount = rnd.Random(6) + 4;

            Adjustments = new Adjustment[adjustmentsCount];
            int h = (int)((BillingPeriodEnd - BillingPeriodStart).TotalHours / adjustmentsCount);

            var adj = Adjustments[0] = Adjustment.CreateBalanceForward(rnd.RandomTime(BillingPeriodStart, 0, h), rnd.Random(10000));

            int[] items = rnd.RandomList(adjustmentsCount - 1, 2);

            for (int j = 1; j < Adjustments.Length; j++)
            {
                DateTime nextDate = rnd.RandomTime(BillingPeriodStart.AddHours(h * j), 0, h);
                switch (items[j - 1])
                {
                case 0:
                    adj = Adjustments[j] = Adjustment.CreateCharge(nextDate, rnd.Random(10000));
                    break;

                case 1:
                    adj = Adjustments[j] = Adjustment.CreatePayment(nextDate, rnd.Random(10000));
                    break;
                }
            }
        }