Interface CalculationService
- All Known Implementing Classes:
DefaultCalculationService
FindDiscountValuesStrategy, FindTaxValuesStrategy, FindPriceStrategy. Also payment and
delivery costs are resolved using strategies FindDeliveryCostStrategy and FindPaymentCostStrategy.
Whether order needs to be calculated or not is up to the implementation of OrderRequiresCalculationStrategy.
All methods should be executed in transaction.
-
Method Summary
Modifier and TypeMethodDescriptionvoidcalculate(AbstractOrderModel order) Calculates the given order and all its entries unless they're already calculated and the order has not been modified.voidcalculate(AbstractOrderModel order, Date date) Calculates the given order and all its entries unless they're already calculated and the order has not been modified.voidcalculateTotals(AbstractOrderEntryModel entry, boolean recalculate) Recalculates given entries total prices and re-applies tax and discount values.voidcalculateTotals(AbstractOrderModel order, boolean recalculate) (re)calculates all totals for the given order.voidCalculates this entry even if the entry was calculated before.voidrecalculate(AbstractOrderModel order) recalculates the whole order and all its entries.voidrecalculate(AbstractOrderModel order, Date date) recalculates the whole order and all its entries.booleanReturnBoolean.TRUEin case if order needs to be calculated.
-
Method Details
-
calculate
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
ReturnBoolean.TRUEin case if order needs to be calculated. Default implementation use calculationStrategy to get this information. -
calculate
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- targetAbstractOrderModeldate- 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
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
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- targetAbstractOrderModeldate- the date to calculate prices for- Throws:
CalculationException- if a pricefactory error occurred
-
calculateTotals
(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- targetAbstractOrderModelrecalculate- forces setting total even if order is marked as calculated- Throws:
CalculationException
-
calculateTotals
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- targetAbstractOrderEntryModelrecalculate- forces the recalculation of the abstract order entry.
-
recalculate
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
-