netsuite 0.7.9 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/README.md +35 -29
  4. data/lib/netsuite.rb +13 -0
  5. data/lib/netsuite/records/assembly_build.rb +36 -0
  6. data/lib/netsuite/records/assembly_component.rb +28 -0
  7. data/lib/netsuite/records/assembly_component_list.rb +12 -0
  8. data/lib/netsuite/records/assembly_unbuild.rb +37 -0
  9. data/lib/netsuite/records/cash_refund.rb +99 -3
  10. data/lib/netsuite/records/cash_sale.rb +1 -0
  11. data/lib/netsuite/records/credit_memo.rb +1 -0
  12. data/lib/netsuite/records/custom_field_list.rb +6 -1
  13. data/lib/netsuite/records/customer_deposit.rb +1 -0
  14. data/lib/netsuite/records/customer_deposit_apply.rb +17 -0
  15. data/lib/netsuite/records/customer_deposit_apply_list.rb +12 -0
  16. data/lib/netsuite/records/employee.rb +1 -0
  17. data/lib/netsuite/records/inventory_adjustment_inventory.rb +2 -2
  18. data/lib/netsuite/records/inventory_number.rb +35 -0
  19. data/lib/netsuite/records/inventory_number_locations.rb +16 -0
  20. data/lib/netsuite/records/inventory_number_locations_list.rb +10 -0
  21. data/lib/netsuite/records/inventory_transfer.rb +2 -2
  22. data/lib/netsuite/records/inventory_transfer_inventory_list.rb +0 -2
  23. data/lib/netsuite/records/invoice.rb +2 -2
  24. data/lib/netsuite/records/item_fulfillment.rb +1 -0
  25. data/lib/netsuite/records/job.rb +2 -1
  26. data/lib/netsuite/records/serialized_inventory_item.rb +2 -2
  27. data/lib/netsuite/records/serialized_inventory_item_location.rb +37 -0
  28. data/lib/netsuite/records/serialized_inventory_item_locations_list.rb +10 -0
  29. data/lib/netsuite/records/serialized_inventory_item_numbers.rb +15 -0
  30. data/lib/netsuite/records/serialized_inventory_item_numbers_list.rb +10 -0
  31. data/lib/netsuite/records/vendor_bill.rb +2 -1
  32. data/lib/netsuite/utilities.rb +14 -26
  33. data/lib/netsuite/version.rb +1 -1
  34. data/spec/netsuite/records/basic_record_spec.rb +7 -1
  35. data/spec/netsuite/records/custom_field_list_spec.rb +7 -1
  36. data/spec/netsuite/records/inventory_transfer_spec.rb +21 -0
  37. data/spec/netsuite/records/invoice_spec.rb +2 -2
  38. data/spec/netsuite/utilities_spec.rb +12 -0
  39. metadata +16 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37636c6c1899441452fd3042cf52037b76680616
4
- data.tar.gz: 15c8900ac424109bdece121e2abbc3902a47bf7e
3
+ metadata.gz: c8c286d33279948996df71637831759f30d28a50
4
+ data.tar.gz: c3dc58125830de21646b4fcaf905b8c25dd6793e
5
5
  SHA512:
