Example #1
0
        public void TestRefunds()
        {
            DailyTransactionRange range = es.getTransactionRangeFor(new DateTime(2012, 10, 15));
            Int32 refundCount           = es.getRefundCount(range);

            Assert.AreEqual(1, refundCount);

            List <Int32> txnIds = es.getRefundTransactionIds(range);

            Assert.AreEqual(1, txnIds.Count);

            EaglesoftRefund refund = es.getRefund(txnIds[0]);

            Assert.AreEqual(112.00, refund.Amount);
            Assert.AreEqual("Johnny", refund.FirstName);
            Assert.AreEqual("Grieshaber", refund.LastName);
            Assert.AreEqual("13008 Brown Bark Trail", refund.Address1);
            Assert.IsNull(refund.Address2);
            Assert.AreEqual("Clermont", refund.City);
            Assert.AreEqual("FL", refund.State);
            Assert.AreEqual("34711", refund.Zip);
            Assert.AreEqual("ins check came here (CMN/14124/247649)", refund.Description);
            Assert.AreEqual(new EaglesoftAdjustmentType()
            {
                Id = 3
            }, refund.AdjustmentType);
        }
        private void LoadEaglesoftDataWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Eaglesoft    es           = new Eaglesoft();
            DailyDeposit dailyDeposit = new DailyDeposit(Date);

            try
            {
                if (CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                es.Connect();
                DailyTransactionRange range = es.getTransactionRangeFor(Date);
                if (range == null)
                {
                    ReportProgress(100, "No data available");
                    return;
                }
                queryCount      = 0;
                totalQueryCount = es.getPaymentCount(range) + es.getRefundCount(range);

                List <EaglesoftBulkPayment> bulkPaymentsProcessed = new List <EaglesoftBulkPayment>();
                List <Int32> paymentTxnIds = es.getPaymentTransactionIds(range);
                List <Int32> refundTxnIds  = es.getRefundTransactionIds(range);
                e.Result = dailyDeposit;

                foreach (Int32 paymentTxnId in paymentTxnIds)
                {
                    EaglesoftPayment     payment     = es.getPayment(paymentTxnId);
                    EaglesoftBulkPayment bulkPayment = payment as EaglesoftBulkPayment;
                    queryCount++;

                    if (bulkPayment == null)
                    {
                        dailyDeposit.addPayment(payment);
                        ReportProgress(calculatePercentageComplete(), String.Format("{0}", payment));
                    }
                    else if (bulkPayment != null && bulkPaymentsProcessed.Contains(bulkPayment) == false)
                    {
                        dailyDeposit.addPayment(payment);
                        ReportProgress(calculatePercentageComplete(), String.Format("{0}", payment));
                    }

                    if (bulkPayment != null)
                    {
                        bulkPaymentsProcessed.Add(bulkPayment);
                    }

                    if (CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                }

                foreach (Int32 refundTxnId in refundTxnIds)
                {
                    EaglesoftRefund refund = es.getRefund(refundTxnId);
                    dailyDeposit.addRefund(refund);
                    queryCount++;
                    ReportProgress(calculatePercentageComplete(), String.Format("{0}", refund));
                    if (CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            finally
            {
                if (es != null)
                {
                    es.Disconnect();
                }
            }
        }