netsuite 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,6 +34,7 @@ module NetSuite
34
34
  end
35
35
 
36
36
  module Records
37
+ autoload :Account, 'netsuite/records/account'
37
38
  autoload :BillAddress, 'netsuite/records/bill_address'
38
39
  autoload :Classification, 'netsuite/records/classification'
39
40
  autoload :CreditMemo, 'netsuite/records/credit_memo'
@@ -47,6 +48,7 @@ module NetSuite
47
48
  autoload :CustomerAddressbookList, 'netsuite/records/customer_addressbook_list'
48
49
  autoload :CustomerPayment, 'netsuite/records/customer_payment'
49
50
  autoload :Duration, 'netsuite/records/duration'
51
+ autoload :InventoryItem, 'netsuite/records/inventory_item'
50
52
  autoload :Invoice, 'netsuite/records/invoice'
51
53
  autoload :InvoiceItem, 'netsuite/records/invoice_item'
52
54
  autoload :InvoiceItemList, 'netsuite/records/invoice_item_list'
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class Account
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+
7
+ fields :acct_name, :acct_number, :acct_type, :cash_flow_rate, :cur_doc_num, :description, :eliminate, :exchange_rate,
8
+ :general_rate, :include_children, :inventory, :is_inactive, :opening_balance, :revalue, :tran_date
9
+
10
+ record_refs :billable_expenses_acct, :category1099misc, :currency, :deferral_acct, :department, :klass, :location, :parent
11
+
12
+ attr_reader :internal_id
13
+ attr_accessor :external_id
14
+
15
+ def initialize(attributes = {})
16
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
17
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
18
+ initialize_from_attributes_hash(attributes)
19
+ end
20
+
21
+ def self.get(options = {})
22
+ response = Actions::Get.call(self, options)
23
+ if response.success?
24
+ new(response.body)
25
+ else
26
+ raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,65 @@
1
+ module NetSuite
2
+ module Records
3
+ class InventoryItem
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::ListAcct
8
+
9
+ fields :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, :average_cost,
10
+ :copy_description, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :cost_units, :costing_method,
11
+ :costing_method_display, :country_of_manufacture, :created_date, :currency, :date_converted_to_inv,
12
+ :default_return_cost, :demand_modifier, :display_name, :dont_show_price, :enforce_min_qty_internally,
13
+ :exclude_from_sitemap, :featured_description, :fixed_lot_size, :handling_cost, :handling_cost_units, :include_children,
14
+ :is_donation_item, :is_drop_ship_item, :is_gco_compliant, :is_inactive, :is_online, :is_special_order_item, :is_taxable,
15
+ :item_id, :last_modified_date, :last_purchase_price, :lead_time, :manufacturer, :manufacturer_addr1, :manufacturer_city,
16
+ :manufacturer_state, :manufacturer_tariff, :manufacturer_tax_id, :manufacturer_zip, :match_bill_to_receipt,
17
+ :matrix_type, :max_donation_amount, :meta_tag_html, :minimum_quantity, :minimum_quantity_units, :mpn,
18
+ :mult_manufacture_addr, :nex_tag_category, :no_price_message, :offer_support, :on_hand_value_mli, :on_special,
19
+ :original_item_subtype, :original_item_type, :out_of_stock_behavior, :out_of_stock_message,
20
+ :overall_quantity_pricing_type, :page_title, :preference_criterion, :preferred_stock_level, :preferred_stock_level_days,
21
+ :preferred_stock_level_units, :prices_include_tax, :producer, :purchase_description, :quantity_available,
22
+ :quantity_available_units, :quantity_back_ordered, :quantity_committed, :quantity_committed_units, :quantity_on_hand,
23
+ :quantity_on_hand_units, :quantity_on_order, :quantity_on_order_units, :quantity_reorder_units, :rate,
24
+ :related_items_description, :reorder_multiple, :reorder_point, :reorder_point_units, :safety_stock_level,
25
+ :safety_stock_level_days, :safety_stock_level_units, :sales_description, :schedule_b_code, :schedule_b_number,
26
+ :schedule_b_quantity, :search_keywords, :seasonal_demand, :ship_individually, :shipping_cost, :shipping_cost_units,
27
+ :shopping_dot_com_category, :shopzilla_category_id, :show_default_donation_amount, :sitemap_priority,
28
+ :specials_description, :stock_description, :store_description, :store_detailed_description, :store_display_name,
29
+ :total_value, :track_landed_cost, :transfer_price, :upc_code, :url_component, :use_bins, :use_marginal_rates,
30
+ :vendor_name, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :weight, :weight_unit, :weight_units
31
+
32
+ record_refs :alternate_demand_source_item, :asset_account, :bill_exch_rate_variance_acct, :bill_price_variance_acct,
33
+ :bill_qty_variance_acct, :billing_schedule, :cogs_account, :cost_category, :custom_form, :deferred_revenue_account,
34
+ :demand_source, :department, :expense_account, :gain_loss_account, :income_account, :issue_product, :klass, :location,
35
+ :parent, :preferred_location, :pricing_group, :purchase_price_variance_acct, :purchase_tax_code, :purchase_unit,
36
+ :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :ship_package, :soft_descriptor,
37
+ :stock_unit, :store_display_image, :store_display_thumbnail, :store_item_template, :supply_lot_sizing_method,
38
+ :supply_replenishment_method, :supply_type, :tax_schedule, :units_type, :vendor
39
+
40
+ attr_reader :internal_id
41
+ attr_accessor :external_id
42
+
43
+ def initialize(attributes = {})
44
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
45
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
46
+ initialize_from_attributes_hash(attributes)
47
+ end
48
+
49
+ def self.get(options = {})
50
+ response = Actions::Get.call(self, options)
51
+ if response.success?
52
+ new(response.body)
53
+ else
54
+ raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
55
+ end
56
+ end
57
+
58
+ def add
59
+ response = Actions::Add.call(self)
60
+ response.success?
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.22'
2
+ VERSION = '0.0.23'
3
3
  end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::Account do
