public static IEnumerable <ContributionInfo> NonTaxItems(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { var q = from c in Db.Contributions where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionTypeId != ContributionTypeCode.Stock where c.ContributionTypeId != ContributionTypeCode.GiftInKind where c.ContributionTypeId != ContributionTypeCode.Pledge where !Codes.ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionStatusId == ContributionStatusCode.Recorded where c.ContributionDate >= fromDate where c.ContributionDate.Value.Date <= toDate.Date where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionFund.NonTaxDeductible == true || ContributionTypeCode.NonTaxTypes.Contains(c.ContributionTypeId) where (c.PledgeFlag ?? false) == false orderby c.ContributionDate select new ContributionInfo { ContributionId = c.ContributionId, ContributionAmount = c.ContributionAmount ?? 0, ContributionDate = c.ContributionDate ?? SqlDateTime.MinValue.Value, Fund = c.ContributionFund.FundName, CheckNo = c.CheckNo, Name = c.Person.Name, Description = c.ContributionDesc }; return(q); }
public static IEnumerable<ContributionInfo> contributions(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { var q = from c in Db.Contributions where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionTypeId != ContributionTypeCode.GiftInKind where c.ContributionTypeId != ContributionTypeCode.Stock where c.ContributionStatusId == ContributionStatusCode.Recorded where c.ContributionDate >= fromDate where c.ContributionDate.Value.Date <= toDate.Date where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where !(c.ContributionFund.NonTaxDeductible ?? false) where !ContributionTypeCode.NonTaxTypes.Contains(c.ContributionTypeId) orderby c.ContributionDate select new ContributionInfo { ContributionId = c.ContributionId, ContributionAmount = c.ContributionAmount ?? 0, ContributionDate = c.ContributionDate ?? SqlDateTime.MinValue.Value, Fund = c.ContributionFund.FundName, CheckNo = c.CheckNo, Name = c.Person.Name, Description = c.ContributionDesc }; return q; }
public static IEnumerable <GiftsInKind> GiftsInKind(CMSDataContext db, ContributorInfo ci, DateTime fromDate, DateTime toDate, List <int> funds) { var q = from c in db.GiftsInKind(ci.PeopleId, ci.SpouseID, ci.Joint, fromDate, toDate, funds.JoinInts(",")) select c; return(q); }
public static IEnumerable <UnitPledgeSummary> Pledges(CMSDataContext db, ContributorInfo ci, DateTime toDate, List <int> funds) { var q = from c in db.UnitPledgeSummary(ci.PeopleId, ci.SpouseID, ci.Joint, toDate, funds.JoinInts(",")) select c; return(q); }
public static IEnumerable <GiftSummary> GiftSummary(CMSDataContext db, ContributorInfo ci, DateTime fromDate, DateTime toDate, List <int> funds) { var q = from c in db.GiftSummary(ci.PeopleId, ci.SpouseId, ci.Joint, fromDate, toDate, funds.JoinInts(",")) orderby c.FundName select c; return(q); }
public static IEnumerable <StockGift> StockGifts(CMSDataContext db, ContributorInfo ci, DateTime fromDate, DateTime toDate, List <int> funds) { var q = from c in db.StockGifts(ci.PeopleId, ci.SpouseID, ci.Joint, fromDate, toDate, funds.JoinInts(",")) orderby c.ContributionDate select c; return(q); }
public static IEnumerable <UnitPledgeSummary> Pledges(CMSDataContext db, ContributorInfo ci, DateTime toDate, List <int> funds) { var showNegatives = db.Setting("ShowNegativePledgeBalances"); var q = from c in db.UnitPledgeSummary(ci.PeopleId, ci.SpouseId, ci.Joint, toDate, funds.JoinInts(",")) orderby c.FundName select c; foreach (var p in q) { decimal balance = (p.Pledged - p.Given) ?? 0; p.Balance = (!showNegatives && balance < 0) ? 0 : balance; yield return(p); } }
public static IEnumerable <ContributionInfo> GiftsInKind(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { var q = from c in Db.Contributions where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId == ContributionTypeCode.GiftInKind where c.ContributionStatusId.Value != ContributionStatusCode.Reversed where c.ContributionDate <= toDate orderby c.ContributionDate select new ContributionInfo { ContributionDate = c.ContributionDate, Fund = c.ContributionFund.FundName, Description = c.ContributionDesc }; return(q); }
public static IEnumerable <PledgeSummaryInfo> pledges(CMSDataContext db, ContributorInfo ci, DateTime toDate) { var PledgeExcludes = new int[] { ContributionTypeCode.Reversed, }; var showPledgeIfMet = db.Setting("ShowPledgeIfMet", "true").ToBool(); var qp = from p in db.Contributions where p.PeopleId == ci.PeopleId || (ci.Joint && p.PeopleId == ci.SpouseID) where p.ContributionTypeId == ContributionTypeCode.Pledge where p.ContributionStatusId.Value != ContributionStatusCode.Reversed where p.ContributionFund.FundStatusId == 1 // active where p.ContributionDate.Value.Date <= toDate.Date where p.ContributionFund.FundPledgeFlag group p by p.FundId into g select new { FundId = g.Key, Fund = g.First().ContributionFund.FundName, Total = g.Sum(p => p.ContributionAmount) }; var qc = from c in db.Contributions where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionTypeId != ContributionTypeCode.GiftInKind where !Codes.ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionStatusId == ContributionStatusCode.Recorded where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId != ContributionTypeCode.Pledge where c.ContributionStatusId != ContributionStatusCode.Reversed where c.ContributionDate.Value.Date <= toDate.Date where c.ContributionFund.FundPledgeFlag group c by c.FundId into g select new { FundId = g.Key, Total = g.Sum(c => c.ContributionAmount) }; var q = from p in qp join c in qc on p.FundId equals c.FundId into items from c in items.DefaultIfEmpty() where (p.Total ?? 0) > (c == null ? 0 : c.Total ?? 0) || showPledgeIfMet orderby p.FundId descending select new PledgeSummaryInfo { Fund = p.Fund, ContributionAmount = c.Total, PledgeAmount = p.Total }; return(q); }
public static IEnumerable <ContributionInfo> StockGifts(CMSDataContext db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { var q = from c in db.Contributions where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionTypeId == ContributionTypeCode.Stock where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionStatusId == ContributionStatusCode.Recorded where c.ContributionDate >= fromDate where c.ContributionDate.Value.Date <= toDate.Date where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) orderby c.ContributionDate select new ContributionInfo { ContributionId = c.ContributionId, ContributionAmount = c.ContributionAmount ?? 0, ContributionDate = c.ContributionDate ?? SqlDateTime.MinValue.Value, Fund = c.ContributionFund.FundName, CheckNo = c.CheckNo, Name = c.Person.Name, Description = c.ContributionDesc }; return(q); }
public static IEnumerable <NonTaxContribution> NonTaxItems(CMSDataContext db, ContributorInfo ci, DateTime fromDate, DateTime toDate, List <int> funds) { var q = from c in db.NonTaxContributions(ci.PeopleId, ci.SpouseID, ci.Joint, fromDate, toDate, funds.JoinInts(",")) select c; return(q); }
private void writeContributions(ContributorInfo c) { string hdrContributions = " Date Fund Name Amount Date Fund Name Amount\n\n"; rWrite(hdrContributions); var q2 = APIContribution.contributions(Db, c, fd, td); var contrib = new List<string>(); foreach (var ci in q2) contrib.Add("{0:MM/dd/yyyy} {1,-16}{2,11:N2}" .Fmt(ci.ContributionDate, ci.Fund, ci.ContributionAmount)); var n = contrib.Count; var nrows = n / 32 * 16; var remainder = n % 32; if (remainder < 16) nrows += remainder; else nrows += 16; int row, c1; for (row = 0, c1 = 0; row < nrows; row++, c1++) { if (row % 16 == 0) c1 = row * 2; var line = contrib[c1]; var c2 = c1 + 16; if (c2 < n) line += " " + contrib[c2]; if (row > 0 && row % 16 == 0) { pageStatement += 1; writeHeader(c); rWrite(hdrContributions); rWrite("\n"); } rWrite(line + "\n"); } if (nrows > 0) rWrite("\n"); }
public static IEnumerable<ContributionInfo> GiftsInKind(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { var q = from c in Db.Contributions where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId == ContributionTypeCode.GiftInKind || c.ContributionTypeId == ContributionTypeCode.Stock where c.ContributionStatusId.Value != ContributionStatusCode.Reversed where c.ContributionDate >= fromDate where c.ContributionDate <= toDate orderby c.ContributionDate select new ContributionInfo { ContributionId = c.ContributionId, ContributionDate = c.ContributionDate ?? SqlDateTime.MinValue.Value, Fund = c.ContributionFund.FundName, Description = c.ContributionDesc }; return q; }
public static IEnumerable<ContributionInfo> quarterlySummary(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { int[] excludetypes = new int[] { ContributionTypeCode.ReturnedCheck, ContributionTypeCode.Reversed, ContributionTypeCode.GiftInKind, ContributionTypeCode.Stock, ContributionTypeCode.NonTaxDed, ContributionTypeCode.Pledge, }; var q = from c in Db.Contributions where !excludetypes.Contains(c.ContributionTypeId) where c.ContributionStatusId == ContributionStatusCode.Recorded where c.ContributionDate >= fromDate where c.ContributionDate <= toDate where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId != ContributionTypeCode.Pledge where (c.ContributionFund.NonTaxDeductible ?? false) == false group c by c.ContributionFund.FundName into g orderby g.Key select new ContributionInfo { ContributionAmount = g.Sum(z => z.ContributionAmount ?? 0), Fund = g.Key, }; return q; }
public static IEnumerable<PledgeSummaryInfo> pledges(CMSDataContext Db, ContributorInfo ci, DateTime toDate) { var PledgeExcludes = new int[] { ContributionTypeCode.Reversed, }; var showPledgeIfMet = Db.Setting("ShowPledgeIfMet", "true").ToBool(); var qp = from p in Db.Contributions where p.PeopleId == ci.PeopleId || (ci.Joint && p.PeopleId == ci.SpouseID) where p.ContributionTypeId == ContributionTypeCode.Pledge where p.ContributionStatusId.Value != ContributionStatusCode.Reversed where p.ContributionFund.FundStatusId == 1 // active where p.ContributionDate <= toDate group p by p.FundId into g select new { FundId = g.Key, Fund = g.First().ContributionFund.FundName, Total = g.Sum(p => p.ContributionAmount) }; var qc = from c in Db.Contributions where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionTypeId != ContributionTypeCode.GiftInKind where !Codes.ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionStatusId == ContributionStatusCode.Recorded where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId != ContributionTypeCode.Pledge where c.ContributionStatusId != ContributionStatusCode.Reversed where c.ContributionDate <= toDate group c by c.FundId into g select new { FundId = g.Key, Total = g.Sum(c => c.ContributionAmount) }; var q = from p in qp join c in qc on p.FundId equals c.FundId into items from c in items.DefaultIfEmpty() where (p.Total ?? 0) > (c == null ? 0 : c.Total ?? 0) || showPledgeIfMet orderby p.FundId descending select new PledgeSummaryInfo { Fund = p.Fund, ContributionAmount = c.Total, PledgeAmount = p.Total }; return q; }
public static IEnumerable <ContributionInfo> quarterlySummary(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { int[] excludetypes = new int[] { ContributionTypeCode.ReturnedCheck, ContributionTypeCode.Reversed, ContributionTypeCode.GiftInKind, ContributionTypeCode.Stock, ContributionTypeCode.NonTaxDed, ContributionTypeCode.Pledge, }; var q = from c in Db.Contributions where !excludetypes.Contains(c.ContributionTypeId) where c.ContributionStatusId == ContributionStatusCode.Recorded where c.ContributionDate >= fromDate where c.ContributionDate.Value.Date <= toDate.Date where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where c.ContributionTypeId != ContributionTypeCode.Pledge where (c.ContributionFund.NonTaxDeductible ?? false) == false group c by c.ContributionFund.FundName into g orderby g.Key select new ContributionInfo { ContributionAmount = g.Sum(z => z.ContributionAmount ?? 0), Fund = g.Key, }; return(q); }
private void writeSummary(ContributorInfo c) { string hdr1Pledge = " Pledge History Current Year Summary ({0:MM/dd/yyyy})\n".Fmt(td); string hdr2Pledge = " Fund Name Pledge Given Fund Name Amount This Year\n\n"; var recPledges = new List<string>(); decimal Total = 0; rWrite(hdr1Pledge + hdr2Pledge); foreach (var p in APIContribution.pledges(Db, c, td)) if (p.Fund != null) recPledges.Add("{0,-16}{1,12:N2} {2,12:N2} ".Fmt(p.Fund, p.PledgeAmount, p.ContributionAmount)); foreach (var ci in APIContribution.quarterlySummary(Db, c, fd, td)) { Total += ci.ContributionAmount; if (recPledges != null && recPledges.Count > 0 && countRec < recPledges.Count) recPledges[countRec] += "{0,-20}{1,14:N2} ".Fmt(ci.Fund, ci.ContributionAmount); else recPledges.Add("{0,43}{1,-20}{2,14:N2} ".Fmt("", ci.Fund, ci.ContributionAmount)); countRec++; } countRec = 0; foreach (var s in recPledges) { countRec++; if (countRec > 6 && (countRec % 6) == 1) { pageStatement++; writeHeader(c); rWrite(hdr1Pledge + hdr2Pledge); } rWrite(s + "\n"); } if (countRec != 0) rWrite("\n"); rWrite(totalLine + Total.ToString("C").PadLeft(25) + "\n"); countRec = 0; }
private void writeHeader(ContributorInfo c) { var isAddress2 = c.Address2 != null; if (newPage > 0) rWrite(newPage); newPage = (char)12; rWrite(dateLine); rWrite(churchAddr); rWrite(nineSpaces); rWrite(c.Name.PadRight(42) + "Envelope: # " + c.PeopleId.ToString() + "\n"); rWrite(nineSpaces); if (pageStatement == 1) { rWrite(c.Address1 + "\n"); if (isAddress2) { rWrite(nineSpaces); rWrite(c.Address2); rWrite("\n"); } rWrite(nineSpaces); rWrite(c.City + ", " + c.State + " " + Util.FmtZip(c.Zip) + "\n"); if (!isAddress2) rWrite("\n"); rWrite(disclaimer); } else rWrite("\n" + nineSpaces + "Cont.....Page " + pageStatement.ToString() + "\n".PadRight(6, '\n')); rWrite("-------------------------------------------------------------------------------\n\n"); }
public static IEnumerable <ContributionInfo> contributions(CMSDataContext Db, ContributorInfo ci, DateTime fromDate, DateTime toDate) { var q = from c in Db.Contributions where !ContributionTypeCode.ReturnedReversedTypes.Contains(c.ContributionTypeId) where c.ContributionTypeId != ContributionTypeCode.GiftInKind where c.ContributionStatusId == ContributionStatusCode.Recorded where c.ContributionDate >= fromDate && c.ContributionDate.Value.Date <= toDate where c.PeopleId == ci.PeopleId || (ci.Joint && c.PeopleId == ci.SpouseID) where !(c.ContributionFund.NonTaxDeductible ?? false) where !ContributionTypeCode.NonTaxTypes.Contains(c.ContributionTypeId) orderby c.ContributionDate select new ContributionInfo { ContributionAmount = c.ContributionAmount, ContributionDate = c.ContributionDate, Fund = c.ContributionFund.FundName, CheckNo = c.CheckNo, Name = c.Person.Name }; return(q); }