netsuite 0.8.10 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) 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 +56 -2
  8. data/README.md +94 -38
  9. data/lib/netsuite/actions/add.rb +7 -2
  10. data/lib/netsuite/actions/attach_file.rb +87 -0
  11. data/lib/netsuite/actions/delete.rb +18 -1
  12. data/lib/netsuite/actions/delete_list.rb +1 -1
  13. data/lib/netsuite/actions/get.rb +1 -1
  14. data/lib/netsuite/actions/get_deleted.rb +1 -1
  15. data/lib/netsuite/actions/get_list.rb +1 -1
  16. data/lib/netsuite/actions/initialize.rb +2 -2
  17. data/lib/netsuite/actions/search.rb +20 -7
  18. data/lib/netsuite/configuration.rb +16 -3
  19. data/lib/netsuite/records/account.rb +0 -1
  20. data/lib/netsuite/records/accounting_period.rb +1 -1
  21. data/lib/netsuite/records/assembly_component.rb +0 -2
  22. data/lib/netsuite/records/assembly_item.rb +2 -2
  23. data/lib/netsuite/records/assembly_unbuild.rb +0 -1
  24. data/lib/netsuite/records/cash_refund.rb +0 -1
  25. data/lib/netsuite/records/cash_refund_item.rb +1 -1
  26. data/lib/netsuite/records/cash_sale.rb +1 -2
  27. data/lib/netsuite/records/contact.rb +0 -1
  28. data/lib/netsuite/records/credit_memo.rb +1 -1
  29. data/lib/netsuite/records/currency_rate.rb +0 -1
  30. data/lib/netsuite/records/custom_record.rb +1 -1
  31. data/lib/netsuite/records/customer.rb +224 -23
  32. data/lib/netsuite/records/customer_deposit.rb +0 -1
  33. data/lib/netsuite/records/customer_payment.rb +0 -1
  34. data/lib/netsuite/records/customer_refund.rb +1 -2
  35. data/lib/netsuite/records/deposit.rb +0 -1
  36. data/lib/netsuite/records/deposit_application.rb +0 -1
  37. data/lib/netsuite/records/description_item.rb +3 -3
  38. data/lib/netsuite/records/discount_item.rb +1 -1
  39. data/lib/netsuite/records/employee.rb +1 -1
  40. data/lib/netsuite/records/estimate.rb +0 -1
  41. data/lib/netsuite/records/file.rb +1 -1
  42. data/lib/netsuite/records/gift_certificate_item.rb +1 -1
  43. data/lib/netsuite/records/inbound_shipment.rb +0 -1
  44. data/lib/netsuite/records/inventory_item.rb +237 -38
  45. data/lib/netsuite/records/inventory_number.rb +0 -1
  46. data/lib/netsuite/records/invoice.rb +2 -2
  47. data/lib/netsuite/records/item_availability.rb +46 -0
  48. data/lib/netsuite/records/item_fulfillment.rb +4 -2
  49. data/lib/netsuite/records/item_fulfillment_package_fed_ex.rb +28 -0
  50. data/lib/netsuite/records/item_fulfillment_package_fed_ex_list.rb +32 -0
  51. data/lib/netsuite/records/item_fulfillment_package_ups.rb +27 -0
  52. data/lib/netsuite/records/item_fulfillment_package_ups_list.rb +32 -0
  53. data/lib/netsuite/records/item_fulfillment_package_usps.rb +26 -0
  54. data/lib/netsuite/records/item_fulfillment_package_usps_list.rb +32 -0
  55. data/lib/netsuite/records/item_group.rb +3 -3
  56. data/lib/netsuite/records/item_option_custom_field.rb +52 -0
  57. data/lib/netsuite/records/item_receipt.rb +0 -1
  58. data/lib/netsuite/records/item_vendor.rb +10 -1
  59. data/lib/netsuite/records/job.rb +0 -1
  60. data/lib/netsuite/records/kit_item.rb +2 -2
  61. data/lib/netsuite/records/location.rb +0 -1
  62. data/lib/netsuite/records/lot_numbered_assembly_item.rb +1 -1
  63. data/lib/netsuite/records/lot_numbered_inventory_item.rb +226 -82
  64. data/lib/netsuite/records/matrix_option_list.rb +16 -0
  65. data/lib/netsuite/records/non_inventory_purchase_item.rb +1 -1
  66. data/lib/netsuite/records/non_inventory_resale_item.rb +157 -21
  67. data/lib/netsuite/records/non_inventory_sale_item.rb +134 -22
  68. data/lib/netsuite/records/null_field_list.rb +15 -0
  69. data/lib/netsuite/records/opportunity.rb +0 -1
  70. data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
  71. data/lib/netsuite/records/payment_item.rb +3 -3
  72. data/lib/netsuite/records/payroll_item.rb +0 -1
  73. data/lib/netsuite/records/purchase_order.rb +0 -1
  74. data/lib/netsuite/records/record_ref.rb +1 -1
  75. data/lib/netsuite/records/return_authorization.rb +1 -0
  76. data/lib/netsuite/records/sales_order.rb +2 -2
  77. data/lib/netsuite/records/sales_order_item.rb +2 -1
  78. data/lib/netsuite/records/serialized_assembly_item.rb +1 -1
  79. data/lib/netsuite/records/serialized_inventory_item.rb +2 -2
  80. data/lib/netsuite/records/serialized_inventory_item_location.rb +0 -1
  81. data/lib/netsuite/records/service_resale_item.rb +125 -21
  82. data/lib/netsuite/records/service_sale_item.rb +1 -2
  83. data/lib/netsuite/records/{customer_subscription.rb → subscription.rb} +1 -1
  84. data/lib/netsuite/records/subscriptions_list.rb +10 -0
  85. data/lib/netsuite/records/subsidiary.rb +0 -1
  86. data/lib/netsuite/records/subtotal_item.rb +3 -4
  87. data/lib/netsuite/records/transfer_order.rb +0 -1
  88. data/lib/netsuite/records/translation.rb +17 -0
  89. data/lib/netsuite/records/translation_list.rb +11 -0
  90. data/lib/netsuite/records/vendor.rb +0 -1
  91. data/lib/netsuite/records/vendor_bill.rb +0 -1
  92. data/lib/netsuite/records/work_order.rb +0 -1
  93. data/lib/netsuite/records/work_order_item.rb +0 -1
  94. data/lib/netsuite/support/actions.rb +2 -0
  95. data/lib/netsuite/support/fields.rb +2 -0
  96. data/lib/netsuite/support/records.rb +22 -5
  97. data/lib/netsuite/support/sublist.rb +2 -2
  98. data/lib/netsuite/utilities/strings.rb +15 -0
  99. data/lib/netsuite/utilities.rb +25 -13
  100. data/lib/netsuite/version.rb +1 -1
  101. data/lib/netsuite.rb +15 -3
  102. data/netsuite.gemspec +5 -2
  103. data/spec/netsuite/actions/add_spec.rb +39 -1
  104. data/spec/netsuite/actions/attach_file_spec.rb +59 -0
  105. data/spec/netsuite/actions/delete_spec.rb +74 -14
  106. data/spec/netsuite/actions/get_select_value_spec.rb +43 -0
  107. data/spec/netsuite/actions/search_spec.rb +205 -0
  108. data/spec/netsuite/configuration_spec.rb +35 -0
  109. data/spec/netsuite/records/cash_refund_item_spec.rb +1 -1
  110. data/spec/netsuite/records/credit_memo_spec.rb +14 -0
  111. data/spec/netsuite/records/customer_spec.rb +287 -20
  112. data/spec/netsuite/records/inventory_item_spec.rb +239 -22
  113. data/spec/netsuite/records/invoice_spec.rb +43 -0
  114. data/spec/netsuite/records/item_availability_spec.rb +59 -0
  115. data/spec/netsuite/records/item_fulfillment_package_fed_ex_list_spec.rb +27 -0
  116. data/spec/netsuite/records/item_fulfillment_package_ups_list_spec.rb +27 -0
  117. data/spec/netsuite/records/item_fulfillment_package_usps_list_spec.rb +27 -0
  118. data/spec/netsuite/records/item_option_custom_field_spec.rb +27 -0
  119. data/spec/netsuite/records/item_vendor_list_spec.rb +2 -5
  120. data/spec/netsuite/records/item_vendor_spec.rb +14 -2
  121. data/spec/netsuite/records/lot_numbered_inventory_item_spec.rb +247 -0
  122. data/spec/netsuite/records/matrix_option_list_spec.rb +26 -0
  123. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +159 -24
  124. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +135 -22
  125. data/spec/netsuite/records/null_field_list_spec.rb +30 -0
  126. data/spec/netsuite/records/return_authorization_spec.rb +62 -0
  127. data/spec/netsuite/records/sales_order_item_spec.rb +4 -3
  128. data/spec/netsuite/records/sales_order_spec.rb +46 -0
  129. data/spec/netsuite/records/service_resale_item_spec.rb +122 -17
  130. data/spec/netsuite/records/{customer_subscription_spec.rb → subscription_spec.rb} +2 -2
  131. data/spec/netsuite/records/{customer_subscriptions_list_spec.rb → subscriptions_list_spec.rb} +2 -2
  132. data/spec/netsuite/records/translation_list_spec.rb +34 -0
  133. data/spec/netsuite/records/translation_spec.rb +28 -0
  134. data/spec/netsuite/support/fields_spec.rb +16 -4
  135. data/spec/netsuite/support/records_spec.rb +33 -7
  136. data/spec/netsuite/support/search_result_spec.rb +12 -0
  137. data/spec/netsuite/utilities_spec.rb +10 -2
  138. data/spec/support/fixtures/add/add_file.xml +20 -0
  139. data/spec/support/fixtures/add/add_invoice.xml +9 -5
  140. data/spec/support/fixtures/attach/attach_file_to_sales_order.xml +16 -0
  141. data/spec/support/fixtures/attach/attach_file_to_sales_order_error.xml +20 -0
  142. data/spec/support/fixtures/delete/delete_customer_error.xml +21 -0
  143. data/spec/support/fixtures/delete/delete_customer_multiple_errors.xml +25 -0
  144. data/spec/support/fixtures/get_item_availability/get_item_availability.xml +46 -0
  145. data/spec/support/fixtures/get_select_value/empty_result.xml +22 -0
  146. data/spec/support/fixtures/get_select_value/item_fulfillment_ship_method.xml +43 -0
  147. data/spec/support/fixtures/search/basic_search_contact.xml +39 -0
  148. data/spec/support/fixtures/search/single_search_result.xml +46 -0
  149. metadata +78 -17
  150. data/lib/netsuite/core_ext/string/lower_camelcase.rb +0 -9
  151. data/lib/netsuite/records/customer_subscriptions_list.rb +0 -10
