Sha256: ae3340c412f324f537709b3809e0d4ee47fbbf5334588575f1e0dfb5ba02e661

Contents?: true

Size: 402 Bytes

Versions: 6

Compression:

Stored size: 402 Bytes

Contents

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

    private

      def update_user_balance
        user.increment(: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_credit_transaction.rb
spree_loyalty_points-1.0.3 app/models/spree/loyalty_points_credit_transaction.rb
spree_loyalty_points-1.1.0 app/models/spree/loyalty_points_credit_transaction.rb
spree_loyalty_points-1.0.2 app/models/spree/loyalty_points_credit_transaction.rb
spree_loyalty_points-1.0.1 app/models/spree/loyalty_points_credit_transaction.rb
spree_loyalty_points-1.0.0 app/models/spree/loyalty_points_credit_transaction.rb