Class: Helper::XmlEnumsToOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/helper/xml_enums_to_output.rb

Constant Summary collapse

RATINGS =
{
  "0" => "N/A",
  "1" => "Very Poor",
  "2" => "Poor",
  "3" => "Average",
  "4" => "Good",
  "5" => "Very Good",
}.freeze
BUILT_FORM =
{
  "1" => "Detached",
  "2" => "Semi-Detached",
  "3" => "End-Terrace",
  "4" => "Mid-Terrace",
  "5" => "Enclosed End-Terrace",
  "6" => "Enclosed Mid-Terrace",
  "NR" => "Not Recorded",
}.freeze
SAP_ENERGY_TARIFF =
{
  "1" => "standard tariff",
  "2" => "off-peak 7 hour",
  "3" => "off-peak 10 hour",
  "4" => "24 hour",
  "ND" => "not applicable",
}.freeze
RDSAP_ENERGY_TARIFF =
{
  "1" => "dual",
  "2" => "Single",
  "3" => "Unknown",
  "4" => "dual (24 hour)",
  "5" => "off-peak 18 hour",
}.freeze
RDSAP_MAIN_FUEL =
{
  "0" =>
    "To be used only when there is no heating/hot-water system or data is from a community network",
  "1" =>
    "mains gas - this is for backwards compatibility only and should not be used",
  "2" =>
    "LPG - this is for backwards compatibility only and should not be used",
  "3" => "bottled LPG",
  "4" =>
    "oil - this is for backwards compatibility only and should not be used",
  "5" => "anthracite",
  "6" => "wood logs",
  "7" => "bulk wood pellets",
  "8" => "wood chips",
  "9" => "dual fuel - mineral + wood",
  "10" =>
    "electricity - this is for backwards compatibility only and should not be used",
  "11" =>
    "waste combustion - this is for backwards compatibility only and should not be used",
  "12" =>
    "biomass - this is for backwards compatibility only and should not be used",
  "13" =>
    "biogas - landfill - this is for backwards compatibility only and should not be used",
  "14" =>
    "house coal - this is for backwards compatibility only and should not be used",
  "15" => "smokeless coal",
  "16" => "wood pellets in bags for secondary heating",
  "17" => "LPG special condition",
  "18" => "B30K (not community)",
  "19" => "bioethanol",
  "20" => "mains gas (community)",
  "21" => "LPG (community)",
  "22" => "oil (community)",
  "23" => "B30D (community)",
  "24" => "coal (community)",
  "25" => "electricity (community)",
  "26" => "mains gas (not community)",
  "27" => "LPG (not community)",
  "28" => "oil (not community)",
  "29" => "electricity (not community)",
  "30" => "waste combustion (community)",
  "31" => "biomass (community)",
  "32" => "biogas (community)",
  "33" => "house coal (not community)",
  "34" => "biodiesel from any biomass source",
  "35" => "biodiesel from used cooking oil only",
  "36" => "biodiesel from vegetable oil only (not community)",
  "37" => "appliances able to use mineral oil or liquid biofuel",
  "51" => "biogas (not community)",
  "56" =>
    "heat from boilers that can use mineral oil or biodiesel (community)",
  "57" =>
    "heat from boilers using biodiesel from any biomass source (community)",
  "58" => "biodiesel from vegetable oil only (community)",
  "99" => "from heat network data (community)",
}.freeze
SAP_MAIN_FUEL =
{
  "1" => "Gas: mains gas",
  "2" => "Gas: bulk LPG",
  "3" => "Gas: bottled LPG",
  "4" => "Oil: heating oil",
  "7" => "Gas: biogas",
  "8" => "LNG",
  "9" => "LPG subject to Special Condition 18",
  "10" => "Solid fuel: dual fuel appliance (mineral and wood)",
  "11" => "Solid fuel: house coal",
  "12" => "Solid fuel: manufactured smokeless fuel",
  "15" => "Solid fuel: anthracite",
  "20" => "Solid fuel: wood logs",
  "21" => "Solid fuel: wood chips",
  "22" => "Solid fuel: wood pellets (in bags, for secondary heating)",
  "23" =>
    "Solid fuel: wood pellets (bulk supply in bags, for main heating)",
  "36" => "Electricity: electricity sold to grid",
  "37" => "Electricity: electricity displaced from grid",
  "39" => "Electricity: electricity, unspecified tariff",
  "41" => "Community heating schemes: heat from electric heat pump",
  "42" => "Community heating schemes: heat from boilers - waste combustion",
  "43" => "Community heating schemes: heat from boilers - biomass",
  "44" => "Community heating schemes: heat from boilers - biogas",
  "45" => "Community heating schemes: waste heat from power stations",
  "46" => "Community heating schemes: geothermal heat source",
  "48" => "Community heating schemes: heat from CHP",
  "49" => "Community heating schemes: electricity generated by CHP",
  "50" =>
    "Community heating schemes: electricity for pumping in distribution network",
  "51" => "Community heating schemes: heat from mains gas",
  "52" => "Community heating schemes: heat from LPG",
  "53" => "Community heating schemes: heat from oil",
  "54" => "Community heating schemes: heat from coal",
  "55" => "Community heating schemes: heat from B30D",
  "56" =>
    "Community heating schemes: heat from boilers that can use mineral oil or biodiesel",
  "57" =>
    "Community heating schemes: heat from boilers using biodiesel from any biomass source",
  "58" => "Community heating schemes: biodiesel from vegetable oil only",
  "72" => "biodiesel from used cooking oil only",
  "73" => "biodiesel from vegetable oil only",
  "74" => "appliances able to use mineral oil or liquid biofuel",
  "75" => "B30K",
  "76" => "bioethanol from any biomass source",
  "99" => "Community heating schemes: special fuel",
}.freeze
RDSAP_GLAZED_TYPE =
{
  "1" => "double glazing installed before 2002",
  "2" => "double glazing installed during or after 2002",
  "3" => "double glazing, unknown install date",
  "4" => "secondary glazing",
  "5" => "single glazing",
  "6" => "triple glazing",
  "7" => "double, known data",
  "8" => "triple, known data",
  "ND" => "not defined",
}.freeze
RDSAP_GLAZED_AREA =
{
  "1" => "Normal",
  "2" => "More Than Typical",
  "3" => "Less Than Typical",
  "4" => "Much More Than Typical",
  "5" => "Much Less Than Typical",
  "ND" => "Not Defined",
}.freeze
TENURE =
{
  "1" => "Owner-occupied",
  "2" => "Rented (social)",
  "3" => "Rented (private)",
  "ND" =>
    "Not defined - use in the case of a new dwelling for which the intended tenure in not known. It is not to be used for an existing dwelling",
}.freeze
TRANSACTION_TYPE =
{
  "1" => "marketed sale",
  "2" => "non marketed sale",
  "3" =>
    "rental (social) - this is for backwards compatibility only and should not be used",
  "4" =>
    "rental (private) - this is for backwards compatibility only and should not be used",
  "5" => "not sale or rental",
  "6" => "new dwelling",
  "7" =>
    "not recorded - this is for backwards compatibility only and should not be used",
  "8" => "rental",
  "9" => "assessment for green deal",
  "10" => "following green deal",
  "11" => "FiT application",
  "12" => "Stock condition survey",
  "12RdSAP" => "RHI application",
  "13RdSAP" => "ECO assessment",
  "14RdSAP" => "Stock condition survey",
}.freeze
CONSTRUCTION_AGE_BAND =
{
  "A" => "England and Wales: before 1900",
  "B" => "England and Wales: 1900-1929",
  "C" => "England and Wales: 1930-1949",
  "D" => "England and Wales: 1950-1966",
  "E" => "England and Wales: 1967-1975",
  "F" => "England and Wales: 1976-1982",
  "G" => "England and Wales: 1983-1990",
  "H" => "England and Wales: 1991-1995",
  "I" => "England and Wales: 1996-2002",
  "J" => "England and Wales: 2003-2006",
  "K" => "England and Wales: 2007-2011",
  "K-pre-17.0" => "England and Wales: 2007 onwards",
  "K-12.0" => "Post-2006",
  "L" => "England and Wales: 2012 onwards",
  "0" => "Not applicable",
  "NR" => "Not recorded",
}.freeze
PROPERTY_TYPE =
{
  "0" => "House",
  "1" => "Bungalow",
  "2" => "Flat",
  "3" => "Maisonette",
  "4" => "Park home",
}.freeze
HEAT_LOSS_CORRIDOR =
{
  "0" => "no corridor",
  "1" => "heated corridor",
  "2" => "unheated corridor",
}.freeze
MECHANICAL_VENTILATION =
{
  "0" => "natural",
  "1" => "mechanical, supply and extract",
  "2" => "mechanical, extract only",
  "0-pre12.0" => "none",
  "1-pre12.0" => "mechanical - heat recovering",
  "2-pre12.0" => "mechanical - non recovering",
}.freeze
CEPC_TRANSACTION_TYPE =
{
  "1" => "Mandatory issue (Marketed sale)",
  "2" => "Mandatory issue (Non-marketed sale)",
  "3" => "Mandatory issue (Property on construction).",
  "4" => "Mandatory issue (Property to let).",
  "5" => "Voluntary re-issue (A valid EPC is already lodged).",
  "6" => "Voluntary (No legal requirement for an EPC).",
  "7" => "Not recorded.",
}.freeze

