Esempio n. 1
0
        /// <summary>
        /// Get a booking reports
        /// </summary>
        /// <param name="bookingRequest">Booking request</param>
        /// <returns>Return a report</returns>
        public ReportingResult GetBookingReports(ReportingBookingRequest bookingRequest)
        {
            List<Model.Reporting.Booking> bookings = GetBookingsByRequest(bookingRequest);

            BookingReport bookingReport = new BookingReport(bookings, dictionaryDao, bookingRequest.CultureCode);

            ReportingResult reportingResult = new ReportingResult();
            reportingResult.ContentType = BookingReport.CONTENT_TYPE;
            reportingResult.FileContent = bookingReport.BuildReport();

            return reportingResult;
        }
Esempio n. 2
0
        public List<Model.Reporting.Booking> Execute(ReportingBookingRequest request)
        {
            // in parameters
            var parameters = new List<SqlParameter>
            {
                DbHelper.CreateParameter(Parameters.BusinessId, request.BusinessId),
                DbHelper.CreateParameter(Parameters.CultureCode, request.CultureCode),
                DbHelper.CreateParameter(Parameters.StartDate, request.StartDate),
                DbHelper.CreateParameter(Parameters.EndDate, request.EndDate),
                DbHelper.CreateParameter(Parameters.SearchBy, request.ReportingBookingType.ToString()),
                DbHelper.CreateParameter(Parameters.DctNightKey, DictionaryConstants.NIGHT_KEY),
                DbHelper.CreateParameter(Parameters.DctNightsKey, DictionaryConstants.NIGHTS_KEY),
                DbHelper.CreateParameter(Parameters.OfflineSource, request.OfflineSource.GetCode())
            };

            return DbHelper.CreateInstanceList(this, MapRecord, parameters);
        }
Esempio n. 3
0
            public void GetByBookingDateWithValidParametersReturnValidBooking()
            {
                // Arrange
                var startDate = DateTime.Now.AddDays(-1);
                var endDate = DateTime.Now.AddDays(1);
                var request = new ReportingBookingRequest
                {
                    BusinessId = BUSINESS_ID,
                    StartDate = startDate,
                    EndDate = endDate,
                    CultureCode = DEFAULT_CULTURE,
                    ReportingBookingType = ReportingBookingTypeEnum.BookingDate,
                    OfflineSource = OfflineSourceEnum.Web
                };

                // Act
                var bookings = reportBookingDao.GetBookingReport(request);

                // Assert
                Assert.IsTrue(bookings.Count() == 1);
                Assert.IsTrue(bookings[0].BusinessId == BUSINESS_ID);
                Assert.IsTrue(bookings[0].BookingDate >= startDate);
                Assert.IsTrue(bookings[0].BookingDate <= endDate);
            }
Esempio n. 4
0
 /// <summary>
 /// Get booking reports filtered by report type
 /// </summary>
 /// <param name="request">booking report request</param>
 /// <returns>Return a bookings array</returns>
 public List<Model.Reporting.Booking> GetBookingReport(ReportingBookingRequest request)
 {
     return new StoredProcedures.Reporting.GetBookingReportMapper().Execute(request);
 }
Esempio n. 5
0
        /// <summary>
        /// Get booking reports
        /// </summary>
        /// <param name="bookingRequest">Booking request</param>
        /// <returns>Return a report</returns>
        public MobileBookingReport GetMobileBookingReports(ReportingBookingRequest bookingRequest)
        {
            // get all bookings for the request
            var bookings = GetBookingsByRequest(bookingRequest);

            var currencySymbol = string.Empty;

            // get unknown text
            if (bookings.Any())
            {
                currencySymbol = bookings.First().CurrencySymbol;

                var rootCulture = dictionaryManager.GetRootCultureForGivenCultureCode(bookingRequest.CultureCode);

                // get root culture 
                var items =
                    dictionaryManager.GetDictionaryItemByKeysAndCultures(new List<string> { DictionaryConstants.NOT_KNOWN_KEY },
                                                                         new List<string> { rootCulture });

                if (CheckDictionaryItemExistence(items))
                {
                    var notKnown = items.First().DictionaryInstances.First().Content;
                    bookings.ForEach(b => b.NotKnownText = notKnown);
                }

                //for all bookings with no channel name set them to the PMS order source
                if (bookingRequest.ReportingBookingType == ReportingBookingTypeEnum.BookingDate)
                {
                    items = dictionaryManager.GetDictionaryItemByKeysAndCultures(new List<string> { DictionaryConstants.ORDER_SOURCE },
                                                                                 new List<string> { rootCulture });

                    if (CheckDictionaryItemExistence(items))
                    {
                        var orderSource = items.First().DictionaryInstances.First().Content;
                        bookings.Where(c => c.Channel == null).ToList().ForEach(b => b.Channel = orderSource);
                    }
                }
            }

            // set up summary for all bookings
            var summary = new BookingSummary(bookings, currencySymbol);

            // return object
            return new MobileBookingReport
                       {
                           Bookings = bookings,
                           BookingSummary = summary
                       };
        }
