예제 #1
0
            public void GetBookingEmailRequestSettingsReturnsCorrectForOta()
            {
                bool isOtaBooking;
                bool temp;

                var order = new Order
                                {
                                    IntegrationType = IntegrationTypeEnum.Push,
                                    LeadGuest = new Guest()
                                };

                var emailManager = new EmailManager();

                emailManager.GetBookingEmailRequestSettings(order, out isOtaBooking, out temp, out temp);

                Assert.IsTrue(isOtaBooking, "Order is not an OTA booking");
            }
예제 #2
0
            public void GetBookingEmailRequestSettingsReturnsCorrectForMyWebOrWls()
            {
                bool isMyWebOrWls;
                bool temp;

                var order = new Order
                {
                    IntegrationType = IntegrationTypeEnum.WhiteLabel,
                    LeadGuest = new Guest()
                };

                var emailManager = new EmailManager();

                emailManager.GetBookingEmailRequestSettings(order, out temp, out isMyWebOrWls, out temp);

                Assert.IsTrue(isMyWebOrWls, "Order is not for MyWeb or WLS");
            }
예제 #3
0
            public void TestGetByOrderIdAndReferenceTypeReturnsData()
            {
                // arrange
                var guest = new Guest
                {
                    BusinessId = BUSINESS_ID,
                    DefaultCultureCode = "en-GB",
                    AddressLine1 = "AL1",
                    City = "City",
                    Forename = "Bob",
                    Surname = "Smith"
                };

                guestManager.Create(guest);

                var mockOrder = new Order
                {
                    IntegrationType = IntegrationTypeEnum.Myweb,
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    CustomerCurrencyCode = "GBP",
                    OrderSourceCode = SourceType.Online.GetCode(),
                    LeadGuest = guest,
                    LeadGuestId = guest.Id.Value
                };

                orderDao.CreateOrder(BUSINESS_ID, mockOrder);
                Assert.IsTrue(mockOrder.Id.HasValue, "Test order was not created");

                var mockOrderReference = new OrderReference
                                             {
                                                 OrderId = mockOrder.Id.Value,
                                                 Reference = Guid.NewGuid().ToString(),
                                                 ReferenceTypeCode = ReferenceTypeEnum.EcommerceReservation.GetCode()
                                             };

                orderReferenceDao.Create(mockOrderReference);
                Assert.IsTrue(mockOrder.Id.HasValue, "Test order reference was not created");

                // act
                var resultOrderReference = orderReferenceDao.GetByOrderIdAndReferenceType(mockOrder.Id.Value, ReferenceTypeEnum.EcommerceReservation);

                // assert
                Assert.IsNotNull(resultOrderReference, "Order reference object has not been returned.");
                Assert.AreEqual(mockOrderReference.Id, resultOrderReference.Id, "Order reference ids do not match");
            }
예제 #4
0
            public void CreateOrderEventIsSuccessful()
            {
                // Arrange
                var orderDao = new OrderDao();
                GuestManager guestManager = new GuestManager();
                Guest guest = new Guest
                {
                    BusinessId = BUSINESS_ID,
                    DefaultCultureCode = "en-GB",
                    AddressLine1 = "AL1",
                    City = "City",
                    Forename = "Bob",
                    Surname = "Smith"
                };
                guestManager.Create(guest);

                var mockOrder = new Order
                    {
                        IntegrationType = IntegrationTypeEnum.Myweb,
                        OfflineSourceEnum = OfflineSourceEnum.Web,
                        CustomerCurrencyCode = "GBP",
                        OrderSourceCode = SourceType.Online.GetCode(),
                        LeadGuest = guest,
                        LeadGuestId = guest.Id.Value
                    };
                
                orderDao.CreateOrder(BUSINESS_ID, mockOrder);

                Assert.IsTrue(mockOrder.Id.HasValue);

                var orderEvent = new OrderEvent
                    {
                        OrderId = mockOrder.Id.Value,
                        EventType = new Model.Core.EnumEntity { Code = OrderEventTypeEnum.OrderCreated.GetCode() }
                    };

                // Act
                orderEventDao.Create(orderEvent);

                // Assert
                Assert.IsTrue(orderEvent.Id > 0, "Id was not filled in after create");
            }
예제 #5
0
            public void GetBookingEmailRequestSettingsReturnsCorrectForCustomerRequest()
            {
                bool isCustomerRequested;
                bool temp;

                var order = new Order
                {
                    LeadGuest = new Guest
                                    {
                                        Email = "*****@*****.**",
                                        IsConfirmationEmailToBeSent = true
                                    }
                };

                var emailManager = new EmailManager();

                emailManager.GetBookingEmailRequestSettings(order, out temp, out temp, out isCustomerRequested);

                Assert.IsTrue(isCustomerRequested, "Order has not been requested by the customer");
            }
예제 #6
0
            public void CreateBookingWithSendConfirmationEmailUncheckedDoesNotEmailConfirmation()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var emailManager = new Mock<IEmailManager>();
                var guestManager = new Mock<IGuestManager>();
                var cancellationPoliciesManager = new Mock<ICancellationPoliciesManager>();

                var bookingManager = new BookingManager
                {
                    EmailManager = emailManager.Object,
                    BookingDao = bookingDao.Object,
                    OrderDao = orderDao.Object,
                    GuestManager = guestManager.Object,
                    CancellationPoliciesManager = cancellationPoliciesManager.Object
                };

                var booking = new Booking
                    {
                        BusinessId = 1,
                        OrderId = 1,
                        Guest = new Guest { Id = 23, Surname = "Test Guest", Email = "*****@*****.**", IsConfirmationEmailToBeSent = false },
                        StartDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc),
                        EndDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc),
                        NumberOfAdults = 2,
                        NumberOfChildren = 1,
                        Cost = new decimal(120.5),
                        BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                        RoomTypeId = 1,
                        RoomId = 1,
                        RatePlanId = 1,
                        Notes = "Testing note",
                        BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                        RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE }
                    };

                var order = new Order
                    {
                        OfflineSourceEnum = OfflineSourceEnum.Web,
                        Id = booking.OrderId,
                        OrderSourceCode = SourceType.Online.GetCode(),
                        CustomerCurrencyCode = "GBP"
                    };

                bookingDao.Setup(b => b.Create(booking, order)).Callback(delegate { booking.Id = 1; });
                cancellationPoliciesManager.Setup(cm => cm.GetRatePlanCancellationRule(It.IsAny<CancellationPolicyRequest>(), booking.RatePlanId)).Returns(new CancellationRule());
                
                // Act
                bookingManager.CreateBooking(booking, order);

                // Assert
                bookingDao.VerifyAll();
                orderDao.VerifyAll();
                emailManager.Verify(e => e.SendConfirmationEmails(It.IsAny<Order>()), Times.Never());
            }
