diff --git a/app/models/student_loans_data_importer.rb b/app/models/student_loans_data_importer.rb index 977b4fb6af..dc08e80777 100644 --- a/app/models/student_loans_data_importer.rb +++ b/app/models/student_loans_data_importer.rb @@ -28,12 +28,28 @@ def row_to_hash(row) full_name: row.fetch("Full name"), date_of_birth: cast_as_date(row.fetch("Date of birth")), policy_name: row.fetch("Policy name"), - no_of_plans_currently_repaying: row.fetch("No of Plans Currently Repaying"), - plan_type_of_deduction: row.fetch("Plan Type of Deduction"), + no_of_plans_currently_repaying: calculate_no_of_plans_currently_repaying(row.fetch("No of Plans Currently Repaying")), + plan_type_of_deduction: calculate_plan_type_of_deduction(row.fetch("Plan Type of Deduction")), amount: row.fetch("Amount") } end + def calculate_plan_type_of_deduction(value) + if value == "No data" + nil + else + value + end + end + + def calculate_no_of_plans_currently_repaying(value) + if value == "No data" + nil + else + value + end + end + def cast_as_date(string) Date.strptime(string, I18n.t("date.formats.day_month_year")) rescue TypeError, Date::Error