netsuite 0.8.9 → 0.8.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/dependabot.yml +14 -0
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.github/workflows/main.yml +7 -4
- data/Gemfile +5 -3
- data/HISTORY.md +45 -5
- data/README.md +95 -39
- data/lib/netsuite/actions/add.rb +5 -1
- data/lib/netsuite/actions/attach_file.rb +87 -0
- data/lib/netsuite/actions/delete.rb +1 -1
- data/lib/netsuite/actions/delete_list.rb +1 -1
- data/lib/netsuite/actions/get.rb +1 -1
- data/lib/netsuite/actions/get_deleted.rb +1 -1
- data/lib/netsuite/actions/get_list.rb +1 -1
- data/lib/netsuite/actions/initialize.rb +2 -2
- data/lib/netsuite/actions/search.rb +20 -7
- data/lib/netsuite/records/account.rb +0 -1
- data/lib/netsuite/records/accounting_period.rb +1 -1
- data/lib/netsuite/records/assembly_component.rb +0 -2
- data/lib/netsuite/records/assembly_item.rb +1 -2
- data/lib/netsuite/records/assembly_unbuild.rb +0 -1
- data/lib/netsuite/records/cash_refund.rb +0 -1
- data/lib/netsuite/records/cash_refund_item.rb +1 -1
- data/lib/netsuite/records/cash_sale.rb +1 -2
- data/lib/netsuite/records/contact.rb +0 -1
- data/lib/netsuite/records/credit_memo.rb +1 -1
- data/lib/netsuite/records/currency_rate.rb +0 -1
- data/lib/netsuite/records/custom_record.rb +1 -1
- data/lib/netsuite/records/customer.rb +0 -1
- data/lib/netsuite/records/customer_deposit.rb +0 -1
- data/lib/netsuite/records/customer_payment.rb +0 -1
- data/lib/netsuite/records/customer_refund.rb +0 -1
- data/lib/netsuite/records/deposit.rb +0 -1
- data/lib/netsuite/records/deposit_application.rb +0 -1
- data/lib/netsuite/records/description_item.rb +3 -3
- data/lib/netsuite/records/discount_item.rb +1 -1
- data/lib/netsuite/records/employee.rb +1 -1
- data/lib/netsuite/records/estimate.rb +95 -15
- data/lib/netsuite/records/inbound_shipment.rb +0 -1
- data/lib/netsuite/records/inventory_item.rb +237 -38
- data/lib/netsuite/records/inventory_number.rb +1 -2
- data/lib/netsuite/records/inventory_transfer.rb +1 -0
- data/lib/netsuite/records/invoice.rb +2 -2
- data/lib/netsuite/records/item_fulfillment.rb +0 -1
- data/lib/netsuite/records/item_group.rb +3 -3
- data/lib/netsuite/records/item_option_custom_field.rb +52 -0
- data/lib/netsuite/records/item_receipt.rb +0 -1
- data/lib/netsuite/records/item_receipt_item.rb +2 -1
- data/lib/netsuite/records/item_vendor.rb +10 -1
- data/lib/netsuite/records/job.rb +0 -1
- data/lib/netsuite/records/kit_item.rb +2 -2
- data/lib/netsuite/records/location.rb +0 -1
- data/lib/netsuite/records/lot_numbered_assembly_item.rb +1 -1
- data/lib/netsuite/records/lot_numbered_inventory_item.rb +226 -82
- data/lib/netsuite/records/matrix_option_list.rb +16 -0
- data/lib/netsuite/records/non_inventory_purchase_item.rb +1 -1
- data/lib/netsuite/records/non_inventory_resale_item.rb +157 -21
- data/lib/netsuite/records/non_inventory_sale_item.rb +134 -22
- data/lib/netsuite/records/null_field_list.rb +15 -0
- data/lib/netsuite/records/opportunity.rb +0 -1
- data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
- data/lib/netsuite/records/payment_item.rb +3 -3
- data/lib/netsuite/records/payroll_item.rb +0 -1
- data/lib/netsuite/records/purchase_order.rb +0 -1
- data/lib/netsuite/records/record_ref.rb +1 -1
- data/lib/netsuite/records/return_authorization.rb +1 -0
- data/lib/netsuite/records/sales_order.rb +1 -2
- data/lib/netsuite/records/serialized_assembly_item.rb +1 -1
- data/lib/netsuite/records/serialized_inventory_item.rb +2 -2
- data/lib/netsuite/records/serialized_inventory_item_location.rb +0 -1
- data/lib/netsuite/records/service_resale_item.rb +125 -21
- data/lib/netsuite/records/service_sale_item.rb +1 -2
- data/lib/netsuite/records/subsidiary.rb +0 -1
- data/lib/netsuite/records/subtotal_item.rb +3 -4
- data/lib/netsuite/records/transfer_order.rb +0 -1
- data/lib/netsuite/records/translation.rb +17 -0
- data/lib/netsuite/records/translation_list.rb +11 -0
- data/lib/netsuite/records/vendor.rb +0 -1
- data/lib/netsuite/records/vendor_bill.rb +0 -1
- data/lib/netsuite/records/work_order.rb +0 -1
- data/lib/netsuite/records/work_order_item.rb +0 -1
- data/lib/netsuite/support/actions.rb +2 -0
- data/lib/netsuite/support/fields.rb +2 -0
- data/lib/netsuite/support/records.rb +22 -5
- data/lib/netsuite/support/sublist.rb +1 -1
- data/lib/netsuite/utilities/strings.rb +15 -0
- data/lib/netsuite/utilities.rb +5 -0
- data/lib/netsuite/version.rb +1 -1
- data/lib/netsuite.rb +6 -1
- data/netsuite.gemspec +4 -3
- data/spec/netsuite/actions/add_spec.rb +36 -0
- data/spec/netsuite/actions/attach_file_spec.rb +59 -0
- data/spec/netsuite/actions/search_spec.rb +205 -0
- data/spec/netsuite/records/cash_refund_item_spec.rb +1 -1
- data/spec/netsuite/records/credit_memo_spec.rb +14 -0
- data/spec/netsuite/records/estimate_spec.rb +103 -13
- data/spec/netsuite/records/inventory_item_spec.rb +239 -22
- data/spec/netsuite/records/invoice_spec.rb +43 -0
- data/spec/netsuite/records/item_option_custom_field_spec.rb +27 -0
- data/spec/netsuite/records/item_vendor_list_spec.rb +2 -5
- data/spec/netsuite/records/item_vendor_spec.rb +14 -2
- data/spec/netsuite/records/lot_numbered_inventory_item_spec.rb +247 -0
- data/spec/netsuite/records/matrix_option_list_spec.rb +26 -0
- data/spec/netsuite/records/non_inventory_resale_item_spec.rb +159 -24
- data/spec/netsuite/records/non_inventory_sale_item_spec.rb +135 -22
- data/spec/netsuite/records/null_field_list_spec.rb +30 -0
- data/spec/netsuite/records/return_authorization_spec.rb +62 -0
- data/spec/netsuite/records/sales_order_spec.rb +29 -0
- data/spec/netsuite/records/service_resale_item_spec.rb +122 -17
- data/spec/netsuite/records/translation_list_spec.rb +34 -0
- data/spec/netsuite/records/translation_spec.rb +28 -0
- data/spec/netsuite/support/fields_spec.rb +16 -4
- data/spec/netsuite/support/records_spec.rb +33 -7
- data/spec/netsuite/support/search_result_spec.rb +12 -0
- data/spec/netsuite/utilities_spec.rb +10 -2
- data/spec/support/field_matcher.rb +8 -6
- data/spec/support/fixtures/add/add_file.xml +20 -0
- data/spec/support/fixtures/attach/attach_file_to_sales_order.xml +16 -0
- data/spec/support/fixtures/attach/attach_file_to_sales_order_error.xml +20 -0
- data/spec/support/fixtures/search/basic_search_contact.xml +39 -0
- data/spec/support/fixtures/search/single_search_result.xml +46 -0
- metadata +43 -16
- data/lib/netsuite/core_ext/string/lower_camelcase.rb +0 -9
@@ -6,8 +6,8 @@ module NetSuite
|
|
6
6
|
|
7
7
|
def to_record
|
8
8
|
attributes.reject { |k,v| self.class.read_only_fields.include?(k) || self.class.search_only_fields.include?(k) }.inject({}) do |hash, (k,v)|
|
9
|
-
kname = "#{record_namespace}:"
|
10
|
-
kname += k == :klass ? 'class' : k.to_s
|
9
|
+
kname = "#{v.is_a?(NetSuite::Records::NullFieldList) ? v.record_namespace : record_namespace}:"
|
10
|
+
kname += k == :klass ? 'class' : NetSuite::Utilities::Strings.lower_camelcase(k.to_s)
|
11
11
|
|
12
12
|
to_attributes!(hash, kname, v)
|
13
13
|
|
@@ -38,18 +38,26 @@ module NetSuite
|
|
38
38
|
if v.kind_of?(NetSuite::Records::RecordRef) && v.type
|
39
39
|
hash[:attributes!] ||= {}
|
40
40
|
hash[:attributes!][kname] ||= {}
|
41
|
-
hash[:attributes!][kname]['type'] = v.type
|
41
|
+
hash[:attributes!][kname]['type'] = NetSuite::Utilities::Strings.lower_camelcase(v.type)
|
42
42
|
end
|
43
43
|
|
44
44
|
if v.kind_of?(NetSuite::Records::CustomRecordRef) && v.type_id
|
45
45
|
hash[:attributes!] ||= {}
|
46
46
|
hash[:attributes!][kname] ||= {}
|
47
|
-
hash[:attributes!][kname]['typeId'] = v.type_id
|
47
|
+
hash[:attributes!][kname]['typeId'] = NetSuite::Utilities::Strings.lower_camelcase(v.type_id)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
def record_type
|
52
|
-
"#{record_namespace}:#{
|
52
|
+
"#{record_namespace}:#{record_type_without_namespace}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def netsuite_type
|
56
|
+
Records.netsuite_type(self)
|
57
|
+
end
|
58
|
+
|
59
|
+
def record_type_without_namespace
|
60
|
+
Records.record_type_without_namespace(self)
|
53
61
|
end
|
54
62
|
|
55
63
|
def refresh(credentials = {})
|
@@ -67,6 +75,15 @@ module NetSuite
|
|
67
75
|
self
|
68
76
|
end
|
69
77
|
|
78
|
+
def self.netsuite_type(obj)
|
79
|
+
NetSuite::Utilities::Strings.lower_camelcase(record_type_without_namespace(obj))
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.record_type_without_namespace(obj)
|
83
|
+
klass = obj.is_a?(Class) ? obj : obj.class
|
84
|
+
"#{klass.to_s.split('::').last}"
|
85
|
+
end
|
86
|
+
|
70
87
|
end
|
71
88
|
end
|
72
89
|
end
|
@@ -35,7 +35,7 @@ module NetSuite
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def to_record
|
38
|
-
rec = { "#{record_namespace}:#{sublist_key.to_s
|
38
|
+
rec = { "#{record_namespace}:#{NetSuite::Utilities::Strings.lower_camelcase(sublist_key.to_s)}" => send(self.sublist_key).map(&:to_record) }
|
39
39
|
|
40
40
|
if !replace_all.nil?
|
41
41
|
rec["#{record_namespace}:replaceAll"] = !!replace_all
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Utilities
|
3
|
+
module Strings
|
4
|
+
class << self
|
5
|
+
def lower_camelcase(obj)
|
6
|
+
str = obj.is_a?(String) ? obj.dup : obj.to_s
|
7
|
+
str.gsub!(/\/(.?)/) { "::#{$1.upcase}" }
|
8
|
+
str.gsub!(/(?:_+|-+)([a-z]|[0-9])/) { $1.upcase }
|
9
|
+
str.gsub!(/(\A|\s)([A-Z])/) { $1 + $2.downcase }
|
10
|
+
str
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/netsuite/utilities.rb
CHANGED
@@ -103,6 +103,10 @@ module NetSuite
|
|
103
103
|
exceptions_to_retry << OpenSSL::SSL::SSLErrorWaitReadable if defined?(OpenSSL::SSL::SSLErrorWaitReadable)
|
104
104
|
|
105
105
|
# depends on the http library chosen
|
106
|
+
exceptions_to_retry << HTTPClient::TimeoutError if defined?(HTTPClient::TimeoutError)
|
107
|
+
exceptions_to_retry << HTTPClient::ConnectTimeoutError if defined?(HTTPClient::ConnectTimeoutError)
|
108
|
+
exceptions_to_retry << HTTPClient::ReceiveTimeoutError if defined?(HTTPClient::ReceiveTimeoutError)
|
109
|
+
exceptions_to_retry << HTTPClient::SendTimeoutError if defined?(HTTPClient::SendTimeoutError)
|
106
110
|
exceptions_to_retry << Excon::Error::Timeout if defined?(Excon::Error::Timeout)
|
107
111
|
exceptions_to_retry << Excon::Error::Socket if defined?(Excon::Error::Socket)
|
108
112
|
|
@@ -170,6 +174,7 @@ module NetSuite
|
|
170
174
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::DiscountItem, ns_item_internal_id, opts)
|
171
175
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::OtherChargeSaleItem, ns_item_internal_id, opts)
|
172
176
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ServiceSaleItem, ns_item_internal_id, opts)
|
177
|
+
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ServiceResaleItem, ns_item_internal_id, opts)
|
173
178
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::GiftCertificateItem, ns_item_internal_id, opts)
|
174
179
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::KitItem, ns_item_internal_id, opts)
|
175
180
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedInventoryItem, ns_item_internal_id, opts)
|
data/lib/netsuite/version.rb
CHANGED
data/lib/netsuite.rb
CHANGED
@@ -5,9 +5,9 @@ require 'netsuite/version'
|
|
5
5
|
require 'netsuite/errors'
|
6
6
|
require 'netsuite/utilities'
|
7
7
|
require 'netsuite/utilities/data_center'
|
8
|
+
require 'netsuite/utilities/strings'
|
8
9
|
require 'netsuite/rest/utilities/roles'
|
9
10
|
require 'netsuite/rest/utilities/request'
|
10
|
-
require 'netsuite/core_ext/string/lower_camelcase'
|
11
11
|
|
12
12
|
module NetSuite
|
13
13
|
autoload :Configuration, 'netsuite/configuration'
|
@@ -49,6 +49,7 @@ module NetSuite
|
|
49
49
|
|
50
50
|
module Actions
|
51
51
|
autoload :Add, 'netsuite/actions/add'
|
52
|
+
autoload :AttachFile, 'netsuite/actions/attach_file'
|
52
53
|
autoload :Delete, 'netsuite/actions/delete'
|
53
54
|
autoload :DeleteList, 'netsuite/actions/delete_list'
|
54
55
|
autoload :Get, 'netsuite/actions/get'
|
@@ -200,6 +201,7 @@ module NetSuite
|
|
200
201
|
autoload :ItemGroup, 'netsuite/records/item_group'
|
201
202
|
autoload :ItemMember, 'netsuite/records/item_member'
|
202
203
|
autoload :ItemMemberList, 'netsuite/records/item_member_list'
|
204
|
+
autoload :ItemOptionCustomField, 'netsuite/records/item_option_custom_field'
|
203
205
|
autoload :ItemReceipt, 'netsuite/records/item_receipt'
|
204
206
|
autoload :ItemReceiptItemList, 'netsuite/records/item_receipt_item_list'
|
205
207
|
autoload :ItemReceiptItem, 'netsuite/records/item_receipt_item'
|
@@ -223,6 +225,7 @@ module NetSuite
|
|
223
225
|
autoload :NonInventoryResaleItem, 'netsuite/records/non_inventory_resale_item'
|
224
226
|
autoload :Note, 'netsuite/records/note'
|
225
227
|
autoload :NoteType, 'netsuite/records/note_type'
|
228
|
+
autoload :NullFieldList, 'netsuite/records/null_field_list'
|
226
229
|
autoload :Opportunity, 'netsuite/records/opportunity'
|
227
230
|
autoload :OpportunityItem, 'netsuite/records/opportunity_item'
|
228
231
|
autoload :OpportunityItemList, 'netsuite/records/opportunity_item_list'
|
@@ -283,6 +286,8 @@ module NetSuite
|
|
283
286
|
autoload :TransferOrder, 'netsuite/records/transfer_order'
|
284
287
|
autoload :TransferOrderItemList, 'netsuite/records/transfer_order_item_list'
|
285
288
|
autoload :TransferOrderItem, 'netsuite/records/transfer_order_item'
|
289
|
+
autoload :Translation, 'netsuite/records/translation'
|
290
|
+
autoload :TranslationList, 'netsuite/records/translation_list'
|
286
291
|
autoload :UnitsType, 'netsuite/records/units_type'
|
287
292
|
autoload :UnitsTypeUomList, 'netsuite/records/units_type_uom_list'
|
288
293
|
autoload :UnitsTypeUom, 'netsuite/records/units_type_uom'
|
data/netsuite.gemspec
CHANGED
@@ -15,9 +15,10 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.name = 'netsuite'
|
16
16
|
gem.require_paths = ['lib']
|
17
17
|
gem.version = NetSuite::VERSION
|
18
|
+
gem.metadata['changelog_uri'] = 'https://github.com/netsweet/netsuite/blob/master/HISTORY.md'
|
18
19
|
|
19
|
-
gem.add_dependency 'savon', '>= 2.3.0'
|
20
|
+
gem.add_dependency 'savon', '>= 2.3.0'
|
20
21
|
|
21
|
-
gem.add_development_dependency 'rspec', '~> 3.
|
22
|
-
gem.add_development_dependency 'rake'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3.11.0'
|
23
|
+
gem.add_development_dependency 'rake', '~> 12.3.3'
|
23
24
|
end
|
@@ -114,4 +114,40 @@ describe NetSuite::Actions::Add do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
context 'File' do
|
118
|
+
let(:file) do
|
119
|
+
NetSuite::Records::File.new(name: 'foo.pdf', content: 'abc123')
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'when successful' do
|
123
|
+
before do
|
124
|
+
savon.expects(:add).with(:message => {
|
125
|
+
'platformMsgs:record' => {
|
126
|
+
:content! => {
|
127
|
+
'fileCabinet:name' => 'foo.pdf',
|
128
|
+
'fileCabinet:content' => 'abc123',
|
129
|
+
},
|
130
|
+
'@xsi:type' => 'fileCabinet:File'
|
131
|
+
},
|
132
|
+
}).returns(File.read('spec/support/fixtures/add/add_file.xml'))
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'makes a valid request to the NetSuite API' do
|
136
|
+
NetSuite::Actions::Add.call([file])
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'returns a valid Response object' do
|
140
|
+
response = NetSuite::Actions::Add.call([file])
|
141
|
+
expect(response).to be_kind_of(NetSuite::Response)
|
142
|
+
expect(response).to be_success
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'properly extracts internal ID from response' do
|
146
|
+
file.add
|
147
|
+
|
148
|
+
expect(file.internal_id).to eq('23556')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
117
153
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Actions::AttachFile do
|
4
|
+
before(:all) { savon.mock! }
|
5
|
+
after(:all) { savon.unmock! }
|
6
|
+
|
7
|
+
let(:sales_order) { NetSuite::Records::SalesOrder.new(internal_id: 999) }
|
8
|
+
let(:file) { double('file', internal_id: 111) }
|
9
|
+
let(:message) do
|
10
|
+
{
|
11
|
+
'platformCore:attachReference' => {
|
12
|
+
'@xsi:type' => 'platformCore:AttachBasicReference',
|
13
|
+
'platformCore:attachTo' => {
|
14
|
+
'@internalId' => sales_order.internal_id,
|
15
|
+
'@type' => 'salesOrder',
|
16
|
+
'@xsi:type' => 'platformCore:RecordRef'
|
17
|
+
},
|
18
|
+
'platformCore:attachedRecord' => {
|
19
|
+
'@internalId' => file.internal_id,
|
20
|
+
'@type' => 'file',
|
21
|
+
'@xsi:type' => 'platformCore:RecordRef'
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
before do
|
28
|
+
savon.expects(:attach).with(:message => message).returns(envelope)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when successful' do
|
32
|
+
let(:envelope) { File.read('spec/support/fixtures/attach/attach_file_to_sales_order.xml') }
|
33
|
+
|
34
|
+
it 'returns a valid Response object' do
|
35
|
+
response = NetSuite::Actions::AttachFile.call([sales_order, file])
|
36
|
+
expect(response).to be_kind_of(NetSuite::Response)
|
37
|
+
expect(response).to be_success
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when not successful' do
|
42
|
+
let(:envelope) { File.read('spec/support/fixtures/attach/attach_file_to_sales_order_error.xml') }
|
43
|
+
|
44
|
+
it 'provides an error method on the object with details about the error' do
|
45
|
+
sales_order.attach_file(file)
|
46
|
+
error = sales_order.errors.first
|
47
|
+
|
48
|
+
expect(error).to be_kind_of(NetSuite::Error)
|
49
|
+
expect(error.type).to eq('ERROR')
|
50
|
+
expect(error.code).to eq('INVALID')
|
51
|
+
expect(error.message).to eq('Invalid request.')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'provides an error method on the response' do
|
55
|
+
response = NetSuite::Actions::AttachFile.call([sales_order, file])
|
56
|
+
expect(response.errors.first).to be_kind_of(NetSuite::Error)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -193,6 +193,30 @@ describe NetSuite::Actions::Search do
|
|
193
193
|
expect(search.results.first.location_re_order_point).to eq('2565.0')
|
194
194
|
expect(search.results.first.location_quantity_on_order).to eq('40000.0')
|
195
195
|
end
|
196
|
+
|
197
|
+
it "should handle an ID search with basic non-field result columns" do
|
198
|
+
response = File.read('spec/support/fixtures/search/saved_search_item_2.xml')
|
199
|
+
savon.expects(:search)
|
200
|
+
.with(message: {
|
201
|
+
"searchRecord"=>{
|
202
|
+
"@xsi:type" =>"listAcct:ItemSearchAdvanced",
|
203
|
+
"@savedSearchId" =>42,
|
204
|
+
:content! =>{"listAcct:criteria"=>{}},
|
205
|
+
}
|
206
|
+
}).returns(response)
|
207
|
+
|
208
|
+
search = NetSuite::Records::InventoryItem.search(saved: 42)
|
209
|
+
|
210
|
+
results = search.results
|
211
|
+
custom_fields = results.map do |record|
|
212
|
+
record.custom_field_list.custom_fields.map(&:internal_id)
|
213
|
+
end.flatten.uniq
|
214
|
+
[
|
215
|
+
:location_quantity_available,
|
216
|
+
:location_re_order_point,
|
217
|
+
:location_quantity_on_order,
|
218
|
+
].each {|field| expect(custom_fields).to include(field)}
|
219
|
+
end
|
196
220
|
end
|
197
221
|
|
198
222
|
context "advanced search" do
|
@@ -201,6 +225,187 @@ describe NetSuite::Actions::Search do
|
|
201
225
|
end
|
202
226
|
|
203
227
|
context "basic search" do
|
228
|
+
it "should handle a basic search matching on RecordRef using internalId" do
|
229
|
+
response = File.read('spec/support/fixtures/search/basic_search_contact.xml')
|
230
|
+
savon.expects(:search)
|
231
|
+
.with(message: {
|
232
|
+
"searchRecord" => {
|
233
|
+
:content! => {
|
234
|
+
"listRel:basic" => {
|
235
|
+
"platformCommon:company" => {
|
236
|
+
"@operator" => "anyOf",
|
237
|
+
"@xsi:type" => "platformCore:SearchMultiSelectField",
|
238
|
+
"platformCore:searchValue" => [
|
239
|
+
{
|
240
|
+
:content! => {},
|
241
|
+
"@xsi:type" => "platformCore:RecordRef",
|
242
|
+
"@type" => "account",
|
243
|
+
"@internalId" => 7497,
|
244
|
+
},
|
245
|
+
{
|
246
|
+
:content! => {},
|
247
|
+
"@xsi:type" => "platformCore:RecordRef",
|
248
|
+
"@type" => "account",
|
249
|
+
"@internalId" => 7270,
|
250
|
+
},
|
251
|
+
],
|
252
|
+
},
|
253
|
+
},
|
254
|
+
},
|
255
|
+
"@xsi:type" => "listRel:ContactSearch",
|
256
|
+
},
|
257
|
+
}).returns(response)
|
258
|
+
|
259
|
+
search = NetSuite::Records::Contact.search(
|
260
|
+
basic: [{
|
261
|
+
field: 'company',
|
262
|
+
operator: 'anyOf',
|
263
|
+
value: [
|
264
|
+
NetSuite::Records::RecordRef.new(internal_id: 7497),
|
265
|
+
NetSuite::Records::RecordRef.new(internal_id: 7270),
|
266
|
+
],
|
267
|
+
}],
|
268
|
+
)
|
269
|
+
|
270
|
+
expect(search.results.size).to eq(1)
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should handle a basic search matching on RecordRef using externalId" do
|
274
|
+
response = File.read('spec/support/fixtures/search/basic_search_contact.xml')
|
275
|
+
savon.expects(:search)
|
276
|
+
.with(message: {
|
277
|
+
"searchRecord" => {
|
278
|
+
:content! => {
|
279
|
+
"listRel:basic" => {
|
280
|
+
"platformCommon:company" => {
|
281
|
+
"@operator" => "anyOf",
|
282
|
+
"@xsi:type" => "platformCore:SearchMultiSelectField",
|
283
|
+
"platformCore:searchValue" => [
|
284
|
+
{
|
285
|
+
:content! => {},
|
286
|
+
"@xsi:type" => "platformCore:RecordRef",
|
287
|
+
"@type" => "account",
|
288
|
+
"@externalId" => "external_abc",
|
289
|
+
},
|
290
|
+
{
|
291
|
+
:content! => {},
|
292
|
+
"@xsi:type" => "platformCore:RecordRef",
|
293
|
+
"@type" => "account",
|
294
|
+
"@externalId" => "external_xyz",
|
295
|
+
},
|
296
|
+
],
|
297
|
+
},
|
298
|
+
},
|
299
|
+
},
|
300
|
+
"@xsi:type" => "listRel:ContactSearch",
|
301
|
+
},
|
302
|
+
}).returns(response)
|
303
|
+
|
304
|
+
search = NetSuite::Records::Contact.search(
|
305
|
+
basic: [{
|
306
|
+
field: 'company',
|
307
|
+
operator: 'anyOf',
|
308
|
+
value: [
|
309
|
+
NetSuite::Records::RecordRef.new(external_id: "external_abc"),
|
310
|
+
NetSuite::Records::RecordRef.new(external_id: "external_xyz"),
|
311
|
+
],
|
312
|
+
}],
|
313
|
+
)
|
314
|
+
|
315
|
+
expect(search.results.size).to eq(1)
|
316
|
+
end
|
317
|
+
|
318
|
+
it "should handle a basic search matching on RecordRef using mix of internalId and externalId" do
|
319
|
+
response = File.read('spec/support/fixtures/search/basic_search_contact.xml')
|
320
|
+
savon.expects(:search)
|
321
|
+
.with(message: {
|
322
|
+
"searchRecord" => {
|
323
|
+
:content! => {
|
324
|
+
"listRel:basic" => {
|
325
|
+
"platformCommon:company" => {
|
326
|
+
"@operator" => "anyOf",
|
327
|
+
"@xsi:type" => "platformCore:SearchMultiSelectField",
|
328
|
+
"platformCore:searchValue" => [
|
329
|
+
{
|
330
|
+
:content! => {},
|
331
|
+
"@xsi:type" => "platformCore:RecordRef",
|
332
|
+
"@type" => "account",
|
333
|
+
"@internalId" => 7497,
|
334
|
+
},
|
335
|
+
{
|
336
|
+
:content! => {},
|
337
|
+
"@xsi:type" => "platformCore:RecordRef",
|
338
|
+
"@type" => "account",
|
339
|
+
"@externalId" => "external_xyz",
|
340
|
+
},
|
341
|
+
],
|
342
|
+
},
|
343
|
+
},
|
344
|
+
},
|
345
|
+
"@xsi:type" => "listRel:ContactSearch",
|
346
|
+
},
|
347
|
+
}).returns(response)
|
348
|
+
|
349
|
+
search = NetSuite::Records::Contact.search(
|
350
|
+
basic: [{
|
351
|
+
field: 'company',
|
352
|
+
operator: 'anyOf',
|
353
|
+
value: [
|
354
|
+
NetSuite::Records::RecordRef.new(internal_id: 7497),
|
355
|
+
NetSuite::Records::RecordRef.new(external_id: "external_xyz"),
|
356
|
+
],
|
357
|
+
}],
|
358
|
+
)
|
359
|
+
|
360
|
+
expect(search.results.size).to eq(1)
|
361
|
+
end
|
362
|
+
|
363
|
+
it "should handle a basic search matching on RecordRef using both internalId and externalId" do
|
364
|
+
response = File.read('spec/support/fixtures/search/basic_search_contact.xml')
|
365
|
+
savon.expects(:search)
|
366
|
+
.with(message: {
|
367
|
+
"searchRecord" => {
|
368
|
+
:content! => {
|
369
|
+
"listRel:basic" => {
|
370
|
+
"platformCommon:company" => {
|
371
|
+
"@operator" => "anyOf",
|
372
|
+
"@xsi:type" => "platformCore:SearchMultiSelectField",
|
373
|
+
"platformCore:searchValue" => [
|
374
|
+
{
|
375
|
+
:content! => {},
|
376
|
+
"@xsi:type" => "platformCore:RecordRef",
|
377
|
+
"@type" => "account",
|
378
|
+
"@internalId" => 7497,
|
379
|
+
"@externalId" => "external_abc",
|
380
|
+
},
|
381
|
+
{
|
382
|
+
:content! => {},
|
383
|
+
"@xsi:type" => "platformCore:RecordRef",
|
384
|
+
"@type" => "account",
|
385
|
+
"@externalId" => 7270,
|
386
|
+
},
|
387
|
+
],
|
388
|
+
},
|
389
|
+
},
|
390
|
+
},
|
391
|
+
"@xsi:type" => "listRel:ContactSearch",
|
392
|
+
},
|
393
|
+
}).returns(response)
|
394
|
+
|
395
|
+
search = NetSuite::Records::Contact.search(
|
396
|
+
basic: [{
|
397
|
+
field: 'company',
|
398
|
+
operator: 'anyOf',
|
399
|
+
value: [
|
400
|
+
NetSuite::Records::RecordRef.new(internal_id: 7497, external_id: "external_abc"),
|
401
|
+
NetSuite::Records::RecordRef.new(external_id: 7270),
|
402
|
+
],
|
403
|
+
}],
|
404
|
+
)
|
405
|
+
|
406
|
+
expect(search.results.size).to eq(1)
|
407
|
+
end
|
408
|
+
|
204
409
|
skip "should handle searching basic fields"
|
205
410
|
skip "should handle searching with joined fields"
|
206
411
|
end
|
@@ -20,6 +20,20 @@ describe NetSuite::Records::CreditMemo do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
it 'has all the right fields with specific classes' do
|
24
|
+
{
|
25
|
+
custom_field_list: NetSuite::Records::CustomFieldList,
|
26
|
+
item_list: NetSuite::Records::CreditMemoItemList,
|
27
|
+
apply_list: NetSuite::Records::CreditMemoApplyList,
|
28
|
+
ship_group_list: NetSuite::Records::SalesOrderShipGroupList,
|
29
|
+
null_field_list: NetSuite::Records::NullFieldList,
|
30
|
+
transaction_bill_address: NetSuite::Records::BillAddress,
|
31
|
+
billing_address: NetSuite::Records::Address,
|
32
|
+
}.each do |field, klass|
|
33
|
+
expect(memo).to have_field(field, klass)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
23
37
|
it 'has all the right record refs' do
|
24
38
|
[
|
25
39
|
:account, :bill_address_list, :created_from, :custom_form, :department, :discount_item, :entity, :gift_cert,
|
@@ -7,27 +7,117 @@ describe NetSuite::Records::Estimate do
|
|
7
7
|
|
8
8
|
it 'has all the right fields' do
|
9
9
|
[
|
10
|
-
:alt_handling_cost,
|
11
|
-
:
|
12
|
-
:
|
10
|
+
:alt_handling_cost,
|
11
|
+
:alt_sales_total,
|
12
|
+
:alt_shipping_cost,
|
13
|
+
:can_have_stackable,
|
14
|
+
:contrib_pct,
|
15
|
+
:created_date,
|
16
|
+
:currency_name,
|
17
|
+
:discount_rate,
|
18
|
+
:discount_total,
|
19
|
+
:due_date,
|
20
|
+
:email,
|
21
|
+
:end_date,
|
22
|
+
:est_gross_profit,
|
23
|
+
:est_gross_profit_percent,
|
13
24
|
:exchange_rate,
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
25
|
+
:expected_close_date,
|
26
|
+
:fax,
|
27
|
+
:fob,
|
28
|
+
:handling_cost,
|
29
|
+
:handling_tax1_rate,
|
30
|
+
:handling_tax2_rate,
|
31
|
+
:include_in_forecast,
|
32
|
+
:is_taxable,
|
33
|
+
:last_modified_date,
|
34
|
+
:linked_tracking_numbers,
|
35
|
+
:memo,
|
36
|
+
:message,
|
37
|
+
:one_time,
|
38
|
+
:other_ref_num,
|
39
|
+
:probability,
|
40
|
+
:recur_annually,
|
41
|
+
:recur_monthly,
|
42
|
+
:recur_quarterly,
|
43
|
+
:recur_weekly,
|
44
|
+
:ship_date,
|
45
|
+
:ship_is_residential,
|
46
|
+
:shipping_cost,
|
47
|
+
:shipping_tax1_rate,
|
48
|
+
:shipping_tax2_rate,
|
49
|
+
:source,
|
50
|
+
:start_date,
|
51
|
+
:status,
|
52
|
+
:sub_total,
|
53
|
+
:sync_partner_teams,
|
54
|
+
:sync_sales_teams,
|
55
|
+
:tax2_total,
|
56
|
+
:tax_details_override,
|
57
|
+
:tax_point_date,
|
58
|
+
:tax_rate,
|
59
|
+
:tax_reg_override,
|
60
|
+
:tax_total,
|
61
|
+
:title,
|
62
|
+
:to_be_emailed,
|
63
|
+
:to_be_faxed,
|
64
|
+
:to_be_printed,
|
65
|
+
:total,
|
66
|
+
:total_cost_estimate,
|
67
|
+
:tracking_numbers,
|
68
|
+
:tran_date,
|
69
|
+
:tran_id,
|
70
|
+
:vat_reg_num,
|
71
|
+
:visible_to_customer,
|
20
72
|
].each do |field|
|
21
73
|
expect(estimate).to have_field(field)
|
22
74
|
end
|
23
75
|
end
|
24
76
|
|
77
|
+
it 'has all the right fields with specific classes' do
|
78
|
+
{
|
79
|
+
billing_address: NetSuite::Records::Address,
|
80
|
+
custom_field_list: NetSuite::Records::CustomFieldList,
|
81
|
+
item_list: NetSuite::Records::EstimateItemList,
|
82
|
+
promotions_list: NetSuite::Records::PromotionsList,
|
83
|
+
shipping_address: NetSuite::Records::Address,
|
84
|
+
}.each do |field, klass|
|
85
|
+
expect(estimate).to have_field(field, klass)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
25
89
|
it 'has all the right record refs' do
|
26
90
|
[
|
27
|
-
:bill_address_list,
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
91
|
+
:bill_address_list,
|
92
|
+
:billing_schedule,
|
93
|
+
:klass,
|
94
|
+
:created_from,
|
95
|
+
:currency,
|
96
|
+
:custom_form,
|
97
|
+
:department,
|
98
|
+
:discount_item,
|
99
|
+
:entity,
|
100
|
+
:entity_status,
|
101
|
+
:entity_tax_reg_num,
|
102
|
+
:forecast_type,
|
103
|
+
:handling_tax_code,
|
104
|
+
:job,
|
105
|
+
:lead_source,
|
106
|
+
:location,
|
107
|
+
:message_sel,
|
108
|
+
:nexus,
|
109
|
+
:opportunity,
|
110
|
+
:partner,
|
111
|
+
:promo_code,
|
112
|
+
:sales_group,
|
113
|
+
:sales_rep,
|
114
|
+
:ship_address_list,
|
115
|
+
:ship_method,
|
116
|
+
:shipping_tax_code,
|
117
|
+
:subsidiary,
|
118
|
+
:subsidiary_tax_reg_num,
|
119
|
+
:tax_item,
|
120
|
+
:terms,
|
31
121
|
].each do |record_ref|
|
32
122
|
expect(estimate).to have_record_ref(record_ref)
|
33
123
|
end
|