netsuite 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06cedbc327be3be9dc71bbed933d03cf7351f7bc
4
- data.tar.gz: 468fd51d45565c586380bea58c8013d0070c8050
3
+ metadata.gz: c137a01aff81975a25856d832bc61d90b37468c5
4
+ data.tar.gz: afbbaf1726823511a72bef89702f09011c87ceb0
5
5
  SHA512:
6
- metadata.gz: ab0c469a17de1c1c98fb793f7f986c0cbb6c10848d065f63b2b7865e3af1a5d245a7c24d4871929eafc0aee92a003bc3a26eaf8e688db91f66d3ed7c5137ead2
7
- data.tar.gz: 4ffdda3b662d8bd0937fb0b0a58072da952a61dcb162f2dac8a1d55c5b3a3e8481b0ede1c9417724646c708481b5f6477fe9e208bfa4cecdad8c590b67fe7a4c
6
+ metadata.gz: ec904bf4c128f98da10e50688e3b2ffbfc81fe933c96001fce48f9e9788c1d2df5067206ce19a129296930447b8560de4204776f3c8da4489676c4d57a88be68
7
+ data.tar.gz: 8b1d944d17d8af49ce0fee65a965166766e50645ee1c3c759c8178fcfbb094f22e5d83f83cb1e1a8b15a3c614a84630cd5ab15acff64574d77fb5094264ba62f
@@ -105,6 +105,7 @@ module NetSuite
105
105
  autoload :SalesOrder, 'netsuite/records/sales_order'
106
106
  autoload :SalesOrderItem, 'netsuite/records/sales_order_item'
107
107
  autoload :SalesOrderItemList, 'netsuite/records/sales_order_item_list'
108
+ autoload :ServiceSaleItem, 'netsuite/records/service_sale_item'
108
109
  autoload :ShipAddress, 'netsuite/records/ship_address'
109
110
  autoload :SupportCase, 'netsuite/records/support_case'
110
111
  autoload :Task, 'netsuite/records/task'
@@ -5,8 +5,9 @@ module NetSuite
5
5
  include Support::RecordRefs
6
6
  include Support::Records
7
7
  include Support::Actions
8
+ include Namespaces::ListAcct
8
9
 
9
- actions :get, :add, :delete
10
+ actions :get, :add, :delete, :search
10
11
 
11
12
  fields :acct_name, :acct_number, :acct_type, :cash_flow_rate, :cur_doc_num, :description, :eliminate, :exchange_rate,
12
13
  :general_rate, :include_children, :inventory, :is_inactive, :opening_balance, :revalue, :tran_date
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListRel
9
9
 
10
- actions :get, :add, :delete, :search
10
+ actions :get, :add, :delete, :search, :update
11
11
 
12
12
  fields :salutation, :first_name, :middle_name, :last_name, :title, :phone, :fax, :email, :default_address,
13
13
  :entity_id, :phonetic_name, :alt_email, :office_phone, :home_phone, :mobile_phone, :supervisor_phone,
@@ -17,7 +17,7 @@ module NetSuite
17
17
 
18
18
  actions :add, :get
19
19
 
20
- fields :custom_form, :payment, :tran_date, :exchange_rate
20
+ fields :custom_form, :payment, :tran_date, :exchange_rate, :undep_funds
21
21
 
22
22
  record_refs :customer, :sales_order, :account
23
23
 
@@ -1,13 +1,42 @@
1
1
  module NetSuite
2
2
  module Records
3
3
  class MatrixOptionList
4
+ # Deals with both hash and arrays of attributes[:matrix_option_list]
5
+ #
6
+ # Hash:
7
+ #
8
+ # <listAcct:matrixOptionList>
9
+ # <listAcct:matrixOption internalId="47" scriptId="custitem15">
10
+ # <platformCore:value internalId="2" typeId="36"/>
11
+ # </listAcct:matrixOption>
12
+ # </listAcct:matrixOptionList>
13
+ #
14
+ # Array:
15
+ #
16
+ # <listAcct:matrixOptionList>
17
+ # <listAcct:matrixOption internalId="45" scriptId="custitem13">
18
+ # <platformCore:value internalId="4" typeId="28"/>
19
+ # </listAcct:matrixOption>
20
+ # <listAcct:matrixOption internalId="46" scriptId="custitem14">
21
+ # <platformCore:value internalId="1" typeId="29"/>
22
+ # </listAcct:matrixOption>
23
+ # </listAcct:matrixOptionList>
24
+ #
4
25
  def initialize(attributes = {})
