netsuite 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/netsuite.rb +1 -0
- data/lib/netsuite/records/invoice.rb +9 -0
- data/lib/netsuite/records/invoice_item_list.rb +23 -0
- data/lib/netsuite/records/non_inventory_sale_item.rb +4 -0
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/records/invoice_item_list_spec.rb +24 -0
- data/spec/netsuite/records/invoice_spec.rb +84 -1
- metadata +7 -4
data/lib/netsuite.rb
CHANGED
@@ -44,6 +44,15 @@ module NetSuite
|
|
44
44
|
attributes[:transaction_ship_address] = ShipAddress.new(attrs)
|
45
45
|
end
|
46
46
|
|
47
|
+
def item_list=(attrs)
|
48
|
+
attributes[:item_list] = case attrs[:item]
|
49
|
+
when Hash
|
50
|
+
InvoiceItemList.new(attrs[:item])
|
51
|
+
when Array
|
52
|
+
attrs[:item].map { |item| InvoiceItemList.new(item) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
47
56
|
def self.get(id)
|
48
57
|
response = Actions::Get.call(id, self)
|
49
58
|
if response.success?
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class InvoiceItemList
|
4
|
+
include FieldSupport
|
5
|
+
include RecordRefSupport
|
6
|
+
|
7
|
+
fields :amount, :amount_ordered, :bin_numbers, :cost_estimate, :cost_estimate_type, :current_percent, :custom_field_list,
|
8
|
+
:defer_rev_rec, :description, :gift_cert_from, :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email,
|
9
|
+
:gift_cert_recipient_name, :gross_amt, :inventory_detail, :is_taxable, :item_is_fulfilled, :license_code, :line,
|
10
|
+
:options, :order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled, :quantity_on_hand,
|
11
|
+
:quantity_ordered, :quantity_remaining, :rate, :rev_rec_end_date, :rev_rec_start_date, :serial_numbers, :ship_group,
|
12
|
+
:tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered,
|
13
|
+
:vsoe_permit_discount, :vsoe_price
|
14
|
+
|
15
|
+
record_refs :department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units
|
16
|
+
|
17
|
+
def initialize(attributes = {})
|
18
|
+
initialize_from_attributes_hash(attributes)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -25,7 +25,11 @@ module NetSuite
|
|
25
25
|
:rev_rec_schedule, :sale_unit, :sales_tax_code, :ship_package, :store_display_image, :store_display_thumbnail,
|
26
26
|
:store_item_template, :subsidiary_list, :tax_schedule, :units_type
|
27
27
|
|
28
|
+
attr_reader :internal_id, :external_id
|
29
|
+
|
28
30
|
def initialize(attributes = {})
|
31
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
32
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
29
33
|
initialize_from_attributes_hash(attributes)
|
30
34
|
end
|
31
35
|
|
data/lib/netsuite/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::InvoiceItemList do
|
4
|
+
let(:list) { NetSuite::Records::InvoiceItemList.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, :defer_rev_rec, :description, :gift_cert_from, :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email, :gift_cert_recipient_name, :gross_amt, :inventory_detail, :is_taxable, :item_is_fulfilled, :license_code, :line, :options, :order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled, :quantity_on_hand, :quantity_ordered, :quantity_remaining, :rate, :rev_rec_end_date, :rev_rec_start_date, :serial_numbers, :ship_group, :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price
|
9
|
+
].each do |field|
|
10
|
+
list.should have_field(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has the right record_refs' do
|
15
|
+
[
|
16
|
+
:department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units
|
17
|
+
].each do |record_ref|
|
18
|
+
list.should have_record_ref(record_ref)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# :class RecordRef
|
23
|
+
|
24
|
+
end
|
@@ -16,7 +16,7 @@ describe NetSuite::Records::Invoice do
|
|
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, :
|
19
|
+
:item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :job, :klass, :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,
|
@@ -40,6 +40,89 @@ describe NetSuite::Records::Invoice do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
describe 'item_list' do
|
44
|
+
context 'when the attributes constitute an Array of items' do
|
45
|
+
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
|
+
invoice.item_list.should be_kind_of(NetSuite::Records::InvoiceItemList)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
43
126
|
it 'handles the "klass" field correctly'
|
44
127
|
# This field maps to 'class' but cannot be set as such in Ruby as it will cause runtime errors.
|
45
128
|
|
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: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
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
|
+
date: 2012-01-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: savon
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/netsuite/records/customer.rb
|
114
114
|
- lib/netsuite/records/customer_addressbook_list.rb
|
115
115
|
- lib/netsuite/records/invoice.rb
|
116
|
+
- lib/netsuite/records/invoice_item_list.rb
|
116
117
|
- lib/netsuite/records/non_inventory_sale_item.rb
|
117
118
|
- lib/netsuite/records/record_ref.rb
|
118
119
|
- lib/netsuite/records/ship_address.rb
|
@@ -131,6 +132,7 @@ files:
|
|
131
132
|
- spec/netsuite/records/bill_address_spec.rb
|
132
133
|
- spec/netsuite/records/customer_addressbook_list_spec.rb
|
133
134
|
- spec/netsuite/records/customer_spec.rb
|
135
|
+
- spec/netsuite/records/invoice_item_list_spec.rb
|
134
136
|
- spec/netsuite/records/invoice_spec.rb
|
135
137
|
- spec/netsuite/records/non_inventory_sale_item_spec.rb
|
136
138
|
- spec/netsuite/records/record_ref_spec.rb
|
@@ -194,6 +196,7 @@ test_files:
|
|
194
196
|
- spec/netsuite/records/bill_address_spec.rb
|
195
197
|
- spec/netsuite/records/customer_addressbook_list_spec.rb
|
196
198
|
- spec/netsuite/records/customer_spec.rb
|
199
|
+
- spec/netsuite/records/invoice_item_list_spec.rb
|
197
200
|
- spec/netsuite/records/invoice_spec.rb
|
198
201
|
- spec/netsuite/records/non_inventory_sale_item_spec.rb
|
199
202
|
- spec/netsuite/records/record_ref_spec.rb
|