public class DefaultCalculationService extends AbstractBusinessService implements CalculationService
CalculationService.AbstractService.SerializableDTOmodelService, sessionService, txManagertenant| Constructor and Description |
|---|
DefaultCalculationService() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAbsoluteEntryTaxValue(long entryQuantity,
TaxValue taxValue,
java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap) |
protected void |
addRelativeEntryTaxValue(double entryTotal,
TaxValue taxValue,
java.util.Set<TaxValue> relativeEntryTaxValues,
java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap) |
protected TaxValue |
applyGrossMixedRate(TaxValue unappliedTaxValue,
java.util.Map<java.util.Set<TaxValue>,java.lang.Double> taxGroups,
int digits,
double taxAdjustmentFactor) |
protected TaxValue |
applyNetMixedRate(TaxValue unappliedTaxValue,
java.util.Map<java.util.Set<TaxValue>,java.lang.Double> taxGroups,
int digits,
double taxAdjustmentFactor) |
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.
|
protected TaxValue |
calculateAbsoluteTotalTaxValue(CurrencyModel curr,
java.lang.String currencyIso,
int digits,
boolean net,
TaxValue taxValue,
double cumulatedEntryQuantities) |
protected double |
calculateDiscountValues(AbstractOrderModel order,
boolean recalculate)
Returns the total discount for this abstract order.
|
void |
calculateEntries(AbstractOrderModel order,
boolean forceRecalculate) |
protected java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> |
calculateSubtotal(AbstractOrderModel order,
boolean recalculate) |
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.
|
protected void |
calculateTotals(AbstractOrderModel order,
boolean recalculate,
java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap)
calculates all totals.
|
protected void |
calculateTotalTaxValues(AbstractOrderEntryModel entry) |
protected double |
calculateTotalTaxValues(AbstractOrderModel order,
boolean recalculate,
int digits,
double taxAdjustmentFactor,
java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap) |
protected java.util.List |
convertDiscountValues(AbstractOrderModel order,
java.util.List dvs) |
PriceValue |
convertPriceIfNecessary(PriceValue pv,
boolean toNet,
CurrencyModel toCurrency,
java.util.Collection taxValues)
converts a PriceValue object into a double matching the target currency and net/gross - state if necessary.
|
protected PriceValue |
findBasePrice(AbstractOrderEntryModel entry) |
protected java.util.List<DiscountValue> |
findDiscountValues(AbstractOrderEntryModel entry) |
protected java.util.List<DiscountValue> |
findGlobalDiscounts(AbstractOrderModel order) |
protected java.util.Collection<TaxValue> |
findTaxValues(AbstractOrderEntryModel entry) |
protected double |
getTaxCorrectionFactor(java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap,
double subtotal,
double total,
AbstractOrderModel order) |
boolean |
getTaxFreeEntrySupport()
Deprecated.
since ages - use
isTaxFreeEntrySupport() |
protected double |
getTaxFreeSubTotal(AbstractOrderModel order)
Calculates the sub total of all order entries with NO tax values.
|
protected java.util.Set<TaxValue> |
getUnappliedRelativeTaxValues(java.util.Collection<TaxValue> allTaxValues) |
protected boolean |
hasJaloStrategies() |
protected boolean |
isAllEntriesTaxed(java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap,
double subtotal,
AbstractOrderModel order) |
boolean |
isTaxFreeEntrySupport() |
protected boolean |
mustHandleTaxFreeEntries(java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap,
double subtotal,
AbstractOrderModel 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.
|
protected void |
recalculateOrderEntryIfNeeded(AbstractOrderEntryModel entry,
boolean forceRecalculation) |
protected void |
refreshOrder(AbstractOrderModel order) |
boolean |
requiresCalculation(AbstractOrderModel order)
Return
Boolean.TRUE in case if order needs to be calculated. |
protected void |
resetAdditionalCosts(AbstractOrderModel order,
java.util.Collection<TaxValue> relativeTaxValues) |
protected void |
resetAllValues(AbstractOrderEntryModel entry) |
protected java.util.Map |
resetAllValues(AbstractOrderModel order) |
protected void |
saveOrder(AbstractOrderModel order) |
protected void |
setCalculatedStatus(AbstractOrderEntryModel entry) |
protected void |
setCalculatedStatus(AbstractOrderModel order) |
void |
setCommonI18NService(CommonI18NService commonI18NService) |
void |
setFindDeliveryCostStrategy(FindDeliveryCostStrategy findDeliveryCostStrategy) |
void |
setFindDiscountsStrategies(java.util.List<FindDiscountValuesStrategy> findDiscountsStrategies) |
void |
setFindPaymentCostStrategy(FindPaymentCostStrategy findPaymentCostStrategy) |
void |
setFindPriceStrategy(FindPriceStrategy findPriceStrategy) |
void |
setFindTaxesStrategies(java.util.List<FindTaxValuesStrategy> findTaxesStrategies) |
void |
setOrderRequiresCalculationStrategy(OrderRequiresCalculationStrategy orderRequiresCalculationStrategy) |
void |
setTaxFreeEntrySupport(boolean taxFreeEntrySupport) |
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerafterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplacepublic void calculate(AbstractOrderModel order) throws CalculationException
CalculationServiceSo 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
CalculationService.calculateTotals(AbstractOrderModel, boolean) instead (e.g. if just a quantity has changed or prices have
been imported and cannot be found via price factory ).
calculate in interface CalculationServiceorder - target AbstractOrderModelCalculationException - if a pricefactory error occurred.public boolean requiresCalculation(AbstractOrderModel order)
CalculationServiceBoolean.TRUE in case if order needs to be calculated. Default implementation use
calculationStrategy to get this information.requiresCalculation in interface CalculationServiceprotected void setCalculatedStatus(AbstractOrderModel order)
protected void setCalculatedStatus(AbstractOrderEntryModel entry)
public void calculate(AbstractOrderModel order, java.util.Date date) throws CalculationException
CalculationServiceSo 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
CalculationService.calculateTotals(AbstractOrderModel, boolean) instead (e.g. if just a quantity has changed or prices have
been imported and cannot be found via price factory ).
calculate in interface CalculationServiceorder - target AbstractOrderModeldate - 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!CalculationException - if a pricefactory error occurredpublic void calculateTotals(AbstractOrderModel order, boolean recalculate) throws CalculationException
CalculationServicecalculateTotals in interface CalculationServiceorder - target AbstractOrderModelrecalculate - forces setting total even if order is marked as calculatedCalculationExceptionprotected void calculateTotals(AbstractOrderModel order, boolean recalculate, java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap) throws CalculationException
recalculate - if false calculation is done only if the calculated flag is not settaxValueMap - the map { tax value -> Double( sum of all entry totals for this tax ) } obtainable via
calculateSubtotal(AbstractOrderModel, boolean)CalculationExceptionprotected void saveOrder(AbstractOrderModel order)
protected double getTaxCorrectionFactor(java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap, double subtotal, double total, AbstractOrderModel order) throws CalculationException
CalculationExceptionprotected boolean mustHandleTaxFreeEntries(java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap, double subtotal, AbstractOrderModel order)
protected double getTaxFreeSubTotal(AbstractOrderModel order)
protected boolean isAllEntriesTaxed(java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap, double subtotal, AbstractOrderModel order)
public void recalculate(AbstractOrderModel order) throws CalculationException
CalculationService
if you merely like to adjust totals while keeping prices, taxes and discounts you should call
CalculationService.calculateTotals(AbstractOrderModel, boolean) instead (e.g. if just a quantity has changed or prices have
been imported and cannot be found via price factory ).
recalculate in interface CalculationServiceorder - target AbstractOrderModelCalculationException - if a pricefactory error occurred.public void recalculate(AbstractOrderModel order, java.util.Date date) throws CalculationException
CalculationServiceFindPriceStrategy,
FindDeliveryCostStrategy, FindTaxValuesStrategy, etc... ).
if you merely like to adjust totals while keeping prices, taxes and discounts you should call
CalculationService.calculateTotals(AbstractOrderModel, boolean) instead (e.g. if just a quantity has changed or prices have
been imported and cannot be found via price factory ).
recalculate in interface CalculationServiceorder - target AbstractOrderModeldate - the date to calculate prices forCalculationException - if a pricefactory error occurredpublic void calculateEntries(AbstractOrderModel order, boolean forceRecalculate) throws CalculationException
CalculationExceptionpublic void calculateTotals(AbstractOrderEntryModel entry, boolean recalculate)
CalculationServicecalculateTotals in interface CalculationServiceentry - target AbstractOrderEntryModelrecalculate - forces the recalculation of the abstract order entry.protected boolean hasJaloStrategies()
protected void calculateTotalTaxValues(AbstractOrderEntryModel entry)
protected void recalculateOrderEntryIfNeeded(AbstractOrderEntryModel entry, boolean forceRecalculation) throws CalculationException
CalculationExceptionpublic void recalculate(AbstractOrderEntryModel entry) throws CalculationException
CalculationService
If prices should be left as currently set but the entry totals have to be consolidated (e.g. when the quantity has
changed) call CalculationService.calculateTotals(AbstractOrderEntryModel,boolean) instead !
recalculate in interface CalculationServiceentry - target AbstractOrderEntryModelCalculationException - if a pricefactory error occurredprotected void refreshOrder(AbstractOrderModel order)
protected void resetAllValues(AbstractOrderEntryModel entry) throws CalculationException
CalculationExceptionprotected java.util.Map resetAllValues(AbstractOrderModel order) throws CalculationException
CalculationExceptionprotected void resetAdditionalCosts(AbstractOrderModel order, java.util.Collection<TaxValue> relativeTaxValues)
public PriceValue convertPriceIfNecessary(PriceValue pv, boolean toNet, CurrencyModel toCurrency, java.util.Collection taxValues)
pv - the base price to converttoNet - the target net/gross statetoCurrency - the target currencytaxValues - the collection of tax values which apply to this priceprotected java.util.List convertDiscountValues(AbstractOrderModel order, java.util.List dvs)
protected java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> calculateSubtotal(AbstractOrderModel order, boolean recalculate)
protected double calculateDiscountValues(AbstractOrderModel order, boolean recalculate)
recalculate - true forces a recalculationprotected double calculateTotalTaxValues(AbstractOrderModel order, boolean recalculate, int digits, double taxAdjustmentFactor, java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap)
recalculate - digits - taxAdjustmentFactor - taxValueMap - protected void addRelativeEntryTaxValue(double entryTotal,
TaxValue taxValue,
java.util.Set<TaxValue> relativeEntryTaxValues,
java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap)
protected void addAbsoluteEntryTaxValue(long entryQuantity,
TaxValue taxValue,
java.util.Map<TaxValue,java.util.Map<java.util.Set<TaxValue>,java.lang.Double>> taxValueMap)
protected java.util.Set<TaxValue> getUnappliedRelativeTaxValues(java.util.Collection<TaxValue> allTaxValues)
protected TaxValue calculateAbsoluteTotalTaxValue(CurrencyModel curr, java.lang.String currencyIso, int digits, boolean net, TaxValue taxValue, double cumulatedEntryQuantities)
protected TaxValue applyGrossMixedRate(TaxValue unappliedTaxValue, java.util.Map<java.util.Set<TaxValue>,java.lang.Double> taxGroups, int digits, double taxAdjustmentFactor)
protected TaxValue applyNetMixedRate(TaxValue unappliedTaxValue, java.util.Map<java.util.Set<TaxValue>,java.lang.Double> taxGroups, int digits, double taxAdjustmentFactor)
protected java.util.Collection<TaxValue> findTaxValues(AbstractOrderEntryModel entry) throws CalculationException
CalculationExceptionprotected java.util.List<DiscountValue> findDiscountValues(AbstractOrderEntryModel entry) throws CalculationException
CalculationExceptionprotected java.util.List<DiscountValue> findGlobalDiscounts(AbstractOrderModel order) throws CalculationException
CalculationExceptionprotected PriceValue findBasePrice(AbstractOrderEntryModel entry) throws CalculationException
CalculationExceptionpublic void setCommonI18NService(CommonI18NService commonI18NService)
public void setFindTaxesStrategies(java.util.List<FindTaxValuesStrategy> findTaxesStrategies)
public void setFindDiscountsStrategies(java.util.List<FindDiscountValuesStrategy> findDiscountsStrategies)
public void setFindPriceStrategy(FindPriceStrategy findPriceStrategy)
public void setFindDeliveryCostStrategy(FindDeliveryCostStrategy findDeliveryCostStrategy)
public void setFindPaymentCostStrategy(FindPaymentCostStrategy findPaymentCostStrategy)
public void setOrderRequiresCalculationStrategy(OrderRequiresCalculationStrategy orderRequiresCalculationStrategy)
public void setTaxFreeEntrySupport(boolean taxFreeEntrySupport)
@Deprecated public boolean getTaxFreeEntrySupport()
isTaxFreeEntrySupport()public boolean isTaxFreeEntrySupport()
Copyright © 2018 SAP SE. All Rights Reserved.