effective_orders 6.7.0 → 6.7.2

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
  SHA256:
3
- metadata.gz: 7b95b58112e836a932ba93507f74ab11a551110d5e656100be363fef929dff4f
4
- data.tar.gz: baa58804ceab0264a4f87b9c97c1268c90a765d5d1d3bc86e224b6ec2e558982
3
+ metadata.gz: cf1784e619c52695ef3be94dfd8ed164c5c6b0f81e2a853239ba5963e916ee14
4
+ data.tar.gz: ef0eeb3c19bd456a8d806dfb0ea2963b06b0a2786ce2e7d0f0071c261ed61162
5
5
  SHA512:
6
- metadata.gz: a4bd65c532f86d5eeb602a4699ff87922f010137825bcfa960f82584f33fd61bb5d7f2db962fdbc93c7044c076597ee677e84b9285909a24d99864f192d8c360
7
- data.tar.gz: fe9c072ee1aad78d10216fa930faafe7ebd569b21488347c674c9dc34fe590f23352e6a3820701df89d4366b869cc26d007c94bc2155d4bf4bf162bbb6db20e0
6
+ metadata.gz: dba9ec63003ed63c5b40ea9aae431c42ea55d11eb496acfe9154e07e5ecdc5ab41f7b37be0b6ab1d65747bc7515b77fc342cb841491c714aab238d7c5d0f182b
7
+ data.tar.gz: 5b809f63ee1cb262688f69f274b79519711b7a8fc5eec2028fdc76aa1fcb579bd78bd6aac681227947e86ea43737f54693889aac79d82237a145ab4ed32316d7
@@ -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]
@@ -9,5 +9,5 @@
9
9
  %tbody
10
10
  %tr
11
11
  %td= price_to_currency(order.total)
12
- %td= order.purchased_at.strftime('%b %d, %Y')
12
+ %td= order.purchased_at.in_time_zone(Time.zone).strftime('%b %d, %Y')
13
13
  %td= order.payment_method
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.7.0'.freeze
2
+ VERSION = '6.7.2'.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.2
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