@@ -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
@@ -32,6 +32,20 @@ describe NetSuite::Records::Invoice do
32
32
  end
33
33
  end
34
34
 
35
+ it 'has all the right fields with specific classes' do
36
+ {
37
+ transaction_bill_address: NetSuite::Records::BillAddress,
38
+ transaction_ship_address: NetSuite::Records::ShipAddress,
39
+ item_list: NetSuite::Records::InvoiceItemList,
40
+ custom_field_list: NetSuite::Records::CustomFieldList,
41
+ shipping_address: NetSuite::Records::Address,
42
+ billing_address: NetSuite::Records::Address,
43
+ null_field_list: NetSuite::Records::NullFieldList,
44
+ }.each do |field, klass|
45
+ expect(invoice).to have_field(field, klass)
46
+ end
47
+ end
48
+
35
49
  it 'has all the right read_only_fields' do
36
50
  [
37
51
  :sub_total, :discount_total, :total, :alt_handling_cost, :alt_shipping_cost, :gift_cert_applied,
@@ -392,6 +406,35 @@ describe NetSuite::Records::Invoice do
392
406
  end
393
407
  end
394
408
 
409
+ describe '#attach_file' do
410
+ let(:test_data) { { :email => 'test@example.com', :fax => '1234567890' } }
411
+ let(:file) { double('file') }
412
+
413
+ context 'when the response is successful' do
414
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
415
+
416
+ it 'returns true' do
417
+ invoice = NetSuite::Records::Invoice.new(test_data)
418
+ expect(NetSuite::Actions::AttachFile).to receive(:call).
419
+ with([invoice, file], {}).
420
+ and_return(response)
421
+ expect(invoice.attach_file(file)).to be_truthy
422
+ end
423
+ end
424
+
425
+ context 'when the response is unsuccessful' do
426
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
427
+
428
+ it 'returns false' do
429
+ invoice = NetSuite::Records::Invoice.new(test_data)
430
+ expect(NetSuite::Actions::AttachFile).to receive(:call).
431
+ with([invoice, file], {}).
432
+ and_return(response)
433
+ expect(invoice.attach_file(file)).to be_falsey
434
+ end
435
+ end
436
+ end
437
+
395
438
  describe '#delete' do
396
439
  context 'when the response is successful' do
397
440
  let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ItemAvailability do
4
+ before(:all) { savon.mock! }
5
+ after(:all) { savon.unmock! }
6
+
7
+ let(:item_availability) { NetSuite::Records::ItemAvailability.new }
8
+
9
+ it 'has all the right fields' do
10
+ [
11
+ :quantity_on_hand,
12
+ :on_hand_value_mli,
13
+ :reorder_point,
14
+ :quantity_on_order,
15
+ :quantity_committed,
16
+ :quantity_available,
17
+ ].each do |field|
18
+ expect(item_availability).to have_field(field)
19
+ end
20
+ end
21
+
22
+ it { expect(item_availability).to have_field(:item, NetSuite::Records::InventoryItem) }
23
+ it { expect(item_availability).to have_field(:location_id, NetSuite::Records::Location) }
24
+
25
+ describe 'get_item_availability' do
26
+ let(:inventory_item_ref_list) {
27
+ NetSuite::Records::RecordRefList.new(
28
+ record_ref: [
29
+ NetSuite::Records::RecordRef.new(internal_id: 57)
30
+ ]
31
+ )
32
+ }
33
+ let(:result) { NetSuite::Records::ItemAvailability.get_item_availability(inventory_item_ref_list) }
34
+
35
+ before do
36
+ savon.expects(:get_item_availability).with(:message => {
37
+ "platformMsgs:itemAvailabilityFilter" => {
38
+ "platformCore:item"=>{"platformCore:recordRef"=>[{:@internalId=>57}]}
39
+ }
40
+ }).returns(File.read('spec/support/fixtures/get_item_availability/get_item_availability.xml'))
41
+ end
42
+
43
+ it 'returns ItemAvailability records' do
44
+ expect(result).to be_kind_of(Array)
45
+ expect(result).not_to be_empty
46
+ expect(result[0]).to be_kind_of(NetSuite::Records::ItemAvailability)
47
+ expect(result[0]).to have_attributes(
48
+ item: be_kind_of(NetSuite::Records::InventoryItem),
49
+ location_id: NetSuite::Records::Location,
50
+ quantity_on_hand: '264.0',
51
+ on_hand_value_mli: '129.36',
52
+ reorder_point: '50.0',
53
+ quantity_on_order: '0.0',
54
+ quantity_committed: '0.0',
55
+ quantity_available: '264.0',
56
+ )
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ItemFulfillmentPackageFedExList do
4
+ let(:list) { NetSuite::Records::ItemFulfillmentPackageFedExList.new }
5
+
6
+ it 'has a packages attribute' do
7
+ expect(list.packages).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ before do
12
+ list.packages << NetSuite::Records::ItemFulfillmentPackageFedEx.new(
13
+ :package_tracking_number_fed_ex => '1Z12354645757686786'
14
+ )
15
+ end
16
+
17
+ it 'can represent itself as a SOAP record' do
18
+ record = {
19
+ 'tranSales:packageFedEx' => [
20
+ 'tranSales:packageTrackingNumberFedEx' => '1Z12354645757686786'
21
+ ]
22
+ }
23
+
24
+ expect(list.to_record).to eql(record)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ItemFulfillmentPackageUpsList do
4
+ let(:list) { NetSuite::Records::ItemFulfillmentPackageUpsList.new }
5
+
6
+ it 'has a packages attribute' do
7
+ expect(list.packages).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ before do
12
+ list.packages << NetSuite::Records::ItemFulfillmentPackageUps.new(
13
+ :package_tracking_number_ups => '1Z12354645757686786'
14
+ )
15
+ end
16
+
17
+ it 'can represent itself as a SOAP record' do
18
+ record = {
19
+ 'tranSales:packageUps' => [
20
+ 'tranSales:packageTrackingNumberUps' => '1Z12354645757686786'
21
+ ]
22
+ }
23
+
24
+ expect(list.to_record).to eql(record)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ItemFulfillmentPackageUspsList do
4
+ let(:list) { NetSuite::Records::ItemFulfillmentPackageUspsList.new }
5
+
6
+ it 'has a packages attribute' do
7
+ expect(list.packages).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ before do
12
+ list.packages << NetSuite::Records::ItemFulfillmentPackageUsps.new(
13
+ :package_tracking_number_usps => '1Z12354645757686786'
14
+ )
15
+ end
16
+
17
+ it 'can represent itself as a SOAP record' do
18
+ record = {
19
+ 'tranSales:packageUsps' => [
20
+ 'tranSales:packageTrackingNumberUsps' => '1Z12354645757686786'
21
+ ]
22
+ }
23
+
24
+ expect(list.to_record).to eql(record)
25
+ end
26
+ end
27
+ end
@@ -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