effective_qb_online 0.9.7 → 0.9.8

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: 3a76e27c7de7949bc0eda143d1f54b01a24f9242df10ded427287d952758451a
4
- data.tar.gz: bbd314c5c7a59814c67386a44f2e097ae71cf46759736ce2e2b3652ff0f34a7b
3
+ metadata.gz: c795cfdd9e5caa950820b5e5dc0757ee4b3fe583dd635baed5bcf37b08271206
4
+ data.tar.gz: 8ad4fec36e7d4fd79ff82036030f95c43cf5ef7ba0e776fa27a9780155bbae4c
5
5
  SHA512:
6
- metadata.gz: 108bfb5e515c03ea0fa47c0718298504718fb3d0ee63d448131fc0fdc32ddc6517facd9eb382fa8e1d3471096c54e4c0845a376ad43eb2b1d6f05f48cc49fd59
7
- data.tar.gz: 43653ac4f849fe09de8bb7b06b23b458d76f514423a3f92f14fce53727f382871613afe6d85c8c534dc7c8b2138710698a3d61454b01a94fb25a13558e6d3135
6
+ metadata.gz: a4b15a1601cc2cf2e7dc9de3ea14b8f8402aefa0ac0eb755a270ab0796c5860dbefc249559fc3ec968196049776e57869e38dde5983541dcf025a60237affbe4
7
+ data.tar.gz: 5415027204b5a1deb9d3d0ce48ec2601da0d4ed2e928f39d421079389def6d72a87bfb3cdd1862c368fcf128d4cc0b5003bd74f4433698d77d4d7bbdb97941f2
@@ -79,6 +79,11 @@ module Effective
79
79
  .group_by(&:last)
80
80
  end
81
81
 
82
+ # Array of strings
83
+ def item_names
84
+ items_collection.values.flatten(1).map(&:first).map(&:to_s).reject(&:blank?).uniq.sort
85
+ end
86
+
82
87
  def item_html(item)
83
88
  details = [
84
89
  ("##{item.id}"),
@@ -88,7 +88,7 @@ module Effective
88
88
  assign_attributes(result: 'completed successfully', sales_receipt_id: sales_receipt.id)
89
89
  complete!
90
90
  rescue => e
91
- result = [e.message, ("(intuit_tid: #{e.intuit_tid})" if e.try(:intuit_tid).present?), e.backtrace.first(15)].compact.flatten.join("\n\n")
91
+ result = [e.message, ("(intuit_tid: #{e.intuit_tid})" if e.try(:intuit_tid).present?)].compact.join("\n\n")
92
92
  assign_attributes(result: result)
93
93
  error!
94
94
  end
@@ -19,7 +19,7 @@ module Effective
19
19
  end
20
20
 
21
21
  def order_item_qb_name
22
- item_id || order_item.purchasable.try(:qb_item_id) || order_item.purchasable.try(:qb_item_name)
22
+ item_id.presence || order_item.purchasable.try(:qb_item_id) || order_item.purchasable.try(:qb_item_name)
23
23
  end
24
24
 
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.9.7'.freeze
2
+ VERSION = '0.9.8'.freeze
3
3
  end
@@ -61,4 +61,28 @@ module EffectiveQbOnline
61
61
  qb_receipt.skip!
62
62
  end
63
63
 
64
+ # Syncs the QuickBooks Online item names down into Effective::ItemName
65
+ def self.sync_item_names!
66
+ client = api()
67
+ raise 'expected a connected QuickBooks Online realm' if client.blank?
68
+
69
+ qb_item_names = client.item_names
70
+ raise 'QuickBooks Online returned no items' if qb_item_names.blank?
71
+
72
+ qb_item_names.each do |name|
73
+ item_name = Effective::ItemName.where(name: name).first_or_initialize
74
+
75
+ if item_name.new_record?
76
+ item_name.save!
77
+ elsif item_name.archived?
78
+ item_name.unarchive!
79
+ end
80
+ end
81
+
82
+ Effective::ItemName.unarchived.where.not(name: qb_item_names).find_each do |item_name|
83
+ item_name.archive!
84
+ end
85
+
86
+ true
87
+ end
64
88
  end
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.9.7
4
+ version: 0.9.8
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: 2026-03-13 00:00:00.000000000 Z
11
+ date: 2026-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails