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);
            }
        }
Пример #2
0
        private List <BundleHeader> CreateTestContributionSet(CMSDataContext db, DateTime dt)
        {
            List <BundleHeader> bundleList = new List <BundleHeader>();
            var b1 = MockContributions.CreateSaveBundle(db);

            bundleList.Add(b1);
            var c1 = MockContributions.CreateSaveContribution(db, b1, dt, 500, peopleId: 1, contributionType: ContributionTypeCode.CheckCash);
            var c3 = MockContributions.CreateSaveContribution(db, b1, dt.AddSeconds(1), 500, peopleId: 1, contributionType: ContributionTypeCode.NonTaxDed);
            var c4 = MockContributions.CreateSaveContribution(db, b1, dt.AddSeconds(2), 500, peopleId: 1, contributionType: ContributionTypeCode.Online);
            var c5 = MockContributions.CreateSaveContribution(db, b1, dt.AddSeconds(3), 500, peopleId: 1, contributionType: ContributionTypeCode.Pledge);
            var c6 = MockContributions.CreateSaveContribution(db, b1, dt.AddSeconds(4), 500, peopleId: 1, contributionType: ContributionTypeCode.ReturnedCheck);
            var c7 = MockContributions.CreateSaveContribution(db, b1, dt.AddSeconds(5), 500, peopleId: 1, contributionType: ContributionTypeCode.Reversed);

            b1.BundleStatusId = BundleStatusCode.Closed;
            db.SubmitChanges();

            var b2 = MockContributions.CreateSaveBundle(db);

            bundleList.Add(b2);
            var b2c1 = MockContributions.CreateSaveContribution(db, b2, dt.AddSeconds(6), 500, peopleId: 1, contributionType: ContributionTypeCode.CheckCash);
            var b2c3 = MockContributions.CreateSaveContribution(db, b2, dt.AddSeconds(7), 500, peopleId: 1, contributionType: ContributionTypeCode.NonTaxDed);
            var b2c4 = MockContributions.CreateSaveContribution(db, b2, dt.AddSeconds(8), 500, peopleId: 1, contributionType: ContributionTypeCode.Online);
            var b2c5 = MockContributions.CreateSaveContribution(db, b2, dt.AddSeconds(9), 500, peopleId: 1, contributionType: ContributionTypeCode.Pledge);
            var b2c6 = MockContributions.CreateSaveContribution(db, b2, dt.AddSeconds(10), 500, peopleId: 1, contributionType: ContributionTypeCode.ReturnedCheck);
            var b2c7 = MockContributions.CreateSaveContribution(db, b2, dt.AddSeconds(11), 500, peopleId: 1, contributionType: ContributionTypeCode.Reversed);

            return(bundleList);
        }
        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 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 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);
            }
        }
Пример #6
0
        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);
            }
        }
Пример #7
0
        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 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);
            }
        }