Class: CollectionsReport
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
139
140
141
142
143
144
145
|
# File 'app/reports/collections_report.rb', line 139
def calculations
{
:cash_sum => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(collections.cash_sum) AS "cash_sum"') },
:approved_payments_sum => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(collections.approved_payments_sum) AS "approved_payments_sum"') },
:payments_sum => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(collections.payments_sum) AS "payments_sum"') }
}.with_indifferent_access
end
|
#conditions ⇒ Object
147
148
149
150
|
# File 'app/reports/collections_report.rb', line 147
def conditions
{
}
end
|
#context(start, finish) ⇒ Object
14
15
16
17
18
19
20
21
22
23
|
# File 'app/reports/collections_report.rb', line 14
def context(start, finish)
context = tables[:collection]
context = context.join(tables[:terminal], Arel::Nodes::OuterJoin).on(tables[:collection][:terminal_id].eq tables[:terminal][:id])
context = context.join(tables[:agent], Arel::Nodes::OuterJoin).on(tables[:terminal][:agent_id].eq tables[:agent][:id])
context = context.where(tables[:collection][:created_at].in(start..finish))
context
end
|
#fields ⇒ Object
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'app/reports/collections_report.rb', line 35
def fields
{
'' => %w(
collection.terminal_id
terminal.keyword
terminal.address
terminal.version
terminal.issues_started_at
terminal.collected_at
terminal.printer_error
terminal.cash_acceptor_error
terminal.juristic_name
terminal.sector
terminal.contact_name
terminal.contact_phone
terminal.contact_email
terminal.schedule
terminal.juristic_name
terminal.contract_number
terminal.manager
terminal.rent
terminal.rent_finish_date
terminal.collection_zone
terminal.check_phone_number
collection.agent_id
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
collection.created_at
collection.approved_payments_sum
collection.cash_sum
collection.payments_sum
),
'collection.terminal_id' => %w(
collection.terminal_id
terminal.keyword
terminal.address
terminal.version
terminal.issues_started_at
terminal.collected_at
terminal.printer_error
terminal.cash_acceptor_error
terminal.juristic_name
terminal.sector
terminal.contact_name
terminal.contact_phone
terminal.contact_email
terminal.schedule
terminal.juristic_name
terminal.contract_number
terminal.manager
terminal.rent
terminal.rent_finish_date
terminal.collection_zone
terminal.check_phone_number
),
'collection.agent_id' => %w(
collection.agent_id
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
),
'collection.hour' => %w(
collection.hour
),
'collection.day' => %w(
collection.day
),
'collection.month' => %w(
collection.month
)
}
end
|
#groupping ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'app/reports/collections_report.rb', line 25
def groupping
%w(
collection.agent_id
collection.terminal_id
collection.hour
collection.day
collection.month
)
end
|
#tables ⇒ Object
6
7
8
9
10
11
12
|
# File 'app/reports/collections_report.rb', line 6
def tables
@tables ||= {
:collection => Arel::Table.new(:collections),
:terminal => Arel::Table.new(:terminals),
:agent => Arel::Table.new(:agents)
}.with_indifferent_access
end
|