netsuite 0.0.34 → 0.0.35
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/netsuite/actions/get.rb +15 -6
- data/lib/netsuite/actions/initialize.rb +20 -6
- data/lib/netsuite/records/invoice_item.rb +15 -5
- data/lib/netsuite/support/actions.rb +2 -7
- data/lib/netsuite/version.rb +1 -1
- data/netsuite.gemspec +2 -1
- data/spec/netsuite/records/invoice_item_spec.rb +36 -18
- metadata +3 -3
data/lib/netsuite/actions/get.rb
CHANGED
@@ -59,13 +59,22 @@ module NetSuite
|
|
59
59
|
end
|
60
60
|
|
61
61
|
module Support
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
62
|
+
|
63
|
+
def self.included(base)
|
64
|
+
base.extend(ClassMethods)
|
65
|
+
end
|
66
|
+
|
67
|
+
module ClassMethods
|
68
|
+
|
69
|
+
def get(options = {})
|
70
|
+
response = NetSuite::Actions::Get.call(self, options)
|
71
|
+
if response.success?
|
72
|
+
new(response.body)
|
73
|
+
else
|
74
|
+
raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
|
75
|
+
end
|
68
76
|
end
|
77
|
+
|
69
78
|
end
|
70
79
|
end
|
71
80
|
|
@@ -52,13 +52,27 @@ module NetSuite
|
|
52
52
|
end
|
53
53
|
|
54
54
|
module Support
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
|
56
|
+
def self.included(base)
|
57
|
+
(class << base; self; end).instance_eval do # We have to do this because Class has a private
|
58
|
+
define_method :initialize do |*args| # #initialize method that this method will override.
|
59
|
+
super(*args)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
base.extend(ClassMethods)
|
63
|
+
end
|
64
|
+
|
65
|
+
module ClassMethods
|
66
|
+
|
67
|
+
def initialize(object)
|
68
|
+
response = NetSuite::Actions::Initialize.call(self, object)
|
69
|
+
if response.success?
|
70
|
+
new(response.body)
|
71
|
+
else
|
72
|
+
raise InitializationError, "#{self}.initialize with #{object} failed."
|
73
|
+
end
|
61
74
|
end
|
75
|
+
|
62
76
|
end
|
63
77
|
end
|
64
78
|
|
@@ -6,13 +6,15 @@ module NetSuite
|
|
6
6
|
include Support::Records
|
7
7
|
include Namespaces::TranSales
|
8
8
|
|
9
|
-
fields :amount, :amount_ordered, :bin_numbers, :cost_estimate, :cost_estimate_type, :current_percent,
|
9
|
+
fields :amount, :amount_ordered, :bin_numbers, :cost_estimate, :cost_estimate_type, :current_percent,
|
10
10
|
:defer_rev_rec, :description, :gift_cert_from, :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email,
|
11
11
|
:gift_cert_recipient_name, :gross_amt, :inventory_detail, :is_taxable, :item_is_fulfilled, :license_code, :line,
|
12
|
-
:options, :order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled,
|
13
|
-
:quantity_ordered, :quantity_remaining, :rate, :rev_rec_end_date, :rev_rec_start_date,
|
14
|
-
:tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral,
|
15
|
-
:vsoe_permit_discount, :vsoe_price
|
12
|
+
:klass, :options, :order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled,
|
13
|
+
:quantity_on_hand, :quantity_ordered, :quantity_remaining, :rate, :rev_rec_end_date, :rev_rec_start_date,
|
14
|
+
:serial_numbers, :ship_group, :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral,
|
15
|
+
:vsoe_delivered, :vsoe_permit_discount, :vsoe_price
|
16
|
+
|
17
|
+
field :custom_field_list, CustomFieldList
|
16
18
|
|
17
19
|
record_refs :department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units
|
18
20
|
|
@@ -29,6 +31,14 @@ module NetSuite
|
|
29
31
|
self.attributes = record.send(:attributes)
|
30
32
|
end
|
31
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
|
+
|
32
42
|
end
|
33
43
|
end
|
34
44
|
end
|
@@ -17,7 +17,7 @@ module NetSuite
|
|
17
17
|
def action(name)
|
18
18
|
case name
|
19
19
|
when :get
|
20
|
-
self.
|
20
|
+
self.send(:include, NetSuite::Actions::Get::Support)
|
21
21
|
when :add
|
22
22
|
self.send(:include, NetSuite::Actions::Add::Support)
|
23
23
|
when :delete
|
@@ -25,12 +25,7 @@ module NetSuite
|
|
25
25
|
when :update
|
26
26
|
self.send(:include, NetSuite::Actions::Update::Support)
|
27
27
|
when :initialize
|
28
|
-
(
|
29
|
-
define_method :initialize do |*args| # #initialize method that this method will override.
|
30
|
-
super(*args)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
self.extend(NetSuite::Actions::Initialize::Support)
|
28
|
+
self.send(:include, NetSuite::Actions::Initialize::Support)
|
34
29
|
else
|
35
30
|
raise "Unknown action: #{name.inspect}"
|
36
31
|
end
|
data/lib/netsuite/version.rb
CHANGED
data/netsuite.gemspec
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe NetSuite::Records::InvoiceItem do
|
4
|
-
let(:
|
4
|
+
let(:item) { NetSuite::Records::InvoiceItem.new }
|
5
5
|
|
6
6
|
it 'has the right fields' do
|
7
7
|
[
|
8
|
-
:amount, :amount_ordered, :bin_numbers, :cost_estimate, :cost_estimate_type, :current_percent, :
|
9
|
-
:
|
10
|
-
:gift_cert_recipient_name, :gross_amt, :inventory_detail, :is_taxable, :item_is_fulfilled, :license_code, :line, :
|
11
|
-
:order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled, :quantity_on_hand,
|
12
|
-
:quantity_remaining, :rate, :rev_rec_end_date, :rev_rec_start_date, :serial_numbers, :ship_group,
|
13
|
-
:tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount,
|
8
|
+
:amount, :amount_ordered, :bin_numbers, :cost_estimate, :cost_estimate_type, :current_percent, :defer_rev_rec,
|
9
|
+
:description, :gift_cert_from, :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email,
|
10
|
+
:gift_cert_recipient_name, :gross_amt, :inventory_detail, :is_taxable, :item_is_fulfilled, :license_code, :line, :klass,
|
11
|
+
:options, :order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled, :quantity_on_hand,
|
12
|
+
:quantity_ordered, :quantity_remaining, :rate, :rev_rec_end_date, :rev_rec_start_date, :serial_numbers, :ship_group,
|
13
|
+
:tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount,
|
14
|
+
:vsoe_price
|
14
15
|
].each do |field|
|
15
|
-
|
16
|
+
item.should have_field(field)
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
@@ -20,24 +21,41 @@ describe NetSuite::Records::InvoiceItem do
|
|
20
21
|
[
|
21
22
|
:department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units
|
22
23
|
].each do |record_ref|
|
23
|
-
|
24
|
+
item.should have_record_ref(record_ref)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
28
|
it 'can initialize from a record' do
|
28
29
|
record = NetSuite::Records::InvoiceItem.new(:amount => 123, :cost_estimate => 234)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
item = NetSuite::Records::InvoiceItem.new(record)
|
31
|
+
item.should be_kind_of(NetSuite::Records::InvoiceItem)
|
32
|
+
item.amount.should eql(123)
|
33
|
+
item.cost_estimate.should eql(234)
|
33
34
|
end
|
34
35
|
|
35
|
-
#
|
36
|
+
describe '#custom_field_list' do
|
37
|
+
it 'can be set from attributes' do
|
38
|
+
attributes = {
|
39
|
+
:custom_field => {
|
40
|
+
:value => 10
|
41
|
+
}
|
42
|
+
}
|
43
|
+
item.custom_field_list = attributes
|
44
|
+
item.custom_field_list.should be_kind_of(NetSuite::Records::CustomFieldList)
|
45
|
+
item.custom_field_list.custom_fields.length.should eql(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'can be set from a CustomFieldList object' do
|
49
|
+
custom_field_list = NetSuite::Records::CustomFieldList.new
|
50
|
+
item.custom_field_list = custom_field_list
|
51
|
+
item.custom_field_list.should eql(custom_field_list)
|
52
|
+
end
|
53
|
+
end
|
36
54
|
|
37
55
|
describe '#to_record' do
|
38
56
|
before do
|
39
|
-
|
40
|
-
|
57
|
+
item.amount = '7'
|
58
|
+
item.description = 'Some thingy'
|
41
59
|
end
|
42
60
|
|
43
61
|
it 'can represent itself as a SOAP record' do
|
@@ -45,13 +63,13 @@ describe NetSuite::Records::InvoiceItem do
|
|
45
63
|
'tranSales:amount' => '7',
|
46
64
|
'tranSales:description' => 'Some thingy'
|
47
65
|
}
|
48
|
-
|
66
|
+
item.to_record.should eql(record)
|
49
67
|
end
|
50
68
|
end
|
51
69
|
|
52
70
|
describe '#record_type' do
|
53
71
|
it 'returns a string of the SOAP record type' do
|
54
|
-
|
72
|
+
item.record_type.should eql('tranSales:InvoiceItem')
|
55
73
|
end
|
56
74
|
end
|
57
75
|
|
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:
|
4
|
+
hash: 89
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 35
|
10
|
+
version: 0.0.35
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Moran
|