ledger_sync-quickbooks_online 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.env.test +9 -0
  4. data/.gitignore +21 -0
  5. data/.overcommit.yml +29 -0
  6. data/.rubocop.yml +78 -0
  7. data/.rubocop_todo.yml +25 -0
  8. data/.travis.yml +25 -0
  9. data/Gemfile +8 -0
  10. data/Gemfile.lock +211 -0
  11. data/README.md +19 -0
  12. data/Rakefile +8 -0
  13. data/bin/console +15 -0
  14. data/bin/quickbooks_online_oauth_server.rb +104 -0
  15. data/bin/setup +8 -0
  16. data/ledger_sync-quickbooks_online.gemspec +46 -0
  17. data/lib/ledger_sync/quickbooks_online.rb +14 -0
  18. data/lib/ledger_sync/quickbooks_online/account/deserializer.rb +29 -0
  19. data/lib/ledger_sync/quickbooks_online/account/operations/create.rb +26 -0
  20. data/lib/ledger_sync/quickbooks_online/account/operations/find.rb +26 -0
  21. data/lib/ledger_sync/quickbooks_online/account/operations/update.rb +28 -0
  22. data/lib/ledger_sync/quickbooks_online/account/searcher.rb +13 -0
  23. data/lib/ledger_sync/quickbooks_online/account/serializer.rb +29 -0
  24. data/lib/ledger_sync/quickbooks_online/account_based_expense_line_detail/deserializer.rb +19 -0
  25. data/lib/ledger_sync/quickbooks_online/account_based_expense_line_detail/serializer.rb +19 -0
  26. data/lib/ledger_sync/quickbooks_online/bill/deserializer.rb +39 -0
  27. data/lib/ledger_sync/quickbooks_online/bill/operations/create.rb +27 -0
  28. data/lib/ledger_sync/quickbooks_online/bill/operations/find.rb +27 -0
  29. data/lib/ledger_sync/quickbooks_online/bill/operations/update.rb +27 -0
  30. data/lib/ledger_sync/quickbooks_online/bill/searcher.rb +12 -0
  31. data/lib/ledger_sync/quickbooks_online/bill/serializer.rb +39 -0
  32. data/lib/ledger_sync/quickbooks_online/bill_line/deserializer.rb +20 -0
  33. data/lib/ledger_sync/quickbooks_online/bill_line/serializer.rb +24 -0
  34. data/lib/ledger_sync/quickbooks_online/bill_payment/deserializer.rb +53 -0
  35. data/lib/ledger_sync/quickbooks_online/bill_payment/operations/create.rb +31 -0
  36. data/lib/ledger_sync/quickbooks_online/bill_payment/operations/find.rb +31 -0
  37. data/lib/ledger_sync/quickbooks_online/bill_payment/operations/update.rb +31 -0
  38. data/lib/ledger_sync/quickbooks_online/bill_payment/serializer.rb +53 -0
  39. data/lib/ledger_sync/quickbooks_online/bill_payment_line/deserializer.rb +14 -0
  40. data/lib/ledger_sync/quickbooks_online/bill_payment_line/serializer.rb +14 -0
  41. data/lib/ledger_sync/quickbooks_online/check_payment/deserializer.rb +15 -0
  42. data/lib/ledger_sync/quickbooks_online/check_payment/serializer.rb +15 -0
  43. data/lib/ledger_sync/quickbooks_online/client.rb +235 -0
  44. data/lib/ledger_sync/quickbooks_online/config.rb +15 -0
  45. data/lib/ledger_sync/quickbooks_online/credit_card_payment/deserializer.rb +15 -0
  46. data/lib/ledger_sync/quickbooks_online/credit_card_payment/serializer.rb +15 -0
  47. data/lib/ledger_sync/quickbooks_online/currency/deserializer.rb +14 -0
  48. data/lib/ledger_sync/quickbooks_online/currency/serializer.rb +15 -0
  49. data/lib/ledger_sync/quickbooks_online/customer/deserializer.rb +24 -0
  50. data/lib/ledger_sync/quickbooks_online/customer/operations/create.rb +24 -0
  51. data/lib/ledger_sync/quickbooks_online/customer/operations/find.rb +24 -0
  52. data/lib/ledger_sync/quickbooks_online/customer/operations/update.rb +24 -0
  53. data/lib/ledger_sync/quickbooks_online/customer/searcher.rb +13 -0
  54. data/lib/ledger_sync/quickbooks_online/customer/serializer.rb +24 -0
  55. data/lib/ledger_sync/quickbooks_online/dashboard_url_helper.rb +32 -0
  56. data/lib/ledger_sync/quickbooks_online/department/deserializer.rb +20 -0
  57. data/lib/ledger_sync/quickbooks_online/department/operations/create.rb +23 -0
  58. data/lib/ledger_sync/quickbooks_online/department/operations/find.rb +23 -0
  59. data/lib/ledger_sync/quickbooks_online/department/operations/update.rb +23 -0
  60. data/lib/ledger_sync/quickbooks_online/department/searcher.rb +15 -0
  61. data/lib/ledger_sync/quickbooks_online/department/serializer.rb +39 -0
  62. data/lib/ledger_sync/quickbooks_online/deposit/deserializer.rb +34 -0
  63. data/lib/ledger_sync/quickbooks_online/deposit/operations/create.rb +25 -0
  64. data/lib/ledger_sync/quickbooks_online/deposit/operations/find.rb +25 -0
  65. data/lib/ledger_sync/quickbooks_online/deposit/operations/update.rb +25 -0
  66. data/lib/ledger_sync/quickbooks_online/deposit/searcher.rb +12 -0
  67. data/lib/ledger_sync/quickbooks_online/deposit/serializer.rb +34 -0
  68. data/lib/ledger_sync/quickbooks_online/deposit_line/deserializer.rb +20 -0
  69. data/lib/ledger_sync/quickbooks_online/deposit_line/serializer.rb +24 -0
  70. data/lib/ledger_sync/quickbooks_online/deposit_line_detail/deserializer.rb +32 -0
  71. data/lib/ledger_sync/quickbooks_online/deposit_line_detail/serializer.rb +33 -0
  72. data/lib/ledger_sync/quickbooks_online/deserializer.rb +97 -0
  73. data/lib/ledger_sync/quickbooks_online/expense/deserializer.rb +52 -0
  74. data/lib/ledger_sync/quickbooks_online/expense/operations/create.rb +28 -0
  75. data/lib/ledger_sync/quickbooks_online/expense/operations/find.rb +28 -0
  76. data/lib/ledger_sync/quickbooks_online/expense/operations/update.rb +28 -0
  77. data/lib/ledger_sync/quickbooks_online/expense/searcher.rb +12 -0
  78. data/lib/ledger_sync/quickbooks_online/expense/serializer.rb +51 -0
  79. data/lib/ledger_sync/quickbooks_online/expense_line/deserializer.rb +20 -0
  80. data/lib/ledger_sync/quickbooks_online/expense_line/serializer.rb +24 -0
  81. data/lib/ledger_sync/quickbooks_online/invoice/deserializer.rb +33 -0
  82. data/lib/ledger_sync/quickbooks_online/invoice/operations/create.rb +25 -0
  83. data/lib/ledger_sync/quickbooks_online/invoice/operations/find.rb +25 -0
  84. data/lib/ledger_sync/quickbooks_online/invoice/operations/update.rb +25 -0
  85. data/lib/ledger_sync/quickbooks_online/invoice/serializer.rb +33 -0
  86. data/lib/ledger_sync/quickbooks_online/invoice_line/deserializer.rb +19 -0
  87. data/lib/ledger_sync/quickbooks_online/invoice_line/serializer.rb +23 -0
  88. data/lib/ledger_sync/quickbooks_online/item/deserializer.rb +11 -0
  89. data/lib/ledger_sync/quickbooks_online/item/serializer.rb +10 -0
  90. data/lib/ledger_sync/quickbooks_online/journal_entry/deserializer.rb +26 -0
  91. data/lib/ledger_sync/quickbooks_online/journal_entry/operations/create.rb +23 -0
  92. data/lib/ledger_sync/quickbooks_online/journal_entry/operations/find.rb +23 -0
  93. data/lib/ledger_sync/quickbooks_online/journal_entry/operations/update.rb +23 -0
  94. data/lib/ledger_sync/quickbooks_online/journal_entry/searcher.rb +12 -0
  95. data/lib/ledger_sync/quickbooks_online/journal_entry/serializer.rb +26 -0
  96. data/lib/ledger_sync/quickbooks_online/journal_entry_line/deserializer.rb +18 -0
  97. data/lib/ledger_sync/quickbooks_online/journal_entry_line/serializer.rb +22 -0
  98. data/lib/ledger_sync/quickbooks_online/journal_entry_line_detail/deserializer.rb +27 -0
  99. data/lib/ledger_sync/quickbooks_online/journal_entry_line_detail/serializer.rb +27 -0
  100. data/lib/ledger_sync/quickbooks_online/ledger_class/deserializer.rb +22 -0
  101. data/lib/ledger_sync/quickbooks_online/ledger_class/operations/create.rb +23 -0
  102. data/lib/ledger_sync/quickbooks_online/ledger_class/operations/find.rb +23 -0
  103. data/lib/ledger_sync/quickbooks_online/ledger_class/operations/update.rb +23 -0
  104. data/lib/ledger_sync/quickbooks_online/ledger_class/searcher.rb +13 -0
  105. data/lib/ledger_sync/quickbooks_online/ledger_class/serializer.rb +22 -0
  106. data/lib/ledger_sync/quickbooks_online/oauth_client.rb +91 -0
  107. data/lib/ledger_sync/quickbooks_online/operation.rb +59 -0
  108. data/lib/ledger_sync/quickbooks_online/operation/create.rb +24 -0
  109. data/lib/ledger_sync/quickbooks_online/operation/find.rb +23 -0
  110. data/lib/ledger_sync/quickbooks_online/operation/full_update.rb +40 -0
  111. data/lib/ledger_sync/quickbooks_online/operation/sparse_update.rb +27 -0
  112. data/lib/ledger_sync/quickbooks_online/payment/deserializer.rb +40 -0
  113. data/lib/ledger_sync/quickbooks_online/payment/operations/create.rb +28 -0
  114. data/lib/ledger_sync/quickbooks_online/payment/operations/find.rb +28 -0
  115. data/lib/ledger_sync/quickbooks_online/payment/operations/update.rb +28 -0
  116. data/lib/ledger_sync/quickbooks_online/payment/serializer.rb +40 -0
  117. data/lib/ledger_sync/quickbooks_online/payment_line/deserializer.rb +15 -0
  118. data/lib/ledger_sync/quickbooks_online/payment_line/serializer.rb +15 -0
  119. data/lib/ledger_sync/quickbooks_online/preferences/deserializer.rb +22 -0
  120. data/lib/ledger_sync/quickbooks_online/preferences/operations/find.rb +28 -0
  121. data/lib/ledger_sync/quickbooks_online/preferences/serializer.rb +22 -0
  122. data/lib/ledger_sync/quickbooks_online/primary_email_addr/deserializer.rb +11 -0
  123. data/lib/ledger_sync/quickbooks_online/primary_email_addr/serializer.rb +11 -0
  124. data/lib/ledger_sync/quickbooks_online/primary_phone/deserializer.rb +11 -0
  125. data/lib/ledger_sync/quickbooks_online/primary_phone/serializer.rb +11 -0
  126. data/lib/ledger_sync/quickbooks_online/reference/deserializer.rb +11 -0
  127. data/lib/ledger_sync/quickbooks_online/reference/serializer.rb +11 -0
  128. data/lib/ledger_sync/quickbooks_online/request.rb +96 -0
  129. data/lib/ledger_sync/quickbooks_online/resource.rb +8 -0
  130. data/lib/ledger_sync/quickbooks_online/resources/account.rb +357 -0
  131. data/lib/ledger_sync/quickbooks_online/resources/account_based_expense_line_detail.rb +17 -0
  132. data/lib/ledger_sync/quickbooks_online/resources/bill.rb +29 -0
  133. data/lib/ledger_sync/quickbooks_online/resources/bill_line.rb +17 -0
  134. data/lib/ledger_sync/quickbooks_online/resources/bill_payment.rb +42 -0
  135. data/lib/ledger_sync/quickbooks_online/resources/bill_payment_line.rb +17 -0
  136. data/lib/ledger_sync/quickbooks_online/resources/check_payment.rb +11 -0
  137. data/lib/ledger_sync/quickbooks_online/resources/credit_card_payment.rb +11 -0
  138. data/lib/ledger_sync/quickbooks_online/resources/currency.rb +15 -0
  139. data/lib/ledger_sync/quickbooks_online/resources/customer.rb +22 -0
  140. data/lib/ledger_sync/quickbooks_online/resources/department.rb +20 -0
  141. data/lib/ledger_sync/quickbooks_online/resources/deposit.rb +26 -0
  142. data/lib/ledger_sync/quickbooks_online/resources/deposit_line.rb +17 -0
  143. data/lib/ledger_sync/quickbooks_online/resources/deposit_line_detail.rb +20 -0
  144. data/lib/ledger_sync/quickbooks_online/resources/expense.rb +38 -0
  145. data/lib/ledger_sync/quickbooks_online/resources/expense_line.rb +17 -0
  146. data/lib/ledger_sync/quickbooks_online/resources/invoice.rb +26 -0
  147. data/lib/ledger_sync/quickbooks_online/resources/invoice_line.rb +17 -0
  148. data/lib/ledger_sync/quickbooks_online/resources/item.rb +9 -0
  149. data/lib/ledger_sync/quickbooks_online/resources/journal_entry.rb +22 -0
  150. data/lib/ledger_sync/quickbooks_online/resources/journal_entry_line.rb +18 -0
  151. data/lib/ledger_sync/quickbooks_online/resources/journal_entry_line_detail.rb +25 -0
  152. data/lib/ledger_sync/quickbooks_online/resources/ledger_class.rb +18 -0
  153. data/lib/ledger_sync/quickbooks_online/resources/payment.rb +29 -0
  154. data/lib/ledger_sync/quickbooks_online/resources/payment_line.rb +17 -0
  155. data/lib/ledger_sync/quickbooks_online/resources/preferences.rb +22 -0
  156. data/lib/ledger_sync/quickbooks_online/resources/primary_email_addr.rb +9 -0
  157. data/lib/ledger_sync/quickbooks_online/resources/primary_phone.rb +9 -0
  158. data/lib/ledger_sync/quickbooks_online/resources/sales_item_line_detail.rb +17 -0
  159. data/lib/ledger_sync/quickbooks_online/resources/transfer.rb +22 -0
  160. data/lib/ledger_sync/quickbooks_online/resources/vendor.rb +23 -0
  161. data/lib/ledger_sync/quickbooks_online/sales_item_line_detail/deserializer.rb +19 -0
  162. data/lib/ledger_sync/quickbooks_online/sales_item_line_detail/serializer.rb +19 -0
  163. data/lib/ledger_sync/quickbooks_online/searcher.rb +58 -0
  164. data/lib/ledger_sync/quickbooks_online/serialization/type/amount_float_to_integer_type.rb +19 -0
  165. data/lib/ledger_sync/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb +28 -0
  166. data/lib/ledger_sync/quickbooks_online/serialization/type/integer_to_amount_float_type.rb +19 -0
  167. data/lib/ledger_sync/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb +28 -0
  168. data/lib/ledger_sync/quickbooks_online/serializer.rb +69 -0
  169. data/lib/ledger_sync/quickbooks_online/serialziation/type/mapping_type.rb +27 -0
  170. data/lib/ledger_sync/quickbooks_online/transfer/deserializer.rb +29 -0
  171. data/lib/ledger_sync/quickbooks_online/transfer/operations/create.rb +24 -0
  172. data/lib/ledger_sync/quickbooks_online/transfer/operations/find.rb +24 -0
  173. data/lib/ledger_sync/quickbooks_online/transfer/operations/update.rb +24 -0
  174. data/lib/ledger_sync/quickbooks_online/transfer/serializer.rb +29 -0
  175. data/lib/ledger_sync/quickbooks_online/util/error_matcher.rb +68 -0
  176. data/lib/ledger_sync/quickbooks_online/util/error_parser.rb +25 -0
  177. data/lib/ledger_sync/quickbooks_online/util/ledger_error_parser.rb +101 -0
  178. data/lib/ledger_sync/quickbooks_online/util/operation_error_parser.rb +97 -0
  179. data/lib/ledger_sync/quickbooks_online/vendor/deserializer.rb +25 -0
  180. data/lib/ledger_sync/quickbooks_online/vendor/operations/create.rb +25 -0
  181. data/lib/ledger_sync/quickbooks_online/vendor/operations/find.rb +25 -0
  182. data/lib/ledger_sync/quickbooks_online/vendor/operations/update.rb +25 -0
  183. data/lib/ledger_sync/quickbooks_online/vendor/searcher.rb +13 -0
  184. data/lib/ledger_sync/quickbooks_online/vendor/serializer.rb +25 -0
  185. data/lib/ledger_sync/quickbooks_online/version.rb +19 -0
  186. data/lib/ledger_sync/quickbooks_online/webhook.rb +56 -0
  187. data/lib/ledger_sync/quickbooks_online/webhook_event.rb +79 -0
  188. data/lib/ledger_sync/quickbooks_online/webhook_notification.rb +41 -0
  189. data/license.txt +4 -0
  190. metadata +456 -0
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'ledger_sync/quickbooks_online'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Setup
4
+ #
5
+ # gem install bundler
6
+ # Ensure you have http://localhost:5678 (or PORT) as a Redirect URI in QBO.
7
+
8
+ require 'bundler/inline'
9
+
10
+ gemfile do
11
+ source 'https://rubygems.org'
12
+ gem 'dotenv'
13
+ # gem 'ledger_sync'
14
+ gem 'ledger_sync-quickbooks_online', path: './'
15
+ gem 'rack'
16
+ gem 'pd_ruby'
17
+ end
18
+
19
+ puts 'Gems installed and loaded!'
20
+
21
+ require 'pd_ruby'
22
+ require 'socket'
23
+ require 'dotenv'
24
+ require 'rack'
25
+ require 'ledger_sync/quickbooks_online'
26
+ require 'rack/lobster'
27
+
28
+ Dotenv.load('.env.local')
29
+
30
+ port = ENV.fetch('PORT', 5678)
31
+ server = TCPServer.new port
32
+
33
+ base_url = "http://localhost:#{port}"
34
+
35
+ puts "Listening at #{base_url}"
36
+
37
+ client_id = ENV.fetch('QUICKBOOKS_ONLINE_CLIENT_ID')
38
+
39
+ raise 'QUICKBOOKS_ONLINE_CLIENT_ID not set in ../.env' if client_id.blank?
40
+
41
+ client = LedgerSync::QuickBooksOnline::Client.new_from_env(test: true)
42
+
43
+ puts 'Go to the following URL:'
44
+ puts client.authorization_url(redirect_uri: base_url)
45
+
46
+ while (session = server.accept) # rubocop:disable Lint/UnreachableLoop
47
+ request = session.gets
48
+
49
+ puts request
50
+
51
+ # 1
52
+ _method, full_path = request.split
53
+
54
+ # 2
55
+ _path, query = full_path.split('?')
56
+
57
+ params = Hash[query.split('&').map { |e| e.split('=') }] if query.present?
58
+
59
+ client.set_credentials_from_oauth_code(
60
+ code: params.fetch('code'),
61
+ realm_id: params.fetch('realmId'),
62
+ redirect_uri: base_url
63
+ )
64
+
65
+ puts "\n"
66
+
67
+ puts 'access_token:'
68
+ puts client.access_token
69
+ puts "\n"
70
+ puts 'client_id:'
71
+ puts client.client_id
72
+ puts "\n"
73
+ puts 'client_secret:'
74
+ puts client.client_secret
75
+ puts "\n"
76
+ puts 'realm_id:'
77
+ puts client.realm_id
78
+ puts "\n"
79
+ puts 'refresh_token:'
80
+ puts client.refresh_token
81
+ puts "\n"
82
+
83
+ puts 'Done!'
84
+
85
+ status = 200
86
+ body = 'Done'
87
+ headers = {
88
+ 'Content-Length' => body.size
89
+ }
90
+
91
+ session.print "HTTP/1.1 #{status}\r\n"
92
+
93
+ headers.each do |key, value|
94
+ session.print "#{key}: #{value}\r\n"
95
+ end
96
+
97
+ session.print "\r\n"
98
+
99
+ session.print body
100
+
101
+ session.close
102
+
103
+ break
104
+ end
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'ledger_sync/quickbooks_online/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'ledger_sync-quickbooks_online'
9
+ spec.version = LedgerSync::QuickBooksOnline::VERSION
10
+ spec.authors = ['Modern Treasury']
11
+ spec.email = ['ledgersync@moderntreasury.com']
12
+
13
+ spec.required_ruby_version = '>= 2.5.8'
14
+
15
+ spec.summary = 'Sync common objects to accounting software.'
16
+ spec.description = 'LedgerSync is a simple library that allows you to sync common objects to popular accounting '\
17
+ 'software like QuickBooks Online, QuickBooksOnline, NetSuite, etc.'
18
+ spec.homepage = 'https://www.ledgersync.dev'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_development_dependency('awesome_print', '>= 0')
30
+ spec.add_development_dependency('bump', '~> 0.9.0')
31
+ spec.add_development_dependency('bundler', '~> 2.1')
32
+ spec.add_development_dependency('byebug')
33
+ spec.add_development_dependency('climate_control')
34
+ spec.add_development_dependency('coveralls')
35
+ spec.add_development_dependency('factory_bot', '~> 6.1.0')
36
+ spec.add_development_dependency('overcommit', '~> 0.57.0')
37
+ spec.add_development_dependency('rake', '~> 13.0')
38
+ spec.add_development_dependency('rspec', '~> 3.2')
39
+ spec.add_development_dependency('rubocop', '>= 0')
40
+ spec.add_development_dependency('vcr', '>= 0')
41
+ spec.add_development_dependency('webmock', '>= 0')
42
+ spec.add_runtime_dependency('dotenv')
43
+ spec.add_runtime_dependency('ledger_sync', '~> 1.8.0')
44
+ # spec.add_runtime_dependency('nokogiri', '>= 0')
45
+ spec.add_runtime_dependency('oauth2', '>= 0')
46
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ledger_sync'
4
+ require 'oauth2'
5
+
6
+ module LedgerSync
7
+ module QuickBooksOnline
8
+ def self.root(*paths)
9
+ File.join(File.expand_path('../..', __dir__), *paths.map(&:to_s))
10
+ end
11
+ end
12
+ end
13
+
14
+ require_relative 'quickbooks_online/config'
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../reference/deserializer'
4
+
5
+ module LedgerSync
6
+ module QuickBooksOnline
7
+ class Account
8
+ class Deserializer < QuickBooksOnline::Deserializer
9
+ id
10
+
11
+ attribute :Name
12
+ attribute :AcctNum
13
+ attribute :Description
14
+ attribute :Active
15
+
16
+ mapping :AccountType,
17
+ hash: Account::TYPES.invert
18
+ mapping :AccountSubType,
19
+ hash: Account::SUB_TYPES.invert
20
+ mapping :Classification,
21
+ hash: Account::CLASSIFICATIONS.invert
22
+
23
+ references_one :Currency,
24
+ hash_attribute: :CurrencyRef,
25
+ deserializer: Reference::Deserializer
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module QuickBooksOnline
5
+ class Account
6
+ module Operations
7
+ class Create < QuickBooksOnline::Operation::Create
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ required(:external_id).maybe(:string)
11
+ required(:ledger_id).value(:nil)
12
+ required(:AccountSubType).filled(:string)
13
+ required(:AccountType).filled(:string)
14
+ required(:AcctNum).maybe(:string)
15
+ required(:Active).maybe(:bool)
16
+ required(:Classification).filled(:string)
17
+ required(:Currency).maybe(:hash, Types::Reference)
18
+ required(:Description).maybe(:string)
19
+ required(:Name).filled(:string)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module QuickBooksOnline
5
+ class Account
6
+ module Operations
7
+ class Find < Operation::Find
8
+ class Contract < LedgerSync::Ledgers::Contract
9
+ params do
10
+ required(:external_id).maybe(:string)
11
+ required(:ledger_id).filled(:string)
12
+ required(:AccountType).maybe(:string)
13
+ required(:AccountSubType).maybe(:string)
14
+ required(:AcctNum).maybe(:string)
15
+ required(:Active).maybe(:bool)
16
+ required(:Classification).maybe(:string)
17
+ required(:Currency).maybe(:hash, Types::Reference)
18
+ required(:Description).maybe(:string)
19
+ required(:Name).maybe(:string)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/account
4
+ # Requires full update
5
+ module LedgerSync
6
+ module QuickBooksOnline
7
+ class Account
8
+ module Operations
9
+ class Update < Operation::FullUpdate
10
+ class Contract < LedgerSync::Ledgers::Contract
11
+ params do
12
+ required(:external_id).maybe(:string)
13
+ required(:ledger_id).filled(:string)
14
+ required(:AccountSubType).filled(:string)
15
+ required(:AccountType).filled(:string)
16
+ required(:AcctNum).maybe(:string)
17
+ required(:Active).maybe(:bool)
18
+ required(:Classification).filled(:string)
19
+ required(:Currency).maybe(:hash, Types::Reference)
20
+ required(:Description).maybe(:string)
21
+ required(:Name).filled(:string)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LedgerSync
4
+ module QuickBooksOnline
5
+ class Account
6
+ class Searcher < Searcher
7
+ def query_string
8
+ "Name LIKE '%#{query}%'"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../reference/serializer'
4
+
5
+ module LedgerSync
6
+ module QuickBooksOnline
7
+ class Account
8
+ class Serializer < QuickBooksOnline::Serializer
9
+ id
10
+
11
+ attribute :Name
12
+ attribute :AcctNum
13
+ attribute :Description
14
+ attribute :Active
15
+
16
+ mapping :AccountType,
17
+ hash: Account::TYPES
18
+ mapping :AccountSubType,
19
+ hash: Account::SUB_TYPES
20
+ mapping :Classification,
21
+ hash: Account::CLASSIFICATIONS
22
+
23
+ references_one :CurrencyRef,
24
+ resource_attribute: :Currency,
25
+ serializer: Reference::Serializer
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../reference/deserializer'
4
+
5
+ module LedgerSync
6
+ module QuickBooksOnline
7
+ class AccountBasedExpenseLineDetail
8
+ class Deserializer < QuickBooksOnline::Deserializer
9
+ references_one :Account,
10
+ hash_attribute: 'AccountRef',
11
+ deserializer: Reference::Deserializer
12
+
13
+ references_one :Class,
14
+ hash_attribute: 'ClassRef',
15
+ deserializer: Reference::Deserializer
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../reference/serializer'
4
+
5
+ module LedgerSync
6
+ module QuickBooksOnline
7
+ class AccountBasedExpenseLineDetail
8
+ class Serializer < QuickBooksOnline::Serializer
9
+ references_one 'AccountRef',
10
+ resource_attribute: :Account,
11
+ serializer: Reference::Serializer
12
+
13
+ references_one 'ClassRef',
14
+ resource_attribute: :Class,
15
+ serializer: Reference::Serializer
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../bill_line/deserializer'
4
+ require_relative '../reference/deserializer'
5
+
6
+ module LedgerSync
7
+ module QuickBooksOnline
8
+ class Bill
9
+ class Deserializer < QuickBooksOnline::Deserializer
10
+ id
11
+
12
+ date :DueDate
13
+ date :TxnDate
14
+ attribute :PrivateNote
15
+ attribute :DocNumber
16
+
17
+ references_one :Currency,
18
+ hash_attribute: 'CurrencyRef',
19
+ deserializer: Reference::Deserializer
20
+
21
+ references_one :Vendor,
22
+ hash_attribute: 'VendorRef',
23
+ deserializer: Reference::Deserializer
24
+
25
+ references_one :APAccount,
26
+ hash_attribute: 'APAccountRef',
27
+ deserializer: Reference::Deserializer
28
+
29
+ references_one :Department,
30
+ hash_attribute: 'DepartmentRef',
31
+ deserializer: Reference::Deserializer
32
+
33
+ references_many :Line,
34
+ hash_attribute: 'Line',
35
+ deserializer: BillLine::Deserializer
36
+ end
37
+ end
38
+ end
39
+ end