Class: InvoiceSearch

Inherits:
Search show all
Includes:
Models::SearchAddressable
Defined in:
app/models/invoice_search.rb

Overview

== Schema Information

Table name: searches
Database name: primary

id :integer not null, primary key
name :string(255)
persist :boolean default(FALSE)
pinned :boolean default(FALSE), not null
query_params :jsonb
result_set_size :integer default(0)
selected_columns :string is an Array
set_limit :integer default(25)
sort_column :string(255)
sort_columns :string default([]), not null, is an Array
sort_direction :string(255) default("ASC")
type :string(255) not null
created_at :datetime
updated_at :datetime
employee_id :integer

Indexes

employee_id_pinned (employee_id,pinned)
employee_id_type (employee_id,type)

Constant Summary

Constants inherited from Search

Search::DISTANCE_SEARCH_KEYS

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary

Attributes inherited from Search

#composite_columns, #pagy_count, #pagy_limit, #pagy_page, #sql_select_columns

Instance Method Summary collapse

Methods included from Models::SearchAddressable

#mass_googlemap

Methods inherited from Search

#all_composite_columns, allowed_role_ids, #append_custom_column, #append_ouput_column, #append_to_sql_select_columns, #applicable_sort_terms, #apply_array_match, #apply_criteria, #apply_customer_cross_reference, #apply_distance_search, #apply_select, #apply_sort, #available_events, available_output_columns, #available_output_columns, base_search_class_name, #cleanup_search_results, composite_column, #composite_column, custom_criteria_keys, database_columns, default_columns, default_sort, #discard_excess, #effective_name, #effective_short_name, #employee, #enqueue_navbar_pinned_refresh, #fast_count, favorites, friendly_column_name, #get_pinned_results, #get_sort_term, global_favorite, has_role_for_search?, #human_query_params, instantiate_query_template, #instantiate_resource_updater, #limit_options, main_resource_class, main_resource_table, mass_actions_for_select, #mass_export, maximum_unpersisted_queries, #normalize_for_mass_update, options, options_classes, #output_columns_for_select, #pagy_from_search, #perform, #perform_selected, #pinned_query, #prepend_custom_column, #prepend_output_column, query_favorites_templates, #ransack_probe_params, recent_searches_for_employee_id, #record_list, #refresh_pinned_results, #remove_other_pins, search_name, #search_name, #search_results, search_type, search_type_humanized, select_sort_columns, #select_sort_columns, #select_statement, #set_defaults, #set_sort_term, #sort_column1, #sort_column1=, #sort_column2, #sort_column2=, #sort_column3, #sort_column3=, #sort_columns_for_select, #sort_columns_to_hash, #target_geocoding, unpersisted_queries_quote_reached?, #unrecord_list, #validated_selected_columns, view_resource_class, view_resource_klass, #view_resource_klass, view_resource_table, visible?, with_search_results

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Method Details

#address_id_fieldsArray<Array(String, String)>

Models::SearchAddressable hook — list of [label, column] pairs
the address-search panel can target on an invoice (billing /
shipping). Used to render address-filter sub-panels.

Returns:

  • (Array<Array(String, String)>)


57
58
59
# File 'app/models/invoice_search.rb', line 57

def address_id_fields
  [%w[Billing billing_address_id], %w[Shipping shipping_address_id]]
end

#mass_assign_source(params, cur_user = nil) ⇒ Hash{Symbol => Object}

Mass-action handler for "set source on all matching invoices" —
enqueues a SearchResourceUpdateWorker that walks the search
result set and applies the supplied source_id to each row.

Parameters:

  • params (ActionController::Parameters, Hash)
  • cur_user (Employee, nil) (defaults to: nil)

Returns:

  • (Hash{Symbol => Object})

    {status: :ok, job_id: jid}



68
69
70
71
72
73
74
75
76
# File 'app/models/invoice_search.rb', line 68

def mass_assign_source(params, cur_user = nil)
  jid = ::SearchResourceUpdateWorker.perform_async(
    'search_id'     => id,
    'action_params' => { 'resource_params' => { 'source_id' => params[:source_id] } },
    'user_id'       => cur_user&.id,
    'locale'        => I18n.locale.to_s
  )
  { status: :ok, job_id: jid }
end