netsuite 0.8.4 → 0.8.8
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.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +20 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Gemfile +2 -5
- data/HISTORY.md +26 -0
- data/README.md +72 -29
- data/Rakefile +1 -1
- data/lib/netsuite.rb +13 -19
- data/lib/netsuite/actions/login.rb +10 -2
- data/lib/netsuite/actions/upsert.rb +2 -0
- data/lib/netsuite/configuration.rb +34 -4
- data/lib/netsuite/records/accounting_period.rb +2 -2
- data/lib/netsuite/records/classification.rb +4 -1
- data/lib/netsuite/records/contact.rb +1 -1
- data/lib/netsuite/records/cost_category.rb +28 -0
- data/lib/netsuite/records/credit_memo.rb +1 -1
- data/lib/netsuite/records/custom_field_list.rb +9 -3
- data/lib/netsuite/records/custom_record.rb +1 -1
- data/lib/netsuite/records/customer.rb +2 -1
- data/lib/netsuite/records/customer_credit_cards.rb +36 -0
- data/lib/netsuite/records/customer_credit_cards_list.rb +10 -0
- data/lib/netsuite/records/customer_deposit.rb +5 -5
- data/lib/netsuite/records/customer_payment.rb +6 -2
- data/lib/netsuite/records/customer_payment_credit.rb +17 -0
- data/lib/netsuite/records/customer_payment_credit_list.rb +12 -0
- data/lib/netsuite/records/employee.rb +1 -1
- data/lib/netsuite/records/estimate.rb +42 -0
- data/lib/netsuite/records/estimate_item.rb +40 -0
- data/lib/netsuite/records/estimate_item_list.rb +11 -0
- data/lib/netsuite/records/inventory_item.rb +62 -1
- data/lib/netsuite/records/invoice.rb +94 -1
- data/lib/netsuite/records/item_fulfillment.rb +1 -1
- data/lib/netsuite/records/lot_numbered_inventory_item.rb +116 -0
- data/lib/netsuite/records/matrix_option_list.rb +12 -4
- data/lib/netsuite/records/message.rb +30 -0
- data/lib/netsuite/records/non_inventory_resale_item.rb +1 -0
- data/lib/netsuite/records/non_inventory_sale_item.rb +1 -1
- data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
- data/lib/netsuite/records/partner.rb +7 -5
- data/lib/netsuite/records/serialized_assembly_item.rb +3 -1
- data/lib/netsuite/records/service_resale_item.rb +1 -1
- data/lib/netsuite/records/support_case_type.rb +26 -0
- data/lib/netsuite/records/tax_group.rb +2 -2
- data/lib/netsuite/records/vendor.rb +2 -1
- data/lib/netsuite/records/vendor_currency.rb +26 -0
- data/lib/netsuite/records/vendor_currency_list.rb +9 -0
- data/lib/netsuite/support/fields.rb +16 -0
- data/lib/netsuite/support/records.rb +1 -1
- data/lib/netsuite/support/search_result.rb +36 -6
- data/lib/netsuite/utilities.rb +18 -6
- data/lib/netsuite/version.rb +1 -1
- data/netsuite.gemspec +5 -3
- data/spec/netsuite/actions/search_spec.rb +22 -0
- data/spec/netsuite/configuration_spec.rb +111 -6
- data/spec/netsuite/records/basic_record_spec.rb +9 -1
- data/spec/netsuite/records/classification_spec.rb +10 -1
- data/spec/netsuite/records/cost_category_spec.rb +105 -0
- data/spec/netsuite/records/custom_field_list_spec.rb +46 -6
- data/spec/netsuite/records/custom_record_spec.rb +1 -1
- data/spec/netsuite/records/customer_credit_cards_list_spec.rb +23 -0
- data/spec/netsuite/records/customer_payment_credit_list_spec.rb +26 -0
- data/spec/netsuite/records/customer_payment_spec.rb +1 -6
- data/spec/netsuite/records/customer_spec.rb +22 -1
- data/spec/netsuite/records/employee_spec.rb +2 -2
- data/spec/netsuite/records/estimate_item_list_spec.rb +26 -0
- data/spec/netsuite/records/estimate_item_spec.rb +40 -0
- data/spec/netsuite/records/estimate_spec.rb +216 -0
- data/spec/netsuite/records/inventory_item_spec.rb +65 -0
- data/spec/netsuite/records/invoice_spec.rb +94 -0
- data/spec/netsuite/records/matrix_option_list_spec.rb +15 -5
- data/spec/netsuite/records/message_spec.rb +49 -0
- data/spec/netsuite/records/non_inventory_resale_item_spec.rb +165 -0
- data/spec/netsuite/records/non_inventory_sale_item_spec.rb +1 -1
- data/spec/netsuite/records/partner_spec.rb +143 -0
- data/spec/netsuite/records/service_resale_item_spec.rb +134 -0
- data/spec/netsuite/records/support_case_type_spec.rb +22 -0
- data/spec/netsuite/records/vendor_spec.rb +1 -1
- data/spec/netsuite/support/search_result_spec.rb +24 -0
- data/spec/netsuite/utilities_spec.rb +20 -15
- data/spec/support/fixtures/custom_fields/multi_select.xml +47 -0
- data/spec/support/fixtures/search/saved_search_item.xml +55 -0
- data/spec/support/fixtures/search/saved_search_joined_custom_customer.xml +15 -1
- data/spec/support/search_only_field_matcher.rb +7 -0
- metadata +77 -12
- data/circle.yml +0 -17
@@ -3,17 +3,53 @@ require 'spec_helper'
|
|
3
3
|
describe NetSuite::Records::CustomFieldList do
|
4
4
|
let(:list) { NetSuite::Records::CustomFieldList.new }
|
5
5
|
|
6
|
+
before(:all) { savon.mock! }
|
7
|
+
after(:all) { savon.unmock! }
|
8
|
+
|
6
9
|
it 'has a custom_fields attribute' do
|
7
10
|
expect(list.custom_fields).to be_kind_of(Array)
|
8
11
|
end
|
9
12
|
|
10
13
|
it 'accepts a collection of CustomField records' do
|
11
|
-
field = NetSuite::Records::CustomField.new({
|
12
|
-
|
14
|
+
field = NetSuite::Records::CustomField.new({
|
15
|
+
:value=>{:internal_id=>"5", :type_id=>"103"},
|
16
|
+
:script_id=>"custitem_item_category",
|
17
|
+
:"@xsi:type"=>"platformCore:SelectCustomFieldRef"
|
18
|
+
})
|
19
|
+
|
13
20
|
list = described_class.new(custom_field: [field])
|
21
|
+
|
14
22
|
expect(list.custom_fields).to eq([field])
|
15
23
|
end
|
16
24
|
|
25
|
+
it 'properly decodes various custom field types' do
|
26
|
+
savon.
|
27
|
+
expects(:get).
|
28
|
+
with(message: {"platformMsgs:baseRef"=>{"@xsi:type"=>"platformCore:RecordRef", "@internalId"=>123, "@type"=>"creditMemo"}}).
|
29
|
+
returns(File.read('spec/support/fixtures/custom_fields/multi_select.xml'))
|
30
|
+
|
31
|
+
credit_memo_with_custom_fields = NetSuite::Records::CreditMemo.get(123)
|
32
|
+
|
33
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_standard_select.value.internal_id).to eq("2")
|
34
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_standard_select.value.attributes[:name]).to eq("Manual")
|
35
|
+
|
36
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_date_field.value).to be_a(DateTime)
|
37
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_date_field.value.to_s).to eq("2021-07-13T22:00:00-07:00")
|
38
|
+
|
39
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_string_field.value).to eq("a very nice string")
|
40
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_boolean_field.value).to eq(false)
|
41
|
+
|
42
|
+
# even if there's a single value, it should return an array
|
43
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_multi_select_field.value).to be_a(Array)
|
44
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_multi_select_field.value.size).to eq(1)
|
45
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_multi_select_field.value.first.attributes[:name]).to eq("selection value")
|
46
|
+
|
47
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_multi_select_with_multiple.value).to be_a(Array)
|
48
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_multi_select_with_multiple.value.size).to eq(2)
|
49
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_multi_select_with_multiple.value.first.attributes[:name]).to eq("selection value 1")
|
50
|
+
expect(credit_memo_with_custom_fields.custom_field_list.custbody_multi_select_with_multiple.value.last.attributes[:name]).to eq("selection value 2")
|
51
|
+
end
|
52
|
+
|
17
53
|
context 'initializing with custom field attributes without a type' do
|
18
54
|
it 'does not mutate the attributes' do
|
19
55
|
field = {:value=>{:internal_id=>"5", :type_id=>"103"},
|
@@ -28,7 +64,9 @@ describe NetSuite::Records::CustomFieldList do
|
|
28
64
|
it 'does not mutate the attributes' do
|
29
65
|
field = {:value=>{:internal_id=>"5", :type_id=>"103"},
|
30
66
|
:script_id=>"custitem_item_category", :"@xsi:type"=>"platformCore:SelectCustomFieldRef"}
|
67
|
+
|
31
68
|
described_class.new(custom_field: [field])
|
69
|
+
|
32
70
|
expect(field).to eq({:value=>{:internal_id=>"5", :type_id=>"103"},
|
33
71
|
:script_id=>"custitem_item_category", :"@xsi:type"=>"platformCore:SelectCustomFieldRef"})
|
34
72
|
end
|
@@ -37,9 +75,11 @@ describe NetSuite::Records::CustomFieldList do
|
|
37
75
|
context 'writing convience methods' do
|
38
76
|
it "should create a custom field entry when none exists" do
|
39
77
|
list.custrecord_somefield = 'a value'
|
40
|
-
list.custom_fields
|
41
|
-
|
42
|
-
|
78
|
+
custom_fields = list.custom_fields
|
79
|
+
|
80
|
+
expect(custom_fields.size).to eq(1)
|
81
|
+
expect(custom_fields.first.value).to eq('a value')
|
82
|
+
expect(custom_fields.first.type).to eq('platformCore:StringCustomFieldRef')
|
43
83
|
end
|
44
84
|
|
45
85
|
# https://github.com/NetSweet/netsuite/issues/325
|
@@ -116,7 +156,7 @@ describe NetSuite::Records::CustomFieldList do
|
|
116
156
|
end
|
117
157
|
|
118
158
|
it "should raise an error if custom field entry does not exist" do
|
119
|
-
expect{ list.nonexisting_custom_field }.to raise_error
|
159
|
+
expect{ list.nonexisting_custom_field }.to raise_error(NoMethodError)
|
120
160
|
end
|
121
161
|
end
|
122
162
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::CustomerCreditCardsList do
|
4
|
+
let(:list) { NetSuite::Records::CustomerCreditCardsList.new }
|
5
|
+
|
6
|
+
it 'has a credit_cards attribute' do
|
7
|
+
expect(list.credit_cards).to be_kind_of(Array)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#to_record' do
|
11
|
+
it 'can represent itself as a SOAP record' do
|
12
|
+
list.replace_all = true
|
13
|
+
|
14
|
+
record = {
|
15
|
+
'listRel:creditCards' => [],
|
16
|
+
'listRel:replaceAll' => true
|
17
|
+
}
|
18
|
+
|
19
|
+
expect(list.to_record).to eql(record)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::CustomerPaymentCreditList do
|
4
|
+
let(:list) { NetSuite::Records::CustomerPaymentCreditList.new }
|
5
|
+
let(:apply) { NetSuite::Records::CustomerPaymentCredit.new }
|
6
|
+
|
7
|
+
it 'can have credits be added to it' do
|
8
|
+
list.credits << apply
|
9
|
+
credit_list = list.credits
|
10
|
+
expect(credit_list).to be_kind_of(Array)
|
11
|
+
expect(credit_list.length).to eql(1)
|
12
|
+
credit_list.each { |i| expect(i).to be_kind_of(NetSuite::Records::CustomerPaymentCredit) }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#to_record' do
|
16
|
+
it 'can represent itself as a SOAP record' do
|
17
|
+
record = {
|
18
|
+
'tranCust:credit' => [{},{}]
|
19
|
+
}
|
20
|
+
|
21
|
+
list.credits.concat([apply, apply])
|
22
|
+
expect(list.to_record).to eql(record)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -18,7 +18,7 @@ describe NetSuite::Records::CustomerPayment do
|
|
18
18
|
|
19
19
|
it 'has all the right record refs' do
|
20
20
|
[
|
21
|
-
:account, :ar_acct, :credit_card, :credit_card_processor, :custom_form, :customer, :department, :klass, :location, :payment_method, :posting_period, :subsidiary
|
21
|
+
:account, :ar_acct, :credit_card, :credit_card_processor, :custom_form, :customer, :department, :klass, :location, :payment_method, :payment_option, :posting_period, :subsidiary
|
22
22
|
].each do |record_ref|
|
23
23
|
expect(payment).to have_record_ref(record_ref)
|
24
24
|
end
|
@@ -49,11 +49,6 @@ describe NetSuite::Records::CustomerPayment do
|
|
49
49
|
it 'can be set from a CustomerPaymentApplyList object'
|
50
50
|
end
|
51
51
|
|
52
|
-
describe '#credit_list' do
|
53
|
-
it 'can be set from attributes'
|
54
|
-
it 'can be set from a CustomerPaymentCreditList object'
|
55
|
-
end
|
56
|
-
|
57
52
|
describe '#deposit_list' do
|
58
53
|
it 'can be set from attributes'
|
59
54
|
it 'can be set from a CustomerPaymentDepositList object'
|
@@ -8,7 +8,7 @@ describe NetSuite::Records::Customer do
|
|
8
8
|
:account_number, :aging, :alt_email, :alt_name, :alt_phone, :balance, :bill_pay,
|
9
9
|
:buying_reason, :buying_time_frame, :campaign_category, :click_stream, :comments, :company_name,
|
10
10
|
:consol_aging, :consol_balance, :consol_days_overdue, :consol_deposit_balance, :consol_overdue_balance,
|
11
|
-
:consol_unbilled_orders, :contrib_pct, :
|
11
|
+
:consol_unbilled_orders, :contrib_pct, :credit_hold_override, :credit_limit,
|
12
12
|
:date_created, :days_overdue, :default_address,
|
13
13
|
:deposit_balance, :download_list, :email, :email_preference, :email_transactions, :end_date, :entity_id,
|
14
14
|
:estimated_budget, :fax, :fax_transactions, :first_name, :first_visit, :give_access, :global_subscription_status,
|
@@ -65,6 +65,27 @@ describe NetSuite::Records::Customer do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
describe '#credit_cards_list' do
|
69
|
+
it 'can be set from attributes' do
|
70
|
+
customer.credit_cards_list = {
|
71
|
+
:credit_cards => {
|
72
|
+
:internal_id => '1234567',
|
73
|
+
:cc_default => true,
|
74
|
+
:cc_expire_date => '2099-12-01T00:00:00.000-08:00'
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
expect(customer.credit_cards_list).to be_kind_of(NetSuite::Records::CustomerCreditCardsList)
|
79
|
+
expect(customer.credit_cards_list.credit_cards.length).to eql(1)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'can be set from a CustomerCreditCardsList object' do
|
83
|
+
customer_credit_cards_list = NetSuite::Records::CustomerCreditCardsList.new
|
84
|
+
customer.credit_cards_list = customer_credit_cards_list
|
85
|
+
expect(customer.credit_cards_list).to eql(customer_credit_cards_list)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
68
89
|
describe '#custom_field_list' do
|
69
90
|
it 'can be set from attributes' do
|
70
91
|
attributes = {
|
@@ -21,7 +21,7 @@ describe NetSuite::Records::Employee do
|
|
21
21
|
|
22
22
|
it 'has all the right record refs' do
|
23
23
|
[
|
24
|
-
:location, :employee_status, :
|
24
|
+
:currency, :department, :location, :sales_role, :subsidiary, :employee_type, :employee_status, :supervisor
|
25
25
|
].each do |record_ref|
|
26
26
|
expect(employee).to have_record_ref(record_ref)
|
27
27
|
end
|
@@ -144,7 +144,7 @@ describe NetSuite::Records::Employee do
|
|
144
144
|
|
145
145
|
it 'has the right record_refs' do
|
146
146
|
[
|
147
|
-
:currency, :department, :location, :subsidiary
|
147
|
+
:currency, :department, :location, :sales_role, :subsidiary, :employee_type, :employee_status, :supervisor
|
148
148
|
].each do |record_ref|
|
149
149
|
expect(employee).to have_record_ref(record_ref)
|
150
150
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::EstimateItemList do
|
4
|
+
let(:list) { NetSuite::Records::EstimateItemList.new }
|
5
|
+
|
6
|
+
it 'has a items attribute' do
|
7
|
+
expect(list.items).to be_kind_of(Array)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#to_record' do
|
11
|
+
before do
|
12
|
+
list.items << NetSuite::Records::EstimateItem.new(
|
13
|
+
:rate => 10
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'can represent itself as a SOAP record' do
|
18
|
+
record = {
|
19
|
+
'tranSales:item' => [{
|
20
|
+
'tranSales:rate' => 10
|
21
|
+
}]
|
22
|
+
}
|
23
|
+
expect(list.to_record).to eql(record)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::EstimateItem do
|
4
|
+
let(:item) { NetSuite::Records::EstimateItem.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:amount, :cost_estimate, :cost_estimate_type,
|
9
|
+
:defer_rev_rec, :description,
|
10
|
+
:is_taxable, :line, :quantity,
|
11
|
+
:rate, :tax_rate1
|
12
|
+
].each do |field|
|
13
|
+
expect(item).to have_field(field)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has all the right record refs' do
|
18
|
+
[
|
19
|
+
:item, :job, :price, :tax_code, :units
|
20
|
+
].each do |record_ref|
|
21
|
+
expect(item).to have_record_ref(record_ref)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#options' do
|
26
|
+
it 'can be set from attributes'
|
27
|
+
it 'can be set from a CustomFieldList object'
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#inventory_detail' do
|
31
|
+
it 'can be set from attributes'
|
32
|
+
it 'can be set from an InventoryDetail object'
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#custom_field_list' do
|
36
|
+
it 'can be set from attributes'
|
37
|
+
it 'can be set from a CustomFieldList object'
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::Estimate do
|
4
|
+
let(:estimate) { NetSuite::Records::Estimate.new }
|
5
|
+
let(:customer) { NetSuite::Records::Customer.new }
|
6
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
7
|
+
|
8
|
+
it 'has all the right fields' do
|
9
|
+
[
|
10
|
+
:alt_handling_cost, :alt_shipping_cost,
|
11
|
+
:balance, :bill_address, :created_date, :currency_name,
|
12
|
+
:discount_rate, :email, :end_date, :est_gross_profit,
|
13
|
+
:exchange_rate,
|
14
|
+
:handling_cost, :handling_tax1_rate, :is_taxable,
|
15
|
+
:last_modified_date, :memo, :message, :other_ref_num,
|
16
|
+
:shipping_cost, :shipping_tax1_rate,
|
17
|
+
:source, :start_date, :status, :sync_partner_teams,
|
18
|
+
:sync_sales_teams, :to_be_emailed, :to_be_faxed, :to_be_printed,
|
19
|
+
:total_cost_estimate, :tran_date, :tran_id
|
20
|
+
].each do |field|
|
21
|
+
expect(estimate).to have_field(field)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'has all the right record refs' do
|
26
|
+
[
|
27
|
+
:bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item,
|
28
|
+
:entity, :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel,
|
29
|
+
:opportunity, :partner, :promo_code, :sales_group, :sales_rep,
|
30
|
+
:ship_method, :shipping_tax_code, :subsidiary
|
31
|
+
].each do |record_ref|
|
32
|
+
expect(estimate).to have_record_ref(record_ref)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#order_status' do
|
37
|
+
it 'can be set from attributes'
|
38
|
+
it 'can be set from a EstimateStatus object'
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#item_list' do
|
42
|
+
it 'can be set from attributes' do
|
43
|
+
attributes = {
|
44
|
+
:item => {
|
45
|
+
:amount => 10
|
46
|
+
}
|
47
|
+
}
|
48
|
+
estimate.item_list = attributes
|
49
|
+
expect(estimate.item_list).to be_kind_of(NetSuite::Records::EstimateItemList)
|
50
|
+
expect(estimate.item_list.items.length).to eql(1)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'can be set from a EstimateItemList object' do
|
54
|
+
item_list = NetSuite::Records::EstimateItemList.new
|
55
|
+
estimate.item_list = item_list
|
56
|
+
expect(estimate.item_list).to eql(item_list)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#transaction_bill_address' do
|
61
|
+
it 'can be set from attributes'
|
62
|
+
it 'can be set from a BillAddress object'
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#transaction_ship_address' do
|
66
|
+
it 'can be set from attributes'
|
67
|
+
it 'can be set from a ShipAddress object'
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#revenue_status' do
|
71
|
+
it 'can be set from attributes'
|
72
|
+
it 'can be set from a RevenueStatus object'
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#sales_team_list' do
|
76
|
+
it 'can be set from attributes'
|
77
|
+
it 'can be set from a EstimateSalesTeamList object'
|
78
|
+
end
|
79
|
+
|
80
|
+
describe '#partners_list' do
|
81
|
+
it 'can be set from attributes'
|
82
|
+
it 'can be set from a EstimatePartnersList object'
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#custom_field_list' do
|
86
|
+
it 'can be set from attributes'
|
87
|
+
it 'can be set from a CustomFieldList object'
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '.get' do
|
91
|
+
context 'when the response is successful' do
|
92
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :alt_shipping_cost => 100 }) }
|
93
|
+
|
94
|
+
it 'returns a Estimate instance populated with the data from the response object' do
|
95
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Estimate, :external_id => 1], {}).and_return(response)
|
96
|
+
estimate = NetSuite::Records::Estimate.get(:external_id => 1)
|
97
|
+
expect(estimate).to be_kind_of(NetSuite::Records::Estimate)
|
98
|
+
expect(estimate.alt_shipping_cost).to eql(100)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when the response is unsuccessful' do
|
103
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
104
|
+
|
105
|
+
it 'raises a RecordNotFound exception' do
|
106
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Estimate, :external_id => 1], {}).and_return(response)
|
107
|
+
expect {
|
108
|
+
NetSuite::Records::Estimate.get(:external_id => 1)
|
109
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
110
|
+
/NetSuite::Records::Estimate with OPTIONS=(.*) could not be found/)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '.initialize' do
|
116
|
+
context 'when the request is successful' do
|
117
|
+
it 'returns an initialized sales order from the customer entity' do
|
118
|
+
expect(NetSuite::Actions::Initialize).to receive(:call).with([NetSuite::Records::Estimate, customer], {}).and_return(response)
|
119
|
+
estimate = NetSuite::Records::Estimate.initialize(customer)
|
120
|
+
expect(estimate).to be_kind_of(NetSuite::Records::Estimate)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'when the response is unsuccessful' do
|
125
|
+
skip
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#add' do
|
130
|
+
let(:test_data) { { :email => 'test@example.com', :fax => '1234567890' } }
|
131
|
+
|
132
|
+
context 'when the response is successful' do
|
133
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
134
|
+
|
135
|
+
it 'returns true' do
|
136
|
+
estimate = NetSuite::Records::Estimate.new(test_data)
|
137
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
138
|
+
with([estimate], {}).
|
139
|
+
and_return(response)
|
140
|
+
expect(estimate.add).to be_truthy
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'when the response is unsuccessful' do
|
145
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
146
|
+
|
147
|
+
it 'returns false' do
|
148
|
+
estimate = NetSuite::Records::Estimate.new(test_data)
|
149
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
150
|
+
with([estimate], {}).
|
151
|
+
and_return(response)
|
152
|
+
expect(estimate.add).to be_falsey
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe '#delete' do
|
158
|
+
let(:test_data) { { :internal_id => '1' } }
|
159
|
+
|
160
|
+
context 'when the response is successful' do
|
161
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
162
|
+
|
163
|
+
it 'returns true' do
|
164
|
+
estimate = NetSuite::Records::Estimate.new(test_data)
|
165
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
166
|
+
with([estimate], {}).
|
167
|
+
and_return(response)
|
168
|
+
expect(estimate.delete).to be_truthy
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'when the response is unsuccessful' do
|
173
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
174
|
+
|
175
|
+
it 'returns false' do
|
176
|
+
estimate = NetSuite::Records::Estimate.new(test_data)
|
177
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
178
|
+
with([estimate], {}).
|
179
|
+
and_return(response)
|
180
|
+
expect(estimate.delete).to be_falsey
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#to_record' do
|
186
|
+
before do
|
187
|
+
estimate.email = 'something@example.com'
|
188
|
+
estimate.tran_id = '4'
|
189
|
+
end
|
190
|
+
it 'can represent itself as a SOAP record' do
|
191
|
+
record = {
|
192
|
+
'tranSales:email' => 'something@example.com',
|
193
|
+
'tranSales:tranId' => '4'
|
194
|
+
}
|
195
|
+
expect(estimate.to_record).to eql(record)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#record_type' do
|
200
|
+
it 'returns a string representation of the SOAP type' do
|
201
|
+
expect(estimate.record_type).to eql('tranSales:Estimate')
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
skip "closing a sales order" do
|
206
|
+
it "closes each line to close the sales order" do
|
207
|
+
attributes = sales_order.attributes
|
208
|
+
attributes[:item_list].items.each do |item|
|
209
|
+
item.is_closed = true
|
210
|
+
item.attributes = item.attributes.slice(:line, :is_closed)
|
211
|
+
end
|
212
|
+
|
213
|
+
sales_order.update({ item_list: attributes[:item_list] })
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|