ShoppingCartImpl implements MutableShoppingCart { @Override public boolean removeItemOffers() { boolean removed = false; for (final CartItemImpl item : getItems()) { if (item.isFixedPrice()) { removed = true; item.setPrice(item.getSalePrice() != null ? item.getSalePrice() : item.getListPrice()); item.setAppliedPromo(null); item.setFixedPrice(false); } } return removed; }  @Override void initialise(final AmountCalculationStrategy calculationStrategy); @Override void markDirty(); @Override void clean(); @Override void recalculate(); @Override @JsonIgnore boolean isSeparateBillingAddress(); @Override @JsonIgnore boolean isBillingAddressNotRequired(); @Override @JsonIgnore boolean isDeliveryAddressNotRequired(); @Override @JsonIgnore String getOrderMessage(); @Override String getGuid(); @Override @JsonIgnore Map<String, Long> getCarrierSlaId(); @Override @JsonIgnore boolean isAllCarrierSlaSelected(); @Override @JsonIgnore boolean isAllCartItemsBucketed(); @Override @JsonIgnore List<CartItem> getCartItemList(); @Override @JsonIgnore Map<DeliveryBucket, List<CartItem>> getCartItemMap(); @Override @JsonIgnore List<CartItem> getShippingList(); @Override @JsonIgnore Map<DeliveryBucket, List<CartItem>> getShippingListMap(); @Override BigDecimal getProductSkuQuantity(final String supplier,
                                            final String sku); @Override boolean addProductSkuToCart(final String supplier,
                                       final String sku,
                                       final String skuName,
                                       final BigDecimal quantity,
                                       final String itemGroup,
                                       final boolean configurable,
                                       final boolean notSoldSeparately); @Override boolean addShippingToCart(final DeliveryBucket deliveryBucket,
                                     final String carrierSlaGUID,
                                     final String carrierSlaName,
                                     final BigDecimal quantity); @Override boolean addGiftToCart(final String supplier,
                                 final String sku,
                                 final String skuName,
                                 final BigDecimal quantity,
                                 final String promotionCode); @Override boolean setProductSkuToCart(final String supplier,
                                       final String sku,
                                       final String skuName,
                                       final BigDecimal quantity,
                                       final String itemGroup); @Override boolean setProductSkuDeliveryBucket(final String sku,
                                               final DeliveryBucket deliveryBucket); @Override boolean setGiftDeliveryBucket(final String sku,
                                         final DeliveryBucket deliveryBucket); @Override boolean removeCartItem(final String supplier,
                                  final String productSku,
                                  final String itemGroup); @Override boolean removeCartItemQuantity(final String supplier,
                                          final String productSku,
                                          final BigDecimal quantity,
                                          final String itemGroup); @Override boolean removeItemPromotions(); @Override boolean removeItemOffers(); @Override boolean removeShipping(); @Override boolean removeShipping(final String carrierSlaGUID,
                                  final DeliveryBucket deliveryBucket); @Override boolean setProductSkuPrice(final String supplier,
                                      final String skuCode,
                                      final BigDecimal salePrice,
                                      final BigDecimal listPrice); @Override boolean setShippingPrice(final String carrierSlaGUID,
                                    final DeliveryBucket deliveryBucket,
                                    final BigDecimal salePrice,
                                    final BigDecimal listPrice); @Override boolean setGiftPrice(final String supplier,
                                final String skuCode,
                                final BigDecimal salePrice,
                                final BigDecimal listPrice); @Override boolean setProductSkuPromotion(final String supplier,
                                          final String skuCode,
                                          final BigDecimal promoPrice,
                                          final String promoCode); @Override boolean setProductSkuOffer(final String supplier,
                                      final String skuCode,
                                      final BigDecimal fixedPrice,
                                      final String authCode); @Override boolean setShippingPromotion(final String carrierSlaGUID,
                                        final DeliveryBucket deliveryBucket,
                                        final BigDecimal promoPrice,
                                        final String promoCode); @Override boolean setProductSkuTax(final String supplier,
                                    final String skuCode,
                                    final BigDecimal netPrice,
                                    final BigDecimal grossPrice,
                                    final BigDecimal rate,
                                    final String taxCode,
                                    final boolean exclPrice); @Override boolean setShippingTax(final String carrierSlaGUID, final DeliveryBucket deliveryBucket, final BigDecimal netPrice, final BigDecimal grossPrice, final BigDecimal rate, final String taxCode, final boolean exclPrice); @Override List<String> getCoupons(); @Override @JsonIgnore List<String> getAppliedCoupons(); @Override boolean addCoupon(final String coupon); @Override boolean removeCoupon(final String coupon); @Override @JsonIgnore int getCartItemsCount(); @Override @JsonIgnore List<String> getCartItemsSuppliers(); @Override String getCurrencyCode(); @Override void setCurrencyCode(final String currencyCode); @Override @JsonIgnore String getCustomerName(); @Override long getModifiedTimestamp(); @Override @JsonIgnore boolean isModified(); @Override @JsonIgnore boolean hasGifts(); @Override @JsonIgnore boolean isPromotionsDisabled(); @Override void setPromotionsDisabled(final boolean promotionsDisabled); @Override @JsonIgnore String getOrdernum(); @Override void setOrdernum(final String ordernum); @Override @JsonIgnore String getCustomerEmail(); @Override @JsonIgnore int getLogonState(); @Override MutableShoppingContext getShoppingContext(); @Override String getCurrentLocale(); @Override void setCurrentLocale(final String currentLocale); @Override MutableOrderInfo getOrderInfo(); @Override long getProcessingStartTimestamp(); @Override Total getTotal();  }
