effective_qb_online 0.1.2 → 0.1.5

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: f968250054d40c75ee2bc796e410de19045376c8f08677ee687f3490c9e6112b
4
- data.tar.gz: 653edff54bf9a9a1eaace903f2b60097c472de077e6617dacf1dd68cf85035da
3
+ metadata.gz: b576a3949ed29e03fff73780968b77c380cd4454c8117b39aba87690f96a0ae9
4
+ data.tar.gz: c16c7f2ad020a416e0fae62fa98016cff913f1bd372e4e06feb8cd042954ebae
5
5
  SHA512:
6
- metadata.gz: af13a7eb3903c75dedbcc8cdf234208393fe8f79438321bd7fc9f524c9d3d8c0ba91eb163c494f0919a1127197a0a4d5cf94e18f1417fc6cb7aa4fbd50523213
7
- data.tar.gz: 359c596ffac483d5c1599b6008e590a0e58c8127be3ab468a6aab64bcb356035db2dde2de0cb8388bc17f0a5cb4849cac5f6b1424505ea5e5f4c771c1e2ae35f
6
+ metadata.gz: 07c548ac7ea522e377897dca08cb17f77b3db74b3633bd61135584297857c04100a7adc1942f410b141dbbb2c7e3968e748c2769f4e32c98fbd627977924c8fc
7
+ data.tar.gz: d4986d17edbe98241942c5888537f2593fcbab09a0ddf81c6194989a0daf7db7124025c992c0d39ac1157077314cd8b6dd3dcdbdecd6dabd05e4a00e428e6c99
@@ -1,7 +1,7 @@
1
1
  class QbSyncOrderJob < ApplicationJob
2
2
  queue_as :default
3
3
 
4
- def perform(order)
4
+ def perform(order, opts = {})
5
5
  raise('expected a purchased Effective::Order') unless order.kind_of?(Effective::Order) && order.purchased?
6
6
 
7
7
  puts "Starting QB Sync Order Job for order #{order}"
@@ -41,6 +41,14 @@ module Effective
41
41
  )
42
42
  end
43
43
 
44
+ def api_error
45
+ begin
46
+ company_info.present?; nil
47
+ rescue => e
48
+ return e.message
49
+ end
50
+ end
51
+
44
52
  # Singular
45
53
  def company_info
46
54
  with_service('CompanyInfo') { |service| service.fetch_by_id(realm.realm_id) }
@@ -67,10 +75,29 @@ module Effective
67
75
  items
68
76
  .reject { |item| item.type == 'Category' }
69
77
  .sort_by { |item| [item.type, item.name] }
70
- .map { |item| [item.name, item.id, item.type] }
78
+ .map { |item| [item_name(item), item.id, {'data-html': item_html(item)}, item.type] }
71
79
  .group_by(&:last)
72
80
  end
73
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
+ def item_html(item)
92
+ details = [
93
+ ("##{item.id}"),
94
+ (item.sku if item.sku.present?),
95
+ (item.description if item.description.present?)
96
+ ].compact.join(', ')
97
+
98
+ "<span>#{item.name}</span> <small>(#{details})</small>"
99
+ end
100
+
74
101
  def payment_methods
75
102
  with_service('PaymentMethod') { |service| service.all }
76
103
  end
@@ -1,32 +1,46 @@
1
- %table.table.table-sm
2
- - company_info = api.company_info
3
-
4
- %tbody
5
- %tr
6
- %td Name
7
- %td= company_info.company_name
8
-
9
- %tr
10
- %td Country
11
- %td= company_info.country
12
-
13
- %tr
14
- %td QuickBooks Online
15
- %td
16
- = link_to('Revoke Access and Disconnect', effective_qb_online.revoke_quickbooks_oauth_path, class: 'btn btn-sm btn-danger', 'data-method': 'delete', 'data-confirm': 'Really disconnect from QuickBooks Online?')
17
-
18
- %tr
19
- %td Deposit to Account
20
- %td
21
- = effective_form_with(model: [:admin, api.realm], engine: true) do |f|
22
- .row
23
- .col= f.select :deposit_to_account_id, api.accounts_collection, grouped: true, label: false
24
- .col= f.save
25
-
26
- %tr
27
- %td Payment Method
28
- %td
29
- = effective_form_with(model: [:admin, api.realm], engine: true) do |f|
30
- .row
31
- .col= f.select :payment_method_id, api.payment_methods_collection, label: false
32
- .col= f.save
1
+ - company_info = (api.company_info rescue nil)
2
+
3
+ - if company_info.present?
4
+ %table.table.table-sm
5
+ %tbody
6
+ %tr
7
+ %td Name
8
+ %td= company_info.company_name
9
+
10
+ %tr
11
+ %td Country
12
+ %td= company_info.country
13
+
14
+ %tr
15
+ %td QuickBooks Online
16
+ %td
17
+ = link_to('Revoke Access and Disconnect', effective_qb_online.revoke_quickbooks_oauth_path, class: 'btn btn-sm btn-danger', 'data-method': 'delete', 'data-confirm': 'Really disconnect from QuickBooks Online?')
18
+
19
+ %tr
20
+ %td Deposit to Account
21
+ %td
22
+ = effective_form_with(model: [:admin, api.realm], engine: true) do |f|
23
+ .row
24
+ .col= f.select :deposit_to_account_id, api.accounts_collection, grouped: true, label: false
25
+ .col= f.save
26
+
27
+ %tr
28
+ %td Payment Method
29
+ %td
30
+ = effective_form_with(model: [:admin, api.realm], engine: true) do |f|
31
+ .row
32
+ .col= f.select :payment_method_id, api.payment_methods_collection, label: false
33
+ .col= f.save
34
+
35
+
36
+ - if company_info.blank?
37
+ %table.table.table-sm
38
+ %tbody
39
+ %tr
40
+ %td QuickBooks API Error
41
+ %td= api.api_error
42
+
43
+ %tr
44
+ %td QuickBooks Online
45
+ %td
46
+ = link_to('Revoke Access and Disconnect', effective_qb_online.revoke_quickbooks_oauth_path, class: 'btn btn-sm btn-danger', 'data-method': 'delete', 'data-confirm': 'Really disconnect from QuickBooks Online?')
@@ -35,6 +35,6 @@
35
35
 
36
36
  = existing || fi.object.order_item_qb_name || '-'
37
37
 
38
- %td= fi.select :item_id, items_collection, grouped: true, label: false
38
+ %td= fi.select :item_id, items_collection, grouped: true, label: false, template: :html
39
39
 
40
40
  = f.submit 'Save and Sync'
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
@@ -1,4 +1,4 @@
1
- module EffectiveMemberships
1
+ module EffectiveQbOnline
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
  include Rails::Generators::Migration
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.2
4
+ version: 0.1.5
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-03-07 00:00:00.000000000 Z
11
+ date: 2022-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails