effective_orders 5.2.14 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/order.rb +26 -2
- data/app/models/effective/order_item.rb +1 -1
- data/config/effective_orders.rb +1 -0
- data/lib/effective_orders/version.rb +1 -1
- data/lib/effective_orders.rb +14 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d6adca64d53290d7772a9c7a5c6840575eade0813edfb8065a8cb2950d6e078
|
4
|
+
data.tar.gz: 31c4fbd7b2aadb0479199494027fbb493caf4fe53e75aa2e8604e245e9d125b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bcedc55d631c5fa39a5680d9dccd6e7abe0b5e67119187abbdf51df0290476ebbc06550cf7fefa8a6309474b2a35127436b03fe51726a491aa5b487c62fc34d
|
7
|
+
data.tar.gz: 8ca3dd2b2fa412f3a933a054cfbcba264bb120101ae5955ae50b9305f64bcf31548374ab9ce001f9f6a5d17652e2b08ac0b7641dd3e130e045a1ad5ed4ba2756
|
@@ -333,8 +333,12 @@ module Effective
|
|
333
333
|
else payment_card.to_s
|
334
334
|
end unless payment_provider == 'free'
|
335
335
|
|
336
|
+
last4 = if payment[:active_card] && payment[:active_card].include?('**** **** ****')
|
337
|
+
payment[:active_card][15,4]
|
338
|
+
end
|
339
|
+
|
336
340
|
# stripe, moneris, moneris_checkout
|
337
|
-
last4
|
341
|
+
last4 ||= (payment['f4l4'] || payment['first6last4']).to_s.last(4)
|
338
342
|
|
339
343
|
[card, '-', last4].compact.join(' ')
|
340
344
|
end
|
@@ -472,8 +476,14 @@ module Effective
|
|
472
476
|
false
|
473
477
|
end
|
474
478
|
|
479
|
+
# Call this as a way to skip over non consequential orders
|
480
|
+
# And mark some purchasables purchased
|
481
|
+
def mark_as_purchased!
|
482
|
+
purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true)
|
483
|
+
end
|
484
|
+
|
475
485
|
# Effective::Order.new(items: Product.first, user: User.first).purchase!(email: false)
|
476
|
-
def purchase!(payment: 'none', provider: 'none', card: 'none', email: true, skip_buyer_validations: false)
|
486
|
+
def purchase!(payment: 'none', provider: 'none', card: 'none', email: true, skip_buyer_validations: false, skip_quickbooks: false)
|
477
487
|
# Assign attributes
|
478
488
|
self.state = EffectiveOrders::PURCHASED
|
479
489
|
self.skip_buyer_validations = skip_buyer_validations
|
@@ -502,6 +512,20 @@ module Effective
|
|
502
512
|
end
|
503
513
|
|
504
514
|
send_order_receipts! if email
|
515
|
+
after_commit { sync_quickbooks!(skip: skip_quickbooks) }
|
516
|
+
|
517
|
+
true
|
518
|
+
end
|
519
|
+
|
520
|
+
# We support two different Quickbooks synchronization gems: effective_qb_sync and effective_qb_online
|
521
|
+
def sync_quickbooks!(skip:)
|
522
|
+
if EffectiveOrders.qb_online?
|
523
|
+
skip ? EffectiveQbOnline.skip_order!(self) : EffectiveQbOnline.sync_order!(self)
|
524
|
+
end
|
525
|
+
|
526
|
+
if EffectiveOrders.qb_sync?
|
527
|
+
skip ? EffectiveQbSync.skip_order!(self) : true # Nothing to do
|
528
|
+
end
|
505
529
|
|
506
530
|
true
|
507
531
|
end
|
@@ -68,7 +68,7 @@ module Effective
|
|
68
68
|
# first or build
|
69
69
|
def qb_item_name
|
70
70
|
raise('expected EffectiveQbSync gem') unless defined?(EffectiveQbSync)
|
71
|
-
(qb_order_item || build_qb_order_item(name: purchasable
|
71
|
+
(qb_order_item || build_qb_order_item(name: purchasable&.qb_item_name)).name
|
72
72
|
end
|
73
73
|
|
74
74
|
end
|
data/config/effective_orders.rb
CHANGED
@@ -25,6 +25,7 @@ EffectiveOrders.setup do |config|
|
|
25
25
|
|
26
26
|
# Synchronize with Quickbooks
|
27
27
|
config.use_effective_qb_sync = false
|
28
|
+
config.use_effective_qb_online = false
|
28
29
|
|
29
30
|
# If set, the orders#new screen will render effective/orders/_order_note_fields to capture any Note info
|
30
31
|
config.collect_note = false
|
data/lib/effective_orders.rb
CHANGED
@@ -35,7 +35,7 @@ module EffectiveOrders
|
|
35
35
|
:customers_table_name, :subscriptions_table_name, :products_table_name,
|
36
36
|
:layout, :mailer_class_name, :mailer,
|
37
37
|
:orders_collection_scope, :order_tax_rate_method,
|
38
|
-
:obfuscate_order_ids, :use_effective_qb_sync,
|
38
|
+
:obfuscate_order_ids, :use_effective_qb_sync, :use_effective_qb_online,
|
39
39
|
:billing_address, :shipping_address,
|
40
40
|
:collect_note, :collect_note_required, :collect_note_message,
|
41
41
|
:terms_and_conditions, :terms_and_conditions_label, :minimum_charge,
|
@@ -136,6 +136,14 @@ module EffectiveOrders
|
|
136
136
|
[('cheque' if cheque?), ('phone' if phone?)].compact
|
137
137
|
end
|
138
138
|
|
139
|
+
def self.qb_sync?
|
140
|
+
use_effective_qb_sync && defined?(EffectiveQbSync)
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.qb_online?
|
144
|
+
use_effective_qb_online && defined?(EffectiveQbOnline)
|
145
|
+
end
|
146
|
+
|
139
147
|
def self.mailer_klass
|
140
148
|
name = mailer_class_name.presence || 'Effective::OrdersMailer'
|
141
149
|
name.safe_constantize || raise("unable to constantize mailer class. check config.mailer_class_name")
|
@@ -229,4 +237,9 @@ module EffectiveOrders
|
|
229
237
|
|
230
238
|
class SoldOutException < Exception; end
|
231
239
|
class AlreadyPurchasedException < Exception; end
|
240
|
+
|
241
|
+
def self.gem_path
|
242
|
+
__dir__.chomp('/lib')
|
243
|
+
end
|
244
|
+
|
232
245
|
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: 5.
|
4
|
+
version: 5.3.0
|
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: 2022-
|
11
|
+
date: 2022-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|