From 14574ad71731d3f13bacdbc1739b0252514e1731 Mon Sep 17 00:00:00 2001 From: Chris Gunther Date: Thu, 29 Sep 2022 13:45:15 -0400 Subject: [PATCH] Add search only fields to `CreditMemo` Both `Invoice` and `CreditMemo` records (as well as many other records) use the same search fields for the returned basic results, `TransactionSearchRowBasic`, so rather than repeat the fields for each record, extract them to a common module that can be shared between the respective records. Since the search module may cover multiple records, it's fields will overlap with some of the standard fields on each record, so defining search only fields is now a no-op if the search only field already exists on the record as a standard field. For this reason, it's necessary to include the search module after defining all the standard fields, otherwise we'll error if we try to define a standard field if it's already been defined as a search only field. At this point, I only have use for searching invoices and credit memos, so the module is only included on those records, but it's the same search fields that could eventually be included on `AssemblyBuild`, `BinTransfer`, `CashSale`, etc. records, all of which generally seem to fall under "transaction". --- HISTORY.md | 1 + lib/netsuite.rb | 4 + lib/netsuite/records/credit_memo.rb | 2 + lib/netsuite/records/invoice.rb | 95 +----- .../searches/transaction_search_row_basic.rb | 308 +++++++++++++++++ lib/netsuite/support/fields.rb | 3 + spec/netsuite/records/credit_memo_spec.rb | 4 + spec/netsuite/records/invoice_spec.rb | 93 +----- .../transaction_search_row_basic_spec.rb | 314 ++++++++++++++++++ spec/netsuite/support/fields_spec.rb | 10 + 10 files changed, 650 insertions(+), 184 deletions(-) create mode 100644 lib/netsuite/searches/transaction_search_row_basic.rb create mode 100644 spec/netsuite/searches/transaction_search_row_basic_spec.rb diff --git a/HISTORY.md b/HISTORY.md index c98b9118..790d04fd 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,7 @@ ### Added * Add `Configuration#multi_tenant!` for opting into multi-tentant support where configuration/caching is per-thread (#556) +* Add search-only fields to `CreditMemo` (#) ### Fixed * Avoid Savon version `2.13.0` to prevent generating invalid envelopes. (#558, #563) diff --git a/lib/netsuite.rb b/lib/netsuite.rb index baff263f..faa831aa 100644 --- a/lib/netsuite.rb +++ b/lib/netsuite.rb @@ -66,6 +66,10 @@ module Actions autoload :Login, 'netsuite/actions/login' end + module Searches + autoload :TransactionSearchRowBasic, 'netsuite/searches/transaction_search_row_basic' + end + module Records autoload :AssemblyItem, 'netsuite/records/assembly_item' autoload :AssemblyBuild, 'netsuite/records/assembly_build' diff --git a/lib/netsuite/records/credit_memo.rb b/lib/netsuite/records/credit_memo.rb index 887bcac1..93f89248 100644 --- a/lib/netsuite/records/credit_memo.rb +++ b/lib/netsuite/records/credit_memo.rb @@ -37,6 +37,8 @@ class CreditMemo :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, :partner, :posting_period, :promo_code, :sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :tax_item, :currency + include Searches::TransactionSearchRowBasic + attr_reader :internal_id attr_accessor :external_id diff --git a/lib/netsuite/records/invoice.rb b/lib/netsuite/records/invoice.rb index eb2aeec4..079a3f10 100644 --- a/lib/netsuite/records/invoice.rb +++ b/lib/netsuite/records/invoice.rb @@ -43,103 +43,12 @@ class Invoice 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 - # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_2/schema/search/transactionsearchrowbasic.html?mode=package - search_only_fields :abbrev, :account_type, :acct_corp_card_exp, - :actual_production_end_date, :actual_production_start_date, - :actual_ship_date, :alt_sales_amount, :alt_sales_net_amount, :amount, - :amount_unbilled, :applied_to_foreign_amount, - :applied_to_is_fx_variance, :applied_to_link_amount, - :applied_to_link_type, :applied_to_transaction, - :applying_foreign_amount, :applying_is_fx_variance, - :applying_link_amount, :applying_link_type, :applying_transaction, - :auth_code, :auto_calculate_lag, :avs_street_match, :avs_zip_match, - :billable, :bill_address, :bill_address1, :bill_address2, - :bill_address3, :bill_addressee, :bill_attention, :bill_city, - :bill_country, :bill_country_code, :billed_date, :billing_amount, - :billing_transaction, :bill_phone, :bill_state, :bill_variance_status, - :bill_zip, :bin_number, :bin_number_quantity, :bom_quantity, - :build_entire_assembly, :build_variance, :built, - :can_have_stackable_promotions, :catch_up_period, :cc_customer_code, - :cc_exp_date, :cc_holder_name, :cc_number, :cc_street, :cc_zip_code, - :cleared, :closed, :close_date, :cogs_amount, - :commission_effective_date, :commit, :component_yield, - :confirmation_number, :contribution, :contribution_primary, - :cost_component_amount, :cost_component_category, :cost_component_item, - :cost_component_quantity, :cost_component_standard_cost, :cost_estimate, - :cost_estimate_rate, :cost_estimate_type, :created_by, :credit_amount, - :csc_match, :custom_gl, :cust_type, :date_created, :days_open, - :days_overdue, :debit_amount, :defer_rev_rec, :deposit_date, - :deposit_transaction, :doc_unit, :dr_account, :effective_rate, - :entity_status, :est_gross_profit_pct, :exclude_from_rate_request, - :expected_close_date, :expected_receipt_date, :expense_category, - :expense_date, :firmed, :forecast_type, :fulfilling_transaction, - :fx_account, :fx_amount, :fx_cost_estimate, :fx_cost_estimate_rate, - :fx_est_gross_profit, :fx_tran_cost_estimate, :fx_vsoe_allocation, - :fx_vsoe_amount, :fx_vsoe_price, :gco_availabel_to_charge, - :gco_available_to_refund, :gco_avs_street_match, :gco_avs_zip_match, - :gco_buyer_account_age, :gco_buyer_ip, :gco_charge_amount, - :gco_chargeback_amount, :gco_confirmed_charged_total, - :gco_confirmed_refunded_total, :gco_creditcard_number, :gco_csc_match, - :gco_financial_state, :gco_fulfillment_state, :gco_order_id, - :gco_order_total, :gco_promotion_amount, :gco_promotion_name, - :gco_refund_amount, :gco_shipping_total, :gco_state_changed_detail, - :gift_cert, :gross_amount, :include_in_forecast, :incoterm, - :interco_status, :interco_transaction, :inventory_location, - :inventory_subsidiary, :in_vsoe_bundle, :is_allocation, :is_backflush, - :is_gco_chargeback, :is_gco_charge_confirmed, - :is_gco_payment_guaranteed, :is_gco_refund_confirmed, - :is_inside_delivery, :is_inside_pickup, :is_intercompany_adjustment, - :is_in_transit_payment, :is_multi_ship_to, :is_reversal, - :is_rev_rec_transaction, :is_scrap, :is_ship_address, - :is_transfer_price_costing, :is_wip, :item, :item_fulfillment_choice, - :item_revision, :landed_cost_per_line, :line, :line_sequence_number, - :line_unique_key, :location_auto_assigned, :main_line, :main_name, - :manufacturing_routing, :match_bill_to_receipt, :memo_main, :memorized, - :merchant_account, :multi_subsidiary, :net_amount, :net_amount_no_tax, - :next_bill_date, :no_auto_assign_location, :non_reimbursable, - :one_time_total, :options, :order_allocation_strategy, :order_priority, - :originator, :overhead_parent_item, - :override_installments, :package_count, :paid_amount, :paid_transaction, - :partner_contribution, :partner_role, :partner_team_member, - :paying_amount, :paying_transaction, :payment_approved, - :payment_event_date, :payment_event_hold_reason, - :payment_event_purchase_card_used, :payment_event_purchase_data_sent, - :payment_event_result, :payment_event_type, :payment_hold, - :payment_method, :payment_option, :pay_pal_pending, :pay_pal_status, - :pay_pal_tran_id, :payroll_batch, :pn_ref_num, :po_rate, :posting, - :price_level, :print, :probability, :projected_amount, :project_task, - :purchase_order, :quantity, :quantity_billed, :quantity_committed, - :quantity_packed, :quantity_picked, :quantity_rev_committed, - :quantity_ship_recv, :quantity_uom, :rate, - :realized_gain_posting_transaction, :recur_annually_total, - :recur_monthly_total, :recur_quarterly_total, :recur_weekly_total, - :ref_number, :requested_date, :rev_commit_status, - :rev_committing_transaction, :reversal_date, :reversal_number, - :rg_account, :rg_amount, :sales_order, :sales_team_member, - :sales_team_role, :scheduling_method, :serial_number, - :serial_number_cost, :serial_number_cost_adjustment, - :serial_number_quantity, :serial_numbers, :ship_address, :ship_address1, - :ship_address2, :ship_address3, :ship_addressee, :ship_attention, - :ship_carrier, :ship_city, :ship_complete, :ship_country, - :ship_country_code, :ship_group, :ship_phone, :shipping_amount, - :ship_recv_status_line, :ship_state, :ship_to, :ship_zip, - :signed_amount, :subscription, :subscription_line, :tax_amount, - :tax_code, :tax_line, :tax_period, :term_in_months, :terms_of_sale, - :title, :to_subsidiary, :tran_est_gross_profit, - :tran_fx_est_gross_profit, :transaction_discount, - :transaction_line_type, :transaction_number, :transfer_location, - :transfer_order_item_line, :transfer_order_quantity_committed, - :transfer_order_quantity_packed, :transfer_order_quantity_picked, - :transfer_order_quantity_received, :transfer_order_quantity_shipped, - :type, :unit, :unit_cost_override, :vend_type, :visible_to_customer, - :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, - :vsoe_permit_discount, :vsoe_price, :web_site - # TODO: Add record_type, conflicts with Support::Records#record_type, returns "invoice" versus "tranSales: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 + include Searches::TransactionSearchRowBasic + attr_reader :internal_id attr_accessor :external_id diff --git a/lib/netsuite/searches/transaction_search_row_basic.rb b/lib/netsuite/searches/transaction_search_row_basic.rb new file mode 100644 index 00000000..aa9f4638 --- /dev/null +++ b/lib/netsuite/searches/transaction_search_row_basic.rb @@ -0,0 +1,308 @@ +module NetSuite + module Searches + module TransactionSearchRowBasic + + def self.included(base) + # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_2/schema/search/transactionsearchrowbasic.html?mode=package + base.search_only_fields :abbrev, + :account_type, + :actual_production_end_date, + :actual_production_start_date, + :actual_ship_date, + :alt_sales_amount, + :alt_sales_net_amount, + :amount, + :amount_paid, + :amount_remaining, + :amount_unbilled, + :applied_to_foreign_amount, + :applied_to_is_fx_variance, + :applied_to_link_amount, + :applied_to_link_type, + :applying_foreign_amount, + :applying_is_fx_variance, + :applying_link_amount, + :applying_link_type, + :approval_status, + :auth_code, + :auto_calculate_lag, + :avs_street_match, + :avs_zip_match, + :billable, + :bill_address, + :bill_address1, + :bill_address2, + :bill_address3, + :bill_addressee, + :bill_attention, + :bill_city, + :bill_country, + :bill_country_code, + :billed_date, + :billing_amount, + :bill_phone, + :bill_state, + :bill_variance_status, + :bill_zip, + :bin_number, + :bin_number_quantity, + :bom_quantity, + :build_entire_assembly, + :build_variance, + :built, + :can_have_stackable_promotions, + :catch_up_period, + :cc_customer_code, + :cc_exp_date, + :cc_holder_name, + :cc_number, + :cc_street, + :cc_zip_code, + :cleared, + :closed, + :close_date, + :cogs_amount, + :commission_effective_date, + :commit, + :component_yield, + :confirmation_number, + :contribution, + :contribution_primary, + :cost_component_amount, + :cost_component_category, + :cost_component_item, + :cost_component_quantity, + :cost_component_standard_cost, + :cost_estimate, + :cost_estimate_rate, + :cost_estimate_type, + :credit_amount, + :csc_match, + :custom_g_l, + :date_created, + :days_open, + :days_overdue, + :debit_amount, + :deferred_revenue, + :defer_rev_rec, + :deposit_date, + :discount_amount, + :doc_unit, + :dr_account, + :due_date, + :effective_rate, + :email, + :end_date, + :est_gross_profit, + :est_gross_profit_pct, + :est_gross_profit_percent, + :exchange_rate, + :exclude_commission, + :exclude_from_rate_request, + :expected_close_date, + :expected_receipt_date, + :expense_date, + :firmed, + :forecast_type, + :fx_account, + :fx_amount, + :fx_cost_estimate, + :fx_cost_estimate_rate, + :fx_est_gross_profit, + :fx_tran_cost_estimate, + :fx_vsoe_allocation, + :fx_vsoe_amount, + :fx_vsoe_price, + :gco_availabel_to_charge, + :gco_available_to_refund, + :gco_avs_street_match, + :gco_avs_zip_match, + :gco_buyer_account_age, + :gco_buyer_ip, + :gco_charge_amount, + :gco_chargeback_amount, + :gco_confirmed_charged_total, + :gco_confirmed_refunded_total, + :gco_creditcard_number, + :gco_csc_match, + :gco_financial_state, + :gco_fulfillment_state, + :gco_order_id, + :gco_order_total, + :gco_promotion_amount, + :gco_promotion_name, + :gco_refund_amount, + :gco_shipping_total, + :gco_state_changed_detail, + :gift_cert, + :gross_amount, + :include_in_forecast, + :interco_status, + :interco_transaction, + :in_vsoe_bundle, + :is_allocation, + :is_backflush, + :is_gco_chargeback, + :is_gco_charge_confirmed, + :is_gco_payment_guaranteed, + :is_gco_refund_confirmed, + :is_inside_delivery, + :is_inside_pickup, + :is_intercompany_adjustment, + :is_in_transit_payment, + :is_multi_ship_to, + :is_reversal, + :is_rev_rec_transaction, + :is_scrap, + :is_ship_address, + :is_transfer_price_costing, + :is_wip, + :item_fulfillment_choice, + :landed_cost_per_line, + :last_modified_date, + :line, + :line_sequence_number, + :line_unique_key, + :location_auto_assigned, + :main_line, + :main_name, + :match_bill_to_receipt, + :memo, + :memo_main, + :memorized, + :message, + :multi_subsidiary, + :net_amount, + :net_amount_no_tax, + :next_bill_date, + :no_auto_assign_location, + :non_reimbursable, + :one_time_total, + :options, + :order_priority, + :originator, + :other_ref_num, + :override_installments, + :package_count, + :paid_amount, + :partner_contribution, + :paying_amount, + :payment_approved, + :payment_event_date, + :payment_event_hold_reason, + :payment_event_purchase_card_used, + :payment_event_purchase_data_sent, + :payment_event_result, + :payment_event_type, + :payment_hold, + :pay_pal_pending, + :pay_pal_status, + :pay_pal_tran_id, + :payroll_batch, + :pn_ref_num, + :po_rate, + :posting, + :print, + :probability, + :projected_amount, + :quantity, + :quantity_billed, + :quantity_committed, + :quantity_packed, + :quantity_picked, + :quantity_rev_committed, + :quantity_ship_recv, + :quantity_uom, + :rate, + :realized_gain_posting_transaction, + :recognized_revenue, + # :record_type, # TODO: Conflicts with Support::Records#record_type + :recur_annually_total, + :recur_monthly_total, + :recur_quarterly_total, + :recurring_bill, + :recur_weekly_total, + :ref_number, + :requested_date, + :rev_commit_status, + :revenue_status, + :reversal_date, + :reversal_number, + :rev_rec_end_date, + :rev_rec_on_rev_commitment, + :rev_rec_start_date, + :rg_amount, + :sales_effective_date, + :scheduling_method, + :serial_number, + :serial_number_cost, + :serial_number_cost_adjustment, + :serial_number_quantity, + :serial_numbers, + :ship_address, + :ship_address1, + :ship_address2, + :ship_address3, + :ship_addressee, + :ship_attention, + :ship_carrier, + :ship_city, + :ship_complete, + :ship_country, + :ship_country_code, + :ship_date, + :ship_group, + :ship_phone, + :shipping_amount, + :ship_recv_status_line, + :ship_state, + :ship_zip, + :signed_amount, + :source, + :start_date, + :status, + :subsidiary_tax_reg_num, + :tax_amount, + :tax_line, + :tax_point_date, + :tax_total, + :term_in_months, + :terms_of_sale, + :title, + :to_be_emailed, + :to_be_printed, + :total, + :total_cost_estimate, + :tracking_numbers, + :tran_date, + :tran_est_gross_profit, + :tran_fx_est_gross_profit, + :tran_id, + :tran_is_vsoe_bundle, + :transaction_discount, + :transaction_line_type, + :transaction_number, + :transfer_order_item_line, + :transfer_order_quantity_committed, + :transfer_order_quantity_packed, + :transfer_order_quantity_picked, + :transfer_order_quantity_received, + :transfer_order_quantity_shipped, + :type, + :unit, + :unit_cost_override, + :visible_to_customer, + :vsoe_allocation, + :vsoe_amount, + :vsoe_deferral, + :vsoe_delivered, + :vsoe_permit_discount, + :vsoe_price, + :web_site + + # Assumes all "SearchColumnSelectField"s (RecordRefs) are defined on the including record. + end + + end + end +end diff --git a/lib/netsuite/support/fields.rb b/lib/netsuite/support/fields.rb index af478e54..4306b602 100644 --- a/lib/netsuite/support/fields.rb +++ b/lib/netsuite/support/fields.rb @@ -76,6 +76,9 @@ def search_only_fields(*args) def search_only_field(name) name_sym = name.to_sym + + return if fields.include?(name_sym) + search_only_fields << name_sym field name end diff --git a/spec/netsuite/records/credit_memo_spec.rb b/spec/netsuite/records/credit_memo_spec.rb index 1a305886..cfd82d36 100644 --- a/spec/netsuite/records/credit_memo_spec.rb +++ b/spec/netsuite/records/credit_memo_spec.rb @@ -44,6 +44,10 @@ end end + it 'includes TransactionSearchRowBasic for search_only_fields' do + expect(memo.is_a?(NetSuite::Searches::TransactionSearchRowBasic)).to be_truthy + end + describe '#item_list' do it 'can be set from attributes' do attributes = { diff --git a/spec/netsuite/records/invoice_spec.rb b/spec/netsuite/records/invoice_spec.rb index e903459b..c88e7bf1 100644 --- a/spec/netsuite/records/invoice_spec.rb +++ b/spec/netsuite/records/invoice_spec.rb @@ -55,97 +55,8 @@ end end - it 'has all the right search_only_fields' do - [ - :abbrev, :account_type, :acct_corp_card_exp, :actual_production_end_date, - :actual_production_start_date, :actual_ship_date, :alt_sales_amount, - :alt_sales_net_amount, :amount, :amount_unbilled, - :applied_to_foreign_amount, :applied_to_is_fx_variance, - :applied_to_link_amount, :applied_to_link_type, :applied_to_transaction, - :applying_foreign_amount, :applying_is_fx_variance, :applying_link_amount, - :applying_link_type, :applying_transaction, :auth_code, - :auto_calculate_lag, :avs_street_match, :avs_zip_match, :billable, - :bill_address, :bill_address1, :bill_address2, :bill_address3, - :bill_addressee, :bill_attention, :bill_city, :bill_country, - :bill_country_code, :billed_date, :billing_amount, :billing_transaction, - :bill_phone, :bill_state, :bill_variance_status, :bill_zip, :bin_number, - :bin_number_quantity, :bom_quantity, :build_entire_assembly, - :build_variance, :built, :can_have_stackable_promotions, :catch_up_period, - :cc_customer_code, :cc_exp_date, :cc_holder_name, :cc_number, :cc_street, - :cc_zip_code, :cleared, :closed, :close_date, :cogs_amount, - :commission_effective_date, :commit, :component_yield, - :confirmation_number, :contribution, :contribution_primary, - :cost_component_amount, :cost_component_category, :cost_component_item, - :cost_component_quantity, :cost_component_standard_cost, :cost_estimate, - :cost_estimate_rate, :cost_estimate_type, :created_by, :credit_amount, - :csc_match, :custom_gl, :cust_type, :date_created, :days_open, - :days_overdue, :debit_amount, :defer_rev_rec, :deposit_date, - :deposit_transaction, :doc_unit, :dr_account, :effective_rate, - :entity_status, :est_gross_profit_pct, :exclude_from_rate_request, - :expected_close_date, :expected_receipt_date, :expense_category, - :expense_date, :firmed, :forecast_type, :fulfilling_transaction, - :fx_account, :fx_amount, :fx_cost_estimate, :fx_cost_estimate_rate, - :fx_est_gross_profit, :fx_tran_cost_estimate, :fx_vsoe_allocation, - :fx_vsoe_amount, :fx_vsoe_price, :gco_availabel_to_charge, - :gco_available_to_refund, :gco_avs_street_match, :gco_avs_zip_match, - :gco_buyer_account_age, :gco_buyer_ip, :gco_charge_amount, - :gco_chargeback_amount, :gco_confirmed_charged_total, - :gco_confirmed_refunded_total, :gco_creditcard_number, :gco_csc_match, - :gco_financial_state, :gco_fulfillment_state, :gco_order_id, - :gco_order_total, :gco_promotion_amount, :gco_promotion_name, - :gco_refund_amount, :gco_shipping_total, :gco_state_changed_detail, - :gift_cert, :gross_amount, :include_in_forecast, :incoterm, - :interco_status, :interco_transaction, :inventory_location, - :inventory_subsidiary, :in_vsoe_bundle, :is_allocation, :is_backflush, - :is_gco_chargeback, :is_gco_charge_confirmed, :is_gco_payment_guaranteed, - :is_gco_refund_confirmed, :is_inside_delivery, :is_inside_pickup, - :is_intercompany_adjustment, :is_in_transit_payment, :is_multi_ship_to, - :is_reversal, :is_rev_rec_transaction, :is_scrap, :is_ship_address, - :is_transfer_price_costing, :is_wip, :item, :item_fulfillment_choice, - :item_revision, :landed_cost_per_line, :line, :line_sequence_number, - :line_unique_key, :location_auto_assigned, :main_line, :main_name, - :manufacturing_routing, :match_bill_to_receipt, :memo_main, :memorized, - :merchant_account, :multi_subsidiary, :net_amount, :net_amount_no_tax, - :next_bill_date, :no_auto_assign_location, :non_reimbursable, - :one_time_total, :options, :order_allocation_strategy, :order_priority, - :originator, :overhead_parent_item, - :override_installments, :package_count, :paid_amount, :paid_transaction, - :partner_contribution, :partner_role, :partner_team_member, - :paying_amount, :paying_transaction, :payment_approved, - :payment_event_date, :payment_event_hold_reason, - :payment_event_purchase_card_used, :payment_event_purchase_data_sent, - :payment_event_result, :payment_event_type, :payment_hold, - :payment_method, :payment_option, :pay_pal_pending, :pay_pal_status, - :pay_pal_tran_id, :payroll_batch, :pn_ref_num, :po_rate, :posting, - :price_level, :print, :probability, :projected_amount, :project_task, - :purchase_order, :quantity, :quantity_billed, :quantity_committed, - :quantity_packed, :quantity_picked, :quantity_rev_committed, - :quantity_ship_recv, :quantity_uom, :rate, - :realized_gain_posting_transaction, :recur_annually_total, - :recur_monthly_total, :recur_quarterly_total, :recur_weekly_total, - :ref_number, :requested_date, :rev_commit_status, - :rev_committing_transaction, :reversal_date, :reversal_number, - :rg_account, :rg_amount, :sales_order, :sales_team_member, - :sales_team_role, :scheduling_method, :serial_number, :serial_number_cost, - :serial_number_cost_adjustment, :serial_number_quantity, :serial_numbers, - :ship_address, :ship_address1, :ship_address2, :ship_address3, - :ship_addressee, :ship_attention, :ship_carrier, :ship_city, - :ship_complete, :ship_country, :ship_country_code, :ship_group, - :ship_phone, :shipping_amount, :ship_recv_status_line, :ship_state, - :ship_to, :ship_zip, :signed_amount, :subscription, :subscription_line, - :tax_amount, :tax_code, :tax_line, :tax_period, :term_in_months, - :terms_of_sale, :title, :to_subsidiary, :tran_est_gross_profit, - :tran_fx_est_gross_profit, :transaction_discount, :transaction_line_type, - :transaction_number, :transfer_location, :transfer_order_item_line, - :transfer_order_quantity_committed, :transfer_order_quantity_packed, - :transfer_order_quantity_picked, :transfer_order_quantity_received, - :transfer_order_quantity_shipped, :type, :unit, :unit_cost_override, - :vend_type, :visible_to_customer, :vsoe_allocation, :vsoe_amount, - :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, - :web_site, - ].each do |field| - expect(NetSuite::Records::Invoice).to have_search_only_field(field) - end + it 'includes TransactionSearchRowBasic for search_only_fields' do + expect(invoice.is_a?(NetSuite::Searches::TransactionSearchRowBasic)).to be_truthy end it 'has the right record_refs' do diff --git a/spec/netsuite/searches/transaction_search_row_basic_spec.rb b/spec/netsuite/searches/transaction_search_row_basic_spec.rb new file mode 100644 index 00000000..c211890c --- /dev/null +++ b/spec/netsuite/searches/transaction_search_row_basic_spec.rb @@ -0,0 +1,314 @@ +require 'spec_helper' + +describe NetSuite::Searches::TransactionSearchRowBasic do + + let(:klass) do + Class.new do + include NetSuite::Support::Fields + include NetSuite::Searches::TransactionSearchRowBasic + end + end + + it 'has all the right search_only_fields' do + [ + :abbrev, + :account_type, + :actual_production_end_date, + :actual_production_start_date, + :actual_ship_date, + :alt_sales_amount, + :alt_sales_net_amount, + :amount, + :amount_paid, + :amount_remaining, + :amount_unbilled, + :applied_to_foreign_amount, + :applied_to_is_fx_variance, + :applied_to_link_amount, + :applied_to_link_type, + :applying_foreign_amount, + :applying_is_fx_variance, + :applying_link_amount, + :applying_link_type, + :approval_status, + :auth_code, + :auto_calculate_lag, + :avs_street_match, + :avs_zip_match, + :billable, + :bill_address, + :bill_address1, + :bill_address2, + :bill_address3, + :bill_addressee, + :bill_attention, + :bill_city, + :bill_country, + :bill_country_code, + :billed_date, + :billing_amount, + :bill_phone, + :bill_state, + :bill_variance_status, + :bill_zip, + :bin_number, + :bin_number_quantity, + :bom_quantity, + :build_entire_assembly, + :build_variance, + :built, + :can_have_stackable_promotions, + :catch_up_period, + :cc_customer_code, + :cc_exp_date, + :cc_holder_name, + :cc_number, + :cc_street, + :cc_zip_code, + :cleared, + :closed, + :close_date, + :cogs_amount, + :commission_effective_date, + :commit, + :component_yield, + :confirmation_number, + :contribution, + :contribution_primary, + :cost_component_amount, + :cost_component_category, + :cost_component_item, + :cost_component_quantity, + :cost_component_standard_cost, + :cost_estimate, + :cost_estimate_rate, + :cost_estimate_type, + :credit_amount, + :csc_match, + :custom_g_l, + :date_created, + :days_open, + :days_overdue, + :debit_amount, + :deferred_revenue, + :defer_rev_rec, + :deposit_date, + :discount_amount, + :doc_unit, + :dr_account, + :due_date, + :effective_rate, + :email, + :end_date, + :est_gross_profit, + :est_gross_profit_pct, + :est_gross_profit_percent, + :exchange_rate, + :exclude_commission, + :exclude_from_rate_request, + :expected_close_date, + :expected_receipt_date, + :expense_date, + :firmed, + :forecast_type, + :fx_account, + :fx_amount, + :fx_cost_estimate, + :fx_cost_estimate_rate, + :fx_est_gross_profit, + :fx_tran_cost_estimate, + :fx_vsoe_allocation, + :fx_vsoe_amount, + :fx_vsoe_price, + :gco_availabel_to_charge, + :gco_available_to_refund, + :gco_avs_street_match, + :gco_avs_zip_match, + :gco_buyer_account_age, + :gco_buyer_ip, + :gco_charge_amount, + :gco_chargeback_amount, + :gco_confirmed_charged_total, + :gco_confirmed_refunded_total, + :gco_creditcard_number, + :gco_csc_match, + :gco_financial_state, + :gco_fulfillment_state, + :gco_order_id, + :gco_order_total, + :gco_promotion_amount, + :gco_promotion_name, + :gco_refund_amount, + :gco_shipping_total, + :gco_state_changed_detail, + :gift_cert, + :gross_amount, + :include_in_forecast, + :interco_status, + :interco_transaction, + :in_vsoe_bundle, + :is_allocation, + :is_backflush, + :is_gco_chargeback, + :is_gco_charge_confirmed, + :is_gco_payment_guaranteed, + :is_gco_refund_confirmed, + :is_inside_delivery, + :is_inside_pickup, + :is_intercompany_adjustment, + :is_in_transit_payment, + :is_multi_ship_to, + :is_reversal, + :is_rev_rec_transaction, + :is_scrap, + :is_ship_address, + :is_transfer_price_costing, + :is_wip, + :item_fulfillment_choice, + :landed_cost_per_line, + :last_modified_date, + :line, + :line_sequence_number, + :line_unique_key, + :location_auto_assigned, + :main_line, + :main_name, + :match_bill_to_receipt, + :memo, + :memo_main, + :memorized, + :message, + :multi_subsidiary, + :net_amount, + :net_amount_no_tax, + :next_bill_date, + :no_auto_assign_location, + :non_reimbursable, + :one_time_total, + :options, + :order_priority, + :originator, + :other_ref_num, + :override_installments, + :package_count, + :paid_amount, + :partner_contribution, + :paying_amount, + :payment_approved, + :payment_event_date, + :payment_event_hold_reason, + :payment_event_purchase_card_used, + :payment_event_purchase_data_sent, + :payment_event_result, + :payment_event_type, + :payment_hold, + :pay_pal_pending, + :pay_pal_status, + :pay_pal_tran_id, + :payroll_batch, + :pn_ref_num, + :po_rate, + :posting, + :print, + :probability, + :projected_amount, + :quantity, + :quantity_billed, + :quantity_committed, + :quantity_packed, + :quantity_picked, + :quantity_rev_committed, + :quantity_ship_recv, + :quantity_uom, + :rate, + :realized_gain_posting_transaction, + :recognized_revenue, + # :record_type, # TODO: Conflicts with Support::Records#record_type + :recur_annually_total, + :recur_monthly_total, + :recur_quarterly_total, + :recurring_bill, + :recur_weekly_total, + :ref_number, + :requested_date, + :rev_commit_status, + :revenue_status, + :reversal_date, + :reversal_number, + :rev_rec_end_date, + :rev_rec_on_rev_commitment, + :rev_rec_start_date, + :rg_amount, + :sales_effective_date, + :scheduling_method, + :serial_number, + :serial_number_cost, + :serial_number_cost_adjustment, + :serial_number_quantity, + :serial_numbers, + :ship_address, + :ship_address1, + :ship_address2, + :ship_address3, + :ship_addressee, + :ship_attention, + :ship_carrier, + :ship_city, + :ship_complete, + :ship_country, + :ship_country_code, + :ship_date, + :ship_group, + :ship_phone, + :shipping_amount, + :ship_recv_status_line, + :ship_state, + :ship_zip, + :signed_amount, + :source, + :start_date, + :status, + :subsidiary_tax_reg_num, + :tax_amount, + :tax_line, + :tax_point_date, + :tax_total, + :term_in_months, + :terms_of_sale, + :title, + :to_be_emailed, + :to_be_printed, + :total, + :total_cost_estimate, + :tracking_numbers, + :tran_date, + :tran_est_gross_profit, + :tran_fx_est_gross_profit, + :tran_id, + :tran_is_vsoe_bundle, + :transaction_discount, + :transaction_line_type, + :transaction_number, + :transfer_order_item_line, + :transfer_order_quantity_committed, + :transfer_order_quantity_packed, + :transfer_order_quantity_picked, + :transfer_order_quantity_received, + :transfer_order_quantity_shipped, + :type, + :unit, + :unit_cost_override, + :visible_to_customer, + :vsoe_allocation, + :vsoe_amount, + :vsoe_deferral, + :vsoe_delivered, + :vsoe_permit_discount, + :vsoe_price, + :web_site, + ].each do |field| + expect(klass).to have_search_only_field(field) + end + end + +end diff --git a/spec/netsuite/support/fields_spec.rb b/spec/netsuite/support/fields_spec.rb index f888f473..528d893e 100644 --- a/spec/netsuite/support/fields_spec.rb +++ b/spec/netsuite/support/fields_spec.rb @@ -102,6 +102,16 @@ def existing_method expect(klass).to receive(:field).with(:one) klass.search_only_field(:one) end + + it 'becomes a no-op if the field was previously defined as a regular field' do + klass.field :one + + expect(klass).to_not receive(:field) + + klass.search_only_field(:one) + + expect(klass.search_only_fields).to_not include(:one) + end end end