예제 #7
0
            public void CancelBookingNotFailedRefundCreatesNoEventLog()
            {
                eventTrackingManager = new Mock<IEventTrackingManager>();
                var userManager = new Mock<IUserManager>();
                bookingManager.EventTrackingManager = eventTrackingManager.Object;

                const int BOOKING_ID = 1;
                const int BUSINESS_ID = 1;
                var bookingToCancel = new Booking
                {
                    Id = BOOKING_ID,
                    OrderId = 5,
                    BusinessId = BUSINESS_ID,
                    BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                    BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                    Guest = new Guest(),
                    RoomId = 1,
                    RoomTypeId = 1,
                    RatePlanId = 1,
                    Cost = new decimal(10),
                    StartDate = DateTime.UtcNow,
                    EndDate = DateTime.UtcNow.AddDays(1),
                    NumberOfAdults = 1,
                    RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE },
                    CancellationDetails = new CancellationDetail() { Notes = "Booking cancelled!", CancellationChargeType = CancellationChargeTypeEnum.Unknown, CancellationType = CancellationTypeEnum.Unknown, DefaultCheckinDateTime = DateTime.UtcNow}
                };
                var order = new Order
                {
                    Id = bookingToCancel.OrderId
                };

                orderManager.Setup(o => o.GetOrderWithBookingsByKey(bookingToCancel.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);
                bookingDao.Setup(c => c.Cancel(bookingToCancel, order, It.IsAny<decimal>())).Returns(true);
                bookingDao.Setup(c => c.GetByKey(It.IsAny<int>(),"")).Returns(bookingToCancel);

                paymentManager.Setup(x => x.GetPaymentsByOrder(It.IsAny<int>(), It.IsAny<long>())).Returns(new List<Model.Booking.Payment>());

                // Act
                int? refundId;
                bool? isRefundSuccessful;
                bool? isRefundAttempted;
                bookingManager.CancelBooking(bookingToCancel, out refundId, out isRefundSuccessful, out isRefundAttempted);
            }
예제 #8
0
파일: PmsMobile.cs 프로젝트: ognjenm/egle
        public CreateBookingResponseDto CreateBooking(long propertyId, SaveMobileBookingDto saveMobileBookingDto)
        {
            Log.LogDebug("CreateBooking" + Environment.NewLine + "propertyId: " + propertyId, saveMobileBookingDto);

            var loggedInBusiness = GetBusinessId();

            CheckAndGetBusiness(propertyId.ToString(CultureInfo.InvariantCulture), GetMethodName());

            if (propertyId != loggedInBusiness)
            {
                throw new AccessDeniedException(ErrorFactory.CreateAndLogError(Errors.SRVEX30000, GetMethodName(),
                                                             additionalDescriptionParameters:
                                                                 new object[] { propertyId, loggedInBusiness },
                                                                 arguments: new object[] { propertyId, loggedInBusiness }));
            }

            var business = businessManager.GetBusiness(loggedInBusiness);

            var booking = CreateBookingFromCreateBookingDto(saveMobileBookingDto, business);

            if (saveMobileBookingDto.Guest.PhoneNumber != null)
            {
                booking.Guest.GuestPhones.Add(new GuestPhone { Number = saveMobileBookingDto.Guest.PhoneNumber, PhoneTypeCode = PhoneTypeEnum.Contact1 });
            }

            var order = new Order
                            {
                                CustomerCurrencyCode = business.WorkingCurrencyCode,
                                IntegrationType = null,
                                OfflineSourceEnum = OfflineSourceEnum.Mobile,
                                OrderSourceCode = SourceType.Pms.GetCode(),
                                CustomerCultureCode = business.DefaultCultureCode,
                                Bookings = new List<Booking>
                                  {
                                      booking
                                  }                                
                            };

            orderManager.CreateOrder(business.Id, order);

            return new CreateBookingResponseDto
            {
                BookingReference = booking.BookingReferenceNumber
            };
        }
