TheAirline.Models.Airlines.Airline.GetInvoicesAmount C# (CSharp) Method

GetInvoicesAmount() public method

public GetInvoicesAmount ( System.DateTime startTime, System.DateTime endTime, Invoice type ) : double
startTime System.DateTime
endTime System.DateTime
type TheAirline.Models.General.Finances.Invoice
return double
        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;
        }