Class: ReportsManager::CommonAreaUPCSFormReport
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- ReportsManager::CommonAreaUPCSFormReport
- Defined in:
- app/services/reports_manager/common_area_upcs_form_report.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(user_id, property_id, report_type) ⇒ CommonAreaUPCSFormReport
constructor
A new instance of CommonAreaUPCSFormReport.
Methods inherited from ApplicationService
Constructor Details
#initialize(user_id, property_id, report_type) ⇒ CommonAreaUPCSFormReport
Returns a new instance of CommonAreaUPCSFormReport.
5 6 7 8 9 |
# File 'app/services/reports_manager/common_area_upcs_form_report.rb', line 5 def initialize(user_id, property_id, report_type) @user_id = user_id @property_id = property_id @report_type = report_type end |
Instance Method Details
#call ⇒ Object
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 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/services/reports_manager/common_area_upcs_form_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 = InspectionDetail.where(property_id: @property_id) item_def = DeficiencyDefinition.get_details_with_area('CA') buildings = Building.where(property_id: @property_id) header = [ 'Building No', 'Inspectable Item', 'Observable Deficiency', 'NOD', 'Level 1', 'Level 2', 'Level 3', 'NA', 'H & S' ] data = [] buildings.each do |building| data.push({ 'header-row1' => property['property_name'] + ' - UPCS Form - Unit', 'header-row2' => 'Building Name: ' + building['building_name'], 'header-row4' => 'Inspection Date: ' + inspection_date }) item_def.each do |it_de| type = it_de['type'] temp = {} temp['Building No'] = building['building_name'] temp['Inspectable Item'] = it_de['inspectable_item_title'] temp['Observable Deficiency'] = it_de['deficiency_title'] temp['H & S'] = type == 'LT' ? 'LT' : 'NLT' temp['NOD'] = '' temp['Level 1'] = '' temp['Level 2'] = '' temp['Level 3'] = '' temp['NA'] = '' details.each do |detail| if detail['inspectable_item_id'] == it_de['inspectable_item_id'] && detail['deficiency_definition_id'].nil? && (detail['building_id'] == building['old_id'] || detail['building_id'] == building['id']) prop = detail['properties'] status = prop['status'] if status == 'NOD' temp['NOD'] = 'X' elsif status == 'N/A' temp['NA'] = 'X' end elsif detail['inspectable_item_id'] == it_de['inspectable_item_id'] && detail['deficiency_definition_id'] == it_de['id'] && (detail['building_id'] == building['old_id'] || detail['building_id'] == building['id']) prop = detail['properties'] level = prop['level'] if level == 'L1' temp['Level 1'] = 'X' elsif level == 'L2' temp['Level 2'] = 'X' elsif level == 'L3' temp['Level 3'] = 'X' end end end temp['NOD'] = 'X' if temp['Level 1'].empty? && temp['Level 2'].empty? && temp['Level 3'].empty? data.push(temp) end data.push([]) end view_data = {} view_data['headers'] = header view_data['data'] = data view_data['report_title'] = 'Uniform Physical Condition Standards - Comprehensive Listing - Inspectable Area: Common Area' view_data['report_filename'] = property['property_name'] + '-UPCS-Form-Common Area' view_data['work_sheet_name'] = 'Inspectable Area - Common Area' view_data['user_id'] = @user_id view_data['freeze_header'] = true view_data end |