netsuite 0.8.2 → 0.8.7
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/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Gemfile +4 -3
- data/README.md +129 -38
- data/circle.yml +36 -13
- data/lib/netsuite.rb +40 -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 +34 -4
- data/lib/netsuite/errors.rb +1 -0
- data/lib/netsuite/records/accounting_period.rb +2 -2
- 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/contact.rb +1 -1
- data/lib/netsuite/records/credit_memo.rb +1 -1
- 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 +9 -6
- 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/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 +3 -2
- 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 +7 -5
- 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.rb +2 -1
- data/lib/netsuite/records/vendor_credit.rb +2 -0
- data/lib/netsuite/records/vendor_currency.rb +26 -0
- data/lib/netsuite/records/vendor_currency_list.rb +9 -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 +111 -6
- data/spec/netsuite/records/address_spec.rb +10 -0
- data/spec/netsuite/records/basic_record_spec.rb +19 -2
- 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_payment_credit_list_spec.rb +26 -0
- data/spec/netsuite/records/customer_payment_spec.rb +1 -6
- 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 +143 -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/records/vendor_spec.rb +1 -1
- 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 +111 -11
|
@@ -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
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe NetSuite::Records::InterCompanyJournalEntryLineList do
|
|
4
|
+
let(:list) { NetSuite::Records::InterCompanyJournalEntryLineList.new }
|
|
5
|
+
|
|
6
|
+
it 'has a custom_fields attribute' do
|
|
7
|
+
expect(list.lines).to be_kind_of(Array)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#to_record' do
|
|
11
|
+
before do
|
|
12
|
+
list.lines << NetSuite::Records::InterCompanyJournalEntryLine.new(:memo => 'This is a memo')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'can represent itself as a SOAP record' do
|
|
16
|
+
record =
|
|
17
|
+
{
|
|
18
|
+
'tranGeneral:line' => [{
|
|
19
|
+
'tranGeneral:memo' => 'This is a memo'
|
|
20
|
+
}]
|
|
21
|
+
}
|
|
22
|
+
expect(list.to_record).to eql(record)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe NetSuite::Records::InterCompanyJournalEntryLine do
|
|
4
|
+
let(:line) { NetSuite::Records::InterCompanyJournalEntryLine.new }
|
|
5
|
+
|
|
6
|
+
it 'has all the right fields' do
|
|
7
|
+
[
|
|
8
|
+
:amortization_end_date, :amortization_residual, :amortiz_start_date, :credit, :debit, :eliminate, :end_date, :gross_amt, :memo,
|
|
9
|
+
:residual, :start_date, :tax1_amt, :tax_rate1
|
|
10
|
+
].each do |field|
|
|
11
|
+
expect(line).to have_field(field)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'has all the right record refs' do
|
|
16
|
+
[
|
|
17
|
+
:account, :department, :entity, :klass, :line_subsidiary, :location, :schedule, :schedule_num, :tax1_acct, :tax_code
|
|
18
|
+
].each do |record_ref|
|
|
19
|
+
expect(line).to have_record_ref(record_ref)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
describe '#custom_field_list' do
|
|
24
|
+
it 'can be set from attributes' do
|
|
25
|
+
attributes = {
|
|
26
|
+
:custom_field => {
|
|
27
|
+
:amount => 10,
|
|
28
|
+
:internal_id => 'custfield_amount'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
line.custom_field_list = attributes
|
|
32
|
+
expect(line.custom_field_list).to be_kind_of(NetSuite::Records::CustomFieldList)
|
|
33
|
+
expect(line.custom_field_list.custom_fields.length).to eql(1)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'can be set from a CustomFieldList object' do
|
|
37
|
+
custom_field_list = NetSuite::Records::CustomFieldList.new
|
|
38
|
+
line.custom_field_list = custom_field_list
|
|
39
|
+
expect(line.custom_field_list).to eql(custom_field_list)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '#to_record' do
|
|
44
|
+
let(:line) { NetSuite::Records::InterCompanyJournalEntryLine.new(:memo => 'This is a memo', :eliminate => true) }
|
|
45
|
+
|
|
46
|
+
it 'returns a hash of attributes that can be used in a SOAP request' do
|
|
47
|
+
expect(line.to_record).to eql({
|
|
48
|
+
'tranGeneral:memo' => 'This is a memo',
|
|
49
|
+
'tranGeneral:eliminate' => true
|
|
50
|
+
})
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe '#record_type' do
|
|
55
|
+
it 'returns a string type for the record to be used in a SOAP request' do
|
|
56
|
+
expect(line.record_type).to eql('tranGeneral:InterCompanyJournalEntryLine')
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe NetSuite::Records::InterCompanyJournalEntry do
|
|
4
|
+
let(:entry) { NetSuite::Records::InterCompanyJournalEntry.new }
|
|
5
|
+
|
|
6
|
+
it 'has all the right fields' do
|
|
7
|
+
[
|
|
8
|
+
:approved, :created_date, :exchange_rate, :is_book_specific, :last_modified_date, :memo, :reversal_date,
|
|
9
|
+
:reversal_defer, :reversal_entry, :tran_date, :tran_id
|
|
10
|
+
].each do |field|
|
|
11
|
+
expect(entry).to have_field(field)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'has all the right record refs' do
|
|
16
|
+
[
|
|
17
|
+
:created_from, :currency, :custom_form, :department, :klass, :location, :parent_expense_alloc, :posting_period,
|
|
18
|
+
:subsidiary, :to_subsidiary
|
|
19
|
+
].each do |record_ref|
|
|
20
|
+
expect(entry).to have_record_ref(record_ref)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe '#custom_field_list' do
|
|
25
|
+
it 'can be set from attributes' do
|
|
26
|
+
attributes = {
|
|
27
|
+
:custom_field => {
|
|
28
|
+
:amount => 10,
|
|
29
|
+
:script_id => 'custfield_amount'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
entry.custom_field_list = attributes
|
|
33
|
+
expect(entry.custom_field_list).to be_kind_of(NetSuite::Records::CustomFieldList)
|
|
34
|
+
expect(entry.custom_field_list.custom_fields.length).to eql(1)
|
|
35
|
+
expect(entry.custom_field_list.custfield_amount.attributes[:amount]).to eq(10)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'can be set from a CustomFieldList object' do
|
|
39
|
+
custom_field_list = NetSuite::Records::CustomFieldList.new
|
|
40
|
+
entry.custom_field_list = custom_field_list
|
|
41
|
+
expect(entry.custom_field_list).to eql(custom_field_list)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#line_list' do
|
|
46
|
+
it 'can be set from attributes' do
|
|
47
|
+
attributes = {
|
|
48
|
+
:line => {
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
entry.line_list = attributes
|
|
53
|
+
expect(entry.line_list).to be_kind_of(NetSuite::Records::InterCompanyJournalEntryLineList)
|
|
54
|
+
expect(entry.line_list.lines.length).to eql(1)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'can be set from a InterCompanyJournalEntryLineList object' do
|
|
58
|
+
line_list = NetSuite::Records::InterCompanyJournalEntryLineList.new
|
|
59
|
+
entry.line_list = line_list
|
|
60
|
+
expect(entry.line_list).to eql(line_list)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe '.get' do
|
|
65
|
+
context 'when the response is successful' do
|
|
66
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :approved => true }) }
|
|
67
|
+
|
|
68
|
+
it 'returns a InterCompanyJournalEntry instance populated with the data from the response object' do
|
|
69
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::InterCompanyJournalEntry, {:external_id => 1}], {}).and_return(response)
|
|
70
|
+
customer = NetSuite::Records::InterCompanyJournalEntry.get(:external_id => 1)
|
|
71
|
+
expect(customer).to be_kind_of(NetSuite::Records::InterCompanyJournalEntry)
|
|
72
|
+
expect(customer.approved).to be_truthy
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context 'when the response is unsuccessful' do
|
|
77
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
|
78
|
+
|
|
79
|
+
it 'raises a RecordNotFound exception' do
|
|
80
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::InterCompanyJournalEntry, {:external_id => 1}], {}).and_return(response)
|
|
81
|
+
expect {
|
|
82
|
+
NetSuite::Records::InterCompanyJournalEntry.get(:external_id => 1)
|
|
83
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
|
84
|
+
/NetSuite::Records::InterCompanyJournalEntry with OPTIONS=(.*) could not be found/)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe '#add' do
|
|
90
|
+
let(:entry) { NetSuite::Records::InterCompanyJournalEntry.new(:approved => true) }
|
|
91
|
+
|
|
92
|
+
context 'when the response is successful' do
|
|
93
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
|
94
|
+
|
|
95
|
+
it 'returns true' do
|
|
96
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
|
97
|
+
with([entry], {}).
|
|
98
|
+
and_return(response)
|
|
99
|
+
expect(entry.add).to be_truthy
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
context 'when the response is unsuccessful' do
|
|
104
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
|
105
|
+
|
|
106
|
+
it 'returns false' do
|
|
107
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
|
108
|
+
with([entry], {}).
|
|
109
|
+
and_return(response)
|
|
110
|
+
expect(entry.add).to be_falsey
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
describe '#delete' do
|
|
116
|
+
context 'when the response is successful' do
|
|
117
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
|
118
|
+
|
|
119
|
+
it 'returns true' do
|
|
120
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
|
121
|
+
with([entry], {}).
|
|
122
|
+
and_return(response)
|
|
123
|
+
expect(entry.delete).to be_truthy
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
context 'when the response is unsuccessful' do
|
|
128
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
|
129
|
+
|
|
130
|
+
it 'returns false' do
|
|
131
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
|
132
|
+
with([entry], {}).
|
|
133
|
+
and_return(response)
|
|
134
|
+
expect(entry.delete).to be_falsey
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
describe '#to_record' do
|
|
140
|
+
let(:entry) { NetSuite::Records::InterCompanyJournalEntry.new(:tran_id => '1234', :approved => true) }
|
|
141
|
+
|
|
142
|
+
it 'returns a hash of attributes that can be used in a SOAP request' do
|
|
143
|
+
expect(entry.to_record).to eql({
|
|
144
|
+
'tranGeneral:tranId' => '1234',
|
|
145
|
+
'tranGeneral:approved' => true
|
|
146
|
+
})
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe '#record_type' do
|
|
151
|
+
it 'returns a string type for the record to be used in a SOAP request' do
|
|
152
|
+
expect(entry.record_type).to eql('tranGeneral:InterCompanyJournalEntry')
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
end
|