Class Method Summary collapse

Class Method Details

.cepc_transaction_type(value) ⇒ Object



393
394
395
# File 'lib/helper/xml_enums_to_output.rb', line 393

def self.cepc_transaction_type(value)
  CEPC_TRANSACTION_TYPE[value] || value
end

.construction_age_band_lookup(value, schema_type, report_type = 0) ⇒ Object



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/helper/xml_enums_to_output.rb', line 276

def self.construction_age_band_lookup(value, schema_type, report_type = 0)
  types_of_sap_pre17 = %w[
    SAP-Schema-16.3
    SAP-Schema-16.2
    SAP-Schema-16.1
    SAP-Schema-16.0
    SAP-Schema-15.0
    SAP-Schema-14.2
    SAP-Schema-14.1
    SAP-Schema-14.0
    SAP-Schema-13.0
    SAP-Schema-12.0
    SAP-Schema-11.2
    SAP-Schema-11.0
  ].freeze

  schemes_that_use_not_recorded = %w[
    SAP-Schema-16.3
    SAP-Schema-16.2
    SAP-Schema-16.1
    RdSAP-Schema-20.0.0
    RdSAP-Schema-19.0
    RdSAP-Schema-18.0
    RdSAP-Schema-17.1
    RdSAP-Schema-17.0
    RdSAP-Schema-NI-20.0.0
    RdSAP-Schema-NI-19.0
    RdSAP-Schema-NI-18.0
    RdSAP-Schema-NI-17.4
    RdSAP-Schema-NI-17.3
  ]

  schemes_that_use_l = %w[
    SAP-Schema-18.0.0
    SAP-Schema-17.1
    SAP-Schema-17.0
    RdSAP-Schema-20.0.0
    RdSAP-Schema-19.0
    RdSAP-Schema-18.0
    RdSAP-Schema-17.1
    RdSAP-Schema-17.0
    RdSAP-Schema-NI-20.0.0
    RdSAP-Schema-NI-19.0
    RdSAP-Schema-NI-18.0
    RdSAP-Schema-NI-17.4
    RdSAP-Schema-NI-17.3
  ]

  schemes_that_use_0 = %w[
    SAP-Schema-16.3
    SAP-Schema-16.2
    SAP-Schema-16.1
    SAP-Schema-16.0
    SAP-Schema-15.0
    SAP-Schema-14.2
    SAP-Schema-14.1
    SAP-Schema-14.0
    SAP-Schema-13.0
    SAP-Schema-12.0
    RdSAP-Schema-20.0.0
    RdSAP-Schema-19.0
    RdSAP-Schema-18.0
    RdSAP-Schema-17.1
    RdSAP-Schema-17.0
    RdSAP-Schema-NI-20.0.0
    RdSAP-Schema-NI-19.0
    RdSAP-Schema-NI-18.0
    RdSAP-Schema-NI-17.4
    RdSAP-Schema-NI-17.3
  ]

  if value == "K" && schema_type == "SAP-Schema-12.0" && report_type == 2
    return CONSTRUCTION_AGE_BAND["K-12.0"]
  end

  if value == "K" && types_of_sap_pre17.include?(schema_type)
    return CONSTRUCTION_AGE_BAND["K-pre-17.0"]
  end

  if value == "NR" &&
      !schemes_that_use_not_recorded.include?(schema_type) ||
      report_type == 3
    return value
  end

  return value if value == "L" && !schemes_that_use_l.include?(schema_type)

  if value == "0" && !schemes_that_use_0.include?(schema_type) ||
      report_type == 3
    return value
  end

  value == "" ? nil : CONSTRUCTION_AGE_BAND[value] || value
end

.energy_rating_string(value) ⇒ Object



235
236
237
# File 'lib/helper/xml_enums_to_output.rb', line 235

def self.energy_rating_string(value)
  RATINGS[value]
end

.energy_tariff(value, report_type = "2") ⇒ Object



239
240
241
242
243
244
245
246
# File 'lib/helper/xml_enums_to_output.rb', line 239

def self.energy_tariff(value, report_type = "2")
  case report_type.to_s
  when "3"
    SAP_ENERGY_TARIFF[value] || value
  when "2"
    RDSAP_ENERGY_TARIFF[value] || value
  end
end

.glazed_area_rdsap(value) ⇒ Object



256
257
258
# File 'lib/helper/xml_enums_to_output.rb', line 256

def self.glazed_area_rdsap(value)
  RDSAP_GLAZED_AREA[value]
end

.glazed_type_rdsap(value) ⇒ Object



260
261
262
# File 'lib/helper/xml_enums_to_output.rb', line 260

def self.glazed_type_rdsap(value)
  RDSAP_GLAZED_TYPE[value]
end

.heat_loss_corridor(value) ⇒ Object



375
376
377
# File 'lib/helper/xml_enums_to_output.rb', line 375

def self.heat_loss_corridor(value)
  HEAT_LOSS_CORRIDOR[value] || value