Esempio n. 6
0
 /// <summary>
 /// Get bookings based on request type
 /// </summary>
 /// <param name="bookingRequest">request params</param>
 /// <returns>list of report bookings</returns>
 private List<Model.Reporting.Booking> GetBookingsByRequest(ReportingBookingRequest bookingRequest)
 {
     return reportBookingDao.GetBookingReport(bookingRequest);
 }
Esempio n. 7
0
        /// <summary>
        /// Returns report for sales
        /// </summary>
        /// <param name="propertyId">Property Id</param>
        /// <param name="startDate">Start date</param>
        /// <param name="endDate">End date</param>
        /// <param name="methodName">Calling method</param>
        /// <param name="reportingBookingType">Type of report</param>
        /// <returns>Reporting request</returns>
        private ReportingBookingRequest ValidateAndCreateBookingReportRequest(string propertyId, DateTime startDate, DateTime endDate, string methodName, ReportingBookingTypeEnum reportingBookingType)
        {
            //Set the culture for date/display transformations
            var cultureCode = GetAndSetCulture();

            // property id is string so get it into long:
            var business = CheckAndGetBusiness(propertyId, methodName);

            //set up the reporting request
            var reportingBookingRequest = new ReportingBookingRequest
            {
                BusinessId = business.Id,
                StartDate = startDate,
                EndDate = endDate,
                CultureCode = cultureCode,
                ReportingBookingType = reportingBookingType,
                OfflineSource = OfflineSourceEnum.Mobile
            };

            return reportingBookingRequest;
        }
        public ReportingResultDto GetBookingReports(ReportingBookingRequestDto bookingRequest)
        {
            if (bookingRequest == null)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30077, "PropertyManagementSystemService.GetBookingReports"));    
            }

            CheckAccessRights(bookingRequest.BusinessId);

            // Validate if the business exists
            if (Cache.Business.TryGetValue(bookingRequest.BusinessId) == null)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30001, "PropertyManagementSystemService.GetBookingReports",
                    additionalDescriptionParameters: (new object[] { bookingRequest.BusinessId })));
            }

            var bookingTypeEnum = (ReportingBookingTypeEnum)Enum.Parse(typeof(ReportingBookingTypeEnum), bookingRequest.ReportingBookingType.ToString());


            var request = new ReportingBookingRequest
                          {
                              BusinessId = bookingRequest.BusinessId,
                              EndDate = bookingRequest.EndDate,
                              StartDate = bookingRequest.StartDate,
                              ReportingBookingType = bookingTypeEnum,
                              CultureCode = bookingRequest.CultureCode,
                              OfflineSource = OfflineSourceEnum.Web
                          };

            if (request.IsValid() == false)
            {
                throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30078, "PropertyManagementSystemService.GetBookingReports",
                    additionalDescriptionParameters: (new object[] { bookingRequest.CultureCode, bookingRequest.StartDate, bookingRequest.EndDate})));
            }

            ReportingResult reportingResult = reportingManager.GetBookingReports(request);


            return new ReportingResultDto
                   {
                       ContentType = reportingResult.ContentType,
                       FileContent = reportingResult.FileContent
                   };
        }
Esempio n. 9
0
            public void GetMobileReportsCallsMethodsCorrectlyReturnsOnlyConfirmed()
            {
                // Arrange
                var reportDaoMock = MockRepository.GenerateMock<IReportBookingDao>();
                var dictMock = MockRepository.GenerateMock<IDictionaryManager>();

                var mockBookings = new List<Booking>
                {
                    new Booking
                    {
                        BusinessId = VALID_BUSINESS_ID,
                        CurrencyCode = UK_CURRENCY,
                        CurrencySymbol = UK_CURRENCY_SYMBOL,
                        BookingStatusCode = BookingStatusType.CONFIRMED
                    }
                };

                var mockReportRequest = new ReportingBookingRequest
                {
                    BusinessId = VALID_BUSINESS_ID,
                    CultureCode = UK_CULTURE,
                    StartDate = DateTime.Now.Date,
                    EndDate = DateTime.Now.Date,
                    ReportingBookingType = ReportingBookingTypeEnum.StayDate
                };
                
                reportDaoMock.Expect(rd => rd.GetBookingReport(Arg<ReportingBookingRequest>.Is.Anything)).Return(mockBookings)
                             .Repeat.Once();

                dictMock.Expect(
                    dm => dm.GetRootCultureForGivenCultureCode(Arg<string>.Is.Equal(mockReportRequest.CultureCode)))
                        .Return(ROOT_CULTURE)
                        .Repeat.Once();

                dictMock.Expect(
                    dm =>
                    dm.GetDictionaryItemByKeysAndCultures(
                        Arg<List<string>>.Matches(l => l.Contains(DictionaryConstants.NOT_KNOWN_KEY)),
                        Arg<List<string>>.Matches(lc => lc.Contains(ROOT_CULTURE)))).Return(new List<DictionaryDataItem>
                        {
                            new DictionaryDataItem
                            {
                                DictionaryInstances = new List<DictionaryInstance>
                                {
                                    new DictionaryInstance
                                    {
                                        Content = "translatedText",
                                        CultureCode = ROOT_CULTURE
                                    }
                                }
                            }
                        }).Repeat.Once();

                var reportManager = new ReportingManager
                {
                    DictionaryManager = dictMock,
                    ReportBookingDao = reportDaoMock
                };

                // Act
                var resultReport = reportManager.GetMobileBookingReports(mockReportRequest);

                // Assert
                Assert.IsNotNull(resultReport, "report was returned as null");
                Assert.IsNotNull(resultReport.Bookings, "Bookings were returned as null");
                Assert.AreEqual(1, resultReport.Bookings.Count, "Cancelled bookings were returned with report");
                Assert.IsNotNull(resultReport.BookingSummary, "Booking Summary was returned as null");
                Assert.AreNotEqual(string.Empty, resultReport.Bookings.First().NotKnownText,
                                   "Not known text was not set");

                dictMock.VerifyAllExpectations();
                reportDaoMock.VerifyAllExpectations();
            }  
