netsuite 0.8.8 → 0.8.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) 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 +42 -5
  8. data/README.md +18 -20
  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 +1 -4
  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 +1 -2
  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 +95 -15
  31. data/lib/netsuite/records/inbound_shipment.rb +0 -1
  32. data/lib/netsuite/records/inventory_item.rb +239 -40
  33. data/lib/netsuite/records/inventory_number.rb +1 -2
  34. data/lib/netsuite/records/inventory_transfer.rb +1 -0
  35. data/lib/netsuite/records/invoice.rb +7 -8
  36. data/lib/netsuite/records/invoice_item.rb +1 -1
  37. data/lib/netsuite/records/item_fulfillment.rb +0 -1
  38. data/lib/netsuite/records/item_fulfillment_item.rb +1 -1
  39. data/lib/netsuite/records/item_group.rb +1 -1
  40. data/lib/netsuite/records/item_option_custom_field.rb +52 -0
  41. data/lib/netsuite/records/item_receipt.rb +0 -1
  42. data/lib/netsuite/records/item_receipt_item.rb +3 -2
  43. data/lib/netsuite/records/item_vendor.rb +10 -1
  44. data/lib/netsuite/records/job.rb +0 -1
  45. data/lib/netsuite/records/kit_item.rb +1 -1
  46. data/lib/netsuite/records/location.rb +0 -1
  47. data/lib/netsuite/records/lot_numbered_inventory_item.rb +225 -81
  48. data/lib/netsuite/records/matrix_option_list.rb +16 -0
  49. data/lib/netsuite/records/member_list.rb +0 -2
  50. data/lib/netsuite/records/non_inventory_purchase_item.rb +1 -1
  51. data/lib/netsuite/records/non_inventory_resale_item.rb +156 -20
  52. data/lib/netsuite/records/non_inventory_sale_item.rb +133 -21
  53. data/lib/netsuite/records/opportunity.rb +2 -3
  54. data/lib/netsuite/records/other_charge_sale_item.rb +1 -1
  55. data/lib/netsuite/records/payment_item.rb +1 -1
  56. data/lib/netsuite/records/payroll_item.rb +0 -1
  57. data/lib/netsuite/records/phone_call.rb +1 -1
  58. data/lib/netsuite/records/purchase_order.rb +0 -1
  59. data/lib/netsuite/records/return_authorization.rb +1 -0
  60. data/lib/netsuite/records/sales_order.rb +1 -2
  61. data/lib/netsuite/records/serialized_assembly_item.rb +0 -1
  62. data/lib/netsuite/records/serialized_inventory_item.rb +1 -1
  63. data/lib/netsuite/records/serialized_inventory_item_location.rb +0 -1
  64. data/lib/netsuite/records/service_resale_item.rb +123 -19
  65. data/lib/netsuite/records/service_sale_item.rb +1 -2
  66. data/lib/netsuite/records/subsidiary.rb +0 -1
  67. data/lib/netsuite/records/subtotal_item.rb +1 -1
  68. data/lib/netsuite/records/transfer_order.rb +0 -1
  69. data/lib/netsuite/records/transfer_order_item.rb +1 -1
  70. data/lib/netsuite/records/translation.rb +17 -0
  71. data/lib/netsuite/records/translation_list.rb +11 -0
  72. data/lib/netsuite/records/vendor.rb +4 -5
  73. data/lib/netsuite/records/vendor_bill.rb +0 -1
  74. data/lib/netsuite/records/work_order.rb +0 -1
  75. data/lib/netsuite/records/work_order_item.rb +0 -1
  76. data/lib/netsuite/support/actions.rb +2 -0
  77. data/lib/netsuite/support/fields.rb +3 -0
  78. data/lib/netsuite/support/records.rb +9 -1
  79. data/lib/netsuite/utilities.rb +5 -0
  80. data/lib/netsuite/version.rb +1 -1
  81. data/lib/netsuite.rb +4 -0
  82. data/netsuite.gemspec +4 -3
  83. data/spec/netsuite/actions/add_spec.rb +36 -0
  84. data/spec/netsuite/actions/attach_file_spec.rb +59 -0
  85. data/spec/netsuite/actions/search_spec.rb +205 -0
  86. data/spec/netsuite/records/estimate_spec.rb +103 -13
  87. data/spec/netsuite/records/inventory_item_spec.rb +242 -25
  88. data/spec/netsuite/records/invoice_spec.rb +30 -1
  89. data/spec/netsuite/records/item_option_custom_field_spec.rb +27 -0
  90. data/spec/netsuite/records/item_vendor_list_spec.rb +2 -5
  91. data/spec/netsuite/records/item_vendor_spec.rb +14 -2
  92. data/spec/netsuite/records/lot_numbered_inventory_item_spec.rb +247 -0
  93. data/spec/netsuite/records/matrix_option_list_spec.rb +26 -0
  94. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +159 -24
  95. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +135 -22
  96. data/spec/netsuite/records/return_authorization_spec.rb +62 -0
  97. data/spec/netsuite/records/sales_order_spec.rb +29 -0
  98. data/spec/netsuite/records/service_resale_item_spec.rb +122 -17
  99. data/spec/netsuite/records/translation_list_spec.rb +34 -0
  100. data/spec/netsuite/records/translation_spec.rb +28 -0
  101. data/spec/netsuite/support/fields_spec.rb +48 -1
  102. data/spec/netsuite/support/search_result_spec.rb +12 -0
  103. data/spec/netsuite/utilities_spec.rb +10 -2
  104. data/spec/support/field_matcher.rb +8 -6
  105. data/spec/support/fixtures/add/add_file.xml +20 -0
  106. data/spec/support/fixtures/attach/attach_file_to_sales_order.xml +16 -0
  107. data/spec/support/fixtures/attach/attach_file_to_sales_order_error.xml +20 -0
  108. data/spec/support/fixtures/search/basic_search_contact.xml +39 -0
  109. data/spec/support/fixtures/search/single_search_result.xml +46 -0
  110. metadata +39 -15
