internal static void FinishBundle(BundleHeader bh)
 {
     bh.TotalChecks = bh.BundleDetails.Sum(d => d.Contribution.ContributionAmount);
     bh.TotalCash = 0;
     bh.TotalEnvelopes = 0;
     DbUtil.Db.SubmitChanges();
 }
Esempio n. 2
0
        private void ParseBatchHeader(string line)
        {
            var companyName = line.Substring(4, 16).Trim();
            var discretionaryData = line.Substring(20, 20).Trim();
            _batchDate = DateTime.ParseExact(line.Substring(69, 6).Trim(), "yyMMdd", CultureInfo.InvariantCulture);
            var bankBatchNumber = int.Parse(line.Substring(87, 7).Trim());

            _bundleHeader = BatchImportContributions.GetBundleHeader(_batchDate, DateTime.Now);
        }
 internal static BundleHeader GetBundleHeader(DateTime date, DateTime now, int? btid = null)
 {
     var bh = new BundleHeader
     {
         BundleHeaderTypeId = BundleTypeCode.PreprintedEnvelope,
         BundleStatusId = BundleStatusCode.Open,
         ContributionDate = date,
         CreatedBy = Util.UserId,
         CreatedDate = now,
         FundId = DbUtil.Db.Setting("DefaultFundId", "1").ToInt()
     };
     DbUtil.Db.BundleHeaders.InsertOnSubmit(bh);
     bh.BundleStatusId = BundleStatusCode.Open;
     bh.BundleHeaderTypeId = btid ?? BundleTypeCode.ChecksAndCash;
     return bh;
 }
Esempio n. 4
0
 public ActionResult NewBundle()
 {
     var dt = Util.Now.Date;
     var dw = (int)dt.DayOfWeek;
     dt = dt.AddDays(-dw);
     var b = new BundleHeader
     {
         BundleHeaderTypeId = DbUtil.Db.Setting("DefaultBundleTypeId", BundleTypeCode.PreprintedEnvelope.ToString()).ToInt(),
         BundleStatusId = BundleStatusCode.Open,
         ChurchId = 1,
         ContributionDate = dt,
         CreatedBy = Util.UserId1,
         CreatedDate = Util.Now,
         RecordStatus = false,
         FundId = DbUtil.Db.Setting("DefaultFundId", "1").ToInt(), 
     };
     DbUtil.Db.BundleHeaders.InsertOnSubmit(b);
     DbUtil.Db.SubmitChanges();
     TempData["createbundle"] = true;
     return Redirect("/Bundle/" + b.BundleHeaderId);
 }
 public void FinishBundle(BundleHeader bh)
 {
     Contribution.FinishBundle(db, bh);
 }
