상속: BaseModel
 public MonthlyInvoice(Invoice.InvoiceType type, int year, int month, int day, double amount)
 {
     Type = type;
     Year = year;
     Month = month;
     Amount = amount;
     Day = day;
 }
예제 #2
0
        public Boolean Contains(Invoice.InvoiceType type, int year, int month, int day)
        {
            Boolean contains;
            lock (MonthlyInvoices)
            {
                contains = MonthlyInvoices.Exists(m => m.Month == month && m.Year == year && m.Day == day && m.Type == type);
            }

            return contains;
        }
예제 #3
0
 public void AddInvoice(Invoice.InvoiceType type, int year, int month, int day, double amount)
 {
     lock (MonthlyInvoices)
     {
         if (Contains(type, year, month, day))
         {
             MonthlyInvoice mInvoice =
                 MonthlyInvoices.Find(m => m.Month == month && m.Year == year && m.Type == type && m.Day == day);
             mInvoice.Amount += amount;
         }
         else
         {
             var mInvoice = new MonthlyInvoice(type, year, month, day, amount);
             MonthlyInvoices.Add(mInvoice);
         }
     }
 }
예제 #4
0
 public double GetInvoicesAmountMonth(int year, int month, Invoice.InvoiceType type)
 {
     if (type == Invoice.InvoiceType.Total)
     {
         return Invoices.GetAmount(year, month);
     }
     return Invoices.GetAmount(type, year, month);
 }
예제 #5
0
        /*
        //returns all invoices with type
        public List<Invoice> getInvoices(DateTime start, DateTime end, Invoice.InvoiceType type)

        {
            return this.Invoices.FindAll(i=>i.Date>=start && i.Date <=end && i.Type == type);
        }
        //returns all the invoices in a specific period
        public List<Invoice> getInvoices(DateTime start, DateTime end)
        {
           return this.Invoices.FindAll(delegate(Invoice i) { return i.Date >= start && i.Date <= end; });

        }
           */
        //returns the amount of all the invoices in a specific period of a specific type
        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;
        }
예제 #6
0
        //removes a facility from the airline
        //adds an invoice for the airline - both incoming and expends - if updateMoney == true the money is updated as well
        public void AddInvoice(Invoice invoice, bool updateMoney = true)
        {
            Invoices.AddInvoice(invoice);

            if (updateMoney)
            {
                Money += invoice.Amount;
            }
        }
예제 #7
0
 public AirlineFinanceMVVM(Models.Airlines.Airline airline, Invoice.InvoiceType type)
 {
     InvoiceType = type;
     Airline = airline;
 }
 //adds an invoice to an airline
 public static void AddAirlineInvoice(Airline airline, DateTime date, Invoice.InvoiceType type, double amount)
 {
     if (airline.IsHuman && GameObject.GetInstance().HumanAirline == airline)
     {
         GameObject.GetInstance().AddHumanMoney(amount);
         GameObject.GetInstance().HumanAirline.AddInvoice(new Invoice(date, type, amount), false);
     }
     else
         airline.AddInvoice(new Invoice(date, type, amount));
 }
예제 #9
0
        //returns invoices amount for a specific type for a route
        public double GetRouteInvoiceAmount(Invoice.InvoiceType type)
        {
            double amount = Stopovers.Sum(stopover => stopover.Legs.Sum(l => l.GetRouteInvoiceAmount(type)));

            if (type == Invoice.InvoiceType.Total)
            {
                amount += Invoices.GetAmount();
            }
            else
            {
                amount += Invoices.GetAmount(type);
            }

            return amount;
        }
예제 #10
0
 public void SetInvoice(Invoice.InvoiceType type, int year, int month, int day, double amount)
 {
     Invoices.AddInvoice(type, year, month, day, amount);
 }
예제 #11
0
 //adds an invoice to the invoices
 public void AddInvoice(Invoice invoice)
 {
     AddInvoice(invoice.Type, invoice.Date.Year, invoice.Date.Month, invoice.Date.Day, invoice.Amount);
 }
예제 #12
0
 public double GetYearlyAmount(Invoice.InvoiceType type, int year)
 {
     return MonthlyInvoices.FindAll(i => i.Type == type && i.Year == year).Sum(i => i.Amount);
 }
 public MonthlyInvoice(Invoice.InvoiceType type, int year, int month, int day)
     : this(type, year, month, day, 0)
 {
 }
예제 #14
0
 public double GetInvoicesAmountYear(int year, Invoice.InvoiceType type)
 {
     if (type == Invoice.InvoiceType.Total)
     {
         return Invoices.GetYearlyAmount(year);
     }
     return Invoices.GetYearlyAmount(type, year);
 }
예제 #15
0
 //returns the yearly amount for a given type and year
 //returns the total amount for a given type
 public double GetAmount(Invoice.InvoiceType type)
 {
     return MonthlyInvoices.FindAll(i => i.Type == type).Sum(i => i.Amount);
 }
예제 #16
0
 public void SetInvoice(Invoice invoice)
 {
     Invoices.AddInvoice(invoice);
 }
