@Test public void testEnforcedTierPriceWithFallback() throws Exception { SkuPrice skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, 10L, "EUR", new BigDecimal("0.250"), false, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, null, "EUR", new BigDecimal("0.250"), false, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, 10L, "EUR", new BigDecimal("0.250"), true, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, null, "EUR", new BigDecimal("0.250"), true, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, 10L, "EUR", new BigDecimal("1.250"), false, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, null, "EUR", new BigDecimal("1.250"), false, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, 10L, "EUR", new BigDecimal("1.250"), true, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("12.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("12.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, null, "EUR", new BigDecimal("1.250"), true, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, 10L, "EUR", new BigDecimal("1.250"), false, "P1", null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, null, "EUR", new BigDecimal("1.250"), false, "P1", null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, 10L, "EUR", new BigDecimal("1.250"), true, "P1", null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("12.50", skuPrice.getRegularPrice()); assertValue("9.50", skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("12.50", skuPrice.getSalePriceForCalculation().getFirst()); assertValue("9.50", skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, null, "EUR", new BigDecimal("1.250"), true, "P1", null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("12.50", skuPrice.getRegularPrice()); assertValue("9.50", skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("12.50", skuPrice.getSalePriceForCalculation().getFirst()); assertValue("9.50", skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, 10L, "EUR", new BigDecimal("10.250"), false, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, null, "EUR", new BigDecimal("10.250"), false, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, 10L, "EUR", new BigDecimal("10.250"), true, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("30.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("30.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); skuPrice = priceService.getMinimalPrice(null, "WV_CARRIERSLA_KG", 1011L, null, "EUR", new BigDecimal("10.250"), true, null, null); assertNotNull(skuPrice); assertEquals("WV_CARRIERSLA_KG", skuPrice.getSkuCode()); assertValue("5.50", skuPrice.getRegularPrice()); assertNull(skuPrice.getSalePrice()); assertNotNull(skuPrice.getSalePriceForCalculation()); assertValue("5.50", skuPrice.getSalePriceForCalculation().getFirst()); assertNull(skuPrice.getSalePriceForCalculation().getSecond()); }
@Override public SkuPrice getMinimalPrice(final Long productId, final String selectedSku, final long customerShopId, final Long masterShopId, final String currencyCode, final BigDecimal quantity, final boolean enforceTier, final String pricingPolicy, final String supplier) { final List<Pair<String, SkuPrice>> skuPrices; if (selectedSku == null && productId != null) { skuPrices = getSkuPrices(productId, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else if (selectedSku != null) { skuPrices = getSkuPrices(selectedSku, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else { skuPrices = Collections.emptyList(); } return getMinimalSkuPrice(skuPrices, selectedSku, quantity, enforceTier); }
PriceServiceImpl extends BaseGenericServiceImpl<SkuPrice> implements PriceService { @Override public SkuPrice getMinimalPrice(final Long productId, final String selectedSku, final long customerShopId, final Long masterShopId, final String currencyCode, final BigDecimal quantity, final boolean enforceTier, final String pricingPolicy, final String supplier) { final List<Pair<String, SkuPrice>> skuPrices; if (selectedSku == null && productId != null) { skuPrices = getSkuPrices(productId, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else if (selectedSku != null) { skuPrices = getSkuPrices(selectedSku, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else { skuPrices = Collections.emptyList(); } return getMinimalSkuPrice(skuPrices, selectedSku, quantity, enforceTier); } }
PriceServiceImpl extends BaseGenericServiceImpl<SkuPrice> implements PriceService { @Override public SkuPrice getMinimalPrice(final Long productId, final String selectedSku, final long customerShopId, final Long masterShopId, final String currencyCode, final BigDecimal quantity, final boolean enforceTier, final String pricingPolicy, final String supplier) { final List<Pair<String, SkuPrice>> skuPrices; if (selectedSku == null && productId != null) { skuPrices = getSkuPrices(productId, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else if (selectedSku != null) { skuPrices = getSkuPrices(selectedSku, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else { skuPrices = Collections.emptyList(); } return getMinimalSkuPrice(skuPrices, selectedSku, quantity, enforceTier); } PriceServiceImpl(final GenericDAO<SkuPrice, Long> skuPriceDao); }
PriceServiceImpl extends BaseGenericServiceImpl<SkuPrice> implements PriceService { @Override public SkuPrice getMinimalPrice(final Long productId, final String selectedSku, final long customerShopId, final Long masterShopId, final String currencyCode, final BigDecimal quantity, final boolean enforceTier, final String pricingPolicy, final String supplier) { final List<Pair<String, SkuPrice>> skuPrices; if (selectedSku == null && productId != null) { skuPrices = getSkuPrices(productId, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else if (selectedSku != null) { skuPrices = getSkuPrices(selectedSku, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else { skuPrices = Collections.emptyList(); } return getMinimalSkuPrice(skuPrices, selectedSku, quantity, enforceTier); } PriceServiceImpl(final GenericDAO<SkuPrice, Long> skuPriceDao); @Override SkuPrice getMinimalPrice(final Long productId,
                                    final String selectedSku,
                                    final long customerShopId,
                                    final Long masterShopId,
                                    final String currencyCode,
                                    final BigDecimal quantity,
                                    final boolean enforceTier,
                                    final String pricingPolicy,
                                    final String supplier); @Override List<SkuPrice> getAllCurrentPrices(final Long productId,
                                              final String selectedSku,
                                              final long customerShopId,
                                              final Long masterShopId,
                                              final String currencyCode,
                                              final String pricingPolicy,
                                              final String supplier); @Override List<SkuPrice> getAllPrices(final Long productId, final String selectedSku, final String currencyCode); @Override SkuPrice create(final SkuPrice instance); @Override SkuPrice update(final SkuPrice instance); @Override List<SkuPrice> findPrices(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findPriceCount(final Map<String, List> filter); }
PriceServiceImpl extends BaseGenericServiceImpl<SkuPrice> implements PriceService { @Override public SkuPrice getMinimalPrice(final Long productId, final String selectedSku, final long customerShopId, final Long masterShopId, final String currencyCode, final BigDecimal quantity, final boolean enforceTier, final String pricingPolicy, final String supplier) { final List<Pair<String, SkuPrice>> skuPrices; if (selectedSku == null && productId != null) { skuPrices = getSkuPrices(productId, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else if (selectedSku != null) { skuPrices = getSkuPrices(selectedSku, customerShopId, masterShopId, currencyCode, pricingPolicy, supplier); } else { skuPrices = Collections.emptyList(); } return getMinimalSkuPrice(skuPrices, selectedSku, quantity, enforceTier); } PriceServiceImpl(final GenericDAO<SkuPrice, Long> skuPriceDao); @Override SkuPrice getMinimalPrice(final Long productId,
                                    final String selectedSku,
                                    final long customerShopId,
                                    final Long masterShopId,
                                    final String currencyCode,
                                    final BigDecimal quantity,
                                    final boolean enforceTier,
                                    final String pricingPolicy,
                                    final String supplier); @Override List<SkuPrice> getAllCurrentPrices(final Long productId,
                                              final String selectedSku,
                                              final long customerShopId,
                                              final Long masterShopId,
                                              final String currencyCode,
                                              final String pricingPolicy,
                                              final String supplier); @Override List<SkuPrice> getAllPrices(final Long productId, final String selectedSku, final String currencyCode); @Override SkuPrice create(final SkuPrice instance); @Override SkuPrice update(final SkuPrice instance); @Override List<SkuPrice> findPrices(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findPriceCount(final Map<String, List> filter);  }