private float GetPaidAboveNinety(FullDatabaseRow row)
 {
     return(row
            .Payments
            .Where(payment => (payment.PaymentDate.AddDays(payment.Latency) - row.PaymentDueDate).TotalDays > 90)
            .Sum(payment => payment.PaymentPaid));
 }
 private float GetPaidBetweenSixtyAndNinety(FullDatabaseRow row)
 {
     return(row
            .Payments
            .Where(payment => (payment.PaymentDate.AddDays(payment.Latency) - row.PaymentDueDate).TotalDays > 60 && (payment.PaymentDate.AddDays(payment.Latency) - row.PaymentDueDate).TotalDays < 90)
            .Sum(payment => payment.PaymentPaid));
 }
 private float GetPaidBelowThirty(FullDatabaseRow row)
 {
     return(row
            .Payments
            .Where(payment => (payment.PaymentDate.AddDays(payment.Latency) - row.PaymentDueDate).TotalDays < 30)
            .Sum(payment => payment.PaymentPaid));
 }
        private List <string> AddClientLogsGetBackIssues(FullDatabaseModel fullDatabase, List <ClientLog> clientLogs)
        {
            var issues = new List <string>();

            if (!clientLogs.Any())
            {
                return(issues);
            }
            var uniqueClientReportRows =
                clientLogs
                .Select(report => report.ClientReport)
                .Aggregate((a, b) => a.Union(b).ToList());

            foreach (var clientReportRow in uniqueClientReportRows)
            {
                if (fullDatabase.FullDatabase.Any(fullDatabaseRow => fullDatabaseRow.InvoiceNumber.Equals(clientReportRow.InvoiceNumber)))
                {
                    continue;
                }

                var newDatabaseRow = new FullDatabaseRow
                {
                    InvoiceNumber  = clientReportRow.InvoiceNumber,
                    PaymentDue     = clientReportRow.AmountDue,
                    PaymentDueDate = new DateTime(
                        clientReportRow.InvoiceDate.Year,
                        clientReportRow.InvoiceDate.Month,
                        DateTime.DaysInMonth(clientReportRow.InvoiceDate.Year, clientReportRow.InvoiceDate.Month)).
                                     AddDays(clientReportRow.PaymentTerms),
                    ClientId = clientReportRow.ClientId
                };

                fullDatabase.FullDatabase.Add(newDatabaseRow);
            }

            return(issues);
        }
 private float GetPaymentsPaid(FullDatabaseRow row)
 {
     return(row
            .Payments
            .Sum(payment => payment.PaymentPaid));
 }