コード例 #1
0
  /**
   * Populate.
   *
   * @param source the source
   * @param target the target
   * @throws ConversionException the conversion exception
   */
  public void populate(final BasePackage source, final List<PriceBreakDownViewData> target)
      throws ConversionException {

    final PriceBreakDownViewData basicPrice = new PriceBreakDownViewData();
    final PriceBreakDownViewData extrasPrice = new PriceBreakDownViewData();
    final PriceBreakDownViewData onlineDiscount = new PriceBreakDownViewData();
    final PriceBreakDownViewData totalPrice = new PriceBreakDownViewData();

    BigDecimal viewDataBasicPrice = priceCalculationService.calculateBasicCost(source);

    BigDecimal viewDataOnlineDiscountPrice =
        source.getDiscount().getPrice().getAmount().getAmount();
    if (viewDataOnlineDiscountPrice.signum() == -1) {
      viewDataOnlineDiscountPrice = viewDataOnlineDiscountPrice.negate();
    }
    final String defaultCurrencyCode = currencyResolver.getSiteCurrency();
    basicPrice.setDescription(getDescription("BASICHOLIDAY"));
    if (!PackageUtilityService.isMulticomThirdPartyFlight(
            packageComponentService.getFlightItinerary(source))
        && viewDataOnlineDiscountPrice.compareTo(BigDecimal.ZERO) > 0) {
      viewDataBasicPrice =
          viewDataBasicPrice.add(viewDataOnlineDiscountPrice).setScale(TWO, RoundingMode.HALF_UP);
      onlineDiscount.setDescription(getDescription("ONLINEDISCOUNT"));

      onlineDiscount.setPrice(viewDataOnlineDiscountPrice.setScale(TWO, RoundingMode.HALF_UP));
      onlineDiscount.setCurrencyAppendedPrice(
          "-"
              + " "
              + CurrencyUtils.getCurrencySymbol(defaultCurrencyCode)
              + (viewDataOnlineDiscountPrice.setScale(TWO, RoundingMode.HALF_UP)).toString());
      target.add(onlineDiscount);
    }
    basicPrice.setPrice(viewDataBasicPrice.setScale(TWO, RoundingMode.HALF_UP));
    basicPrice.setCurrencyAppendedPrice(
        CurrencyUtils.getCurrencySymbol(defaultCurrencyCode)
            + viewDataBasicPrice.setScale(TWO, RoundingMode.HALF_UP).toString());
    target.add(basicPrice);
    extrasPrice.setDescription(getDescription("OPTION&EXTRAS"));
    extrasPrice.setPrice(priceCalculationService.calculateExtraFacilitiesTotalCost(source));
    extrasPrice.setCurrencyAppendedPrice(
        CurrencyUtils.getCurrencySymbol(defaultCurrencyCode)
            + extrasPrice.getPrice().setScale(TWO, RoundingMode.HALF_UP));

    totalPrice.setDescription(getDescription("TOTALPRICE"));
    totalPrice.setPrice(
        source.getPrice().getAmount().getAmount().setScale(TWO, RoundingMode.HALF_UP));
    totalPrice.setCurrencyAppendedPrice(
        CurrencyUtils.getCurrencySymbol(defaultCurrencyCode)
            + (source.getPrice().getAmount().getAmount().setScale(TWO, RoundingMode.HALF_UP))
                .toString());
    target.add(extrasPrice);

    populateCardChargesIfApplicable(source.getBookingDetails(), target);
    populatePromotionalChargesIfApplicable(source.getPromotionalDiscount(), target);
    target.add(totalPrice);
  }
コード例 #2
0
 /**
  * Populate card charges if applicable.
  *
  * @param bookingDetails the booking details
  * @param target the target
  */
 private void populateCardChargesIfApplicable(
     final BookingDetails bookingDetails, final List<PriceBreakDownViewData> target) {
   if (SyntacticSugar.isNotNull(bookingDetails)
       && CollectionUtils.isNotEmpty(
           bookingDetails.getBookingHistory().get(0).getPaymentReferences())) {
     final PriceBreakDownViewData cardCharges = new PriceBreakDownViewData();
     final BigDecimal cardCharge =
         getTotalCardCharges(bookingDetails.getBookingHistory().get(0).getPaymentReferences());
     cardCharges.setDescription(getDescription("CARD_CHARGES"));
     cardCharges.setPrice(cardCharge);
     cardCharges.setCurrencyAppendedPrice(
         CurrencyUtils.getCurrencySymbol(currencyResolver.getSiteCurrency())
             + cardCharge.setScale(0, RoundingMode.HALF_UP));
     target.add(cardCharges);
   }
 }
コード例 #3
0
 /**
  * Populate promotional charges if applicable.
  *
  * @param promotionalDiscount the promotional discount
  * @param target the target
  */
 private void populatePromotionalChargesIfApplicable(
     final PromotionalDiscount promotionalDiscount, final List<PriceBreakDownViewData> target) {
   if (SyntacticSugar.isNotNull(promotionalDiscount)) {
     final PriceBreakDownViewData promotionalDiscountPrice = new PriceBreakDownViewData();
     final BigDecimal promotionalDis = promotionalDiscount.getPrice().getAmount().getAmount();
     promotionalDiscountPrice.setDescription(getDescription("PROMOTIONAL_DISCOUNT"));
     promotionalDiscountPrice.setPrice(promotionalDis);
     promotionalDiscountPrice.setCurrencyAppendedPrice(
         "-"
             + " "
             + CurrencyUtils.getCurrencySymbol(currencyResolver.getSiteCurrency())
             + promotionalDis
                 .multiply(BigDecimal.valueOf(-1))
                 .setScale(TWO, RoundingMode.HALF_UP));
     target.add(promotionalDiscountPrice);
   }
 }