예제 #9
0
            public void GetOrderByIdIsSuccessful()
            {
                // Arrange
                const int orderId = 1;
                const string orderChannelName = "channel_name";

                var orderManager = new Mock<IOrderManager>();

                adminService.OrderManager = orderManager.Object;

                var bookings = new List<Booking>
                    {
                        new Booking
                            {
                                Id = 1,
                                OrderId = orderId,
                                BusinessId = 1,
                                BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                                BookingStatus = new EnumEntity {Code = BookingStatusType.CANCELLED},
                                RoomId = 1,
                                RoomTypeId = 1,
                                RatePlanId = 1,
                                Cost = new decimal(210.67),
                                AmountPaid = new decimal(110.67),
                                StartDate = DateTime.Now,
                                EndDate = DateTime.Now.AddDays(2),
                                NumberOfAdults = 2
                            },
                        new Booking
                            {
                                Id = 2,
                                OrderId = orderId,
                                BusinessId = 1,
                                BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                                BookingStatus = new EnumEntity {Code = BookingStatusType.CANCELLED},
                                RoomId = 2,
                                RoomTypeId = 1,
                                RatePlanId = 1,
                                Cost = new decimal(100.30),
                                AmountPaid = 0,
                                StartDate = DateTime.Now,
                                EndDate = DateTime.Now.AddDays(2),
                                NumberOfAdults = 1
                            }
                    };

                var order = new Order
                    {
                        Id = 1,
                        OrderSourceCode = "O",
                        OrderSourceName = "online",
                        OfflineSourceEnum = OfflineSourceEnum.Web,
                        OrderDatetime = new DateTime(2020, 1, 31),
                        CreatedDateTime = new DateTime(2020, 1, 1),
                        IntegrationType = IntegrationTypeEnum.Myweb,
                        TotalValue = new decimal(310.97),
                        AmountPaid = new decimal(110.67),
                        AgentId = 1,
                        Bookings = bookings,
                        ChannelId = 1,
                        Channel = new Channel { Name = orderChannelName },
                        ChannelReference = "channel_ref",
                        FirstBookingId = bookings[0].Id
                    };

                orderManager.Setup(o => o.GetOrderWithBookingsByKey(orderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);

                // Act
                OrderDto orderDto = adminService.GetOrderById(orderId, cultureCode: null);

                // Assert
                Assert.IsNotNull(orderDto, "Order object has not been returned.");
                Assert.IsNotNull(orderDto.Bookings, "Order object has no bookings.");
                Assert.AreEqual(2, orderDto.Bookings.Count, "Order object has the wrong number of bookings.");

                Assert.AreEqual(new decimal(310.97), orderDto.TotalValue, "Order total value is not the expected one.");
                Assert.AreEqual(new decimal(110.67), orderDto.AmountPaid, "Order amount paid is not the expected one.");

                orderManager.VerifyAll();
            }
예제 #10
0
            public void CancelValidBookingIsSuccessful()
            {
                var bookingToCancel = BookingBuilder.SetupSimpleBooking(isTentative:false);

                var order = new Order
                                  {
                                      Id = bookingToCancel.OrderId
                                  };

                orderManager.Setup(o => o.GetOrderWithBookingsByKey(bookingToCancel.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);
                bookingDao.Setup(b => b.GetByKey(bookingToCancel.Id.Value, string.Empty)).Returns(bookingToCancel);
                bookingDao.Setup(c => c.Cancel(bookingToCancel, order, It.IsAny<decimal>())).Returns(true);

                paymentManager.Setup(x => x.GetPaymentsByOrder(It.IsAny<int>(), It.IsAny<long>())).Returns(new List<Model.Booking.Payment>());
                // Act
                int? refundId;
                bool? isRefundSuccessful;
                bool? isRefundAttempted;
                bookingManager.CancelBooking(bookingToCancel, out refundId, out isRefundSuccessful, out isRefundAttempted);
            }
            public void CreateBookingCreatesBooking()
            {
                // Arrange
                const long BUSINESS_ID = 1;

                // Stub the BusinessCache to be used by our service method
                CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID);

                // invalidate the cache so we make sure our business is loaded into the cache
                Cache.Business.Invalidate();

                var bookingDto = new BookingDto
                {
                    BusinessId = BUSINESS_ID,
                    OrderId = 4,
                    Order = new OrderDto
                    {
                        Id = 4,
                        OfflineSourceCode = OfflineSourceEnum.Web.GetCode(),
                        LeadGuest = new GuestDto { BusinessId = BUSINESS_ID, Surname = "Test Guest", Email = "*****@*****.**" }
                    },
                    Guest =
                        new GuestDto
                        {BusinessId = BUSINESS_ID, Surname = "Test Guest", Email = "*****@*****.**"},
                    StartDate = DateTime.Now,
                    EndDate = DateTime.Now.AddDays(1),
                    NumberOfAdults = 2,
                    RoomTypeId = 1,
                    RoomId = 1,
                    RatePlanId = 1,
                    BookingStatusCode = BookingStatusType.TENTATIVE,
                    BookingScenarioType = BookingScenarioTypeEnumDto.OnAccountBooking
                };
                var orderMock = new Order
                {
                    Id = bookingDto.OrderId
                };

                var bookingManager = new Mock<IBookingManager>();
                var orderManager = new Mock<IOrderManager>();

                orderManager.Setup(o => o.GetByKey(It.Is<int>(i => i == bookingDto.OrderId), It.IsAny<string>())).Returns(orderMock);
                bookingManager.Setup(x => x.CreateBooking(It.IsAny<Booking>(), It.Is<Order>(o => o.Id == orderMock.Id)));

                PropertyManagementSystemService.BookingManager = bookingManager.Object;
                PropertyManagementSystemService.OrderManager = orderManager.Object;

                // Act
                PropertyManagementSystemService.CreateBooking(BUSINESS_ID, bookingDto);

                // Assert
                bookingManager.VerifyAll();
                orderManager.VerifyAll();

                // Reassign the Dao on the cache to discard the stub assigned on the StubBusinessCacheSingleBusiness method
                CacheHelper.ReAssignBusinessDaoToBusinessCache();
            }
            public void CreateOrderCreatesOrder()
            {
                // Arrange
                const long BUSINESS_ID = 1;

                // Stub the BusinessCache to be used by our service method
                CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID);

                // invalidate the cache so we make sure our business is loaded into the cache
                Cache.Business.Invalidate();

                var orderDto = new OrderDto
                    {
                        Id = 1,
                        Bookings = new List<BookingDto>()
                    };

                var order = new Order
                    {
                        Id = 1,
                        Bookings = new List<Booking>()
                    };
                
                var orderManager = MockRepository.GenerateMock<IOrderManager>();

                orderManager.Expect(x => x.CreateOrder(Arg<long>.Is.Anything, Arg<Order>.Is.Anything)).Return(true);
                orderManager.Expect(x => x.GetOrderWithBookingsByKey(Arg<int>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<string>.Is.Anything, Arg<GetOrderWithBookingsByEnum>.Is.Equal(GetOrderWithBookingsByEnum.Id))).Return(order);

                PropertyManagementSystemService.OrderManager = orderManager;

                // Act
                PropertyManagementSystemService.CreateOrder(BUSINESS_ID, orderDto);

                // Assert
                orderManager.VerifyAllExpectations();

                // Reassign the Dao on the cache to discard the stub assigned on the StubBusinessCacheSingleBusiness method
                CacheHelper.ReAssignBusinessDaoToBusinessCache();
            }
