Module: Crm::AccountsPayableDashboardHelper
- Defined in:
- app/helpers/crm/accounts_payable_dashboard_helper.rb
Overview
View helpers for the CRM accounts payable dashboard.
Builds the tab definitions (counters and remote search URLs) rendered by the
accounts payable dashboard views, backed by Voucher and OutgoingPayment
searches.
Constant Summary collapse
- DASHBOARD_SEARCH_LIMIT =
Tabs that feed mass-action flows need all records loaded, not the default page size.
9999
Instance Method Summary collapse
-
#ap_tab_options ⇒ Hash{Symbol => Hash}
Builds the tab options hash for the accounts payable dashboard.
Instance Method Details
#ap_tab_options ⇒ Hash{Symbol => Hash}
Builds the tab options hash for the accounts payable dashboard.
Each entry maps a tab key to its record counter and remote search URL;
tabs with a zero counter are removed before returning.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/helpers/crm/accounts_payable_dashboard_helper.rb', line 20 def hsh = {} hsh[:unpaid_vouchers] = { counter: Voucher.voucher_count(@company_id, { state: 'unpaid' }), remote_href: search_and_show_searches_path( type: 'VoucherSearch', set_limit: DASHBOARD_SEARCH_LIMIT, query_params: { state_in: ['unpaid'], company_id_eq: @company_id }, selected_columns: %w[voucher_link company_name category payee_name supplier_name payment_method invoice_number invoice_date gl_date currency total open_amount due_date] ) } hsh[:checks_pending_review] = { counter: OutgoingPayment.payment_count(@company_id, @bank_account_id, { category: 'check', state: 'applied', check_state: ['pending_review'], job_id: nil }), remote_href: search_and_show_searches_path( type: 'OutgoingPaymentSearch', query_params: { category_in: ['check'], state_in: ['applied'], check_state_in: ['pending_review'], job_id_null: 1, company_id_eq: @company_id, bank_account_id_eq: @bank_account_id }, selected_columns: %w[payment_link company_name supplier_name payee_name amount payment_date bank_account_name] ) } hsh[:unprinted_checks] = { counter: OutgoingPayment.payment_count(@company_id, @bank_account_id, { category: 'check', state: 'applied', check_state: %w[queued generated], job_id: nil }), remote_href: search_and_show_searches_path( type: 'OutgoingPaymentSearch', set_limit: DASHBOARD_SEARCH_LIMIT, query_params: { category_in: ['check'], state_in: ['applied'], check_state_in: %w[queued generated], job_id_null: 1, company_id_eq: @company_id, bank_account_id_eq: @bank_account_id }, selected_columns: %w[payment_link company_name supplier_name payee_name amount payment_date bank_account_name] ) } hsh[:checks_being_printed] = { counter: OutgoingPayment.payment_count(@company_id, @bank_account_id, { category: 'check', state: 'applied', check_state: %w[queued generated] }, { job_id: nil }), remote_href: search_and_show_searches_path( type: 'OutgoingPaymentSearch', query_params: { category_in: ['check'], state_in: ['applied'], check_state_in: %w[queued generated], job_id_not_null: 1, company_id_eq: @company_id, bank_account_id_eq: @bank_account_id }, selected_columns: %w[payment_link company_name supplier_name payee_name amount payment_date bank_account_name job_link] ) } hsh[:unreconciled_payments] = { counter: query_template_link(OutgoingPaymentSearch, nil, query_params: { state_in: ['applied'], reconciled_in: ['outstanding'], company_id_eq: @company_id, bank_account_id_eq: @bank_account_id })[1], remote_href: search_and_show_searches_path( type: 'OutgoingPaymentSearch', query_params: { state_in: ['applied'], reconciled_in: ['outstanding'], company_id_eq: @company_id, bank_account_id_eq: @bank_account_id }, selected_columns: %w[payment_link company_name supplier_name category check_number amount payment_date bank_account_name] ) } hsh[:printed_checks] = { counter: nil, remote_href: search_and_show_searches_path( type: 'OutgoingPaymentSearch', query_params: { category_in: ['check'], state_in: ['applied'], check_state_in: %w[printed reprinted], company_id_eq: @company_id, bank_account_id_eq: @bank_account_id }, selected_columns: %w[check_number last_printed_at payment_link company_name supplier_name payee_name amount payment_date bank_account_name], sort_columns: ["last_printed_at DESC"] ) } hsh[:draft_vouchers] = { counter: Voucher.voucher_count(@company_id, { state: 'draft' }), remote_href: search_and_show_searches_path( type: 'VoucherSearch', query_params: { state_in: ['draft'], company_id_eq: @company_id }, selected_columns: %w[voucher_link company_name category supplier_name invoice_number invoice_date gl_date currency total] ) } hsh[:draft_payments] = { counter: OutgoingPayment.payment_count(@company_id, @bank_account_id, { state: 'draft' }), remote_href: search_and_show_searches_path( type: 'OutgoingPaymentSearch', query_params: { state_in: ['draft'], company_id_eq: @company_id, bank_account_id_eq: @bank_account_id }, selected_columns: %w[payment_link company_name supplier_name category amount payment_date bank_account_name] ) } hsh.delete_if { |_k, v| v[:counter] == 0 } hsh end |