Class Order
java.lang.Object
de.hybris.order.calculation.domain.Order
Central Object that holds all calculation related data and strategies required for calculating the order/cart. The
net/gross mode (see
isNet()) and the current currency (getCurrency()) has to be provided during
creation. After this point LineItem or other objects can be created with a different Currency but
when adding it tho the current Order a CurrenciesAreNotEqualException is thrown.
The getTotal...() methods returns the overall calculated Money for the different line item posts or taxes. With
get...Values() a map is returned which shows the concrete single amount for each charge/discount/tax.-
Constructor Summary
ConstructorsConstructorDescriptionOrder(Currency currency, boolean isNet, CalculationStrategies calculationStrategies) Creates a new order calculation object based on a specific currency and bet/gross mode.Order(Currency currency, CalculationStrategies calculationStrategies) Creates a new gross order calculation object based on a specific currency. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCharge(int index, OrderCharge aoc) Assigns a single charge to this order at a specific position.voidaddCharge(OrderCharge aoc) Assigns a single charge to this order.voidaddCharges(OrderCharge... charges) Assigns multiple charges to this order.voidaddCharges(List<OrderCharge> charges) Assigns multiple charges to this order.voidaddDiscount(int index, OrderDiscount discount) Assigns a discount to this order at a speific position.voidaddDiscount(OrderDiscount discount) Assigns a discount to this order.voidaddDiscounts(OrderDiscount... discounts) Assigns multiple discounts to this order.voidaddDiscounts(List<OrderDiscount> discounts) Assigns multiple discounts to this order.voidaddLineItem(int index, LineItem lineitem) Attaches a line items to this order at the specified position.voidaddLineItem(LineItem lineitem) Attaches a line items to this order.voidaddLineItems(LineItem... lineItems) Attaches multiple line items to this order.voidaddLineItems(List<LineItem> lineItems) Attaches multiple line items to this order.voidAssigns a tax to this order.voidAssigns multiple taxes to this order.voidaddTaxes(Collection<Tax> taxes) Assigns multiple taxes to this order.protected MoneycalculateOrderCharge(Money currentValue, OrderCharge addCharge) protected MoneycalculateOrderDiscount(Money currentValue, OrderDiscount discount) Calculates order discountprotected MoneycalculateTaxTotal(Tax tax, double autoTaxCorrectionFactor) voidRemoves all assigned charges from this order.voidRemoves all assigned discounts from this order.voidRemoves all attached line items.voidRemoves all attached taxes from this order.protected doubleDelegate to all necessary strategies.Returns all charges assigned to this order.Returns the currency which this order is being calculated for.Returns all discounts attached to this order.protected MoneygetFixedTaxedAdditionalCharges(Map<OrderCharge, Money> aocValues) Returns all line items attached to this order.Calculates the sum of all line item totals (LineItem.getTotal(Order)).getTaxes()Returns all taxes assigned to this order.getTaxesFor(Taxable object) getTotal()Calculates the order total.Calculates the total of all charges which apply to the order at a whole.getTotalChargeOfType(AbstractCharge.ChargeType chargeType) Calculates the total of all charges of one specific type which apply to the order at a whole.Calculates totals of all charges assigned to this order separately.Calculates the total of all discounts assigned to this order.Calculates totals of all discounts assigned to this order separately.Calculates the order total always including taxes.Returns the overall sum of taxes within this order.Calculates total taxes for all assignedTaxobject.getTotalTaxFor(Tax tax) Calculates the total tax for a specificTaxobject.booleanhasAssignedTaxes(Taxable object) booleanTells whether this order has got assigned charges or not.booleanTells whether this order has got assigned discounts or not.booleanTells whether or not this order has got line items.booleanhasTaxes()Tells whether this order has got assigned taxes or not.booleanisGross()booleanisNet()voidremoveCharge(OrderCharge aoc) Removes a charge from this order.voidremoveDiscount(OrderDiscount orderDiscount) Removes a discount from this order.voidremoveLineItem(LineItem lineitem) Removes a single line item.voidRemoves the given tax from this order.
-
Constructor Details
-
Order
Creates a new gross order calculation object based on a specific currency.- Parameters:
currency- the currency the whole calculation will be incalculationStrategies- some strategies
-
Order
Creates a new order calculation object based on a specific currency and bet/gross mode.- Parameters:
currency- the currency the whole calculation will be inisNet- true for net, false for gross modecalculationStrategies- some strategies
-
-
Method Details
-
getTotal
Calculates the order total. Depending on the net/gross status of this order that total is either net or gross. Please know thatgetTotalIncludingTaxes()will always return the gross total for both modes. -
getSubTotal
Calculates the sum of all line item totals (LineItem.getTotal(Order)).- See Also:
-
getTotalTaxFor
Calculates the total tax for a specificTaxobject. -
getTotalTaxes
Calculates total taxes for all assignedTaxobject. -
getAutomaticTaxCorrectionFactor
protected double getAutomaticTaxCorrectionFactor() -
getFixedTaxedAdditionalCharges
-
getTaxesFor
- Returns:
- the assigned taxes or an empty collection
-
hasAssignedTaxes
-
getTotalTax
Returns the overall sum of taxes within this order. To get the exact money for each tax please usegetTotalTaxes().- See Also:
-
calculateTaxTotal
-
getTotalCharge
Calculates the total of all charges which apply to the order at a whole. Please note that line item charges are not included here since they are already part of the line item total! -
getTotalChargeOfType
Calculates the total of all charges of one specific type which apply to the order at a whole. Please note that line item charges are not included here since they are already part of the line item total!- Parameters:
chargeType- the type of charge to select- See Also:
-
getTotalDiscount
Calculates the total of all discounts assigned to this order. Please note that this does not include line item discounts since they are already included in line item totals!- See Also:
-
getTotalCharges
Calculates totals of all charges assigned to this order separately.- Returns:
- a map (
OrderCharge->Money)
-
getTotalDiscounts
Calculates totals of all discounts assigned to this order separately.- Returns:
- a map (
OrderDiscount->Money)
-
calculateOrderCharge
-
calculateOrderDiscount
Calculates order discount- Parameters:
currentValue-discount-- Returns:
- money
- Throws:
CurrenciesAreNotEqualExceptionMissingCalculationDataException
-
getTotalIncludingTaxes
Calculates the order total always including taxes. This makes most sense in case of this order being in net mode whengetTotal()will show order total without taxes only. -
getLineItems
Returns all line items attached to this order. -
addLineItems
Attaches multiple line items to this order. Please note that each line item will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case at least one line item has got a base price of different currency than the order currency
-
addLineItems
Attaches multiple line items to this order. Please note that each line item will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case at least one line item has got a base price of different currency than the order currency
-
addLineItem
Attaches a line items to this order. Please note that the line item will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case the line item has got a base price of different currency than the order currency
-
addLineItem
Attaches a line items to this order at the specified position. Please note that the line item will receive a back reference to this order.- Parameters:
index- insert the given line item into this position.lineitem- the line item to be added- Throws:
CurrenciesAreNotEqualException- in case the line item has got a base price of different currency than the order currency
-
clearLineItems
public void clearLineItems()Removes all attached line items. Please note that these line items also lose their back reference to this order. -
removeLineItem
Removes a single line item. Please note that the line items also lose its back reference to this order. -
getTaxes
Returns all taxes assigned to this order. -
addTaxes
Assigns multiple taxes to this order. Please note that each tax receives a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case there is at least one absolute tax having a different currency than the one of this order
-
addTaxes
Assigns multiple taxes to this order. Please note that each tax receives a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case there is at least one absolute tax having a different currency than the one of this order
-
addTax
Assigns a tax to this order. Please note that the tax receives a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case it's a absolute tax having a different currency than the one of this order
-
clearTaxes
public void clearTaxes()Removes all attached taxes from this order. Please note that all back references to this order are cleared. -
removeTax
Removes the given tax from this order. -
getDiscounts
Returns all discounts attached to this order. -
addDiscounts
Assigns multiple discounts to this order. Please note that the discounts will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case there is at least one absolute discount having a different currency than the one of this order
-
addDiscounts
Assigns multiple discounts to this order. Please note that the discounts will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case there is at least one absolute discount having a different currency than the one of this order
-
addDiscount
Assigns a discount to this order. Please note that the discount will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case it's a absolute discount having a different currency than the one of this order
-
addDiscount
Assigns a discount to this order at a speific position. Please note that the discount will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case it's a absolute discount having a different currency than the one of this order
-
clearDiscounts
public void clearDiscounts()Removes all assigned discounts from this order. Please note that all back reference to this order are also cleared. -
removeDiscount
Removes a discount from this order. Please note that the back reference to this order isalso cleared. -
getCharges
Returns all charges assigned to this order. -
addCharges
Assigns multiple charges to this order. Please note that each one will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case at least one absolute charge is using a different currency than the one used for this order
-
addCharges
Assigns multiple charges to this order. Please note that each one will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case at least one absolute charge is using a different currency than the one used for this order
-
addCharge
Assigns a single charge to this order. Please note that it will receive a back reference to this order.- Throws:
CurrenciesAreNotEqualException- in case it's a absolute charge using a different currency than the one used for this order
-
addCharge
Assigns a single charge to this order at a specific position. Please note that it will receive a back reference to this order.- Parameters:
index- the position to add the charge at- Throws:
CurrenciesAreNotEqualException- in case it's a absolute charge using a different currency than the one used for this order
-
clearCharges
public void clearCharges()Removes all assigned charges from this order. Please note that all back references are cleared as well. -
removeCharge
Removes a charge from this order. Please note that the back reference is cleared as well. -
hasLineItems
public boolean hasLineItems()Tells whether or not this order has got line items. -
hasCharges
public boolean hasCharges()Tells whether this order has got assigned charges or not. -
hasDisounts
public boolean hasDisounts()Tells whether this order has got assigned discounts or not. -
hasTaxes
public boolean hasTaxes()Tells whether this order has got assigned taxes or not. -
isNet
public boolean isNet()- Returns:
- true if this order is in net mode, returns false if the order is in gross mode.
-
isGross
public boolean isGross()- Returns:
- false if this order is in net mode, returns true if the order is in gross mode.
-
getCalculationStrategies
Delegate to all necessary strategies. -
getCurrency
Returns the currency which this order is being calculated for.
-