private SummedDatabasePartner GetSummedDatabasePartner(List <FullDatabaseRow> summedPartnerRows)
        {
            var summedPartner = new SummedDatabasePartner();

            summedPartner.YearlySummedDbData = SplitRowsIntoYears(summedPartnerRows)
                                               .ToDictionary(k => k.Key, v => GetYearlySummedDb(v.Value));

            return(summedPartner);
        }
Beispiel #2
0
        private List <string> GetSummedDbPartnerCsv(string client, SummedDatabasePartner summedDatabasePartner)
        {
            var summedPartnerReportCsv = new List <string>();

            summedPartnerReportCsv.Add($"{InvoiceNumber},{PaymentDue},{PaymentPaid},{LateBelow30},{LateBelow60},{LateBelow90},{LateAbove90}");
            summedPartnerReportCsv.Add(client);

            foreach (var yearlySummedData in summedDatabasePartner.YearlySummedDbData.OrderByDescending(k => k.Key))
            {
                foreach (var monthlySummedData in yearlySummedData.Value.MonthlySummedDbData.OrderByDescending(k => k.Key))
                {
                    summedPartnerReportCsv.Add($"{monthlySummedData.Key}-{yearlySummedData.Key}");
                    summedPartnerReportCsv.AddRange(monthlySummedData.Value.Select(monthlyRow => $"{monthlyRow.InvoiceNumber},{monthlyRow.PaymentDue},{monthlyRow.PaymentPaid},{monthlyRow.PaidBelow30},{monthlyRow.PaidOver30Below60},{monthlyRow.PaidOver60Below90},{monthlyRow.PaidOver90}"));
                    summedPartnerReportCsv.Add($"total due: {monthlySummedData.Value.Sum(payments => payments.PaymentDue)}, total paid: {monthlySummedData.Value.Sum(payments => payments.PaymentPaid)}");
                    summedPartnerReportCsv.Add(string.Empty);
                }
                summedPartnerReportCsv.Add(string.Empty);
            }

            return(summedPartnerReportCsv);
        }