Пример #1
0
        /// <summary>
        /// Shows the view.
        /// </summary>
        /// <param name="txn">The TXN.</param>
        private void ShowView(FinancialScheduledTransaction txn)
        {
            if (txn != null)
            {
                hlStatus.Text      = txn.IsActive ? "Active" : "Inactive";
                hlStatus.LabelType = txn.IsActive ? LabelType.Success : LabelType.Danger;

                string rockUrlRoot = ResolveRockUrl("/");

                var detailsLeft = new DescriptionList()
                                  .Add("Person", (txn.AuthorizedPersonAlias != null && txn.AuthorizedPersonAlias.Person != null) ?
                                       txn.AuthorizedPersonAlias.Person.GetAnchorTag(rockUrlRoot) : string.Empty);

                var detailsRight = new DescriptionList()
                                   .Add("Amount", (txn.ScheduledTransactionDetails.Sum(d => (decimal?)d.Amount) ?? 0.0M).FormatAsCurrency())
                                   .Add("Frequency", txn.TransactionFrequencyValue != null ? txn.TransactionFrequencyValue.Value : string.Empty)
                                   .Add("Start Date", txn.StartDate.ToShortDateString())
                                   .Add("End Date", txn.EndDate.HasValue ? txn.EndDate.Value.ToShortDateString() : string.Empty)
                                   .Add("Next Payment Date", txn.NextPaymentDate.HasValue ? txn.NextPaymentDate.Value.ToShortDateString() : string.Empty)
                                   .Add("Last Status Refresh", txn.LastStatusUpdateDateTime.HasValue ? txn.LastStatusUpdateDateTime.Value.ToString("g") : string.Empty);

                detailsLeft.Add("Source", txn.SourceTypeValue != null ? txn.SourceTypeValue.Value : string.Empty);

                if (txn.FinancialPaymentDetail != null && txn.FinancialPaymentDetail.CurrencyTypeValue != null)
                {
                    var paymentMethodDetails = new DescriptionList();

                    var currencyType = txn.FinancialPaymentDetail.CurrencyTypeValue;
                    if (currencyType.Guid.Equals(Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_CREDIT_CARD.AsGuid()))
                    {
                        // Credit Card
                        paymentMethodDetails.Add("Type", currencyType.Value + (txn.FinancialPaymentDetail.CreditCardTypeValue != null ? (" - " + txn.FinancialPaymentDetail.CreditCardTypeValue.Value) : string.Empty));
                        paymentMethodDetails.Add("Name on Card", txn.FinancialPaymentDetail.NameOnCard.Trim());
                        paymentMethodDetails.Add("Account Number", txn.FinancialPaymentDetail.AccountNumberMasked);
                        paymentMethodDetails.Add("Expires", txn.FinancialPaymentDetail.ExpirationDate);
                    }
                    else
                    {
                        // ACH
                        paymentMethodDetails.Add("Type", currencyType.Value);
                        paymentMethodDetails.Add("Account Number", txn.FinancialPaymentDetail.AccountNumberMasked);
                    }

                    detailsLeft.Add("Payment Method", paymentMethodDetails.GetFormattedList("{0}: {1}").AsDelimited("<br/>"));
                }

                GatewayComponent gateway = null;
                if (txn.FinancialGateway != null)
                {
                    gateway = txn.FinancialGateway.GetGatewayComponent();
                    if (gateway != null)
                    {
                        detailsLeft.Add("Payment Gateway", GatewayContainer.GetComponentName(gateway.TypeName));
                    }
                }

                detailsLeft
                .Add("Transaction Code", txn.TransactionCode)
                .Add("Schedule Id", txn.GatewayScheduleId);

                lDetailsLeft.Text  = detailsLeft.Html;
                lDetailsRight.Text = detailsRight.Html;

                gAccountsView.DataSource = txn.ScheduledTransactionDetails.ToList();
                gAccountsView.DataBind();

                var noteType = NoteTypeCache.Read(Rock.SystemGuid.NoteType.SCHEDULED_TRANSACTION_NOTE.AsGuid());
                if (noteType != null)
                {
                    var rockContext = new RockContext();
                    rptrNotes.DataSource = new NoteService(rockContext).Get(noteType.Id, txn.Id)
                                           .Where(n => n.CreatedDateTime.HasValue)
                                           .OrderBy(n => n.CreatedDateTime)
                                           .ToList()
                                           .Select(n => new
                    {
                        n.Caption,
                        Text   = n.Text.ConvertCrLfToHtmlBr(),
                        Person = (n.CreatedByPersonAlias != null && n.CreatedByPersonAlias.Person != null) ? n.CreatedByPersonAlias.Person.FullName : "",
                        Date   = n.CreatedDateTime.HasValue ? n.CreatedDateTime.Value.ToShortDateString() : "",
                        Time   = n.CreatedDateTime.HasValue ? n.CreatedDateTime.Value.ToShortTimeString() : ""
                    })
                                           .ToList();
                    rptrNotes.DataBind();
                }

                lbRefresh.Visible            = gateway != null && gateway.GetScheduledPaymentStatusSupported;
                lbUpdate.Visible             = gateway != null && gateway.UpdateScheduledPaymentSupported;
                lbCancelSchedule.Visible     = txn.IsActive;
                lbReactivateSchedule.Visible = !txn.IsActive && gateway != null && gateway.ReactivateScheduledPaymentSupported;
            }
        }
