Exemplo n.º 1
0
        public void CalculateWithDownPaymentAndOneOverPaymentTest()
        {
            AddReceipt(60M, Layaway.DateMade, ReceiptEventTypes.LAYPMT, "98581", "97907", new DateTime(2011, 2, 8, 14, 38, 50));

            Builder         = new LayawayPaymentHistoryBuilder();
            Builder.Layaway = Layaway;
            Builder.Calculate();

            // Need to account for the down payment
            Assert.AreEqual(Layaway.NumberOfPayments + 1, Builder.ScheduledPayments.Count);

            // Is the first payment the downpayment
            Assert.AreEqual(1, Builder.ScheduledPayments[0].Payments.Count);
            Assert.IsTrue(Builder.ScheduledPayments[0].IsPaid());

            Assert.AreEqual(1, Builder.ScheduledPayments[1].Payments.Count);
            Assert.AreEqual(Layaway.MonthlyPayment, Builder.ScheduledPayments[1].Payments[0].PaymentAmountMade);
            Assert.AreEqual(0M, Builder.ScheduledPayments[1].GetRemainingBalance());
            Assert.IsTrue(Builder.ScheduledPayments[1].IsPaid());

            Assert.AreEqual(1, Builder.ScheduledPayments[2].Payments.Count);
            Assert.AreEqual(Layaway.MonthlyPayment, Builder.ScheduledPayments[2].Payments[0].PaymentAmountMade);
            Assert.AreEqual(0M, Builder.ScheduledPayments[2].GetRemainingBalance());
            Assert.IsTrue(Builder.ScheduledPayments[2].IsPaid());

            Assert.AreEqual(1, Builder.ScheduledPayments[3].Payments.Count);
            Assert.AreEqual(9.9M, Builder.ScheduledPayments[3].Payments[0].PaymentAmountMade);
            Assert.AreEqual(15.15M, Builder.ScheduledPayments[3].GetRemainingBalance());
            Assert.IsFalse(Builder.ScheduledPayments[3].IsPaid());
        }
