Skip to content

Commit

Permalink
Merge pull request #178 from hmrc/DL-12076
Browse files Browse the repository at this point in the history
DL-12076 replaced pdf download with print link
  • Loading branch information
VLukovski authored Nov 3, 2023
2 parents 72b74ca + 321d970 commit b1272dd
Show file tree
Hide file tree
Showing 53 changed files with 368 additions and 2,424 deletions.
9 changes: 9 additions & 0 deletions app/assets/javascripts/print.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const printlink = document.getElementById('printLink');

if(printlink != null && printlink != 'undefined' ) {

printlink.addEventListener("click", function (e) {
e.preventDefault();
window.print();
});
};
8 changes: 8 additions & 0 deletions app/assets/stylesheets/cgt-calculator-resident-shares.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@

.govuk-summary-list__actions {
width: 10%
}

.cgt-for-print {
display: none;
}

body:not(.js-enabled) .cgt-print-button {
display: none;
}
27 changes: 27 additions & 0 deletions app/assets/stylesheets/cgt-print.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
*{
font-family: Arial, Helvetica, sans-serif;
}

#secondary-nav,
.hmrc-language-select,
.hmrc-report-technical-issue,
.govuk-footer,
.govuk-back-link {
display: none;
}

.govuk-header__container {
border-bottom: 0;
}

.govuk-header {
margin-bottom: 50px;
}

.cgt-for-print {
display: block !important;
}

