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
data/lib/netsuite/version.rb
CHANGED
@@ -81,7 +81,7 @@ describe NetSuite::Actions::Search do
|
|
81
81
|
|
82
82
|
:attributes! => {
|
83
83
|
"platformCore:customField" => {
|
84
|
-
"
|
84
|
+
"scriptId" => ["custentity_customerandcontacttypelist", "custentity_relatedthing"],
|
85
85
|
"operator" => ["anyOf", "anyOf"],
|
86
86
|
"xsi:type" => ["platformCore:SearchMultiSelectCustomField", "platformCore:SearchMultiSelectCustomField"]
|
87
87
|
}
|
@@ -7,9 +7,8 @@ describe NetSuite::Actions::Update do
|
|
7
7
|
context 'Customer' do
|
8
8
|
let(:customer) { NetSuite::Records::Customer.new }
|
9
9
|
let(:attributes) { { :entity_id => 'Shutter Fly', :company_name => 'Shutter Fly, Inc.' } }
|
10
|
-
|
11
|
-
|
12
|
-
savon.expects(:update).with(:message => {
|
10
|
+
let(:message) do
|
11
|
+
{
|
13
12
|
'platformMsgs:record' => {
|
14
13
|
:content! => {
|
15
14
|
'listRel:entityId' => 'Shutter Fly',
|
@@ -17,44 +16,76 @@ describe NetSuite::Actions::Update do
|
|
17
16
|
},
|
18
17
|
'@xsi:type' => 'listRel:Customer'
|
19
18
|
},
|
20
|
-
}
|
19
|
+
}
|
21
20
|
end
|
22
21
|
|
23
|
-
it 'makes a valid request to the NetSuite API' do
|
24
|
-
NetSuite::Actions::Update.call([NetSuite::Records::Customer, attributes])
|
25
|
-
end
|
26
22
|
|
27
|
-
|
28
|
-
response = NetSuite::Actions::Update.call([NetSuite::Records::Customer, attributes])
|
29
|
-
response.should be_kind_of(NetSuite::Response)
|
30
|
-
response.should be_success
|
31
|
-
end
|
32
|
-
end
|
23
|
+
context 'when successful' do
|
33
24
|
|
34
|
-
|
35
|
-
|
36
|
-
|
25
|
+
before do
|
26
|
+
savon.expects(:update).with(:message => message).returns(File.read('spec/support/fixtures/update/update_customer.xml'))
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'makes a valid request to the NetSuite API' do
|
30
|
+
NetSuite::Actions::Update.call([NetSuite::Records::Customer, attributes])
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns a valid Response object' do
|
34
|
+
response = NetSuite::Actions::Update.call([NetSuite::Records::Customer, attributes])
|
35
|
+
response.should be_kind_of(NetSuite::Response)
|
36
|
+
response.should be_success
|
37
|
+
end
|
37
38
|
|
38
|
-
before do
|
39
|
-
savon.expects(:update).with(:message => {
|
40
|
-
'platformMsgs:record' => {
|
41
|
-
:content! => {
|
42
|
-
'tranSales:source' => 'Google',
|
43
|
-
},
|
44
|
-
'@xsi:type' => 'tranSales:Invoice'
|
45
|
-
},
|
46
|
-
}).returns(File.read('spec/support/fixtures/update/update_invoice.xml'))
|
47
39
|
end
|
48
40
|
|
49
|
-
|
50
|
-
|
41
|
+
context 'when not successful' do
|
42
|
+
|
43
|
+
before do
|
44
|
+
savon.expects(:update).with(:message => message).returns(File.read('spec/support/fixtures/update/update_customer_error.xml'))
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'provides an errors method on the object with details about the errors' do
|
48
|
+
customer.update(attributes)
|
49
|
+
error = customer.errors.first
|
50
|
+
|
51
|
+
error.should be_kind_of(NetSuite::Error)
|
52
|
+
error.type.should eq('ERROR')
|
53
|
+
error.code.should eq('INSUFFICIENT_PERMISSION')
|
54
|
+
error.message.should eq('You do not have permissions to set a value for element addrtext due to one of the following reasons: 1) The field is read-only; 2) An associated feature is disabled; 3) The field is available either when a record is created or updated, but not in both cases.')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'provides an errors method on the response' do
|
58
|
+
response = NetSuite::Actions::Update.call([NetSuite::Records::Customer, attributes])
|
59
|
+
response.errors.first.should be_kind_of(NetSuite::Error)
|
60
|
+
end
|
61
|
+
|
51
62
|
end
|
52
63
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
64
|
+
context 'when not successful with multiple errors' do
|
65
|
+
|
66
|
+
before do
|
67
|
+
savon.expects(:update).with(:message => message).returns(File.read('spec/support/fixtures/update/update_customer_multiple_errors.xml'))
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'provides an errors method on the object with details about the errors' do
|
71
|
+
customer.update(attributes)
|
72
|
+
customer.errors.length.should eq(2)
|
73
|
+
|
74
|
+
first_error = customer.errors.first
|
75
|
+
first_error.should be_kind_of(NetSuite::Error)
|
76
|
+
first_error.type.should eq('ERROR')
|
77
|
+
first_error.code.should eq('First error code')
|
78
|
+
first_error.message.should eq('First error message')
|
79
|
+
|
80
|
+
second_error = customer.errors.last
|
81
|
+
second_error.should be_kind_of(NetSuite::Error)
|
82
|
+
second_error.type.should eq('WARNING')
|
83
|
+
second_error.code.should eq('Second error code')
|
84
|
+
second_error.message.should eq('Second error message')
|
85
|
+
|
86
|
+
end
|
57
87
|
end
|
88
|
+
|
58
89
|
end
|
59
90
|
|
60
91
|
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Actions::UpsertList do
|
4
|
+
before { savon.mock! }
|
5
|
+
after { savon.unmock! }
|
6
|
+
|
7
|
+
context 'Customers' do
|
8
|
+
context 'one customer' do
|
9
|
+
let(:customers) do
|
10
|
+
[
|
11
|
+
NetSuite::Records::Customer.new(external_id: 'ext2', entity_id: 'Target', company_name: 'Target')
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
before do
|
16
|
+
savon.expects(:upsert_list).with(:message =>
|
17
|
+
{
|
18
|
+
'record' => [{
|
19
|
+
'listRel:entityId' => 'Target',
|
20
|
+
'listRel:companyName' => 'Target',
|
21
|
+
'@xsi:type' => 'listRel:Customer',
|
22
|
+
'@externalId' => 'ext2'
|
23
|
+
}]
|
24
|
+
}).returns(File.read('spec/support/fixtures/upsert_list/upsert_list_one_customer.xml'))
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'makes a valid request to the NetSuite API' do
|
28
|
+
NetSuite::Actions::UpsertList.call(customers)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns a valid Response object' do
|
32
|
+
response = NetSuite::Actions::UpsertList.call(customers)
|
33
|
+
response.should be_kind_of(NetSuite::Response)
|
34
|
+
response.should be_success
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'two customers' do
|
39
|
+
let(:customers) do
|
40
|
+
[
|
41
|
+
NetSuite::Records::Customer.new(external_id: 'ext1', entity_id: 'Shutter Fly', company_name: 'Shutter Fly, Inc.'),
|
42
|
+
NetSuite::Records::Customer.new(external_id: 'ext2', entity_id: 'Target', company_name: 'Target')
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
before do
|
47
|
+
savon.expects(:upsert_list).with(:message =>
|
48
|
+
{
|
49
|
+
'record' => [{
|
50
|
+
'listRel:entityId' => 'Shutter Fly',
|
51
|
+
'listRel:companyName' => 'Shutter Fly, Inc.',
|
52
|
+
'@xsi:type' => 'listRel:Customer',
|
53
|
+
'@externalId' => 'ext1'
|
54
|
+
},
|
55
|
+
{
|
56
|
+
'listRel:entityId' => 'Target',
|
57
|
+
'listRel:companyName' => 'Target',
|
58
|
+
'@xsi:type' => 'listRel:Customer',
|
59
|
+
'@externalId' => 'ext2'
|
60
|
+
}
|
61
|
+
]
|
62
|
+
}).returns(File.read('spec/support/fixtures/upsert_list/upsert_list_customers.xml'))
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'makes a valid request to the NetSuite API' do
|
66
|
+
NetSuite::Actions::UpsertList.call(customers)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'returns a valid Response object' do
|
70
|
+
response = NetSuite::Actions::UpsertList.call(customers)
|
71
|
+
response.should be_kind_of(NetSuite::Response)
|
72
|
+
response.should be_success
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'with errors' do
|
78
|
+
let(:customers) do
|
79
|
+
[
|
80
|
+
NetSuite::Records::Customer.new(external_id: 'ext1-bad', entity_id: 'Shutter Fly', company_name: 'Shutter Fly, Inc.'),
|
81
|
+
NetSuite::Records::Customer.new(external_id: 'ext2-bad', entity_id: 'Target', company_name: 'Target')
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
before do
|
86
|
+
savon.expects(:upsert_list).with(:message =>
|
87
|
+
{
|
88
|
+
'record' => [{
|
89
|
+
'listRel:entityId' => 'Shutter Fly',
|
90
|
+
'listRel:companyName' => 'Shutter Fly, Inc.',
|
91
|
+
'@xsi:type' => 'listRel:Customer',
|
92
|
+
'@externalId' => 'ext1-bad'
|
93
|
+
},
|
94
|
+
{
|
95
|
+
'listRel:entityId' => 'Target',
|
96
|
+
'listRel:companyName' => 'Target',
|
97
|
+
'@xsi:type' => 'listRel:Customer',
|
98
|
+
'@externalId' => 'ext2-bad'
|
99
|
+
}
|
100
|
+
]
|
101
|
+
}).returns(File.read('spec/support/fixtures/upsert_list/upsert_list_with_errors.xml'))
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'constructs error objects' do
|
105
|
+
response = NetSuite::Actions::UpsertList.call(customers)
|
106
|
+
expect(response.errors.keys).to match_array(['ext1', 'ext2'])
|
107
|
+
expect(response.errors['ext1'].first.code).to eq('USER_ERROR')
|
108
|
+
expect(response.errors['ext1'].first.message).to eq('Please enter value(s) for: Item')
|
109
|
+
expect(response.errors['ext1'].first.type).to eq('ERROR')
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -71,7 +71,7 @@ describe NetSuite::Records::Account do
|
|
71
71
|
NetSuite::Actions::Add.should_receive(:call).
|
72
72
|
with([account], {}).
|
73
73
|
and_return(response)
|
74
|
-
account.add.should
|
74
|
+
account.add.should be_truthy
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
@@ -83,7 +83,7 @@ describe NetSuite::Records::Account do
|
|
83
83
|
NetSuite::Actions::Add.should_receive(:call).
|
84
84
|
with([account], {}).
|
85
85
|
and_return(response)
|
86
|
-
account.add.should
|
86
|
+
account.add.should be_falsey
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -99,7 +99,7 @@ describe NetSuite::Records::Account do
|
|
99
99
|
NetSuite::Actions::Delete.should_receive(:call).
|
100
100
|
with([account], {}).
|
101
101
|
and_return(response)
|
102
|
-
account.delete.should
|
102
|
+
account.delete.should be_truthy
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
@@ -111,7 +111,7 @@ describe NetSuite::Records::Account do
|
|
111
111
|
NetSuite::Actions::Delete.should_receive(:call).
|
112
112
|
with([account], {}).
|
113
113
|
and_return(response)
|
114
|
-
account.delete.should
|
114
|
+
account.delete.should be_falsey
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -91,7 +91,7 @@ describe NetSuite::Records::AccountingPeriod do
|
|
91
91
|
NetSuite::Actions::Add.should_receive(:call).
|
92
92
|
with([accounting_period], {}).
|
93
93
|
and_return(response)
|
94
|
-
accounting_period.add.should
|
94
|
+
accounting_period.add.should be_truthy
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -103,7 +103,7 @@ describe NetSuite::Records::AccountingPeriod do
|
|
103
103
|
NetSuite::Actions::Add.should_receive(:call).
|
104
104
|
with([accounting_period], {}).
|
105
105
|
and_return(response)
|
106
|
-
accounting_period.add.should
|
106
|
+
accounting_period.add.should be_falsey
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end
|
@@ -119,7 +119,7 @@ describe NetSuite::Records::AccountingPeriod do
|
|
119
119
|
NetSuite::Actions::Delete.should_receive(:call).
|
120
120
|
with([accounting_period], {}).
|
121
121
|
and_return(response)
|
122
|
-
accounting_period.delete.should
|
122
|
+
accounting_period.delete.should be_truthy
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -131,7 +131,7 @@ describe NetSuite::Records::AccountingPeriod do
|
|
131
131
|
NetSuite::Actions::Delete.should_receive(:call).
|
132
132
|
with([accounting_period], {}).
|
133
133
|
and_return(response)
|
134
|
-
accounting_period.delete.should
|
134
|
+
accounting_period.delete.should be_falsey
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::AssemblyItem do
|
4
|
+
let(:item) { described_class.new }
|
5
|
+
|
6
|
+
describe '#member_list' do
|
7
|
+
it 'can be set from attributes' do
|
8
|
+
attributes = {
|
9
|
+
:item_member => [{
|
10
|
+
:item => { :internal_id => 1 },
|
11
|
+
:quantity => 20
|
12
|
+
}]
|
13
|
+
}
|
14
|
+
item.member_list = attributes
|
15
|
+
item.member_list.should be_kind_of(NetSuite::Records::MemberList)
|
16
|
+
item.member_list.item_member.length.should eql(1)
|
17
|
+
|
18
|
+
expect(item.member_list.item_member.first.item.internal_id).to eq(1)
|
19
|
+
expect(item.member_list.item_member.first.quantity).to eq(20)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#subsidiary_list' do
|
24
|
+
it 'creates record refs from attributes' do
|
25
|
+
item = described_class.new({
|
26
|
+
subsidiary_list: {
|
27
|
+
record_ref: [
|
28
|
+
{ internal_id: 1 },
|
29
|
+
{ internal_id: 2 },
|
30
|
+
]
|
31
|
+
}
|
32
|
+
})
|
33
|
+
|
34
|
+
expect(item.subsidiary_list.record_ref[0].internal_id).to eq(1)
|
35
|
+
expect(item.subsidiary_list.record_ref[1].internal_id).to eq(2)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::BillingScheduleMilestoneList do
|
4
|
+
let(:list) { NetSuite::Records::BillingScheduleMilestoneList.new }
|
5
|
+
let(:milestone) { NetSuite::Records::BillingScheduleMilestone.new }
|
6
|
+
|
7
|
+
it 'can have milestones be added to it' do
|
8
|
+
list.milestones << milestone
|
9
|
+
milestone_list = list.milestones
|
10
|
+
milestone_list.should be_kind_of(Array)
|
11
|
+
milestone_list.length.should eql(1)
|
12
|
+
milestone_list.each { |i| i.should be_kind_of(NetSuite::Records::BillingScheduleMilestone) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#to_record' do
|
16
|
+
it 'can represent itself as a SOAP record' do
|
17
|
+
record = {
|
18
|
+
'listAcct:billingScheduleMilestone' => []
|
19
|
+
}
|
20
|
+
list.to_record.should eql(record)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::BillingScheduleMilestone do
|
4
|
+
let(:milestone) { NetSuite::Records::BillingScheduleMilestone.new }
|
5
|
+
|
6
|
+
it 'has the right fields' do
|
7
|
+
[
|
8
|
+
:comments, :milestone_actual_completion_date, :milestone_amount,
|
9
|
+
:milestone_completed, :milestone_date, :milestone_id
|
10
|
+
].each do |field|
|
11
|
+
milestone.should have_field(field)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'has the right record_refs' do
|
16
|
+
[
|
17
|
+
:milestone_term, :project_task
|
18
|
+
].each do |record_ref|
|
19
|
+
milestone.should have_record_ref(record_ref)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can initialize from a record' do
|
24
|
+
record = NetSuite::Records::BillingScheduleMilestone.new(:comments => "foo")
|
25
|
+
milestone = NetSuite::Records::BillingScheduleMilestone.new(record)
|
26
|
+
milestone.should be_kind_of(NetSuite::Records::BillingScheduleMilestone)
|
27
|
+
milestone.comments.should eql("foo")
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#to_record' do
|
31
|
+
before do
|
32
|
+
milestone.comments = 'comment'
|
33
|
+
milestone.milestone_amount = 1
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'can represent itself as a SOAP record' do
|
37
|
+
record = {
|
38
|
+
'listAcct:comments' => 'comment',
|
39
|
+
'listAcct:milestoneAmount' => 1
|
40
|
+
}
|
41
|
+
milestone.to_record.should eql(record)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#record_type' do
|
46
|
+
it 'returns a string of the SOAP record type' do
|
47
|
+
milestone.record_type.should eql('listAcct:BillingScheduleMilestone')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::BillingScheduleRecurrenceList do
|
4
|
+
let(:list) { NetSuite::Records::BillingScheduleRecurrenceList.new }
|
5
|
+
let(:recurrence) { NetSuite::Records::BillingScheduleRecurrence.new }
|
6
|
+
|
7
|
+
it 'can have recurrences be added to it' do
|
8
|
+
list.recurrences << recurrence
|
9
|
+
recurrence_list = list.recurrences
|
10
|
+
recurrence_list.should be_kind_of(Array)
|
11
|
+
recurrence_list.length.should eql(1)
|
12
|
+
recurrence_list.each { |i| i.should be_kind_of(NetSuite::Records::BillingScheduleRecurrence) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#to_record' do
|
16
|
+
it 'can represent itself as a SOAP record' do
|
17
|
+
record = {
|
18
|
+
'listAcct:billingScheduleRecurrence' => []
|
19
|
+
}
|
20
|
+
list.to_record.should eql(record)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|