effective_qb_online 0.1.1 → 0.1.2

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: 1a31723c72961dc0ba5993baddd7ac885b7ecd7af18faeafdfb013b9a7e5b7c9
4
- data.tar.gz: 4b7b95d44a3781909dcf3c37cab321e4d9a1f0cafb4955e72427dfc48e2062a2
3
+ metadata.gz: f968250054d40c75ee2bc796e410de19045376c8f08677ee687f3490c9e6112b
4
+ data.tar.gz: 653edff54bf9a9a1eaace903f2b60097c472de077e6617dacf1dd68cf85035da
5
5
  SHA512:
6
- metadata.gz: 7836b7fe029d1235578a0eaa8c5baf2585a32af0c506a212ddbd14a8a57b6b02e35515de488249045876227489e3a128979609cf03a9de77780936f71b035c6c
7
- data.tar.gz: 4dea0b635bfd1fcb76f2b31ceab639bb721dabbf661d73a4e24eeb553b615fac1720f19491be26d1eef0536ada3da07fa9d74a11f08c01c0ea4f69e937edc463
6
+ metadata.gz: af13a7eb3903c75dedbcc8cdf234208393fe8f79438321bd7fc9f524c9d3d8c0ba91eb163c494f0919a1127197a0a4d5cf94e18f1417fc6cb7aa4fbd50523213
7
+ data.tar.gz: 359c596ffac483d5c1599b6008e590a0e58c8127be3ab468a6aab64bcb356035db2dde2de0cb8388bc17f0a5cb4849cac5f6b1424505ea5e5f4c771c1e2ae35f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Effective Quickbooks Online
1
+ # Effective QuickBooks Online
2
2
 
3
- Create Quickbooks Online SalesReceipts for purchased effective orders.
3
+ Create QuickBooks Online SalesReceipts for purchased effective orders. This is an unofficial integration that is not supported by or affiliated with Intuit.
4
4
 
5
5
  ## Getting Started
6
6
 
@@ -44,7 +44,7 @@ Add a link to the admin menu:
44
44
 
45
45
  ```haml
46
46
  - if can? :admin, :effective_qb_online
47
- = nav_link_to 'Quickbooks Online', effective_qb_online.admin_quickbooks_path
47
+ = nav_link_to 'QuickBooks Online', effective_qb_online.admin_quickbooks_path
48
48
  ```
49
49
 
50
50
  and visit `/admin/quickbooks`.
@@ -66,11 +66,11 @@ if user.admin?
66
66
  end