예제 #13
0
        /// <summary>
        /// Create an order
        /// </summary>
        /// <param name="orderRequest">Order Request Dto</param>
        /// <returns>OrderResponseDto</returns>
        ///<remarks>
        /// Create orders steps :
        ///   -We search availability to find a free rooms
        ///   -We assign these rooms to each bookings
        ///     -if PUSH channel and no availability we assign rooms of the same type anyway
        ///     -if no PUSH channel and no availability we return null meaning no availability
        ///   -We return the order reference
        /// </remarks>
        public OrderResponseDto CreateOrder(OrderRequestDto orderRequest)
        {
            OrderResponseDto responseDto = null;

            // Log request
            Log.LogInfo("CreateOrder request: {0}", null, orderRequest);
            Log.LogInfoAsXml(orderRequest);

            #region Precondition

            var business = businessManager.GetLimitedBusinessByShortname(orderRequest.BusinessShortName);

            if (business == null)
            {
                return null;
            }

            var channel = distributionManager.GetChannelByShortName(orderRequest.ChannelShortName);

            if (channel == null)
            {
                return null;
            }

            #endregion

            orderRequest.ChannelId = channel.Id;

            var roomIdsReserved = new List<int>();
            var searchResults = new Dictionary<BookingRequestDto, AvailabilitySearchResult>();
            var rooms = new Dictionary<BookingRequestDto, List<Room>>();

            bool isAvailable = SearchAvailability(orderRequest, rooms, business, searchResults);

            if (isAvailable == true || orderRequest.AllowOverbooking == true)
            {
                bool isOverBooking = false;
                bool isOverLoaded = false;
                string reasonForOverbooking = null;

                var bookings = AllocateBookings(orderRequest, searchResults, roomIdsReserved, rooms, out isOverBooking, out isOverLoaded, out reasonForOverbooking);

                if ((isOverBooking == false || orderRequest.AllowOverbooking == true) && isOverLoaded == false)
                {
                    if (isOverBooking)
                    {
                        log.LogWarn("There is an overbooking on the order {0} for the business with shortname {1}", orderRequest.ChannelReference, orderRequest.BusinessShortName);
                    }

                    //Abs does not manage the currency well so we default to the business working currency
                    // Also set up order, then call create order first
                    var order = new Order
                                    {
                                        CustomerCurrencyCode = string.IsNullOrWhiteSpace(orderRequest.CurrencyCode) ? business.WorkingCurrencyCode : orderRequest.CurrencyCode,
                                        ChannelId = channel.Id,
                                        Channel = channel,
                                        IntegrationType = channel.IntegrationType,
                                        OrderSourceCode = SourceType.Online.GetCode(),
                                        ChannelReference = orderRequest.ChannelReference,
                                        LeadGuest = Mapper.Map<Guest>(orderRequest.Guest),
                                        Bookings = bookings,
                                        IsIssue = !string.IsNullOrEmpty(reasonForOverbooking),
                                        ReasonForIssue = reasonForOverbooking
                                    };

                    order.LeadGuest.BusinessId = business.Id;

                    var success = orderManager.CreateOrder(business.Id, order);

                    if (success && order.Id.HasValue)
                    {
                        // Return the updated Order with Bookings (make sure to get the full object from database since the OrderReference is only generated in SQL code)
                        responseDto =
                            Mapper.Map<Order, OrderResponseDto>(orderManager.GetOrderWithBookingsByKey(order.Id.Value));
                    }
                }
            }

            Log.LogInfo("CreateOrder response: {0}", null, responseDto);
            Log.LogInfoAsXml(responseDto);

            return responseDto;
        }
예제 #14
0
            public void CancelBookingFailedRefundCreatesEventLog()
            {
                eventTrackingManager.Setup(
                    x => x.CreateOrderEvent(It.IsAny<int>(),
                                            It.IsAny<OrderEventTypeEnum>(), It.IsAny<string>(), It.IsAny<string>()));

                const int BOOKING_ID = 1;
                const int BUSINESS_ID = 1;
                CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID, "TestBus1");
                var bookingToCancel = new Booking
                    {
                        Id = BOOKING_ID,
                        OrderId = 5,
                        BusinessId = BUSINESS_ID,
                        BookingScenarioType = BookingScenarioTypeEnum.DepositFirstNight,
                        BookingStatus = new EnumEntity {Code = BookingStatusType.CONFIRMED},
                        Guest = new Guest(),
                        RoomId = 1,
                        RoomTypeId = 1,
                        RatePlanId = 1,
                        Cost = new decimal(10),
                        StartDate = DateTime.UtcNow,
                        EndDate = DateTime.UtcNow.AddDays(1),
                        NumberOfAdults = 1,
                        RateType = new EnumEntity {Code = RateType.BEST_AVAILABLE_RATE},
                        CancellationDetails = new CancellationDetail
                            {
                                CancellationCharge = 5,
                                CancellationChargeValue = 0,
                                CancellationType = new CancellationType
                                    {
                                        Type = CancellationTypeEnum.FullyRefundable
                                    }
                            }
                    };
                var order = new Order
                {
                    Id = bookingToCancel.OrderId,
                    IntegrationType = IntegrationTypeEnum.Myweb,
                    Bookings = new List<Booking>
                                   {
                                       bookingToCancel
                                   }
                };

                orderManager.Setup(o => o.GetOrderWithBookingsByKey(bookingToCancel.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);
                bookingDao.Setup(b => b.GetByKey(BOOKING_ID, string.Empty)).Returns(bookingToCancel);
                bookingDao.Setup(b => b.Cancel(bookingToCancel, order, It.IsAny<decimal>())).Returns(true);

                paymentManager.Setup(x => x.GetPaymentsByOrder(bookingToCancel.OrderId, BUSINESS_ID)).Returns(new List<Model.Booking.Payment>
                {
                    new Model.Booking.Payment
                    {
                        PaymentSourceEnum = PaymentSourceEnum.Online,
                        PaymentMethodEnum = PaymentMethodEnum.PayPal,
                        Amount = 10
                    }
                });

                // Act
                int? refundId;
                bool? isRefundSuccessful;
                bool? isRefundAttempted;
                bookingManager.CancelBooking(bookingToCancel, out refundId, out isRefundSuccessful, out isRefundAttempted);
                CacheHelper.ReAssignBusinessDaoToBusinessCache();
            }
