netsuite 0.0.43 → 0.0.44

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use ree-1.8.7-2010.02@netsuite
1
+ rvm use ree-1.8.7-2010.02@netsuite --create
data/lib/netsuite.rb CHANGED
@@ -38,6 +38,7 @@ module NetSuite
38
38
 
39
39
  module Records
40
40
  autoload :Account, 'netsuite/records/account'
41
+ autoload :AccountingPeriod, 'netsuite/records/accounting_period'
41
42
  autoload :BillAddress, 'netsuite/records/bill_address'
42
43
  autoload :Classification, 'netsuite/records/classification'
43
44
  autoload :CreditMemo, 'netsuite/records/credit_memo'
@@ -0,0 +1,25 @@
1
+ module NetSuite
2
+ module Records
3
+ class AccountingPeriod
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Actions
7
+
8
+ actions :get, :add, :delete
9
+
10
+ fields :allow_non_gl_changes, :end_date, :is_adjust, :is_quarter, :is_year, :period_name, :start_date
11
+
12
+ record_refs :parent
13
+
14
+ attr_reader :internal_id
15
+ attr_accessor :external_id
16
+
17
+ def initialize(attributes = {})
18
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
19
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
20
+ initialize_from_attributes_hash(attributes)
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.43'
2
+ VERSION = '0.0.44'
3
3
  end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::AccountingPeriod do
4
+ let(:accounting_period) { NetSuite::Records::AccountingPeriod.new }
5
+
6
+ it 'has all the right fields' do
7
+ [
8
+ :allow_non_gl_changes, :end_date, :is_adjust, :is_quarter, :is_year, :period_name, :start_date
9
+ ].each do |field|
10
+ accounting_period.should have_field(field)
11
+ end
12
+ end
13
+
14
+ it 'has all the right record refs' do
15
+ [
16
+ :parent
17
+ ].each do |record_ref|
18
+ accounting_period.should have_record_ref(record_ref)
19
+ end
20
+ end
21
+
22
+ describe '.get' do
23
+ context 'when the response is successful' do
24
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :period_name => 'Accounting Period 1' }) }
25
+
26
+ it 'returns a Account instance populated with the data from the response object' do
27
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::AccountingPeriod, :external_id => 1).and_return(response)
28
+ accounting_period = NetSuite::Records::AccountingPeriod.get(:external_id => 1)
29
+ accounting_period.should be_kind_of(NetSuite::Records::AccountingPeriod)
30
+ accounting_period.period_name.should eql('Accounting Period 1')
31
+ end
32
+ end
33
+
34
+ context 'when the response is unsuccessful' do
35
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
36
+
37
+ it 'raises a RecordNotFound exception' do
38
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::AccountingPeriod, :external_id => 1).and_return(response)
39
+ lambda {
40
+ NetSuite::Records::AccountingPeriod.get(:external_id => 1)
41
+ }.should raise_error(NetSuite::RecordNotFound,
42
+ /NetSuite::Records::AccountingPeriod with OPTIONS=(.*) could not be found/)
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#add' do
48
+ let(:test_data) { { :acct_name => 'Test Accounting Period', :description => 'An example accounting period' } }
49
+
50
+ context 'when the response is successful' do
51
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
52
+
53
+ it 'returns true' do
54
+ accounting_period = NetSuite::Records::AccountingPeriod.new(test_data)
55
+ NetSuite::Actions::Add.should_receive(:call).
56
+ with(accounting_period).
57
+ and_return(response)
58
+ accounting_period.add.should be_true
59
+ end
60
+ end
61
+
62
+ context 'when the response is unsuccessful' do
63
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
64
+
65
+ it 'returns false' do
66
+ accounting_period = NetSuite::Records::AccountingPeriod.new(test_data)
67
+ NetSuite::Actions::Add.should_receive(:call).
68
+ with(accounting_period).
69
+ and_return(response)
70
+ accounting_period.add.should be_false
71
+ end
72
+ end
73
+ end
74
+
75
+ describe '#delete' do
76
+ let(:test_data) { { :internal_id => '1' } }
77
+
78
+ context 'when the response is successful' do
79
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
80
+
81
+ it 'returns true' do
82
+ accounting_period = NetSuite::Records::AccountingPeriod.new(test_data)
83
+ NetSuite::Actions::Delete.should_receive(:call).
84
+ with(accounting_period).
85
+ and_return(response)
86
+ accounting_period.delete.should be_true
87
+ end
88
+ end
89
+
90
+ context 'when the response is unsuccessful' do
91
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
92
+
93
+ it 'returns false' do
94
+ accounting_period = NetSuite::Records::AccountingPeriod.new(test_data)
95
+ NetSuite::Actions::Delete.should_receive(:call).
96
+ with(accounting_period).
97
+ and_return(response)
98
+ accounting_period.delete.should be_false
99
+ end
100
+ end
101
+ end
102
+
103
+ 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: 73
4
+ hash: 71
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 43
10
- version: 0.0.43
9
+ - 44
10
+ version: 0.0.44
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Moran
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-01 00:00:00 Z
18
+ date: 2012-03-06 00:00:00 -08:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: savon
@@ -130,6 +131,7 @@ files:
130
131
  - lib/netsuite/namespaces/tran_general.rb
131
132
  - lib/netsuite/namespaces/tran_sales.rb
132
133
  - lib/netsuite/records/account.rb
134
+ - lib/netsuite/records/accounting_period.rb
133
135
  - lib/netsuite/records/bill_address.rb
134
136
  - lib/netsuite/records/classification.rb
135
137
  - lib/netsuite/records/credit_memo.rb
@@ -183,6 +185,7 @@ files:
183
185
  - spec/netsuite/actions/update_spec.rb
184
186
  - spec/netsuite/configuration_spec.rb
185
187
  - spec/netsuite/records/account_spec.rb
188
+ - spec/netsuite/records/accounting_period_spec.rb
186
189
  - spec/netsuite/records/bill_address_spec.rb
187
190
  - spec/netsuite/records/classification_spec.rb
188
191
  - spec/netsuite/records/credit_memo_apply_list_spec.rb
@@ -242,6 +245,7 @@ files:
242
245
  - spec/support/record_ref_matcher.rb
243
246
  - spec/support/savon.rb
244
247
  - wsdl/2011_02.wsdl
248
+ has_rdoc: true
245
249
  homepage: https://github.com/RevolutionPrep/netsuite
246
250
  licenses: []
247
251
 
@@ -271,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
275
  requirements: []
272
276
 
273
277
  rubyforge_project:
274
- rubygems_version: 1.8.10
278
+ rubygems_version: 1.4.2
275
279
  signing_key:
276
280
  specification_version: 3
277
281
  summary: NetSuite SuiteTalk API Wrapper
@@ -283,6 +287,7 @@ test_files:
283
287
  - spec/netsuite/actions/update_spec.rb
284
288
  - spec/netsuite/configuration_spec.rb
285
289
  - spec/netsuite/records/account_spec.rb
290
+ - spec/netsuite/records/accounting_period_spec.rb
286
291
  - spec/netsuite/records/bill_address_spec.rb
287
292
  - spec/netsuite/records/classification_spec.rb
288
293
  - spec/netsuite/records/credit_memo_apply_list_spec.rb