Esempio n. 10
0
            public void GetByBookingDateWithInvalidParametersReturnEmptyBookingArray()
            {
                // Arrange
                DateTime startDate = DateTime.MaxValue;
                DateTime endDate = DateTime.MaxValue;
                var request = new ReportingBookingRequest
                {
                    BusinessId = BUSINESS_ID,
                    StartDate = startDate,
                    EndDate = endDate,
                    CultureCode = DEFAULT_CULTURE,
                    ReportingBookingType = ReportingBookingTypeEnum.BookingDate
                };

                // Act
                var bookings = reportBookingDao.GetBookingReport(request);

                // Assert
                Assert.IsFalse(bookings.Any());
            }
Esempio n. 11
0
            public void GetByStayDateWithInvalidParametersReturnEmptyBookingArray()
            {
                using (new TestDataHelper(GetTestQuery(TestQuery.PopulateBookingAndPaymentsTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    // Arrange
                    //We are looking for the checkout date '2012/02/10'
                    var startDate = new DateTime(2012, 2, 10);
                    var endDate = new DateTime(2012, 2, 10);
                    var request = new ReportingBookingRequest
                    {
                        BusinessId = BUSINESS_ID,
                        StartDate = startDate,
                        EndDate = endDate,
                        CultureCode = DEFAULT_CULTURE,
                        ReportingBookingType = ReportingBookingTypeEnum.StayDate
                    };

                    // Act
                    var bookings = reportBookingDao.GetBookingReport(request);

                    // Assert
                    Assert.IsFalse(bookings.Any());
                }
            }
Esempio n. 12
0
            public void GetByStayDateWithValidParametersReturnValidBooking()
            {
                using (new TestDataHelper(GetTestQuery(TestQuery.PopulateBookingAndPaymentsTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    // Arrange
                    //We are looking for the checkout date '2012/02/10'
                    //We are looking for the checking date '2012/02/06'
                    var startDate = new DateTime(2012, 2, 1);
                    var endDate = new DateTime(2012, 2, 10);
                    var request = new ReportingBookingRequest
                    {
                        BusinessId = BUSINESS_ID,
                        StartDate = startDate,
                        EndDate = endDate,
                        CultureCode = DEFAULT_CULTURE,
                        ReportingBookingType = ReportingBookingTypeEnum.StayDate
                    };

                    // Act
                    var bookings = reportBookingDao.GetBookingReport(request);

                    // Assert
                    Assert.IsTrue(bookings.Count() == 1);
                    Assert.IsTrue(bookings[0].BusinessId == BUSINESS_ID);
                    Assert.IsTrue(bookings[0].CheckIn <= endDate);
                    Assert.IsTrue(bookings[0].CheckOut >= startDate);
                }
            }
Esempio n. 13
0
            public void GetByCheckOutDateWithInvalidParametersReturnEmptyBookingArray()
            {
                using (new TestDataHelper(GetTestQuery(TestQuery.PopulateBookingAndPaymentsTestData), GetTestQuery(TestQuery.CleanupUnitTestData)))
                {
                    // Arrange
                    var startDate = DateTime.MaxValue;
                    var endDate = DateTime.MaxValue;
                    var request = new ReportingBookingRequest
                    {
                        BusinessId = BUSINESS_ID,
                        StartDate = startDate,
                        EndDate = endDate,
                        CultureCode = DEFAULT_CULTURE,
                        ReportingBookingType = ReportingBookingTypeEnum.CheckOutDate
                    };

                    // Act
                    var bookings = reportBookingDao.GetBookingReport(request);

                    //Assert
                    Assert.IsFalse(bookings.Any());
                }
            }