예제 #15
0
            public void CreateBookingWithInvalidRateTypeThrowsValidationException()
            {
                // Arrange
                var bookingManager = new BookingManager();

                var booking = new Booking
                    {
                        BusinessId = 1,
                        Guest = new Guest {Id = 23, Surname = "Test Guest", Email = "*****@*****.**"},
                        StartDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc),
                        EndDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc),
                        NumberOfAdults = 2,
                        NumberOfChildren = 1,
                        Cost = new decimal(120.5),
                        BookingStatus = new EnumEntity {Code = BookingStatusType.CONFIRMED},
                        RoomTypeId = 1,
                        RoomId = 1,
                        RatePlanId = 1,
                        Notes = "Testing note",
                        RateType = new EnumEntity {Code = "BAD"},
                        BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking
                    };

                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    Id = booking.OrderId,
                    OrderSourceCode = SourceType.Online.GetCode(),
                    CustomerCurrencyCode = "GBP"
                };

                try
                {
                    // Act
                    bookingManager.CreateBooking(booking, order);

                    // Assert
                    Assert.Fail("An exception of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30046", ex.Code, "The Validation exception is not returning the right error code");
                }
            }
예제 #16
0
 private static void CreateBooking(Booking b, Order o)
 {
     b.Id = 10;
 }
예제 #17
0
 private static void SaveOrder(long a, Order order)
 {
     order.Id = 2;
 }
예제 #18
0
            public void RequestCancelExistingBookingIsSuccessful()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var emailManagerMock = new Mock<IEmailManager>();
                var orderDao = new Mock<IOrderDao>();
                
                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao.Object,
                        EmailManager = emailManagerMock.Object,
                        OrderDao = orderDao.Object
                    };

                var requestCancelBooking = new RequestCancelBooking
                    {
                        BookingId = 1,
                        BusinessContactedGuest = true,
                        CancellationRequestAction = CancellationRequestAction.ChargedFullBookingValue,
                        CancellationRequestReason = CancellationReasonEnum.CardDeclined,
                        Notes = "unit test notes"
                    };

                var order = new Order
                    {
                        Id = 1,
                        OrderSourceCode = SourceType.Online.GetCode(),
                        IntegrationType = IntegrationTypeEnum.Push
                    };

                orderDao.Setup(o => o.GetByKey(It.Is<int>(i => i == order.Id), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);
                bookingDao.Setup(c => c.RequestCancelBooking(requestCancelBooking)).Returns(true);
                emailManagerMock.Setup(e => e.SendCancellationRequestEmail(requestCancelBooking, It.IsAny<Booking>(), It.Is<Order>(o => o.Id == order.Id))).Returns(true);
                
                //Act
                bookingManager.RequestCancelBooking(requestCancelBooking, new Booking
                    {
                        Id = 1,
                        OrderId = 1
                    });

                // Assert
                bookingDao.VerifyAll();
                emailManagerMock.VerifyAll();
                orderDao.VerifyAll();
            }
예제 #19
0
            public void CreateBookingInvalidStartEndDateThrowsValidationException()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var bookingManager = new BookingManager { BookingDao = bookingDao.Object };

                var booking = new Booking
                {
                    OrderId = 5,
                    BusinessId = 1,
                    Guest = new Guest { Id = 23, Surname = "Test Guest", Email = "*****@*****.**" },
                    StartDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc),
                    NumberOfAdults = 2,
                    NumberOfChildren = 1,
                    Cost = new decimal(120.5),
                    BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                    RoomTypeId = 1,
                    RoomId = 1,
                    RatePlanId = 1,
                    Notes = "Testing note",
                    BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking
                };

                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    Id = booking.OrderId,
                    OrderSourceCode = SourceType.Online.GetCode(),
                    CustomerCurrencyCode = "GBP"
                };

                bookingManager.BookingDao = bookingDao.Object;

                try
                {
                    // Act
                    bookingManager.CreateBooking(booking, order);

                    // Assert
                    Assert.Fail("An exception SRVEX30002 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30002", ex.Code, "The Validation exception is not returning the right error code");
                    bookingDao.Verify(b => b.Create(booking, order), Times.Never);
                }

                // Make sure this is reset for future tests
                bookingManager.BookingDao = new BookingDao();
            }
예제 #20
0
            public void GetByKeyWithValidBookingIdReturnsValidBooking()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const int ORDER_ID = 1;
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager
                {
                    BookingDao = bookingDao.Object,
                    OrderDao = orderDao.Object
                };
                var bookingReturnedByDao = BookingBuilder.SetupSimpleBooking(isTentative: false);
                var order = new Order { Id = ORDER_ID };

                bookingDao.Setup(b => b.GetByKey(BOOKING_ID, It.IsAny<string>())).Returns(bookingReturnedByDao);
                orderDao.Setup(o => o.GetByKey(bookingReturnedByDao.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);

                // Act
                var bookingReturnedByManager = bookingManager.GetByKey(BOOKING_ID);

                // Assert
                Assert.IsNotNull(bookingReturnedByManager, "Booking is null.");
                Assert.AreEqual(bookingReturnedByDao, bookingReturnedByManager, "Booking returned is not correct.");

                bookingDao.VerifyAll();
                orderDao.VerifyAll();
            }
예제 #21
0
            public void CreatePaymentAndQueueToSettlementCreatesPaymentAndQueueItem(PreAuthPaymentResult result, Order order, bool endResult)
            {
                // Arrange
                var managerMock = new Mock<PaymentManager>();
                var queueManager = new Mock<IQueueManager>();
                managerMock.CallBase = true;
                managerMock.Object.QueueManager = queueManager.Object;

                
                if (endResult)
                {
                    queueManager.Setup(
                        q =>
                        q.AddQueueItem(
                        It.Is<QueueItem>(qi =>
                                            qi.Key == order.Id.Value.ToString() &&
                                            qi.PayloadType == PayloadTypeEnum.BookingInv &&
                                            qi.QueueCode == QueueCodeType.SettlementInvoiceRequest
                            ))).Returns(new QueueItem());
                }

                if (endResult)
                {
                    managerMock.Setup(mm => mm.CreatePaymentForOrder(It.Is<Model.Booking.Payment>(p => 
                        p.OrderId == order.Id &&
                        p.Amount == result.Amount &&
                        p.PaymentMethodEnum == PaymentMethodEnum.CreditCard &&
                        p.PaymentSourceEnum == PaymentSourceEnum.Online &&
                        p.PaymentTypeEnum == PaymentTypeEnum.Payment &&
                        p.ReceivedDate == result.TransactionDate &&
                        p.MerchantType == null &&
                        p.Currency.ISOCode == order.CustomerCurrencyCode &&
                        p.CardLast4Digits == result.LastCardDigits &&
                        p.CardType.Code == CardType.ConvertOgoneCardTypeToEagleCardType(result.CardTypeCode).GetCode()
                        ), It.IsAny<long>()));
                }

                Assert.AreEqual(endResult, managerMock.Object.CreatePaymentAndQueueToSettlement(result, order, string.Empty),
                                "result did not equal expected result");

                managerMock.VerifyAll();
                queueManager.VerifyAll();
            }
