Exemplo n.º 1
0
        public IEnumerable <FundTotalInfo> TotalsByFund(DateTime dt1, DateTime dt2, bool Pledges, int CampusId)
        {
            var q = from c in DbUtil.Db.Contributions
                    where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId)
                    where c.ContributionTypeId != ContributionTypeCode.GiftInKind
                    where Pledges || c.ContributionStatusId == ContributionStatusCode.Recorded
                    where c.ContributionDate >= dt1 && c.ContributionDate.Value.Date <= dt2
                    where (c.ContributionTypeId == ContributionTypeCode.Pledge && Pledges) ||
                    (c.ContributionTypeId != ContributionTypeCode.Pledge && !Pledges)
                    where c.BundleDetails.First().BundleHeader.BundleStatusId == 0
                    //where Pledges || c.PostingDate != null
                    where CampusId == 0 || c.CampusId == CampusId
                    group c by c.FundId into g
                    orderby g.Key
                    select new FundTotalInfo
            {
                FundId   = g.Key,
                FundName = g.First().ContributionFund.FundName,
                Total    = g.Sum(t => t.ContributionAmount).Value,
                Count    = g.Count()
            };

            FundTotal = new FundTotalInfo
            {
                Count = q.Sum(t => t.Count),
                Total = q.Sum(t => t.Total),
            };
            return(q);
        }
Exemplo n.º 2
0
        public IEnumerable <FundTotalInfo> TotalsByFund()
        {
            var q = from c in DbUtil.Db.GetTotalContributions2(Dt1, Dt2, CampusId, NonTaxDeductible, IncUnclosedBundles)
                    where Online == 2 || (Online == 1 && c.OnLine == 1) || (Online == 0 && c.OnLine == 0)
                    group c by new { c.FundId, c.QBSynced }
            into g
            orderby g.Key.FundId, g.Key.QBSynced
                select new FundTotalInfo
            {
                FundId   = g.Key.FundId,
                QBSynced = g.Key.QBSynced,
                FundName = g.First().FundName,
                Total    = g.Sum(t => t.Amount).Value,
                Count    = g.Count(),
            };

            FundTotal = new FundTotalInfo
            {
                Count = q.Sum(t => t.Count),
                Total = q.Sum(t => t.Total),
            };
            return(q);
        }
Exemplo n.º 3
0
        public IEnumerable <FundTotalInfo> TotalsByFund()
        {
            List <FundTotalInfo> q = null;

            var api = new APIContributionSearchModel(DbUtil.Db)
            {
                model =
                {
                    StartDate = Dt1,
                    EndDate   = Dt2,
                    IncludeUnclosedBundles = IncUnclosedBundles,
                    TaxNonTax         = TaxDedNonTax,
                    CampusId          = CampusId,
                    Status            = ContributionStatusCode.Recorded,
                    Online            = Online,
                    FilterByActiveTag = FilterByActiveTag,
                }
            };

            if (IncludeBundleType)
            {
                q = (from c in api.FetchContributions()
                     let BundleType = c.BundleDetails.First().BundleHeader.BundleHeaderType.Description
                                      let BundleTypeId = c.BundleDetails.First().BundleHeader.BundleHeaderTypeId
                                                         group c by new { c.FundId, c.QBSyncID, BundleTypeId, BundleType } into g
                     orderby g.Key.FundId, g.Key.QBSyncID, g.Key.BundleTypeId
                     select new FundTotalInfo
                {
                    BundleType = g.Key.BundleType,
                    BundleTypeId = g.Key.BundleTypeId,
                    FundId = g.Key.FundId,
                    QBSynced = g.Key.QBSyncID ?? 0,
                    FundName = g.First().ContributionFund.FundName,
                    GeneralLedgerId = g.First().ContributionFund.FundIncomeAccount,
                    Total = g.Sum(t => t.ContributionAmount).Value,
                    Count = g.Count(),
                    model = this
                }).ToList();
            }
            else
            {
                q = (from c in api.FetchContributions()
                     group c by new { c.FundId, c.QBSyncID } into g
                     orderby g.Key.FundId, g.Key.QBSyncID
                     select new FundTotalInfo
                {
                    FundId = g.Key.FundId,
                    QBSynced = g.Key.QBSyncID ?? 0,
                    FundName = g.First().ContributionFund.FundName,
                    GeneralLedgerId = g.First().ContributionFund.FundIncomeAccount,
                    Total = g.Sum(t => t.ContributionAmount).Value,
                    Count = g.Count(),
                    model = this
                }).ToList();
            }

            FundTotal = new FundTotalInfo
            {
                Count = q.Sum(t => t.Count),
                Total = q.Sum(t => t.Total),
                model = this
            };
            return(q);
        }
