Skip to content

Commit

Permalink
Fix documentation in persist_discounted_order.rb
Browse files Browse the repository at this point in the history
Much of this code has been lifted from some tax abstraction in core, and
some of the comments had not been updated.
  • Loading branch information
mamhoff committed Oct 25, 2024
1 parent 471db28 commit 4c75a16
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def call
attr_reader :order

# Walk through the discounts for an item and update adjustments for it. Once
# all of the discounts have been added as adjustments, remove any old tax
# all of the discounts have been added as adjustments, remove any old promotion
# adjustments that weren't touched.
#
# @private
Expand All @@ -49,18 +49,18 @@ def update_adjustments(item, item_discounts)
update_adjustment(item, item_discount)
end
item.update(promo_total: active_adjustments.sum(&:amount))
# Remove any tax adjustments tied to promotion benefits which no longer match.
# Remove any promotion adjustments tied to promotion benefits which no longer match.
unmatched_adjustments = promotion_adjustments - active_adjustments

item.adjustments.destroy(unmatched_adjustments)
end

# Update or create a new tax adjustment on an item.
# Update or create a new promotion adjustment on an item.
#
# @private
# @param [#adjustments] item a {Spree::LineItem} or {Spree::Shipment}
# @param [SolidusPromotions::ItemDiscount] tax_item calculated discounts for an item
# @return [Spree::Adjustment] the created or updated tax adjustment
# @param [SolidusPromotions::ItemDiscount] discount_item calculated discounts for an item
# @return [Spree::Adjustment] the created or updated promotion adjustment
def update_adjustment(item, discount_item)
adjustment = item.adjustments.detect do |item_adjustment|
item_adjustment.source == discount_item.source
Expand Down

0 comments on commit 4c75a16

Please sign in to comment.