Beispiel #1
0
        public void GetPaymentPlanTest()
        {
            string      candidateID   = string.Empty; // TODO: Initialize to an appropriate value
            string      electionCycle = string.Empty; // TODO: Initialize to an appropriate value
            PaymentPlan expected      = null;         // TODO: Initialize to an appropriate value
            PaymentPlan actual;

            actual = PaymentPlan.GetPaymentPlan(candidateID, electionCycle);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Beispiel #2
0
        /// <overview>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </overview>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            _plan = PaymentPlan.GetPaymentPlan(CPProfile.Cid, CPProfile.ElectionCycle);
            if (_plan == null)
            {
                return;
            }
            CultureInfo        enCulture = CultureInfo.CreateSpecificCulture("en-US");
            Table              table;
            bool               altColor;
            PaymentInstallment current = _plan.Schedule.Current;

            // overview
            // overview: next payment
            Panel overview = MakeSectionPanel(Properties.Resources.OverviewTitle);

            overview.CssClass += " cp-PaymentPlanOverviewPanel";
            table              = MakeSectionTable();
            table.CssClass    += " cp-leftcolumn";
            overview.Controls.Add(table);
            table.Rows.Add(MakeLabeledDataRow(
                               "Next due date",
                               (current == null) ? "(n/a)" : current.DueDate.ToString(Properties.Resources.DateFormat)
                               ));
            table.Rows.Add(MakeLabeledDataRow(
                               "Payment amount:",
                               (current == null) ? "(n/a)" : current.AmountDue.ToString("C", enCulture)
                               ));
            // overview: plan dates
            table           = MakeSectionTable();
            table.CssClass += " cp-leftcolumn";
            overview.Controls.Add(table);
            table.Rows.Add(MakeLabeledDataRow(
                               "Initial payment:",
                               _plan.FirstPaymentDate.ToString(Properties.Resources.DateFormat)
                               ));
            table.Rows.Add(MakeLabeledDataRow(
                               "Final payment:",
                               _plan.FinalPaymentDueDate.ToString(Properties.Resources.DateFormat)
                               ));
            // overview: totals
            table = MakeSectionTable();
            overview.Controls.Add(table);
            table.Rows.Add(MakeLabeledDataRow(
                               "Total amount:",
                               _plan.Total.ToString("C", enCulture)
                               ));
            table.Rows.Add(MakeLabeledDataRow(
                               "Amount outstanding:",
                               _plan.GetBalance().ToString("C", enCulture)
                               ));
            if (_plan.PastDueBalance > 0)
            {
                table.Rows.Add(MakeLabeledDataRow("Balance past due:", _plan.PastDueBalance.ToString("C", enCulture)));
            }

            // schedule
            Panel schedule = MakeSectionPanel(Properties.Resources.ScheduleTitle);

            schedule.CssClass += " cp-PaymentPlanSchedulePanel";
            table              = MakeSectionTable();
            schedule.Controls.Add(table);
            table.Rows.Add(MakeHeaderRow("Payment Schedule", "Start Date", "End Date"));
            foreach (PaymentPlanSummary summary in _plan.Summaries)
            {
                table.Rows.Add(MakeDataRow(
                                   string.Format("{0} {1} {2} of {3}", summary.PaymentCount, CPConvert.ToString(_plan.Period),
                                                 (summary.PaymentCount > 0) ? "payments" : "payment",
                                                 summary.PeriodPaymentAmount.ToString("C", enCulture)), summary.FirstPaymentDate.ToString(Properties.Resources.DateFormat), summary.FinalPaymentDueDate.ToString(Properties.Resources.DateFormat)
                                   ));
            }

            // balances
            Panel balances = MakeSectionPanel(Properties.Resources.BalancesTitle);

            balances.CssClass += " cp-PaymentPlanBalancesPanel";
            table              = MakeSectionTable();
            balances.Controls.Add(table);
            table.Rows.Add(MakeHeaderRow("Payment #", "Due Date", "Amount Due", "Amount Paid"));
            altColor = false;
            foreach (PaymentInstallment installment in _plan.Installments)
            {
                uint?amountPaid = installment.AmountPaid;
                table.Rows.Add(MakeDataRow(altColor,
                                           installment.Number.ToString(),
                                           installment.DueDate.ToString(Properties.Resources.DateFormat),
                                           installment.AmountDue.ToString("C", enCulture),
                                           (amountPaid == null) ? "--" : ((uint)amountPaid).ToString("C", enCulture)
                                           ));
            }

            // history
            Panel history = MakeSectionPanel(Properties.Resources.HistoryTitle);

            history.CssClass += " cp-PaymentPlanHistoryPanel";
            table             = MakeSectionTable();
            history.Controls.Add(table);
            table.Rows.Add(MakeHeaderRow("Date", "Amount"));
            altColor = false;
            foreach (PlanPayment payment in _plan.Payments)
            {
                table.Rows.Add(MakeDataRow(altColor,
                                           payment.Date.ToString(Properties.Resources.DateFormat),
                                           payment.Amount.ToString("C", enCulture)
                                           ));
                altColor = !altColor;
            }

            _container          = new Panel();
            _container.CssClass = "PaymentPlanWebPart";
            _container.Controls.Add(overview);
            _container.Controls.Add(schedule);
            balances.CssClass += " cp-leftcolumn";
            _container.Controls.Add(balances);
            _container.Controls.Add(history);
            this.Controls.Add(_container);
        }