netsuite 0.8.10 → 0.8.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/dependabot.yml +14 -0
  4. data/.github/workflows/codeql-analysis.yml +70 -0
  5. data/.github/workflows/main.yml +7 -4
  6. data/Gemfile +5 -3
  7. data/HISTORY.md +27 -2
  8. data/README.md +13 -18
  9. data/lib/netsuite/actions/add.rb +5 -1
  10. data/lib/netsuite/actions/attach_file.rb +87 -0
  11. data/lib/netsuite/actions/search.rb +19 -6
  12. data/lib/netsuite/records/account.rb +0 -1
  13. data/lib/netsuite/records/accounting_period.rb +1 -1
  14. data/lib/netsuite/records/assembly_component.rb +0 -2
  15. data/lib/netsuite/records/assembly_item.rb +0 -1
  16. data/lib/netsuite/records/assembly_unbuild.rb +0 -1
  17. data/lib/netsuite/records/cash_refund.rb +0 -1
  18. data/lib/netsuite/records/cash_sale.rb +1 -2
  19. data/lib/netsuite/records/contact.rb +0 -1
  20. data/lib/netsuite/records/credit_memo.rb +0 -1
  21. data/lib/netsuite/records/currency_rate.rb +0 -1
  22. data/lib/netsuite/records/custom_record.rb +1 -1
  23. data/lib/netsuite/records/customer.rb +0 -1
  24. data/lib/netsuite/records/customer_deposit.rb +0 -1
  25. data/lib/netsuite/records/customer_payment.rb +0 -1
  26. data/lib/netsuite/records/customer_refund.rb +0 -1
  27. data/lib/netsuite/records/deposit.rb +0 -1
  28. data/lib/netsuite/records/deposit_application.rb +0 -1
  29. data/lib/netsuite/records/description_item.rb +1 -1
  30. data/lib/netsuite/records/estimate.rb +0 -1
  31. data/lib/netsuite/records/inbound_shipment.rb +0 -1
  32. data/lib/netsuite/records/inventory_item.rb +236 -37
  33. data/lib/netsuite/records/inventory_number.rb +0 -1
  34. data/lib/netsuite/records/invoice.rb +1 -2
  35. data/lib/netsuite/records/item_fulfillment.rb +0 -1
  36. data/lib/netsuite/records/item_group.rb +1 -1
  37. data/lib/netsuite/records/item_option_custom_field.rb +52 -0
  38. data/lib/netsuite/records/item_receipt.rb +0 -1
  39. data/lib/netsuite/records/item_vendor.rb +10 -1
  40. data/lib/netsuite/records/job.rb +0 -1
  41. data/lib/netsuite/records/kit_item.rb +1 -1
  42. data/lib/netsuite/records/location.rb +0 -1
  43. data/lib/netsuite/records/lot_numbered_inventory_item.rb +225 -81
  44. data/lib/netsuite/records/matrix_option_list.rb +16 -0
  45. data/lib/netsuite/records/non_inventory_resale_item.rb +156 -20
  46. data/lib/netsuite/records/non_inventory_sale_item.rb +133 -21
  47. data/lib/netsuite/records/opportunity.rb +0 -1
  48. data/lib/netsuite/records/other_charge_sale_item.rb +1 -1
  49. data/lib/netsuite/records/payment_item.rb +1 -1
  50. data/lib/netsuite/records/payroll_item.rb +0 -1
  51. data/lib/netsuite/records/purchase_order.rb +0 -1
  52. data/lib/netsuite/records/return_authorization.rb +1 -0
  53. data/lib/netsuite/records/sales_order.rb +1 -2
  54. data/lib/netsuite/records/serialized_inventory_item.rb +1 -1
  55. data/lib/netsuite/records/serialized_inventory_item_location.rb +0 -1
  56. data/lib/netsuite/records/service_resale_item.rb +123 -19
  57. data/lib/netsuite/records/service_sale_item.rb +0 -1
  58. data/lib/netsuite/records/subsidiary.rb +0 -1
  59. data/lib/netsuite/records/subtotal_item.rb +1 -1
  60. data/lib/netsuite/records/transfer_order.rb +0 -1
  61. data/lib/netsuite/records/translation.rb +17 -0
  62. data/lib/netsuite/records/translation_list.rb +11 -0
  63. data/lib/netsuite/records/vendor.rb +0 -1
  64. data/lib/netsuite/records/vendor_bill.rb +0 -1
  65. data/lib/netsuite/records/work_order.rb +0 -1
  66. data/lib/netsuite/records/work_order_item.rb +0 -1
  67. data/lib/netsuite/support/actions.rb +2 -0
  68. data/lib/netsuite/support/fields.rb +2 -0
  69. data/lib/netsuite/support/records.rb +9 -1
  70. data/lib/netsuite/utilities.rb +5 -0
  71. data/lib/netsuite/version.rb +1 -1
  72. data/lib/netsuite.rb +4 -0
  73. data/netsuite.gemspec +2 -2
  74. data/spec/netsuite/actions/add_spec.rb +36 -0
  75. data/spec/netsuite/actions/attach_file_spec.rb +59 -0
  76. data/spec/netsuite/actions/search_spec.rb +205 -0
  77. data/spec/netsuite/records/inventory_item_spec.rb +239 -22
  78. data/spec/netsuite/records/invoice_spec.rb +29 -0
  79. data/spec/netsuite/records/item_option_custom_field_spec.rb +27 -0
  80. data/spec/netsuite/records/item_vendor_list_spec.rb +2 -5
  81. data/spec/netsuite/records/item_vendor_spec.rb +14 -2
  82. data/spec/netsuite/records/lot_numbered_inventory_item_spec.rb +247 -0
  83. data/spec/netsuite/records/matrix_option_list_spec.rb +26 -0
  84. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +159 -24
  85. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +135 -22
  86. data/spec/netsuite/records/return_authorization_spec.rb +62 -0
  87. data/spec/netsuite/records/sales_order_spec.rb +29 -0
  88. data/spec/netsuite/records/service_resale_item_spec.rb +122 -17
  89. data/spec/netsuite/records/translation_list_spec.rb +34 -0
  90. data/spec/netsuite/records/translation_spec.rb +28 -0
  91. data/spec/netsuite/support/fields_spec.rb +16 -4
  92. data/spec/netsuite/support/search_result_spec.rb +12 -0
  93. data/spec/netsuite/utilities_spec.rb +10 -2
  94. data/spec/support/fixtures/add/add_file.xml +20 -0
  95. data/spec/support/fixtures/attach/attach_file_to_sales_order.xml +16 -0
  96. data/spec/support/fixtures/attach/attach_file_to_sales_order_error.xml +20 -0
  97. data/spec/support/fixtures/search/basic_search_contact.xml +39 -0
  98. data/spec/support/fixtures/search/single_search_result.xml +46 -0
  99. metadata +37 -8