Пример #2
0
        /// <summary>
        /// Shows the view.
        /// </summary>
        /// <param name="financialScheduledTransaction">The TXN.</param>
        private void ShowView(FinancialScheduledTransaction financialScheduledTransaction)
        {
            if (financialScheduledTransaction == null)
            {
                return;
            }

            hlStatus.Text      = financialScheduledTransaction.IsActive ? "Active" : "Inactive";
            hlStatus.LabelType = financialScheduledTransaction.IsActive ? LabelType.Success : LabelType.Danger;

            string rockUrlRoot = ResolveRockUrl("/");
            Person person      = null;

            if (financialScheduledTransaction.AuthorizedPersonAlias != null)
            {
                person = financialScheduledTransaction.AuthorizedPersonAlias.Person;
            }

            var detailsLeft = new DescriptionList().Add("Person", person);

            var detailsRight = new DescriptionList()
                               .Add("Amount", (financialScheduledTransaction.ScheduledTransactionDetails.Sum(d => ( decimal? )d.Amount) ?? 0.0M).FormatAsCurrency())
                               .Add("Frequency", financialScheduledTransaction.TransactionFrequencyValue != null ? financialScheduledTransaction.TransactionFrequencyValue.Value : string.Empty)
                               .Add("Start Date", financialScheduledTransaction.StartDate.ToShortDateString())
                               .Add("End Date", financialScheduledTransaction.EndDate.HasValue ? financialScheduledTransaction.EndDate.Value.ToShortDateString() : string.Empty)
                               .Add("Next Payment Date", financialScheduledTransaction.NextPaymentDate.HasValue ? financialScheduledTransaction.NextPaymentDate.Value.ToShortDateString() : string.Empty)
                               .Add("Last Status Refresh", financialScheduledTransaction.LastStatusUpdateDateTime.HasValue ? financialScheduledTransaction.LastStatusUpdateDateTime.Value.ToString("g") : string.Empty);

            detailsLeft.Add("Source", financialScheduledTransaction.SourceTypeValue != null ? financialScheduledTransaction.SourceTypeValue.Value : string.Empty);

            if (financialScheduledTransaction.FinancialPaymentDetail != null && financialScheduledTransaction.FinancialPaymentDetail.CurrencyTypeValue != null)
            {
                var paymentMethodDetails = new DescriptionList();

                var currencyType = financialScheduledTransaction.FinancialPaymentDetail.CurrencyTypeValue;
                if (currencyType.Guid.Equals(Rock.SystemGuid.DefinedValue.CURRENCY_TYPE_CREDIT_CARD.AsGuid()))
                {
                    // Credit Card
                    paymentMethodDetails.Add("Type", currencyType.Value + (financialScheduledTransaction.FinancialPaymentDetail.CreditCardTypeValue != null ? (" - " + financialScheduledTransaction.FinancialPaymentDetail.CreditCardTypeValue.Value) : string.Empty));
                    paymentMethodDetails.Add("Name on Card", financialScheduledTransaction.FinancialPaymentDetail.NameOnCard.Trim());
                    paymentMethodDetails.Add("Account Number", financialScheduledTransaction.FinancialPaymentDetail.AccountNumberMasked);
                    paymentMethodDetails.Add("Expires", financialScheduledTransaction.FinancialPaymentDetail.ExpirationDate);
                }
                else
                {
                    // ACH
                    paymentMethodDetails.Add("Type", currencyType.Value);
                    paymentMethodDetails.Add("Account Number", financialScheduledTransaction.FinancialPaymentDetail.AccountNumberMasked);
                }

                detailsLeft.Add("Payment Method", paymentMethodDetails.GetFormattedList("{0}: {1}").AsDelimited("<br/>"));
            }

            GatewayComponent gateway = null;

            if (financialScheduledTransaction.FinancialGateway != null)
            {
                gateway = financialScheduledTransaction.FinancialGateway.GetGatewayComponent();
                if (gateway != null)
                {
                    detailsLeft.Add("Payment Gateway", GatewayContainer.GetComponentName(gateway.TypeName));
                }
            }

            detailsLeft
            .Add("Transaction Code", financialScheduledTransaction.TransactionCode)
            .Add("Schedule Id", financialScheduledTransaction.GatewayScheduleId);

            lSummary.Visible = financialScheduledTransaction.Summary.IsNotNullOrWhiteSpace();
            lSummary.Text    = financialScheduledTransaction.Summary.ConvertCrLfToHtmlBr();

            lDetailsLeft.Text  = detailsLeft.Html;
            lDetailsRight.Text = detailsRight.Html;

            gAccountsView.DataSource = financialScheduledTransaction.ScheduledTransactionDetails.ToList();
            gAccountsView.DataBind();

            btnRefresh.Visible            = gateway != null && gateway.GetScheduledPaymentStatusSupported;
            btnUpdate.Visible             = gateway != null && gateway.UpdateScheduledPaymentSupported;
            btnCancelSchedule.Visible     = financialScheduledTransaction.IsActive;
            btnReactivateSchedule.Visible = !financialScheduledTransaction.IsActive && gateway != null && gateway.ReactivateScheduledPaymentSupported;
        }