Skip to content

Commit f4faff5

Browse files
committed
Add search only fields to CreditMemo and PurchaseOrder
Both `Invoice`, `CreditMemo`, and `PurchaseOrder` 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, credit memos, and purchase orders, 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".
1 parent 5470f03 commit f4faff5

11 files changed

Lines changed: 652 additions & 184 deletions

File tree

HISTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
### Added
3535
* Add `Configuration#multi_tenant!` for opting into multi-tentant support where configuration/caching is per-thread (#556)
36+
* Add search-only fields to `CreditMemo` and `PurchaseOrder` (#565)
3637

3738
### Fixed
3839
* Avoid Savon version `2.13.0` to prevent generating invalid envelopes. (#558, #563)

lib/netsuite.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ module Actions
6767
autoload :Login, 'netsuite/actions/login'
6868
end
6969

70+
module Searches
71+
autoload :TransactionSearchRowBasic, 'netsuite/searches/transaction_search_row_basic'
72+
end
73+
7074
module Records
7175
autoload :AssemblyItem, 'netsuite/records/assembly_item'
7276
autoload :AssemblyBuild, 'netsuite/records/assembly_build'

lib/netsuite/records/credit_memo.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class CreditMemo
3737
:handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, :partner, :posting_period, :promo_code,
3838
:sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :tax_item, :currency
3939

40+
include Searches::TransactionSearchRowBasic
41+
4042
attr_reader :internal_id
4143
attr_accessor :external_id
4244

lib/netsuite/records/invoice.rb

Lines changed: 2 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -43,104 +43,13 @@ class Invoice
4343
read_only_fields :sub_total, :discount_total, :total, :recognized_revenue, :amount_remaining, :amount_paid,
4444
:alt_shipping_cost, :gift_cert_applied, :handling_cost, :alt_handling_cost
4545

46-
# https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2020_2/schema/search/transactionsearchrowbasic.html?mode=package
47-
search_only_fields :abbrev, :account_type, :acct_corp_card_exp,
48-
:actual_production_end_date, :actual_production_start_date,
49-
:actual_ship_date, :alt_sales_amount, :alt_sales_net_amount, :amount,
50-
:amount_unbilled, :applied_to_foreign_amount,
51-
:applied_to_is_fx_variance, :applied_to_link_amount,
52-
:applied_to_link_type, :applied_to_transaction,
53-
:applying_foreign_amount, :applying_is_fx_variance,
54-
:applying_link_amount, :applying_link_type, :applying_transaction,
55-
:auth_code, :auto_calculate_lag, :avs_street_match, :avs_zip_match,
56-
:billable, :bill_address, :bill_address1, :bill_address2,
57-
:bill_address3, :bill_addressee, :bill_attention, :bill_city,
58-
:bill_country, :bill_country_code, :billed_date, :billing_amount,
59-
:billing_transaction, :bill_phone, :bill_state, :bill_variance_status,
60-
:bill_zip, :bin_number, :bin_number_quantity, :bom_quantity,
61-
:build_entire_assembly, :build_variance, :built,
62-
:can_have_stackable_promotions, :catch_up_period, :cc_customer_code,
63-
:cc_exp_date, :cc_holder_name, :cc_number, :cc_street, :cc_zip_code,
64-
:cleared, :closed, :close_date, :cogs_amount,
65-
:commission_effective_date, :commit, :component_yield,
66-
:confirmation_number, :contribution, :contribution_primary,
67-
:cost_component_amount, :cost_component_category, :cost_component_item,
68-
:cost_component_quantity, :cost_component_standard_cost, :cost_estimate,
69-
:cost_estimate_rate, :cost_estimate_type, :created_by, :credit_amount,
70-
:csc_match, :custom_gl, :cust_type, :date_created, :days_open,
71-
:days_overdue, :debit_amount, :defer_rev_rec, :deposit_date,
72-
:deposit_transaction, :doc_unit, :dr_account, :effective_rate,
73-
:entity_status, :est_gross_profit_pct, :exclude_from_rate_request,
74-
:expected_close_date, :expected_receipt_date, :expense_category,
75-
:expense_date, :firmed, :forecast_type, :fulfilling_transaction,
76-
:fx_account, :fx_amount, :fx_cost_estimate, :fx_cost_estimate_rate,
77-
:fx_est_gross_profit, :fx_tran_cost_estimate, :fx_vsoe_allocation,
78-
:fx_vsoe_amount, :fx_vsoe_price, :gco_availabel_to_charge,
79-
:gco_available_to_refund, :gco_avs_street_match, :gco_avs_zip_match,
80-
:gco_buyer_account_age, :gco_buyer_ip, :gco_charge_amount,
81-
:gco_chargeback_amount, :gco_confirmed_charged_total,
82-
:gco_confirmed_refunded_total, :gco_creditcard_number, :gco_csc_match,
83-
:gco_financial_state, :gco_fulfillment_state, :gco_order_id,
84-
:gco_order_total, :gco_promotion_amount, :gco_promotion_name,
85-
:gco_refund_amount, :gco_shipping_total, :gco_state_changed_detail,
86-
:gift_cert, :gross_amount, :include_in_forecast, :incoterm,
87-
:interco_status, :interco_transaction, :inventory_location,
88-
:inventory_subsidiary, :in_vsoe_bundle, :is_allocation, :is_backflush,
89-
:is_gco_chargeback, :is_gco_charge_confirmed,
90-
:is_gco_payment_guaranteed, :is_gco_refund_confirmed,
91-
:is_inside_delivery, :is_inside_pickup, :is_intercompany_adjustment,
92-
:is_in_transit_payment, :is_multi_ship_to, :is_reversal,
93-
:is_rev_rec_transaction, :is_scrap, :is_ship_address,
94-
:is_transfer_price_costing, :is_wip, :item, :item_fulfillment_choice,
95-
:item_revision, :landed_cost_per_line, :line, :line_sequence_number,
96-
:line_unique_key, :location_auto_assigned, :main_line, :main_name,
97-
:manufacturing_routing, :match_bill_to_receipt, :memo_main, :memorized,
98-
:merchant_account, :multi_subsidiary, :net_amount, :net_amount_no_tax,
99-
:next_bill_date, :no_auto_assign_location, :non_reimbursable,
100-
:one_time_total, :options, :order_allocation_strategy, :order_priority,
101-
:originator, :overhead_parent_item,
102-
:override_installments, :package_count, :paid_amount, :paid_transaction,
103-
:partner_contribution, :partner_role, :partner_team_member,
104-
:paying_amount, :paying_transaction, :payment_approved,
105-
:payment_event_date, :payment_event_hold_reason,
106-
:payment_event_purchase_card_used, :payment_event_purchase_data_sent,
107-
:payment_event_result, :payment_event_type, :payment_hold,
108-
:payment_method, :payment_option, :pay_pal_pending, :pay_pal_status,
109-
:pay_pal_tran_id, :payroll_batch, :pn_ref_num, :po_rate, :posting,
110-
:price_level, :print, :probability, :projected_amount, :project_task,
111-
:purchase_order, :quantity, :quantity_billed, :quantity_committed,
112-
:quantity_packed, :quantity_picked, :quantity_rev_committed,
113-
:quantity_ship_recv, :quantity_uom, :rate,
114-
:realized_gain_posting_transaction, :recur_annually_total,
115-
:recur_monthly_total, :recur_quarterly_total, :recur_weekly_total,
116-
:ref_number, :requested_date, :rev_commit_status,
117-
:rev_committing_transaction, :reversal_date, :reversal_number,
118-
:rg_account, :rg_amount, :sales_order, :sales_team_member,
119-
:sales_team_role, :scheduling_method, :serial_number,
120-
:serial_number_cost, :serial_number_cost_adjustment,
121-
:serial_number_quantity, :serial_numbers, :ship_address, :ship_address1,
122-
:ship_address2, :ship_address3, :ship_addressee, :ship_attention,
123-
:ship_carrier, :ship_city, :ship_complete, :ship_country,
124-
:ship_country_code, :ship_group, :ship_phone, :shipping_amount,
125-
:ship_recv_status_line, :ship_state, :ship_to, :ship_zip,
126-
:signed_amount, :subscription, :subscription_line, :tax_amount,
127-
:tax_code, :tax_line, :tax_period, :term_in_months, :terms_of_sale,
128-
:title, :to_subsidiary, :tran_est_gross_profit,
129-
:tran_fx_est_gross_profit, :transaction_discount,
130-
:transaction_line_type, :transaction_number, :transfer_location,
131-
:transfer_order_item_line, :transfer_order_quantity_committed,
132-
:transfer_order_quantity_packed, :transfer_order_quantity_picked,
133-
:transfer_order_quantity_received, :transfer_order_quantity_shipped,
134-
:type, :unit, :unit_cost_override, :vend_type, :visible_to_customer,
135-
:vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered,
136-
:vsoe_permit_discount, :vsoe_price, :web_site
137-
# TODO: Add record_type, conflicts with Support::Records#record_type, returns "invoice" versus "tranSales:Invoice"
138-
13946
record_refs :account, :bill_address_list, :custom_form, :department, :entity, :klass, :partner,
14047
:posting_period, :ship_address_list, :terms, :location, :sales_rep, :tax_item, :created_from,
14148
:ship_method, :lead_source, :promo_code, :subsidiary, :currency, :approval_status, :job, :discount_item,
14249
:shipping_tax_code
14350

51+
include Searches::TransactionSearchRowBasic
52+
14453
attr_reader :internal_id
14554
attr_accessor :external_id
14655

lib/netsuite/records/purchase_order.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class PurchaseOrder
2929
:custom_form, :department, :employee, :entity, :location, :next_approver,
3030
:order_status, :purchase_contract, :ship_method, :subsidiary, :terms
3131

32+
include Searches::TransactionSearchRowBasic
33+
3234
attr_reader :internal_id
3335
attr_accessor :external_id
3436

0 commit comments

Comments
 (0)