public double GetInvoicesAmount(DateTime startTime, DateTime endTime, Invoice.InvoiceType type)
{
int startYear = startTime.Year;
int endYear = endTime.Year;
int startMonth = startTime.Month;
int endMonth = endTime.Month;
int totalMonths = (endMonth - startMonth) + 12*(endYear - startYear) + 1;
double totalAmount = 0;
var date = new DateTime(startYear, startMonth, 1);
for (int i = 0; i < totalMonths; i++)
{
if (type == Invoice.InvoiceType.Total)
{
totalAmount += Invoices.GetAmount(date.Year, date.Month);
}
else
{
totalAmount += Invoices.GetAmount(type, date.Year, date.Month);
}
date = date.AddMonths(1);
}
return totalAmount;
}