netsuite 0.0.20 → 0.0.21

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/lib/netsuite.rb CHANGED
@@ -50,6 +50,8 @@ require 'netsuite/records/custom_record_type'
50
50
  require 'netsuite/records/job'
51
51
  require 'netsuite/records/customer_payment'
52
52
  require 'netsuite/records/payment_method'
53
+ require 'netsuite/records/credit_memo'
54
+ require 'netsuite/records/location'
53
55
 
54
56
  module NetSuite
55
57
 
@@ -0,0 +1,59 @@
1
+ module NetSuite
2
+ module Records
3
+ class CreditMemo
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::TranCust
8
+
9
+ fields :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :auto_apply, :balance,
10
+ :bill_address, :contrib_pct, :created_date, :currency_name, :deferred_revenue, :discount_rate, :email,
11
+ :est_gross_profit, :est_gross_profit_percent, :exchange_rate, :exclude_commission, :fax, :gift_cert_applied,
12
+ :gift_cert_available, :gift_cert_total, :handling_cost, :handling_tax1_rate, :handling_tax2_rate, :is_taxable,
13
+ :last_modified_date, :memo, :message, :on_credit_hold, :other_ref_num, :recognized_revenue, :rev_rec_on_rev_commitment,
14
+ :sales_effective_date, :shipping_cost, :shipping_tax1_rate, :shipping_tax2_rate, :source, :status,
15
+ :sync_partner_teams, :sync_sales_teams, :tax2_total, :tax_rate, :to_be_emailed, :to_be_faxed,
16
+ :to_be_printed, :total_cost_estimate, :tran_date, :tran_id, :tran_is_vsoe_bundle, :vat_reg_num,
17
+ :vsoe_auto_calc
18
+
19
+ read_only_fields :applied, :discount_total, :sub_total, :tax_total, :total, :unapplied
20
+
21
+ record_refs :account, :bill_address_list, :created_from, :custom_form, :department, :discount_item, :entity, :gift_cert,
22
+ :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, :partner, :posting_period, :promo_code,
23
+ :sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :tax_item
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
+
34
+ def self.get(options = {})
35
+ response = Actions::Get.call(self, options)
36
+ if response.success?
37
+ new(response.body)
38
+ else
39
+ raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
40
+ end
41
+ end
42
+
43
+ def self.initialize(object)
44
+ response = Actions::Initialize.call(self, object)
45
+ if response.success?
46
+ new(response.body)
47
+ else
48
+ raise InitializationError, "#{self}.initialize with #{object} failed."
49
+ end
50
+ end
51
+
52
+ def add
53
+ response = Actions::Add.call(self)
54
+ response.success?
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -2,6 +2,7 @@ module NetSuite
2
2
  module Records
3
3
  class Duration
4
4
  include Support::Fields
5
+ include Support::Records
5
6
 
6
7
  fields :time_span, :unit
7
8
 
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class Location
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+
7
+ fields :addr1, :addr2, :addr3, :addr_phone, :addr_text, :addressee, :attention, :city, :country, :include_children,
8
+ :is_inactive, :make_inventory_available, :make_inventory_available_store, :name, :override, :state, :tran_prefix, :zip
9
+
10
+ record_refs :logo, :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
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.20'
2
+ VERSION = '0.0.21'
3
3
  end
