Module: Crm::AccountingDashboardHelper

Defined in:
app/helpers/crm/accounting_dashboard_helper.rb

Overview

View helper: accounting dashboard.

Provides tab options (with lazy-loaded counters) and transmission error
markup for the CRM accounting dashboard's document transmission tabs.

Instance Method Summary collapse

Instance Method Details

#accounting_transmissions_tab_optionsHash{Symbol => Hash}

Builds the tab options for the accounting transmissions dashboard.

Tab counters are lazy-loaded via individual Turbo Frame requests to avoid
blocking the initial page render with 7 expensive COUNT queries on a complex view.

Returns:

  • (Hash{Symbol => Hash})

    tab options keyed by tab name, each entry
    carrying :counter_html (lazy Turbo Frame markup) and :remote_href
    (tab content path with the current ransack query merged in); the
    :missing_edi_810 tab also carries a custom :title



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/crm/accounting_dashboard_helper.rb', line 18

def accounting_transmissions_tab_options
  params[:q] ||= {}
  base_q = params[:q].to_h

  {
    email_or_fax: {
      counter_html: lazy_tab_count_frame('email_or_fax', base_q),
      remote_href: accounting_dashboard_tab_email_or_fax_path(q: base_q.merge(transmission_type_in: ['Email/Fax']))
    },
    portal: {
      counter_html: lazy_tab_count_frame('portal', base_q),
      remote_href: accounting_dashboard_tab_portal_path(q: base_q.merge(transmission_type_in: ['Portal']))
    },
    mail: {
      counter_html: lazy_tab_count_frame('mail', base_q),
      remote_href: accounting_dashboard_tab_mail_path(q: base_q.merge(transmission_type_in: ['Mail']))
    },
    mixed: {
      counter_html: lazy_tab_count_frame('mixed', base_q),
      remote_href: accounting_dashboard_tab_mixed_path(q: base_q.merge(transmission_type_not_in: ['Email/Fax', 'Portal', 'Mail', 'No Channel Set']))
    },
    no_channel_set: {
      counter_html: lazy_tab_count_frame('no_channel_set', base_q),
      remote_href: accounting_dashboard_tab_no_channel_set_path(q: base_q.merge(transmission_type_in: ['No Channel Set']))
    },
    replacement_invoice: {
      counter_html: lazy_tab_count_frame('replacement_invoice', base_q),
      remote_href: accounting_dashboard_tab_replacement_invoice_path(q: base_q.merge(doc_type_in: ['INV']))
    },
    missing_edi_810: {
      title: 'EDI 810',
      counter_html: lazy_tab_count_frame('missing_edi_810', base_q),
      remote_href: accounting_dashboard_tab_missing_edi_810_path
    }
  }
end