effective_qb_online 0.1.6 → 0.1.7

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: e6236043039764c3ed21da2815ed933c0e5fb7a1203d8de504bc48068945c9cc
4
- data.tar.gz: 7739b969b9364ca80a9588708eb0c718356e1f8ff7f131b0fed9661d576e2249
3
+ metadata.gz: a7fc21efb0c22e83527301d73ea8361950ac6509df72473f6b508c02a4395033
4
+ data.tar.gz: d64a65682a39acda71d381395cf88075f8ac52d2675c1edd0056d417a8c082dc
5
5
  SHA512:
6
- metadata.gz: e3f15e8dc09f8fa4aefb34494bfadd0b780a029bb60efea223aecbcd3e01feaf99a53937ab02a79c7d4e09fac6ccf8b11f4784aa74de0bcd92b3bae35be4f838
7
- data.tar.gz: f4a6c151041e0da67c8ea8ad3536bd2f15747a93c3045058c7d255d53f0f17c1eb81094d530a6ad01844b727b99cacd8e09f919bccba6235550619fac1cf45a4
6
+ metadata.gz: 8906f78473bcdbd0f52968e7e5071296116bbdda9bb772fcc02c76bc6bf6d21cbe53767550687417b896cf0d171f63b3e7758526259777c4a709dc22d87640f4
7
+ data.tar.gz: 642358ce67927f0fd30dc7af890d082a35291fed20a0b8ef2497ebeec41dc88154d0ab4d278836cb56d63b1eed638f3be9620475c0c2bf19316473d212534b65
@@ -5,9 +5,14 @@ module Admin
5
5
 
6
6
  include Effective::CrudController
7
7
 
8
+ page_title 'QuickBooks Online'
9
+
8
10
  # /admin/quickbooks
9
11
  def index
10
- @page_title = 'QuickBooks Online'
12
+ end
13
+
14
+ # /admin/quickbooks/items
15
+ def items
11
16
  end
12
17
 
13
18
  end
@@ -0,0 +1,13 @@
1
+ module Admin
2
+ class EffectiveQbItemsDatatable < Effective::Datatable
3
+ datatable do
4
+ col :name, label: 'QuickBooks Item Name'
5
+ col :id, label: 'QuickBooks Item Id'
6
+ end
7
+
8
+ collection do
9
+ EffectiveQbOnline.api.items_collection.values.flatten(1)
10
+ end
11
+
12
+ end
13
+ 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
 
@@ -33,5 +33,9 @@ module Effective
33
33
  'QuickBooks Online Settings'
34
34
  end
35
35
 
36
+ def configured?
37
+ realm_id.present? && access_token.present? && deposit_to_account_id.present? && payment_method_id.present?
38
+ end
39
+
36
40
  end
37
41
  end
@@ -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,19 @@ 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 = [purchasable.try(:qb_item_id), purchasable.try(:qb_item_name)].compact
34
+
32
35
  # Find item by receipt item
33
36
  item = items.find { |item| [item.id, item.name].include?(receipt_item.item_id) }
34
37
 
35
38
  # Find item by purchasable qb_item_id and qb_item_name
36
39
  item ||= begin
37
- purchasable_id_name = [purchasable.try(:qb_item_id), purchasable.try(:qb_item_name)]
38
40
  items.find { |item| ([item.id, item.name] & purchasable_id_name).present? }
39
41
  end
40
42
 
41
43
  if item.blank?
42
- raise("Unknown QuickBooks Item for #{purchasable} (#{purchasable.class.name} ##{purchasable.id})")
44
+ raise("Unknown Item #{purchasable_id_name.join(' or ')} from #{purchasable} (#{purchasable.class.name} ##{purchasable.id})")
43
45
  end
44
46
 
45
47
  receipt_item.update!(item_id: item.id)
@@ -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
- = card('Company') do
15
- = render('company', api: api)
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
@@ -0,0 +1,5 @@
1
+ %h1.effective-admin-heading= @page_title
2
+
3
+ %p The following items are present on the connected QuickBooks company.
4
+
5
+ = render_datatable(Admin::EffectiveQbItemsDatatable.new)
data/config/routes.rb CHANGED
@@ -21,6 +21,7 @@ EffectiveQbOnline::Engine.routes.draw do
21
21
  end
22
22
 
23
23
  get '/quickbooks', to: 'qb_online#index', as: :quickbooks
24
+ get '/quickbooks/items', to: 'qb_online#items', as: :quickbooks_items
24
25
  end
25
26
 
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.7'.freeze
3
3
  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.1.6
4
+ version: 0.1.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: 2022-04-14 00:00:00.000000000 Z
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