Skip to content

Commit

Permalink
Merge pull request #86 from hmrc/SASS-7507
Browse files Browse the repository at this point in the history
[SASS-7507] Convert Yes/No RadioButton pages to Boolean pages - Expenses journey
  • Loading branch information
Jake-Raffe authored Mar 5, 2024
2 parents 8364fd9 + 4f55fe5 commit ad6f7c1
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@

package models.database.expenses

import models.frontend.expenses.goodsToSellOrUse.TaxiMinicabOrRoadHaulage
import play.api.libs.json.{Json, OFormat}

final case class TaxiMinicabOrRoadHaulageDb(taxiMinicabOrRoadHaulage: TaxiMinicabOrRoadHaulage)
final case class TaxiMinicabOrRoadHaulageDb(taxiMinicabOrRoadHaulage: Boolean)

object TaxiMinicabOrRoadHaulageDb {
implicit val format: OFormat[TaxiMinicabOrRoadHaulageDb] = Json.format[TaxiMinicabOrRoadHaulageDb]
Expand Down
6 changes: 3 additions & 3 deletions app/models/database/expenses/WorkplaceRunningCostsDb.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

package models.database.expenses

import models.frontend.expenses.workplaceRunningCosts.{LiveAtBusinessPremises, MoreThan25Hours, WfbpFlatRateOrActualCosts, WfhFlatRateOrActualCosts}
import models.frontend.expenses.workplaceRunningCosts.{WfbpFlatRateOrActualCosts, WfhFlatRateOrActualCosts}
import play.api.libs.json.{Json, OFormat}

final case class WorkplaceRunningCostsDb(moreThan25Hours: Option[MoreThan25Hours],
final case class WorkplaceRunningCostsDb(moreThan25Hours: Option[Boolean],
wfhHours25To50: Option[Int],
wfhHours51To100: Option[Int],
wfhHours101Plus: Option[Int],
wfhFlatRateOrActualCosts: Option[WfhFlatRateOrActualCosts],
wfhClaimingAmount: Option[BigDecimal],
liveAtBusinessPremises: Option[LiveAtBusinessPremises],
liveAtBusinessPremises: Option[Boolean],
businessPremisesAmount: Option[BigDecimal],
wfbpExpensesAreDisallowable: Boolean,
livingAtBusinessPremisesOnePerson: Option[Int],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object GoodsToSellOrUseJourneyAnswers {
implicit val formats: OFormat[GoodsToSellOrUseJourneyAnswers] = Json.format[GoodsToSellOrUseJourneyAnswers]
}

case class GoodsToSellOrUseAnswers(taxiMinicabOrRoadHaulage: TaxiMinicabOrRoadHaulage,
case class GoodsToSellOrUseAnswers(taxiMinicabOrRoadHaulage: Boolean,
goodsToSellOrUseAmount: BigDecimal,
disallowableGoodsToSellOrUseAmount: Option[BigDecimal])

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ object WorkplaceRunningCostsJourneyAnswers {
implicit val formats: OFormat[WorkplaceRunningCostsJourneyAnswers] = Json.format[WorkplaceRunningCostsJourneyAnswers]
}

case class WorkplaceRunningCostsAnswers(moreThan25Hours: Option[MoreThan25Hours],
case class WorkplaceRunningCostsAnswers(moreThan25Hours: Option[Boolean],
wfhHours25To50: Option[Int],
wfhHours51To100: Option[Int],
wfhHours101Plus: Option[Int],
wfhFlatRateOrActualCosts: Option[WfhFlatRateOrActualCosts],
wfhClaimingAmount: Option[BigDecimal],
liveAtBusinessPremises: Option[LiveAtBusinessPremises],
liveAtBusinessPremises: Option[Boolean],
businessPremisesAmount: Option[BigDecimal],
businessPremisesDisallowableAmount: Option[BigDecimal],
livingAtBusinessPremisesOnePerson: Option[Int],
Expand Down
8 changes: 4 additions & 4 deletions test/gens/ExpensesJourneyAnswersGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import models.frontend.expenses.construction.ConstructionJourneyAnswers
import models.frontend.expenses.depreciation.DepreciationCostsJourneyAnswers
import models.frontend.expenses.entertainment.EntertainmentJourneyAnswers
import models.frontend.expenses.financialCharges.FinancialChargesJourneyAnswers
import models.frontend.expenses.goodsToSellOrUse.{GoodsToSellOrUseAnswers, GoodsToSellOrUseJourneyAnswers, TaxiMinicabOrRoadHaulage}
import models.frontend.expenses.goodsToSellOrUse.{GoodsToSellOrUseAnswers, GoodsToSellOrUseJourneyAnswers}
import models.frontend.expenses.interest.InterestJourneyAnswers
import models.frontend.expenses.irrecoverableDebts.IrrecoverableDebtsJourneyAnswers
import models.frontend.expenses.officeSupplies.OfficeSuppliesJourneyAnswers
Expand All @@ -40,7 +40,7 @@ object ExpensesJourneyAnswersGen {
} yield GoodsToSellOrUseJourneyAnswers(amount, disallowableAmount)

val goodsToSellOrUseAnswersGen: Gen[GoodsToSellOrUseAnswers] = for {
taxiMinicabOrRoadHaulage <- Gen.oneOf(TaxiMinicabOrRoadHaulage.values)
taxiMinicabOrRoadHaulage <- booleanGen
amount <- bigDecimalGen
disallowableAmount <- Gen.option(bigDecimalGen)
} yield GoodsToSellOrUseAnswers(taxiMinicabOrRoadHaulage, amount, disallowableAmount)
Expand All @@ -51,13 +51,13 @@ object ExpensesJourneyAnswersGen {
} yield WorkplaceRunningCostsJourneyAnswers(wfhPremisesRunningCosts, wfbpPremisesRunningCostsDisallowable)

val workplaceRunningCostsAnswersGen: Gen[WorkplaceRunningCostsAnswers] = for {
moreThan25Hours <- Gen.option(Gen.oneOf(MoreThan25Hours.values))
moreThan25Hours <- Gen.option(booleanGen)
wfhHours25To50 <- Gen.option(intGen)
wfhHours51To100 <- Gen.option(intGen)
wfhHours101Plus <- Gen.option(intGen)
wfhFlatRateOrActualCosts <- Gen.option(Gen.oneOf(WfhFlatRateOrActualCosts.values))
wfhClaimingAmount <- Gen.option(bigDecimalGen)
liveAtBusinessPremises <- Gen.option(Gen.oneOf(LiveAtBusinessPremises.values))
liveAtBusinessPremises <- Gen.option(booleanGen)
businessPremisesAmount <- Gen.option(bigDecimalGen)
businessPremisesDisallowableAmount <- Gen.option(bigDecimalGen)
livingAtBusinessPremisesOnePerson <- Gen.option(intGen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import models.common.{JourneyName, JourneyStatus}
import models.connector.Api1786ExpensesResponseParser.goodsToSellOrUseParser
import models.database.JourneyAnswers
import models.database.expenses.{ExpensesCategoriesDb, TaxiMinicabOrRoadHaulageDb, WorkplaceRunningCostsDb}
import models.frontend.expenses.goodsToSellOrUse.TaxiMinicabOrRoadHaulage.Yes
import models.frontend.expenses.goodsToSellOrUse.{GoodsToSellOrUseAnswers, GoodsToSellOrUseJourneyAnswers}
import models.frontend.expenses.tailoring.ExpensesTailoring.{NoExpenses, TotalAmount}
import models.frontend.expenses.tailoring.ExpensesTailoringAnswers.{AsOneTotalAnswers, NoExpensesAnswers}
Expand Down Expand Up @@ -151,10 +150,10 @@ class ExpensesAnswersServiceImplSpec extends AnyWordSpecLike with Matchers {
override val connector =
StubSelfEmploymentConnector(getPeriodicSummaryDetailResult = Future.successful(api1786DeductionsSuccessResponse.asRight))
override val repo = StubJourneyAnswersRepository(getAnswer = goodsToSellOrUseJourneyAnswers
.copy(data = Json.toJson(TaxiMinicabOrRoadHaulageDb(Yes)).as[JsObject])
.copy(data = Json.toJson(TaxiMinicabOrRoadHaulageDb(true)).as[JsObject])
.some)
val result = underTest.getGoodsToSellOrUseAnswers(journeyCtxWithNino)(hc).value.futureValue
result shouldBe GoodsToSellOrUseAnswers(Yes, BigDecimal("100.0"), Some(BigDecimal("100.0"))).some.asRight
result shouldBe GoodsToSellOrUseAnswers(true, BigDecimal("100.0"), Some(BigDecimal("100.0"))).some.asRight
}
}

Expand Down

0 comments on commit ad6f7c1

Please sign in to comment.