netsuite 0.0.10 → 0.0.11
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 +17 -6
- data/lib/netsuite/actions/add.rb +7 -4
- data/lib/netsuite/actions/get.rb +1 -1
- data/lib/netsuite/actions/initialize.rb +1 -1
- data/lib/netsuite/namespaces/list_acct.rb +11 -0
- data/lib/netsuite/namespaces/list_rel.rb +11 -0
- data/lib/netsuite/namespaces/platform_common.rb +11 -0
- data/lib/netsuite/namespaces/platform_core.rb +11 -0
- data/lib/netsuite/namespaces/tran_sales.rb +11 -0
- data/lib/netsuite/records/bill_address.rb +3 -1
- data/lib/netsuite/records/classification.rb +27 -0
- data/lib/netsuite/records/customer.rb +4 -3
- data/lib/netsuite/records/customer_addressbook_list.rb +3 -2
- data/lib/netsuite/records/invoice.rb +18 -15
- data/lib/netsuite/records/invoice_item.rb +34 -0
- data/lib/netsuite/records/invoice_item_list.rb +11 -12
- data/lib/netsuite/records/non_inventory_sale_item.rb +4 -2
- data/lib/netsuite/records/record_ref.rb +8 -2
- data/lib/netsuite/records/ship_address.rb +3 -1
- data/lib/netsuite/support/attributes.rb +22 -0
- data/lib/netsuite/support/fields.rb +54 -0
- data/lib/netsuite/support/record_refs.rb +33 -0
- data/lib/netsuite/support/records.rb +40 -0
- data/lib/netsuite/{savon_support.rb → support/requests.rb} +2 -2
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/records/bill_address_spec.rb +37 -0
- data/spec/netsuite/records/classification_spec.rb +37 -0
- data/spec/netsuite/records/customer_addressbook_list_spec.rb +53 -28
- data/spec/netsuite/records/invoice_item_list_spec.rb +13 -13
- data/spec/netsuite/records/invoice_item_spec.rb +58 -0
- data/spec/netsuite/records/invoice_spec.rb +33 -83
- data/spec/netsuite/records/non_inventory_sale_item_spec.rb +21 -0
- data/spec/netsuite/records/record_ref_spec.rb +26 -0
- data/spec/netsuite/records/ship_address_spec.rb +21 -0
- data/spec/netsuite/support/attributes_spec.rb +5 -0
- data/spec/netsuite/support/fields_spec.rb +60 -0
- data/spec/netsuite/support/record_refs_spec.rb +5 -0
- data/spec/netsuite/{record_support_spec.rb → support/records_spec.rb} +6 -5
- data/spec/netsuite/{savon_support_spec.rb → support/requests_spec.rb} +2 -2
- data/spec/support/read_only_field_matcher.rb +7 -0
- metadata +32 -19
- data/lib/netsuite/attribute_support.rb +0 -16
- data/lib/netsuite/field_support.rb +0 -36
- data/lib/netsuite/record_ref_support.rb +0 -31
- data/lib/netsuite/record_support.rb +0 -17
- data/spec/netsuite/attribute_support_spec.rb +0 -5
- data/spec/netsuite/field_support_spec.rb +0 -34
- data/spec/netsuite/record_ref_support_spec.rb +0 -5
@@ -0,0 +1,33 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Support
|
3
|
+
module RecordRefs
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
|
11
|
+
def record_refs(*names)
|
12
|
+
names.each do |name|
|
13
|
+
record_ref name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def record_ref(name)
|
18
|
+
name_sym = name.to_sym
|
19
|
+
fields << name_sym
|
20
|
+
define_method "#{name}=" do |attrs|
|
21
|
+
attributes[name_sym] = NetSuite::Records::RecordRef.new(attrs)
|
22
|
+
end
|
23
|
+
|
24
|
+
define_method name_sym do
|
25
|
+
attributes[name_sym]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Support
|
3
|
+
module Records
|
4
|
+
include Attributes
|
5
|
+
include Namespaces::PlatformCore
|
6
|
+
|
7
|
+
def to_record
|
8
|
+
attributes.reject { |k,v| self.class.read_only_fields.include?(k) }.inject({}) do |hash, (k,v)|
|
9
|
+
kname = if k == :klass
|
10
|
+
"#{record_namespace}:class"
|
11
|
+
else
|
12
|
+
"#{record_namespace}:#{k.to_s.lower_camelcase}"
|
13
|
+
end
|
14
|
+
if v.respond_to?(:internal_id) && v.internal_id
|
15
|
+
hash[:attributes!] ||= {}
|
16
|
+
hash[:attributes!][kname] ||= {}
|
17
|
+
hash[:attributes!][kname]['internalId'] = v.internal_id
|
18
|
+
end
|
19
|
+
if v.kind_of?(NetSuite::Records::RecordRef) && v.type
|
20
|
+
hash[:attributes!] ||= {}
|
21
|
+
hash[:attributes!][kname] ||= {}
|
22
|
+
hash[:attributes!][kname]['type'] = v.type.lower_camelcase
|
23
|
+
end
|
24
|
+
if Array === v
|
25
|
+
v = v.map { |i| i.respond_to?(:to_record) ? i.to_record : i }
|
26
|
+
else
|
27
|
+
v = v.to_record if v.respond_to?(:to_record)
|
28
|
+
end
|
29
|
+
hash[kname] = v
|
30
|
+
hash
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def record_type
|
35
|
+
"#{record_namespace}:#{self.class.to_s.split('::').last}"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/netsuite/version.rb
CHANGED
@@ -12,4 +12,41 @@ describe NetSuite::Records::BillAddress do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe '#to_record' do
|
16
|
+
before do
|
17
|
+
bill_address.bill_attention = 'Mr. Smith'
|
18
|
+
bill_address.bill_addressee = 'Mr. Robert Smith'
|
19
|
+
bill_address.bill_phone = '1234567890'
|
20
|
+
bill_address.bill_addr1 = '123 Happy Lane'
|
21
|
+
bill_address.bill_addr2 = '#4'
|
22
|
+
bill_address.bill_addr3 = 'Box 6'
|
23
|
+
bill_address.bill_city = 'Los Angeles'
|
24
|
+
bill_address.bill_state = 'CA'
|
25
|
+
bill_address.bill_zip = '90007'
|
26
|
+
bill_address.bill_country = '_unitedStates'
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can represent itself as a SOAP record' do
|
30
|
+
record = {
|
31
|
+
'platformCommon:billAttention' => 'Mr. Smith',
|
32
|
+
'platformCommon:billAddressee' => 'Mr. Robert Smith',
|
33
|
+
'platformCommon:billPhone' => '1234567890',
|
34
|
+
'platformCommon:billAddr1' => '123 Happy Lane',
|
35
|
+
'platformCommon:billAddr2' => '#4',
|
36
|
+
'platformCommon:billAddr3' => 'Box 6',
|
37
|
+
'platformCommon:billCity' => 'Los Angeles',
|
38
|
+
'platformCommon:billState' => 'CA',
|
39
|
+
'platformCommon:billZip' => '90007',
|
40
|
+
'platformCommon:billCountry' => '_unitedStates'
|
41
|
+
}
|
42
|
+
bill_address.to_record.should eql(record)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'record_namespace' do
|
47
|
+
it 'belongs to the platformCommon namespace' do
|
48
|
+
bill_address.record_namespace.should eql('platformCommon')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
15
52
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::Classification do
|
4
|
+
let(:classification) { NetSuite::Records::Classification.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:name, :include_children, :is_inactive, :class_translation_list, :subsidiary_list, :custom_field_list
|
9
|
+
].each do |field|
|
10
|
+
classification.should have_field(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.get' do
|
15
|
+
context 'when the response is successful' do
|
16
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :name => 'Retail' }) }
|
17
|
+
|
18
|
+
it 'returns an Invoice instance populated with the data from the response object' do
|
19
|
+
NetSuite::Actions::Get.should_receive(:call).with(10, NetSuite::Records::Classification).and_return(response)
|
20
|
+
invoice = NetSuite::Records::Classification.get(10)
|
21
|
+
invoice.should be_kind_of(NetSuite::Records::Classification)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when the response is unsuccessful' do
|
26
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
27
|
+
|
28
|
+
it 'raises a RecordNotFound exception' do
|
29
|
+
NetSuite::Actions::Get.should_receive(:call).with(10, NetSuite::Records::Classification).and_return(response)
|
30
|
+
lambda {
|
31
|
+
NetSuite::Records::Classification.get(10)
|
32
|
+
}.should raise_error(NetSuite::RecordNotFound, 'NetSuite::Records::Classification with ID=10 could not be found')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -19,53 +19,78 @@ describe NetSuite::Records::CustomerAddressbookList do
|
|
19
19
|
}
|
20
20
|
}
|
21
21
|
end
|
22
|
-
let(:
|
22
|
+
let(:list) { NetSuite::Records::CustomerAddressbookList.new(attributes) }
|
23
23
|
|
24
24
|
it 'has all the right fields' do
|
25
25
|
[
|
26
26
|
:default_shipping, :default_billing, :is_residential, :label, :attention, :addressee,
|
27
27
|
:phone, :addr1, :addr2, :addr3, :city, :zip, :country, :addr_text, :override, :state
|
28
28
|
].each do |field|
|
29
|
-
|
29
|
+
list.should have_field(field)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe '#initialize' do
|
34
34
|
context 'when taking in a hash of attributes' do
|
35
35
|
it 'sets the attributes for the object given the attributes hash' do
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
36
|
+
list.addr1.should eql('123 Happy Lane')
|
37
|
+
list.addr_text.should eql("123 Happy Lane\nLos Angeles CA 90007")
|
38
|
+
list.city.should eql('Los Angeles')
|
39
|
+
list.country.should eql('_unitedStates')
|
40
|
+
list.default_billing.should be_true
|
41
|
+
list.default_shipping.should be_true
|
42
|
+
list.is_residential.should be_false
|
43
|
+
list.label.should eql('123 Happy Lane')
|
44
|
+
list.override.should be_false
|
45
|
+
list.state.should eql('CA')
|
46
|
+
list.zip.should eql('90007')
|
47
|
+
list.internal_id.should eql('567')
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
context 'when taking in a CustomerAddressbookList instance' do
|
52
52
|
it 'sets the attributes for the object given the record attributes' do
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
53
|
+
old_list = NetSuite::Records::CustomerAddressbookList.new(attributes)
|
54
|
+
list = NetSuite::Records::CustomerAddressbookList.new(old_list)
|
55
|
+
list.addr1.should eql('123 Happy Lane')
|
56
|
+
list.addr_text.should eql("123 Happy Lane\nLos Angeles CA 90007")
|
57
|
+
list.city.should eql('Los Angeles')
|
58
|
+
list.country.should eql('_unitedStates')
|
59
|
+
list.default_billing.should be_true
|
60
|
+
list.default_shipping.should be_true
|
61
|
+
list.is_residential.should be_false
|
62
|
+
list.label.should eql('123 Happy Lane')
|
63
|
+
list.override.should be_false
|
64
|
+
list.state.should eql('CA')
|
65
|
+
list.zip.should eql('90007')
|
66
|
+
list.internal_id.should eql('567')
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
describe '#to_record' do
|
72
|
+
it 'can represent itself as a SOAP record' do
|
73
|
+
record = {
|
74
|
+
'listRel:addr1' => '123 Happy Lane',
|
75
|
+
'listRel:addrText' => "123 Happy Lane\nLos Angeles CA 90007",
|
76
|
+
'listRel:city' => 'Los Angeles',
|
77
|
+
'listRel:country' => '_unitedStates',
|
78
|
+
'listRel:defaultBilling' => true,
|
79
|
+
'listRel:defaultShipping' => true,
|
80
|
+
'listRel:isResidential' => false,
|
81
|
+
'listRel:label' => '123 Happy Lane',
|
82
|
+
'listRel:override' => false,
|
83
|
+
'listRel:state' => 'CA',
|
84
|
+
'listRel:zip' => '90007'
|
85
|
+
}
|
86
|
+
list.to_record.should eql(record)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#record_type' do
|
91
|
+
it 'returns a string of the record SOAP type' do
|
92
|
+
list.record_type.should eql('listRel:CustomerAddressbookList')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
71
96
|
end
|
@@ -2,23 +2,23 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe NetSuite::Records::InvoiceItemList do
|
4
4
|
let(:list) { NetSuite::Records::InvoiceItemList.new }
|
5
|
+
let(:item) { NetSuite::Records::InvoiceItem.new }
|
5
6
|
|
6
|
-
it '
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
it 'can have items be added to it' do
|
8
|
+
list.add_item(item)
|
9
|
+
item_list = list.send(:items)
|
10
|
+
item_list.should be_kind_of(Array)
|
11
|
+
item_list.length.should eql(1)
|
12
|
+
item_list.each { |i| i.should be_kind_of(NetSuite::Records::InvoiceItem) }
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
describe '#to_record' do
|
16
|
+
it 'can represent itself as a SOAP record' do
|
17
|
+
record = {
|
18
|
+
'tranSales:item' => []
|
19
|
+
}
|
20
|
+
list.to_record.should eql(record)
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
# :class RecordRef
|
23
|
-
|
24
24
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::InvoiceItem do
|
4
|
+
let(:list) { NetSuite::Records::InvoiceItem.new }
|
5
|
+
|
6
|
+
it 'has the right fields' do
|
7
|
+
[
|
8
|
+
:amount, :amount_ordered, :bin_numbers, :cost_estimate, :cost_estimate_type, :current_percent, :custom_field_list,
|
9
|
+
:defer_rev_rec, :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, :options,
|
11
|
+
:order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled, :quantity_on_hand, :quantity_ordered,
|
12
|
+
:quantity_remaining, :rate, :rev_rec_end_date, :rev_rec_start_date, :serial_numbers, :ship_group, :tax1_amt, :tax_rate1,
|
13
|
+
:tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price
|
14
|
+
].each do |field|
|
15
|
+
list.should have_field(field)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has the right record_refs' do
|
20
|
+
[
|
21
|
+
:department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units
|
22
|
+
].each do |record_ref|
|
23
|
+
list.should have_record_ref(record_ref)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'can initialize from a record' do
|
28
|
+
record = NetSuite::Records::InvoiceItem.new(:amount => 123, :cost_estimate => 234)
|
29
|
+
list = NetSuite::Records::InvoiceItem.new(record)
|
30
|
+
list.should be_kind_of(NetSuite::Records::InvoiceItem)
|
31
|
+
list.amount.should eql(123)
|
32
|
+
list.cost_estimate.should eql(234)
|
33
|
+
end
|
34
|
+
|
35
|
+
# :class RecordRef
|
36
|
+
|
37
|
+
describe '#to_record' do
|
38
|
+
before do
|
39
|
+
list.amount = '7'
|
40
|
+
list.description = 'Some thingy'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'can represent itself as a SOAP record' do
|
44
|
+
record = {
|
45
|
+
'tranSales:amount' => '7',
|
46
|
+
'tranSales:description' => 'Some thingy'
|
47
|
+
}
|
48
|
+
list.to_record.should eql(record)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#record_type' do
|
53
|
+
it 'returns a string of the SOAP record type' do
|
54
|
+
list.record_type.should eql('tranSales:InvoiceItem')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -10,31 +10,39 @@ describe NetSuite::Records::Invoice do
|
|
10
10
|
:alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :balance, :bill_address,
|
11
11
|
:billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name, :custom_field_list,
|
12
12
|
:deferred_revenue, :department, :discount_amount, :discount_date, :discount_item, :discount_rate,
|
13
|
-
:
|
13
|
+
:due_date, :email, :end_date, :est_gross_profit, :est_gross_profit_percent, :exchange_rate,
|
14
14
|
:exclude_commission, :exp_cost_disc_amount, :exp_cost_disc_print, :exp_cost_disc_rate, :exp_cost_disc_tax_1_amt,
|
15
15
|
:exp_cost_disc_taxable, :exp_cost_discount, :exp_cost_list, :exp_cost_tax_code, :exp_cost_tax_rate_1,
|
16
16
|
:exp_cost_tax_rate_2, :fax, :fob, :gift_cert_applied, :gift_cert_redemption_list, :handling_cost, :handling_tax_1_rate,
|
17
17
|
:handling_tax_2_rate, :handling_tax_code, :is_taxable, :item_cost_disc_amount, :item_cost_disc_print,
|
18
18
|
:item_cost_disc_rate, :item_cost_disc_tax_1_amt, :item_cost_disc_taxable, :item_cost_discount, :item_cost_list,
|
19
|
-
:item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :job, :
|
19
|
+
:item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :job, :last_modified_date,
|
20
20
|
:lead_source, :linked_tracking_numbers, :location, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
|
21
21
|
:other_ref_name, :partner, :partners_list, :promo_code, :recognized_revenue, :rev_rec_end_date,
|
22
22
|
:rev_rec_on_rev_commitment, :rev_rec_schedule, :rev_rec_start_date, :revenue_status, :sales_effective_date,
|
23
23
|
:sales_group, :sales_rep, :sales_team_list, :ship_address, :ship_date, :ship_group_list,
|
24
24
|
:ship_method, :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :shipping_tax_code, :source, :start_date,
|
25
|
-
:status, :
|
25
|
+
:status, :subsidiary, :sync_partner_teams, :sync_sales_teams, :tax_2_total, :tax_item, :tax_rate,
|
26
26
|
:tax_total, :terms, :time_disc_amount, :time_disc_print, :time_disc_rate, :time_disc_tax_1_amt, :time_disc_taxable,
|
27
27
|
:time_discount, :time_list, :time_tax_code, :time_tax_rate_1, :time_tax_rate_2, :to_be_emailed, :to_be_faxed,
|
28
|
-
:to_be_printed, :
|
28
|
+
:to_be_printed, :total_cost_estimate, :tracking_numbers, :tran_date, :tran_id, :tran_is_vsoe_bundle,
|
29
29
|
:vat_reg_num, :vsoe_auto_calc
|
30
30
|
].each do |field|
|
31
31
|
invoice.should have_field(field)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
it 'has all the right read_only_fields' do
|
36
|
+
[
|
37
|
+
:sub_total, :discount_total, :total
|
38
|
+
].each do |field|
|
39
|
+
NetSuite::Records::Invoice.should have_read_only_field(field)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
35
43
|
it 'has the right record_refs' do
|
36
44
|
[
|
37
|
-
:account, :bill_address_list, :custom_form, :entity, :posting_period, :ship_address_list
|
45
|
+
:account, :bill_address_list, :custom_form, :entity, :klass, :posting_period, :ship_address_list
|
38
46
|
].each do |record_ref|
|
39
47
|
invoice.should have_record_ref(record_ref)
|
40
48
|
end
|
@@ -43,89 +51,11 @@ describe NetSuite::Records::Invoice do
|
|
43
51
|
describe 'item_list' do
|
44
52
|
context 'when the attributes constitute an Array of items' do
|
45
53
|
it 'builds an InvoiceItemList for each list item_list field' do
|
46
|
-
invoice.item_list = {
|
47
|
-
:item => [
|
48
|
-
{
|
49
|
-
:amount => '15993.6',
|
50
|
-
:item => {
|
51
|
-
:@internal_id => '217',
|
52
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
53
|
-
:name => 'Dummy Item For Import'
|
54
|
-
},
|
55
|
-
:line => '1',
|
56
|
-
:price => {
|
57
|
-
:@internal_id => '-1',
|
58
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
59
|
-
:name => ' '
|
60
|
-
},
|
61
|
-
:quantity => '1.0',
|
62
|
-
:tax_code => {
|
63
|
-
:@internal_id => '-8',
|
64
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
65
|
-
:name => '-Not Taxable-'
|
66
|
-
}
|
67
|
-
},
|
68
|
-
{
|
69
|
-
:amount => '499.0',
|
70
|
-
:defer_rev_rec => false,
|
71
|
-
:item => {
|
72
|
-
:@internal_id => '111',
|
73
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
74
|
-
:name => 'SAT Prep Course'
|
75
|
-
},
|
76
|
-
:line => '2',
|
77
|
-
:price => {
|
78
|
-
:@internal_id => '1',
|
79
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
80
|
-
:name => 'Base Price'
|
81
|
-
},
|
82
|
-
:quantity => '1.0',
|
83
|
-
:rate => '499.00',
|
84
|
-
:tax_code => {
|
85
|
-
:@internal_id => '-8',
|
86
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
87
|
-
:name => '-Not Taxable-'
|
88
|
-
}
|
89
|
-
}
|
90
|
-
]
|
91
|
-
}
|
92
|
-
invoice.item_list.should be_kind_of(Array)
|
93
|
-
invoice.item_list.each { |il| il.should be_kind_of(NetSuite::Records::InvoiceItemList) }
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'when the attributes constitute a single item' do
|
98
|
-
it 'builds an InvoiceItemList for the item_list field' do
|
99
|
-
invoice.item_list = {
|
100
|
-
:item => {
|
101
|
-
:amount => '15993.6',
|
102
|
-
:item => {
|
103
|
-
:@internal_id => '217',
|
104
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
105
|
-
:name => 'Dummy Item For Import'
|
106
|
-
},
|
107
|
-
:line => '1',
|
108
|
-
:price => {
|
109
|
-
:@internal_id => '-1',
|
110
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
111
|
-
:name => ' '
|
112
|
-
},
|
113
|
-
:quantity => '1.0',
|
114
|
-
:tax_code => {
|
115
|
-
:@internal_id => '-8',
|
116
|
-
:"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
|
117
|
-
:name => '-Not Taxable-'
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
54
|
invoice.item_list.should be_kind_of(NetSuite::Records::InvoiceItemList)
|
122
55
|
end
|
123
56
|
end
|
124
57
|
end
|
125
58
|
|
126
|
-
it 'handles the "klass" field correctly'
|
127
|
-
# This field maps to 'class' but cannot be set as such in Ruby as it will cause runtime errors.
|
128
|
-
|
129
59
|
describe '.get' do
|
130
60
|
context 'when the response is successful' do
|
131
61
|
let(:response) { NetSuite::Response.new(:success => true, :body => { :is_person => true }) }
|
@@ -220,4 +150,24 @@ describe NetSuite::Records::Invoice do
|
|
220
150
|
end
|
221
151
|
end
|
222
152
|
|
153
|
+
describe '#to_record' do
|
154
|
+
before do
|
155
|
+
invoice.email = 'something@example.com'
|
156
|
+
invoice.tran_id = '4'
|
157
|
+
end
|
158
|
+
it 'can represent itself as a SOAP record' do
|
159
|
+
record = {
|
160
|
+
'tranSales:email' => 'something@example.com',
|
161
|
+
'tranSales:tranId' => '4'
|
162
|
+
}
|
163
|
+
invoice.to_record.should eql(record)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
describe '#record_type' do
|
168
|
+
it 'returns a string representation of the SOAP type' do
|
169
|
+
invoice.record_type.should eql('tranSales:Invoice')
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
223
173
|
end
|