netsuite 0.8.2 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/Gemfile +7 -2
- data/README.md +107 -32
- data/circle.yml +33 -13
- data/lib/netsuite.rb +36 -19
- data/lib/netsuite/actions/login.rb +20 -1
- data/lib/netsuite/actions/search.rb +1 -6
- data/lib/netsuite/actions/update.rb +6 -2
- data/lib/netsuite/actions/update_list.rb +109 -0
- data/lib/netsuite/actions/upsert.rb +2 -0
- data/lib/netsuite/configuration.rb +21 -4
- data/lib/netsuite/errors.rb +1 -0
- data/lib/netsuite/records/assembly_build.rb +4 -1
- data/lib/netsuite/records/assembly_item.rb +1 -0
- data/lib/netsuite/records/assembly_unbuild.rb +3 -0
- data/lib/netsuite/records/bin_number.rb +18 -0
- data/lib/netsuite/records/bin_number_list.rb +1 -20
- data/lib/netsuite/records/bin_transfer.rb +38 -0
- data/lib/netsuite/records/bin_transfer_inventory.rb +20 -0
- data/lib/netsuite/records/bin_transfer_inventory_list.rb +10 -0
- data/lib/netsuite/records/cash_refund_item.rb +1 -1
- data/lib/netsuite/records/classification.rb +5 -2
- data/lib/netsuite/records/custom_field_list.rb +10 -2
- data/lib/netsuite/records/custom_record.rb +3 -3
- data/lib/netsuite/records/custom_record_ref.rb +1 -0
- data/lib/netsuite/records/customer.rb +5 -4
- 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 -2
- data/lib/netsuite/records/customer_payment.rb +1 -0
- data/lib/netsuite/records/customer_sales_team.rb +24 -0
- data/lib/netsuite/records/customer_sales_team_list.rb +9 -0
- data/lib/netsuite/records/customer_status.rb +29 -0
- data/lib/netsuite/records/customer_subscription.rb +18 -0
- data/lib/netsuite/records/customer_subscriptions_list.rb +10 -0
- data/lib/netsuite/records/employee.rb +1 -1
- data/lib/netsuite/records/entity_custom_field.rb +53 -0
- 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/inbound_shipment.rb +33 -0
- data/lib/netsuite/records/inbound_shipment_item.rb +39 -0
- data/lib/netsuite/records/inbound_shipment_item_list.rb +11 -0
- data/lib/netsuite/records/inter_company_journal_entry.rb +48 -0
- data/lib/netsuite/records/inter_company_journal_entry_line.rb +28 -0
- data/lib/netsuite/records/inter_company_journal_entry_line_list.rb +14 -0
- data/lib/netsuite/records/inventory_item.rb +1 -1
- data/lib/netsuite/records/invoice.rb +1 -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 +3 -2
- 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 +1 -1
- data/lib/netsuite/records/price.rb +17 -0
- data/lib/netsuite/records/price_level.rb +26 -0
- data/lib/netsuite/records/price_list.rb +9 -0
- data/lib/netsuite/records/pricing.rb +20 -0
- data/lib/netsuite/records/pricing_matrix.rb +2 -2
- data/lib/netsuite/records/promotions.rb +26 -0
- data/lib/netsuite/records/promotions_list.rb +9 -0
- data/lib/netsuite/records/return_authorization_item.rb +1 -1
- data/lib/netsuite/records/sales_order.rb +1 -0
- data/lib/netsuite/records/sales_order_item.rb +12 -5
- data/lib/netsuite/records/sales_role.rb +26 -0
- data/lib/netsuite/records/sales_tax_item.rb +3 -1
- data/lib/netsuite/records/serialized_assembly_item.rb +239 -0
- data/lib/netsuite/records/service_resale_item.rb +1 -1
- data/lib/netsuite/records/service_sale_item.rb +1 -1
- data/lib/netsuite/records/support_case.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/transaction_body_custom_field.rb +61 -0
- data/lib/netsuite/records/transaction_column_custom_field.rb +59 -0
- data/lib/netsuite/records/vendor_credit.rb +2 -0
- data/lib/netsuite/records/work_order.rb +8 -0
- data/lib/netsuite/support/actions.rb +2 -0
- data/lib/netsuite/support/country.rb +27 -15
- data/lib/netsuite/support/search_result.rb +20 -5
- data/lib/netsuite/utilities.rb +83 -21
- data/lib/netsuite/version.rb +1 -1
- data/netsuite.gemspec +4 -3
- data/spec/netsuite/actions/login_spec.rb +23 -0
- data/spec/netsuite/actions/update_list_spec.rb +107 -0
- data/spec/netsuite/actions/update_spec.rb +42 -0
- data/spec/netsuite/configuration_spec.rb +79 -6
- data/spec/netsuite/records/address_spec.rb +10 -0
- data/spec/netsuite/records/basic_record_spec.rb +11 -1
- data/spec/netsuite/records/bin_number_spec.rb +23 -0
- data/spec/netsuite/records/classification_spec.rb +10 -1
- data/spec/netsuite/records/custom_field_list_spec.rb +39 -4
- 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_sales_team_list_spec.rb +41 -0
- data/spec/netsuite/records/customer_spec.rb +44 -2
- data/spec/netsuite/records/customer_subscription_spec.rb +41 -0
- data/spec/netsuite/records/customer_subscriptions_list_spec.rb +19 -0
- data/spec/netsuite/records/employee_spec.rb +2 -2
- data/spec/netsuite/records/entity_custom_field_spec.rb +34 -0
- 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/inter_company_journal_entry_line_list_spec.rb +26 -0
- data/spec/netsuite/records/inter_company_journal_entry_line_spec.rb +60 -0
- data/spec/netsuite/records/inter_company_journal_entry_spec.rb +156 -0
- data/spec/netsuite/records/inventory_item_spec.rb +57 -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 +141 -0
- data/spec/netsuite/records/price_level_spec.rb +16 -0
- data/spec/netsuite/records/pricing_matrix_spec.rb +15 -13
- data/spec/netsuite/records/return_authorization_item_spec.rb +1 -1
- data/spec/netsuite/records/sales_order_item_spec.rb +11 -5
- 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/transaction_body_custom_field_spec.rb +32 -0
- data/spec/netsuite/records/transaction_column_custom_field_spec.rb +32 -0
- data/spec/netsuite/records/vendor_credit_spec.rb +29 -0
- data/spec/netsuite/support/search_result_spec.rb +24 -0
- data/spec/netsuite/utilities_spec.rb +44 -6
- data/spec/spec_helper.rb +5 -4
- data/spec/support/fixtures/update_list/update_list_items.xml +22 -0
- data/spec/support/fixtures/update_list/update_list_one_item.xml +18 -0
- data/spec/support/fixtures/update_list/update_list_with_errors.xml +32 -0
- metadata +101 -8
@@ -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,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::CustomerSalesTeamList do
|
4
|
+
let(:list) { NetSuite::Records::CustomerSalesTeamList.new }
|
5
|
+
|
6
|
+
it 'has an customer_sales_team attribute' do
|
7
|
+
expect(list.sales_team).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:salesTeam' => [],
|
16
|
+
'listRel:replaceAll' => true
|
17
|
+
}
|
18
|
+
expect(list.to_record).to eql(record)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#replace_all" do
|
23
|
+
it "can be changed via accessor" do
|
24
|
+
list.replace_all = false
|
25
|
+
|
26
|
+
expect(list.replace_all).to eql(false)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "coerces to a boolean" do
|
30
|
+
list.replace_all = "goober"
|
31
|
+
|
32
|
+
record = {
|
33
|
+
'listRel:salesTeam' => [],
|
34
|
+
'listRel:replaceAll' => true
|
35
|
+
}
|
36
|
+
|
37
|
+
expect(list.to_record).to eql(record)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -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,
|
@@ -17,7 +17,7 @@ describe NetSuite::Records::Customer do
|
|
17
17
|
:opening_balance, :opening_balance_account, :opening_balance_date, :overdue_balance,
|
18
18
|
:password, :password2, :phone, :phonetic_name, :pref_cc_processor,:print_on_check_as,
|
19
19
|
:print_transactions, :referrer, :reminder_days, :representing_subsidiary, :require_pwd_change, :resale_number,
|
20
|
-
:sales_group, :sales_readiness, :
|
20
|
+
:sales_group, :sales_readiness, :salutation, :send_email, :ship_complete,
|
21
21
|
:stage, :start_date, :sync_partner_teams, :tax_exempt, :taxable,
|
22
22
|
:third_party_acct, :third_party_country, :third_party_zipcode, :title, :unbilled_orders, :url,
|
23
23
|
:vat_reg_number, :visits, :web_lead
|
@@ -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 = {
|
@@ -85,6 +106,27 @@ describe NetSuite::Records::Customer do
|
|
85
106
|
end
|
86
107
|
end
|
87
108
|
|
109
|
+
describe '#subscriptions_list' do
|
110
|
+
it 'can be set from attributes' do
|
111
|
+
customer.subscriptions_list = {
|
112
|
+
subscriptions: [
|
113
|
+
{
|
114
|
+
:subscribed => true
|
115
|
+
}
|
116
|
+
]
|
117
|
+
}
|
118
|
+
expect(customer.subscriptions_list).to be_kind_of(NetSuite::Records::CustomerSubscriptionsList)
|
119
|
+
expect(customer.subscriptions_list.subscriptions.length).to eql(1)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'can be set from a CustomerSubscriptionsList object' do
|
123
|
+
customer_subscriptions_list = NetSuite::Records::CustomerSubscriptionsList.new
|
124
|
+
customer.subscriptions_list = customer_subscriptions_list
|
125
|
+
expect(customer.subscriptions_list).to eql(customer_subscriptions_list)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
88
130
|
describe '.get' do
|
89
131
|
context 'when the response is successful' do
|
90
132
|
let(:response) { NetSuite::Response.new(:success => true, :body => { :is_person => true }) }
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::CustomerSubscription do
|
4
|
+
|
5
|
+
before do
|
6
|
+
NetSuite::Configuration.api_version = '2014_2'
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:attributes) do
|
10
|
+
{
|
11
|
+
:subscription => {
|
12
|
+
:subscribed => true,
|
13
|
+
:subscription => NetSuite::Records::RecordRef.new(internal_id: '123123', name: 'My Sub'),
|
14
|
+
:last_modified_date => DateTime.new(2018, 1, 1, 0, 0, 0)
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:list) { NetSuite::Records::CustomerSubscription.new(attributes) }
|
20
|
+
|
21
|
+
it 'has all the right fields' do
|
22
|
+
[
|
23
|
+
:subscribed, :last_modified_date
|
24
|
+
].each do |field|
|
25
|
+
expect(list).to have_field(field)
|
26
|
+
end
|
27
|
+
|
28
|
+
expect(list.subscription).to_not be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#initialize' do
|
32
|
+
context 'when taking in a hash of attributes' do
|
33
|
+
it 'sets the attributes for the object given the attributes hash' do
|
34
|
+
expect(list.subscription.subscribed).to eql(true)
|
35
|
+
expect(list.subscription.subscription.internal_id).to eql('123123')
|
36
|
+
expect(list.subscription.subscription.name).to eql('My Sub')
|
37
|
+
expect(list.subscription.last_modified_date).to_not be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::CustomerSubscriptionsList do
|
4
|
+
let(:list) { NetSuite::Records::CustomerSubscriptionsList.new }
|
5
|
+
|
6
|
+
it 'has a subscriptions attribute' do
|
7
|
+
expect(list.subscriptions).to be_kind_of(Array)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#to_record' do
|
11
|
+
it 'can represent itself as a SOAP record' do
|
12
|
+
|
13
|
+
record = {
|
14
|
+
'listRel:subscriptions' => []
|
15
|
+
}
|
16
|
+
expect(list.to_record).to eql(record)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -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,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe NetSuite::Records::EntityCustomField do
|
4
|
+
describe ".get" do
|
5
|
+
context "success" do
|
6
|
+
let(:internal_id) { 1 }
|
7
|
+
let(:response) do
|
8
|
+
NetSuite::Response.new(
|
9
|
+
success: true,
|
10
|
+
body: {
|
11
|
+
access_level: "_edit",
|
12
|
+
field_type: "_integerNumber",
|
13
|
+
label: "Salesforce Customer ID",
|
14
|
+
show_in_list: true,
|
15
|
+
}
|
16
|
+
)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns a EntityCustomField instance with populated fields" do
|
20
|
+
expect(NetSuite::Actions::Get)
|
21
|
+
.to receive(:call)
|
22
|
+
.with([NetSuite::Records::EntityCustomField, internal_id: internal_id], {})
|
23
|
+
.and_return(response)
|
24
|
+
|
25
|
+
record = NetSuite::Records::EntityCustomField.get(internal_id: internal_id)
|
26
|
+
|
27
|
+
expect(record.access_level).to eql("_edit")
|
28
|
+
expect(record.field_type).to eql("_integerNumber")
|
29
|
+
expect(record.label).to eql("Salesforce Customer ID")
|
30
|
+
expect(record.show_in_list).to eq(true)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
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
|