Browse Source

feat: update labels (lar/incref/letting_allocation_none still pending)

pull/2089/head
natdeanlewissoftwire 2 years ago
parent
commit
c16573227e
  1. 20
      app/services/csv/lettings_log_csv_service.rb

20
app/services/csv/lettings_log_csv_service.rb

@ -177,7 +177,7 @@ module Csv
value value
when "labels" when "labels"
answer_label = get_label(value, attribute, log) answer_label = get_label(value, attribute, log)
answer_label || label_if_boolean_value(value) || label_if_checkbox_value(value) || value answer_label || label_if_boolean_value(value) || YES_OR_BLANK_ATTRIBUTES.include?(attribute) ? yes_or_blank_label(value) : value
end end
end end
end end
@ -185,7 +185,8 @@ module Csv
def get_label(value, attribute, log) def get_label(value, attribute, log)
return LETTYPE_LABELS[value] if attribute == "lettype" return LETTYPE_LABELS[value] if attribute == "lettype"
return IRPRODUCT_LABELS[value] if attribute == "irproduct" return IRPRODUCT_LABELS[value] if attribute == "irproduct"
return label_if_checkbox_value(value) if ILLNESS_TYPES.include?(attribute) return NEWPROP_LABELS[value] if attribute == "newprop"
return conventional_yes_no_label(value) if CONVENTIONAL_YES_NO_ATTRIBUTES.include?(attribute)
log.form log.form
.get_question(attribute, log) .get_question(attribute, log)
@ -197,11 +198,15 @@ module Csv
return "No" if value == false return "No" if value == false
end end
def label_if_checkbox_value(value) def conventional_yes_no_label(value)
return "Yes" if value == 1 return "Yes" if value == 1
return "No" if value.zero? return "No" if value.zero?
end end
def yes_or_blank_label(value)
value == 1 ? "Yes" : nil
end
LETTYPE_LABELS = { LETTYPE_LABELS = {
1 => "Social rent general needs private registered provider", 1 => "Social rent general needs private registered provider",
2 => "Social rent supported housing private registered provider", 2 => "Social rent supported housing private registered provider",
@ -223,7 +228,14 @@ module Csv
3 => "Other intermediate rent product", 3 => "Other intermediate rent product",
}.freeze }.freeze
ILLNESS_TYPES = %w[illness_type_1 illness_type_2 illness_type_3 illness_type_4 illness_type_5 illness_type_6 illness_type_7 illness_type_8 illness_type_9 illness_type_10].freeze NEWPROP_LABELS = {
1 => "Yes",
2 => "No",
}.freeze
CONVENTIONAL_YES_NO_ATTRIBUTES = %w[illness_type_1 illness_type_2 illness_type_3 illness_type_4 illness_type_5 illness_type_6 illness_type_7 illness_type_8 illness_type_9 illness_type_10 refused cbl cap chr letting_allocation_none has_benefits nocharge].freeze
YES_OR_BLANK_ATTRIBUTES = %w[declaration rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow]
ATTRIBUTE_MAPPINGS = { ATTRIBUTE_MAPPINGS = {
"owning_organisation_id" => %w[owning_organisation_name], "owning_organisation_id" => %w[owning_organisation_name],

Loading…
Cancel
Save