/// <summary> /// Map from Eagle's TransactionModel to settlement service transaction model /// </summary> /// <param name="transactionModel"></param> /// <returns></returns> public static SettlementServiceContract.Transaction MapToServiceTransaction(TransactionModel transactionModel) { SettlementService.Transaction transaction = new SettlementServiceContract.Transaction() { Customer = CreateServiceContractCustomer(transactionModel), CurrencyCode = transactionModel.CurrencyCode, MerchantID = transactionModel.MerchantId, MerchantShortname = transactionModel.MerchantShortname, MerchantReferenceCode = transactionModel.MerchantReferenceCode, ServerTransactionID = transactionModel.ServerTransactionId, StartDate = transactionModel.StartDate, EndDate = transactionModel.EndDate, BusinessAccountType = transactionModel.BusinessAccountType, FinancialDetails = CreateFinancialDetails(transactionModel), PartnerOrderNumber = transactionModel.PartnerOrderNumber, BookingReferenceNumber = transactionModel.BookingReferenceNumber, ReservationID = transactionModel.ReservationId, TransactonDate = transactionModel.TransactonDate, ID = transactionModel.Id, MovedStartDate = transactionModel.MovedStartDate, MovedEndDate = transactionModel.MovedEndDate, ScenarioType = MapToSettlementServiceContractScenarioTypes(transactionModel.ScenarioType), ProviderReferenceCode = transactionModel.ProviderReferenceCode, ProviderShortname = transactionModel.ProviderShortname, DistributorShortName = transactionModel.DistributorShortName, SupplyPartnerReferenceCode = transactionModel.SupplyPartnerReferenceCode, DistributorReferenceCode = transactionModel.DistributorReferenceCode, CardType = transactionModel.CardType, PayPalApplied = transactionModel.PayPalApplied, ReservationStatus = MapToSettlementServiceContractReservationStatusTypes(transactionModel.ReservationStatus), ReservedProducts = CreateServiceContractReservedProducts(transactionModel.ReservedProducts), TransactionLineItems = CreateServiceContractTransactionLineItems(transactionModel.TransactionLineItems) }; // only set if it has a date, otherwise empty cancel line will show up in settlement if (transactionModel.CancellationDate.HasValue) { transaction.CancellationDate = transactionModel.CancellationDate.Value; } return transaction; }
public void SetFinancialInfoOnTransactionModelCallsCorrectMethodsWithExpediaIsSuccessful() { // Arrange const decimal ORDER_AMOUNT_PAID = 25M; const decimal GROSS_AMOUNT = 50M; const int ORDER_ID = 5; const int BOOKING_ID = 3; const int BOOKING_ITEM_ONE = 1, BOOKING_ITEM_TWO = 2, BOOKING_ITEM_THREE = 3; const decimal NO_SHOW_ONE = 4, NO_SHOW_TWO = 8; TransactionModel mockTransModel = new TransactionModel {ScenarioType = ScenarioType.OnAccountPrincipalWholesaleRate}; Booking mockBooking = new Booking() { Id = BOOKING_ID, OrderId = ORDER_ID, BookingScenarioType = BookingScenarioTypeEnum.OnAccountBooking }; Model.Business.Business mockBusiness = new Model.Business.Business(); Order mockOrder = new Order() { Id = ORDER_ID, ChannelCommissionType = CommissionTypeEnum.Net, TotalValue = 4, TotalNetValue = 3 }; List<BookingItem> mockBookingItems = new List<BookingItem>() { new BookingItem { Id = BOOKING_ITEM_ONE, BookingId = BOOKING_ID, ItemType = ItemTypeEnum.Breakfast, Charge = new Charge { Amount = 5m } }, new BookingItem { Id = BOOKING_ITEM_THREE, BookingId = BOOKING_ID, ItemType = ItemTypeEnum.DistributorCommission }, new BookingItem { Id = BOOKING_ITEM_TWO, BookingId = BOOKING_ID, ItemType = ItemTypeEnum.EviivoCommission } }; List<BookingConstituent> mockConstituentsOne = new List<BookingConstituent>() { new BookingConstituent { ItemId = BOOKING_ITEM_ONE, ConstituentType = BookingConstituentType.ValueAddedTax, RelevantPercentage = 6 } }; List<BookingConstituent> mockConstituentsTwo = new List<BookingConstituent>() { new BookingConstituent { ItemId = BOOKING_ITEM_TWO, RelevantPercentage = 5 }, new BookingConstituent { ItemId = BOOKING_ITEM_TWO, Amount = NO_SHOW_ONE, ConstituentType = BookingConstituentType.NoShowFee } }; List<BookingConstituent> mockConstituentsThree = new List<BookingConstituent>() { new BookingConstituent { ItemId = BOOKING_ITEM_THREE, RelevantPercentage = 10 }, new BookingConstituent { ItemId = BOOKING_ITEM_THREE, Amount = NO_SHOW_TWO, ConstituentType = BookingConstituentType.NoShowFee } }; IBookingItemDao bookingItemDaoMock = MockRepository.GenerateMock<IBookingItemDao>(); bookingItemDaoMock.Expect(bid => bid.GetConstituentsByItemId(Arg<int>.Is.Equal(BOOKING_ITEM_ONE))) .Return(mockConstituentsOne).Repeat.Once(); bookingItemDaoMock.Expect(bid => bid.GetConstituentsByItemId(Arg<int>.Is.Equal(BOOKING_ITEM_TWO))) .Return(mockConstituentsTwo).Repeat.Once(); bookingItemDaoMock.Expect(bid => bid.GetConstituentsByItemId(Arg<int>.Is.Equal(BOOKING_ITEM_THREE))) .Return(mockConstituentsThree).Repeat.Once(); IOrderDao orderDaoMock = MockRepository.GenerateMock<IOrderDao>(); orderDaoMock.Expect(o => o.GetOrderValueByItemTypes(Arg<int>.Is.Anything, Arg<bool>.Is.Anything, Arg<string>.Is.Anything)).Return(GROSS_AMOUNT); SettlementManager manager = MockRepository.GeneratePartialMock<SettlementManager>(); manager.BookingItemDao = bookingItemDaoMock; manager.OrderDao = orderDaoMock; manager.Expect(m => m.GetRelevantPercentageByItemType(Arg<List<BookingItem>>.Is.Equal(mockBookingItems), Arg<List<BookingConstituent>>.List.ContainsAll(new List<BookingConstituent> { mockConstituentsOne.First(), mockConstituentsThree.First(), mockConstituentsTwo.First() }), Arg<ItemTypeEnum>.Is.Equal( ItemTypeEnum.DistributorCommission))). Return(mockConstituentsThree.First().RelevantPercentage.Value).Repeat.Once(); manager.Expect(m => m.GetRelevantPercentageByItemType(Arg<List<BookingItem>>.Is.Equal(mockBookingItems), Arg<List<BookingConstituent>>.List.ContainsAll(new List<BookingConstituent> { mockConstituentsOne.First(), mockConstituentsThree.First(), mockConstituentsTwo.First() }), Arg<ItemTypeEnum>.Is.Equal( ItemTypeEnum.EviivoCommission))). Return(mockConstituentsTwo.First().RelevantPercentage.Value).Repeat.Once(); manager.Expect( m => m.GetRelevantPercentageByConstituentType( Arg<List<BookingConstituent>>.List.ContainsAll(new List<BookingConstituent> { mockConstituentsOne.First(), mockConstituentsThree.First(), mockConstituentsTwo.First() }), Arg<BookingConstituentType>.Is.Equal(BookingConstituentType.ValueAddedTax))) .Return(mockConstituentsOne.First().RelevantPercentage.Value) .Repeat.Once(); // Act manager.SetFinancialInfoOnTransactionModel(mockTransModel, mockBooking, mockBusiness, mockOrder, mockBookingItems, ORDER_AMOUNT_PAID); // Assert Assert.AreEqual(ORDER_AMOUNT_PAID, mockTransModel.AmountPaid, "Amount paid not set"); Assert.AreEqual(GROSS_AMOUNT, mockTransModel.GrossBookingAmount, "Gross booking amount not set correctly"); Assert.AreEqual(mockOrder.TotalNetValue, mockTransModel.NetBookingAmount, "Net booking amount not set correctly"); Assert.AreEqual(mockConstituentsTwo.First().RelevantPercentage.Value, mockTransModel.EviivoCommissionPercentage, "eviivo percentage not set correctly"); Assert.AreEqual(mockConstituentsThree.First().RelevantPercentage.Value, mockTransModel.DistributorCommissionPercentage, "distributor Commission not set properly"); Assert.AreEqual(NO_SHOW_ONE + NO_SHOW_TWO, mockTransModel.NoShowFeeAmount, "No show fee not summed"); bookingItemDaoMock.VerifyAllExpectations(); manager.VerifyAllExpectations(); }
public void SetPaymentInfoOnTransactionModelWithPaymentIsSuccessful() { // ARRANGE const string SETTLEMENT_ACTION_CODE_PAYMENT = "PAYMENT"; TransactionModel mockModel = new TransactionModel(); var bookingPaymentMock = new Model.Booking.Payment(); Model.Order.Order orderMock = new Order() { IntegrationType = IntegrationTypeEnum.WhiteLabel }; List<SettlementPaymentDto> settlementPaymentsMock = new List<SettlementPaymentDto>() { new SettlementPaymentDto { ActionCode = SETTLEMENT_ACTION_CODE_PAYMENT } }; bool forceProcess = false; const string last4Digits = "0123"; bookingPaymentMock.CardLast4Digits = last4Digits; SettlementManager settlementManager = new SettlementManager(); // Act settlementManager.SetPaymentInfoOnTransactionModel(mockModel, bookingPaymentMock, settlementPaymentsMock, orderMock, forceProcess); // Assert Assert.AreEqual(last4Digits, mockModel.MaskedCardNumber, "Should have been set if settlement payment is present"); }
public void SetPaymentInfoOnTransactionModelWithNoPaymentAndForceProccessIsSuccessful() { // ARRANGE TransactionModel mockModel = new TransactionModel(); var bookingPaymentMock = new Model.Booking.Payment(); List<SettlementPaymentDto> settlementPaymentsMock = new List<SettlementPaymentDto>(); Model.Order.Order orderMock = new Order(); bool forceProcess = true; bookingPaymentMock.CardLast4Digits = "0123"; SettlementManager settlementManager = new SettlementManager(); // Act settlementManager.SetPaymentInfoOnTransactionModel(mockModel, bookingPaymentMock, settlementPaymentsMock, orderMock, forceProcess); // Assert Assert.IsNull(mockModel.MaskedCardNumber, "Should not have been set if settlement payment not present"); }
public void SetPaymentInfoOnTransactionModelWithNoPaymentNotMyWebDoesNotThrowException() { // ARRANGE TransactionModel mockModel = new TransactionModel(); var bookingPaymentMock = new Model.Booking.Payment(); List<SettlementPaymentDto> settlementPaymentsMock = new List<SettlementPaymentDto>(); Model.Order.Order orderMock = new Order() { IntegrationType = IntegrationTypeEnum.RequestResponse }; bookingPaymentMock.CardLast4Digits = "0123"; bool forceProcess = false; SettlementManager settlementManager = new SettlementManager(); // Act settlementManager.SetPaymentInfoOnTransactionModel(mockModel, bookingPaymentMock, settlementPaymentsMock, orderMock, forceProcess); // Assert Assert.IsNull(mockModel.MaskedCardNumber, "Should not have been set if settlement payment not present and not myweb or toprooms"); }
public void SetPaymentInfoOnTransactionModelWithNoPaymentThrowsException() { // ARRANGE TransactionModel mockModel = new TransactionModel(); var bookingPaymentMock = new Model.Booking.Payment(); List<SettlementPaymentDto> settlementPaymentsMock = new List<SettlementPaymentDto>(); Model.Order.Order orderMock = new Order() { IntegrationType = IntegrationTypeEnum.Myweb }; bool forceProcess = false; SettlementManager settlementManager = new SettlementManager(); // Act settlementManager.SetPaymentInfoOnTransactionModel(mockModel, bookingPaymentMock, settlementPaymentsMock, orderMock, forceProcess); // Assert // done in expected exception }
/// <summary> /// Create a settlement TransactionModel for invoice request /// </summary> /// <remarks> /// Will need changes for multi-room booking and also for bookings without channel information /// </remarks> /// <param name="bookingId">bookingId</param> /// <param name="orderId">orderId</param> /// <param name="eventId">event Id that caused this</param> /// <param name="forceProcess">if true will ignore some missing data and process anyway</param> /// <returns>TransactionModel</returns> public TransactionModel CreateTransactionModelForInvoiceRequest(int bookingId, int orderId, int eventId, bool forceProcess) { // Check that there is a booking and order Helper.ArgumentNotDefaultValue<int>(bookingId, "bookingId"); Helper.ArgumentNotDefaultValue<int>(orderId, "orderId"); var transactionModel = new TransactionModel(); // get data from eagle database Model.Order.Order order = orderDao.GetOrderWithBookingsByKey(orderId); Model.Booking.Booking booking = order.Bookings.FirstOrDefault(b => b.Id == bookingId); Model.Business.Business business = businessDao.GetByKey(booking.BusinessId); var orderReference = orderReferenceDao.GetByOrderIdAndReferenceType(orderId, ReferenceTypeEnum.EcommerceReservation); var reservationId = orderReference != null ? orderReference.Reference : Helper.IntToGuid(orderId).ToString(); order.Channel = channelDao.GetById(order.ChannelId.Value); Model.Business.Business channelBusiness = businessDao.GetByKey(order.Channel.DistributorId.Value); var country = countryDao.GetByBusiness(booking.BusinessId); BookingEvent bookingEvent = null; List<BookingEventData> bookingEventData = null; #region booking event fetch if available if (eventId != default(int) && eventId > 0) { bookingEvent = bookingEventDao.GetByKey(eventId); } if (bookingEvent != null) { bookingEventData = bookingEventDataDao.GetAllByEventId(bookingEvent.Id); } #endregion List<Payment> payments = paymentDao.GetPaymentsByOrder(orderId); decimal orderPaidAmount = payments.Where(p => p.PaymentSourceEnum.GetCode() == order.OrderSourceCode && p.PaymentTypeEnum == PaymentTypeEnum.Payment).Sum(pym => pym.Amount); Payment bookingPayment = GetPaymentByTypeAndSource(payments, PaymentTypeEnum.Payment, PaymentSourceEnum.Online); List<BookingItem> bookingItems = bookingItemDao.GetByBooking(bookingId); List<PaymentEvent> paymentEvents = paymentEventDao.GetByPaymentId(bookingPayment.Id); logger.LogInfo("Get data from eagle database completed in CreateTransactionModelForInvoiceRequest "); // get payment data from payment service var paymentRequest = new SettlementPaymentModel.PaymentRequest() { OrderReferenceCode = order.OrderReference, BookingReferenceCode = booking.BookingReferenceNumber, IsoCountryCode = country.IsoChar2Code }; List<SettlementPaymentDto> settlementPaymentDtos = GetSettlementPayment(paymentRequest); logger.LogInfo("Get payment data from payment service completed in CreateTransactionModelForInvoiceRequest"); // set retrieved data on settlement TransactionModel SetLineItemsOnTransactionModel(transactionModel, settlementPaymentDtos, order, payments, paymentEvents); SetGuestInfoOnTransactionModel(transactionModel, order); SetBookingInfoOnTransactionModel(transactionModel, booking, order, bookingEvent, bookingEventData, business, settlementPaymentDtos, reservationId); SetFinancialInfoOnTransactionModel(transactionModel, booking, business, order, bookingItems, orderPaidAmount); settlementHelper.SetMerchantInfoOnTransactionModel(transactionModel, booking, business, channelBusiness, settlementPaymentDtos); SetPaymentInfoOnTransactionModel(transactionModel, bookingPayment, settlementPaymentDtos, order, forceProcess); SetProviderDistributorInformationOnTransactionModel(transactionModel, business, channelBusiness, order.Channel); SetReservedProductOnTransactionModel(transactionModel, booking, order, reservationId); return transactionModel; }
/// <summary> /// Create settlement service contract customer from eagle business transaction model /// </summary> /// <returns>SettlementServiceContract.Customer</returns> private static SettlementServiceContract.Customer CreateServiceContractCustomer( TransactionModel transactionModel) { return new SettlementServiceContract.Customer() { CustomerID = transactionModel.CustomerID, FirstName = transactionModel.CustomerFirstName, LastName = transactionModel.CustomerLastName, Email = transactionModel.CustomerEmail, }; }
/// <summary> /// Set payment on settlement TransactionModel /// </summary> /// <param name="transactionModel">TransactionModel</param> /// <param name="bookingPayment">Payment</param> /// <param name="settlementPayments">Collection of SettlementPaymentDto </param> /// <param name="forceProcess">if true will ignore a lack of settlement payment</param> /// <param name="order">order for this transaction</param> public virtual void SetPaymentInfoOnTransactionModel(TransactionModel transactionModel, Payment bookingPayment, List<SettlementPaymentDto> settlementPayments, Model.Order.Order order, bool forceProcess) { Helper.ArgumentNotNull(transactionModel, "transactionModel"); Helper.ArgumentNotNull(order, "order"); SettlementPaymentDto settlementPayment = null; if (settlementPayments != null && settlementPayments.Any()) { settlementPayment = settlementPayments.Find(p => p.ActionCode == SETTLEMENT_ACTION_CODE_PAYMENT); // both payment information from Payment Service and booking must be available if (bookingPayment != null && settlementPayment != null) { transactionModel.ServerTransactionId = settlementPayment.PaymentGatewayTransactionId; transactionModel.CurrencyCode = bookingPayment.Currency != null ? bookingPayment.Currency.ISOCode : string.Empty; transactionModel.MaskedCardNumber = bookingPayment.CardLast4Digits; transactionModel.CardType = bookingPayment.CardType != null ? bookingPayment.CardType.Name : null; transactionModel.PayPalApplied = settlementPayment.PayPalApplied; transactionModel.VoucherDiscountCode = settlementPayment.VoucherDiscountCode; } } // logging / exceptions if (settlementPayment == null || bookingPayment == null) { // to help with logging when payment isn't present for some reason if (bookingPayment == null) { logger.LogInfo("Eagle booking payment was not present for this transaction for booking {0}.", null, transactionModel.BookingReferenceNumber); } if (settlementPayment == null) { logger.LogInfo("Payment Service did not have payment for this transaction for booking {0}.", null, transactionModel.BookingReferenceNumber); if (!forceProcess && order.IntegrationType != null && (order.IntegrationType == IntegrationTypeEnum.Myweb || order.IntegrationType == IntegrationTypeEnum.WhiteLabel)) // if we aren't force processing throw exception so it will be retried { throw new ValidationException(ErrorFactory.CreateAndLogError(Errors.SRVEX30113, "SettlementManager.SetPaymentInfoOnTransactionModel")); } } } logger.LogInfo("SetPaymentInfoOnTransactionModel completed"); }
/// <summary> /// Set booking information on settlement TransactionModel /// </summary> /// <remarks> /// This will need looking into again when orders with multiple bookings gets done /// </remarks> /// <param name="transactionModel">TransactionModel</param> /// <param name="booking">Booking</param> /// <param name="order">Order</param> /// <param name="bookingEvent">booking event for this transaction</param> /// <param name="bookingEventData">booking event data from related event</param> /// <param name="business">Model.Business.Business</param> /// <param name="settlementPaymentDtos">Collection of SettlementPaymentDto</param> /// <param name="reservationId">Reservation Id</param> public virtual void SetBookingInfoOnTransactionModel(TransactionModel transactionModel, Model.Booking.Booking booking, Model.Order.Order order, BookingEvent bookingEvent, List<BookingEventData> bookingEventData, Model.Business.Business business, List<SettlementPaymentDto> settlementPaymentDtos, string reservationId) { Helper.ArgumentNotNull(transactionModel, "transactionModel"); Helper.ArgumentNotNull(booking, "booking"); Helper.ArgumentNotNull(order, "order"); Helper.ArgumentNotNull(order.Channel, "channel"); Helper.ArgumentNotNull(reservationId, "reservationId"); SetTransactionModelStartEndDateFromBookingEvent(transactionModel, booking, bookingEvent, bookingEventData); transactionModel.PartnerOrderNumber = order.ChannelReference; transactionModel.BookingReferenceNumber = order.OrderReference.RemoveAllSpacesAndNonAlphaNumerics(); transactionModel.ReservationId = reservationId; transactionModel.TransactonDate = order.OrderDatetime.GetValueOrDefault(); transactionModel.Id = order.Id.HasValue ? Helper.IntToGuid(order.Id.Value) : default(Guid); transactionModel.CancellationDate = GetTransactionCancellationDate(bookingEvent); transactionModel.ScenarioType = GetTransactionScenarioType(booking, order, settlementPaymentDtos); transactionModel.CurrencyCode = order.CustomerCurrencyCode; transactionModel.CancelledAmount = order.TotalValue.HasValue && transactionModel.CancellationDate.HasValue ? order.TotalValue.Value : default(decimal); transactionModel.ReservationStatus = MapToSettlementTransactionReservationStatusTypes(booking.BookingStatus); logger.LogInfo("SetBookingInfoOnTransactionModel completed"); }
/// <summary> /// Set financial information on settlement Transaction Model /// </summary> /// <param name="transactionModel">TransactionModel</param> /// <param name="booking">Booking</param> /// <param name="business">Business</param> /// <param name="order">Order</param> /// <param name="bookingItems">Collection of BookingItem</param> /// <param name="orderAmountPaid">total of order payments with matching source</param> public virtual void SetFinancialInfoOnTransactionModel(TransactionModel transactionModel, Model.Booking.Booking booking, Model.Business.Business business, Model.Order.Order order, List<BookingItem> bookingItems, decimal orderAmountPaid) { Helper.ArgumentNotNull(transactionModel, "transactionModel"); Helper.ArgumentNotNull(booking, "booking"); Helper.ArgumentNotNull(business, "business"); Helper.ArgumentNotNull(order, "order"); // get all the constituents, currently by sent in booking items List<BookingConstituent> bookingConstituents = new List<BookingConstituent>(); bookingItems.ForEach(bi => bookingConstituents.AddRange(bookingItemDao.GetConstituentsByItemId(bi.Id))); transactionModel.DistributorCommissionPercentage = GetRelevantPercentageByItemType(bookingItems, bookingConstituents, ItemTypeEnum.DistributorCommission); transactionModel.EviivoCommissionPercentage = GetRelevantPercentageByItemType(bookingItems, bookingConstituents, ItemTypeEnum.EviivoCommission); transactionModel.EviivoCommissionPercentageSupplement = 0; transactionModel.TransactionTimeTaxRate = GetRelevantPercentageByConstituentType(bookingConstituents, BookingConstituentType .ValueAddedTax); transactionModel.SupplyPartnerCommissionPercentageSupplement = 0; transactionModel.SupplyPartnerCommissionPercentage = 0; transactionModel.LicenseeCommissionPercentage = 0; transactionModel.LicenseeCommissionPercentageSupplement = 0; transactionModel.PaymentProcessingFee = 0; transactionModel.MerchantAcquirerFee = 0; transactionModel.TaxRegistered = business.IsTaxRegistered; transactionModel.CurrentTaxRate = 0; transactionModel.AmountPaid = orderAmountPaid; transactionModel.GrossBookingAmount = GetGrossAmount(order.Id); transactionModel.NetBookingAmount = CalculateNetBookingAmount(transactionModel, order.TotalNetValue); transactionModel.AgentPayment = GetAgentPaymentAmount(booking.BookingScenarioType, transactionModel.GrossBookingAmount, transactionModel.DistributorCommissionPercentage); transactionModel.TotalExpenses = GetOrderTotalExpenses(order.Id); transactionModel.RefundedAmount = -order.AmountRefunded; //Settlement expects refunded amounts to be positive. Eagle stores as negative // May need looking at again after multi-room bookings / orders are working in EAGLE decimal noShowFee = default(decimal); if (bookingConstituents.Any(bc => bc.ConstituentType == BookingConstituentType.NoShowFee)) { noShowFee = bookingConstituents.Where(bc => bc.ConstituentType == BookingConstituentType.NoShowFee) .Sum(bc => bc.Amount); } transactionModel.NoShowFeeAmount = noShowFee; if (booking.BookingStatus.Code == BookingStatusType.CANCELLED) { transactionModel.CancellationCharge = bookingManager.GetCancellationCharges(new List<string> {order.OrderReference}) .DefaultIfEmpty(new CancellationCharge { Amount = default(decimal) }) .Sum(c => c.Amount); } logger.LogInfo("SetFinancialInfoOnTransactionModel completed"); }
/// <summary> /// Set Customer information on settlement TransactionModel /// </summary> /// <param name="transactionModel">TransactionModel</param> /// <param name="order">Order</param> public virtual void SetGuestInfoOnTransactionModel(TransactionModel transactionModel, Model.Order.Order order) { Helper.ArgumentNotNull(transactionModel, "transactionModel"); if (order.LeadGuest != null) { var guest = order.LeadGuest; transactionModel.CustomerEmail = guest.Email; transactionModel.CustomerFirstName = guest.Forename; transactionModel.CustomerLastName = guest.Surname; transactionModel.CustomerID = guest.Id.HasValue ? Helper.IntToGuid(guest.Id.Value).ToString() : string.Empty; } logger.LogInfo("SetGuestInfoOnTransactionModel completed"); }
/// <summary> /// Set TransactionLineItem on settlement TransactionModel /// </summary> /// <param name="transactionModel">TransactionModel</param> /// <param name="payments">Collection of SettlementPaymentModel.Payment</param> /// <param name="bookingPayments">booking payments</param> /// <param name="paymentEvents">Collection of PaymentEvents</param> /// <param name="order">order for transaction</param> public virtual void SetLineItemsOnTransactionModel(TransactionModel transactionModel, List<SettlementPaymentDto> payments, Model.Order.Order order, List<Payment> bookingPayments, List<PaymentEvent> paymentEvents) { Helper.ArgumentNotNull(transactionModel, "transactionModel"); Helper.ArgumentNotNull(order, "order"); // if there are no payment information, TransactionLineItem cannot be set if (payments == null || bookingPayments == null) { return; } var transactionItems = new List<TransactionLineItem>(); // This still doesn't handle multiple online payments, which will need to be resolved in future Payment bookingPayment = GetPaymentByTypeAndSource(bookingPayments, PaymentTypeEnum.Payment, PaymentSourceEnum.Online); Payment bookingRefund = GetPaymentByTypeAndSource(bookingPayments, PaymentTypeEnum.Refund, PaymentSourceEnum.Online); foreach (var settlementPayment in payments) { Payment payment; switch (settlementPayment.ActionCode) { case SETTLEMENT_ACTION_CODE_REFUND: { payment = bookingRefund; break; } case SETTLEMENT_ACTION_CODE_PAYMENT: default: { payment = bookingPayment; break; } } // only add if there is a matching payment type between settlement payment from Payment Service and the booking payment from Eagle if (payment != null) { transactionItems.Add(CreateTransactionLineItem(settlementPayment, order, payment, paymentEvents)); } } transactionModel.TransactionLineItems = new List<TransactionLineItem>(transactionItems); logger.LogInfo("SetLineItemsOnTransactionModel completed"); }
/// <summary> /// Set ReservedProduct information on settlement TransactionModel /// </summary> /// <param name="transactionModel">TransactionModel</param> /// <param name="booking">booking</param> /// <param name="order">Order</param> /// <param name="reservationId">Reservation Id</param> public virtual void SetReservedProductOnTransactionModel(TransactionModel transactionModel, Model.Booking.Booking booking, Model.Order.Order order, string reservationId) { Helper.ArgumentNotNull(transactionModel, "transactionModel"); Helper.ArgumentNotNull(booking, "booking"); Helper.ArgumentNotNull(order, "order"); Helper.ArgumentNotNull(reservationId, "reservationId"); // Might need changing when orders with multiple bookings start to happen List<ReservedProduct> reservedProducts = order.Bookings.Select(bking => CreateTransactionReservedProduct(bking, order, reservationId)).ToList(); transactionModel.ReservedProducts = reservedProducts; }
/// <summary> /// Send invoice request to settlement service /// </summary> /// <param name="transactionModel">TransactionModel</param> /// <returns>true if request succeeds</returns> public bool SendStoreInvoiceRequest(TransactionModel transactionModel) { return serviceProxy.StoreTransaction(transactionModel); }
/// <summary> /// Set provider and distributor information on settlement TransactionModel /// </summary> /// <param name="transactionModel">TransactionModel</param> /// <param name="business">Business</param> /// <param name="distributorBusiness">Distributor business</param> /// <param name="channel">Channel</param> public virtual void SetProviderDistributorInformationOnTransactionModel(TransactionModel transactionModel, Model.Business.Business business, Model.Business.Business distributorBusiness, Channel channel) { Helper.ArgumentNotNull(transactionModel, "transactionModel"); Helper.ArgumentNotNull(business, "business"); Helper.ArgumentNotNull(distributorBusiness, "distributorBusiness"); Helper.ArgumentNotNull(channel, "channel"); transactionModel.ProviderReferenceCode = business.ReferenceCode; transactionModel.ProviderShortname = business.ShortName; transactionModel.SupplyPartnerReferenceCode = 0.ToString(CultureInfo.InvariantCulture); transactionModel.DistributorShortName = channel.ShortName; transactionModel.DistributorReferenceCode = distributorBusiness.ReferenceCode; transactionModel.BusinessAccountType = distributorBusiness.BusinessType.ToString(); logger.LogInfo("SetProviderDistributorInformationOnTransactionModel completed"); }
/// <summary> /// Set transaction info based upon the events and booking /// </summary> /// <param name="transactionModel">what will be sent to settlement</param> /// <param name="booking">updated / inserted booking</param> /// <param name="bookingEvent">booking event for this booking</param> /// <param name="bookingEventData">list of booking event data from the related booking event</param> private void SetTransactionModelStartEndDateFromBookingEvent(TransactionModel transactionModel, Model.Booking.Booking booking, BookingEvent bookingEvent, List<BookingEventData> bookingEventData) { Helper.ArgumentNotNull(transactionModel, "transactionModel"); DateTime oldStartDate = booking.StartDate; DateTime newStartDate = booking.StartDate; DateTime oldEndDate = booking.EndDate; DateTime newEndDate = booking.EndDate; // Only need to grab event data if it is modify event if (bookingEvent != null && bookingEvent.EventType != null && bookingEvent.EventType.Code == BookingEventType.Modified.GetCode()) { // fill in here the old / new start / end date BookingEventData startDateData = GetRecordFromColumnName(bookingEventData, BookingMapper.PublicParameters.StartDate.ToString()); BookingEventData endDateData = GetRecordFromColumnName(bookingEventData, BookingMapper.PublicParameters.EndDate.ToString()); DateTime tempDateTime; if (startDateData != null) { // start date changed if (DateTime.TryParse(startDateData.OldValue, out tempDateTime)) { oldStartDate = tempDateTime; } if (DateTime.TryParse(startDateData.NewValue, out tempDateTime)) { newStartDate = tempDateTime; } } else { oldStartDate = booking.StartDate; newStartDate = booking.StartDate; } if (endDateData != null) { // end date changed if (DateTime.TryParse(endDateData.OldValue, out tempDateTime)) { oldEndDate = tempDateTime; } if (DateTime.TryParse(endDateData.NewValue, out tempDateTime)) { newEndDate = tempDateTime; } } else { oldEndDate = booking.EndDate; newEndDate = booking.EndDate; } } transactionModel.StartDate = oldStartDate; transactionModel.MovedStartDate = newStartDate; transactionModel.EndDate = oldEndDate; transactionModel.MovedEndDate = newEndDate; }
/// <summary> /// Create settlement service contract FinancialDetail from eagle business transaction model /// </summary> /// <param name="transactionModel"></param> /// <returns></returns> private static SettlementServiceContract.FinancialDetails CreateFinancialDetails( TransactionModel transactionModel) { return new SettlementServiceContract.FinancialDetails() { AgentPayment = transactionModel.AgentPayment, AmountPaid = transactionModel.AmountPaid, CancelledAmount = transactionModel.CancelledAmount, CurrentTaxRate = transactionModel.CurrentTaxRate, DistributorCommissionPercentage = transactionModel.DistributorCommissionPercentage, EviivoCommissionPercentage = transactionModel.EviivoCommissionPercentage, EviivoCommissionPercentageSupplement = transactionModel.EviivoCommissionPercentageSupplement, GrossBookingAmount = transactionModel.GrossBookingAmount, NetBookingAmount = transactionModel.NetBookingAmount, LicenseeCommissionPercentage = transactionModel.LicenseeCommissionPercentage, LicenseeCommissionPercentageSupplement = transactionModel.LicenseeCommissionPercentageSupplement, MerchantAcquirerFee = transactionModel.MerchantAcquirerFee, NoShowFeeAmount = transactionModel.NoShowFeeAmount, RefundedAmount = transactionModel.RefundedAmount, SupplyPartnerCommissionPercentage = transactionModel.SupplyPartnerCommissionPercentage, SupplyPartnerCommissionPercentageSupplement = transactionModel.SupplyPartnerCommissionPercentageSupplement, TaxRegistered = transactionModel.TaxRegistered, TotalExpenses = transactionModel.TotalExpenses, TotalVoucherDiscountAmount = transactionModel.TotalVoucherDiscountAmount, TransactionTimeTaxRate = transactionModel.TransactionTimeTaxRate, CancellationCharge = transactionModel.CancellationCharge }; }
/// <summary> /// Calculate the NetBookingAmount to replicate to Settlement /// </summary> /// <remarks> /// If the booking scenario is OnAccount and the TotalNetValue is greater than 0 and less than TotalBookingValue, /// set the new NetBookingValue field to the TotalNetValue (i.e. this should only effectively be populated for Expedia prepay bookings) /// </remarks> /// <param name="transactionModel"></param> /// <param name="totalNetValue"></param> /// <returns></returns> private static decimal? CalculateNetBookingAmount(TransactionModel transactionModel, decimal totalNetValue) { return transactionModel.ScenarioType == ScenarioType.OnAccountPrincipalWholesaleRate && totalNetValue > 0 && totalNetValue < transactionModel.GrossBookingAmount ? totalNetValue : (decimal?)null; }