.govuk-grid-column-two-thirds {
width: 100%;
}
6 changes: 3 additions & 3 deletions app/common/Dates.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ trait Dates {

object TemplateImplicits {
implicit class RichDate(date: LocalDate) {
def localFormat(pattern: String)(implicit lang: play.api.i18n.Lang, messages: Messages): String = {
if(lang.language == "cy") {
def localFormat(pattern: String)(implicit messages: Messages): String = {
if(messages.lang.language == "cy") {
val monthNum = date.getMonthValue
val welshFormatter = DateTimeFormatter.ofPattern(s"""d '${messages(s"calc.month.$monthNum")}' yyyy""")
date.format(welshFormatter)
} else {
val localFormatter = DateTimeFormatter.ofPattern(pattern, lang.toLocale)
val localFormatter = DateTimeFormatter.ofPattern(pattern, messages.lang.toLocale)
date.format(localFormatter)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/IncomeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IncomeController @Inject()(calcConnector: CalculatorConnector,
val inCurrentTaxYear = taxYear.taxYearSupplied == currentTaxYear
implicit val lang: Lang = messagesApi.preferred(request).lang

val form: Form[CurrentIncomeModel] = currentIncomeForm(TaxYearModel.convertWithWelsh(taxYear.taxYearSupplied), lang)
val form: Form[CurrentIncomeModel] = currentIncomeForm(TaxYearModel.convertWithWelsh(taxYear.taxYearSupplied))

sessionCacheService.fetchAndGetFormData[CurrentIncomeModel](keystoreKeys.currentIncome).map {
case Some(data) => Ok(currentIncomeView(form.fill(data), backUrl, taxYear, inCurrentTaxYear))
Expand All @@ -99,7 +99,7 @@ class IncomeController @Inject()(calcConnector: CalculatorConnector,

val inCurrentTaxYear = taxYearModel.taxYearSupplied == currentTaxYear
implicit val lang: Lang = messagesApi.preferred(request).lang
val form: Form[CurrentIncomeModel] = currentIncomeForm(TaxYearModel.convertWithWelsh(taxYearModel.taxYearSupplied), lang)
val form: Form[CurrentIncomeModel] = currentIncomeForm(TaxYearModel.convertWithWelsh(taxYearModel.taxYearSupplied))
form.bindFromRequest().fold(
errors => buildCurrentIncomeBackUrl.flatMap(url => Future.successful(BadRequest(currentIncomeView(errors, url,
taxYearModel, inCurrentTaxYear)))),
Expand Down
125 changes: 0 additions & 125 deletions app/controllers/ReportController.scala

This file was deleted.

6 changes: 4 additions & 2 deletions app/controllers/SummaryController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ class SummaryController @Inject()(calculatorConnector: CalculatorConnector,
implicit val lang: Lang = messagesApi.preferred(request).lang
if (chargeableGain.isDefined && chargeableGain.get.chargeableGain > 0 &&
incomeAnswers.personalAllowanceModel.isDefined && incomeAnswers.currentIncomeModel.isDefined) Future.successful(
Ok(finalSummaryView(totalGainAnswers, deductionGainAnswers,
totalGainAndTax.get, routes.ReviewAnswersController.reviewFinalAnswers.url, taxYear.get, totalCosts, chargeableGain.get.deductions, showUserResearchPanel = false)))
Ok(finalSummaryView(totalGainAnswers, deductionGainAnswers, incomeAnswers, totalGainAndTax.get,
routes.ReviewAnswersController.reviewFinalAnswers.url, taxYear.get, totalCosts, chargeableGain.get.deductions,
taxYear.get.taxYearSupplied == currentTaxYear, showUserResearchPanel = false))
)

else if (grossGain > 0) Future.successful(Ok(deductionsSummaryView(totalGainAnswers, deductionGainAnswers,
chargeableGain.get, backUrl, taxYear.get, totalCosts, showUserResearchPanel)))
Expand Down
16 changes: 8 additions & 8 deletions app/forms/CurrentIncomeForm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ import models.resident.income.CurrentIncomeModel
import play.api.Logging
import play.api.data.Forms._
import play.api.data._
import play.api.i18n.{Lang, MessagesApi}
import play.api.i18n.Messages
import uk.gov.hmrc.time.TaxYear

class CurrentIncomeForm @Inject()(implicit val messagesApi: MessagesApi) extends Logging {
class CurrentIncomeForm @Inject()() extends Logging {

def apply(taxYear: String, lang: Lang): Form[CurrentIncomeModel] = {
val question = if(taxYear == TaxYearModel.convertWithWelsh(TaxYear.current.startYear.toString)(lang)) "questionCurrentYear" else "question"
def apply(taxYear: String)(implicit messages: Messages): Form[CurrentIncomeModel] = {
val question = if(taxYear == TaxYearModel.convertWithWelsh(TaxYear.current.startYear.toString)) "questionCurrentYear" else "question"

Form(
mapping(
"amount" -> text
.verifying(messagesApi(s"calc.resident.currentIncome.$question.error.mandatoryAmount", taxYear)(lang), mandatoryCheck)
.verifying(messagesApi(s"calc.resident.currentIncome.$question.error.invalidAmount", taxYear)(lang), bigDecimalCheck)
.verifying(messages(s"calc.resident.currentIncome.$question.error.mandatoryAmount", taxYear), mandatoryCheck)
.verifying(messages(s"calc.resident.currentIncome.$question.error.invalidAmount", taxYear), bigDecimalCheck)
.transform[BigDecimal](stringToBigDecimal, bigDecimalToString)
.verifying(maxMonetaryValueConstraint(Constants.maxNumeric))
.verifying(messagesApi(s"calc.resident.currentIncome.$question.error.minimumAmount", taxYear)(lang), isPositive)
.verifying(messagesApi(s"calc.resident.currentIncome.$question.error.invalidAmount", taxYear)(lang), decimalPlacesCheck)
.verifying(messages(s"calc.resident.currentIncome.$question.error.minimumAmount", taxYear), isPositive)
.verifying(messages(s"calc.resident.currentIncome.$question.error.invalidAmount", taxYear), decimalPlacesCheck)
)(CurrentIncomeModel.apply)(CurrentIncomeModel.unapply)
)
}
Expand Down
6 changes: 3 additions & 3 deletions app/models/resident/TaxYearModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package models.resident

import play.api.i18n.Lang
import play.api.i18n.Messages
import play.api.libs.json.{Json, OFormat}

case class TaxYearModel (taxYearSupplied: String, isValidYear: Boolean, calculationTaxYear: String)
Expand All @@ -31,10 +31,10 @@ object TaxYearModel {
startYear + " to " + endYear
}

def convertWithWelsh(taxYear: String)(implicit lang: Lang): String = {
def convertWithWelsh(taxYear: String)(implicit messages: Messages): String = {
val startYear = taxYear.take(4)
val endYear = startYear.toInt + 1
if (lang.language == "cy") startYear + " i " + endYear
if (messages.lang.language == "cy") startYear + " i " + endYear
else startYear + " to " + endYear
}
}
8 changes: 7 additions & 1 deletion app/views/Layout.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
backLinkHref: Option[String] = None,
isUserResearchBannerVisible: Boolean = false,
timeoutEnabled: Boolean = true,
fullGrid: Boolean = false
fullGrid: Boolean = false,
scripts: Option[Html] = None
)(
contentBlock: Html
)(
Expand All @@ -56,6 +57,10 @@
<link rel="stylesheet" type="text/css" href ='@routes.Assets.versioned("stylesheets/cgt-calculator-resident-shares.css")'>
}

@scriptsBlock = {
@scripts
}

@mainContent = {
@contentBlock
@hmrcReportTechnicalIssueHelper()
Expand All @@ -69,6 +74,7 @@
templateOverrides = TemplateOverrides(
additionalHeadBlock = Some(head),
beforeContentBlock = Some(accountMenu),
additionalScriptsBlock = Some(scriptsBlock),
mainContentLayout = if (fullGrid) Some(_ => Html(s"<div class='govuk-grid-row'><div class='govuk-grid-column-full'>$mainContent</div></div>")) else Some(_ => Html(s"<div class='govuk-grid-row'><div class='govuk-grid-column-two-thirds'>$mainContent</div></div>"))
),
serviceName = Some(messages("service.name")),
Expand Down
23 changes: 10 additions & 13 deletions app/views/calculation/checkYourAnswers/checkYourAnswers.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@

@import models.resident._
@import models.resident.shares._
@import controllers.routes.{GainController => gainRoutes}
@import controllers.routes.{DeductionsController => deductionRoutes}
@import controllers.routes.{IncomeController => incomeRoutes}
@import play.api.i18n.Lang
@import uk.gov.hmrc.govukfrontend.views.html.components.FormWithCSRF

@this(
layout: Layout,
form: FormWithCSRF,
checkYourAnswersPartial: playHelpers.checkYourAnswersPartial,
submitButton: playHelpers.submitButton
layout: Layout,
checkYourAnswersPartial: playHelpers.checkYourAnswersPartial,
link: playHelpers.link
)

@(postAction: Call, backUrl: String, gainAnswers: GainAnswersModel, deductionsAnswers: Option[DeductionGainAnswersModel] = None, taxYear: Option[TaxYearModel] = None, incomeAnswers: Option[IncomeAnswersModel] = None, isCurrentTaxYear: Boolean = false)(implicit request: Request[_], messages: Messages, lang: Lang)
@(postAction: Call, backUrl: String, gainAnswers: GainAnswersModel, deductionsAnswers: Option[DeductionGainAnswersModel] = None, taxYear: Option[TaxYearModel] = None, incomeAnswers: Option[IncomeAnswersModel] = None, isCurrentTaxYear: Boolean = false)(implicit request: Request[_], messages: Messages)

@layout(
pageTitle = Messages("calc.checkYourAnswers.title"),
Expand All @@ -41,7 +35,10 @@ <h1 class="govuk-heading-xl">@Messages("calc.checkYourAnswers.title")</h1>

@checkYourAnswersPartial(gainAnswers, deductionsAnswers, taxYear, incomeAnswers, isCurrentTaxYear)

@form(action = postAction) {
@submitButton()
}
@link(
href = postAction.url,
messageKey = "calc.base.button.continue",
isButton = true,
id = Some("submit")
)
}
Loading

0 comments on commit b1272dd

Please sign in to comment.