Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shiphawk 0 8 stable #4

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5b99969
Fix issue with empty `record_list` node in search result
andrykonchin May 16, 2019
2e58c99
Adding guide to finding the account ID
iloveitaly May 18, 2019
56413df
Add direct_revenue_posting field to non-inventory sale item model
antoinesaliba May 20, 2019
7684482
Improving configuration documentation
iloveitaly May 26, 2019
df796ee
Adding subsidiary_list to OtherChargeSaleItem
iloveitaly May 28, 2019
ba4a55b
Adding new netsuite error
iloveitaly May 29, 2019
b0d5396
Adding lot numbered item to get_item
iloveitaly May 30, 2019
1a6081d
Added support case types and messages
jeremycrosbie Jun 10, 2019
3a5ae3e
added more properties to matrix_option_list
joerzepiejewski Jul 11, 2019
659d463
Version bump
iloveitaly Jul 11, 2019
5dfa2ef
Add credit cards to customer
jeremycrosbie Jul 24, 2019
af26673
rescue Exception => rescue StandardError
shaicoleman Sep 4, 2019
cd350c2
Add cost to ServiceResaleItem.
Sep 11, 2019
e48f808
Add spec for ServiceResaleItem.
Sep 11, 2019
ec46a26
Update data center url method name in README
Sep 9, 2019
35f393a
Support passing streams as log option
iloveitaly Oct 25, 2019
a5ba921
Bumping ruby version
iloveitaly Oct 25, 2019
cf9f5c2
Adding spec for using IO stream as a log destination
iloveitaly Oct 25, 2019
b404f18
Add the status field to ItemFulfillments
jormon Nov 20, 2019
de0286b
update classification to include parent record_ref
toyhammered Mar 4, 2020
1292ddc
Fixing classification parent and custom field field definition
iloveitaly Mar 4, 2020
a2b0376
Fixes Issues #450
toyhammered Mar 6, 2020
4d6ac2f
Fixing classification test
iloveitaly Mar 6, 2020
1585ca8
add item vendor list to non inventory resale item
nkulbiski Apr 25, 2020
f13ef9c
Add amount as a read_only_field to Invoice
jormon Apr 23, 2020
f900e5d
Adding search join to CustomerPayment
justincatalana May 10, 2020
653532f
Typo: proces -> process in README
dleve123 Jul 2, 2020
73a24dc
Fix deprecation warnings in custom_field_list_spec.rb
dleve123 Aug 3, 2020
a1dfef7
Backfill tests for Configuration#log_level & #log_level=
dleve123 Aug 3, 2020
49bdd03
Add failing tests: can not override log level
dleve123 Aug 3, 2020
0b01431
Configuration: Allow for log_level overriding
dleve123 Aug 3, 2020
0d0ba9f
Explicitly and consistently mark pending specs in configuration_spec.rb
dleve123 Aug 3, 2020
abdc7de
Docs: Document log_level in README and provide suggestion for Rails a…
dleve123 Aug 4, 2020
67ad6bc
Bumping CI build dependencies to remove vulnerability warnings
iloveitaly Aug 4, 2020
48a8fb3
circle ci v2
iloveitaly Aug 4, 2020
2e0bbc0
Adding rspec_junit_formatter for circleci ruby orb
iloveitaly Aug 4, 2020
d65aa39
Bump ruby version
iloveitaly Aug 4, 2020
cc6c318
add subsidiary to partner record
nkulbiski Aug 14, 2020
6f73221
add sales_role to employee record
nkulbiski Aug 14, 2020
3dffc39
Adding Estimate support for Quotes
jeperkins4 Sep 1, 2020
c2d7933
Version bump
iloveitaly Sep 23, 2020
8960d58
Addressing gemspec warnings. Ensure savon is less than 2.11
iloveitaly Sep 23, 2020
0b430cc
[#2101] add runSuiteScriptAndTriggerWorkflow header support on Update…
Jun 5, 2019
0c9902f
do not pass run_suite_scripts flag with nil value
Jun 6, 2019
ca636da
dup soap header when setting per request web preferences configuration
Jun 6, 2019
eee4d44
[#13198] Updated exceptions to retry list
DmytroVasin Jun 17, 2022
13cc24f
Merge pull request #6 from ShipHawk/dm-13198-update-exceptions-to-retry
vasiliysablin Jun 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adding Estimate support for Quotes
  • Loading branch information
jeperkins4 authored and iloveitaly committed Sep 2, 2020
commit 3dffc392a1af44a5ce78eb3f936a071ba4f0379b
3 changes: 3 additions & 0 deletions lib/netsuite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ module Records
autoload :Duration, 'netsuite/records/duration'
autoload :Employee, 'netsuite/records/employee'
autoload :EntityCustomField, 'netsuite/records/entity_custom_field'
autoload :Estimate, 'netsuite/records/estimate'
autoload :EstimateItem, 'netsuite/records/estimate_item'
autoload :EstimateItemList, 'netsuite/records/estimate_item_list'
autoload :File, 'netsuite/records/file'
autoload :GiftCertificate, 'netsuite/records/gift_certificate'
autoload :GiftCertificateItem, 'netsuite/records/gift_certificate_item'
Expand Down
42 changes: 42 additions & 0 deletions lib/netsuite/records/estimate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
module NetSuite
module Records
class Estimate
include Support::Fields
include Support::RecordRefs
include Support::Records
include Support::Actions
include Namespaces::TranSales

actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search

fields :alt_handling_cost, :alt_sales_total, :alt_shipping_cost, :balance,
:bill_address, :billing_address, :billing_schedule, :bill_is_residential,
:created_date, :currency_name, :discount_rate, :email, :end_date,
:est_gross_profit, :exchange_rate, :handling_cost, :handling_tax1_rate, :is_taxable,
:last_modified_date, :memo, :message, :other_ref_num, :ship_date, :shipping_cost,
:shipping_tax1_rate, :source, :start_date, :status, :sync_partner_teams, :sync_sales_teams,
:to_be_emailed, :to_be_faxed, :to_be_printed, :total_cost_estimate, :tran_date, :tran_id,
:linked_tracking_numbers, :is_multi_ship_to

field :shipping_address, Address
field :billing_address, Address

field :item_list, EstimateItemList
field :custom_field_list, CustomFieldList

record_refs :bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item, :entity,
:handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, :opportunity, :partner,
:promo_code, :sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :terms

attr_reader :internal_id
attr_accessor :external_id
attr_accessor :search_joins

def initialize(attributes = {})
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
initialize_from_attributes_hash(attributes)
end
end
end
end
40 changes: 40 additions & 0 deletions lib/netsuite/records/estimate_item.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module NetSuite
module Records
class EstimateItem
include Support::Fields
include Support::RecordRefs
include Support::Records
include Namespaces::TranSales

fields :amount, :cost_estimate,
:cost_estimate_type, :defer_rev_rec, :description,
:is_taxable, :line, :quantity,
:rate, :tax_rate1

field :custom_field_list, CustomFieldList

record_refs :item, :job, :price, :tax_code, :units

def initialize(attributes_or_record = {})
case attributes_or_record
when Hash
initialize_from_attributes_hash(attributes_or_record)
when self.class
initialize_from_record(attributes_or_record)
end
end

def initialize_from_record(record)
self.attributes = record.send(:attributes)
end

def to_record
rec = super
if rec["#{record_namespace}:customFieldList"]
rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
end
rec
end
end
end
end
11 changes: 11 additions & 0 deletions lib/netsuite/records/estimate_item_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module NetSuite
module Records
class EstimateItemList < Support::Sublist
include Namespaces::TranSales

sublist :item, EstimateItem

alias :items :item
end
end
end
26 changes: 26 additions & 0 deletions spec/netsuite/records/estimate_item_list_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'spec_helper'

describe NetSuite::Records::EstimateItemList do
let(:list) { NetSuite::Records::EstimateItemList.new }

it 'has a items attribute' do
expect(list.items).to be_kind_of(Array)
end

describe '#to_record' do
before do
list.items << NetSuite::Records::EstimateItem.new(
:rate => 10
)
end

it 'can represent itself as a SOAP record' do
record = {
'tranSales:item' => [{
'tranSales:rate' => 10
}]
}
expect(list.to_record).to eql(record)
end
end
end
40 changes: 40 additions & 0 deletions spec/netsuite/records/estimate_item_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'spec_helper'

describe NetSuite::Records::EstimateItem do
let(:item) { NetSuite::Records::EstimateItem.new }

it 'has all the right fields' do
[
:amount, :cost_estimate, :cost_estimate_type,
:defer_rev_rec, :description,
:is_taxable, :line, :quantity,
:rate, :tax_rate1
].each do |field|
expect(item).to have_field(field)
end
end

it 'has all the right record refs' do
[
:item, :job, :price, :tax_code, :units
].each do |record_ref|
expect(item).to have_record_ref(record_ref)
end
end

describe '#options' do
it 'can be set from attributes'
it 'can be set from a CustomFieldList object'
end

describe '#inventory_detail' do
it 'can be set from attributes'
it 'can be set from an InventoryDetail object'
end

describe '#custom_field_list' do
it 'can be set from attributes'
it 'can be set from a CustomFieldList object'
end

end
216 changes: 216 additions & 0 deletions spec/netsuite/records/estimate_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
require 'spec_helper'

describe NetSuite::Records::Estimate do
let(:estimate) { NetSuite::Records::Estimate.new }
let(:customer) { NetSuite::Records::Customer.new }
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }

it 'has all the right fields' do
[
:alt_handling_cost, :alt_shipping_cost,
:balance, :bill_address, :created_date, :currency_name,
:discount_rate, :email, :end_date, :est_gross_profit,
:exchange_rate,
:handling_cost, :handling_tax1_rate, :is_taxable,
:last_modified_date, :memo, :message, :other_ref_num,
:shipping_cost, :shipping_tax1_rate,
:source, :start_date, :status, :sync_partner_teams,
:sync_sales_teams, :to_be_emailed, :to_be_faxed, :to_be_printed,
:total_cost_estimate, :tran_date, :tran_id
].each do |field|
expect(estimate).to have_field(field)
end
end

it 'has all the right record refs' do
[
:bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item,
:entity, :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel,
:opportunity, :partner, :promo_code, :sales_group, :sales_rep,
:ship_method, :shipping_tax_code, :subsidiary
].each do |record_ref|
expect(estimate).to have_record_ref(record_ref)
end
end

describe '#order_status' do
it 'can be set from attributes'
it 'can be set from a EstimateStatus object'
end

describe '#item_list' do
it 'can be set from attributes' do
attributes = {
:item => {
:amount => 10
}
}
estimate.item_list = attributes
expect(estimate.item_list).to be_kind_of(NetSuite::Records::EstimateItemList)
expect(estimate.item_list.items.length).to eql(1)
end

it 'can be set from a EstimateItemList object' do
item_list = NetSuite::Records::EstimateItemList.new
estimate.item_list = item_list
expect(estimate.item_list).to eql(item_list)
end
end

describe '#transaction_bill_address' do
it 'can be set from attributes'
it 'can be set from a BillAddress object'
end

describe '#transaction_ship_address' do
it 'can be set from attributes'
it 'can be set from a ShipAddress object'
end

describe '#revenue_status' do
it 'can be set from attributes'
it 'can be set from a RevenueStatus object'
end

describe '#sales_team_list' do
it 'can be set from attributes'
it 'can be set from a EstimateSalesTeamList object'
end

describe '#partners_list' do
it 'can be set from attributes'
it 'can be set from a EstimatePartnersList object'
end

describe '#custom_field_list' do
it 'can be set from attributes'
it 'can be set from a CustomFieldList object'
end

describe '.get' do
context 'when the response is successful' do
let(:response) { NetSuite::Response.new(:success => true, :body => { :alt_shipping_cost => 100 }) }

it 'returns a Estimate instance populated with the data from the response object' do
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Estimate, :external_id => 1], {}).and_return(response)
estimate = NetSuite::Records::Estimate.get(:external_id => 1)
expect(estimate).to be_kind_of(NetSuite::Records::Estimate)
expect(estimate.alt_shipping_cost).to eql(100)
end
end

