Sha256: a6d6cd9b8810d019a2391f8f4e47c64b03938544478b405c97d64adaa580f951

Contents?: true

Size: 401 Bytes

Versions: 6

Compression:

Stored size: 401 Bytes

Contents

module Spree
  class LoyaltyPointsDebitTransaction < LoyaltyPointsTransaction
    after_create :update_user_balance
    before_create :update_balance

    private

      def update_user_balance
        user.decrement(:loyalty_points_balance, loyalty_points)
        user.save!
      end

      def update_balance
        self.balance = user.loyalty_points_balance - loyalty_points
      end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
spree_loyalty_points-1.1.1 app/models/spree/loyalty_points_debit_transaction.rb
spree_loyalty_points-1.0.3 app/models/spree/loyalty_points_debit_transaction.rb
spree_loyalty_points-1.1.0 app/models/spree/loyalty_points_debit_transaction.rb
spree_loyalty_points-1.0.2 app/models/spree/loyalty_points_debit_transaction.rb
spree_loyalty_points-1.0.1 app/models/spree/loyalty_points_debit_transaction.rb
spree_loyalty_points-1.0.0 app/models/spree/loyalty_points_debit_transaction.rb