Class: AgentsReport
Instance Attribute Summary
#report, #template
Instance Method Summary
collapse
#arelize, #human_calculation_name, #human_calculation_names, #human_condition_name, #human_condition_values, #human_field_name, #human_field_value, #human_groupping_field_names, #human_groupping_names, #initialize, #keyword, #query, requires_dates!, requires_dates?, #requires_dates?
Instance Method Details
#calculations ⇒ Object
70
71
72
73
74
|
# File 'app/reports/agents_report.rb', line 70
def calculations
{
:quantity => lambda{|q, t| t.groupping.blank? ? q : q.project('COUNT(*) AS "quantity"').where(tables[:agent][:agent_id].not_eq nil) }
}.with_indifferent_access
end
|
#conditions ⇒ Object
76
77
78
79
80
|
# File 'app/reports/agents_report.rb', line 76
def conditions
{
'agent.agent_id' => proc{ Agent.rmap.invert }
}
end
|
#context(start, finish) ⇒ Object
11
12
13
14
15
16
|
# File 'app/reports/agents_report.rb', line 11
def context(start, finish)
context = tables[:agent]
context = context.join(tables[:parent_agent], Arel::Nodes::OuterJoin).on(tables[:agent][:agent_id].eq tables[:parent_agent][:id])
context = context.where(tables[:agent][:created_at].in(start..finish)) if !start.blank? || !finish.blank?
context
end
|
#fields ⇒ Object
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
|
# File 'app/reports/agents_report.rb', line 24
def fields
{
'' => %w(
agent.title
agent.juristic_name
agent.juristic_address_city
agent.juristic_address_street
agent.juristic_address_home
agent.physical_address_city
agent.physical_address_district
agent.physical_address_subway
agent.physical_address_street
agent.physical_address_home
agent.contact_name
agent.contact_info
agent.director_name
agent.director_contact_info
agent.bookkeeper_name
agent.bookkeeper_contact_info
agent.inn
agent.support_phone
),
'agent.agent_id' => %w(
agent.agent_id
parent_agent.title
parent_agent.juristic_name
parent_agent.juristic_address_city
parent_agent.juristic_address_street
parent_agent.juristic_address_home
parent_agent.physical_address_city
parent_agent.physical_address_district
parent_agent.physical_address_subway
parent_agent.physical_address_street
parent_agent.physical_address_home
parent_agent.contact_name
parent_agent.contact_info
parent_agent.director_name
parent_agent.director_contact_info
parent_agent.bookkeeper_name
parent_agent.bookkeeper_contact_info
parent_agent.inn
parent_agent.support_phone
)
}
end
|
#groupping ⇒ Object
18
19
20
21
22
|
# File 'app/reports/agents_report.rb', line 18
def groupping
%w(
agent.agent_id
)
end
|
#tables ⇒ Object
4
5
6
7
8
9
|
# File 'app/reports/agents_report.rb', line 4
def tables
@tables ||= {
:agent => Arel::Table.new(:agents),
:parent_agent => Arel::Table.new(:agents).alias("parent_agents")
}.with_indifferent_access
end
|