end

.main_fuel_rdsap(value) ⇒ Object



248
249
250
# File 'lib/helper/xml_enums_to_output.rb', line 248

def self.main_fuel_rdsap(value)
  RDSAP_MAIN_FUEL[value]
end

.main_fuel_sap(value) ⇒ Object



252
253
254
# File 'lib/helper/xml_enums_to_output.rb', line 252

def self.main_fuel_sap(value)
  SAP_MAIN_FUEL[value]
end

.mechanical_ventilation(value, schema_type, report_type = 0) ⇒ Object



379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/helper/xml_enums_to_output.rb', line 379

def self.mechanical_ventilation(value, schema_type, report_type = 0)
  types_of_sap_pre12 = %w[
    SAP-Schema-11.2
    SAP-Schema-11.0
    SAP-Schema-10.2
  ].freeze

  if types_of_sap_pre12.include?(schema_type) && report_type == 2
    return MECHANICAL_VENTILATION["#{value}-pre12.0"]
  end

  MECHANICAL_VENTILATION[value] || value
end

.property_type(value) ⇒ Object



371
372
373
# File 'lib/helper/xml_enums_to_output.rb', line 371

def self.property_type(value)
  PROPERTY_TYPE[value] || value
end

.tenure(value) ⇒ Object



264
265
266
# File 'lib/helper/xml_enums_to_output.rb', line 264

def self.tenure(value)
  TENURE[value] || value
end

.transaction_type(value, report_type = "2") ⇒ Object



268
269
270
271
272
273
274
# File 'lib/helper/xml_enums_to_output.rb', line 268

def self.transaction_type(value, report_type = "2")
  if report_type.to_s == "2" && value.to_i >= 12
    TRANSACTION_TYPE["#{value}RdSAP"]
  else
    TRANSACTION_TYPE[value] || value
  end
end

.xml_value_to_string(number) ⇒ Object



231
232
233
# File 'lib/helper/xml_enums_to_output.rb', line 231

def self.xml_value_to_string(number)
  BUILT_FORM[number]
end