@@ -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
@@ -5,27 +5,169 @@ describe NetSuite::Records::InventoryItem do
5
5
 
6
6
  it 'has all the right fields' do
7
7
  [
8
- :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, :average_cost, :copy_description,
9
- :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :cost_units, :costing_method, :costing_method_display,
10
- :country_of_manufacture, :created_date, :currency, :date_converted_to_inv, :default_return_cost, :demand_modifier,
11
- :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description, :fixed_lot_size,
12
- :handling_cost, :handling_cost_units, :include_children, :is_donation_item, :is_drop_ship_item, :is_gco_compliant,
13
- :is_inactive, :is_online, :is_special_order_item, :is_taxable, :item_id, :last_modified_date, :last_purchase_price,
14
- :lead_time, :manufacturer, :manufacturer_addr1, :manufacturer_city, :manufacturer_state, :manufacturer_tariff,
15
- :manufacturer_tax_id, :manufacturer_zip, :match_bill_to_receipt, :matrix_type, :max_donation_amount, :meta_tag_html,
16
- :minimum_quantity, :minimum_quantity_units, :mpn, :mult_manufacture_addr, :nex_tag_category, :no_price_message,
17
- :offer_support, :on_hand_value_mli, :on_special, :original_item_subtype, :original_item_type, :out_of_stock_behavior,
18
- :out_of_stock_message, :overall_quantity_pricing_type, :page_title, :preference_criterion, :preferred_stock_level,
19
- :preferred_stock_level_days, :preferred_stock_level_units, :prices_include_tax, :producer, :purchase_description,
20
- :quantity_available, :quantity_available_units, :quantity_back_ordered, :quantity_committed, :quantity_committed_units,
21
- :quantity_on_hand, :quantity_on_hand_units, :quantity_on_order, :quantity_on_order_units, :quantity_reorder_units, :rate,
22
- :related_items_description, :reorder_multiple, :reorder_point, :reorder_point_units, :safety_stock_level,
23
- :safety_stock_level_days, :safety_stock_level_units, :sales_description, :schedule_b_code, :schedule_b_number,
24
- :schedule_b_quantity, :search_keywords, :seasonal_demand, :ship_individually, :shipping_cost, :shipping_cost_units,
25
- :shopping_dot_com_category, :shopzilla_category_id, :show_default_donation_amount, :sitemap_priority, :specials_description,
26
- :stock_description, :store_description, :store_detailed_description, :store_display_name, :total_value, :track_landed_cost,
27
- :transfer_price, :upc_code, :url_component, :use_bins, :use_marginal_rates, :vendor_name, :vsoe_deferral, :vsoe_delivered,
28
- :vsoe_permit_discount, :vsoe_price, :weight, :weight_unit, :weight_units
8
+ :auto_lead_time,
9
+ :auto_preferred_stock_level,
10
+ :auto_reorder_point,
11
+ :available_to_partners,
12
+ :average_cost,
13
+ :backward_consumption_days,
14
+ :contingent_revenue_handling,
15
+ :conversion_rate,
16
+ :copy_description,
17
+ :cost,
18
+ :cost_estimate,
19
+ :cost_estimate_type,
20
+ :cost_estimate_units,
21
+ :costing_method,
22
+ :costing_method_display,
23
+ :cost_units,
24
+ :country_of_manufacture,
25
+ :created_date,
26
+ :currency,
27
+ :date_converted_to_inv,
28
+ :default_return_cost,
29
+ :defer_rev_rec,
30
+ :demand_modifier,
31
+ :demand_time_fence,
32
+ :direct_revenue_posting,
33
+ :display_name,
34
+ :dont_show_price,
35
+ :enable_catch_weight,
36
+ :enforce_min_qty_internally,
37
+ :exclude_from_sitemap,
38
+ :featured_description,
39
+ :fixed_lot_size,
40
+ :forward_consumption_days,
41
+ :fraud_risk,
42
+ :future_horizon,
43
+ :handling_cost,
44
+ :handling_cost_units,
45
+ :hazmat_hazard_class,
46
+ :hazmat_id,
47
+ :hazmat_item_units,
48
+ :hazmat_item_units_qty,
49
+ :hazmat_packing_group,
50
+ :hazmat_shipping_name,
51
+ :include_children,
52
+ :invt_classification,
53
+ :invt_count_interval,
54
+ :is_donation_item,
55
+ :is_drop_ship_item,
56
+ :is_gco_compliant,
57
+ :is_hazmat_item,
58
+ :is_inactive,
59
+ :is_online,
60
+ :is_special_order_item,
61
+ :is_store_pickup_allowed,
62
+ :is_taxable,
63
+ :item_carrier,
64
+ :item_id,
65
+ :last_invt_count_date,
66
+ :last_modified_date,
67
+ :last_purchase_price,
68
+ :lead_time,
69
+ :lower_warning_limit,
70
+ :manufacturer,
71
+ :manufacturer_addr1,
72
+ :manufacturer_city,
73
+ :manufacturer_state,
74
+ :manufacturer_tariff,
75
+ :manufacturer_tax_id,
76
+ :manufacturer_zip,
77
+ :match_bill_to_receipt,
78
+ :matrix_item_name_template,
79
+ :matrix_type,
80
+ :max_donation_amount,
81
+ :maximum_quantity,
82
+ :meta_tag_html,
83
+ :minimum_quantity,
84
+ :minimum_quantity_units,
85
+ :mpn,
86
+ :mult_manufacture_addr,
87
+ :nex_tag_category,
88
+ :next_invt_count_date,
89
+ :no_price_message,
90
+ :offer_support,
91
+ :on_hand_value_mli,
92
+ :on_special,
93
+ :original_item_subtype,
94
+ :original_item_type,
95
+ :out_of_stock_behavior,
96
+ :out_of_stock_message,
97
+ :overall_quantity_pricing_type,
98
+ :page_title,
99
+ :periodic_lot_size_days,
100
+ :periodic_lot_size_type,
101
+ :preference_criterion,
102
+ :preferred_stock_level,
103
+ :preferred_stock_level_days,
104
+ :preferred_stock_level_units,
105
+ :prices_include_tax,
106
+ :producer,
107
+ :purchase_description,
108
+ :purchase_order_amount,
109
+ :purchase_order_quantity,
110
+ :purchase_order_quantity_diff,
111
+ :quantity_available,
112
+ :quantity_available_units,
113
+ :quantity_back_ordered,
114
+ :quantity_committed,
115
+ :quantity_committed_units,
116
+ :quantity_on_hand,
117
+ :quantity_on_hand_units,
118
+ :quantity_on_order,
119
+ :quantity_on_order_units,
120
+ :quantity_reorder_units,
121
+ :rate,
122
+ :receipt_amount,
123
+ :receipt_quantity,
124
+ :receipt_quantity_diff,
125
+ :related_items_description,
126
+ :reorder_multiple,
127
+ :reorder_point,
128
+ :reorder_point_units,
129
+ :reschedule_in_days,
130
+ :reschedule_out_days,
131
+ :round_up_as_component,
132
+ :safety_stock_level,
133
+ :safety_stock_level_days,
134
+ :safety_stock_level_units,
135
+ :sales_description,
136
+ :schedule_b_code,
137
+ :schedule_b_number,
138
+ :schedule_b_quantity,
139
+ :search_keywords,
140
+ :seasonal_demand,
141
+ :ship_individually,
142
+ :shipping_cost,
143
+ :shipping_cost_units,
144
+ :shopping_dot_com_category,
145
+ :shopzilla_category_id,
146
+ :show_default_donation_amount,
147
+ :sitemap_priority,
148
+ :specials_description,
149
+ :stock_description,
150
+ :store_description,
151
+ :store_detailed_description,
152
+ :store_display_name,
153
+ :supply_time_fence,
154
+ :total_value,
155
+ :track_landed_cost,
156
+ :transfer_price,
157
+ :upc_code,
158
+ :upper_warning_limit,
159
+ :url_component,
160
+ :use_bins,
161
+ :use_marginal_rates,
162
+ :vendor_name,
163
+ :vsoe_deferral,
164
+ :vsoe_delivered,
165
+ :vsoe_permit_discount,
166
+ :vsoe_price,
167
+ :vsoe_sop_group,
168
+ :weight,
169
+ :weight_unit,
170
+ :weight_units,
29
171
  ].each do |field|
