Class TestPriceFactory
- java.lang.Object
-
- de.hybris.platform.order.TestPriceFactory
-
- All Implemented Interfaces:
PriceFactory,FindDiscountValuesStrategy,FindPriceStrategy,FindTaxValuesStrategy,ServiceLayerOnlyCalculationVerifier
public class TestPriceFactory extends java.lang.Object implements PriceFactory, FindPriceStrategy, FindDiscountValuesStrategy, FindTaxValuesStrategy, ServiceLayerOnlyCalculationVerifier
Price factory implementation for testing order calculation only. It allows to specify prices, taxes and discounts per order/cart entry or per product. Please not that price info methods are not implemented yet! Use like this:Cart = ... CartEntry e1 = ... CartEntry e2 = ... TestPriceFactory pf = new TestPriceFactory(); jaloSession.getSessionContext().setPriceFactory(pf); // e1 = 5 EUR pf.setBasePrice(e1, new PriceValue("EUR", 5, cart.isNet())); // e1 = VAT_FULL 19% pf.setTaxes(e1, new TaxValue("VAT_FULL", 19, false, null)); // e2 = 1.5 EUR pf.setBasePrice(e2, new PriceValue("EUR", 1.5, cart.isNet())); // e2 = VAT_HALF 7% pf.setTaxes(e2, new TaxValue("VAT_HALF", 7, false, null)); cart.calculate();
-
-
Constructor Summary
Constructors Constructor Description TestPriceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearAll()PriceValuefindBasePrice(AbstractOrderEntryModel entry)Resolves price value for the givenAbstractOrderEntryModel.java.util.List<DiscountValue>findDiscountValues(AbstractOrderEntryModel entry)Find applicableDiscountValues for the target order entry.java.util.List<DiscountValue>findDiscountValues(AbstractOrderModel order)Find applicable globalDiscountValues for the target order.java.util.Collection<TaxValue>findTaxValues(AbstractOrderEntryModel entry)Resolves tax value for the givenAbstractOrderEntryModelbasing on the underlying implementation.ProductPriceInformationsgetAllPriceInformations(SessionContext ctx, Product product, java.util.Date date, boolean net)Implement this to calculates a product price quote containing all applicable prices, discounts and taxes for the given product and net/gross state.PriceValuegetBasePrice(AbstractOrderEntry entry)Implement this to define thebase priceof an order entryjava.util.ListgetDiscountValues(AbstractOrder order)Implement this to define(global) discount valuesfor an order.java.util.ListgetDiscountValues(AbstractOrderEntry entry)Implement this to definediscount valuesfor an order entry.java.util.ListgetProductDiscountInformations(SessionContext ctx, Product product, java.util.Date date, boolean net)Implement this to show all discounts which may apply to the given productjava.util.ListgetProductPriceInformations(SessionContext ctx, Product product, java.util.Date date, boolean net)Implement this to show all prices available for the given productjava.util.ListgetProductTaxInformations(SessionContext ctx, Product product, java.util.Date date)Implement this to show all taxes which apply to the given productjava.util.CollectiongetTaxValues(AbstractOrderEntry entry)Implement this to definetax valuesfor an order entry.booleanisNetUser(User user)Implement this to define whether a user should be treated as net or gross customer.voidsetBasePrice(AbstractOrderEntry entry, PriceValue priceValue)voidsetBasePrice(Product product, PriceValue priceValue)voidsetDiscounts(AbstractOrderEntry entry, DiscountValue... discountValues)voidsetDiscounts(AbstractOrderEntry entry, java.util.List<DiscountValue> discountValues)voidsetDiscounts(Product product, java.util.List<DiscountValue> discountValues)voidsetGLobalDiscounts(AbstractOrder abstractOrder, DiscountValue... discountValues)voidsetGLobalDiscounts(AbstractOrder abstractOrder, java.util.List<DiscountValue> discountValues)voidsetTaxes(AbstractOrderEntry entry, TaxValue... taxValues)voidsetTaxes(AbstractOrderEntry entry, java.util.List<TaxValue> taxValues)voidsetTaxes(Product product, java.util.List<TaxValue> taxValues)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.order.strategies.calculation.FindDiscountValuesStrategy
getDiscountInformation
-
Methods inherited from interface de.hybris.platform.order.strategies.calculation.FindPriceStrategy
getPriceInformation
-
Methods inherited from interface de.hybris.platform.order.strategies.calculation.FindTaxValuesStrategy
getTaxInformation
-
Methods inherited from interface de.hybris.platform.order.strategies.calculation.ServiceLayerOnlyCalculationVerifier
isSLOnly
-
-
-
-
Method Detail
-
clearAll
public void clearAll()
-
setBasePrice
public void setBasePrice(AbstractOrderEntry entry, PriceValue priceValue)
-
setBasePrice
public void setBasePrice(Product product, PriceValue priceValue)
-
setTaxes
public void setTaxes(AbstractOrderEntry entry, TaxValue... taxValues)
-
setTaxes
public void setTaxes(AbstractOrderEntry entry, java.util.List<TaxValue> taxValues)
-
setDiscounts
public void setDiscounts(AbstractOrderEntry entry, DiscountValue... discountValues)
-
setDiscounts
public void setDiscounts(AbstractOrderEntry entry, java.util.List<DiscountValue> discountValues)
-
setDiscounts
public void setDiscounts(Product product, java.util.List<DiscountValue> discountValues)
-
setGLobalDiscounts
public void setGLobalDiscounts(AbstractOrder abstractOrder, DiscountValue... discountValues)
-
setGLobalDiscounts
public void setGLobalDiscounts(AbstractOrder abstractOrder, java.util.List<DiscountValue> discountValues)
-
getBasePrice
public PriceValue getBasePrice(AbstractOrderEntry entry) throws JaloPriceFactoryException
Description copied from interface:PriceFactoryImplement this to define thebase priceof an order entry- Specified by:
getBasePricein interfacePriceFactory- Returns:
- a price with the order's currency iso code, 0.0 as value and the order's net status
- Throws:
JaloPriceFactoryException
-
getDiscountValues
public java.util.List getDiscountValues(AbstractOrderEntry entry) throws JaloPriceFactoryException
Description copied from interface:PriceFactoryImplement this to definediscount valuesfor an order entry.- Specified by:
getDiscountValuesin interfacePriceFactory- Returns:
- the Collection of DiscountValues assigned to the given AbstractOrderEntry
- Throws:
JaloPriceFactoryException
-
getDiscountValues
public java.util.List getDiscountValues(AbstractOrder order) throws JaloPriceFactoryException
Description copied from interface:PriceFactoryImplement this to define(global) discount valuesfor an order.These discount values are applied to the whole order, not just to one entry like
PriceFactory.getDiscountValues(AbstractOrderEntry)- Specified by:
getDiscountValuesin interfacePriceFactory- Returns:
- the Collection of DiscountValues applicable to the given AbstractOrder
- Throws:
JaloPriceFactoryException
-
getTaxValues
public java.util.Collection getTaxValues(AbstractOrderEntry entry) throws JaloPriceFactoryException
Description copied from interface:PriceFactoryImplement this to definetax valuesfor an order entry.- Specified by:
getTaxValuesin interfacePriceFactory- Returns:
- the Collection of TaxValues assigned to the given AbstractOrderEntry
- Throws:
JaloPriceFactoryException
-
isNetUser
public boolean isNetUser(User user)
Description copied from interface:PriceFactoryImplement this to define whether a user should be treated as net or gross customer.- Specified by:
isNetUserin interfacePriceFactory- Returns:
- true, if the given user is treated as a net customer
-
getAllPriceInformations
public ProductPriceInformations getAllPriceInformations(SessionContext ctx, Product product, java.util.Date date, boolean net) throws JaloPriceFactoryException
Description copied from interface:PriceFactoryImplement this to calculates a product price quote containing all applicable prices, discounts and taxes for the given product and net/gross state.This default implementation just calls
PriceFactory.getProductPriceInformations(SessionContext, Product, Date, boolean),PriceFactory.getProductTaxInformations(SessionContext, Product, Date)andPriceFactory.getProductDiscountInformations(SessionContext, Product, Date, boolean)and wraps the results inside aProductPriceInformationsobject.Override to define the prices, taxes and discounts for all occasions when no order or order entry is available, e.g. for product lists. Please take care also to override
PriceFactory.getProductPriceInformations(SessionContext, Product, Date, boolean),PriceFactory.getProductTaxInformations(SessionContext, Product, Date)andPriceFactory.getProductDiscountInformations(SessionContext, Product, Date, boolean)since these methods are called byProductdirectly.- Specified by:
getAllPriceInformationsin interfacePriceFactory- Throws:
JaloPriceFactoryException- if a calculation error occured
-
getProductDiscountInformations
public java.util.List getProductDiscountInformations(SessionContext ctx, Product product, java.util.Date date, boolean net) throws JaloPriceFactoryException
Description copied from interface:PriceFactoryImplement this to show all discounts which may apply to the given product- Specified by:
getProductDiscountInformationsin interfacePriceFactoryproduct- the product- Returns:
- a list of
DiscountInformationobjects - Throws:
JaloPriceFactoryException- if price calculation error occured
-
getProductPriceInformations
public java.util.List getProductPriceInformations(SessionContext ctx, Product product, java.util.Date date, boolean net) throws JaloPriceFactoryException
Description copied from interface:PriceFactoryImplement this to show all prices available for the given product- Specified by:
getProductPriceInformationsin interfacePriceFactoryproduct- the productnet- the net/gross state of the requested prices- Returns:
- a list of
PriceInformationobjects - Throws:
JaloPriceFactoryException- if price calculation error occured
-
getProductTaxInformations
public java.util.List getProductTaxInformations(SessionContext ctx, Product product, java.util.Date date) throws JaloPriceFactoryException
Description copied from interface:PriceFactoryImplement this to show all taxes which apply to the given product- Specified by:
getProductTaxInformationsin interfacePriceFactoryproduct- the product- Returns:
- a list of
TaxInformationobjects - Throws:
JaloPriceFactoryException- if price calculation error occured
-
findTaxValues
public java.util.Collection<TaxValue> findTaxValues(AbstractOrderEntryModel entry) throws CalculationException
Description copied from interface:FindTaxValuesStrategyResolves tax value for the givenAbstractOrderEntryModelbasing on the underlying implementation.- Specified by:
findTaxValuesin interfaceFindTaxValuesStrategy- Parameters:
entry-AbstractOrderEntryModel- Returns:
- collection of
TaxValues - Throws:
CalculationException
-
findDiscountValues
public java.util.List<DiscountValue> findDiscountValues(AbstractOrderEntryModel entry) throws CalculationException
Description copied from interface:FindDiscountValuesStrategyFind applicableDiscountValues for the target order entry.- Specified by:
findDiscountValuesin interfaceFindDiscountValuesStrategy- Returns:
- List of
DiscountValues - Throws:
CalculationException
-
findDiscountValues
public java.util.List<DiscountValue> findDiscountValues(AbstractOrderModel order) throws CalculationException
Description copied from interface:FindDiscountValuesStrategyFind applicable globalDiscountValues for the target order. They may originate from the current session's price factory orDiscountModels directly attached to the target order.- Specified by:
findDiscountValuesin interfaceFindDiscountValuesStrategy- Returns:
- List of
DiscountValues - Throws:
CalculationException
-
findBasePrice
public PriceValue findBasePrice(AbstractOrderEntryModel entry) throws CalculationException
Description copied from interface:FindPriceStrategyResolves price value for the givenAbstractOrderEntryModel. Please refer toFindPricingWithCurrentPriceFactoryStrategy, which resolves the price according to the current price factory.- Specified by:
findBasePricein interfaceFindPriceStrategy- Parameters:
entry-AbstractOrderEntryModel- Returns:
PriceValue- Throws:
CalculationException
-
-