5
- attributes[:matrix_option].each do |option|
26
+ case attributes[:matrix_option]
27
+ when Hash
6
28
  options << OpenStruct.new(
7
- type_id: option[:value][:'@type_id'],
8
- value_id: option[:value][:'@internal_id']
29
+ type_id: attributes[:matrix_option][:value][:'@type_id'],
30
+ value_id: attributes[:matrix_option][:value][:'@internal_id']
9
31
  )
10
- end if attributes[:matrix_option]
32
+ when Array
33
+ attributes[:matrix_option].each do |option|
34
+ options << OpenStruct.new(
35
+ type_id: option[:value][:'@type_id'],
36
+ value_id: option[:value][:'@internal_id']
37
+ )
38
+ end
39
+ end
11
40
  end
12
41
 
13
42
  def options
@@ -1,5 +1,8 @@
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
3
6
  class SalesOrderItem
4
7
  include Support::Fields
5
8
  include Support::RecordRefs
@@ -10,7 +13,7 @@ module NetSuite
10
13
  :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email, :gift_cert_recipient_name, :gross_amt, :is_taxable,
11
14
  :line, :order_line, :quantity, :rate, :rev_rec_end_date, :rev_rec_start_date, :rev_rec_term_in_months, :serial_numbers,
12
15
  :shipping_cost, :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered,
13
- :vsoe_permit_discount, :vsoe_price
16
+ :vsoe_permit_discount, :vsoe_price, :is_closed
14
17
 
15
18
  field :custom_field_list, CustomFieldList
16
19
 
@@ -36,7 +39,6 @@ module NetSuite
36
39
  end
37
40
  rec
38
41
  end
39
-
40
42
  end
41
43
  end
42
44
  end
