Exemplo n.º 1
0
        private PaymentInfo PopulatePaymentInfo()
        {
            var pi = person.PaymentInfo();

            if (pi == null)
            {
                return(new PaymentInfo());
            }

            CreditCard           = pi.MaskedCard;
            Account              = pi.MaskedAccount;
            Expires              = pi.Expires;
            Routing              = Util.Mask(new StringBuilder(pi.Routing), 2);
            NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool();
            Type = pi.PreferredGivingType;
            if (NoCreditCardsAllowed)
            {
                Type = PaymentType.Ach; // bank account only
            }
            else if (NoEChecksAllowed)
            {
                Type = PaymentType.CreditCard; // credit card only
            }
            Type = NoEChecksAllowed ? PaymentType.CreditCard : Type;
            ClearMaskedNumbers(pi);
            total = FundItem.Sum(ff => ff.Value) ?? 0;

            return(pi);
        }
Exemplo n.º 2
0
        public ManageGivingModel(int pid, int orgid = 0)
            : this()
        {
            this.pid   = pid;
            this.orgid = orgid;
            var rg = person.ManagedGiving();
            var pi = person.PaymentInfo();

            if (rg != null && pi != null)
            {
                SemiEvery = rg.SemiEvery;
                StartWhen = rg.StartWhen;
                StopWhen  = null; //rg.StopWhen;
                Day1      = rg.Day1;
                Day2      = rg.Day2;
                EveryN    = rg.EveryN;
                Period    = rg.Period;
                foreach (var ra in person.RecurringAmounts.AsEnumerable())
                {
                    FundItem.Add(ra.FundId, ra.Amt);
                }
                Cardnumber           = pi.MaskedCard;
                Account              = pi.MaskedAccount;
                Expires              = pi.Expires;
                Cardcode             = Util.Mask(new StringBuilder(pi.Ccv), 0);
                Routing              = Util.Mask(new StringBuilder(pi.Routing), 2);
                NextDate             = rg.NextDate;
                NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool();
                Type = pi.PreferredGivingType;
                if (NoCreditCardsAllowed)
                {
                    Type = "B"; // bank account only
                }
                else if (NoEChecksAllowed)
                {
                    Type = "C"; // credit card only
                }
                Type = NoEChecksAllowed ? "C" : Type;
            }
            else if (Setting.ExtraValueFeeName.HasValue())
            {
                var f = CmsWeb.Models.OnlineRegPersonModel.Funds().SingleOrDefault(ff => ff.Text == Setting.ExtraValueFeeName);
                // reasonable defaults
                Period    = "M";
                SemiEvery = "E";
                EveryN    = 1;
                var evamt = person.GetExtra(Setting.ExtraValueFeeName).ToDecimal();
                if (f != null && evamt > 0)
                {
                    FundItem.Add(f.Value.ToInt(), evamt);
                }
            }
            if (pi == null)
            {
                pi = new PaymentInfo();
            }
            FirstName = pi.FirstName ?? person.FirstName;
            Middle    = (pi.MiddleInitial ?? person.MiddleName).Truncate(1);
            LastName  = pi.LastName ?? person.LastName;
            Suffix    = pi.Suffix ?? person.SuffixCode;
            Address   = pi.Address ?? person.PrimaryAddress;
            City      = pi.City ?? person.PrimaryCity;
            State     = pi.State ?? person.PrimaryState;
            Zip       = pi.Zip ?? person.PrimaryZip;
            Phone     = pi.Phone ?? person.HomePhone ?? person.CellPhone;

            total = FundItem.Sum(ff => ff.Value) ?? 0;
        }