Exemplo n.º 4
0
 public IEnumerable<FundTotalInfo> TotalsByFund(DateTime dt1, DateTime dt2, bool Pledges, int CampusId)
 {
     var q = from c in DbUtil.Db.Contributions
             where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId)
             where c.ContributionTypeId != ContributionTypeCode.GiftInKind
             where Pledges || c.ContributionStatusId == ContributionStatusCode.Recorded
             where c.ContributionDate >= dt1 && c.ContributionDate.Value.Date <= dt2
             where (c.ContributionTypeId == ContributionTypeCode.Pledge && Pledges)
                 || (c.ContributionTypeId != ContributionTypeCode.Pledge && !Pledges)
             where c.BundleDetails.First().BundleHeader.BundleStatusId == 0
             //where Pledges || c.PostingDate != null
             where CampusId == 0 || c.Person.CampusId == CampusId
             group c by c.FundId into g
             orderby g.Key
             select new FundTotalInfo
             {
                 FundId = g.Key,
                 FundName = g.First().ContributionFund.FundName,
                 Total = g.Sum(t => t.ContributionAmount).Value,
                 Count = g.Count()
             };
     FundTotal = new FundTotalInfo
     {
         Count = q.Sum(t => t.Count),
         Total = q.Sum(t => t.Total),
     };
     return q;
 }
Exemplo n.º 5
0
        public IEnumerable <FundTotalInfo> TotalsByFund()
        {
            List <FundTotalInfo> q = null;

            var api = new APIContributionSearchModel(DbUtil.Db)
            {
                model =
                {
                    StartDate = Dt1,
                    EndDate   = Dt2,
                    IncludeUnclosedBundles = IncUnclosedBundles,
                    TaxNonTax         = TaxDedNonTax,
                    CampusId          = CampusId,
                    Status            = ContributionStatusCode.Recorded,
                    Online            = Online,
                    FilterByActiveTag = FilterByActiveTag,
                    FundSet           = FundSet,
                }
            };

#if DEBUG2
            // for reconciliation by developer
            var v = from c in api.FetchContributions()
                    orderby c.ContributionId
                    select c.ContributionId;
            using (var tw = new StreamWriter("D:\\totalsbyfund.txt"))
                foreach (var s in v)
                {
                    tw.WriteLine(s);
                }
#endif


            if (IncludeBundleType)
            {
                q = (from c in api.FetchContributions()
                     let BundleType = c.BundleDetails.First().BundleHeader.BundleHeaderType.Description
                                      let BundleTypeId = c.BundleDetails.First().BundleHeader.BundleHeaderTypeId
                                                         group c by new { c.FundId, c.QBSyncID, BundleTypeId, BundleType }
                     into g
                     orderby g.Key.FundId, g.Key.QBSyncID, g.Key.BundleTypeId
                     select new FundTotalInfo
                {
                    BundleType = g.Key.BundleType,
                    BundleTypeId = g.Key.BundleTypeId,
                    FundId = g.Key.FundId,
                    QBSynced = g.Key.QBSyncID ?? 0,
                    FundName = g.First().ContributionFund.FundName,
                    GeneralLedgerId = g.First().ContributionFund.FundIncomeAccount,
                    Total = g.Sum(t => t.ContributionAmount).Value,
                    Count = g.Count(),
                    model = this
                }).ToList();
            }
            else
            {
                q = (from c in api.FetchContributions()
                     group c by new { c.FundId, c.QBSyncID } into g
                     orderby g.Key.FundId, g.Key.QBSyncID
                     select new FundTotalInfo
                {
                    FundId = g.Key.FundId,
                    QBSynced = g.Key.QBSyncID ?? 0,
                    FundName = g.First().ContributionFund.FundName,
                    GeneralLedgerId = g.First().ContributionFund.FundIncomeAccount,
                    Total = g.Sum(t => t.ContributionAmount).Value,
                    Count = g.Count(),
                    model = this
                }).ToList();
            }

            FundTotal = new FundTotalInfo
            {
                Count = q.Sum(t => t.Count),
                Total = q.Sum(t => t.Total),
                model = this
            };
            return(q);
        }