Esempio n. 6
0
        public Contribution PostUnattendedContribution(CMSDataContext Db, decimal Amt, int? Fund, string Description, bool pledge = false, int? typecode = null, int? tranid = null)
        {
            if (!typecode.HasValue)
            {
                typecode = BundleTypeCode.Online;
                if (pledge)
                    typecode = BundleTypeCode.OnlinePledge;
            }

            var now = Util.Now;
            var d = now.Date;
            BundleHeader bundle = null;

            var spec = Db.Setting("OnlineContributionBundleDayTime", "");
            if (Util.HasValue(spec))
            {
                var a = spec.SplitStr(" ", 2);
                try
                {
                    var next = DateTime.Parse(now.ToShortDateString() + " " + a[1]);
                    var dow = Enum.Parse(typeof(DayOfWeek), a[0], ignoreCase: true);
                    next = next.Sunday().Add(next.TimeOfDay).AddDays(dow.ToInt());
                    if(now > next)
                        next = next.AddDays(7);
                    var prev = next.AddDays(-7);
                    var bid = BundleTypeCode.MissionTrip == typecode
                        ? Db.GetCurrentMissionTripBundle(next, prev)
                        : Db.GetCurrentOnlineBundle(next, prev);
                    bundle = Db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid);
                }
                catch (Exception)
                {
                    spec = "";
                }
            }
            if(!Util.HasValue(spec))
            {
                var nextd = d.AddDays(1);
                var bid = BundleTypeCode.MissionTrip == typecode
                    ? Db.GetCurrentMissionTripBundle(nextd, d)
                    : Db.GetCurrentOnlineBundle(nextd, d);
                bundle = Db.BundleHeaders.SingleOrDefault(bb => bb.BundleHeaderId == bid);
            }
            if (bundle == null)
            {
                bundle = new BundleHeader
                {
                    BundleHeaderTypeId = typecode.Value,
                    BundleStatusId = BundleStatusCode.Open,
                    CreatedBy = Util.UserId1,
                    ContributionDate = d,
                    CreatedDate = now,
                    FundId = Db.Setting("DefaultFundId", "1").ToInt(),
                    RecordStatus = false,
                    TotalCash = 0,
                    TotalChecks = 0,
                    TotalEnvelopes = 0,
                    BundleTotal = 0
                };
                Db.BundleHeaders.InsertOnSubmit(bundle);
            }
            if (!Fund.HasValue)
                Fund = Db.Setting("DefaultFundId", "1").ToInt();
            var fundtouse = (from f in Db.ContributionFunds
                where f.FundId == Fund
                select f).SingleOrDefault();

            //failsafe if fund is not found
            if(fundtouse == null)
                Fund = (from f in Db.ContributionFunds
                        where f.FundStatusId == 1
                        orderby f.FundId
                        select f.FundId).First();

            var FinanceManagerId = Db.Setting("FinanceManagerId", "").ToInt2();
            if (!FinanceManagerId.HasValue)
            {
                var qu = from u in Db.Users
                         where u.UserRoles.Any(ur => ur.Role.RoleName == "Finance")
                         orderby u.Person.LastName
                         select u.UserId;
                FinanceManagerId = qu.FirstOrDefault();
                if (!FinanceManagerId.HasValue)
                    FinanceManagerId = 1;
            }
            var bd = new BundleDetail
            {
                BundleHeaderId = bundle.BundleHeaderId,
                CreatedBy = FinanceManagerId.Value,
                CreatedDate = now,
            };
            var typid = ContributionTypeCode.CheckCash;
            if (pledge)
                typid = ContributionTypeCode.Pledge;
            bd.Contribution = new Contribution
            {
                CreatedBy = FinanceManagerId.Value,
                CreatedDate = bd.CreatedDate,
                FundId = Fund.Value,
                PeopleId = PeopleId,
                ContributionDate = bd.CreatedDate,
                ContributionAmount = Amt,
                ContributionStatusId = 0,
                ContributionTypeId = typid,
                ContributionDesc = Description,
                TranId = tranid,
                Source = Util2.FromMobile.HasValue() ? 1 : (int?)null
            };
            bundle.BundleDetails.Add(bd);
            Db.SubmitChanges();
            if(fundtouse == null)
                Db.LogActivity($"FundNotFound Used fund #{Fund} on contribution #{bd.ContributionId}");
            return bd.Contribution;
        }
Esempio n. 7
0
 private void detach_BundleHeaders(BundleHeader entity)
 {
     this.SendPropertyChanging();
     entity.BundleHeaderType = null;
 }
Esempio n. 8
0
 private void attach_BundleHeaders(BundleHeader entity)
 {
     this.SendPropertyChanging();
     entity.Fund = this;
 }
Esempio n. 9
0
 private void detach_BundleHeaders(BundleHeader entity)
 {
     this.SendPropertyChanging();
     entity.BundleHeaderType = null;
 }
Esempio n. 10
0
 private void attach_BundleHeaders(BundleHeader entity)
 {
     this.SendPropertyChanging();
     entity.Fund = this;
 }
Esempio n. 11
0
        private static int? BatchProcessMagTek(string lines, DateTime date)
        {
            var now = DateTime.Now;
            var bh = new BundleHeader
            {
                BundleHeaderTypeId = BundleTypeCode.ChecksAndCash,
                BundleStatusId = BundleStatusCode.Open,
                ContributionDate = date,
                CreatedBy = Util.UserId,
                CreatedDate = now,
                FundId = DbUtil.Db.Setting("DefaultFundId", "1").ToInt()
            };
            DbUtil.Db.BundleHeaders.InsertOnSubmit(bh);

            var re = new Regex(
            @"(T(?<rt>[\d?]+)T(?<ac>[\d ?]*)U\s*(?<ck>[\d?]+))|
            (CT(?<rt>[\d?]+)A(?<ac>[\d ?]*)C(?<ck>[\d?]+)M)",
                RegexOptions.IgnoreCase);
            var m = re.Match(lines);
            while (m.Success)
            {
                var rt = m.Groups["rt"].Value;
                var ac = m.Groups["ac"].Value;
                var ck = m.Groups["ck"].Value;
                var bd = new CmsData.BundleDetail
                {
                    CreatedBy = Util.UserId,
                    CreatedDate = now,
                };
                bh.BundleDetails.Add(bd);
                var qf = from f in DbUtil.Db.ContributionFunds
                         where f.FundStatusId == 1
                         orderby f.FundId
                         select f.FundId;

                bd.Contribution = new Contribution
                {
                    CreatedBy = Util.UserId,
                    CreatedDate = now,
                    ContributionDate = date,
                    FundId = qf.First(),
                    ContributionStatusId = 0,
                    ContributionTypeId = ContributionTypeCode.CheckCash,
                };
                bd.Contribution.ContributionDesc = ck;
                var eac = Util.Encrypt(rt + "," + ac);
                var q = from kc in DbUtil.Db.CardIdentifiers
                        where kc.Id == eac
                        select kc.PeopleId;
                var pid = q.SingleOrDefault();
                if (pid != null)
                    bd.Contribution.PeopleId = pid;
                bd.Contribution.BankAccount = eac;
                bd.Contribution.ContributionDesc = ck;

                m = m.NextMatch();
            }
            bh.TotalChecks = 0;
            bh.TotalCash = 0;
            bh.TotalEnvelopes = 0;
            DbUtil.Db.SubmitChanges();
            return bh.BundleHeaderId;
        }
