Interface CalculationService

    • 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 - target AbstractOrderModel
        Throws:
        CalculationException - if a pricefactory error occurred.
      • requiresCalculation

        boolean requiresCalculation​(AbstractOrderModel order)
        Return Boolean.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 - target AbstractOrderModel
        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 - target AbstractOrderModel
        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 - target AbstractOrderModel
        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 - target AbstractOrderEntryModel
        recalculate - forces the recalculation of the abstract order entry.