예제 #1
0
        private static int?BatchProcessVanco2(CsvReader csv, DateTime date, int?fundid)
        {
            var fundList = (from f in DbUtil.Db.ContributionFunds
                            orderby f.FundId
                            select f.FundId).ToList();

            var          cols      = csv.GetFieldHeaders();
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid != null && fundList.Contains(fundid ?? 0) ? fundid ?? 0 : firstfund;

            while (csv.ReadNextRecord())
            {
                var routing  = "0";
                var checkno  = "0";
                var account  = csv[0];
                var amount   = csv[7];
                var fundText = csv[11];

                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                var f  = DbUtil.Db.FetchOrCreateFund(fundText);
                var bd = BatchImportContributions.AddContributionDetail(date, f.FundId, amount, checkno, routing, account);

                bh.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh.BundleHeaderId);
        }
예제 #2
0
        private static int?BatchProcessEnon(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh  = null;
            var          fid = fundid ?? BatchImportContributions.FirstFundId();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                var dt     = csv[1].ToDate();
                var amount = csv[6];
                if (!amount.HasValue() || !dt.HasValue)
                {
                    continue;
                }

                var account = csv[4];
                var checkno = csv[5];

                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(dt.Value, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(date, fid, amount, checkno, "", account);

                bh.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh.BundleHeaderId);
        }
