Skip to content

Commit

Permalink
MCSC-1165 Comma Separated Numerical Values for New Calculation Results (
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelAAbbott authored Nov 12, 2024
1 parent c877f8a commit 7509080
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 93 deletions.
47 changes: 24 additions & 23 deletions app/services/CalculationResultService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import pages.setupquestions.lifetimeallowance._
import pages.setupquestions.{ReasonForResubmissionPage, ReportingChangePage, ResubmittingAdjustmentPage}
import play.api.Logging
import uk.gov.hmrc.http.HeaderCarrier
import utils.CurrencyFormatter.currencyFormat

import java.time.LocalDate
import javax.inject.Inject
Expand Down Expand Up @@ -854,47 +855,47 @@ class CalculationResultService @Inject() (
Seq(
RowViewModel(
"calculationReviewIndividualAA.annualResults.outDates.chargePaidBySchemes",
outDate.chargePaidBySchemes.toString()
currencyFormat(outDate.chargePaidBySchemes.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.outDates.chargePaidByMember",
outDate.chargePaidByMember.toString()
currencyFormat(outDate.chargePaidByMember.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.outDates.revisedChargeableAmountBeforeTaxRate",
outDate.revisedChargableAmountBeforeTaxRate.toString()
currencyFormat(outDate.revisedChargableAmountBeforeTaxRate.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.outDates.revisedChargeableAmountAfterTaxRate",
outDate.revisedChargableAmountAfterTaxRate.toString()
currencyFormat(outDate.revisedChargableAmountAfterTaxRate.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.outDates.directCompensation",
outDate.directCompensation.toString()
currencyFormat(outDate.directCompensation.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.outDates.indirectCompensation",
outDate.indirectCompensation.toString()
currencyFormat(outDate.indirectCompensation.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.outDates.unusedAnnualAllowance",
outDate.unusedAnnualAllowance.toString()
currencyFormat(outDate.unusedAnnualAllowance.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.reducedNetIncome",
taxYear.reducedNetIncomeAmount.getOrElse(0).toString
currencyFormat(taxYear.reducedNetIncomeAmount.getOrElse(0).toString)
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.personalAllowance",
taxYear.personalAllowanceAmount.getOrElse(0).toString
currencyFormat(taxYear.personalAllowanceAmount.getOrElse(0).toString)
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.thresholdIncome",
thresholdIncomeMessage(outDate.period, taxYear)
currencyFormat(thresholdIncomeMessage(outDate.period, taxYear))
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.adjustedIncome",
adjustedIncomeMessage(outDate.period, taxYear)
currencyFormat(adjustedIncomeMessage(outDate.period, taxYear))
)
)
}
Expand Down Expand Up @@ -934,51 +935,51 @@ class CalculationResultService @Inject() (
Seq(
RowViewModel(
"calculationReviewIndividualAA.annualResults.inDates.chargePaidBySchemes",
inDate.chargePaidBySchemes.toString()
currencyFormat(inDate.chargePaidBySchemes.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.inDates.chargePaidByMember",
inDate.chargePaidByMember.toString()
currencyFormat(inDate.chargePaidByMember.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.inDates.revisedChargeableAmountBeforeTaxRate",
inDate.revisedChargableAmountBeforeTaxRate.toString()
currencyFormat(inDate.revisedChargableAmountBeforeTaxRate.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.inDates.revisedChargeableAmountAfterTaxRate",
inDate.revisedChargableAmountAfterTaxRate.toString()
currencyFormat(inDate.revisedChargableAmountAfterTaxRate.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.inDates.debit",
inDate.debit.toString()
currencyFormat(inDate.debit.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.inDates.memberCredit",
inDate.memberCredit.toString()
currencyFormat(inDate.memberCredit.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.inDates.schemeCredit",
inDate.schemeCredit.toString()
currencyFormat(inDate.schemeCredit.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.inDates.unusedAnnualAllowance",
inDate.unusedAnnualAllowance.toString()
currencyFormat(inDate.unusedAnnualAllowance.toString())
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.reducedNetIncome",
taxYear.reducedNetIncomeAmount.getOrElse(0).toString
currencyFormat(taxYear.reducedNetIncomeAmount.getOrElse(0).toString)
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.personalAllowance",
taxYear.personalAllowanceAmount.getOrElse(0).toString
currencyFormat(taxYear.personalAllowanceAmount.getOrElse(0).toString)
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.thresholdIncome",
thresholdIncomeMessage(inDate.period, taxYear)
currencyFormat(thresholdIncomeMessage(inDate.period, taxYear))
),
RowViewModel(
"calculationReviewIndividualAA.annualResults.adjustedIncome",
adjustedIncomeMessage(inDate.period, taxYear)
currencyFormat(adjustedIncomeMessage(inDate.period, taxYear))
)
)
}
Expand Down
22 changes: 19 additions & 3 deletions app/utils/CurrencyFormatter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,25 @@

package utils

import utils.CurrencyFormatter.formatNumberString

trait CurrencyFormatter {
def currencyFormat(amt: BigInt): String = f"£$amt"
def currencyFormat(amt: Int): String = f"£$amt"
def currencyFormat(amt: BigInt): String = f"£$amt"
def currencyFormat(amt: Int): String = f"£$amt"
def currencyFormat(string: String): String = formatNumberString(string)
}

object CurrencyFormatter extends CurrencyFormatter
object CurrencyFormatter extends CurrencyFormatter {

def formatNumberString(input: String): String =
if (input.forall(_.isDigit)) {
val formattedString = input.reverse
.grouped(3)
.mkString(",")
.reverse
"£" + formattedString
} else {
input
}

}
2 changes: 1 addition & 1 deletion app/views/CalculationReviewIndividualAAView.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h2 class="govuk-heading-m">@messages("calculationReviewIndividualAA.heading3")<
@calculationReviewIndividualAAViewModel.annualResultsData.map { section =>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header">@messages(section.name)</th>
<td class="govuk-table__cell">@messages("£" + section.value)</td>
<td class="govuk-table__cell">@messages(section.value)</td>
</tr>
}
</tbody>
Expand Down
4 changes: 2 additions & 2 deletions app/views/CalculationReviewView.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h2 class="govuk-heading-m">@messages("calculationReview.outDatesAA.heading1")</
@if(section.totalCharge.get == 0) {
<td class="govuk-table__cell">@messages(section.changeString.get)</td>
} else {
<td class="govuk-table__cell">@messages(section.changeString.get)@section.totalCharge</td>
<td class="govuk-table__cell">@messages(section.changeString.get, section.totalCharge.get)</td>
}
<td class="govuk-table__cell"><a class="govuk-link" href=@section.link>@messages("calculationReview.reviewPeriod")</a></td>
</tr>
Expand Down Expand Up @@ -131,7 +131,7 @@ <h2 class="govuk-heading-m">@messages("calculationReview.inDatesAA.heading1")</h
@if(section.totalCharge.get == 0) {
<td class="govuk-table__cell">@messages(section.changeString.get)</td>
} else {
<td class="govuk-table__cell">@messages(section.changeString.get)@section.totalCharge</td>
<td class="govuk-table__cell">@messages(section.changeString.get, section.totalCharge.get)</td>
}
<td class="govuk-table__cell"><a class="govuk-link" href=@section.link>@messages("calculationReview.reviewPeriod")</a></td>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions app/views/PrintReviewView.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h2 class="govuk-heading-m">@messages("printReview.heading.varyAA")</h2>

<p class="govuk-body">@messages("printReview.message6")</p>

<p class="govuk-body">@messages("printReview.message6.1") <a class="govuk-link" href= "https://www.gov.uk/guidance/who-must-pay-the-pensions-annual-allowance-tax-charge"> @messages("printReview.schemepays.link")</a> @messages("printReview.message6.2") </p>
<p class="govuk-body">@messages("printReview.message6.1") <a class="govuk-link" href="https://www.gov.uk/guidance/who-must-pay-the-pensions-annual-allowance-tax-charge" rel="noreferrer noopener" target="_blank"> @messages("printReview.schemepays.link")</a> @messages("printReview.message6.2") <span class="govuk-visually-hidden">(opens in new tab)</span> </p>

<p class="govuk-body">@messages("printReview.message6.3")</p>

Expand All @@ -109,7 +109,7 @@ <h2 class="govuk-heading-m">@messages("printReview.heading.changeOutDates")</h2>
@if(section.totalCharge.getOrElse(0) == 0) {
<td class="govuk-table__cell">@messages(section.changeString.get)</td>
} else {
<td class="govuk-table__cell">@messages(section.changeString.get)@section.totalCharge</td>
<td class="govuk-table__cell">@messages(section.changeString.get, section.totalCharge.get)</td>
}
</tr>
}
Expand Down Expand Up @@ -198,7 +198,7 @@ <h2 class="govuk-heading-m">@messages("printReview.heading.changeInDates")</h2>
@if(section.totalCharge.getOrElse(0) == 0) {
<td class="govuk-table__cell">@messages(section.changeString.get)</td>
} else {
<td class="govuk-table__cell">@messages(section.changeString.get)@section.totalCharge</td>
<td class="govuk-table__cell">@messages(section.changeString.get, section.totalCharge.get)</td>
}
</tr>
}
Expand Down
4 changes: 2 additions & 2 deletions conf/messages.cy
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,8 @@ calculationReview.answers = cy: Answers
calculationReview.reviewPeriod = cy: View breakdown
calculationReview.reviewAnswers = cy: Review answers
calculationReview.taxChargeNotChanged = cy: Not Changed
calculationReview.taxChargeIncreasedBy = cy: Increased by £
calculationReview.taxChargeDecreasedBy = cy: Decreased by £
calculationReview.taxChargeIncreasedBy = cy: Increased by £{0}
calculationReview.taxChargeDecreasedBy = cy: Decreased by £{0}
calculationReview.annualResults.notResubmission = cy: It is not a resubmission
calculationReview.annualResults.isResubmission = cy: It is a resubmission
calculationReview.annualResults.reason = cy: Reason:
Expand Down
4 changes: 2 additions & 2 deletions conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,8 @@ calculationReview.answers = Answers
calculationReview.reviewPeriod = View breakdown
calculationReview.reviewAnswers = Review answers
calculationReview.taxChargeNotChanged = Not Changed
calculationReview.taxChargeIncreasedBy = Increased by £
calculationReview.taxChargeDecreasedBy = Decreased by £
calculationReview.taxChargeIncreasedBy = Increased by £{0}
calculationReview.taxChargeDecreasedBy = Decreased by £{0}
calculationReview.annualResults.notResubmission = It is not a resubmission
calculationReview.annualResults.isResubmission = It is a resubmission
calculationReview.annualResults.reason = Reason:
Expand Down
Loading

0 comments on commit 7509080

Please sign in to comment.