Sha256: 446e223932d0832bb73681921259d0f18f0a19e1352273de426bbc25b9e3dcd5

Contents?: true

Size: 950 Bytes

Versions: 1

Compression:

Stored size: 950 Bytes

Contents

Spree::Order.class_eval do
  money_methods :order_adjustment_total

  # Make sure the order confirmation is delivered when the order has been paid for.
  def finalize!
    # lock all adjustments (coupon promotions, etc.)
    all_adjustments.each(&:close)

    # update payment and shipment(s) states, and save
    updater.update_payment_state
    shipments.each do |shipment|
      shipment.update!(self)
      shipment.finalize! if paid? || authorized?
    end

    updater.update_shipment_state
    save!
    updater.run_hooks

    touch :completed_at

    if !confirmation_delivered? && (paid? || authorized?)
      deliver_order_confirmation_email
    end

    consider_risk
  end

  def mollie_order
    Spree::Mollie::Order.new(self)
  end

  def authorized?
    payments.last.authorized?
  end

  def order_adjustment_total
    adjustments.eligible.sum(:amount)
  end

  def has_order_adjustments?
    order_adjustment_total.abs > 0
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_mollie_gateway-3.0.0.pre.beta app/models/spree/order_decorator.rb