effective_orders 6.7.0 → 6.7.1

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
  SHA256:
3
- metadata.gz: 7b95b58112e836a932ba93507f74ab11a551110d5e656100be363fef929dff4f
4
- data.tar.gz: baa58804ceab0264a4f87b9c97c1268c90a765d5d1d3bc86e224b6ec2e558982
3
+ metadata.gz: 7459a763eab11675ddfe273af19f563ed661cf01919c7f16cded64d8e8b34d90
4
+ data.tar.gz: 4154b76b4bc53fb2b3e2061d37f87359550b9a73481727d169f828a2e892e09b
5
5
  SHA512:
6
- metadata.gz: a4bd65c532f86d5eeb602a4699ff87922f010137825bcfa960f82584f33fd61bb5d7f2db962fdbc93c7044c076597ee677e84b9285909a24d99864f192d8c360
7
- data.tar.gz: fe9c072ee1aad78d10216fa930faafe7ebd569b21488347c674c9dc34fe590f23352e6a3820701df89d4366b869cc26d007c94bc2155d4bf4bf162bbb6db20e0
6
+ metadata.gz: 5e27bf43b30612c9867729ebb1c3b49c72df4141d8798e4a068c6aa22392affd0577fde516aba1abd184ef99e8ebb93554716bd63cf67f3734bd5a2b4fb569d7
7
+ data.tar.gz: ad8507d5fe1c7e497edac91d2b00869a40e48e70e979a10c14ceddbbb7280fca1994a7ab3b9c4e0338a59d43529b74b09a6464002d4571369e0725a23a99b809
@@ -22,6 +22,11 @@ module Effective
22
22
  )
23
23
  end
24
24
 
25
+ if payment['card_type'].present?
26
+ active_card = "**** **** **** #{payment['first6last4'].to_s.last(4)} #{payment['card_type']} #{payment['expiry_date'].to_s.first(2)}/#{payment['expiry_date'].to_s.last(2)}"
27
+ payment = payment.except('first6last4').merge('active_card' => active_card)
28
+ end
29
+
25
30
  order_purchased(
26
31
  payment: payment,
27
32
  provider: 'moneris_checkout',
@@ -54,6 +54,9 @@ module ActsAsPurchasable
54
54
 
55
55
  scope :purchased_by, lambda { |user| joins(order_items: :order).where(orders: { purchased_by: user, status: :purchased }).distinct }
56
56
  scope :not_purchased_by, lambda { |user| where.not(id: purchased_by(user)) }
57
+
58
+ scope :purchased_or_deferred, -> { joins(order_items: :order).where(orders: { status: [:purchased, :deferred] }) }
59
+ scope :deferred, -> { joins(order_items: :order).where(orders: { status: :deferred }) }
57
60
  end
58
61
 
59
62
  module ClassMethods
@@ -103,7 +103,10 @@ module Effective
103
103
  scope :sorted, -> { order(:id) }
104
104
 
105
105
  scope :purchased, -> { where(status: :purchased) }
106
+ scope :purchased_or_deferred, -> { where(status: [:purchased, :deferred]) }
107
+
106
108
  scope :purchased_by, lambda { |user| purchased.where(user: user) }
109
+
107
110
  scope :not_purchased, -> { where.not(status: [:purchased, :deferred]) }
108
111
  scope :was_not_purchased, -> { where.not(status: :purchased) }
109
112
 
@@ -406,6 +409,10 @@ module Effective
406
409
  payment[:active_card][15,4]
407
410
  end
408
411
 
412
+ last4 ||= if payment['active_card'] && payment['active_card'].include?('**** **** ****')
413
+ payment['active_card'][15,4]
414
+ end
415
+
409
416
  # stripe, moneris, moneris_checkout
410
417
  last4 ||= (payment['f4l4'] || payment['first6last4']).to_s.last(4)
411
418
 
@@ -30,14 +30,14 @@ module Effective
30
30
  country = country_code
31
31
  state = state_code
32
32
 
33
- if order.present? && order.billing_address.present?
34
- country ||= order.billing_address.country_code
35
- state ||= order.billing_address.state_code
36
- end
37
-
38
- if order.present? && order.user.respond_to?(:billing_address) && order.user.billing_address.present?
39
- country ||= order.user.billing_address.country_code
40
- state ||= order.user.billing_address.state_code
33
+ if order.present?
34
+ country ||= order.billing_address.try(:country_code)
35
+ country ||= order.organization.try(:billing_address).try(:country_code)
36
+ country ||= order.user.try(:billing_address).try(:country_code)
37
+
38
+ state ||= order.billing_address.try(:state_code)
39
+ state ||= order.organization.try(:billing_address).try(:state_code)
40
+ state ||= order.user.try(:billing_address).try(:state_code)
41
41
  end
42
42
 
43
43
  rate = RATES[country]
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.7.0'.freeze
2
+ VERSION = '6.7.1'.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: 6.7.0
4
+ version: 6.7.1
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: 2023-08-08 00:00:00.000000000 Z
11
+ date: 2023-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails