netsuite 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile +2 -0
- data/README.md +132 -54
- data/lib/netsuite.rb +123 -76
- data/lib/netsuite/actions/add.rb +1 -0
- data/lib/netsuite/actions/delete.rb +1 -0
- data/lib/netsuite/actions/get.rb +1 -0
- data/lib/netsuite/actions/get_all.rb +67 -0
- data/lib/netsuite/actions/get_list.rb +2 -1
- data/lib/netsuite/actions/get_select_value.rb +1 -0
- data/lib/netsuite/actions/initialize.rb +1 -0
- data/lib/netsuite/actions/login.rb +2 -0
- data/lib/netsuite/actions/search.rb +3 -2
- data/lib/netsuite/actions/update.rb +18 -0
- data/lib/netsuite/actions/upsert.rb +1 -0
- data/lib/netsuite/actions/upsert_list.rb +114 -0
- data/lib/netsuite/configuration.rb +5 -0
- data/lib/netsuite/namespaces/file_cabinet.rb +11 -0
- data/lib/netsuite/namespaces/list_emp.rb +12 -0
- data/lib/netsuite/namespaces/list_mkt.rb +12 -0
- data/lib/netsuite/namespaces/list_website.rb +11 -0
- data/lib/netsuite/namespaces/tran_invt.rb +11 -0
- data/lib/netsuite/records/accounting_period.rb +1 -1
- data/lib/netsuite/records/assembly_item.rb +10 -4
- data/lib/netsuite/records/billing_schedule.rb +33 -0
- data/lib/netsuite/records/billing_schedule_milestone.rb +28 -0
- data/lib/netsuite/records/billing_schedule_milestone_list.rb +33 -0
- data/lib/netsuite/records/billing_schedule_recurrence.rb +28 -0
- data/lib/netsuite/records/billing_schedule_recurrence_list.rb +33 -0
- data/lib/netsuite/records/bin.rb +22 -0
- data/lib/netsuite/records/campaign.rb +28 -0
- data/lib/netsuite/records/cash_refund.rb +1 -1
- data/lib/netsuite/records/classification.rb +1 -1
- data/lib/netsuite/records/contact.rb +1 -1
- data/lib/netsuite/records/contact_access_roles.rb +14 -0
- data/lib/netsuite/records/contact_access_roles_list.rb +9 -0
- data/lib/netsuite/records/custom_field.rb +2 -1
- data/lib/netsuite/records/custom_field_list.rb +23 -4
- data/lib/netsuite/records/custom_list.rb +27 -0
- data/lib/netsuite/records/custom_list_custom_value.rb +14 -0
- data/lib/netsuite/records/custom_list_custom_value_list.rb +13 -0
- data/lib/netsuite/records/custom_record.rb +1 -1
- data/lib/netsuite/records/custom_record_type.rb +1 -1
- data/lib/netsuite/records/customer.rb +4 -4
- data/lib/netsuite/records/customer_addressbook.rb +8 -5
- data/lib/netsuite/records/customer_addressbook_list.rb +13 -1
- data/lib/netsuite/records/customer_deposit.rb +3 -2
- data/lib/netsuite/records/customer_payment.rb +1 -1
- data/lib/netsuite/records/customer_refund.rb +1 -1
- data/lib/netsuite/records/department.rb +4 -2
- data/lib/netsuite/records/deposit.rb +1 -1
- data/lib/netsuite/records/deposit_cash_back.rb +2 -2
- data/lib/netsuite/records/deposit_other.rb +2 -2
- data/lib/netsuite/records/discount_item.rb +32 -0
- data/lib/netsuite/records/employee.rb +20 -0
- data/lib/netsuite/records/file.rb +28 -0
- data/lib/netsuite/records/inventory_assignment.rb +24 -0
- data/lib/netsuite/records/inventory_assignment_list.rb +32 -0
- data/lib/netsuite/records/inventory_detail.rb +18 -0
- data/lib/netsuite/records/inventory_transfer.rb +29 -0
- data/lib/netsuite/records/inventory_transfer_inventory.rb +21 -0
- data/lib/netsuite/records/inventory_transfer_inventory_list.rb +33 -0
- data/lib/netsuite/records/item_fulfillment.rb +1 -1
- data/lib/netsuite/records/item_fulfillment_item_list.rb +3 -21
- data/lib/netsuite/records/item_member.rb +21 -0
- data/lib/netsuite/records/journal_entry.rb +1 -1
- data/lib/netsuite/records/kit_item.rb +1 -1
- data/lib/netsuite/records/location.rb +3 -1
- data/lib/netsuite/records/member_list.rb +32 -0
- data/lib/netsuite/records/non_inventory_sale_item.rb +4 -1
- data/lib/netsuite/records/partner.rb +21 -0
- data/lib/netsuite/records/promotion_code.rb +38 -0
- data/lib/netsuite/records/record_ref_list.rb +40 -0
- data/lib/netsuite/records/role_list.rb +25 -0
- data/lib/netsuite/records/sales_order.rb +6 -2
- data/lib/netsuite/records/sales_tax_item.rb +32 -0
- data/lib/netsuite/records/site_category.rb +33 -0
- data/lib/netsuite/records/subsidiary.rb +38 -0
- data/lib/netsuite/records/tax_type.rb +22 -0
- data/lib/netsuite/records/term.rb +1 -1
- data/lib/netsuite/records/units_type.rb +25 -0
- data/lib/netsuite/records/units_type_uom.rb +20 -0
- data/lib/netsuite/records/units_type_uom_list.rb +33 -0
- data/lib/netsuite/records/work_order.rb +38 -0
- data/lib/netsuite/records/work_order_item.rb +31 -0
- data/lib/netsuite/records/work_order_item_list.rb +31 -0
- data/lib/netsuite/support/actions.rb +4 -0
- data/lib/netsuite/support/base.rb +21 -0
- data/lib/netsuite/support/country.rb +273 -0
- data/lib/netsuite/support/search_result.rb +4 -0
- data/lib/netsuite/support/sublist.rb +54 -0
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/actions/search_spec.rb +1 -1
- data/spec/netsuite/actions/update_spec.rb +62 -31
- data/spec/netsuite/actions/upsert_list_spec.rb +112 -0
- data/spec/netsuite/records/account_spec.rb +4 -4
- data/spec/netsuite/records/accounting_period_spec.rb +4 -4
- data/spec/netsuite/records/assembly_item_spec.rb +38 -0
- data/spec/netsuite/records/billing_schedule_milestone_list_spec.rb +24 -0
- data/spec/netsuite/records/billing_schedule_milestone_spec.rb +51 -0
- data/spec/netsuite/records/billing_schedule_recurrence_list_spec.rb +24 -0
- data/spec/netsuite/records/billing_schedule_recurrence_spec.rb +49 -0
- data/spec/netsuite/records/billing_schedule_spec.rb +164 -0
- data/spec/netsuite/records/campaign_spec.rb +43 -0
- data/spec/netsuite/records/cash_refund_spec.rb +1 -1
- data/spec/netsuite/records/classification_spec.rb +2 -2
- data/spec/netsuite/records/credit_memo_spec.rb +4 -4
- data/spec/netsuite/records/custom_field_list_spec.rb +10 -0
- data/spec/netsuite/records/custom_list_spec.rb +21 -0
- data/spec/netsuite/records/custom_record_spec.rb +5 -5
- data/spec/netsuite/records/custom_record_type_spec.rb +5 -5
- data/spec/netsuite/records/customer_addressbook_list_spec.rb +19 -1
- data/spec/netsuite/records/customer_addressbook_spec.rb +42 -13
- data/spec/netsuite/records/customer_payment_spec.rb +4 -4
- data/spec/netsuite/records/customer_refund_spec.rb +4 -4
- data/spec/netsuite/records/customer_spec.rb +80 -6
- data/spec/netsuite/records/department_spec.rb +4 -4
- data/spec/netsuite/records/deposit_spec.rb +22 -4
- data/spec/netsuite/records/discount_item_spec.rb +124 -0
- data/spec/netsuite/records/inventory_item_spec.rb +4 -4
- data/spec/netsuite/records/inventory_transfer_spec.rb +58 -0
- data/spec/netsuite/records/invoice_spec.rb +4 -4
- data/spec/netsuite/records/job_spec.rb +7 -7
- data/spec/netsuite/records/journal_entry_spec.rb +5 -5
- data/spec/netsuite/records/non_inventory_sale_item_spec.rb +4 -4
- data/spec/netsuite/records/payment_method_spec.rb +1 -1
- data/spec/netsuite/records/pomo_code_spec.rb +40 -0
- data/spec/netsuite/records/sales_order_spec.rb +18 -18
- data/spec/netsuite/records/sales_tax_item_spec.rb +30 -0
- data/spec/netsuite/records/service_sale_item_spec.rb +4 -4
- data/spec/netsuite/records/site_category_spec.rb +51 -0
- data/spec/netsuite/records/subsidiary_spec.rb +25 -0
- data/spec/netsuite/records/support_case_spec.rb +8 -8
- data/spec/netsuite/records/tax_type_spec.rb +11 -0
- data/spec/netsuite/records/term_spec.rb +4 -4
- data/spec/netsuite/records/units_type_spec.rb +33 -0
- data/spec/netsuite/records/units_type_uom_list_spec.rb +23 -0
- data/spec/netsuite/records/units_type_uom_spec.rb +14 -0
- data/spec/netsuite/records/work_order_item_list_spec.rb +26 -0
- data/spec/netsuite/records/work_order_item_spec.rb +45 -0
- data/spec/netsuite/records/work_order_spec.rb +92 -0
- data/spec/netsuite/support/record_refs_spec.rb +1 -1
- data/spec/netsuite/support/sublist_spec.rb +36 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/fixtures/update/update_customer_error.xml +21 -0
- data/spec/support/fixtures/update/update_customer_multiple_errors.xml +25 -0
- data/spec/support/fixtures/upsert_list/upsert_list_customers.xml +21 -0
- data/spec/support/fixtures/upsert_list/upsert_list_one_customer.xml +17 -0
- data/spec/support/fixtures/upsert_list/upsert_list_with_errors.xml +32 -0
- data/spec/support/read_only_field_matcher.rb +1 -1
- metadata +115 -5
- checksums.yaml +0 -15
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::SiteCategory do
|
4
|
+
let(:site_category) { NetSuite::Records::SiteCategory.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:description, :exclude_from_site_map, :is_inactive, :is_online,
|
9
|
+
:item_id, :meta_tag_html, :page_title, :presentation_item_list,
|
10
|
+
:search_keywords, :sitemap_priority, :store_detailed_description,
|
11
|
+
:translations_list, :url_component
|
12
|
+
].each do |field|
|
13
|
+
site_category.should have_field(field)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has the right record_refs' do
|
18
|
+
[
|
19
|
+
:category_list_layout, :correlated_items_list_layout, :item_list_layout, :parent_category,
|
20
|
+
:related_items_list_layout, :store_display_image, :store_display_thumbnail, :website
|
21
|
+
].each do |record_ref|
|
22
|
+
site_category.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 => { :url_component => 'some url' }) }
|
29
|
+
|
30
|
+
it 'returns a SiteCategory instance populated with the data from the response object' do
|
31
|
+
NetSuite::Actions::Get.should_receive(:call).with([NetSuite::Records::SiteCategory, :external_id => 1], {}).and_return(response)
|
32
|
+
site_category = NetSuite::Records::SiteCategory.get(:external_id => 1)
|
33
|
+
site_category.should be_kind_of(NetSuite::Records::SiteCategory)
|
34
|
+
site_category.url_component.should == 'some url'
|
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::SiteCategory, :external_id => 1], {}).and_return(response)
|
43
|
+
lambda {
|
44
|
+
NetSuite::Records::SiteCategory.get(:external_id => 1)
|
45
|
+
}.should raise_error(NetSuite::RecordNotFound,
|
46
|
+
/NetSuite::Records::SiteCategory with OPTIONS=(.*) could not be found/)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::Subsidiary do
|
4
|
+
let(:subsidiary) { described_class.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[ :name, :is_inactive, :show_subsidiary_name, :url, :tran_prefix, :attention,
|
8
|
+
:addressee, :addr_phone, :addr1, :addr2, :addr3, :city, :state, :zip,
|
9
|
+
:country, :addr_text, :override, :ship_addr, :return_addr, :return_address1,
|
10
|
+
:return_address2, :return_city, :return_state, :return_country, :return_zip,
|
11
|
+
:legal_name, :is_elimination, :allow_payroll, :email, :fax, :edition,
|
12
|
+
:federal_id_number, :addr_language, :non_consol, :consol, :ship_address1,
|
13
|
+
:ship_address2, :ship_city, :ship_state, :ship_country, :ship_zip,
|
14
|
+
:state1_tax_number, :ssn_or_tin, :inbound_email ].each do |field|
|
15
|
+
subsidiary.should have_field(field)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has all the right record refs' do
|
20
|
+
[ :check_layout, :inter_co_account, :parent, :logo, :page_logo,
|
21
|
+
:fiscal_calendar, :tax_fiscal_calendar, :currency ].each do |record_ref|
|
22
|
+
subsidiary.should have_record_ref(record_ref)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -5,8 +5,8 @@ describe NetSuite::Records::SupportCase do
|
|
5
5
|
|
6
6
|
it 'has all the right fields' do
|
7
7
|
[
|
8
|
-
:end_date, :incoming_message, :outgoing_message, :search_solution, :email_form,
|
9
|
-
:internal_only, :title, :case_number, :start_date, :email, :phone, :inbound_email,
|
8
|
+
:end_date, :incoming_message, :outgoing_message, :search_solution, :email_form,
|
9
|
+
:internal_only, :title, :case_number, :start_date, :email, :phone, :inbound_email,
|
10
10
|
:is_inactive, :help_desk
|
11
11
|
].each do |field|
|
12
12
|
support_case.should have_field(field)
|
@@ -76,7 +76,7 @@ describe NetSuite::Records::SupportCase do
|
|
76
76
|
NetSuite::Actions::Add.should_receive(:call).
|
77
77
|
with([support_case], {}).
|
78
78
|
and_return(response)
|
79
|
-
support_case.add.should
|
79
|
+
support_case.add.should be_truthy
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -87,7 +87,7 @@ describe NetSuite::Records::SupportCase do
|
|
87
87
|
NetSuite::Actions::Add.should_receive(:call).
|
88
88
|
with([support_case], {}).
|
89
89
|
and_return(response)
|
90
|
-
support_case.add.should
|
90
|
+
support_case.add.should be_falsey
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -100,7 +100,7 @@ describe NetSuite::Records::SupportCase do
|
|
100
100
|
NetSuite::Actions::Delete.should_receive(:call).
|
101
101
|
with([support_case], {}).
|
102
102
|
and_return(response)
|
103
|
-
support_case.delete.should
|
103
|
+
support_case.delete.should be_truthy
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -111,7 +111,7 @@ describe NetSuite::Records::SupportCase do
|
|
111
111
|
NetSuite::Actions::Delete.should_receive(:call).
|
112
112
|
with([support_case], {}).
|
113
113
|
and_return(response)
|
114
|
-
support_case.delete.should
|
114
|
+
support_case.delete.should be_falsey
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -123,7 +123,7 @@ describe NetSuite::Records::SupportCase do
|
|
123
123
|
it 'returns true' do
|
124
124
|
NetSuite::Actions::Update.should_receive(:call).with([NetSuite::Records::SupportCase, :external_id => 1, :title => 'Case title'], {}).and_return(response)
|
125
125
|
support_case = NetSuite::Records::SupportCase.new(:external_id => 1)
|
126
|
-
support_case.update(:title => 'Case title').should
|
126
|
+
support_case.update(:title => 'Case title').should be_truthy
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -133,7 +133,7 @@ describe NetSuite::Records::SupportCase do
|
|
133
133
|
it 'raises a RecordNotFound exception' do
|
134
134
|
NetSuite::Actions::Update.should_receive(:call).with([NetSuite::Records::SupportCase, :internal_id => 1, :title => 'Case title'], {}).and_return(response)
|
135
135
|
support_case = NetSuite::Records::SupportCase.new(:internal_id => 1)
|
136
|
-
support_case.update(:title => 'Case title').should
|
136
|
+
support_case.update(:title => 'Case title').should be_falsey
|
137
137
|
end
|
138
138
|
end
|
139
139
|
end
|
@@ -48,7 +48,7 @@ describe NetSuite::Records::Term do
|
|
48
48
|
NetSuite::Actions::Add.should_receive(:call).
|
49
49
|
with([term], {}).
|
50
50
|
and_return(response)
|
51
|
-
term.add.should
|
51
|
+
term.add.should be_truthy
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -60,7 +60,7 @@ describe NetSuite::Records::Term do
|
|
60
60
|
NetSuite::Actions::Add.should_receive(:call).
|
61
61
|
with([term], {}).
|
62
62
|
and_return(response)
|
63
|
-
term.add.should
|
63
|
+
term.add.should be_falsey
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -76,7 +76,7 @@ describe NetSuite::Records::Term do
|
|
76
76
|
NetSuite::Actions::Delete.should_receive(:call).
|
77
77
|
with([term], {}).
|
78
78
|
and_return(response)
|
79
|
-
term.delete.should
|
79
|
+
term.delete.should be_truthy
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -88,7 +88,7 @@ describe NetSuite::Records::Term do
|
|
88
88
|
NetSuite::Actions::Delete.should_receive(:call).
|
89
89
|
with([term], {}).
|
90
90
|
and_return(response)
|
91
|
-
term.delete.should
|
91
|
+
term.delete.should be_falsey
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::UnitsType do
|
4
|
+
let(:units_type) { described_class.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:is_inactive, :name
|
9
|
+
].each do |field|
|
10
|
+
units_type.should have_field(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#uom_list' do
|
15
|
+
it 'can be set from attributes' do
|
16
|
+
attributes = [{
|
17
|
+
uom: {
|
18
|
+
abbreviation: '6 oz',
|
19
|
+
conversion_rate: 1.4
|
20
|
+
}
|
21
|
+
}]
|
22
|
+
units_type.uom_list.uom = attributes
|
23
|
+
units_type.uom_list.should be_kind_of(NetSuite::Records::UnitsTypeUomList)
|
24
|
+
units_type.uom_list.uom.length.should eql(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'can be set from a units_typeItemList object' do
|
28
|
+
item_list = NetSuite::Records::UnitsTypeUomList.new
|
29
|
+
units_type.uom_list = item_list
|
30
|
+
units_type.uom_list.should eql(item_list)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::UnitsTypeUomList do
|
4
|
+
let(:list) { described_class.new }
|
5
|
+
let(:item) { NetSuite::Records::UnitsTypeUom.new }
|
6
|
+
|
7
|
+
it 'can have items be added to it' do
|
8
|
+
list.uom << item
|
9
|
+
item_list = list.uom
|
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::UnitsTypeUom) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#to_record' do
|
16
|
+
it 'can represent itself as a SOAP record' do
|
17
|
+
record = {
|
18
|
+
'listAcct:uom' => []
|
19
|
+
}
|
20
|
+
list.to_record.should eql(record)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::UnitsTypeUom do
|
4
|
+
let(:uom) { described_class.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:abbreviation, :base_unit, :conversion_rate, :plural_abbreviation,
|
9
|
+
:plural_name, :unit_name
|
10
|
+
].each do |field|
|
11
|
+
uom.should have_field(field)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::WorkOrderItemList do
|
4
|
+
let(:list) { NetSuite::Records::WorkOrderItemList.new }
|
5
|
+
|
6
|
+
it 'has a items attribute' do
|
7
|
+
list.items.should be_kind_of(Array)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#to_record' do
|
11
|
+
before do
|
12
|
+
list.items << NetSuite::Records::WorkOrderItem.new(
|
13
|
+
:average_cost => 10
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'can represent itself as a SOAP record' do
|
18
|
+
record = {
|
19
|
+
'tranInvt:item' => [{
|
20
|
+
'tranInvt:averageCost' => 10
|
21
|
+
}]
|
22
|
+
}
|
23
|
+
list.to_record.should eql(record)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::WorkOrderItem do
|
4
|
+
let(:work_order) { NetSuite::Records::WorkOrderItem.new }
|
5
|
+
|
6
|
+
[
|
7
|
+
:average_cost, :bom_quantity, :commit, :component_yield, :contribution,
|
8
|
+
:create_po, :create_wo, :description, :inventory_detail,
|
9
|
+
:last_purchase_price, :line, :order_priority, :percent_complete, :po_rate,
|
10
|
+
:quantity, :quantity_available, :quantity_back_ordered,
|
11
|
+
:quantity_committed, :quantity_on_hand, :serial_numbers
|
12
|
+
].each do |field|
|
13
|
+
it "has the #{field} field" do
|
14
|
+
work_order.should have_field(field)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
[
|
19
|
+
:department, :item, :location, :po_vender, :units
|
20
|
+
].each do |record_ref|
|
21
|
+
it 'has the #{record_ref} record ref' do
|
22
|
+
expect(work_order).to have_record_ref(record_ref)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#custom_field_list' do
|
27
|
+
it 'can be set from attributes' do
|
28
|
+
attributes = {
|
29
|
+
:custom_field => {
|
30
|
+
:value => 10,
|
31
|
+
:internal_id => 'custfield_something'
|
32
|
+
}
|
33
|
+
}
|
34
|
+
work_order.custom_field_list = attributes
|
35
|
+
work_order.custom_field_list.should be_kind_of(NetSuite::Records::CustomFieldList)
|
36
|
+
work_order.custom_field_list.custom_fields.length.should eql(1)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'can be set from a CustomFieldList object' do
|
40
|
+
custom_field_list = NetSuite::Records::CustomFieldList.new
|
41
|
+
work_order.custom_field_list = custom_field_list
|
42
|
+
work_order.custom_field_list.should eql(custom_field_list)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::WorkOrder do
|
4
|
+
let(:work_order) { NetSuite::Records::WorkOrder.new }
|
5
|
+
|
6
|
+
[
|
7
|
+
:buildable, :built, :created_date, :end_date, :expanded_assembly, :firmed,
|
8
|
+
:is_wip, :last_modified_date, :memo, :order_status, :partners_list,
|
9
|
+
:quantity, :sales_team_list, :source_transaction_id,
|
10
|
+
:source_transaction_line, :special_order, :start_date, :status, :tran_date,
|
11
|
+
:tran_id
|
12
|
+
].each do |field|
|
13
|
+
it "has the #{field} field" do
|
14
|
+
work_order.should have_field(field)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
[
|
19
|
+
:assembly_item, :created_from, :custom_form, :department,
|
20
|
+
:entity, :job, :location, :manufacturing_routing, :revision, :subsidiary,
|
21
|
+
:units
|
22
|
+
].each do |record_ref|
|
23
|
+
it 'has the #{record_ref} record ref' do
|
24
|
+
expect(work_order).to have_record_ref(record_ref)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#custom_field_list' do
|
29
|
+
it 'can be set from attributes' do
|
30
|
+
attributes = {
|
31
|
+
:custom_field => {
|
32
|
+
:value => 10,
|
33
|
+
:internal_id => 'custfield_something'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
work_order.custom_field_list = attributes
|
37
|
+
work_order.custom_field_list.should be_kind_of(NetSuite::Records::CustomFieldList)
|
38
|
+
work_order.custom_field_list.custom_fields.length.should eql(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'can be set from a CustomFieldList object' do
|
42
|
+
custom_field_list = NetSuite::Records::CustomFieldList.new
|
43
|
+
work_order.custom_field_list = custom_field_list
|
44
|
+
work_order.custom_field_list.should eql(custom_field_list)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#item_list' do
|
49
|
+
it 'can be set from attributes' do
|
50
|
+
attributes = {
|
51
|
+
item: {
|
52
|
+
:averageCost => 10,
|
53
|
+
:internal_id => 'itemAbc123'
|
54
|
+
}
|
55
|
+
}
|
56
|
+
work_order.item_list = attributes
|
57
|
+
work_order.item_list.should be_kind_of(NetSuite::Records::WorkOrderItemList)
|
58
|
+
work_order.item_list.items.length.should eql(1)
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'can be set from a WorkOrderItemList object' do
|
62
|
+
order_item_list = NetSuite::Records::WorkOrderItemList.new
|
63
|
+
work_order.item_list = order_item_list
|
64
|
+
work_order.item_list.should eq(order_item_list)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '.get' do
|
69
|
+
context 'when the response is successful' do
|
70
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :buildable => 100 }) }
|
71
|
+
|
72
|
+
it 'returns a WorkOrder instance populated with the data from the response object' do
|
73
|
+
NetSuite::Actions::Get.should_receive(:call).with([NetSuite::Records::WorkOrder, :external_id => 1], {}).and_return(response)
|
74
|
+
salesorder = NetSuite::Records::WorkOrder.get(:external_id => 1)
|
75
|
+
salesorder.should be_kind_of(NetSuite::Records::WorkOrder)
|
76
|
+
salesorder.buildable.should eql(100)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when the response is unsuccessful' do
|
81
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
82
|
+
|
83
|
+
it 'raises a RecordNotFound exception' do
|
84
|
+
NetSuite::Actions::Get.should_receive(:call).with([NetSuite::Records::WorkOrder, :external_id => 1], {}).and_return(response)
|
85
|
+
lambda {
|
86
|
+
NetSuite::Records::WorkOrder.get(:external_id => 1)
|
87
|
+
}.should raise_error(NetSuite::RecordNotFound,
|
88
|
+
/NetSuite::Records::WorkOrder with OPTIONS=(.*) could not be found/)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -8,7 +8,7 @@ describe NetSuite::Support::RecordRefs do
|
|
8
8
|
it 'assigns a nil value for a field with a specified class' do
|
9
9
|
klass.field(:record_test, NetSuite::Records::RecordRef)
|
10
10
|
instance.record_test = nil
|
11
|
-
instance.attributes.has_key?(:record_test).should
|
11
|
+
instance.attributes.has_key?(:record_test).should be_falsey
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::ItemFulfillmentItemList do
|
4
|
+
it "should create a list with a single hash as an argument" do
|
5
|
+
i = NetSuite::Records::ItemFulfillmentItemList.new(item: {
|
6
|
+
quantity: 2,
|
7
|
+
item_receive: true
|
8
|
+
})
|
9
|
+
|
10
|
+
expect(i.item.size).to eq(1)
|
11
|
+
expect(i.to_record["tranSales:item"].size).to eq(1)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should create a list with a list of hashes" do
|
15
|
+
i = NetSuite::Records::ItemFulfillmentItemList.new(item: [
|
16
|
+
{
|
17
|
+
quantity: 2,
|
18
|
+
item_receive: true
|
19
|
+
},
|
20
|
+
{
|
21
|
+
quantity: 1,
|
22
|
+
item_receive: false
|
23
|
+
}
|
24
|
+
])
|
25
|
+
|
26
|
+
expect(i.item.size).to eq(2)
|
27
|
+
expect(i.to_record["tranSales:item"].size).to eq(2)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should properly render the replace_all option" do
|
31
|
+
i = NetSuite::Records::ItemFulfillmentItemList.new(replace_all: false)
|
32
|
+
|
33
|
+
expect(i.sublist_key).to eq(:item)
|
34
|
+
expect(i.to_record["tranSales:replaceAll"]).to eq(false)
|
35
|
+
end
|
36
|
+
end
|