ledger_sync-quickbooks_online 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.env.test +9 -0
- data/.gitignore +21 -0
- data/.overcommit.yml +29 -0
- data/.rubocop.yml +78 -0
- data/.rubocop_todo.yml +25 -0
- data/.travis.yml +25 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +211 -0
- data/README.md +19 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/quickbooks_online_oauth_server.rb +104 -0
- data/bin/setup +8 -0
- data/ledger_sync-quickbooks_online.gemspec +46 -0
- data/lib/ledger_sync/quickbooks_online.rb +14 -0
- data/lib/ledger_sync/quickbooks_online/account/deserializer.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/account/operations/create.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/account/operations/find.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/account/operations/update.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/account/searcher.rb +13 -0
- data/lib/ledger_sync/quickbooks_online/account/serializer.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/account_based_expense_line_detail/deserializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/account_based_expense_line_detail/serializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/bill/deserializer.rb +39 -0
- data/lib/ledger_sync/quickbooks_online/bill/operations/create.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/bill/operations/find.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/bill/operations/update.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/bill/searcher.rb +12 -0
- data/lib/ledger_sync/quickbooks_online/bill/serializer.rb +39 -0
- data/lib/ledger_sync/quickbooks_online/bill_line/deserializer.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/bill_line/serializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/deserializer.rb +53 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/operations/create.rb +31 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/operations/find.rb +31 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/operations/update.rb +31 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment/serializer.rb +53 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment_line/deserializer.rb +14 -0
- data/lib/ledger_sync/quickbooks_online/bill_payment_line/serializer.rb +14 -0
- data/lib/ledger_sync/quickbooks_online/check_payment/deserializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/check_payment/serializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/client.rb +235 -0
- data/lib/ledger_sync/quickbooks_online/config.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/credit_card_payment/deserializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/credit_card_payment/serializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/currency/deserializer.rb +14 -0
- data/lib/ledger_sync/quickbooks_online/currency/serializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/customer/deserializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/customer/operations/create.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/customer/operations/find.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/customer/operations/update.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/customer/searcher.rb +13 -0
- data/lib/ledger_sync/quickbooks_online/customer/serializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/dashboard_url_helper.rb +32 -0
- data/lib/ledger_sync/quickbooks_online/department/deserializer.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/department/operations/create.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/department/operations/find.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/department/operations/update.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/department/searcher.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/department/serializer.rb +39 -0
- data/lib/ledger_sync/quickbooks_online/deposit/deserializer.rb +34 -0
- data/lib/ledger_sync/quickbooks_online/deposit/operations/create.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/deposit/operations/find.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/deposit/operations/update.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/deposit/searcher.rb +12 -0
- data/lib/ledger_sync/quickbooks_online/deposit/serializer.rb +34 -0
- data/lib/ledger_sync/quickbooks_online/deposit_line/deserializer.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/deposit_line/serializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/deposit_line_detail/deserializer.rb +32 -0
- data/lib/ledger_sync/quickbooks_online/deposit_line_detail/serializer.rb +33 -0
- data/lib/ledger_sync/quickbooks_online/deserializer.rb +97 -0
- data/lib/ledger_sync/quickbooks_online/expense/deserializer.rb +52 -0
- data/lib/ledger_sync/quickbooks_online/expense/operations/create.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/expense/operations/find.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/expense/operations/update.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/expense/searcher.rb +12 -0
- data/lib/ledger_sync/quickbooks_online/expense/serializer.rb +51 -0
- data/lib/ledger_sync/quickbooks_online/expense_line/deserializer.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/expense_line/serializer.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/invoice/deserializer.rb +33 -0
- data/lib/ledger_sync/quickbooks_online/invoice/operations/create.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/invoice/operations/find.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/invoice/operations/update.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/invoice/serializer.rb +33 -0
- data/lib/ledger_sync/quickbooks_online/invoice_line/deserializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/invoice_line/serializer.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/item/deserializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/item/serializer.rb +10 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/deserializer.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/operations/create.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/operations/find.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/operations/update.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/searcher.rb +12 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry/serializer.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry_line/deserializer.rb +18 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry_line/serializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry_line_detail/deserializer.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/journal_entry_line_detail/serializer.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/deserializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/operations/create.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/operations/find.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/operations/update.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/searcher.rb +13 -0
- data/lib/ledger_sync/quickbooks_online/ledger_class/serializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/oauth_client.rb +91 -0
- data/lib/ledger_sync/quickbooks_online/operation.rb +59 -0
- data/lib/ledger_sync/quickbooks_online/operation/create.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/operation/find.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/operation/full_update.rb +40 -0
- data/lib/ledger_sync/quickbooks_online/operation/sparse_update.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/payment/deserializer.rb +40 -0
- data/lib/ledger_sync/quickbooks_online/payment/operations/create.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/payment/operations/find.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/payment/operations/update.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/payment/serializer.rb +40 -0
- data/lib/ledger_sync/quickbooks_online/payment_line/deserializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/payment_line/serializer.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/preferences/deserializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/preferences/operations/find.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/preferences/serializer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/primary_email_addr/deserializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/primary_email_addr/serializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/primary_phone/deserializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/primary_phone/serializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/reference/deserializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/reference/serializer.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/request.rb +96 -0
- data/lib/ledger_sync/quickbooks_online/resource.rb +8 -0
- data/lib/ledger_sync/quickbooks_online/resources/account.rb +357 -0
- data/lib/ledger_sync/quickbooks_online/resources/account_based_expense_line_detail.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/bill.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/resources/bill_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/bill_payment.rb +42 -0
- data/lib/ledger_sync/quickbooks_online/resources/bill_payment_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/check_payment.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/resources/credit_card_payment.rb +11 -0
- data/lib/ledger_sync/quickbooks_online/resources/currency.rb +15 -0
- data/lib/ledger_sync/quickbooks_online/resources/customer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/resources/department.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/resources/deposit.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/resources/deposit_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/deposit_line_detail.rb +20 -0
- data/lib/ledger_sync/quickbooks_online/resources/expense.rb +38 -0
- data/lib/ledger_sync/quickbooks_online/resources/expense_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/invoice.rb +26 -0
- data/lib/ledger_sync/quickbooks_online/resources/invoice_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/item.rb +9 -0
- data/lib/ledger_sync/quickbooks_online/resources/journal_entry.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/resources/journal_entry_line.rb +18 -0
- data/lib/ledger_sync/quickbooks_online/resources/journal_entry_line_detail.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/resources/ledger_class.rb +18 -0
- data/lib/ledger_sync/quickbooks_online/resources/payment.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/resources/payment_line.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/preferences.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/resources/primary_email_addr.rb +9 -0
- data/lib/ledger_sync/quickbooks_online/resources/primary_phone.rb +9 -0
- data/lib/ledger_sync/quickbooks_online/resources/sales_item_line_detail.rb +17 -0
- data/lib/ledger_sync/quickbooks_online/resources/transfer.rb +22 -0
- data/lib/ledger_sync/quickbooks_online/resources/vendor.rb +23 -0
- data/lib/ledger_sync/quickbooks_online/sales_item_line_detail/deserializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/sales_item_line_detail/serializer.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/searcher.rb +58 -0
- data/lib/ledger_sync/quickbooks_online/serialization/type/amount_float_to_integer_type.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/serialization/type/integer_to_amount_float_type.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb +28 -0
- data/lib/ledger_sync/quickbooks_online/serializer.rb +69 -0
- data/lib/ledger_sync/quickbooks_online/serialziation/type/mapping_type.rb +27 -0
- data/lib/ledger_sync/quickbooks_online/transfer/deserializer.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/transfer/operations/create.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/transfer/operations/find.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/transfer/operations/update.rb +24 -0
- data/lib/ledger_sync/quickbooks_online/transfer/serializer.rb +29 -0
- data/lib/ledger_sync/quickbooks_online/util/error_matcher.rb +68 -0
- data/lib/ledger_sync/quickbooks_online/util/error_parser.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/util/ledger_error_parser.rb +101 -0
- data/lib/ledger_sync/quickbooks_online/util/operation_error_parser.rb +97 -0
- data/lib/ledger_sync/quickbooks_online/vendor/deserializer.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/vendor/operations/create.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/vendor/operations/find.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/vendor/operations/update.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/vendor/searcher.rb +13 -0
- data/lib/ledger_sync/quickbooks_online/vendor/serializer.rb +25 -0
- data/lib/ledger_sync/quickbooks_online/version.rb +19 -0
- data/lib/ledger_sync/quickbooks_online/webhook.rb +56 -0
- data/lib/ledger_sync/quickbooks_online/webhook_event.rb +79 -0
- data/lib/ledger_sync/quickbooks_online/webhook_notification.rb +41 -0
- data/license.txt +4 -0
- metadata +456 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../reference/serializer'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class DepositLineDetail
|
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
|
+
|
17
|
+
attribute 'Entity' do |args = {}|
|
18
|
+
resource = args.fetch(:resource)
|
19
|
+
|
20
|
+
if resource.Entity.present?
|
21
|
+
{
|
22
|
+
'name' => resource.Entity.name,
|
23
|
+
'value' => resource.Entity.ledger_id,
|
24
|
+
'type' => Client.ledger_resource_type_for(
|
25
|
+
resource_class: resource.Entity.class
|
26
|
+
).classify
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Gem.find_files('ledger_sync/ledgers/quickbooks_online/serializer_type/**/*.rb').each { |path| require path }
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class Deserializer < LedgerSync::Deserializer
|
8
|
+
def deserialize(args = {})
|
9
|
+
hash = args.fetch(:hash)
|
10
|
+
merge_for_full_update = args.fetch(:merge_for_full_update, false)
|
11
|
+
resource = args.fetch(:resource)
|
12
|
+
|
13
|
+
deserialized_resource = super(hash: hash, resource: resource)
|
14
|
+
|
15
|
+
# Ref: https://github.com/LedgerSync/ledger_sync/issues/86
|
16
|
+
if deserialized_resource.is_a?(LedgerSync::QuickBooksOnline::Account) &&
|
17
|
+
deserialized_resource.AccountType &&
|
18
|
+
deserialized_resource.Classification.blank?
|
19
|
+
deserialized_resource.Classification = deserialized_resource.class::TYPES_TO_CLASSIFICATION_MAPPING.fetch(
|
20
|
+
deserialized_resource.AccountType,
|
21
|
+
nil
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
return deserialized_resource unless merge_for_full_update
|
26
|
+
|
27
|
+
merge_resources_for_full_update(
|
28
|
+
hash: hash,
|
29
|
+
ledger_resource: deserialized_resource,
|
30
|
+
resource: resource
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def merge_resources_for_full_update(args = {})
|
35
|
+
hash = args.fetch(:hash)
|
36
|
+
resource = args.fetch(:resource)
|
37
|
+
merged_resource = resource.dup
|
38
|
+
|
39
|
+
self.class.attributes.each do |_key, deserializer_attribute|
|
40
|
+
next unless deserializer_attribute.references_many?
|
41
|
+
|
42
|
+
resources_from_ledger = attribute_value_from_ledger(
|
43
|
+
hash: hash,
|
44
|
+
deserializer_attribute: deserializer_attribute,
|
45
|
+
resource: merged_resource
|
46
|
+
)
|
47
|
+
|
48
|
+
resource_hash_from_ledger = Hash[resources_from_ledger.map { |e| [e.ledger_id, e] }]
|
49
|
+
|
50
|
+
# Using original resource since it is overwritten by keyword arg
|
51
|
+
merged_value = resource.send(deserializer_attribute.resource_attribute_dot_parts.first).map do |referenced|
|
52
|
+
if referenced.ledger_id.nil? # Assume creating a new resource in ledger
|
53
|
+
referenced
|
54
|
+
elsif resource_hash_from_ledger.key?(referenced.ledger_id.to_s) # Merged ledger into local
|
55
|
+
ledger_resource = resource_hash_from_ledger[referenced.ledger_id.to_s]
|
56
|
+
ledger_resource_serializer = deserializer_attribute.type.deserializer.inferred_serializer_class.new
|
57
|
+
deserializer_attribute.type.deserializer.new.deserialize(
|
58
|
+
hash: ledger_resource_serializer.serialize(resource: ledger_resource),
|
59
|
+
resource: referenced
|
60
|
+
)
|
61
|
+
end
|
62
|
+
# Else assume delete from ledger
|
63
|
+
end.compact
|
64
|
+
|
65
|
+
merged_resource.assign_attribute(
|
66
|
+
deserializer_attribute.resource_attribute_dot_parts.first,
|
67
|
+
merged_value
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
merged_resource
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.amount(resource_attribute, args = {})
|
75
|
+
attribute(
|
76
|
+
resource_attribute,
|
77
|
+
{
|
78
|
+
type: Serialization::Type::AmountFloatToIntegerType.new
|
79
|
+
}.merge(args)
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.date(resource_attribute, args = {})
|
84
|
+
attribute(
|
85
|
+
resource_attribute,
|
86
|
+
{
|
87
|
+
type: LedgerSync::Serialization::Type::ParseDateType.new(format: '%Y-%m-%d')
|
88
|
+
}.merge(args)
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.id
|
93
|
+
attribute(:ledger_id, hash_attribute: 'Id')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../expense_line/deserializer'
|
4
|
+
require_relative '../reference/deserializer'
|
5
|
+
|
6
|
+
module LedgerSync
|
7
|
+
module QuickBooksOnline
|
8
|
+
class Expense
|
9
|
+
class Deserializer < QuickBooksOnline::Deserializer
|
10
|
+
id
|
11
|
+
|
12
|
+
attribute :DocNumber
|
13
|
+
date :TxnDate
|
14
|
+
attribute :PrivateNote
|
15
|
+
|
16
|
+
attribute :ExchangeRate
|
17
|
+
|
18
|
+
mapping :PaymentType,
|
19
|
+
hash: Expense::PAYMENT_TYPES.invert
|
20
|
+
|
21
|
+
attribute(:Entity) do |args = {}|
|
22
|
+
hash = args.fetch(:hash)
|
23
|
+
value = hash['EntityRef']
|
24
|
+
|
25
|
+
unless value.nil?
|
26
|
+
Client.resource_from_ledger_type(
|
27
|
+
type: value['type']
|
28
|
+
).new(
|
29
|
+
ledger_id: value['value']
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
references_one :Currency,
|
35
|
+
hash_attribute: 'CurrencyRef',
|
36
|
+
deserializer: Reference::Deserializer
|
37
|
+
|
38
|
+
references_one :Account,
|
39
|
+
hash_attribute: 'AccountRef',
|
40
|
+
deserializer: Reference::Deserializer
|
41
|
+
|
42
|
+
references_one :Department,
|
43
|
+
hash_attribute: 'DepartmentRef',
|
44
|
+
deserializer: Reference::Deserializer
|
45
|
+
|
46
|
+
references_many :Line,
|
47
|
+
hash_attribute: 'Line',
|
48
|
+
deserializer: ExpenseLine::Deserializer
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Expense
|
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(:Account).hash(Types::Reference)
|
12
|
+
optional(:Currency).hash(Types::Reference)
|
13
|
+
required(:Department).hash(Types::Reference)
|
14
|
+
optional(:ExchangeRate).maybe(:float)
|
15
|
+
optional(:ledger_id).value(:nil)
|
16
|
+
required(:Line).array(Types::Reference)
|
17
|
+
optional(:PrivateNote).filled(:string)
|
18
|
+
required(:PaymentType).filled(:string)
|
19
|
+
optional(:DocNumber).maybe(:string)
|
20
|
+
optional(:TxnDate).filled(:date?)
|
21
|
+
optional(:Entity).hash(Types::Reference)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Expense
|
6
|
+
module Operations
|
7
|
+
class Find < Operation::Find
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
schema do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
optional(:Account).hash(Types::Reference)
|
12
|
+
optional(:Currency).maybe(:hash, Types::Reference)
|
13
|
+
optional(:Department).hash(Types::Reference)
|
14
|
+
optional(:ExchangeRate).maybe(:float)
|
15
|
+
required(:ledger_id).filled(:string)
|
16
|
+
optional(:Line).array(Types::Reference)
|
17
|
+
optional(:PrivateNote).maybe(:string)
|
18
|
+
optional(:PaymentType).maybe(:string)
|
19
|
+
optional(:DocNumber).maybe(:string)
|
20
|
+
optional(:TxnDate).filled(:date?)
|
21
|
+
optional(:Entity).hash(Types::Reference)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Expense
|
6
|
+
module Operations
|
7
|
+
class Update < Operation::FullUpdate
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
schema do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
required(:Account).hash(Types::Reference)
|
12
|
+
optional(:Currency).hash(Types::Reference)
|
13
|
+
required(:Department).hash(Types::Reference)
|
14
|
+
optional(:ExchangeRate).maybe(:float)
|
15
|
+
required(:ledger_id).filled(:string)
|
16
|
+
required(:Line).array(Types::Reference)
|
17
|
+
optional(:PrivateNote).filled(:string)
|
18
|
+
required(:PaymentType).filled(:string)
|
19
|
+
optional(:DocNumber).maybe(:string)
|
20
|
+
optional(:TxnDate).filled(:date?)
|
21
|
+
optional(:Entity).hash(Types::Reference)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../expense_line/serializer'
|
4
|
+
require_relative '../reference/serializer'
|
5
|
+
|
6
|
+
module LedgerSync
|
7
|
+
module QuickBooksOnline
|
8
|
+
class Expense
|
9
|
+
class Serializer < QuickBooksOnline::Serializer
|
10
|
+
id
|
11
|
+
|
12
|
+
attribute :DocNumber
|
13
|
+
date :TxnDate
|
14
|
+
attribute :PrivateNote
|
15
|
+
attribute :ExchangeRate
|
16
|
+
|
17
|
+
attribute :PaymentType,
|
18
|
+
type: LedgerSync::Serialization::Type::MappingType.new(hash: Expense::PAYMENT_TYPES)
|
19
|
+
|
20
|
+
attribute('EntityRef') do |args = {}|
|
21
|
+
resource = args.fetch(:resource)
|
22
|
+
if resource.Entity
|
23
|
+
{
|
24
|
+
'name' => resource.Entity.name,
|
25
|
+
'value' => resource.Entity.ledger_id,
|
26
|
+
'type' => Client.ledger_resource_type_for(
|
27
|
+
resource_class: resource.Entity.class
|
28
|
+
).classify
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
references_one 'CurrencyRef',
|
34
|
+
resource_attribute: :Currency,
|
35
|
+
serializer: Reference::Serializer
|
36
|
+
|
37
|
+
references_one 'AccountRef',
|
38
|
+
resource_attribute: :Account,
|
39
|
+
serializer: Reference::Serializer
|
40
|
+
|
41
|
+
references_one 'DepartmentRef',
|
42
|
+
resource_attribute: :Department,
|
43
|
+
serializer: Reference::Serializer
|
44
|
+
|
45
|
+
references_many 'Line',
|
46
|
+
resource_attribute: :Line,
|
47
|
+
serializer: ExpenseLine::Serializer
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../account_based_expense_line_detail/deserializer'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class ExpenseLine
|
8
|
+
class Deserializer < QuickBooksOnline::Deserializer
|
9
|
+
id
|
10
|
+
|
11
|
+
amount :Amount
|
12
|
+
attribute :Description
|
13
|
+
|
14
|
+
references_one :AccountBasedExpenseLineDetail,
|
15
|
+
hash_attribute: 'AccountBasedExpenseLineDetail',
|
16
|
+
deserializer: AccountBasedExpenseLineDetail::Deserializer
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../account_based_expense_line_detail/serializer'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class ExpenseLine
|
8
|
+
class Serializer < QuickBooksOnline::Serializer
|
9
|
+
id
|
10
|
+
|
11
|
+
amount :Amount
|
12
|
+
attribute :Description
|
13
|
+
|
14
|
+
attribute :DetailType do
|
15
|
+
'AccountBasedExpenseLineDetail'
|
16
|
+
end
|
17
|
+
|
18
|
+
references_one :AccountBasedExpenseLineDetail,
|
19
|
+
resource_attribute: :AccountBasedExpenseLineDetail,
|
20
|
+
serializer: AccountBasedExpenseLineDetail::Serializer
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../invoice_line/deserializer'
|
4
|
+
require_relative '../reference/deserializer'
|
5
|
+
|
6
|
+
module LedgerSync
|
7
|
+
module QuickBooksOnline
|
8
|
+
class Invoice
|
9
|
+
class Deserializer < QuickBooksOnline::Deserializer
|
10
|
+
id
|
11
|
+
|
12
|
+
date :TxnDate
|
13
|
+
attribute :PrivateNote
|
14
|
+
|
15
|
+
references_one :Currency,
|
16
|
+
hash_attribute: 'CurrencyRef',
|
17
|
+
deserializer: Reference::Deserializer
|
18
|
+
|
19
|
+
references_one :Customer,
|
20
|
+
hash_attribute: 'CustomerRef',
|
21
|
+
deserializer: Reference::Deserializer
|
22
|
+
|
23
|
+
references_one :DepositToAccount,
|
24
|
+
hash_attribute: 'DepositToAccountRef',
|
25
|
+
deserialier: Reference::Deserializer
|
26
|
+
|
27
|
+
references_many :Line,
|
28
|
+
hash_attribute: 'Line',
|
29
|
+
deserializer: InvoiceLine::Deserializer
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Invoice
|
6
|
+
module Operations
|
7
|
+
class Create < Operation::Create
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
required(:Currency).filled(:hash, Types::Reference)
|
12
|
+
required(:Customer).hash(Types::Reference)
|
13
|
+
optional(:Deposit).maybe(:integer)
|
14
|
+
optional(:DepositToAccount).hash(Types::Reference)
|
15
|
+
required(:ledger_id).value(:nil)
|
16
|
+
required(:Line).array(Types::Reference)
|
17
|
+
optional(:PrivateNote).filled(:string)
|
18
|
+
optional(:TxnDate).filled(:date?)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|