effective_orders 5.2.16 → 5.3.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: f39960e8a8f551838180f27b80909a6aaeab1b2188ed64940dc3fe35a97a44a7
4
- data.tar.gz: 7910cdfe509ba84be703aad6bc452bfd53e9b8760027cc17e1bac280b9d373ac
3
+ metadata.gz: dc662c2add95d46295f9dcbf498836481de48d6df528594fbee1e5b1ca333a7e
4
+ data.tar.gz: e6a8beebda502e2bc9ef9d787bfffe349528af236d8dce3716d4f194c98fa733
5
5
  SHA512:
6
- metadata.gz: 87a550796efef35f0175625db99570302027b6f091cb5fdea1510b3a3d4c7691c26c947e6a0e6e4dc95b11bc683fc333fa3590605b5313b527df64186b77c26a
7
- data.tar.gz: 1b73bd83140864c0fbb70ee9bbbe684f5e36abdeb2ecb68cd10ba4bbebc7cc4c83d34673760c2e2fc15484d678b651b563293881ee0449eb5f09eb72639d20f0
6
+ metadata.gz: 3a70337f484b993930a530493e1fdf162e1e9374e8af7821293e4d3763acd9cfb262330a8515b340709ae2d8cb65d539e370225578c98c52dcffbf642330be13
7
+ data.tar.gz: d0f956661942c784d9f8c976f964dfa56ab7b80dd9021ab4e2845e1d79c727b9b3b63a4fdad9b515a1ae44378d7145bf165bf24041cefc0fb589d52e481a1f8a
@@ -82,7 +82,10 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
82
82
 
83
83
  actions_col partial: 'admin/orders/datatable_actions', partial_as: :order
84
84
 
85
- aggregate :total
85
+ unless attributes[:total] == false
86
+ aggregate :total
87
+ end
88
+
86
89
  end
87
90
 
88
91
  collection do
@@ -476,8 +476,14 @@ module Effective
476
476
  false
477
477
  end
478
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
+
479
485
  # Effective::Order.new(items: Product.first, user: User.first).purchase!(email: false)
480
- 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)
481
487
  # Assign attributes
482
488
  self.state = EffectiveOrders::PURCHASED
483
489
  self.skip_buyer_validations = skip_buyer_validations
@@ -506,6 +512,20 @@ module Effective
506
512
  end
507
513
 
508
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
509
529
 
510
530
  true
511
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.16'.freeze
2
+ VERSION = '5.3.1'.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.16
4
+ version: 5.3.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: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails