effective_qb_online 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/qb_online_controller.rb +6 -1
- data/app/datatables/admin/effective_qb_items_datatable.rb +16 -0
- data/app/datatables/admin/effective_qb_receipts_datatable.rb +7 -0
- data/app/models/effective/qb_api.rb +1 -10
- data/app/models/effective/qb_realm.rb +4 -0
- data/app/models/effective/qb_receipt.rb +3 -1
- data/app/models/effective/qb_sales_receipt.rb +19 -5
- data/app/views/admin/qb_online/_company.html.haml +3 -0
- data/app/views/admin/qb_online/index.html.haml +7 -2
- data/app/views/admin/qb_online/items.html.haml +5 -0
- data/config/routes.rb +1 -0
- data/lib/effective_qb_online/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20091c462c42fe7c361cc24f430c7ac8050b5fd101db4d18b0dd96730b1d7e8f
|
4
|
+
data.tar.gz: 86db22b8febd131c30659676ad3a39edb1d6ee8c3cf84fda9055d12c1fab6658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fda907556a72911aedbfa905ea2faef422f6ef4f7a78e0591353f655ffc3b0f3b66a3fc024381f2de0a143315f32f80c567c63bba47b5453471731d733f97708
|
7
|
+
data.tar.gz: b37c30a31998a33d7f4fc5e50256f2c09b4833a541384717473edf90b11bd692c8a7082ec000acf3e184e22c872346fad7b9f85509c023d20e9d452cc8378429
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Admin
|
2
|
+
class EffectiveQbItemsDatatable < Effective::Datatable
|
3
|
+
datatable do
|
4
|
+
col :id, label: 'QuickBooks Item Id'
|
5
|
+
col :name, label: 'QuickBooks Item Name'
|
6
|
+
col :fully_qualified_name, label: 'QuickBooks Fully Qualified Name'
|
7
|
+
end
|
8
|
+
|
9
|
+
collection do
|
10
|
+
EffectiveQbOnline.api.items.map do |item|
|
11
|
+
[item.id, item.name, item.fully_qualified_name]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -26,6 +26,13 @@ module Admin
|
|
26
26
|
col :status
|
27
27
|
col :result
|
28
28
|
|
29
|
+
col :order_items, label: 'Purchasable Qb Item Names' do |receipt|
|
30
|
+
receipt.order.purchasables.map do |purchasable|
|
31
|
+
purchasable_id_name = [purchasable.try(:qb_item_id), purchasable.try(:qb_item_name)].compact
|
32
|
+
content_tag(:div, purchasable_id_name.join(' or '), class: "col-resource_item")
|
33
|
+
end.join.html_safe
|
34
|
+
end
|
35
|
+
|
29
36
|
actions_col
|
30
37
|
end
|
31
38
|
|
@@ -75,19 +75,10 @@ module Effective
|
|
75
75
|
items
|
76
76
|
.reject { |item| item.type == 'Category' }
|
77
77
|
.sort_by { |item| [item.type, item.name] }
|
78
|
-
.map { |item| [
|
78
|
+
.map { |item| [item.name, item.id, {'data-html': item_html(item)}, item.type] }
|
79
79
|
.group_by(&:last)
|
80
80
|
end
|
81
81
|
|
82
|
-
def item_name(item)
|
83
|
-
[
|
84
|
-
item.name,
|
85
|
-
("##{item.id}"),
|
86
|
-
(item.sku if item.sku.present?),
|
87
|
-
(item.description if item.description.present?)
|
88
|
-
].compact.join(' ')
|
89
|
-
end
|
90
|
-
|
91
82
|
def item_html(item)
|
92
83
|
details = [
|
93
84
|
("##{item.id}"),
|
@@ -79,7 +79,6 @@ module Effective
|
|
79
79
|
error!
|
80
80
|
end
|
81
81
|
|
82
|
-
true
|
83
82
|
end
|
84
83
|
|
85
84
|
def skip!
|
@@ -93,6 +92,9 @@ module Effective
|
|
93
92
|
|
94
93
|
def error!
|
95
94
|
errored!
|
95
|
+
EffectiveLogger.error(result, associated: self) if defined?(EffectiveLogger)
|
96
|
+
|
97
|
+
false
|
96
98
|
end
|
97
99
|
|
98
100
|
end
|
@@ -29,17 +29,25 @@ module Effective
|
|
29
29
|
purchasable = receipt_item.order_item.purchasable
|
30
30
|
raise("Expected a purchasable for Effective::OrderItem #{receipt_item.order_item.id}") unless purchasable.present?
|
31
31
|
|
32
|
+
# Either of these could match
|
33
|
+
purchasable_id_name = [
|
34
|
+
(scrub(purchasable.qb_item_id) if purchasable.try(:qb_item_id)),
|
35
|
+
(scrub(purchasable.qb_item_name) if purchasable.try(:qb_item_name))
|
36
|
+
].compact
|
37
|
+
|
32
38
|
# Find item by receipt item
|
33
|
-
item = items.find
|
39
|
+
item = items.find do |item|
|
40
|
+
[scrub(item.id), scrub(item.name), scrub(item.fully_qualified_name)].include?(scrub(receipt_item.item_id))
|
41
|
+
end
|
34
42
|
|
35
43
|
# Find item by purchasable qb_item_id and qb_item_name
|
36
|
-
item ||=
|
37
|
-
|
38
|
-
items.find { |item| ([item.id, item.name] & purchasable_id_name).present? }
|
44
|
+
item ||= items.find do |item|
|
45
|
+
([scrub(item.id), scrub(item.name), scrub(item.fully_qualified_name)] & purchasable_id_name).present?
|
39
46
|
end
|
40
47
|
|
41
48
|
if item.blank?
|
42
|
-
|
49
|
+
purchasable_id_name = [purchasable.try(:qb_item_id), purchasable.try(:qb_item_name)].compact
|
50
|
+
raise("Unknown Item #{purchasable_id_name.join(' or ')} from #{purchasable} (#{purchasable.class.name} ##{purchasable.id})")
|
43
51
|
end
|
44
52
|
|
45
53
|
receipt_item.update!(item_id: item.id)
|
@@ -97,5 +105,11 @@ module Effective
|
|
97
105
|
sales_receipt
|
98
106
|
end
|
99
107
|
|
108
|
+
private
|
109
|
+
|
110
|
+
def self.scrub(value)
|
111
|
+
value.to_s.downcase.strip
|
112
|
+
end
|
113
|
+
|
100
114
|
end
|
101
115
|
end
|
@@ -32,6 +32,9 @@
|
|
32
32
|
.col= f.select :payment_method_id, api.payment_methods_collection, label: false
|
33
33
|
.col= f.save
|
34
34
|
|
35
|
+
%tr
|
36
|
+
%td Items
|
37
|
+
%td= link_to 'Quickbooks Items', effective_qb_online.admin_quickbooks_items_path
|
35
38
|
|
36
39
|
- if company_info.blank?
|
37
40
|
%table.table.table-sm
|
@@ -11,8 +11,13 @@
|
|
11
11
|
= card('Test Credentials') do
|
12
12
|
= render('test_credentials', api: api)
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
- if api.realm&.configured?
|
15
|
+
.mb-2
|
16
|
+
= collapse('Show Company Settings') do
|
17
|
+
= render('company', api: api)
|
18
|
+
- else
|
19
|
+
= card('Company') do
|
20
|
+
= render('company', api: api)
|
16
21
|
|
17
22
|
= card('Sales Receipts') do
|
18
23
|
.text-right.mb-2
|
data/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_qb_online
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -212,6 +212,7 @@ files:
|
|
212
212
|
- app/controllers/admin/qb_realms_controller.rb
|
213
213
|
- app/controllers/admin/qb_receipts_controller.rb
|
214
214
|
- app/controllers/effective/qb_oauth_controller.rb
|
215
|
+
- app/datatables/admin/effective_qb_items_datatable.rb
|
215
216
|
- app/datatables/admin/effective_qb_receipts_datatable.rb
|
216
217
|
- app/helpers/effective_qb_online_helper.rb
|
217
218
|
- app/jobs/qb_sync_order_job.rb
|
@@ -224,6 +225,7 @@ files:
|
|
224
225
|
- app/views/admin/qb_online/_connect.html.haml
|
225
226
|
- app/views/admin/qb_online/_test_credentials.html.haml
|
226
227
|
- app/views/admin/qb_online/index.html.haml
|
228
|
+
- app/views/admin/qb_online/items.html.haml
|
227
229
|
- app/views/admin/qb_receipts/_form.html.haml
|
228
230
|
- app/views/admin/qb_receipts/edit.html.haml
|
229
231
|
- app/views/admin/qb_receipts/new.html.haml
|