Exemplo n.º 6
0
 public IEnumerable<FundTotalInfo> TotalsByFund()
 {
     var q = from c in DbUtil.Db.GetTotalContributions2(Dt1, Dt2, CampusId, NonTaxDeductible, IncUnclosedBundles)
             where Online == 2 || (Online == 1 && c.OnLine == 1) || (Online == 0 && c.OnLine == 0)
             group c by new { c.FundId, c.QBSynced}
                 into g
                 orderby g.Key.FundId, g.Key.QBSynced
                 select new FundTotalInfo
                            {
                                FundId = g.Key.FundId,
                                QBSynced = g.Key.QBSynced,
                                FundName = g.First().FundName,
                                Total = g.Sum(t => t.Amount).Value,
                                Count = g.Count(),
                            };
     FundTotal = new FundTotalInfo
                     {
                         Count = q.Sum(t => t.Count),
                         Total = q.Sum(t => t.Total),
                     };
     return q;
 }
Exemplo n.º 7
0
        public IEnumerable<FundTotalInfo> TotalsByFund()
        {
            List<FundTotalInfo> q = null;

            var api = new APIContributionSearchModel(DbUtil.Db)
            {
                model =
                {
                    StartDate = Dt1,
                    EndDate = Dt2,
                    IncludeUnclosedBundles = IncUnclosedBundles,
                    TaxNonTax = TaxDedNonTax,
                    CampusId = CampusId,
                    Status = ContributionStatusCode.Recorded,
                    Online = Online
                }
            };

            if (IncludeBundleType)
                q = (from c in api.FetchContributions()
                     let BundleType = c.BundleDetails.First().BundleHeader.BundleHeaderType.Description
                     let BundleTypeId = c.BundleDetails.First().BundleHeader.BundleHeaderTypeId
                     group c by new { c.FundId, c.QBSyncID, BundleTypeId, BundleType } into g
                     orderby g.Key.FundId, g.Key.QBSyncID, g.Key.BundleTypeId
                     select new FundTotalInfo
                                {
                                    BundleType = g.Key.BundleType,
                                    BundleTypeId = g.Key.BundleTypeId,
                                    FundId = g.Key.FundId,
                                    QBSynced = g.Key.QBSyncID ?? 0,
                                    FundName = g.First().ContributionFund.FundName,
                                    Total = g.Sum(t => t.ContributionAmount).Value,
                                    Count = g.Count(),
                                    model = this
                                }).ToList();
            else
                q = (from c in api.FetchContributions()
                     group c by new { c.FundId, c.QBSyncID } into g
                     orderby g.Key.FundId, g.Key.QBSyncID
                     select new FundTotalInfo
                                {
                                    FundId = g.Key.FundId,
                                    QBSynced = g.Key.QBSyncID ?? 0,
                                    FundName = g.First().ContributionFund.FundName,
                                    Total = g.Sum(t => t.ContributionAmount).Value,
                                    Count = g.Count(),
                                    model = this
                                }).ToList();

            FundTotal = new FundTotalInfo
                            {
                                Count = q.Sum(t => t.Count),
                                Total = q.Sum(t => t.Total),
                                model = this
                            };
            return q;
        }