@@ -0,0 +1,126 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::CreditMemo do
4
+ let(:memo) { NetSuite::Records::CreditMemo.new }
5
+ let(:customer) { NetSuite::Records::Customer.new }
6
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
7
+
8
+ it 'has all the right fields' do
9
+ [
10
+ :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :applied, :auto_apply, :balance, :bill_address,
11
+ :contrib_pct, :created_date, :currency_name, :deferred_revenue, :discount_rate, :discount_total, :email, :est_gross_profit,
12
+ :est_gross_profit_percent, :exchange_rate, :exclude_commission, :fax, :gift_cert_applied, :gift_cert_available,
13
+ :gift_cert_total, :handling_cost, :handling_tax1_rate, :handling_tax2_rate, :is_taxable, :last_modified_date, :memo,
14
+ :message, :on_credit_hold, :other_ref_num, :recognized_revenue, :rev_rec_on_rev_commitment, :sales_effective_date,
15
+ :shipping_cost, :shipping_tax1_rate, :shipping_tax2_rate, :source, :status, :sub_total, :sync_partner_teams,
16
+ :sync_sales_teams, :tax2_total, :tax_rate, :tax_total, :to_be_emailed, :to_be_faxed, :to_be_printed, :total,
17
+ :total_cost_estimate, :tran_date, :tran_id, :tran_is_vsoe_bundle, :unapplied, :vat_reg_num, :vsoe_auto_calc
18
+ ].each do |field|
19
+ memo.should have_field(field)
20
+ end
21
+ end
22
+
23
+ it 'has all the right record refs' do
24
+ [
25
+ :account, :bill_address_list, :created_from, :custom_form, :department, :discount_item, :entity, :gift_cert, :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, :partner, :posting_period, :promo_code, :sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :tax_item
26
+ ].each do |record_ref|
27
+ memo.should have_record_ref(record_ref)
28
+ end
29
+ end
30
+
31
+ # <element name="transactionBillAddress" type="platformCommon:BillAddress" minOccurs="0"/>
32
+ # <element name="revenueStatus" type="platformCommonTyp:RevenueStatus" minOccurs="0"/>
33
+ # <element name="salesTeamList" type="tranCust:CreditMemoSalesTeamList" minOccurs="0"/>
34
+ # <element name="itemList" type="tranCust:CreditMemoItemList" minOccurs="0"/>
35
+ # <element name="partnersList" type="tranCust:CreditMemoPartnersList" minOccurs="0"/>
36
+ # <element name="applyList" type="tranCust:CreditMemoApplyList" minOccurs="0"/>
37
+ # <element name="customFieldList" type="platformCore:CustomFieldList" minOccurs="0"/>
38
+
39
+ describe '.get' do
40
+ context 'when the response is successful' do
41
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :alt_shipping_cost => 100 }) }
42
+
43
+ it 'returns a CreditMemo instance populated with the data from the response object' do
44
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::CreditMemo, :external_id => 1).and_return(response)
45
+ memo = NetSuite::Records::CreditMemo.get(:external_id => 1)
46
+ memo.should be_kind_of(NetSuite::Records::CreditMemo)
47
+ memo.alt_shipping_cost.should eql(100)
48
+ end
49
+ end
50
+
51
+ context 'when the response is unsuccessful' do
52
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
53
+
54
+ it 'raises a RecordNotFound exception' do
55
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::CreditMemo, :external_id => 1).and_return(response)
56
+ lambda {
57
+ NetSuite::Records::CreditMemo.get(:external_id => 1)
58
+ }.should raise_error(NetSuite::RecordNotFound,
59
+ /NetSuite::Records::CreditMemo with OPTIONS=(.*) could not be found/)
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '.initialize' do
65
+ context 'when the request is successful' do
66
+ it 'returns an initialized credit memo from the customer entity' do
67
+ NetSuite::Actions::Initialize.should_receive(:call).with(NetSuite::Records::CreditMemo, customer).and_return(response)
68
+ invoice = NetSuite::Records::CreditMemo.initialize(customer)
69
+ invoice.should be_kind_of(NetSuite::Records::CreditMemo)
70
+ end
71
+ end
72
+
73
+ context 'when the response is unsuccessful' do
74
+ pending
75
+ end
76
+ end
77
+
78
+ describe '#add' do
79
+ let(:test_data) { { :email => 'test@example.com', :fax => '1234567890' } }
80
+
81
+ context 'when the response is successful' do
82
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
83
+
84
+ it 'returns true' do
85
+ memo = NetSuite::Records::CreditMemo.new(test_data)
86
+ NetSuite::Actions::Add.should_receive(:call).
87
+ with(memo).
88
+ and_return(response)
89
+ memo.add.should be_true
90
+ end
91
+ end
92
+
93
+ context 'when the response is unsuccessful' do
94
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
95
+
96
+ it 'returns false' do
97
+ memo = NetSuite::Records::CreditMemo.new(test_data)
98
+ NetSuite::Actions::Add.should_receive(:call).
99
+ with(memo).
100
+ and_return(response)
101
+ memo.add.should be_false
102
+ end
103
+ end
104
+ end
105
+
106
+ describe '#to_record' do
107
+ before do
108
+ memo.email = 'something@example.com'
109
+ memo.tran_id = '4'
110
+ end
111
+ it 'can represent itself as a SOAP record' do
112
+ record = {
113
+ 'tranCust:email' => 'something@example.com',
114
+ 'tranCust:tranId' => '4'
115
+ }
116
+ memo.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
+ memo.record_type.should eql('tranCust:CreditMemo')
123
+ end
124
+ end
125
+
126
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::Location do
4
+ let(:location) { NetSuite::Records::Location.new }
5
+
6
+ # <element name="classTranslationList" type="listAcct:ClassTranslationList" minOccurs="0"/>
7
+ # <element name="subsidiaryList" type="platformCore:RecordRefList" minOccurs="0"/>
8
+ # <element name="customFieldList" type="platformCore:CustomFieldList" minOccurs="0"/>
9
+ it 'has all the right attributes' do
10
+ [
11
+ :addr1, :addr2, :addr3, :addr_phone, :addr_text, :addressee, :attention, :city, :country, :include_children, :is_inactive,
12
+ :make_inventory_available, :make_inventory_available_store, :name, :override, :state, :tran_prefix, :zip
13
+ ].each do |field|
14
+ location.should have_field(field)
15
+ end
16
+ end
17
+
18
+ it 'has all the right record refs' do
19
+ [
20
+ :logo, :parent
21
+ ].each do |record_ref|
22
+ location.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 => { :city => 'Los Angeles' }) }
29
+
30
+ it 'returns a Location instance populated with the data from the response object' do
31
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Location, :external_id => 1).and_return(response)
32
+ location = NetSuite::Records::Location.get(:external_id => 1)
33
+ location.should be_kind_of(NetSuite::Records::Location)
34
+ location.city.should eql('Los Angeles')
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::Location, :external_id => 1).and_return(response)
43
+ lambda {
44
+ NetSuite::Records::Location.get(:external_id => 1)
45
+ }.should raise_error(NetSuite::RecordNotFound,
46
+ /NetSuite::Records::Location with OPTIONS=(.*) could not be found/)
47
+ end
48
+ end
49
+ end
50
+
51
+ 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: 55
4
+ hash: 53
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 20
10
- version: 0.0.20
9
+ - 21
10
+ version: 0.0.21
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-18 00:00:00 Z
18
+ date: 2012-01-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon
@@ -115,6 +115,7 @@ files:
115
115
  - lib/netsuite/namespaces/tran_sales.rb
