@Before
  public void setup() {
    insuranceCart2QuoteListingPopulator = new InsuranceCart2QuoteListingPopulator();
    MockitoAnnotations.initMocks(this);

    quoteListingData = new InsuranceQuoteListingData();
    cartData = new CartData();
    final PriceData priceData = new PriceData();
    priceData.setFormattedValue(testFormattedValue);
    cartData.setTotalPrice(priceData);
    cartData.setCode(testCartCode);

    final List<OrderEntryData> entries = new ArrayList<>();
    final OrderEntryData orderEntryData = new OrderEntryData();
    final ProductData productData = new ProductData();
    productData.setName(testProductName);
    productData.setImages(imageDataList);
    orderEntryData.setProduct(productData);
    entries.add(orderEntryData);
    cartData.setEntries(entries);
    final SubscriptionPricePlanData pricePlanData = new SubscriptionPricePlanData();
    productData.setPrice(pricePlanData);

    quoteData = new InsuranceQuoteData();
    cartData.setInsuranceQuote(quoteData);
    quoteData.setFormattedExpiryDate(testQuoteFormattedExpiryDate);
  }
コード例 #2
0
 @Test
 public void testAddToCartEntry() {
   final CartModificationData modification = classUnderTest.addToCart(productId, quantity);
   assertNotNull(modification);
   final OrderEntryData entry = modification.getEntry();
   assertNotNull(entry);
   assertEquals(productId, entry.getProduct().getCode());
   assertEquals(new Long(quantity), entry.getQuantity());
 }
  protected void calculateRefundAmount() {
    BigDecimal refundAmountValue = BigDecimal.ZERO;
    PriceData totalPrice = null;
    for (final OrderEntryData entryData : getRefundedEntries()) {
      totalPrice = entryData.getTotalPrice();
      refundAmountValue = refundAmountValue.add(totalPrice.getValue());
    }

    if (totalPrice != null) {
      refundAmount =
          getPriceDataFactory()
              .create(totalPrice.getPriceType(), refundAmountValue, totalPrice.getCurrencyIso());
    }
  }
コード例 #4
0
  @RequestMapping(
      value = "/summary",
      method = {RequestMethod.GET, RequestMethod.POST})
  @RequireHardLogIn
  public String checkoutSummary(final Model model) throws CMSItemNotFoundException {

    if (!b2bUserGroupProvider.isCurrentUserAuthorizedToCheckOut()) {
      GlobalMessages.addErrorMessage(model, "checkout.error.invalid.accountType");
      return FORWARD_PREFIX + "/cart";
    }

    if (!hasItemsInCart()) {
      // no items in the cart
      return FORWARD_PREFIX + "/cart";
    }

    getCheckoutFacade().setDeliveryAddressIfAvailable();
    getCheckoutFacade().setDeliveryModeIfAvailable();
    getCheckoutFacade().setPaymentInfoIfAvailable();

    // Set to default payment type
    final B2BPaymentTypeData paymentTypeData = new B2BPaymentTypeData();
    paymentTypeData.setCode(CheckoutPaymentType.ACCOUNT.getCode());

    final CartData tempCartData = new CartData();
    tempCartData.setPaymentType(paymentTypeData);

    final CartData cartData = getB2BCheckoutFacade().updateCheckoutCart(tempCartData);

    // final CartData cartData = getCheckoutFacade().getCheckoutCart();
    if (cartData.getEntries() != null && !cartData.getEntries().isEmpty()) {
      for (final OrderEntryData entry : cartData.getEntries()) {
        final String productCode = entry.getProduct().getCode();
        final ProductData product =
            productFacade.getProductForCodeAndOptions(
                productCode,
                Arrays.asList(
                    ProductOption.BASIC,
                    ProductOption.PRICE,
                    ProductOption.PRICE_RANGE,
                    ProductOption.VARIANT_MATRIX));
        entry.setProduct(product);
      }
    }

    model.addAttribute("cartData", cartData);
    model.addAttribute("allItems", cartData.getEntries());
    model.addAttribute("deliveryAddress", cartData.getDeliveryAddress());
    model.addAttribute("deliveryMode", cartData.getDeliveryMode());
    model.addAttribute("paymentInfo", cartData.getPaymentInfo());
    model.addAttribute("costCenter", cartData.getCostCenter());
    model.addAttribute("quoteText", new B2BCommentData());
    // TODO:Make configuration hmc driven than hardcoding in controllers
    model.addAttribute("nDays", getNumberRange(1, 30));
    model.addAttribute("nthDayOfMonth", getNumberRange(1, 31));
    model.addAttribute("nthWeek", getNumberRange(1, 12));

    model.addAttribute(new AddressForm());
    model.addAttribute(new PaymentDetailsForm());
    if (!model.containsAttribute("placeOrderForm")) {
      final PlaceOrderForm placeOrderForm = new PlaceOrderForm();
      // TODO: Make setting of default recurrence enum value hmc driven rather hard coding in
      // controller
      placeOrderForm.setReplenishmentRecurrence(B2BReplenishmentRecurrenceEnum.MONTHLY);
      placeOrderForm.setnDays("14");
      final List<DayOfWeek> daysOfWeek = new ArrayList<DayOfWeek>();
      daysOfWeek.add(DayOfWeek.MONDAY);
      placeOrderForm.setnDaysOfWeek(daysOfWeek);
      model.addAttribute("placeOrderForm", placeOrderForm);
    }
    storeCmsPageInModel(model, getContentPageForLabelOrId(SINGLE_STEP_CHECKOUT_SUMMARY_CMS_PAGE));
    setUpMetaDataForContentPage(
        model, getContentPageForLabelOrId(SINGLE_STEP_CHECKOUT_SUMMARY_CMS_PAGE));
    model.addAttribute("metaRobots", "no-index,no-follow");
    return ControllerConstants.Views.Pages.SingleStepCheckout.CheckoutSummaryPage;
  }