4
+ let(:account) { NetSuite::Records::Account.new }
5
+
6
+ # <element name="subsidiaryList" type="platformCore:RecordRefList" minOccurs="0"/>
7
+ # <element name="translationsList" type="listAcct:AccountTranslationList" minOccurs="0"/>
8
+ # <element name="customFieldList" type="platformCore:CustomFieldList" minOccurs="0"/>
9
+ it 'has all the right fields' do
10
+ [
11
+ :acct_name, :acct_number, :acct_type, :cash_flow_rate, :cur_doc_num, :description, :eliminate, :exchange_rate,
12
+ :general_rate, :include_children, :inventory, :is_inactive, :opening_balance, :revalue, :tran_date
13
+ ].each do |field|
14
+ account.should have_field(field)
15
+ end
16
+ end
17
+
18
+ it 'has all the right record refs' do
19
+ [
20
+ :billable_expenses_acct, :category1099misc, :currency, :deferral_acct, :department, :klass, :location, :parent
21
+ ].each do |record_ref|
22
+ account.should have_record_ref(record_ref)
23
+ end
24
+ end
25
+
26
+ describe '.get' do
27
+ context 'when the response is successful' do
28
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :acct_name => 'Account 1' }) }
29
+
30
+ it 'returns a Account instance populated with the data from the response object' do
31
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Account, :external_id => 1).and_return(response)
32
+ account = NetSuite::Records::Account.get(:external_id => 1)
33
+ account.should be_kind_of(NetSuite::Records::Account)
34
+ account.acct_name.should eql('Account 1')
35
+ end
36
+ end
37
+
38
+ context 'when the response is unsuccessful' do
39
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
40
+
41
+ it 'raises a RecordNotFound exception' do
42
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Account, :external_id => 1).and_return(response)
43
+ lambda {
44
+ NetSuite::Records::Account.get(:external_id => 1)
45
+ }.should raise_error(NetSuite::RecordNotFound,
46
+ /NetSuite::Records::Account with OPTIONS=(.*) could not be found/)
47
+ end
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,126 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::InventoryItem do
4
+ let(:item) { NetSuite::Records::InventoryItem.new }
5
+
6
+ it 'has all the right fields' do
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
29
+ ].each do |field|
30
+ item.should have_field(field)
31
+ end
32
+ end
33
+
34
+ it 'has all the right record refs' do
35
+ [
36
+ :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
37
+ ].each do |record_ref|
38
+ item.should have_record_ref(record_ref)
39
+ end
40
+ end
41
+
42
+ # <element name="pricingMatrix" type="listAcct:PricingMatrix" minOccurs="0"/>
43
+ # <element name="productFeedList" type="listAcct:ProductFeedList" minOccurs="0"/>
44
+ # <element name="subsidiaryList" type="platformCore:RecordRefList" minOccurs="0"/>
45
+ # <element name="itemOptionsList" type="listAcct:ItemOptionsList" minOccurs="0"/>
46
+ # <element name="itemVendorList" type="listAcct:ItemVendorList" minOccurs="0"/>
47
+ # <element name="siteCategoryList" type="listAcct:SiteCategoryList" minOccurs="0"/>
48
+ # <element name="translationsList" type="listAcct:TranslationList" minOccurs="0"/>
49
+ # <element name="binNumberList" type="listAcct:InventoryItemBinNumberList" minOccurs="0"/>
50
+ # <element name="locationsList" type="listAcct:InventoryItemLocationsList" minOccurs="0"/>
51
+ # <element name="matrixOptionList" type="listAcct:MatrixOptionList" minOccurs="0"/>
52
+ # <element name="presentationItemList" type="listAcct:PresentationItemList" minOccurs="0"/>
53
+ # <element name="customFieldList" type="platformCore:CustomFieldList" minOccurs="0"/>
54
+
55
+ describe '.get' do
56
+ context 'when the response is successful' do
57
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :cost => 100 }) }
58
+
59
+ it 'returns a InventoryItem instance populated with the data from the response object' do
60
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::InventoryItem, :external_id => 1).and_return(response)
61
+ item = NetSuite::Records::InventoryItem.get(:external_id => 1)
62
+ item.should be_kind_of(NetSuite::Records::InventoryItem)
63
+ item.cost.should eql(100)
64
+ end
65
+ end
66
+
67
+ context 'when the response is unsuccessful' do
68
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
69
+
70
+ it 'raises a RecordNotFound exception' do
71
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::InventoryItem, :external_id => 1).and_return(response)
72
+ lambda {
73
+ NetSuite::Records::InventoryItem.get(:external_id => 1)
74
+ }.should raise_error(NetSuite::RecordNotFound,
75
+ /NetSuite::Records::InventoryItem with OPTIONS=(.*) could not be found/)
76
+ end
77
+ end
78
+ end
79
+
80
+ describe '#add' do
81
+ let(:item) { NetSuite::Records::InventoryItem.new(:cost => 100, :is_inactive => false) }
82
+
83
+ context 'when the response is successful' do
84
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
85
+
86
+ it 'returns true' do
87
+ NetSuite::Actions::Add.should_receive(:call).
88
+ with(item).
89
+ and_return(response)
90
+ item.add.should be_true
91
+ end
92
+ end
93
+
94
+ context 'when the response is unsuccessful' do
95
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
96
+
97
+ it 'returns false' do
98
+ NetSuite::Actions::Add.should_receive(:call).
99
+ with(item).
100
+ and_return(response)
101
+ item.add.should be_false
102
+ end
103
+ end
104
+ end
105
+
106
+ describe '#to_record' do
107
+ before do
108
+ item.cost = 100
109
+ item.is_inactive = false
110
+ end
111
+ it 'can represent itself as a SOAP record' do
112
+ record = {
113
+ 'listAcct:cost' => 100,
114
+ 'listAcct:isInactive' => false
115
+ }
116
+ item.to_record.should eql(record)
117
+ end
118
+ end
119
+
120
+ describe '#record_type' do
121
+ it 'returns a string representation of the SOAP type' do
122
+ item.record_type.should eql('listAcct:InventoryItem')
123
+ end
124
+ end
125
+
126
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsuite
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 22
10
- version: 0.0.22
9
+ - 23
10
+ version: 0.0.23
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Moran
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-19 00:00:00 Z
18
+ date: 2012-01-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon
@@ -114,6 +114,7 @@ files:
114
114
  - lib/netsuite/namespaces/tran_cust.rb
