Interface CalculationService
-
- All Known Implementing Classes:
DefaultC4CCalculationService
,DefaultCalculationService
,SapCartCalculationService
public interface CalculationService
Service allows calculation or recalculation of the order. This includes calculation of all the entries, taxes and discount values. Information about price, taxes and discounts are fetched using dedicated strategies :FindDiscountValuesStrategy
,FindTaxValuesStrategy
,FindPriceStrategy
. Also payment and delivery costs are resolved using strategiesFindDeliveryCostStrategy
andFindPaymentCostStrategy
.Whether order needs to be calculated or not is up to the implementation of
OrderRequiresCalculationStrategy
. All methods should be executed in transaction.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
calculate(AbstractOrderModel order)
Calculates the given order and all its entries unless they're already calculated and the order has not been modified.void
calculate(AbstractOrderModel order, java.util.Date date)
Calculates the given order and all its entries unless they're already calculated and the order has not been modified.void
calculateTotals(AbstractOrderEntryModel entry, boolean recalculate)
Recalculates given entries total prices and re-applies tax and discount values.void
calculateTotals(AbstractOrderModel order, boolean recalculate)
(re)calculates all totals for the given order.void
recalculate(AbstractOrderEntryModel entry)
Calculates this entry even if the entry was calculated before.void
recalculate(AbstractOrderModel order)
recalculates the whole order and all its entries.void
recalculate(AbstractOrderModel order, java.util.Date date)
recalculates the whole order and all its entries.boolean
requiresCalculation(AbstractOrderModel order)
ReturnBoolean.TRUE
in case if order needs to be calculated.
-
-
-
Method Detail
-
calculate
void calculate(AbstractOrderModel order) throws CalculationException
Calculates the given order and all its entries unless they're already calculated and the order has not been modified.So this method will fetch prices, taxes and discounts (using spring configurable strategies) for uncalculated or modified entries only - all other will remain unchanged. If at least one entry has been calculated or the order itself has been modified the totals will be calculated as well.
if you merely like to adjust totals while keeping prices, taxes and discounts you should call
calculateTotals(AbstractOrderModel, boolean)
instead (e.g. if just a quantity has changed or prices have been imported and cannot be found via price factory ).- Parameters:
order
- targetAbstractOrderModel
- Throws:
CalculationException
- if a pricefactory error occurred.
-
requiresCalculation
boolean requiresCalculation(AbstractOrderModel order)
ReturnBoolean.TRUE
in case if order needs to be calculated. Default implementation use calculationStrategy to get this information.
-
calculate
void calculate(AbstractOrderModel order, java.util.Date date) throws CalculationException
Calculates the given order and all its entries unless they're already calculated and the order has not been modified.So this method will fetch prices, taxes and discounts (using spring configured strategies) for uncalculated or modified entries only - all other will remain unchanged. If at least one entry has been calculated or the order itself has been modified the totals will be calculated as well.
if you merely like to adjust totals while keeping prices, taxes and discounts you should call
calculateTotals(AbstractOrderModel, boolean)
instead (e.g. if just a quantity has changed or prices have been imported and cannot be found via price factory ).- Parameters:
order
- targetAbstractOrderModel
date
- assumes a given date to perform calculations for - be careful with that since this method will calculate modified or uncalculated entries only, so the given date may not apply to all entries!- Throws:
CalculationException
- if a pricefactory error occurred
-
recalculate
void recalculate(AbstractOrderModel order) throws CalculationException
recalculates the whole order and all its entries. this includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed price factory.if you merely like to adjust totals while keeping prices, taxes and discounts you should call
calculateTotals(AbstractOrderModel, boolean)
instead (e.g. if just a quantity has changed or prices have been imported and cannot be found via price factory ).- Parameters:
order
- targetAbstractOrderModel
- Throws:
CalculationException
- if a pricefactory error occurred.
-
recalculate
void recalculate(AbstractOrderModel order, java.util.Date date) throws CalculationException
recalculates the whole order and all its entries. this includes finding prices, taxes, discounts, payment and delivery costs by calling the currently installed dedicated strategies (FindPriceStrategy
,FindDeliveryCostStrategy
,FindTaxValuesStrategy
, etc... ).if you merely like to adjust totals while keeping prices, taxes and discounts you should call
calculateTotals(AbstractOrderModel, boolean)
instead (e.g. if just a quantity has changed or prices have been imported and cannot be found via price factory ).- Parameters:
order
- targetAbstractOrderModel
date
- the date to calculate prices for- Throws:
CalculationException
- if a pricefactory error occurred
-
calculateTotals
void calculateTotals(AbstractOrderModel order, boolean recalculate) throws CalculationException
(re)calculates all totals for the given order. This does not trigger price, tax and discount calculation but takes all currently set price, tax and discount values as base.- Parameters:
order
- targetAbstractOrderModel
recalculate
- forces setting total even if order is marked as calculated- Throws:
CalculationException
-
calculateTotals
void calculateTotals(AbstractOrderEntryModel entry, boolean recalculate)
Recalculates given entries total prices and re-applies tax and discount values. This does not include finding price, taxes or discount but uses all currently set values.- Parameters:
entry
- targetAbstractOrderEntryModel
recalculate
- forces the recalculation of the abstract order entry.
-
recalculate
void recalculate(AbstractOrderEntryModel entry) throws CalculationException
Calculates this entry even if the entry was calculated before. This includes finding the correct base price, taxes and discount using the currently installed price factory.If prices should be left as currently set but the entry totals have to be consolidated (e.g. when the quantity has changed) call
calculateTotals(AbstractOrderEntryModel, boolean)
instead !- Parameters:
entry
- targetAbstractOrderEntryModel
- Throws:
CalculationException
- if a pricefactory error occurred
-
-