netsuite 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -130,6 +130,8 @@ module NetSuite
130
130
  autoload :Employee, 'netsuite/records/employee'
131
131
  autoload :File, 'netsuite/records/file'
132
132
  autoload :GiftCertificate, 'netsuite/records/gift_certificate'
133
+ autoload :GiftCertRedemption, 'netsuite/records/gift_cert_redemption'
134
+ autoload :GiftCertRedemptionList, 'netsuite/records/gift_cert_redemption_list'
133
135
  autoload :Folder, 'netsuite/records/folder'
134
136
  autoload :InventoryAssignment, 'netsuite/records/inventory_assignment'
135
137
  autoload :InventoryAssignmentList, 'netsuite/records/inventory_assignment_list'
@@ -146,7 +148,9 @@ module NetSuite
146
148
  autoload :ItemFulfillmentItemList, 'netsuite/records/item_fulfillment_item_list'
147
149
  autoload :ItemFulfillmentPackage, 'netsuite/records/item_fulfillment_package'
148
150
  autoload :ItemFulfillmentPackageList, 'netsuite/records/item_fulfillment_package_list'
151
+ autoload :ItemGroup, 'netsuite/records/item_group'
149
152
  autoload :ItemMember, 'netsuite/records/item_member'
153
+ autoload :ItemMemberList, 'netsuite/records/item_member_list'
150
154
  autoload :ItemReceipt, 'netsuite/records/item_receipt'
151
155
  autoload :ItemReceiptItemList, 'netsuite/records/item_receipt_item_list'
152
156
  autoload :ItemReceiptItem, 'netsuite/records/item_receipt_item'
@@ -1,24 +1,11 @@
1
1
  module NetSuite
2
2
  module Records
3
- class CreditMemoItemList
3
+ class CreditMemoItemList < Support::Sublist
4
4
  include Namespaces::TranCust
5
5
 
6
- def initialize(attributes = {})
7
- case attributes[:item]
8
- when Hash
9
- items << CreditMemoItem.new(attributes[:item])
10
- when Array
11
- attributes[:item].each { |item| items << CreditMemoItem.new(item) }
12
- end
13
- end
6
+ sublist :item, CreditMemoItem
14
7
 
15
- def items
16
- @items ||= []
17
- end
18
-
19
- def to_record
20
- { "#{record_namespace}:item" => items.map(&:to_record) }
21
- end
8
+ alias :items :item
22
9
  end
23
10
  end
24
11
  end
@@ -0,0 +1,25 @@
1
+ module NetSuite
2
+ module Records
3
+ class GiftCertRedemption
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Support::Actions
8
+ include Namespaces::TranSales
9
+
10
+ actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search
11
+
12
+ fields :auth_code_amt_remaining, :auth_code_applied, :gift_cert_available
13
+
14
+ record_refs :auth_code
15
+
16
+ attr_reader :internal_id
17
+
18
+ def initialize(attributes = {})
19
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
20
+ initialize_from_attributes_hash(attributes)
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ module NetSuite
2
+ module Records
3
+ class GiftCertRedemptionList < Support::Sublist
4
+ include Namespaces::TranSales
5
+
6
+ sublist :gift_cert_redemption, GiftCertRedemption
7
+
8
+ alias :gift_cert_redemptions :gift_cert_redemption
9
+ end
10
+ end
11
+ end
@@ -21,6 +21,10 @@ module NetSuite
21
21
  initialize_from_attributes_hash(attributes)
22
22
  end
23
23
 
24
+ def self.search_class_name
25
+ "GiftCertificate"
26
+ end
27
+
24
28
  end
25
29
  end
26
30
  end
@@ -0,0 +1,37 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemGroup
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, :include_start_end_lines,
13
+ :is_inactive, :is_vsoe_bundle, :item_id, :last_modified_date, :print_items, :upc_code, :vendor_name
14
+
15
+ record_refs :custom_form, :default_item_ship_method, :department, :issue_product, :item_ship_method_list, :klass, :location, :parent
16
+
17
+ field :custom_field_list, CustomFieldList
18
+ # TODO field :item_carrier, ShippingCarrier
19
+ field :member_list, ItemMemberList
20
+ field :subsidiary_list, RecordRefList
21
+ # TODO field :translations_list, TranslationList
22
+
23
+ attr_reader :internal_id
24
+ attr_accessor :external_id
25
+
26
+ def initialize(attributes = {})
27
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
28
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
29
+ initialize_from_attributes_hash(attributes)
30
+ end
31
+
32
+ def self.search_class_name
33
+ "Item"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,12 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemMemberList < Support::Sublist
4
+ include Namespaces::ListAcct
5
+
6
+ sublist :item_member, ItemMember
7
+
8
+ alias :item_members :item_member
9
+
10
+ end
11
+ end
12
+ end
@@ -31,6 +31,7 @@ module NetSuite
31
31
  field :custom_field_list, CustomFieldList
