effective_qb_online 0.1.7 → 0.2.0
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:
|
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
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module Admin
|
2
2
|
class EffectiveQbItemsDatatable < Effective::Datatable
|
3
3
|
datatable do
|
4
|
-
col :name, label: 'QuickBooks Item Name'
|
5
4
|
col :id, label: 'QuickBooks Item Id'
|
5
|
+
col :name, label: 'QuickBooks Item Name'
|
6
|
+
col :fully_qualified_name, label: 'QuickBooks Fully Qualified Name'
|
6
7
|
end
|
7
8
|
|
8
9
|
collection do
|
9
|
-
EffectiveQbOnline.api.
|
10
|
+
EffectiveQbOnline.api.items.map do |item|
|
11
|
+
[item.id, item.name, item.fully_qualified_name]
|
12
|
+
end
|
10
13
|
end
|
11
14
|
|
12
15
|
end
|
@@ -30,17 +30,23 @@ module Effective
|
|
30
30
|
raise("Expected a purchasable for Effective::OrderItem #{receipt_item.order_item.id}") unless purchasable.present?
|
31
31
|
|
32
32
|
# Either of these could match
|
33
|
-
purchasable_id_name = [
|
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
|
34
37
|
|
35
38
|
# Find item by receipt item
|
36
|
-
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
|
37
42
|
|
38
43
|
# Find item by purchasable qb_item_id and qb_item_name
|
39
|
-
item ||=
|
40
|
-
|
44
|
+
item ||= items.find do |item|
|
45
|
+
([scrub(item.id), scrub(item.name), scrub(item.fully_qualified_name)] & purchasable_id_name).present?
|
41
46
|
end
|
42
47
|
|
43
48
|
if item.blank?
|
49
|
+
purchasable_id_name = [purchasable.try(:qb_item_id), purchasable.try(:qb_item_name)].compact
|
44
50
|
raise("Unknown Item #{purchasable_id_name.join(' or ')} from #{purchasable} (#{purchasable.class.name} ##{purchasable.id})")
|
45
51
|
end
|
46
52
|
|
@@ -99,5 +105,11 @@ module Effective
|
|
99
105
|
sales_receipt
|
100
106
|
end
|
101
107
|
|
108
|
+
private
|
109
|
+
|
110
|
+
def self.scrub(value)
|
111
|
+
value.to_s.downcase.strip
|
112
|
+
end
|
113
|
+
|
102
114
|
end
|
103
115
|
end
|