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,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Payment
|
6
|
+
module Operations
|
7
|
+
class Update < Operation::FullUpdate
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
schema do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
optional(:ARAccount).hash(Types::Reference)
|
12
|
+
required(:Currency).filled(:hash, Types::Reference)
|
13
|
+
required(:Customer).hash(Types::Reference)
|
14
|
+
optional(:DepositToAccount).hash(Types::Reference)
|
15
|
+
optional(:ExchangeRate).maybe(:float)
|
16
|
+
required(:ledger_id).filled(:string)
|
17
|
+
required(:Line).array(Types::Reference)
|
18
|
+
optional(:PrivateNote).filled(:string)
|
19
|
+
optional(:PaymentRefNum).maybe(:string)
|
20
|
+
required(:TotalAmt).filled(:integer)
|
21
|
+
optional(:TxnDate).filled(:date?)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../reference/serializer'
|
4
|
+
require_relative '../payment_line/serializer'
|
5
|
+
|
6
|
+
module LedgerSync
|
7
|
+
module QuickBooksOnline
|
8
|
+
class Payment
|
9
|
+
class Serializer < QuickBooksOnline::Serializer
|
10
|
+
id
|
11
|
+
|
12
|
+
amount :TotalAmt
|
13
|
+
attribute :PaymentRefNum
|
14
|
+
attribute :PrivateNote
|
15
|
+
attribute :ExchangeRate
|
16
|
+
date :TxnDate
|
17
|
+
|
18
|
+
references_one 'CurrencyRef',
|
19
|
+
resource_attribute: :Currency,
|
20
|
+
serializer: Reference::Serializer
|
21
|
+
|
22
|
+
references_one 'CustomerRef',
|
23
|
+
resource_attribute: :Customer,
|
24
|
+
serializer: Reference::Serializer
|
25
|
+
|
26
|
+
references_one 'DepositToAccountRef',
|
27
|
+
resource_attribute: :DepositToAccount,
|
28
|
+
serializer: Reference::Serializer
|
29
|
+
|
30
|
+
references_one 'ARAccountRef',
|
31
|
+
resource_attribute: :ARAccount,
|
32
|
+
serializer: Reference::Serializer
|
33
|
+
|
34
|
+
references_many 'Line',
|
35
|
+
resource_attribute: :Line,
|
36
|
+
serializer: PaymentLine::Serializer
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class PaymentLine
|
6
|
+
class Deserializer < QuickBooksOnline::Deserializer
|
7
|
+
amount :Amount
|
8
|
+
|
9
|
+
attribute :LinkedTxn,
|
10
|
+
hash_attribute: 'LinkedTxn',
|
11
|
+
type: Serialization::Type::DeserializeTransactionReferenceType.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class PaymentLine
|
6
|
+
class Serializer < QuickBooksOnline::Serializer
|
7
|
+
amount :Amount
|
8
|
+
|
9
|
+
attribute 'LinkedTxn',
|
10
|
+
resource_attribute: :LinkedTxn,
|
11
|
+
type: Serialization::Type::SerializeTransactionReferenceType.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Preferences
|
6
|
+
class Deserializer < QuickBooksOnline::Deserializer
|
7
|
+
id
|
8
|
+
|
9
|
+
attribute :AccountingInfoPrefs
|
10
|
+
attribute :ProductAndServicesPrefs
|
11
|
+
attribute :SalesFormsPrefs
|
12
|
+
attribute :EmailMessagesPrefs
|
13
|
+
attribute :VendorAndPurchasesPrefs
|
14
|
+
attribute :TimeTrackingPrefs
|
15
|
+
attribute :TaxPrefs
|
16
|
+
attribute :CurrencyPrefs
|
17
|
+
attribute :ReportPrefs
|
18
|
+
attribute :OtherPrefs
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Preferences
|
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).value(:nil)
|
12
|
+
required(:AccountingInfoPrefs).maybe(:hash)
|
13
|
+
required(:ProductAndServicesPrefs).maybe(:hash)
|
14
|
+
required(:SalesFormsPrefs).maybe(:hash)
|
15
|
+
required(:EmailMessagesPrefs).maybe(:hash)
|
16
|
+
required(:VendorAndPurchasesPrefs).maybe(:hash)
|
17
|
+
required(:TimeTrackingPrefs).maybe(:hash)
|
18
|
+
required(:TaxPrefs).maybe(:hash)
|
19
|
+
required(:CurrencyPrefs).maybe(:hash)
|
20
|
+
required(:ReportPrefs).maybe(:hash)
|
21
|
+
required(:OtherPrefs).maybe(:hash)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Preferences
|
6
|
+
class Serializer < QuickBooksOnline::Serializer
|
7
|
+
id
|
8
|
+
|
9
|
+
attribute :AccountingInfoPrefs
|
10
|
+
attribute :ProductAndServicesPrefs
|
11
|
+
attribute :SalesFormsPrefs
|
12
|
+
attribute :EmailMessagesPrefs
|
13
|
+
attribute :VendorAndPurchasesPrefs
|
14
|
+
attribute :TimeTrackingPrefs
|
15
|
+
attribute :TaxPrefs
|
16
|
+
attribute :CurrencyPrefs
|
17
|
+
attribute :ReportPrefs
|
18
|
+
attribute :OtherPrefs
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module QuickBooksOnline
|
5
|
+
class Request < Ledgers::Request
|
6
|
+
attr_reader :client
|
7
|
+
|
8
|
+
def initialize(*args, client:, **keywords)
|
9
|
+
@client = client
|
10
|
+
super(*args, **keywords)
|
11
|
+
end
|
12
|
+
|
13
|
+
def perform
|
14
|
+
raise 'Request already performed' if performed?
|
15
|
+
|
16
|
+
@response = generate_response(
|
17
|
+
body: body,
|
18
|
+
headers: headers,
|
19
|
+
method: method,
|
20
|
+
url: url
|
21
|
+
)
|
22
|
+
rescue OAuth2::Error => e
|
23
|
+
error = parse_error(error: e)
|
24
|
+
|
25
|
+
if error.is_a?(Error::LedgerError::AuthenticationError)
|
26
|
+
begin
|
27
|
+
client.refresh!
|
28
|
+
@response = generate_response(
|
29
|
+
body: body,
|
30
|
+
headers: headers,
|
31
|
+
method: method,
|
32
|
+
url: url
|
33
|
+
)
|
34
|
+
return @response
|
35
|
+
rescue OAuth2::Error => e
|
36
|
+
raise parse_error(error: e)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
raise error
|
41
|
+
end
|
42
|
+
|
43
|
+
def refresh!
|
44
|
+
oauth.refresh!
|
45
|
+
rescue OAuth2::Error => e
|
46
|
+
raise parse_error(error: e)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def generate_response(body:, headers:, method:, url:)
|
52
|
+
oauth_response = oauth.send(
|
53
|
+
method,
|
54
|
+
url,
|
55
|
+
body: (body.to_json unless body.nil?),
|
56
|
+
headers: headers
|
57
|
+
)
|
58
|
+
ret = LedgerSync::Ledgers::Response.new_from_oauth_response(
|
59
|
+
oauth_response: oauth_response,
|
60
|
+
request: self
|
61
|
+
)
|
62
|
+
@performed = true
|
63
|
+
ret
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse_error(error:)
|
67
|
+
parsed_client_error(error: error) ||
|
68
|
+
parsed_operation_error(error: error) ||
|
69
|
+
error
|
70
|
+
end
|
71
|
+
|
72
|
+
def parsed_client_error(error:)
|
73
|
+
Util::LedgerErrorParser.new(
|
74
|
+
error: error,
|
75
|
+
client: self
|
76
|
+
).parse
|
77
|
+
end
|
78
|
+
|
79
|
+
def parsed_operation_error(error:)
|
80
|
+
return nil unless error.is_a?(OAuth2::Error)
|
81
|
+
|
82
|
+
Util::OperationErrorParser.new(
|
83
|
+
error: error
|
84
|
+
).parse
|
85
|
+
end
|
86
|
+
|
87
|
+
def oauth
|
88
|
+
client.oauth
|
89
|
+
end
|
90
|
+
|
91
|
+
def oauth_client
|
92
|
+
client.oauth_client
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,357 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'currency'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
module QuickBooksOnline
|
7
|
+
class Account < QuickBooksOnline::Resource
|
8
|
+
SUB_TYPES = {
|
9
|
+
# Bank
|
10
|
+
'cash_and_cash_equivalents' => 'CashAndCashEquivalents',
|
11
|
+
'cash_on_hand' => 'CashOnHand',
|
12
|
+
'checking' => 'Checking',
|
13
|
+
'money_market' => 'MoneyMarket',
|
14
|
+
'other_ear_marked_bank_accounts' => 'OtherEarMarkedBankAccounts',
|
15
|
+
'rents_held_in_trust' => 'RentsHeldInTrust',
|
16
|
+
'savings' => 'Savings',
|
17
|
+
'trust_accounts' => 'TrustAccounts',
|
18
|
+
# Other Current Asset
|
19
|
+
'allowance_for_bad_debts' => 'AllowanceForBadDebts',
|
20
|
+
'assets_available_for_sale' => 'AssetsAvailableForSale',
|
21
|
+
'bal_with_govt_authorities' => 'BalWithGovtAuthorities',
|
22
|
+
'called_up_share_capital_not_paid' => 'CalledUpShareCapitalNotPaid',
|
23
|
+
'development_costs' => 'DevelopmentCosts',
|
24
|
+
'employee_cash_advances' => 'EmployeeCashAdvances',
|
25
|
+
'expenditure_authorisations_and_letters_of_credit' => 'ExpenditureAuthorisationsAndLettersOfCredit',
|
26
|
+
'global_tax_deferred' => 'GlobalTaxDeferred',
|
27
|
+
'global_tax_refund' => 'GlobalTaxRefund',
|
28
|
+
'internal_transfers' => 'InternalTransfers',
|
29
|
+
'inventory' => 'Inventory',
|
30
|
+
'investment_mortgage_real_estate_loans' => 'Investment_MortgageRealEstateLoans',
|
31
|
+
'investment_other' => 'Investment_Other',
|
32
|
+
'investment_tax_exempt_securities' => 'Investment_TaxExemptSecurities',
|
33
|
+
'investment_us_government_obligations' => 'Investment_USGovernmentObligations',
|
34
|
+
'loans_to_officers' => 'LoansToOfficers',
|
35
|
+
'loans_to_others' => 'LoansToOthers',
|
36
|
+
'loans_to_stockholders' => 'LoansToStockholders',
|
37
|
+
'other_consumables' => 'OtherConsumables',
|
38
|
+
'other_current_assets' => 'OtherCurrentAssets',
|
39
|
+
'prepaid_expenses' => 'PrepaidExpenses',
|
40
|
+
'provisions_current_assets' => 'ProvisionsCurrentAssets',
|
41
|
+
'retainage' => 'Retainage',
|
42
|
+
'short_term_investments_in_related_parties' => 'ShortTermInvestmentsInRelatedParties',
|
43
|
+
'short_term_loans_and_advances_to_related_parties' => 'ShortTermLoansAndAdvancesToRelatedParties',
|
44
|
+
'trade_and_other_receivables' => 'TradeAndOtherReceivables',
|
45
|
+
'undeposited_funds' => 'UndepositedFunds',
|
46
|
+
# Fixed Asset
|
47
|
+
'accumulated_amortization' => 'AccumulatedAmortization',
|
48
|
+
'accumulated_depletion' => 'AccumulatedDepletion',
|
49
|
+
'accumulated_depreciation' => 'AccumulatedDepreciation',
|
50
|
+
'assets_in_course_of_construction' => 'AssetsInCourseOfConstruction',
|
51
|
+
'buildings' => 'Buildings',
|
52
|
+
'capital_wip' => 'CapitalWip',
|
53
|
+
'cumulative_depreciation_on_intangible_assets' => 'CumulativeDepreciationOnIntangibleAssets',
|
54
|
+
'depletable_assets' => 'DepletableAssets',
|
55
|
+
'fixed_asset_computers' => 'FixedAssetComputers',
|
56
|
+
'fixed_asset_copiers' => 'FixedAssetCopiers',
|
57
|
+
'fixed_asset_furniture' => 'FixedAssetFurniture',
|
58
|
+
'fixed_asset_other_tools_equipment' => 'FixedAssetOtherToolsEquipment',
|
59
|
+
'fixed_asset_phone' => 'FixedAssetPhone',
|
60
|
+
'fixed_asset_photo_video' => 'FixedAssetPhotoVideo',
|
61
|
+
'fixed_asset_software' => 'FixedAssetSoftware',
|
62
|
+
'furniture_and_fixtures' => 'FurnitureAndFixtures',
|
63
|
+
'intangible_assets_under_development' => 'IntangibleAssetsUnderDevelopment',
|
64
|
+
'intangible_assets' => 'IntangibleAssets',
|
65
|
+
'land_asset' => 'LandAsset',
|
66
|
+
'land' => 'Land',
|
67
|
+
'leasehold_improvements' => 'LeaseholdImprovements',
|
68
|
+
'machinery_and_equipment' => 'MachineryAndEquipment',
|
69
|
+
'non_current_assets' => 'NonCurrentAssets',
|
70
|
+
'other_fixed_assets' => 'OtherFixedAssets',
|
71
|
+
'participating_interests' => 'ParticipatingInterests',
|
72
|
+
'provisions_fixed_assets' => 'ProvisionsFixedAssets',
|
73
|
+
'vehicles' => 'Vehicles',
|
74
|
+
# Other Asset
|
75
|
+
'accumulated_amortization_of_other_assets' => 'AccumulatedAmortizationOfOtherAssets',
|
76
|
+
'assets_held_for_sale' => 'AssetsHeldForSale',
|
77
|
+
'available_for_sale_financial_assets' => 'AvailableForSaleFinancialAssets',
|
78
|
+
'deferred_tax' => 'DeferredTax',
|
79
|
+
'goodwill' => 'Goodwill',
|
80
|
+
'investments' => 'Investments',
|
81
|
+
'lease_buyout' => 'LeaseBuyout',
|
82
|
+
'licenses' => 'Licenses',
|
83
|
+
'long_term_investments' => 'LongTermInvestments',
|
84
|
+
'long_term_loans_and_advances_to_related_parties' => 'LongTermLoansAndAdvancesToRelatedParties',
|
85
|
+
'organizational_costs' => 'OrganizationalCosts',
|
86
|
+
'other_intangible_assets' => 'OtherIntangibleAssets',
|
87
|
+
'other_long_term_assets' => 'OtherLongTermAssets',
|
88
|
+
'other_long_term_investments' => 'OtherLongTermInvestments',
|
89
|
+
'other_long_term_loans_and_advances' => 'OtherLongTermLoansAndAdvances',
|
90
|
+
'prepayments_and_accrued_income' => 'PrepaymentsAndAccruedIncome',
|
91
|
+
'provisions_non_current_assets' => 'ProvisionsNonCurrentAssets',
|
92
|
+
'accounts_receivable' => 'AccountsReceivable',
|
93
|
+
'security_deposits' => 'SecurityDeposits',
|
94
|
+
# Equity
|
95
|
+
'accumulated_adjustment' => 'AccumulatedAdjustment',
|
96
|
+
'accumulated_other_comprehensive_income' => 'AccumulatedOtherComprehensiveIncome',
|
97
|
+
'called_up_share_capital' => 'CalledUpShareCapital',
|
98
|
+
'capital_reserves' => 'CapitalReserves',
|
99
|
+
'common_stock' => 'CommonStock',
|
100
|
+
'dividend_disbursed' => 'DividendDisbursed',
|
101
|
+
'equity_in_earnings_of_subsiduaries' => 'EquityInEarningsOfSubsiduaries',
|
102
|
+
'estimated_taxes' => 'EstimatedTaxes',
|
103
|
+
'funds' => 'Funds',
|
104
|
+
'healthcare' => 'Healthcare',
|
105
|
+
'investment_grants' => 'InvestmentGrants',
|
106
|
+
'money_received_against_share_warrants' => 'MoneyReceivedAgainstShareWarrants',
|
107
|
+
'opening_balance_equity' => 'OpeningBalanceEquity',
|
108
|
+
'other_free_reserves' => 'OtherFreeReserves',
|
109
|
+
'owners_equity' => 'OwnersEquity',
|
110
|
+
'paid_in_capital_or_surplus' => 'PaidInCapitalOrSurplus',
|
111
|
+
'partner_contributions' => 'PartnerContributions',
|
112
|
+
'partner_distributions' => 'PartnerDistributions',
|
113
|
+
'partners_equity' => 'PartnersEquity',
|
114
|
+
'personal_expense' => 'PersonalExpense',
|
115
|
+
'personal_income' => 'PersonalIncome',
|
116
|
+
'preferred_stock' => 'PreferredStock',
|
117
|
+
'retained_earnings' => 'RetainedEarnings',
|
118
|
+
'share_application_money_pending_allotment' => 'ShareApplicationMoneyPendingAllotment',
|
119
|
+
'share_capital' => 'ShareCapital',
|
120
|
+
'treasury_stock' => 'TreasuryStock',
|
121
|
+
# Expense
|
122
|
+
'advertising_promotional' => 'AdvertisingPromotional',
|
123
|
+
'amortization_expense' => 'AmortizationExpense',
|
124
|
+
'appropriations_to_depreciation' => 'AppropriationsToDepreciation',
|
125
|
+
'auto' => 'Auto',
|
126
|
+
'bad_debts' => 'BadDebts',
|
127
|
+
'bank_charges' => 'BankCharges',
|
128
|
+
'borrowing_cost' => 'BorrowingCost',
|
129
|
+
'charitable_contributions' => 'CharitableContributions',
|
130
|
+
'commissions_and_fees' => 'CommissionsAndFees',
|
131
|
+
'cost_of_labor' => 'CostOfLabor',
|
132
|
+
'distribution_costs' => 'DistributionCosts',
|
133
|
+
'dues_subscriptions' => 'DuesSubscriptions',
|
134
|
+
'entertainment_meals' => 'EntertainmentMeals',
|
135
|
+
'entertainment' => 'Entertainment',
|
136
|
+
'equipment_rental' => 'EquipmentRental',
|
137
|
+
'external_services' => 'ExternalServices',
|
138
|
+
'extraordinary_charges' => 'ExtraordinaryCharges',
|
139
|
+
'finance_costs' => 'FinanceCosts',
|
140
|
+
'global_tax_expense' => 'GlobalTaxExpense',
|
141
|
+
'income_tax_expense' => 'IncomeTaxExpense',
|
142
|
+
'insurance' => 'Insurance',
|
143
|
+
'interest_paid' => 'InterestPaid',
|
144
|
+
'legal_professional_fees' => 'LegalProfessionalFees',
|
145
|
+
'loss_on_discontinued_operations_net_of_tax' => 'LossOnDiscontinuedOperationsNetOfTax',
|
146
|
+
'management_compensation' => 'ManagementCompensation',
|
147
|
+
'office_expenses' => 'OfficeExpenses',
|
148
|
+
'office_general_administrative_expenses' => 'OfficeGeneralAdministrativeExpenses',
|
149
|
+
'other_business_expenses' => 'OtherBusinessExpenses',
|
150
|
+
'other_current_operating_charges' => 'OtherCurrentOperatingCharges',
|
151
|
+
'other_external_services' => 'OtherExternalServices',
|
152
|
+
'other_miscellaneous_service_cost' => 'OtherMiscellaneousServiceCost',
|
153
|
+
'other_rental_costs' => 'OtherRentalCosts',
|
154
|
+
'other_selling_expenses' => 'OtherSellingExpenses',
|
155
|
+
'payroll_expenses' => 'PayrollExpenses',
|
156
|
+
'project_studies_surveys_assessments' => 'ProjectStudiesSurveysAssessments',
|
157
|
+
'promotional_meals' => 'PromotionalMeals',
|
158
|
+
'purchases_rebates' => 'PurchasesRebates',
|
159
|
+
'rent_or_lease_of_buildings' => 'RentOrLeaseOfBuildings',
|
160
|
+
'repair_maintenance' => 'RepairMaintenance',
|
161
|
+
'shipping_and_delivery_expense' => 'ShippingAndDeliveryExpense',
|
162
|
+
'shipping_freight_delivery' => 'ShippingFreightDelivery',
|
163
|
+
'staff_costs' => 'StaffCosts',
|
164
|
+
'sundry' => 'Sundry',
|
165
|
+
'supplies_materials' => 'SuppliesMaterials',
|
166
|
+
'taxes_paid' => 'TaxesPaid',
|
167
|
+
'travel_expenses_general_and_admin_expenses' => 'TravelExpensesGeneralAndAdminExpenses',
|
168
|
+
'travel_expenses_selling_expense' => 'TravelExpensesSellingExpense',
|
169
|
+
'travel_meals' => 'TravelMeals',
|
170
|
+
'travel' => 'Travel',
|
171
|
+
'unapplied_cash_bill_payment_expense' => 'UnappliedCashBillPaymentExpense',
|
172
|
+
# Other Expense
|
173
|
+
'amortization' => 'Amortization',
|
174
|
+
'deferred_tax_expense' => 'DeferredTaxExpense',
|
175
|
+
'depletion' => 'Depletion',
|
176
|
+
'depreciation' => 'Depreciation',
|
177
|
+
'exceptional_items' => 'ExceptionalItems',
|
178
|
+
'exchange_gain_or_loss' => 'ExchangeGainOrLoss',
|
179
|
+
'extraordinary_items' => 'ExtraordinaryItems',
|
180
|
+
'gas_and_fuel' => 'GasAndFuel',
|
181
|
+
'home_office' => 'HomeOffice',
|
182
|
+
'home_owner_rental_insurance' => 'HomeOwnerRentalInsurance',
|
183
|
+
'income_tax_other_expense' => 'IncomeTaxOtherExpense',
|
184
|
+
'mat_credit' => 'MatCredit',
|
185
|
+
'mortgage_interest' => 'MortgageInterest',
|
186
|
+
'other_home_office_expenses' => 'OtherHomeOfficeExpenses',
|
187
|
+
'other_miscellaneous_expense' => 'OtherMiscellaneousExpense',
|
188
|
+
'other_vehicle_expenses' => 'OtherVehicleExpenses',
|
189
|
+
'parking_and_tolls' => 'ParkingAndTolls',
|
190
|
+
'penalties_settlements' => 'PenaltiesSettlements',
|
191
|
+
'prior_period_items' => 'PriorPeriodItems',
|
192
|
+
'rent_and_lease' => 'RentAndLease',
|
193
|
+
'repairs_and_maintenance' => 'RepairsAndMaintenance',
|
194
|
+
'tax_roundoff_gain_or_loss' => 'TaxRoundoffGainOrLoss',
|
195
|
+
'utilities' => 'Utilities',
|
196
|
+
'vehicle_insurance' => 'VehicleInsurance',
|
197
|
+
'vehicle_lease' => 'VehicleLease',
|
198
|
+
'vehicle_loan_interest' => 'VehicleLoanInterest',
|
199
|
+
'vehicle_loan' => 'VehicleLoan',
|
200
|
+
'vehicle_registration' => 'VehicleRegistration',
|
201
|
+
'vehicle_repairs' => 'VehicleRepairs',
|
202
|
+
'vehicle' => 'Vehicle',
|
203
|
+
'wash_and_road_services' => 'WashAndRoadServices',
|
204
|
+
# Cost of Goods Sold
|
205
|
+
'cost_of_labor_cos' => 'CostOfLaborCos',
|
206
|
+
'cost_of_sales' => 'CostOfSales',
|
207
|
+
'equipment_rental_cos' => 'EquipmentRentalCos',
|
208
|
+
'freight_and_delivery_cost' => 'FreightAndDeliveryCost',
|
209
|
+
'other_costs_of_service_cos' => 'OtherCostsOfServiceCos',
|
210
|
+
'shipping_freight_delivery_cos' => 'ShippingFreightDeliveryCos',
|
211
|
+
'supplies_materials_cogs' => 'SuppliesMaterialsCogs',
|
212
|
+
# Accounts Payable
|
213
|
+
'accounts_payable' => 'AccountsPayable',
|
214
|
+
'outstanding_dues_micro_small_enterprise' => 'OutstandingDuesMicroSmallEnterprise',
|
215
|
+
'outstanding_dues_other_than_micro_small_enterprise' => 'OutstandingDuesOtherThanMicroSmallEnterprise',
|
216
|
+
# Credit Card
|
217
|
+
'credit_card' => 'CreditCard',
|
218
|
+
# Long Term Liability
|
219
|
+
'accruals_and_deferred_income' => 'AccrualsAndDeferredIncome',
|
220
|
+
'accrued_long_lerm_liabilities' => 'AccruedLongLermLiabilities',
|
221
|
+
'accrued_vacation_payable' => 'AccruedVacationPayable',
|
222
|
+
'bank_loans' => 'BankLoans',
|
223
|
+
'debts_related_to_participating_interests' => 'DebtsRelatedToParticipatingInterests',
|
224
|
+
'deferred_tax_liabilities' => 'DeferredTaxLiabilities',
|
225
|
+
'government_and_other_public_authorities' => 'GovernmentAndOtherPublicAuthorities',
|
226
|
+
'group_and_associates' => 'GroupAndAssociates',
|
227
|
+
'liabilities_related_to_assets_held_for_sale' => 'LiabilitiesRelatedToAssetsHeldForSale',
|
228
|
+
'long_term_borrowings' => 'LongTermBorrowings',
|
229
|
+
'long_term_debit' => 'LongTermDebit',
|
230
|
+
'long_term_employee_benefit_obligations' => 'LongTermEmployeeBenefitObligations',
|
231
|
+
'notes_payable' => 'NotesPayable',
|
232
|
+
'obligations_under_finance_leases' => 'ObligationsUnderFinanceLeases',
|
233
|
+
'other_long_term_liabilities' => 'OtherLongTermLiabilities',
|
234
|
+
'other_long_term_provisions' => 'OtherLongTermProvisions',
|
235
|
+
'provision_for_liabilities' => 'ProvisionForLiabilities',
|
236
|
+
'provisions_non_current_liabilities' => 'ProvisionsNonCurrentLiabilities',
|
237
|
+
'shareholder_notes_payable' => 'ShareholderNotesPayable',
|
238
|
+
'staff_and_related_long_term_liability_accounts' => 'StaffAndRelatedLongTermLiabilityAccounts',
|
239
|
+
# Other Current Liability
|
240
|
+
'accrued_liabilities' => 'AccruedLiabilities',
|
241
|
+
'current_liabilities' => 'CurrentLiabilities',
|
242
|
+
'current_portion_employee_benefits_obligations' => 'CurrentPortionEmployeeBenefitsObligations',
|
243
|
+
'current_portion_of_obligations_under_finance_leases' => 'CurrentPortionOfObligationsUnderFinanceLeases',
|
244
|
+
'current_tax_liability' => 'CurrentTaxLiability',
|
245
|
+
'direct_deposit_payable' => 'DirectDepositPayable',
|
246
|
+
'dividends_payable' => 'DividendsPayable',
|
247
|
+
'duties_and_taxes' => 'DutiesAndTaxes',
|
248
|
+
'federal_income_tax_payable' => 'FederalIncomeTaxPayable',
|
249
|
+
'global_tax_payable' => 'GlobalTaxPayable',
|
250
|
+
'global_tax_suspense' => 'GlobalTaxSuspense',
|
251
|
+
'insurance_payable' => 'InsurancePayable',
|
252
|
+
'interest_payables' => 'InterestPayables',
|
253
|
+
'line_of_credit' => 'LineOfCredit',
|
254
|
+
'loan_payable' => 'LoanPayable',
|
255
|
+
'other_current_liabilities' => 'OtherCurrentLiabilities',
|
256
|
+
'payroll_clearing' => 'PayrollClearing',
|
257
|
+
'payroll_tax_payable' => 'PayrollTaxPayable',
|
258
|
+
'prepaid_expenses_payable' => 'PrepaidExpensesPayable',
|
259
|
+
'provision_for_warranty_obligations' => 'ProvisionForWarrantyObligations',
|
260
|
+
'provisions_current_liabilities' => 'ProvisionsCurrentLiabilities',
|
261
|
+
'rents_in_trust_liability' => 'RentsInTrustLiability',
|
262
|
+
'sales_tax_payable' => 'SalesTaxPayable',
|
263
|
+
'short_term_borrowings' => 'ShortTermBorrowings',
|
264
|
+
'social_security_agencies' => 'SocialSecurityAgencies',
|
265
|
+
'staff_and_related_liability_accounts' => 'StaffAndRelatedLiabilityAccounts',
|
266
|
+
'state_local_income_tax_payable' => 'StateLocalIncomeTaxPayable',
|
267
|
+
'sundry_debtors_and_creditors' => 'SundryDebtorsAndCreditors',
|
268
|
+
'trade_and_other_payables' => 'TradeAndOtherPayables',
|
269
|
+
'trust_accounts_liabilities' => 'TrustAccountsLiabilities',
|
270
|
+
# Income
|
271
|
+
'cash_receipt_income' => 'CashReceiptIncome',
|
272
|
+
'discounts_refunds_given' => 'DiscountsRefundsGiven',
|
273
|
+
'non_profit_income' => 'NonProfitIncome',
|
274
|
+
'operating_grants' => 'OperatingGrants',
|
275
|
+
'other_current_operating_income' => 'OtherCurrentOperatingIncome',
|
276
|
+
'other_primary_income' => 'OtherPrimaryIncome',
|
277
|
+
'own_work_capitalized' => 'OwnWorkCapitalized',
|
278
|
+
'revenue_general' => 'RevenueGeneral',
|
279
|
+
'sales_of_product_income' => 'SalesOfProductIncome',
|
280
|
+
'sales_retail' => 'SalesRetail',
|
281
|
+
'sales_wholesale' => 'SalesWholesale',
|
282
|
+
'savings_by_tax_scheme' => 'SavingsByTaxScheme',
|
283
|
+
'service_fee_income' => 'ServiceFeeIncome',
|
284
|
+
'unapplied_cash_payment_income' => 'UnappliedCashPaymentIncome',
|
285
|
+
# Other Income
|
286
|
+
'dividend_income' => 'DividendIncome',
|
287
|
+
'gain_loss_on_sale_of_fixed_assets' => 'GainLossOnSaleOfFixedAssets',
|
288
|
+
'gain_loss_on_sale_of_investments' => 'GainLossOnSaleOfInvestments',
|
289
|
+
'interest_earned' => 'InterestEarned',
|
290
|
+
'loss_on_disposal_of_assets' => 'LossOnDisposalOfAssets',
|
291
|
+
'other_investment_income' => 'OtherInvestmentIncome',
|
292
|
+
'other_miscellaneous_income' => 'OtherMiscellaneousIncome',
|
293
|
+
'other_operating_income' => 'OtherOperatingIncome',
|
294
|
+
'tax_exempt_interest' => 'TaxExemptInterest',
|
295
|
+
'unrealised_loss_on_securities_net_of_tax' => 'UnrealisedLossOnSecuritiesNetOfTax'
|
296
|
+
}.freeze
|
297
|
+
|
298
|
+
TYPES = {
|
299
|
+
'bank' => 'Bank',
|
300
|
+
'other_current_assets' => 'Other Current Asset',
|
301
|
+
'fixed_asset' => 'Fixed Asset',
|
302
|
+
'other_asset' => 'Other Asset',
|
303
|
+
'accounts_receivable' => 'Accounts Receivable',
|
304
|
+
'equity' => 'Equity',
|
305
|
+
'expense' => 'Expense',
|
306
|
+
'other_expense' => 'Other Expense',
|
307
|
+
'cost_of_goods_sold' => 'Cost of Goods Sold',
|
308
|
+
'accounts_payable' => 'Accounts Payable',
|
309
|
+
'credit_card' => 'Credit Card',
|
310
|
+
'long_term_liability' => 'Long Term Liability',
|
311
|
+
'other_current_liability' => 'Other Current Liability',
|
312
|
+
'income' => 'Income',
|
313
|
+
'other_income' => 'Other Income'
|
314
|
+
}.freeze
|
315
|
+
|
316
|
+
TYPES_TO_CLASSIFICATION_MAPPING = {
|
317
|
+
'bank' => 'asset',
|
318
|
+
'other_current_assets' => 'asset',
|
319
|
+
'fixed_asset' => 'asset',
|
320
|
+
'other_asset' => 'asset',
|
321
|
+
'accounts_receivable' => 'asset',
|
322
|
+
'equity' => 'equity',
|
323
|
+
'expense' => 'expense',
|
324
|
+
'other_expense' => 'expense',
|
325
|
+
'cost_of_goods_sold' => 'expense',
|
326
|
+
'accounts_payable' => 'liability',
|
327
|
+
'credit_card' => 'liability',
|
328
|
+
'long_term_liability' => 'liability',
|
329
|
+
'other_current_liability' => 'liability',
|
330
|
+
'income' => 'revenue',
|
331
|
+
'other_income' => 'revenue'
|
332
|
+
}.freeze
|
333
|
+
|
334
|
+
CLASSIFICATIONS = {
|
335
|
+
'asset' => 'Asset',
|
336
|
+
'equity' => 'Equity',
|
337
|
+
'expense' => 'Expense',
|
338
|
+
'liability' => 'Liability',
|
339
|
+
'revenue' => 'Revenue'
|
340
|
+
}.freeze
|
341
|
+
|
342
|
+
attribute :Name, type: Type::String
|
343
|
+
attribute :Classification, type: Type::String
|
344
|
+
attribute :AccountType, type: Type::StringFromSet.new(values: TYPES.keys)
|
345
|
+
attribute :AccountSubType, type: Type::String
|
346
|
+
attribute :AcctNum, type: Type::String
|
347
|
+
attribute :Description, type: Type::String
|
348
|
+
attribute :Active, type: Type::Boolean
|
349
|
+
|
350
|
+
references_one :Currency, to: Currency
|
351
|
+
|
352
|
+
def name
|
353
|
+
self.Name
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|