6
- metadata.gz: 08d79d1b7ee99dde3b063afab044f47a4d21e2628d15d9bd0119fc81de3fca087e6d5c85b882e5ae6b844e66e9016cfebd204b61cd0656e9b09c02c6880e23e1
7
- data.tar.gz: df7df5ffb7fd5a7815241ef70ac3d29ff46d07d9f26c770e079e663a2450f45e33f535a603d8dfb1221d091297b902472c2c66ba9404d3cc880faaa5341e8e7e
6
+ metadata.gz: 654d04316831d5d9e889a22351690bd319a5383b5ef7f4a7575789021b11833bcb6ecbf92dd0d7a462b3ca374404d19ae64a30d0a69e8f183e6fb4720dd8ee83
7
+ data.tar.gz: 80490066ecb5c094666622be4300294c45ccf14794a7ca853135e798d1dd317b1806945559edf06e71cc9c2d88523cd8757f61695f6153293ceb1596c3a0eeea
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.4.0
data/README.md CHANGED
@@ -3,28 +3,20 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/netsuite.svg)](http://badge.fury.io/rb/netsuite)
4
4
  [![Dependency Status](https://gemnasium.com/roidrage/lograge.svg)](https://gemnasium.com/netsweet/netsuite)
5
5
 
6
- # NetSuite Ruby SuiteTalk Gem
6
+ # NetSuite Ruby SuiteTalk API Gem
7
7
 
8
- * This gem will act as a wrapper around the NetSuite SuiteTalk WebServices API. Wow, that is a mouthful.
9
- * The gem does not cover the entire API, only the subset that we have found useful to cover so far.
10
- * Extending the wrapper is pretty simple, check out recent commits for an example of how to add support for additional records.
11
- * NetSuite development is overall a pretty poor experience. We have a list of [NetSuite Development Resources](https://github.com/NetSweet/netsuite/wiki/NetSuite-Development-Resources) that might make things a bit less painful.
8
+ * This gem will act as a wrapper around the NetSuite SuiteTalk WebServices API.
9
+ * The gem does not cover the entire API, only the subset contributors have used so far.
10
+ * NetSuite is a huge complex system. There's a lot to learn and sparse resources available to learn from. Here's a list of [NetSuite Development Resources](https://github.com/NetSweet/netsuite/wiki/NetSuite-Development-Resources) that might make things a bit less painful.
12
11
 
13
12
  # Help & Support
14
13
 
15
14
  Join the [slack channel](http://opensuite-slackin.herokuapp.com) for help with any NetSuite issues.
16
15
 
17
- ## Installation
18
-
19
- Add this line to your application's Gemfile:
20
-
21
- ```
22
- gem 'netsuite'
23
- ```
24
-
25
- This gem is built for ruby 1.9.x+, checkout the [1-8-stable](https://github.com/NetSweet/netsuite/tree/1-8-stable) branch for ruby 1.8.x support.
16
+ Please do not post usage questions as issues in GitHub.
26
17
 
27
18
  ## Testing
19
+
28
20
  Before contributing a patch make sure all existing tests pass.
29
21
 
30
22
  ```
@@ -33,8 +25,19 @@ cd netsuite
33
25
  bundle
34
26
  bundle exec rspec
35
27
  ```
28
+
36
29
  ## Usage
37
30
 
31
+ ### Installation
32
+
33
+ Add this line to your application's Gemfile:
34
+
35
+ ```
36
+ gem 'netsuite'
37
+ ```
38
+
39
+ This gem is built for ruby 1.9.x+, checkout the [1-8-stable](https://github.com/NetSweet/netsuite/tree/1-8-stable) branch for ruby 1.8.x support.
40
+
38
41
  ### Configuration
39
42
 
40
43
  Not sure how to find your account id? Search for "web service preferences" in the NetSuite global search.
@@ -70,9 +73,7 @@ NetSuite.configure do
70
73
  end
71
74
  ```
72
75
 
73
- There is a [convenience method](https://github.com/NetSweet/netsuite/blob/56fe7fae92908a2e3d6812ecc56516f773cacd45/lib/netsuite.rb#L180) to configure NetSuite based on ENV variables.
74
-
75
- OAuth credentials are also supported:
76
+ OAuth credentials are also supported. [Learn more about how to set up token based authentication here](http://mikebian.co/using-netsuites-token-based-authentication-with-suitetalk/).
76
77
 
77
78
  ```ruby
78
79
  NetSuite.configure do
@@ -84,7 +85,7 @@ NetSuite.configure do
84
85
  consumer_secret ENV['NETSUITE_CONSUMER_SECRET']
85
86
  token_id ENV['NETSUITE_TOKEN_ID']
86
87
  token_secret ENV['NETSUITE_TOKEN_SECRET']
87
-
88
+
88
89
  # oauth does not work with API versions less than 2015_2
89
90
  api_version '2015_2'
90
91
  end
@@ -100,7 +101,8 @@ customer = NetSuite::Records::Customer.get(:internal_id => 4)
100
101
  customer.is_person
101
102
 
102
103
  # or
103
- NetSuite::Records::Customer.get(4).is_person
104
+ NetSuite::Records::Customer.get(4)
105
+
104
106
 
105
107
  # get a list of customers
106
108
  customers = NetSuite::Records::Customer.get_list(:list => [4, 5, 6])
@@ -120,10 +122,15 @@ task.add
120
122
  # this will only work on OS X, open a browser to the record that was just created
121
123
  `open https://system.sandbox.netsuite.com/app/crm/calendar/task.nl?id=#{invoice.internal_id}`
122
124
 
123
- task.update :message => 'New Message'
125
+ # update a field on a record
126
+ task.update(message: 'New Message')
124
127
 
128
+ # delete a record
125
129
  task.delete
126
130
 
131
+ # refresh/reload a record (helpful after adding the record for the first time)
132
+ task.reload
133
+
127
134
  # using get_select_value with a standard record
128
135
  NetSuite::Records::BaseRefList.get_select_value(
129
136
  recordType: 'serviceSaleItem',
@@ -251,15 +258,14 @@ NetSuite::Records::Customer.search({
251
258
  ]
252
259
  }).results
253
260
 
254
- # advanced search from scratch
255
- NetSuite::Records::Transaction.search({
261
+ NetSuite::Records::SalesOrder.search({
256
262
  criteria: {
257
263
  basic: [
264
+ # NOTE do not search for more than one transaction type at a time!
258
265
  {
259
266
  field: 'type',
260
267
  operator: 'anyOf',
261
- type: 'SearchEnumMultiSelectField',
262
- value: [ "_invoice", "_salesOrder" ]
268
+ value: [ "_invoice"]
263
269
  },
264
270
  {
265
271
  field: 'tranDate',
@@ -267,10 +273,7 @@ NetSuite::Records::Transaction.search({
267
273
  # this is needed for date range search requests, for date requests with a single param type is not needed
268
274
  type: 'SearchDateField',
269
275
  value: [
270
- # the following format is equivilent to ISO 8601
271
- # Date.parse("1/1/2012").strftime("%Y-%m-%dT%H:%M:%S%z"),
272
- # Date.parse("30/07/2013").strftime("%Y-%m-%dT%H:%M:%S%z")
273
-
276
+ # NetSuite requires iso8601 time format
274
277
  # need to require the time library for this to work
275
278
  Time.parse("01/01/2012").iso8601,
276
279
  Time.parse("30/07/2013").iso8601,
@@ -337,7 +340,10 @@ NetSuite::Records::Transaction.search({
337
340
  },
338
341
 
339
342
  preferences: {
340
- page_size: 10
343
+ page_size: 10,
344
+
345
+ # only returning body fields increases performance!
346
+ body_fields_only: true
341
347
  }
342
348
  }).results
343
349
 
@@ -66,6 +66,10 @@ module NetSuite
66
66
 
67
67
  module Records
68
68
  autoload :AssemblyItem, 'netsuite/records/assembly_item'
69
+ autoload :AssemblyBuild, 'netsuite/records/assembly_build'
70
+ autoload :AssemblyComponent, 'netsuite/records/assembly_component'
71
+ autoload :AssemblyComponentList, 'netsuite/records/assembly_component_list'
72
+ autoload :AssemblyUnbuild, 'netsuite/records/assembly_unbuild'
69
73
  autoload :Account, 'netsuite/records/account'
70
74
  autoload :AccountingPeriod, 'netsuite/records/accounting_period'
71
75
  autoload :Address, 'netsuite/records/address'
@@ -105,6 +109,8 @@ module NetSuite
105
109
  autoload :CustomerCurrency, 'netsuite/records/customer_currency'
106
110
  autoload :CustomerCurrencyList, 'netsuite/records/customer_currency_list'
107
111
  autoload :CustomerDeposit, 'netsuite/records/customer_deposit'
112
+ autoload :CustomerDepositApplyList, 'netsuite/records/customer_deposit_apply_list'
113
+ autoload :CustomerDepositApply, 'netsuite/records/customer_deposit_apply'
108
114
  autoload :CustomerPartnersList, 'netsuite/records/customer_partners_list'
109
115
  autoload :CustomerPayment, 'netsuite/records/customer_payment'
110
116
  autoload :CustomerPaymentApply, 'netsuite/records/customer_payment_apply'
@@ -148,6 +154,9 @@ module NetSuite
148
154
  autoload :InventoryAssignmentList, 'netsuite/records/inventory_assignment_list'
149
155
  autoload :InventoryDetail, 'netsuite/records/inventory_detail'
150
156
  autoload :InventoryItem, 'netsuite/records/inventory_item'
157
+ autoload :InventoryNumber, 'netsuite/records/inventory_number'
158
+ autoload :InventoryNumberLocations, 'netsuite/records/inventory_number_locations'
159
+ autoload :InventoryNumberLocationsList, 'netsuite/records/inventory_number_locations_list'
151
160
  autoload :InventoryTransfer, 'netsuite/records/inventory_transfer'
152
161
  autoload :InventoryTransferInventory, 'netsuite/records/inventory_transfer_inventory'
153
162
  autoload :InventoryTransferInventoryList, 'netsuite/records/inventory_transfer_inventory_list'
@@ -211,6 +220,10 @@ module NetSuite
211
220
  autoload :ServiceResaleItem, 'netsuite/records/service_resale_item'
212
221
  autoload :ServiceSaleItem, 'netsuite/records/service_sale_item'
213
222
  autoload :SerializedInventoryItem, 'netsuite/records/serialized_inventory_item'
223
+ autoload :SerializedInventoryItemNumbers, 'netsuite/records/serialized_inventory_item_numbers'
224
+ autoload :SerializedInventoryItemNumbersList, 'netsuite/records/serialized_inventory_item_numbers_list'
225
+ autoload :SerializedInventoryItemLocation, 'netsuite/records/serialized_inventory_item_location'
226
+ autoload :SerializedInventoryItemLocationsList, 'netsuite/records/serialized_inventory_item_locations_list'
214
227
  autoload :ShipAddress, 'netsuite/records/ship_address'
215
228
  autoload :SiteCategory, 'netsuite/records/site_category'
216
229
  autoload :Subsidiary, 'netsuite/records/subsidiary'
@@ -0,0 +1,36 @@
1
+ module NetSuite
2
+ module Records
3
+ class AssemblyBuild
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Actions
7
+ include Support::Records
8
+ include Namespaces::TranInvt
9
+
10
+ actions :get, :add, :initialize, :delete, :update, :upsert, :upsert_list,
11
+ :search
12
+
13
+ fields :bin_numbers, :buildable, :created_date, :expiration_date,
14
+ :last_modified_date, :memo, :quantity, :serial_numbers, :total,
15
+ :tran_date, :tran_id
16
+
17
+ record_refs :klass, :created_from, :item, :custom_form,
18
+ :department, :job, :location, :posting_period, :revision,
19
+ :subsidiary, :units
20
+
21
+ field :component_list, AssemblyComponentList
22
+ field :inventory_detail, InventoryDetail
23
+
24
+
25
+ attr_reader :internal_id
26
+ attr_accessor :external_id
27
+
28
+ def initialize(attributes = {})
29
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
30
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
31
+ initialize_from_attributes_hash(attributes)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,28 @@
1
+ module NetSuite
2
+ module Records
3
+ class AssemblyComponent
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::TranInvt
8
+
9
+ fields :bin_number, :component_numbers, :line_number, :quantity,
10
+ :quantity_on_hand
11
+
12
+ field :component_inventory_detail, InventoryDetail
13
+
14
+ record_refs :item
15
+
16
+ attr_reader :internal_id
17
+ attr_accessor :external_id
18
+ attr_accessor :search_joins
19
+
20
+ def initialize(attributes = {})
21
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
22
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
23
+ initialize_from_attributes_hash(attributes)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,12 @@
1
+ module NetSuite
2
+ module Records
3
+ class AssemblyComponentList < Support::Sublist
4
+ include Namespaces::TranInvt
5
+
6
+ sublist :component, AssemblyComponent
7
+
8
+ alias :components :component
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,37 @@
1
+ module NetSuite
2
+ module Records
3
+ class AssemblyUnbuild
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Support::Actions
8
+ include Namespaces::TranInvt
9
+
10
+ actions :get, :add, :initialize, :delete, :update, :upsert, :upsert_list,
11
+ :search
12
+
13
+ fields :bin_numbers, :built, :created_date, :expiration_date,
14
+ :last_modified_date, :memo, :quantity, :serial_numbers, :total,
15
+ :tran_date, :tran_id
16
+
17
+ field :component_list, AssemblyComponentList
18
+ field :inventory_detail, InventoryDetail
19
+
20
+ record_refs :klass, :created_from, :item, :custom_form,
21
+ :department, :job, :location, :posting_period, :revision,
22
+ :subsidiary, :units
23
+
24
+ attr_reader :internal_id
25
+ attr_accessor :external_id
26
+ attr_accessor :search_joins
27
+
28
+ def initialize(attributes = {})
29
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
30
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
31
+ initialize_from_attributes_hash(attributes)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+
@@ -7,17 +7,113 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranCust
9
9
 
10
- actions :add, :get, :delete, :initialize, :upsert, :search
10
+ actions :get, :add, :initialize, :delete, :update, :upsert, :search
11
11
 
12
- fields :tran_id, :tran_date, :to_be_emailed, :memo, :total, :currency_name, :exchange_rate, :source, :tax_rate
12
+ fields :alt_handling_cost,
13
+ :alt_shipping_cost,
14
+ :billing_address,
15
+ :cc_approved,
16
+ :cc_expire_date,
17
+ :cc_is_purchase_card_bin,
18
+ :cc_name,
19
+ :cc_number,
20
+ :cc_process_as_purchase_card,
21
+ :cc_street,
22
+ :cc_zip_code,
23
+ :charge_it,
24
+ :contrib_pct,
25
+ :created_date,
26
+ :currency_name,
27
+ :debit_card_issue_no,
28
+ :deferred_revenue,
29
+ :discount_rate,
30
+ :discount_total,
31
+ :email,
32
+ :est_gross_profit,
33
+ :est_gross_profit_percent,
34
+ :exchange_rate,
35
+ :exclude_commission,
36
+ :fax,
37
+ :gift_cert_applied,
38
+ :gift_cert_available,
39
+ :gift_cert_total,
40
+ :handling_cost,
41
+ :handling_tax1_rate,
42
+ :handling_tax2_rate,
43
+ :is_taxable,
44
+ :last_modified_date,
45
+ :memo,
46
+ :message,
47
+ :other_ref_num,
48
+ :pay_pal_auth_id,
49
+ :pay_pal_process,
50
+ :pay_pal_status,
51
+ :pay_pal_tran_id,
52
+ :pn_ref_num,
53
+ :recognized_revenue,
54
+ :refund_check,
55
+ :rev_rec_on_rev_commitment,
56
+ :sales_effective_date,
57
+ :shipping_cost,
58
+ :shipping_tax1_rate,
59
+ :shipping_tax2_rate,
60
+ :source,
61
+ :status,
62
+ :sub_total,
63
+ :sync_partner_teams,
64
+ :sync_sales_teams,
65
+ :tax2_total,
66
+ :tax_rate,
67
+ :tax_total,
68
+ :to_be_emailed,
69
+ :to_be_faxed,
70
+ :to_be_printed,
71
+ :to_print2,
72
+ :total,
73
+ :total_cost_estimate,
74
+ :tran_date,
75
+ :tran_id,
76
+ :tran_is_vsoe_bundle,
77
+ :valid_from,
78
+ :vat_reg_num,
79
+ :vsoe_auto_calc
13
80
 
14
81
  field :item_list, CashRefundItemList
15
82
  field :custom_field_list, CustomFieldList
83
+ # partnersList CashRefundPartnersList
84
+ # salesTeamList CashRefundSalesTeamList
16
85
 
17
- record_refs :entity, :custom_form, :payment_method, :created_from, :klass, :account, :currency, :posting_period
86
+ record_refs :account,
87
+ :bill_address_list,
88
+ :klass,
89
+ :created_from,
90
+ :credit_card,
91
+ :credit_card_processor,
92
+ :currency,
93
+ :custom_form,
94
+ :department,
95
+ :discount_item,
96
+ :entity,
97
+ :gift_cert,
98
+ :handling_tax_code,
99
+ :job,
100
+ :lead_source,
101
+ :location,
102
+ :message_sel,
103
+ :partner,
104
+ :payment_method,
105
+ :posting_period,
106
+ :promo_code,
107
+ :sales_group,
108
+ :sales_rep,
109
+ :ship_method,
110
+ :shipping_tax_code,
111
+ :subsidiary,
112
+ :tax_item
18
113
 
19
114
  attr_reader :internal_id
20
115
  attr_accessor :external_id
116
+ attr_accessor :search_joins
21
117
 
22
118
  def initialize(attributes = {})
23
119
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -36,6 +36,7 @@ module NetSuite
36
36
 
37
37
  attr_reader :internal_id
38
38
  attr_accessor :external_id
39
+ attr_accessor :search_joins
39
40
 
40
41
  def initialize(attributes = {})
41
42
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -38,6 +38,7 @@ module NetSuite
38
38
 
39
39
  attr_reader :internal_id
40
40
  attr_accessor :external_id
41
+ attr_accessor :search_joins
41
42
 
42
43
  def initialize(attributes = {})
43
44
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -25,7 +25,12 @@ module NetSuite
25
25
  end
26
26
 
27
27
  def delete_custom_field(field)
28
- custom_fields.delete_if { |c| c.send(reference_id_type).to_sym == field }
28
+ custom_fields.delete_if do |c|
29
+ # https://github.com/NetSweet/netsuite/issues/325
30
+ c.send(reference_id_type) &&
31
+ c.send(reference_id_type).to_sym == field
32
+ end
33
+
29
34
  @custom_fields_assoc.delete(field)
30
35
  end
31
36
 
@@ -16,6 +16,7 @@ module NetSuite
16
16
  :check_num, :klass, :currency_name, :is_recurring_payment, :charge_it
17
17
 
18
18
  field :custom_field_list, CustomFieldList
19
+ field :apply_list, CustomerDepositApplyList
19
20
 
20
21
  record_refs :customer, :sales_order, :account, :department, :payment_method,
21
22
  :custom_form, :currency, :posting_period, :subsidiary,
@@ -0,0 +1,17 @@
1
+ module NetSuite
2
+ module Records
3
+ class CustomerDepositApply
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranCust
7
+
8
+ fields :amount, :apply, :apply_date, :currency, :disc, :disc_amt, :disc_date,
9
+ :doc, :due, :job, :line, :ref_num, :total, :type
10
+
11
+ def initialize(attributes = {})
12
+ initialize_from_attributes_hash(attributes)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module NetSuite
2
+ module Records
3
+ class CustomerDepositApplyList < Support::Sublist
4
+ include Namespaces::TranCust
5
+
6
+ sublist :customer_deposit_apply, CustomerDepositApply
7
+
8
+ alias :applies :customer_deposit_apply
9
+
10
+ end
11
+ end
12
+ end
@@ -21,6 +21,7 @@ module NetSuite
21
21
 
22
22
  record_refs :currency, :department, :location, :subsidiary, :employee_type, :employee_status, :supervisor
23
23
 
24
+ field :custom_field_list, CustomFieldList
24
25
  field :roles_list, RoleList
25
26
 
26
27
  attr_reader :internal_id
@@ -7,11 +7,11 @@ module NetSuite
7
7
  include Namespaces::TranInvt
8
8
 
9
9
  fields :adjust_qty_by, :description, :bin_numbers, :line,
10
- :quantity_on_hand, :serial_numbers, :location
10
+ :quantity_on_hand, :serial_numbers, :unit_cost
11
11
 
12
12
  field :inventory_detail, InventoryDetail
13
13
 
14
- record_refs :item, :units
14
+ record_refs :item, :units, :location
15
15
 
16
16
  def initialize(attributes = {})
17
17
  initialize_from_attributes_hash(attributes)
@@ -0,0 +1,35 @@
1
+ module NetSuite
2
+ module Records
3
+ class InventoryNumber
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Support::Actions
8
+ include Namespaces::ListAcct
9
+
10
+ actions :get, :search
11
+
12
+ fields :expiration_date, :inventory_number, :isonhand, :memo, :status, :units, :location,
13
+ :quantityavailable, :quantityintransit, :quantityonhand, :quantityonorder
14
+
15
+ field :locations_list, InventoryNumberLocationsList
16
+ field :custom_field_list, CustomFieldList
17
+
18
+ record_refs :item
19
+
20
+ attr_reader :internal_id
21
+ attr_accessor :external_id
22
+ attr_accessor :search_joins
23
+
24
+ def initialize(attributes = {})
25
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
26
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
27
+ initialize_from_attributes_hash(attributes)
28
+ end
29
+
30
+ def self.search_class_name
31
+ "InventoryNumber"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,16 @@
1
+ module NetSuite
2
+ module Records
3
+ class InventoryNumberLocations
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::ListAcct
7
+
8
+ fields :location, :quantity_available, :quantity_in_transit,
9
+ :quantity_on_hand, :quantity_on_order
10
+
11
+ def initialize(attributes = {})
12
+ initialize_from_attributes_hash(attributes)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ module NetSuite
2
+ module Records
3
+ class InventoryNumberLocationsList < Support::Sublist
4
+ include Namespaces::ListAcct
5
+
6
+ sublist :locations, InventoryNumberLocations
7
+
8
+ end
9
+ end
10
+ end
@@ -9,10 +9,10 @@ module NetSuite
9
9
 
10
10
  actions :get, :add, :delete, :search, :update, :upsert, :upsert_list
11
11
 
12
- fields :created_date, :last_modified_date, :tran_date, :tran_id, :memo
12
+ fields :klass, :created_date, :last_modified_date, :tran_date, :tran_id, :memo
13
13
 
14
14
  field :inventory_list, InventoryTransferInventoryList
15
-
15
+
16
16
  record_refs :posting_period, :location, :transfer_location, :department,
17
17
  :subsidiary
18
18
 
@@ -1,8 +1,6 @@
1
1
  module NetSuite
2
2
  module Records
3
3
  class InventoryTransferInventoryList < Support::Sublist
4
- include Support::RecordRefs
5
- include Support::Records
6
4
  include Namespaces::TranInvt
7
5
 
8
6
  sublist :inventory, InventoryTransferInventory
@@ -20,7 +20,7 @@ module NetSuite
20
20
  :exp_cost_tax_rate_2, :fax, :fob, :gift_cert_redemption_list, :handling_tax_1_rate,
21
21
  :handling_tax_2_rate, :handling_tax_code, :is_taxable, :item_cost_disc_amount, :item_cost_disc_print,
22
22
  :item_cost_disc_rate, :item_cost_disc_tax_1_amt, :item_cost_disc_taxable, :item_cost_discount, :item_cost_list,
23
- :item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :item_list, :job, :last_modified_date,
23
+ :item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :last_modified_date,
24
24
  :linked_tracking_numbers, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
25
25
  :other_ref_num, :partners_list, :rev_rec_end_date,
26
26
  :rev_rec_on_rev_commitment, :rev_rec_schedule, :rev_rec_start_date, :revenue_status, :sales_effective_date,
@@ -44,7 +44,7 @@ module NetSuite
44
44
 
45
45
  record_refs :account, :bill_address_list, :custom_form, :department, :entity, :klass, :partner,
46
46
  :posting_period, :ship_address_list, :terms, :location, :sales_rep, :tax_item, :created_from,
47
- :ship_method, :lead_source, :promo_code, :subsidiary, :currency, :approval_status
47
+ :ship_method, :lead_source, :promo_code, :subsidiary, :currency, :approval_status, :job
48
48
 
49
49
  attr_reader :internal_id
50
50
  attr_accessor :external_id
@@ -30,6 +30,7 @@ module NetSuite
30
30
 
31
31
  attr_reader :internal_id
32
32
  attr_accessor :external_id
33
+ attr_accessor :search_joins
33
34
 
34
35
  def initialize(attributes = {})
35
36
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -25,10 +25,11 @@ module NetSuite
25
25
  field :custom_field_list, CustomFieldList
26
26
 
27
27
  record_refs :billing_schedule, :category, :currency, :custom_form, :entity_status, :estimate_rev_rec_template, :job_item,
28
- :job_type, :language, :parent, :subsidiary, :workplace
28
+ :job_type, :language, :parent, :subsidiary, :workplace, :customer
29
29
 
30
30
  attr_reader :internal_id
31
31
  attr_accessor :external_id
32
+ attr_accessor :search_joins
32
33
 
33
34
  def initialize(attributes = {})
34
35
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -67,7 +67,6 @@ module NetSuite
67
67
  # locations_list SerializedInventoryItemLocationsList
68
68
  # matrix_option_list MatrixOptionList
69
69
  # matrix_type ItemMatrixType
70
- # numbers_list SerializedInventoryItemNumbersList
71
70
  # out_of_stock_behavior ItemOutOfStockBehavior
72
71
  # overall_quantity_pricing_type ItemOverallQuantityPricingType
73
72
  # periodic_lot_size_type PeriodicLotSizeType
@@ -222,8 +221,9 @@ module NetSuite
222
221
  # weight_unit ItemWeightUnit
223
222
 
224
223
  field :custom_field_list, CustomFieldList
225
- field :locations_list, LocationsList
224
+ field :locations_list, SerializedInventoryItemLocationsList
226
225
  field :subsidiary_list, RecordRefList
226
+ field :numbers_list, SerializedInventoryItemNumbersList
227
227
 
228
228
  # TODO from standard copied item record; may need to be deleted
229
229
  # field :pricing_matrix, PricingMatrix
@@ -0,0 +1,37 @@
1
+ module NetSuite
2
+ module Records
3
+ class SerializedInventoryItemLocation
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::ListAcct
8
+
9
+ fields :average_cost_mil, :backward_consumption_days, :build_time,
10
+ :cost, :costing_lot_size, :default_return_cost, :demand_time_force,
11
+ :fixed_lot_size, :forward_consumption_days, :invt_count_interval,
12
+ :is_wip, :last_invt_count_date, :last_purchase_price_mli, :lead_time,
13
+ :location, :next_invt_count_date, :on_hand_value_mli,
14
+ :periodic_lot_size_days, :preferred_stock_level, :quantity_available,
15
+ :quantity_back_ordered, :quantity_committed, :quantity_on_hand,
16
+ :quantity_on_order, :reorder_point, :reschedule_in_days,
17
+ :reschedule_out_days, :safety_stock_level, :serial_numbers
18
+
19
+ # field :invt_classification, ItemInvtClassification
20
+ # field :periodic_lot_size_type, PeriodicLotSizeType
21
+
22
+ record_refs :alternate_demand_source_item, :demand_source, :inventory_cost_template,
23
+ :location_id, :supply_lot_sizing_method, :supply_replenishment_method, :supply_type
24
+
25
+ attr_reader :internal_id
26
+ attr_accessor :external_id
27
+ attr_accessor :search_joins
28
+
29
+ def initialize(attributes = {})
30
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
31
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
32
+ initialize_from_attributes_hash(attributes)
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,10 @@
1
+ module NetSuite
2
+ module Records
3
+ class SerializedInventoryItemLocationsList < Support::Sublist
4
+ include Namespaces::ListAcct
5
+
6
+ sublist :locations, SerializedInventoryItemLocation
7
+
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ module NetSuite
2
+ module Records
3
+ class SerializedInventoryItemNumbers
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::ListAcct
7
+
8
+ fields :serial_number
9
+
10
+ def initialize(attributes = {})
11
+ initialize_from_attributes_hash(attributes)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ module NetSuite
2
+ module Records
3
+ class SerializedInventoryItemNumbersList < Support::Sublist
4
+ include Namespaces::ListAcct
5
+
6
+ sublist :numbers, SerializedInventoryItemNumbers
7
+
8
+ end
9
+ end
10
+ end
@@ -11,7 +11,7 @@ module NetSuite
11
11
 
12
12
  fields :created_date, :credit_limit, :currency_name, :discount_amount, :discount_date, :due_date, :exchange_rate,
13
13
  :landed_costs_list, :landed_cost_method, :landed_cost_per_line, :last_modified_date, :memo, :tax_total,
14
- :tax_2_total, :transaction_number, :tran_date, :tran_id, :user_total, :vat_reg_num
14
+ :tax_2_total, :transaction_number, :tran_date, :tran_id, :user_total, :vat_reg_num, :payment_hold, :amount_remaining
15
15
 
16
16
  field :custom_field_list, CustomFieldList
17
17
  field :expense_list, VendorBillExpenseList
@@ -25,6 +25,7 @@ module NetSuite
25
25
 
26
26
  attr_reader :internal_id
27
27
  attr_accessor :external_id
28
+ attr_accessor :search_joins
28
29
 
29
30
  def initialize(attributes = {})
30
31
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -214,33 +214,21 @@ module NetSuite
214
214
  DataCenter.get(*args)
215
215
  end
216
216
 
217
- # Warning this was developed with a Web Services user whose time zone was set to CST
218
- # the time zone setting of the user seems to effect how times work in NS
219
-
220
- # modifying time without rails:
221
- # http://stackoverflow.com/questions/238684/subtract-n-hours-from-a-datetime-in-ruby
222
-
223
- # converting between time and datetime:
224
- # http://stackoverflow.com/questions/279769/convert-to-from-datetime-and-time-in-ruby
225
-
226
- # use when sending times to NS
227
- def normalize_datetime_to_netsuite(datetime)
228
- # normalize the time to UCT0
229
- # add 6 hours (21600 seconds) of padding (CST offset)
230
- # to force the same time to be displayed in the NS UI
231
-
232
- is_dst = Time.parse(datetime.to_s).dst?
233
-
234
- datetime.new_offset(0) + datetime.offset + Rational(is_dst ? 5 : 6, 24)
235
- end
236
-
237
- # use when displaying times from a NS record
238
- def normalize_datetime_from_netsuite(datetime)
239
- # the code below eliminates the TimeZone offset then shifts the date forward 2 hours (7200 seconds)
240
- # this ensures that ActiveRecord is given a UTC0 DateTime with the exact hour that
241
- # was displayed in the NS UI (CST time zone), which will result in the correct display on the web side
217
+ # http://mikebian.co/notes-on-dates-timezones-with-netsuites-suitetalk-api/
218
+ # assumes input is UTC0 unix timestamp
219
+ def normalize_time_to_netsuite_date(unix_timestamp)
220
+ # convert to date to eliminate hr/min/sec
221
+ time = Time.at(unix_timestamp).utc.to_date.to_datetime
222
+
223
+ offset = 8
224
+ time = time.new_offset("-08:00")
225
+
226
+ if time.to_time.dst?
227
+ offset = 7
228
+ time = time.new_offset("-07:00")
229
+ end
242
230
 
243
- datetime.new_offset(0) + datetime.offset + Rational(2, 24)
231
+ (time + Rational(offset, 24)).iso8601
244
232
  end
245
233
 
246
234
  end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.7.9'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -4,6 +4,8 @@ describe 'basic records' do
4
4
  let(:basic_record_list) {
5
5
  [
6
6
  NetSuite::Records::Currency,
7
+ NetSuite::Records::CashSale,
8
+ NetSuite::Records::CashRefund,
7
9
  NetSuite::Records::Location,
8
10
  NetSuite::Records::JobStatus,
9
11
  NetSuite::Records::TimeBill,
@@ -46,7 +48,11 @@ describe 'basic records' do
46
48
  NetSuite::Records::SerializedInventoryItem,
47
49
  NetSuite::Records::DepositApplication,
48
50
  NetSuite::Records::InventoryAdjustment,
49
- NetSuite::Records::VendorReturnAuthorization
51
+ NetSuite::Records::VendorReturnAuthorization,
52
+ NetSuite::Records::AssemblyBuild,
53
+ NetSuite::Records::AssemblyUnbuild,
54
+ NetSuite::Records::AssemblyComponent,
55
+ NetSuite::Records::InventoryNumber
50
56
  ]
51
57
  }
52
58
 
@@ -6,7 +6,7 @@ describe NetSuite::Records::CustomFieldList do
6
6
  it 'has a custom_fields attribute' do
7
7
  expect(list.custom_fields).to be_kind_of(Array)
8
8
  end
9
-
9
+
10
10
  it 'accepts a collection of CustomField records' do
11
11
  field = NetSuite::Records::CustomField.new({:value=>{:internal_id=>"5", :type_id=>"103"},
12
12
  :script_id=>"custitem_item_category", :"@xsi:type"=>"platformCore:SelectCustomFieldRef"})
@@ -41,6 +41,12 @@ describe NetSuite::Records::CustomFieldList do
41
41
  list.custom_fields.first.value.should == 'a value'
42
42
  list.custom_fields.first.type.should == 'platformCore:StringCustomFieldRef'
43
43
  end
44
+
45
+ # https://github.com/NetSweet/netsuite/issues/325
46
+ it 'should create a custom field entry when some fields exist without scriptIds' do
47
+ list.custom_fields << NetSuite::Records::CustomField.new
48
+ list.custrecord_somefield = 123
49
+ end
44
50
  end
45
51
 
46
52
  context 'custom field internalId-to-scriptId transition at WSDL 2013_2:' do
@@ -19,6 +19,27 @@ describe NetSuite::Records::InventoryTransfer do
19
19
  end
20
20
  end
21
21
 
22
+ describe '#to_record' do
23
+ it 'includes the inventory_list' do
24
+ attributes = {
25
+ :inventory => [{
26
+ :inventory_detail => {
27
+ :custom_form => {
28
+ internal_id: 1
29
+ },
30
+ :inventory_assignment_list => {
31
+ :inventory_assignment => [{
32
+ quantity: 3
33
+ }]
34
+ }
35
+ }
36
+ }]
37
+ }
38
+ inventory_transfer.inventory_list = attributes
39
+ list = inventory_transfer.to_record.fetch("tranInvt:inventoryList").fetch("tranInvt:inventory")
40
+ expect(list.count).to eq(1)
41
+ end
42
+ end
22
43
 
23
44
  describe '#inventory_list' do
24
45
  it 'can be set from attributes' do
@@ -16,7 +16,7 @@ describe NetSuite::Records::Invoice do
16
16
  :exp_cost_tax_rate_2, :fax, :fob, :gift_cert_redemption_list, :handling_tax_1_rate,
17
17
  :handling_tax_2_rate, :handling_tax_code, :is_taxable, :item_cost_disc_amount, :item_cost_disc_print,
18
18
  :item_cost_disc_rate, :item_cost_disc_tax_1_amt, :item_cost_disc_taxable, :item_cost_discount, :item_cost_list,
19
- :item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :job, :last_modified_date,
19
+ :item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :last_modified_date,
20
20
  :linked_tracking_numbers, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
21
21
  :other_ref_num, :partners_list, :rev_rec_end_date,
22
22
  :rev_rec_on_rev_commitment, :rev_rec_schedule, :rev_rec_start_date, :revenue_status, :sales_effective_date,
@@ -43,7 +43,7 @@ describe NetSuite::Records::Invoice do
43
43
 
44
44
  it 'has the right record_refs' do
45
45
  [
46
- :account, :bill_address_list, :custom_form, :department, :entity, :klass, :posting_period, :ship_address_list, :terms,
46
+ :account, :bill_address_list, :job, :custom_form, :department, :entity, :klass, :posting_period, :ship_address_list, :terms,
47
47
  :created_from, :location, :sales_rep, :ship_method, :tax_item, :partner, :lead_source, :promo_code, :subsidiary
48
48
  ].each do |record_ref|
49
49
  expect(invoice).to have_record_ref(record_ref)
@@ -1,6 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Utilities do
4
+ describe 'time utilities' do
5
+ it '#normalize_time_to_netsuite_date' do
6
+ stamp = DateTime.parse('Wed, 27 Jul 2016 00:00:00 -0000')
7
+ formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(stamp.to_time.to_i)
8
+ expect(formatted_date).to eq('2016-07-27T00:00:00-07:00')
9
+
10
+ no_dst_stamp = DateTime.parse('Sun, November 6 2017 00:00:00 -0000')
11
+ formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(no_dst_stamp.to_time.to_i)
12
+ expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
13
+ end
14
+ end
15
+
4
16
  describe '#get_record' do
5
17
  context 'caching' do
6
18
  it 'does not hit the netsuite API' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsuite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-21 00:00:00.000000000 Z
12
+ date: 2017-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -97,7 +97,11 @@ files:
97
97
  - lib/netsuite/records/account.rb
98
98
  - lib/netsuite/records/accounting_period.rb
99
99
  - lib/netsuite/records/address.rb
100
+ - lib/netsuite/records/assembly_build.rb
101
+ - lib/netsuite/records/assembly_component.rb
102
+ - lib/netsuite/records/assembly_component_list.rb
100
103
  - lib/netsuite/records/assembly_item.rb
104
+ - lib/netsuite/records/assembly_unbuild.rb
101
105
  - lib/netsuite/records/base_ref_list.rb
102
106
  - lib/netsuite/records/bill_address.rb
103
107
  - lib/netsuite/records/billing_schedule.rb
@@ -142,6 +146,8 @@ files:
142
146
  - lib/netsuite/records/customer_currency.rb
143
147
  - lib/netsuite/records/customer_currency_list.rb
144
148
  - lib/netsuite/records/customer_deposit.rb
149
+ - lib/netsuite/records/customer_deposit_apply.rb
150
+ - lib/netsuite/records/customer_deposit_apply_list.rb
145
151
  - lib/netsuite/records/customer_partner.rb
146
152
  - lib/netsuite/records/customer_partners_list.rb
147
153
  - lib/netsuite/records/customer_payment.rb
@@ -178,6 +184,9 @@ files:
178
184
  - lib/netsuite/records/inventory_assignment_list.rb
179
185
  - lib/netsuite/records/inventory_detail.rb
180
186
  - lib/netsuite/records/inventory_item.rb
187
+ - lib/netsuite/records/inventory_number.rb
188
+ - lib/netsuite/records/inventory_number_locations.rb
189
+ - lib/netsuite/records/inventory_number_locations_list.rb
181
190
  - lib/netsuite/records/inventory_transfer.rb
182
191
  - lib/netsuite/records/inventory_transfer_inventory.rb
183
192
  - lib/netsuite/records/inventory_transfer_inventory_list.rb
@@ -239,6 +248,10 @@ files:
239
248
  - lib/netsuite/records/sales_order_ship_group_list.rb
240
249
  - lib/netsuite/records/sales_tax_item.rb
241
250
  - lib/netsuite/records/serialized_inventory_item.rb
251
+ - lib/netsuite/records/serialized_inventory_item_location.rb
252
+ - lib/netsuite/records/serialized_inventory_item_locations_list.rb
253
+ - lib/netsuite/records/serialized_inventory_item_numbers.rb
254
+ - lib/netsuite/records/serialized_inventory_item_numbers_list.rb
242
255
  - lib/netsuite/records/service_resale_item.rb
243
256
  - lib/netsuite/records/service_sale_item.rb
244
257
  - lib/netsuite/records/ship_address.rb
@@ -484,7 +497,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
484
497
  version: '0'
485
498
  requirements: []
486
499
  rubyforge_project:
487
- rubygems_version: 2.5.1
500
+ rubygems_version: 2.6.8
488
501
  signing_key:
489
502
  specification_version: 4
490
503
  summary: NetSuite SuiteTalk API (SOAP) Wrapper