Module: SolidusPromotions::DiscountedAmount

Defined in:
app/models/concerns/solidus_promotions/discounted_amount.rb

Defined Under Namespace

Classes: NotCalculatingPromotions

Instance Method Summary collapse

Instance Method Details

#current_lane_discountsArray<Spree::Adjustment,SolidusPromotions::ShippingRateDiscount>

Returns discount objects from the current promotion lane.

Returns:

Raises:



34
35
36
37
38
# File 'app/models/concerns/solidus_promotions/discounted_amount.rb', line 34

def current_lane_discounts
  raise NotCalculatingPromotions unless PromotionLane.current_lane

  discounts_by_lanes([PromotionLane.current_lane])
end

#discounted_amountBigDecimal Also known as: discountable_amount

Calculates the total discounted amount including adjustments from previous lanes.

Returns:

  • (BigDecimal)

    the sum of the current amount and all previous lane discount amounts



24
25
26
# File 'app/models/concerns/solidus_promotions/discounted_amount.rb', line 24

def discounted_amount
  amount + previous_lanes_discounts.sum(&:amount)
end