Exemple #1
0
        /// <summary>
        /// This method returns total tax ABC owes in the system.
        /// </summary>
        public decimal Get_TotalTax_For_TheSystem()
        {
            try
            {
                decimal       totalTax      = 0;
                List <string> bookingIdList = new List <string>();
                Dictionary <string, decimal> bookingIdWithTotalPrice = new Dictionary <string, decimal>();

                var hotel_ids = RDM.Get_HotelIds_For_TaxableHotels();

                foreach (var hotel in hotel_ids)
                {
                    var booking_ids = RDM.Get_AllBookingIds_For_HotelId(hotel);
                    bookingIdList = RDM.Convert_RedisList_To_StringList(booking_ids);

                    bookingIdWithTotalPrice = RDM.Get_TotalPrice_For_BookingIds(bookingIdList);

                    foreach (var eachTotalPrice in bookingIdWithTotalPrice)
                    {
                        decimal eachTax = Math.Round((eachTotalPrice.Value * C.TAX_RATE), 2, MidpointRounding.AwayFromZero);
                        totalTax += eachTax;
                    }

                    bookingIdList.Clear();
                    bookingIdWithTotalPrice.Clear();
                }
                return(totalTax);
            }
            catch (ArgumentException ex1)
            {
                throw new Exception(C.ARGUMENT_EXP + ex1.Message);
            }
            catch (Exception ex2)
            {
                throw new Exception(ex2.Message);
            }
        }