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

            var x    = api.FetchContributions();
            var list = x.Select(xx => new ContributionIdItem {
                ContributionId = xx.ContributionId
            }).ToList();
            var dt = ExcelExportModel.ToDataTable(list);

            dt.SaveAs("D:\\cids.xlsx");
        }
Example #2
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);
        }
Example #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,
                    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);
        }