Class TestPriceFactory
- All Implemented Interfaces:
PriceFactory,FindDiscountValuesStrategy,FindPriceStrategy,FindTaxValuesStrategy,ServiceLayerOnlyCalculationVerifier
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAll()Resolves price value for the givenAbstractOrderEntryModel.Find applicableDiscountValues for the target order entry.Find applicable globalDiscountValues for the target order.Resolves tax value for the givenAbstractOrderEntryModelbasing on the underlying implementation.getAllPriceInformations(SessionContext ctx, Product product, 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.getBasePrice(AbstractOrderEntry entry) Implement this to define thebase priceof an order entrygetDiscountValues(AbstractOrder order) Implement this to define(global) discount valuesfor an order.Implement this to definediscount valuesfor an order entry.getProductDiscountInformations(SessionContext ctx, Product product, Date date, boolean net) Implement this to show all discounts which may apply to the given productgetProductPriceInformations(SessionContext ctx, Product product, Date date, boolean net) Implement this to show all prices available for the given productgetProductTaxInformations(SessionContext ctx, Product product, Date date) Implement this to show all taxes which apply to the given productgetTaxValues(AbstractOrderEntry entry) Implement this to definetax valuesfor an order entry.booleanImplement 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, List<DiscountValue> discountValues) voidsetDiscounts(Product product, List<DiscountValue> discountValues) voidsetGLobalDiscounts(AbstractOrder abstractOrder, DiscountValue... discountValues) voidsetGLobalDiscounts(AbstractOrder abstractOrder, List<DiscountValue> discountValues) voidsetTaxes(AbstractOrderEntry entry, TaxValue... taxValues) voidsetTaxes(AbstractOrderEntry entry, List<TaxValue> taxValues) voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.hybris.platform.order.strategies.calculation.FindDiscountValuesStrategy
getDiscountInformationMethods inherited from interface de.hybris.platform.order.strategies.calculation.FindPriceStrategy
getPriceInformationMethods inherited from interface de.hybris.platform.order.strategies.calculation.FindTaxValuesStrategy
getTaxInformationMethods inherited from interface de.hybris.platform.order.strategies.calculation.ServiceLayerOnlyCalculationVerifier
isSLOnly
-
Constructor Details
-
TestPriceFactory
public TestPriceFactory()
-
-
Method Details
-
clearAll
public void clearAll() -
setBasePrice
-
setBasePrice
-
setTaxes
-
setTaxes
-
setTaxes
-
setDiscounts
-
setDiscounts
-
setDiscounts
-
setGLobalDiscounts
-
setGLobalDiscounts
-
getBasePrice
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
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
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
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
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, 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 List getProductDiscountInformations(SessionContext ctx, Product product, 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 List getProductPriceInformations(SessionContext ctx, Product product, 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 List getProductTaxInformations(SessionContext ctx, Product product, 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 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 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
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
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
-