public void AddSum() { var sumAmount = _model.Sum(x => x.Amount); var sumDiscount = _model.Sum(x => x.Discount); var generalSum = sumAmount + sumDiscount; _document.Add(_pdfHelper.AddParagraph($"Сумма дотацій - {sumAmount} {_pdfHelper.Сurrency}", Element.ALIGN_RIGHT)); _document.Add(_pdfHelper.AddParagraph($"Сумма знижок - {sumDiscount} {_pdfHelper.Сurrency}", Element.ALIGN_RIGHT)); _document.Add(_pdfHelper.AddParagraph($"Загальна сумма - {generalSum} {_pdfHelper.Сurrency}", Element.ALIGN_RIGHT)); _pdfHelper.AddEmptyParagraph(_document, 2); GeneralSum = generalSum; }
public void AddSum() { var sumAmount = _model.Sum(x => x.Amount); foreach (var item in _model.GroupBy(l => l.Name).Select(cl => new { cl.First().Name, Sum = cl.Sum(c => c.Amount) }).ToList()) { _document.Add(_pdfHelper.AddParagraph($"Cумма від {item.Name} - {item.Sum} {_pdfHelper.Сurrency}", Element.ALIGN_RIGHT)); } _document.Add(_pdfHelper.AddParagraph($"Загальна сумма - {sumAmount} {_pdfHelper.Сurrency}", Element.ALIGN_RIGHT)); _pdfHelper.AddEmptyParagraph(_document, 2); GeneralSum = sumAmount; }
private void AddBody(Document document, ReportModel model) { var generalSum = 0.0M; if (model.MaterialAidEmployees.Any()) { var template = new MaterialAidTemplate(_pdfHelper, document, model.MaterialAidEmployees); template.CreateBody(); template.AddSum(); generalSum += template.GeneralSum; } if (model.AwardEmployees.Any()) { var template = new AwardTemplate(_pdfHelper, document, model.AwardEmployees); template.CreateBody(); template.AddSum(); generalSum += template.GeneralSum; } if (model.CulturalEmployees.Any()) { var template = new CulturalTemplate(_pdfHelper, document, model.CulturalEmployees); template.CreateBody(); template.AddSum(); generalSum += template.GeneralSum; } if (model.EventEmployees.Any(x => x.TypeEvent == TypeEvent.Travel)) { var template = new EventTemplate(_pdfHelper, document, model.EventEmployees.Where(x => x.TypeEvent == TypeEvent.Travel)); template.CreateBody(); template.AddSum(); generalSum += template.GeneralSum; } if (model.EventEmployees.Any(x => x.TypeEvent == TypeEvent.Wellness)) { var template = new EventTemplate(_pdfHelper, document, model.EventEmployees.Where(x => x.TypeEvent == TypeEvent.Wellness)); template.CreateBody(); template.AddSum(); generalSum += template.GeneralSum; } if (model.EventEmployees.Any(x => x.TypeEvent == TypeEvent.Tour)) { var template = new EventTemplate(_pdfHelper, document, model.EventEmployees.Where(x => x.TypeEvent == TypeEvent.Tour)); template.CreateBody(); template.AddSum(); generalSum += template.GeneralSum; } if (model.GiftEmployees.Any()) { var template = new GiftTemplate(_pdfHelper, document, model.GiftEmployees); template.CreateBody(); template.AddSum(); generalSum += template.GeneralSum; } if (model.TypeReport == TypeReport.All) { _pdfHelper.AddEmptyParagraph(document, 2); document.Add(_pdfHelper.AddParagraph($"Cумма - {generalSum} {_pdfHelper.Сurrency}", Element.ALIGN_RIGHT)); } _pdfHelper.AddEmptyParagraph(document, 2); }