Skip to content

Commit

Permalink
BST-109845 6048 - Add page "Are you VAT registered?" (#1053)
Browse files Browse the repository at this point in the history
* BST-109845 6048 - Add page "Are you VAT registered?". Refactored ForType to be enum.

* BST-109845 6048 - Add page "Are you VAT registered?"
  • Loading branch information
tumakha authored Oct 18, 2024
1 parent fa45218 commit 7265e2d
Show file tree
Hide file tree
Showing 206 changed files with 1,438 additions and 1,022 deletions.
2 changes: 1 addition & 1 deletion app/controllers/FeedbackController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class FeedbackController @Inject() (
"comments" -> f.comments.getOrElse(""),
"satisfaction" -> f.rating.get,
"referenceNumber" -> session.referenceNumber,
"forType" -> session.forType
"forType" -> session.forType.toString
)
)

Expand Down
18 changes: 10 additions & 8 deletions app/controllers/LoginController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import form.PostcodeMapping.customPostcodeMapping
import form.Errors
import models.audit.DownloadPDFAudit
import models.submissions.common.Address
import models.{ForTypes, Session}
import models.ForType
import models.ForType.*
import models.Session
import play.api.Logging
import play.api.data.Form
import play.api.data.Forms._
Expand Down Expand Up @@ -102,11 +104,11 @@ class LoginController @Inject() (
val forTypeFromURL = request.getQueryString("forType")
val form = loginForm.fill(LoginDetails(referenceNumberFromUrl, "", nowInUK))

forTypeFromURL match {
forTypeFromURL.flatMap(ForType.find) match {
case Some(forType) =>
audit.sendExplicitAudit(
"ForRequestedFromContinue",
DownloadPDFAudit(referenceNumberFromUrl, forType, request.uri)
DownloadPDFAudit(referenceNumberFromUrl, forType.toString, request.uri)
)
case _ => Future.successful(Ok(login(form)))
}
Expand Down Expand Up @@ -150,19 +152,19 @@ class LoginController @Inject() (
loginToBackend(hc, ec)(cleanedRefNumber, cleanPostcode, startTime)
.flatMap { case NoExistingDocument(token, forNum, address, isWelsh) =>
auditLogin(referenceNumber, false, address, forNum)
ForTypes.find(forNum) match {
case Some(_) =>
ForType.find(forNum) match {
case Some(forType) =>
session
.start(Session(referenceNumber, forNum, address, token, isWelsh))
.start(Session(referenceNumber, forType, address, token, isWelsh))
.flatMap { _ =>
backendConnector.loadSubmissionDraft(cleanedRefNumber, hc).map {
case Some(_) => Redirect(controllers.routes.SaveAsDraftController.loginToResume)
case _ => Redirect(startPage)
}
}
case None =>
case None =>
session
.start(Session(referenceNumber, forNum, address, token, isWelsh))
.start(Session(referenceNumber, FOR6010, address, token, isWelsh))
.map(_ => Redirect(routes.LoginController.notValidFORType()))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import config.ErrorHandler
import connectors.AddressLookupConnector
import controllers.FORDataCaptureController
import form.aboutYourLeaseOrTenure.AboutTheLandlordForm.aboutTheLandlordForm
import models.{ForTypes, Session}
import models.ForType.*
import models.Session
import navigation.AboutYourLeaseOrTenureNavigator
import play.api.i18n.{I18nSupport, Lang}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents, Request}
Expand Down Expand Up @@ -130,7 +131,7 @@ class AboutYourLandlordController @Inject() (
)

private def getBackLink(answers: Session)(implicit request: Request[AnyContent]): String =
if (answers.forType == ForTypes.for6020)
if (answers.forType == FOR6020)
controllers.aboutYourLeaseOrTenure.routes.TypeOfTenureController.show().url
else
navigator.from match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package controllers.aboutYourLeaseOrTenure
import actions.{SessionRequest, WithSessionRefiner}
import controllers.FORDataCaptureController
import form.aboutYourLeaseOrTenure.CanRentBeReducedOnReviewForm.canRentBeReducedOnReviewForm
import models.ForTypes
import models.ForType.*
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartTwo.updateAboutLeaseOrAgreementPartTwo
import models.submissions.aboutYourLeaseOrTenure.CanRentBeReducedOnReviewDetails
import navigation.AboutYourLeaseOrTenureNavigator
Expand Down Expand Up @@ -70,7 +70,7 @@ class CanRentBeReducedOnReviewController @Inject() (

private def getBackLink(implicit request: SessionRequest[AnyContent]): String =
request.sessionData.forType match {
case ForTypes.for6020 =>
case FOR6020 =>
if (
request.sessionData.aboutLeaseOrAgreementPartTwo
.flatMap(_.intervalsOfRentReview)
Expand All @@ -80,7 +80,7 @@ class CanRentBeReducedOnReviewController @Inject() (
} else {
controllers.aboutYourLeaseOrTenure.routes.IsRentUnderReviewController.show().url
}
case _ => controllers.aboutYourLeaseOrTenure.routes.IntervalsOfRentReviewController.show().url
case _ => controllers.aboutYourLeaseOrTenure.routes.IntervalsOfRentReviewController.show().url
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -21,7 +21,8 @@ import controllers.FORDataCaptureController
import form.aboutYourLeaseOrTenure.CheckYourAnswersAboutYourLeaseOrTenureForm.checkYourAnswersAboutYourLeaseOrTenureForm
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartOne.updateAboutLeaseOrAgreementPartOne
import models.submissions.aboutYourLeaseOrTenure.CheckYourAnswersAboutYourLeaseOrTenure
import models.{ForTypes, Session}
import models.ForType.*
import models.Session
import navigation.AboutYourLeaseOrTenureNavigator
import navigation.identifiers.CheckYourAnswersAboutYourLeaseOrTenureId
import play.api.Logging
Expand Down Expand Up @@ -120,13 +121,13 @@ class CheckYourAnswersAboutYourLeaseOrTenureController @Inject() (
controllers.aboutYourLeaseOrTenure.routes.CurrentRentPayableWithin12MonthsController.show().url
case _ =>
answers.forType match {
case ForTypes.for6010 =>
case FOR6010 =>
controllers.aboutYourLeaseOrTenure.routes.CurrentAnnualRentController.show().url
case ForTypes.for6011 =>
case FOR6011 =>
controllers.aboutYourLeaseOrTenure.routes.TenancyLeaseAgreementExpireController.show().url
case ForTypes.for6076 =>
case FOR6076 =>
controllers.aboutYourLeaseOrTenure.routes.ProvideDetailsOfYourLeaseController.show().url
case _ =>
case _ =>
logger.warn(s"Navigation for CYA about lease without correct selection of conditions by controller")
throw new RuntimeException("Invalid option exception for CYA about lease back link")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -21,7 +21,8 @@ import controllers.FORDataCaptureController
import form.aboutYourLeaseOrTenure.CurrentAnnualRentForm.currentAnnualRentForm
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartOne.updateAboutLeaseOrAgreementPartOne
import models.submissions.common.{AnswerNo, AnswerYes}
import models.{AnnualRent, ForTypes, Session}
import models.{AnnualRent, Session}
import models.ForType.*
import navigation.AboutYourLeaseOrTenureNavigator
import navigation.identifiers.CurrentAnnualRentPageId
import play.api.Logging
Expand Down Expand Up @@ -86,7 +87,7 @@ class CurrentAnnualRentController @Inject() (

private def getBackLink(answers: Session): String =
answers.forType match {
case ForTypes.for6011 =>
case FOR6011 =>
answers.aboutLeaseOrAgreementPartOne.flatMap(_.connectedToLandlord) match {
case Some(AnswerYes) =>
controllers.aboutYourLeaseOrTenure.routes.ConnectedToLandlordDetailsController.show().url
Expand All @@ -95,6 +96,6 @@ class CurrentAnnualRentController @Inject() (
logger.warn(s"Back link for current annual rent page reached with unknown value")
controllers.routes.TaskListController.show().url
}
case _ => controllers.aboutYourLeaseOrTenure.routes.PropertyUseLeasebackArrangementController.show().url
case _ => controllers.aboutYourLeaseOrTenure.routes.PropertyUseLeasebackArrangementController.show().url
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -19,7 +19,8 @@ package controllers.aboutYourLeaseOrTenure
import actions.WithSessionRefiner
import controllers.{FORDataCaptureController, aboutYourLeaseOrTenure}
import form.aboutYourLeaseOrTenure.CurrentRentFirstPaidForm.currentRentFirstPaidForm
import models.{ForTypes, Session}
import models.ForType.*
import models.Session
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartOne.updateAboutLeaseOrAgreementPartOne
import models.submissions.aboutYourLeaseOrTenure.CurrentRentFirstPaid
import models.submissions.common.AnswerYes
Expand Down Expand Up @@ -72,13 +73,13 @@ class CurrentRentFirstPaidController @Inject() (

private def getBackLink(answers: Session): String =
answers.forType match {
case ForTypes.for6011 => controllers.aboutYourLeaseOrTenure.routes.RentIncludesVatController.show().url
case ForTypes.for6020 =>
case FOR6011 => controllers.aboutYourLeaseOrTenure.routes.RentIncludesVatController.show().url
case FOR6020 =>
answers.aboutLeaseOrAgreementPartThree.flatMap(_.throughputAffectsRent).map(_.doesRentVaryToThroughput) match {
case Some(AnswerYes) => aboutYourLeaseOrTenure.routes.ThroughputAffectsRentDetailsController.show().url
case _ => aboutYourLeaseOrTenure.routes.ThroughputAffectsRentController.show().url
}
case _ => controllers.aboutYourLeaseOrTenure.routes.PropertyUseLeasebackArrangementController.show().url
case _ => controllers.aboutYourLeaseOrTenure.routes.PropertyUseLeasebackArrangementController.show().url
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -22,7 +22,8 @@ import form.aboutYourLeaseOrTenure.HowIsCurrentRentFixedForm.howIsCurrentRentFix
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartTwo.updateAboutLeaseOrAgreementPartTwo
import models.submissions.aboutYourLeaseOrTenure.HowIsCurrentRentFixed
import models.submissions.common.{AnswerNo, AnswerYes}
import models.{ForTypes, Session}
import models.ForType.*
import models.Session
import navigation.AboutYourLeaseOrTenureNavigator
import navigation.identifiers.HowIsCurrentRentFixedId
import play.api.Logging
Expand Down Expand Up @@ -77,7 +78,7 @@ class HowIsCurrentRentFixedController @Inject() (

private def getBackLink(answers: Session): String =
answers.forType match {
case ForTypes.for6010 =>
case FOR6010 =>
answers.aboutLeaseOrAgreementPartTwo.flatMap(
_.rentPayableVaryOnQuantityOfBeersDetails.map(_.rentPayableVaryOnQuantityOfBeersDetails.name)
) match {
Expand All @@ -89,15 +90,15 @@ class HowIsCurrentRentFixedController @Inject() (
logger.warn(s"Back link for 6010 rent payable vary beer page reached with unknown value")
controllers.routes.TaskListController.show().url
}
case ForTypes.for6020 | ForTypes.for6045 | ForTypes.for6046 =>
case FOR6020 | FOR6045 | FOR6046 =>
answers.aboutLeaseOrAgreementPartOne.flatMap(_.rentOpenMarketValueDetails.map(_.rentOpenMarketValues)) match {
case Some(AnswerYes) => controllers.aboutYourLeaseOrTenure.routes.RentOpenMarketValueController.show().url
case Some(AnswerNo) => controllers.aboutYourLeaseOrTenure.routes.WhatIsYourRentBasedOnController.show().url
case _ =>
logger.warn(s"Back link for 6020 rent open market value page reached with unknown value")
controllers.routes.TaskListController.show().url
}
case _ =>
case _ =>
answers.aboutLeaseOrAgreementPartTwo.flatMap(
_.rentPayableVaryAccordingToGrossOrNetDetails.map(_.rentPayableVaryAccordingToGrossOrNets.name)
) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers.aboutYourLeaseOrTenure
import actions.{SessionRequest, WithSessionRefiner}
import controllers.FORDataCaptureController
import form.aboutYourLeaseOrTenure.IncludedInYourRentForm.includedInYourRentForm
import models.ForType
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartOne.updateAboutLeaseOrAgreementPartOne
import models.submissions.aboutYourLeaseOrTenure.IncludedInYourRentDetails
import navigation.AboutYourLeaseOrTenureNavigator
Expand All @@ -41,7 +42,7 @@ class IncludedInYourRentController @Inject() (
) extends FORDataCaptureController(mcc)
with I18nSupport {

private def forType(implicit request: SessionRequest[?]): String = request.sessionData.forType
private def forType(implicit request: SessionRequest[?]): ForType = request.sessionData.forType

def show: Action[AnyContent] = (Action andThen withSessionRefiner).async { implicit request =>
Future.successful(
Expand All @@ -52,7 +53,7 @@ class IncludedInYourRentController @Inject() (
case _ => includedInYourRentForm(forType)
},
request.sessionData.toSummary,
request.sessionData.forType,
forType,
navigator.from
)
)
Expand All @@ -67,7 +68,7 @@ class IncludedInYourRentController @Inject() (
includedInYourRentView(
formWithErrors,
request.sessionData.toSummary,
request.sessionData.forType
forType
)
),
data => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package controllers.aboutYourLeaseOrTenure
import actions.{SessionRequest, WithSessionRefiner}
import controllers.{FORDataCaptureController, aboutYourLeaseOrTenure}
import form.aboutYourLeaseOrTenure.IsRentUnderReviewForm.isRentUnderReviewForm
import models.ForTypes
import models.ForType
import models.ForType.*
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartThree
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartThree.updateAboutLeaseOrAgreementPartThree
import models.submissions.common.AnswersYesNo
Expand Down Expand Up @@ -80,8 +81,8 @@ class IsRentUnderReviewController @Inject() (

private def getBackLink(implicit request: SessionRequest[AnyContent]): String =
request.sessionData.forType match {
case ForTypes.for6045 | ForTypes.for6046 => routes.MethodToFixCurrentRentController.show().url
case _ => routes.IntervalsOfRentReviewController.show().url
case FOR6045 | FOR6046 => routes.MethodToFixCurrentRentController.show().url
case _ => routes.IntervalsOfRentReviewController.show().url
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package controllers.aboutYourLeaseOrTenure
import actions.{SessionRequest, WithSessionRefiner}
import controllers.{FORDataCaptureController, aboutYourLeaseOrTenure}
import form.aboutYourLeaseOrTenure.LegalOrPlanningRestrictionsForm.legalPlanningRestrictionsForm
import models.ForTypes
import models.ForType
import models.ForType.*
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartTwo.updateAboutLeaseOrAgreementPartTwo
import models.submissions.aboutYourLeaseOrTenure.LegalOrPlanningRestrictions
import models.submissions.common.{AnswerNo, AnswerYes}
Expand Down Expand Up @@ -77,7 +78,7 @@ class LegalOrPlanningRestrictionsController @Inject() (

private def getBackLink(implicit request: SessionRequest[AnyContent]): String =
request.sessionData.forType match {
case ForTypes.for6020 =>
case FOR6020 =>
request.sessionData.aboutLeaseOrAgreementPartTwo
.flatMap(_.payACapitalSumDetails)
.map(_.capitalSumOrPremium) match {
Expand All @@ -87,14 +88,14 @@ class LegalOrPlanningRestrictionsController @Inject() (
logger.warn(s"Back link for pay capital sum page reached with unknown benefits given value")
controllers.routes.TaskListController.show().url
}
case ForTypes.for6045 | ForTypes.for6046 =>
case FOR6045 | FOR6046 =>
request.sessionData.aboutLeaseOrAgreementPartTwo
.flatMap(_.payACapitalSumDetails)
.map(_.capitalSumOrPremium) match {
case Some(AnswerYes) => aboutYourLeaseOrTenure.routes.CapitalSumDescriptionController.show().url
case _ => aboutYourLeaseOrTenure.routes.PayACapitalSumController.show().url
}
case _ => aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show().url
case _ => aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show().url
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 HM Revenue & Customs
* Copyright 2024 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.
Expand All @@ -19,7 +19,8 @@ package controllers.aboutYourLeaseOrTenure
import actions.WithSessionRefiner
import controllers.FORDataCaptureController
import form.aboutYourLeaseOrTenure.PayACapitalSumForm.payACapitalSumForm
import models.{ForTypes, Session}
import models.ForType.*
import models.Session
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartTwo.updateAboutLeaseOrAgreementPartTwo
import models.submissions.aboutYourLeaseOrTenure.PayACapitalSumDetails
import models.submissions.common.{AnswerNo, AnswerYes}
Expand Down Expand Up @@ -86,7 +87,7 @@ class PayACapitalSumController @Inject() (
case "TL" => controllers.routes.TaskListController.show().url + "#pay-a-capital-sum"
case _ =>
answers.forType match {
case ForTypes.for6020 =>
case FOR6020 =>
answers.aboutLeaseOrAgreementPartThree.flatMap(_.benefitsGiven).map(_.benefitsGiven) match {
case Some(AnswerYes) =>
controllers.aboutYourLeaseOrTenure.routes.BenefitsGivenDetailsController.show().url
Expand All @@ -95,11 +96,11 @@ class PayACapitalSumController @Inject() (
logger.warn(s"Back link for pay capital sum page reached with unknown benefits given value")
controllers.routes.TaskListController.show().url
}
case ForTypes.for6045 | ForTypes.for6046 =>
case FOR6045 | FOR6046 =>
if answers.aboutLeaseOrAgreementPartFour.flatMap(_.isGivenRentFreePeriod).contains(AnswerYes) then
controllers.aboutYourLeaseOrTenure.routes.RentFreePeriodDetailsController.show().url
else controllers.aboutYourLeaseOrTenure.routes.IsGivenRentFreePeriodController.show().url
case _ =>
case _ =>
answers.aboutLeaseOrAgreementPartTwo.flatMap(
_.tenantAdditionsDisregardedDetails.map(_.tenantAdditionalDisregarded.name)
) match {
Expand Down
Loading

0 comments on commit 7265e2d

Please sign in to comment.