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
|
# File 'app/services/reports_manager/property_fixed_assets_report.rb', line 11
def call
property = Property.find_by_id(@property_id)
property_name = property['property_name'].upcase
inspection_date = ApplicationHelper.inspection_date_for_reports(property)
details = FixedAsset.where(property_id: @property_id)
= [
'Line',
'Building No',
'Unit No',
'Type',
'Make',
'Model',
'Serial Number',
'Bar Code Number',
'Condition',
'Updated Date'
]
data = []
if details.present?
index = 1
details.each do |detail|
building = Building.find_by_old_id(detail['building_id']) || Building.find_by(id:detail['building_id'])
unit = Unit.find_by_old_id(detail['unit_id']) || Unit.find_by(id:detail['unit_id'])
next unless building.present? && unit.present?
temp = {}
temp['Line'] = index
temp['Building No'] = building.present? ? building.building_name : ''
temp['Unit No'] = unit.present? ? unit.unit_name : ''
temp['Type'] = detail['type']
temp['Make'] = detail['make']
temp['Model'] = detail['model']
temp['Serial Number'] = detail['serial_number']
temp['Bar Code Number'] = detail['usig_tag_number']
temp['Condition'] = detail['condition']
temp['Updated Date'] = detail['app_updated_at'] ? detail['app_updated_at'].to_date.strftime("%b %d, %Y") : detail['updated_at'].to_date.strftime("%b %d, %Y")
temp['sort_key'] = (temp['Building No'] + ' ' + temp['Unit No']).downcase
data.push(temp)
end
end
data = custom_sort(data, 'sort_key')
view_data = {}
view_data['headers'] =
view_data['data'] = data
view_data['report_title'] = property_name
view_data['report_sub_title'] = 'Inspection Date: ' + inspection_date
view_data['report_filename'] = property_name + '-Fixed_Assets_Excel'
view_data['work_sheet_name'] = 'fixed-assets'
view_data['user_id'] = @user_id
view_data['freeze_header'] = true
view_data
end
|