Exemplo n.º 1
0
        private void AddSummaryPledge(Contribution contribution, IQueryable <Contribution> contributionRecords)
        {
            var fundName = contribution.ContributionFund.FundName;

            if (!PledgesSummary.Any(p => p.Fund == fundName))
            {
                decimal amountPledged = contributionRecords.Where(c => c.ContributionTypeId == ContributionTypeCode.Pledge && c.ContributionFund.FundName == fundName)
                                        .Sum(c => c.ContributionAmount ?? 0);
                List <Contribution> contributionsThisFund = contributionRecords
                                                            .Where(c => c.ContributionTypeId != ContributionTypeCode.Pledge && c.ContributionFund.FundName == fundName).ToList();
                decimal amountContributed = 0;
                if (contributionsThisFund.Count != 0)
                {
                    amountContributed = contributionsThisFund.Sum(c => c.ContributionAmount ?? 0);
                }
                PledgesSummary.Add(new PledgesSummary()
                {
                    FundId            = contribution.ContributionFund.FundId,
                    Fund              = fundName,
                    AmountPledged     = amountPledged,
                    AmountContributed = amountContributed,
                    Balance           = amountPledged - amountContributed < 0 ? 0 : amountPledged - amountContributed
                });
            }
        }
Exemplo n.º 2
0
        private void AddSummaryPledge(Contribution contribution, IQueryable <Contribution> contributionRecords)
        {
            var fundName       = contribution.ContributionFund.FundName;
            var fundOnlineSort = contribution.ContributionFund.OnlineSort;

            if (!PledgesSummary.Any(p => p.Fund == fundName))
            {
                var     lastPledgeDate = contribution.ContributionDate;
                decimal amountPledged  = contributionRecords.Where(c => c.ContributionTypeId == ContributionTypeCode.Pledge && c.ContributionFund.FundName == fundName)
                                         .Sum(c => c.ContributionAmount ?? 0);
                List <Contribution> contributionsThisFund = contributionRecords
                                                            .Where(c => c.ContributionTypeId != ContributionTypeCode.Pledge && c.ContributionFund.FundName == fundName).ToList();
                decimal amountContributed = 0;
                if (contributionsThisFund.Count != 0)
                {
                    amountContributed = contributionsThisFund.Sum(c => c.ContributionAmount ?? 0);
                }
                var pledgeBalance = amountPledged - amountContributed;
                if (pledgeBalance < 0 && !showNegativePledgeBalances)
                {
                    pledgeBalance = 0;
                }
                PledgesSummary.Add(new PledgesSummary()
                {
                    FundId            = contribution.ContributionFund.FundId,
                    Fund              = fundName,
                    AmountPledged     = amountPledged,
                    AmountContributed = amountContributed,
                    Balance           = pledgeBalance,
                    LastPledgeDate    = contribution.ContributionDate.Value,
                    FundOnlineSort    = contribution.ContributionFund.OnlineSort
                });
            }
        }