32
32
  field :pricing_matrix, PricingMatrix
33
33
  field :subsidiary_list, RecordRefList
34
+ field :member_list, ItemMemberList
34
35
 
35
36
  # TODO custom records need to be implemented
36
37
  # field :accounting_book_detail_list, ItemAccountingBookDetailList
@@ -41,7 +42,6 @@ module NetSuite
41
42
  # field :item_carrier, ItemCarrier
42
43
  # field :item_options_list, ItemOptionsList
43
44
  # field :item_ship_method_list, RecordRefList
44
- # field :member_list, ItemMemberList
45
45
  # field :out_of_stock_behavior, ItemOutOfStockBehavior
46
46
  # field :overall_quantity_pricing_type, ItemOverallQuantityPricingType
47
47
  # field :preference_criterion, ItemPreferenceCriterion
@@ -14,7 +14,7 @@ module NetSuite
14
14
  :est_gross_profit, :est_gross_profit_percent, :exchange_rate, :exclude_commission, :fax, :gift_cert_applied,
15
15
  :gift_cert_available, :gift_cert_total, :handling_cost, :handling_tax1_rate, :handling_tax2_rate, :is_taxable,
16
16
  :last_modified_date, :memo, :message, :on_credit_hold, :order_status, :other_ref_num, :recognized_revenue,
17
- :rev_rec_on_rev_commitment, :sales_effective_date, :ship_date, :shipping_cost, :shipping_tax1_rate, :shipping_tax2_rate, :source,
17
+ :rev_rec_on_rev_commitment, :sales_effective_date, :ship_complete, :ship_date, :shipping_cost, :shipping_tax1_rate, :shipping_tax2_rate, :source,
18
18
  :start_date, :status, :sync_partner_teams, :sync_sales_teams, :tax2_total, :tax_rate, :to_be_emailed, :to_be_faxed,
19
19
  :to_be_printed, :total_cost_estimate, :tran_date, :tran_id, :tran_is_vsoe_bundle, :vat_reg_num,
20
20
  :linked_tracking_numbers, :vsoe_auto_calc, :quantity, :bill_city, :bill_state, :ship_city, :ship_state, :cost_estimate,
@@ -28,8 +28,9 @@ module NetSuite
28
28
  field :transaction_ship_address, ShipAddress
29
29
  field :transaction_bill_address, BillAddress
30
30
 
31
- field :item_list, SalesOrderItemList
32
- field :custom_field_list, CustomFieldList
31
+ field :item_list, SalesOrderItemList
32
+ field :custom_field_list, CustomFieldList
33
+ field :gift_cert_redemption_list, GiftCertRedemptionList
33
34
 
34
35
  read_only_fields :applied, :discount_total, :sub_total, :tax_total, :total, :unapplied
35
36
 
@@ -4,6 +4,28 @@ module NetSuite
4
4
 
5
5
  # TODO need structured logger for various statements
6
6
 
7
+ def append_memo(ns_record, added_memo, opts = {})
8
+ opts[:skip_if_exists] ||= false
9
+
10
+ memo_key = if ns_record.class == NetSuite::Records::Customer
11
+ :comments
12
+ else
13
+ :memo
14
+ end
15
+
16
+ return if opts[:skip_if_exists] &&
17
+ ns_record.send(memo_key) &&
18
+ ns_record.send(memo_key).include?(added_memo)
19
+
20
+ if ns_record.send(memo_key)
21
+ ns_record.send(:"#{memo_key}=", "#{ns_record.send(memo_key)}. #{added_memo}")
22
+ else
23
+ ns_record.send(:"#{memo_key}=", added_memo.to_s)
24
+ end
25
+
26
+ ns_record
27
+ end
28
+
7
29
  def backoff(options = {})
8
30
  count = 0
9
31
  begin
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.6.8'
2
+ VERSION = '0.6.9'
3
3
  end
