Sha256: 86088f3e585dcd16e2712ca40d28cdf3d3abcfa82ba390a745820aa1211f1dd3

Contents?: true

Size: 555 Bytes

Versions: 1

Compression:

Stored size: 555 Bytes

Contents

class OrderPromote < ApplicationRecord
  belongs_to :order, inverse_of: :order_promotes
  belongs_to :order_item, optional: true
  belongs_to :promote
  belongs_to :promote_charge, optional: true

  after_update_commit :sync_amount, if: -> { saved_change_to_amount? }

  def sync_amount
    if self.order_item_id.nil?
      order.compute_sum
      order.save
    else
      order_item.compute_sum
      order_item.save
    end
  end

end unless RailsTrade.config.disabled_models.include?('OrderPromtote')

# :order_id, :integer
# :order_item_id :integer

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_trade-0.0.1 app/models/rails_trade/order_promote.rb