public void DonorDetailsTest(string notitles, string uselabelname)
        {
            using (var db = CMSDataContext.Create(Util.Host))
            {
                db.SetSetting("NoTitlesOnStatements", notitles);
                db.SetSetting("UseLabelNameForDonorDetails", uselabelname);

                var      bundleList   = CreateTestContributionSet(db, Util.Now.Date);
                var      exportPeople = new ExportPeople(db);
                DateTime startDate    = Util.Now.AddDays(-180);
                DateTime endDate      = Util.Now.AddDays(180);

                DataTable tableResult        = exportPeople.DonorDetails(startDate, endDate, 0, 0, false, null, true, null, null);
                var       dbContributionsQry = db.Contributions
                                               .Where(x => !ContributionTypeCode.ReturnedReversedTypes.Contains(x.ContributionTypeId) && !ContributionTypeCode.Pledge.Equals(x.ContributionTypeId))
                                               .Where(x => x.ContributionDate >= startDate && x.ContributionDate < endDate)
                                               .Select(x => x);

                var tableResultTotals  = tableResult.AsEnumerable().Sum(row => row.Field <decimal>("Amount"));
                var totalContributions = dbContributionsQry.Sum(x => x.ContributionAmount) ?? 0;
                totalContributions.ToDouble().ShouldBe(tableResultTotals.ToDouble());

                foreach (var b in bundleList)
                {
                    MockContributions.DeleteAllFromBundle(db, b);
                }
                db.DeleteSetting("NoTitlesOnStatements");
                db.DeleteSetting("UseLabelNameForDonorDetails");
            }
        }
        public void PledgesSummaryTest()
        {
            var fromDate = new DateTime(2019, 1, 1);

            using (var db = CMSDataContext.Create(Util.Host))
            {
                var bundleHeader       = MockContributions.CreateSaveBundle(db);
                var FirstContribution  = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: 1);
                var SecondContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 20, peopleId: 1);
                var Pledges            = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 500, peopleId: 1, contributionType: ContributionTypeCode.Pledge);

                //Get amount contributed to the pledge
                var TotalAmmountContributions = db.Contributions
                                                .Where(x => x.ContributionTypeId == ContributionTypeCode.CheckCash)
                                                .Sum(x => x.ContributionAmount) ?? 0;

                //Get Pledge amount
                var TotalPledgeAmount = db.Contributions
                                        .Where(x => x.ContributionTypeId == ContributionTypeCode.Pledge && x.PeopleId == 1 && x.FundId == 1)
                                        .Sum(x => x.ContributionAmount) ?? 0;

                var results = db.PledgesSummary(1);
                var actual  = results.ToList().First();

                actual.AmountContributed.ShouldBe(TotalAmmountContributions);
                actual.AmountPledged.ShouldBe(TotalPledgeAmount);
                actual.Balance.ShouldBe((TotalPledgeAmount) - (TotalAmmountContributions) < 0 ? 0 : (TotalPledgeAmount) - (TotalAmmountContributions));

                MockContributions.DeleteAllFromBundle(db, bundleHeader);
            }
        }
        public void ExportDonorFundTotals_Should_Bring_Pledges(int fundid, int campusid, bool?nontaxdeductible,
                                                               bool includeUnclosed, int?tagid, string fundids, int?online)
        {
            using (var db = CMSDataContext.Create(Util.Host))
            {
                var bundleList    = CreateTestContributionSet(db, Util.Now.Date);
                var _exportPeople = new ExportPeople(db);

                DateTime  exportStartDt = Util.Now.AddDays(-180);
                DateTime  exportEndDt   = Util.Now.AddDays(180);
                DataTable tableResult   = _exportPeople.ExcelDonorFundTotals(exportStartDt, exportEndDt, fundid, campusid, true, nontaxdeductible, includeUnclosed, tagid, fundids, (int)online);

                try
                {
                    var q = from c in tableResult.Select() where c.ItemArray[3].ToInt() > 0 select c;
                    if (q.IsNotNull())
                    {
                        var amountpledged = Double.Parse(q.Select(x => x.ItemArray[3]).SingleOrDefault().ToString());
                        //The pledged amount correspond to the pledge amount created in CreateTestContributionSet()
                        amountpledged.ShouldBe(1000.00);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    foreach (var b in bundleList)
                    {
                        MockContributions.DeleteAllFromBundle(db, b);
                    }
                }
            }
        }
        public void GetTotalContributionsDonorTest()
        {
            var fromDate = new DateTime(2019, 1, 1);
            var toDate   = new DateTime(2019, 7, 31);

            using (var db = CMSDataContext.Create(DatabaseFixture.Host))
            {
                var TotalAmmountContributions = db.Contributions
                                                .Where(x => x.ContributionTypeId == ContributionTypeCode.CheckCash)
                                                .Where(x => x.ContributionDate >= fromDate)
                                                .Where(x => x.ContributionDate < toDate.AddDays(1))
                                                .Sum(x => x.ContributionAmount) ?? 0;
                var TotalPledgeAmountContributions = db.Contributions
                                                     .Where(x => x.ContributionTypeId == ContributionTypeCode.Pledge)
                                                     .Where(x => x.ContributionDate >= fromDate)
                                                     .Where(x => x.ContributionDate < toDate.AddDays(1))
                                                     .Sum(x => x.ContributionAmount) ?? 0;

                var bundleHeader       = MockContributions.CreateSaveBundle(db);
                var FirstContribution  = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 120, peopleId: 1);
                var SecondContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 500, peopleId: 1, contributionType: ContributionTypeCode.Pledge);

                var results = db.GetTotalContributionsDonor(fromDate, toDate, null, null, true, null, null, true).ToList();
                var actualContributionsAmount = results.Where(x => x.ContributionTypeId == ContributionTypeCode.CheckCash).Sum(x => x.Amount);
                var actualPledgesAmount       = results.Where(x => x.ContributionTypeId == ContributionTypeCode.Pledge).Sum(x => x.PledgeAmount);

                actualContributionsAmount.ShouldBe(TotalAmmountContributions + 120);
                actualPledgesAmount.ShouldBe(TotalPledgeAmountContributions + 500);

                MockContributions.DeleteAllFromBundle(db, bundleHeader);
            }
        }
        public void ExcelDonorTotals_Should_Not_Bring_Reversed_or_Returned_contributions(int campusid, bool pledges, bool?nontaxdeductible, bool includeUnclosed, int?tagid, string fundids)
        {
            using (var db = CMSDataContext.Create(Util.Host))
            {
                var bundleList    = CreateTestContributionSet(db, Util.Now.Date);
                var _exportPeople = new ExportPeople(db);
                int?online        = null;

                DateTime  exportStartDt      = Util.Now.AddDays(-180);
                DateTime  exportEndDt        = Util.Now.AddDays(180);
                DataTable tableResult        = _exportPeople.ExcelDonorTotals(exportStartDt, exportEndDt, campusid, pledges, nontaxdeductible, online, includeUnclosed, tagid, fundids, false);
                var       dbContributionsQry = db.Contributions
                                               .Where(x => !ContributionTypeCode.ReturnedReversedTypes.Contains(x.ContributionTypeId) && !ContributionTypeCode.Pledge.Equals(x.ContributionTypeId))
                                               .Where(x => ContributionStatusCode.Recorded.Equals(x.ContributionStatusId))
                                               .Where(x => x.ContributionDate >= exportStartDt && x.ContributionDate < exportEndDt)
                                               .Select(x => x);

                dbContributionsQry = nontaxdeductible.HasValue
                    ? (nontaxdeductible is true)
                        ? dbContributionsQry = dbContributionsQry.Where(x => ContributionTypeCode.NonTaxDed.Equals(x.ContributionTypeId)).Select(x => x)
                        : dbContributionsQry = dbContributionsQry.Where(x => !ContributionTypeCode.NonTaxDed.Equals(x.ContributionTypeId)).Select(x => x)
                    : dbContributionsQry;

                if (includeUnclosed is false)
                {
                    dbContributionsQry = from c in dbContributionsQry
                                         join bd in db.BundleDetails on c.ContributionId equals bd.ContributionId
                                         join bh in db.BundleHeaders on bd.BundleHeaderId equals bh.BundleHeaderId
                                         where bh.BundleStatusId == 0
                                         select c;
                }

                var tableResultTotals  = tableResult.AsEnumerable().Sum(row => row.Field <decimal>("Amount"));
                var totalContributions = dbContributionsQry.Sum(x => x.ContributionAmount) ?? 0;

                try
                {
                    totalContributions.ToDouble().ShouldBe(tableResultTotals.ToDouble());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    foreach (var b in bundleList)
                    {
                        MockContributions.DeleteAllFromBundle(db, b);
                    }
                }
            }
        }
        public void IsTopGiverTest()
        {
            var fromDate = new DateTime(2017, 4, 4);
            var toDate   = new DateTime(2017, 7, 31);

            using (var db = CMSDataContext.Create(Util.Host))
            {
                // Cleaning Contribution garbage from previous tests
                db.ExecuteCommand("DELETE FROM dbo.BundleDetail; DELETE FROM dbo.BundleHeader; DELETE FROM dbo.ContributionTag; DELETE FROM dbo.Contribution;");

                var family = new Family();
                db.Families.InsertOnSubmit(family);
                db.SubmitChanges();

                var person = new Person
                {
                    Family             = family,
                    FirstName          = "MockPersonFirstName",
                    LastName           = "MockPersonLastName",
                    EmailAddress       = "*****@*****.**",
                    MemberStatusId     = MemberStatusCode.Member,
                    PositionInFamilyId = PositionInFamily.PrimaryAdult,
                };

                db.People.InsertOnSubmit(person);
                db.SubmitChanges();

                var bundleHeader = MockContributions.CreateSaveBundle(db);

                var FirstContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: person.PeopleId, contributionType: 1);

                var SecondContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 20, peopleId: person.PeopleId, contributionType: 9);

                var FundIds         = $"{FirstContribution.FundId},{SecondContribution.FundId}";
                var TopGiversResult = db.TopGivers(10, fromDate, toDate, FundIds, null).ToList();

                if (TopGiversResult.Count > 0)
                {
                    var TotalAmmountTopGivers = TopGiversResult[0].Amount;
                    TotalAmmountTopGivers.ShouldBe(120);
                }
                else
                {
                    TopGiversResult.ShouldNotBeNull();
                }

                MockContributions.DeleteAllFromBundle(db, bundleHeader);
            }
        }
        public void DonorDetails_Should_Not_Bring_Reversed_or_Returned_contributions(
            int fundid, int campusid, bool pledges, bool?nontaxdeductible, bool includeUnclosed, int?tagid, string fundids)
        {
            using (var db = CMSDataContext.Create(Util.Host))
            {
                var bundleList = CreateTestContributionSet(db, Util.Now.Date);

                var       _exportPeople = new ExportPeople();
                DateTime  exportStartDt = new DateTime(Util.Now.Date.Year, 1, 1);
                DateTime  exportEndDt   = new DateTime(Util.Now.Date.Year, 12, 31);
                DataTable tableResult   = _exportPeople.DonorDetails(exportStartDt, exportEndDt, fundid, campusid, pledges, nontaxdeductible, includeUnclosed, tagid, fundids);

                var dbContributionsQry = db.Contributions
                                         .Where(x => !ContributionTypeCode.ReturnedReversedTypes.Contains(x.ContributionTypeId) && !ContributionTypeCode.Pledge.Equals(x.ContributionTypeId))
                                         .Where(x => ContributionStatusCode.Recorded.Equals(x.ContributionStatusId))
                                         .Where(x => x.ContributionDate >= exportStartDt && x.ContributionDate < exportEndDt)
                                         .Select(x => x);

                dbContributionsQry = nontaxdeductible.HasValue
                    ? (nontaxdeductible is true)
                        ? dbContributionsQry = dbContributionsQry.Where(x => ContributionTypeCode.NonTaxDed.Equals(x.ContributionTypeId)).Select(x => x)
                        : dbContributionsQry = dbContributionsQry.Where(x => !ContributionTypeCode.NonTaxDed.Equals(x.ContributionTypeId)).Select(x => x)
                    : dbContributionsQry;

                if (includeUnclosed is false)
                {
                    dbContributionsQry = from c in dbContributionsQry
                                         join bd in db.BundleDetails on c.ContributionId equals bd.ContributionId
                                         join bh in db.BundleHeaders on bd.BundleHeaderId equals bh.BundleHeaderId
                                         where bh.BundleStatusId == 0
                                         select c;
                }

                var rc = tableResult.AsEnumerable().Where(row => ContributionTypeCode.ReturnedReversedTypes.Contains(row.Field <int>("ContributionTypeId")));
                var tableResultTotals  = tableResult.AsEnumerable().Sum(row => row.Field <decimal>("Amount"));
                var totalContributions = dbContributionsQry.Sum(x => x.ContributionAmount) ?? 0;

                totalContributions.ToDouble().ShouldBe(tableResultTotals.ToDouble());
                rc.Count().ShouldBeLessThan(1);

                foreach (var b in bundleList)
                {
                    MockContributions.DeleteAllFromBundle(db, b);
                }
            }
        }
        public void GetTotalContributionsDonor2Test()
        {
            var fromDate = new DateTime(2016, 4, 4);
            var toDate   = new DateTime(2016, 7, 31);

            using (var db = CMSDataContext.Create(Util.Host))
            {
                var bundleHeader = MockContributions.CreateSaveBundle(db);
                var Contribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 120, peopleId: 1);

                var TotalContributionsDonor = db.GetTotalContributionsDonor2(fromDate, toDate, null, null, true, null, null).ToList();

                var ammount = TotalContributionsDonor[0].Amount;
                ammount.ShouldBe(120);

                MockContributions.DeleteAllFromBundle(db, bundleHeader);
            }
        }
        public void DonorDetails_Should_Not_Bring_Reversed_or_Returned_contributions(
            int campusid, bool pledges, bool?nontaxdeductible, bool includeUnclosed, int?tagid, string fundids)
        {
            using (var db = CMSDataContext.Create(Util.Host))
            {
                var      bundleList    = CreateTestContributionSet(db, Util.Now.Date);
                var      _exportPeople = new ExportPeople(db);
                DateTime exportStartDt = Util.Now.AddDays(-180);
                DateTime exportEndDt   = Util.Now.AddDays(180);
                var      tableResult   = _exportPeople.GetValidContributionDetails(exportStartDt, exportEndDt, campusid, pledges, nontaxdeductible, includeUnclosed, tagid, fundids);
                var      rc            = tableResult.Where(row => ContributionTypeCode.ReturnedReversedTypes.Contains(row.ContributionTypeId));
                rc.Count().ShouldBe(0);

                foreach (var b in bundleList)
                {
                    MockContributions.DeleteAllFromBundle(db, b);
                }
            }
        }
        public void Should_GetFilteredPledgesSummary()
        {
            using (var db = CMSDataContext.Create(DatabaseFixture.Host))
            {
                var fromDate     = new DateTime(2019, 1, 1);
                var person       = MockPeople.CreateSavePerson(db);
                var bundleHeader = MockContributions.CreateSaveBundle(db);
                var pledge       = MockContributions.CreateSaveContribution(
                    db, bundleHeader, fromDate, 200, peopleId: person.PeopleId, fundId: 1, contributionType: ContributionTypeCode.Pledge);
                var firstContribution  = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: person.PeopleId, fundId: 1, contributionType: ContributionTypeCode.CheckCash);
                var secondContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: person.PeopleId, fundId: 2, contributionType: ContributionTypeCode.CheckCash);
                var setting            = MockSettings.CreateSaveSetting(db, "PostContributionPledgeFunds", "1");
                var expected           = MockContributions.FilteredPledgesSummary();

                var actual = PledgesHelper.GetFilteredPledgesSummary(db, person.PeopleId);
                actual.Should().BeEquivalentTo(expected);

                MockContributions.DeleteAllFromBundle(db, bundleHeader);
            }
        }
