public class TestPriceFactory extends java.lang.Object implements PriceFactory, FindPriceStrategy, FindDiscountValuesStrategy, 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 and Description |
|---|
TestPriceFactory() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearAll() |
PriceValue |
findBasePrice(AbstractOrderEntryModel entry)
Resolves price value for the given
AbstractOrderEntryModel. |
java.util.List<DiscountValue> |
findDiscountValues(AbstractOrderEntryModel entry)
Find applicable
DiscountValues for the target order entry. |
java.util.List<DiscountValue> |
findDiscountValues(AbstractOrderModel order)
Find applicable global
DiscountValues for the target order. |
java.util.Collection<TaxValue> |
findTaxValues(AbstractOrderEntryModel entry)
Resolves tax value for the given
AbstractOrderEntryModel basing on the underlying implementation. |
ProductPriceInformations |
getAllPriceInformations(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.
|
PriceValue |
getBasePrice(AbstractOrderEntry entry)
Implement this to define the
base price of an order entry |
java.util.List |
getDiscountValues(AbstractOrder order)
Implement this to define
(global) discount values for an order. |
java.util.List |
getDiscountValues(AbstractOrderEntry entry)
Implement this to define
discount values for an order entry. |
java.util.List |
getProductDiscountInformations(SessionContext ctx,
Product product,
java.util.Date date,
boolean net)
Implement this to show all discounts which may apply to the given product
|
java.util.List |
getProductPriceInformations(SessionContext ctx,
Product product,
java.util.Date date,
boolean net)
Implement this to show all prices available for the given product
|
java.util.List |
getProductTaxInformations(SessionContext ctx,
Product product,
java.util.Date date)
Implement this to show all taxes which apply to the given product
|
java.util.Collection |
getTaxValues(AbstractOrderEntry entry)
Implement this to define
tax values for an order entry. |
boolean |
isNetUser(User user)
Implement this to define whether a user should be treated as net or gross customer.
|
void |
setBasePrice(AbstractOrderEntry entry,
PriceValue priceValue) |
void |
setBasePrice(Product product,
PriceValue priceValue) |
void |
setDiscounts(AbstractOrderEntry entry,
DiscountValue... discountValues) |
void |
setDiscounts(AbstractOrderEntry entry,
java.util.List<DiscountValue> discountValues) |
void |
setDiscounts(Product product,
java.util.List<DiscountValue> discountValues) |
void |
setGLobalDiscounts(AbstractOrder abstractOrder,
DiscountValue... discountValues) |
void |
setGLobalDiscounts(AbstractOrder abstractOrder,
java.util.List<DiscountValue> discountValues) |
void |
setTaxes(AbstractOrderEntry entry,
java.util.List<TaxValue> taxValues) |
void |
setTaxes(AbstractOrderEntry entry,
TaxValue... taxValues) |
void |
setTaxes(Product product,
java.util.List<TaxValue> taxValues) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetPriceInformationgetDiscountInformationgetTaxInformationisSLOnlypublic void clearAll()
public void setBasePrice(AbstractOrderEntry entry, PriceValue priceValue)
public void setBasePrice(Product product, PriceValue priceValue)
public void setTaxes(AbstractOrderEntry entry, TaxValue... taxValues)
public void setTaxes(AbstractOrderEntry entry, java.util.List<TaxValue> taxValues)
public void setDiscounts(AbstractOrderEntry entry, DiscountValue... discountValues)
public void setDiscounts(AbstractOrderEntry entry, java.util.List<DiscountValue> discountValues)
public void setDiscounts(Product product, java.util.List<DiscountValue> discountValues)
public void setGLobalDiscounts(AbstractOrder abstractOrder, DiscountValue... discountValues)
public void setGLobalDiscounts(AbstractOrder abstractOrder, java.util.List<DiscountValue> discountValues)
public PriceValue getBasePrice(AbstractOrderEntry entry) throws JaloPriceFactoryException
PriceFactorybase price of an order entrygetBasePrice in interface PriceFactoryJaloPriceFactoryExceptionpublic java.util.List getDiscountValues(AbstractOrderEntry entry) throws JaloPriceFactoryException
PriceFactorydiscount values for an order entry.getDiscountValues in interface PriceFactoryJaloPriceFactoryExceptionpublic java.util.List getDiscountValues(AbstractOrder order) throws JaloPriceFactoryException
PriceFactory(global) discount values for an order.
These discount values are applied to the whole order, not just to one entry like
PriceFactory.getDiscountValues(AbstractOrderEntry)getDiscountValues in interface PriceFactoryJaloPriceFactoryExceptionpublic java.util.Collection getTaxValues(AbstractOrderEntry entry) throws JaloPriceFactoryException
PriceFactorytax values for an order entry.getTaxValues in interface PriceFactoryJaloPriceFactoryExceptionpublic boolean isNetUser(User user)
PriceFactoryisNetUser in interface PriceFactorypublic ProductPriceInformations getAllPriceInformations(SessionContext ctx, Product product, java.util.Date date, boolean net) throws JaloPriceFactoryException
PriceFactory
This default implementation just calls
PriceFactory.getProductPriceInformations(SessionContext, Product, Date, boolean),
PriceFactory.getProductTaxInformations(SessionContext, Product, Date ) and
PriceFactory.getProductDiscountInformations(SessionContext, Product, Date, boolean )
and wraps the results inside a ProductPriceInformations object.
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) and
PriceFactory.getProductDiscountInformations(SessionContext, Product, Date, boolean ) since these methods are
called by Product directly.
getAllPriceInformations in interface PriceFactoryJaloPriceFactoryException - if a calculation error occuredpublic java.util.List getProductDiscountInformations(SessionContext ctx, Product product, java.util.Date date, boolean net) throws JaloPriceFactoryException
PriceFactorygetProductDiscountInformations in interface PriceFactoryproduct - the productDiscountInformation objectsJaloPriceFactoryException - if price calculation error occuredpublic java.util.List getProductPriceInformations(SessionContext ctx, Product product, java.util.Date date, boolean net) throws JaloPriceFactoryException
PriceFactorygetProductPriceInformations in interface PriceFactoryproduct - the productnet - the net/gross state of the requested pricesPriceInformation objectsJaloPriceFactoryException - if price calculation error occuredpublic java.util.List getProductTaxInformations(SessionContext ctx, Product product, java.util.Date date) throws JaloPriceFactoryException
PriceFactorygetProductTaxInformations in interface PriceFactoryproduct - the productTaxInformation objectsJaloPriceFactoryException - if price calculation error occuredpublic java.util.Collection<TaxValue> findTaxValues(AbstractOrderEntryModel entry) throws CalculationException
FindTaxValuesStrategyAbstractOrderEntryModel basing on the underlying implementation.findTaxValues in interface FindTaxValuesStrategyentry - AbstractOrderEntryModelTaxValuesCalculationExceptionpublic java.util.List<DiscountValue> findDiscountValues(AbstractOrderEntryModel entry) throws CalculationException
FindDiscountValuesStrategyDiscountValues for the target order entry.findDiscountValues in interface FindDiscountValuesStrategyDiscountValuesCalculationExceptionpublic java.util.List<DiscountValue> findDiscountValues(AbstractOrderModel order) throws CalculationException
FindDiscountValuesStrategyDiscountValues for the target order. They may originate from the current session's
price factory or DiscountModels directly attached to the target order.findDiscountValues in interface FindDiscountValuesStrategyDiscountValuesCalculationExceptionpublic PriceValue findBasePrice(AbstractOrderEntryModel entry) throws CalculationException
FindPriceStrategyAbstractOrderEntryModel. Please refer to
FindPricingWithCurrentPriceFactoryStrategy, which resolves the price according to the current price factory.findBasePrice in interface FindPriceStrategyentry - AbstractOrderEntryModelPriceValueCalculationExceptionCopyright © 2018 SAP SE. All Rights Reserved.