/// <summary> /// When a new Transaction is generated in the Process /// </summary> /// <param name="costPerLiterInCent">the cost of the fueltype per liter</param> /// <param name="amount"></param> /// <param name="fueltype"></param> /// <param name="zapfsaulenName"></param> public Transaction(int costPerLiterInCent, int amount, FuelType fueltype, string zapfsaulenName) // SUPER IMPORTANT!: DO NOT USE FUELTYPE FOR COST CALCULATION DO NOT REMOVE COSTPERLITERINCENT { SetDateTimeStampNow(); this.CostPerLiterInCent = costPerLiterInCent; this.Amount = amount; this.FuelTypeName = fueltype.GetFuelTypeName(); this.ZapfsauleName = zapfsaulenName; this.IsPaid = false; }
/// <summary> /// calculates todays total liters from a certain fueltype /// </summary> /// <param name="fuelType">The fuel type from which the amount of liters needs to be calculated</param> /// <returns>Amount of drained liters from tank according to the fuel type</returns> public int GetTodaysLiterStats(FuelType fuelType) { int totalLiters = 0; // gets fuel amount of paid transactions foreach (Transaction transaction in this.tankstellenkasse.GetPaidTransactions()) { if (transaction.GetDateTime().ToShortDateString() == DateTime.Now.ToShortDateString() && transaction.GetFuelTypeName() == fuelType.GetFuelTypeName()) { totalLiters += transaction.GetTotalFuelAmount(); } } // gets fuel amount of unpaid transactions foreach (Transaction transaction in this.tankstellenkasse.GetUnpaidTransactions()) { if (transaction.GetDateTime().ToShortDateString() == DateTime.Now.ToShortDateString() && transaction.GetFuelTypeName() == fuelType.GetFuelTypeName()) { totalLiters += transaction.GetTotalFuelAmount(); } } return(totalLiters); }