Module: Crm::AccountsPayableDashboardHelper

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

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

Instance Method Details

#ap_tab_optionsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/crm/accounts_payable_dashboard_helper.rb', line 5

def ap_tab_options
  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: ["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: ["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: ['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: ['queued', 'generated'], job_id_null: 1, company_id_eq: @company_id, bank_account_id_eq: @bank_account_id},
      selected_columns: ["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: ['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: ['queued', 'generated'], job_id_not_null: 1, company_id_eq: @company_id, bank_account_id_eq: @bank_account_id},
      selected_columns: ["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: ["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: ['printed', 'reprinted'], company_id_eq: @company_id, bank_account_id_eq: @bank_account_id},
      selected_columns: ["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: ["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: ['payment_link', 'company_name', 'supplier_name', 'category', 'amount', 'payment_date', 'bank_account_name']
    )
  }
  hsh.delete_if {|k,v| v[:counter] == 0}
  hsh
end