context 'when the response is unsuccessful' do
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }

it 'raises a RecordNotFound exception' do
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Estimate, :external_id => 1], {}).and_return(response)
expect {
NetSuite::Records::Estimate.get(:external_id => 1)
}.to raise_error(NetSuite::RecordNotFound,
/NetSuite::Records::Estimate with OPTIONS=(.*) could not be found/)
end
end
end

describe '.initialize' do
context 'when the request is successful' do
it 'returns an initialized sales order from the customer entity' do
expect(NetSuite::Actions::Initialize).to receive(:call).with([NetSuite::Records::Estimate, customer], {}).and_return(response)
estimate = NetSuite::Records::Estimate.initialize(customer)
expect(estimate).to be_kind_of(NetSuite::Records::Estimate)
end
end

context 'when the response is unsuccessful' do
skip
end
end

describe '#add' do
let(:test_data) { { :email => 'test@example.com', :fax => '1234567890' } }

context 'when the response is successful' do
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }

it 'returns true' do
estimate = NetSuite::Records::Estimate.new(test_data)
expect(NetSuite::Actions::Add).to receive(:call).
with([estimate], {}).
and_return(response)
expect(estimate.add).to be_truthy
end
end

context 'when the response is unsuccessful' do
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }

it 'returns false' do
estimate = NetSuite::Records::Estimate.new(test_data)
expect(NetSuite::Actions::Add).to receive(:call).
with([estimate], {}).
and_return(response)
expect(estimate.add).to be_falsey
end
end
end