Exemple #11
0
        public void AddContributionDetailTest(string date, string cDate, int fundid, string amount, string checkno, string routing, string account, int cType)
        {
            var model            = new PythonModel(db);
            var dateValue        = DateTime.Parse(date);
            var bundleHeader     = model.GetBundleHeader(dateValue, DateTime.Now);
            var contributionDate = model.ParseDate(cDate).Value;
            var detail           = model.AddContributionDetail(contributionDate, fundid, amount, checkno, routing, account, cType);

            bundleHeader.BundleDetails.Add(detail);
            model.FinishBundle(bundleHeader);

            detail.ContributionId.ShouldNotBe(0);
            detail.BundleHeader.ContributionDate.ShouldBe(dateValue);
            detail.Contribution.ContributionDate.ShouldBe(contributionDate);
            detail.Contribution.ContributionTypeId.ShouldBe(cType);
            detail.Contribution.FundId.ShouldBe(fundid);
            detail.Contribution.ContributionAmount.ShouldBe(decimal.Parse(amount));
            detail.Contribution.CheckNo.ShouldBe(checkno);
            detail.Contribution.BankAccount.ShouldNotBeNull();
            MockContributions.DeleteAllFromBundle(db, detail.BundleHeader);
        }
Exemple #12
0
        public void AddContributionTest(string date, string cDate, int fundid, string amount, string checkno, string description, int peopleid)
        {
            var model            = new PythonModel(db);
            var dateValue        = DateTime.Parse(date);
            var bundleHeader     = model.GetBundleHeader(dateValue, DateTime.Now);
            var contributionDate = model.ParseDate(cDate).Value;
            var detail           = model.AddContribution(contributionDate, fundid, amount, checkno, description, peopleid);

            bundleHeader.BundleDetails.Add(detail);
            model.FinishBundle(bundleHeader);

            detail.ContributionId.ShouldNotBe(0);
            detail.BundleHeader.ContributionDate.ShouldBe(dateValue);
            detail.Contribution.ContributionDate.ShouldBe(contributionDate);
            detail.Contribution.FundId.ShouldBe(fundid);
            detail.Contribution.ContributionAmount.ShouldBe(decimal.Parse(amount));
            detail.Contribution.CheckNo.ShouldBe(checkno);
            detail.Contribution.ContributionDesc.ShouldBe(description);
            detail.Contribution.PeopleId.ShouldBe(peopleid);
            MockContributions.DeleteAllFromBundle(db, detail.BundleHeader);
        }
        public void Should_GetFilteredPledgesSummary(decimal pledged, decimal contributed)
        {
            using (var db = CMSDataContext.Create(DatabaseFixture.Host))
            {
                var fromDate     = new DateTime(2019, 1, 1);
                var fund         = MockFunds.CreateSaveFund(db, true);
                var bundleHeader = MockContributions.CreateSaveBundle(db);
                var pledge       = MockContributions.CreateSaveContribution(
                    db, bundleHeader, fromDate, pledged, peopleId: 1, fundId: fund.FundId, contributionType: ContributionTypeCode.Pledge);
                MockSettings.CreateSaveSetting(db, "PostContributionPledgeFunds", fund.FundId.ToString());
                var firstContribution  = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, contributed, peopleId: 1, fundId: fund.FundId, contributionType: ContributionTypeCode.CheckCash);
                var secondContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: 1, fundId: 2, contributionType: ContributionTypeCode.CheckCash);

                var expected = MockContributions.CustomFilteredPledgesSummary(fund.FundId, fund.FundName, contributed, pledged);
                var actual   = PledgesHelper.GetFilteredPledgesSummary(db, 1);
                actual.Should().BeEquivalentTo(expected);

                MockSettings.CreateSaveSetting(db, "PostContributionPledgeFunds", "1");
                MockContributions.DeleteAllFromBundle(db, bundleHeader);
                MockFunds.DeleteFund(db, fund.FundId);
            }
        }
        public void ExcelDonorFundTotals_Should_Not_Bring_Reversed_or_Returned_contributions(int fundid, int?campusid, bool pledges, bool?nontaxdeductible, bool includeUnclosed, int?tagid, string fundids, int online)
        {
            using (var db = CMSDataContext.Create(Util.Host))
            {
                var      bundleList    = CreateTestContributionSet(db, Util.Now.Date);
                var      _exportPeople = new ExportPeople(db);
                DateTime exportStartDt = Util.Now.AddDays(-180);
                DateTime exportEndDt   = Util.Now.AddDays(180);

                DataTable tableResult = _exportPeople.ExcelDonorFundTotals(exportStartDt, exportEndDt, fundid, (int)campusid, pledges, nontaxdeductible, includeUnclosed, tagid, fundids, online);

                var nontax = nontaxdeductible is null ? "Both" : nontaxdeductible == true ? "NonTaxDed" : "";

                IQueryable <Contribution> contributions;

                if (!nontax.HasValue())
                {
                    nontax = "TaxDed";
                }

                contributions = db.Contributions;

                if (!includeUnclosed)
                {
                    contributions = from c in contributions
                                    where c.BundleDetails.Any(dd => dd.BundleHeader.BundleStatusId == BundleStatusCode.Closed)
                                    select c;
                }

                switch (nontax)
                {
                case "TaxDed":
                    contributions = pledges
                                        ?
                                    (from c in contributions
                                     where !ContributionTypeCode.NonTaxDed.Equals(c.ContributionTypeId)
                                     select c)
                                        :
                                    (from c in contributions
                                     where !ContributionTypeCode.NonTaxDed.Equals(c.ContributionTypeId)
                                     where !ContributionTypeCode.Pledge.Equals(c.ContributionTypeId)
                                     select c);
                    break;

                case "NonTaxDed":
                    contributions = pledges
                                        ?
                                    (from c in contributions
                                     where ContributionTypeCode.NonTaxDed.Equals(c.ContributionTypeId)
                                     select c).Concat(from c in contributions where c.ContributionTypeId == ContributionTypeCode.Pledge select c)
                                        :
                                    (from c in contributions
                                     where ContributionTypeCode.NonTaxDed.Equals(c.ContributionTypeId)
                                     where !ContributionTypeCode.Pledge.Equals(c.ContributionTypeId)
                                     select c);
                    break;

                case "Both":
                    contributions = pledges
                                        ?
                                    (from c in contributions
                                     select c)
                                        :
                                    (from c in contributions
                                     where !ContributionTypeCode.Pledge.Equals(c.ContributionTypeId)
                                     select c);
                    break;

                case "Pledge":
                    contributions = from c in contributions
                                    where c.ContributionTypeId == ContributionTypeCode.Pledge
                                    select c;
                    break;
                }

                if (exportStartDt.ToDate().HasValue)
                {
                    contributions = from c in contributions
                                    where c.ContributionDate >= exportStartDt
                                    select c;
                }

                if (exportEndDt.ToDate().HasValue)
                {
                    contributions = from c in contributions
                                    where c.ContributionDate < exportEndDt.ToDate().Value.AddDays(1)
                                    select c;
                }

                if (online == 1)
                {
                    contributions = from c in contributions
                                    where c.BundleDetails.Any(dd => dd.BundleHeader.BundleHeaderTypeId == BundleTypeCode.Online)
                                    select c;
                }
                else if (online == 0)
                {
                    contributions = from c in contributions
                                    where c.BundleDetails.All(dd => dd.BundleHeader.BundleHeaderTypeId != BundleTypeCode.Online)
                                    select c;
                }

                if ((campusid ?? 0) != 0)
                {
                    contributions = from c in contributions
                                    where (c.CampusId ?? c.Person.CampusId) == campusid
                                    select c;
                }

                if (fundids.HasValue())
                {
                    if (fundids != null)
                    {
                        contributions = from c in contributions
                                        where fundids.Contains(c.FundId.ToString())
                                        select c;
                    }
                }

                var tableResultTotals  = tableResult.AsEnumerable().Sum(row => row.Field <decimal>("Amount"));
                var totalContributions = contributions.Sum(x => x.ContributionAmount) ?? 0;
                totalContributions.ToDouble().ShouldBe(tableResultTotals.ToDouble());

                foreach (var b in bundleList)
                {
                    MockContributions.DeleteAllFromBundle(db, b);
                }
            }
        }
        public void ContributionAmount2Test()
        {
            var fromDate = new DateTime(2019, 4, 4);
            var toDate   = new DateTime(2019, 7, 31);

            using (var db = CMSDataContext.Create(Util.Host))
            {
                // Cleaning Contribution garbage from previous tests
                db.ExecuteCommand("DELETE FROM dbo.BundleDetail; DELETE FROM dbo.BundleHeader; DELETE FROM dbo.ContributionTag; DELETE FROM dbo.Contribution;");

                var family  = new Family();
                var family2 = new Family();
                db.Families.InsertOnSubmit(family);
                db.Families.InsertOnSubmit(family2);
                db.SubmitChanges();

                var person = new Person
                {
                    Family             = family,
                    FirstName          = "MockPersonFirstName",
                    LastName           = "MockPersonLastName",
                    EmailAddress       = "*****@*****.**",
                    MemberStatusId     = MemberStatusCode.Member,
                    PositionInFamilyId = PositionInFamily.PrimaryAdult,
                    MaritalStatusId    = MaritalStatusCode.Married,
                    GenderId           = GenderCode.Male
                };

                var Wife = new Person
                {
                    Family             = family,
                    FirstName          = "WifeFirst",
                    LastName           = "WifeLast",
                    EmailAddress       = "*****@*****.**",
                    MemberStatusId     = MemberStatusCode.Member,
                    PositionInFamilyId = PositionInFamily.PrimaryAdult,
                    MaritalStatusId    = MaritalStatusCode.Married,
                    GenderId           = GenderCode.Female
                };

                var person2 = new Person
                {
                    Family             = family2,
                    FirstName          = "Person2First",
                    LastName           = "Person2Last",
                    EmailAddress       = "*****@*****.**",
                    MemberStatusId     = MemberStatusCode.Member,
                    PositionInFamilyId = PositionInFamily.PrimaryAdult,
                    MaritalStatusId    = MaritalStatusCode.Married,
                    GenderId           = GenderCode.Male
                };

                db.People.InsertOnSubmit(person);
                db.People.InsertOnSubmit(Wife);
                db.People.InsertOnSubmit(person2);
                db.SubmitChanges();

                var bundleHeader = MockContributions.CreateSaveBundle(db);

                var FirstContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 100, peopleId: person.PeopleId, contributionType: ContributionTypeCode.NonTaxDed);

                var SecondContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 20, peopleId: person.PeopleId, contributionType: ContributionTypeCode.Online);

                var ThirdContribution = MockContributions.CreateSaveContribution(db, bundleHeader, fromDate, 20, peopleId: person2.PeopleId, contributionType: ContributionTypeCode.NonTaxDed);

                var FundIds = $"{FirstContribution.FundId},{SecondContribution.FundId},{ThirdContribution.FundId}";

                Condition c = new Condition();

                CompareType op = CompareType.Greater;

                //Both Joint
                var bothjoint = c.GetContributionList(db, op, fromDate, toDate, null, null, true);
                bothjoint.ToList().Count().ShouldBe(3);

                //Donor Only
                var donoronly = c.GetContributionList(db, op, fromDate, toDate, null, null, true, false);
                donoronly.ToList().Count().ShouldBe(2);

                MockContributions.DeleteAllFromBundle(db, bundleHeader);
            }
        }