//returns the invoices amount for a specific type for a period public double getRouteInvoiceAmount(Invoice.InvoiceType type, DateTime startTime, DateTime endTime) { int startYear = startTime.Year; int endYear = endTime.Year; int startMonth = startTime.Month; int endMonth = endTime.Month; int totalMonths = (endMonth - startMonth) + 12 * (endYear - startYear); double totalAmount = 0; DateTime date = new DateTime(startYear, startMonth, 1); for (int i = 0; i < totalMonths; i++) { if (type == Invoice.InvoiceType.Total) { totalAmount += this.Invoices.getAmount(date.Year, date.Month); } else { totalAmount += this.Invoices.getAmount(type, date.Year, date.Month); } date = date.AddMonths(1); } return(totalAmount); }
public MonthlyInvoice(Invoice.InvoiceType type, int year, int month, double amount) { this.Type = type; this.Year = year; this.Month = month; this.Amount = amount; }
public double getInvoicesAmountYear(int year, Invoice.InvoiceType type) { if (type == Invoice.InvoiceType.Total) { return(this.Invoices.getYearlyAmount(year)); } else { return(this.Invoices.getYearlyAmount(type, year)); } }
public double getInvoicesAmountMonth(int year, int month, Invoice.InvoiceType type) { if (type == Invoice.InvoiceType.Total) { return(this.Invoices.getAmount(year, month)); } else { return(this.Invoices.getAmount(type, year, month)); } }
//returns if the invoices contains a month, year and type element public Boolean contains(Invoice.InvoiceType type, int year, int month) { Boolean contains; lock (this.MonthlyInvoices) { contains = this.MonthlyInvoices.Exists(m => m.Month == month && m.Year == year && m.Type == type); } return(contains); }
//returns the total amount for a given year, month and type public double getAmount(Invoice.InvoiceType type, int year, int month) { if (contains(type, year, month)) { MonthlyInvoice mInvoice = this.MonthlyInvoices.Find(m => m.Month == month && m.Year == year && m.Type == type); return(mInvoice.Amount); } else { return(0); } }
public void addInvoice(Invoice.InvoiceType type, int year, int month, double amount) { lock (this.MonthlyInvoices) { if (contains(type, year, month)) { MonthlyInvoice mInvoice = this.MonthlyInvoices.Find(m => m.Month == month && m.Year == year && m.Type == type); mInvoice.Amount += amount; } else { MonthlyInvoice mInvoice = new MonthlyInvoice(type, year, month, amount); this.MonthlyInvoices.Add(mInvoice); } } }
//returns invoices amount for a specific type for a route public double getRouteInvoiceAmount(Invoice.InvoiceType type) { double amount = 0; foreach (StopoverRoute stopover in this.Stopovers) { amount += stopover.Legs.Sum(l => l.getRouteInvoiceAmount(type)); } if (type == Invoice.InvoiceType.Total) { amount += this.Invoices.getAmount(); } else { amount += this.Invoices.getAmount(type); } return(amount); }
//sets the invoice to the route public void setRouteInvoice(Invoice.InvoiceType type, int year, int month, double amount) { this.Invoices.addInvoice(type, year, month, amount); }
public MonthlyInvoice(Invoice.InvoiceType type, int year, int month) : this(type, year, month, 0) { }
public SpecsItem(Airline airline, Invoice.InvoiceType type) { this.InvoiceType = type; this.Airline = airline; }
public AirlineFinanceMVVM(Airline airline, Invoice.InvoiceType type) { this.InvoiceType = type; this.Airline = airline; }
//returns the total amount for a given type public double getAmount(Invoice.InvoiceType type) { return(this.MonthlyInvoices.FindAll(i => i.Type == type).Sum(i => i.Amount)); }
//returns the yearly amount for a given type and year public double getYearlyAmount(Invoice.InvoiceType type, int year) { return(this.MonthlyInvoices.FindAll(i => i.Type == type && i.Year == year).Sum(i => i.Amount)); }