spree_payment_calculator 0.70.0 → 0.70.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,7 +9,7 @@ Basic Installation
9
9
 
10
10
  1. Add the following to your Gemfile
11
11
  <pre>
12
- gem 'spree_payment_calculator', '~> 0.70.0'
12
+ gem 'spree_payment_calculator', '~> 0.70.1'
13
13
  </pre>
14
14
  2. Run `bundle install`
15
15
  3. Go to Payment Method in the Admin panel and add a calculator for each type of payment you prefer
@@ -0,0 +1,3 @@
1
+ Gateway.class_eval do
2
+ calculated_adjustments
3
+ end
@@ -1,12 +1,6 @@
1
1
  class PaymentCalculator::FlatPercentItemTotal < Calculator
2
2
  preference :flat_percent, :decimal, :default => 0
3
-
4
- # Register the calculator
5
- def self.register
6
- super
7
- PaymentMethod.register_calculator(self)
8
- end
9
-
3
+
10
4
  def self.description
11
5
  I18n.t("flat_percent")
12
6
  end
@@ -1,12 +1,6 @@
1
1
  class PaymentCalculator::FlatRate < Calculator
2
2
  preference :amount, :decimal, :default => 0
3
-
4
- # Register the calculator
5
- def self.register
6
- super
7
- PaymentMethod.register_calculator(self)
8
- end
9
-
3
+
10
4
  def self.description
11
5
  I18n.t("flat_rate_per_order")
12
6
  end
@@ -2,13 +2,7 @@ class PaymentCalculator::FlexiRate < Calculator
2
2
  preference :first_item, :decimal, :default => 0
3
3
  preference :additional_item, :decimal, :default => 0
4
4
  preference :max_items, :decimal, :default => 0
5
-
6
- # Register the calculator
7
- def self.register
8
- super
9
- PaymentMethod.register_calculator(self)
10
- end
11
-
5
+
12
6
  def self.description
13
7
  I18n.t("flexible_rate")
14
8
  end
@@ -1,12 +1,6 @@
1
1
  class PaymentCalculator::PerItem < Calculator
2
2
  preference :amount, :decimal, :default => 0
3
-
4
- # Register the calculator
5
- def self.register
6
- super
7
- PaymentMethod.register_calculator(self)
8
- end
9
-
3
+
10
4
  def self.description
11
5
  I18n.t("flat_rate_per_item")
12
6
  end
@@ -2,13 +2,7 @@ class PaymentCalculator::PriceSack < Calculator
2
2
  preference :minimal_amount, :decimal, :default => 0
3
3
  preference :normal_amount, :decimal, :default => 0
4
4
  preference :discount_amount, :decimal, :default => 0
5
-
6
- # Register the calculator
7
- def self.register
8
- super
9
- PaymentMethod.register_calculator(self)
10
- end
11
-
5
+
12
6
  def self.description
13
7
  I18n.t("price_sack")
14
8
  end
@@ -1,3 +1,17 @@
1
1
  PaymentMethod.class_eval do
2
2
  calculated_adjustments
3
+
4
+ def self.send_calculator(id = nil)
5
+ if id
6
+ if PaymentMethod.find(id).class.to_s.match(/Gateway/)
7
+ return Gateway.calculators.sort_by(&:name)
8
+ elsif PaymentMethod.find(id).class.to_s.match(/BillingIntegration/)
9
+ return BillingIntegration.calculators.sort_by(&:name)
10
+ else
11
+ return PaymentMethod.calculators.sort_by(&:name)
12
+ end
13
+ else
14
+ return PaymentMethod.calculators.sort_by(&:name)
15
+ end
16
+ end
3
17
  end
@@ -1,5 +1,5 @@
1
1
  Deface::Override.new(:virtual_path => 'admin/payment_methods/_form',
2
2
  :name => 'add_calculators_to_payment_methods',
3
3
  :insert_before => %q{[id='preference-settings']},
4
- :text => %q{<% @calculators = PaymentMethod.calculators.sort_by(&:name) rescue nil %><%= render :partial => 'admin/shared/calculator_fields', :locals => {:f => f}},
4
+ :text => %q{<% @calculators = PaymentMethod.send_calculator(params[:id]) %><%= render :partial => 'admin/shared/calculator_fields', :locals => {:f => f}},
5
5
  :disabled => false)
@@ -11,19 +11,6 @@ module SpreePaymentCalculator
11
11
  #inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_payment_calculator\n", :before => /\*\//, :verbose => true
12
12
  #inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_payment_calculator\n", :before => /\*\//, :verbose => true