30
172
  expect(item).to have_field(field)
31
173
  end
@@ -95,9 +237,84 @@ describe NetSuite::Records::InventoryItem do
95
237
  end
96
238
  end
97
239
 
240
+ it 'has all the right fields with specific classes' do
241
+ {
242
+ bin_number_list: NetSuite::Records::BinNumberList,
243
+ custom_field_list: NetSuite::Records::CustomFieldList,
244
+ item_ship_method_list: NetSuite::Records::RecordRefList,
245
+ item_vendor_list: NetSuite::Records::ItemVendorList,
246
+ locations_list: NetSuite::Records::LocationsList,
247
+ matrix_option_list: NetSuite::Records::MatrixOptionList,
248
+ pricing_matrix: NetSuite::Records::PricingMatrix,
249
+ subsidiary_list: NetSuite::Records::RecordRefList,
250
+ }.each do |field, klass|
251
+ expect(item).to have_field(field, klass)
252
+ end
253
+ end
254
+
98
255
  it 'has all the right record refs' do
99
256
  [
100
- :alternate_demand_source_item, :asset_account, :bill_exch_rate_variance_acct, :bill_price_variance_acct, :bill_qty_variance_acct, :billing_schedule, :cogs_account, :cost_category, :custom_form, :deferred_revenue_account, :demand_source, :department, :expense_account, :gain_loss_account, :income_account, :issue_product, :klass, :location, :parent, :preferred_location, :pricing_group, :purchase_price_variance_acct, :purchase_tax_code, :purchase_unit, :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :ship_package, :soft_descriptor, :stock_unit, :store_display_image, :store_display_thumbnail, :store_item_template, :supply_lot_sizing_method, :supply_replenishment_method, :supply_type, :tax_schedule, :units_type, :vendor
257
+ :alternate_demand_source_item,
258
+ :asset_account,
259
+ :bill_exch_rate_variance_acct,
260
+ :billing_schedule,
261
+ :bill_price_variance_acct,
262
+ :bill_qty_variance_acct,
263
+ :klass,
264
+ :cogs_account,
265
+ :consumption_unit,
266
+ :cost_category,
267
+ :create_revenue_plans_on,
268
+ :custom_form,
269
+ :default_item_ship_method,
270
+ :deferred_revenue_account,
271
+ :demand_source,
272
+ :department,
273
+ :distribution_category,
274
+ :distribution_network,
275
+ :dropship_expense_account,
276
+ :expense_account,
277
+ :gain_loss_account,
278
+ :income_account,
279
+ :interco_cogs_account,
280
+ :interco_def_rev_account,
281
+ :interco_income_account,
282
+ :issue_product,
283
+ :item_revenue_category,
284
+ :location,
285
+ :parent,
286
+ :planning_item_category,
287
+ :preferred_location,
288
+ :pricing_group,
289
+ :purchase_price_variance_acct,
290
+ :purchase_tax_code,
291
+ :purchase_unit,
292
+ :quantity_pricing_schedule,
293
+ :revenue_allocation_group,
294
+ :revenue_recognition_rule,
295
+ :rev_rec_forecast_rule,
296
+ :rev_reclass_f_x_account,
297
+ :rev_rec_schedule,
298
+ :sales_tax_code,
299
+ :sale_unit,
300
+ :secondary_base_unit,
301
+ :secondary_consumption_unit,
302
+ :secondary_purchase_unit,
303
+ :secondary_sale_unit,
304
+ :secondary_stock_unit,
305
+ :secondary_units_type,
306
+ :ship_package,
307
+ :soft_descriptor,
308
+ :stock_unit,
309
+ :store_display_image,
310
+ :store_display_thumbnail,
311
+ :store_item_template,
312
+ :supply_lot_sizing_method,
313
+ :supply_replenishment_method,
314
+ :supply_type,
315
+ :tax_schedule,
316
+ :units_type,
317
+ :vendor,
101
318
  ].each do |record_ref|