@@ -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
@@ -80,12 +222,12 @@ describe NetSuite::Records::InventoryItem do
80
222
  :number_allowed_downloads, :num_currently_listed, :obsolete_date,
81
223
  :obsolete_revision, :online_customer_price, :online_price, :other_prices,
82
224
  :other_vendor, :overhead_type, :preferred_bin, :primary_category,
83
- :prod_price_variance_acct, :prod_qty_variance_acct, :purchase_unit,
84
- :reserve_price, :revenue_recognition_rule,
225
+ :prod_price_variance_acct, :prod_qty_variance_acct,
226
+ :reserve_price,
85
227
  :same_as_primary_book_amortization, :same_as_primary_book_rev_rec,
86
228
  :scrap_acct, :sell_on_ebay, :serial_number, :serial_number_location,
87
229
  :shipping_carrier, :shipping_rate, :shopping_product_feed,
88
- :shopzilla_product_feed, :soft_descriptor, :starting_price, :subsidiary,
230
+ :shopzilla_product_feed, :starting_price, :subsidiary,
89
231
  :sub_type, :thumb_nail_url, :type, :unbuild_variance_account,
90
232
  :use_component_yield, :vendor_code, :vendor_cost, :vendor_cost_entered,
91
233
  :vendor_price_currency, :vendor_schedule, :vend_return_variance_account,
@@ -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
@@ -94,7 +94,7 @@ describe NetSuite::Records::Invoice do
94
94
  :merchant_account, :multi_subsidiary, :net_amount, :net_amount_no_tax,
95
95
  :next_bill_date, :no_auto_assign_location, :non_reimbursable,
96
96
  :one_time_total, :options, :order_allocation_strategy, :order_priority,
97
- :originator, :other_ref_num, :overhead_parent_item,
97
+ :originator, :overhead_parent_item,
98
98
  :override_installments, :package_count, :paid_amount, :paid_transaction,
99
99
  :partner_contribution, :partner_role, :partner_team_member,
100
100
  :paying_amount, :paying_transaction, :payment_approved,
@@ -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
 
@@ -5,11 +5,23 @@ describe NetSuite::Records::ItemVendor do
5
5
 
6
6
  it 'has all the right fields' do
7
7
  [
8
- :vendor, :purchase_price, :preferred_vendor
8
+ :purchase_price,
9
+ :preferred_vendor,
10
+ :vendor_code,
11
+ :vendor_currency_name,
9
12
  ].each do |field|
10
13
  expect(vendor).to have_field(field)
11
14
  end
12
15
  end
13
16
 
14
- it 'has all the right record refs'
17
+ it 'has all the right record refs' do
18
+ [
19
+ :schedule,
20
+ :subsidiary,
21
+ :vendor,
22
+ :vendor_currency,
23
+ ].each do |field|
24
+ expect(vendor).to have_record_ref(field)
25
+ end
26
+ end
15
27
  end
