spree_loyalty_points 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Spree Loyalty Points [![Code Climate](https://codeclimate.com/github/vinsol/spree-loyalty-points.png)](https://codeclimate.com/github/vinsol/spree-loyalty-points) [![Build Status](https://travis-ci.org/vinsol/spree-loyalty-points.png?branch=master)](https://travis-ci.org/vinsol/spree-loyalty-points)
|
2
2
|
====================
|
3
3
|
|
4
|
-
This extension adds Loyalty Points for users.
|
4
|
+
This extension adds Loyalty Points for users in Spree.
|
5
5
|
|
6
6
|
|
7
7
|
Installation
|
@@ -14,17 +14,17 @@ gem 'spree_loyalty_points'
|
|
14
14
|
```
|
15
15
|
|
16
16
|
For Spree 2.1.x:
|
17
|
-
|
18
17
|
```ruby
|
19
|
-
gem 'spree_loyalty_points', '1.0.
|
18
|
+
gem 'spree_loyalty_points', '1.0.3'
|
20
19
|
```
|
21
20
|
|
21
|
+
At present this extention is not compatible with Spree 2.0.x
|
22
|
+
|
22
23
|
Bundle your dependencies and run the installation generator:
|
23
24
|
|
24
25
|
```shell
|
25
26
|
bundle
|
26
27
|
bundle exec rails g spree_loyalty_points:install
|
27
|
-
bundle exec rake db:migrate
|
28
28
|
```
|
29
29
|
|
30
30
|
Usage
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'active_support/concern'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
class Payment
|
4
|
+
class Payment
|
5
5
|
module LoyaltyPoints
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
@@ -20,9 +20,7 @@ module Spree
|
|
20
20
|
|
21
21
|
def redeem_loyalty_points
|
22
22
|
loyalty_points_redeemed = loyalty_points_for(amount, 'redeem')
|
23
|
-
|
24
|
-
order.create_debit_transaction(loyalty_points_redeemed)
|
25
|
-
end
|
23
|
+
order.create_debit_transaction(loyalty_points_redeemed)
|
26
24
|
end
|
27
25
|
|
28
26
|
def return_loyalty_points
|
@@ -35,7 +33,14 @@ module Spree
|
|
35
33
|
end
|
36
34
|
|
37
35
|
def redeemable_loyalty_points_balance?
|
38
|
-
|
36
|
+
order.user.loyalty_points_balance >= Spree::Config.loyalty_points_redeeming_balance
|
37
|
+
end
|
38
|
+
|
39
|
+
def redeemable_user_balance
|
40
|
+
unless redeemable_loyalty_points_balance?
|
41
|
+
min_balance = Spree::Config.loyalty_points_redeeming_balance
|
42
|
+
errors.add :loyalty_points_balance, "should be atleast #{ min_balance.to_s + " " + "point".pluralize(min_balance) } for redeeming Loyalty Points"
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
end
|
@@ -4,6 +4,7 @@ Spree::Payment.class_eval do
|
|
4
4
|
include Spree::Payment::LoyaltyPoints
|
5
5
|
|
6
6
|
validates :amount, numericality: { greater_than: 0 }, :if => :by_loyalty_points?
|
7
|
+
validate :redeemable_user_balance, :if => :by_loyalty_points?
|
7
8
|
scope :state_not, ->(s) { where('state != ?', s) }
|
8
9
|
|
9
10
|
fsm = self.state_machines[:state]
|
@@ -12,14 +13,14 @@ Spree::Payment.class_eval do
|
|
12
13
|
fsm.after_transition :from => fsm.states.map(&:name) - [:completed], :to => [:completed], :do => :redeem_loyalty_points, :if => :by_loyalty_points?
|
13
14
|
fsm.after_transition :from => [:completed], :to => fsm.states.map(&:name) - [:completed] , :do => :return_loyalty_points, :if => :by_loyalty_points?
|
14
15
|
|
15
|
-
def invalidate_old_payments
|
16
|
-
order.payments.with_state('checkout').where("id != ?", self.id).each do |payment|
|
17
|
-
payment.invalidate!
|
18
|
-
end unless by_loyalty_points?
|
19
|
-
end
|
20
|
-
|
21
16
|
private
|
22
17
|
|
18
|
+
def invalidate_old_payments
|
19
|
+
order.payments.with_state('checkout').where("id != ?", self.id).each do |payment|
|
20
|
+
payment.invalidate!
|
21
|
+
end unless by_loyalty_points?
|
22
|
+
end
|
23
|
+
|
23
24
|
def notify_paid_order
|
24
25
|
if all_payments_completed?
|
25
26
|
order.touch :paid_at
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class AddLockVersionToSpreeUser < ActiveRecord::Migration
|
2
2
|
def change
|
3
|
-
add_column :spree_users, :lock_version, :integer, default: 0, null: false
|
3
|
+
add_column :spree_users, :lock_version, :integer, default: 0, null: false unless column_exists?(:spree_users, :lock_version)
|
4
4
|
end
|
5
5
|
end
|
metadata
CHANGED
@@ -1,47 +1,39 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_loyalty_points
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 0
|
10
|
-
version: 1.1.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jatin Baweja
|
14
9
|
- Sushant Mittal
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: spree_core
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
19
|
+
requirements:
|
27
20
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 2
|
33
|
-
version: "2.2"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.2'
|
34
23
|
type: :runtime
|
35
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '2.2'
|
36
31
|
description: To award loyalty points and add loyalty points payment method to spree
|
37
32
|
email: info@vinsol.com
|
38
33
|
executables: []
|
39
|
-
|
40
34
|
extensions: []
|
41
|
-
|
42
35
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
36
|
+
files:
|
45
37
|
- LICENSE
|
46
38
|
- README.md
|
47
39
|
- app/assets/javascripts/spree/backend/spree_loyalty_points.js
|
@@ -105,39 +97,29 @@ files:
|
|
105
97
|
- db/migrate/20140205111553_add_transaction_id_to_spree_loyalty_points_transactions.rb
|
106
98
|
- db/migrate/20140207055836_add_lock_version_to_spree_user.rb
|
107
99
|
homepage: http://vinsol.com
|
108
|
-
licenses:
|
100
|
+
licenses:
|
109
101
|
- MIT
|
110
102
|
post_install_message:
|
111
103
|
rdoc_options: []
|
112
|
-
|
113
|
-
require_paths:
|
104
|
+
require_paths:
|
114
105
|
- lib
|
115
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
107
|
none: false
|
117
|
-
requirements:
|
118
|
-
- -
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
hash: 53
|
121
|
-
segments:
|
122
|
-
- 1
|
123
|
-
- 9
|
124
|
-
- 3
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
125
111
|
version: 1.9.3
|
126
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
113
|
none: false
|
128
|
-
requirements:
|
129
|
-
- -
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
|
132
|
-
|
133
|
-
- 0
|
134
|
-
version: "0"
|
135
|
-
requirements:
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements:
|
136
119
|
- none
|
137
120
|
rubyforge_project:
|
138
|
-
rubygems_version: 1.8.
|
121
|
+
rubygems_version: 1.8.23
|
139
122
|
signing_key:
|
140
123
|
specification_version: 3
|
141
124
|
summary: Add loyalty points to spree
|
142
125
|
test_files: []
|
143
|
-
|