ledger_sync-netsuite 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/.env.test +14 -0
- data/.github/workflows/gem-workflow.yml +63 -0
- data/.gitignore +20 -0
- data/.overcommit.yml +29 -0
- data/.rubocop.yml +78 -0
- data/.rubocop_todo.yml +25 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +203 -0
- data/README.md +19 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/ledger_sync-netsuite.gemspec +44 -0
- data/lib/ledger_sync/netsuite.rb +13 -0
- data/lib/ledger_sync/netsuite/account/deserializer.rb +21 -0
- data/lib/ledger_sync/netsuite/account/operations/create.rb +26 -0
- data/lib/ledger_sync/netsuite/account/operations/find.rb +26 -0
- data/lib/ledger_sync/netsuite/account/searcher.rb +10 -0
- data/lib/ledger_sync/netsuite/account/searcher_deserializer.rb +27 -0
- data/lib/ledger_sync/netsuite/account/serializer.rb +19 -0
- data/lib/ledger_sync/netsuite/check/deserializer.rb +27 -0
- data/lib/ledger_sync/netsuite/check/operations/create.rb +25 -0
- data/lib/ledger_sync/netsuite/check/operations/delete.rb +25 -0
- data/lib/ledger_sync/netsuite/check/operations/find.rb +25 -0
- data/lib/ledger_sync/netsuite/check/operations/update.rb +25 -0
- data/lib/ledger_sync/netsuite/check/searcher.rb +13 -0
- data/lib/ledger_sync/netsuite/check/searcher_deserializer.rb +14 -0
- data/lib/ledger_sync/netsuite/check/serializer.rb +49 -0
- data/lib/ledger_sync/netsuite/check_line_item/deserializer.rb +16 -0
- data/lib/ledger_sync/netsuite/check_line_item/serializer.rb +24 -0
- data/lib/ledger_sync/netsuite/client.rb +186 -0
- data/lib/ledger_sync/netsuite/config.rb +12 -0
- data/lib/ledger_sync/netsuite/currency/deserializer.rb +21 -0
- data/lib/ledger_sync/netsuite/currency/operations/create.rb +23 -0
- data/lib/ledger_sync/netsuite/currency/operations/delete.rb +21 -0
- data/lib/ledger_sync/netsuite/currency/operations/find.rb +25 -0
- data/lib/ledger_sync/netsuite/currency/operations/update.rb +21 -0
- data/lib/ledger_sync/netsuite/currency/serializer.rb +19 -0
- data/lib/ledger_sync/netsuite/customer/deserializer.rb +20 -0
- data/lib/ledger_sync/netsuite/customer/operations/create.rb +24 -0
- data/lib/ledger_sync/netsuite/customer/operations/delete.rb +24 -0
- data/lib/ledger_sync/netsuite/customer/operations/find.rb +24 -0
- data/lib/ledger_sync/netsuite/customer/operations/update.rb +24 -0
- data/lib/ledger_sync/netsuite/customer/searcher.rb +10 -0
- data/lib/ledger_sync/netsuite/customer/searcher_deserializer.rb +16 -0
- data/lib/ledger_sync/netsuite/customer/serializer.rb +27 -0
- data/lib/ledger_sync/netsuite/customer_deposit/deserializer.rb +18 -0
- data/lib/ledger_sync/netsuite/customer_deposit/operations/create.rb +22 -0
- data/lib/ledger_sync/netsuite/customer_deposit/operations/delete.rb +22 -0
- data/lib/ledger_sync/netsuite/customer_deposit/operations/find.rb +22 -0
- data/lib/ledger_sync/netsuite/customer_deposit/operations/update.rb +22 -0
- data/lib/ledger_sync/netsuite/customer_deposit/searcher.rb +10 -0
- data/lib/ledger_sync/netsuite/customer_deposit/searcher_deserializer.rb +14 -0
- data/lib/ledger_sync/netsuite/customer_deposit/serializer.rb +23 -0
- data/lib/ledger_sync/netsuite/dashboard_url_helper.rb +26 -0
- data/lib/ledger_sync/netsuite/department/deserializer.rb +13 -0
- data/lib/ledger_sync/netsuite/department/operations/create.rb +23 -0
- data/lib/ledger_sync/netsuite/department/operations/delete.rb +23 -0
- data/lib/ledger_sync/netsuite/department/operations/find.rb +23 -0
- data/lib/ledger_sync/netsuite/department/operations/update.rb +23 -0
- data/lib/ledger_sync/netsuite/department/searcher.rb +10 -0
- data/lib/ledger_sync/netsuite/department/searcher_deserializer.rb +17 -0
- data/lib/ledger_sync/netsuite/department/serializer.rb +11 -0
- data/lib/ledger_sync/netsuite/deserializer.rb +16 -0
- data/lib/ledger_sync/netsuite/error.rb +17 -0
- data/lib/ledger_sync/netsuite/journal_entry/deserializer.rb +29 -0
- data/lib/ledger_sync/netsuite/journal_entry/operations/create.rb +24 -0
- data/lib/ledger_sync/netsuite/journal_entry/operations/delete.rb +24 -0
- data/lib/ledger_sync/netsuite/journal_entry/operations/find.rb +24 -0
- data/lib/ledger_sync/netsuite/journal_entry/operations/update.rb +28 -0
- data/lib/ledger_sync/netsuite/journal_entry/serializer.rb +34 -0
- data/lib/ledger_sync/netsuite/journal_entry_line_item/deserializer.rb +18 -0
- data/lib/ledger_sync/netsuite/journal_entry_line_item/serializer.rb +18 -0
- data/lib/ledger_sync/netsuite/ledger_class/deserializer.rb +13 -0
- data/lib/ledger_sync/netsuite/ledger_class/operations/create.rb +23 -0
- data/lib/ledger_sync/netsuite/ledger_class/operations/delete.rb +23 -0
- data/lib/ledger_sync/netsuite/ledger_class/operations/find.rb +23 -0
- data/lib/ledger_sync/netsuite/ledger_class/operations/update.rb +23 -0
- data/lib/ledger_sync/netsuite/ledger_class/searcher.rb +10 -0
- data/lib/ledger_sync/netsuite/ledger_class/searcher_deserializer.rb +17 -0
- data/lib/ledger_sync/netsuite/ledger_class/serializer.rb +11 -0
- data/lib/ledger_sync/netsuite/location/deserializer.rb +13 -0
- data/lib/ledger_sync/netsuite/location/operations/create.rb +19 -0
- data/lib/ledger_sync/netsuite/location/operations/delete.rb +19 -0
- data/lib/ledger_sync/netsuite/location/operations/find.rb +19 -0
- data/lib/ledger_sync/netsuite/location/operations/update.rb +19 -0
- data/lib/ledger_sync/netsuite/location/searcher.rb +10 -0
- data/lib/ledger_sync/netsuite/location/serializer.rb +11 -0
- data/lib/ledger_sync/netsuite/operation.rb +38 -0
- data/lib/ledger_sync/netsuite/operation/create.rb +56 -0
- data/lib/ledger_sync/netsuite/operation/delete.rb +47 -0
- data/lib/ledger_sync/netsuite/operation/find.rb +68 -0
- data/lib/ledger_sync/netsuite/operation/update.rb +59 -0
- data/lib/ledger_sync/netsuite/record/http_method.rb +31 -0
- data/lib/ledger_sync/netsuite/record/metadata.rb +107 -0
- data/lib/ledger_sync/netsuite/record/parameter.rb +18 -0
- data/lib/ledger_sync/netsuite/record/property.rb +20 -0
- data/lib/ledger_sync/netsuite/reference/serializer.rb +11 -0
- data/lib/ledger_sync/netsuite/resource.rb +8 -0
- data/lib/ledger_sync/netsuite/resources/account.rb +41 -0
- data/lib/ledger_sync/netsuite/resources/check.rb +21 -0
- data/lib/ledger_sync/netsuite/resources/check_line_item.rb +13 -0
- data/lib/ledger_sync/netsuite/resources/currency.rb +11 -0
- data/lib/ledger_sync/netsuite/resources/customer.rb +17 -0
- data/lib/ledger_sync/netsuite/resources/customer_deposit.rb +13 -0
- data/lib/ledger_sync/netsuite/resources/department.rb +14 -0
- data/lib/ledger_sync/netsuite/resources/deposit.rb +26 -0
- data/lib/ledger_sync/netsuite/resources/deposit_line_item.rb +23 -0
- data/lib/ledger_sync/netsuite/resources/invoice.rb +26 -0
- data/lib/ledger_sync/netsuite/resources/invoice_line_item.rb +19 -0
- data/lib/ledger_sync/netsuite/resources/item.rb +9 -0
- data/lib/ledger_sync/netsuite/resources/journal_entry.rb +24 -0
- data/lib/ledger_sync/netsuite/resources/journal_entry_line_item.rb +22 -0
- data/lib/ledger_sync/netsuite/resources/ledger_class.rb +14 -0
- data/lib/ledger_sync/netsuite/resources/location.rb +9 -0
- data/lib/ledger_sync/netsuite/resources/subsidiary.rb +10 -0
- data/lib/ledger_sync/netsuite/resources/vendor.rb +21 -0
- data/lib/ledger_sync/netsuite/searcher.rb +64 -0
- data/lib/ledger_sync/netsuite/serializer.rb +11 -0
- data/lib/ledger_sync/netsuite/subsidiary/deserializer.rb +15 -0
- data/lib/ledger_sync/netsuite/subsidiary/searcher.rb +10 -0
- data/lib/ledger_sync/netsuite/subsidiary/searcher_deserializer.rb +13 -0
- data/lib/ledger_sync/netsuite/subsidiary/serializer.rb +13 -0
- data/lib/ledger_sync/netsuite/token.rb +156 -0
- data/lib/ledger_sync/netsuite/type/deserializer_active_type.rb +30 -0
- data/lib/ledger_sync/netsuite/type/deserializer_customer_type.rb +33 -0
- data/lib/ledger_sync/netsuite/type/deserializer_entity_type.rb +28 -0
- data/lib/ledger_sync/netsuite/type/deserializer_subsidiary_type.rb +33 -0
- data/lib/ledger_sync/netsuite/vendor/deserializer.rb +28 -0
- data/lib/ledger_sync/netsuite/vendor/operations/create.rb +25 -0
- data/lib/ledger_sync/netsuite/vendor/operations/delete.rb +25 -0
- data/lib/ledger_sync/netsuite/vendor/operations/find.rb +25 -0
- data/lib/ledger_sync/netsuite/vendor/operations/update.rb +25 -0
- data/lib/ledger_sync/netsuite/vendor/searcher.rb +10 -0
- data/lib/ledger_sync/netsuite/vendor/searcher_deserializer.rb +19 -0
- data/lib/ledger_sync/netsuite/vendor/serializer.rb +28 -0
- data/lib/ledger_sync/netsuite/version.rb +17 -0
- data/license.txt +4 -0
- metadata +392 -0
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# LedgerSync::NetSuite
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/LedgerSync/ledger_sync-netsuite.svg?branch=master)](https://travis-ci.org/LedgerSync/ledger_sync-netsuite)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/ledger_sync-netsuite.svg)](https://badge.fury.io/rb/ledger_sync-netsuite)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/LedgerSync/ledger_sync-netsuite/badge.svg?branch=master)](https://coveralls.io/github/LedgerSync/ledger_sync-netsuite?branch=master)
|
6
|
+
|
7
|
+
[ledgersync.dev](www.ledgersync.dev)
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
This template ledger enables you to easily create your own ledger for public or private use. Although this is not an
|
12
|
+
exhaustive list, a good place to start assuming your ledger name is `NewLedger`:
|
13
|
+
|
14
|
+
1. Find and replace all `NETSUITE` with `NEW_LEDGER`
|
15
|
+
2. Find and replace all `NetSuite` with `NewLedger`
|
16
|
+
3. Find and replace all `netsuite` with `new_ledger`
|
17
|
+
4. Find and replace all `NetSuite` with `New Ledger`
|
18
|
+
5. Find and replace all `netsuite` directories and files with `new_ledger`
|
19
|
+
6. Remove `SampleResource` example files.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'ledger_sync/netsuite'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'ledger_sync/netsuite/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'ledger_sync-netsuite'
|
9
|
+
spec.version = LedgerSync::NetSuite::VERSION
|
10
|
+
spec.authors = ['Modern Treasury']
|
11
|
+
spec.email = ['ledgersync@moderntreasury.com']
|
12
|
+
|
13
|
+
spec.required_ruby_version = '>= 2.5.8'
|
14
|
+
|
15
|
+
spec.summary = 'Sync common objects to accounting software.'
|
16
|
+
spec.description = 'LedgerSync is a simple library that allows you to sync common objects to popular accounting '\
|
17
|
+
'software like QuickBooks Online, NetSuite, NetSuite, etc.'
|
18
|
+
spec.homepage = 'https://www.ledgersync.dev'
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = 'exe'
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency('awesome_print', '>= 0')
|
30
|
+
spec.add_development_dependency('bump', '~> 0.9.0')
|
31
|
+
spec.add_development_dependency('bundler', '~> 2.1')
|
32
|
+
spec.add_development_dependency('byebug')
|
33
|
+
spec.add_development_dependency('climate_control')
|
34
|
+
spec.add_development_dependency('coveralls', '~> 0.8.23')
|
35
|
+
spec.add_development_dependency('factory_bot', '~> 6.1.0')
|
36
|
+
spec.add_development_dependency('rake', '~> 13.0')
|
37
|
+
spec.add_development_dependency('rspec', '~> 3.2')
|
38
|
+
spec.add_development_dependency('rubocop', '>= 0')
|
39
|
+
spec.add_development_dependency('webmock', '>= 0')
|
40
|
+
spec.add_runtime_dependency('dotenv')
|
41
|
+
spec.add_runtime_dependency('ledger_sync', '1.8.0')
|
42
|
+
spec.add_runtime_dependency('nokogiri', '>= 0')
|
43
|
+
spec.add_runtime_dependency('oauth2', '>= 0')
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Account
|
6
|
+
class Deserializer < NetSuite::Deserializer
|
7
|
+
id
|
8
|
+
|
9
|
+
attribute :name,
|
10
|
+
hash_attribute: :acctname
|
11
|
+
|
12
|
+
mapping :account_type,
|
13
|
+
hash_attribute: :accttype,
|
14
|
+
hash: Account::TYPES.invert
|
15
|
+
|
16
|
+
attribute :number,
|
17
|
+
hash_attribute: :acctnumber
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Account
|
6
|
+
module Operations
|
7
|
+
class Create < NetSuite::Operation::Create
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).filled(:string)
|
11
|
+
required(:ledger_id).value(:nil)
|
12
|
+
required(:name).filled(:string)
|
13
|
+
required(:classification).maybe(:string)
|
14
|
+
required(:account_type).maybe(:string)
|
15
|
+
required(:account_sub_type).maybe(:string)
|
16
|
+
required(:number).filled(:string)
|
17
|
+
required(:currency).filled(:hash, Types::Reference)
|
18
|
+
required(:description).maybe(:string)
|
19
|
+
required(:active).maybe(:bool)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Account
|
6
|
+
module Operations
|
7
|
+
class Find < NetSuite::Operation::Find
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
required(:ledger_id).filled(:string)
|
12
|
+
required(:name).maybe(:string)
|
13
|
+
required(:classification).maybe(:string)
|
14
|
+
required(:account_type).maybe(:string)
|
15
|
+
required(:account_sub_type).maybe(:string)
|
16
|
+
required(:number).maybe(:string)
|
17
|
+
required(:currency).maybe(:hash, Types::Reference)
|
18
|
+
required(:description).maybe(:string)
|
19
|
+
required(:active).maybe(:bool)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Account
|
6
|
+
class SearcherDeserializer < NetSuite::Deserializer
|
7
|
+
id
|
8
|
+
|
9
|
+
attribute :name,
|
10
|
+
hash_attribute: :accountsearchdisplayname
|
11
|
+
|
12
|
+
attribute :number,
|
13
|
+
hash_attribute: :acctnumber
|
14
|
+
|
15
|
+
mapping :account_type,
|
16
|
+
hash_attribute: :accttype,
|
17
|
+
hash: Account::TYPES.invert
|
18
|
+
|
19
|
+
attribute :description
|
20
|
+
|
21
|
+
attribute :active,
|
22
|
+
hash_attribute: :isinactive,
|
23
|
+
type: Type::DeserializerActiveType.new
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Account
|
6
|
+
class Serializer < NetSuite::Serializer
|
7
|
+
attribute :name,
|
8
|
+
ledger_attribute: :acctname
|
9
|
+
|
10
|
+
mapping :accttype,
|
11
|
+
resource_attribute: :account_type,
|
12
|
+
hash: Account::TYPES
|
13
|
+
|
14
|
+
attribute :number,
|
15
|
+
ledger_attribute: :acctnumber
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Check
|
6
|
+
class Deserializer < NetSuite::Deserializer
|
7
|
+
id
|
8
|
+
|
9
|
+
attribute :memo
|
10
|
+
|
11
|
+
attribute :trandate
|
12
|
+
|
13
|
+
references_one :account
|
14
|
+
|
15
|
+
references_one :currency
|
16
|
+
|
17
|
+
references_one :department
|
18
|
+
|
19
|
+
attribute :entity,
|
20
|
+
type: Type::DeserializerEntityType.new
|
21
|
+
|
22
|
+
references_many :line_items,
|
23
|
+
hash_attribute: 'expense.items'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Check
|
6
|
+
module Operations
|
7
|
+
class Create < NetSuite::Operation::Create
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).filled(:string)
|
11
|
+
required(:ledger_id).value(:nil)
|
12
|
+
required(:memo).maybe(:string)
|
13
|
+
required(:trandate).maybe(:string)
|
14
|
+
required(:account).filled(:hash, Types::Reference)
|
15
|
+
required(:department).filled(:hash, Types::Reference)
|
16
|
+
required(:entity).filled(:hash, Types::Reference)
|
17
|
+
required(:currency).filled(:hash, Types::Reference)
|
18
|
+
required(:line_items).array(Types::Reference)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Check
|
6
|
+
module Operations
|
7
|
+
class Delete < NetSuite::Operation::Delete
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
required(:ledger_id).filled(:string)
|
12
|
+
required(:memo).maybe(:string)
|
13
|
+
required(:trandate).maybe(:string)
|
14
|
+
required(:account).maybe(:hash, Types::Reference)
|
15
|
+
required(:department).maybe(:hash, Types::Reference)
|
16
|
+
required(:entity).maybe(:hash, Types::Reference)
|
17
|
+
required(:currency).maybe(:hash, Types::Reference)
|
18
|
+
required(:line_items).array(Types::Reference)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Check
|
6
|
+
module Operations
|
7
|
+
class Find < NetSuite::Operation::Find
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
required(:ledger_id).filled(:string)
|
12
|
+
required(:memo).maybe(:string)
|
13
|
+
required(:trandate).maybe(:string)
|
14
|
+
required(:account).maybe(:hash, Types::Reference)
|
15
|
+
required(:department).maybe(:hash, Types::Reference)
|
16
|
+
required(:entity).maybe(:hash, Types::Reference)
|
17
|
+
required(:currency).maybe(:hash, Types::Reference)
|
18
|
+
required(:line_items).array(Types::Reference)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LedgerSync
|
4
|
+
module NetSuite
|
5
|
+
class Check
|
6
|
+
module Operations
|
7
|
+
class Update < NetSuite::Operation::Update
|
8
|
+
class Contract < LedgerSync::Ledgers::Contract
|
9
|
+
params do
|
10
|
+
required(:external_id).maybe(:string)
|
11
|
+
required(:ledger_id).filled(:string)
|
12
|
+
required(:memo).maybe(:string)
|
13
|
+
required(:trandate).maybe(:string)
|
14
|
+
required(:account).filled(:hash, Types::Reference)
|
15
|
+
required(:department).filled(:hash, Types::Reference)
|
16
|
+
required(:entity).filled(:hash, Types::Reference)
|
17
|
+
required(:currency).filled(:hash, Types::Reference)
|
18
|
+
required(:line_items).array(Types::Reference)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../reference/serializer'
|
4
|
+
require_relative '../check_line_item/serializer'
|
5
|
+
|
6
|
+
module LedgerSync
|
7
|
+
module NetSuite
|
8
|
+
class Check
|
9
|
+
class Serializer < NetSuite::Serializer
|
10
|
+
attribute :memo
|
11
|
+
attribute :trandate
|
12
|
+
|
13
|
+
references_one :account,
|
14
|
+
serializer: Reference::Serializer, if: :account_present?
|
15
|
+
|
16
|
+
references_one :department,
|
17
|
+
serializer: Reference::Serializer, if: :department_present?
|
18
|
+
|
19
|
+
references_one :currency,
|
20
|
+
serializer: Reference::Serializer, if: :currency_present?
|
21
|
+
|
22
|
+
references_one :entity,
|
23
|
+
serializer: Reference::Serializer
|
24
|
+
|
25
|
+
references_many 'expense.items',
|
26
|
+
resource_attribute: :line_items,
|
27
|
+
serializer: CheckLineItem::Serializer
|
28
|
+
|
29
|
+
def account_present?(args = {})
|
30
|
+
resource = args.fetch(:resource)
|
31
|
+
|
32
|
+
resource.account.present?
|
33
|
+
end
|
34
|
+
|
35
|
+
def department_present?(args = {})
|
36
|
+
resource = args.fetch(:resource)
|
37
|
+
|
38
|
+
resource.department.present?
|
39
|
+
end
|
40
|
+
|
41
|
+
def currency_present?(args = {})
|
42
|
+
resource = args.fetch(:resource)
|
43
|
+
|
44
|
+
resource.currency.present?
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|