netsuite 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/netsuite.rb +1 -0
- data/lib/netsuite/records/job.rb +1 -0
- data/lib/netsuite/records/payment_item.rb +36 -0
- data/lib/netsuite/records/pricing_matrix.rb +2 -0
- data/lib/netsuite/records/vendor_bill_expense_list.rb +4 -23
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/records/basic_record_spec.rb +2 -0
- data/spec/netsuite/records/payment_item_spec.rb +117 -0
- data/spec/netsuite/records/pricing_matrix_spec.rb +25 -0
- metadata +7 -2
data/lib/netsuite.rb
CHANGED
@@ -167,6 +167,7 @@ module NetSuite
|
|
167
167
|
autoload :OpportunityItem, 'netsuite/records/opportunity_item'
|
168
168
|
autoload :OpportunityItemList, 'netsuite/records/opportunity_item_list'
|
169
169
|
autoload :Partner, 'netsuite/records/partner'
|
170
|
+
autoload :PaymentItem, 'netsuite/records/payment_item'
|
170
171
|
autoload :PaymentMethod, 'netsuite/records/payment_method'
|
171
172
|
autoload :PayrollItem, 'netsuite/records/payroll_item'
|
172
173
|
autoload :PhoneCall, 'netsuite/records/phone_call'
|
data/lib/netsuite/records/job.rb
CHANGED
@@ -22,6 +22,7 @@ module NetSuite
|
|
22
22
|
field :estimated_time_override, Duration
|
23
23
|
field :actual_time, Duration
|
24
24
|
field :time_remaining, Duration
|
25
|
+
field :custom_field_list, CustomFieldList
|
25
26
|
|
26
27
|
record_refs :billing_schedule, :category, :currency, :custom_form, :entity_status, :estimate_rev_rec_template, :job_item,
|
27
28
|
:job_type, :language, :parent, :subsidiary, :workplace
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class PaymentItem
|
4
|
+
include Support::Fields
|
5
|
+
include Support::RecordRefs
|
6
|
+
include Support::Records
|
7
|
+
include Support::Actions
|
8
|
+
include Namespaces::ListAcct
|
9
|
+
|
10
|
+
actions :get, :get_list, :add, :delete, :search, :update, :upsert
|
11
|
+
|
12
|
+
fields :available_to_partners, :created_date, :description, :display_name, :include_children, :is_inactive, :item_id, :last_modified_date, :undep_funds
|
13
|
+
|
14
|
+
record_refs :account, :custom_form, :department, :issue_product, :klass, :location, :payment_method
|
15
|
+
|
16
|
+
field :custom_field_list, CustomFieldList
|
17
|
+
field :subsidiary_list, RecordRefList
|
18
|
+
|
19
|
+
# TODO custom records need to be implemented
|
20
|
+
# field :translations_list, TranslationList
|
21
|
+
|
22
|
+
attr_reader :internal_id
|
23
|
+
attr_accessor :external_id
|
24
|
+
|
25
|
+
def initialize(attributes = {})
|
26
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
27
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
28
|
+
initialize_from_attributes_hash(attributes)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.search_class_name
|
32
|
+
"Item"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -4,6 +4,8 @@ module NetSuite
|
|
4
4
|
include Namespaces::PlatformCore
|
5
5
|
|
6
6
|
def initialize(attributes = {})
|
7
|
+
attributes[:pricing] = [attributes[:pricing]] unless
|
8
|
+
attributes[:pricing].is_a? Array
|
7
9
|
attributes[:pricing].each do |pricing|
|
8
10
|
prices << RecordRef.new(pricing)
|
9
11
|
end if attributes[:pricing]
|
@@ -1,31 +1,12 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class VendorBillExpenseList
|
4
|
-
include Support::Fields
|
3
|
+
class VendorBillExpenseList < Support::Sublist
|
5
4
|
include Namespaces::TranPurch
|
6
5
|
|
7
|
-
|
6
|
+
sublist :expense, VendorBillExpense
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def expense=(expenses)
|
14
|
-
case expenses
|
15
|
-
when Hash
|
16
|
-
self.expenses << VendorBillExpense.new(expenses)
|
17
|
-
when Array
|
18
|
-
expenses.each { |expense| self.expenses << VendorBillExpense.new(expense) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def expenses
|
23
|
-
@expenses ||= []
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_record
|
27
|
-
{ "#{record_namespace}:expense" => expenses.map(&:to_record) }
|
28
|
-
end
|
8
|
+
# legacy support
|
9
|
+
alias :expenses :expense
|
29
10
|
|
30
11
|
end
|
31
12
|
end
|
data/lib/netsuite/version.rb
CHANGED
@@ -12,6 +12,7 @@ describe 'basic records' do
|
|
12
12
|
NetSuite::Records::PayrollItem,
|
13
13
|
NetSuite::Records::Opportunity,
|
14
14
|
NetSuite::Records::VendorCategory,
|
15
|
+
NetSuite::Records::VendorBill,
|
15
16
|
NetSuite::Records::Deposit,
|
16
17
|
NetSuite::Records::RevRecTemplate,
|
17
18
|
NetSuite::Records::RevRecSchedule,
|
@@ -31,6 +32,7 @@ describe 'basic records' do
|
|
31
32
|
NetSuite::Records::ItemReceipt,
|
32
33
|
NetSuite::Records::GiftCertificate,
|
33
34
|
NetSuite::Records::ContactRole,
|
35
|
+
NetSuite::Records::PaymentItem,
|
34
36
|
]
|
35
37
|
}
|
36
38
|
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::PaymentItem do
|
4
|
+
let(:item) { NetSuite::Records::PaymentItem.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:available_to_partners, :created_date, :description, :display_name, :include_children, :is_inactive, :item_id, :last_modified_date, :undep_funds
|
9
|
+
].each do |field|
|
10
|
+
expect(item).to have_field(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has all the right record refs' do
|
15
|
+
[
|
16
|
+
:account, :custom_form, :department, :issue_product, :klass, :location, :payment_method
|
17
|
+
].each do |record_ref|
|
18
|
+
expect(item).to have_record_ref(record_ref)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.get' do
|
23
|
+
context 'when the response is successful' do
|
24
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :item_id => "Item100" }) }
|
25
|
+
|
26
|
+
it 'returns a PaymentItem instance populated with the data from the response object' do
|
27
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::PaymentItem, {:external_id => 1}], {}).and_return(response)
|
28
|
+
item = NetSuite::Records::PaymentItem.get(:external_id => 1)
|
29
|
+
expect(item).to be_kind_of(NetSuite::Records::PaymentItem)
|
30
|
+
expect(item.item_id).to eql("Item100")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when the response is unsuccessful' do
|
35
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
36
|
+
|
37
|
+
it 'raises a RecordNotFound exception' do
|
38
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::PaymentItem, {:external_id => 1}], {}).and_return(response)
|
39
|
+
expect {
|
40
|
+
NetSuite::Records::PaymentItem.get(:external_id => 1)
|
41
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
42
|
+
/NetSuite::Records::PaymentItem with OPTIONS=(.*) could not be found/)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#add' do
|
48
|
+
let(:item) { NetSuite::Records::PaymentItem.new(:item_id => "Item100", :is_inactive => false) }
|
49
|
+
|
50
|
+
context 'when the response is successful' do
|
51
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
52
|
+
|
53
|
+
it 'returns true' do
|
54
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
55
|
+
with([item], {}).
|
56
|
+
and_return(response)
|
57
|
+
expect(item.add).to be_truthy
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when the response is unsuccessful' do
|
62
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
63
|
+
|
64
|
+
it 'returns false' do
|
65
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
66
|
+
with([item], {}).
|
67
|
+
and_return(response)
|
68
|
+
expect(item.add).to be_falsey
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#delete' do
|
74
|
+
context 'when the response is successful' do
|
75
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
76
|
+
|
77
|
+
it 'returns true' do
|
78
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
79
|
+
with([item], {}).
|
80
|
+
and_return(response)
|
81
|
+
expect(item.delete).to be_truthy
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when the response is unsuccessful' do
|
86
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
87
|
+
|
88
|
+
it 'returns false' do
|
89
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
90
|
+
with([item], {}).
|
91
|
+
and_return(response)
|
92
|
+
expect(item.delete).to be_falsey
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#to_record' do
|
98
|
+
before do
|
99
|
+
item.item_id = "Item100"
|
100
|
+
item.is_inactive = false
|
101
|
+
end
|
102
|
+
it 'can represent itself as a SOAP record' do
|
103
|
+
record = {
|
104
|
+
'listAcct:itemId' => "Item100",
|
105
|
+
'listAcct:isInactive' => false
|
106
|
+
}
|
107
|
+
expect(item.to_record).to eql(record)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe '#record_type' do
|
112
|
+
it 'returns a string representation of the SOAP type' do
|
113
|
+
expect(item.record_type).to eql('listAcct:PaymentItem')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::PricingMatrix do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "behaves appropriately if it gets a hash as attributes[:pricing]" do
|
6
|
+
# this is what savon returns if there is only one pricing strategy matrix
|
7
|
+
# for the item:
|
8
|
+
matrix = {
|
9
|
+
:pricing=> {
|
10
|
+
:currency=>"US Dollar",
|
11
|
+
:priceLevel=>"Base Price",
|
12
|
+
:priceList=>[
|
13
|
+
{:price=>{:value=>12.0, :quantity=>0.0}},
|
14
|
+
{:price=>{:value=>10.0, :quantity=>10.0}},
|
15
|
+
{:price=>{:value=>9.0, :quantity=>100.0}},
|
16
|
+
{:price=>{:value=>7.0, :quantity=>5000.0}}
|
17
|
+
]
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
subject = NetSuite::Records::PricingMatrix.new({pricing: matrix})
|
22
|
+
expect(subject.prices[0].pricing).to eq(matrix[:pricing])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netsuite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-06
|
13
|
+
date: 2016-07-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: savon
|
@@ -205,6 +205,7 @@ files:
|
|
205
205
|
- lib/netsuite/records/opportunity_item.rb
|
206
206
|
- lib/netsuite/records/opportunity_item_list.rb
|
207
207
|
- lib/netsuite/records/partner.rb
|
208
|
+
- lib/netsuite/records/payment_item.rb
|
208
209
|
- lib/netsuite/records/payment_method.rb
|
209
210
|
- lib/netsuite/records/payroll_item.rb
|
210
211
|
- lib/netsuite/records/phone_call.rb
|
@@ -345,9 +346,11 @@ files:
|
|
345
346
|
- spec/netsuite/records/location_spec.rb
|
346
347
|
- spec/netsuite/records/matrix_option_list_spec.rb
|
347
348
|
- spec/netsuite/records/non_inventory_sale_item_spec.rb
|
349
|
+
- spec/netsuite/records/payment_item_spec.rb
|
348
350
|
- spec/netsuite/records/payment_method_spec.rb
|
349
351
|
- spec/netsuite/records/phone_call_spec.rb
|
350
352
|
- spec/netsuite/records/pomo_code_spec.rb
|
353
|
+
- spec/netsuite/records/pricing_matrix_spec.rb
|
351
354
|
- spec/netsuite/records/record_ref_spec.rb
|
352
355
|
- spec/netsuite/records/rev_rec_template_spec.rb
|
353
356
|
- spec/netsuite/records/sales_order_item_list_spec.rb
|
@@ -523,9 +526,11 @@ test_files:
|
|
523
526
|
- spec/netsuite/records/location_spec.rb
|
524
527
|
- spec/netsuite/records/matrix_option_list_spec.rb
|
525
528
|
- spec/netsuite/records/non_inventory_sale_item_spec.rb
|
529
|
+
- spec/netsuite/records/payment_item_spec.rb
|
526
530
|
- spec/netsuite/records/payment_method_spec.rb
|
527
531
|
- spec/netsuite/records/phone_call_spec.rb
|
528
532
|
- spec/netsuite/records/pomo_code_spec.rb
|
533
|
+
- spec/netsuite/records/pricing_matrix_spec.rb
|
529
534
|
- spec/netsuite/records/record_ref_spec.rb
|
530
535
|
- spec/netsuite/records/rev_rec_template_spec.rb
|
531
536
|
- spec/netsuite/records/sales_order_item_list_spec.rb
|