102
319
  expect(item).to have_record_ref(record_ref)
103
320
  end
@@ -392,6 +392,35 @@ describe NetSuite::Records::Invoice do
392
392
  end
393
393
  end
394
394
 
395
+ describe '#attach_file' do
396
+ let(:test_data) { { :email => 'test@example.com', :fax => '1234567890' } }
397
+ let(:file) { double('file') }
398
+
399
+ context 'when the response is successful' do
400
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
401
+
402
+ it 'returns true' do
403
+ invoice = NetSuite::Records::Invoice.new(test_data)
404
+ expect(NetSuite::Actions::AttachFile).to receive(:call).
405
+ with([invoice, file], {}).
406
+ and_return(response)
407
+ expect(invoice.attach_file(file)).to be_truthy
408
+ end
409
+ end
410
+
411
+ context 'when the response is unsuccessful' do
412
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
413
+
414
+ it 'returns false' do
415
+ invoice = NetSuite::Records::Invoice.new(test_data)
416
+ expect(NetSuite::Actions::AttachFile).to receive(:call).
417
+ with([invoice, file], {}).
418
+ and_return(response)
419
+ expect(invoice.attach_file(file)).to be_falsey
420
+ end
421
+ end
422
+ end
423
+
395
424
  describe '#delete' do
