effective_qb_sync 1.3.3 → 1.3.7
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 +4 -4
- data/app/controllers/admin/qb_syncs_controller.rb +1 -8
- data/app/datatables/effective_qb_sync_datatable.rb +2 -15
- data/app/models/effective/qb_request.rb +13 -3
- data/app/models/effective/qb_ticket.rb +13 -0
- data/app/views/admin/qb_syncs/instructions.html.haml +5 -0
- data/lib/effective_qb_sync/version.rb +1 -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: 5e1b10dc71838c8390bd6baff5fa2bcec970c0be67d3a799967b17cbb1e8490d
|
4
|
+
data.tar.gz: 38cea0b7beb53c3ebfcddda052ea3970514a3c9bfbc4d31d17b9e27194f0db26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 653e25f22cd61bac1119dc50cf0abbc29109906ee8de741db7c75527f60db2f5278567d18a9e3fa70df376a042672487ddfeec0d262e6fbe0ed088367a212464
|
7
|
+
data.tar.gz: '019270eb08c5b8267676b7f94d01ae15150a7c3f34d643aa762a0c726833d5192a5ba791a352d550571d73d3510756c8d4eee6d6e79fe1526776473e5e66df3d'
|
@@ -52,14 +52,7 @@ module Admin
|
|
52
52
|
def set_all_orders_finished
|
53
53
|
Effective::QbTicket.transaction do
|
54
54
|
begin
|
55
|
-
|
56
|
-
@qb_ticket.qb_logs.build(message: 'Set all orders Finished')
|
57
|
-
@qb_ticket.save!
|
58
|
-
|
59
|
-
Effective::QbRequest.new_requests_for_unsynced_items.each do |qb_request|
|
60
|
-
qb_request.qb_ticket = @qb_ticket
|
61
|
-
qb_request.transition_to_finished
|
62
|
-
end
|
55
|
+
Effective::QbTicket.set_orders_finished!
|
63
56
|
|
64
57
|
flash[:success] = 'Successfully set all orders finished'
|
65
58
|
rescue => e
|
@@ -9,20 +9,7 @@ class EffectiveQbSyncDatatable < Effective::Datatable
|
|
9
9
|
qb_ticket.qb_requests.length
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
qb_ticket.qb_requests.select { |qb_request| qb_request.order.present? }
|
14
|
-
end.format do |requests|
|
15
|
-
requests.map { |qb_request| link_to "##{qb_request.order.to_param}", effective_orders.admin_order_path(qb_request.order) }
|
16
|
-
.join('<br>').html_safe
|
17
|
-
end.search do |collection, term, column, sql_column|
|
18
|
-
order = Effective::Order.where(id: search_term).first
|
19
|
-
|
20
|
-
if order.present?
|
21
|
-
collection.where(id: Effective::QbRequest.where(order_id: order.id).pluck(:qb_ticket_id))
|
22
|
-
else
|
23
|
-
collection.none
|
24
|
-
end
|
25
|
-
end
|
12
|
+
col :orders
|
26
13
|
|
27
14
|
actions_col do |qb_ticket|
|
28
15
|
dropdown_link_to 'Show', effective_qb_sync.admin_qb_sync_path(qb_ticket)
|
@@ -31,7 +18,7 @@ class EffectiveQbSyncDatatable < Effective::Datatable
|
|
31
18
|
end
|
32
19
|
|
33
20
|
collection do
|
34
|
-
Effective::QbTicket.deep.all
|
21
|
+
Effective::QbTicket.deep.includes(:orders).all
|
35
22
|
end
|
36
23
|
|
37
24
|
end
|
@@ -30,10 +30,20 @@ module Effective
|
|
30
30
|
|
31
31
|
# creates (does not persist) QbRequests for outstanding orders. The caller may choose to
|
32
32
|
# persist a request when that request starts communicating with QuickBooks
|
33
|
-
def self.new_requests_for_unsynced_items
|
33
|
+
def self.new_requests_for_unsynced_items(before: nil, order_ids: nil)
|
34
34
|
finished_order_ids = Effective::QbRequest.where(state: 'Finished').pluck(:order_id)
|
35
|
-
Effective::Order.purchased.includes(order_items: [:purchasable, :qb_order_item])
|
36
|
-
|
35
|
+
finished_orders = Effective::Order.purchased.includes(order_items: [:purchasable, :qb_order_item]).where.not(id: finished_order_ids)
|
36
|
+
|
37
|
+
if before.present?
|
38
|
+
raise('expected before to be a date') unless before.respond_to?(:strftime)
|
39
|
+
finished_orders = finished_orders.where('purchased_at < ?', before)
|
40
|
+
end
|
41
|
+
|
42
|
+
if order_ids.present?
|
43
|
+
finished_orders = finished_orders.where(id: order_ids)
|
44
|
+
end
|
45
|
+
|
46
|
+
finished_orders.map { |order| Effective::QbRequest.new(order: order) }
|
37
47
|
end
|
38
48
|
|
39
49
|
# Finds a QbRequest using response qb_xml. If the response could not be parsed, or if there was no
|
@@ -30,6 +30,19 @@ module Effective
|
|
30
30
|
|
31
31
|
validates :state, inclusion: { in: STATES }
|
32
32
|
|
33
|
+
def self.set_orders_finished!(before: nil, order_ids: nil)
|
34
|
+
qb_ticket = Effective::QbTicket.new(state: 'Finished')
|
35
|
+
qb_ticket.qb_logs.build(message: 'Set all orders Finished')
|
36
|
+
qb_ticket.save!
|
37
|
+
|
38
|
+
Effective::QbRequest.new_requests_for_unsynced_items(before: before, order_ids: order_ids).each do |qb_request|
|
39
|
+
qb_request.qb_ticket = qb_ticket
|
40
|
+
qb_request.transition_to_finished
|
41
|
+
end
|
42
|
+
|
43
|
+
true
|
44
|
+
end
|
45
|
+
|
33
46
|
def request_error!(error, atts={})
|
34
47
|
self.error!(error, atts.reverse_merge(state: 'RequestError'))
|
35
48
|
end
|
@@ -15,11 +15,16 @@
|
|
15
15
|
%strong= Array(EffectiveQbSync.quickbooks_username).join('</strong> or <strong>').html_safe
|
16
16
|
and password:
|
17
17
|
%strong= Array(EffectiveQbSync.quickbooks_password).join('</strong> or <strong>').html_safe
|
18
|
+
- elsif EffectiveQbSync.quickbooks_username.blank? && EffectiveQbSync.quickbooks_password.present?
|
19
|
+
%li
|
20
|
+
Add a Quickbooks user any username, and password:
|
21
|
+
%strong= Array(EffectiveQbSync.quickbooks_password).join('</strong> or <strong>').html_safe
|
18
22
|
- else
|
19
23
|
%li
|
20
24
|
(developer) Add a quickbooks_username and quickbooks_password to the config/initializers/effective_qb_sync.rb file
|
21
25
|
%ul
|
22
26
|
%li Add a Quickbooks user with that same username and password
|
27
|
+
|
23
28
|
%li Access for user: "Selected areas of Quickbooks"
|
24
29
|
%li Sales and Accounts Receivable "Selective Access - Create transactions only"
|
25
30
|
%li Purchases and Accounts Payable "No Access"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_qb_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.7
|
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:
|
11
|
+
date: 2022-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|