effective_orders 1.5.3 → 1.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c08f993d24d281ba8e17af297fc43eda2d25425
4
- data.tar.gz: 405e69619e74b45eeb3808dc31403e681666ed5d
3
+ metadata.gz: 69ff7ff6e5414d61ae7a6fc8982f4975917e72ac
4
+ data.tar.gz: d7dc79b1ccba44c64636c436ee4adc58bc0b6253
5
5
  SHA512:
6
- metadata.gz: 456c396d95df8356f5db6a1985b0814955cda265c04162540ba9ac6dae48aa7b575183137ec00ae84445127d351b1673f7abc3441cd6cc0f3ebb4bd159a8bfd6
7
- data.tar.gz: b1e31fdf1558cdf2160be96e1b289595e8f341fd2a244f35f4302061d88027d81ae2fa1828002384c89e285e9af65d4831c6ee3562b28a854f931990a8f21000
6
+ metadata.gz: 2a8641f98c31e8eaf05efc5d3ec699cd68a6ad1c4fb429349d45303c685958848e0e1fb3b1a402e658b35a42e86945535a791f2e3641d3c4aadc8074efb921c9
7
+ data.tar.gz: 2ed81e8f55fbaa86af4428f89598a189da0abf147bbf4233098383d5cfc080270ccf4440d7f5ded06a27ad24bcc9f25d2c0a990fbe0c92e29c1bf979191e5f16
@@ -29,6 +29,7 @@ if defined?(EffectiveDatatables)
29
29
  end
30
30
 
31
31
  table_column(:total) { |order| price_to_currency(order[:total].to_i) }
32
+ table_column :payment_method
32
33
 
33
34
  table_column :created_at, :visible => false
34
35
  table_column :updated_at, :visible => false
@@ -70,15 +71,22 @@ if defined?(EffectiveDatatables)
70
71
  'SUM((order_items.price * order_items.quantity) + (CASE order_items.tax_exempt WHEN true THEN 0 ELSE ((order_items.price * order_items.quantity) * order_items.tax_rate) END))'
71
72
  end
72
73
 
74
+ def query_payment_method
75
+ "SUBSTRING(payment FROM 'card: (\\w{1,2})\\n')"
76
+ end
77
+
73
78
  def search_column(collection, table_column, search_term)
74
- if table_column[:name] == 'subtotal'
75
- collection.having("#{query_subtotal} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
76
- elsif table_column[:name] == 'tax'
77
- collection.having("#{query_tax} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
78
- elsif table_column[:name] == 'total'
79
- collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
80
- elsif table_column[:name] == 'purchase_state' && search_term == 'abandoned'
81
- collection.where(purchase_state: nil)
79
+ case table_column[:name]
80
+ when 'subtotal'
81
+ then collection.having("#{query_subtotal} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
82
+ when 'tax'
83
+ then collection.having("#{query_tax} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
84
+ when 'total'
85
+ then collection.having("#{query_total} = ?", (search_term.gsub(/[^0-9.]/, '').to_f * 100.0).to_i)
86
+ when 'purchase_state'
87
+ then search_term == 'abandoned' ? collection.where(purchase_state: nil) : super
88
+ when 'payment_method'
89
+ then collection.having("#{query_payment_method} = ?", search_term)
82
90
  else
83
91
  super
84
92
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '1.5.3'.freeze
2
+ VERSION = '1.5.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.5.3
4
+ version: 1.5.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-10-26 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails