Class: ReportsManager::SiteUPCSFormReport
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- ReportsManager::SiteUPCSFormReport
- Defined in:
- app/services/reports_manager/site_upcs_form_report.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(user_id, property_id, report_type) ⇒ SiteUPCSFormReport
constructor
A new instance of SiteUPCSFormReport.
Methods inherited from ApplicationService
Constructor Details
#initialize(user_id, property_id, report_type) ⇒ SiteUPCSFormReport
Returns a new instance of SiteUPCSFormReport.
5 6 7 8 9 |
# File 'app/services/reports_manager/site_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 |
# File 'app/services/reports_manager/site_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('ST') header = [ 'Inspectable Item', 'Observable Deficiency', 'NOD', 'Level 1', 'Level 2', 'Level 3', 'NA', 'H & S' ] data = [] data.push({ 'header-row1' => property['property_name'] + ' - UPCS Form - Site', 'header-row4' => 'Inspection Date: ' + inspection_date }) item_def.each do |it_de| type = it_de['type'] temp = {} 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? 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'] 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 view_data = {} view_data['headers'] = header view_data['data'] = data view_data['report_title'] = 'Uniform Physical Condition Standards - Comprehensive Listing - Inspectable Area: Site' view_data['report_filename'] = property_name + '-UPCS-Form-Site' view_data['work_sheet_name'] = 'Inspectable Area - Site' view_data['user_id'] = @user_id view_data['freeze_header'] = true view_data end |