describe '#delete' do
let(:test_data) { { :internal_id => '1' } }

context 'when the response is successful' do
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }

it 'returns true' do
estimate = NetSuite::Records::Estimate.new(test_data)
expect(NetSuite::Actions::Delete).to receive(:call).
with([estimate], {}).
and_return(response)
expect(estimate.delete).to be_truthy
end
end

context 'when the response is unsuccessful' do
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }

it 'returns false' do
estimate = NetSuite::Records::Estimate.new(test_data)
expect(NetSuite::Actions::Delete).to receive(:call).
with([estimate], {}).
and_return(response)
expect(estimate.delete).to be_falsey
end
end
end

describe '#to_record' do
before do
estimate.email = 'something@example.com'
estimate.tran_id = '4'
end
it 'can represent itself as a SOAP record' do
record = {
'tranSales:email' => 'something@example.com',
'tranSales:tranId' => '4'
}
expect(estimate.to_record).to eql(record)
end
end

describe '#record_type' do
it 'returns a string representation of the SOAP type' do
expect(estimate.record_type).to eql('tranSales:Estimate')
end
end

skip "closing a sales order" do
it "closes each line to close the sales order" do
attributes = sales_order.attributes
attributes[:item_list].items.each do |item|
item.is_closed = true
item.attributes = item.attributes.slice(:line, :is_closed)
end

sales_order.update({ item_list: attributes[:item_list] })
end
end
end