コード例 #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);
  }
  /**
   * @param packageModel
   * @return leg
   */
  private Leg getFlightLeg(final BasePackage packageModel) {
    Leg leg = null;
    final Itinerary flightItir = packageComponentService.getFlightItinerary(packageModel);

    if (CollectionUtils.isNotEmpty(flightItir.getInBound())) {
      leg = flightItir.getInBound().get(0);
    } else {
      leg = flightItir.getOutBound().get(0);
    }
    return leg;
  }