<commit_before>package controllers.s7_employment

import models.view.CachedClaim
import play.api.mvc.Controller
import play.api.data.Form
import play.api.data.Forms._
import models.domain.LastWage
import utils.helpers.CarersForm._
import controllers.Mappings._
import Employment._
import models.PeriodFromTo

object G4LastWage extends Controller with CachedClaim {
  val form = Form(
    mapping(
      "jobID" -> nonEmptyText,
      "lastPaidDate" -> optional(dayMonthYear.verifying(validDateOnly)),
      "periodCovered" -> optional(
        mapping(
          "from"->dayMonthYear.verifying(validDate),
          "to" -> dayMonthYear.verifying(validDate)
        )(PeriodFromTo.apply)(PeriodFromTo.unapply)),
      "grossPay" -> optional(text),
      "payInclusions" -> optional(text),
      "sameAmountEachTime" -> optional(text),
      call(routes.G4LastWage.present())
    )(LastWage.apply)(LastWage.unapply))

  def present = claiming { implicit claim => implicit request =>
    Ok(views.html.s7_employment.g4_lastWage(form, completedQuestionGroups(LastWage)))
  }

  def submit = claiming { implicit claim => implicit request =>
    form.bindEncrypted.fold(
      formWithErrors => BadRequest(views.html.s7_employment.g4_lastWage(formWithErrors, completedQuestionGroups(LastWage))),
      lastWage => claim.update(lastWage) -> Redirect(routes.G4LastWage.present()))
  }
}<commit_msg>Moved the periodFromTo mapping to Mappings<commit_after>package controllers.s7_employment

import models.view.CachedClaim
import play.api.mvc.Controller
import play.api.data.Form
import play.api.data.Forms._
import models.domain.LastWage
import utils.helpers.CarersForm._
import controllers.Mappings._
import Employment._
import models.PeriodFromTo

object G4LastWage extends Controller with CachedClaim {
  val form = Form(
    mapping(
      "jobID" -> nonEmptyText,
      "lastPaidDate" -> optional(dayMonthYear.verifying(validDateOnly)),
      "periodCovered" -> optional(periodFromTo),
      "grossPay" -> optional(text),
      "payInclusions" -> optional(text),
      "sameAmountEachTime" -> optional(text),
      call(routes.G4LastWage.present())
    )(LastWage.apply)(LastWage.unapply))

  def present = claiming { implicit claim => implicit request =>
    Ok(views.html.s7_employment.g4_lastWage(form, completedQuestionGroups(LastWage)))
  }

  def submit = claiming { implicit claim => implicit request =>
    form.bindEncrypted.fold(
      formWithErrors => BadRequest(views.html.s7_employment.g4_lastWage(formWithErrors, completedQuestionGroups(LastWage))),
      lastWage => claim.update(lastWage) -> Redirect(routes.G4LastWage.present()))
  }
}
{'fraction_non_alphanumeric': 0.11513778784446961, 'fraction_numerical': 0.00604001510003775, 'mean_word_length': 4.430327868852459, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1209482', 'n_tokens_mistral': 823, 'n_tokens_neox': 806, 'n_words': 144}