spree_payment_calculator 1.0.0 → 1.0.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', '~> 1.0.0'
12
+ gem 'spree_payment_calculator', '~> 1.0.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
+ Spree::Gateway.class_eval do
2
+ calculated_adjustments
3
+ end
@@ -1,3 +1,17 @@
1
1
  Spree::PaymentMethod.class_eval do
2
2
  calculated_adjustments
3
+
4
+ def self.send_calculator(id = nil)
5
+ if id
6
+ if Spree::PaymentMethod.find(id).class.to_s.match(/Gateway/)
7
+ return Spree::Gateway.calculators.sort_by(&:name)
8
+ elsif Spree::PaymentMethod.find(id).class.to_s.match(/BillingIntegration/)
9
+ return Spree::BillingIntegration.calculators.sort_by(&:name)
10
+ else
11
+ return Spree::PaymentMethod.calculators.sort_by(&:name)
12
+ end
13
+ else
14
+ return Spree::PaymentMethod.calculators.sort_by(&:name)
15
+ end
16
+ end
3
17
  end
@@ -1,5 +1,5 @@
1
1
  Deface::Override.new(:virtual_path => 'spree/admin/payment_methods/_form',
2
2
  :name => 'add_calculators_to_payment_methods',
3
3
  :insert_before => %q{[id='preference-settings']},
4
- :text => %q{<% @calculators = Spree::PaymentMethod.calculators.sort_by(&:name) rescue nil %><%= render :partial => 'spree/admin/shared/calculator_fields', :locals => {:f => f}},
4
+ :text => %q{<% @calculators = Spree::PaymentMethod.send_calculator(params[:id]) %><%= render :partial => 'spree/admin/shared/calculator_fields', :locals => {:f => f}},
5
5
  :disabled => false)
@@ -17,14 +17,35 @@ 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
+ Spree::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
- PaymentCalculator::DefaultTax,
41
+ PaymentCalculator::PriceSack,
42
+ PaymentCalculator::FlatPercentItemTotal,
43
+ PaymentCalculator::FlatRate,
44
+ PaymentCalculator::FlexiRate,
45
+ PaymentCalculator::PerItem
46
+ ]
47
+
48
+ app.config.spree.calculators.gateways = [
28
49
  PaymentCalculator::PriceSack,
29
50
  PaymentCalculator::FlatPercentItemTotal,
30
51
  PaymentCalculator::FlatRate,
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: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-12 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
@@ -59,6 +59,7 @@ files:
59
59
  - app/assets/javascripts/store/spree_payment_calculator.js
60
60
  - app/assets/stylesheets/admin/spree_payment_calculator.css
61
61
  - app/assets/stylesheets/store/spree_payment_calculator.css
62
+ - app/model/spree/gateway_decorator.rb
62
63
  - app/model/spree/payment_calculator/default_tax.rb
63
64
  - app/model/spree/payment_calculator/flat_percent_item_total.rb
64
65
  - app/model/spree/payment_calculator/flat_rate.rb