Class LineItemOfferDetail

    • Constructor Detail

      • LineItemOfferDetail

        public LineItemOfferDetail()
    • Method Detail

      • finalizeQuantities

        public void finalizeQuantities()
        Updates the target and qualifier quantities to indicate the number that are being used.
      • clearAllNonFinalizedQuantities

        public void clearAllNonFinalizedQuantities()
        Clears target and qualifier quantities that were marked for a promotion that did not have enough qualifiers or targets to get applied.
      • getQtyAvailableToUseAsTarget

        public int getQtyAvailableToUseAsTarget​(CandidateItemOffer offer)
        Calculates the number of order items available to be used as targets for the provided Offer.

        Checks if the provided Offer is combinable and if all offers already applied to the related order item are also combinable, then returns the result of #getQtyAvailableToBeUsed(Offer, boolean). If this or an already applied offer are non-combinable or totalitarian, then returns 0.

        Parameters:
        offer - the offer for which we are counting the number of possible targets
        Returns:
        the number of orderLineItems not already exclusively used as targets or qualifiers
      • getQtyAvailableToUseAsQualifier

        public int getQtyAvailableToUseAsQualifier​(CandidateItemOffer offer)
        Calculates the number of order items available to be used as qualifiers for the provided Offer.
        Parameters:
        offer - the offer for which we are counting the number of possible qualifiers
        Returns:
        the number of orderLineItems not already exclusively used as targets or qualifiers
      • getFinalizedTotalWithAdjustments

        public javax.money.MonetaryAmount getFinalizedTotalWithAdjustments()
        Returns the final total for this item taking into account the finalized orderAdjustments. Calls chooseSaleOrStandardPrice() to finalize the orderAdjustments before returning them.
        Returns:
        the final total for this item taking into account the finalized orderAdjustments.
      • splitIfNecessary

        @NonNull
        public Optional<LineItemOfferDetail> splitIfNecessary​(@NonNull
                                                              com.broadleafcommerce.common.extension.TypeFactory offerFactory)
        Checks to see that the discount quantities match the target quantities. If not, splits this item into two.
        Returns:
        the item created by splitting
      • calculateItemUnitPriceWithAdjustments

        public javax.money.MonetaryAmount calculateItemUnitPriceWithAdjustments​(boolean allowSalePrice)
        Parameters:
        allowSalePrice - whether to use the sale price in the calculation
        Returns:
        the price to be used for this priceDetail taking into account whether or not the sales price can be used.
      • chooseSaleOrStandardPrice

        public void chooseSaleOrStandardPrice()
        This method will check to see if the salePriceAdjustments or standardPriceAdjustments are better and remove those that should not apply.
      • buildDetailKey

        @NonNull
        public String buildDetailKey()
        Returns:
        a key that represents a unique offer detail
      • getFinalTotalAdjustmentValue

        public javax.money.MonetaryAmount getFinalTotalAdjustmentValue​(javax.money.CurrencyUnit currency)
        Returns:
        the finalized adjustment value multiplied by the quantity
      • calculateTotalAdjustmentValue

        public javax.money.MonetaryAmount calculateTotalAdjustmentValue​(javax.money.CurrencyUnit currency,
                                                                        boolean useSaleAdjustments)
      • calculateAdjustmentValue

        public javax.money.MonetaryAmount calculateAdjustmentValue​(javax.money.CurrencyUnit currency,
                                                                   boolean useSaleAdjustments)
      • getFinalAdjustmentValue

        public javax.money.MonetaryAmount getFinalAdjustmentValue​(javax.money.CurrencyUnit currency)
      • getFinalAdjustmentValueIncludingFutureDiscounts

        public javax.money.MonetaryAmount getFinalAdjustmentValueIncludingFutureDiscounts​(javax.money.CurrencyUnit currency)
      • removeAllAdjustments

        public void removeAllAdjustments()
        Removes all orderAdjustments from this detail. Typically called when it has been determined that another "totalitarian" offer has been applied.
      • getQuantityOfItemsExclusivelyUsedAsTargets

        protected int getQuantityOfItemsExclusivelyUsedAsTargets​(CandidateItemOffer thisOffer,
                                                                 Set<OfferDiscount> offerDiscounts,
                                                                 boolean isForQualifierQty)
        Calculates the number of order items already exclusively used as targets.

        For qualifiers, his will include:

        • The number of items already used as targets by this offer
        • The number of items already used as targets by another offer if Offer.isQualifiersCanBeTargets() is false for this offer or the other

        For targets, his will include:

        • The number of items already used as targets by this offer
        • The number of items already used as targets by another offer if Offer#isTargetsCanBeTargets() is false for that offerr
        Parameters:
        thisOffer - the offer for which we are counting the number of possible qualifiers
        offerDiscounts - the OfferDiscount DTOs containing information about items already used as targets
        Returns:
        the number of orderLineItems not already exclusively used as targets
      • isStackable

        protected boolean isStackable​(Offer offer,
                                      Offer otherOffer)
      • checkStackable

        protected boolean checkStackable​(Offer offer,
                                         Offer otherOffer)
      • getQuantityOfItemsExclusivelyUsedAsQualifiers

        protected int getQuantityOfItemsExclusivelyUsedAsQualifiers​(CandidateItemOffer thisOffer,
                                                                    Set<OfferQualifier> offerQualifiers,
                                                                    boolean isForQualifierQty)
        Calculates the number of order items already exclusively used as qualifiers.

        For qualifiers, this will include:

        • The number of items already used as qualifiers by this offer
        • The number of items already used as qualifiers by another offer if Offer.isQualifiersCanBeQualifiers() is false for this offer or the other offer

        For targets, this will include:

        • The number of items already used as qualifiers by this offer
        • The number of items already used as qualifiers by another offer if Offer.isQualifiersCanBeTargets() is false that offer
        Parameters:
        thisOffer - the offer for which we are counting the number of possible qualifiers
        offerQualifiers - the OfferQualifier DTOs containing information about items already used as qualifiers
        Returns:
        the number of orderLineItems already exclusively used as qualifiers
      • hasOrderItemAdjustments

        protected boolean hasOrderItemAdjustments()
      • chooseUnadjustedSaleOrStandardPrice

        protected void chooseUnadjustedSaleOrStandardPrice()
      • calculateSaleAdjustmentUnitPrice

        protected javax.money.MonetaryAmount calculateSaleAdjustmentUnitPrice()
      • calculateStandardAdjustmentUnitPrice

        protected javax.money.MonetaryAmount calculateStandardAdjustmentUnitPrice()
      • getAdjustedTotalUsingSalePrice

        protected javax.money.MonetaryAmount getAdjustedTotalUsingSalePrice​(javax.money.MonetaryAmount standardAdjustmentPrice)
      • getAdjustedTotalUsingStandardPrice

        protected javax.money.MonetaryAmount getAdjustedTotalUsingStandardPrice​(javax.money.MonetaryAmount standardAdjustmentPrice)
      • removeStandardOnlyAdjustments

        protected void removeStandardOnlyAdjustments()
      • removeZeroDollarAdjustments

        protected void removeZeroDollarAdjustments​(boolean useSalePrice)
      • finalizeAdjustments

        protected void finalizeAdjustments​(boolean useSaleAdjustments)
      • addNewQualifierAndGet

        protected OfferQualifier addNewQualifierAndGet​(com.broadleafcommerce.common.extension.TypeFactory offerFactory,
                                                       CandidateItemOffer itemOffer)
      • getQtyAvailableToBeUsed

        protected int getQtyAvailableToBeUsed​(CandidateItemOffer offer,
                                              boolean isForQualifierQty)
        Calculates the number of order items not already exclusively used as targets or qualifiers either by this offer or any other and, therefore, are available to be used as qualifiers or targets by the given Offer.

        Items that are not available to be qualifiers will be:

        • Items already used as targets by the given offer
        • Items already used as qualifiers by the given offer
        • Items already used as targets by another offer if Offer.isQualifiersCanBeTargets() is false for the given offer
        • Items already used as qualifiers by another offer if Offer.isQualifiersCanBeQualifiers() is false for the given offer or for the other offer

        Items that are not available to be targets will be:

        • Items already used as targets by the given offer
        • Items already used as qualifiers by the given offer
        • Items already used as targets by another offer if Offer#isTargetsCanBeTargets() is false for the given offer
        • Items already used as qualifiers by another offer if Offer.isQualifiersCanBeTargets() is false for the given offer or for the other offer
        Parameters:
        offer - the offer for which we are counting the number of possible qualifiers and targets
        isForQualifierQty - Whether this calculation is for qualifiers available or targets.
        Returns:
        the number of orderLineItems not already exclusively used as targets or qualifiers
      • addNewTargetAndGet

        protected OfferDiscount addNewTargetAndGet​(com.broadleafcommerce.common.extension.TypeFactory offerFactory,
                                                   CandidateItemOffer itemOffer)
      • getFutureCreditValue

        public javax.money.MonetaryAmount getFutureCreditValue​(javax.money.CurrencyUnit currency)
      • getBundleRatioOr1

        public double getBundleRatioOr1()
      • getQuantity

        public int getQuantity()
        The quantity of items related to this detail.
        Returns:
        The quantity of items related to this detail.
      • isAdjustmentsFinalized

        public boolean isAdjustmentsFinalized()
        Whether the adjustments are the orderAdjustments to actually use rather than being potential or incomplete.
        Returns:
        Whether the adjustments are the orderAdjustments to actually use rather than being potential or incomplete.
      • getAdjustedTotal

        public javax.money.MonetaryAmount getAdjustedTotal()
        The total value of all adjustments times the quantity of this detail.
        Returns:
        The total value of all adjustments times the quantity of this detail.
      • getBundleRatio

        public double getBundleRatio()
        The ratio of the offer discount to apply to this item. Used for bundle offers like buy 3 for a fixed price of $10.
        Returns:
        The ratio of the offer discount to apply to this item
      • setQuantity

        public void setQuantity​(int quantity)
        The quantity of items related to this detail.
        Parameters:
        quantity - The quantity of items related to this detail.
      • setAdjustmentsFinalized

        public void setAdjustmentsFinalized​(boolean adjustmentsFinalized)
        Whether the adjustments are the orderAdjustments to actually use rather than being potential or incomplete.
        Parameters:
        adjustmentsFinalized - Whether the adjustments are the orderAdjustments to actually use rather than being potential or incomplete.
      • setAdjustedTotal

        public void setAdjustedTotal​(javax.money.MonetaryAmount adjustedTotal)
        The total value of all adjustments times the quantity of this detail.
        Parameters:
        adjustedTotal - The total value of all adjustments times the quantity of this detail.
      • setBundleRatio

        public void setBundleRatio​(double bundleRatio)
        The ratio of the offer discount to apply to this item. Used for bundle offers like buy 3 for a fixed price of $10.
        Parameters:
        bundleRatio - Fraction of the offer discount amount to use for this item detail
      • canEqual

        protected boolean canEqual​(Object other)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object