netsuite 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +28 -11
- data/lib/netsuite.rb +5 -0
- data/lib/netsuite/configuration.rb +14 -1
- data/lib/netsuite/records/purchase_order.rb +52 -0
- data/lib/netsuite/records/purchase_order_item.rb +42 -0
- data/lib/netsuite/records/purchase_order_item_list.rb +11 -0
- data/lib/netsuite/records/sales_order_item.rb +0 -3
- data/lib/netsuite/records/transfer_order.rb +2 -2
- data/lib/netsuite/records/transfer_order_item.rb +43 -0
- data/lib/netsuite/records/transfer_order_item_list.rb +11 -0
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/configuration_spec.rb +12 -0
- data/spec/netsuite/records/basic_record_spec.rb +1 -0
- metadata +7 -2
data/README.md
CHANGED
@@ -7,24 +7,22 @@
|
|
7
7
|
|
8
8
|
* This gem will act as a wrapper around the NetSuite SuiteTalk WebServices API. Wow, that is a mouthful.
|
9
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
|
10
|
+
* Extending the wrapper is pretty simple, check out recent commits for an example of how to add support for additional records.
|
11
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.
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
Add this line to your application's Gemfile:
|
13
|
+
# Help & Support
|
16
14
|
|
17
|
-
|
15
|
+
Join the [slack channel](http://opensuite-slackin.herokuapp.com) for help with any NetSuite issues.
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
$ bundle
|
17
|
+
## Installation
|
22
18
|
|
23
|
-
|
19
|
+
Add this line to your application's Gemfile:
|
24
20
|
|
25
|
-
|
21
|
+
```
|
22
|
+
gem 'netsuite'
|
23
|
+
```
|
26
24
|
|
27
|
-
This gem is built for ruby 1.9.x
|
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.
|
28
26
|
|
29
27
|
## Testing
|
30
28
|
Before contributing a patch make sure all existing tests pass.
|
@@ -32,6 +30,7 @@ Before contributing a patch make sure all existing tests pass.
|
|
32
30
|
```
|
33
31
|
git clone git://github.com/NetSweet/netsuite.git
|
34
32
|
cd netsuite
|
33
|
+
|
35
34
|
bundle
|
36
35
|
bundle exec rspec
|
37
36
|
```
|
@@ -74,6 +73,21 @@ end
|
|
74
73
|
|
75
74
|
There is a [convenience method](https://github.com/NetSweet/netsuite/blob/56fe7fae92908a2e3d6812ecc56516f773cacd45/lib/netsuite.rb#L180) to configure NetSuite based on ENV variables.
|
76
75
|
|
76
|
+
OAuth credentials are also supported:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
NetSuite.configure do
|
80
|
+
reset!
|
81
|
+
|
82
|
+
account ENV['NETSUITE_ACCOUNT']
|
83
|
+
|
84
|
+
consumer_key ENV['NETSUITE_CONSUMER_KEY']
|
85
|
+
consumer_secret ENV['NETSUITE_CONSUMER_SECRET']
|
86
|
+
token_id ENV['NETSUITE_TOKEN_ID']
|
87
|
+
token_secret ENV['NETSUITE_TOKEN_SECRET']
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
77
91
|
### Examples
|
78
92
|
|
79
93
|
#### CRUD Operations
|
@@ -377,6 +391,9 @@ search.results_in_batches do |batch|
|
|
377
391
|
puts batch.map(&:internal_id)
|
378
392
|
end
|
379
393
|
|
394
|
+
# search on transaction status
|
395
|
+
NetSuite::Records::InventoryItem
|
396
|
+
|
380
397
|
# item search
|
381
398
|
NetSuite::Records::InventoryItem.search({
|
382
399
|
criteria: {
|
data/lib/netsuite.rb
CHANGED
@@ -167,6 +167,9 @@ module NetSuite
|
|
167
167
|
autoload :PhoneCall, 'netsuite/records/phone_call'
|
168
168
|
autoload :PricingMatrix, 'netsuite/records/pricing_matrix'
|
169
169
|
autoload :PromotionCode, 'netsuite/records/promotion_code'
|
170
|
+
autoload :PurchaseOrder, 'netsuite/records/purchase_order'
|
171
|
+
autoload :PurchaseOrderItemList, 'netsuite/records/purchase_order_item_list'
|
172
|
+
autoload :PurchaseOrderItem, 'netsuite/records/purchase_order_item'
|
170
173
|
autoload :Roles, 'netsuite/records/roles'
|
171
174
|
autoload :RecordRef, 'netsuite/records/record_ref'
|
172
175
|
autoload :RecordRefList, 'netsuite/records/record_ref_list'
|
@@ -190,6 +193,8 @@ module NetSuite
|
|
190
193
|
autoload :TimeBill, 'netsuite/records/time_bill'
|
191
194
|
autoload :Transaction, 'netsuite/records/transaction'
|
192
195
|
autoload :TransferOrder, 'netsuite/records/transfer_order'
|
196
|
+
autoload :TransferOrderItemList, 'netsuite/records/transfer_order_item_list'
|
197
|
+
autoload :TransferOrderItem, 'netsuite/records/transfer_order_item'
|
193
198
|
autoload :UnitsType, 'netsuite/records/units_type'
|
194
199
|
autoload :UnitsTypeUomList, 'netsuite/records/units_type_uom_list'
|
195
200
|
autoload :UnitsTypeUom, 'netsuite/records/units_type_uom'
|
@@ -17,12 +17,25 @@ module NetSuite
|
|
17
17
|
namespaces: namespaces,
|
18
18
|
soap_header: auth_header(credentials).update(soap_header),
|
19
19
|
pretty_print_xml: true,
|
20
|
+
filters: filters,
|
20
21
|
logger: logger,
|
21
22
|
log_level: log_level,
|
22
|
-
log: !silent,
|
23
|
+
log: !silent, # turn off logging entirely if configured
|
23
24
|
}.update(params))
|
24
25
|
end
|
25
26
|
|
27
|
+
def filters(list = nil)
|
28
|
+
if list
|
29
|
+
self.filters = list
|
30
|
+
else
|
31
|
+
attributes[:filters] ||= [:password, :email]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def filters=(list)
|
36
|
+
attributes[:filters] = list
|
37
|
+
end
|
38
|
+
|
26
39
|
def api_version(version = nil)
|
27
40
|
if version
|
28
41
|
self.api_version = version
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class PurchaseOrder
|
4
|
+
include Support::Fields
|
5
|
+
include Support::RecordRefs
|
6
|
+
include Support::Records
|
7
|
+
include Support::Actions
|
8
|
+
include Namespaces::TranPurch
|
9
|
+
|
10
|
+
actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search
|
11
|
+
|
12
|
+
fields :created_date, :currency_name, :due_date, :email, :exchange_rate,
|
13
|
+
:fax, :fob, :interco_status, :interco_transaction, :last_modified_date,
|
14
|
+
:linked_tracking_numbers, :memo, :message, :other_ref_num, :ship_date,
|
15
|
+
:ship_is_residential, :ship_to, :source, :status, :sub_total, :supervisor_approval,
|
16
|
+
:tax2_total, :tax_total, :to_be_emailed, :to_be_faxed, :to_be_printed,
|
17
|
+
:total, :tracking_numbers, :tran_date, :tran_id, :vat_reg_num
|
18
|
+
|
19
|
+
field :billing_address, Address
|
20
|
+
field :shipping_address, Address
|
21
|
+
field :custom_field_list, CustomFieldList
|
22
|
+
field :item_list, PurchaseOrderItemList
|
23
|
+
|
24
|
+
# TODO custom lists
|
25
|
+
# :ship_address_list
|
26
|
+
# :expense_list
|
27
|
+
|
28
|
+
record_refs :approval_status, :bill_address_list, :klass, :created_from, :currency,
|
29
|
+
:custom_form, :department, :employee, :entity, :location, :next_approver,
|
30
|
+
:order_status, :purchase_contract, :ship_method, :subsidiary, :terms
|
31
|
+
|
32
|
+
attr_reader :internal_id
|
33
|
+
attr_accessor :external_id
|
34
|
+
attr_accessor :search_joins
|
35
|
+
|
36
|
+
def initialize(attributes = {})
|
37
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
38
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
39
|
+
initialize_from_attributes_hash(attributes)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.search_class_name
|
43
|
+
"Transaction"
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.search_class_namespace
|
47
|
+
'tranSales'
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class PurchaseOrderItem
|
4
|
+
include Support::Fields
|
5
|
+
include Support::RecordRefs
|
6
|
+
include Support::Records
|
7
|
+
include Namespaces::TranPurch
|
8
|
+
|
9
|
+
fields :amount, :description, :expected_receipt_date, :gross_amt, :is_billable,
|
10
|
+
:is_closed, :line, :match_bill_to_receipt, :quantity, :quantity_available,
|
11
|
+
:quantity_billed, :quantity_on_hand, :quantity_received, :rate, :serial_numbers,
|
12
|
+
:tax1_amt, :tax_rate1, :tax_rate2, :vendor_name
|
13
|
+
|
14
|
+
field :custom_field_list, CustomFieldList
|
15
|
+
|
16
|
+
record_refs :bill_variance_status, :klass, :created_from, :customer, :department,
|
17
|
+
:inventory_detail, :item, :landed_cost_category, :linked_order_list,
|
18
|
+
:location, :options, :purchase_contract, :tax_code, :units
|
19
|
+
|
20
|
+
def initialize(attributes_or_record = {})
|
21
|
+
case attributes_or_record
|
22
|
+
when Hash
|
23
|
+
initialize_from_attributes_hash(attributes_or_record)
|
24
|
+
when self.class
|
25
|
+
initialize_from_record(attributes_or_record)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize_from_record(record)
|
30
|
+
self.attributes = record.send(:attributes)
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_record
|
34
|
+
rec = super
|
35
|
+
if rec["#{record_namespace}:customFieldList"]
|
36
|
+
rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
|
37
|
+
end
|
38
|
+
rec
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -1,8 +1,5 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
# Beaware of possible gotcha when closing sales order. You need to set the
|
4
|
-
# SalesOrder#custom_form to "Basic Sales Order Form" otherwise you might get
|
5
|
-
# errors when trying to close it
|
6
3
|
class SalesOrderItem
|
7
4
|
include Support::Fields
|
8
5
|
include Support::RecordRefs
|
@@ -19,8 +19,8 @@ module NetSuite
|
|
19
19
|
:ship_method, :order_status, :employee, :handling_tax_code,
|
20
20
|
:location, :custom_form, :department, :klass, :ship_address_list
|
21
21
|
|
22
|
-
field :custom_field_list,
|
23
|
-
|
22
|
+
field :custom_field_list, CustomFieldList
|
23
|
+
field :item_list, TransferOrderItemList
|
24
24
|
|
25
25
|
attr_reader :internal_id
|
26
26
|
attr_accessor :external_id
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class TransferOrderItem
|
4
|
+
include Support::Fields
|
5
|
+
include Support::RecordRefs
|
6
|
+
include Support::Records
|
7
|
+
include Namespaces::TranInvt
|
8
|
+
|
9
|
+
fields :amount, :average_cost, :klass, :commit_inventory, :description,
|
10
|
+
:expected_receipt_date, :expected_ship_date, :is_closed, :last_purchase_price,
|
11
|
+
:line, :options, :order_priority, :quantity, :quantity_available,
|
12
|
+
:quantity_back_ordered, :quantity_committed, :quantity_fulfilled,
|
13
|
+
:quantity_on_hand, :quantity_packed, :quantity_picked, :quantity_received,
|
14
|
+
:rate, :serial_numbers
|
15
|
+
|
16
|
+
field :options, CustomFieldList
|
17
|
+
field :custom_field_list, CustomFieldList
|
18
|
+
|
19
|
+
record_refs :department, :inventory_detail, :item, :units
|
20
|
+
|
21
|
+
def initialize(attributes_or_record = {})
|
22
|
+
case attributes_or_record
|
23
|
+
when Hash
|
24
|
+
initialize_from_attributes_hash(attributes_or_record)
|
25
|
+
when self.class
|
26
|
+
initialize_from_record(attributes_or_record)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize_from_record(record)
|
31
|
+
self.attributes = record.send(:attributes)
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_record
|
35
|
+
rec = super
|
36
|
+
if rec["#{record_namespace}:customFieldList"]
|
37
|
+
rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
|
38
|
+
end
|
39
|
+
rec
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/netsuite/version.rb
CHANGED
@@ -16,6 +16,18 @@ describe NetSuite::Configuration do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
describe '#filters' do
|
20
|
+
it 'filters out email and password by default' do
|
21
|
+
expect(config.filters).to eq([:password, :email])
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'allows the user to set custom filters' do
|
25
|
+
config.filters([:special])
|
26
|
+
|
27
|
+
expect(config.filters).to eq([:special])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
19
31
|
describe '#connection' do
|
20
32
|
it 'returns a Savon::Client object that allows requests to the service' do
|
21
33
|
# reset clears out the password info
|
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.6.
|
4
|
+
version: 0.6.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-05-
|
13
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: savon
|
@@ -205,6 +205,9 @@ files:
|
|
205
205
|
- lib/netsuite/records/phone_call.rb
|
206
206
|
- lib/netsuite/records/pricing_matrix.rb
|
207
207
|
- lib/netsuite/records/promotion_code.rb
|
208
|
+
- lib/netsuite/records/purchase_order.rb
|
209
|
+
- lib/netsuite/records/purchase_order_item.rb
|
210
|
+
- lib/netsuite/records/purchase_order_item_list.rb
|
208
211
|
- lib/netsuite/records/record_ref.rb
|
209
212
|
- lib/netsuite/records/record_ref_list.rb
|
210
213
|
- lib/netsuite/records/rev_rec_schedule.rb
|
@@ -227,6 +230,8 @@ files:
|
|
227
230
|
- lib/netsuite/records/term.rb
|
228
231
|
- lib/netsuite/records/time_bill.rb
|
229
232
|
- lib/netsuite/records/transfer_order.rb
|
233
|
+
- lib/netsuite/records/transfer_order_item.rb
|
234
|
+
- lib/netsuite/records/transfer_order_item_list.rb
|
230
235
|
- lib/netsuite/records/units_type.rb
|
231
236
|
- lib/netsuite/records/units_type_uom.rb
|
232
237
|
- lib/netsuite/records/units_type_uom_list.rb
|