예제 #22
0
            public void CreateBookingNoEmailAndSendConfirmationEmailCheckedThrowsValidationException()
            {
                // Arrange
                var bookingManager = new BookingManager { BookingDao = MockRepository.GenerateStub<IBookingDao>() };

                var booking = new Booking
                {
                    BusinessId = 1,
                    OrderId = 1, 
                    Guest = new Guest { Id = 23, Surname = "Test Guest", IsConfirmationEmailToBeSent = true },
                    StartDate = new DateTime(2012, 2, 1, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2012, 2, 2, 0, 0, 0, DateTimeKind.Utc),
                    NumberOfAdults = 2,
                    NumberOfChildren = 1,
                    Cost = new decimal(120.5),
                    BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                    RoomTypeId = 1,
                    RoomId = 1,
                    RatePlanId = 1,
                    Notes = "Testing note",
                    RateType = new EnumEntity { Code = "BAR" },
                    BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking
                };
                
                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    Id = booking.OrderId,
                    OrderSourceCode = SourceType.Online.GetCode(),
                    CustomerCurrencyCode = "GBP"
                };

                try
                {
                    // Act
                    bookingManager.CreateBooking(booking, order);

                    // Assert
                    Assert.Fail("An exception of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30110", ex.Code, "The Validation exception is not returning the right error code");
                }
            }
예제 #23
0
            protected override void RunBeforeAllTests()
            {
                base.RunBeforeAllTests();

                var businessManager = new BusinessManager();
                var roomTypeManager = new RoomTypeManager();
                var roomManager = new RoomManager();
                var orderManager = new OrderManager();


                //Create a business
                var paymentMethod = new BusinessPaymentMethod
                    {
                        BusinessId = BUSINESS_ID,
                        CurrencyCode = CURRENCY,
                        PaymentMethodCode = PaymentMethodEnum.Cash.GetCode()
                    };

                var provider = new Provider
                    {
                        RoomCount = ROOM_COUNT,
                        ContentId = BUSINESS_ID.ToString(),
                        ProviderTypeCode = PROVIDER_TYPE,
                    };

                var business = new Model.Business.Business
                    {
                        BusinessStatusCode = "A",
                        BusinessTypeCode = "P",
                        Name = "Test Business",
                        ShortName = "Test",
                        ReferenceCode = "B001",
                        IsTaxRegistered = true,
                        TaxRegistrationNumber = "12345",
                        BusinessRegistrationNumber = "12345",
                        AddressLine1 = "5 Main Road",
                        AddressLine2 = "Twickenham",
                        City = "London",
                        StateProvinceId = 386,
                        PostCode = "TW2 5SE",
                        CountryId = 16,
                        BusinessTelephoneNumber = "07448752114",
                        TimeZoneId = 36,
                        DefaultCultureCode = CULTURE,
                        WorkingCurrencyCode = CURRENCY,
                        UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"),
                        Provider = provider,
                        BusinessPaymentMethods = new List<BusinessPaymentMethod> {paymentMethod}
                    };

                var businessId = businessManager.CreateBusiness(business);


                // Create a room type
                
                var ratePlan = new BaseRatePlan
                    {
                        BusinessId = businessId,
                        CurrencyCode = CURRENCY,
                        MaxAdults = 2,
                        MaxChildren = 2,
                        MaxOccupancy = 3,
                        BoardBasis = new EnumEntity {Code = "BK"},
                        CancellationClass = new EnumEntity {Code = "FR"},
                        RackRate = new decimal(120.0),
                        SellAtRackRate = true,
                        RatePlanType = new RatePlanType {Type = RatePlanTypeEnum.Base},
                        Rates = new RatePlanRate{BusinessId = businessId, MonRate = 120, MonMinStay = 120},
                        UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"),
                    };

                var roomType = new RoomType
                    {
                        BusinessId = businessId,
                        RoomClass = roomTypeManager.GetRoomClasses(CULTURE).FirstOrDefault(),      //new RoomClass { Code = "DBL" },
                        QualityType = roomTypeManager.GetQualityTypes(CULTURE).FirstOrDefault(),   //new QualityType { Code = "APT" },
                        BathroomType = roomTypeManager.GetBathroomTypes(CULTURE).FirstOrDefault(), //new BathroomType { Code = "SP" },
                        Code = "DBL99",
                        ServiceFrequency = new EnumEntity { Code = "B" },
                        UpdatedByUserId = new Guid("11111111-1111-1111-1111-111111111111"),
                        BaseRatePlan = ratePlan,
                        BaseRatePlanId = ratePlan.Id,
                        Aspect = new Aspect { Code = "BAL"},                    
                    };
                
                roomTypeManager.CreateRoomTypeAndBaseRatePlan(roomType);
                roomType = roomTypeManager.GetRoomTypesAndBaseRatePlans(businessId, CULTURE).First();
                ratePlan = roomType.BaseRatePlan;


                //Create a room
                var roomId = roomManager.CreateRoom("TestRoom", roomType.Id, businessId);


                //Create an order
                var booking = new Booking
                {
                    BusinessId = businessId,
                    Guest = new Guest { DefaultCultureCode = CULTURE, Surname = "TestSurname", BusinessId = businessId },
                    StartDate = new DateTime(2014, 2, 10, 0, 0, 0, DateTimeKind.Utc),
                    EndDate = new DateTime(2014, 2, 12, 0, 0, 0, DateTimeKind.Utc),
                    NumberOfAdults = 2,
                    NumberOfChildren = 1,
                    Cost = new decimal(120.5),
                    BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                    RoomTypeId = roomType.Id,
                    RoomId = roomId,
                    RatePlanId = ratePlan.Id,
                    Notes = "Testing note",
                    BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                    RateType = new EnumEntity { Code = RateType.BEST_AVAILABLE_RATE },
                    CheckinStatus = new EnumEntity { Code = CheckinStatusOptions.NOTCHECKEDIN },
                    IsAvailabilityIgnored = true,
                    BoardBasis = BoardBasisTypeEnum.BreakfastIncluded,
                    CancellationDetails = new CancellationDetail()
                };

                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    OrderSourceCode = SourceType.Pms.GetCode(),
                    CustomerCurrencyCode = CURRENCY,
                    Bookings = new List<Booking> { booking },
                    CustomerCultureCode = "en-GB"
                };
                
                // Mock email manager so it doesn't send emails
                var emailManager = new Mock<IEmailManager>();
                orderManager.EmailManager = emailManager.Object;

                emailManager.Setup(x => x.SendConfirmationEmails(order)).Returns(true);

                orderManager.CreateOrder(businessId, order);
            }
