private void Charges(double diffPrice, ActualPriceObject newPrice, double actualPrice) { string description = string.Format("Update Check-In Date {0} - {1} - {2} - {3:MMM dd, yyyy}", ProductTypeTrackString, PublicProduct.ProductName, PublicHotel.HotelName, DateTime.UtcNow.ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId)); StripeCharge stripeCharge = CreateCharges(diffPrice, PublicCustomerInfos.StripeCustomerId, description); var chargeInvoice = new Invoices { BookingId = PublicBooking.BookingId, PassStatus = PublicBooking.PassStatus, StripeChargeId = stripeCharge.Id, ChargeAmount = diffPrice, CreatedDate = DateTime.UtcNow, CreatedBy = PublicCustomerInfos.CustomerId, InvoiceStatus = (int)Enums.InvoiceStatus.Charge, HotelPrice = actualPrice, MerchantPrice = newPrice.Price, Quantity = PublicBooking.Quantity, RefundAmount = 0, StripeRefundId = string.Empty, StripeRefundStatus = string.Empty, TotalPrice = PublicBooking.TotalPrice + diffPrice }; _bookingRepository.AddInvoices(chargeInvoice, string.Empty); }
private double GetActualPrice(ActualPriceObject newPrice) { var discounts = (from dp in _bookingRepository.DiscountBookingList join d in _bookingRepository.DiscountList on dp.DiscountId equals d.Id where dp.ProductId == PublicProduct.ProductId && dp.BookingId == PublicBooking.BookingId select d).FirstOrDefault(); double actualPrice = newPrice.Price; if (discounts != null) { return(Helper.CalculateDiscount(discounts, actualPrice, PublicBooking.Quantity)); } return(actualPrice); }
private void BindPrice(ActualPriceObject price = null, DateTime?selectedCheckInDate = null) { double actualPrice = PublicProduct.LowestPrice; double msrpPrice = PublicProduct.LowestPrice; double discountPrice = PublicProduct.LowestUpgradeDiscount; if (price != null) { actualPrice = price.Price; msrpPrice = price.Price; discountPrice = price.DiscountPrice; } RegularPrice = msrpPrice; var maxGuest = (PublicProduct.MaxGuest <= 0 ? Constant.DefaultMaxGuest : PublicProduct.MaxGuest); bool isShowMsrp = false; // Upgrade ? if (Session[Constant.UpgradeKey] != null) { int bookingTempId = int.Parse(Session[Constant.UpgradeKey].ToString()); var bookingsTemps = _productRepository.GetBookingsTempById(bookingTempId).Item1; actualPrice = actualPrice - discountPrice - bookingsTemps.HotelPrice; if (actualPrice <= 0) { actualPrice = 0; } msrp.Visible = true; msrp2.Visible = true; isShowMsrp = true; AnchorButton.InnerText = "Upgrade Now"; } else { var discounts = _productRepository.GetAutoPromosByProductId(PublicProduct.ProductId, selectedCheckInDate).FirstOrDefault(); if (discounts != null) { if (PublicCustomerInfos != null) { discounts = _discountRepository.VerifyDiscounts(discounts, PublicCustomerInfos.CustomerId); } if (discounts != null) { actualPrice = Helper.CalculateDiscount(discounts, actualPrice, 1); if (!actualPrice.Equals(msrpPrice)) { msrp.Visible = true; msrp2.Visible = true; isShowMsrp = true; } } } } int index = 0; if (PublicDiscounts != null && !IsHaveBookingWithSelectedDate && TotalActiveBookingWithSubscription < AppConfiguration.MaxReserveSubscriptionPass && _selectedCheckInDate.Date <= DateTime.UtcNow.AddHours(AppConfiguration.ReserveSubscriptionPassInHours).ToLosAngerlesTimeWithTimeZone(PublicHotel.TimeZoneId).Date&& PublicProduct.ProductType == (int)Enums.ProductType.DayPass && TotalBookingInCurrentRecycle < PublicDiscounts.MaxPurchases) { index = 1; if (!RegularPrice.Equals(actualPrice)) { msrp.Visible = true; msrp2.Visible = true; isShowMsrp = true; } } if (isShowMsrp) { priceMobile.Attributes["class"] += " has-promo"; priceDesktop.Attributes["class"] += " has-promo"; DiscountPrice = actualPrice; PerGuestLitMobile.Text = string.Format("<span class=\"price\">{0}</span><span class=\"upto-guest\">{1}</span>", Helper.FormatPrice(actualPrice * (TotalTickets - index)), Helper.GetStringMaxGuest(maxGuest * TotalTickets)); PerGuestLit2.Text = string.Format("<div>{0} <span>per guest</span></div>", Helper.FormatPrice(actualPrice / maxGuest)); TotalLit.Text = string.Format("<div class=\"total-price\">{0} <span>{1}</span></div>", Helper.FormatPrice(actualPrice * (TotalTickets - index)), Helper.GetStringMaxGuest(maxGuest * TotalTickets)); PerGuestMsrpLitMobile.Text = string.Format("was <i>{0}</i>", Helper.FormatPrice(msrpPrice * TotalTickets)); PerGuestMsrpLit2.Text = string.Format("was <i>{0}</i>", Helper.FormatPrice(msrpPrice / maxGuest)); } else { PerGuestLitMobile.Text = string.Format("<span class=\"price\">{0}</span><span class=\"upto-guest\">{1}</span>", Helper.FormatPrice(actualPrice * (TotalTickets - index)), Helper.GetStringMaxGuest(maxGuest * TotalTickets)); PerGuestLit2.Text = string.Format("<div>{0} <span>per guest</span></div>", Helper.FormatPrice(actualPrice / maxGuest)); TotalLit.Text = string.Format("<div class=\"total-price\">{0} <span>{1}</span></div>", Helper.FormatPrice(actualPrice * (TotalTickets - index)), Helper.GetStringMaxGuest(maxGuest * TotalTickets)); PerGuestMsrpLit2.Text = "per guest"; } GuestLit.Text = string.Format("{0} Guests", maxGuest * TotalTickets == 1 ? "" : (maxGuest * TotalTickets).ToString()); if (selectedCheckInDate.HasValue) { _searchParams.StartDate = selectedCheckInDate.Value; PublicProduct = PublicProduct = _productRepository.GetById(_productId, _searchParams); LvRelatedProductsRepeater.DataSource = PublicProduct.RelatedProducts; LvRelatedProductsRepeater.DataBind(); SimilarProductLv.DataSource = PublicProduct.Similarproduct; SimilarProductLv.DataBind(); } }