396
425
  context 'when the response is successful' do
397
426
  let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ItemOptionCustomField do
4
+
5
+ describe ".get" do
6
+ let(:response) do
7
+ NetSuite::Response.new(
8
+ success: true,
9
+ body: {
10
+ label: "Value of Label",
11
+ }
12
+ )
13
+ end
14
+
15
+ it "returns a ItemOptionCustomField instance with populated fields" do
16
+ expect(NetSuite::Actions::Get)
17
+ .to receive(:call)
18
+ .with([NetSuite::Records::ItemOptionCustomField, internal_id: 1], {})
19
+ .and_return(response)
20
+
21
+ record = NetSuite::Records::ItemOptionCustomField.get(internal_id: 1)
22
+
23
+ expect(record.label).to eql("Value of Label")
24
+ end
25
+ end
26
+
27
+ end
@@ -10,17 +10,14 @@ describe NetSuite::Records::ItemVendorList do
10
10
  describe '#to_record' do
11
11
  before do
12
12
  list.item_vendors << NetSuite::Records::ItemVendor.new(
13
- :vendor => {:name => 'Spring Water'}
13
+ :vendor_code => 'Spring Water',
14
14
  )
15
15
  end
16
16
 
17
17
  it 'can represent itself as a SOAP record' do
18
18
  record = {
19
19
  "listAcct:itemVendor"=>[
20
- {"listAcct:vendor"=>{
21
- :name=>"Spring Water"
22
- }
23
- }
20
+ {"listAcct:vendorCode"=>"Spring Water"}
24
21
  ]
25
22
  }
26
23