<commit_before>/*
 * Copyright 2017 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package controllers.userJourney

import javax.inject.Inject

import controllers.{CommonPlayDependencies, VatRegistrationController}
import forms.StartDateForm
import models.StartDateModel
import play.api.mvc._

import scala.concurrent.Future

class StartDateController @Inject()(ds: CommonPlayDependencies) extends VatRegistrationController(ds) {

  def show: Action[AnyContent] = authorised(implicit user => implicit request => {
    val form = StartDateForm.form.fill(StartDateModel.empty)
    Ok(views.html.pages.start_date(form))
  })

  val submit = authorised.async {
    implicit user =>
      implicit request => {
        StartDateForm.form.bindFromRequest().fold(
          formWithErrors => {
            Future.successful(BadRequest(views.html.pages.start_date(formWithErrors)))
          }, {
            data => {
              val updatedData = data.dateType match {
                case _ :String  if (StartDateModel.FUTURE_DATE != data.dateType) => data.copy(day = None, month = None, year = None)
                case _ => data
              }
              //call to service
              Future.successful(Redirect(routes.TaxableTurnoverController.show()))
            }
          }
        )
      }
  }<commit_msg>[SCRS-4552  RY | EL ] Bug fixed with controller submit method It was Val, it caused test cases failing, we have fixed defined as def<commit_after>/*
 * Copyright 2017 HM Revenue & Customs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package controllers.userJourney

import javax.inject.Inject

import auth.VatTaxRegime
import controllers.{CommonPlayDependencies, VatRegistrationController}
import forms.StartDateForm
import models.StartDateModel
import play.api.mvc._

import scala.concurrent.Future

class StartDateController @Inject()(ds: CommonPlayDependencies) extends VatRegistrationController(ds) {

  def show: Action[AnyContent] = authorised(implicit user => implicit request => {
    val form = StartDateForm.form.fill(StartDateModel.empty)
    Ok(views.html.pages.start_date(form))
  })

  def submit: Action[AnyContent] = authorised.async {
    implicit user =>
      implicit request => {
        StartDateForm.form.bindFromRequest().fold(
          formWithErrors => {
            Future.successful(BadRequest(views.html.pages.start_date(formWithErrors)))
          }, {
            data => {
              val updatedData = data.dateType match {
                case _ :String  if (StartDateModel.FUTURE_DATE != data.dateType) => data.copy(day = None, month = None, year = None)
                case _ => data
              }
              //call to service
              Future.successful(Redirect(controllers.userJourney.routes.TaxableTurnoverController.show()))
            }
          }
        )
      }
  }
{'fraction_non_alphanumeric': 0.0876923076923077, 'fraction_numerical': 0.005128205128205128, 'mean_word_length': 2.992835209825998, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3134277', 'n_tokens_mistral': 1039, 'n_tokens_neox': 1016, 'n_words': 321}