@@ -0,0 +1,247 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::LotNumberedInventoryItem do
4
+ let(:item) { described_class.new }
5
+
6
+ it 'has all the right fields' do
7
+ [
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
+ :conversion_rate,
15
+ :copy_description,
16
+ :cost,
17
+ :cost_estimate,
18
+ :cost_estimate_type,
19
+ :costing_method,
20
+ :costing_method_display,
21
+ :cost_units,
22
+ :country_of_manufacture,
23
+ :created_date,
24
+ :currency,
25
+ :default_return_cost,
26
+ :demand_modifier,
27
+ :demand_time_fence,
28
+ :direct_revenue_posting,
29
+ :display_name,
30
+ :dont_show_price,
31
+ :enable_catch_weight,
32
+ :enforce_min_qty_internally,
33
+ :exclude_from_sitemap,
34
+ :expiration_date,
35
+ :featured_description,
36
+ :fixed_lot_size,
37
+ :forward_consumption_days,
38
+ :future_horizon,
39
+ :handling_cost,
40
+ :handling_cost_units,
41
+ :hazmat_hazard_class,
42
+ :hazmat_id,
43
+ :hazmat_item_units,
44
+ :hazmat_item_units_qty,
45
+ :hazmat_packing_group,
46
+ :hazmat_shipping_name,
47
+ :include_children,
48
+ :invt_classification,
49
+ :invt_count_interval,
50
+ :is_donation_item,
51
+ :is_drop_ship_item,
52
+ :is_gco_compliant,
53
+ :is_hazmat_item,
54
+ :is_inactive,
55
+ :is_online,
56
+ :is_special_order_item,
57
+ :is_store_pickup_allowed,
58
+ :is_taxable,
59
+ :item_carrier,
60
+ :item_id,
61
+ :last_invt_count_date,
62
+ :last_modified_date,
63
+ :last_purchase_price,
64
+ :lead_time,
65
+ :lower_warning_limit,
66
+ :manufacturer,
67
+ :manufacturer_addr1,
68
+ :manufacturer_city,
69
+ :manufacturer_state,
70
+ :manufacturer_tariff,
71
+ :manufacturer_tax_id,
72
+ :manufacturer_zip,
73
+ :match_bill_to_receipt,
74
+ :matrix_item_name_template,
75
+ :matrix_type,
76
+ :max_donation_amount,
77
+ :maximum_quantity,
78
+ :meta_tag_html,
79
+ :minimum_quantity,
80
+ :minimum_quantity_units,
81
+ :mpn,
82
+ :mult_manufacture_addr,
83
+ :nex_tag_category,
84
+ :next_invt_count_date,
85
+ :no_price_message,
86
+ :offer_support,
87
+ :on_hand_value_mli,
88
+ :on_special,
89
+ :out_of_stock_behavior,
90
+ :out_of_stock_message,
91
+ :overall_quantity_pricing_type,
92
+ :page_title,
93
+ :periodic_lot_size_days,
94
+ :periodic_lot_size_type,
95
+ :preference_criterion,
96
+ :preferred_stock_level,
97
+ :preferred_stock_level_days,
98
+ :preferred_stock_level_units,
99
+ :prices_include_tax,
100
+ :producer,
101
+ :purchase_description,
102
+ :purchase_order_amount,
103
+ :purchase_order_quantity,
104
+ :purchase_order_quantity_diff,
105
+ :quantity_available,
106
+ :quantity_back_ordered,
107
+ :quantity_committed,
108
+ :quantity_on_hand,
109
+ :quantity_on_hand_units,
110
+ :quantity_on_order,
111
+ :quantity_reorder_units,
112
+ :rate,
113
+ :receipt_amount,
114
+ :receipt_quantity,
115
+ :receipt_quantity_diff,
116
+ :related_items_description,
117
+ :reorder_multiple,
118
+ :reorder_point,
119
+ :reorder_point_units,
120
+ :reschedule_in_days,
121
+ :reschedule_out_days,
122
+ :round_up_as_component,
123
+ :safety_stock_level,
124
+ :safety_stock_level_days,
125
+ :safety_stock_level_units,
126
+ :sales_description,
127
+ :schedule_b_code,
128
+ :schedule_b_number,
129
+ :schedule_b_quantity,
130
+ :search_keywords,
131
+ :seasonal_demand,
132
+ :serial_numbers,
133
+ :ship_individually,
134
+ :shipping_cost,
135
+ :shipping_cost_units,
136
+ :shopping_dot_com_category,
137
+ :shopzilla_category_id,
138
+ :show_default_donation_amount,
139
+ :sitemap_priority,
140
+ :specials_description,
141
+ :stock_description,
142
+ :store_description,
143
+ :store_detailed_description,
144
+ :store_display_name,
145
+ :supply_time_fence,
146
+ :total_value,
147
+ :track_landed_cost,
148
+ :transfer_price,
149
+ :upc_code,
150
+ :upper_warning_limit,
151
+ :url_component,
152
+ :use_bins,
153
+ :use_marginal_rates,
154
+ :vendor_name,
155
+ :vsoe_deferral,
156
+ :vsoe_delivered,
157
+ :vsoe_permit_discount,
158
+ :vsoe_price,
159
+ :vsoe_sop_group,
160
+ :weight,
161
+ :weight_unit,
162
+ :weight_units,
163
+ ].each do |field|
164
+ expect(item).to have_field(field)
165
+ end
166
+ end
167
+
168
+ it 'has all the right fields with specific classes' do
169
+ {
170
+ bin_number_list: NetSuite::Records::BinNumberList,
171
+ custom_field_list: NetSuite::Records::CustomFieldList,
172
+ item_number_options_list: NetSuite::Records::RecordRefList,
173
+ item_ship_method_list: NetSuite::Records::RecordRefList,
174
+ item_vendor_list: NetSuite::Records::ItemVendorList,
175
+ locations_list: NetSuite::Records::LocationsList,
176
+ matrix_option_list: NetSuite::Records::MatrixOptionList,
177
+ pricing_matrix: NetSuite::Records::PricingMatrix,
178
+ subsidiary_list: NetSuite::Records::RecordRefList,
179
+ translations_list: NetSuite::Records::TranslationList,
180
+ }.each do |field, klass|
181
+ expect(item).to have_field(field, klass)
182
+ end
183
+ end
184
+
185
+ it 'has all the right record refs' do
186
+ [
187
+ :alternate_demand_source_item,
188
+ :asset_account,
189
+ :bill_exch_rate_variance_acct,
190
+ :billing_schedule,
191
+ :bill_price_variance_acct,
192
+ :bill_qty_variance_acct,
193
+ :klass,
194
+ :cogs_account,
195
+ :consumption_unit,
196
+ :cost_category,
197
+ :create_revenue_plans_on,
198
+ :custom_form,
199
+ :default_item_ship_method,
200
+ :deferred_revenue_account,
201
+ :demand_source,
202
+ :department,
203
+ :dropship_expense_account,
204
+ :gain_loss_account,
205
+ :income_account,
206
+ :interco_cogs_account,
207
+ :interco_income_account,
208
+ :issue_product,
209
+ :item_revenue_category,
210
+ :location,
211
+ :parent,
212
+ :planning_item_category,
213
+ :preferred_location,
214
+ :pricing_group,
215
+ :purchase_price_variance_acct,
216
+ :purchase_tax_code,
217
+ :purchase_unit,
218
+ :quantity_pricing_schedule,
219
+ :revenue_allocation_group,
220
+ :revenue_recognition_rule,
221
+ :rev_rec_forecast_rule,
222
+ :rev_rec_schedule,
223
+ :sales_tax_code,
224
+ :sale_unit,
225
+ :secondary_base_unit,
226
+ :secondary_consumption_unit,
227
+ :secondary_purchase_unit,
228
+ :secondary_sale_unit,
229
+ :secondary_stock_unit,
230
+ :secondary_units_type,
231
+ :ship_package,
232
+ :soft_descriptor,
233
+ :stock_unit,
234
+ :store_display_image,
235
+ :store_display_thumbnail,
236
+ :store_item_template,
237
+ :supply_lot_sizing_method,
238
+ :supply_replenishment_method,
239
+ :supply_type,
240
+ :tax_schedule,
241
+ :units_type,
242
+ :vendor,
243
+ ].each do |record_ref|
244
+ expect(item).to have_record_ref(record_ref)
245
+ end
246
+ end
247
+ end
@@ -4,6 +4,8 @@ require 'ostruct'
4
4
  module NetSuite
