public Act(Payer payer, DateTime date) : this() { SetPayer(payer); Date = Payer.GetDocumentDate(date); Period = date.ToPeriod(); }
public Invoice(Payer payer, DateTime date) : this() { Parts = new List <InvoicePart>(); CreatedOn = DateTime.Now; Author = SecurityContext.Administrator.Name; SetPayer(payer); Date = Payer.GetDocumentDate(date); Period = Date.ToPeriod(); }
public Act(DateTime actDate, params Invoice[] invoices) : this() { Period = invoices.Select(i => i.Period).Distinct().Single(); Payer = invoices.Select(i => i.Payer).Distinct().Single(); Recipient = invoices.Select(i => i.Recipient).Distinct().Single(); PayerName = invoices.Select(i => i.PayerName).Distinct().Single(); Customer = invoices.Select(i => i.Customer).Distinct().Single(); Date = Payer.GetDocumentDate(actDate); var invoiceParts = invoices.SelectMany(i => i.Parts); if (Payer.InvoiceSettings.DoNotGroupParts) { Parts = invoiceParts .Select(p => new ActPart(p.Name, p.Count, p.Cost)) .ToList(); } else { Parts = invoiceParts .GroupBy(p => new { p.Name, p.Cost }) .Select(g => new ActPart(g.Key.Name, g.Sum(i => i.Count), g.Key.Cost)) .ToList(); } CalculateSum(); foreach (var part in invoiceParts.Where(p => p.Ad != null)) { part.Ad.Act = this; } foreach (var invoice in invoices) { invoice.Act = this; } }