Class SubscriptionItemPriceDetail

java.lang.Object
com.broadleafcommerce.subscriptionoperation.domain.SubscriptionItemPriceDetail
All Implemented Interfaces:
Serializable

public class SubscriptionItemPriceDetail extends Object implements Serializable
Describes the amount being charged for this item. This may be an amount due now, or a future payment.
See Also:
  • Constructor Details

    • SubscriptionItemPriceDetail

      public SubscriptionItemPriceDetail()
  • Method Details

    • addAttribute

      public void addAttribute(String name, Object value)
      Takes in any additional attributes passed in the request not matching any defined properties.
      Parameters:
      name - Name of the additional attribute
      value - Value of the additional attribute
    • getAttribute

      public Map<String,Object> getAttribute()
      Return any additional attributes passed in the request not matching any defined properties.
      Returns:
      any additional attributes passed in the request not matching any defined properties.
    • getEffectiveQuantityForPricing

      public Integer getEffectiveQuantityForPricing()
      Gathers the item's quantity, considering the getDueNowQuantityOverride() if it's non-null.
      Returns:
      The getDueNowQuantityOverride() if non-null. Otherwise, the getQuantity().
    • getAdjustmentPriceDetails

      public List<SubscriptionItemAdjustmentPriceDetail> getAdjustmentPriceDetails()
    • getItemSubtotal

      public javax.money.MonetaryAmount getItemSubtotal()
      Gathers the itemSubtotal, which is equal to getProratedAmount() + getPriorUnbilledAmount() - getCreditedAmount().

      Note: Keep in mind that the getProratedAmount() is based on a unit price that's scaled based on the item's new quantity, whereas the getPriorUnbilledAmount() & getCreditedAmount() are based on unit prices that are scaled based on the item's previous quantity.

      Returns:
      the item subtotal.
    • getProratedAmount

      public javax.money.MonetaryAmount getProratedAmount()
      Gathers the prorated portion of the item subtotal, which is based on the getProratedUnitAmount(). This unit amount is scaled by the getDueNowQuantityOverride() if it's present. Otherwise, the unit amount is scaled by the getQuantity().

      It is calculated as follows: (getProratedUnitAmount() * getEffectiveQuantityForPricing()) - getProratedDiscountAmount().

      Returns:
      the prorated portion of the item subtotal.
    • getProratedDiscountAmount

      public javax.money.MonetaryAmount getProratedDiscountAmount()
      Gathers the prorated discount amount, which is the total discount offered on the prorated price which is prorated relative to the next invoice date. For a new purchase, this reflects the full date range. For edits, upgrades, and downgrades, this reflects the prorated price between the action date and the end of the billing period.

      It is calculated as follows: (SubscriptionItemAdjustmentPriceDetail.getProratedUnitDiscountAmount() * getItemAdjustmentQuantity(SubscriptionItemAdjustmentPriceDetail, String).

      Returns:
      the prorated discounted amount.
    • getCreditedAmount

      public javax.money.MonetaryAmount getCreditedAmount()
      Gathers the credited portion of the item subtotal, which is based on the getCreditedUnitAmount(). This unit amount is scaled by the getExistingSubscriptionItemQuantity().

      It is calculated as follows: (getCreditedUnitAmount() * getEffectiveQuantityForPricing(String)) - getCreditedDiscountAmount().

      Returns:
      the credited portion of the item subtotal.
    • getCreditedDiscountAmount

      public javax.money.MonetaryAmount getCreditedDiscountAmount()
      Gathers the credited discount amount, which is the total discount offered on the credited price. It is mainly used in the prepaid flows.

      It is calculated as follows: SubscriptionItemAdjustmentPriceDetail.getCreditedUnitDiscountAmount() * getItemAdjustmentQuantity(SubscriptionItemAdjustmentPriceDetail, String)

      Returns:
      the credited discounted amount.
    • getPriorUnbilledAmount

      public javax.money.MonetaryAmount getPriorUnbilledAmount()
      Returns:
      the prior unbilled portion of the item subtotal.
    • getChargeForPreviouslyReceivedDiscountedPeriods

      public javax.money.MonetaryAmount getChargeForPreviouslyReceivedDiscountedPeriods()
      Gathers the charge for previously received discounted periods based on the cancellation policy.

      It is calculated as follows: SubscriptionItemAdjustmentPriceDetail.getUnitChargeForPreviouslyDiscountedPeriods() * getItemAdjustmentQuantity(SubscriptionItemAdjustmentPriceDetail, String)

      Returns:
      the amount charged for previous discounts.
    • getPriorUnbilledDiscountAmount

      public javax.money.MonetaryAmount getPriorUnbilledDiscountAmount()
      Gathers the prior unbilled discount amount, which is the total discount offered on the prior unbilled price.

      It is calculated as follows: SubscriptionItemAdjustmentPriceDetail.getPriorUnbilledUnitDiscountAmount() * getItemAdjustmentQuantity(SubscriptionItemAdjustmentPriceDetail, String)

      Returns:
      the prior unbilled discounted amount.
    • getRemainderOfTermsDiscountAmount

      public javax.money.MonetaryAmount getRemainderOfTermsDiscountAmount()
      Gathers the remainder of terms discount amount, which is the total discount offered on the remainder of terms price.

      It is calculated as follows: SubscriptionItemAdjustmentPriceDetail.getUnitDiscountAmountForRemainderOfTerms() * getItemAdjustmentQuantity(SubscriptionItemAdjustmentPriceDetail, String)

      Returns:
      the remainder of terms discounted amount.
    • getItemAdjustmentQuantity

      protected <T extends SubscriptionItemAdjustmentPriceDetail> int getItemAdjustmentQuantity(@NonNull T itemAdjustmentDetail, @NonNull @NonNull String priceDetailType)
      The effective quantity of the items that are receiving the adjustment/discount. For the prorated unit discount amount, it uses the quantity after the subscription action.
      Parameters:
      itemAdjustmentDetail - the item adjustment detail that contains the quantity information
      priceDetailType - the type of price detail being calculated, e.g. "PRORATED_UNIT_DISCOUNT_AMOUNT"
      Returns:
      the effective quantity of discounted items based on the price detail type
    • getEffectiveQuantityForPricing

      protected Integer getEffectiveQuantityForPricing(@NonNull @NonNull String priceDetailType)
      Different prices use different item quantities in their calculations. This method assists in getting the correct quantity to use when calculating the subtotal for that price type. For example, the getProratedAmount() is based on a unit price that's scaled based on the item's new quantity, whereas the getPriorUnbilledAmount() & getCreditedAmount() are based on unit prices that are scaled based on the item's previous quantity.
      Returns:
      the item quantity related to the given price detail type
    • getCartItemId

      public String getCartItemId()
      Reference to the subscription CartItem. If the subscription item has been removed as part of the action, then this value will be null.
    • getItemRefType

      public String getItemRefType()
      Type of item that this object represents. For example, BLC_PRODUCT.
    • getItemRef

      public String getItemRef()
      Reference to the id of the item represented by this object. For example, the product id.
    • getItemName

      public String getItemName()
      Name of the item identified by getItemRefType() & getItemRef().
    • getParentItemRefType

      public String getParentItemRefType()
      Type of the parent subscription item's backing item if this is a child subscription item
    • getParentItemRef

      public String getParentItemRef()
      Reference of the parent subscription item's backing item if this is a child subscription item
    • getParentQuantity

      public Integer getParentQuantity()
      The item's parent quantity following the subscription action (e.g. create, edit, upgrade, downgrade, etc.).

      This is typically used to scale a dependent item's quantity based on its parent for calculating subtotals.

    • getParentExistingQuantity

      public Integer getParentExistingQuantity()
      The item's parent existing quantity prior to the subscription action (e.g. create, edit, upgrade, downgrade, etc.).

      This is typically used to scale a dependent item's quantity based on its parent for calculating subtotals.

    • getFullSubscriptionPeriodUnitAmount

      public javax.money.MonetaryAmount getFullSubscriptionPeriodUnitAmount()
      The unit price of the item (price of one) for the length of a full subscription period. This serves an informational purpose for downstream services.

      For net new signups, it's just the typical recurring price.

    • getProratedUnitAmountBetweenPeriodStartAndActionDate

      public javax.money.MonetaryAmount getProratedUnitAmountBetweenPeriodStartAndActionDate()
      The subscription item price per unit prorated for the period between the period start date and the action date and the regardless of the subscription action being taken or the payment strategy. This serves as informational purposes for downstream services.

      For example, if a subscription's typical recurring price is $30/month and the subscription sign up date is on 4/1, the action date is on 4/11, and the next bill date is on 5/1, the prorated unit amount between the period start date and the action date would be $10.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • getProratedUnitAmountBetweenActionAndNextBillDate

      public javax.money.MonetaryAmount getProratedUnitAmountBetweenActionAndNextBillDate()
      The subscription item price per unit prorated for the period between the action date and the next invoice date regardless of the subscription action being taken or the payment strategy. This serves as informational purposes for downstream services.

      For example, if a subscription's typical recurring price is $30/month and the subscription sign up date is on 4/1, the action date is on 4/11, and the next bill date is on 5/1, the prorated unit amount between the action date and the next bill date would be $20.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • getProratedUnitAmount

      public javax.money.MonetaryAmount getProratedUnitAmount()
      The subscription item price per unit, prorated relative to the next invoice date. For a new purchase, this reflects the full date range. For edits, upgrades, & downgrades, this reflects the prorated price between the action & the end of the billing period.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • getCreditedUnitAmount

      public javax.money.MonetaryAmount getCreditedUnitAmount()
      For edits, upgrades, and downgrades on a subscription that’s using an DefaultSubscriptionPaymentStrategy.PREPAID payment strategy, the customer has already paid the full amount for this billing cycle at the previous rate.

      For example, consider a customer who is upgrading from 10 to 20 licenses at $1 each half-way through a 30-day month. The user prorated amount would be $10 for 20 licenses. This user has already partially paid for 10 of the licenses, so they will be due a credit of $5 toward the second-half-of-the-month amount.

      Note: This typically only impacts the first period in the estimatedFuturePayments list.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • getPriorUnbilledUnitAmount

      public javax.money.MonetaryAmount getPriorUnbilledUnitAmount()
      Prior to an edit, upgrade, or downgrade on a subscription that’s using a Postpaid payment strategy, the system will have prior unbilled charges that will be part of the next invoice. In this case, the user will owe this in addition to the prorated charges for the changes being made.

      For example, consider a customer who is upgrading from 10 to 20 licenses at $1 each half-way through a 30-day month. The user prorated amount would be $10 for 20 licenses. This user also owes $5 for access to the 10 licenses in the first half of the month.

      Note: This typically only impacts the first period in the estimatedFuturePayments list.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • getRemainderOfTermsUnitAmount

      public javax.money.MonetaryAmount getRemainderOfTermsUnitAmount()
      The unit amount to charge for the remainder of terms if the remainder of terms is being charged.

      Note: This typically only impacts the first period in the estimatedFuturePayments list.

    • getQuantity

      public Integer getQuantity()
      The item's quantity following the subscription action (e.g. create, edit, upgrade, downgrade, etc.).
    • getDueNowQuantityOverride

      public Integer getDueNowQuantityOverride()
      An item's quantity override value used for "due now" price calculations where the item's quantity decreased due to the subscription action.
    • getExistingSubscriptionItemId

      public String getExistingSubscriptionItemId()
      The existing subscription item's id prior the subscription action (e.g. edit, upgrade, downgrade, etc.).
    • getExistingSubscriptionItemQuantity

      public Integer getExistingSubscriptionItemQuantity()
      The existing subscription item's quantity prior the subscription action (e.g. edit, upgrade, downgrade, etc.).
    • getExistingSubscriptionItemUnitPrice

      @Nullable public javax.money.MonetaryAmount getExistingSubscriptionItemUnitPrice()
      The existing subscription item's unit price prior the subscription action (e.g. edit, upgrade, downgrade, etc.).
    • getCurrency

      public javax.money.CurrencyUnit getCurrency()
      Currency of this subscription
    • getAttributes

      public Map<String,Object> getAttributes()
      Map holding any additional attributes passed in the request not matching any defined properties.
    • getAdjustmentPriceDetailsByAdjustmentRef

      public Map<String,SubscriptionItemAdjustmentPriceDetail> getAdjustmentPriceDetailsByAdjustmentRef()
      The map of SubscriptionItemAdjustmentPriceDetail by adjustment reference, containing the details about how the discount affects the prorated unit amount, credited amount, and prior unbilled amount.
    • setCartItemId

      public void setCartItemId(String cartItemId)
      Reference to the subscription CartItem. If the subscription item has been removed as part of the action, then this value will be null.
    • setItemRefType

      public void setItemRefType(String itemRefType)
      Type of item that this object represents. For example, BLC_PRODUCT.
    • setItemRef

      public void setItemRef(String itemRef)
      Reference to the id of the item represented by this object. For example, the product id.
    • setItemName

      public void setItemName(String itemName)
      Name of the item identified by getItemRefType() & getItemRef().
    • setParentItemRefType

      public void setParentItemRefType(String parentItemRefType)
      Type of the parent subscription item's backing item if this is a child subscription item
    • setParentItemRef

      public void setParentItemRef(String parentItemRef)
      Reference of the parent subscription item's backing item if this is a child subscription item
    • setParentQuantity

      public void setParentQuantity(Integer parentQuantity)
      The item's parent quantity following the subscription action (e.g. create, edit, upgrade, downgrade, etc.).

      This is typically used to scale a dependent item's quantity based on its parent for calculating subtotals.

    • setParentExistingQuantity

      public void setParentExistingQuantity(Integer parentExistingQuantity)
      The item's parent existing quantity prior to the subscription action (e.g. create, edit, upgrade, downgrade, etc.).

      This is typically used to scale a dependent item's quantity based on its parent for calculating subtotals.

    • setFullSubscriptionPeriodUnitAmount

      public void setFullSubscriptionPeriodUnitAmount(javax.money.MonetaryAmount fullSubscriptionPeriodUnitAmount)
      The unit price of the item (price of one) for the length of a full subscription period. This serves an informational purpose for downstream services.

      For net new signups, it's just the typical recurring price.

    • setProratedUnitAmountBetweenPeriodStartAndActionDate

      public void setProratedUnitAmountBetweenPeriodStartAndActionDate(javax.money.MonetaryAmount proratedUnitAmountBetweenPeriodStartAndActionDate)
      The subscription item price per unit prorated for the period between the period start date and the action date and the regardless of the subscription action being taken or the payment strategy. This serves as informational purposes for downstream services.

      For example, if a subscription's typical recurring price is $30/month and the subscription sign up date is on 4/1, the action date is on 4/11, and the next bill date is on 5/1, the prorated unit amount between the period start date and the action date would be $10.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • setProratedUnitAmountBetweenActionAndNextBillDate

      public void setProratedUnitAmountBetweenActionAndNextBillDate(javax.money.MonetaryAmount proratedUnitAmountBetweenActionAndNextBillDate)
      The subscription item price per unit prorated for the period between the action date and the next invoice date regardless of the subscription action being taken or the payment strategy. This serves as informational purposes for downstream services.

      For example, if a subscription's typical recurring price is $30/month and the subscription sign up date is on 4/1, the action date is on 4/11, and the next bill date is on 5/1, the prorated unit amount between the action date and the next bill date would be $20.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • setProratedUnitAmount

      public void setProratedUnitAmount(javax.money.MonetaryAmount proratedUnitAmount)
      The subscription item price per unit, prorated relative to the next invoice date. For a new purchase, this reflects the full date range. For edits, upgrades, & downgrades, this reflects the prorated price between the action & the end of the billing period.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • setCreditedUnitAmount

      public void setCreditedUnitAmount(javax.money.MonetaryAmount creditedUnitAmount)
      For edits, upgrades, and downgrades on a subscription that’s using an DefaultSubscriptionPaymentStrategy.PREPAID payment strategy, the customer has already paid the full amount for this billing cycle at the previous rate.

      For example, consider a customer who is upgrading from 10 to 20 licenses at $1 each half-way through a 30-day month. The user prorated amount would be $10 for 20 licenses. This user has already partially paid for 10 of the licenses, so they will be due a credit of $5 toward the second-half-of-the-month amount.

      Note: This typically only impacts the first period in the estimatedFuturePayments list.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • setPriorUnbilledUnitAmount

      public void setPriorUnbilledUnitAmount(javax.money.MonetaryAmount priorUnbilledUnitAmount)
      Prior to an edit, upgrade, or downgrade on a subscription that’s using a Postpaid payment strategy, the system will have prior unbilled charges that will be part of the next invoice. In this case, the user will owe this in addition to the prorated charges for the changes being made.

      For example, consider a customer who is upgrading from 10 to 20 licenses at $1 each half-way through a 30-day month. The user prorated amount would be $10 for 20 licenses. This user also owes $5 for access to the 10 licenses in the first half of the month.

      Note: This typically only impacts the first period in the estimatedFuturePayments list.

      Note that this is the price per unit not including discounts, discounts are recorded in getAdjustmentPriceDetailsByAdjustmentRef()

    • setRemainderOfTermsUnitAmount

      public void setRemainderOfTermsUnitAmount(javax.money.MonetaryAmount remainderOfTermsUnitAmount)
      The unit amount to charge for the remainder of terms if the remainder of terms is being charged.

      Note: This typically only impacts the first period in the estimatedFuturePayments list.

    • setQuantity

      public void setQuantity(Integer quantity)
      The item's quantity following the subscription action (e.g. create, edit, upgrade, downgrade, etc.).
    • setDueNowQuantityOverride

      public void setDueNowQuantityOverride(Integer dueNowQuantityOverride)
      An item's quantity override value used for "due now" price calculations where the item's quantity decreased due to the subscription action.
    • setExistingSubscriptionItemId

      public void setExistingSubscriptionItemId(String existingSubscriptionItemId)
      The existing subscription item's id prior the subscription action (e.g. edit, upgrade, downgrade, etc.).
    • setExistingSubscriptionItemQuantity

      public void setExistingSubscriptionItemQuantity(Integer existingSubscriptionItemQuantity)
      The existing subscription item's quantity prior the subscription action (e.g. edit, upgrade, downgrade, etc.).
    • setExistingSubscriptionItemUnitPrice

      public void setExistingSubscriptionItemUnitPrice(@Nullable javax.money.MonetaryAmount existingSubscriptionItemUnitPrice)
      The existing subscription item's unit price prior the subscription action (e.g. edit, upgrade, downgrade, etc.).
    • setCurrency

      public void setCurrency(javax.money.CurrencyUnit currency)
      Currency of this subscription
    • setAttributes

      public void setAttributes(Map<String,Object> attributes)
      Map holding any additional attributes passed in the request not matching any defined properties.
    • setAdjustmentPriceDetailsByAdjustmentRef

      public void setAdjustmentPriceDetailsByAdjustmentRef(Map<String,SubscriptionItemAdjustmentPriceDetail> adjustmentPriceDetailsByAdjustmentRef)
      The map of SubscriptionItemAdjustmentPriceDetail by adjustment reference, containing the details about how the discount affects the prorated unit amount, credited amount, and prior unbilled amount.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object