ledger_sync 1.1.3 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.template +25 -0
- data/.gitignore +3 -1
- data/.rubocop_todo.yml +4 -1
- data/.travis.yml +1 -1
- data/Gemfile.lock +59 -25
- data/README.md +160 -8
- data/_config.yml +1 -0
- data/bin/qa +3 -0
- data/ledger_sync.gemspec +4 -0
- data/lib/ledger_sync.rb +40 -30
- data/lib/ledger_sync/adaptor_configuration.rb +17 -11
- data/lib/ledger_sync/adaptor_configuration_store.rb +13 -9
- data/lib/ledger_sync/adaptors/adaptor.rb +9 -1
- data/lib/ledger_sync/adaptors/ledger_serializer.rb +3 -6
- data/lib/ledger_sync/adaptors/ledger_serializer_attribute_set.rb +1 -1
- data/lib/ledger_sync/adaptors/ledger_serializer_type/references_many_type.rb +1 -1
- data/lib/ledger_sync/adaptors/mixins/infer_adaptor_class_mixin.rb +24 -0
- data/lib/ledger_sync/adaptors/mixins/infer_ledger_serializer_mixin.rb +31 -0
- data/lib/ledger_sync/adaptors/mixins/infer_resource_class_mixin.rb +22 -0
- data/lib/ledger_sync/adaptors/mixins/offset_and_limit_pagination_searcher_mixin.rb +37 -0
- data/lib/ledger_sync/adaptors/netsuite/account/ledger_deserializer.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/account/ledger_serializer.rb +22 -0
- data/lib/ledger_sync/adaptors/netsuite/account/operations/create.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/account/operations/find.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/account/searcher.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/adaptor.rb +145 -0
- data/lib/ledger_sync/adaptors/netsuite/config.rb +6 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/deledger_serializer.rb +28 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/ledger_serializer.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/create.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/delete.rb +23 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/find.rb +23 -0
- data/lib/ledger_sync/adaptors/netsuite/currency/operations/update.rb +23 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/ledger_deserializer.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/ledger_serializer.rb +38 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/create.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/delete.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/find.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/customer/operations/update.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer.rb +30 -0
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/reference_type.rb +24 -0
- data/lib/ledger_sync/adaptors/netsuite/ledger_serializer_type/subsidiary_type.rb +22 -0
- data/lib/ledger_sync/adaptors/netsuite/operation.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite/operation/create.rb +65 -0
- data/lib/ledger_sync/adaptors/netsuite/operation/delete.rb +49 -0
- data/lib/ledger_sync/adaptors/netsuite/operation/find.rb +56 -0
- data/lib/ledger_sync/adaptors/netsuite/operation/update.rb +68 -0
- data/lib/ledger_sync/adaptors/netsuite/record/http_method.rb +38 -0
- data/lib/ledger_sync/adaptors/netsuite/record/metadata.rb +75 -0
- data/lib/ledger_sync/adaptors/netsuite/record/property.rb +45 -0
- data/lib/ledger_sync/adaptors/netsuite/searcher.rb +17 -0
- data/lib/ledger_sync/adaptors/netsuite/token.rb +162 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/ledger_deserializer.rb +32 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/ledger_serializer.rb +35 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/create.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/delete.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/find.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite/vendor/operations/update.rb +27 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/adaptor.rb +92 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/config.rb +5 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/customer/ledger_serializer.rb +13 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/customer/operations/create.rb +64 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/customer/operations/find.rb +49 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/ledger_serializer.rb +25 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/operation.rb +40 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/operation/create.rb +29 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/operation/find.rb +15 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/create.rb +42 -0
- data/lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/find.rb +38 -0
- data/lib/ledger_sync/adaptors/operation.rb +7 -11
- data/lib/ledger_sync/adaptors/quickbooks_online/account/searcher.rb +2 -13
- data/lib/ledger_sync/adaptors/quickbooks_online/adaptor.rb +158 -109
- data/lib/ledger_sync/adaptors/quickbooks_online/bill/searcher.rb +1 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/config.rb +3 -2
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/operations/create.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/operations/find.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/operations/update.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/customer/searcher.rb +2 -16
- data/lib/ledger_sync/adaptors/quickbooks_online/dashboard_url_helper.rb +57 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/ledger_serializer.rb +38 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/operations/create.rb +23 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/operations/find.rb +23 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/operations/update.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/department/searcher.rb +17 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/ledger_serializer.rb +3 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/create.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/find.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/operations/update.rb +1 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/deposit/searcher.rb +0 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/expense/ledger_serializer.rb +0 -2
- data/lib/ledger_sync/adaptors/quickbooks_online/expense/searcher.rb +1 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/ledger_serializer.rb +35 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/create.rb +27 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/find.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice/operations/update.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/invoice_sales_line_item/ledger_serializer.rb +30 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/item/ledger_serializer.rb +13 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/journal_entry/searcher.rb +1 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/ledger_serializer.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/create.rb +23 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/find.rb +23 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/operations/update.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_class/searcher.rb +15 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer.rb +8 -5
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/entity_reference_type.rb +4 -14
- data/lib/ledger_sync/adaptors/quickbooks_online/ledger_serializer_type/transaction_reference_type.rb +49 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/oauth_client.rb +93 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/operation.rb +42 -7
- data/lib/ledger_sync/adaptors/quickbooks_online/operation/create.rb +5 -8
- data/lib/ledger_sync/adaptors/quickbooks_online/operation/find.rb +9 -9
- data/lib/ledger_sync/adaptors/quickbooks_online/operation/full_update.rb +17 -15
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/ledger_serializer.rb +25 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/operations/create.rb +9 -6
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/operations/find.rb +9 -2
- data/lib/ledger_sync/adaptors/quickbooks_online/payment/operations/update.rb +8 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/payment_line_item/ledger_serializer.rb +19 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/request.rb +98 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/searcher.rb +29 -13
- data/lib/ledger_sync/adaptors/quickbooks_online/util/operation_error_parser.rb +1 -1
- data/lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/create.rb +3 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/find.rb +3 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/vendor/operations/update.rb +3 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/vendor/searcher.rb +5 -54
- data/lib/ledger_sync/adaptors/quickbooks_online/webhook.rb +58 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/webhook_event.rb +79 -0
- data/lib/ledger_sync/adaptors/quickbooks_online/webhook_notification.rb +42 -0
- data/lib/ledger_sync/adaptors/request.rb +53 -0
- data/lib/ledger_sync/adaptors/response.rb +55 -0
- data/lib/ledger_sync/adaptors/searcher.rb +3 -1
- data/lib/ledger_sync/adaptors/stripe/adaptor.rb +45 -0
- data/lib/ledger_sync/adaptors/stripe/config.rb +6 -0
- data/lib/ledger_sync/adaptors/stripe/customer/operations/create.rb +44 -0
- data/lib/ledger_sync/adaptors/stripe/customer/operations/delete.rb +35 -0
- data/lib/ledger_sync/adaptors/stripe/customer/operations/find.rb +44 -0
- data/lib/ledger_sync/adaptors/stripe/customer/operations/update.rb +43 -0
- data/lib/ledger_sync/adaptors/stripe/operation.rb +35 -0
- data/lib/ledger_sync/adaptors/stripe/operation/create.rb +17 -0
- data/lib/ledger_sync/adaptors/stripe/operation/delete.rb +17 -0
- data/lib/ledger_sync/adaptors/stripe/operation/find.rb +15 -0
- data/lib/ledger_sync/adaptors/stripe/operation/update.rb +17 -0
- data/lib/ledger_sync/adaptors/test/config.rb +0 -1
- data/lib/ledger_sync/adaptors/test/customer/operations/create.rb +1 -0
- data/lib/ledger_sync/adaptors/test/customer/operations/find.rb +1 -0
- data/lib/ledger_sync/adaptors/test/customer/operations/invalid.rb +1 -0
- data/lib/ledger_sync/adaptors/test/customer/operations/update.rb +1 -0
- data/lib/ledger_sync/adaptors/test/customer/operations/valid.rb +1 -0
- data/lib/ledger_sync/adaptors/test/payment/operations/create.rb +8 -1
- data/lib/ledger_sync/adaptors/test/payment/operations/find.rb +9 -2
- data/lib/ledger_sync/adaptors/test/payment/operations/update.rb +9 -5
- data/lib/ledger_sync/adaptors/test/vendor/operations/create.rb +5 -0
- data/lib/ledger_sync/adaptors/test/vendor/operations/find.rb +3 -0
- data/lib/ledger_sync/adaptors/test/vendor/operations/invalid.rb +5 -0
- data/lib/ledger_sync/adaptors/test/vendor/operations/update.rb +5 -0
- data/lib/ledger_sync/adaptors/test/vendor/operations/valid.rb +5 -0
- data/lib/ledger_sync/error/adaptor_errors.rb +18 -5
- data/lib/ledger_sync/error/operation_errors.rb +13 -4
- data/lib/ledger_sync/resource.rb +6 -0
- data/lib/ledger_sync/resource_attribute/dirty_mixin.rb +16 -15
- data/lib/ledger_sync/resources/bill.rb +7 -1
- data/lib/ledger_sync/resources/bill_line_item.rb +2 -0
- data/lib/ledger_sync/resources/currency.rb +9 -0
- data/lib/ledger_sync/resources/customer.rb +16 -0
- data/lib/ledger_sync/resources/department.rb +14 -0
- data/lib/ledger_sync/resources/deposit.rb +7 -0
- data/lib/ledger_sync/resources/deposit_line_item.rb +6 -0
- data/lib/ledger_sync/resources/expense.rb +5 -0
- data/lib/ledger_sync/resources/expense_line_item.rb +2 -0
- data/lib/ledger_sync/resources/invoice.rb +23 -0
- data/lib/ledger_sync/resources/invoice_sales_line_item.rb +17 -0
- data/lib/ledger_sync/resources/item.rb +5 -0
- data/lib/ledger_sync/resources/journal_entry.rb +5 -1
- data/lib/ledger_sync/resources/journal_entry_line_item.rb +4 -0
- data/lib/ledger_sync/resources/ledger_class.rb +14 -0
- data/lib/ledger_sync/resources/payment.rb +13 -0
- data/lib/ledger_sync/resources/payment_line_item.rb +15 -0
- data/lib/ledger_sync/resources/subsidiary.rb +8 -0
- data/lib/ledger_sync/resources/transfer.rb +4 -0
- data/lib/ledger_sync/resources/vendor.rb +9 -2
- data/lib/ledger_sync/type/reference_many.rb +12 -1
- data/lib/ledger_sync/type/reference_one.rb +1 -1
- data/lib/ledger_sync/util/resonad.rb +18 -0
- data/lib/ledger_sync/util/signer.rb +36 -0
- data/lib/ledger_sync/util/string_helpers.rb +12 -12
- data/lib/ledger_sync/version.rb +1 -1
- data/qa/env_spec.rb +5 -0
- data/qa/netsuite/account_spec.rb +20 -0
- data/qa/netsuite/currency_spec.rb +16 -0
- data/qa/netsuite/customer.rb +76 -0
- data/qa/netsuite/customer_spec.rb +21 -0
- data/qa/netsuite/vendor.rb +76 -0
- data/qa/netsuite/vendor_spec.rb +23 -0
- data/qa/netsuite_soap/customer_spec.rb +21 -0
- data/qa/netsuite_soap/subsidiary_spec.rb +0 -0
- data/qa/netsuite_test.rb +42 -0
- data/qa/qa_helper.rb +58 -0
- data/qa/quickbooks_online/account_spec.rb +14 -0
- data/qa/quickbooks_online/customer_spec.rb +13 -0
- data/qa/quickbooks_online/expense_spec.rb +31 -0
- data/qa/quickbooks_online/vendor_spec.rb +13 -0
- data/qa/stripe/customers_spec.rb +15 -0
- data/qa/support/adaptor_helpers.rb +99 -0
- data/qa/support/adaptor_support_setup.rb +23 -0
- data/qa/support/netsuite_helpers.rb +33 -0
- data/qa/support/netsuite_shared_examples.rb +30 -0
- data/qa/support/netsuite_soap_helpers.rb +33 -0
- data/qa/support/netsuite_soap_shared_examples.rb +10 -0
- data/qa/support/quickbooks_online_helpers.rb +42 -0
- data/qa/support/quickbooks_online_shared_examples.rb +82 -0
- data/qa/support/shared_examples.rb +127 -0
- data/qa/support/stripe_helpers.rb +22 -0
- data/qa/support/stripe_shared_examples.rb +10 -0
- data/qa/test.rb +67 -0
- data/release.sh +13 -1
- metadata +189 -3
- data/qa.rb +0 -142
@@ -10,22 +10,23 @@ module LedgerSync
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
# Removed as it was not being used.
|
14
|
+
# def dirty_attribute(*names)
|
15
|
+
# names.each do |name|
|
16
|
+
# class_eval do
|
17
|
+
# attr_reader name
|
18
|
+
# define_attribute_methods name # From ActiveModel
|
19
|
+
# dirty_attributes[name] = {
|
20
|
+
# name: name
|
21
|
+
# }
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
23
|
+
# define_method("#{name}=") do |val|
|
24
|
+
# send("#{name}_will_change!") unless val == instance_variable_get("@#{name}")
|
25
|
+
# instance_variable_set("@#{name}", val)
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
# end
|
29
30
|
|
30
31
|
def dirty_attributes
|
31
32
|
@dirty_attributes ||= {}
|
@@ -1,3 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'account'
|
4
|
+
require_relative 'bill_line_item'
|
5
|
+
require_relative 'vendor'
|
6
|
+
|
1
7
|
module LedgerSync
|
2
8
|
class Bill < LedgerSync::Resource
|
3
9
|
attribute :currency, type: Type::String
|
@@ -12,7 +18,7 @@ module LedgerSync
|
|
12
18
|
references_many :line_items, to: BillLineItem
|
13
19
|
|
14
20
|
def name
|
15
|
-
"Bill: #{transaction_date
|
21
|
+
"Bill: #{transaction_date}"
|
16
22
|
end
|
17
23
|
end
|
18
24
|
end
|
@@ -1,9 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'subsidiary'
|
4
|
+
|
3
5
|
module LedgerSync
|
4
6
|
class Customer < LedgerSync::Resource
|
5
7
|
attribute :email, type: Type::String
|
6
8
|
attribute :name, type: Type::String
|
7
9
|
attribute :phone_number, type: Type::String
|
10
|
+
|
11
|
+
references_one :subsidiary, to: Subsidiary
|
12
|
+
|
13
|
+
def first_name
|
14
|
+
return '' if name.blank?
|
15
|
+
|
16
|
+
name.split(' ').first
|
17
|
+
end
|
18
|
+
|
19
|
+
def last_name
|
20
|
+
return '' if name.blank?
|
21
|
+
|
22
|
+
name.split(' ')[1..-1].join(' ')
|
23
|
+
end
|
8
24
|
end
|
9
25
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'department'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
class Department < LedgerSync::Resource
|
7
|
+
attribute :name, type: Type::String
|
8
|
+
attribute :fully_qualified_name, type: Type::String
|
9
|
+
attribute :active, type: Type::Boolean
|
10
|
+
attribute :sub_department, type: Type::Boolean
|
11
|
+
|
12
|
+
references_one :parent, to: Department
|
13
|
+
end
|
14
|
+
end
|
@@ -1,3 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'account'
|
4
|
+
require_relative 'department'
|
5
|
+
require_relative 'deposit_line_item'
|
6
|
+
|
1
7
|
module LedgerSync
|
2
8
|
class Deposit < LedgerSync::Resource
|
3
9
|
attribute :currency, type: Type::String
|
@@ -6,6 +12,7 @@ module LedgerSync
|
|
6
12
|
attribute :exchange_rate, type: Type::Float
|
7
13
|
|
8
14
|
references_one :account, to: Account
|
15
|
+
references_one :department, to: Department
|
9
16
|
|
10
17
|
references_many :line_items, to: DepositLineItem
|
11
18
|
|
@@ -1,5 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'account'
|
4
|
+
require_relative 'customer'
|
5
|
+
require_relative 'expense_line_item'
|
6
|
+
require_relative 'vendor'
|
7
|
+
|
3
8
|
module LedgerSync
|
4
9
|
class Expense < LedgerSync::Resource
|
5
10
|
attribute :currency, type: Type::String
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'account'
|
4
|
+
require_relative 'customer'
|
5
|
+
require_relative 'invoice_sales_line_item'
|
6
|
+
|
7
|
+
module LedgerSync
|
8
|
+
class Invoice < LedgerSync::Resource
|
9
|
+
attribute :currency, type: Type::String
|
10
|
+
attribute :memo, type: Type::String
|
11
|
+
attribute :transaction_date, type: Type::Date
|
12
|
+
attribute :deposit, type: Type::Integer
|
13
|
+
|
14
|
+
references_one :customer, to: Customer
|
15
|
+
references_one :account, to: Account
|
16
|
+
|
17
|
+
references_many :line_items, to: InvoiceSalesLineItem
|
18
|
+
|
19
|
+
def name
|
20
|
+
"Invoice: #{transaction_date}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'item'
|
4
|
+
require_relative 'ledger_class'
|
5
|
+
|
6
|
+
module LedgerSync
|
7
|
+
class InvoiceSalesLineItem < LedgerSync::Resource
|
8
|
+
references_one :item, to: Item
|
9
|
+
references_one :ledger_class, to: LedgerClass
|
10
|
+
attribute :amount, type: Type::Integer
|
11
|
+
attribute :description, type: Type::String
|
12
|
+
|
13
|
+
def name
|
14
|
+
description
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'journal_entry_line_item'
|
4
|
+
|
1
5
|
module LedgerSync
|
2
6
|
class JournalEntry < LedgerSync::Resource
|
3
7
|
attribute :currency, type: Type::String
|
@@ -8,7 +12,7 @@ module LedgerSync
|
|
8
12
|
references_many :line_items, to: JournalEntryLineItem
|
9
13
|
|
10
14
|
def name
|
11
|
-
"JournalEntry: #{transaction_date
|
15
|
+
"JournalEntry: #{transaction_date}"
|
12
16
|
end
|
13
17
|
end
|
14
18
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'ledger_class'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
class LedgerClass < LedgerSync::Resource
|
7
|
+
attribute :name, type: Type::String
|
8
|
+
attribute :fully_qualified_name, type: Type::String
|
9
|
+
attribute :active, type: Type::Boolean
|
10
|
+
attribute :sub_class, type: Type::Boolean
|
11
|
+
|
12
|
+
references_one :parent, to: LedgerClass
|
13
|
+
end
|
14
|
+
end
|
@@ -1,10 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative 'account'
|
4
|
+
require_relative 'customer'
|
5
|
+
require_relative 'payment_line_item'
|
6
|
+
|
3
7
|
module LedgerSync
|
4
8
|
class Payment < LedgerSync::Resource
|
5
9
|
attribute :amount, type: Type::Integer
|
6
10
|
attribute :currency, type: Type::String
|
11
|
+
attribute :memo, type: Type::String
|
12
|
+
attribute :transaction_date, type: Type::Date
|
13
|
+
attribute :exchange_rate, type: Type::Float
|
14
|
+
attribute :reference_number, type: Type::String
|
15
|
+
|
7
16
|
references_one :customer, to: Customer
|
17
|
+
references_one :deposit_account, to: Account
|
18
|
+
references_one :account, to: Account
|
19
|
+
|
20
|
+
references_many :line_items, to: PaymentLineItem
|
8
21
|
|
9
22
|
def name
|
10
23
|
"Payment: #{amount} #{currency}"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'invoice'
|
4
|
+
|
5
|
+
module LedgerSync
|
6
|
+
class PaymentLineItem < LedgerSync::Resource
|
7
|
+
attribute :amount, type: Type::Integer
|
8
|
+
|
9
|
+
references_many :ledger_transactions, to: [Invoice]
|
10
|
+
|
11
|
+
def name
|
12
|
+
amount
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,12 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'subsidiary'
|
4
|
+
|
1
5
|
module LedgerSync
|
2
6
|
class Vendor < LedgerSync::Resource
|
7
|
+
attribute :company_name, type: Type::String
|
3
8
|
attribute :email, type: Type::String
|
9
|
+
attribute :display_name, type: Type::String
|
4
10
|
attribute :first_name, type: Type::String
|
5
11
|
attribute :last_name, type: Type::String
|
6
|
-
attribute :
|
12
|
+
attribute :phone_number, type: Type::String
|
13
|
+
references_one :subsidiary, to: Subsidiary
|
7
14
|
|
8
15
|
def name
|
9
|
-
|
16
|
+
display_name.to_s
|
10
17
|
end
|
11
18
|
end
|
12
19
|
end
|
@@ -25,8 +25,19 @@ module LedgerSync
|
|
25
25
|
|
26
26
|
def valid_without_casting?(value:)
|
27
27
|
return false unless value.is_a?(Array)
|
28
|
+
return true if (resource_classes & value.map(&:class)).any?
|
29
|
+
return true if value.is_a?(Array) && value.empty?
|
28
30
|
|
29
|
-
|
31
|
+
false
|
32
|
+
end
|
33
|
+
private
|
34
|
+
|
35
|
+
def resource_classes
|
36
|
+
@resource_classes ||= if resource_class.is_a?(Array)
|
37
|
+
resource_class
|
38
|
+
else
|
39
|
+
[resource_class]
|
40
|
+
end
|
30
41
|
end
|
31
42
|
end
|
32
43
|
end
|
@@ -16,7 +16,7 @@ module LedgerSync
|
|
16
16
|
if resource_class.is_a?(Array)
|
17
17
|
"Attribute #{attribute.name} for #{resource.class.name} should be one of the following: #{resource_class.map(&:name).join(', ')}. Given #{value.class.name}"
|
18
18
|
else
|
19
|
-
"Attribute #{attribute.name} for #{resource.class.name} should be a #{resource_class.
|
19
|
+
"Attribute #{attribute.name} for #{resource.class.name} should be a #{resource_class.name}. Given #{value.class.name}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Extend the Resonad gem to offer method to raise errors directly
|
5
|
+
#
|
6
|
+
class Resonad
|
7
|
+
class Success
|
8
|
+
def raise_if_error
|
9
|
+
self
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Failure
|
14
|
+
def raise_if_error
|
15
|
+
raise error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module Util
|
5
|
+
class Signer
|
6
|
+
HMAC_SHA1_DIGEST = OpenSSL::Digest.new('sha1')
|
7
|
+
HMAC_SHA256_DIGEST = OpenSSL::Digest.new('sha256')
|
8
|
+
|
9
|
+
attr_reader :str
|
10
|
+
|
11
|
+
def initialize(str:)
|
12
|
+
@str = str
|
13
|
+
end
|
14
|
+
|
15
|
+
def hmac_sha1(escape: false, key:)
|
16
|
+
ret = Base64.encode64(OpenSSL::HMAC.digest(HMAC_SHA1_DIGEST, key, str)).strip
|
17
|
+
ret = self.class.escape(str: ret) if escape
|
18
|
+
ret
|
19
|
+
end
|
20
|
+
|
21
|
+
def hmac_sha256(escape: false, key:)
|
22
|
+
ret = Base64.encode64(OpenSSL::HMAC.digest(HMAC_SHA256_DIGEST, key, str)).strip
|
23
|
+
ret = self.class.escape(str: ret) if escape
|
24
|
+
ret
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.escape(str:)
|
28
|
+
CGI.escape(str).gsub(/\+/, '%20')
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.unescape(str:)
|
32
|
+
CGI.unescape(str.gsub(/%20/, '+'))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,17 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LedgerSync
|
2
4
|
module Util
|
3
5
|
module StringHelpers
|
4
|
-
|
6
|
+
module_function
|
5
7
|
|
6
8
|
def camelcase(str)
|
7
|
-
str.to_s.split('/').map { |e| e.split('_').collect(&:capitalize).
|
9
|
+
str.to_s.split('/').map { |e| inflect(e.split('_').collect(&:capitalize).join) }.join('::')
|
8
10
|
end
|
9
11
|
|
10
|
-
# def underscore!(str)
|
11
|
-
# str.gsub!(/(.)([A-Z])/, '\1_\2')
|
12
|
-
# str.downcase!
|
13
|
-
# end
|
14
|
-
|
15
12
|
def underscore!(str)
|
16
13
|
str.gsub!(/::/, '/')
|
17
14
|
str.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
@@ -25,12 +22,15 @@ module LedgerSync
|
|
25
22
|
end
|
26
23
|
|
27
24
|
def inflect(str)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
return str unless LedgerSync.respond_to?(:adaptors)
|
26
|
+
|
27
|
+
LedgerSync.adaptors.inflections.each do |inflection|
|
28
|
+
next unless inflection.downcase == str.downcase
|
29
|
+
|
30
|
+
return inflection
|
33
31
|
end
|
32
|
+
|
33
|
+
str
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|