Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SASS-7368: Fix loading of prior data for employment pensions #74

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 2 additions & 0 deletions app/models/Dividends.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ case class Dividends(ukDividends: Option[BigDecimal] = None, otherUkDividends: O

object Dividends {
implicit val formats: OFormat[Dividends] = Json.format[Dividends]

val empty: Dividends = Dividends(None, None)
}

case class EncryptedDividends(ukDividends: Option[EncryptedValue] = None, otherUkDividends: Option[EncryptedValue] = None)
Expand Down
9 changes: 4 additions & 5 deletions app/models/Interest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@

package models

import cats.implicits.catsSyntaxOptionId
import play.api.libs.json.{Format, Json, OFormat}
import uk.gov.hmrc.crypto.EncryptedValue

case class Interest(accountName: String,
incomeSourceId: String,
taxedUkInterest: Option[BigDecimal],
untaxedUkInterest: Option[BigDecimal])

case class Interest(accountName: String, incomeSourceId: String, taxedUkInterest: Option[BigDecimal], untaxedUkInterest: Option[BigDecimal])

object Interest {
implicit val formats: OFormat[Interest] = Json.format[Interest]

val empty: Interest = Interest("", "", BigDecimal(0).some, BigDecimal(0).some)
}

case class EncryptedInterest(accountName: EncryptedValue,
Expand Down
16 changes: 11 additions & 5 deletions app/models/SavingsIncomeDataModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@ package models
import play.api.libs.json.{Format, Json, OFormat}
import uk.gov.hmrc.crypto.EncryptedValue

case class SavingsIncomeDataModel(submittedOn: Option[String], securities: Option[SecuritiesModel], foreignInterest: Option[Seq[ForeignInterestModel]])
case class SavingsIncomeDataModel(submittedOn: Option[String],
securities: Option[SecuritiesModel],
foreignInterest: Option[Seq[ForeignInterestModel]])

object SavingsIncomeDataModel {
val empty: SavingsIncomeDataModel = SavingsIncomeDataModel(None, None, None)

object SavingsIncomeDataModel{
implicit val formats: OFormat[SavingsIncomeDataModel] = Json.format[SavingsIncomeDataModel]
}

case class EncryptedSavingsIncomeDataModel(submittedOn: Option[EncryptedValue], securities: Option[EncryptedSecuritiesModel], foreignInterest: Option[Seq[EncryptedForeignInterestModel]])
case class EncryptedSavingsIncomeDataModel(submittedOn: Option[EncryptedValue],
securities: Option[EncryptedSecuritiesModel],
foreignInterest: Option[Seq[EncryptedForeignInterestModel]])

object EncryptedSavingsIncomeDataModel{
object EncryptedSavingsIncomeDataModel {
implicit lazy val encryptedValueOFormat: OFormat[EncryptedValue] = Json.format[EncryptedValue]

implicit val formats: Format[EncryptedSavingsIncomeDataModel] = Json.format[EncryptedSavingsIncomeDataModel]
}
}
1 change: 1 addition & 0 deletions app/models/StockDividends.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ case class StockDividends(
)

object StockDividends {
val empty: StockDividends = StockDividends()
implicit val formats: OFormat[StockDividends] = Json.format[StockDividends]
}

Expand Down
1 change: 1 addition & 0 deletions app/models/cis/CISSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ case class CISSource(totalDeductionAmount: Option[BigDecimal],
}

object CISSource {
val empty: CISSource = CISSource(None, None, None, Seq.empty)
implicit val format: OFormat[CISSource] = Json.format[CISSource]
}

Expand Down
2 changes: 2 additions & 0 deletions app/models/employment/AllEmploymentData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ case class AllEmploymentData(hmrcEmploymentData: Seq[HmrcEmploymentSource],

object AllEmploymentData {
implicit val format: OFormat[AllEmploymentData] = Json.format[AllEmploymentData]

val empty: AllEmploymentData = AllEmploymentData(Seq.empty, None, Seq.empty, None, None)
}

case class EncryptedAllEmploymentData(hmrcEmploymentData: Seq[EncryptedHmrcEmploymentSource],
Expand Down
15 changes: 4 additions & 11 deletions app/models/gains/InsurancePoliciesModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,7 @@

package models.gains

import models.{
CapitalRedemptionModel,
EncryptedCapitalRedemptionModel,
EncryptedForeignModel,
EncryptedLifeInsuranceModel,
EncryptedVoidedIsaModel,
ForeignModel,
LifeInsuranceModel,
VoidedIsaModel
}
import models._
import play.api.libs.json.{Format, Json, OFormat}
import uk.gov.hmrc.crypto.EncryptedValue

Expand All @@ -37,6 +28,8 @@ case class InsurancePoliciesModel(submittedOn: Option[String],
foreign: Option[Seq[ForeignModel]])

object InsurancePoliciesModel {
val empty: InsurancePoliciesModel = InsurancePoliciesModel(None, None, None, None, None, None)

implicit val formats: OFormat[InsurancePoliciesModel] = Json.format[InsurancePoliciesModel]
}

Expand All @@ -51,4 +44,4 @@ object EncryptedInsurancePoliciesModel {
implicit lazy val encryptedValueOFormat: OFormat[EncryptedValue] = Json.format[EncryptedValue]

implicit val formats: Format[EncryptedInsurancePoliciesModel] = Json.format[EncryptedInsurancePoliciesModel]
}
}
6 changes: 3 additions & 3 deletions app/models/gifts/GiftAid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ case class GiftAid(giftAidPayments: Option[GiftAidPayments], gifts: Option[Gifts

object GiftAid {
implicit val format: OFormat[GiftAid] = Json.format[GiftAid]

val empty: GiftAid = GiftAid(None, None)
}

case class EncryptedGiftAid(giftAidPayments: Option[EncryptedGiftAidPayments],
gifts: Option[EncryptedGifts])
case class EncryptedGiftAid(giftAidPayments: Option[EncryptedGiftAidPayments], gifts: Option[EncryptedGifts])

object EncryptedGiftAid {
implicit val format: OFormat[EncryptedGiftAid] = Json.format[EncryptedGiftAid]
}

11 changes: 5 additions & 6 deletions app/models/pensions/Pensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package models.pensions

import models.pensions.charges.{EncryptedPensionCharges, PensionCharges}
import models.pensions.income.{EncryptedPensionIncomeModel, PensionIncomeModel}
import models.pensions.employmentPensions.{EmploymentPensions, EncryptedEmploymentPensions}
import models.pensions.income.{EncryptedPensionIncomeModel, PensionIncomeModel}
import models.pensions.reliefs.{EncryptedPensionReliefs, PensionReliefs}
import models.statebenefits.{AllStateBenefitsData, EncryptedAllStateBenefitsData}
import play.api.libs.json.{Json, OFormat}
Expand All @@ -27,21 +27,20 @@ case class Pensions(pensionReliefs: Option[PensionReliefs],
pensionCharges: Option[PensionCharges],
stateBenefits: Option[AllStateBenefitsData],
employmentPensions: Option[EmploymentPensions],
pensionIncome: Option[PensionIncomeModel]
)
pensionIncome: Option[PensionIncomeModel])

object Pensions {
implicit val formats: OFormat[Pensions] = Json.format[Pensions]

val empty: Pensions = Pensions(None, None, None, None, None)
}

case class EncryptedPensions(pensionReliefs: Option[EncryptedPensionReliefs],
pensionCharges: Option[EncryptedPensionCharges],
stateBenefits: Option[EncryptedAllStateBenefitsData],
employmentPensions: Option[EncryptedEmploymentPensions],
pensionIncome: Option[EncryptedPensionIncomeModel]
)
pensionIncome: Option[EncryptedPensionIncomeModel])

object EncryptedPensions {
implicit val formats: OFormat[EncryptedPensions] = Json.format[EncryptedPensions]
}

1 change: 1 addition & 0 deletions app/models/statebenefits/AllStateBenefitsData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ case class AllStateBenefitsData(stateBenefitsData: Option[StateBenefitsData],
}

object AllStateBenefitsData {
val empty: AllStateBenefitsData = AllStateBenefitsData(None, None)

implicit val allStateBenefitsDataWrites: OWrites[AllStateBenefitsData] = (data: AllStateBenefitsData) => {
jsonObjNoNulls(
Expand Down
Loading