예제 #3
0
        private static int?BatchProcessFbcFayetteville(CsvReader csv, DateTime date, int?fundid)
        {
            var          cols      = csv.GetFieldHeaders();
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            while (csv.ReadNextRecord())
            {
                if (csv[6].StartsWith("Total Checks"))
                {
                    continue;
                }
                var routing = csv[4];
                var account = csv[5];
                var checkno = csv[6];
                var amount  = csv[7];

                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(date, fund, amount, checkno, routing, account);
                bh.BundleDetails.Add(bd);
            }
            if (bh == null)
            {
                return(null);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #4
0
        private static int?BatchProcessAbundantLife(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh  = null;
            var          fid = fundid ?? BatchImportContributions.FirstFundId();

            var prevbatch = "";

            while (csv.ReadNextRecord())
            {
                var batch = csv[5];
                if (bh == null || batch != prevbatch)
                {
                    if (bh != null)
                    {
                        BatchImportContributions.FinishBundle(bh);
                    }
                    bh        = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                    prevbatch = batch;
                    continue; // the first row of a batch is a total row
                }
                var amount  = csv[3];
                var routing = csv[8];
                var account = csv[9];
                var checkno = csv[10];
                var bd      = BatchImportContributions.AddContributionDetail(date, fid, amount, checkno, routing, account);
                bh.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh?.BundleHeaderId);
        }
예제 #5
0
        private static int?BatchProcess(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh   = null;
            var          fid  = fundid ?? BatchImportContributions.FirstFundId();
            var          now  = DateTime.Now;
            var          list = new List <DepositRecord>();

            bh = BatchImportContributions.GetBundleHeader(date, now);
            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                var Amount  = csv["Amount"];
                var Date    = csv["Processing Date"].ToDate() ?? DateTime.Today;
                var Account = csv["Account"];
                var Routing = csv["RT"];
                var CheckNo = csv["Check"];

                var bd = BatchImportContributions.AddContributionDetail(Date, fid, Amount, CheckNo, Routing, Account);
                bd.Contribution.PostingDate = now;
                bh.BundleDetails.Add(bd);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh?.BundleHeaderId ?? 0);
        }
예제 #6
0
        private static int?BatchProcessHollyCreek(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            // 0 Amount, 1 Account, 2 Serial, 3 RoutingNumber, 4 TransmissionDate, 5 DepositTotal"))
            while (csv.ReadNextRecord())
            {
                var amount  = csv[0];
                var account = csv[1];
                var checkno = csv[2];
                var routing = csv[3];
                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }
                var bd = BatchImportContributions.AddContributionDetail(date, fund, amount, checkno, routing, account);
                bh.BundleDetails.Add(bd);
            }
            if (bh == null)
            {
                return(null);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #7
0
        private static int?BatchProcessFirstState(CsvReader csv, DateTime date, int?fundid)
        {
            var          cols      = csv.GetFieldHeaders();
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();

            var list = new List <DepositRecord>();

/*
 *  Deposit Item
 *  Sequence #
 *  Item Date
 *  Item Status
 *  Customer Name
 *  Routing / Account #
 *  Check #
 *  Amount
 *  Deposit As
 *  Amount Source
 *  Image Quality Pass
 *  Scanned Count
 */
            while (csv.ReadNextRecord())
            {
                var a = csv[5].Split('/');
                list.Add(new DepositRecord()
                {
                    Date    = csv[2].ToDate(),
                    Routing = a[0].Trim(),
                    Account = a[1].Trim(),
                    Amount  = csv[7],
                    CheckNo = csv[6],
                    Row     = csv[1].ToInt(),
                    Valid   = csv[3].Trim() == "Deposited"
                });
            }
            DateTime?prevbatch = null;

            foreach (var r in list.Where(rr => rr.Valid).OrderBy(rr => rr.Row))
            {
                if (r.Date != prevbatch)
                {
                    if (bh != null)
                    {
                        BatchImportContributions.FinishBundle(bh);
                    }
                    bh             = BatchImportContributions.GetBundleHeader(r.Date ?? date, DateTime.Now, BundleTypeCode.Online);
                    bh.DepositDate = r.Date;
                    prevbatch      = r.Date;
                }

                BundleDetail bd;

                bd = BatchImportContributions.AddContributionDetail(r.Date ?? date, fundid ?? firstfund, r.Amount, r.CheckNo, r.Routing, r.Account);
                bh.BundleDetails.Add(bd);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #8
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);
        }
예제 #9
0
        private static int?Import(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bundleHeader = null;
            var          fid          = fundid ?? BatchImportContributions.FirstFundId();

            var details = new List <BundleDetail>();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                if (csv[0].EndsWith("ENDTRNS"))
                {
                    continue;
                }

                var amount = csv[6];
                var dt     = csv[3].ToDate();
                if (!amount.HasValue())
                {
                    continue;
                }

                var fund = csv[4];
                int ffid = !fund.HasValue() ? fid : DbUtil.Db.FetchOrCreateFund(fund).FundId;

                var name    = csv[5];
                var address = csv[12];
                var city    = csv[13];
                var st      = csv[14];
                var zip     = csv[15];

                if (bundleHeader == null)
                {
                    bundleHeader = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(dt ?? date, ffid, amount, null, "", $"{name};{address}");
                details.Add(bd);
                bd.Contribution.ContributionDesc = $"{name};{address},{city},{st},{zip}";
            }

            details.Reverse();
            if (bundleHeader != null)
            {
                foreach (var bd in details)
                {
                    bundleHeader.BundleDetails.Add(bd);
                }

                BatchImportContributions.FinishBundle(bundleHeader);
                return(bundleHeader.BundleHeaderId);
            }
            return(null);
        }
예제 #10
0
        private static int?BatchProcessAbundantLife(CsvReader csv, DateTime date, int?fundid)
        {
            var          db = DbUtil.Db;
            BundleHeader bh = null;

            csv.MissingFieldAction = MissingFieldAction.ReplaceByEmpty;

            var fid = fundid ?? BatchImportContributions.FirstFundId();

            var prevbatch = "";

            while (csv.ReadNextRecord())
            {
                if (!csv[Columns.TransNumber.ToInt()].HasValue())
                {
                    continue; // skip summary rows
                }

                var batch = csv[Columns.BatchId.ToInt()];
                if (bh == null || batch != prevbatch)
                {
                    if (bh != null)
                    {
                        BatchImportContributions.FinishBundle(bh);
                    }
                    bh        = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                    prevbatch = batch;
                }

                var amount = csv[Columns.GrossAmount.ToInt()];

                var bd = new BundleDetail
                {
                    CreatedBy   = db.UserId,
                    CreatedDate = DateTime.Now
                };

                bd.Contribution = new Contribution
                {
                    CreatedBy            = db.UserId,
                    CreatedDate          = DateTime.Now,
                    ContributionDate     = date,
                    FundId               = fid,
                    ContributionStatusId = ContributionStatusCode.Recorded,
                    ContributionTypeId   = ContributionTypeCode.CheckCash,
                    ContributionAmount   = amount.GetAmount()
                };

                bh.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh?.BundleHeaderId);
        }
예제 #11
0
        private static int?BatchProcess(CsvReader csv, DateTime date, int?fundid)
        {
            var          prevdt = DateTime.MinValue;
            BundleHeader bh     = null;
            var          fid    = fundid ?? BatchImportContributions.FirstFundId();

            var rows = new List <Row>();

            var n = 0;

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                n += 1;
                if (!csv[4].HasValue())
                {
                    continue;
                }
                var row = new Row
                {
                    N      = n,
                    Dt     = csv[1].ToDate() ?? date,
                    Amount = csv[4],
                    Pid    = csv[2].ToInt(),
                    Fund   = csv[5].ToInt2() ?? fid
                };
                rows.Add(row);
            }

            var q = from row in rows
                    orderby row.Dt, row.N
            select row;

            foreach (var row in q)
            {
                if (bh == null || row.Dt != prevdt)
                {
                    if (bh != null)
                    {
                        BatchImportContributions.FinishBundle(bh);
                    }
                    bh     = BatchImportContributions.GetBundleHeader(row.Dt, DateTime.Now);
                    prevdt = row.Dt;
                }
                var bd = BatchImportContributions.AddContributionDetail(row.Dt, row.Fund, row.Amount, row.Pid);
                bh.BundleDetails.Add(bd);
                bd.Contribution.PostingDate = date;
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh?.BundleHeaderId ?? 1);
        }
예제 #12
0
        private static int?BatchProcessKindred(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            var list = new List <DepositRecord>();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                if (csv[14] == "Completed")
                {
                    var desc = csv[13].HasValue()
                        ? $"keyword={csv[13]}; {csv[2]}; {csv[3]}, {csv[4]}, {csv[5]} {csv[6]}; {csv[8]}"
                        : $"{csv[2]}; {csv[3]}, {csv[4]}, {csv[5]} {csv[6]}; {csv[8]}";
                    list.Add(new DepositRecord()
                    {
                        Date        = csv[1].ToDate(),
                        Account     = csv[7],
                        Amount      = csv[9],
                        CheckNo     = csv[12],
                        Description = desc,
                    });
                }
            }
            var q = from r in list
                    select r;

            foreach (var r in q)
            {
                var dt = DateTime.Parse("1/1/1980");
                if (r.Date.HasValue)
                {
                    dt = r.Date.Value;
                }
                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(dt.Date, DateTime.Now);
                }
                var bd = BatchImportContributions.AddContributionDetail(dt, fund, r.Amount, r.CheckNo, "", r.Account);
                bd.Contribution.ContributionDesc = r.Description;
                bh.BundleDetails.Add(bd);
            }
            if (bh == null)
            {
                return(null);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #13
0
        private static int?BatchProcessText2Give(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            var list = new List <DepositRecord>();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                if (csv[28].Equal("collected"))
                {
                    var dt   = Regex.Match(csv[24] ?? "", @"(\d{1,2}/\d{1,2}/\d{4} \d+:\d+:\d+ [A-P]M)").Value.ToDate();
                    var desc = $"{csv[8]}, {csv[9]}, {csv[10]}, {csv[16]}, {csv[17]}";
                    list.Add(new DepositRecord()
                    {
                        Date        = dt,
                        Account     = csv[18],
                        Amount      = csv[2],
                        CheckNo     = csv[0],
                        Description = desc,
                    });
                }
            }
            var q = from r in list
                    select r;

            foreach (var r in q)
            {
                var dt = DateTime.Parse("1/1/1980");
                if (r.Date.HasValue)
                {
                    dt = r.Date.Value;
                }
                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(dt.Date, DateTime.Now);
                }
                var bd = BatchImportContributions.AddContributionDetail(dt, fund, r.Amount, r.CheckNo, "", r.Account);
                bd.Contribution.ContributionDesc = r.Description;
                bh.BundleDetails.Add(bd);
            }
            if (bh == null)
            {
                return(null);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #14
0
        private static int?Import(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bundleHeader = null;
            var          fid          = fundid ?? BatchImportContributions.FirstFundId();

            var details = new List <BundleDetail>();

            while (csv.ReadNextRecord())
            {
                var batchDate = csv[2].ToDate();
                var amount    = csv[5];

                var paymentMethod = csv[7];
                var payerName     = csv[8];

                if (bundleHeader == null)
                {
                    bundleHeader = BatchImportContributions.GetBundleHeader(batchDate.Value, DateTime.Now);
                }

                var bd = BatchImportContributions.NewBundleDetail(date, fid, amount);

                var eac = Util.Encrypt(paymentMethod);
                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      = paymentMethod;
                bd.Contribution.ContributionDesc = payerName;

                details.Add(bd);
            }

            details.Reverse();
            foreach (var bd in details)
            {
                bundleHeader.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bundleHeader);

            return(bundleHeader.BundleHeaderId);
        }
        private static int?BatchProcess(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh   = null;
            var          fid  = fundid ?? BatchImportContributions.FirstFundId();
            var          now  = DateTime.Now;
            var          list = new List <Record>();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                if (csv[0] != "Deposit") // Type
                {
                    continue;
                }

                var rec = new Record
                {
                    CheckNo   = csv[2],          //Num
                    Identifer = csv[3],          //Name
                    Dt        = csv[4].ToDate(), //Memo
                    Fund      = csv[6],          //Split
                    Amount    = csv[7],          //Amount
                };
                list.Add(rec);
            }
            foreach (var rec in list)
            {
                if (!rec.Dt.HasValue)
                {
                    continue;
                }

                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(date, now);
                }

                var f  = DbUtil.Db.FetchOrCreateFund(rec.Fund);
                var bd = BatchImportContributions.AddContributionDetail(rec.Dt.Value, f.FundId, rec.Amount, rec.CheckNo, "", rec.Identifer);
                bd.Contribution.PostingDate = now;
                bh.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh?.BundleHeaderId ?? 0);
        }