115
115
  - lib/netsuite/namespaces/tran_general.rb
116
116
  - lib/netsuite/namespaces/tran_sales.rb
117
+ - lib/netsuite/records/account.rb
117
118
  - lib/netsuite/records/bill_address.rb
118
119
  - lib/netsuite/records/classification.rb
119
120
  - lib/netsuite/records/credit_memo.rb
@@ -127,6 +128,7 @@ files:
127
128
  - lib/netsuite/records/customer_addressbook_list.rb
128
129
  - lib/netsuite/records/customer_payment.rb
129
130
  - lib/netsuite/records/duration.rb
131
+ - lib/netsuite/records/inventory_item.rb
130
132
  - lib/netsuite/records/invoice.rb
131
133
  - lib/netsuite/records/invoice_item.rb
132
134
  - lib/netsuite/records/invoice_item_list.rb
@@ -152,6 +154,7 @@ files:
152
154
  - spec/netsuite/actions/initialize_spec.rb
153
155
  - spec/netsuite/actions/update_spec.rb
154
156
  - spec/netsuite/configuration_spec.rb
157
+ - spec/netsuite/records/account_spec.rb
155
158
  - spec/netsuite/records/bill_address_spec.rb
156
159
  - spec/netsuite/records/classification_spec.rb
157
160
  - spec/netsuite/records/credit_memo_spec.rb
@@ -165,6 +168,7 @@ files:
165
168
  - spec/netsuite/records/customer_payment_spec.rb
166
169
  - spec/netsuite/records/customer_spec.rb
167
170
  - spec/netsuite/records/duration_spec.rb
171
+ - spec/netsuite/records/inventory_item_spec.rb
168
172
  - spec/netsuite/records/invoice_item_list_spec.rb
169
173
  - spec/netsuite/records/invoice_item_spec.rb
170
174
  - spec/netsuite/records/invoice_spec.rb
@@ -237,6 +241,7 @@ test_files:
237
241
  - spec/netsuite/actions/initialize_spec.rb
238
242
  - spec/netsuite/actions/update_spec.rb
239
243
  - spec/netsuite/configuration_spec.rb
244
+ - spec/netsuite/records/account_spec.rb
240
245
  - spec/netsuite/records/bill_address_spec.rb
241
246
  - spec/netsuite/records/classification_spec.rb
242
247
  - spec/netsuite/records/credit_memo_spec.rb
@@ -250,6 +255,7 @@ test_files:
250
255
  - spec/netsuite/records/customer_payment_spec.rb
251
256
  - spec/netsuite/records/customer_spec.rb
252
257
  - spec/netsuite/records/duration_spec.rb
258
+ - spec/netsuite/records/inventory_item_spec.rb
253
259
  - spec/netsuite/records/invoice_item_list_spec.rb
254
260
  - spec/netsuite/records/invoice_item_spec.rb
255
261
  - spec/netsuite/records/invoice_spec.rb