예제 #24
0
            public void ConfirmProvisionalBookingWithoutBookingReferenceNumberThrowsValidationException()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 100011110010000;
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao.Object,
                        OrderDao = orderDao.Object
                    };

                // Provisional booking without BookingReferenceNumber
                var booking = BookingBuilder.SetupSimpleBooking();
                booking.BookingReferenceNumber = null;

                var order = new Order
                {
                    Id = booking.OrderId
                };

                bookingDao.Setup(b => b.GetByKey(BOOKING_ID, It.IsAny<string>())).Returns(booking);
                orderDao.Setup(o => o.GetByKey(booking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);

                try
                {
                    // Act
                    // Call ConfirmProvisionalBooking method on BookingManager
                    bookingManager.ConfirmTentativeBooking(BOOKING_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30030 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30030", ex.Code, "The exception code thrown is not the expected.");
                }
            }
예제 #25
0
            public void CheckInCheckOutValidBookingReturnsUpdatedBooking()
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager { BookingDao = bookingDao.Object, OrderDao = orderDao.Object };

                var booking = BookingBuilder.SetupSimpleBooking();
                
                booking.BookingStatus = new EnumEntity {Code = BookingStatusType.CONFIRMED};
                booking.CheckinStatus = new EnumEntity {Code = CheckinStatusOptions.CHECKEDIN};
                booking.BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking;

                var order = new Order
                {
                    Id = booking.OrderId,
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    OrderSourceCode = SourceType.Pms.GetCode()
                };

                bookingDao.Setup(b => b.GetByKey(booking.Id.Value, string.Empty)).Returns(booking);
                orderDao.Setup(o => o.GetByKey(booking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);

                bookingDao.Setup(b => b.CheckInCheckOutBooking(It.Is<Booking>(book => book == booking), It.Is<EnumEntity>(ee => ee.Code == CheckinStatusOptions.CHECKEDIN), It.IsAny<string>())).Returns(booking);

                // Act
                Booking updatedBooking = bookingManager.CheckInCheckOutBooking(1, 1, CheckinStatusOptions.CHECKEDIN);

                // Assert
                Assert.AreEqual(CheckinStatusOptions.CHECKEDIN, updatedBooking.CheckinStatus.Code, "Check in status of the booking is not updated as expected.");
                bookingDao.VerifyAll();
                orderDao.VerifyAll();
            }
예제 #26
0
            public void ConfirmProvisionalBookingInvalidRatePlanThrowsValidationException()
            {
                // Arrange
                const int BOOKING_ID = 1;
                const long BUSINESS_ID = 100011110010000;
                var bookingDao = new Mock<IBookingDao>();
                var orderDao = new Mock<IOrderDao>();
                var bookingManager = new BookingManager
                    {
                        BookingDao = bookingDao.Object,
                        OrderDao = orderDao.Object
                    };

                // Provisional booking with invalid RatePlan
                var booking = BookingBuilder.SetupSimpleBooking();
                booking.RatePlanId = null;

                var order = new Order
                {
                    Id = booking.OrderId,
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    OrderSourceCode = SourceType.Pms.GetCode()
                };

                bookingDao.Setup(b => b.GetByKey(booking.Id.Value, string.Empty)).Returns(booking);
                orderDao.Setup(o => o.GetByKey(booking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);

                try
                {
                    // Act
                    // Call ConfirmProvisionalBooking method on BookingManager
                    bookingManager.ConfirmTentativeBooking(BOOKING_ID, BUSINESS_ID);

                    // Assert
                    Assert.Fail("An exception SRVEX30008 of type ValidationException should have been thrown");
                }
                catch (ValidationException ex)
                {
                    // Assert
                    Assert.AreEqual("SRVEX30008", ex.Code, "The exception code thrown is not the expected.");

                    orderDao.VerifyAll();
                    bookingDao.VerifyAll();
                }
            }
            public void ModifyGroupReferenceCallsCorrectMethod()
            {
                // Arrange
                const long BUSINESS_ID = 1;
                const int ORDER_ID = 1;
                const string GROUP_REFERENCE = "Test";

                // Stub the BusinessCache to be used by our service method
                CacheHelper.StubBusinessCacheSingleBusiness(BUSINESS_ID);

                // invalidate the cache so we make sure our business is loaded into the cache
                Cache.Business.Invalidate();

                var orderManager = new Mock<IOrderManager>();

                PropertyManagementSystemService.OrderManager = orderManager.Object;

                var order = new Order
                    {
                        Bookings = new List<Booking>
                            {
                                new Booking { BusinessId = BUSINESS_ID }
                            }
                    };

                orderManager.Setup(x => x.GetOrderWithBookingsByKey(ORDER_ID, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);
                orderManager.Setup(x => x.ModifyGroupReference(ORDER_ID, GROUP_REFERENCE));

                // Act
                PropertyManagementSystemService.ModifyGroupReference(BUSINESS_ID, ORDER_ID, GROUP_REFERENCE);

                // Assert
                orderManager.Verify(x => x.ModifyGroupReference(It.Is<int>(c => c.Equals(ORDER_ID)), It.Is<string>(c => c.Equals(GROUP_REFERENCE))), Times.Once);

                // Reassign the Dao on the cache to discard the stub assigned on the StubBusinessCacheSingleBusiness method
                CacheHelper.ReAssignBusinessDaoToBusinessCache();
            }
예제 #28
0
            protected override void RunBeforeAllTests()
            {
                base.RunBeforeAllTests();

                GuestManager guestManager = new GuestManager();
                PaymentManager paymentManager = new PaymentManager();

                Guest guest = new Guest
                {
                    BusinessId = BUSINESS_ID,
                    DefaultCultureCode = "en-GB",
                    AddressLine1 = "AL1",
                    City = "City",
                    Forename = "Bob",
                    Surname = "Smith"
                };
                guestManager.Create(guest);

                var mockOrder = new Order
                {
                    IntegrationType = IntegrationTypeEnum.Myweb,
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    CustomerCurrencyCode = "GBP",
                    OrderSourceCode = SourceType.Online.GetCode(),
                    LeadGuest = guest,
                    LeadGuestId = guest.Id.Value
                };

                orderDao.CreateOrder(BUSINESS_ID, mockOrder);

                // set up payment for the order
                setupPayment = new Model.Booking.Payment
                                   {
                                       OrderId = mockOrder.Id.Value,
                                       PaymentSourceEnum = PaymentSourceEnum.Online,
                                       PaymentTypeEnum = PaymentTypeEnum.Payment,
                                       PaymentMethodEnum = PaymentMethodEnum.AccountTransfer,
                                       Currency = new Currency(mockOrder.CustomerCurrencyCode),
                                       Amount = 30,
                                       Notes = "Test Notes",
                                       PaymentStatusEnum = PaymentStatusEnum.Created,
                                       ReceivedDate = DateTime.Now.AddDays(-5),
                                       MerchantType = MerchantTypeEnum.EviivoAccount
                                   };

                paymentManager.CreatePaymentForOrder(setupPayment, BUSINESS_ID);
            }
예제 #29
0
        /// <summary>
        /// Helpful for testing bunches of bookings, creates a booking for every room / day in the given range
        /// </summary>
        /// <param name="businessId">Business to test</param>
        /// <param name="startDate">start date</param>
        /// <param name="endDate">end date</param>
        /// <param name="cultureCode">for ease of creating guests</param>
        public static void FillDateRangeWithBookings(long businessId, DateTime startDate, DateTime endDate, string cultureCode)
        {
            RoomInformationManager roomManager = new RoomInformationManager();
            Model.Room.RoomInformation roomInfo = roomManager.GetRoomInformationWithRateCache(businessId, startDate, endDate, cultureCode);
            OrderManager orderManager = new OrderManager();

            while (startDate.Date < endDate.Date)
            {
                foreach (Model.Room.RoomType rt in roomInfo.RoomTypes)
                {
                    var ratePlanToUse = rt.BaseRatePlan;
                    foreach (Model.Room.Room r in rt.Rooms)
                    {
                        Booking booking = new Booking
                        {
                            StartDate = startDate,
                            EndDate = startDate.AddDays(1),
                            BookingStatus = new EnumEntity { Code = BookingStatusType.CONFIRMED },
                            RateType = new EnumEntity { Code = RateType.MANUAL },
                            BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking,
                            Cost = 5,
                            Guest = new Guest
                            {
                                Surname = "randomGuest",
                                BusinessId = businessId,
                                DefaultCultureCode = cultureCode,
                                GuestPhones = new List<GuestPhone>
                                    {
                                        new GuestPhone
                                        {
                                            PhoneTypeCode = Model.Common.PhoneTypeEnum.Contact1,
                                            Number = "12345"
                                        }
                                    }
                            },
                            CheckinStatus = new EnumEntity { Code = CheckinStatusOptions.NOTCHECKEDIN },
                            IsAvailabilityIgnored = true,
                            NumberOfAdults = 1,
                            NumberOfChildren = 0,
                            RatePlanId = ratePlanToUse.Id,
                            RoomId = r.Id,
                            RoomTypeId = rt.Id,
                            BusinessId = businessId
                        };

                        Order order = new Order
                        {
                            OfflineSourceEnum = OfflineSourceEnum.Web,
                            OrderSourceCode = SourceType.Pms.GetCode(),
                            CustomerCultureCode = cultureCode,
                            CustomerCurrencyCode = ratePlanToUse.CurrencyCode,
                            GuestMessage = "what",
                            Bookings = new List<Booking>
                                {
                                    booking
                                }
                        };

                        orderManager.CreateOrder(businessId, order);
                    }
                }

                startDate = startDate.AddDays(1);
            }
        }
예제 #30
0
            public void ModifyBookingThatIsUnavailableWithNoRateDefinedStillUpdatedIsSuccessful(UnavailabilityReasonCode validReason)
            {
                // Arrange
                var bookingDao = new Mock<IBookingDao>();
                var availabilityManager = new Mock<IAvailabilityManager>();
                var orderDao = new Mock<IOrderDao>();

                var bookingManager = new BookingManager
                                                    {
                                                        BookingDao = bookingDao.Object,
                                                        AvailabilityManager = availabilityManager.Object,
                                                        OrderDao = orderDao.Object
                                                    };

                var guest = new Guest { Surname = "Smith", Id = 1 };
                bookingDao.Setup(b => b.GetByKey(1, It.IsAny<string>())).Returns(BookingBuilder.SetupSimpleBooking(guest, false));
                // update that changes the start date
                var updatedBooking = BookingBuilder.SetupSimpleBooking(guest, false);
                updatedBooking.StartDate = updatedBooking.StartDate.AddDays(-1);
                var order = new Order
                {
                    OfflineSourceEnum = OfflineSourceEnum.Web,
                    Id = updatedBooking.OrderId,
                    OrderSourceCode = SourceType.Online.GetCode(),
                    CustomerCurrencyCode = "GBP"
                };

                orderDao.Setup(o => o.GetByKey(updatedBooking.OrderId, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<GetOrderWithBookingsByEnum>())).Returns(order);
                
                bookingDao.Setup(x => x.Modify(updatedBooking, It.Is<Order>(o => o.Id == order.Id)));
                
                // mock up that it shows as not available with reason code NoRateDefined
                var mockSearchResult = AvailabilitySearchResultBuilder.GetSimpleAvailabilitySearchResult(1, false, validReason);

                availabilityManager.Setup(am => am.CheckAvailabilityForBookingModify(updatedBooking, order.CustomerCurrencyCode)).Returns(mockSearchResult);

                // ACT
                // Modify booking record, force update
                var modifyResult = bookingManager.ModifyBooking(false, updatedBooking);

                // ASSERT
                Assert.IsNotNull(modifyResult, "Modify was not successful");
                bookingDao.VerifyAll();
                availabilityManager.VerifyAll();
                orderDao.VerifyAll();
            }