effective_orders 1.6.3 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93008369c9c4018e92a6605bde7b37c1d1952992
4
- data.tar.gz: b9ec1fdfc02964bd077a3c1b8a1eccaab7d6b112
3
+ metadata.gz: 34511876560d7a99a31838f447cbfadc4a30c70c
4
+ data.tar.gz: a5d30c4367be050345e227f33790c39a82b04729
5
5
  SHA512:
6
- metadata.gz: e2bab85ac8f6749f4b081b44198c6476323a082e9768001a4b3ee4ff81718a48f0fd9dafb7240e69f4f6b4a8fe5ee29452b2f6c3878868f771417c85293037db
7
- data.tar.gz: f1edea1ec59980aee87fac9cf2652a41f50de0cb78f29d69cac937bda0c98f57605fca429d5c5fae3a0ddfd03faf38b3a4441282c924b3e9f079864918e1bc09
6
+ metadata.gz: 9509286115a6fdcb802c962b777aab0d4a6d8950c34620b11b48b7c0ec138e2e87892ffdddb07efb89de171c2a07565e7d1ac40c3b2bcdc456bfaa86c7ccbd42
7
+ data.tar.gz: 2dfca854a6115611fdfceb10629780a1128adc2f3a022cb4f49e44c96715f2f1bf171cfcc83ba1770d84f1c85f39d20b10e84691fee1a4a4e37033614a569fa2
@@ -18,7 +18,9 @@ if defined?(ActiveAdmin)
18
18
  include EffectiveOrdersHelper
19
19
 
20
20
  def scoped_collection
21
- end_of_association_chain.includes(:user).includes(order_items: :purchasable)
21
+ scoped = end_of_association_chain.includes(:user).includes(order_items: :purchasable)
22
+ scoped = scoped.where(user: current_user) if !authorized?(:admin, :effective_orders)
23
+ scoped
22
24
  end
23
25
  end
24
26
 
@@ -45,7 +47,7 @@ if defined?(ActiveAdmin)
45
47
 
46
48
  column 'Order Items' do |order|
47
49
  content_tag(:ul) do
48
- (order.order_items).map { |oi| content_tag(:li, oi) }.join.html_safe
50
+ (order.order_items).map { |oi| content_tag(:li, oi.to_s.html_safe) }.join.html_safe
49
51
  end
50
52
  end
51
53
 
@@ -79,6 +81,7 @@ if defined?(ActiveAdmin)
79
81
  col_headers << "Tax"
80
82
  col_headers << "Total"
81
83
  col_headers << 'Purchase method'
84
+ col_headers << 'Card Type'
82
85
 
83
86
  csv_string = CSV.generate do |csv|
84
87
  csv << col_headers
@@ -92,7 +95,8 @@ if defined?(ActiveAdmin)
92
95
  (order.subtotal / 100.0).round(2),
93
96
  (order.tax / 100.0).round(2),
94
97
  (order.total / 100.0).round(2),
95
- order.purchase_method
98
+ order.payment_method,
99
+ order.payment_card_type
96
100
  ]
97
101
  end
98
102
  end
@@ -141,18 +141,17 @@ module Effective
141
141
  protected
142
142
 
143
143
  def order_purchased(details = nil, redirect_url = nil, declined_redirect_url = nil)
144
- #begin
144
+ begin
145
145
  @order.purchase!(details)
146
146
  current_cart.try(:destroy)
147
147
 
148
148
  flash[:success] = "Successfully purchased order"
149
149
 
150
150
  redirect_to (redirect_url.presence || effective_orders.order_purchased_path(':id')).gsub(':id', @order.to_param.to_s)
151
- #rescue => e
152
- # binding.pry
153
- # flash[:danger] = "Unable to process your order. Your card has not been charged. Your Cart items have been restored. Please try again. Error Message: #{e.message}"
154
- # redirect_to (declined_redirect_url.presence || effective_orders.cart_path).gsub(':id', @order.to_param.to_s)
155
- #end
151
+ rescue => e
152
+ flash[:danger] = "Unable to process your order. Your card has not been charged. Your Cart items have been restored. Please try again. Error Message: #{e.message}"
153
+ redirect_to (declined_redirect_url.presence || effective_orders.cart_path).gsub(':id', @order.to_param.to_s)
154
+ end
156
155
  end
157
156
 
158
157
  def order_declined(details = nil, redirect_url = nil)
@@ -15,7 +15,9 @@ module ActsAsPurchasable
15
15
 
16
16
  validates_with Effective::SoldOutValidator, :on => :create
17
17
 
18
- validates :price, :presence => true, :numericality => true
18
+ # Database max integer value is 2147483647. So let's round that down and use a max/min of $20 million (2000000000)
19
+ validates :price, :presence => true, :numericality => { less_than_or_equal_to: 2000000000, message: 'maximum price is $20,000,000' }
20
+
19
21
  validates :tax_exempt, :inclusion => {:in => [true, false]}
20
22
 
21
23
  # These are breaking on the check for quanitty_enabled?. More research is due
@@ -24,7 +24,7 @@ if defined?(EffectiveDatatables)
24
24
 
25
25
  table_column :items, label: 'Order Items', sortable: false, column: query_items_list do |order|
26
26
  content_tag(:ul) do
27
- (order[:items] || '').split('!!SEP!!').map { |oi| content_tag(:li, oi) }.join.html_safe
27
+ (order[:items] || '').split('!!SEP!!').map { |oi| content_tag(:li, oi.to_s.html_safe) }.join.html_safe
28
28
  end
29
29
  end
30
30
 
@@ -28,18 +28,19 @@
28
28
  %td.price= price_to_currency(item.subtotal)
29
29
 
30
30
  %tfoot
31
- %tr
32
- %th.quantity
33
- - if include_download_column
34
- %th.download
35
- %th.subtotal Subtotal
36
- %td.price.subtotal-price= price_to_currency(order.subtotal)
37
- %tr
38
- %th.quantity
39
- - if include_download_column
40
- %th.download
41
- %th.tax Tax
42
- %td.price.tax-price= price_to_currency(order.tax)
31
+ - if order.tax > 0
32
+ %tr
33
+ %th.quantity
34
+ - if include_download_column
35
+ %th.download
36
+ %th.subtotal Subtotal
37
+ %td.price.subtotal-price= price_to_currency(order.subtotal)
38
+ %tr
39
+ %th.quantity
40
+ - if include_download_column
41
+ %th.download
42
+ %th.tax Tax
43
+ %td.price.tax-price= price_to_currency(order.tax)
43
44
  %tr
44
45
  %th.quantity
45
46
  - if include_download_column
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '1.6.3'.freeze
2
+ VERSION = '1.6.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-26 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: devise
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: haml-rails
43
57
  requirement: !ruby/object:Gem::Requirement