internal void CreatePayments(Booking booking, PaymentController paymentController) { Supplier supplier = (Supplier)booking.Supplier; Customer customer = (Customer)booking.Customer; BookingType bookingType = booking.Type; List<IPaymentRule> paymentRules = findMatchingPaymentRules(supplier, customer, bookingType); foreach (IPaymentRule paymentRule in paymentRules) { DateTime dueDate; if (paymentRule.BaseDate == BaseDate.StartDate) { dueDate = booking.StartDate.AddDays(paymentRule.DaysOffset); } else { dueDate = booking.EndDate.AddDays(paymentRule.DaysOffset); } booking.CalculateAmounts(); decimal dueAmount = booking.TransferAmount * paymentRule.Percentage / 100; Customer lonelyTree = customerController.findLonelyTree(); IPayment payment = paymentController.CreatePayment(dueDate, dueAmount, lonelyTree, booking.Supplier, paymentRule.PaymentType, booking.Sale, booking.BookingNumber); paymentController.UpdatePayment(payment); } }
internal IBooking Create(Supplier supplier, Customer customer, string sale, int bookingNumber, DateTime startDate, DateTime endDate) { //Creates a new object and adds it to a list of Bookings. Booking booking = new Booking(supplier, customer, sale, bookingNumber, startDate, endDate, dataAccessFacade); bookings.Add(booking); return booking; }
internal static List<Booking> ReadAll(IDataAccessFacade dataAccessFacade) { //Calls readall bookings and adds them to a list List<IBooking> bookingEntities = dataAccessFacade.ReadAllBookings(); List<Booking> bookings = new List<Booking>(); foreach (IBooking bookingEntity in bookingEntities) { Booking booking = new Booking(bookingEntity, dataAccessFacade); bookings.Add(booking); } return bookings; }
internal void Update(Booking booking) { //Call update for a specific booking. booking.Update(); }
internal void Delete(Booking booking) { //Calls delete for an object and removes it from the list. booking.Delete(); bookings.Remove(booking); }