@@ -0,0 +1,45 @@
1
+ module NetSuite
2
+ module Records
3
+ class ServiceSaleItem
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Support::Actions
8
+ include Namespaces::ListAcct
9
+
10
+ actions :get, :add, :delete
11
+
12
+ fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date,
13
+ :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description,
14
+ :include_children, :is_donation_item, :is_fulfillable, :is_gco_compliant, :is_inactive, :is_online, :is_taxable,
15
+ :item_id, :last_modified_date, :matrix_option_list, :matrix_type, :max_donation_amount, :meta_tag_html,
16
+ :minimum_quantity, :minimum_quantity_units, :no_price_message, :offer_support, :on_special, :out_of_stock_behavior,
17
+ :out_of_stock_message, :overall_quantity_pricing_type, :page_title, :presentation_item_list, :prices_include_tax,
18
+ :pricing_matrix, :rate, :related_items_description, :sales_description, :search_keywords,
19
+ :show_default_donation_amount, :site_category_list, :sitemap_priority, :soft_descriptor, :specials_description,
20
+ :store_description, :store_detailed_description, :store_display_name, :translations_list, :upc_code, :url_component,
21
+ :use_marginal_rates, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :vsoe_sop_group
22
+
23
+ # item_task_templates_list
24
+ # billing_rates_matrix -- RecordRef, via listAcct::ItemOptionsList
25
+
26
+ record_refs :billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_account,
27
+ :issue_product, :item_options_list, :klass, :location, :parent, :pricing_group, :purchase_tax_code,
28
+ :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :store_display_image,
29
+ :store_display_thumbnail, :store_item_template, :subsidiary_list, :tax_schedule, :units_type
30
+
31
+ field :pricing_matrix, PricingMatrix
32
+ field :custom_field_list, CustomFieldList
33
+
34
+ attr_reader :internal_id
35
+ attr_accessor :external_id
36
+
37
+ def initialize(attributes = {})
38
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
39
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
40
+ initialize_from_attributes_hash(attributes)
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -3,9 +3,9 @@ require File.expand_path('../lib/netsuite/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ['Ryan Moran', 'Michael Bianco']
6
- gem.email = ['ryan.moran@gmail.com', 'info@cliffsidedev.com']
6
+ gem.email = ['ryan.moran@gmail.com', 'mike@cliffsidemedia.com']
7
7
  gem.description = %q{NetSuite SuiteTalk API Wrapper}
8
- gem.summary = %q{NetSuite SuiteTalk API Wrapper}
8
+ gem.summary = %q{NetSuite SuiteTalk API (SOAP) Wrapper}
9
9
  gem.homepage = 'https://github.com/RevolutionPrep/netsuite'
10
10
 
11
11
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'ostruct'
3
+
4
+ module NetSuite
5
+ module Records
6
+ describe MatrixOptionList do
7
+ it "deals with hash properly" do
8
+ hash = {:value=>{:@internal_id=>"1", :@type_id=>"36"}}
9
+
10
+ list = described_class.new({ matrix_option: hash })
11
+ expect(list.options.first.value_id).to eq "1"
12
+ end
13
+
14
+ it "deals with arrays properly" do
15
+ array = [
16
+ {:value=>{:@internal_id=>"2", :@type_id=>"28"}},
17
+ {:value=>{:@internal_id=>"1", :@type_id=>"29"}}
18
+ ]
19
+
20
+ list = described_class.new({ matrix_option: array })
21
+ expect(list.options.first.value_id).to eq "2"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -203,4 +203,15 @@ describe NetSuite::Records::SalesOrder do
203
203
  end
204
204
  end
205
205
 
206
+ pending "closing a sales order" do
207
+ it "closes each line to close the sales order" do
208
+ attributes = sales_order.attributes
209
+ attributes[:item_list].items.each do |item|
210
+ item.is_closed = true
211
+ item.attributes = item.attributes.slice(:line, :is_closed)
212
+ end
213
+
214
+ sales_order.update({ item_list: attributes[:item_list] })
215
+ end
216
+ end
206
217
  end
@@ -0,0 +1,134 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ServiceSaleItem do
4
+ let(:item) { NetSuite::Records::ServiceSaleItem.new }
5
+
6
+ it 'has the right fields' do
7
+ [
8
+ :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date,
9
+ :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description,
10
+ :include_children, :is_donation_item, :is_fulfillable, :is_gco_compliant, :is_inactive, :is_online, :is_taxable,
11
+ :item_id, :last_modified_date, :matrix_option_list, :matrix_type, :max_donation_amount, :meta_tag_html,
12
+ :minimum_quantity, :minimum_quantity_units, :no_price_message, :offer_support, :on_special, :out_of_stock_behavior,
13
+ :out_of_stock_message, :overall_quantity_pricing_type, :page_title, :presentation_item_list, :prices_include_tax,
14
+ :rate, :related_items_description, :sales_description, :search_keywords,
15
+ :show_default_donation_amount, :site_category_list, :sitemap_priority, :soft_descriptor, :specials_description,
16
+ :store_description, :store_detailed_description, :store_display_name, :translations_list, :upc_code, :url_component,
17
+ :use_marginal_rates, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :vsoe_sop_group
18
+ ].each do |field|
19
+ item.should have_field(field)
20
+ end
21
+
22
+ # TODO there is a probably a more robust way to test this
23
+ item.custom_field_list.class.should == NetSuite::Records::CustomFieldList
24
+ item.pricing_matrix.class.should == NetSuite::Records::PricingMatrix
25
+ end
26
+
27
+ it 'has the right record_refs' do
28
+ [
29
+ :billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_account,
30
+ :issue_product, :item_options_list, :klass, :location, :parent, :pricing_group, :purchase_tax_code,
31
+ :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :store_display_image,
32
+ :store_display_thumbnail, :store_item_template, :subsidiary_list, :tax_schedule, :units_type
33
+ ].each do |record_ref|
34
+ item.should have_record_ref(record_ref)
35
+ end
36
+ end
37
+
38
+ describe '.get' do
39
+ context 'when the response is successful' do
40
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :item_id => 'penguins' }) }
41
+
42
+ it 'returns a ServiceSaleItem instance populated with the data from the response object' do
43
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::ServiceSaleItem, :external_id => 20).and_return(response)
44
+ customer = NetSuite::Records::ServiceSaleItem.get(:external_id => 20)
45
+ customer.should be_kind_of(NetSuite::Records::ServiceSaleItem)
46
+ customer.item_id.should eql('penguins')
47
+ end
48
+ end
49
+
50
+ context 'when the response is unsuccessful' do
51
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
52
+
53
+ it 'raises a RecordNotFound exception' do
54
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::ServiceSaleItem, :external_id => 20).and_return(response)
55
+ lambda {
56
+ NetSuite::Records::ServiceSaleItem.get(:external_id => 20)
57
+ }.should raise_error(NetSuite::RecordNotFound,
58
+ /NetSuite::Records::ServiceSaleItem with OPTIONS=(.*) could not be found/)
59
+ end
60
+ end
61
+ end
62
+
63
+ describe '#add' do
64
+ # let(:item) { NetSuite::Records::ServiceSaleItem.new(:cost => 100, :is_inactive => false) }
65
+
66
+ context 'when the response is successful' do
67
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
68
+
69
+ it 'returns true' do
70
+ NetSuite::Actions::Add.should_receive(:call).
71
+ with(item).
72
+ and_return(response)
73
+ item.add.should be_true
74
+ end
75
+ end
76
+
77
+ context 'when the response is unsuccessful' do
78
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
79
+
80
+ it 'returns false' do
81
+ NetSuite::Actions::Add.should_receive(:call).
82
+ with(item).
83
+ and_return(response)
84
+ item.add.should be_false
85
+ end
86
+ end
87
+ end
88
+
89
+ describe '#delete' do
90
+ context 'when the response is successful' do
91
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
92
+
93
+ it 'returns true' do
94
+ NetSuite::Actions::Delete.should_receive(:call).
95
+ with(item).
96
+ and_return(response)
97
+ item.delete.should be_true
98
+ end
99
+ end
100
+
101
+ context 'when the response is unsuccessful' do
102
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
103
+
104
+ it 'returns false' do
105
+ NetSuite::Actions::Delete.should_receive(:call).
106
+ with(item).
107
+ and_return(response)
108
+ item.delete.should be_false
109
+ end
110
+ end
111
+ end
112
+
113
+ describe '#to_record' do
114
+ before do
115
+ item.item_id = 'penguins'
116
+ item.is_online = true
117
+ end
118
+
119
+ it 'can represent itself as a SOAP record' do
120
+ record = {
121
+ 'listAcct:itemId' => 'penguins',
122
+ 'listAcct:isOnline' => true
123
+ }
124
+ item.to_record.should eql(record)
125
+ end
126
+ end
127
+
128
+ describe '#record_type' do
129
+ it 'returns a string of the SOAP type' do
130
+ item.record_type.should eql('listAcct:ServiceSaleItem')
131
+ end
132
+ end
133
+
134
+ end
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.2.2
4
+ version: 0.2.3
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: 2014-02-11 00:00:00.000000000 Z
12
+ date: 2014-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -42,7 +42,7 @@ dependencies:
42
42
  description: NetSuite SuiteTalk API Wrapper