116
116
  - lib/netsuite/records/bill_address.rb
117
117
  - lib/netsuite/records/classification.rb
118
+ - lib/netsuite/records/credit_memo.rb
118
119
  - lib/netsuite/records/custom_field.rb
119
120
  - lib/netsuite/records/custom_field_list.rb
120
121
  - lib/netsuite/records/custom_record.rb
@@ -129,6 +130,7 @@ files:
129
130
  - lib/netsuite/records/invoice_item.rb
130
131
  - lib/netsuite/records/invoice_item_list.rb
131
132
  - lib/netsuite/records/job.rb
133
+ - lib/netsuite/records/location.rb
132
134
  - lib/netsuite/records/non_inventory_sale_item.rb
133
135
  - lib/netsuite/records/payment_method.rb
134
136
  - lib/netsuite/records/record_ref.rb
@@ -148,6 +150,7 @@ files:
148
150
  - spec/netsuite/configuration_spec.rb
149
151
  - spec/netsuite/records/bill_address_spec.rb
150
152
  - spec/netsuite/records/classification_spec.rb
153
+ - spec/netsuite/records/credit_memo_spec.rb
151
154
  - spec/netsuite/records/custom_field_list_spec.rb
152
155
  - spec/netsuite/records/custom_field_spec.rb
153
156
  - spec/netsuite/records/custom_record_ref_spec.rb
@@ -162,6 +165,7 @@ files:
162
165
  - spec/netsuite/records/invoice_item_spec.rb
163
166
  - spec/netsuite/records/invoice_spec.rb
164
167
  - spec/netsuite/records/job_spec.rb
168
+ - spec/netsuite/records/location_spec.rb
165
169
  - spec/netsuite/records/non_inventory_sale_item_spec.rb
166
170
  - spec/netsuite/records/payment_method_spec.rb
167
171
  - spec/netsuite/records/record_ref_spec.rb
@@ -228,6 +232,7 @@ test_files:
228
232
  - spec/netsuite/configuration_spec.rb
229
233
  - spec/netsuite/records/bill_address_spec.rb
230
234
  - spec/netsuite/records/classification_spec.rb
235
+ - spec/netsuite/records/credit_memo_spec.rb
231
236
  - spec/netsuite/records/custom_field_list_spec.rb
232
237
  - spec/netsuite/records/custom_field_spec.rb
233
238
  - spec/netsuite/records/custom_record_ref_spec.rb
@@ -242,6 +247,7 @@ test_files:
242
247
  - spec/netsuite/records/invoice_item_spec.rb
243
248
  - spec/netsuite/records/invoice_spec.rb
244
249
  - spec/netsuite/records/job_spec.rb
250
+ - spec/netsuite/records/location_spec.rb
245
251
  - spec/netsuite/records/non_inventory_sale_item_spec.rb
246
252
  - spec/netsuite/records/payment_method_spec.rb
247
253
  - spec/netsuite/records/record_ref_spec.rb