13
13
  end
14
-
15
- def add_migrations
16
- run 'bundle exec rake railties:install:migrations FROM=spree_payment_calculator'
17
- end
18
-
19
- def run_migrations
20
- res = ask "Would you like to run the migrations now? [Y/n]"
21
- if res == "" || res.downcase == "y"
22
- run 'bundle exec rake db:migrate'
23
- else
24
- puts "Skiping rake db:migrate, don't forget to run it!"
25
- end
26
- end
27
14
  end
28
15
  end
29
16
  end
@@ -17,12 +17,26 @@ module SpreePaymentCalculator
17
17
  Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
18
18
  Rails.application.config.cache_classes ? require(c) : load(c)
19
19
  end
20
-
21
- Dir.glob(File.join(File.dirname(__FILE__), "../../lib/spree/environment/calculator.rb")) do |c|
22
- Rails.application.config.cache_classes ? require(c) : load(c)
23
- end
24
20
  end
21
+
25
22
  initializer 'spree.register.calculators' do |app|
23
+ if Gem::Specification::find_by_name('spree_paypal_express')
24
+ BillingIntegration.class_eval do
25
+ calculated_adjustments
26
+ end
27
+ app.config.spree.calculators.add_class('billing_integrations')
28
+ app.config.spree.calculators.billing_integrations = [
29
+ PaymentCalculator::PriceSack,
30
+ PaymentCalculator::FlatPercentItemTotal,
31
+ PaymentCalculator::FlatRate,
32
+ PaymentCalculator::FlexiRate,
33
+ PaymentCalculator::PerItem
34
+ ]
35
+ end
36
+
37
+ app.config.spree.calculators.add_class('payment_methods')
38
+ app.config.spree.calculators.add_class('gateways')
39
+
26
40
  app.config.spree.calculators.payment_methods = [
27
41
  PaymentCalculator::PriceSack,
28
42
  PaymentCalculator::FlatPercentItemTotal,
@@ -30,6 +44,14 @@ module SpreePaymentCalculator
30
44
  PaymentCalculator::FlexiRate,
31
45
  PaymentCalculator::PerItem
32
46
  ]
47
+
48
+ app.config.spree.calculators.gateways = [
49
+ PaymentCalculator::PriceSack,
50
+ PaymentCalculator::FlatPercentItemTotal,
51
+ PaymentCalculator::FlatRate,
52
+ PaymentCalculator::FlexiRate,
53
+ PaymentCalculator::PerItem
54
+ ]
33
55
  end
34
56
 
35
57
  config.to_prepare &method(:activate).to_proc
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_payment_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.70.0
4
+ version: 0.70.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,40 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-20 00:00:00.000000000 Z
12
+ date: 2012-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 0.70.5
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 0.70.5
30
- - !ruby/object:Gem::Dependency
31
- name: spree_auth
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
19
+ - - ! '>='
36
20
  - !ruby/object:Gem::Version
37
- version: 0.70.5
21
+ version: '0'
38
22
  type: :runtime
39
23
  prerelease: false
40
24
  version_requirements: !ruby/object:Gem::Requirement
41
25
  none: false
42
26
  requirements:
43
- - - ~>
27
+ - - ! '>='
44
28
  - !ruby/object:Gem::Version
45
- version: 0.70.5
29
+ version: '0'
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: rspec-rails
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -68,13 +52,13 @@ files:
68
52
  - README.md
69
53
  - LICENSE
70
54
  - lib/generators/spree_payment_calculator/install/install_generator.rb
71
- - lib/spree/environment/calculators.rb
72
55
  - lib/spree_payment_calculator/engine.rb
73
56
  - lib/spree_payment_calculator.rb
74
57
  - app/assets/javascripts/admin/spree_payment_calculator.js
75
58
  - app/assets/javascripts/store/spree_payment_calculator.js
76
59
  - app/assets/stylesheets/admin/spree_payment_calculator.css
77
60
  - app/assets/stylesheets/store/spree_payment_calculator.css
61
+ - app/model/gateway_decorator.rb
78
62
  - app/model/payment_calculator/flat_percent_item_total.rb
79
63
  - app/model/payment_calculator/flat_rate.rb
80
64
  - app/model/payment_calculator/flexi_rate.rb
@@ -1,9 +0,0 @@
1
- module Spree
2
- class Environment
3
- class Calculators
4
- include EnvironmentExtension
5
-
6
- attr_accessor :shipping_methods, :tax_rates, :payment_methods
7
- end
8
- end
9
- end