67
67
  ```
68
68
 
69
- ## Configuring Quickbooks Company
69
+ ## Configuring QuickBooks Company
70
70
 
71
- This gem has only been tested with a Canadian Quickbooks Online store.
71
+ This gem has only been tested with Canadian Quickbooks Online stores.
72
72
 
73
- It has GST, HST and Tax Exempt tax codes and rates set up ahead of time by Quickbooks.
73
+ It has GST, HST and Tax Exempt tax codes and rates set up ahead of time by QuickBooks.
74
74
 
75
75
  ## License
76
76
 
@@ -7,7 +7,7 @@ module Admin
7
7
 
8
8
  # /admin/quickbooks
9
9
  def index
10
- @page_title = 'Quickbooks Online'
10
+ @page_title = 'QuickBooks Online'
11
11
  end
12
12
 
13
13
  end
@@ -4,7 +4,7 @@ module Effective
4
4
  class QbOauthController < ApplicationController
5
5
  before_action(:authenticate_user!) if defined?(Devise)
6
6
 
7
- # Any user that has priviledges with the Quickbooks Online company could authenticate
7
+ # Any user that has priviledges with the QuickBooks Online company could authenticate
8
8
  # But we assume this user also has admin priviledges on our site
9
9
  # This should only be done once anyway
10
10
  before_action { EffectiveResources.authorize!(self, :admin, :effective_qb_online) }
@@ -20,7 +20,7 @@ module Effective
20
20
  redirect_to(grant_url)
21
21
  end
22
22
 
23
- # This matches the Quickbooks Redirect URI and we have to set it up ahead of time.
23
+ # This matches the QuickBooks Redirect URI and we have to set it up ahead of time.
24
24
  def callback
25
25
  return unless params[:code].present? && params[:realmId].present? && params[:state].present?
26
26
 
@@ -37,7 +37,7 @@ module Effective
37
37
  refresh_token_expires_at: (Time.at(token.expires_at) + 100.days)
38
38
  )
39
39
 
40
- flash[:success] = 'Successfully connected with Quickbooks Online'
40
+ flash[:success] = 'Successfully connected with QuickBooks Online'
41
41
 
42
42
  redirect_to(effective_qb_online.admin_quickbooks_path)
43
43
  end
@@ -53,7 +53,7 @@ module Effective
53
53
  response = token.post('/o/oauth2/revoke', params: { token: realm.refresh_token })
54
54
 
55
55
  if response.status == 200
56
- flash[:success] = 'Successfully revoked from Quickbooks Online'
56
+ flash[:success] = 'Successfully revoked from QuickBooks Online'
57
57
  realm.destroy!
58
58
  else
59
59
  flash[:danger] = 'Unable to revoke'
@@ -1,4 +1,4 @@
1
- # The Quickbooks namespace comes from quickbooks-ruby gem
1
+ # The QuickBooks namespace comes from quickbooks-ruby gem
2
2
  # https://github.com/ruckus/quickbooks-ruby
3
3
 
4
4
  module Effective
@@ -135,8 +135,8 @@ module Effective
135
135
  with_service('TaxRate') { |service| service.all }
136
136
  end
137
137
 
138
- # Returns a Hash of BigNumeral Tax Rate => TaxCode Object
139
- # { 0.0 => Quickbooks::Model::TaxCode }
138
+ # Returns a Hash of BigDecimal.to_s String Tax Rate => TaxCode Object
139
+ # { '0.0' => 'Quickbooks::Model::TaxCode(Exempt)', '5.0' => 'Quickbooks::Model::TaxCode(GST)' }
140
140
  def taxes_collection
141
141
  rates = tax_rates()
142
142
  codes = tax_codes()
@@ -180,10 +180,10 @@ module Effective
180
180
  token = OAuth2::AccessToken.new(EffectiveQbOnline.oauth2_client, realm.access_token, refresh_token: realm.refresh_token)
181
181
  yield(token)
182
182
  rescue OAuth2::Error, Quickbooks::AuthorizationFailure => e
183
- puts "Quickbooks OAuth Error: #{e.message}"
183
+ puts "QuickBooks OAuth Error: #{e.message}"
184
184
 
185
185
  attempts += 1
186
- raise "unable to refresh Quickbooks OAuth2 token" if attempts >= max_attempts
186
+ raise "unable to refresh QuickBooks OAuth2 token" if attempts >= max_attempts
187
187
 
188
188
  # Refresh
189
189
  refreshed = token.refresh!
@@ -1,10 +1,10 @@
1
- # One Quickbooks Realm / Company
1
+ # One QuickBooks Realm / Company
2
2
 
3
3
  module Effective
4
4
  class QbRealm < ActiveRecord::Base
5
5
 
6
6
  effective_resource do
7
- # As per Quickbooks oAuth
7
+ # As per QuickBooks oAuth
8
8
  realm_id :string
9
9
 
10
10
  access_token :text
@@ -30,7 +30,7 @@ module Effective
30
30
  validates :refresh_token_expires_at, presence: true
31
31
 
32
32
  def to_s
33
- 'Quickbooks Online Settings'
33
+ 'QuickBooks Online Settings'
34
34
  end
35
35
 
36
36
  end
@@ -13,7 +13,7 @@ module Effective
13
13
  # QuickBooks Customer
14
14
  customer_id :string
15
15
 
16
- # Quickbooks Online SalesReceipt id, once sync'd
16
+ # QuickBooks Online SalesReceipt id, once sync'd
17
17
  sales_receipt_id :string
18
18
 
19
19
  # Any error message from our sync
@@ -57,7 +57,7 @@ module Effective
57
57
  end
58
58
 
59
59
  def sync!(force: false)
60
- raise('Already created SalesReceipt with Quickbooks Online') if sales_receipt_id.present? && !force
60
+ raise('Already created SalesReceipt with QuickBooks Online') if sales_receipt_id.present? && !force
61
61
  save!
62
62
 
63
63
  api = EffectiveQbOnline.api
@@ -68,13 +68,14 @@ module Effective
68
68
 
69
69
  # Sanity check
70
70
  if (expected = api.price_to_amount(order.total)) != sales_receipt.total
71
- raise("A Quickbooks Online Sales Receipt has been created with an unexpected total. Quickbooks total is #{sales_receipt.total} but we expected #{expected}. Please adjust the Sales Receipt on Quickbooks")
71
+ raise("A QuickBooks Online Sales Receipt has been created with an unexpected total. QuickBooks total is #{sales_receipt.total} but we expected #{expected}. Please adjust the Sales Receipt on QuickBooks")
72
72
  end
73
73
 
74
74
  assign_attributes(result: 'completed successfully', sales_receipt_id: sales_receipt.id)
75
75
  complete!
76
76
  rescue => e
77
- assign_attributes(result: e.message)
77
+ result = [e.message, *("(intuit_tid: #{e.intuit_tid})" if e.try(:intuit_tid).present?)].join(' ')
78
+ assign_attributes(result: result)
78
79
  error!
79
80
  end
80
81
 
@@ -1,12 +1,12 @@
1
1
  module Effective
2
2
  class QbSalesReceipt
3
3
 
4
- # Build the Quickbooks SalesReceipt from a QbReceipt
4
+ # Build the QuickBooks SalesReceipt from a QbReceipt
5
5
  def self.build_from_receipt!(receipt, api: nil)
6
6
  raise('Expected a persisted Effective::QbReceipt') unless receipt.kind_of?(Effective::QbReceipt) && receipt.persisted?
7
7
 
8
8
  api ||= EffectiveQbOnline.api
9
- raise('Expected a connected Quickbooks API') unless api.present?
9
+ raise('Expected a connected QuickBooks API') unless api.present?
10
10
 
11
11
  order = receipt.order
12
12
  raise('Expected a purchased Effective::Order') unless order.purchased?
@@ -39,7 +39,7 @@ module Effective
39
39
  end
40
40
 
41
41
  if item.blank?
42
- raise("Unknown Quickbooks Item for #{purchasable} (#{purchasable.class.name} ##{purchasable.id})")
42
+ raise("Unknown QuickBooks Item for #{purchasable} (#{purchasable.class.name} ##{purchasable.id})")
43
43
  end
44
44
 
45
45
  receipt_item.update!(item_id: item.id)
@@ -54,7 +54,7 @@ module Effective
54
54
  # Receipt
55
55
  sales_receipt = Quickbooks::Model::SalesReceipt.new(
56
56
  customer_id: receipt.customer_id,
57
- deposit_to_account_id: api.realm.deposit_to_account_id, # The ID of the Account Entity you want hte SalesReceipt to be deposited to
57
+ deposit_to_account_id: api.realm.deposit_to_account_id, # The ID of the Account Entity you want the SalesReceipt to be deposited to
58
58
  payment_method_id: api.realm.payment_method_id, # The ID of the PaymentMethod Entity
59
59
  payment_ref_number: order.to_param, # Optional payment reference number/string
60
60
  txn_date: order.purchased_at.to_date,
@@ -64,7 +64,7 @@ module Effective
64
64
  email_status: 'EmailSent'
65
65
  )
66
66
 
67
- # Allows Quickbooks to auto-generate the transaction number
67
+ # Allows QuickBooks to auto-generate the transaction number
68
68
  sales_receipt.auto_doc_number!
69
69
 
70
70
  # Addresses
@@ -11,9 +11,9 @@
11
11
  %td= company_info.country
12
12
 
13
13
  %tr
14
- %td Quickbooks Online
14
+ %td QuickBooks Online
15
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?')
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
17
 
18
18
  %tr
19
19
  %td Deposit to Account
@@ -1,5 +1,5 @@
1
1
  %p Welcome!
2
- %p Please click below to connect this website with your Quickbooks Online company.
2
+ %p Please click below to connect this website with your QuickBooks Online company.
3
3
 
4
4
  %p
5
5
  = link_to(effective_qb_online.quickbooks_oauth_path) do
@@ -7,11 +7,11 @@
7
7
 
8
8
  %p
9
9
  If it's not connecting, make sure the
10
- Quickbooks Application has the correct Redirect URI.
10
+ QuickBooks Application has the correct Redirect URI.
11
11
 
12
12
  %ul
13
13
  %li The url is: #{effective_qb_online.quickbooks_oauth_callback_url}
14
14
 
15
15
  %p
16
- Once connected, a Quickbooks Online Sales Receipt
16
+ Once connected, a QuickBooks Online Sales Receipt
17
17
  will be created when an order is purchased.
@@ -3,7 +3,7 @@
3
3
  - api = EffectiveQbOnline.api
4
4
 
5
5
  - if api.blank?
6
- = card('Connect to Quickbooks Online') do
6
+ = card('Connect to QuickBooks Online') do
7
7
  = render('connect')
8
8
 
9
9
  - if api.present?
@@ -11,7 +11,7 @@
11
11
  = f.static_field :updated_at
12
12
 
13
13
  = f.static_field :status
14
- = f.static_field :result, label: 'Quickbooks Online Result'
14
+ = f.static_field :result, label: 'QuickBooks Online Result'
15
15
 
16
16
  %table.table.table-sm
17
17
  %thead
@@ -19,7 +19,7 @@
19
19
  %th Id
20
20
  %th Order Item
21
21
  %th Existing Name
22
- %th Quickbooks Online Item
22
+ %th QuickBooks Online Item
23
23
 
24
24
  %tbody
25
25
  - items_collection = EffectiveQbOnline.api.items_collection
@@ -7,12 +7,12 @@ EffectiveQbOnline.setup do |config|
7
7
  # Configure the Layout per controller, or all at once
8
8
  # config.layout = { application: 'application', admin: 'admin' }
9
9
 
10
- # Quickbooks Online Application
10
+ # QuickBooks Online Application
11
11
  # Client and Seceret
12
12
  config.oauth_client_id = ENV['QUICKBOOKS_ONLINE_OAUTH_CLIENT_ID']
13
13
  config.oauth_client_secret = ENV['QUICKBOOKS_ONLINE_OAUTH_CLIENT_SECRET']
14
14
 
15
- # Quickbooks API
15
+ # QuickBooks API
16
16
  # https://github.com/ruckus/quickbooks-ruby
17
17
  Quickbooks.sandbox_mode = (ENV['QUICKBOOKS_ONLINE_SANDBOX'].to_s == 'true')
18
18
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveQbOnline
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.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.1
4
+ version: 0.1.2
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-02-18 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -192,7 +192,7 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
- description: Create Quickbooks Online SalesReceipts for purchased effective orders
195
+ description: Create QuickBooks Online SalesReceipts for purchased effective orders
196
196
  email:
197
197
  - info@codeandeffect.com
198
198
  executables: []
@@ -259,5 +259,5 @@ requirements: []
259
259
  rubygems_version: 3.1.2
260
260
  signing_key:
261
261
  specification_version: 4
262
- summary: Create Quickbooks Online SalesReceipts for purchased effective orders
262
+ summary: Create QuickBooks Online SalesReceipts for purchased effective orders
263
263
  test_files: []