Skip to content

Commit e69f89e

Browse files
committed
Merge branch 'main' into DTR-1719
# Conflicts: # app/handlers/ErrorHandler.scala # conf/app.routes # conf/application.conf # conf/messages.en
2 parents 122310d + 7e29f03 commit e69f89e

40 files changed

+1354
-837
lines changed

app/config/FrontendAppConfig.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,8 @@ class FrontendAppConfig @Inject() (configuration: Configuration) {
6060
val cacheTtl: Long = configuration.get[Int]("mongodb.timeToLiveInSeconds")
6161

6262
lazy val howToPayUrl: String = configuration.get[String]("urls.howToPay")
63+
64+
lazy val hmrcOnlineServiceDeskUrl: String = configuration.get[String]("urls.hmrcOnlineServiceDesk")
65+
lazy val govUKUrl: String = configuration.get[String]("urls.govUK")
6366
}
6467

app/connectors/StampDutyLandTaxConnector.scala

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,11 @@ class StampDutyLandTaxConnector @Inject()(http: HttpClientV2,
5959
Future.failed(e)
6060
}
6161

62-
def getReturns(status: Option[String], pageType: Option[String], deletionFlag: Boolean)
63-
(implicit hc: HeaderCarrier, request: DataRequest[_]): Future[SdltReturnRecordResponse] =
62+
def getReturns(request: SdltReturnRecordRequest)
63+
(implicit hc: HeaderCarrier): Future[SdltReturnRecordResponse] =
6464
http
6565
.post(getReturnsUrl)
66-
.withBody(Json.toJson(
67-
SdltReturnRecordRequest(
68-
storn = request.storn,
69-
status = status,
70-
deletionFlag = deletionFlag,
71-
pageType = pageType,
72-
pageNumber = None))
66+
.withBody(Json.toJson(request)
7367
)
7468
.execute[Either[UpstreamErrorResponse, SdltReturnRecordResponse]]
7569
.flatMap {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2025 HM Revenue & Customs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package controllers
18+
19+
import config.FrontendAppConfig
20+
import play.api.i18n.I18nSupport
21+
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
22+
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
23+
import views.html.PageNotFoundView
24+
25+
import javax.inject.Inject
26+
27+
class PageNotFoundController @Inject()(
28+
val controllerComponents: MessagesControllerComponents,
29+
view: PageNotFoundView
30+
)(implicit appConfig: FrontendAppConfig) extends FrontendBaseController with I18nSupport {
31+
32+
def onPageLoad: Action[AnyContent] = Action { implicit request =>
33+
Ok(view())
34+
}
35+
}

app/controllers/manage/AtAGlanceController.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import controllers.routes.JourneyRecoveryController
3030
import controllers.manage.routes.*
3131
import viewmodels.manage.{AgentDetailsViewModel, FeedbackViewModel, HelpAndContactViewModel, ReturnsManagementViewModel}
3232
import AtAGlanceController.*
33+
import models.SdltReturnTypes.{IN_PROGRESS_RETURNS, IN_PROGRESS_RETURNS_DUE_FOR_DELETION, SUBMITTED_RETURNS_DUE_FOR_DELETION}
3334
import models.manage.AtAGlanceViewModel
3435

3536
import scala.concurrent.ExecutionContext
@@ -53,11 +54,11 @@ class AtAGlanceController@Inject()(
5354

5455
(for {
5556
agentsCount <- stampDutyLandTaxService.getAgentCount
56-
returnsInProgress <- stampDutyLandTaxService.getInProgressReturns
57-
submittedReturns <- stampDutyLandTaxService.getSubmittedReturns
58-
submittedReturnsDueForDeletion <- stampDutyLandTaxService.getSubmittedReturnsDueForDeletion
59-
inProgressReturnsDueForDeletion <- stampDutyLandTaxService.getInProgressReturnsDueForDeletion
60-
returnsDueForDeletion = (submittedReturnsDueForDeletion ++ inProgressReturnsDueForDeletion).sortBy(_.purchaserName)
57+
returnsInProgress <- stampDutyLandTaxService.getReturnsByTypeViewModel(request.storn, IN_PROGRESS_RETURNS, None)
58+
submittedReturns <- stampDutyLandTaxService.getSubmittedReturnsViewModel(request.storn, None)
59+
submittedReturnsDueForDeletion <- stampDutyLandTaxService.getReturnsByTypeViewModel(request.storn, SUBMITTED_RETURNS_DUE_FOR_DELETION, None)
60+
inProgressReturnsDueForDeletion <- stampDutyLandTaxService.getReturnsByTypeViewModel(request.storn, IN_PROGRESS_RETURNS_DUE_FOR_DELETION, None)
61+
returnsDueForDeletionRows = (submittedReturnsDueForDeletion.rows ++ inProgressReturnsDueForDeletion.rows).sortBy(_.purchaserName)
6162
} yield {
6263

6364
Ok(view(
@@ -66,7 +67,7 @@ class AtAGlanceController@Inject()(
6667
name = name,
6768
inProgressReturns = returnsInProgress,
6869
submittedReturns = submittedReturns,
69-
dueForDeletionReturns = returnsDueForDeletion,
70+
dueForDeletionReturns = returnsDueForDeletionRows,
7071
agentsCount = agentsCount
7172
)
7273
))

app/controllers/manage/DueForDeletionReturnsController.scala

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,72 +17,70 @@
1717
package controllers.manage
1818

1919
import controllers.actions.*
20+
import controllers.manage.routes.*
21+
import controllers.routes.JourneyRecoveryController
22+
import models.SdltReturnTypes.{IN_PROGRESS_RETURNS_DUE_FOR_DELETION, SUBMITTED_RETURNS_DUE_FOR_DELETION}
23+
import navigation.Navigator
24+
import play.api.Logging
2025
import play.api.i18n.I18nSupport
2126
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
27+
import services.StampDutyLandTaxService
2228
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
23-
import controllers.routes.JourneyRecoveryController
24-
import play.api.{Logger, Logging}
25-
import uk.gov.hmrc.govukfrontend.views.viewmodels.pagination.Pagination
26-
27-
import javax.inject.{Inject, Singleton}
28-
import navigation.Navigator
2929
import utils.PaginationHelper
30-
import services.StampDutyLandTaxService
31-
import viewmodels.manage.deletedReturns.SdltDeletedSubmittedReturnsViewModel._
32-
import viewmodels.manage.deletedReturns.SdltDeletedInProgressReturnViewRow._
33-
import viewmodels.manage.deletedReturns.PaginatedDeletedSubmittedReturnsViewModel
34-
import viewmodels.manage.deletedReturns.PaginatedDeletedInProgressReturnsViewModel
3530
import views.html.manage.DueForDeletionReturnsView
36-
import controllers.manage.routes._
3731

32+
import javax.inject.{Inject, Singleton}
3833
import scala.concurrent.ExecutionContext
3934

4035
@Singleton
4136
class DueForDeletionReturnsController @Inject()(
42-
val controllerComponents: MessagesControllerComponents,
43-
stampDutyLandTaxService: StampDutyLandTaxService,
44-
identify: IdentifierAction,
45-
getData: DataRetrievalAction,
46-
requireData: DataRequiredAction,
47-
stornRequiredAction: StornRequiredAction,
48-
navigator: Navigator,
49-
view: DueForDeletionReturnsView
50-
)(implicit executionContext: ExecutionContext) extends FrontendBaseController with I18nSupport with Logging with PaginationHelper {
37+
val controllerComponents: MessagesControllerComponents,
38+
stampDutyLandTaxService: StampDutyLandTaxService,
39+
identify: IdentifierAction,
40+
getData: DataRetrievalAction,
41+
requireData: DataRequiredAction,
42+
stornRequiredAction: StornRequiredAction,
43+
navigator: Navigator,
44+
view: DueForDeletionReturnsView
45+
)(implicit executionContext: ExecutionContext) extends FrontendBaseController with I18nSupport with Logging with PaginationHelper {
5146

5247
def onPageLoad(inProgressIndex: Option[Int], submittedIndex: Option[Int]): Action[AnyContent] =
5348
(identify andThen getData andThen requireData andThen stornRequiredAction).async { implicit request =>
49+
logger.info(s"[DueForDeletionReturnsController][onPageLoad] :: ${inProgressIndex} - ${submittedIndex}")
5450

5551
val outOfScopeUrlSelector: String = DueForDeletionReturnsController.onPageLoad(Some(1), Some(1)).url
5652

5753
lazy val inProgressUrlSelector: Int => String =
58-
(inProgressIndex: Int) =>
59-
s"${DueForDeletionReturnsController.onPageLoad(Some(inProgressIndex), submittedIndex).url}#in-progress"
54+
(index: Int) =>
55+
s"${DueForDeletionReturnsController.onPageLoad(Some(index), submittedIndex).url}#in-progress"
6056

6157
lazy val submittedUrlSelector: Int => String =
62-
(submittedIndex: Int) =>
63-
s"${DueForDeletionReturnsController.onPageLoad(inProgressIndex, Some(submittedIndex)).url}#submitted"
58+
(index: Int) =>
59+
s"${DueForDeletionReturnsController.onPageLoad(inProgressIndex, Some(index)).url}#submitted"
6460

6561
(for {
66-
submitted <- stampDutyLandTaxService.getSubmittedReturnsDueForDeletion
67-
submittedReturnsRows = convertResponseToSubmittedView(submitted)
68-
submittedPaginatedView = paginateIfValidPageIndex(Some(submittedReturnsRows), submittedIndex, submittedUrlSelector)
69-
paginatedSubmittedReturns = submittedPaginatedView.collectFirst { case Right((rows, paginator, paginationText)) => PaginatedDeletedSubmittedReturnsViewModel(rows, paginator, paginationText) }
70-
inProgress <- stampDutyLandTaxService.getInProgressReturnsDueForDeletion
71-
inProgressReturnsRows = convertResponseToViewRows(inProgress)
72-
inProgressPaginatedView = paginateIfValidPageIndex(Some(inProgressReturnsRows), inProgressIndex, inProgressUrlSelector)
73-
paginatedInProgressReturns = inProgressPaginatedView.collectFirst { case Right((rows, paginator, paginationText)) => PaginatedDeletedInProgressReturnsViewModel(rows, paginator, paginationText) }
62+
inProgressDurForDeletion <- stampDutyLandTaxService.getReturnsByTypeViewModel(
63+
storn = request.storn,
64+
IN_PROGRESS_RETURNS_DUE_FOR_DELETION,
65+
inProgressIndex)
66+
submittedDueDorDeletionViewModel <- stampDutyLandTaxService.getReturnsByTypeViewModel(
67+
storn = request.storn,
68+
SUBMITTED_RETURNS_DUE_FOR_DELETION,
69+
submittedIndex)
7470
} yield {
75-
(paginatedInProgressReturns, paginatedSubmittedReturns) match {
76-
case (Some(inProgressViewModel), Some(submittedViewModel)) =>
77-
Ok(view(inProgressViewModel, submittedViewModel))
78-
case _ =>
79-
logger.warn(s"[DueForDeletionReturnsController][onPageLoad] - Pagination Index Error")
80-
Redirect(outOfScopeUrlSelector)
81-
}
71+
Ok(
72+
view(
73+
inProgressDurForDeletion,
74+
submittedDueDorDeletionViewModel,
75+
inProgressIndex.getOrElse(1),
76+
submittedIndex.getOrElse(1),
77+
inProgressUrlSelector,
78+
submittedUrlSelector))
8279
}) recover {
8380
case ex =>
8481
logger.error("[DueForDeletionReturnsController][onPageLoad] Unexpected failure", ex)
8582
Redirect(JourneyRecoveryController.onPageLoad())
8683
}
8784
}
88-
}
85+
86+
}

app/controllers/manage/InProgressReturnsController.scala

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package controllers.manage
1919
import controllers.actions.{DataRequiredAction, DataRetrievalAction, IdentifierAction, StornRequiredAction}
2020
import controllers.routes.JourneyRecoveryController
2121
import models.requests.DataRequest
22-
import models.responses.SdltInProgressReturnViewRow
2322
import play.api.Logging
2423
import play.api.i18n.{I18nSupport, MessagesApi}
2524
import play.api.mvc.{Action, ActionBuilder, AnyContent, MessagesControllerComponents}
@@ -28,7 +27,7 @@ import uk.gov.hmrc.govukfrontend.views.Aliases.Pagination
2827
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
2928
import utils.PaginationHelper
3029
import views.html.InProgressReturnView
31-
30+
import models.SdltReturnTypes.*
3231
import scala.concurrent.ExecutionContext
3332
import javax.inject.*
3433

@@ -42,30 +41,34 @@ class InProgressReturnsController @Inject()(
4241
requireData: DataRequiredAction,
4342
stornRequiredAction: StornRequiredAction,
4443
view: InProgressReturnView
45-
)(implicit ec: ExecutionContext) extends FrontendBaseController with I18nSupport with PaginationHelper with Logging {
44+
)(implicit ec: ExecutionContext) extends FrontendBaseController with I18nSupport with Logging {
4645

4746
private lazy val authActions: ActionBuilder[DataRequest, AnyContent] = identify andThen getData andThen requireData andThen stornRequiredAction
4847

4948
val urlSelector: Int => String = (pageIndex: Int) => controllers.manage.routes.InProgressReturnsController.onPageLoad(Some(pageIndex)).url
5049

5150
def onPageLoad(index: Option[Int]): Action[AnyContent] = authActions.async { implicit request =>
5251

53-
stampDutyLandTaxService.getInProgressReturns map { allDataRows =>
52+
stampDutyLandTaxService.getReturnsByTypeViewModel(request.storn, IN_PROGRESS_RETURNS, index) map { viewModel =>
5453
logger.info(s"[InProgressReturnsController][onPageLoad] - render page: $index")
55-
pageIndexSelector(index, allDataRows.length) match {
54+
val totalRowsCount = viewModel.totalRowCount.getOrElse(0)
55+
viewModel.pageIndexSelector(index, totalRowsCount) match {
5656
case Right(selectedPageIndex) =>
57-
val paginator: Option[Pagination] = createPagination(selectedPageIndex, allDataRows.length, urlSelector)
58-
val paginationText: Option[String] = getPaginationInfoText(selectedPageIndex, allDataRows)
59-
val rowsForSelectedPage: List[SdltInProgressReturnViewRow] = getSelectedPageRows(allDataRows, selectedPageIndex)
60-
logger.info(s"[InProgressReturnsController][onPageLoad] - view model r/count: ${rowsForSelectedPage.length}")
61-
Ok(view(rowsForSelectedPage, paginator, paginationText))
62-
case Left(error) => // strongly advised to avoid this approach to redirect to itself / implemented as per QA request
63-
logger.error(s"[InProgressReturnsController][onPageLoad] - indexError: $error")
64-
Redirect( urlSelector(1) )
57+
val paginator: Option[Pagination] = viewModel.createPagination(selectedPageIndex, totalRowsCount, urlSelector)
58+
val paginationText: Option[String] = viewModel.getPaginationInfoText(selectedPageIndex, viewModel.rows )
59+
logger.info(s"[InProgressReturnsController][onPageLoad] - view model r/count: ${viewModel.rows.length}")
60+
Ok(view(viewModel.rows, paginator, paginationText))
61+
// TODO: disable page index redirect / need to be fix as part of tech debt or bug fix story: TBC
62+
// case Left(error) if error.getMessage.contains("PageIndex selected is out of scope") =>
63+
// logger.error(s"[InProgressReturnsController][onPageLoad] - indexError: $error")
64+
// Redirect( urlSelector(1) )
65+
case Left(error) =>
66+
logger.error(s"[InProgressReturnsController][onPageLoad] - other error: $error")
67+
Redirect(JourneyRecoveryController.onPageLoad())
6568
}
6669
} recover {
6770
case ex =>
68-
logger.error("[AgentOverviewController][onPageLoad] Unexpected failure", ex)
71+
logger.error("[InProgressReturnsController][onPageLoad] Unexpected failure", ex)
6972
Redirect(JourneyRecoveryController.onPageLoad())
7073
}
7174
}

app/controllers/manage/SubmittedReturnsController.scala

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ import play.api.i18n.I18nSupport
2121
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
2222
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
2323
import controllers.routes.JourneyRecoveryController
24-
import play.api.{Logger, Logging}
25-
import uk.gov.hmrc.govukfrontend.views.viewmodels.pagination.Pagination
26-
24+
import play.api.Logging
2725
import javax.inject.{Inject, Singleton}
2826
import navigation.Navigator
2927
import utils.PaginationHelper
3028
import services.StampDutyLandTaxService
31-
import viewmodels.manage.SdltSubmittedReturnsViewModel
29+
import uk.gov.hmrc.govukfrontend.views.Aliases.Pagination
3230
import views.html.manage.SubmittedReturnsView
31+
import controllers.manage.routes._
3332

3433
import scala.concurrent.ExecutionContext
3534

@@ -45,32 +44,30 @@ class SubmittedReturnsController @Inject()(
4544
view: SubmittedReturnsView
4645
)(implicit executionContext: ExecutionContext) extends FrontendBaseController with I18nSupport with Logging with PaginationHelper {
4746

48-
val urlSelector: Int => String = (paginationIndex: Int) => controllers.manage.routes.SubmittedReturnsController.onPageLoad(Some(paginationIndex)).url
47+
val urlSelector: Int => String = (paginationIndex: Int) => SubmittedReturnsController.onPageLoad(Some(paginationIndex)).url
4948

5049
def onPageLoad(paginationIndex: Option[Int]): Action[AnyContent] =
51-
(identify andThen getData andThen requireData andThen stornRequiredAction).async { implicit request =>
52-
53-
stampDutyLandTaxService
54-
.getSubmittedReturns map {
55-
allDataRows =>
56-
pageIndexSelector(paginationIndex, allDataRows.length) match {
50+
(identify andThen getData andThen requireData andThen stornRequiredAction)
51+
.async { implicit request =>
52+
stampDutyLandTaxService
53+
.getSubmittedReturnsViewModel(request.storn, paginationIndex)
54+
.map { viewModel =>
55+
logger.info(s"[SubmittedReturnsController][onPageLoad] - render page: $paginationIndex")
56+
val totalRowsCount = viewModel.totalRowCount.getOrElse(0)
57+
pageIndexSelector(paginationIndex, totalRowsCount) match {
5758
case Right(selectedPageIndex) =>
58-
59-
val selectedPageIndex: Int = paginationIndex.getOrElse(1)
60-
val paginator: Option[Pagination] = createPagination(selectedPageIndex, allDataRows.length, urlSelector)
61-
val paginationText: Option[String] = getPaginationInfoText(selectedPageIndex, allDataRows)
62-
val rowsForSelectedPage: List[SdltSubmittedReturnsViewModel] = getSelectedPageRows(allDataRows, selectedPageIndex)
63-
64-
Ok(view(rowsForSelectedPage, paginator, paginationText))
65-
59+
val paginator : Option[Pagination] = createPaginationV2(selectedPageIndex, totalRowsCount, urlSelector)
60+
val paginationText : Option[String] = getPaginationInfoTextV2(selectedPageIndex, totalRowsCount)
61+
logger.info(s"[SubmittedReturnsController][onPageLoad] - view model r/count: ${viewModel.rows.length}")
62+
Ok(view(viewModel.rows, paginator, paginationText))
6663
case Left(error) =>
67-
Logger("application").error(s"[SubmittedReturnsController][onPageLoad] - paginationIndexError: $error")
68-
Redirect(urlSelector(1))
64+
logger.error(s"[SubmittedReturnsController][onPageLoad] - other error: $error")
65+
Redirect(JourneyRecoveryController.onPageLoad())
6966
}
7067
} recover {
71-
case ex =>
72-
logger.error("[SubmittedReturnsController][onPageLoad] Unexpected failure", ex)
73-
Redirect(JourneyRecoveryController.onPageLoad())
68+
case ex =>
69+
logger.error("[SubmittedReturnsController][onPageLoad] Unexpected failure", ex)
70+
Redirect(JourneyRecoveryController.onPageLoad())
71+
}
7472
}
75-
}
7673
}

0 commit comments

Comments
 (0)