diff --git a/.gitignore b/.gitignore index 2ae118378..f17263e15 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ test/version_tmp tmp vendor/ .tags* +.editorconfig diff --git a/lib/netsuite.rb b/lib/netsuite.rb index 4afe36b39..3daed7f50 100644 --- a/lib/netsuite.rb +++ b/lib/netsuite.rb @@ -5,9 +5,9 @@ require 'netsuite/errors' require 'netsuite/utilities' require 'netsuite/utilities/data_center' +require 'netsuite/utilities/strings' require 'netsuite/rest/utilities/roles' require 'netsuite/rest/utilities/request' -require 'netsuite/core_ext/string/lower_camelcase' module NetSuite autoload :Configuration, 'netsuite/configuration' @@ -33,6 +33,7 @@ module Namespaces autoload :SetupCustom, 'netsuite/namespaces/setup_custom' autoload :ListEmp, 'netsuite/namespaces/list_emp' autoload :ListMkt, 'netsuite/namespaces/list_mkt' + autoload :ListBom, 'netsuite/namespaces/list_bom' end module Support @@ -48,7 +49,9 @@ module Support end module Actions + autoload :AbstractAction, 'netsuite/actions/abstract_action' autoload :Add, 'netsuite/actions/add' + autoload :AttachFile, 'netsuite/actions/attach_file' autoload :Delete, 'netsuite/actions/delete' autoload :DeleteList, 'netsuite/actions/delete_list' autoload :Get, 'netsuite/actions/get' @@ -87,6 +90,8 @@ module Records autoload :BinTransfer, 'netsuite/records/bin_transfer' autoload :BinTransferInventory, 'netsuite/records/bin_transfer_inventory' autoload :BinTransferInventoryList, 'netsuite/records/bin_transfer_inventory_list' + autoload :Bom, 'netsuite/records/bom' + autoload :BomRevision, 'netsuite/records/bom_revision' autoload :CashSale, 'netsuite/records/cash_sale' autoload :CashSaleItem, 'netsuite/records/cash_sale_item' autoload :CashSaleItemList, 'netsuite/records/cash_sale_item_list' @@ -132,8 +137,6 @@ module Records autoload :CustomerRefundApplyList, 'netsuite/records/customer_refund_apply_list' autoload :CustomerRefundDeposit, 'netsuite/records/customer_refund_deposit' autoload :CustomerRefundDepositList, 'netsuite/records/customer_refund_deposit_list' - autoload :CustomerSubscription, 'netsuite/records/customer_subscription' - autoload :CustomerSubscriptionsList, 'netsuite/records/customer_subscriptions_list' autoload :CustomerStatus, 'netsuite/records/customer_status' autoload :CustomerPartner, 'netsuite/records/customer_partner' autoload :CustomerSalesTeam, 'netsuite/records/customer_sales_team' @@ -192,14 +195,22 @@ module Records autoload :Invoice, 'netsuite/records/invoice' autoload :InvoiceItem, 'netsuite/records/invoice_item' autoload :InvoiceItemList, 'netsuite/records/invoice_item_list' + autoload :ItemAvailability, 'netsuite/records/item_availability' autoload :ItemFulfillment, 'netsuite/records/item_fulfillment' autoload :ItemFulfillmentItem, 'netsuite/records/item_fulfillment_item' autoload :ItemFulfillmentItemList, 'netsuite/records/item_fulfillment_item_list' autoload :ItemFulfillmentPackage, 'netsuite/records/item_fulfillment_package' autoload :ItemFulfillmentPackageList, 'netsuite/records/item_fulfillment_package_list' + autoload :ItemFulfillmentPackageFedEx, 'netsuite/records/item_fulfillment_package_fed_ex' + autoload :ItemFulfillmentPackageUps, 'netsuite/records/item_fulfillment_package_ups' + autoload :ItemFulfillmentPackageUsps, 'netsuite/records/item_fulfillment_package_usps' + autoload :ItemFulfillmentPackageFedExList, 'netsuite/records/item_fulfillment_package_fed_ex_list' + autoload :ItemFulfillmentPackageUpsList, 'netsuite/records/item_fulfillment_package_ups_list' + autoload :ItemFulfillmentPackageUspsList, 'netsuite/records/item_fulfillment_package_usps_list' autoload :ItemGroup, 'netsuite/records/item_group' autoload :ItemMember, 'netsuite/records/item_member' autoload :ItemMemberList, 'netsuite/records/item_member_list' + autoload :ItemOptionCustomField, 'netsuite/records/item_option_custom_field' autoload :ItemReceipt, 'netsuite/records/item_receipt' autoload :ItemReceiptItemList, 'netsuite/records/item_receipt_item_list' autoload :ItemReceiptItem, 'netsuite/records/item_receipt_item' @@ -223,6 +234,7 @@ module Records autoload :NonInventoryResaleItem, 'netsuite/records/non_inventory_resale_item' autoload :Note, 'netsuite/records/note' autoload :NoteType, 'netsuite/records/note_type' + autoload :NullFieldList, 'netsuite/records/null_field_list' autoload :Opportunity, 'netsuite/records/opportunity' autoload :OpportunityItem, 'netsuite/records/opportunity_item' autoload :OpportunityItemList, 'netsuite/records/opportunity_item_list' @@ -268,6 +280,8 @@ module Records autoload :SerializedInventoryItemLocationsList, 'netsuite/records/serialized_inventory_item_locations_list' autoload :ShipAddress, 'netsuite/records/ship_address' autoload :SiteCategory, 'netsuite/records/site_category' + autoload :Subscription, 'netsuite/records/subscription' + autoload :SubscriptionsList, 'netsuite/records/subscriptions_list' autoload :Subsidiary, 'netsuite/records/subsidiary' autoload :SubtotalItem, 'netsuite/records/subtotal_item' autoload :SupportCase, 'netsuite/records/support_case' @@ -283,6 +297,8 @@ module Records autoload :TransferOrder, 'netsuite/records/transfer_order' autoload :TransferOrderItemList, 'netsuite/records/transfer_order_item_list' autoload :TransferOrderItem, 'netsuite/records/transfer_order_item' + autoload :Translation, 'netsuite/records/translation' + autoload :TranslationList, 'netsuite/records/translation_list' autoload :UnitsType, 'netsuite/records/units_type' autoload :UnitsTypeUomList, 'netsuite/records/units_type_uom_list' autoload :UnitsTypeUom, 'netsuite/records/units_type_uom' diff --git a/lib/netsuite/actions/abstract_action.rb b/lib/netsuite/actions/abstract_action.rb new file mode 100644 index 000000000..ff9f73221 --- /dev/null +++ b/lib/netsuite/actions/abstract_action.rb @@ -0,0 +1,32 @@ +module NetSuite + module Actions + class AbstractAction + def request(credentials={}) + NetSuite::Configuration.connection(request_options, credentials, soap_header_extra_info).call(action_name, message: request_body) + end + + protected + + def action_name + raise NotImplementedError, 'Not implemented on abstract class' + end + + def initialize + raise NotImplementedError, 'Not implemented on abstract class' + end + + def request_body + raise NotImplementedError, 'Not implemented on abstract class' + end + + def request_options + {} + end + + def soap_header_extra_info + {} + end + end + end +end + \ No newline at end of file diff --git a/lib/netsuite/actions/add.rb b/lib/netsuite/actions/add.rb index 4cc352661..d6a9a58c8 100644 --- a/lib/netsuite/actions/add.rb +++ b/lib/netsuite/actions/add.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/add.html module NetSuite module Actions - class Add + class Add < AbstractAction include Support::Requests attr_reader :response_hash @@ -12,10 +12,6 @@ def initialize(object = nil) private - def request(credentials={}) - NetSuite::Configuration.connection({}, credentials).call(:add, :message => request_body) - end - # # # @@ -49,7 +45,11 @@ def success? end def response_body - @response_body ||= response_hash[:base_ref] + @response_body ||= if response_hash[:base_ref].is_a?(Nori::StringIOFile) + { :@internal_id => Nokogiri::XML(@response.to_s).remove_namespaces!.at_xpath('//baseRef')[:internalId] } + else + response_hash[:base_ref] + end end def response_errors @@ -62,12 +62,17 @@ def response_hash @response_hash ||= @response.to_hash[:add_response][:write_response] end + def action_name + :add + end + def errors error_obj = response_hash[:status][:status_detail] error_obj = [error_obj] if error_obj.class == Hash error_obj.map do |error| + next if error.keys == [:after_submit_failed] NetSuite::Error.new(error) - end + end.compact end module Support diff --git a/lib/netsuite/actions/attach_file.rb b/lib/netsuite/actions/attach_file.rb new file mode 100644 index 000000000..61b106372 --- /dev/null +++ b/lib/netsuite/actions/attach_file.rb @@ -0,0 +1,87 @@ +module NetSuite + module Actions + class AttachFile < AbstractAction + include Support::Requests + + def initialize(object, file) + @object = object + @file = file + end + + private + + # + # + # + # + # + # + # + # + # + + def request_body + { + 'platformCore:attachReference' => { + '@xsi:type' => 'platformCore:AttachBasicReference', + 'platformCore:attachTo' => { + '@internalId' => @object.internal_id, + '@type' => @object.netsuite_type, + '@xsi:type' => 'platformCore:RecordRef' + }, + 'platformCore:attachedRecord' => { + '@internalId' => @file.internal_id, + '@type' => 'file', + '@xsi:type' => 'platformCore:RecordRef' + } + } + } + end + + def success? + @success ||= response_hash[:status][:@is_success] == 'true' + end + + def response_body + @response_body ||= response_hash[:base_ref] + end + + def response_errors + if response_hash[:status] && response_hash[:status][:status_detail] + @response_errors ||= errors + end + end + + def response_hash + @response_hash ||= @response.to_hash[:attach_response][:write_response] + end + + def action_name + :attach + end + + def errors + error_obj = response_hash[:status][:status_detail] + error_obj = [error_obj] if error_obj.class == Hash + error_obj.map do |error| + NetSuite::Error.new(error) + end + end + + module Support + def attach_file(file, credentials = {}) + response = NetSuite::Actions::AttachFile.call([self, file], credentials) + + @errors = response.errors + + if response.success? + @internal_id = response.body[:@internal_id] + true + else + false + end + end + end + end + end +end diff --git a/lib/netsuite/actions/delete.rb b/lib/netsuite/actions/delete.rb index d79aafb05..ebe3eae1a 100644 --- a/lib/netsuite/actions/delete.rb +++ b/lib/netsuite/actions/delete.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/delete.html module NetSuite module Actions - class Delete + class Delete < AbstractAction include Support::Requests def initialize(object = nil, options = {}) @@ -11,17 +11,8 @@ def initialize(object = nil, options = {}) private - def request(credentials={}) - NetSuite::Configuration.connection( - {namespaces: { - 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", - 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" - }}, credentials - ).call :delete, message: request_body - end - def soap_type - @object.class.to_s.split('::').last.lower_camelcase + NetSuite::Support::Records.netsuite_type(@object) end # @@ -65,6 +56,33 @@ def response_body @response_body ||= response_hash[:base_ref] end + def response_errors + if response_hash[:status] && response_hash[:status][:status_detail] + @response_errors ||= errors + end + end + + def request_options + { + namespaces: { + 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", + 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" + } + } + end + + def action_name + :delete + end + + def errors + error_obj = response_hash[:status][:status_detail] + error_obj = [error_obj] if error_obj.class == Hash + error_obj.map do |error| + NetSuite::Error.new(error) + end + end + module Support def delete(options = {}, credentials={}) response = if options.empty? @@ -72,6 +90,9 @@ def delete(options = {}, credentials={}) else NetSuite::Actions::Delete.call([self, options], credentials) end + + @errors = response.errors + response.success? end end diff --git a/lib/netsuite/actions/delete_list.rb b/lib/netsuite/actions/delete_list.rb index 36eb4ecfe..2b42292be 100644 --- a/lib/netsuite/actions/delete_list.rb +++ b/lib/netsuite/actions/delete_list.rb @@ -1,6 +1,6 @@ module NetSuite module Actions - class DeleteList + class DeleteList < AbstractAction include Support::Requests def initialize(klass, options = { }) @@ -10,15 +10,6 @@ def initialize(klass, options = { }) private - def request(credentials={}) - NetSuite::Configuration.connection( - {namespaces: { - 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", - 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" - }}, credentials - ).call :delete_list, message: request_body - end - # # # @@ -40,7 +31,7 @@ def request_body } end else - type = @klass.to_s.split('::').last.lower_camelcase + type = NetSuite::Support::Records.netsuite_type(@klass) record_type = 'platformCore:RecordRef' list.map do |internal_id| @@ -71,6 +62,19 @@ def response_errors end end + def request_options + { + namespaces: { + 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", + 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" + } + } + end + + def action_name + :delete_list + end + def errors errors = response_list.select { |r| r[:status] && r[:status][:status_detail] }.map do |obj| error_obj = obj[:status][:status_detail] diff --git a/lib/netsuite/actions/get.rb b/lib/netsuite/actions/get.rb index 6674ef0c9..a74ff5c7e 100644 --- a/lib/netsuite/actions/get.rb +++ b/lib/netsuite/actions/get.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/get.html module NetSuite module Actions - class Get + class Get < AbstractAction include Support::Requests def initialize(klass, options = {}) @@ -11,17 +11,8 @@ def initialize(klass, options = {}) private - def request(credentials={}) - NetSuite::Configuration.connection( - {namespaces: { - 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", - 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" - }}, credentials - ).call :get, message: request_body - end - def soap_type - @klass.to_s.split('::').last.lower_camelcase + NetSuite::Support::Records.netsuite_type(@klass) end # @@ -56,6 +47,19 @@ def response_hash @response_hash = @response.body[:get_response][:read_response] end + def request_options + { + namespaces: { + 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", + 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" + } + } + end + + def action_name + :get + end + module Support def self.included(base) diff --git a/lib/netsuite/actions/get_all.rb b/lib/netsuite/actions/get_all.rb index dddf32dbd..ee938f94a 100644 --- a/lib/netsuite/actions/get_all.rb +++ b/lib/netsuite/actions/get_all.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/getAll.html module NetSuite module Actions - class GetAll + class GetAll < AbstractAction include Support::Requests def initialize(klass) @@ -10,12 +10,6 @@ def initialize(klass) private - def request(credentials={}) - NetSuite::Configuration.connection( - { element_form_default: :unqualified }, credentials - ).call(:get_all, message: request_body) - end - # # # @@ -49,6 +43,16 @@ def response_hash @response_hash ||= @response.body[:get_all_response][:get_all_result] end + def request_options + { + element_form_default: :unqualified + } + end + + def action_name + :get_all + end + module Support def self.included(base) diff --git a/lib/netsuite/actions/get_deleted.rb b/lib/netsuite/actions/get_deleted.rb index c13b936d9..d0489e8b6 100644 --- a/lib/netsuite/actions/get_deleted.rb +++ b/lib/netsuite/actions/get_deleted.rb @@ -1,6 +1,6 @@ module NetSuite module Actions - class GetDeleted + class GetDeleted < AbstractAction include Support::Requests def initialize(object = nil, options = {}) @@ -10,17 +10,8 @@ def initialize(object = nil, options = {}) private - def request(credentials={}) - NetSuite::Configuration.connection( - {namespaces: { - 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", - 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" - }}, credentials - ).call :get_deleted, message: request_body - end - def soap_type - @object.class.to_s.split('::').last.lower_camelcase + NetSuite::Support::Records.netsuite_type(@object) end # @@ -72,6 +63,19 @@ def response_body @response_body ||= response_hash[:get_deleted_result] end + def request_options + { + namespaces: { + 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", + 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" + } + } + end + + def action_name + :get_deleted + end + module Support def self.included(base) base.extend(ClassMethods) diff --git a/lib/netsuite/actions/get_list.rb b/lib/netsuite/actions/get_list.rb index 2fc18105f..eb6462da9 100644 --- a/lib/netsuite/actions/get_list.rb +++ b/lib/netsuite/actions/get_list.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/getList.html module NetSuite module Actions - class GetList + class GetList < AbstractAction include Support::Requests def initialize(klass, options = { }) @@ -11,10 +11,6 @@ def initialize(klass, options = { }) private - def request(credentials={}) - NetSuite::Configuration.connection({}, credentials).call(:get_list, :message => request_body) - end - def request_body # list of all netsuite types; useful for debugging # https://webservices.netsuite.com/xsd/platform/v2014_1_0/coreTypes.xsd @@ -33,7 +29,7 @@ def request_body } end else - type = @klass.to_s.split('::').last.lower_camelcase + type = NetSuite::Support::Records.netsuite_type(@klass) record_type = 'platformCore:RecordRef' list.map do |internal_id| @@ -64,6 +60,10 @@ def response_body @response_body end + def action_name + :get_list + end + def success? # each returned record has its own status; if @options[:allow_incomplete] diff --git a/lib/netsuite/actions/get_select_value.rb b/lib/netsuite/actions/get_select_value.rb index f4938f7b2..1091f6a66 100644 --- a/lib/netsuite/actions/get_select_value.rb +++ b/lib/netsuite/actions/get_select_value.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/getSelectValue.html module NetSuite module Actions - class GetSelectValue + class GetSelectValue < AbstractAction include Support::Requests def initialize(klass, options = {}) @@ -11,13 +11,8 @@ def initialize(klass, options = {}) private - def request(credentials={}) - NetSuite::Configuration.connection( - {namespaces: { - 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", - 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" - }}, credentials - ).call :get_select_value, :message => @options + def request_body + @options end def success? @@ -32,6 +27,19 @@ def response_hash @response_hash = @response.body[:get_select_value_response][:get_select_value_result] end + def request_options + { + namespaces: { + 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", + 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com" + } + } + end + + def action_name + :get_select_value + end + module Support def self.included(base) diff --git a/lib/netsuite/actions/initialize.rb b/lib/netsuite/actions/initialize.rb index 8e5ab949c..24ca62dca 100644 --- a/lib/netsuite/actions/initialize.rb +++ b/lib/netsuite/actions/initialize.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/initializeinitializeList.html module NetSuite module Actions - class Initialize + class Initialize < AbstractAction include Support::Requests def initialize(klass, object) @@ -9,16 +9,6 @@ def initialize(klass, object) @object = object end - def request(credentials={}) - NetSuite::Configuration.connection( - {namespaces: { - 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", - 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", - 'xmlns:platformCoreTyp' => "urn:types.core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", - }}, credentials - ).call :initialize, :message => request_body - end - # # invoice # @@ -28,12 +18,12 @@ def request(credentials={}) def request_body { 'platformMsgs:initializeRecord' => { - 'platformCore:type' => @klass.to_s.split('::').last.lower_camelcase, + 'platformCore:type' => NetSuite::Support::Records.netsuite_type(@klass), 'platformCore:reference' => {}, :attributes! => { 'platformCore:reference' => { 'internalId' => @object.internal_id, - :type => @object.class.to_s.split('::').last.lower_camelcase + :type => NetSuite::Support::Records.netsuite_type(@object) } } } @@ -52,6 +42,20 @@ def response_body @response_body ||= response_hash[:record] end + def request_options + { + namespaces: { + 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", + 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", + 'xmlns:platformCoreTyp' => "urn:types.core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com", + } + } + end + + def action_name + :initialize + end + module Support def self.included(base) diff --git a/lib/netsuite/actions/search.rb b/lib/netsuite/actions/search.rb index e5f8420dd..51451b3b9 100644 --- a/lib/netsuite/actions/search.rb +++ b/lib/netsuite/actions/search.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/search.html module NetSuite module Actions - class Search + class Search < AbstractAction include Support::Requests def initialize(klass, options = { }) @@ -18,24 +18,6 @@ def class_name end private - def request(credentials={}) - # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/SettingSearchPreferences.html - # https://webservices.netsuite.com/xsd/platform/v2012_2_0/messages.xsd - - preferences = NetSuite::Configuration.auth_header(credentials) - .update(NetSuite::Configuration.soap_header) - .merge( - (@options.delete(:preferences) || {}).inject({'platformMsgs:SearchPreferences' => {}}) do |h, (k, v)| - h['platformMsgs:SearchPreferences'][k.to_s.lower_camelcase] = v - h - end - ) - - NetSuite::Configuration - .connection({ soap_header: preferences }, credentials) - .call (@options.has_key?(:search_id)? :search_more_with_id : :search), :message => request_body - end - # basic search XML # @@ -144,12 +126,23 @@ def request_body h[element_name] = { '@operator' => condition[:operator], '@xsi:type' => 'platformCore:SearchMultiSelectField', - "platformCore:searchValue" => { - :content! => condition[:value].map(&:to_record), - '@internalId' => condition[:value].map(&:internal_id), - '@xsi:type' => 'platformCore:RecordRef', - '@type' => 'account' - } + "platformCore:searchValue" => condition[:value].map do |value| + search_value = { + :content! => value.to_record, + '@xsi:type' => 'platformCore:RecordRef', + '@type' => 'account' + } + + if value.internal_id + search_value['@internalId'] = value.internal_id + end + + if value.external_id + search_value['@externalId'] = value.external_id + end + + search_value + end } elsif condition[:value].is_a?(Array) && condition[:type] == 'SearchDateField' # date ranges are handled via searchValue (start range) and searchValue2 (end range) @@ -228,6 +221,21 @@ def search_result end[:search_result] end + def action_name + @options.has_key?(:search_id)? :search_more_with_id : :search + end + + def soap_header_extra_info + # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/SettingSearchPreferences.html + # https://webservices.netsuite.com/xsd/platform/v2012_2_0/messages.xsd + + (@options.delete(:preferences) || {}) + .inject({'platformMsgs:SearchPreferences' => {}}) do |h, (k, v)| + h['platformMsgs:SearchPreferences'][NetSuite::Utilities::Strings.lower_camelcase(k.to_s)] = v + h + end + end + def success? @success ||= search_result[:status][:@is_success] == 'true' end @@ -235,6 +243,8 @@ def success? module Support def self.included(base) base.extend(ClassMethods) + + attr_accessor :search_joins end module ClassMethods diff --git a/lib/netsuite/actions/update.rb b/lib/netsuite/actions/update.rb index 37e822349..c71e7fd5e 100644 --- a/lib/netsuite/actions/update.rb +++ b/lib/netsuite/actions/update.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/update.html module NetSuite module Actions - class Update + class Update < AbstractAction include Support::Requests attr_reader :response_hash @@ -11,10 +11,6 @@ def initialize(klass, attributes) @attributes = attributes end - def request(credentials={}) - NetSuite::Configuration.connection({}, credentials).call :update, :message => request_body - end - # # # Shutter Fly Corporation @@ -69,6 +65,10 @@ def errors end end + def action_name + :update + end + module Support def update(options = {}, credentials={}) options[:internal_id] = internal_id if respond_to?(:internal_id) && internal_id diff --git a/lib/netsuite/actions/update_list.rb b/lib/netsuite/actions/update_list.rb index 0bc506f14..637c3da27 100644 --- a/lib/netsuite/actions/update_list.rb +++ b/lib/netsuite/actions/update_list.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/updateList.html module NetSuite module Actions - class UpdateList + class UpdateList < AbstractAction include Support::Requests def initialize(*objects) @@ -10,12 +10,6 @@ def initialize(*objects) private - def request(credentials={}) - NetSuite::Configuration.connection( - { element_form_default: :unqualified }, credentials - ).call(:update_list, message: request_body) - end - # # # @@ -79,6 +73,16 @@ def success? @success ||= response_hash.all? { |h| h[:status][:@is_success] == 'true' } end + def request_options + { + element_form_default: :unqualified + } + end + + def action_name + :update_list + end + module Support def self.included(base) diff --git a/lib/netsuite/actions/upsert.rb b/lib/netsuite/actions/upsert.rb index 02b2d2137..19c363457 100644 --- a/lib/netsuite/actions/upsert.rb +++ b/lib/netsuite/actions/upsert.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/upsert.html module NetSuite module Actions - class Upsert + class Upsert < AbstractAction include Support::Requests attr_reader :response_hash @@ -12,10 +12,6 @@ def initialize(object = nil) private - def request(credentials={}) - NetSuite::Configuration.connection({}, credentials).call :upsert, :message => request_body - end - # # # @@ -68,6 +64,10 @@ def errors end end + def action_name + :upsert + end + module Support def upsert(credentials={}) response = NetSuite::Actions::Upsert.call([self], credentials) diff --git a/lib/netsuite/actions/upsert_list.rb b/lib/netsuite/actions/upsert_list.rb index 8027da4fd..cd434b3af 100644 --- a/lib/netsuite/actions/upsert_list.rb +++ b/lib/netsuite/actions/upsert_list.rb @@ -1,7 +1,7 @@ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteCloudCustomizationScriptingWebServices/SuiteTalkWebServices/upsertList.html module NetSuite module Actions - class UpsertList + class UpsertList < AbstractAction include Support::Requests def initialize(*objects) @@ -10,12 +10,6 @@ def initialize(*objects) private - def request(credentials={}) - NetSuite::Configuration.connection( - { element_form_default: :unqualified }, credentials - ).call(:upsert_list, message: request_body) - end - # # # @@ -75,6 +69,16 @@ def success? @success ||= response_hash.all? { |h| h[:status][:@is_success] == 'true' } end + def request_options + { + element_form_default: :unqualified + } + end + + def action_name + :upsert_list + end + module Support def self.included(base) diff --git a/lib/netsuite/configuration.rb b/lib/netsuite/configuration.rb index 936cbb247..85b36210a 100644 --- a/lib/netsuite/configuration.rb +++ b/lib/netsuite/configuration.rb @@ -11,23 +11,28 @@ def reset! end def attributes - @attributes ||= {} + if multi_tenant? + Thread.current[:netsuite_gem_attributes] ||= {} + else + @attributes ||= {} + end end - def connection(params={}, credentials={}) + def connection(params={}, credentials={}, soap_header_extra_info={}) client = Savon.client({ wsdl: cached_wsdl || wsdl, endpoint: endpoint, read_timeout: read_timeout, open_timeout: open_timeout, namespaces: namespaces, - soap_header: auth_header(credentials).update(soap_header), + soap_header: auth_header(credentials).update(soap_header).merge(soap_header_extra_info), pretty_print_xml: true, filters: filters, logger: logger, log_level: log_level, log: !silent, # turn off logging entirely if configured }.update(params)) + client.globals.proxy(proxy) if proxy cache_wsdl(client) return client end @@ -50,11 +55,19 @@ def filters=(list) end def wsdl_cache - @wsdl_cache ||= {} + if multi_tenant? + Thread.current[:netsuite_gem_wsdl_cache] ||= {} + else + @wsdl_cache ||= {} + end end def clear_wsdl_cache - @wsdl_cache = {} + if multi_tenant? + Thread.current[:netsuite_gem_wsdl_cache] = {} + else + @wsdl_cache = {} + end end def cached_wsdl @@ -82,7 +95,7 @@ def api_version(version = nil) if version self.api_version = version else - attributes[:api_version] ||= '2015_1' + attributes[:api_version] ||= '2016_2' end end @@ -394,5 +407,25 @@ def log_level(value = nil) def log_level=(value) attributes[:log_level] = value end + + def proxy=(proxy) + attributes[:proxy] = proxy + end + + def proxy(proxy = nil) + if proxy + self.proxy = proxy + else + attributes[:proxy] + end + end + + def multi_tenant! + @multi_tenant = true + end + + def multi_tenant? + @multi_tenant + end end end diff --git a/lib/netsuite/namespaces/list_bom.rb b/lib/netsuite/namespaces/list_bom.rb new file mode 100644 index 000000000..3266b6606 --- /dev/null +++ b/lib/netsuite/namespaces/list_bom.rb @@ -0,0 +1,11 @@ +module NetSuite + module Namespaces + module ListBom + + def record_namespace + 'ListBom' + end + + end + end +end diff --git a/lib/netsuite/records/account.rb b/lib/netsuite/records/account.rb index b749f9596..f69f4b855 100644 --- a/lib/netsuite/records/account.rb +++ b/lib/netsuite/records/account.rb @@ -18,7 +18,6 @@ class Account 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) diff --git a/lib/netsuite/records/accounting_period.rb b/lib/netsuite/records/accounting_period.rb index 74a240a15..b3546974a 100644 --- a/lib/netsuite/records/accounting_period.rb +++ b/lib/netsuite/records/accounting_period.rb @@ -13,7 +13,7 @@ class AccountingPeriod record_refs :parent attr_reader :internal_id - attr_accessor :external_id, :search_joins + attr_accessor :external_id def initialize(attributes = {}) @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id) diff --git a/lib/netsuite/records/assembly_build.rb b/lib/netsuite/records/assembly_build.rb index 0c83114bd..0c8878cd4 100644 --- a/lib/netsuite/records/assembly_build.rb +++ b/lib/netsuite/records/assembly_build.rb @@ -5,7 +5,7 @@ class AssemblyBuild include Support::RecordRefs include Support::Actions include Support::Records - include Support::Fields +# include Support::Fields include Namespaces::TranInvt actions :get, :add, :initialize, :delete, :update, :upsert, :upsert_list, diff --git a/lib/netsuite/records/assembly_component.rb b/lib/netsuite/records/assembly_component.rb index d8ab8ca8f..74fce5641 100644 --- a/lib/netsuite/records/assembly_component.rb +++ b/lib/netsuite/records/assembly_component.rb @@ -15,7 +15,6 @@ class AssemblyComponent 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) @@ -25,4 +24,3 @@ def initialize(attributes = {}) end end end - diff --git a/lib/netsuite/records/assembly_item.rb b/lib/netsuite/records/assembly_item.rb index e259617dc..f0d4d4207 100644 --- a/lib/netsuite/records/assembly_item.rb +++ b/lib/netsuite/records/assembly_item.rb @@ -7,7 +7,7 @@ class AssemblyItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :get_select_value, :add, :delete, :update, :upsert, :upsert_list, :search + actions :get, :get_deleted, :get_list, :get_select_value, :add, :delete, :update, :update_list, :upsert, :upsert_list, :search fields :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, :average_cost, :build_entire_assembly, :copy_description, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :cost_units, :costing_method, @@ -47,10 +47,10 @@ class AssemblyItem field :pricing_matrix, PricingMatrix field :member_list, MemberList field :subsidiary_list, RecordRefList + field :translations_list, TranslationList 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) diff --git a/lib/netsuite/records/assembly_unbuild.rb b/lib/netsuite/records/assembly_unbuild.rb index 763cb0d73..e4914f324 100644 --- a/lib/netsuite/records/assembly_unbuild.rb +++ b/lib/netsuite/records/assembly_unbuild.rb @@ -5,7 +5,7 @@ class AssemblyUnbuild include Support::RecordRefs include Support::Records include Support::Actions - include Support::Fields + #include Support::Fields include Namespaces::TranInvt actions :get, :add, :initialize, :delete, :update, :upsert, :upsert_list, @@ -26,7 +26,6 @@ class AssemblyUnbuild 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) diff --git a/lib/netsuite/records/bom.rb b/lib/netsuite/records/bom.rb new file mode 100644 index 000000000..f6d3082a4 --- /dev/null +++ b/lib/netsuite/records/bom.rb @@ -0,0 +1,20 @@ +module NetSuite + module Records + class Bom + include Support::Actions + include Support::Fields + include Namespaces::ListAcct + + actions :get, :get_list + + attr_reader :internal_id + attr_accessor :external_id + + 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 diff --git a/lib/netsuite/records/bom_revision.rb b/lib/netsuite/records/bom_revision.rb new file mode 100644 index 000000000..956db2782 --- /dev/null +++ b/lib/netsuite/records/bom_revision.rb @@ -0,0 +1,20 @@ +module NetSuite + module Records + class BomRevision + include Support::Actions + include Support::Fields + include Namespaces::ListAcct + + actions :get, :get_list, :search + + attr_reader :internal_id + attr_accessor :external_id + + 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 diff --git a/lib/netsuite/records/cash_refund.rb b/lib/netsuite/records/cash_refund.rb index a4c9b46ab..46eb02fc8 100644 --- a/lib/netsuite/records/cash_refund.rb +++ b/lib/netsuite/records/cash_refund.rb @@ -115,7 +115,6 @@ class CashRefund 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) diff --git a/lib/netsuite/records/cash_refund_item.rb b/lib/netsuite/records/cash_refund_item.rb index 76736f881..44b743158 100644 --- a/lib/netsuite/records/cash_refund_item.rb +++ b/lib/netsuite/records/cash_refund_item.rb @@ -6,7 +6,7 @@ class CashRefundItem include Support::Records include Namespaces::TranCust - fields :amount, :rate, :quantity, :is_taxable, :order_line, :line, :description + fields :amount, :gross_amt, :rate, :quantity, :is_taxable, :order_line, :line, :description field :custom_field_list, CustomFieldList record_refs :item, :klass, :price diff --git a/lib/netsuite/records/cash_sale.rb b/lib/netsuite/records/cash_sale.rb index 97fe2d042..ba12a0f79 100644 --- a/lib/netsuite/records/cash_sale.rb +++ b/lib/netsuite/records/cash_sale.rb @@ -7,7 +7,7 @@ class CashSale include Support::Actions include Namespaces::TranSales - actions :get, :add, :initialize, :delete, :update, :upsert, :search + actions :get, :add, :initialize, :delete, :update, :upsert, :upsert_list, :search fields :alt_handling_cost, :alt_shipping_cost, :auth_code, :bill_address, :cc_approved, :cc_expire_date, :cc_is_purchase_card_bin, :cc_name, :cc_number, :cc_process_as_purchas_card, :cc_security_code, :cc_street, :cc_zip_code, :charge_it, :contrib_pct, :created_date, @@ -36,7 +36,6 @@ class CashSale 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) diff --git a/lib/netsuite/records/contact.rb b/lib/netsuite/records/contact.rb index c107311ca..5dc01b3f4 100644 --- a/lib/netsuite/records/contact.rb +++ b/lib/netsuite/records/contact.rb @@ -24,7 +24,6 @@ class Contact 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) diff --git a/lib/netsuite/records/credit_memo.rb b/lib/netsuite/records/credit_memo.rb index d8134113f..887bcac1c 100644 --- a/lib/netsuite/records/credit_memo.rb +++ b/lib/netsuite/records/credit_memo.rb @@ -23,6 +23,7 @@ class CreditMemo field :item_list, CreditMemoItemList field :apply_list, CreditMemoApplyList field :ship_group_list, SalesOrderShipGroupList + field :null_field_list, NullFieldList # field :bill_address_list, field :transaction_bill_address, BillAddress @@ -38,7 +39,6 @@ class CreditMemo 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) diff --git a/lib/netsuite/records/currency_rate.rb b/lib/netsuite/records/currency_rate.rb index 6ed7c962d..85163e93d 100644 --- a/lib/netsuite/records/currency_rate.rb +++ b/lib/netsuite/records/currency_rate.rb @@ -21,7 +21,6 @@ class CurrencyRate 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) diff --git a/lib/netsuite/records/custom_record.rb b/lib/netsuite/records/custom_record.rb index 60fd4f1de..18e66ee91 100644 --- a/lib/netsuite/records/custom_record.rb +++ b/lib/netsuite/records/custom_record.rb @@ -17,12 +17,12 @@ class CustomRecord :show_last_modified, :show_notes, :show_owner, :show_owner_allow_change, :show_owner_on_list, :use_permissions field :custom_field_list, CustomFieldList + field :translations_list, TranslationList record_refs :custom_form, :owner, :rec_type, :parent 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) diff --git a/lib/netsuite/records/customer.rb b/lib/netsuite/records/customer.rb index 055088713..6af3a8065 100644 --- a/lib/netsuite/records/customer.rb +++ b/lib/netsuite/records/customer.rb @@ -7,44 +7,245 @@ class Customer include Support::Actions include Namespaces::ListRel - actions :get, :get_list, :add, :update, :upsert, :upsert_list, :delete, :delete_list, :search + actions :get, :get_list, :add, :update, :upsert, :upsert_list, :delete, :delete_list, :search, :attach_file # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2014_1/schema/record/customer.html - fields :account_number, :aging, :alt_email, :alt_name, :alt_phone, :bill_pay, - :buying_reason, :buying_time_frame, :campaign_category, :click_stream, :comments, :company_name, - :consol_aging, :consol_days_overdue, :contrib_pct, :credit_hold_override, - :credit_limit, :date_created, :days_overdue, :default_address, - :download_list, :email, :email_preference, :email_transactions, :end_date, :entity_id, - :estimated_budget, :fax, :fax_transactions, :first_name, :first_visit, :give_access, :global_subscription_status, - :group_pricing_list, :home_phone, :image, :is_budget_approved, :is_inactive, :is_person, :item_pricing_list, :keywords, - :language, :last_modified_date, :last_name, :last_page_visited, :last_visit, :middle_name, :mobile_phone, - :opening_balance, :opening_balance_account, :opening_balance_date, - :password, :password2, :phone, :phonetic_name, :pref_cc_processor, :print_on_check_as, - :print_transactions, :referrer, :reminder_days, :representing_subsidiary, :require_pwd_change, :resale_number, - :sales_group, :sales_readiness, :salutation, :send_email, :ship_complete, - :stage, :start_date, :sync_partner_teams, :tax_exempt, :taxable, - :third_party_acct, :third_party_country, :third_party_zipcode, :title, :url, - :vat_reg_number, :visits, :web_lead + fields :account_number, + :aging, + :aging1, + :aging2, + :aging3, + :aging4, + :alcohol_recipient_type, + :alt_email, + :alt_name, + :alt_phone, + :bill_pay, + :click_stream, + :comments, + :company_name, + :consol_aging, + :consol_aging1, + :consol_aging2, + :consol_aging3, + :consol_aging4, + :consol_days_overdue, + :contrib_pct, + :credit_hold_override, + :credit_limit, + :date_created, + :days_overdue, + :default_address, + :default_order_priority, + :display_symbol, + :email, + :email_preference, + :email_transactions, + :end_date, + :entity_id, + :estimated_budget, + :fax, + :fax_transactions, + :first_name, + :first_visit, + :give_access, + :global_subscription_status, + :home_phone, + :is_budget_approved, + :is_inactive, + :is_person, + :keywords, + :language, + :last_modified_date, + :last_name, + :last_page_visited, + :last_visit, + :middle_name, + :mobile_phone, + :monthly_closing, + :negative_number_format, + :number_format, + :opening_balance, + :opening_balance_date, + :override_currency_format, + :password, + :password2, + :phone, + :phonetic_name, + :print_on_check_as, + :print_transactions, + :referrer, + :reminder_days, + :require_pwd_change, + :resale_number, + :salutation, + :send_email, + :ship_complete, + :stage, + :start_date, + :symbol_placement, + :sync_partner_teams, + :taxable, + :tax_exempt, + :third_party_acct, + :third_party_country, + :third_party_zipcode, + :title, + :url, + :vat_reg_number, + :visits, + :web_lead - field :addressbook_list, CustomerAddressbookList - field :credit_cards_list, CustomerCreditCardsList - field :custom_field_list, CustomFieldList + field :addressbook_list, CustomerAddressbookList field :contact_roles_list, ContactAccessRolesList + field :credit_cards_list, CustomerCreditCardsList field :currency_list, CustomerCurrencyList + field :custom_field_list, CustomFieldList + # field :download_list, CustomerDownloadList # TODO Implement me + # field :group_pricing_list, CustomerGroupPricingList # TODO: Implement me + # field :item_pricing_list, CustomerItemPricingList # TODO: Implement me field :partners_list, CustomerPartnersList - field :subscriptions_list, CustomerSubscriptionsList field :sales_team_list, CustomerSalesTeamList + field :subscriptions_list, SubscriptionsList + # field :tax_registration_list, CustomerTaxRegistrationList # TODO: Implement me read_only_fields :balance, :consol_balance, :deposit_balance, :consol_deposit_balance, :overdue_balance, :consol_overdue_balance, :unbilled_orders, :consol_unbilled_orders - record_refs :access_role, :custom_form, :currency, :entity_status, :partner, :category, :lead_source, - :price_level, :sales_rep, :subsidiary, :terms, :parent, :territory, :tax_item, :shipping_item, :receivables_account + search_only_fields :address, + :address1, + :address2, + :address3, + :addressee, + :address_internal_id, + :address_label, + :address_phone, + :alt_contact, + :assigned_site, + :assigned_site_id, + :attention, + :available_offline, + :bill_address, + :bill_address1, + :bill_address2, + :bill_address3, + :bill_addressee, + :bill_attention, + :bill_city, + :bill_country, + :bill_country_code, + :bill_phone, + :bill_state, + :bill_zip_code, + :cc_customer_code, + :cc_default, + :cc_exp_date, + :cc_holder_name, + :cc_internal_id, + :cc_number, + :cc_state, + :cc_state_from, + :cc_type, + :city, + :contact, + :contribution, + :contribution_primary, + :conversion_date, + :country, + :country_code, + :credit_hold, + :date_closed, + :entity_number, + :explicit_conversion, + :first_order_date, + :first_sale_date, + :fx_balance, + :fx_consol_balance, + :fx_consol_unbilled_orders, + :fx_unbilled_orders, + :group_pricing_level, + :has_duplicates, + :is_default_billing, + :is_default_shipping, + :is_ship_address, + :item_pricing_level, + :item_pricing_unit_price, + :job_end_date, + :job_projected_end, + :job_start_date, + :job_type, + :last_order_date, + :last_sale_date, + :lead_date, + :level, + :manual_credit_hold, + :on_credit_hold, + :partner_contribution, + :partner_role, + :partner_team_member, + :pec, + :permission, + :pricing_group, + :pricing_item, + :prospect_date, + :role, + :sales_team_member, + :sales_team_role, + :ship_address, + :ship_address1, + :ship_address2, + :ship_address3, + :ship_addressee, + :ship_attention, + :ship_city, + :ship_country, + :ship_country_code, + :ship_phone, + :ship_state, + :ship_zip, + :source_site, + :source_site_id, + :state, + :subscription, + :subscription_date, + :subscription_status, + :zip_code + + record_refs :access_role, + :assigned_web_site, + :buying_reason, + :buying_time_frame, + :campaign_category, + :category, + :currency, + :custom_form, + :default_allocation_strategy, + :default_tax_reg, + :dr_account, + :entity_status, + :fx_account, + :image, + :lead_source, + :opening_balance_account, + :parent, + :partner, + :pref_cc_processor, + :price_level, + :receivables_account, + :representing_subsidiary, + :sales_group, + :sales_readiness, + :sales_rep, + :shipping_item, + :source_web_site, + :subsidiary, + :tax_item, + :terms, + :territory 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) diff --git a/lib/netsuite/records/customer_deposit.rb b/lib/netsuite/records/customer_deposit.rb index 089627b35..3489cd9b8 100644 --- a/lib/netsuite/records/customer_deposit.rb +++ b/lib/netsuite/records/customer_deposit.rb @@ -29,7 +29,6 @@ class CustomerDeposit 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) diff --git a/lib/netsuite/records/customer_payment.rb b/lib/netsuite/records/customer_payment.rb index e2fef1996..a8e96f8d8 100644 --- a/lib/netsuite/records/customer_payment.rb +++ b/lib/netsuite/records/customer_payment.rb @@ -28,7 +28,6 @@ class CustomerPayment 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) diff --git a/lib/netsuite/records/customer_refund.rb b/lib/netsuite/records/customer_refund.rb index 4f6398e40..8c768d3ab 100644 --- a/lib/netsuite/records/customer_refund.rb +++ b/lib/netsuite/records/customer_refund.rb @@ -20,11 +20,10 @@ class CustomerRefund read_only_fields :balance, :total record_refs :account, :ar_acct, :credit_card, :credit_card_processor, :custom_form, :customer, :department, :klass, - :location, :payment_method, :posting_period, :subsidiary, :void_journal, :currency + :location, :payment_method, :posting_period, :subsidiary, :void_journal, :currency, :payment_option 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) diff --git a/lib/netsuite/records/deposit.rb b/lib/netsuite/records/deposit.rb index 9f1eec3f8..9110dc77a 100644 --- a/lib/netsuite/records/deposit.rb +++ b/lib/netsuite/records/deposit.rb @@ -20,7 +20,6 @@ class Deposit 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) diff --git a/lib/netsuite/records/deposit_application.rb b/lib/netsuite/records/deposit_application.rb index 536778848..2dc67b500 100644 --- a/lib/netsuite/records/deposit_application.rb +++ b/lib/netsuite/records/deposit_application.rb @@ -37,7 +37,6 @@ class DepositApplication 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) diff --git a/lib/netsuite/records/description_item.rb b/lib/netsuite/records/description_item.rb index 7a4d3a442..5c7c5c31f 100644 --- a/lib/netsuite/records/description_item.rb +++ b/lib/netsuite/records/description_item.rb @@ -7,15 +7,15 @@ class SubtotalItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :update, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert fields :available_to_partners, :created_date, :description, :display_name, :include_children, :is_inactive, :item_id, :last_modified_date record_refs :custom_form, :department, :issue_product, :klass, :location - + field :custom_field_list, CustomFieldList field :subsidiary_list, RecordRefList - # TODO field :translations_list, TranslationList + field :translations_list, TranslationList attr_reader :internal_id attr_accessor :external_id diff --git a/lib/netsuite/records/discount_item.rb b/lib/netsuite/records/discount_item.rb index db1cc7827..8f83956bb 100644 --- a/lib/netsuite/records/discount_item.rb +++ b/lib/netsuite/records/discount_item.rb @@ -7,7 +7,7 @@ class DiscountItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :update, :delete, :search, :upsert + actions :get, :get_deleted, :get_list, :add, :update, :update_list, :delete, :search, :upsert fields :available_to_partners, :created_date, :description, :display_name, :include_children, :is_inactive, :is_pre_tax, :item_id, :last_modified_date, :non_posting, :rate, :upc_code, :vendor_name diff --git a/lib/netsuite/records/employee.rb b/lib/netsuite/records/employee.rb index 4df2f03d0..1cccd51e6 100644 --- a/lib/netsuite/records/employee.rb +++ b/lib/netsuite/records/employee.rb @@ -9,7 +9,7 @@ class Employee # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2014_1/script/record/employee.html - actions :get, :get_list, :add, :update, :upsert, :upsert_list, :delete, :search + actions :get, :get_deleted, :get_list, :add, :update, :upsert, :upsert_list, :delete, :search fields :alt_name, :phone, :first_name, :last_name, :is_inactive, :email, :give_access, :send_email, :is_support_rep, :birth_date, :hire_date, :last_review_date, :next_review_date, :title, :home_phone, :office_phone, diff --git a/lib/netsuite/records/estimate.rb b/lib/netsuite/records/estimate.rb index 41e11631b..426714b80 100644 --- a/lib/netsuite/records/estimate.rb +++ b/lib/netsuite/records/estimate.rb @@ -111,7 +111,6 @@ class Estimate 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) diff --git a/lib/netsuite/records/estimate_item.rb b/lib/netsuite/records/estimate_item.rb index 433725af4..902733f47 100644 --- a/lib/netsuite/records/estimate_item.rb +++ b/lib/netsuite/records/estimate_item.rb @@ -13,7 +13,14 @@ class EstimateItem field :custom_field_list, CustomFieldList - record_refs :item, :job, :price, :tax_code, :units + record_refs :department, + :item, + :job, + :klass, + :location, + :price, + :tax_code, + :units def initialize(attributes_or_record = {}) case attributes_or_record diff --git a/lib/netsuite/records/file.rb b/lib/netsuite/records/file.rb index 096bd7af3..d8c13bb8d 100644 --- a/lib/netsuite/records/file.rb +++ b/lib/netsuite/records/file.rb @@ -9,7 +9,7 @@ class File # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2014_1/schema/record/file.html - actions :get, :add, :delete, :search, :get_list + actions :get, :add, :delete, :search, :get_list, :update fields :content, :description, :name, :media_type_name, :file_type, :text_file_encoding, :created_date, :last_modified_date diff --git a/lib/netsuite/records/gift_certificate_item.rb b/lib/netsuite/records/gift_certificate_item.rb index beb52f11b..065b8392b 100644 --- a/lib/netsuite/records/gift_certificate_item.rb +++ b/lib/netsuite/records/gift_certificate_item.rb @@ -7,7 +7,7 @@ class GiftCertificateItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :upsert + actions :get, :get_list, :add, :delete, :search, :update_list, :upsert fields :auth_codes_list, :available_to_partners, diff --git a/lib/netsuite/records/inbound_shipment.rb b/lib/netsuite/records/inbound_shipment.rb index 380fbc7db..b636dc806 100644 --- a/lib/netsuite/records/inbound_shipment.rb +++ b/lib/netsuite/records/inbound_shipment.rb @@ -20,7 +20,6 @@ class InboundShipment 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) diff --git a/lib/netsuite/records/inventory_item.rb b/lib/netsuite/records/inventory_item.rb index 1850d04d0..e8473c963 100644 --- a/lib/netsuite/records/inventory_item.rb +++ b/lib/netsuite/records/inventory_item.rb @@ -20,30 +20,171 @@ class InventoryItem # } # ] # - actions :get, :get_list, :add, :delete, :search, :update, :upsert, :update_list + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert, :update_list - fields :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, :average_cost, - :copy_description, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :cost_units, :costing_method, - :costing_method_display, :country_of_manufacture, :created_date, :currency, :date_converted_to_inv, - :default_return_cost, :demand_modifier, :display_name, :dont_show_price, :enforce_min_qty_internally, - :exclude_from_sitemap, :featured_description, :fixed_lot_size, :handling_cost, :handling_cost_units, :include_children, - :is_donation_item, :is_drop_ship_item, :is_gco_compliant, :is_inactive, :is_online, :is_special_order_item, :is_taxable, - :item_id, :last_modified_date, :last_purchase_price, :lead_time, :manufacturer, :manufacturer_addr1, :manufacturer_city, - :manufacturer_state, :manufacturer_tariff, :manufacturer_tax_id, :manufacturer_zip, :match_bill_to_receipt, - :matrix_type, :max_donation_amount, :meta_tag_html, :minimum_quantity, :minimum_quantity_units, :mpn, - :mult_manufacture_addr, :nex_tag_category, :no_price_message, :offer_support, :on_hand_value_mli, :on_special, - :original_item_subtype, :original_item_type, :out_of_stock_behavior, :out_of_stock_message, - :overall_quantity_pricing_type, :page_title, :preference_criterion, :preferred_stock_level, :preferred_stock_level_days, - :preferred_stock_level_units, :prices_include_tax, :producer, :purchase_description, :quantity_available, - :quantity_available_units, :quantity_back_ordered, :quantity_committed, :quantity_committed_units, :quantity_on_hand, - :quantity_on_hand_units, :quantity_on_order, :quantity_on_order_units, :quantity_reorder_units, :rate, - :related_items_description, :reorder_multiple, :reorder_point, :reorder_point_units, :safety_stock_level, - :safety_stock_level_days, :safety_stock_level_units, :sales_description, :schedule_b_code, :schedule_b_number, - :schedule_b_quantity, :search_keywords, :seasonal_demand, :ship_individually, :shipping_cost, :shipping_cost_units, - :shopping_dot_com_category, :shopzilla_category_id, :show_default_donation_amount, :sitemap_priority, - :specials_description, :stock_description, :store_description, :store_detailed_description, :store_display_name, - :total_value, :track_landed_cost, :transfer_price, :upc_code, :url_component, :use_bins, :use_marginal_rates, - :vendor_name, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :weight, :weight_unit, :weight_units + fields :auto_lead_time, + :auto_preferred_stock_level, + :auto_reorder_point, + :available_to_partners, + :average_cost, + :backward_consumption_days, + :contingent_revenue_handling, + :conversion_rate, + :copy_description, + :cost, + :cost_estimate, + :cost_estimate_type, + :cost_estimate_units, + :costing_method, + :costing_method_display, + :cost_units, + :country_of_manufacture, + :created_date, + :currency, + :date_converted_to_inv, + :default_return_cost, + :defer_rev_rec, + :demand_modifier, + :demand_time_fence, + :direct_revenue_posting, + :display_name, + :dont_show_price, + :enable_catch_weight, + :enforce_min_qty_internally, + :exclude_from_sitemap, + :featured_description, + :fixed_lot_size, + :forward_consumption_days, + :fraud_risk, + :future_horizon, + :handling_cost, + :handling_cost_units, + :hazmat_hazard_class, + :hazmat_id, + :hazmat_item_units, + :hazmat_item_units_qty, + :hazmat_packing_group, + :hazmat_shipping_name, + :include_children, + :invt_classification, + :invt_count_interval, + :is_donation_item, + :is_drop_ship_item, + :is_gco_compliant, + :is_hazmat_item, + :is_inactive, + :is_online, + :is_special_order_item, + :is_store_pickup_allowed, + :is_taxable, + :item_carrier, + :item_id, + :last_invt_count_date, + :last_modified_date, + :last_purchase_price, + :lead_time, + :lower_warning_limit, + :manufacturer, + :manufacturer_addr1, + :manufacturer_city, + :manufacturer_state, + :manufacturer_tariff, + :manufacturer_tax_id, + :manufacturer_zip, + :match_bill_to_receipt, + :matrix_item_name_template, + :matrix_type, + :max_donation_amount, + :maximum_quantity, + :meta_tag_html, + :minimum_quantity, + :minimum_quantity_units, + :mpn, + :mult_manufacture_addr, + :nex_tag_category, + :next_invt_count_date, + :no_price_message, + :offer_support, + :on_hand_value_mli, + :on_special, + :original_item_subtype, + :original_item_type, + :out_of_stock_behavior, + :out_of_stock_message, + :overall_quantity_pricing_type, + :page_title, + :periodic_lot_size_days, + :periodic_lot_size_type, + :preference_criterion, + :preferred_stock_level, + :preferred_stock_level_days, + :preferred_stock_level_units, + :prices_include_tax, + :producer, + :purchase_description, + :purchase_order_amount, + :purchase_order_quantity, + :purchase_order_quantity_diff, + :quantity_available, + :quantity_available_units, + :quantity_back_ordered, + :quantity_committed, + :quantity_committed_units, + :quantity_on_hand, + :quantity_on_hand_units, + :quantity_on_order, + :quantity_on_order_units, + :quantity_reorder_units, + :rate, + :receipt_amount, + :receipt_quantity, + :receipt_quantity_diff, + :related_items_description, + :reorder_multiple, + :reorder_point, + :reorder_point_units, + :reschedule_in_days, + :reschedule_out_days, + :round_up_as_component, + :safety_stock_level, + :safety_stock_level_days, + :safety_stock_level_units, + :sales_description, + :schedule_b_code, + :schedule_b_number, + :schedule_b_quantity, + :search_keywords, + :seasonal_demand, + :ship_individually, + :shipping_cost, + :shipping_cost_units, + :shopping_dot_com_category, + :shopzilla_category_id, + :show_default_donation_amount, + :sitemap_priority, + :specials_description, + :stock_description, + :store_description, + :store_detailed_description, + :store_display_name, + :supply_time_fence, + :total_value, + :track_landed_cost, + :transfer_price, + :upc_code, + :upper_warning_limit, + :url_component, + :use_bins, + :use_marginal_rates, + :vendor_name, + :vsoe_deferral, + :vsoe_delivered, + :vsoe_permit_discount, + :vsoe_price, + :vsoe_sop_group, + :weight, + :weight_unit, + :weight_units # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_2/schema/search/itemsearchrowbasic.html?mode=package search_only_fields :acc_book_rev_rec_forecast_rule, :accounting_book, @@ -105,28 +246,86 @@ class InventoryItem :vendor_price_currency, :vendor_schedule, :vend_return_variance_account, :web_site, :wip_acct, :wip_variance_acct, :yahoo_product_feed - record_refs :alternate_demand_source_item, :asset_account, :bill_exch_rate_variance_acct, :bill_price_variance_acct, - :bill_qty_variance_acct, :billing_schedule, :cogs_account, :cost_category, :custom_form, :deferred_revenue_account, - :demand_source, :department, :expense_account, :gain_loss_account, :income_account, :issue_product, :klass, :location, - :parent, :preferred_location, :pricing_group, :purchase_price_variance_acct, :purchase_tax_code, :purchase_unit, - :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :ship_package, :soft_descriptor, - :stock_unit, :store_display_image, :store_display_thumbnail, :store_item_template, :supply_lot_sizing_method, - :supply_replenishment_method, :supply_type, :tax_schedule, :units_type, :vendor, :create_revenue_plans_on, - :revenue_recognition_rule, :rev_rec_forecast_rule + record_refs :alternate_demand_source_item, + :asset_account, + :bill_exch_rate_variance_acct, + :billing_schedule, + :bill_price_variance_acct, + :bill_qty_variance_acct, + :klass, + :cogs_account, + :consumption_unit, + :cost_category, + :create_revenue_plans_on, + :custom_form, + :default_item_ship_method, + :deferred_revenue_account, + :demand_source, + :department, + :distribution_category, + :distribution_network, + :dropship_expense_account, + :expense_account, + :gain_loss_account, + :income_account, + :interco_cogs_account, + :interco_def_rev_account, + :interco_income_account, + :issue_product, + :item_revenue_category, + :location, + :parent, + :planning_item_category, + :preferred_location, + :pricing_group, + :purchase_price_variance_acct, + :purchase_tax_code, + :purchase_unit, + :quantity_pricing_schedule, + :revenue_allocation_group, + :revenue_recognition_rule, + :rev_rec_forecast_rule, + :rev_reclass_f_x_account, + :rev_rec_schedule, + :sales_tax_code, + :sale_unit, + :secondary_base_unit, + :secondary_consumption_unit, + :secondary_purchase_unit, + :secondary_sale_unit, + :secondary_stock_unit, + :secondary_units_type, + :ship_package, + :soft_descriptor, + :stock_unit, + :store_display_image, + :store_display_thumbnail, + :store_item_template, + :supply_lot_sizing_method, + :supply_replenishment_method, + :supply_type, + :tax_schedule, + :units_type, + :vendor - field :pricing_matrix, PricingMatrix - field :custom_field_list, CustomFieldList field :bin_number_list, BinNumberList - field :locations_list, LocationsList + field :custom_field_list, CustomFieldList + field :item_ship_method_list, RecordRefList field :item_vendor_list, ItemVendorList + field :locations_list, LocationsList field :matrix_option_list, MatrixOptionList + field :pricing_matrix, PricingMatrix field :subsidiary_list, RecordRefList - - # for Assembly/Kit - field :member_list, MemberList + # TODO: :accounting_book_detail_list, ItemAccountingBookDetailList + # TODO: :hierarchy_versions_list, InventoryItemHierarchyVersionsList + # TODO: :item_options_list, ItemOptionsList + # TODO: :presentation_item_list, PresentationItemList + # TODO: :product_feed_list, ProductFeedList + # TODO: :site_category_list, SiteCategoryList + field :translations_list, TranslationList attr_reader :internal_id - attr_accessor :external_id, :search_joins + attr_accessor :external_id def initialize(attributes = {}) @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id) diff --git a/lib/netsuite/records/inventory_number.rb b/lib/netsuite/records/inventory_number.rb index 83bf2e824..0e0a84377 100644 --- a/lib/netsuite/records/inventory_number.rb +++ b/lib/netsuite/records/inventory_number.rb @@ -19,7 +19,6 @@ class InventoryNumber 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) diff --git a/lib/netsuite/records/invoice.rb b/lib/netsuite/records/invoice.rb index 997ed302f..a8984025b 100644 --- a/lib/netsuite/records/invoice.rb +++ b/lib/netsuite/records/invoice.rb @@ -9,7 +9,7 @@ class Invoice # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2014_1/schema/record/invoice.html?mode=package - actions :get, :get_deleted, :get_list, :initialize, :add, :update, :delete, :upsert, :upsert_list, :search + actions :attach_file, :get, :get_deleted, :get_list, :initialize, :add, :update, :delete, :upsert, :upsert_list, :search fields :balance, :billing_schedule, :contrib_pct, :created_date, :currency_name, @@ -25,7 +25,7 @@ class Invoice :other_ref_num, :partners_list, :rev_rec_end_date, :rev_rec_on_rev_commitment, :rev_rec_schedule, :rev_rec_start_date, :revenue_status, :sales_effective_date, :sales_group, :sales_team_list, :ship_date, :ship_group_list, - :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :shipping_tax_code, :source, :start_date, + :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :source, :start_date, :status, :sync_partner_teams, :sync_sales_teams, :tax_2_total, :tax_total, :time_disc_amount, :time_disc_print, :time_disc_rate, :time_disc_tax_1_amt, :time_disc_taxable, :time_discount, :time_list, :time_tax_code, :time_tax_rate_1, :time_tax_rate_2, :to_be_emailed, :to_be_faxed, @@ -38,6 +38,7 @@ class Invoice field :custom_field_list, CustomFieldList field :shipping_address, Address field :billing_address, Address + field :null_field_list, NullFieldList read_only_fields :sub_total, :discount_total, :total, :recognized_revenue, :amount_remaining, :amount_paid, :alt_shipping_cost, :gift_cert_applied, :handling_cost, :alt_handling_cost @@ -137,11 +138,11 @@ class Invoice record_refs :account, :bill_address_list, :custom_form, :department, :entity, :klass, :partner, :posting_period, :ship_address_list, :terms, :location, :sales_rep, :tax_item, :created_from, - :ship_method, :lead_source, :promo_code, :subsidiary, :currency, :approval_status, :job, :discount_item + :ship_method, :lead_source, :promo_code, :subsidiary, :currency, :approval_status, :job, :discount_item, + :shipping_tax_code 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) diff --git a/lib/netsuite/records/item_availability.rb b/lib/netsuite/records/item_availability.rb new file mode 100644 index 000000000..ea9cb542f --- /dev/null +++ b/lib/netsuite/records/item_availability.rb @@ -0,0 +1,46 @@ +module NetSuite + module Records + class ItemAvailability + include Support::Fields + include Support::RecordRefs + include Support::Records + + field :item, InventoryItem + field :location_id, Location + alias_method :location, :location_id + + field :quantity_on_hand + field :on_hand_value_mli + field :reorder_point + field :quantity_on_order + field :quantity_committed + field :quantity_available + + def self.get_item_availability(ref_list, credentials={}) + connection = NetSuite::Configuration.connection({}, credentials) + response = connection.call :get_item_availability, message: { + "platformMsgs:itemAvailabilityFilter" => { + "platformCore:item" => ref_list.to_record + } + } + return false unless response.success? + + result = response.body[:get_item_availability_response][:get_item_availability_result] + unless result[:status][:@is_success] == "true" + return false + end + if result[:item_availability_list] + result[:item_availability_list][:item_availability].map do |row| + NetSuite::Records::ItemAvailability.new(row) + end + else + [] + end + end + + def initialize(attributes = {}) + initialize_from_attributes_hash(attributes) + end + end + end +end diff --git a/lib/netsuite/records/item_fulfillment.rb b/lib/netsuite/records/item_fulfillment.rb index aa37b4546..53e9e2877 100644 --- a/lib/netsuite/records/item_fulfillment.rb +++ b/lib/netsuite/records/item_fulfillment.rb @@ -9,7 +9,7 @@ class ItemFulfillment actions :get, :get_list, :add, :initialize, :update, :delete, :search, :upsert, :upsert_list - fields :tran_date, :tran_id, :shipping_cost, :memo, :ship_company, :ship_attention, :ship_addr1, + fields :created_from_ship_group, :tran_date, :tran_id, :shipping_cost, :memo, :ship_company, :ship_attention, :ship_addr1, :ship_addr2, :ship_city, :ship_state, :ship_zip, :ship_phone, :ship_is_residential, :ship_status, :last_modified_date, :created_date, :status @@ -26,11 +26,13 @@ class ItemFulfillment field :item_list, ItemFulfillmentItemList field :package_list, ItemFulfillmentPackageList + field :package_fed_ex_list, ItemFulfillmentPackageFedExList + field :package_ups_list, ItemFulfillmentPackageUpsList + field :package_usps_list, ItemFulfillmentPackageUspsList field :custom_field_list, CustomFieldList 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) diff --git a/lib/netsuite/records/item_fulfillment_package_fed_ex.rb b/lib/netsuite/records/item_fulfillment_package_fed_ex.rb new file mode 100644 index 000000000..48e8f1446 --- /dev/null +++ b/lib/netsuite/records/item_fulfillment_package_fed_ex.rb @@ -0,0 +1,28 @@ +module NetSuite + module Records + class ItemFulfillmentPackageFedEx + include Support::Fields + include Support::Records + include Namespaces::TranSales + + fields :authorization_number_fed_ex, :cod_amount_fed_ex, :dry_ice_weight_fed_ex, :insured_value_fed_ex, :is_alcohol_fed_ex, + :is_non_haz_lithium_fed_ex, :is_non_standard_container_fed_ex, :package_height_fed_ex, :package_length_fed_ex, + :package_tracking_number_fed_ex, :package_weight_fed_ex, :package_width_fed_ex, :priority_alert_content_fed_ex, + :reference1_fed_ex, :signature_releasefed_ex, :use_cod_fed_ex, :use_insured_value_fed_ex + + + 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 + end + end +end diff --git a/lib/netsuite/records/item_fulfillment_package_fed_ex_list.rb b/lib/netsuite/records/item_fulfillment_package_fed_ex_list.rb new file mode 100644 index 000000000..070f97b13 --- /dev/null +++ b/lib/netsuite/records/item_fulfillment_package_fed_ex_list.rb @@ -0,0 +1,32 @@ +module NetSuite + module Records + class ItemFulfillmentPackageFedExList + include Support::Fields + include Support::Records + include Namespaces::TranSales + + fields :package_fed_ex + + def initialize(attributes = {}) + initialize_from_attributes_hash(attributes) + end + + def package_fed_ex=(packages) + case packages + when Hash + self.packages << ItemFulfillmentPackageFedEx.new(packages) + when Array + packages.each { |package| self.packages << ItemFulfillmentPackageFedEx.new(package) } + end + end + + def packages + @packages ||= [] + end + + def to_record + { "#{record_namespace}:packageFedEx" => packages.map(&:to_record) } + end + end + end +end diff --git a/lib/netsuite/records/item_fulfillment_package_ups.rb b/lib/netsuite/records/item_fulfillment_package_ups.rb new file mode 100644 index 000000000..235292080 --- /dev/null +++ b/lib/netsuite/records/item_fulfillment_package_ups.rb @@ -0,0 +1,27 @@ +module NetSuite + module Records + class ItemFulfillmentPackageUps + include Support::Fields + include Support::Records + include Namespaces::TranSales + + fields :additional_handling_ups, :cod_amount_ups, :cod_method_ups, :delivery_conf_ups, :insured_value_ups, :package_descr_ups, + :package_height_ups, :package_length_ups, :package_tracking_number_ups, :package_weight_ups, :package_width_ups, + :packaging_ups, :reference1_ups, :reference2_ups, :use_cod_ups + + + 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 + end + end +end diff --git a/lib/netsuite/records/item_fulfillment_package_ups_list.rb b/lib/netsuite/records/item_fulfillment_package_ups_list.rb new file mode 100644 index 000000000..22b0455d4 --- /dev/null +++ b/lib/netsuite/records/item_fulfillment_package_ups_list.rb @@ -0,0 +1,32 @@ +module NetSuite + module Records + class ItemFulfillmentPackageUpsList + include Support::Fields + include Support::Records + include Namespaces::TranSales + + fields :package_ups + + def initialize(attributes = {}) + initialize_from_attributes_hash(attributes) + end + + def package_ups=(packages) + case packages + when Hash + self.packages << ItemFulfillmentPackageUps.new(packages) + when Array + packages.each { |package| self.packages << ItemFulfillmentPackageUps.new(package) } + end + end + + def packages + @packages ||= [] + end + + def to_record + { "#{record_namespace}:packageUps" => packages.map(&:to_record) } + end + end + end +end diff --git a/lib/netsuite/records/item_fulfillment_package_usps.rb b/lib/netsuite/records/item_fulfillment_package_usps.rb new file mode 100644 index 000000000..e8df42da1 --- /dev/null +++ b/lib/netsuite/records/item_fulfillment_package_usps.rb @@ -0,0 +1,26 @@ +module NetSuite + module Records + class ItemFulfillmentPackageUsps + include Support::Fields + include Support::Records + include Namespaces::TranSales + + fields :insured_value_usps, :package_descr_usps, :package_height_usps, :package_length_usps, + :package_tracking_number_usps, :package_weight_usps, :package_width_usps, :reference1_usps, :reference2_usps, :use_insured_value_usps + + + 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 + end + end +end diff --git a/lib/netsuite/records/item_fulfillment_package_usps_list.rb b/lib/netsuite/records/item_fulfillment_package_usps_list.rb new file mode 100644 index 000000000..0daa01622 --- /dev/null +++ b/lib/netsuite/records/item_fulfillment_package_usps_list.rb @@ -0,0 +1,32 @@ +module NetSuite + module Records + class ItemFulfillmentPackageUspsList + include Support::Fields + include Support::Records + include Namespaces::TranSales + + fields :package_usps + + def initialize(attributes = {}) + initialize_from_attributes_hash(attributes) + end + + def package_usps=(packages) + case packages + when Hash + self.packages << ItemFulfillmentPackageUsps.new(packages) + when Array + packages.each { |package| self.packages << ItemFulfillmentPackageUsps.new(package) } + end + end + + def packages + @packages ||= [] + end + + def to_record + { "#{record_namespace}:packageUsps" => packages.map(&:to_record) } + end + end + end +end diff --git a/lib/netsuite/records/item_group.rb b/lib/netsuite/records/item_group.rb index 3cda03efb..64f9755e8 100644 --- a/lib/netsuite/records/item_group.rb +++ b/lib/netsuite/records/item_group.rb @@ -7,18 +7,18 @@ class ItemGroup include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :update, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert fields :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 record_refs :custom_form, :default_item_ship_method, :department, :issue_product, :item_ship_method_list, :klass, :location, :parent - + field :custom_field_list, CustomFieldList # TODO field :item_carrier, ShippingCarrier field :member_list, ItemMemberList field :subsidiary_list, RecordRefList - # TODO field :translations_list, TranslationList + field :translations_list, TranslationList attr_reader :internal_id attr_accessor :external_id diff --git a/lib/netsuite/records/item_option_custom_field.rb b/lib/netsuite/records/item_option_custom_field.rb new file mode 100644 index 000000000..97631ce95 --- /dev/null +++ b/lib/netsuite/records/item_option_custom_field.rb @@ -0,0 +1,52 @@ +module NetSuite + module Records + class ItemOptionCustomField + include Support::Fields + include Support::RecordRefs + include Support::Records + include Support::Actions + include Namespaces::SetupCustom + + actions :get, :get_list, :add, :delete, :update, :upsert, :upsert_list + + # http://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2017_1/schema/record/ItemOptionCustomField.html + fields( + :access_level, + :col_all_items, + :col_kit_item, + :col_opportunity, + :col_option_label, + :col_purchase, + :col_sale, + :col_store, + :col_store_hidden, + :col_transfer_order, + :default_checked, + :default_value, + :description, + :display_height, + :display_width, + :help, + :is_formula, + :is_mandatory, + :label, + :link_text, + :max_length, + :max_value, + :min_value, + :store_value + ) + + record_refs :owner, :source_list, :select_record_type, :source_filter_by, :source_from, :search_default, :search_compare_field, :insert_before, :default_selection + + attr_reader :internal_id + attr_accessor :external_id + + 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 diff --git a/lib/netsuite/records/item_receipt.rb b/lib/netsuite/records/item_receipt.rb index 798b2b70c..5d92c65df 100644 --- a/lib/netsuite/records/item_receipt.rb +++ b/lib/netsuite/records/item_receipt.rb @@ -26,7 +26,6 @@ class ItemReceipt 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) diff --git a/lib/netsuite/records/item_vendor.rb b/lib/netsuite/records/item_vendor.rb index 91c7d788c..d14bc1496 100644 --- a/lib/netsuite/records/item_vendor.rb +++ b/lib/netsuite/records/item_vendor.rb @@ -2,10 +2,19 @@ module NetSuite module Records class ItemVendor include Support::Fields + include Support::RecordRefs include Support::Records include Namespaces::ListAcct - fields :vendor, :purchase_price, :preferred_vendor + fields :purchase_price, + :preferred_vendor, + :vendor_code, + :vendor_currency_name + + record_refs :schedule, + :subsidiary, + :vendor, + :vendor_currency def initialize(attributes = {}) initialize_from_attributes_hash(attributes) diff --git a/lib/netsuite/records/job.rb b/lib/netsuite/records/job.rb index dcfb5e59f..f56da433d 100644 --- a/lib/netsuite/records/job.rb +++ b/lib/netsuite/records/job.rb @@ -29,7 +29,6 @@ class Job 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) diff --git a/lib/netsuite/records/kit_item.rb b/lib/netsuite/records/kit_item.rb index 34dd2c7c2..cb7be1f54 100644 --- a/lib/netsuite/records/kit_item.rb +++ b/lib/netsuite/records/kit_item.rb @@ -7,7 +7,7 @@ class KitItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :update, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert fields :available_to_partners, :cost_estimate, :created_date, :defer_rev_rec, :description, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description, :handling_cost, @@ -49,7 +49,7 @@ class KitItem # field :product_feed_list, ProductFeedList # field :site_category_list, SiteCategoryList # field :sitemap_priority, SitemapPriority - # field :translations_list, TranslationList + field :translations_list, TranslationList # field :vsoe_deferral, VsoeDeferral # field :vsoe_permit_discount, VsoePermitDiscount # field :vsoe_sop_group, VsoeSopGroup diff --git a/lib/netsuite/records/location.rb b/lib/netsuite/records/location.rb index 3212dad9d..b7b3424d5 100644 --- a/lib/netsuite/records/location.rb +++ b/lib/netsuite/records/location.rb @@ -28,7 +28,6 @@ class Location 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) diff --git a/lib/netsuite/records/lot_numbered_assembly_item.rb b/lib/netsuite/records/lot_numbered_assembly_item.rb index 67c7d07f3..f4249a822 100644 --- a/lib/netsuite/records/lot_numbered_assembly_item.rb +++ b/lib/netsuite/records/lot_numbered_assembly_item.rb @@ -7,7 +7,7 @@ class LotNumberedAssemblyItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :get_select_value, :add, :delete, :update, :upsert, :upsert_list, :search + actions :get, :get_deleted, :get_list, :get_select_value, :add, :delete, :update, :update_list, :upsert, :upsert_list, :search fields :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, :average_cost, :build_entire_assembly, :copy_description, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :cost_units, :costing_method, diff --git a/lib/netsuite/records/lot_numbered_inventory_item.rb b/lib/netsuite/records/lot_numbered_inventory_item.rb index 027f27a91..02d2ddc49 100644 --- a/lib/netsuite/records/lot_numbered_inventory_item.rb +++ b/lib/netsuite/records/lot_numbered_inventory_item.rb @@ -9,97 +9,241 @@ class LotNumberedInventoryItem # http://www.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2018_2/schema/record/lotnumberedinventoryitem.html - # TODO - # countryOfManufacture Country - # hazmatPackingGroup HazmatPackingGroup - # accountingBookDetailList ItemAccountingBookDetailList - # costEstimateType ItemCostEstimateType - # costingMethod ItemCostingMethod - # invtClassification ItemInvtClassification - # matrixType ItemMatrixType - # itemOptionsList ItemOptionsList - # outOfStockBehavior ItemOutOfStockBehavior - # overallQuantityPricingType ItemOverallQuantityPricingType - # preferenceCriterion ItemPreferenceCriterion - # itemVendorList ItemVendorList - # weightUnit ItemWeightUnit - # hierarchyVersionsList LotNumberedInventoryItemHierarchyVersionsList - # numbersList LotNumberedInventoryItemNumbersList - # periodicLotSizeType PeriodicLotSizeType - # presentationItemList PresentationItemList - # productFeedList ProductFeedList - - field :pricing_matrix, PricingMatrix - field :custom_field_list, CustomFieldList field :bin_number_list, BinNumberList - field :locations_list, LocationsList + field :custom_field_list, CustomFieldList + field :item_number_options_list, RecordRefList + field :item_ship_method_list, RecordRefList field :item_vendor_list, ItemVendorList + field :locations_list, LocationsList field :matrix_option_list, MatrixOptionList + field :pricing_matrix, PricingMatrix field :subsidiary_list, RecordRefList + # TODO: field :accounting_book_detail_list, ItemAccountingBookDetailList + # TODO: field :hierarchy_versions_list, LotNumberedInventoryItemHierarchyVersionsList + # TODO: field :item_options_list, ItemOptionsList + # TODO: field :numbers_list, LotNumberedInventoryItemNumbersList + # TODO: field :presentation_item_list, PresentationItemList + # TODO: field :product_feed_list, ProductFeedList + # TODO: field :site_category_list, SiteCategoryList + field :translations_list, TranslationList - actions :get, :get_list, :add, :delete, :search, :update, :upsert, :update_list - - record_refs :alternate_demand_source_item, :asset_account, :bill_exch_rate_variance_acct, - :billing_schedule, :bill_price_variance_acct, :bill_qty_variance_acct, - :klass, :cogs_account, :cost_category, :create_revenue_plans_on, - :custom_form, :default_item_ship_method, :deferred_revenue_account, - :demand_source, :department, :dropship_expense_account, :gain_loss_account, - :income_account, :interco_cogs_account, :interco_income_account, - :issue_product, :item_revenue_category, :location, :parent, :preferred_location, - :pricing_group, :purchase_price_variance_acct, :purchase_tax_code, :purchase_unit, - :quantity_pricing_schedule, :revenue_allocation_group, :revenue_recognition_rule, - :rev_rec_forecast_rule, :rev_rec_schedule, :sales_tax_code, :sale_unit, - :ship_package, :soft_descriptor, :stock_unit, :store_display_image, - :store_display_thumbnail, :store_item_template, :supply_lot_sizing_method, - :supply_replenishment_method, :supply_type, :tax_schedule, :units_type, :vendor - - # TODO - # itemNumberOptionsList RecordRefList - # itemShipMethodList RecordRefList - # subsidiaryList RecordRefList - # scheduleBCode ScheduleBCode - # itemCarrier ShippingCarrier - # siteCategoryList SiteCategoryList - # sitemapPriority SitemapPriority - # translationsList TranslationList - # vsoeDeferral VsoeDeferral - # vsoePermitDiscount VsoePermitDiscount - # vsoeSopGroup VsoeSopGroup + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert, :update_list - fields :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, - :copy_description, :direct_revenue_posting, :dont_show_price, :enforce_min_qty_internally, - :exclude_from_sitemap, :include_children, :is_donation_item, :is_drop_ship_item, :is_gco_compliant, - :is_hazmat_item, :is_inactive, :is_online, :is_special_order_item, :is_store_pickup_allowed, - :is_taxable, :match_bill_to_receipt, :mult_manufacture_addr, :offer_support, :on_special, - :prices_include_tax, :producer, :round_up_as_component, :seasonal_demand, :ship_individually, - :show_default_donation_amount, :track_landed_cost, :use_bins, :use_marginal_rates, :vsoe_delivered, - :created_date, :expiration_date, :last_invt_count_date, :last_modified_date, :next_invt_count_date, - :average_cost, :cost, :cost_estimate, :default_return_cost, :demand_modifier, :fixed_lot_size, - :handling_cost, :hazmat_item_units_qty, :last_purchase_price, :max_donation_amount, - :on_hand_value_mli, :preferred_stock_level, :preferred_stock_level_days, :purchase_order_amount, - :purchase_order_quantity, :purchase_order_quantity_diff, :quantity_available, - :quantity_back_ordered, :quantity_committed, :quantity_on_hand, :quantity_on_order, - :rate, :receipt_amount, :receipt_quantity, :receipt_quantity_diff, :reorder_point, - :safety_stock_level, :shipping_cost, :total_value, :transfer_price, :vsoe_price, - :weight, :backward_consumption_days, :demand_time_fence, :forward_consumption_days, - :invt_count_interval, :lead_time, :maximum_quantity, :minimum_quantity, :periodic_lot_size_days, - :reorder_multiple, :reschedule_in_days, :reschedule_out_days, :safety_stock_level_days, - :schedule_b_quantity, :shopzilla_category_id, :supply_time_fence, :costing_method_display, - :cost_units, :currency, :display_name, :featured_description, :handling_cost_units, - :hazmat_hazard_class, :hazmat_id, :hazmat_item_units, :hazmat_shipping_name, :item_id, - :manufacturer, :manufacturer_addr1, :manufacturer_city, :manufacturer_state, - :manufacturer_tariff, :manufacturer_tax_id, :manufacturer_zip, :matrix_item_name_template, - :meta_tag_html, :minimum_quantity_units, :mpn, :nex_tag_category, :no_price_message, - :out_of_stock_message, :page_title, :preferred_stock_level_units, :purchase_description, - :quantity_on_hand_units, :quantity_reorder_units, :related_items_description, - :reorder_point_units, :safety_stock_level_units, :sales_description, :schedule_b_number, - :search_keywords, :serial_numbers, :shipping_cost_units, :shopping_dot_com_category, - :specials_description, :stock_description, :store_description, :store_detailed_description, - :store_display_name, :upc_code, :url_component, :vendor_name, :weight_units + record_refs :alternate_demand_source_item, + :asset_account, + :bill_exch_rate_variance_acct, + :billing_schedule, + :bill_price_variance_acct, + :bill_qty_variance_acct, + :klass, + :cogs_account, + :consumption_unit, + :cost_category, + :create_revenue_plans_on, + :custom_form, + :default_item_ship_method, + :deferred_revenue_account, + :demand_source, + :department, + :dropship_expense_account, + :gain_loss_account, + :income_account, + :interco_cogs_account, + :interco_income_account, + :issue_product, + :item_revenue_category, + :location, + :parent, + :planning_item_category, + :preferred_location, + :pricing_group, + :purchase_price_variance_acct, + :purchase_tax_code, + :purchase_unit, + :quantity_pricing_schedule, + :revenue_allocation_group, + :revenue_recognition_rule, + :rev_rec_forecast_rule, + :rev_rec_schedule, + :sales_tax_code, + :sale_unit, + :secondary_base_unit, + :secondary_consumption_unit, + :secondary_purchase_unit, + :secondary_sale_unit, + :secondary_stock_unit, + :secondary_units_type, + :ship_package, + :soft_descriptor, + :stock_unit, + :store_display_image, + :store_display_thumbnail, + :store_item_template, + :supply_lot_sizing_method, + :supply_replenishment_method, + :supply_type, + :tax_schedule, + :units_type, + :vendor + fields :auto_lead_time, + :auto_preferred_stock_level, + :auto_reorder_point, + :available_to_partners, + :average_cost, + :backward_consumption_days, + :conversion_rate, + :copy_description, + :cost, + :cost_estimate, + :cost_estimate_type, + :costing_method, + :costing_method_display, + :cost_units, + :country_of_manufacture, + :created_date, + :currency, + :default_return_cost, + :demand_modifier, + :demand_time_fence, + :direct_revenue_posting, + :display_name, + :dont_show_price, + :enable_catch_weight, + :enforce_min_qty_internally, + :exclude_from_sitemap, + :expiration_date, + :featured_description, + :fixed_lot_size, + :forward_consumption_days, + :future_horizon, + :handling_cost, + :handling_cost_units, + :hazmat_hazard_class, + :hazmat_id, + :hazmat_item_units, + :hazmat_item_units_qty, + :hazmat_packing_group, + :hazmat_shipping_name, + :include_children, + :invt_classification, + :invt_count_interval, + :is_donation_item, + :is_drop_ship_item, + :is_gco_compliant, + :is_hazmat_item, + :is_inactive, + :is_online, + :is_special_order_item, + :is_store_pickup_allowed, + :is_taxable, + :item_carrier, + :item_id, + :last_invt_count_date, + :last_modified_date, + :last_purchase_price, + :lead_time, + :lower_warning_limit, + :manufacturer, + :manufacturer_addr1, + :manufacturer_city, + :manufacturer_state, + :manufacturer_tariff, + :manufacturer_tax_id, + :manufacturer_zip, + :match_bill_to_receipt, + :matrix_item_name_template, + :matrix_type, + :max_donation_amount, + :maximum_quantity, + :meta_tag_html, + :minimum_quantity, + :minimum_quantity_units, + :mpn, + :mult_manufacture_addr, + :nex_tag_category, + :next_invt_count_date, + :no_price_message, + :offer_support, + :on_hand_value_mli, + :on_special, + :out_of_stock_behavior, + :out_of_stock_message, + :overall_quantity_pricing_type, + :page_title, + :periodic_lot_size_days, + :periodic_lot_size_type, + :preference_criterion, + :preferred_stock_level, + :preferred_stock_level_days, + :preferred_stock_level_units, + :prices_include_tax, + :producer, + :purchase_description, + :purchase_order_amount, + :purchase_order_quantity, + :purchase_order_quantity_diff, + :quantity_available, + :quantity_back_ordered, + :quantity_committed, + :quantity_on_hand, + :quantity_on_hand_units, + :quantity_on_order, + :quantity_reorder_units, + :rate, + :receipt_amount, + :receipt_quantity, + :receipt_quantity_diff, + :related_items_description, + :reorder_multiple, + :reorder_point, + :reorder_point_units, + :reschedule_in_days, + :reschedule_out_days, + :round_up_as_component, + :safety_stock_level, + :safety_stock_level_days, + :safety_stock_level_units, + :sales_description, + :schedule_b_code, + :schedule_b_number, + :schedule_b_quantity, + :search_keywords, + :seasonal_demand, + :serial_numbers, + :ship_individually, + :shipping_cost, + :shipping_cost_units, + :shopping_dot_com_category, + :shopzilla_category_id, + :show_default_donation_amount, + :sitemap_priority, + :specials_description, + :stock_description, + :store_description, + :store_detailed_description, + :store_display_name, + :supply_time_fence, + :total_value, + :track_landed_cost, + :transfer_price, + :upc_code, + :upper_warning_limit, + :url_component, + :use_bins, + :use_marginal_rates, + :vendor_name, + :vsoe_deferral, + :vsoe_delivered, + :vsoe_permit_discount, + :vsoe_price, + :vsoe_sop_group, + :weight, + :weight_unit, + :weight_units attr_reader :internal_id - attr_accessor :external_id, :search_joins + attr_accessor :external_id def initialize(attributes = {}) @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id) diff --git a/lib/netsuite/records/matrix_option_list.rb b/lib/netsuite/records/matrix_option_list.rb index af0790205..55a29b745 100644 --- a/lib/netsuite/records/matrix_option_list.rb +++ b/lib/netsuite/records/matrix_option_list.rb @@ -1,6 +1,8 @@ module NetSuite module Records class MatrixOptionList + include Namespaces::ListAcct + # Deals with both hash and arrays of attributes[:matrix_option_list] # # Hash: @@ -50,6 +52,20 @@ def initialize(attributes = {}) def options @options ||= [] end + + def to_record + { + "#{record_namespace}:matrixOption" => options.map do |option| + { + 'platformCore:value' => { + '@internalId' => option.value_id, + '@typeId' => option.type_id, + }, + '@scriptId' => option.script_id + } + end + } + end end end end diff --git a/lib/netsuite/records/non_inventory_purchase_item.rb b/lib/netsuite/records/non_inventory_purchase_item.rb index 12d831eb0..249ccd95b 100644 --- a/lib/netsuite/records/non_inventory_purchase_item.rb +++ b/lib/netsuite/records/non_inventory_purchase_item.rb @@ -7,7 +7,7 @@ class NonInventoryPurchaseItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update_list, :upsert fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :country_of_manufacture, :created_date, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, diff --git a/lib/netsuite/records/non_inventory_resale_item.rb b/lib/netsuite/records/non_inventory_resale_item.rb index 25c084aa6..f40833824 100644 --- a/lib/netsuite/records/non_inventory_resale_item.rb +++ b/lib/netsuite/records/non_inventory_resale_item.rb @@ -7,34 +7,170 @@ class NonInventoryResaleItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :upsert, :update + actions :get, :get_deleted, :get_list, :add, :delete, :search, :upsert, :update, :update_list - fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :country_of_manufacture, - :created_date, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, - :featured_description, :handling_cost, :handling_cost_units, :include_children, :is_donation_item, :is_fulfillable, - :is_gco_compliant, :is_inactive, :is_online, :is_taxable, :item_id, :last_modified_date, :manufacturer, - :manufacturer_addr1, :manufacturer_city, :manufacturer_state, :manufacturer_tariff, :manufacturer_tax_id, - :manufacturer_zip, :matrix_option_list, :matrix_type, :max_donation_amount, :meta_tag_html, :minimum_quantity, - :minimum_quantity_units, :mpn, :mult_manufacture_addr, :nex_tag_category, :no_price_message, :offer_support, - :on_special, :out_of_stock_behavior, :out_of_stock_message, :overall_quantity_pricing_type, :page_title, - :preference_criterion, :presentation_item_list, :prices_include_tax, :producer, :product_feed_list, - :rate, :related_items_description, :sales_description, :schedule_b_code, :schedule_b_number, :schedule_b_quantity, - :search_keywords, :ship_individually, :shipping_cost, :shipping_cost_units, :shopping_dot_com_category, - :shopzilla_category_id, :show_default_donation_amount, :site_category_list, :sitemap_priority, :soft_descriptor, - :specials_description, :stock_description, :store_description, :store_detailed_description, :store_display_name, - :translations_list, :upc_code, :url_component, :use_marginal_rates, :vsoe_deferral, :vsoe_delivered, - :vsoe_permit_discount, :vsoe_price, :weight, :weight_unit, :weight_units + fields :amortization_period, + :available_to_partners, + :copy_description, + :cost, + :cost_estimate, + :cost_estimate_type, + :cost_estimate_units, + :cost_units, + :country_of_manufacture, + :created_date, + :currency, + :defer_rev_rec, + :direct_revenue_posting, + :display_name, + :dont_show_price, + :enforce_min_qty_internally, + :exclude_from_sitemap, + :featured_description, + :generate_accruals, + :handling_cost, + :handling_cost_units, + :hazmat_hazard_class, + :hazmat_id, + :hazmat_item_units, + :hazmat_item_units_qty, + :hazmat_packing_group, + :hazmat_shipping_name, + :include_children, + :is_donation_item, + :is_drop_ship_item, + :is_fulfillable, + :is_gco_compliant, + :is_hazmat_item, + :is_inactive, + :is_online, + :is_special_order_item, + :is_taxable, + :item_carrier, + :item_id, + :last_modified_date, + :manufacturer, + :manufacturer_addr1, + :manufacturer_city, + :manufacturer_state, + :manufacturer_tariff, + :manufacturer_tax_id, + :manufacturer_zip, + :matrix_item_name_template, + :matrix_type, + :max_donation_amount, + :maximum_quantity, + :meta_tag_html, + :minimum_quantity, + :minimum_quantity_units, + :mpn, + :mult_manufacture_addr, + :nex_tag_category, + :no_price_message, + :offer_support, + :on_special, + :out_of_stock_behavior, + :out_of_stock_message, + :overall_quantity_pricing_type, + :page_title, + :preference_criterion, + :prices_include_tax, + :producer, + :purchase_description, + :purchase_order_amount, + :purchase_order_quantity, + :purchase_order_quantity_diff, + :rate, + :receipt_amount, + :receipt_quantity, + :receipt_quantity_diff, + :related_items_description, + :residual, + :sales_description, + :schedule_b_code, + :schedule_b_number, + :schedule_b_quantity, + :search_keywords, + :ship_individually, + :shipping_cost, + :shipping_cost_units, + :shopping_dot_com_category, + :shopzilla_category_id, + :show_default_donation_amount, + :sitemap_priority, + :soft_descriptor, + :specials_description, + :stock_description, + :store_description, + :store_detailed_description, + :store_display_name, + :upc_code, + :url_component, + :use_marginal_rates, + :vendor_name, + :vsoe_deferral, + :vsoe_delivered, + :vsoe_permit_discount, + :vsoe_price, + :vsoe_sop_group, + :weight, + :weight_unit, + :weight_units - record_refs :billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_account, - :issue_product, :item_options_list, :klass, :location, :parent, :pricing_group, :purchase_tax_code, - :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :ship_package, :store_display_image, - :store_display_thumbnail, :store_item_template, :tax_schedule, :units_type, :expense_account + record_refs :amortization_template, + :bill_exch_rate_variance_acct, + :billing_schedule, + :bill_price_variance_acct, + :bill_qty_variance_acct, + :klass, + :consumption_unit, + :cost_category, + :create_revenue_plans_on, + :custom_form, + :default_item_ship_method, + :deferral_account, + :deferred_revenue_account, + :department, + :dropship_expense_account, + :expense_account, + :income_account, + :interco_expense_account, + :interco_income_account, + :issue_product, + :item_revenue_category, + :location, + :parent, + :pricing_group, + :purchase_tax_code, + :purchase_unit, + :quantity_pricing_schedule, + :revenue_allocation_group, + :revenue_recognition_rule, + :rev_rec_forecast_rule, + :rev_rec_schedule, + :sales_tax_code, + :sale_unit, + :ship_package, + :store_display_image, + :store_display_thumbnail, + :store_item_template, + :tax_schedule, + :units_type, + :vendor field :custom_field_list, CustomFieldList + field :item_ship_method_list, RecordRefList + field :matrix_option_list, MatrixOptionList field :pricing_matrix, PricingMatrix field :subsidiary_list, RecordRefList field :item_vendor_list, ItemVendorList - + # TODO: field :accounting_book_detail_list, ItemAccountingBookDetailList + # TODO: field :hierarchy_versions_list, NonInventoryResaleItemHierarchyVersionsList + # TODO: field :item_options_list, ItemOptionsList + # TODO: field :presentation_item_list, PresentationItemList + # TODO: field :product_feed_list, ProductFeedList + # TODO: field :site_category_list, SiteCategoryList + field :translations_list, TranslationList attr_reader :internal_id attr_accessor :external_id diff --git a/lib/netsuite/records/non_inventory_sale_item.rb b/lib/netsuite/records/non_inventory_sale_item.rb index 832e267bf..8d2a44577 100644 --- a/lib/netsuite/records/non_inventory_sale_item.rb +++ b/lib/netsuite/records/non_inventory_sale_item.rb @@ -7,37 +7,149 @@ class NonInventorySaleItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :update, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert - fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :country_of_manufacture, - :created_date, :direct_revenue_posting, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, - :featured_description, :handling_cost, :handling_cost_units, :include_children, :is_donation_item, :is_fulfillable, - :is_gco_compliant, :is_inactive, :is_online, :is_taxable, :item_id, :last_modified_date, :manufacturer, - :manufacturer_addr1, :manufacturer_city, :manufacturer_state, :manufacturer_tariff, :manufacturer_tax_id, - :manufacturer_zip, :matrix_option_list, :matrix_type, :max_donation_amount, :meta_tag_html, :minimum_quantity, - :minimum_quantity_units, :mpn, :mult_manufacture_addr, :nex_tag_category, :no_price_message, :offer_support, - :on_special, :out_of_stock_behavior, :out_of_stock_message, :overall_quantity_pricing_type, :page_title, - :preference_criterion, :presentation_item_list, :prices_include_tax, :producer, :product_feed_list, - :rate, :related_items_description, :sales_description, :schedule_b_code, :schedule_b_number, :schedule_b_quantity, - :search_keywords, :ship_individually, :shipping_cost, :shipping_cost_units, :shopping_dot_com_category, - :shopzilla_category_id, :show_default_donation_amount, :site_category_list, :sitemap_priority, :soft_descriptor, - :specials_description, :stock_description, :store_description, :store_detailed_description, :store_display_name, - :translations_list, :upc_code, :url_component, :use_marginal_rates, :vsoe_deferral, :vsoe_delivered, - :vsoe_permit_discount, :vsoe_price, :weight, :weight_unit, :weight_units + fields :available_to_partners, + :contingent_revenue_handling, + :cost_estimate, + :cost_estimate_type, + :cost_estimate_units, + :country_of_manufacture, + :created_date, + :defer_rev_rec, + :direct_revenue_posting, + :display_name, + :dont_show_price, + :enforce_min_qty_internally, + :exclude_from_sitemap, + :featured_description, + :handling_cost, + :handling_cost_units, + :hazmat_hazard_class, + :hazmat_id, + :hazmat_item_units, + :hazmat_item_units_qty, + :hazmat_packing_group, + :hazmat_shipping_name, + :include_children, + :is_donation_item, + :is_fulfillable, + :is_gco_compliant, + :is_hazmat_item, + :is_inactive, + :is_online, + :is_taxable, + :item_carrier, + :item_id, + :last_modified_date, + :manufacturer, + :manufacturer_addr1, + :manufacturer_city, + :manufacturer_state, + :manufacturer_tariff, + :manufacturer_tax_id, + :manufacturer_zip, + :matrix_item_name_template, + :matrix_type, + :max_donation_amount, + :maximum_quantity, + :meta_tag_html, + :minimum_quantity, + :minimum_quantity_units, + :mpn, + :mult_manufacture_addr, + :nex_tag_category, + :no_price_message, + :offer_support, + :on_special, + :out_of_stock_behavior, + :out_of_stock_message, + :overall_quantity_pricing_type, + :page_title, + :preference_criterion, + :prices_include_tax, + :producer, + :rate, + :related_items_description, + :sales_description, + :schedule_b_code, + :schedule_b_number, + :schedule_b_quantity, + :search_keywords, + :ship_individually, + :shipping_cost, + :shipping_cost_units, + :shopping_dot_com_category, + :shopzilla_category_id, + :show_default_donation_amount, + :sitemap_priority, + :soft_descriptor, + :specials_description, + :stock_description, + :store_description, + :store_detailed_description, + :store_display_name, + :upc_code, + :url_component, + :use_marginal_rates, + :vsoe_deferral, + :vsoe_delivered, + :vsoe_permit_discount, + :vsoe_price, + :vsoe_sop_group, + :weight, + :weight_unit, + :weight_units - record_refs :billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_account, - :issue_product, :item_options_list, :klass, :location, :parent, :pricing_group, :purchase_tax_code, - :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :ship_package, :store_display_image, - :store_display_thumbnail, :store_item_template, :tax_schedule, :units_type + record_refs :bill_exch_rate_variance_acct, + :billing_schedule, + :bill_price_variance_acct, + :bill_qty_variance_acct, + :klass, + :consumption_unit, + :cost_category, + :create_revenue_plans_on, + :custom_form, + :default_item_ship_method, + :deferred_revenue_account, + :department, + :income_account, + :issue_product, + :item_revenue_category, + :location, + :parent, + :pricing_group, + :purchase_tax_code, + :quantity_pricing_schedule, + :revenue_allocation_group, + :revenue_recognition_rule, + :rev_rec_forecast_rule, + :rev_reclass_f_x_account, + :rev_rec_schedule, + :sales_tax_code, + :sale_unit, + :ship_package, + :store_display_image, + :store_display_thumbnail, + :store_item_template, + :tax_schedule, + :units_type field :custom_field_list, CustomFieldList + field :item_ship_method_list, RecordRefList + field :matrix_option_list, MatrixOptionList field :pricing_matrix, PricingMatrix field :subsidiary_list, RecordRefList - + # TODO: field :accounting_book_detail_list, ItemAccountingBookDetailList + # TODO: field :hierarchy_versions_list, NonInventorySaleItemHierarchyVersionsList + # TODO: field :item_options_list, ItemOptionsList + # TODO: field :presentation_item_list, PresentationItemList + # TODO: field :product_feed_list, ProductFeedList + # TODO: field :site_category_list, SiteCategoryList + field :translations_list, TranslationList 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) diff --git a/lib/netsuite/records/null_field_list.rb b/lib/netsuite/records/null_field_list.rb new file mode 100644 index 000000000..3d6f8cb51 --- /dev/null +++ b/lib/netsuite/records/null_field_list.rb @@ -0,0 +1,15 @@ +module NetSuite + module Records + class NullFieldList + include Support::Fields + include Support::Records + include Namespaces::PlatformCore + + fields :name + + def initialize(attributes = {}) + initialize_from_attributes_hash(attributes) + end + end + end +end diff --git a/lib/netsuite/records/opportunity.rb b/lib/netsuite/records/opportunity.rb index 7da4f0aef..3162b81bc 100644 --- a/lib/netsuite/records/opportunity.rb +++ b/lib/netsuite/records/opportunity.rb @@ -33,7 +33,6 @@ class Opportunity 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) diff --git a/lib/netsuite/records/other_charge_sale_item.rb b/lib/netsuite/records/other_charge_sale_item.rb index 874643327..be5f4bde9 100644 --- a/lib/netsuite/records/other_charge_sale_item.rb +++ b/lib/netsuite/records/other_charge_sale_item.rb @@ -7,7 +7,7 @@ class OtherChargeSaleItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :update, :delete, :upsert, :search + actions :get, :get_deleted, :get_list, :add, :update, :update_list, :delete, :upsert, :search attr_reader :internal_id attr_accessor :external_id @@ -53,7 +53,7 @@ class OtherChargeSaleItem field :custom_field_list, CustomFieldList field :pricing_matrix, PricingMatrix - # :translations_list, + field :translations_list, TranslationList # :matrix_option_list, # :item_options_list field :subsidiary_list, RecordRefList diff --git a/lib/netsuite/records/payment_item.rb b/lib/netsuite/records/payment_item.rb index d58a0268d..254684b16 100644 --- a/lib/netsuite/records/payment_item.rb +++ b/lib/netsuite/records/payment_item.rb @@ -7,7 +7,7 @@ class PaymentItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :update, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert fields :available_to_partners, :created_date, :description, :display_name, :include_children, :is_inactive, :item_id, :last_modified_date, :undep_funds @@ -15,9 +15,9 @@ class PaymentItem field :custom_field_list, CustomFieldList field :subsidiary_list, RecordRefList - + # TODO custom records need to be implemented - # field :translations_list, TranslationList + field :translations_list, TranslationList attr_reader :internal_id attr_accessor :external_id diff --git a/lib/netsuite/records/payroll_item.rb b/lib/netsuite/records/payroll_item.rb index 0e00b148b..3f49af3cf 100644 --- a/lib/netsuite/records/payroll_item.rb +++ b/lib/netsuite/records/payroll_item.rb @@ -17,7 +17,6 @@ class PayrollItem 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) diff --git a/lib/netsuite/records/purchase_order.rb b/lib/netsuite/records/purchase_order.rb index fe5c0d12d..7a0a55aaf 100644 --- a/lib/netsuite/records/purchase_order.rb +++ b/lib/netsuite/records/purchase_order.rb @@ -31,7 +31,6 @@ class PurchaseOrder 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) diff --git a/lib/netsuite/records/record_ref.rb b/lib/netsuite/records/record_ref.rb index f83bac8cd..1ada59644 100644 --- a/lib/netsuite/records/record_ref.rb +++ b/lib/netsuite/records/record_ref.rb @@ -21,7 +21,7 @@ def initialize(attributes_or_record = {}) record = attributes_or_record @internal_id = record.internal_id if record.respond_to?(:internal_id) @external_id = record.external_id if record.respond_to?(:external_id) - @type = record.class.to_s.split('::').last.lower_camelcase + @type = NetSuite::Support::Records.netsuite_type(record) end end diff --git a/lib/netsuite/records/return_authorization.rb b/lib/netsuite/records/return_authorization.rb index dc92e0cc9..12f34eb5e 100644 --- a/lib/netsuite/records/return_authorization.rb +++ b/lib/netsuite/records/return_authorization.rb @@ -105,6 +105,7 @@ class ReturnAuthorization # :ship_address_list, field :billing_address, Address + field :shipping_address, Address field :custom_field_list, CustomFieldList field :item_list, ReturnAuthorizationItemList diff --git a/lib/netsuite/records/sales_order.rb b/lib/netsuite/records/sales_order.rb index 8b6059e47..7d63fd0f9 100644 --- a/lib/netsuite/records/sales_order.rb +++ b/lib/netsuite/records/sales_order.rb @@ -7,7 +7,7 @@ class SalesOrder include Support::Actions include Namespaces::TranSales - actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :upsert_list, :search + actions :attach_file, :get, :get_list, :add, :initialize, :delete, :update, :upsert, :upsert_list, :search fields :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :auto_apply, :balance, :bill_address, :cc_approved, :contrib_pct, :created_date, :currency_name, :deferred_revenue, :discount_rate, :email, :end_date, @@ -33,6 +33,7 @@ class SalesOrder field :gift_cert_redemption_list, GiftCertRedemptionList field :ship_group_list, SalesOrderShipGroupList field :promotions_list, PromotionsList + field :null_field_list, NullFieldList read_only_fields :applied, :discount_total, :sub_total, :tax_total, :total, :unapplied, :est_gross_profit_percent @@ -43,7 +44,6 @@ class SalesOrder 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) diff --git a/lib/netsuite/records/sales_order_item.rb b/lib/netsuite/records/sales_order_item.rb index 0b659a5ea..2a8a09c11 100644 --- a/lib/netsuite/records/sales_order_item.rb +++ b/lib/netsuite/records/sales_order_item.rb @@ -17,7 +17,8 @@ class SalesOrderItem :rev_rec_start_date, :rev_rec_term_in_months, :serial_numbers, :shipping_cost, :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, - :vsoe_delivered, :vsoe_permit_discount, :vsoe_price + :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, + :ship_group field :custom_field_list, CustomFieldList diff --git a/lib/netsuite/records/serialized_assembly_item.rb b/lib/netsuite/records/serialized_assembly_item.rb index 60c0c5866..6e99b6f77 100644 --- a/lib/netsuite/records/serialized_assembly_item.rb +++ b/lib/netsuite/records/serialized_assembly_item.rb @@ -7,7 +7,7 @@ class SerializedAssemblyItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :update, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert fields :alternate_demand_source_item, :asset_account, diff --git a/lib/netsuite/records/serialized_inventory_item.rb b/lib/netsuite/records/serialized_inventory_item.rb index 6ce9a46a8..a90cfd1e3 100644 --- a/lib/netsuite/records/serialized_inventory_item.rb +++ b/lib/netsuite/records/serialized_inventory_item.rb @@ -7,7 +7,7 @@ class SerializedInventoryItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :update, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert record_refs :soft_descriptor, :stock_unit, @@ -214,7 +214,7 @@ class SerializedInventoryItem # site_category_list SiteCategoryList # sitemap_priority SitemapPriority # subsidiary_list RecordRefList - # translations_list TranslationList + field :translations_list, TranslationList # vsoe_deferral VsoeDeferral # vsoe_permit_discount VsoePermitDiscount # vsoe_sop_group VsoeSopGroup diff --git a/lib/netsuite/records/serialized_inventory_item_location.rb b/lib/netsuite/records/serialized_inventory_item_location.rb index 1ce57e3b0..e5ff61cf0 100644 --- a/lib/netsuite/records/serialized_inventory_item_location.rb +++ b/lib/netsuite/records/serialized_inventory_item_location.rb @@ -24,7 +24,6 @@ class SerializedInventoryItemLocation 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) diff --git a/lib/netsuite/records/service_resale_item.rb b/lib/netsuite/records/service_resale_item.rb index 0eef3bc4b..fa5c761be 100644 --- a/lib/netsuite/records/service_resale_item.rb +++ b/lib/netsuite/records/service_resale_item.rb @@ -7,30 +7,134 @@ class ServiceResaleItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :update, :delete, :upsert, :search - - fields :available_to_partners, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date, - :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description, - :include_children, :is_donation_item, :is_fulfillable, :is_gco_compliant, :is_inactive, :is_online, :is_taxable, - :item_id, :last_modified_date, :matrix_option_list, :matrix_type, :max_donation_amount, :meta_tag_html, - :minimum_quantity, :minimum_quantity_units, :no_price_message, :offer_support, :on_special, :out_of_stock_behavior, - :out_of_stock_message, :overall_quantity_pricing_type, :page_title, :presentation_item_list, :prices_include_tax, - :rate, :related_items_description, :sales_description, :search_keywords, - :show_default_donation_amount, :site_category_list, :sitemap_priority, :soft_descriptor, :specials_description, - :store_description, :store_detailed_description, :store_display_name, :translations_list, :upc_code, :url_component, - :use_marginal_rates, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :vsoe_sop_group - - # item_task_templates_list - # billing_rates_matrix -- RecordRef, via listAcct::ItemOptionsList - - record_refs :billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_account, - :issue_product, :item_options_list, :klass, :location, :parent, :pricing_group, :purchase_tax_code, - :quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :store_display_image, - :store_display_thumbnail, :store_item_template, :tax_schedule, :units_type + actions :get, :get_deleted, :get_list, :add, :update, :update_list, :delete, :upsert, :search + + fields :amortization_period, + :available_to_partners, + :contingent_revenue_handling, + :cost, + :cost_estimate, + :cost_estimate_type, + :cost_estimate_units, + :cost_units, + :created_date, + :create_job, + :currency, + :defer_rev_rec, + :direct_revenue_posting, + :display_name, + :dont_show_price, + :enforce_min_qty_internally, + :exclude_from_sitemap, + :featured_description, + :generate_accruals, + :include_children, + :is_donation_item, + :is_fulfillable, + :is_gco_compliant, + :is_inactive, + :is_online, + :is_taxable, + :item_id, + :last_modified_date, + :manufacturing_charge_item, + :matrix_item_name_template, + :matrix_type, + :max_donation_amount, + :maximum_quantity, + :meta_tag_html, + :minimum_quantity, + :minimum_quantity_units, + :no_price_message, + :offer_support, + :on_special, + :out_of_stock_behavior, + :out_of_stock_message, + :overall_quantity_pricing_type, + :page_title, + :prices_include_tax, + :purchase_description, + :purchase_order_amount, + :purchase_order_quantity, + :purchase_order_quantity_diff, + :rate, + :receipt_amount, + :receipt_quantity, + :receipt_quantity_diff, + :related_items_description, + :residual, + :sales_description, + :search_keywords, + :show_default_donation_amount, + :sitemap_priority, + :soft_descriptor, + :specials_description, + :store_description, + :store_detailed_description, + :store_display_name, + :upc_code, + :url_component, + :use_marginal_rates, + :vendor_name, + :vsoe_deferral, + :vsoe_delivered, + :vsoe_permit_discount, + :vsoe_price, + :vsoe_sop_group + + record_refs :amortization_template, + :bill_exch_rate_variance_acct, + :billing_schedule, + :bill_price_variance_acct, + :bill_qty_variance_acct, + :klass, + :consumption_unit, + :cost_category, + :create_revenue_plans_on, + :custom_form, + :deferral_account, + :deferred_revenue_account, + :department, + :expense_account, + :income_account, + :interco_def_rev_account, + :interco_expense_account, + :interco_income_account, + :issue_product, + :item_revenue_category, + :location, + :parent, + :pricing_group, + :purchase_tax_code, + :purchase_unit, + :quantity_pricing_schedule, + :revenue_allocation_group, + :revenue_recognition_rule, + :rev_rec_forecast_rule, + :rev_reclass_f_x_account, + :rev_rec_schedule, + :sales_tax_code, + :sale_unit, + :store_display_image, + :store_display_thumbnail, + :store_item_template, + :tax_schedule, + :units_type, + :vendor - field :pricing_matrix, PricingMatrix field :custom_field_list, CustomFieldList + field :item_vendor_list, ItemVendorList + field :matrix_option_list, MatrixOptionList + field :pricing_matrix, PricingMatrix field :subsidiary_list, RecordRefList + # TODO: field :accounting_book_detail_list, ItemAccountingBookDetailList + # TODO: field :billing_rates_matrix, BillingRatesMatrix + # TODO: field :item_options_list, ItemOptionsList + # TODO: field :item_task_templates_list, ServiceItemTaskTemplatesList + # TODO: field :hierarchy_versions_list, ServiceResaleItemHierarchyVersionsList + # TODO: field :presentation_item_list, PresentationItemList + # TODO: field :site_category_list, SiteCategoryList + field :translations_list, TranslationList attr_reader :internal_id attr_accessor :external_id diff --git a/lib/netsuite/records/service_sale_item.rb b/lib/netsuite/records/service_sale_item.rb index 5a1b361f4..7631660c1 100644 --- a/lib/netsuite/records/service_sale_item.rb +++ b/lib/netsuite/records/service_sale_item.rb @@ -7,7 +7,7 @@ class ServiceSaleItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :update, :delete, :upsert, :search + actions :get, :get_deleted, :get_list, :add, :update, :update_list, :delete, :upsert, :search fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description, @@ -34,7 +34,6 @@ class ServiceSaleItem 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) diff --git a/lib/netsuite/records/subscription.rb b/lib/netsuite/records/subscription.rb new file mode 100644 index 000000000..849c60b79 --- /dev/null +++ b/lib/netsuite/records/subscription.rb @@ -0,0 +1,18 @@ +module NetSuite + module Records + class Subscription + include Support::Fields + include Support::Records + include Support::RecordRefs + include Namespaces::ListRel + + fields :subscribed, :last_modified_date + record_refs :subscription + + def initialize(attributes_or_record = {}) + initialize_from_attributes_hash(attributes_or_record) + end + + end + end +end diff --git a/lib/netsuite/records/subscriptions_list.rb b/lib/netsuite/records/subscriptions_list.rb new file mode 100644 index 000000000..7d25d4426 --- /dev/null +++ b/lib/netsuite/records/subscriptions_list.rb @@ -0,0 +1,10 @@ +module NetSuite + module Records + class SubscriptionsList < Support::Sublist + include Namespaces::ListRel + + sublist :subscriptions, Subscription + + end + end +end diff --git a/lib/netsuite/records/subsidiary.rb b/lib/netsuite/records/subsidiary.rb index b35c4a407..b85b47ba4 100644 --- a/lib/netsuite/records/subsidiary.rb +++ b/lib/netsuite/records/subsidiary.rb @@ -27,7 +27,6 @@ class Subsidiary 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) diff --git a/lib/netsuite/records/subtotal_item.rb b/lib/netsuite/records/subtotal_item.rb index 85cb546a2..f36a7f312 100644 --- a/lib/netsuite/records/subtotal_item.rb +++ b/lib/netsuite/records/subtotal_item.rb @@ -7,15 +7,15 @@ class DescriptionItem include Support::Actions include Namespaces::ListAcct - actions :get, :get_list, :add, :delete, :search, :update, :upsert + actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert fields :available_to_partners, :created_date, :description, :include_children, :is_inactive, :item_id, :last_modified_date record_refs :custom_form, :department, :issue_product, :klass, :location - + field :custom_field_list, CustomFieldList field :subsidiary_list, RecordRefList - # TODO field :translations_list, TranslationList + field :translations_list, TranslationList attr_reader :internal_id attr_accessor :external_id @@ -32,4 +32,3 @@ def self.search_class_name end end end - \ No newline at end of file diff --git a/lib/netsuite/records/transfer_order.rb b/lib/netsuite/records/transfer_order.rb index db43ce630..35aae2a94 100644 --- a/lib/netsuite/records/transfer_order.rb +++ b/lib/netsuite/records/transfer_order.rb @@ -24,7 +24,6 @@ class TransferOrder 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) diff --git a/lib/netsuite/records/translation.rb b/lib/netsuite/records/translation.rb new file mode 100644 index 000000000..ad43bf0b6 --- /dev/null +++ b/lib/netsuite/records/translation.rb @@ -0,0 +1,17 @@ +module NetSuite + module Records + class Translation + include Support::Fields + include Support::Records + include Namespaces::ListAcct + + fields :description, :display_name, :featured_description, :language, :locale, :locale_description, :name, + :no_price_message, :out_of_stock_message, :page_title, :replace_all, :sales_description, + :specials_description, :store_description, :store_detailed_description, :store_display_name + + def initialize(attributes = {}) + initialize_from_attributes_hash(attributes) + end + end + end +end diff --git a/lib/netsuite/records/translation_list.rb b/lib/netsuite/records/translation_list.rb new file mode 100644 index 000000000..699304cbf --- /dev/null +++ b/lib/netsuite/records/translation_list.rb @@ -0,0 +1,11 @@ +module NetSuite + module Records + class TranslationList < Support::Sublist + include NetSuite::Namespaces::ListAcct + + sublist :translation, NetSuite::Records::Translation + + alias translations translation + end + end +end diff --git a/lib/netsuite/records/vendor.rb b/lib/netsuite/records/vendor.rb index caff2fbf7..93277fc6b 100644 --- a/lib/netsuite/records/vendor.rb +++ b/lib/netsuite/records/vendor.rb @@ -35,7 +35,6 @@ class Vendor 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) diff --git a/lib/netsuite/records/vendor_bill.rb b/lib/netsuite/records/vendor_bill.rb index cebd7de7e..131f42d3f 100644 --- a/lib/netsuite/records/vendor_bill.rb +++ b/lib/netsuite/records/vendor_bill.rb @@ -25,7 +25,6 @@ class VendorBill 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) diff --git a/lib/netsuite/records/vendor_return_authorization.rb b/lib/netsuite/records/vendor_return_authorization.rb index a7035de20..991a0c9a7 100644 --- a/lib/netsuite/records/vendor_return_authorization.rb +++ b/lib/netsuite/records/vendor_return_authorization.rb @@ -9,7 +9,7 @@ class VendorReturnAuthorization actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search - fields :billing_address, :created_date, :memo, :tran_date, :tran_id + fields :billing_address, :created_date, :memo, :tran_date, :tran_id, :klass record_refs :bill_address_list, :department, :entity, :location diff --git a/lib/netsuite/records/vendor_return_authorization_item.rb b/lib/netsuite/records/vendor_return_authorization_item.rb index c0a51faa0..611aa0e2f 100644 --- a/lib/netsuite/records/vendor_return_authorization_item.rb +++ b/lib/netsuite/records/vendor_return_authorization_item.rb @@ -8,7 +8,7 @@ class VendorReturnAuthorizationItem fields :amortization_end_date, :amortization_residual, :amount, :bin_numbers, :description, :gross_amt, :is_billable, :is_closed, :is_drop_shipment, :line, :order_line, :quantity, - :rate, :vendor_name + :rate, :vendor_name, :klass field :inventory_detail, InventoryDetail diff --git a/lib/netsuite/records/work_order.rb b/lib/netsuite/records/work_order.rb index 7807047e7..8f62250f0 100644 --- a/lib/netsuite/records/work_order.rb +++ b/lib/netsuite/records/work_order.rb @@ -26,7 +26,6 @@ class WorkOrder 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) diff --git a/lib/netsuite/records/work_order_item.rb b/lib/netsuite/records/work_order_item.rb index 0a8e5c7be..9da922a52 100644 --- a/lib/netsuite/records/work_order_item.rb +++ b/lib/netsuite/records/work_order_item.rb @@ -19,7 +19,6 @@ class WorkOrderItem 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) diff --git a/lib/netsuite/support/actions.rb b/lib/netsuite/support/actions.rb index 19d62c552..a7b9b3fc2 100644 --- a/lib/netsuite/support/actions.rb +++ b/lib/netsuite/support/actions.rb @@ -18,6 +18,8 @@ def actions(*args) def action(name) case name + when :attach_file + self.send(:include, NetSuite::Actions::AttachFile::Support) when :get self.send(:include, NetSuite::Actions::Get::Support) when :get_all diff --git a/lib/netsuite/support/country.rb b/lib/netsuite/support/country.rb index eac66da08..ab576353c 100644 --- a/lib/netsuite/support/country.rb +++ b/lib/netsuite/support/country.rb @@ -240,6 +240,7 @@ class Country 'UA' => '_ukraine', 'AE' => '_unitedArabEmirates', 'GB' => '_unitedKingdom', + 'UK' => '_unitedKingdom', 'US' => '_unitedStates', 'UY' => '_uruguay', 'UM' => '_uSMinorOutlyingIslands', @@ -280,12 +281,7 @@ def to_record end def iso_to_netsuite - # NOTE GB country code changed on 2016_1 - if NetSuite::Configuration.api_version <= "2015_2" - ISO_TO_NETSUITE.merge({ 'GB' => '_unitedKingdomGB' }) - else - ISO_TO_NETSUITE - end + ISO_TO_NETSUITE end end diff --git a/lib/netsuite/support/fields.rb b/lib/netsuite/support/fields.rb index 56adb55dc..af478e541 100644 --- a/lib/netsuite/support/fields.rb +++ b/lib/netsuite/support/fields.rb @@ -22,6 +22,8 @@ def fields(*args) def field(name, klass = nil) name_sym = name.to_sym raise "#{name} already defined on #{self.name}" if fields.include?(name_sym) + raise "#{name} conflicts with a method defined on #{self.name}" if method_defined?(name_sym) + fields << name_sym if klass define_method(name_sym) do diff --git a/lib/netsuite/support/records.rb b/lib/netsuite/support/records.rb index 447755f55..43065247f 100644 --- a/lib/netsuite/support/records.rb +++ b/lib/netsuite/support/records.rb @@ -6,8 +6,8 @@ module Records def to_record attributes.reject { |k,v| self.class.read_only_fields.include?(k) || self.class.search_only_fields.include?(k) }.inject({}) do |hash, (k,v)| - kname = "#{record_namespace}:" - kname += k == :klass ? 'class' : k.to_s.lower_camelcase + kname = "#{v.is_a?(NetSuite::Records::NullFieldList) ? v.record_namespace : record_namespace}:" + kname += k == :klass ? 'class' : NetSuite::Utilities::Strings.lower_camelcase(k.to_s) to_attributes!(hash, kname, v) @@ -38,18 +38,26 @@ def to_attributes!(hash, kname, v) if v.kind_of?(NetSuite::Records::RecordRef) && v.type hash[:attributes!] ||= {} hash[:attributes!][kname] ||= {} - hash[:attributes!][kname]['type'] = v.type.lower_camelcase + hash[:attributes!][kname]['type'] = NetSuite::Utilities::Strings.lower_camelcase(v.type) end if v.kind_of?(NetSuite::Records::CustomRecordRef) && v.type_id hash[:attributes!] ||= {} hash[:attributes!][kname] ||= {} - hash[:attributes!][kname]['typeId'] = v.type_id.lower_camelcase + hash[:attributes!][kname]['typeId'] = NetSuite::Utilities::Strings.lower_camelcase(v.type_id) end end def record_type - "#{record_namespace}:#{self.class.to_s.split('::').last}" + "#{record_namespace}:#{record_type_without_namespace}" + end + + def netsuite_type + Records.netsuite_type(self) + end + + def record_type_without_namespace + Records.record_type_without_namespace(self) end def refresh(credentials = {}) @@ -67,6 +75,15 @@ def refresh(credentials = {}) self end + def self.netsuite_type(obj) + NetSuite::Utilities::Strings.lower_camelcase(record_type_without_namespace(obj)) + end + + def self.record_type_without_namespace(obj) + klass = obj.is_a?(Class) ? obj : obj.class + "#{klass.to_s.split('::').last}" + end + end end end diff --git a/lib/netsuite/support/requests.rb b/lib/netsuite/support/requests.rb index c107cec4a..8df32aa8a 100644 --- a/lib/netsuite/support/requests.rb +++ b/lib/netsuite/support/requests.rb @@ -22,10 +22,6 @@ def call(credentials={}) private - def request - raise NotImplementedError, 'Please implement a #request method' - end - def build_response Response.new(success: success?, header: response_header, body: response_body, errors: response_errors) end diff --git a/lib/netsuite/support/search_result.rb b/lib/netsuite/support/search_result.rb index 2cd936c5f..2b7bd6549 100644 --- a/lib/netsuite/support/search_result.rb +++ b/lib/netsuite/support/search_result.rb @@ -48,7 +48,8 @@ def initialize(response, result_class, credentials) end elsif response.body.has_key? :search_row_list # advanced search results - record_list = response.body[:search_row_list][:search_row] + record_list = response.body[:search_row_list] + record_list = record_list ? record_list[:search_row] : [] record_list = [record_list] unless record_list.is_a?(Array) record_list.each do |record| diff --git a/lib/netsuite/support/sublist.rb b/lib/netsuite/support/sublist.rb index 4266f09d1..b8d6a1fa1 100644 --- a/lib/netsuite/support/sublist.rb +++ b/lib/netsuite/support/sublist.rb @@ -31,11 +31,11 @@ def sublist(key, klass) end def initialize(attributes = {}) - initialize_from_attributes_hash(attributes) + initialize_from_attributes_hash(attributes || {}) end def to_record - rec = { "#{record_namespace}:#{sublist_key.to_s.lower_camelcase}" => send(self.sublist_key).map(&:to_record) } + rec = { "#{record_namespace}:#{NetSuite::Utilities::Strings.lower_camelcase(sublist_key.to_s)}" => send(self.sublist_key).map(&:to_record) } if !replace_all.nil? rec["#{record_namespace}:replaceAll"] = !!replace_all diff --git a/lib/netsuite/utilities.rb b/lib/netsuite/utilities.rb index c8a1ca9de..dd1a9a904 100644 --- a/lib/netsuite/utilities.rb +++ b/lib/netsuite/utilities.rb @@ -7,11 +7,33 @@ module Utilities # TODO need structured logger for various statements def clear_cache! - @netsuite_get_record_cache = {} - @netsuite_find_record_cache = {} + if NetSuite::Configuration.multi_tenant? + Thread.current[:netsuite_gem_netsuite_get_record_cache] = {} + Thread.current[:netsuite_gem_netsuite_find_record_cache] = {} + else + @netsuite_get_record_cache = {} + @netsuite_find_record_cache = {} + end + DataCenter.clear_cache! end + def netsuite_get_record_cache + if NetSuite::Configuration.multi_tenant? + Thread.current[:netsuite_gem_netsuite_get_record_cache] ||= {} + else + @netsuite_get_record_cache ||= {} + end + end + + def netsuite_find_record_cache + if NetSuite::Configuration.multi_tenant? + Thread.current[:netsuite_gem_netsuite_find_record_cache] ||= {} + else + @netsuite_find_record_cache ||= {} + end + end + def append_memo(ns_record, added_memo, opts = {}) opts[:skip_if_exists] ||= false @@ -34,12 +56,12 @@ def append_memo(ns_record, added_memo, opts = {}) ns_record end - def netsuite_server_time - server_time_response = NetSuite::Utilities.backoff { NetSuite::Configuration.connection.call(:get_server_time) } + def netsuite_server_time(credentials={}) + server_time_response = NetSuite::Utilities.backoff { NetSuite::Configuration.connection({}, credentials).call(:get_server_time) } server_time_response.body[:get_server_time_response][:get_server_time_result][:server_time] end - def netsuite_data_center_urls(account_id) + def netsuite_data_center_urls(account_id, credentials={}) data_center_call_response = NetSuite::Configuration.connection({ # NOTE force a production WSDL so the sandbox settings are ignored # as of 1/20/18 NS will start using the account ID to determine @@ -53,7 +75,7 @@ def netsuite_data_center_urls(account_id) }, soap_header: {} - }).call(:get_data_center_urls, message: { + }, credentials).call(:get_data_center_urls, message: { 'platformMsgs:account' => account_id }) @@ -103,6 +125,12 @@ def backoff(options = {}) exceptions_to_retry << OpenSSL::SSL::SSLErrorWaitReadable if defined?(OpenSSL::SSL::SSLErrorWaitReadable) # depends on the http library chosen + exceptions_to_retry << HTTPI::SSLError if defined?(HTTPI::SSLError) + exceptions_to_retry << HTTPI::TimeoutError if defined?(HTTPI::TimeoutError) + exceptions_to_retry << HTTPClient::TimeoutError if defined?(HTTPClient::TimeoutError) + exceptions_to_retry << HTTPClient::ConnectTimeoutError if defined?(HTTPClient::ConnectTimeoutError) + exceptions_to_retry << HTTPClient::ReceiveTimeoutError if defined?(HTTPClient::ReceiveTimeoutError) + exceptions_to_retry << HTTPClient::SendTimeoutError if defined?(HTTPClient::SendTimeoutError) exceptions_to_retry << Excon::Error::Timeout if defined?(Excon::Error::Timeout) exceptions_to_retry << Excon::Error::Socket if defined?(Excon::Error::Socket) @@ -170,8 +198,10 @@ def get_item(ns_item_internal_id, opts = {}) ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::DiscountItem, ns_item_internal_id, opts) ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::OtherChargeSaleItem, ns_item_internal_id, opts) ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ServiceSaleItem, ns_item_internal_id, opts) + ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ServiceResaleItem, ns_item_internal_id, opts) ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::GiftCertificateItem, ns_item_internal_id, opts) ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::KitItem, ns_item_internal_id, opts) + ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ItemGroup, ns_item_internal_id, opts) ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedInventoryItem, ns_item_internal_id, opts) ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedAssemblyItem, ns_item_internal_id, opts) ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::LotNumberedAssemblyItem, ns_item_internal_id, opts) @@ -188,11 +218,10 @@ def get_record(record_klass, id, opts = {}) opts[:external_id] ||= false if opts[:cache] - @netsuite_get_record_cache ||= {} - @netsuite_get_record_cache[record_klass.to_s] ||= {} + netsuite_get_record_cache[record_klass.to_s] ||= {} - if @netsuite_get_record_cache[record_klass.to_s].has_key?(id.to_i) - return @netsuite_get_record_cache[record_klass.to_s][id.to_i] + if netsuite_get_record_cache[record_klass.to_s].has_key?(id.to_i) + return netsuite_get_record_cache[record_klass.to_s][id.to_i] end end @@ -206,14 +235,14 @@ def get_record(record_klass, id, opts = {}) end if opts[:cache] - @netsuite_get_record_cache[record_klass.to_s][id.to_i] = ns_record + netsuite_get_record_cache[record_klass.to_s][id.to_i] = ns_record end return ns_record rescue ::NetSuite::RecordNotFound # log.warn("record not found", ns_record_type: record_klass.name, ns_record_id: id) if opts[:cache] - @netsuite_get_record_cache[record_klass.to_s][id.to_i] = nil + netsuite_get_record_cache[record_klass.to_s][id.to_i] = nil end return nil @@ -228,10 +257,8 @@ def find_record(record, names, opts = {}) # FIXME: Records that have the same name but different types will break # the cache names.each do |name| - @netsuite_find_record_cache ||= {} - - if @netsuite_find_record_cache.has_key?(name) - return @netsuite_find_record_cache[name] + if netsuite_find_record_cache.has_key?(name) + return netsuite_find_record_cache[name] end # sniff for an email-like input; useful for employee/customer searches @@ -257,7 +284,7 @@ def find_record(record, names, opts = {}) }) } if search.results.first - return @netsuite_find_record_cache[name] = search.results.first + return netsuite_find_record_cache[name] = search.results.first end end diff --git a/lib/netsuite/utilities/strings.rb b/lib/netsuite/utilities/strings.rb new file mode 100644 index 000000000..2aaeeeb46 --- /dev/null +++ b/lib/netsuite/utilities/strings.rb @@ -0,0 +1,15 @@ +module NetSuite + module Utilities + module Strings + class << self + def lower_camelcase(obj) + str = obj.is_a?(String) ? obj.dup : obj.to_s + str.gsub!(/\/(.?)/) { "::#{$1.upcase}" } + str.gsub!(/(?:_+|-+)([a-z]|[0-9])/) { $1.upcase } + str.gsub!(/(\A|\s)([A-Z])/) { $1 + $2.downcase } + str + end + end + end + end +end \ No newline at end of file diff --git a/lib/netsuite/version.rb b/lib/netsuite/version.rb index 98c3aebd2..24d6d8450 100644 --- a/lib/netsuite/version.rb +++ b/lib/netsuite/version.rb @@ -1,3 +1,3 @@ module NetSuite - VERSION = '0.8.10' + VERSION = '0.9.3' end