5
5
  module Records
6
6
  describe MatrixOptionList do
7
+ let(:list) { described_class.new }
8
+
7
9
  it "deals with hash properly" do
8
10
  hash = {:value=>{:@internal_id=>"1", :@type_id=>"36", :name=>"some value"}, :@script_id=>'cust_field_1'}
9
11
 
@@ -30,6 +32,30 @@ module NetSuite
30
32
  expect(option.name).to eq "some value 28"
31
33
  expect(option.script_id).to eq "cust_field_28"
32
34
  end
35
+
36
+ describe '#to_record' do
37
+ before do
38
+ list.options << OpenStruct.new(
39
+ type_id: 'TYPE',
40
+ value_id: 'VALUE',
41
+ script_id: 'SCRIPT',
42
+ name: 'NAME',
43
+ )
44
+ end
45
+
46
+ it 'can represent itself as a SOAP record' do
47
+ record = {
48
+ 'listAcct:matrixOption' => [{
49
+ '@scriptId' => 'SCRIPT',
50
+ 'platformCore:value' => {
51
+ '@internalId' => 'VALUE',
52
+ '@typeId' => 'TYPE',
53
+ },
54
+ }],
55
+ }
56
+ expect(list.to_record).to eql(record)
57
+ end
58
+ end
33
59
  end
34
60
  end
35
61
  end