Esempio n. 12
0
File: Person.cs Progetto: vs06/bvcms
        public Contribution PostUnattendedContribution(CMSDataContext Db, decimal Amt, int? Fund, string Description, bool pledge = false, int? typecode = null)
        {
            if (!typecode.HasValue)
            {
                typecode = BundleTypeCode.Online;
                if (pledge)
                    typecode = BundleTypeCode.OnlinePledge;
            }

            var now = DateTime.Now;
            var d = Util.Now.Date;
            var q = from b in Db.BundleHeaders
                    where b.BundleHeaderTypeId == typecode
                    where b.BundleStatusId == BundleStatusCode.Open
                    where b.ContributionDate >= d
                    where b.ContributionDate < now
                    where b.ContributionDate.Year == now.Year
                    where b.ContributionDate.Month == now.Month
                    orderby b.ContributionDate descending
                    select b;
            var bundle = q.FirstOrDefault();
            if (bundle == null)
            {
                bundle = new BundleHeader
                {
                    BundleHeaderTypeId = typecode.Value,
                    BundleStatusId = BundleStatusCode.Open,
                    CreatedBy = Util.UserId1,
                    ContributionDate = d,
                    CreatedDate = now,
                    FundId = Db.Setting("DefaultFundId", "1").ToInt(),
                    RecordStatus = false,
                    TotalCash = 0,
                    TotalChecks = 0,
                    TotalEnvelopes = 0,
                    BundleTotal = 0
                };
                Db.BundleHeaders.InsertOnSubmit(bundle);
            }
            if (!Fund.HasValue)
                Fund = (from f in Db.ContributionFunds
                        where f.FundStatusId == 1
                        orderby f.FundId
                        select f.FundId).First();

            var FinanceManagerId = Db.Setting("FinanceManagerId", "").ToInt2();
            if (!FinanceManagerId.HasValue)
            {
                var qu = from u in Db.Users
                         where u.UserRoles.Any(ur => ur.Role.RoleName == "Finance")
                         orderby u.Person.LastName
                         select u.UserId;
                FinanceManagerId = qu.FirstOrDefault();
                if (!FinanceManagerId.HasValue)
                    FinanceManagerId = 1;
            }
            var bd = new CmsData.BundleDetail
            {
                BundleHeaderId = bundle.BundleHeaderId,
                CreatedBy = FinanceManagerId.Value,
                CreatedDate = now,
            };
            var typid = ContributionTypeCode.CheckCash;
            if (pledge)
                typid = ContributionTypeCode.Pledge;
            bd.Contribution = new Contribution
            {
                CreatedBy = FinanceManagerId.Value,
                CreatedDate = bd.CreatedDate,
                FundId = Fund.Value,
                PeopleId = PeopleId,
                ContributionDate = bd.CreatedDate,
                ContributionAmount = Amt,
                ContributionStatusId = 0,
                ContributionTypeId = typid,
                ContributionDesc = Description,
            };
            bundle.BundleDetails.Add(bd);
            Db.SubmitChanges();
            return bd.Contribution;
        }
Esempio n. 13
0
 private void attach_BundleHeaders(BundleHeader entity)
 {
     this.SendPropertyChanging();
     entity.BundleStatusType = this;
 }
Esempio n. 14
0
		private void attach_BundleHeaders(BundleHeader entity)
		{
			this.SendPropertyChanging();
			entity.BundleStatusType = this;
		}
Esempio n. 15
0
 public BundleHeader NewBundle()
 {
     var dt = Util.Now.Date;
     var dw = (int)dt.DayOfWeek;
     dt = dt.AddDays(-dw);
     var b = new BundleHeader
     {
         BundleHeaderTypeId = BundleTypeCode.PreprintedEnvelope,
         BundleStatusId = BundleStatusCode.Open,
         ChurchId = 1,
         ContributionDate = dt,
         CreatedBy = Util.UserId1,
         CreatedDate = Util.Now,
         RecordStatus = false,
         FundId = DbUtil.Db.Setting("DefaultFundId", "1").ToInt(),
     };
     DbUtil.Db.BundleHeaders.InsertOnSubmit(b);
     DbUtil.Db.SubmitChanges();
     return b;
 }