예제 #17
0
 //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 =
             MonthlyInvoices.Find(m => m.Month == month && m.Year == year && m.Type == type);
         return mInvoice.Amount;
     }
     return 0;
 }
        //does the maintenance of a given type, sends the invoice, updates the last/next maintenance, and improves the aircraft's damage
        //make sure you pass this function a string value of either "A" "B" "C" or "D" or it will throw an error!
        public static void DoMaintenance(FleetAirliner airliner)
        {
            if (airliner.SchedAMaintenance == GameObject.GetInstance().GameTime.Date)
            {
                double expense = (airliner.Airliner.GetValue()*0.01) + 2000;
                GameObject.GetInstance().AddHumanMoney((long) -expense);
                var maintCheck = new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Maintenances, -expense);
                AirlineHelpers.AddAirlineInvoice(airliner.Airliner.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Maintenances, -expense);
                airliner.Airliner.Condition += Rnd.Next(3, 10);
                if (airliner.Airliner.Condition > 100) airliner.Airliner.Condition = 100;
                airliner.LastAMaintenance = GameObject.GetInstance().GameTime;
                airliner.SchedAMaintenance = airliner.SchedAMaintenance.AddDays(airliner.AMaintenanceInterval);
                airliner.MaintenanceHistory.Add(maintCheck, "A");
            }

            if (airliner.SchedBMaintenance == GameObject.GetInstance().GameTime.Date)
            {
                double expense = (airliner.Airliner.GetValue()*0.02) + 4500;
                GameObject.GetInstance().AddHumanMoney((long) -expense);
                var maintCheck = new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Maintenances, -expense);
                AirlineHelpers.AddAirlineInvoice(airliner.Airliner.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Maintenances, -expense);
                airliner.Airliner.Condition += Rnd.Next(12, 20);
                if (airliner.Airliner.Condition > 100) airliner.Airliner.Condition = 100;
                airliner.LastBMaintenance = GameObject.GetInstance().GameTime;
                airliner.SchedBMaintenance = airliner.SchedBMaintenance.AddDays(airliner.BMaintenanceInterval);
                airliner.MaintenanceHistory.Add(maintCheck, "B");
            }

            if (airliner.SchedCMaintenance == GameObject.GetInstance().GameTime.Date)
            {
                double expense = (airliner.Airliner.GetValue()*0.025) + 156000;
                airliner.OOSDate = airliner.SchedCMaintenance.AddDays(airliner.Airliner.Condition + 20);
                GameObject.GetInstance().AddHumanMoney((long) -expense);
                var maintCheck = new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Maintenances, -expense);
                AirlineHelpers.AddAirlineInvoice(airliner.Airliner.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Maintenances, -expense);
                airliner.Airliner.Condition += Rnd.Next(20, 30);
                if (airliner.Airliner.Condition > 100) airliner.Airliner.Condition = 100;
                airliner.LastCMaintenance = GameObject.GetInstance().GameTime;
                airliner.SchedCMaintenance = airliner.CMaintenanceInterval > -1
                                                 ? airliner.SchedCMaintenance.AddMonths(airliner.CMaintenanceInterval)
                                                 : airliner.DueCMaintenance = GameObject.GetInstance().GameTime.AddMonths(18);
                airliner.MaintenanceHistory.Add(maintCheck, "C");
                foreach (Route r in airliner.Routes.ToList())
                {
                    airliner.MaintRoutes.Add(r);
                    airliner.Routes.Remove(r);
                }
            }

            if (airliner.SchedDMaintenance == GameObject.GetInstance().GameTime.Date)
            {
                double expense = (airliner.Airliner.GetValue()*0.03) + 1200000;
                airliner.OOSDate = airliner.SchedDMaintenance.AddDays(airliner.Airliner.Condition + 50);
                GameObject.GetInstance().AddHumanMoney((long) -expense);
                var maintCheck = new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Maintenances, -expense);
                AirlineHelpers.AddAirlineInvoice(airliner.Airliner.Airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Maintenances, -expense);
                airliner.Airliner.Condition += Rnd.Next(35, 50);
                if (airliner.Airliner.Condition > 100) airliner.Airliner.Condition = 100;
                airliner.LastDMaintenance = GameObject.GetInstance().GameTime;
                airliner.SchedDMaintenance = airliner.DMaintenanceInterval > -1
                                                 ? airliner.SchedDMaintenance.AddMonths(airliner.DMaintenanceInterval)
                                                 : airliner.DueDMaintenance = GameObject.GetInstance().GameTime.AddMonths(60);
                airliner.DueDMaintenance = GameObject.GetInstance().GameTime.AddMonths(60);
                airliner.MaintenanceHistory.Add(maintCheck, "D");
                foreach (Route r in airliner.Routes.ToList())
                {
                    airliner.MaintRoutes.Add(r);
                    airliner.Routes.Remove(r);
                }
            }
        }
예제 #19
0
 public void AddRouteInvoice(Invoice invoice)
 {
     Invoices.AddInvoice(invoice);
 }