@@ -33,6 +33,8 @@ describe 'basic records' do
33
33
  NetSuite::Records::GiftCertificate,
34
34
  NetSuite::Records::ContactRole,
35
35
  NetSuite::Records::PaymentItem,
36
+ NetSuite::Records::CreditMemo,
37
+ NetSuite::Records::GiftCertRedemption,
36
38
  ]
37
39
  }
38
40
 
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::GiftCertRedemptionList do
4
+ let(:list) { NetSuite::Records::GiftCertRedemptionList.new }
5
+
6
+ it 'has a gift_cert_redemptions attribute' do
7
+ expect(list.gift_cert_redemptions).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ before do
12
+ list.gift_cert_redemptions << NetSuite::Records::GiftCertRedemption.new(
13
+ :auth_code_applied => 20
14
+ )
15
+ end
16
+
17
+ it 'can represent itself as a SOAP record' do
18
+ record = {
19
+ 'tranSales:giftCertRedemption' => [{
20
+ 'tranSales:authCodeApplied' => 20
21
+ }]
22
+ }
23
+ expect(list.to_record).to eql(record)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::GiftCertRedemption do
4
+ let(:redemption) { NetSuite::Records::GiftCertRedemption.new }
5
+
6
+ it 'has all the right fields' do
7
+ [
8
+ :auth_code_amt_remaining, :auth_code_applied, :gift_cert_available
9
+ ].each do |field|
10
+ expect(redemption).to have_field(field)
11
+ end
12
+ end
13
+
14
+ it 'has all the right record refs' do
15
+ [
16
+ :auth_code
17
+ ].each do |record_ref|
18
+ expect(redemption).to have_record_ref(record_ref)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ItemGroup do
4
+ let(:item) { NetSuite::Records::ItemGroup.new }
5
+
6
+ it 'has all the right fields' do
7
+ [
8
+ :available_to_partners, :created_date, :description, :display_name, :include_children, :include_start_end_lines, :is_inactive, :is_vsoe_bundle, :item_id, :last_modified_date, :print_items, :upc_code, :vendor_name
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
+ :custom_form, :default_item_ship_method, :department, :issue_product, :item_ship_method_list, :location
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 ItemGroup instance populated with the data from the response object' do
27
+ expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::ItemGroup, {:external_id => 1}], {}).and_return(response)
28
+ item = NetSuite::Records::ItemGroup.get(:external_id => 1)
29
+ expect(item).to be_kind_of(NetSuite::Records::ItemGroup)
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::ItemGroup, {:external_id => 1}], {}).and_return(response)
39
+ expect {
40
+ NetSuite::Records::ItemGroup.get(:external_id => 1)
41
+ }.to raise_error(NetSuite::RecordNotFound,
42
+ /NetSuite::Records::ItemGroup with OPTIONS=(.*) could not be found/)
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#add' do
48
+ let(:item) { NetSuite::Records::ItemGroup.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:ItemGroup')
114
+ end
115
+ end
116
+
117
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ItemMemberList do
4
+ let(:list) { NetSuite::Records::ItemMemberList.new }
5
+
6
+ it 'has a item_members attribute' do
7
+ expect(list.item_members).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ before do
12
+ list.item_members << NetSuite::Records::ItemMember.new(:quantity => 3, :member_descr => "Component 5")
13
+ end
14
+
15
+ it 'can represent itself as a SOAP record' do
16
+ record = {
17
+ 'listAcct:itemMember' => [{
18
+ 'listAcct:quantity' => 3,
19
+ 'listAcct:memberDescr' => "Component 5"
20
+ }]
21
+ }
22
+ expect(list.to_record).to eql(record)
23
+ end
24
+ end
25
+
26
+ end
@@ -58,6 +58,25 @@ describe NetSuite::Records::SalesOrder do
58
58
  end
59
59
  end
60
60
 
61
+ describe '#gift_cert_redemption_list' do
62
+ it 'can be set from attributes' do
63
+ attributes = {
64
+ :gift_cert_redemption => {
65
+ :auth_code_amt_remaining => 20
66
+ }
67
+ }
68
+ salesorder.gift_cert_redemption_list = attributes
69
+ expect(salesorder.gift_cert_redemption_list).to be_kind_of(NetSuite::Records::GiftCertRedemptionList)
70
+ expect(salesorder.gift_cert_redemption_list.gift_cert_redemptions.length).to eql(1)
71
+ end
72
+
73
+ it 'can be set from a GiftCertRedemptionList object' do
74
+ gift_cert_redemption_list = NetSuite::Records::GiftCertRedemptionList.new
75
+ salesorder.gift_cert_redemption_list = gift_cert_redemption_list
76
+ expect(salesorder.gift_cert_redemption_list).to eql(gift_cert_redemption_list)
77
+ end
78
+ end
79
+
61
80
  describe '#transaction_bill_address' do
62
81
  it 'can be set from attributes'
63
82
  it 'can be set from a BillAddress object'
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.8
4
+ version: 0.6.9
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-07-06 00:00:00.000000000 Z
13
+ date: 2016-07-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: savon
@@ -168,6 +168,8 @@ files:
168
168
  - lib/netsuite/records/employee.rb
169
169
  - lib/netsuite/records/file.rb
170
170
  - lib/netsuite/records/folder.rb
171
+ - lib/netsuite/records/gift_cert_redemption.rb
172
+ - lib/netsuite/records/gift_cert_redemption_list.rb
171
173
  - lib/netsuite/records/gift_certificate.rb
172
174
  - lib/netsuite/records/inventory_assignment.rb
173
175
  - lib/netsuite/records/inventory_assignment_list.rb
@@ -184,7 +186,9 @@ files:
184
186
  - lib/netsuite/records/item_fulfillment_item_list.rb
185
187
  - lib/netsuite/records/item_fulfillment_package.rb
186
188
  - lib/netsuite/records/item_fulfillment_package_list.rb
189
+ - lib/netsuite/records/item_group.rb
187
190
  - lib/netsuite/records/item_member.rb
191
+ - lib/netsuite/records/item_member_list.rb
188
192
  - lib/netsuite/records/item_receipt.rb
189
193
  - lib/netsuite/records/item_receipt_item.rb
190
194
  - lib/netsuite/records/item_receipt_item_list.rb
@@ -328,6 +332,8 @@ files:
328
332
  - spec/netsuite/records/employee_spec.rb
329
333
  - spec/netsuite/records/file_spec.rb
330
334
  - spec/netsuite/records/folder_spec.rb
335
+ - spec/netsuite/records/gift_cert_redemption_list_spec.rb
336
+ - spec/netsuite/records/gift_cert_redemption_spec.rb
331
337
  - spec/netsuite/records/inventory_assignment_list_spec.rb
332
338
  - spec/netsuite/records/inventory_assignment_spec.rb
333
339
  - spec/netsuite/records/inventory_detail_spec.rb
@@ -338,6 +344,8 @@ files:
338
344
  - spec/netsuite/records/invoice_spec.rb
339
345
  - spec/netsuite/records/item_fulfillment_package_list_spec.rb
340
346
  - spec/netsuite/records/item_fulfillment_spec.rb
347
+ - spec/netsuite/records/item_group_spec.rb
348
+ - spec/netsuite/records/item_member_list_spec.rb
341
349
  - spec/netsuite/records/job_spec.rb
342
350
  - spec/netsuite/records/journal_entry_line_list_spec.rb
343
351
  - spec/netsuite/records/journal_entry_line_spec.rb
@@ -508,6 +516,8 @@ test_files:
508
516
  - spec/netsuite/records/employee_spec.rb
509
517
  - spec/netsuite/records/file_spec.rb
510
518
  - spec/netsuite/records/folder_spec.rb
519
+ - spec/netsuite/records/gift_cert_redemption_list_spec.rb
520
+ - spec/netsuite/records/gift_cert_redemption_spec.rb
511
521
  - spec/netsuite/records/inventory_assignment_list_spec.rb
512
522
  - spec/netsuite/records/inventory_assignment_spec.rb
513
523
  - spec/netsuite/records/inventory_detail_spec.rb
@@ -518,6 +528,8 @@ test_files:
518
528
  - spec/netsuite/records/invoice_spec.rb
519
529
  - spec/netsuite/records/item_fulfillment_package_list_spec.rb
520
530
  - spec/netsuite/records/item_fulfillment_spec.rb
531
+ - spec/netsuite/records/item_group_spec.rb
532
+ - spec/netsuite/records/item_member_list_spec.rb
521
533
  - spec/netsuite/records/job_spec.rb
522
534
  - spec/netsuite/records/journal_entry_line_list_spec.rb
523
535
  - spec/netsuite/records/journal_entry_line_spec.rb