effective_orders 5.2.17 → 5.3.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: f6b400848ddbb8a36cfadf1d89aaa88edf09f21f4e769e0d0c43065071de128a
4
- data.tar.gz: 2e6ddefee5a035af6222eb8f96971bf134205cc320a4fcf8e826e65f61ec78bb
3
+ metadata.gz: 0ff21e266d5908efc6a31250b6b265879e0e6c2330f598bd673fee6058f54b3d
4
+ data.tar.gz: c20fba9f6371012d5895bf17555ef003d88c57d19ba0a8e0b5e087d69b8eab0e
5
5
  SHA512:
6
- metadata.gz: fc4584d1c4739bf175be6bcf85369e3d0e5fd83bdc66b5d132258e2273b9b79cc5bdee8b02bed75ba809d40197058be6b3c75bd541d05bcfaf079ffa1202c1fb
7
- data.tar.gz: 596b1c81741d349d0f18c35a63248ab62abd725aae8d5a5748a2a969d371c1e26139712548f13898157d783c39065ba10a0fdd44322cd7b8cd53d6fecd7fad60
6
+ metadata.gz: 11dfee0b764d2b93259b0cde740ecc9fcd39b2f80d0c5dc5795ea76919ed27528fbeb69f2a84d99fc27cfe09feeab2d07bc9b809e804ce3e19abba210f51a42b
7
+ data.tar.gz: 05a83379f89294bf22f3c6010f944b62a4839e8129e14b6f8a81226a8315e555731afd76963a8cb0bbbe4ac9a3725dd9e46ce3d742fe84eddd993f254947e160
@@ -59,7 +59,9 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
59
59
  col :shipping_address, visible: false
60
60
  end
61
61
 
62
- col :order_items, search: { as: :string }
62
+ col(:order_items, search: :string).search do |collection, term|
63
+ collection.where(id: Effective::OrderItem.where('name ILIKE ?', "%#{term}%").select('order_id'))
64
+ end
63
65
 
64
66
  col :subtotal, as: :price, visible: false
65
67
  col :tax, as: :price, visible: false
@@ -82,7 +84,10 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
82
84
 
83
85
  actions_col partial: 'admin/orders/datatable_actions', partial_as: :order
84
86
 
85
- aggregate :total
87
+ unless attributes[:total] == false
88
+ aggregate :total
89
+ end
90
+
86
91
  end
87
92
 
88
93
  collection do
@@ -38,7 +38,9 @@ class EffectiveOrdersDatatable < Effective::Datatable
38
38
  col :shipping_address, visible: false
39
39
  end
40
40
 
41
- col :order_items, search: { as: :string }
41
+ col(:order_items, search: :string).search do |collection, term|
42
+ collection.where(id: Effective::OrderItem.where('name ILIKE ?', "%#{term}%").select('order_id'))
43
+ end
42
44
 
43
45
  col :subtotal, as: :price, visible: false
44
46
  col :tax, as: :price, visible: false
@@ -479,13 +479,11 @@ module Effective
479
479
  # Call this as a way to skip over non consequential orders
480
480
  # And mark some purchasables purchased
481
481
  def mark_as_purchased!
482
- purchase!(skip_buyer_validations: true, email: false)
483
- skip_qb_sync!
484
- true
482
+ purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true)
485
483
  end
486
484
 
487
485
  # Effective::Order.new(items: Product.first, user: User.first).purchase!(email: false)
488
- 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)
489
487
  # Assign attributes
490
488
  self.state = EffectiveOrders::PURCHASED
491
489
  self.skip_buyer_validations = skip_buyer_validations
@@ -514,6 +512,20 @@ module Effective
514
512
  end
515
513
 
516
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
517
529
 
518
530
  true
519
531
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '5.2.17'.freeze
2
+ VERSION = '5.3.2'.freeze
3
3
  end
@@ -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.2.17
4
+ version: 5.3.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: 2022-02-03 00:00:00.000000000 Z
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails