Class AbstractOrderEntry

    • Field Detail

      • DISCOUNTVALUES

        public static final java.lang.String DISCOUNTVALUES
        Qualifier of the AbstractOrderEntry.discountValues attribute
        See Also:
        Constant Field Values
      • TAXVALUES

        public static final java.lang.String TAXVALUES
        Qualifier of the AbstractOrderEntry.taxValues attribute
        See Also:
        Constant Field Values
      • ENTRY_NUMBER

        @Deprecated
        public static final java.lang.String ENTRY_NUMBER
        Deprecated.
        The running order of the CartEntry on the Cart it is assigned to. Defaults to new Integer( de.hybris.platform.jalo.order.AbstractOrder.APPEND_AS_LAST )
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractOrderEntry

        public AbstractOrderEntry()
    • Method Detail

      • createItem

        protected Item createItem​(SessionContext ctx,
                                  ComposedType type,
                                  Item.ItemAttributeMap allAttributes)
                           throws JaloBusinessException
        Description copied from class: Item
        Has to be implemented for each concrete subtype of item. This method is responsible for creating a new item instance ( by calling managers, ejb homes, etc. ) during ComposedType.newInstance(Map).

        In case this method uses any of the attribute values during creation it is required to override Item.getNonInitialAttributes(SessionContext, ItemAttributeMap) too.
        Sn example:

        
         public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext
         ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return
         man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) );
         // here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes(
         SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret =
         super.getNonInitialAttributes( ctx, allAttributes );
         // remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }
        
         
        Overrides:
        createItem in class GeneratedAbstractOrderEntry
        Parameters:
        ctx - the current session context which this item is created within
        type - the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )
        Returns:
        the new item instance
        Throws:
        JaloBusinessException - indicates an error during creation - any changes will be rollbacked
      • setProduct

        public void setProduct​(SessionContext ctx,
                               Product product)
        Changes the ordered product. Please note that this resets the entry in the 'uncalculated' status since price information cannot be valid any more.
        Overrides:
        setProduct in class GeneratedAbstractOrderEntry
        Parameters:
        ctx - can be used for cached access object may be outdated!
        product -
      • setQuantity

        public void setQuantity​(SessionContext ctx,
                                java.lang.Long qtd)
        Changes the number of ordered products. Please note that this resets the entry in the 'uncalculated' status since price information cannot be valid any more.
        Overrides:
        setQuantity in class GeneratedAbstractOrderEntry
        Parameters:
        ctx - can be used for cached access value may be outdated!
        qtd -
      • setUnit

        public void setUnit​(SessionContext ctx,
                            Unit unit)
        Changes the unit of the ordered amount. Please note that this resets the entry in the 'uncalculated' status since prices might also depend on units.
        Overrides:
        setUnit in class GeneratedAbstractOrderEntry
        Parameters:
        ctx - can be used for cached access object may be outdated!
        unit -
      • setBasePrice

        public void setBasePrice​(SessionContext ctx,
                                 java.lang.Double price)
        Sets the calculated base price for this entry.
        Overrides:
        setBasePrice in class GeneratedAbstractOrderEntry
        Parameters:
        ctx - the session context
        price - the new base price
      • getTaxValues

        @Deprecated
        public java.util.Collection getTaxValues()
        Deprecated.
        since ages - Use AbstractOrderEntryModel.getTaxValues() instead.
        The collection of this entry's taxes. These are relative TaxValues which means they dont include real prices but only the tax rate. Please note that during order calculation these tax values are calculated by the current price factory.
        Returns:
        a collection containing all TaxValue objects which are applied on this entry
        Throws:
        JaloNotYetCalculatedException - if this order entry was not yet calculated.
      • getTaxValues

        @Deprecated
        public java.util.Collection getTaxValues​(SessionContext ctx)
        Deprecated.
        since ages - Use AbstractOrderEntryModel.getTaxValues() instead.
        The collection of this entry's taxes. These are relative TaxValues which means they dont include real prices but only the tax rate. Please note that during order calculation these tax values are calculated by the current price factory.
        Parameters:
        ctx - can be used for cached access values may be outdated!
        Returns:
        a collection containing all TaxValue objects which are applied on this entry
        Throws:
        JaloNotYetCalculatedException - if this order entry was not yet calculated.
      • setTaxValues

        @Deprecated
        public void setTaxValues​(java.util.Collection collection)
        Deprecated.
        since ages - Use AbstractOrderEntryModel.setTaxValues(Collection) instead.
        discards all present tax values and adds the given values.
        Parameters:
        collection - the new tax values
      • setTaxValues

        @Deprecated
        public void setTaxValues​(SessionContext ctx,
                                 java.util.Collection collection)
        Deprecated.
        since ages - Use AbstractOrderEntryModel.setTaxValues(Collection) instead.
        discards all present tax values and adds the given values.
        Parameters:
        collection - the new tax values
      • addTaxValue

        @Deprecated
        public void addTaxValue​(TaxValue taxValue)
        Deprecated.
        since ages - Use OrderEntryService.addTaxValue(de.hybris.platform.core.model.order.AbstractOrderEntryModel, TaxValue) instead.
        Adds a new tax into this entry
        Parameters:
        taxValue -
      • addTaxValue

        @Deprecated
        public void addTaxValue​(SessionContext ctx,
                                TaxValue taxValue)
        Deprecated.
        since ages - Use OrderEntryService.addTaxValue(de.hybris.platform.core.model.order.AbstractOrderEntryModel, TaxValue) instead.
        Adds a new tax into this entry
        Parameters:
        ctx -
        taxValue -
      • addAllTaxValues

        @Deprecated
        public void addAllTaxValues​(java.util.Collection values)
        Deprecated.
        since ages - Use OrderEntryService.addAllTaxValues(de.hybris.platform.core.model.order.AbstractOrderEntryModel, List) instead.
        Adds a collection of taxes into this entry
        Parameters:
        values -
      • addAllTaxValues

        @Deprecated
        public void addAllTaxValues​(SessionContext ctx,
                                    java.util.Collection values)
        Deprecated.
        since ages - Use OrderEntryService.addAllTaxValues(de.hybris.platform.core.model.order.AbstractOrderEntryModel, List) instead.
        Adds a collection of taxes into this entry
        Parameters:
        ctx -
        values -
      • removeTaxValue

        @Deprecated
        public void removeTaxValue​(TaxValue taxValue)
        Deprecated.
        since ages - Use OrderEntryService.removeTaxValue(de.hybris.platform.core.model.order.AbstractOrderEntryModel, TaxValue) instead.
        Removes a new tax out of this entry
        Parameters:
        taxValue -
      • removeTaxValue

        @Deprecated
        public void removeTaxValue​(SessionContext ctx,
                                   TaxValue taxValue)
        Deprecated.
        since ages - Use OrderEntryService.removeTaxValue(de.hybris.platform.core.model.order.AbstractOrderEntryModel, TaxValue) instead.
        Removes a new tax out of this entry
        Parameters:
        ctx -
        taxValue -
      • removeAllTaxValues

        @Deprecated
        public void removeAllTaxValues()
        Deprecated.
        since ages - Use AbstractOrderEntryModel.setTaxValues(Collection) and ModelService.save() instead. In order to remove all taxes, use null in the setter.
        Removes all taxes of this entry
      • removeAllTaxValues

        @Deprecated
        public void removeAllTaxValues​(SessionContext ctx)
        Deprecated.
        since ages - Use AbstractOrderEntryModel.setTaxValues(Collection) and ModelService.save() instead. In order to remove all taxes, use null in the setter.
        Removes all taxes of this entry
        Parameters:
        ctx - the session context
      • getDiscountValues

        @Deprecated
        public java.util.List getDiscountValues()
        Deprecated.
        since ages - Use AbstractOrderEntryModel.getDiscountValues() instead.
        The list of this entry's discount values. In contrary to taxes these values contain "real" prices since all discounts directly apply to this entry ( otherwise they're global discounts and are not applied here). Since this may include absolute discounts the ordering of values is important for correct presentation of this entry, so we chose a List as collection format. Please note that during order calculation these discount values are calculated by the current price factory.
        Returns:
        a list of all DiscountValue objects which are applied on this entry
        Throws:
        JaloNotYetCalculatedException - if this order entry was not yet calculated.
      • getDiscountValues

        @Deprecated
        public java.util.List getDiscountValues​(SessionContext ctx)
        Deprecated.
        since ages - Use AbstractOrderEntryModel.getDiscountValues() instead.
        The list of this entry's discount values. In contrary to taxes these values contain "real" prices since all discounts directly apply to this entry ( otherwise they're global discounts and are not applied here). Since this may include absolute discounts the ordering of values is important for correct presentation of this entry, so we chose a List as collection format. Please note that during order calculation these discount values are calculated by the current price factory.
        Parameters:
        ctx - can be used for cached access values may be outdated!
        Returns:
        a list of all DiscountValue objects which are applied on this entry
        Throws:
        JaloNotYetCalculatedException - if this order entry was not yet calculated.
      • setDiscountValues

        @Deprecated
        public void setDiscountValues​(SessionContext ctx,
                                      java.util.List discountValues)
        Deprecated.
        since ages - Use AbstractOrderEntryModel.setDiscountValues(List) and ModelService.save() method instead.
        discards all present discount values and adds the given values.
        Parameters:
        discountValues - the new values
      • setDiscountValues

        public void setDiscountValues​(java.util.List discountValues)
      • addDiscountValue

        @Deprecated
        public void addDiscountValue​(DiscountValue discountValue)
        Deprecated.
        since ages - Use OrderEntryService.addDiscountValue(de.hybris.platform.core.model.order.AbstractOrderEntryModel, DiscountValue) instead.
        Adds a new discount into this entry
        Parameters:
        discountValue -
      • addDiscountValue

        @Deprecated
        public void addDiscountValue​(SessionContext ctx,
                                     DiscountValue discountValue)
        Deprecated.
        since ages - Use OrderEntryService.addDiscountValue(de.hybris.platform.core.model.order.AbstractOrderEntryModel, DiscountValue) instead.
        Adds a new discount into this entry
        Parameters:
        ctx -
        discountValue -
      • addAllDisocuntValues

        @Deprecated
        public void addAllDisocuntValues​(java.util.List values)
        Deprecated.
        since ages - UseaddAllDiscountValues(List) instead
        Adds a collection of discounts into this entry
        Parameters:
        values -
      • addAllDiscountValues

        @Deprecated
        public void addAllDiscountValues​(java.util.List values)
        Deprecated.
        since ages - Use OrderEntryService.addAllDiscountValues(de.hybris.platform.core.model.order.AbstractOrderEntryModel, List) instead.
        Adds a collection of discounts into this entry
        Parameters:
        values -
      • addAllDiscountValues

        @Deprecated
        public void addAllDiscountValues​(SessionContext ctx,
                                         java.util.List values)
        Deprecated.
        since ages - Use OrderEntryService.addAllDiscountValues(de.hybris.platform.core.model.order.AbstractOrderEntryModel, List) instead.
        Adds a collection of discounts into this entry
        Parameters:
        ctx -
        values -
      • removeDiscountValue

        @Deprecated
        public void removeDiscountValue​(DiscountValue discountValue)
        Deprecated.
        since ages - Use OrderEntryService.removeDiscountValue(de.hybris.platform.core.model.order.AbstractOrderEntryModel, DiscountValue) instead.
        Removes a new discount out of this entry
        Parameters:
        discountValue -
      • removeDiscountValue

        @Deprecated
        public void removeDiscountValue​(SessionContext ctx,
                                        DiscountValue discountValue)
        Deprecated.
        since ages - Use OrderEntryService.removeDiscountValue(de.hybris.platform.core.model.order.AbstractOrderEntryModel, DiscountValue) instead.
        Removes a new discount out of this entry
        Parameters:
        ctx -
        discountValue -
      • removeAllDiscountValues

        @Deprecated
        public void removeAllDiscountValues()
        Deprecated.
        since ages - Use AbstractOrderEntryModel.setDiscountValues(List) and ModelService.save() method instead. In order to remove all discounts, simply use null as setter argument.
        Removes all discounts of this entry
      • removeAllDiscountValues

        @Deprecated
        public void removeAllDiscountValues​(SessionContext ctx)
        Deprecated.
        since ages - Use AbstractOrderEntryModel.setDiscountValues(List) and ModelService.save() method instead. In order to remove all discounts, simply use null as setter argument.
        Removes all discounts of this entry
        Parameters:
        ctx - the session context
      • isCalculated

        public java.lang.Boolean isCalculated​(SessionContext ctx)
        Shows if this entry was calculated before. Please note that all calculated fields are only valid if this method returns true .
        Overrides:
        isCalculated in class GeneratedAbstractOrderEntry
        Parameters:
        ctx - can be used for cached access value may be outdated!
        Returns:
        true if this entry is calculated
      • isGiveAway

        public java.lang.Boolean isGiveAway​(SessionContext ctx)
        Shows if this entry will be treated as a give away (that is, for free).
        Overrides:
        isGiveAway in class GeneratedAbstractOrderEntry
        Parameters:
        ctx - can be used for cached access value may be outdated!
        Returns:
        true if this entry is calculated
      • isRejected

        public java.lang.Boolean isRejected​(SessionContext ctx)
        Shows if the GIVEAWAY flag of this entry will be ignored.
        Overrides:
        isRejected in class GeneratedAbstractOrderEntry
        Parameters:
        ctx - can be used for cached access value may be outdated!
        Returns:
        true the rejected flag
      • calculate

        @Deprecated
        public void calculate()
                       throws JaloPriceFactoryException
        Deprecated.
        since ages - Use CalculationService.calculate(de.hybris.platform.core.model.order.AbstractOrderEntryModel) intsead.
        Calculates this entry if the entry is not calculated yet. 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(boolean) instead !

        Throws:
        JaloPriceFactoryException - if no price could be found or other price factory errors occurred.
      • recalculate

        @Deprecated
        public void recalculate()
                         throws JaloPriceFactoryException
        Deprecated.
        since ages - Use CalculationService.recalculate(de.hybris.platform.core.model.order.AbstractOrderEntryModel) instead.
        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(boolean) instead !

        Throws:
        JaloPriceFactoryException - if no price could be found or other price factory errors occurred.
      • setEntryNumberDirect

        protected void setEntryNumberDirect​(int number)
        Changes entry number directly.
        Parameters:
        number - the new entry number
      • calculateTotals

        @Deprecated
        public void calculateTotals​(boolean recalculate)
        Deprecated.
        since ages - Use CalculationService.calculateTotals(de.hybris.platform.core.model.order.AbstractOrderEntryModel, boolean) instead
        Recalculates this 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:
        recalculate - forces the recalculation of the abstract order entry.
      • applyDiscounts

        protected double applyDiscounts​(double totalWithoutDiscounts)
        Applies the discount values of this order entry to the given total value. The calculation algorithm is:

            value = given total value
                for each DiscountValue dv
            {
                        if dv is absolute
                                subtract from value the value of dv
               else
                                subtract from value ( the value of dv * value / 100 )
            }
            round value to order currency
         
        Parameters:
        totalWithoutDiscounts -
        Returns:
        the total minus all discounts
      • toString

        public java.lang.String toString()
        Description copied from class: Item
        Returns the String representation of this item. This is by default the representation of the primary key of this item.
        Overrides:
        toString in class Item
        Returns:
        the String representation of this item.
      • compareTo

        public int compareTo​(java.lang.Object order)
        AbstractOrderEntries are compared by entry number.
        Specified by:
        compareTo in interface java.lang.Comparable
        Overrides:
        compareTo in class Item
        Parameters:
        order - the abstract order entry, which should be compared with this abstract order entry
        Returns:
        an int value calculated by subtracting the entry number of the argument abstract order entry from the entry number of this abstract order entry.
      • setChanged

        protected void setChanged()