43
43
  email:
44
44
  - ryan.moran@gmail.com
45
- - info@cliffsidedev.com
45
+ - mike@cliffsidemedia.com
46
46
  executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
@@ -136,6 +136,7 @@ files:
136
136
  - lib/netsuite/records/sales_order.rb
137
137
  - lib/netsuite/records/sales_order_item.rb
138
138
  - lib/netsuite/records/sales_order_item_list.rb
139
+ - lib/netsuite/records/service_sale_item.rb
139
140
  - lib/netsuite/records/ship_address.rb
140
141
  - lib/netsuite/records/support_case.rb
141
142
  - lib/netsuite/records/task.rb
@@ -192,6 +193,7 @@ files:
192
193
  - spec/netsuite/records/journal_entry_line_spec.rb
193
194
  - spec/netsuite/records/journal_entry_spec.rb
194
195
  - spec/netsuite/records/location_spec.rb
196
+ - spec/netsuite/records/matrix_option_list_spec.rb
195
197
  - spec/netsuite/records/non_inventory_sale_item_spec.rb
196
198
  - spec/netsuite/records/payment_method_spec.rb
197
199
  - spec/netsuite/records/phone_call_spec.rb
@@ -200,6 +202,7 @@ files:
200
202
  - spec/netsuite/records/sales_order_item_list_spec.rb
201
203
  - spec/netsuite/records/sales_order_item_spec.rb
202
204
  - spec/netsuite/records/sales_order_spec.rb
205
+ - spec/netsuite/records/service_sale_item_spec.rb
203
206
  - spec/netsuite/records/ship_address_spec.rb
204
207
  - spec/netsuite/records/support_case_spec.rb
205
208
  - spec/netsuite/records/term_spec.rb
@@ -253,7 +256,7 @@ rubyforge_project:
253
256
  rubygems_version: 2.2.0
254
257
  signing_key:
255
258
  specification_version: 4
256
- summary: NetSuite SuiteTalk API Wrapper
259
+ summary: NetSuite SuiteTalk API (SOAP) Wrapper
257
260
  test_files:
258
261
  - spec/netsuite/actions/add_spec.rb
259
262
  - spec/netsuite/actions/delete_spec.rb
@@ -296,6 +299,7 @@ test_files:
296
299
  - spec/netsuite/records/journal_entry_line_spec.rb
297
300
  - spec/netsuite/records/journal_entry_spec.rb
298
301
  - spec/netsuite/records/location_spec.rb
302
+ - spec/netsuite/records/matrix_option_list_spec.rb
299
303
  - spec/netsuite/records/non_inventory_sale_item_spec.rb
300
304
  - spec/netsuite/records/payment_method_spec.rb
301
305
  - spec/netsuite/records/phone_call_spec.rb
@@ -304,6 +308,7 @@ test_files:
304
308
  - spec/netsuite/records/sales_order_item_list_spec.rb
305
309
  - spec/netsuite/records/sales_order_item_spec.rb
306
310
  - spec/netsuite/records/sales_order_spec.rb
311
+ - spec/netsuite/records/service_sale_item_spec.rb
307
312
  - spec/netsuite/records/ship_address_spec.rb
308
313
  - spec/netsuite/records/support_case_spec.rb
309
314
  - spec/netsuite/records/term_spec.rb