예제 #16
0
        private static int?BatchProcessFcchudson(CsvReader csv, DateTime date, int?fundid)
        {
            var          cols      = csv.GetFieldHeaders();
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            var list = new List <DepositRecord>();

            while (csv.ReadNextRecord())
            {
                list.Add(new DepositRecord()
                {
                    Batch   = csv[0],
                    Routing = csv[1],
                    Account = csv[2],
                    Amount  = csv[3],
                    CheckNo = csv[4],
                    Type    = csv[5],
                });
            }
            var q = from r in list
                    where r.Type == "Check"
                    select r;
            var prevbatch = "";

            foreach (var r in q)
            {
                if (r.Batch != prevbatch)
                {
                    if (bh != null)
                    {
                        BatchImportContributions.FinishBundle(bh);
                    }
                    bh        = BatchImportContributions.GetBundleHeader(r.Batch.ToDate().Value, DateTime.Now);
                    prevbatch = r.Batch;
                }
                var bd = BatchImportContributions.AddContributionDetail(date, fund, r.Amount, r.CheckNo, r.Routing, r.Account);
                bh.BundleDetails.Add(bd);
            }
            if (bh == null)
            {
                return(null);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #17
0
        private static int?Import(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bundleHeader = null;
            var          fid          = fundid ?? BatchImportContributions.FirstFundId();

            var details = new List <BundleDetail>();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                var amount = csv["give_amount"];
                var dt     = csv["date"].ToDate();
                if (!amount.HasValue())
                {
                    continue;
                }

                var fund = csv["fund"];
                var ffid = DbUtil.Db.ContributionFunds.FirstOrDefault(f => f.FundName == fund && f.FundStatusId == 1)?.FundId ?? fid;
                var pid  = GetPersonByEmail(csv["email"]);
                var desc = $"{csv["first_name"]} {csv["last_name"]};{csv["email"]}";

                if (bundleHeader == null)
                {
                    bundleHeader = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(dt ?? date, ffid, amount, null, "", desc);
                details.Add(bd);
                bd.Contribution.PeopleId         = pid;
                bd.Contribution.ContributionDesc = desc;
            }

            details.Reverse();
            if (bundleHeader != null)
            {
                foreach (var bd in details)
                {
                    bundleHeader.BundleDetails.Add(bd);
                }

                BatchImportContributions.FinishBundle(bundleHeader);
                return(bundleHeader.BundleHeaderId);
            }
            return(null);
        }
예제 #18
0
        private static int?BatchProcessMetropolitan(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            var list = new List <DepositRecord>();

            while (csv.ReadNextRecord())
            {
                list.Add(new DepositRecord()
                {
                    Type    = csv[13],
                    Batch   = csv[0],
                    Routing = csv[17],
                    Account = csv[16],
                    CheckNo = csv[15],
                    Amount  = csv[14],
                });
            }
            var q = from r in list
                    where r.Type.Equal("debit")
                    orderby r.Batch
                    select r;
            var prevbatch = "";

            foreach (var r in q)
            {
                if (r.Batch != prevbatch)
                {
                    if (bh != null)
                    {
                        BatchImportContributions.FinishBundle(bh);
                    }
                    bh        = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                    prevbatch = r.Batch;
                }
                var bd = BatchImportContributions.AddContributionDetail(date, fund, r.Amount, r.CheckNo, r.Routing, r.Account);
                bh.BundleDetails.Add(bd);
            }
            if (bh == null)
            {
                return(null);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #19
0
        private static int?BatchProcessVanco(CsvReader csv, DateTime date, int?fundid)
        {
            var fundList = (from f in DbUtil.Db.ContributionFunds
                            orderby f.FundId
                            select f.FundId).ToList();

            var          cols      = csv.GetFieldHeaders();
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid != null && fundList.Contains(fundid ?? 0) ? fundid ?? 0 : firstfund;

            while (csv.ReadNextRecord())
            {
                var routing  = "0";
                var checkno  = "0";
                var account  = csv[0];
                var amount   = csv[1];
                var fundText = csv[3];
                var fundNum  = 0;

                int.TryParse(fundText, out fundNum);

                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                BundleDetail bd;

                if (fundList.Contains(fundNum))
                {
                    bd = BatchImportContributions.AddContributionDetail(date, fundNum, amount, checkno, routing, account);
                }
                else
                {
                    bd = BatchImportContributions.AddContributionDetail(date, fund, amount, checkno, routing, account);
                    bd.Contribution.ContributionDesc = $"Used default fund (fund requested: {fundText})";
                }

                bh.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh.BundleHeaderId);
        }
예제 #20
0
        private void AddSortedContributions()
        {
            foreach (var record in _details.OrderByDescending(x => x.Name).ToList())
            {
                var detail = BatchImportContributions.AddContributionDetail(_batchDate, _fundId, record.Amount,
                                                                            record.IndividualIdNumber,
                                                                            record.RoutingNumber,
                                                                            record.AccountNumber);

                if (!detail.Contribution.PeopleId.HasValue)
                {
                    detail.Contribution.ContributionDesc = record.Name;
                }

                _bundleHeader.BundleDetails.Add(detail);
            }
        }
예제 #21
0
        private static int?Import(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bundleHeader = null;
            var          fid          = fundid ?? BatchImportContributions.FirstFundId();

            var details = new List <BundleDetail>();

            while (csv.Read())
            {
                var amount = csv[0];
                var dt     = csv[2].ToDate();
                if (!amount.HasValue())
                {
                    continue;
                }

                var fund    = csv[4];
                int ffid    = !fund.HasValue() ? fid : DbUtil.Db.FetchOrCreateFund(fund).FundId;
                var name    = csv[5];
                var email   = csv[6];
                var address = csv[7];
                var phone   = csv[8];

                if (bundleHeader == null)
                {
                    bundleHeader = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(dt ?? date, ffid, amount, null, "", email);
                details.Add(bd);
                bd.Contribution.ContributionDesc = $"{name};{address};{phone}";
            }

            details.Reverse();
            if (bundleHeader != null)
            {
                foreach (var bd in details)
                {
                    bundleHeader.BundleDetails.Add(bd);
                }
                BatchImportContributions.FinishBundle(bundleHeader);
                return(bundleHeader.BundleHeaderId);
            }
            return(null);
        }
예제 #22
0
        public int?RunImport(string text, DateTime date, int?fundid, bool fromFile)
        {
            _fundId = fundid ?? BatchImportContributions.FirstFundId();

            using (var sr = new StringReader(text))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    HandleRecord(line);
                }
            }

            AddSortedContributions();

            BatchImportContributions.FinishBundle(_bundleHeader);
            return(_bundleHeader.BundleHeaderId);
        }
예제 #23
0
        private static int?BatchProcessJackHenry(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            var list = new List <DepositRecord>();
            var r    = 2;

            while (csv.ReadNextRecord())
            {
                var peopleid = csv[6].ToInt();
                list.Add(new DepositRecord()
                {
                    PeopleId = peopleid,
                    Amount   = csv[9],
                    CheckNo  = csv[10],
                    Row      = r++,
                    Valid    = DbUtil.Db.People.Any(pp => pp.PeopleId == peopleid),
                });
            }
            if (list.Any(vv => vv.Valid == false))
            {
                throw new Exception("The following rows had peopleids that were not found<br>\n" +
                                    string.Join(",", (list.Where(vv => vv.Valid == false).Select(vv => vv.Row)).ToArray()));
            }
            foreach (var i in list)
            {
                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(date, fund, i.Amount, i.CheckNo, i.Routing, i.PeopleId);
                bh.BundleDetails.Add(bd);
            }
            if (bh == null)
            {
                return(null);
            }

            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #24
0
        private static int?BatchProcess(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh   = null;
            var          fid  = fundid ?? BatchImportContributions.FirstFundId();
            var          now  = DateTime.Now;
            var          list = new List <Record>();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                var rec = new Record
                {
                    ItemType = csv["ItemTypeName"],
                    Amount   = csv["Amount"],
                    Dt       = csv["CapturedDate"].ToDate(),
                    Account  = csv["Account"],
                    Routing  = csv["RoutingNumber"],
                    CheckNo  = csv["TranCode"],
                };
                if (rec.ItemType == "CK")
                {
                    list.Add(rec);
                }
            }
            bh = BatchImportContributions.GetBundleHeader(date, now);
            foreach (var rec in list)
            {
                if (!rec.HasAmount || !rec.Dt.HasValue)
                {
                    continue;
                }

                var bd = BatchImportContributions.AddContributionDetail(rec.Dt.Value, fid, rec.Amount, rec.CheckNo, rec.Routing, rec.Account);
                bd.Contribution.PostingDate = now;

                bh.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh?.BundleHeaderId ?? 0);
        }
예제 #25
0
        private static int?BatchProcessTeaysValley(CsvReader csv, DateTime date, int?fundid)
        {
            var fundList = (from f in DbUtil.Db.ContributionFunds
                            orderby f.FundId
                            select f.FundId).ToList();

            var          cols      = csv.GetFieldHeaders();
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            while (csv.ReadNextRecord())
            {
                var dt     = csv[0].ToDate();
                var amount = csv[2];
                if (!amount.HasValue() || !dt.HasValue)
                {
                    continue;
                }

                var fid     = csv[1].ToInt2() ?? fund;
                var account = csv[3];
                var checkno = csv[4];

                if (!fundList.Contains(fid))
                {
                    fid = firstfund;
                }

                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(dt.Value, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(date, fid, amount, checkno, "", account);

                bh.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bh);

            return(bh.BundleHeaderId);
        }
예제 #26
0
        private static int?Import(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bh  = null;
            var          fid = fundid ?? BatchImportContributions.FirstFundId();

            var list = new List <DepositRecord>();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                list.Add(new DepositRecord()
                {
                    Batch   = csv[0],
                    Account = csv[4],
                    CheckNo = csv[5],
                    Amount  = csv[7],
                });
            }
            var q = from r in list
                    select r;
            var prevbatch = "";

            foreach (var r in q)
            {
                if (r.Batch != prevbatch)
                {
                    if (bh == null)
                    {
                        bh = BatchImportContributions.GetBundleHeader(r.Batch.ToDate() ?? date, DateTime.Now);
                    }
                    prevbatch = r.Batch;
                }
                var bd = BatchImportContributions.AddContributionDetail(date, fid, r.Amount, r.CheckNo, r.Routing, r.Account);
                bh.BundleDetails.Add(bd);
            }
            if (bh == null)
            {
                return(null);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #27
0
        private static int?Import(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bundleHeader = null;
            var          fid          = fundid ?? BatchImportContributions.FirstFundId();

            csv.Read();
            csv.ReadHeader();
            while (csv.Read())
            {
                var batchDate = csv["Date"].ToDate();
                var amount    = csv["Amount"];

                //var paymentMethod = csv["Payment Method"];
                var method = csv["Method"];
                //var payerName = csv["Payer Name"];
                var email    = csv["Email address"];
                var phone    = csv["Mobile Number"];
                var fundText = "";
                if (csv.Context.HeaderRecord.Contains("Giving Type Label"))
                {
                    fundText = csv["Giving Type Label"];
                }

                ContributionFund f = null;
                if (fundText.HasValue())
                {
                    f = DbUtil.Db.FetchOrCreateFund(fundText);
                }

                if (bundleHeader == null)
                {
                    bundleHeader = BatchImportContributions.GetBundleHeader(batchDate ?? DateTime.Today, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(date, f?.FundId ?? fid, amount, method, null, $"{email}|{phone}");
                bundleHeader.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bundleHeader);
            return(bundleHeader.BundleHeaderId);
        }
예제 #28
0
        public static int?BatchProcessSilverdale(CsvReader csv, DateTime date, int?fundid)
        {
            var          cols      = csv.GetFieldHeaders();
            BundleHeader bh        = null;
            var          firstfund = BatchImportContributions.FirstFundId();
            var          fund      = fundid ?? firstfund;

            while (csv.ReadNextRecord())
            {
                var excludecol = csv[12] == "Virtual Credit Item";
                var routing    = csv[18];
                var account    = csv[19];
                var amount     = csv[20];
                var checkno    = csv[24];
                if (!checkno.HasValue() && account.Count(c => c == ' ') == 1)
                {
                    var a = account.Split(' ');
                    account = a[1];
                    checkno = a[0];
                }

                if (excludecol)
                {
                    if (bh != null)
                    {
                        BatchImportContributions.FinishBundle(bh);
                    }
                    bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                    continue;
                }
                if (bh == null)
                {
                    bh = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                var bd = BatchImportContributions.AddContributionDetail(date, fund, amount, checkno, routing, account);
                bh.BundleDetails.Add(bd);
            }
            BatchImportContributions.FinishBundle(bh);
            return(bh.BundleHeaderId);
        }
예제 #29
0
        private static int?BatchProcessFbcFayetteville(CsvReader csv, DateTime date, int?fundid)
        {
            var          cols         = csv.GetFieldHeaders();
            BundleHeader bundleHeader = null;
            var          firstfund    = BatchImportContributions.FirstFundId(); //TODO: use default fund id based on DBSetting w/ default to 1 if not set
            var          fund         = fundid ?? firstfund;

            while (csv.ReadNextRecord())
            {
                var isHeaderRow = csv[0].StartsWith("Date");

                if (isHeaderRow)
                {
                    continue;
                }

                var contributionDate = csv[0].Trim();
                var memberNumber     = csv[1].Trim();
                var memberName       = csv[2].Trim();
                var amount           = csv[3].Trim();
                var checkNumber      = csv[4].Trim();

                if (bundleHeader == null)
                {
                    bundleHeader = BatchImportContributions.GetBundleHeader(date, DateTime.Now);
                }

                var bundleDetails = BatchImportContributions.AddContributionDetail(date, fund, amount, checkNumber, "", int.Parse(memberNumber));
                bundleHeader.BundleDetails.Add(bundleDetails);
            }

            if (bundleHeader == null)
            {
                return(null);
            }

            BatchImportContributions.FinishBundle(bundleHeader);
            return(bundleHeader.BundleHeaderId);
        }
예제 #30
0
        private static int?Import(CsvReader csv, DateTime date, int?fundid)
        {
            BundleHeader bundleHeader = null;
            var          fid          = fundid ?? BatchImportContributions.FirstFundId();

            var details = new List <BundleDetail>();

            while (csv.ReadNextRecord())
            {
                var batchDate = csv[0].ToDate();
                var amount    = csv[14];
                var type      = csv[13];
                if (!amount.HasValue() || !batchDate.HasValue || type == "Credit")
                {
                    continue;
                }

                var routingNumber = csv[17];
                var accountNumber = csv[16];
                var checkNumber   = csv[15];

                if (bundleHeader == null)
                {
                    bundleHeader = BatchImportContributions.GetBundleHeader(batchDate.Value, DateTime.Now);
                }

                details.Add(BatchImportContributions.AddContributionDetail(date, fid, amount, checkNumber, routingNumber, accountNumber));
            }

            details.Reverse();
            foreach (var bd in details)
            {
                bundleHeader.BundleDetails.Add(bd);
            }

            BatchImportContributions.FinishBundle(bundleHeader);

            return(bundleHeader.BundleHeaderId);
        }