Exemplo n.º 2
0
        private void LayawayPaymentHistory_Load(object sender, EventArgs e)
        {
            lblTotalLayaway.Text = (Layaway.Amount + Layaway.SalesTaxAmount).ToString("c");

            try
            {
                _builder = new LayawayPaymentHistoryBuilder(Layaway);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error building the payment schedule");
                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "LayawayPaymentHistory_Load errored:  " + exc.Message);
                return;
            }

            lblAmountOutstanding.Text = _builder.GetBalanceOwed().ToString("c");
            lblPaidToDate.Text        = _builder.GetTotalPaid().ToString("c");

            gvPayments.AutoGenerateColumns = false;

            foreach (LayawayHistory history in _builder.ScheduledPayments)
            {
                if (history.Payments.Count == 0)
                {
                    int             idx = gvPayments.Rows.Add();
                    DataGridViewRow row = gvPayments.Rows[idx];
                    row.Cells[this.colPaymentDueDate.Index].Value   = history.PaymentDueDate.ToString("d");
                    row.Cells[this.colPaymentAmountDue.Index].Value = history.PaymentAmountDue.ToString("c");
                }
                else
                {
                    for (int i = 0; i < history.Payments.Count; i++)
                    {
                        LayawayHistoryPaymentInfo paymentInfo = history.Payments.OrderBy(p => p.PaymentMadeOn).ToArray()[i];

                        int             idx = gvPayments.Rows.Add();
                        DataGridViewRow row = gvPayments.Rows[idx];
                        if (i == 0)
                        {
                            row.Cells[this.colPaymentDueDate.Index].Value   = history.PaymentDueDate.ToString("d");
                            row.Cells[this.colPaymentAmountDue.Index].Value = history.PaymentAmountDue.ToString("c");
                        }
                        row.Cells[this.colPaymentMadeOn.Index].Value     = paymentInfo.PaymentMadeOn.ToString("d");
                        row.Cells[this.colPaymentAmountMade.Index].Value = paymentInfo.PaymentAmountMade.ToString("c");
                        row.Cells[this.colBalanceDue.Index].Value        = paymentInfo.BalanceDue.ToString("c");
                        row.Cells[this.colReceiptNumber.Index].Value     = paymentInfo.ReceiptNumber;
                        row.Cells[this.colStatus.Index].Value            = paymentInfo.Status;
                        row.Tag = paymentInfo;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void InitialLayawayCalculateWithDownPaymentTest()
        {
            Builder         = new LayawayPaymentHistoryBuilder();
            Builder.Layaway = Layaway;
            Builder.Calculate();

            // Need to account for the down payment
            Assert.AreEqual(Layaway.NumberOfPayments + 1, Builder.ScheduledPayments.Count);

            // Is the first payment the downpayment
            Assert.AreEqual(1, Builder.ScheduledPayments[0].Payments.Count);
            Assert.IsTrue(Builder.ScheduledPayments[0].IsPaid());
        }
        public void CreateHistoryAndScheduleReport(LayawayPaymentHistoryBuilder layawayPaymentHistoryBuilder, LayawayVO layaway)
        {
            //First get Report Object
            reportObject = GetReportObject("Layaway History And Schedule", (int)LayawayReportIDs.LayawayHistoryAndSchedule, "LayawayHistoryAndSchedule", "LayawayHistoryAndSchedule.PDF");

            //then load the Data to be displayed into the reportObject
            reportObject.LayawayHistoryAndScheduleMainData = GetHistoryAndScheduleReportData(layawayPaymentHistoryBuilder, layaway);
            reportObject.CurrentLayaway = layaway;
            //with the data loaded, now call to create the report and pass the reportObject with the loaded data
            if (reportObject.LayawayHistoryAndScheduleMainData.LayawayScheduleList.Count > 0)
            {
                LayawayReportProcessing.DoReport(reportObject, true, PdfLauncher.Instance);
            }
            //PrintAndStoreReport(layaway);
        }
Exemplo n.º 5
0
        public LayawayPaymentValues(List <LayawayVO> layaways)
        {
            Layaways = layaways;

            InitializeComponent();

            gvPayments.AutoGenerateColumns = false;

            foreach (LayawayVO layaway in layaways)
            {
                LayawayPaymentHistoryBuilder builder;
                try
                {
                    builder = new LayawayPaymentHistoryBuilder(layaway);
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Error building the payment schedule");
                    FileLogger.Instance.logMessage(LogLevel.ERROR, this, "gvPayments_CellLeave errored:  " + exc.Message);
                    continueButton.Enabled = false;
                    gvPayments.ReadOnly    = true;
                    return;
                }

                DataGridViewRow row = gvPayments.Rows.AddNew();
                row.Cells[colNumber.Index].Value = layaway.TicketNumber.ToString();
                DateTime nextPayment = layaway.NextPayment;
                LayawayPaymentHistoryBuilder _builder = new LayawayPaymentHistoryBuilder(layaway);
                if (_builder.ScheduledPayments != null && _builder.ScheduledPayments.Count > 0)
                {
                    var lPaymentDate = (from lPayment in _builder.ScheduledPayments
                                        where lPayment.PaymentDueDate >= ShopDateTime.Instance.ShopDate
                                        select lPayment.PaymentDueDate).FirstOrDefault();
                    if (nextPayment <= ShopDateTime.Instance.ShopDate)
                    {
                        nextPayment = lPaymentDate != DateTime.MinValue ? lPaymentDate : layaway.LastPayment;
                    }
                }
                row.Cells[colDueDate.Index].Value = nextPayment.ToString("d");
                row.Cells[colPayment.Index].Value = builder.GetTotalDueNextPayment(ShopDateTime.Instance.FullShopDateTime).ToString("f2");
                row.Tag = layaway;
            }
        }
Exemplo n.º 6
0
        private void gvPayments_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex != 2)
            {
                return;
            }

            DataGridViewCell paymentAmountCell = gvPayments[2, e.RowIndex];
            LayawayVO        layaway           = gvPayments.Rows[e.RowIndex].Tag as LayawayVO;
            decimal          currentValue      = Utilities.GetDecimalValue(paymentAmountCell.EditedFormattedValue, -1);

            if (currentValue <= 0)
            {
                MessageBox.Show("Invalid payment amount.");
                gvPayments.CancelEdit();
                return;
            }

            LayawayPaymentHistoryBuilder builder;

            try
            {
                builder = new LayawayPaymentHistoryBuilder(layaway);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Error building the payment schedule");
                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "gvPayments_CellLeave errored:  " + exc.Message);
                return;
            }

            if (currentValue > builder.GetBalanceOwed())
            {
                MessageBox.Show("Payment Cannot Exceed Total Owed");
                gvPayments.CancelEdit();
                return;
            }

            gvPayments.CommitEdit(DataGridViewDataErrorContexts.Commit);
        }
        private LayawayReportObject.LayawayHistoryAndScheduleMain GetHistoryAndScheduleReportData(LayawayPaymentHistoryBuilder layawayPaymentHistoryBuilder, LayawayVO layaway)
        {
            var main        = new LayawayReportObject.LayawayHistoryAndScheduleMain();
            var historyList = new List <LayawayReportObject.LayawaySchedule>();

            main.AmountOutstanding = layawayPaymentHistoryBuilder.GetBalanceOwed();
            foreach (var history in layawayPaymentHistoryBuilder.ScheduledPayments)
            {
                var paymentHistory = new LayawayReportObject.LayawaySchedule();
                var detailsList    = new List <LayawayReportObject.LayawayScheduleDetails>();
                var historyDetail  = new LayawayReportObject.LayawayScheduleDetails();
                if (history.Payments.Count == 0)
                {
                    historyDetail.PaymentDateDue   = history.PaymentDueDate;
                    historyDetail.PaymentAmountDue = history.PaymentAmountDue;
                    detailsList.Add(historyDetail);
                }
                else
                {
                    for (int i = 0; i < history.Payments.Count; i++)
                    {
                        if (i > 0)
                        {
                            historyDetail = new LayawayReportObject.LayawayScheduleDetails();
                        }

                        var paymentInfo = history.Payments.OrderBy(p => p.PaymentMadeOn).ToArray()[i];
                        if (i == 0)
                        {
                            historyDetail.PaymentDateDue   = history.PaymentDueDate;
                            historyDetail.PaymentAmountDue = history.PaymentAmountDue;
                        }
                        historyDetail.PaymentMadeOn     = paymentInfo.PaymentMadeOn;
                        historyDetail.PaymentAmountMade = paymentInfo.PaymentAmountMade;
                        historyDetail.BalanceDue        = paymentInfo.BalanceDue;
                        //historyDetail.PaymentType = paymentInfo.PaymentType;
                        historyDetail.ReceiptNumber = paymentInfo.ReceiptNumber;
                        historyDetail.Status        = paymentInfo.Status;
                        detailsList.Add(historyDetail);
                    }
                }
                paymentHistory.LayawayScheduleDetailsList = detailsList;
                historyList.Add(paymentHistory);
            }
            //layawayPaymentHistoryBuilder.
            main.LayawayScheduleList = historyList;
            main.Layaway             = layaway;
            return(main);
        }