effective_qb_online 0.1.7 → 0.2.0

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: a7fc21efb0c22e83527301d73ea8361950ac6509df72473f6b508c02a4395033
4
- data.tar.gz: d64a65682a39acda71d381395cf88075f8ac52d2675c1edd0056d417a8c082dc
3
+ metadata.gz: 20091c462c42fe7c361cc24f430c7ac8050b5fd101db4d18b0dd96730b1d7e8f
4
+ data.tar.gz: 86db22b8febd131c30659676ad3a39edb1d6ee8c3cf84fda9055d12c1fab6658
5
5
  SHA512:
6
- metadata.gz: 8906f78473bcdbd0f52968e7e5071296116bbdda9bb772fcc02c76bc6bf6d21cbe53767550687417b896cf0d171f63b3e7758526259777c4a709dc22d87640f4
7
- data.tar.gz: 642358ce67927f0fd30dc7af890d082a35291fed20a0b8ef2497ebeec41dc88154d0ab4d278836cb56d63b1eed638f3be9620475c0c2bf19316473d212534b65
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.items_collection.values.flatten(1)
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 = [purchasable.try(:qb_item_id), purchasable.try(:qb_item_name)].compact
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 { |item| [item.id, item.name].include?(receipt_item.item_id) }
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 ||= begin
40
- 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?
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_qb_online
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect