effective_qb_online 0.7.0 → 0.7.1

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: 842a17b9ed39140d60b1e8d579a6a8ac73e7ccb44fc9c977afe71fd7ba6f7566
4
- data.tar.gz: 5d9aa52fcd52d31d1b13c4fae7b48fefdca77da9a737bf2881c8bc0c19c4332e
3
+ metadata.gz: 15867b1dfe0acb70639a0d07a4f772288659f3bbb48161fc95587f13c4709365
4
+ data.tar.gz: 7836486e1ca0178fb7defd247a5e338a78f9124e1e401fc28e29f1b1da175b0c
5
5
  SHA512:
6
- metadata.gz: 8f24c8045da3be2527514640de6d2f62985a0f5d16299eeed5775cb3c96ed5a745ce53808df6027b044e33947db41d296e077f9d1cb846cac6636446781da82a
7
- data.tar.gz: 1d84f06fccbc0570ffce4470c046ce12c4b3d58a345e9d37a625b1a6721536b1126504287b928303e26bd8278a10bcdd13aa9bb9dbc89c069ceb351c261930c7
6
+ metadata.gz: e9876ee172702a699a7892957df6a8f129c2b4045a9a4ce66ab1f0b1162eb6c5bdd2b06339afbb61f13f78bf14c79d0f024a3228070d19b83f6a5aa0104d2bb7
7
+ data.tar.gz: 6b41207fbf79478358b629fb329521e0b9b7c8c819ff914cf632e82d73d618bf9bd8ef5ccdf2ad088bbb7d1456b80977bf8520fd3abce4797a047e5f14c5728b
@@ -0,0 +1,19 @@
1
+ module Effective
2
+ class QbOnlineMailer < EffectiveQbOnline.parent_mailer_class
3
+ include EffectiveMailer
4
+
5
+ def sync_error(resource, opts = {})
6
+ raise('expected an Effective::QbReceipt') unless resource.kind_of?(Effective::QbReceipt)
7
+
8
+ @qb_receipt = resource
9
+ @order = resource.order
10
+
11
+ to = EffectiveOrders.qb_online_sync_error_recipients.presence || EffectiveOrders.mailer_admin
12
+ subject = subject_for(__method__, "Quickbooks Sync Error - Order ##{@order.to_param}", resource, opts)
13
+ headers = headers_for(resource, opts)
14
+
15
+ mail(to: to, subject: subject, **headers)
16
+ end
17
+
18
+ end
19
+ end
@@ -74,7 +74,7 @@ module Effective
74
74
  assign_attributes(result: 'completed successfully', sales_receipt_id: sales_receipt.id)
75
75
  complete!
76
76
  rescue => e
77
- result = [e.message, *("(intuit_tid: #{e.intuit_tid})" if e.try(:intuit_tid).present?), e.backtrace.first(15).join("\n\n")].join(' ')
77
+ result = [e.message, ("(intuit_tid: #{e.intuit_tid})" if e.try(:intuit_tid).present?), e.backtrace.first(15)].compact.flatten.join("\n\n")
78
78
  assign_attributes(result: result)
79
79
  error!
80
80
  end
@@ -93,6 +93,7 @@ module Effective
93
93
  def error!
94
94
  errored!
95
95
  EffectiveLogger.error(result, associated: self) if defined?(EffectiveLogger)
96
+ EffectiveQbOnline.send_email(:sync_error, self)
96
97
 
97
98
  false
98
99
  end
@@ -0,0 +1,44 @@
1
+ %p An error occurred while synchronizing Order ##{@order.to_param} to Quickbooks Online
2
+
3
+ %div
4
+ %strong Error Message
5
+ = simple_format(@qb_receipt.result)
6
+
7
+ %div
8
+ %strong= "Order ##{@order.to_param}"
9
+ %br
10
+ = @order.created_at
11
+ %br
12
+ = @order.billing_name
13
+ %p
14
+ - @order.order_items.each do |oi|
15
+ = "#{oi.name} (#{oi.try(:qb_item_name)})"
16
+ %br
17
+
18
+ %p
19
+ %strong Resolution Steps
20
+ %br
21
+
22
+ - if @qb_receipt.result.to_s.include?('Duplicate Name Exists')
23
+ %ul
24
+ %li This customer could not be created because they share a name with an existing Item Name. This could be as a Vendor, Product, or Service.
25
+ %li Search QuickBooks for the non-customer item name and rename it. Ex: rename "John Doe" to "John Doe (Vendor)"
26
+ %li Re-run the QuickBooks Sync
27
+ - elsif @qb_receipt.result.to_s.include?('Unknown Item')
28
+ %ul
29
+ %li Confirm the QuickBooks Item Names for this Order within QuickBooks
30
+ %li If this Item Name does not exist, add it to QuickBooks
31
+ %li Otherwise, #{link_to('click here', effective_qb_online.edit_admin_qb_receipt_url(@qb_receipt))} to assign the correct Item Name to this Order
32
+ %li Re-run the QuickBooks Sync
33
+ - else
34
+ %ul
35
+ %li This is an error without a predefined resolution.
36
+ %li Please contact support.
37
+
38
+ %hr
39
+
40
+ %p{style: "text-align: center;"}
41
+ = link_to "View Quickbooks Sales Receipts", effective_qb_online.admin_quickbooks_url
42
+
43
+ %p{style: "text-align: center;"}
44
+ = link_to "View Order ##{@order.to_param}", effective_orders.admin_order_url(@order)
@@ -12,8 +12,18 @@ EffectiveQbOnline.setup do |config|
12
12
  # https://github.com/ruckus/quickbooks-ruby
13
13
  Quickbooks.sandbox_mode = (ENV['QUICKBOOKS_ONLINE_SANDBOX'].to_s == 'true')
14
14
 
15
- # Effective Orders
16
- # Add the following to your config/intializers/effective_orders.rb
17
- # config.use_effective_qb_online = true
18
-
15
+ # Mailer Settings
16
+ # Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
17
+ #
18
+ # Configure the class responsible to send e-mails.
19
+ # config.mailer = 'Effective::QbOnlineMailer'
20
+ #
21
+ # Override effective_resource mailer defaults
22
+ #
23
+ # config.parent_mailer = nil # The parent class responsible for sending emails
24
+ # config.deliver_method = nil # The deliver method, deliver_later or deliver_now
25
+ # config.mailer_layout = nil # Default mailer layout
26
+ # config.mailer_sender = nil # Default From value
27
+ # config.mailer_admin = nil # Default To value for Admin correspondence
28
+ # config.mailer_subject = nil # Proc.new method used to customize Subject
19
29
  end
@@ -1,11 +1,10 @@
1
1
  class CreateEffectiveQbOnline < ActiveRecord::Migration[6.0]
2
2
  def change
3
- create_table :qb_realms do |t|
3
+ create_table :qb_realms, if_not_exists: true do |t|
4
4
  t.string :realm_id
5
5
 
6
- t.integer :deposit_to_account_id
7
- t.integer :payment_method_id
8
- t.boolean :order_number_as_transaction_number, default: false
6
+ t.string :deposit_to_account_id
7
+ t.string :payment_method_id
9
8
 
10
9
  t.text :access_token
11
10
  t.datetime :access_token_expires_at
@@ -13,12 +12,16 @@ class CreateEffectiveQbOnline < ActiveRecord::Migration[6.0]
13
12
  t.text :refresh_token
14
13
  t.datetime :refresh_token_expires_at
15
14
 
15
+ t.boolean :order_number_as_transaction_number, default: false
16
+
16
17
  t.timestamps
17
18
  end
18
19
 
19
- create_table :qb_receipts do |t|
20
+ create_table :qb_receipts, if_not_exists: true do |t|
20
21
  t.integer :order_id
21
- t.integer :customer_id
22
+
23
+ t.string :customer_id
24
+ t.string :sales_receipt_id
22
25
 
23
26
  t.text :result
24
27
 
@@ -28,13 +31,13 @@ class CreateEffectiveQbOnline < ActiveRecord::Migration[6.0]
28
31
  t.timestamps
29
32
  end
30
33
 
31
- add_index :qb_receipts, :order_id
34
+ add_index :qb_receipts, :order_id, if_not_exists: true
32
35
 
33
- create_table :qb_receipt_items_name do |t|
36
+ create_table :qb_receipt_items, if_not_exists: true do |t|
34
37
  t.integer :qb_receipt_id
35
38
  t.integer :order_item_id
36
39
 
37
- t.integer :item_id
40
+ t.string :item_id
38
41
 
39
42
  t.timestamps
40
43
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.7.1'.freeze
3
3
  end
@@ -8,6 +8,7 @@ module EffectiveQbOnline
8
8
  def self.config_keys
9
9
  [
10
10
  :qb_realms_table_name, :qb_receipts_table_name, :qb_receipt_items_table_name,
11
+ :mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject,
11
12
  :oauth_client_id, :oauth_client_secret,
12
13
  :layout
13
14
  ]
@@ -15,6 +16,10 @@ module EffectiveQbOnline
15
16
 
16
17
  include EffectiveGem
17
18
 
19
+ def self.mailer_class
20
+ mailer&.constantize || Effective::QbOnlineMailer
21
+ end
22
+
18
23
  def self.oauth2_client
19
24
  OAuth2::Client.new(
20
25
  oauth_client_id,
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.7.0
4
+ version: 0.7.1
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: 2025-04-17 00:00:00.000000000 Z
11
+ date: 2025-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -216,6 +216,7 @@ files:
216
216
  - app/datatables/admin/effective_qb_receipts_datatable.rb
217
217
  - app/helpers/effective_qb_online_helper.rb
218
218
  - app/jobs/qb_sync_order_job.rb
219
+ - app/mailers/effective/qb_online_mailer.rb
219
220
  - app/models/effective/qb_api.rb
220
221
  - app/models/effective/qb_realm.rb
221
222
  - app/models/effective/qb_receipt.rb
@@ -229,6 +230,7 @@ files:
229
230
  - app/views/admin/qb_receipts/_form.html.haml
230
231
  - app/views/admin/qb_receipts/edit.html.haml
231
232
  - app/views/admin/qb_receipts/new.html.haml
233
+ - app/views/effective/qb_online_mailer/sync_error.html.haml
232
234
  - config/effective_qb_online.rb
233
235
  - config/routes.rb
234
236
  - db/migrate/101_create_effective_qb_online.rb