@Test public void testRemoveItemOffers() throws Exception { cart.addProductSkuToCart("s01", "ABC001", "SKU name", BigDecimal.ONE, null, false, false); cart.setProductSkuPrice("s01", "ABC001", new BigDecimal("9.99"), new BigDecimal("10.99")); cart.setProductSkuPromotion("s01", "ABC001", new BigDecimal("5.99"), "-50"); cart.addGiftToCart("s01", "G001", "SKU name", BigDecimal.ONE, "G001"); cart.setGiftPrice("s01", "G001", new BigDecimal("4.99"), new BigDecimal("4.99")); cart.addProductSkuToCart("s01", "ABC002", "SKU name", BigDecimal.ONE, null, false, false); cart.setProductSkuPrice("s01", "ABC002", new BigDecimal("9.99"), new BigDecimal("10.99")); cart.setProductSkuOffer("s01", "ABC002", new BigDecimal("5.99"), "AUTH001"); assertEquals(3, cart.getCartItemList().size()); final CartItem abc001 = cart.getCartItemList().get(0); assertNotNull(abc001); assertFalse(abc001.isGift()); assertTrue(abc001.isPromoApplied()); assertFalse(abc001.isFixedPrice()); assertEquals("-50", abc001.getAppliedPromo()); assertEquals(new BigDecimal("5.99"), abc001.getPrice()); final CartItem abc002 = cart.getCartItemList().get(1); assertNotNull(abc002); assertFalse(abc002.isGift()); assertFalse(abc002.isPromoApplied()); assertTrue(abc002.isFixedPrice()); assertEquals("AUTH001", abc002.getAppliedPromo()); assertEquals(new BigDecimal("5.99"), abc002.getPrice()); final CartItem gift = cart.getCartItemList().get(2); assertNotNull(gift); assertTrue(gift.isGift()); assertTrue(gift.isPromoApplied()); assertFalse(gift.isFixedPrice()); assertEquals("G001", gift.getAppliedPromo()); assertEquals(new BigDecimal("0.00"), gift.getPrice()); cart.removeItemOffers(); assertEquals(3, cart.getCartItemList().size()); final CartItem abc001_2 = cart.getCartItemList().get(0); assertNotNull(abc001_2); assertFalse(abc001_2.isGift()); assertTrue(abc001_2.isPromoApplied()); assertFalse(abc001_2.isFixedPrice()); assertEquals("-50", abc001_2.getAppliedPromo()); assertEquals(new BigDecimal("5.99"), abc001_2.getPrice()); final CartItem abc002_2 = cart.getCartItemList().get(1); assertNotNull(abc002_2); assertFalse(abc002_2.isGift()); assertFalse(abc002_2.isPromoApplied()); assertFalse(abc002_2.isFixedPrice()); assertNull("AUTH001", abc002_2.getAppliedPromo()); assertEquals(new BigDecimal("9.99"), abc002_2.getPrice()); final CartItem gift_2 = cart.getCartItemList().get(2); assertNotNull(gift_2); assertTrue(gift_2.isGift()); assertTrue(gift_2.isPromoApplied()); assertFalse(gift_2.isFixedPrice()); assertEquals("G001", gift_2.getAppliedPromo()); assertEquals(new BigDecimal("0.00"), gift_2.getPrice()); }