From 52c1e46d278b67646aa1cba8cc8b4e48267bcd61 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:10:47 +0100 Subject: [PATCH 01/32] NOJIRA Remove advanced-rate enum from def1 --- .../calculation/taxCalculation/IncomeTaxBandName.scala | 3 --- .../schemas/retrieve/def1/calculation/taxCalculation.json | 3 +-- .../calculation/taxCalculation/IncomeTaxBandNameSpec.scala | 6 ++---- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/v6/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandName.scala b/app/v6/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandName.scala index c2758a781..89fd6cf43 100644 --- a/app/v6/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandName.scala +++ b/app/v6/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandName.scala @@ -40,8 +40,6 @@ object IncomeTaxBandName { case object `additional-rate` extends IncomeTaxBandName - case object `advanced-rate` extends IncomeTaxBandName - implicit val writes: Writes[IncomeTaxBandName] = Enums.writes[IncomeTaxBandName] implicit val reads: Reads[IncomeTaxBandName] = Enums.readsUsing { @@ -54,7 +52,6 @@ object IncomeTaxBandName { case "IRT" => `intermediate-rate` case "HRT" => `higher-rate` case "ART" => `additional-rate` - case "AVRT" => `advanced-rate` } } diff --git a/resources/public/api/conf/6.0/schemas/retrieve/def1/calculation/taxCalculation.json b/resources/public/api/conf/6.0/schemas/retrieve/def1/calculation/taxCalculation.json index 9725eae61..507505407 100644 --- a/resources/public/api/conf/6.0/schemas/retrieve/def1/calculation/taxCalculation.json +++ b/resources/public/api/conf/6.0/schemas/retrieve/def1/calculation/taxCalculation.json @@ -999,8 +999,7 @@ "basic-rate", "intermediate-rate", "higher-rate", - "additional-rate", - "advanced-rate" + "additional-rate" ] }, "rate": { diff --git a/test/v6/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala b/test/v6/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala index 93360dde4..cd3dca2f1 100644 --- a/test/v6/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala +++ b/test/v6/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala @@ -31,8 +31,7 @@ class IncomeTaxBandNameSpec extends UnitSpec with EnumJsonSpecSupport { "BRT" -> `basic-rate`, "IRT" -> `intermediate-rate`, "HRT" -> `higher-rate`, - "ART" -> `additional-rate`, - "AVRT" -> `advanced-rate` + "ART" -> `additional-rate` ) testWrites[IncomeTaxBandName]( @@ -44,8 +43,7 @@ class IncomeTaxBandNameSpec extends UnitSpec with EnumJsonSpecSupport { `basic-rate` -> "basic-rate", `intermediate-rate` -> "intermediate-rate", `higher-rate` -> "higher-rate", - `additional-rate` -> "additional-rate", - `advanced-rate` -> "advanced-rate" + `additional-rate` -> "additional-rate" ) } From 2e87f805c1c29c68dfb8bb43b615add9ab9874b1 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:04:20 +0100 Subject: [PATCH 02/32] MTDSA-23287 Shared code update --- .../validators/resolvers/ResolveTaxYear.scala | 19 ++++++++- app/shared/shared-code-changelog.md | 8 +++- .../resolvers/ResolveTaxYearSpec.scala | 41 ++++++++++++++++++- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/app/shared/controllers/validators/resolvers/ResolveTaxYear.scala b/app/shared/controllers/validators/resolvers/ResolveTaxYear.scala index 3e8c77fb4..1ee4476b3 100644 --- a/app/shared/controllers/validators/resolvers/ResolveTaxYear.scala +++ b/app/shared/controllers/validators/resolvers/ResolveTaxYear.scala @@ -38,6 +38,16 @@ object ResolveTaxYear extends ResolverSupport { case _ => Invalid(List(TaxYearFormatError)) } + def resolverWithCustomErrors(formatError: MtdError, rangeError: MtdError): Resolver[String, TaxYear] = { + case value @ taxYearFormat(start, end) => + if (end.toInt - start.toInt == 1) + Valid(TaxYear.fromMtd(value)) + else + Invalid(List(rangeError)) + + case _ => Invalid(List(formatError)) + } + def apply(value: String): Validated[Seq[MtdError], TaxYear] = resolver(value) def apply(value: Option[String]): Validated[Seq[MtdError], Option[TaxYear]] = @@ -55,10 +65,15 @@ object ResolveTaxYear extends ResolverSupport { } -case class ResolveTaxYearMinimum(minimumTaxYear: TaxYear, error: MtdError = RuleTaxYearNotSupportedError) extends ResolverSupport { +case class ResolveTaxYearMinimum( + minimumTaxYear: TaxYear, + notSupportedError: MtdError = RuleTaxYearNotSupportedError, + formatError: MtdError = TaxYearFormatError, + rangeError: MtdError = RuleTaxYearRangeInvalidError +) extends ResolverSupport { val resolver: Resolver[String, TaxYear] = - ResolveTaxYear.resolver thenValidate satisfiesMin(minimumTaxYear, error) + ResolveTaxYear.resolverWithCustomErrors(formatError, rangeError) thenValidate satisfiesMin(minimumTaxYear, notSupportedError) def apply(value: String): Validated[Seq[MtdError], TaxYear] = resolver(value) diff --git a/app/shared/shared-code-changelog.md b/app/shared/shared-code-changelog.md index 5d1d32de2..2a79472f1 100644 --- a/app/shared/shared-code-changelog.md +++ b/app/shared/shared-code-changelog.md @@ -7,10 +7,14 @@ For the Shared Code update steps, see: https://confluence.tools.tax.service.gov. Place new items at the top, and auto-format the file... +## September 17 2024: ResolveTaxYearMinimum + +Added an apply function on ResolveTaxYearMinimum to allow adding custom errors. Required in individual-losses-api. + ## August 29 2024: Increased code coverage -Increased the coverage for ResolveTaxYearMinMax and ResolveDateRange so that introducing the shared code into other APIs won't -reduce their coverage % quite so much. +Increased the coverage for ResolveTaxYearMinMax and ResolveDateRange so that introducing the shared code into other APIs +won't reduce their coverage % quite so much. ## Aug 21 2024: Re-engineer BaseDownstreamConnector and DownstreamUri for HIP support diff --git a/test/shared/controllers/validators/resolvers/ResolveTaxYearSpec.scala b/test/shared/controllers/validators/resolvers/ResolveTaxYearSpec.scala index 74b967a20..e9c8ee37b 100644 --- a/test/shared/controllers/validators/resolvers/ResolveTaxYearSpec.scala +++ b/test/shared/controllers/validators/resolvers/ResolveTaxYearSpec.scala @@ -69,7 +69,7 @@ class ResolveTaxYearSpec extends UnitSpec with ResolverSupport { } } - "ResolveTaxYearMinimum" should { + "ResolveTaxYearMinimum using the default errors" should { val minimumTaxYear = TaxYear.fromMtd("2021-22") val resolver = ResolveTaxYearMinimum(minimumTaxYear) @@ -103,6 +103,45 @@ class ResolveTaxYearSpec extends UnitSpec with ResolverSupport { } } + "ResolveTaxYearMinimum using custom errors" should { + val minimumTaxYear = TaxYear.fromMtd("2021-22") + + val notSupportedError = NotFoundError.withPath("/notSupported") + val formatError = NinoFormatError.withPath("/formatError") + val rangeError = BadRequestError.withPath("/rangeError") + + val resolver = ResolveTaxYearMinimum( + minimumTaxYear, + notSupportedError = notSupportedError, + formatError = formatError, + rangeError = rangeError + ) + + "return no errors" when { + "given the minimum allowed tax year" in { + val result: Validated[Seq[MtdError], TaxYear] = resolver("2021-22") + result shouldBe Valid(minimumTaxYear) + } + } + + "return the custom error" when { + "given a tax year before the minimum tax year" in { + val result: Validated[Seq[MtdError], TaxYear] = resolver("2020-21") + result shouldBe Invalid(List(notSupportedError)) + } + + "given a badly formatted tax year" in { + val result: Validated[Seq[MtdError], TaxYear] = resolver("not-a-tax-year") + result shouldBe Invalid(List(formatError)) + } + + "given a tax year with an invalid range" in { + val result: Validated[Seq[MtdError], TaxYear] = resolver("2024-26") + result shouldBe Invalid(List(rangeError)) + } + } + } + "ResolveTaxYearMaximum" should { val maximumTaxYear = TaxYear.fromMtd("2024-25") val resolver = ResolveTaxYearMaximum(maximumTaxYear) From 170cdefe222b19ad91b7e80f652a9b5294718daf Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:46:15 +0100 Subject: [PATCH 03/32] MTDSA-26589 Create V7 --- .../model/response/CalculationType.scala | 36 + app/v7/common/model/response/ClaimType.scala | 43 + .../model/response/IncomeSourceType.scala | 80 ++ .../model/response/PensionBandName.scala | 41 + .../model/response/ReliefsClaimedType.scala | 49 + app/v7/common/model/response/Source.scala | 30 + .../model/response/StudentLoanPlanType.scala | 40 + .../ListCalculationsConnector.scala | 53 + .../ListCalculationsController.scala | 60 + .../ListCalculationsService.scala | 59 + .../ListCalculationsValidatorFactory.scala | 34 + .../def1/Def1_ListCalculationsValidator.scala | 45 + .../model/response/Def1_Calculation.scala | 63 + .../request/ListCalculationsRequestData.scala | 31 + .../response/ListCalculationsResponse.scala | 54 + .../schema/ListCalculationsSchema.scala | 55 + .../RetrieveCalculationConnector.scala | 50 + .../RetrieveCalculationController.scala | 82 ++ .../RetrieveCalculationService.scala | 63 + .../RetrieveCalculationValidatorFactory.scala | 36 + .../Def1_RetrieveCalculationValidator.scala | 43 + .../response/calculation/Calculation.scala | 241 ++++ .../AllowancesAndDeductions.scala | 58 + .../AnnuityPayments.scala | 25 + .../MarriageAllowanceTransferOut.scala | 25 + .../PensionContributionsDetail.scala | 27 + .../BusinessProfitAndLoss.scala | 146 +++ .../ChargeableEventGainsIncome.scala | 33 + ...gnGainsOnLifePoliciesNoTaxPaidDetail.scala | 27 + ...eignGainsOnLifePoliciesTaxPaidDetail.scala | 28 + ...GainsWithNoTaxPaidAndVoidedIsaDetail.scala | 30 + .../GainsWithTaxPaidDetail.scala | 29 + .../CodedOutUnderpayments.scala | 30 + .../PayeUnderpaymentsDetail.scala | 25 + .../SelfAssessmentUnderpaymentsDetail.scala | 29 + .../CommonForeignDividend.scala | 33 + .../dividendsIncome/DividendsIncome.scala | 31 + .../dividendsIncome/OtherDividends.scala | 25 + .../dividendsIncome/UkDividends.scala | 31 + ...FromEmployerFinancedRetirementScheme.scala | 29 + .../BenefitsInKind.scala | 26 + .../BenefitsInKindDetail.scala | 152 +++ .../EmploymentAndPensionsIncome.scala | 51 + .../EmploymentAndPensionsIncomeDetail.scala | 62 + .../LumpSums.scala | 26 + .../LumpSumsDetail.scala | 29 + ...ncyCompensationPaymentsOverExemption.scala | 28 + ...cyCompensationPaymentsUnderExemption.scala | 26 + .../StudentLoans.scala | 26 + .../TaxableLumpSumsAndCertainIncome.scala | 26 + .../EmploymentExpenses.scala | 26 + .../EmploymentExpensesDetail.scala | 33 + .../endOfYearEstimate/EndOfYearEstimate.scala | 66 + .../endOfYearEstimate/IncomeSource.scala | 57 + ...rgeableForeignBenefitsAndGiftsDetail.scala | 29 + .../foreignIncome/CommonForeignIncome.scala | 29 + .../foreignIncome/ForeignIncome.scala | 31 + .../OverseasIncomeAndGains.scala | 25 + .../ForeignPropertyIncome.scala | 38 + .../ForeignTaxForFtcrNotClaimed.scala | 25 + .../calculation/giftAid/GiftAid.scala | 30 + .../IncomeSummaryTotals.scala | 31 + .../lossesAndClaims/CarriedForwardLoss.scala | 49 + .../lossesAndClaims/ClaimNotApplied.scala | 45 + .../DefaultCarriedForwardLoss.scala | 45 + .../lossesAndClaims/LossesAndClaims.scala | 31 + .../ResultOfClaimsApplied.scala | 51 + .../lossesAndClaims/UnclaimedLoss.scala | 46 + .../MarriageAllowanceTransferredIn.scala | 25 + .../calculation/notionalTax/NotionalTax.scala | 25 + .../calculation/otherIncome/OtherIncome.scala | 25 + .../otherIncome/PostCessationIncome.scala | 28 + .../otherIncome/PostCessationReceipt.scala | 25 + .../PensionContributionDetail.scala | 25 + .../PensionContributionReliefs.scala | 25 + .../ExcessOfLifeTimeAllowance.scala | 28 + .../OverseasPensionContributions.scala | 29 + .../PensionBand.scala | 31 + ...ibutionsInExcessOfTheAnnualAllowance.scala | 32 + .../PensionSavingsDetailBreakdown.scala | 28 + .../PensionSavingsTaxCharges.scala | 28 + .../PensionSavingsTaxChargesDetail.scala | 30 + .../PensionSchemeOverseasTransfers.scala | 28 + .../PensionSchemeUnauthorisedPayments.scala | 28 + .../ShortServiceRefundBands.scala | 30 + .../PreviousCalculation.scala | 34 + .../AllOtherIncomeReceivedWhilstAbroad.scala | 25 + .../reliefs/BasicRateExtension.scala | 27 + .../calculation/reliefs/ForeignProperty.scala | 25 + .../reliefs/ForeignPropertyRfcDetail.scala | 28 + .../reliefs/ForeignTaxCreditRelief.scala | 31 + .../ForeignTaxCreditReliefDetail.scala | 46 + ...AidTaxReductionWhereBasicRateDiffers.scala | 25 + .../reliefs/OtherIncomeRfcDetail.scala | 27 + .../calculation/reliefs/Reliefs.scala | 40 + .../calculation/reliefs/ReliefsClaimed.scala | 31 + .../reliefs/ReliefsClaimedDetail.scala | 31 + .../reliefs/ResidentialFinanceCosts.scala | 32 + .../reliefs/TopSlicingRelief.scala | 25 + .../calculation/reliefs/UkProperty.scala | 25 + .../royaltyPayments/RoyaltyPayments.scala | 25 + .../ForeignSavingsAndGainsIncome.scala | 33 + .../SavingsAndGainsIncome.scala | 29 + .../UkSavingsAndGainsIncome.scala | 33 + .../SeafarersDeductionDetail.scala | 26 + .../SeafarersDeductions.scala | 26 + .../ShareSchemeDetail.scala | 25 + .../ShareSchemesIncome.scala | 25 + .../stateBenefitsIncome/CommonBenefit.scala | 25 + .../CommonBenefitWithTaxPaid.scala | 25 + .../StateBenefitsDetail.scala | 31 + .../StateBenefitsIncome.scala | 28 + .../StatePensionLumpSum.scala | 25 + .../studentLoans/StudentLoans.scala | 35 + ...sinessAssetsDisposalsAndInvestorsRel.scala | 34 + .../taxCalculation/CapitalGainsTax.scala | 40 + .../calculation/taxCalculation/CgtBand.scala | 30 + .../taxCalculation/CgtBandName.scala | 35 + .../taxCalculation/Class2Nics.scala | 36 + .../taxCalculation/Class4Nics.scala | 33 + .../taxCalculation/IncomeTax.scala | 48 + .../taxCalculation/IncomeTaxBand.scala | 32 + .../taxCalculation/IncomeTaxBandName.scala | 57 + .../taxCalculation/IncomeTaxItem.scala | 31 + .../calculation/taxCalculation/Nic4Band.scala | 32 + .../taxCalculation/Nic4BandName.scala | 39 + .../calculation/taxCalculation/Nics.scala | 44 + .../taxCalculation/OtherGains.scala | 36 + ...esidentialPropertyAndCarriedInterest.scala | 34 + .../taxCalculation/TaxCalculation.scala | 46 + .../TaxDeductedAtSource.scala | 40 + .../AllowancesReliefsAndDeductions.scala | 29 + .../response/inputs/AnnualAdjustment.scala | 49 + .../inputs/BusinessIncomeSource.scala | 63 + .../def1/model/response/inputs/Claim.scala | 47 + .../inputs/ConstructionIndustryScheme.scala | 25 + .../model/response/inputs/IncomeSources.scala | 51 + .../def1/model/response/inputs/Inputs.scala | 53 + .../response/inputs/LossBroughtForward.scala | 47 + .../inputs/NonBusinessIncomeSource.scala | 52 + .../def1/model/response/inputs/Other.scala | 25 + .../PensionContributionAndCharges.scala | 29 + .../model/response/inputs/PeriodData.scala | 25 + .../response/inputs/PersonalInformation.scala | 35 + .../response/inputs/StudentLoanPlan.scala | 27 + .../response/inputs/SubmissionPeriod.scala | 25 + .../model/response/messages/Messages.scala | 28 + .../model/response/metadata/Metadata.scala | 59 + .../Def2_RetrieveCalculationValidator.scala | 42 + .../response/calculation/Calculation.scala | 205 +++ .../AllowancesAndDeductions.scala | 58 + .../AnnuityPayments.scala | 25 + .../MarriageAllowanceTransferOut.scala | 25 + .../PensionContributionsDetail.scala | 27 + .../BusinessProfitAndLoss.scala | 146 +++ .../ChargeableEventGainsIncome.scala | 33 + ...gnGainsOnLifePoliciesNoTaxPaidDetail.scala | 27 + ...eignGainsOnLifePoliciesTaxPaidDetail.scala | 28 + ...GainsWithNoTaxPaidAndVoidedIsaDetail.scala | 30 + .../GainsWithTaxPaidDetail.scala | 29 + .../CodedOutUnderpayments.scala | 30 + .../PayeUnderpaymentsDetail.scala | 25 + .../SelfAssessmentUnderpaymentsDetail.scala | 29 + .../CommonForeignDividend.scala | 33 + .../dividendsIncome/DividendsIncome.scala | 31 + .../dividendsIncome/OtherDividends.scala | 25 + .../dividendsIncome/UkDividends.scala | 31 + ...FromEmployerFinancedRetirementScheme.scala | 29 + .../BenefitsInKind.scala | 26 + .../BenefitsInKindDetail.scala | 152 +++ .../EmploymentAndPensionsIncome.scala | 30 + .../EmploymentAndPensionsIncomeDetail.scala | 41 + .../LumpSums.scala | 26 + .../LumpSumsDetail.scala | 29 + ...ncyCompensationPaymentsOverExemption.scala | 28 + ...cyCompensationPaymentsUnderExemption.scala | 26 + .../StudentLoans.scala | 26 + .../TaxableLumpSumsAndCertainIncome.scala | 26 + .../EmploymentExpenses.scala | 26 + .../EmploymentExpensesDetail.scala | 33 + .../endOfYearEstimate/EndOfYearEstimate.scala | 43 + .../endOfYearEstimate/IncomeSource.scala | 57 + ...rgeableForeignBenefitsAndGiftsDetail.scala | 29 + .../foreignIncome/CommonForeignIncome.scala | 29 + .../foreignIncome/ForeignIncome.scala | 31 + .../OverseasIncomeAndGains.scala | 25 + .../ForeignPropertyIncome.scala | 38 + .../ForeignTaxForFtcrNotClaimed.scala | 25 + .../calculation/giftAid/GiftAid.scala | 30 + .../IncomeSummaryTotals.scala | 31 + .../lossesAndClaims/CarriedForwardLoss.scala | 49 + .../lossesAndClaims/ClaimNotApplied.scala | 45 + .../DefaultCarriedForwardLoss.scala | 45 + .../lossesAndClaims/LossesAndClaims.scala | 31 + .../ResultOfClaimsApplied.scala | 51 + .../lossesAndClaims/UnclaimedLoss.scala | 46 + .../MarriageAllowanceTransferredIn.scala | 25 + .../calculation/notionalTax/NotionalTax.scala | 25 + .../calculation/otherIncome/OtherIncome.scala | 25 + .../otherIncome/PostCessationIncome.scala | 28 + .../otherIncome/PostCessationReceipt.scala | 25 + .../PensionContributionDetail.scala | 25 + .../PensionContributionReliefs.scala | 25 + .../OverseasPensionContributions.scala | 29 + .../PensionBand.scala | 31 + ...ibutionsInExcessOfTheAnnualAllowance.scala | 32 + .../PensionSavingsDetailBreakdown.scala | 28 + .../PensionSavingsTaxCharges.scala | 28 + .../PensionSavingsTaxChargesDetail.scala | 29 + .../PensionSchemeOverseasTransfers.scala | 28 + .../PensionSchemeUnauthorisedPayments.scala | 28 + .../ShortServiceRefundBands.scala | 30 + .../PreviousCalculation.scala | 34 + .../AllOtherIncomeReceivedWhilstAbroad.scala | 25 + .../reliefs/BasicRateExtension.scala | 27 + .../calculation/reliefs/ForeignProperty.scala | 25 + .../reliefs/ForeignPropertyRfcDetail.scala | 28 + .../reliefs/ForeignTaxCreditRelief.scala | 31 + .../ForeignTaxCreditReliefDetail.scala | 46 + ...AidTaxReductionWhereBasicRateDiffers.scala | 25 + .../reliefs/OtherIncomeRfcDetail.scala | 27 + .../calculation/reliefs/Reliefs.scala | 31 + .../calculation/reliefs/ReliefsClaimed.scala | 31 + .../reliefs/ReliefsClaimedDetail.scala | 31 + .../reliefs/ResidentialFinanceCosts.scala | 32 + .../reliefs/TopSlicingRelief.scala | 25 + .../calculation/reliefs/UkProperty.scala | 25 + .../royaltyPayments/RoyaltyPayments.scala | 25 + .../ForeignSavingsAndGainsIncome.scala | 33 + .../SavingsAndGainsIncome.scala | 29 + .../UkSavingsAndGainsIncome.scala | 33 + .../SeafarersDeductionDetail.scala | 26 + .../SeafarersDeductions.scala | 26 + .../ShareSchemeDetail.scala | 25 + .../ShareSchemesIncome.scala | 25 + .../stateBenefitsIncome/CommonBenefit.scala | 25 + .../CommonBenefitWithTaxPaid.scala | 25 + .../StateBenefitsDetail.scala | 31 + .../StateBenefitsIncome.scala | 28 + .../StatePensionLumpSum.scala | 25 + .../studentLoans/StudentLoans.scala | 35 + ...sinessAssetsDisposalsAndInvestorsRel.scala | 34 + .../taxCalculation/CapitalGainsTax.scala | 40 + .../calculation/taxCalculation/CgtBand.scala | 30 + .../taxCalculation/CgtBandName.scala | 35 + .../taxCalculation/Class2Nics.scala | 34 + .../taxCalculation/Class4Nics.scala | 33 + .../taxCalculation/IncomeTax.scala | 46 + .../taxCalculation/IncomeTaxBand.scala | 32 + .../taxCalculation/IncomeTaxBandName.scala | 60 + .../taxCalculation/IncomeTaxItem.scala | 31 + .../calculation/taxCalculation/Nic4Band.scala | 32 + .../taxCalculation/Nic4BandName.scala | 39 + .../calculation/taxCalculation/Nics.scala | 31 + .../taxCalculation/OtherGains.scala | 36 + ...esidentialPropertyAndCarriedInterest.scala | 34 + .../taxCalculation/TaxCalculation.scala | 38 + .../TaxDeductedAtSource.scala | 35 + .../transitionProfit/TransitionProfit.scala | 28 + .../TransitionProfitDetail.scala | 34 + .../AllowancesReliefsAndDeductions.scala | 29 + .../response/inputs/AnnualAdjustment.scala | 49 + .../inputs/BusinessIncomeSource.scala | 49 + .../def2/model/response/inputs/Claim.scala | 47 + .../inputs/ConstructionIndustryScheme.scala | 25 + .../model/response/inputs/IncomeSources.scala | 25 + .../def2/model/response/inputs/Inputs.scala | 47 + .../response/inputs/LossBroughtForward.scala | 47 + .../inputs/NonBusinessIncomeSource.scala | 52 + .../def2/model/response/inputs/Other.scala | 25 + .../PensionContributionAndCharges.scala | 29 + .../model/response/inputs/PeriodData.scala | 25 + .../response/inputs/PersonalInformation.scala | 33 + .../response/inputs/StudentLoanPlan.scala | 27 + .../response/inputs/SubmissionPeriod.scala | 25 + .../model/response/messages/Messages.scala | 28 + .../model/response/metadata/Metadata.scala | 59 + .../RetrieveCalculationRequestData.scala | 35 + .../RetrieveCalculationResponse.scala | 192 +++ .../schema/RetrieveCalculationSchema.scala | 53 + conf/v7.routes | 4 +- .../ListCalculationsControllerISpec.scala | 203 +++ ...1_RetrieveCalculationControllerISpec.scala | 274 +++++ ...2_RetrieveCalculationControllerISpec.scala | 151 +++ .../taxCalculation_downstream.json | 198 +++ .../taxCalculation/taxCalculation_mtd.json | 198 +++ .../response/calculation_downstream.json | 1094 +++++++++++++++++ .../def1/model/response/calculation_mtd.json | 1079 ++++++++++++++++ .../taxCalculation_downstream.json | 198 +++ .../taxCalculation/taxCalculation_mtd.json | 198 +++ .../response/calculation_downstream.json | 1093 ++++++++++++++++ .../def2/model/response/calculation_mtd.json | 1078 ++++++++++++++++ .../model/response/CalculationTypeSpec.scala | 35 + .../common/model/response/ClaimTypeSpec.scala | 43 + .../model/response/IncomeSourceTypeSpec.scala | 97 ++ .../model/response/PensionBandNameSpec.scala | 41 + .../response/ReliefsClaimedTypeSpec.scala | 49 + .../response/StudentLoanPlanTypeSpec.scala | 39 + .../ListCalculationsConnectorSpec.scala | 88 ++ .../ListCalculationsControllerSpec.scala | 105 ++ .../ListCalculationsServiceSpec.scala | 86 ++ ...ListCalculationsValidatorFactorySpec.scala | 48 + .../MockListCalculationsConnector.scala | 42 + .../MockListCalculationsService.scala | 43 + ...MockListCalculationsValidatorFactory.scala | 31 + .../Def1_ListCalculationsValidatorSpec.scala | 101 ++ .../model/Def1_ListCalculationsFixture.scala | 77 ++ .../Def1_ListCalculationsResponseSpec.scala | 39 + .../schema/ListCalculationsSchemaSpec.scala | 66 + .../MockRetrieveCalculationConnector.scala | 42 + .../MockRetrieveCalculationService.scala | 44 + ...kRetrieveCalculationValidatorFactory.scala | 31 + .../RetrieveCalculationConnectorSpec.scala | 114 ++ .../RetrieveCalculationControllerSpec.scala | 258 ++++ .../RetrieveCalculationServiceSpec.scala | 92 ++ ...rieveCalculationValidatorFactorySpec.scala | 50 + ...ef1_RetrieveCalculationValidatorSpec.scala | 107 ++ .../def1/model/Def1_CalculationFixture.scala | 873 +++++++++++++ ...Def1_RetrieveCalculationResponseSpec.scala | 45 + ...trieveCalculationResponseWithoutSpec.scala | 96 ++ .../AllowancesAndDeductionsSpec.scala | 130 ++ .../BusinessProfitAndLossSpec.scala | 145 +++ .../CommonForeignDividendSpec.scala | 77 ++ .../dividendsIncome/DividendsIncomeSpec.scala | 160 +++ .../dividendsIncome/UkDividendsSpec.scala | 71 ++ .../BenefitsInKindDetailSpec.scala | 142 +++ .../EmploymentAndPensionsIncomeSpec.scala | 72 ++ .../endOfYearEstimate/IncomeSourceSpec.scala | 74 ++ .../CarriedForwardLossSpec.scala | 102 ++ .../lossesAndClaims/ClaimNotAppliedSpec.scala | 90 ++ .../DefaultCarriedForwardLossSpec.scala | 86 ++ .../ResultOfClaimsAppliedSpec.scala | 108 ++ .../lossesAndClaims/UnclaimedLossSpec.scala | 89 ++ .../ForeignSavingsAndGainsIncomeSpec.scala | 77 ++ .../SavingsAndGainsIncomeSpec.scala | 128 ++ .../UkSavingsAndGainsIncomeSpec.scala | 77 ++ ...ssAssetsDisposalsAndInvestorsRelSpec.scala | 31 + .../taxCalculation/CapitalGainsTaxSpec.scala | 35 + .../taxCalculation/CgtBandNameSpec.scala | 35 + .../taxCalculation/CgtBandSpec.scala | 31 + .../taxCalculation/Class2NicsSpec.scala | 31 + .../taxCalculation/Class4NicsSpec.scala | 30 + .../IncomeTaxBandNameSpec.scala | 49 + .../taxCalculation/IncomeTaxBandSpec.scala | 31 + .../taxCalculation/IncomeTaxItemSpec.scala | 31 + .../taxCalculation/IncomeTaxSpec.scala | 35 + .../taxCalculation/Nic4BandNameSpec.scala | 37 + .../taxCalculation/Nic4BandSpec.scala | 31 + .../calculation/taxCalculation/NicsSpec.scala | 30 + .../taxCalculation/OtherGainsSpec.scala | 31 + ...entialPropertyAndCarriedInterestSpec.scala | 31 + .../TaxCalculationFixture.scala | 29 + .../taxCalculation/TaxCalculationSpec.scala | 38 + .../response/metadata/MetadataSpec.scala | 132 ++ ...ef2_RetrieveCalculationValidatorSpec.scala | 107 ++ .../def2/model/Def2_CalculationFixture.scala | 29 + ...Def2_RetrieveCalculationResponseSpec.scala | 90 ++ .../AllowancesAndDeductionsSpec.scala | 130 ++ .../BusinessProfitAndLossSpec.scala | 145 +++ .../CommonForeignDividendSpec.scala | 77 ++ .../dividendsIncome/DividendsIncomeSpec.scala | 160 +++ .../dividendsIncome/UkDividendsSpec.scala | 71 ++ .../BenefitsInKindDetailSpec.scala | 142 +++ .../endOfYearEstimate/IncomeSourceSpec.scala | 74 ++ .../CarriedForwardLossSpec.scala | 102 ++ .../lossesAndClaims/ClaimNotAppliedSpec.scala | 90 ++ .../DefaultCarriedForwardLossSpec.scala | 86 ++ .../ResultOfClaimsAppliedSpec.scala | 108 ++ .../lossesAndClaims/UnclaimedLossSpec.scala | 89 ++ .../ForeignSavingsAndGainsIncomeSpec.scala | 77 ++ .../SavingsAndGainsIncomeSpec.scala | 128 ++ .../UkSavingsAndGainsIncomeSpec.scala | 77 ++ ...ssAssetsDisposalsAndInvestorsRelSpec.scala | 31 + .../taxCalculation/CapitalGainsTaxSpec.scala | 35 + .../taxCalculation/CgtBandNameSpec.scala | 35 + .../taxCalculation/CgtBandSpec.scala | 31 + .../taxCalculation/Class2NicsSpec.scala | 31 + .../taxCalculation/Class4NicsSpec.scala | 30 + .../IncomeTaxBandNameSpec.scala | 51 + .../taxCalculation/IncomeTaxBandSpec.scala | 31 + .../taxCalculation/IncomeTaxItemSpec.scala | 31 + .../taxCalculation/IncomeTaxSpec.scala | 35 + .../taxCalculation/Nic4BandNameSpec.scala | 37 + .../taxCalculation/Nic4BandSpec.scala | 31 + .../calculation/taxCalculation/NicsSpec.scala | 30 + .../taxCalculation/OtherGainsSpec.scala | 31 + ...entialPropertyAndCarriedInterestSpec.scala | 31 + .../TaxCalculationFixture.scala | 30 + .../taxCalculation/TaxCalculationSpec.scala | 38 + .../response/metadata/MetadataSpec.scala | 129 ++ .../RetrieveCalculationSchemaSpec.scala | 52 + 391 files changed, 23963 insertions(+), 2 deletions(-) create mode 100644 app/v7/common/model/response/CalculationType.scala create mode 100644 app/v7/common/model/response/ClaimType.scala create mode 100644 app/v7/common/model/response/IncomeSourceType.scala create mode 100644 app/v7/common/model/response/PensionBandName.scala create mode 100644 app/v7/common/model/response/ReliefsClaimedType.scala create mode 100644 app/v7/common/model/response/Source.scala create mode 100644 app/v7/common/model/response/StudentLoanPlanType.scala create mode 100644 app/v7/listCalculations/ListCalculationsConnector.scala create mode 100644 app/v7/listCalculations/ListCalculationsController.scala create mode 100644 app/v7/listCalculations/ListCalculationsService.scala create mode 100644 app/v7/listCalculations/ListCalculationsValidatorFactory.scala create mode 100644 app/v7/listCalculations/def1/Def1_ListCalculationsValidator.scala create mode 100644 app/v7/listCalculations/def1/model/response/Def1_Calculation.scala create mode 100644 app/v7/listCalculations/model/request/ListCalculationsRequestData.scala create mode 100644 app/v7/listCalculations/model/response/ListCalculationsResponse.scala create mode 100644 app/v7/listCalculations/schema/ListCalculationsSchema.scala create mode 100644 app/v7/retrieveCalculation/RetrieveCalculationConnector.scala create mode 100644 app/v7/retrieveCalculation/RetrieveCalculationController.scala create mode 100644 app/v7/retrieveCalculation/RetrieveCalculationService.scala create mode 100644 app/v7/retrieveCalculation/RetrieveCalculationValidatorFactory.scala create mode 100644 app/v7/retrieveCalculation/def1/Def1_RetrieveCalculationValidator.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/Calculation.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductions.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AnnuityPayments.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/MarriageAllowanceTransferOut.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/PensionContributionsDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLoss.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ChargeableEventGainsIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesNoTaxPaidDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesTaxPaidDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/CodedOutUnderpayments.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/PayeUnderpaymentsDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/SelfAssessmentUnderpaymentsDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/CommonForeignDividend.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/UkDividends.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitFromEmployerFinancedRetirementScheme.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKind.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/LumpSums.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/LumpSumsDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsOverExemption.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsUnderExemption.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/StudentLoans.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/TaxableLumpSumsAndCertainIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentExpenses/EmploymentExpenses.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/employmentExpenses/EmploymentExpensesDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/EndOfYearEstimate.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/IncomeSource.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/ChargeableForeignBenefitsAndGiftsDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/CommonForeignIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/ForeignIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/OverseasIncomeAndGains.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/foreignPropertyIncome/ForeignPropertyIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/foreignTaxForFtcrNotClaimed/ForeignTaxForFtcrNotClaimed.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/giftAid/GiftAid.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/incomeSummaryTotals/IncomeSummaryTotals.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ClaimNotApplied.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLoss.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossesAndClaims.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/marriageAllowanceTransferredIn/MarriageAllowanceTransferredIn.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/notionalTax/NotionalTax.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/OtherIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/PostCessationIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/PostCessationReceipt.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionContributionReliefs/PensionContributionDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionContributionReliefs/PensionContributionReliefs.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ExcessOfLifeTimeAllowance.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/OverseasPensionContributions.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionBand.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionContributionsInExcessOfTheAnnualAllowance.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsDetailBreakdown.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxCharges.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxChargesDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeOverseasTransfers.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeUnauthorisedPayments.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/previousCalculation/PreviousCalculation.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/AllOtherIncomeReceivedWhilstAbroad.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/BasicRateExtension.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignProperty.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignPropertyRfcDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignTaxCreditRelief.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignTaxCreditReliefDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/GiftAidTaxReductionWhereBasicRateDiffers.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/OtherIncomeRfcDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/Reliefs.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimed.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ResidentialFinanceCosts.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/TopSlicingRelief.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/UkProperty.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/royaltyPayments/RoyaltyPayments.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/seafarersDeductions/SeafarersDeductionDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/seafarersDeductions/SeafarersDeductions.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemesIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/CommonBenefit.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/CommonBenefitWithTaxPaid.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StateBenefitsDetail.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StateBenefitsIncome.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StatePensionLumpSum.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/studentLoans/StudentLoans.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRel.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CapitalGainsTax.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBand.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandName.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class2Nics.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class4Nics.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTax.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBand.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandName.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxItem.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4Band.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandName.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nics.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/OtherGains.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterest.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculation.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/calculation/taxDeductedAtSource/TaxDeductedAtSource.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/AnnualAdjustment.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/BusinessIncomeSource.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/Claim.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/ConstructionIndustryScheme.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/IncomeSources.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/Inputs.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/LossBroughtForward.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/NonBusinessIncomeSource.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/PeriodData.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/StudentLoanPlan.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/inputs/SubmissionPeriod.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/messages/Messages.scala create mode 100644 app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala create mode 100644 app/v7/retrieveCalculation/def2/Def2_RetrieveCalculationValidator.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/Calculation.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductions.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AnnuityPayments.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/MarriageAllowanceTransferOut.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/PensionContributionsDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLoss.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ChargeableEventGainsIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesNoTaxPaidDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesTaxPaidDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/CodedOutUnderpayments.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/PayeUnderpaymentsDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/SelfAssessmentUnderpaymentsDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/CommonForeignDividend.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/UkDividends.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitFromEmployerFinancedRetirementScheme.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKind.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/LumpSums.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/LumpSumsDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsOverExemption.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsUnderExemption.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/StudentLoans.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/TaxableLumpSumsAndCertainIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentExpenses/EmploymentExpenses.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentExpenses/EmploymentExpensesDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/EndOfYearEstimate.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/IncomeSource.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/ChargeableForeignBenefitsAndGiftsDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/CommonForeignIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/ForeignIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/OverseasIncomeAndGains.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/foreignPropertyIncome/ForeignPropertyIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/foreignTaxForFtcrNotClaimed/ForeignTaxForFtcrNotClaimed.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/giftAid/GiftAid.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/incomeSummaryTotals/IncomeSummaryTotals.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ClaimNotApplied.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLoss.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossesAndClaims.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/marriageAllowanceTransferredIn/MarriageAllowanceTransferredIn.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/notionalTax/NotionalTax.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/OtherIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/PostCessationIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/PostCessationReceipt.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionContributionReliefs/PensionContributionDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionContributionReliefs/PensionContributionReliefs.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/OverseasPensionContributions.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionBand.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionContributionsInExcessOfTheAnnualAllowance.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsDetailBreakdown.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxCharges.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxChargesDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeOverseasTransfers.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeUnauthorisedPayments.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/previousCalculation/PreviousCalculation.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/AllOtherIncomeReceivedWhilstAbroad.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/BasicRateExtension.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignProperty.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignPropertyRfcDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignTaxCreditRelief.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignTaxCreditReliefDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/GiftAidTaxReductionWhereBasicRateDiffers.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/OtherIncomeRfcDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/Reliefs.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimed.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ResidentialFinanceCosts.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/TopSlicingRelief.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/UkProperty.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/royaltyPayments/RoyaltyPayments.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/seafarersDeductions/SeafarersDeductionDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/seafarersDeductions/SeafarersDeductions.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemesIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/CommonBenefit.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/CommonBenefitWithTaxPaid.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StateBenefitsDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StateBenefitsIncome.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StatePensionLumpSum.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/studentLoans/StudentLoans.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRel.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CapitalGainsTax.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBand.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandName.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class2Nics.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class4Nics.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTax.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBand.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandName.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxItem.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4Band.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandName.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nics.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/OtherGains.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterest.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculation.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/taxDeductedAtSource/TaxDeductedAtSource.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/transitionProfit/TransitionProfit.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/transitionProfit/TransitionProfitDetail.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/AnnualAdjustment.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/BusinessIncomeSource.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/Claim.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/ConstructionIndustryScheme.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/IncomeSources.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/Inputs.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/LossBroughtForward.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/NonBusinessIncomeSource.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/PeriodData.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/StudentLoanPlan.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/SubmissionPeriod.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/messages/Messages.scala create mode 100644 app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala create mode 100644 app/v7/retrieveCalculation/models/request/RetrieveCalculationRequestData.scala create mode 100644 app/v7/retrieveCalculation/models/response/RetrieveCalculationResponse.scala create mode 100644 app/v7/retrieveCalculation/schema/RetrieveCalculationSchema.scala create mode 100644 it/v7/listCalculations/def1/ListCalculationsControllerISpec.scala create mode 100644 it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala create mode 100644 it/v7/retrieveCalculation/def2/Def2_RetrieveCalculationControllerISpec.scala create mode 100644 test/resources/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_downstream.json create mode 100644 test/resources/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_mtd.json create mode 100644 test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json create mode 100644 test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json create mode 100644 test/resources/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_downstream.json create mode 100644 test/resources/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_mtd.json create mode 100644 test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json create mode 100644 test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json create mode 100644 test/v7/common/model/response/CalculationTypeSpec.scala create mode 100644 test/v7/common/model/response/ClaimTypeSpec.scala create mode 100644 test/v7/common/model/response/IncomeSourceTypeSpec.scala create mode 100644 test/v7/common/model/response/PensionBandNameSpec.scala create mode 100644 test/v7/common/model/response/ReliefsClaimedTypeSpec.scala create mode 100644 test/v7/common/model/response/StudentLoanPlanTypeSpec.scala create mode 100644 test/v7/listCalculations/ListCalculationsConnectorSpec.scala create mode 100644 test/v7/listCalculations/ListCalculationsControllerSpec.scala create mode 100644 test/v7/listCalculations/ListCalculationsServiceSpec.scala create mode 100644 test/v7/listCalculations/ListCalculationsValidatorFactorySpec.scala create mode 100644 test/v7/listCalculations/MockListCalculationsConnector.scala create mode 100644 test/v7/listCalculations/MockListCalculationsService.scala create mode 100644 test/v7/listCalculations/MockListCalculationsValidatorFactory.scala create mode 100644 test/v7/listCalculations/def1/Def1_ListCalculationsValidatorSpec.scala create mode 100644 test/v7/listCalculations/def1/model/Def1_ListCalculationsFixture.scala create mode 100644 test/v7/listCalculations/def1/model/response/Def1_ListCalculationsResponseSpec.scala create mode 100644 test/v7/listCalculations/schema/ListCalculationsSchemaSpec.scala create mode 100644 test/v7/retrieveCalculation/MockRetrieveCalculationConnector.scala create mode 100644 test/v7/retrieveCalculation/MockRetrieveCalculationService.scala create mode 100644 test/v7/retrieveCalculation/MockRetrieveCalculationValidatorFactory.scala create mode 100644 test/v7/retrieveCalculation/RetrieveCalculationConnectorSpec.scala create mode 100644 test/v7/retrieveCalculation/RetrieveCalculationControllerSpec.scala create mode 100644 test/v7/retrieveCalculation/RetrieveCalculationServiceSpec.scala create mode 100644 test/v7/retrieveCalculation/RetrieveCalculationValidatorFactorySpec.scala create mode 100644 test/v7/retrieveCalculation/def1/Def1_RetrieveCalculationValidatorSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/Def1_RetrieveCalculationResponseSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/RetrieveCalculationResponseWithoutSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductionsSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLossSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/CommonForeignDividendSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/UkDividendsSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetailSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/IncomeSourceSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ClaimNotAppliedSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLossSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRelSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CapitalGainsTaxSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandNameSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class2NicsSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class4NicsSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxItemSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandNameSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/NicsSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/OtherGainsSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterestSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculationFixture.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculationSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/Def2_RetrieveCalculationValidatorSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/Def2_CalculationFixture.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/Def2_RetrieveCalculationResponseSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductionsSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLossSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/CommonForeignDividendSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/UkDividendsSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetailSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/IncomeSourceSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ClaimNotAppliedSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLossSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncomeSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRelSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CapitalGainsTaxSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandNameSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class2NicsSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class4NicsSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxItemSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandNameSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/NicsSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/OtherGainsSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterestSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculationFixture.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculationSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala create mode 100644 test/v7/retrieveCalculation/schema/RetrieveCalculationSchemaSpec.scala diff --git a/app/v7/common/model/response/CalculationType.scala b/app/v7/common/model/response/CalculationType.scala new file mode 100644 index 000000000..e83c18d1c --- /dev/null +++ b/app/v7/common/model/response/CalculationType.scala @@ -0,0 +1,36 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait CalculationType + +object CalculationType { + + case object `inYear` extends CalculationType + case object `finalDeclaration` extends CalculationType + + implicit val writes: Writes[CalculationType] = Enums.writes[CalculationType] + + implicit val reads: Reads[CalculationType] = Enums.readsUsing[CalculationType] { + case "inYear" => `inYear` + case "crystallisation" => `finalDeclaration` + } + +} diff --git a/app/v7/common/model/response/ClaimType.scala b/app/v7/common/model/response/ClaimType.scala new file mode 100644 index 000000000..a8a481193 --- /dev/null +++ b/app/v7/common/model/response/ClaimType.scala @@ -0,0 +1,43 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait ClaimType + +object ClaimType { + case object `carry-forward` extends ClaimType + case object `carry-sideways` extends ClaimType + case object `carry-forward-to-carry-sideways` extends ClaimType + case object `carry-sideways-fhl` extends ClaimType + case object `carry-backwards` extends ClaimType + case object `carry-backwards-general-income` extends ClaimType + + implicit val writes: Writes[ClaimType] = Enums.writes[ClaimType] + + implicit val reads: Reads[ClaimType] = Enums.readsUsing { + case "CF" => `carry-forward` + case "CSGI" => `carry-sideways` + case "CFCSGI" => `carry-forward-to-carry-sideways` + case "CSFHL" => `carry-sideways-fhl` + case "CB" => `carry-backwards` + case "CBGI" => `carry-backwards-general-income` + } + +} diff --git a/app/v7/common/model/response/IncomeSourceType.scala b/app/v7/common/model/response/IncomeSourceType.scala new file mode 100644 index 000000000..608b7bd47 --- /dev/null +++ b/app/v7/common/model/response/IncomeSourceType.scala @@ -0,0 +1,80 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json._ + +sealed trait IncomeSourceType + +object IncomeSourceType { + + case object `self-employment` extends IncomeSourceType + case object `uk-property-non-fhl` extends IncomeSourceType + case object `foreign-property-fhl-eea` extends IncomeSourceType + case object `uk-property-fhl` extends IncomeSourceType + case object `employments` extends IncomeSourceType + case object `foreign-income` extends IncomeSourceType + case object `foreign-dividends` extends IncomeSourceType + case object `uk-savings-and-gains` extends IncomeSourceType + case object `uk-dividends` extends IncomeSourceType + case object `state-benefits` extends IncomeSourceType + case object `gains-on-life-policies` extends IncomeSourceType + case object `share-schemes` extends IncomeSourceType + case object `foreign-property` extends IncomeSourceType + case object `foreign-savings-and-gains` extends IncomeSourceType + case object `other-dividends` extends IncomeSourceType + case object `uk-securities` extends IncomeSourceType + case object `other-income` extends IncomeSourceType + case object `foreign-pension` extends IncomeSourceType + case object `non-paye-income` extends IncomeSourceType + case object `capital-gains-tax` extends IncomeSourceType + case object `charitable-giving` extends IncomeSourceType + + implicit val incomeSourceTypeWrites: Writes[IncomeSourceType] = Enums.writes[IncomeSourceType] + + implicit val reads: Reads[IncomeSourceType] = Enums.readsUsing { + case "01" => `self-employment` + case "02" => `uk-property-non-fhl` + case "03" => `foreign-property-fhl-eea` + case "04" => `uk-property-fhl` + case "05" => `employments` + case "06" => `foreign-income` + case "07" => `foreign-dividends` + case "09" => `uk-savings-and-gains` + case "10" => `uk-dividends` + case "11" => `state-benefits` + case "12" => `gains-on-life-policies` + case "13" => `share-schemes` + case "15" => `foreign-property` + case "16" => `foreign-savings-and-gains` + case "17" => `other-dividends` + case "18" => `uk-securities` + case "19" => `other-income` + case "20" => `foreign-pension` + case "21" => `non-paye-income` + case "22" => `capital-gains-tax` + case "98" => `charitable-giving` + } + + def formatRestricted(types: IncomeSourceType*): Format[IncomeSourceType] = new Format[IncomeSourceType] { + override def writes(o: IncomeSourceType): JsValue = incomeSourceTypeWrites.writes(o) + + override def reads(json: JsValue): JsResult[IncomeSourceType] = json.validate[IncomeSourceType](Enums.readsRestricted(types: _*)) + } + +} diff --git a/app/v7/common/model/response/PensionBandName.scala b/app/v7/common/model/response/PensionBandName.scala new file mode 100644 index 000000000..6b4d59731 --- /dev/null +++ b/app/v7/common/model/response/PensionBandName.scala @@ -0,0 +1,41 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait PensionBandName + +object PensionBandName { + case object `basic-rate` extends PensionBandName + case object `intermediate-rate` extends PensionBandName + case object `higher-rate` extends PensionBandName + case object `additional-rate` extends PensionBandName + case object `advanced-rate` extends PensionBandName + + implicit val writes: Writes[PensionBandName] = Enums.writes[PensionBandName] + + implicit val reads: Reads[PensionBandName] = Enums.readsUsing { + case "BRT" => `basic-rate` + case "IRT" => `intermediate-rate` + case "HRT" => `higher-rate` + case "ART" => `additional-rate` + case "AVRT" => `advanced-rate` + } + +} diff --git a/app/v7/common/model/response/ReliefsClaimedType.scala b/app/v7/common/model/response/ReliefsClaimedType.scala new file mode 100644 index 000000000..7472f8913 --- /dev/null +++ b/app/v7/common/model/response/ReliefsClaimedType.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait ReliefsClaimedType + +object ReliefsClaimedType { + case object vctSubscriptions extends ReliefsClaimedType + case object eisSubscriptions extends ReliefsClaimedType + case object communityInvestment extends ReliefsClaimedType + case object seedEnterpriseInvestment extends ReliefsClaimedType + case object socialEnterpriseInvestment extends ReliefsClaimedType + case object maintenancePayments extends ReliefsClaimedType + case object deficiencyRelief extends ReliefsClaimedType + case object nonDeductibleLoanInterest extends ReliefsClaimedType + case object qualifyingDistributionRedemptionOfSharesAndSecurities extends ReliefsClaimedType + + implicit val writes: Writes[ReliefsClaimedType] = Enums.writes[ReliefsClaimedType] + + implicit val reads: Reads[ReliefsClaimedType] = Enums.readsUsing { + case "vctSubscriptions" => vctSubscriptions + case "eisSubscriptions" => eisSubscriptions + case "communityInvestment" => communityInvestment + case "seedEnterpriseInvestment" => seedEnterpriseInvestment + case "socialEnterpriseInvestment" => socialEnterpriseInvestment + case "maintenancePayments" => maintenancePayments + case "deficiencyRelief" => deficiencyRelief + case "nonDeductableLoanInterest" => nonDeductibleLoanInterest + case "qualifyingDistributionRedemptionOfSharesAndSecurities" => qualifyingDistributionRedemptionOfSharesAndSecurities + } + +} diff --git a/app/v7/common/model/response/Source.scala b/app/v7/common/model/response/Source.scala new file mode 100644 index 000000000..dd6750299 --- /dev/null +++ b/app/v7/common/model/response/Source.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.Format + +sealed trait Source + +object Source { + + case object `customer` extends Source + case object `HMRC HELD` extends Source + + implicit val format: Format[Source] = Enums.format[Source] +} diff --git a/app/v7/common/model/response/StudentLoanPlanType.scala b/app/v7/common/model/response/StudentLoanPlanType.scala new file mode 100644 index 000000000..f0b2ccd9c --- /dev/null +++ b/app/v7/common/model/response/StudentLoanPlanType.scala @@ -0,0 +1,40 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait StudentLoanPlanType + +object StudentLoanPlanType { + + case object `plan1` extends StudentLoanPlanType + case object `plan2` extends StudentLoanPlanType + case object `postgraduate` extends StudentLoanPlanType + case object `plan4` extends StudentLoanPlanType + + implicit val writes: Writes[StudentLoanPlanType] = Enums.writes[StudentLoanPlanType] + + implicit val reads: Reads[StudentLoanPlanType] = Enums.readsUsing { + case "01" => `plan1` + case "02" => `plan2` + case "03" => `postgraduate` + case "04" => `plan4` + } + +} diff --git a/app/v7/listCalculations/ListCalculationsConnector.scala b/app/v7/listCalculations/ListCalculationsConnector.scala new file mode 100644 index 000000000..d1eb3e428 --- /dev/null +++ b/app/v7/listCalculations/ListCalculationsConnector.scala @@ -0,0 +1,53 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.connectors.DownstreamUri.{DesUri, TaxYearSpecificIfsUri} +import shared.connectors.httpparsers.StandardDownstreamHttpParser._ +import shared.connectors.{BaseDownstreamConnector, DownstreamOutcome, DownstreamUri} +import shared.config.AppConfig +import uk.gov.hmrc.http.{HeaderCarrier, HttpClient} +import v7.listCalculations.def1.model.response.Calculation +import v7.listCalculations.model.request.ListCalculationsRequestData +import v7.listCalculations.model.response.ListCalculationsResponse + +import javax.inject.{Inject, Singleton} +import scala.concurrent.{ExecutionContext, Future} + +@Singleton +class ListCalculationsConnector @Inject() (val http: HttpClient, val appConfig: AppConfig) extends BaseDownstreamConnector { + + def list(request: ListCalculationsRequestData)(implicit + hc: HeaderCarrier, + ec: ExecutionContext, + correlationId: String + ): Future[DownstreamOutcome[ListCalculationsResponse[Calculation]]] = { + + import request._ + import schema._ + + val downstreamUri: DownstreamUri[DownstreamResp] = + if (taxYear.useTaxYearSpecificApi) { + TaxYearSpecificIfsUri(s"income-tax/view/calculations/liability/${taxYear.asTysDownstream}/$nino") + } else { + DesUri(s"income-tax/list-of-calculation-results/$nino?taxYear=${taxYear.asDownstream}") + } + + get(downstreamUri) + } + +} diff --git a/app/v7/listCalculations/ListCalculationsController.scala b/app/v7/listCalculations/ListCalculationsController.scala new file mode 100644 index 000000000..5b6dc2b58 --- /dev/null +++ b/app/v7/listCalculations/ListCalculationsController.scala @@ -0,0 +1,60 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.utils.{IdGenerator, Logging} +import shared.controllers._ +import shared.services.{EnrolmentsAuthService, MtdIdLookupService} +import play.api.mvc.{Action, AnyContent, ControllerComponents} +import v7.listCalculations.schema.ListCalculationsSchema + +import javax.inject.{Inject, Singleton} +import scala.concurrent.ExecutionContext + +@Singleton +class ListCalculationsController @Inject() (val authService: EnrolmentsAuthService, + val lookupService: MtdIdLookupService, + validatorFactory: ListCalculationsValidatorFactory, + service: ListCalculationsService, + cc: ControllerComponents, + val idGenerator: IdGenerator)(implicit val ec: ExecutionContext, appConfig: shared.config.AppConfig) + extends AuthorisedController(cc) + with Logging { + + val endpointName = "list-calculations" + + implicit val endpointLogContext: EndpointLogContext = EndpointLogContext( + controllerName = "ListCalculationsController", + endpointName = "list" + ) + + def list(nino: String, taxYear: Option[String]): Action[AnyContent] = + authorisedAction(nino).async { implicit request => + implicit val ctx: RequestContext = RequestContext.from(idGenerator, endpointLogContext) + + val validator = validatorFactory.validator(nino, taxYear, ListCalculationsSchema.schemaFor(taxYear)) + + val requestHandler = + RequestHandler + .withValidator(validator) + .withService(service.list) + .withPlainJsonResult() + + requestHandler.handleRequest() + } + +} diff --git a/app/v7/listCalculations/ListCalculationsService.scala b/app/v7/listCalculations/ListCalculationsService.scala new file mode 100644 index 000000000..97878abd5 --- /dev/null +++ b/app/v7/listCalculations/ListCalculationsService.scala @@ -0,0 +1,59 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.controllers.RequestContext +import shared.models +import shared.models.errors._ +import shared.services.{BaseService, ServiceOutcome} +import cats.implicits._ +import v7.listCalculations.def1.model.response.Calculation +import v7.listCalculations.model.request.ListCalculationsRequestData +import v7.listCalculations.model.response.ListCalculationsResponse + +import javax.inject.{Inject, Singleton} +import scala.concurrent.{ExecutionContext, Future} + +@Singleton +class ListCalculationsService @Inject() (connector: ListCalculationsConnector) extends BaseService { + + def list(request: ListCalculationsRequestData)(implicit + ctx: RequestContext, + ec: ExecutionContext): Future[ServiceOutcome[ListCalculationsResponse[Calculation]]] = { + + connector.list(request).map(_.leftMap(mapDownstreamErrors(downstreamErrorMap))) + + } + + private val downstreamErrorMap: Map[String, MtdError] = { + val errors = Map( + "INVALID_TAXABLE_ENTITY_ID" -> NinoFormatError, + "INVALID_TAXYEAR" -> TaxYearFormatError, + "NOT_FOUND" -> NotFoundError, + "SERVER_ERROR" -> models.errors.InternalError, + "SERVICE_UNAVAILABLE" -> models.errors.InternalError, + "UNMATCHED_STUB_ERROR" -> RuleIncorrectGovTestScenarioError + ) + val extraTysErrors = Map( + "INVALID_TAX_YEAR" -> TaxYearFormatError, + "INVALID_CORRELATION_ID" -> models.errors.InternalError, + "TAX_YEAR_NOT_SUPPORTED" -> RuleTaxYearNotSupportedError + ) + errors ++ extraTysErrors + } + +} diff --git a/app/v7/listCalculations/ListCalculationsValidatorFactory.scala b/app/v7/listCalculations/ListCalculationsValidatorFactory.scala new file mode 100644 index 000000000..513178430 --- /dev/null +++ b/app/v7/listCalculations/ListCalculationsValidatorFactory.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.controllers.validators.Validator +import v7.listCalculations.def1.Def1_ListCalculationsValidator +import v7.listCalculations.model.request.ListCalculationsRequestData +import v7.listCalculations.schema.ListCalculationsSchema + +import javax.inject.Singleton + +@Singleton +class ListCalculationsValidatorFactory { + + def validator(nino: String, taxYear: Option[String], schema: ListCalculationsSchema): Validator[ListCalculationsRequestData] = + schema match { + case ListCalculationsSchema.Def1 => new Def1_ListCalculationsValidator(nino, taxYear) + } + +} diff --git a/app/v7/listCalculations/def1/Def1_ListCalculationsValidator.scala b/app/v7/listCalculations/def1/Def1_ListCalculationsValidator.scala new file mode 100644 index 000000000..b492039c8 --- /dev/null +++ b/app/v7/listCalculations/def1/Def1_ListCalculationsValidator.scala @@ -0,0 +1,45 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.def1 + +import shared.controllers.validators.Validator +import shared.controllers.validators.resolvers.ResolverSupport._ +import shared.controllers.validators.resolvers.{ResolveNino, ResolveTaxYear} +import shared.models.domain.TaxYear +import shared.models.errors.{MtdError, RuleTaxYearNotSupportedError} +import cats.data.Validated +import cats.implicits.catsSyntaxTuple2Semigroupal +import v7.listCalculations.model.request.{Def1_ListCalculationsRequestData, ListCalculationsRequestData} + +object Def1_ListCalculationsValidator { + private val listCalculationsMinimumTaxYear = TaxYear.fromMtd("2017-18") + + private val resolveTaxYear = ResolveTaxYear.resolver.resolveOptionallyWithDefault(TaxYear.currentTaxYear) thenValidate + satisfiesMin(listCalculationsMinimumTaxYear, RuleTaxYearNotSupportedError) + +} + +class Def1_ListCalculationsValidator(nino: String, taxYear: Option[String]) extends Validator[ListCalculationsRequestData] { + import Def1_ListCalculationsValidator._ + + def validate: Validated[Seq[MtdError], ListCalculationsRequestData] = + ( + ResolveNino(nino), + resolveTaxYear(taxYear) + ).mapN(Def1_ListCalculationsRequestData) + +} diff --git a/app/v7/listCalculations/def1/model/response/Def1_Calculation.scala b/app/v7/listCalculations/def1/model/response/Def1_Calculation.scala new file mode 100644 index 000000000..30b88bd96 --- /dev/null +++ b/app/v7/listCalculations/def1/model/response/Def1_Calculation.scala @@ -0,0 +1,63 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.def1.model.response + +import common.TaxYearFormats._ +import play.api.libs.functional.syntax._ +import play.api.libs.json.{JsPath, Json, OWrites, Reads} +import shared.models.domain.TaxYear +import v7.common.model.response.CalculationType + +sealed trait Calculation { + def calculationId: String + def taxYear: Option[TaxYear] +} + +object Calculation { + + implicit val writes: OWrites[Calculation] = OWrites.apply[Calculation] { case a: Def1_Calculation => + Json.toJsObject(a) + } + +} + +case class Def1_Calculation(calculationId: String, + calculationTimestamp: String, + calculationType: CalculationType, + requestedBy: Option[String], + taxYear: Option[TaxYear], + totalIncomeTaxAndNicsDue: Option[BigDecimal], + intentToSubmitFinalDeclaration: Option[Boolean], + finalDeclaration: Option[Boolean], + finalDeclarationTimestamp: Option[String]) + extends Calculation + +object Def1_Calculation { + implicit val writes: OWrites[Def1_Calculation] = Json.writes[Def1_Calculation] + + implicit val reads: Reads[Def1_Calculation] = + ((JsPath \ "calculationId").read[String] and + (JsPath \ "calculationTimestamp").read[String] and + (JsPath \ "calculationType").read[CalculationType] and + (JsPath \ "requestedBy").readNullable[String] and + (JsPath \ "year").readNullable[TaxYear] and + (JsPath \ "totalIncomeTaxAndNicsDue").readNullable[BigDecimal] and + (JsPath \ "intentToCrystallise").readNullable[Boolean] and + (JsPath \ "crystallised").readNullable[Boolean] and + (JsPath \ "crystallisationTimestamp").readNullable[String])(Def1_Calculation.apply _) + +} diff --git a/app/v7/listCalculations/model/request/ListCalculationsRequestData.scala b/app/v7/listCalculations/model/request/ListCalculationsRequestData.scala new file mode 100644 index 000000000..6e033f61d --- /dev/null +++ b/app/v7/listCalculations/model/request/ListCalculationsRequestData.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.model.request + +import shared.models.domain.{Nino, TaxYear} +import v7.listCalculations.schema.ListCalculationsSchema + +sealed trait ListCalculationsRequestData { + val nino: Nino + val taxYear: TaxYear + + val schema: ListCalculationsSchema +} + +case class Def1_ListCalculationsRequestData(nino: Nino, taxYear: TaxYear) extends ListCalculationsRequestData{ + override val schema: ListCalculationsSchema = ListCalculationsSchema.Def1 +} diff --git a/app/v7/listCalculations/model/response/ListCalculationsResponse.scala b/app/v7/listCalculations/model/response/ListCalculationsResponse.scala new file mode 100644 index 000000000..fc2a50109 --- /dev/null +++ b/app/v7/listCalculations/model/response/ListCalculationsResponse.scala @@ -0,0 +1,54 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.model.response + +import cats.Functor +import play.api.libs.json._ + +sealed trait ListCalculationsResponse[+I] { + def mapItems[B](f: I => B): ListCalculationsResponse[B] +} + +object ListCalculationsResponse { + + implicit def writes[I: Writes]: OWrites[ListCalculationsResponse[I]] = { case def1: Def1_ListCalculationsResponse[I] => + Json.toJsObject(def1) + } + + + implicit object ResponseFunctor extends Functor[ListCalculationsResponse] { + + override def map[A, B](fa: ListCalculationsResponse[A])(f: A => B): ListCalculationsResponse[B] = + fa.mapItems(f) + + } + +} + +case class Def1_ListCalculationsResponse[I](calculations: Seq[I]) extends ListCalculationsResponse[I] { + + override def mapItems[B](f: I => B): ListCalculationsResponse[B] = + Def1_ListCalculationsResponse(calculations.map(f)) + +} + +object Def1_ListCalculationsResponse { + + implicit def writes[I: Writes]: OWrites[Def1_ListCalculationsResponse[I]] = Json.writes[Def1_ListCalculationsResponse[I]] + implicit def reads[I: Reads]: Reads[Def1_ListCalculationsResponse[I]] = JsPath.read[Seq[I]].map(Def1_ListCalculationsResponse(_)) + +} diff --git a/app/v7/listCalculations/schema/ListCalculationsSchema.scala b/app/v7/listCalculations/schema/ListCalculationsSchema.scala new file mode 100644 index 000000000..cfea477af --- /dev/null +++ b/app/v7/listCalculations/schema/ListCalculationsSchema.scala @@ -0,0 +1,55 @@ +/* + * Copyright 2024 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.schema + +import shared.controllers.validators.resolvers.ResolveTaxYear +import shared.models.domain.TaxYear +import shared.schema.DownstreamReadable +import play.api.libs.json.Reads +import v7.listCalculations.def1.model.response.{Calculation, Def1_Calculation} +import v7.listCalculations.model.response.{Def1_ListCalculationsResponse, ListCalculationsResponse} + +import java.time.Clock +import scala.math.Ordered.orderingToOrdered + +sealed trait ListCalculationsSchema extends DownstreamReadable[ListCalculationsResponse[Calculation]] + +object ListCalculationsSchema { + + case object Def1 extends ListCalculationsSchema { + type DownstreamResp = Def1_ListCalculationsResponse[Def1_Calculation] + val connectorReads: Reads[DownstreamResp] = Def1_ListCalculationsResponse.reads + } + + private val defaultSchema = Def1 + + def schemaFor(maybeTaxYear: Option[String])(implicit clock: Clock = Clock.systemUTC): ListCalculationsSchema = { + maybeTaxYear + .map(ResolveTaxYear.resolver) + .flatMap(_.toOption.map(schemaFor)) + .getOrElse(schemaFor(TaxYear.currentTaxYear)) + } + + def schemaFor(taxYear: TaxYear): ListCalculationsSchema = { + if (TaxYear.starting(2023) <= taxYear) { + Def1 + } else { + defaultSchema + } + } + +} diff --git a/app/v7/retrieveCalculation/RetrieveCalculationConnector.scala b/app/v7/retrieveCalculation/RetrieveCalculationConnector.scala new file mode 100644 index 000000000..d7654f7e4 --- /dev/null +++ b/app/v7/retrieveCalculation/RetrieveCalculationConnector.scala @@ -0,0 +1,50 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import shared.connectors.DownstreamUri.{IfsUri, TaxYearSpecificIfsUri} +import shared.connectors.httpparsers.StandardDownstreamHttpParser._ +import shared.connectors.{BaseDownstreamConnector, DownstreamOutcome, DownstreamUri} +import shared.config.AppConfig +import uk.gov.hmrc.http.{HeaderCarrier, HttpClient} +import v7.retrieveCalculation.models.request.RetrieveCalculationRequestData +import v7.retrieveCalculation.models.response.RetrieveCalculationResponse + +import javax.inject.{Inject, Singleton} +import scala.concurrent.{ExecutionContext, Future} + +@Singleton +class RetrieveCalculationConnector @Inject() (val http: HttpClient, val appConfig: AppConfig) extends BaseDownstreamConnector { + + def retrieveCalculation(request: RetrieveCalculationRequestData)(implicit + hc: HeaderCarrier, + ec: ExecutionContext, + correlationId: String): Future[DownstreamOutcome[RetrieveCalculationResponse]] = { + + import request._ + import schema._ + + val downstreamUri: DownstreamUri[DownstreamResp] = if (taxYear.useTaxYearSpecificApi) { + TaxYearSpecificIfsUri(s"income-tax/view/calculations/liability/${taxYear.asTysDownstream}/$nino/$calculationId") + } else { + IfsUri(s"income-tax/view/calculations/liability/$nino/$calculationId") + } + + get(downstreamUri) + } + +} diff --git a/app/v7/retrieveCalculation/RetrieveCalculationController.scala b/app/v7/retrieveCalculation/RetrieveCalculationController.scala new file mode 100644 index 000000000..6814a0b5c --- /dev/null +++ b/app/v7/retrieveCalculation/RetrieveCalculationController.scala @@ -0,0 +1,82 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import shared.utils.{IdGenerator, Logging} +import shared.controllers._ +import shared.services.{AuditService, EnrolmentsAuthService, MtdIdLookupService} +import shared.config.AppConfig +import config.CalculationsFeatureSwitches +import play.api.mvc.{Action, AnyContent, ControllerComponents} +import shared.routing.Version +import v7.retrieveCalculation.models.response.RetrieveCalculationResponse +import v7.retrieveCalculation.schema.RetrieveCalculationSchema + +import javax.inject.Inject +import scala.concurrent.ExecutionContext + +class RetrieveCalculationController @Inject() (val authService: EnrolmentsAuthService, + val lookupService: MtdIdLookupService, + validatorFactory: RetrieveCalculationValidatorFactory, + service: RetrieveCalculationService, + auditService: AuditService, + cc: ControllerComponents, + val idGenerator: IdGenerator)(implicit val ec: ExecutionContext, appConfig: AppConfig) + extends AuthorisedController(cc) + with Logging { + + val endpointName = "retrieve-calculation" + + implicit val endpointLogContext: EndpointLogContext = + EndpointLogContext( + controllerName = "RetrieveCalculationController", + endpointName = "retrieveCalculation" + ) + + def retrieveCalculation(nino: String, taxYear: String, calculationId: String): Action[AnyContent] = + authorisedAction(nino).async { implicit request => + implicit val ctx: RequestContext = RequestContext.from(idGenerator, endpointLogContext) + + val validator = validatorFactory.validator( + nino = nino, + taxYear = taxYear, + calculationId = calculationId, + RetrieveCalculationSchema.schemaFor(taxYear) + ) + + val requestHandler = + RequestHandler + .withValidator(validator) + .withService(service.retrieveCalculation) + .withAuditing(AuditHandler( + auditService, + auditType = "RetrieveATaxCalculation", + transactionName = "retrieve-a-tax-calculation", + apiVersion = Version(request), + params = Map("nino" -> nino, "calculationId" -> calculationId, "taxYear" -> taxYear), + includeResponse = true + )) + .withResponseModifier { response: RetrieveCalculationResponse => + response.adjustFields(CalculationsFeatureSwitches()(appConfig), taxYear) + } + .withPlainJsonResult() + + requestHandler.handleRequest() + + } + +} diff --git a/app/v7/retrieveCalculation/RetrieveCalculationService.scala b/app/v7/retrieveCalculation/RetrieveCalculationService.scala new file mode 100644 index 000000000..8fe780fd9 --- /dev/null +++ b/app/v7/retrieveCalculation/RetrieveCalculationService.scala @@ -0,0 +1,63 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import shared.controllers.RequestContext +import shared.models.errors._ +import shared.services.{BaseService, ServiceOutcome} +import cats.implicits._ +import v7.retrieveCalculation.models.request.RetrieveCalculationRequestData +import v7.retrieveCalculation.models.response.RetrieveCalculationResponse + +import javax.inject.{Inject, Singleton} +import scala.concurrent.{ExecutionContext, Future} + +@Singleton +class RetrieveCalculationService @Inject() (connector: RetrieveCalculationConnector) extends BaseService { + + def retrieveCalculation(request: RetrieveCalculationRequestData)(implicit + ctx: RequestContext, + ec: ExecutionContext): Future[ServiceOutcome[RetrieveCalculationResponse]] = { + + connector.retrieveCalculation(request).map(_.leftMap(mapDownstreamErrors(downstreamErrorMap))) + + } + + private val downstreamErrorMap: Map[String, MtdError] = { + val errors: Map[String, MtdError] = Map( + "INVALID_TAXABLE_ENTITY_ID" -> NinoFormatError, + "INVALID_CALCULATION_ID" -> CalculationIdFormatError, + "INVALID_CORRELATIONID" -> InternalError, + "INVALID_CONSUMERID" -> InternalError, + "NO_DATA_FOUND" -> NotFoundError, + "SERVER_ERROR" -> InternalError, + "SERVICE_UNAVAILABLE" -> InternalError, + "UNMATCHED_STUB_ERROR" -> RuleIncorrectGovTestScenarioError + ) + + val extraTysErrors: Map[String, MtdError] = Map( + "INVALID_TAX_YEAR" -> TaxYearFormatError, + "INVALID_CORRELATION_ID" -> InternalError, + "INVALID_CONSUMER_ID" -> InternalError, + "NOT_FOUND" -> NotFoundError, + "TAX_YEAR_NOT_SUPPORTED" -> RuleTaxYearNotSupportedError + ) + + errors ++ extraTysErrors + } + +} diff --git a/app/v7/retrieveCalculation/RetrieveCalculationValidatorFactory.scala b/app/v7/retrieveCalculation/RetrieveCalculationValidatorFactory.scala new file mode 100644 index 000000000..53d9f1b3f --- /dev/null +++ b/app/v7/retrieveCalculation/RetrieveCalculationValidatorFactory.scala @@ -0,0 +1,36 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import shared.controllers.validators.Validator +import v7.retrieveCalculation.def1.Def1_RetrieveCalculationValidator +import v7.retrieveCalculation.def2.Def2_RetrieveCalculationValidator +import v7.retrieveCalculation.models.request.RetrieveCalculationRequestData +import v7.retrieveCalculation.schema.RetrieveCalculationSchema + +import javax.inject.Singleton + +@Singleton +class RetrieveCalculationValidatorFactory { + + def validator(nino: String, taxYear: String, calculationId: String, schema: RetrieveCalculationSchema): Validator[RetrieveCalculationRequestData] = + schema match { + case RetrieveCalculationSchema.Def1 => new Def1_RetrieveCalculationValidator(nino, taxYear, calculationId) + case RetrieveCalculationSchema.Def2 => new Def2_RetrieveCalculationValidator(nino, taxYear, calculationId) + } + +} diff --git a/app/v7/retrieveCalculation/def1/Def1_RetrieveCalculationValidator.scala b/app/v7/retrieveCalculation/def1/Def1_RetrieveCalculationValidator.scala new file mode 100644 index 000000000..5ad610648 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/Def1_RetrieveCalculationValidator.scala @@ -0,0 +1,43 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1 + +import shared.controllers.validators.Validator +import shared.controllers.validators.resolvers.{ResolveCalculationId, ResolveNino, ResolveTaxYearMinimum} +import shared.models.domain.TaxYear +import shared.models.errors.MtdError +import cats.data.Validated +import cats.implicits._ +import v7.retrieveCalculation.models.request.{Def1_RetrieveCalculationRequestData, RetrieveCalculationRequestData} + +object Def1_RetrieveCalculationValidator { + private val retrieveCalculationsMinimumTaxYear = TaxYear.fromMtd("2017-18") + private val resolveTaxYear = ResolveTaxYearMinimum(retrieveCalculationsMinimumTaxYear) +} + +class Def1_RetrieveCalculationValidator(nino: String, taxYear: String, calculationId: String) extends Validator[RetrieveCalculationRequestData] { + + import Def1_RetrieveCalculationValidator._ + + def validate: Validated[Seq[MtdError], RetrieveCalculationRequestData] = + ( + ResolveNino(nino), + resolveTaxYear(taxYear), + ResolveCalculationId(calculationId) + ).mapN(Def1_RetrieveCalculationRequestData) + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/Calculation.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/Calculation.scala new file mode 100644 index 000000000..c737c84f6 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/Calculation.scala @@ -0,0 +1,241 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation + +import play.api.libs.json._ +import v7.retrieveCalculation.def1.model.response.calculation.allowancesAndDeductions.AllowancesAndDeductions +import v7.retrieveCalculation.def1.model.response.calculation.businessProfitAndLoss.BusinessProfitAndLoss +import v7.retrieveCalculation.def1.model.response.calculation.chargeableEventGainsIncome.ChargeableEventGainsIncome +import v7.retrieveCalculation.def1.model.response.calculation.codedOutUnderpayments.CodedOutUnderpayments +import v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome.DividendsIncome +import v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome.EmploymentAndPensionsIncome +import v7.retrieveCalculation.def1.model.response.calculation.employmentExpenses.EmploymentExpenses +import v7.retrieveCalculation.def1.model.response.calculation.endOfYearEstimate.EndOfYearEstimate +import v7.retrieveCalculation.def1.model.response.calculation.foreignIncome.ForeignIncome +import v7.retrieveCalculation.def1.model.response.calculation.foreignPropertyIncome.ForeignPropertyIncome +import v7.retrieveCalculation.def1.model.response.calculation.foreignTaxForFtcrNotClaimed.ForeignTaxForFtcrNotClaimed +import v7.retrieveCalculation.def1.model.response.calculation.giftAid.GiftAid +import v7.retrieveCalculation.def1.model.response.calculation.incomeSummaryTotals.IncomeSummaryTotals +import v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims.LossesAndClaims +import v7.retrieveCalculation.def1.model.response.calculation.marriageAllowanceTransferredIn.MarriageAllowanceTransferredIn +import v7.retrieveCalculation.def1.model.response.calculation.notionalTax.NotionalTax +import v7.retrieveCalculation.def1.model.response.calculation.otherIncome.OtherIncome +import v7.retrieveCalculation.def1.model.response.calculation.pensionContributionReliefs.PensionContributionReliefs +import v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges.PensionSavingsTaxCharges +import v7.retrieveCalculation.def1.model.response.calculation.previousCalculation.PreviousCalculation +import v7.retrieveCalculation.def1.model.response.calculation.reliefs.Reliefs +import v7.retrieveCalculation.def1.model.response.calculation.royaltyPayments.RoyaltyPayments +import v7.retrieveCalculation.def1.model.response.calculation.savingsAndGainsIncome.SavingsAndGainsIncome +import v7.retrieveCalculation.def1.model.response.calculation.seafarersDeductions.SeafarersDeductions +import v7.retrieveCalculation.def1.model.response.calculation.shareSchemesIncome.ShareSchemesIncome +import v7.retrieveCalculation.def1.model.response.calculation.stateBenefitsIncome.StateBenefitsIncome +import v7.retrieveCalculation.def1.model.response.calculation.studentLoans.StudentLoans +import v7.retrieveCalculation.def1.model.response.calculation.taxCalculation.TaxCalculation +import v7.retrieveCalculation.def1.model.response.calculation.taxDeductedAtSource.TaxDeductedAtSource + +case class Calculation( + allowancesAndDeductions: Option[AllowancesAndDeductions], + reliefs: Option[Reliefs], + taxDeductedAtSource: Option[TaxDeductedAtSource], + giftAid: Option[GiftAid], + royaltyPayments: Option[RoyaltyPayments], + notionalTax: Option[NotionalTax], + marriageAllowanceTransferredIn: Option[MarriageAllowanceTransferredIn], + pensionContributionReliefs: Option[PensionContributionReliefs], + pensionSavingsTaxCharges: Option[PensionSavingsTaxCharges], + studentLoans: Option[Seq[StudentLoans]], + codedOutUnderpayments: Option[CodedOutUnderpayments], + foreignPropertyIncome: Option[Seq[ForeignPropertyIncome]], + businessProfitAndLoss: Option[Seq[BusinessProfitAndLoss]], + employmentAndPensionsIncome: Option[EmploymentAndPensionsIncome], + employmentExpenses: Option[EmploymentExpenses], + seafarersDeductions: Option[SeafarersDeductions], + foreignTaxForFtcrNotClaimed: Option[ForeignTaxForFtcrNotClaimed], + stateBenefitsIncome: Option[StateBenefitsIncome], + shareSchemesIncome: Option[ShareSchemesIncome], + foreignIncome: Option[ForeignIncome], + chargeableEventGainsIncome: Option[ChargeableEventGainsIncome], + savingsAndGainsIncome: Option[SavingsAndGainsIncome], + otherIncome: Option[OtherIncome], + dividendsIncome: Option[DividendsIncome], + incomeSummaryTotals: Option[IncomeSummaryTotals], + taxCalculation: Option[TaxCalculation], + previousCalculation: Option[PreviousCalculation], + endOfYearEstimate: Option[EndOfYearEstimate], + lossesAndClaims: Option[LossesAndClaims] +) { + + def withoutBasicExtension: Calculation = copy(reliefs = reliefs.map(_.withoutBasicExtension).filter(_.isDefined)) + + def withoutGiftAidTaxReductionWhereBasicRateDiffers: Calculation = + copy(reliefs = reliefs.map(_.withoutGiftAidTaxReductionWhereBasicRateDiffers).filter(_.isDefined)) + + def withoutGiftAidTaxChargeWhereBasicRateDiffers: Calculation = + copy(taxCalculation = taxCalculation.map(_.withoutGiftAidTaxChargeWhereBasicRateDiffers)) + + def withoutUnderLowerProfitThreshold: Calculation = + copy(taxCalculation = taxCalculation.map(_.withoutUnderLowerProfitThreshold)) + + def withoutOffPayrollWorker: Calculation = + copy(employmentAndPensionsIncome = employmentAndPensionsIncome.map(_.withoutOffPayrollWorker).filter(_.isDefined)) + + def withoutTotalAllowanceAndDeductions: Calculation = + copy(endOfYearEstimate = endOfYearEstimate.map(_.withoutTotalAllowanceAndDeductions).filter(_.isDefined)) + + def withoutTaxTakenOffTradingIncome: Calculation = + copy(taxDeductedAtSource = taxDeductedAtSource.map(_.withoutTaxTakenOffTradingIncome)) + + def withoutOtherIncome: Calculation = + copy(otherIncome = None) + + val isDefined: Boolean = + !(allowancesAndDeductions.isEmpty && + reliefs.isEmpty && taxDeductedAtSource.isEmpty && + giftAid.isEmpty && + royaltyPayments.isEmpty && + notionalTax.isEmpty && + marriageAllowanceTransferredIn.isEmpty && + pensionContributionReliefs.isEmpty && + pensionSavingsTaxCharges.isEmpty && + studentLoans.isEmpty && + codedOutUnderpayments.isEmpty && + foreignPropertyIncome.isEmpty && + businessProfitAndLoss.isEmpty && + employmentAndPensionsIncome.isEmpty && + employmentExpenses.isEmpty && + seafarersDeductions.isEmpty && + foreignTaxForFtcrNotClaimed.isEmpty && + stateBenefitsIncome.isEmpty && + shareSchemesIncome.isEmpty && + foreignIncome.isEmpty && + chargeableEventGainsIncome.isEmpty && + savingsAndGainsIncome.isEmpty && + otherIncome.isEmpty && + dividendsIncome.isEmpty && + incomeSummaryTotals.isEmpty && + taxCalculation.isEmpty && + previousCalculation.isEmpty && + endOfYearEstimate.isEmpty && + lossesAndClaims.isEmpty) + +} + +object Calculation { + + implicit val reads: Reads[Calculation] = for { + allowancesAndDeductions <- (JsPath \ "allowancesAndDeductions").readNullable[AllowancesAndDeductions] + reliefs <- (JsPath \ "reliefs").readNullable[Reliefs] + taxDeductedAtSource <- (JsPath \ "taxDeductedAtSource").readNullable[TaxDeductedAtSource] + giftAid <- (JsPath \ "giftAid").readNullable[GiftAid] + royaltyPayments <- (JsPath \ "royaltyPayments").readNullable[RoyaltyPayments] + notionalTax <- (JsPath \ "notionalTax").readNullable[NotionalTax] + marriageAllowanceTransferredIn <- (JsPath \ "marriageAllowanceTransferredIn").readNullable[MarriageAllowanceTransferredIn] + pensionContributionReliefs <- (JsPath \ "pensionContributionReliefs").readNullable[PensionContributionReliefs] + pensionSavingsTaxCharges <- (JsPath \ "pensionSavingsTaxCharges").readNullable[PensionSavingsTaxCharges] + studentLoans <- (JsPath \ "studentLoans").readNullable[Seq[StudentLoans]] + codedOutUnderpayments <- (JsPath \ "codedOutUnderpayments").readNullable[CodedOutUnderpayments] + foreignPropertyIncome <- (JsPath \ "foreignPropertyIncome").readNullable[Seq[ForeignPropertyIncome]] + businessProfitAndLoss <- (JsPath \ "businessProfitAndLoss").readNullable[Seq[BusinessProfitAndLoss]] + employmentAndPensionsIncome <- (JsPath \ "employmentAndPensionsIncome").readNullable[EmploymentAndPensionsIncome] + employmentExpenses <- (JsPath \ "employmentExpenses").readNullable[EmploymentExpenses] + seafarersDeductions <- (JsPath \ "seafarersDeductions").readNullable[SeafarersDeductions] + foreignTaxForFtcrNotClaimed <- (JsPath \ "foreignTaxForFtcrNotClaimed").readNullable[ForeignTaxForFtcrNotClaimed] + stateBenefitsIncome <- (JsPath \ "stateBenefitsIncome").readNullable[StateBenefitsIncome] + shareSchemesIncome <- (JsPath \ "shareSchemesIncome").readNullable[ShareSchemesIncome] + foreignIncome <- (JsPath \ "foreignIncome").readNullable[ForeignIncome] + chargeableEventGainsIncome <- (JsPath \ "chargeableEventGainsIncome").readNullable[ChargeableEventGainsIncome] + savingsAndGainsIncome <- (JsPath \ "savingsAndGainsIncome").readNullable[SavingsAndGainsIncome] + otherIncome <- (JsPath \ "otherIncome").readNullable[OtherIncome] + dividendsIncome <- (JsPath \ "dividendsIncome").readNullable[DividendsIncome] + incomeSummaryTotals <- (JsPath \ "incomeSummaryTotals").readNullable[IncomeSummaryTotals] + taxCalculation <- (JsPath \ "taxCalculation").readNullable[TaxCalculation] + previousCalculation <- (JsPath \ "previousCalculation").readNullable[PreviousCalculation] + endOfYearEstimate <- (JsPath \ "endOfYearEstimate").readNullable[EndOfYearEstimate] + lossesAndClaims <- (JsPath \ "lossesAndClaims").readNullable[LossesAndClaims] + } yield { + Calculation( + allowancesAndDeductions = allowancesAndDeductions, + reliefs = reliefs, + taxDeductedAtSource = taxDeductedAtSource, + giftAid = giftAid, + royaltyPayments = royaltyPayments, + notionalTax = notionalTax, + marriageAllowanceTransferredIn = marriageAllowanceTransferredIn, + pensionContributionReliefs = pensionContributionReliefs, + pensionSavingsTaxCharges = pensionSavingsTaxCharges, + studentLoans = studentLoans, + codedOutUnderpayments = codedOutUnderpayments, + foreignPropertyIncome = foreignPropertyIncome, + businessProfitAndLoss = businessProfitAndLoss, + employmentAndPensionsIncome = employmentAndPensionsIncome, + employmentExpenses = employmentExpenses, + seafarersDeductions = seafarersDeductions, + foreignTaxForFtcrNotClaimed = foreignTaxForFtcrNotClaimed, + stateBenefitsIncome = stateBenefitsIncome, + shareSchemesIncome = shareSchemesIncome, + foreignIncome = foreignIncome, + chargeableEventGainsIncome = chargeableEventGainsIncome, + savingsAndGainsIncome = savingsAndGainsIncome, + otherIncome = otherIncome, + dividendsIncome = dividendsIncome, + incomeSummaryTotals = incomeSummaryTotals, + taxCalculation = taxCalculation, + previousCalculation = previousCalculation, + endOfYearEstimate = endOfYearEstimate, + lossesAndClaims = lossesAndClaims + ) + } + + implicit val writes: OWrites[Calculation] = (o: Calculation) => { + JsObject( + Map( + "allowancesAndDeductions" -> Json.toJson(o.allowancesAndDeductions), + "reliefs" -> Json.toJson(o.reliefs), + "taxDeductedAtSource" -> Json.toJson(o.taxDeductedAtSource), + "giftAid" -> Json.toJson(o.giftAid), + "royaltyPayments" -> Json.toJson(o.royaltyPayments), + "notionalTax" -> Json.toJson(o.notionalTax), + "marriageAllowanceTransferredIn" -> Json.toJson(o.marriageAllowanceTransferredIn), + "pensionContributionReliefs" -> Json.toJson(o.pensionContributionReliefs), + "pensionSavingsTaxCharges" -> Json.toJson(o.pensionSavingsTaxCharges), + "studentLoans" -> Json.toJson(o.studentLoans), + "codedOutUnderpayments" -> Json.toJson(o.codedOutUnderpayments), + "foreignPropertyIncome" -> Json.toJson(o.foreignPropertyIncome), + "businessProfitAndLoss" -> Json.toJson(o.businessProfitAndLoss), + "employmentAndPensionsIncome" -> Json.toJson(o.employmentAndPensionsIncome), + "employmentExpenses" -> Json.toJson(o.employmentExpenses), + "seafarersDeductions" -> Json.toJson(o.seafarersDeductions), + "foreignTaxForFtcrNotClaimed" -> Json.toJson(o.foreignTaxForFtcrNotClaimed), + "stateBenefitsIncome" -> Json.toJson(o.stateBenefitsIncome), + "shareSchemesIncome" -> Json.toJson(o.shareSchemesIncome), + "foreignIncome" -> Json.toJson(o.foreignIncome), + "chargeableEventGainsIncome" -> Json.toJson(o.chargeableEventGainsIncome), + "savingsAndGainsIncome" -> Json.toJson(o.savingsAndGainsIncome), + "otherIncome" -> Json.toJson(o.otherIncome), + "dividendsIncome" -> Json.toJson(o.dividendsIncome), + "incomeSummaryTotals" -> Json.toJson(o.incomeSummaryTotals), + "taxCalculation" -> Json.toJson(o.taxCalculation), + "previousCalculation" -> Json.toJson(o.previousCalculation), + "endOfYearEstimate" -> Json.toJson(o.endOfYearEstimate), + "lossesAndClaims" -> Json.toJson(o.lossesAndClaims) + ).filterNot { case (_, value) => + value == JsNull + } + ) + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductions.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductions.scala new file mode 100644 index 000000000..4c0731ea7 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductions.scala @@ -0,0 +1,58 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.allowancesAndDeductions + +import play.api.libs.functional.syntax._ +import play.api.libs.json.{JsPath, Json, Reads, Writes} + +case class AllowancesAndDeductions(personalAllowance: Option[BigInt], + marriageAllowanceTransferOut: Option[MarriageAllowanceTransferOut], + reducedPersonalAllowance: Option[BigInt], + giftOfInvestmentsAndPropertyToCharity: Option[BigInt], + blindPersonsAllowance: Option[BigInt], + lossesAppliedToGeneralIncome: Option[BigInt], + cgtLossSetAgainstInYearGeneralIncome: Option[BigInt], + qualifyingLoanInterestFromInvestments: Option[BigDecimal], + postCessationTradeReceipts: Option[BigDecimal], + paymentsToTradeUnionsForDeathBenefits: Option[BigDecimal], + grossAnnuityPayments: Option[BigDecimal], + annuityPayments: Option[AnnuityPayments], + pensionContributions: Option[BigDecimal], + pensionContributionsDetail: Option[PensionContributionsDetail]) + +object AllowancesAndDeductions { + + implicit val reads: Reads[AllowancesAndDeductions] = ( + (JsPath \ "personalAllowance").readNullable[BigInt] and + (JsPath \ "marriageAllowanceTransferOut").readNullable[MarriageAllowanceTransferOut] and + (JsPath \ "reducedPersonalAllowance").readNullable[BigInt] and + (JsPath \ "giftOfInvestmentsAndPropertyToCharity").readNullable[BigInt] and + (JsPath \ "blindPersonsAllowance").readNullable[BigInt] and + (JsPath \ "lossesAppliedToGeneralIncome").readNullable[BigInt] and + (JsPath \ "cgtLossSetAgainstInYearGeneralIncome").readNullable[BigInt] and + (JsPath \ "qualifyingLoanInterestFromInvestments").readNullable[BigDecimal] and + (JsPath \ "post-cessationTradeReceipts").readNullable[BigDecimal] and + (JsPath \ "paymentsToTradeUnionsForDeathBenefits").readNullable[BigDecimal] and + (JsPath \ "grossAnnuityPayments").readNullable[BigDecimal] and + (JsPath \ "annuityPayments").readNullable[AnnuityPayments] and + (JsPath \ "pensionContributions").readNullable[BigDecimal] and + (JsPath \ "pensionContributionsDetail").readNullable[PensionContributionsDetail] + )(AllowancesAndDeductions.apply _) + + implicit val writes: Writes[AllowancesAndDeductions] = Json.writes[AllowancesAndDeductions] + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AnnuityPayments.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AnnuityPayments.scala new file mode 100644 index 000000000..4fb5cd9eb --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AnnuityPayments.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.allowancesAndDeductions + +import play.api.libs.json.{Json, OFormat} + +case class AnnuityPayments(reliefClaimed: Option[BigDecimal], rate: Option[BigDecimal]) + +object AnnuityPayments { + implicit val format: OFormat[AnnuityPayments] = Json.format[AnnuityPayments] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/MarriageAllowanceTransferOut.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/MarriageAllowanceTransferOut.scala new file mode 100644 index 000000000..21edf7fdc --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/MarriageAllowanceTransferOut.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.allowancesAndDeductions + +import play.api.libs.json.{Json, OFormat} + +case class MarriageAllowanceTransferOut(personalAllowanceBeforeTransferOut: BigDecimal, transferredOutAmount: BigDecimal) + +object MarriageAllowanceTransferOut { + implicit val format: OFormat[MarriageAllowanceTransferOut] = Json.format[MarriageAllowanceTransferOut] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/PensionContributionsDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/PensionContributionsDetail.scala new file mode 100644 index 000000000..5d8a96944 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/PensionContributionsDetail.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.allowancesAndDeductions + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionsDetail(retirementAnnuityPayments: Option[BigDecimal], + paymentToEmployersSchemeNoTaxRelief: Option[BigDecimal], + overseasPensionSchemeContributions: Option[BigDecimal]) + +object PensionContributionsDetail { + implicit val format: OFormat[PensionContributionsDetail] = Json.format[PensionContributionsDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLoss.scala new file mode 100644 index 000000000..986751b30 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLoss.scala @@ -0,0 +1,146 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.businessProfitAndLoss + +import play.api.libs.json._ +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class BusinessProfitAndLoss(incomeSourceId: String, + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + totalIncome: Option[BigDecimal], + totalExpenses: Option[BigDecimal], + netProfit: Option[BigDecimal], + netLoss: Option[BigDecimal], + totalAdditions: Option[BigDecimal], + totalDeductions: Option[BigDecimal], + accountingAdjustments: Option[BigDecimal], + taxableProfit: Option[BigInt], + adjustedIncomeTaxLoss: Option[BigInt], + totalBroughtForwardIncomeTaxLosses: Option[BigInt], + lossForCSFHL: Option[BigInt], + broughtForwardIncomeTaxLossesUsed: Option[BigInt], + taxableProfitAfterIncomeTaxLossesDeduction: Option[BigInt], + carrySidewaysIncomeTaxLossesUsed: Option[BigInt], + broughtForwardCarrySidewaysIncomeTaxLossesUsed: Option[BigInt], + totalIncomeTaxLossesCarriedForward: Option[BigInt], + class4Loss: Option[BigInt], + totalBroughtForwardClass4Losses: Option[BigInt], + broughtForwardClass4LossesUsed: Option[BigInt], + carrySidewaysClass4LossesUsed: Option[BigInt], + totalClass4LossesCarriedForward: Option[BigInt]) + +object BusinessProfitAndLoss { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `foreign-property-fhl-eea`, + `uk-property-fhl`, + `foreign-property` + ) + + implicit val reads: Reads[BusinessProfitAndLoss] = for { + incomeSourceId <- (JsPath \ "incomeSourceId").read[String] + incomeSourceType <- (JsPath \ "incomeSourceType").read[IncomeSourceType] + incomeSourceName <- (JsPath \ "incomeSourceName").readNullable[String] + totalIncome <- (JsPath \ "totalIncome").readNullable[BigDecimal] + totalExpenses <- (JsPath \ "totalExpenses").readNullable[BigDecimal] + netProfit <- (JsPath \ "netProfit").readNullable[BigDecimal] + netLoss <- (JsPath \ "netLoss").readNullable[BigDecimal] + totalAdditions <- (JsPath \ "totalAdditions").readNullable[BigDecimal] + totalDeductions <- (JsPath \ "totalDeductions").readNullable[BigDecimal] + accountingAdjustments <- (JsPath \ "accountingAdjustments").readNullable[BigDecimal] + taxableProfit <- (JsPath \ "taxableProfit").readNullable[BigInt] + adjustedIncomeTaxLoss <- (JsPath \ "adjustedIncomeTaxLoss").readNullable[BigInt] + totalBroughtForwardIncomeTaxLosses <- (JsPath \ "totalBroughtForwardIncomeTaxLosses").readNullable[BigInt] + lossForCSFHL <- (JsPath \ "lossForCSFHL").readNullable[BigInt] + broughtForwardIncomeTaxLossesUsed <- (JsPath \ "broughtForwardIncomeTaxLossesUsed").readNullable[BigInt] + taxableProfitAfterIncomeTaxLossesDeduction <- (JsPath \ "taxableProfitAfterIncomeTaxLossesDeduction").readNullable[BigInt] + carrySidewaysIncomeTaxLossesUsed <- (JsPath \ "carrySidewaysIncomeTaxLossesUsed").readNullable[BigInt] + broughtForwardCarrySidewaysIncomeTaxLossesUsed <- (JsPath \ "broughtForwardCarrySidewaysIncomeTaxLossesUsed").readNullable[BigInt] + totalIncomeTaxLossesCarriedForward <- (JsPath \ "totalIncomeTaxLossesCarriedForward").readNullable[BigInt] + class4Loss <- (JsPath \ "class4Loss").readNullable[BigInt] + totalBroughtForwardClass4Losses <- (JsPath \ "totalBroughtForwardClass4Losses").readNullable[BigInt] + broughtForwardClass4LossesUsed <- (JsPath \ "broughtForwardClass4LossesUsed").readNullable[BigInt] + carrySidewaysClass4LossesUsed <- (JsPath \ "carrySidewaysClass4LossesUsed").readNullable[BigInt] + totalClass4LossesCarriedForward <- (JsPath \ "totalClass4LossesCarriedForward").readNullable[BigInt] + + } yield { + BusinessProfitAndLoss( + incomeSourceId = incomeSourceId, + incomeSourceType = incomeSourceType, + incomeSourceName = incomeSourceName, + totalIncome = totalIncome, + totalExpenses = totalExpenses, + netProfit = netProfit, + netLoss = netLoss, + totalAdditions = totalAdditions, + totalDeductions = totalDeductions, + accountingAdjustments = accountingAdjustments, + taxableProfit = taxableProfit, + adjustedIncomeTaxLoss = adjustedIncomeTaxLoss, + totalBroughtForwardIncomeTaxLosses = totalBroughtForwardIncomeTaxLosses, + lossForCSFHL = lossForCSFHL, + broughtForwardIncomeTaxLossesUsed = broughtForwardIncomeTaxLossesUsed, + taxableProfitAfterIncomeTaxLossesDeduction = taxableProfitAfterIncomeTaxLossesDeduction, + carrySidewaysIncomeTaxLossesUsed = carrySidewaysIncomeTaxLossesUsed, + broughtForwardCarrySidewaysIncomeTaxLossesUsed = broughtForwardCarrySidewaysIncomeTaxLossesUsed, + totalIncomeTaxLossesCarriedForward = totalIncomeTaxLossesCarriedForward, + class4Loss = class4Loss, + totalBroughtForwardClass4Losses = totalBroughtForwardClass4Losses, + broughtForwardClass4LossesUsed = broughtForwardClass4LossesUsed, + carrySidewaysClass4LossesUsed = carrySidewaysClass4LossesUsed, + totalClass4LossesCarriedForward = totalClass4LossesCarriedForward + ) + } + + implicit val writes: OWrites[BusinessProfitAndLoss] = (o: BusinessProfitAndLoss) => { + JsObject( + Map( + "incomeSourceId" -> Json.toJson(o.incomeSourceId), + "incomeSourceType" -> Json.toJson(o.incomeSourceType), + "incomeSourceName" -> Json.toJson(o.incomeSourceName), + "totalIncome" -> Json.toJson(o.totalIncome), + "totalExpenses" -> Json.toJson(o.totalExpenses), + "netProfit" -> Json.toJson(o.netProfit), + "netLoss" -> Json.toJson(o.netLoss), + "totalAdditions" -> Json.toJson(o.totalAdditions), + "totalDeductions" -> Json.toJson(o.totalDeductions), + "accountingAdjustments" -> Json.toJson(o.accountingAdjustments), + "taxableProfit" -> Json.toJson(o.taxableProfit), + "adjustedIncomeTaxLoss" -> Json.toJson(o.adjustedIncomeTaxLoss), + "totalBroughtForwardIncomeTaxLosses" -> Json.toJson(o.totalBroughtForwardIncomeTaxLosses), + "lossForCSFHL" -> Json.toJson(o.lossForCSFHL), + "broughtForwardIncomeTaxLossesUsed" -> Json.toJson(o.broughtForwardIncomeTaxLossesUsed), + "taxableProfitAfterIncomeTaxLossesDeduction" -> Json.toJson(o.taxableProfitAfterIncomeTaxLossesDeduction), + "carrySidewaysIncomeTaxLossesUsed" -> Json.toJson(o.carrySidewaysIncomeTaxLossesUsed), + "broughtForwardCarrySidewaysIncomeTaxLossesUsed" -> Json.toJson(o.broughtForwardCarrySidewaysIncomeTaxLossesUsed), + "totalIncomeTaxLossesCarriedForward" -> Json.toJson(o.totalIncomeTaxLossesCarriedForward), + "class4Loss" -> Json.toJson(o.class4Loss), + "totalBroughtForwardClass4Losses" -> Json.toJson(o.totalBroughtForwardClass4Losses), + "broughtForwardClass4LossesUsed" -> Json.toJson(o.broughtForwardClass4LossesUsed), + "carrySidewaysClass4LossesUsed" -> Json.toJson(o.carrySidewaysClass4LossesUsed), + "totalClass4LossesCarriedForward" -> Json.toJson(o.totalClass4LossesCarriedForward) + ).filterNot { case (_, value) => + value == JsNull + } + ) + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ChargeableEventGainsIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ChargeableEventGainsIncome.scala new file mode 100644 index 000000000..84ea53e78 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ChargeableEventGainsIncome.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class ChargeableEventGainsIncome(totalOfAllGains: BigInt, + totalGainsWithTaxPaid: Option[BigInt], + gainsWithTaxPaidDetail: Option[Seq[GainsWithTaxPaidDetail]], + totalGainsWithNoTaxPaidAndVoidedIsa: Option[BigInt], + gainsWithNoTaxPaidAndVoidedIsaDetail: Option[Seq[GainsWithNoTaxPaidAndVoidedIsaDetail]], + totalForeignGainsOnLifePoliciesTaxPaid: Option[BigInt], + foreignGainsOnLifePoliciesTaxPaidDetail: Option[Seq[ForeignGainsOnLifePoliciesTaxPaidDetail]], + totalForeignGainsOnLifePoliciesNoTaxPaid: Option[BigInt], + foreignGainsOnLifePoliciesNoTaxPaidDetail: Option[Seq[ForeignGainsOnLifePoliciesNoTaxPaidDetail]]) + +object ChargeableEventGainsIncome { + implicit val format: Format[ChargeableEventGainsIncome] = Json.format[ChargeableEventGainsIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesNoTaxPaidDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesNoTaxPaidDetail.scala new file mode 100644 index 000000000..1e7317a7a --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesNoTaxPaidDetail.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class ForeignGainsOnLifePoliciesNoTaxPaidDetail(customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt]) + +object ForeignGainsOnLifePoliciesNoTaxPaidDetail { + implicit val format: Format[ForeignGainsOnLifePoliciesNoTaxPaidDetail] = Json.format[ForeignGainsOnLifePoliciesNoTaxPaidDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesTaxPaidDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesTaxPaidDetail.scala new file mode 100644 index 000000000..8cbea9f50 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesTaxPaidDetail.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class ForeignGainsOnLifePoliciesTaxPaidDetail(customerReference: Option[String], + gainAmount: Option[BigDecimal], + taxPaidAmount: Option[BigDecimal], + yearsHeld: Option[BigInt]) + +object ForeignGainsOnLifePoliciesTaxPaidDetail { + implicit val format: Format[ForeignGainsOnLifePoliciesTaxPaidDetail] = Json.format[ForeignGainsOnLifePoliciesTaxPaidDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala new file mode 100644 index 000000000..79270fbed --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class GainsWithNoTaxPaidAndVoidedIsaDetail(`type`: String, + customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt], + yearsHeldSinceLastGain: Option[BigInt], + voidedIsaTaxPaid: Option[BigDecimal]) + +object GainsWithNoTaxPaidAndVoidedIsaDetail { + implicit val format: Format[GainsWithNoTaxPaidAndVoidedIsaDetail] = Json.format[GainsWithNoTaxPaidAndVoidedIsaDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala new file mode 100644 index 000000000..1b623a150 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class GainsWithTaxPaidDetail(`type`: String, + customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt], + yearsHeldSinceLastGain: Option[BigInt]) + +object GainsWithTaxPaidDetail { + implicit val format: Format[GainsWithTaxPaidDetail] = Json.format[GainsWithTaxPaidDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/CodedOutUnderpayments.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/CodedOutUnderpayments.scala new file mode 100644 index 000000000..0a7ae7748 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/CodedOutUnderpayments.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.codedOutUnderpayments + +import play.api.libs.json.{Json, OFormat} + +case class CodedOutUnderpayments(totalPayeUnderpayments: Option[BigDecimal], + payeUnderpaymentsDetail: Option[Seq[PayeUnderpaymentsDetail]], + totalSelfAssessmentUnderpayments: Option[BigDecimal], + totalCollectedSelfAssessmentUnderpayments: Option[BigDecimal], + totalUncollectedSelfAssessmentUnderpayments: Option[BigDecimal], + selfAssessmentUnderpaymentsDetail: Option[Seq[SelfAssessmentUnderpaymentsDetail]]) + +object CodedOutUnderpayments { + implicit val format: OFormat[CodedOutUnderpayments] = Json.format[CodedOutUnderpayments] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/PayeUnderpaymentsDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/PayeUnderpaymentsDetail.scala new file mode 100644 index 000000000..cfbedddba --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/PayeUnderpaymentsDetail.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.codedOutUnderpayments + +import play.api.libs.json.{Json, OFormat} + +case class PayeUnderpaymentsDetail(amount: BigDecimal, relatedTaxYear: String, source: Option[String]) + +object PayeUnderpaymentsDetail { + implicit val format: OFormat[PayeUnderpaymentsDetail] = Json.format[PayeUnderpaymentsDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/SelfAssessmentUnderpaymentsDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/SelfAssessmentUnderpaymentsDetail.scala new file mode 100644 index 000000000..138afb037 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/codedOutUnderpayments/SelfAssessmentUnderpaymentsDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.codedOutUnderpayments + +import play.api.libs.json.{Json, OFormat} + +case class SelfAssessmentUnderpaymentsDetail(amount: BigDecimal, + relatedTaxYear: String, + source: Option[String], + collectedAmount: Option[BigDecimal], + uncollectedAmount: Option[BigDecimal]) + +object SelfAssessmentUnderpaymentsDetail { + implicit val format: OFormat[SelfAssessmentUnderpaymentsDetail] = Json.format[SelfAssessmentUnderpaymentsDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/CommonForeignDividend.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/CommonForeignDividend.scala new file mode 100644 index 000000000..bc88bcf58 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/CommonForeignDividend.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType.`foreign-dividends` + +case class CommonForeignDividend(incomeSourceType: Option[IncomeSourceType], + countryCode: String, + grossIncome: Option[BigDecimal], + netIncome: Option[BigDecimal], + taxDeducted: Option[BigDecimal], + foreignTaxCreditRelief: Option[Boolean]) + +object CommonForeignDividend { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`foreign-dividends`) + implicit val format: Format[CommonForeignDividend] = Json.format[CommonForeignDividend] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncome.scala new file mode 100644 index 000000000..2b66cb187 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncome.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome + +import play.api.libs.json.{Format, Json} + +case class DividendsIncome(totalChargeableDividends: Option[BigInt], + totalUkDividends: Option[BigInt], + ukDividends: Option[UkDividends], + otherDividends: Option[Seq[OtherDividends]], + chargeableForeignDividends: Option[BigInt], + foreignDividends: Option[Seq[CommonForeignDividend]], + dividendIncomeReceivedWhilstAbroad: Option[Seq[CommonForeignDividend]]) + +object DividendsIncome { + implicit val format: Format[DividendsIncome] = Json.format[DividendsIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala new file mode 100644 index 000000000..afba74200 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome + +import play.api.libs.json.{Format, Json} + +case class OtherDividends(typeOfDividend: Option[String], customerReference: Option[String], grossAmount: Option[BigDecimal]) + +object OtherDividends { + implicit val format: Format[OtherDividends] = Json.format[OtherDividends] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/UkDividends.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/UkDividends.scala new file mode 100644 index 000000000..fa3035098 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/UkDividends.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType.`uk-dividends` + +case class UkDividends(incomeSourceId: Option[String], + incomeSourceType: Option[IncomeSourceType], + dividends: Option[BigInt], + otherUkDividends: Option[BigInt]) + +object UkDividends { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`uk-dividends`) + implicit val format: Format[UkDividends] = Json.format[UkDividends] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitFromEmployerFinancedRetirementScheme.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitFromEmployerFinancedRetirementScheme.scala new file mode 100644 index 000000000..c282e68c8 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitFromEmployerFinancedRetirementScheme.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class BenefitFromEmployerFinancedRetirementScheme(amount: Option[BigDecimal], + exemptAmount: Option[BigDecimal], + taxPaid: Option[BigDecimal], + taxTakenOffInEmployment: Option[Boolean]) + +object BenefitFromEmployerFinancedRetirementScheme { + + implicit val format: Format[BenefitFromEmployerFinancedRetirementScheme] = Json.format[BenefitFromEmployerFinancedRetirementScheme] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKind.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKind.scala new file mode 100644 index 000000000..63d2f32a7 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKind.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class BenefitsInKind(totalBenefitsInKindReceived: Option[BigDecimal], benefitsInKindDetail: Option[BenefitsInKindDetail]) + +object BenefitsInKind { + + implicit val format: Format[BenefitsInKind] = Json.format[BenefitsInKind] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetail.scala new file mode 100644 index 000000000..52792a1a1 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetail.scala @@ -0,0 +1,152 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json._ + +case class BenefitsInKindDetail(apportionedAccommodation: Option[BigDecimal], + apportionedAssets: Option[BigDecimal], + apportionedAssetTransfer: Option[BigDecimal], + apportionedBeneficialLoan: Option[BigDecimal], + apportionedCar: Option[BigDecimal], + apportionedCarFuel: Option[BigDecimal], + apportionedEducationalServices: Option[BigDecimal], + apportionedEntertaining: Option[BigDecimal], + apportionedExpenses: Option[BigDecimal], + apportionedMedicalInsurance: Option[BigDecimal], + apportionedTelephone: Option[BigDecimal], + apportionedService: Option[BigDecimal], + apportionedTaxableExpenses: Option[BigDecimal], + apportionedVan: Option[BigDecimal], + apportionedVanFuel: Option[BigDecimal], + apportionedMileage: Option[BigDecimal], + apportionedNonQualifyingRelocationExpenses: Option[BigDecimal], + apportionedNurseryPlaces: Option[BigDecimal], + apportionedOtherItems: Option[BigDecimal], + apportionedPaymentsOnEmployeesBehalf: Option[BigDecimal], + apportionedPersonalIncidentalExpenses: Option[BigDecimal], + apportionedQualifyingRelocationExpenses: Option[BigDecimal], + apportionedEmployerProvidedProfessionalSubscriptions: Option[BigDecimal], + apportionedEmployerProvidedServices: Option[BigDecimal], + apportionedIncomeTaxPaidByDirector: Option[BigDecimal], + apportionedTravelAndSubsistence: Option[BigDecimal], + apportionedVouchersAndCreditCards: Option[BigDecimal], + apportionedNonCash: Option[BigDecimal]) + +object BenefitsInKindDetail { + + implicit val reads: Reads[BenefitsInKindDetail] = for { + apportionedAccommodation <- (JsPath \ "apportionedAccommodation").readNullable[BigDecimal] + apportionedAssets <- (JsPath \ "apportionedAssets").readNullable[BigDecimal] + apportionedAssetTransfer <- (JsPath \ "apportionedAssetTransfer").readNullable[BigDecimal] + apportionedBeneficialLoan <- (JsPath \ "apportionedBeneficialLoan").readNullable[BigDecimal] + apportionedCar <- (JsPath \ "apportionedCar").readNullable[BigDecimal] + apportionedCarFuel <- (JsPath \ "apportionedCarFuel").readNullable[BigDecimal] + apportionedEducationalServices <- (JsPath \ "apportionedEducationalServices").readNullable[BigDecimal] + apportionedEntertaining <- (JsPath \ "apportionedEntertaining").readNullable[BigDecimal] + apportionedExpenses <- (JsPath \ "apportionedExpenses").readNullable[BigDecimal] + apportionedMedicalInsurance <- (JsPath \ "apportionedMedicalInsurance").readNullable[BigDecimal] + apportionedTelephone <- (JsPath \ "apportionedTelephone").readNullable[BigDecimal] + apportionedTaxableExpenses <- (JsPath \ "apportionedTaxableExpenses").readNullable[BigDecimal] + apportionedService <- (JsPath \ "apportionedService").readNullable[BigDecimal] + apportionedVan <- (JsPath \ "apportionedVan").readNullable[BigDecimal] + apportionedVanFuel <- (JsPath \ "apportionedVanFuel").readNullable[BigDecimal] + apportionedMileage <- (JsPath \ "apportionedMileage").readNullable[BigDecimal] + apportionedNonQualifyingRelocationExpenses <- (JsPath \ "apportionedNonQualifyingRelocationExpenses").readNullable[BigDecimal] + apportionedNurseryPlaces <- (JsPath \ "apportionedNurseryPlaces").readNullable[BigDecimal] + apportionedOtherItems <- (JsPath \ "apportionedOtherItems").readNullable[BigDecimal] + apportionedPaymentsOnEmployeesBehalf <- (JsPath \ "apportionedPaymentsOnEmployeesBehalf").readNullable[BigDecimal] + apportionedPersonalIncidentalExpenses <- (JsPath \ "apportionedPersonalIncidentalExpenses").readNullable[BigDecimal] + apportionedQualifyingRelocationExpenses <- (JsPath \ "apportionedQualifyingRelocationExpenses").readNullable[BigDecimal] + apportionedEmployerProvidedProfessionalSubscriptions <- (JsPath \ "apportionedEmployerProvidedProfessionalSubscriptions").readNullable[BigDecimal] + apportionedEmployerProvidedServices <- (JsPath \ "apportionedEmployerProvidedServices").readNullable[BigDecimal] + apportionedIncomeTaxPaidByDirector <- (JsPath \ "apportionedIncomeTaxPaidByDirector").readNullable[BigDecimal] + apportionedTravelAndSubsistence <- (JsPath \ "apportionedTravelAndSubsistence").readNullable[BigDecimal] + apportionedVouchersAndCreditCards <- (JsPath \ "apportionedVouchersAndCreditCards").readNullable[BigDecimal] + apportionedNonCash <- (JsPath \ "apportionedNonCash").readNullable[BigDecimal] + + } yield { + BenefitsInKindDetail( + apportionedAccommodation = apportionedAccommodation, + apportionedAssets = apportionedAssets, + apportionedAssetTransfer = apportionedAssetTransfer, + apportionedBeneficialLoan = apportionedBeneficialLoan, + apportionedCar = apportionedCar, + apportionedCarFuel = apportionedCarFuel, + apportionedEducationalServices = apportionedEducationalServices, + apportionedEntertaining = apportionedEntertaining, + apportionedExpenses = apportionedExpenses, + apportionedMedicalInsurance = apportionedMedicalInsurance, + apportionedTelephone = apportionedTelephone, + apportionedService = apportionedService, + apportionedTaxableExpenses = apportionedTaxableExpenses, + apportionedVan = apportionedVan, + apportionedVanFuel = apportionedVanFuel, + apportionedMileage = apportionedMileage, + apportionedNonQualifyingRelocationExpenses = apportionedNonQualifyingRelocationExpenses, + apportionedNurseryPlaces = apportionedNurseryPlaces, + apportionedOtherItems = apportionedOtherItems, + apportionedPaymentsOnEmployeesBehalf = apportionedPaymentsOnEmployeesBehalf, + apportionedPersonalIncidentalExpenses = apportionedPersonalIncidentalExpenses, + apportionedQualifyingRelocationExpenses = apportionedQualifyingRelocationExpenses, + apportionedEmployerProvidedProfessionalSubscriptions = apportionedEmployerProvidedProfessionalSubscriptions, + apportionedEmployerProvidedServices = apportionedEmployerProvidedServices, + apportionedIncomeTaxPaidByDirector = apportionedIncomeTaxPaidByDirector, + apportionedTravelAndSubsistence = apportionedTravelAndSubsistence, + apportionedVouchersAndCreditCards = apportionedVouchersAndCreditCards, + apportionedNonCash = apportionedNonCash + ) + } + + implicit val writes: OWrites[BenefitsInKindDetail] = (o: BenefitsInKindDetail) => { + JsObject( + Map( + "apportionedAccommodation" -> Json.toJson(o.apportionedAccommodation), + "apportionedAssets" -> Json.toJson(o.apportionedAssets), + "apportionedAssetTransfer" -> Json.toJson(o.apportionedAssetTransfer), + "apportionedBeneficialLoan" -> Json.toJson(o.apportionedBeneficialLoan), + "apportionedCar" -> Json.toJson(o.apportionedCar), + "apportionedCarFuel" -> Json.toJson(o.apportionedCarFuel), + "apportionedEducationalServices" -> Json.toJson(o.apportionedEducationalServices), + "apportionedEntertaining" -> Json.toJson(o.apportionedEntertaining), + "apportionedExpenses" -> Json.toJson(o.apportionedExpenses), + "apportionedMedicalInsurance" -> Json.toJson(o.apportionedMedicalInsurance), + "apportionedTelephone" -> Json.toJson(o.apportionedTelephone), + "apportionedService" -> Json.toJson(o.apportionedService), + "apportionedTaxableExpenses" -> Json.toJson(o.apportionedTaxableExpenses), + "apportionedVan" -> Json.toJson(o.apportionedVan), + "apportionedVanFuel" -> Json.toJson(o.apportionedVanFuel), + "apportionedMileage" -> Json.toJson(o.apportionedMileage), + "apportionedNonQualifyingRelocationExpenses" -> Json.toJson(o.apportionedNonQualifyingRelocationExpenses), + "apportionedNurseryPlaces" -> Json.toJson(o.apportionedNurseryPlaces), + "apportionedOtherItems" -> Json.toJson(o.apportionedOtherItems), + "apportionedPaymentsOnEmployeesBehalf" -> Json.toJson(o.apportionedPaymentsOnEmployeesBehalf), + "apportionedPersonalIncidentalExpenses" -> Json.toJson(o.apportionedPersonalIncidentalExpenses), + "apportionedQualifyingRelocationExpenses" -> Json.toJson(o.apportionedQualifyingRelocationExpenses), + "apportionedEmployerProvidedProfessionalSubscriptions" -> Json.toJson(o.apportionedEmployerProvidedProfessionalSubscriptions), + "apportionedEmployerProvidedServices" -> Json.toJson(o.apportionedEmployerProvidedServices), + "apportionedIncomeTaxPaidByDirector" -> Json.toJson(o.apportionedIncomeTaxPaidByDirector), + "apportionedTravelAndSubsistence" -> Json.toJson(o.apportionedTravelAndSubsistence), + "apportionedVouchersAndCreditCards" -> Json.toJson(o.apportionedVouchersAndCreditCards), + "apportionedNonCash" -> Json.toJson(o.apportionedNonCash) + ).filterNot { case (_, value) => + value == JsNull + } + ) + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncome.scala new file mode 100644 index 000000000..1edc932d8 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncome.scala @@ -0,0 +1,51 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class EmploymentAndPensionsIncome(totalPayeEmploymentAndLumpSumIncome: Option[BigDecimal], + totalOccupationalPensionIncome: Option[BigDecimal], + totalBenefitsInKind: Option[BigDecimal], + tipsIncome: Option[BigDecimal], + employmentAndPensionsIncomeDetail: Option[Seq[EmploymentAndPensionsIncomeDetail]]) { + + val isDefined: Boolean = + !(totalPayeEmploymentAndLumpSumIncome.isEmpty && + totalOccupationalPensionIncome.isEmpty && + totalBenefitsInKind.isEmpty && + tipsIncome.isEmpty && + employmentAndPensionsIncomeDetail.isEmpty) + + def withoutOffPayrollWorker: EmploymentAndPensionsIncome = { + employmentAndPensionsIncomeDetail match { + case Some(det) => { + val details = (for (c <- det) yield c.withoutOffPayrollWorker).filter(_.isDefined) + if (details.nonEmpty) + copy(employmentAndPensionsIncomeDetail = Some(details)) + else copy(employmentAndPensionsIncomeDetail = None) + } + case None => copy(employmentAndPensionsIncomeDetail = None) + } + } + +} + +object EmploymentAndPensionsIncome { + + implicit val format: Format[EmploymentAndPensionsIncome] = Json.format[EmploymentAndPensionsIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala new file mode 100644 index 000000000..f4b0e2a49 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala @@ -0,0 +1,62 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.Source + +case class EmploymentAndPensionsIncomeDetail(incomeSourceId: Option[String], + source: Option[Source], + occupationalPension: Option[Boolean], + employerRef: Option[String], + employerName: Option[String], + offPayrollWorker: Option[Boolean], + payrollId: Option[String], + startDate: Option[String], + dateEmploymentEnded: Option[String], + taxablePayToDate: Option[BigDecimal], + totalTaxToDate: Option[BigDecimal], + disguisedRemuneration: Option[Boolean], + lumpSums: Option[LumpSums], + studentLoans: Option[StudentLoans], + benefitsInKind: Option[BenefitsInKind]) { + + val isDefined: Boolean = + !(incomeSourceId.isEmpty && + source.isEmpty && + occupationalPension.isEmpty && + employerRef.isEmpty && + employerName.isEmpty && + offPayrollWorker.isEmpty && + payrollId.isEmpty && + startDate.isEmpty && + dateEmploymentEnded.isEmpty && + taxablePayToDate.isEmpty && + totalTaxToDate.isEmpty && + disguisedRemuneration.isEmpty && + lumpSums.isEmpty && + studentLoans.isEmpty && + benefitsInKind.isEmpty) + + def withoutOffPayrollWorker: EmploymentAndPensionsIncomeDetail = copy(offPayrollWorker = None) + +} + +object EmploymentAndPensionsIncomeDetail { + + implicit val format: Format[EmploymentAndPensionsIncomeDetail] = Json.format[EmploymentAndPensionsIncomeDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/LumpSums.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/LumpSums.scala new file mode 100644 index 000000000..c2cfb243f --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/LumpSums.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class LumpSums(totalLumpSum: BigDecimal, totalTaxPaid: Option[BigDecimal], lumpSumsDetail: LumpSumsDetail) + +object LumpSums { + + implicit val format: Format[LumpSums] = Json.format[LumpSums] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/LumpSumsDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/LumpSumsDetail.scala new file mode 100644 index 000000000..ba35bc5b7 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/LumpSumsDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class LumpSumsDetail(taxableLumpSumsAndCertainIncome: Option[TaxableLumpSumsAndCertainIncome], + benefitFromEmployerFinancedRetirementScheme: Option[BenefitFromEmployerFinancedRetirementScheme], + redundancyCompensationPaymentsOverExemption: Option[RedundancyCompensationPaymentsOverExemption], + redundancyCompensationPaymentsUnderExemption: Option[RedundancyCompensationPaymentsUnderExemption]) + +object LumpSumsDetail { + + implicit val format: Format[LumpSumsDetail] = Json.format[LumpSumsDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsOverExemption.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsOverExemption.scala new file mode 100644 index 000000000..fe8c794a5 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsOverExemption.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class RedundancyCompensationPaymentsOverExemption(amount: Option[BigDecimal], + taxPaid: Option[BigDecimal], + taxTakenOffInEmployment: Option[Boolean]) + +object RedundancyCompensationPaymentsOverExemption { + + implicit val format: Format[RedundancyCompensationPaymentsOverExemption] = Json.format[RedundancyCompensationPaymentsOverExemption] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsUnderExemption.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsUnderExemption.scala new file mode 100644 index 000000000..7c56a2814 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsUnderExemption.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class RedundancyCompensationPaymentsUnderExemption(amount: Option[BigDecimal]) + +object RedundancyCompensationPaymentsUnderExemption { + + implicit val format: Format[RedundancyCompensationPaymentsUnderExemption] = Json.format[RedundancyCompensationPaymentsUnderExemption] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/StudentLoans.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/StudentLoans.scala new file mode 100644 index 000000000..5b0a66aa7 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/StudentLoans.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class StudentLoans(uglDeductionAmount: Option[BigDecimal], pglDeductionAmount: Option[BigDecimal]) + +object StudentLoans { + + implicit val format: Format[StudentLoans] = Json.format[StudentLoans] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/TaxableLumpSumsAndCertainIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/TaxableLumpSumsAndCertainIncome.scala new file mode 100644 index 000000000..6136da69e --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/TaxableLumpSumsAndCertainIncome.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class TaxableLumpSumsAndCertainIncome(amount: Option[BigDecimal], taxPaid: Option[BigDecimal], taxTakenOffInEmployment: Option[Boolean]) + +object TaxableLumpSumsAndCertainIncome { + + implicit val format: Format[TaxableLumpSumsAndCertainIncome] = Json.format[TaxableLumpSumsAndCertainIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentExpenses/EmploymentExpenses.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentExpenses/EmploymentExpenses.scala new file mode 100644 index 000000000..c8344f433 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentExpenses/EmploymentExpenses.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentExpenses + +import play.api.libs.json.{Format, Json} + +case class EmploymentExpenses(totalEmploymentExpenses: Option[BigDecimal], employmentExpensesDetail: Option[EmploymentExpensesDetail]) + +object EmploymentExpenses { + + implicit val format: Format[EmploymentExpenses] = Json.format[EmploymentExpenses] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentExpenses/EmploymentExpensesDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentExpenses/EmploymentExpensesDetail.scala new file mode 100644 index 000000000..c24d6c78f --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentExpenses/EmploymentExpensesDetail.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentExpenses + +import play.api.libs.json.{Format, Json} + +case class EmploymentExpensesDetail(businessTravelCosts: Option[BigDecimal], + jobExpenses: Option[BigDecimal], + flatRateJobExpenses: Option[BigDecimal], + professionalSubscriptions: Option[BigDecimal], + hotelAndMealExpenses: Option[BigDecimal], + otherAndCapitalAllowances: Option[BigDecimal], + vehicleExpenses: Option[BigDecimal], + mileageAllowanceRelief: Option[BigDecimal]) + +object EmploymentExpensesDetail { + + implicit val format: Format[EmploymentExpensesDetail] = Json.format[EmploymentExpensesDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/EndOfYearEstimate.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/EndOfYearEstimate.scala new file mode 100644 index 000000000..e6bc02d3d --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/EndOfYearEstimate.scala @@ -0,0 +1,66 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.endOfYearEstimate + +import play.api.libs.json.{Json, OFormat} + +case class EndOfYearEstimate( + incomeSource: Option[Seq[IncomeSource]], + totalEstimatedIncome: Option[BigInt], + totalAllowancesAndDeductions: Option[BigInt], + totalTaxableIncome: Option[BigInt], + incomeTaxAmount: Option[BigDecimal], + nic2: Option[BigDecimal], + nic4: Option[BigDecimal], + totalTaxDeductedBeforeCodingOut: Option[BigDecimal], + saUnderpaymentsCodedOut: Option[BigDecimal], + totalNicAmount: Option[BigDecimal], + totalStudentLoansRepaymentAmount: Option[BigDecimal], + totalAnnuityPaymentsTaxCharged: Option[BigDecimal], + totalRoyaltyPaymentsTaxCharged: Option[BigDecimal], + totalTaxDeducted: Option[BigDecimal], + incomeTaxNicAmount: Option[BigDecimal], + cgtAmount: Option[BigDecimal], + incomeTaxNicAndCgtAmount: Option[BigDecimal] +) { + + def withoutTotalAllowanceAndDeductions: EndOfYearEstimate = + copy(totalAllowancesAndDeductions = None) + + val isDefined: Boolean = + !(totalEstimatedIncome.isEmpty && + totalAllowancesAndDeductions.isEmpty && + totalTaxableIncome.isEmpty && + incomeTaxAmount.isEmpty && + nic2.isEmpty && + nic4.isEmpty && + totalTaxDeductedBeforeCodingOut.isEmpty && + saUnderpaymentsCodedOut.isEmpty && + totalNicAmount.isEmpty && + totalStudentLoansRepaymentAmount.isEmpty && + totalAnnuityPaymentsTaxCharged.isEmpty && + totalRoyaltyPaymentsTaxCharged.isEmpty && + totalTaxDeducted.isEmpty && + incomeTaxNicAmount.isEmpty && + cgtAmount.isEmpty && + incomeTaxNicAndCgtAmount.isEmpty) + +} + +object EndOfYearEstimate { + implicit val format: OFormat[EndOfYearEstimate] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/IncomeSource.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/IncomeSource.scala new file mode 100644 index 000000000..f7a567325 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/IncomeSource.scala @@ -0,0 +1,57 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.endOfYearEstimate + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType + +case class IncomeSource( + incomeSourceId: Option[String], + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + taxableIncome: BigInt, + finalised: Option[Boolean] +) + +object IncomeSource { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`employments`, + IncomeSourceType.`foreign-income`, + IncomeSourceType.`foreign-dividends`, + IncomeSourceType.`uk-savings-and-gains`, + IncomeSourceType.`uk-dividends`, + IncomeSourceType.`state-benefits`, + IncomeSourceType.`gains-on-life-policies`, + IncomeSourceType.`share-schemes`, + IncomeSourceType.`foreign-property`, + IncomeSourceType.`foreign-savings-and-gains`, + IncomeSourceType.`other-dividends`, + IncomeSourceType.`uk-securities`, + IncomeSourceType.`other-income`, + IncomeSourceType.`foreign-pension`, + IncomeSourceType.`non-paye-income`, + IncomeSourceType.`capital-gains-tax`, + IncomeSourceType.`charitable-giving` + ) + + implicit val format: OFormat[IncomeSource] = Json.format[IncomeSource] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/ChargeableForeignBenefitsAndGiftsDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/ChargeableForeignBenefitsAndGiftsDetail.scala new file mode 100644 index 000000000..4828cd056 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/ChargeableForeignBenefitsAndGiftsDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.foreignIncome + +import play.api.libs.json.{Json, OFormat} + +case class ChargeableForeignBenefitsAndGiftsDetail(transactionBenefit: Option[BigDecimal], + protectedForeignIncomeSourceBenefit: Option[BigDecimal], + protectedForeignIncomeOnwardGift: Option[BigDecimal], + benefitReceivedAsASettler: Option[BigDecimal], + onwardGiftReceivedAsASettler: Option[BigDecimal]) + +object ChargeableForeignBenefitsAndGiftsDetail { + implicit val format: OFormat[ChargeableForeignBenefitsAndGiftsDetail] = Json.format[ChargeableForeignBenefitsAndGiftsDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/CommonForeignIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/CommonForeignIncome.scala new file mode 100644 index 000000000..4ca1a233f --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/CommonForeignIncome.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.foreignIncome + +import play.api.libs.json.{Json, OFormat} + +case class CommonForeignIncome(countryCode: String, + grossIncome: Option[BigDecimal], + netIncome: Option[BigDecimal], + taxDeducted: Option[BigDecimal], + foreignTaxCreditRelief: Option[Boolean]) + +object CommonForeignIncome { + implicit val format: OFormat[CommonForeignIncome] = Json.format[CommonForeignIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/ForeignIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/ForeignIncome.scala new file mode 100644 index 000000000..68e527fcc --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/ForeignIncome.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.foreignIncome + +import play.api.libs.json.{Json, OFormat} + +case class ForeignIncome(chargeableOverseasPensionsStateBenefitsRoyalties: Option[BigDecimal], + overseasPensionsStateBenefitsRoyaltiesDetail: Option[Seq[CommonForeignIncome]], + chargeableAllOtherIncomeReceivedWhilstAbroad: Option[BigDecimal], + allOtherIncomeReceivedWhilstAbroadDetail: Option[Seq[CommonForeignIncome]], + overseasIncomeAndGains: Option[OverseasIncomeAndGains], + totalForeignBenefitsAndGifts: Option[BigDecimal], + chargeableForeignBenefitsAndGiftsDetail: Option[ChargeableForeignBenefitsAndGiftsDetail]) + +object ForeignIncome { + implicit val format: OFormat[ForeignIncome] = Json.format[ForeignIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/OverseasIncomeAndGains.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/OverseasIncomeAndGains.scala new file mode 100644 index 000000000..c4dad8bee --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignIncome/OverseasIncomeAndGains.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.foreignIncome + +import play.api.libs.json.{Json, OFormat} + +case class OverseasIncomeAndGains(gainAmount: BigDecimal) + +object OverseasIncomeAndGains { + implicit val format: OFormat[OverseasIncomeAndGains] = Json.format[OverseasIncomeAndGains] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/foreignPropertyIncome/ForeignPropertyIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignPropertyIncome/ForeignPropertyIncome.scala new file mode 100644 index 000000000..72f9c7112 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignPropertyIncome/ForeignPropertyIncome.scala @@ -0,0 +1,38 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.foreignPropertyIncome + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType.`foreign-property` + +case class ForeignPropertyIncome(incomeSourceId: String, + incomeSourceType: IncomeSourceType, + countryCode: String, + totalIncome: Option[BigDecimal], + totalExpenses: Option[BigDecimal], + netProfit: Option[BigDecimal], + netLoss: Option[BigDecimal], + totalAdditions: Option[BigDecimal], + totalDeductions: Option[BigDecimal], + taxableProfit: Option[BigDecimal], + adjustedIncomeTaxLoss: Option[BigDecimal]) + +object ForeignPropertyIncome { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`foreign-property`) + implicit val format: OFormat[ForeignPropertyIncome] = Json.format[ForeignPropertyIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/foreignTaxForFtcrNotClaimed/ForeignTaxForFtcrNotClaimed.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignTaxForFtcrNotClaimed/ForeignTaxForFtcrNotClaimed.scala new file mode 100644 index 000000000..ae0d552f1 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/foreignTaxForFtcrNotClaimed/ForeignTaxForFtcrNotClaimed.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.foreignTaxForFtcrNotClaimed + +import play.api.libs.json.{Json, OFormat} + +case class ForeignTaxForFtcrNotClaimed(foreignTaxOnForeignEmployment: BigDecimal) + +object ForeignTaxForFtcrNotClaimed { + implicit val format: OFormat[ForeignTaxForFtcrNotClaimed] = Json.format[ForeignTaxForFtcrNotClaimed] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/giftAid/GiftAid.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/giftAid/GiftAid.scala new file mode 100644 index 000000000..6177010ca --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/giftAid/GiftAid.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.giftAid + +import play.api.libs.json.{Json, OFormat} + +case class GiftAid(grossGiftAidPayments: BigInt, + rate: BigDecimal, + giftAidTax: BigDecimal, + giftAidTaxReductions: Option[BigDecimal], + incomeTaxChargedAfterGiftAidTaxReductions: Option[BigDecimal], + giftAidCharge: Option[BigDecimal]) + +object GiftAid { + implicit val format: OFormat[GiftAid] = Json.format[GiftAid] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/incomeSummaryTotals/IncomeSummaryTotals.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/incomeSummaryTotals/IncomeSummaryTotals.scala new file mode 100644 index 000000000..ba6629936 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/incomeSummaryTotals/IncomeSummaryTotals.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.incomeSummaryTotals + +import play.api.libs.json.{Format, Json} + +case class IncomeSummaryTotals(totalSelfEmploymentProfit: Option[BigInt], + totalPropertyProfit: Option[BigInt], + totalFHLPropertyProfit: Option[BigInt], + totalUKOtherPropertyProfit: Option[BigInt], + totalForeignPropertyProfit: Option[BigInt], + totalEeaFhlProfit: Option[BigInt], + totalEmploymentIncome: Option[BigInt]) + +object IncomeSummaryTotals { + implicit val format: Format[IncomeSummaryTotals] = Json.format[IncomeSummaryTotals] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala new file mode 100644 index 000000000..37ff13838 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.{ClaimType, IncomeSourceType} + +case class CarriedForwardLoss( + claimId: Option[String], + originatingClaimId: Option[String], + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + claimType: ClaimType, + taxYearClaimMade: Option[TaxYear], + taxYearLossIncurred: TaxYear, + currentLossValue: BigInt, + lossType: Option[String] +) + +object CarriedForwardLoss { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val format: OFormat[CarriedForwardLoss] = Json.format[CarriedForwardLoss] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ClaimNotApplied.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ClaimNotApplied.scala new file mode 100644 index 000000000..9d471f301 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ClaimNotApplied.scala @@ -0,0 +1,45 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.{ClaimType, IncomeSourceType} + +case class ClaimNotApplied( + claimId: String, + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + taxYearClaimMade: TaxYear, + claimType: ClaimType +) + +object ClaimNotApplied { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val format: OFormat[ClaimNotApplied] = Json.format[ClaimNotApplied] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLoss.scala new file mode 100644 index 000000000..63c74d40b --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLoss.scala @@ -0,0 +1,45 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType + +case class DefaultCarriedForwardLoss( + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + taxYearLossIncurred: TaxYear, + currentLossValue: BigInt +) + +object DefaultCarriedForwardLoss { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val format: OFormat[DefaultCarriedForwardLoss] = Json.format[DefaultCarriedForwardLoss] + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossesAndClaims.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossesAndClaims.scala new file mode 100644 index 000000000..695403795 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossesAndClaims.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{Json, OFormat} + +case class LossesAndClaims( + resultOfClaimsApplied: Option[Seq[ResultOfClaimsApplied]], + unclaimedLosses: Option[Seq[UnclaimedLoss]], + carriedForwardLosses: Option[Seq[CarriedForwardLoss]], + defaultCarriedForwardLosses: Option[Seq[DefaultCarriedForwardLoss]], + claimsNotApplied: Option[Seq[ClaimNotApplied]] +) + +object LossesAndClaims { + implicit val format: OFormat[LossesAndClaims] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala new file mode 100644 index 000000000..dc1f33777 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala @@ -0,0 +1,51 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.{ClaimType, IncomeSourceType} + +case class ResultOfClaimsApplied( + claimId: Option[String], + originatingClaimId: Option[String], + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + taxYearClaimMade: TaxYear, + claimType: ClaimType, + mtdLoss: Option[Boolean], + taxYearLossIncurred: TaxYear, + lossAmountUsed: BigInt, + remainingLossValue: BigInt, + lossType: Option[String] +) + +object ResultOfClaimsApplied { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val format: OFormat[ResultOfClaimsApplied] = Json.format[ResultOfClaimsApplied] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala new file mode 100644 index 000000000..5e2decc15 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala @@ -0,0 +1,46 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType + +case class UnclaimedLoss( + incomeSourceId: Option[String], + incomeSourceType: IncomeSourceType, + taxYearLossIncurred: TaxYear, + currentLossValue: BigInt, + lossType: Option[String] +) + +object UnclaimedLoss { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val format: OFormat[UnclaimedLoss] = Json.format[UnclaimedLoss] + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/marriageAllowanceTransferredIn/MarriageAllowanceTransferredIn.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/marriageAllowanceTransferredIn/MarriageAllowanceTransferredIn.scala new file mode 100644 index 000000000..fadb1121d --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/marriageAllowanceTransferredIn/MarriageAllowanceTransferredIn.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.marriageAllowanceTransferredIn + +import play.api.libs.json.{Json, OFormat} + +case class MarriageAllowanceTransferredIn(amount: Option[BigDecimal], rate: Option[BigDecimal]) + +object MarriageAllowanceTransferredIn { + implicit val format: OFormat[MarriageAllowanceTransferredIn] = Json.format[MarriageAllowanceTransferredIn] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/notionalTax/NotionalTax.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/notionalTax/NotionalTax.scala new file mode 100644 index 000000000..83b434273 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/notionalTax/NotionalTax.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.notionalTax + +import play.api.libs.json.{Json, OFormat} + +case class NotionalTax(chargeableGains: Option[BigDecimal]) + +object NotionalTax { + implicit val format: OFormat[NotionalTax] = Json.format[NotionalTax] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/OtherIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/OtherIncome.scala new file mode 100644 index 000000000..ff2a28297 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/OtherIncome.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.otherIncome + +import play.api.libs.json.{Json, OFormat} + +case class OtherIncome(totalOtherIncome: BigDecimal, postCessationIncome: Option[PostCessationIncome]) + +object OtherIncome { + implicit val format: OFormat[OtherIncome] = Json.format[OtherIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/PostCessationIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/PostCessationIncome.scala new file mode 100644 index 000000000..29a11dc8a --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/PostCessationIncome.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.otherIncome + +import play.api.libs.json.{Json, OFormat} + +case class PostCessationIncome( + totalPostCessationReceipts: BigDecimal, + postCessationReceipts: Seq[PostCessationReceipt] +) + +object PostCessationIncome { + implicit val format: OFormat[PostCessationIncome] = Json.format[PostCessationIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/PostCessationReceipt.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/PostCessationReceipt.scala new file mode 100644 index 000000000..2027ce553 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/otherIncome/PostCessationReceipt.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.otherIncome + +import play.api.libs.json.{Json, OFormat} + +case class PostCessationReceipt(amount: BigDecimal, taxYearIncomeToBeTaxed: String) + +object PostCessationReceipt { + implicit val format: OFormat[PostCessationReceipt] = Json.format[PostCessationReceipt] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionContributionReliefs/PensionContributionDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionContributionReliefs/PensionContributionDetail.scala new file mode 100644 index 000000000..6f329b3c0 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionContributionReliefs/PensionContributionDetail.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionContributionReliefs + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionDetail(regularPensionContributions: Option[BigDecimal], oneOffPensionContributionsPaid: Option[BigDecimal]) + +object PensionContributionDetail { + implicit val format: OFormat[PensionContributionDetail] = Json.format[PensionContributionDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionContributionReliefs/PensionContributionReliefs.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionContributionReliefs/PensionContributionReliefs.scala new file mode 100644 index 000000000..d6f92d1d2 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionContributionReliefs/PensionContributionReliefs.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionContributionReliefs + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionReliefs(totalPensionContributionReliefs: BigDecimal, pensionContributionDetail: PensionContributionDetail) + +object PensionContributionReliefs { + implicit val format: OFormat[PensionContributionReliefs] = Json.format[PensionContributionReliefs] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ExcessOfLifeTimeAllowance.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ExcessOfLifeTimeAllowance.scala new file mode 100644 index 000000000..d1f8207f0 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ExcessOfLifeTimeAllowance.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class ExcessOfLifeTimeAllowance(totalChargeableAmount: Option[BigDecimal], + totalTaxPaid: Option[BigDecimal], + lumpSumBenefitTakenInExcessOfLifetimeAllowance: Option[PensionSavingsDetailBreakdown], + benefitInExcessOfLifetimeAllowance: Option[PensionSavingsDetailBreakdown]) + +object ExcessOfLifeTimeAllowance { + implicit val format: OFormat[ExcessOfLifeTimeAllowance] = Json.format[ExcessOfLifeTimeAllowance] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/OverseasPensionContributions.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/OverseasPensionContributions.scala new file mode 100644 index 000000000..dc814e8ca --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/OverseasPensionContributions.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class OverseasPensionContributions(totalShortServiceRefund: BigDecimal, + totalShortServiceRefundCharge: BigDecimal, + shortServiceRefundTaxPaid: Option[BigDecimal], + totalShortServiceRefundChargeDue: BigDecimal, + shortServiceRefundBands: Option[Seq[ShortServiceRefundBands]]) + +object OverseasPensionContributions { + implicit val format: OFormat[OverseasPensionContributions] = Json.format[OverseasPensionContributions] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionBand.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionBand.scala new file mode 100644 index 000000000..9b6976a97 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionBand.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.PensionBandName + +case class PensionBand(name: PensionBandName, + rate: BigDecimal, + bandLimit: BigInt, + apportionedBandLimit: BigInt, + contributionAmount: BigDecimal, + pensionCharge: BigDecimal) + +object PensionBand { + implicit val format: OFormat[PensionBand] = Json.format[PensionBand] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionContributionsInExcessOfTheAnnualAllowance.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionContributionsInExcessOfTheAnnualAllowance.scala new file mode 100644 index 000000000..143fc08ef --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionContributionsInExcessOfTheAnnualAllowance.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionsInExcessOfTheAnnualAllowance(totalContributions: BigDecimal, + totalPensionCharge: BigDecimal, + annualAllowanceTaxPaid: Option[BigDecimal], + totalPensionChargeDue: BigDecimal, + pensionBands: Option[Seq[PensionBand]]) + +object PensionContributionsInExcessOfTheAnnualAllowance { + + implicit val format: OFormat[PensionContributionsInExcessOfTheAnnualAllowance] = + Json.format[PensionContributionsInExcessOfTheAnnualAllowance] + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsDetailBreakdown.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsDetailBreakdown.scala new file mode 100644 index 000000000..4f3f3fd0b --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsDetailBreakdown.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSavingsDetailBreakdown(amount: Option[BigDecimal], + taxPaid: Option[BigDecimal], + rate: Option[BigDecimal], + chargeableAmount: Option[BigDecimal]) + +object PensionSavingsDetailBreakdown { + implicit val format: OFormat[PensionSavingsDetailBreakdown] = Json.format[PensionSavingsDetailBreakdown] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxCharges.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxCharges.scala new file mode 100644 index 000000000..dea1a4d80 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxCharges.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSavingsTaxCharges(totalPensionCharges: Option[BigDecimal], + totalTaxPaid: Option[BigDecimal], + totalPensionChargesDue: Option[BigDecimal], + pensionSavingsTaxChargesDetail: Option[PensionSavingsTaxChargesDetail]) + +object PensionSavingsTaxCharges { + implicit val format: OFormat[PensionSavingsTaxCharges] = Json.format[PensionSavingsTaxCharges] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxChargesDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxChargesDetail.scala new file mode 100644 index 000000000..6d49aeeab --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxChargesDetail.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSavingsTaxChargesDetail( + excessOfLifeTimeAllowance: Option[ExcessOfLifeTimeAllowance], + pensionSchemeUnauthorisedPayments: Option[PensionSchemeUnauthorisedPayments], + pensionSchemeOverseasTransfers: Option[PensionSchemeOverseasTransfers], + pensionContributionsInExcessOfTheAnnualAllowance: Option[PensionContributionsInExcessOfTheAnnualAllowance], + overseasPensionContributions: Option[OverseasPensionContributions]) + +object PensionSavingsTaxChargesDetail { + implicit val format: OFormat[PensionSavingsTaxChargesDetail] = Json.format[PensionSavingsTaxChargesDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeOverseasTransfers.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeOverseasTransfers.scala new file mode 100644 index 000000000..808fd5ff4 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeOverseasTransfers.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSchemeOverseasTransfers(transferCharge: Option[BigDecimal], + transferChargeTaxPaid: Option[BigDecimal], + rate: Option[BigDecimal], + chargeableAmount: Option[BigDecimal]) + +object PensionSchemeOverseasTransfers { + implicit val format: OFormat[PensionSchemeOverseasTransfers] = Json.format[PensionSchemeOverseasTransfers] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeUnauthorisedPayments.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeUnauthorisedPayments.scala new file mode 100644 index 000000000..4efe58dab --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeUnauthorisedPayments.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSchemeUnauthorisedPayments(totalChargeableAmount: Option[BigDecimal], + totalTaxPaid: Option[BigDecimal], + pensionSchemeUnauthorisedPaymentsSurcharge: Option[PensionSavingsDetailBreakdown], + pensionSchemeUnauthorisedPaymentsNonSurcharge: Option[PensionSavingsDetailBreakdown]) + +object PensionSchemeUnauthorisedPayments { + implicit val format: OFormat[PensionSchemeUnauthorisedPayments] = Json.format[PensionSchemeUnauthorisedPayments] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala new file mode 100644 index 000000000..84f05068a --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class ShortServiceRefundBands(name: String, + rate: BigDecimal, + bandLimit: BigInt, + apportionedBandLimit: BigInt, + shortServiceRefundAmount: BigDecimal, + shortServiceRefundCharge: BigDecimal) + +object ShortServiceRefundBands { + implicit val format: OFormat[ShortServiceRefundBands] = Json.format[ShortServiceRefundBands] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/previousCalculation/PreviousCalculation.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/previousCalculation/PreviousCalculation.scala new file mode 100644 index 000000000..d2c202260 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/previousCalculation/PreviousCalculation.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.previousCalculation + +import play.api.libs.json.{Json, OFormat} + +case class PreviousCalculation( + calculationTimestamp: Option[String], + calculationId: Option[String], + totalIncomeTaxAndNicsDue: Option[BigDecimal], + cgtTaxDue: Option[BigDecimal], + totalIncomeTaxAndNicsAndCgtDue: Option[BigDecimal], + incomeTaxNicDueThisPeriod: Option[BigDecimal], + cgtDueThisPeriod: Option[BigDecimal], + totalIncomeTaxAndNicsAndCgtDueThisPeriod: Option[BigDecimal] +) + +object PreviousCalculation { + implicit val format: OFormat[PreviousCalculation] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/AllOtherIncomeReceivedWhilstAbroad.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/AllOtherIncomeReceivedWhilstAbroad.scala new file mode 100644 index 000000000..ba0f4ef85 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/AllOtherIncomeReceivedWhilstAbroad.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Format, Json} + +case class AllOtherIncomeReceivedWhilstAbroad(totalOtherIncomeAllowableAmount: BigDecimal, otherIncomeRfcDetail: Seq[OtherIncomeRfcDetail]) + +object AllOtherIncomeReceivedWhilstAbroad { + implicit val format: Format[AllOtherIncomeReceivedWhilstAbroad] = Json.format[AllOtherIncomeReceivedWhilstAbroad] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/BasicRateExtension.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/BasicRateExtension.scala new file mode 100644 index 000000000..9692e6f41 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/BasicRateExtension.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class BasicRateExtension(totalBasicRateExtension: Option[BigDecimal], + giftAidRelief: Option[BigInt], + pensionContributionReliefs: Option[BigDecimal]) + +object BasicRateExtension { + implicit val format: OFormat[BasicRateExtension] = Json.format[BasicRateExtension] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignProperty.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignProperty.scala new file mode 100644 index 000000000..f872b0b89 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignProperty.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ForeignProperty(totalForeignPropertyAllowableAmount: BigDecimal, foreignPropertyRfcDetail: Seq[ForeignPropertyRfcDetail]) + +object ForeignProperty { + implicit val format: OFormat[ForeignProperty] = Json.format[ForeignProperty] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignPropertyRfcDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignPropertyRfcDetail.scala new file mode 100644 index 000000000..a9fbe0a4e --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignPropertyRfcDetail.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ForeignPropertyRfcDetail(countryCode: String, + amountClaimed: BigInt, + allowableAmount: BigDecimal, + carryForwardAmount: Option[BigDecimal]) + +object ForeignPropertyRfcDetail { + implicit val format: OFormat[ForeignPropertyRfcDetail] = Json.format[ForeignPropertyRfcDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignTaxCreditRelief.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignTaxCreditRelief.scala new file mode 100644 index 000000000..26a1d49b5 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignTaxCreditRelief.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ForeignTaxCreditRelief(customerCalculatedRelief: Option[Boolean], + totalForeignTaxCreditRelief: BigDecimal, + foreignTaxCreditReliefOnProperty: Option[BigDecimal], + foreignTaxCreditReliefOnDividends: Option[BigDecimal], + foreignTaxCreditReliefOnSavings: Option[BigDecimal], + foreignTaxCreditReliefOnForeignIncome: Option[BigDecimal], + foreignTaxCreditReliefDetail: Option[Seq[ForeignTaxCreditReliefDetail]]) + +object ForeignTaxCreditRelief { + implicit val format: OFormat[ForeignTaxCreditRelief] = Json.format[ForeignTaxCreditRelief] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignTaxCreditReliefDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignTaxCreditReliefDetail.scala new file mode 100644 index 000000000..51ce8f1dc --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ForeignTaxCreditReliefDetail.scala @@ -0,0 +1,46 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class ForeignTaxCreditReliefDetail(incomeSourceType: Option[IncomeSourceType], + incomeSourceId: Option[String], + countryCode: String, + foreignIncome: BigDecimal, + foreignTax: Option[BigDecimal], + dtaRate: Option[BigDecimal], + dtaAmount: Option[BigDecimal], + ukLiabilityOnIncome: Option[BigDecimal], + foreignTaxCredit: BigDecimal, + employmentLumpSum: Option[Boolean]) + +object ForeignTaxCreditReliefDetail { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = + IncomeSourceType.formatRestricted( + `foreign-dividends`, + `foreign-property`, + `foreign-savings-and-gains`, + `other-income`, + `foreign-pension` + ) + + implicit val format: OFormat[ForeignTaxCreditReliefDetail] = Json.format[ForeignTaxCreditReliefDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/GiftAidTaxReductionWhereBasicRateDiffers.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/GiftAidTaxReductionWhereBasicRateDiffers.scala new file mode 100644 index 000000000..94ab91338 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/GiftAidTaxReductionWhereBasicRateDiffers.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class GiftAidTaxReductionWhereBasicRateDiffers(amount: Option[BigDecimal]) + +object GiftAidTaxReductionWhereBasicRateDiffers { + implicit val format: OFormat[GiftAidTaxReductionWhereBasicRateDiffers] = Json.format[GiftAidTaxReductionWhereBasicRateDiffers] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/OtherIncomeRfcDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/OtherIncomeRfcDetail.scala new file mode 100644 index 000000000..f6de83e9d --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/OtherIncomeRfcDetail.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class OtherIncomeRfcDetail(countryCode: String, + residentialFinancialCostAmount: Option[BigDecimal], + broughtFwdResidentialFinancialCostAmount: Option[BigDecimal]) + +object OtherIncomeRfcDetail { + implicit val format: OFormat[OtherIncomeRfcDetail] = Json.format[OtherIncomeRfcDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/Reliefs.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/Reliefs.scala new file mode 100644 index 000000000..2360434bc --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/Reliefs.scala @@ -0,0 +1,40 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class Reliefs(residentialFinanceCosts: Option[ResidentialFinanceCosts], + reliefsClaimed: Option[Seq[ReliefsClaimed]], + foreignTaxCreditRelief: Option[ForeignTaxCreditRelief], + topSlicingRelief: Option[TopSlicingRelief], + basicRateExtension: Option[BasicRateExtension], + giftAidTaxReductionWhereBasicRateDiffers: Option[GiftAidTaxReductionWhereBasicRateDiffers]) { + + val isDefined: Boolean = + !(residentialFinanceCosts.isEmpty && reliefsClaimed.isEmpty && foreignTaxCreditRelief.isEmpty && topSlicingRelief.isEmpty && basicRateExtension.isEmpty && giftAidTaxReductionWhereBasicRateDiffers.isEmpty) + + def withoutBasicExtension: Reliefs = copy(basicRateExtension = None) + + def withoutGiftAidTaxReductionWhereBasicRateDiffers: Reliefs = copy(giftAidTaxReductionWhereBasicRateDiffers = None) + +} + +object Reliefs extends { + + implicit val format: OFormat[Reliefs] = Json.format[Reliefs] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimed.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimed.scala new file mode 100644 index 000000000..ceb32f5b1 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimed.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.ReliefsClaimedType + +case class ReliefsClaimed(`type`: ReliefsClaimedType, + amountClaimed: Option[BigDecimal], + allowableAmount: Option[BigDecimal], + amountUsed: Option[BigDecimal], + rate: Option[BigDecimal], + reliefsClaimedDetail: Option[Seq[ReliefsClaimedDetail]]) + +object ReliefsClaimed { + implicit val format: OFormat[ReliefsClaimed] = Json.format[ReliefsClaimed] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala new file mode 100644 index 000000000..6d7017737 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ReliefsClaimedDetail(amountClaimed: Option[BigDecimal], + uniqueInvestmentRef: Option[String], + name: Option[String], + socialEnterpriseName: Option[String], + companyName: Option[String], + deficiencyReliefType: Option[String], + customerReference: Option[String]) + +object ReliefsClaimedDetail { + implicit val format: OFormat[ReliefsClaimedDetail] = Json.format[ReliefsClaimedDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ResidentialFinanceCosts.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ResidentialFinanceCosts.scala new file mode 100644 index 000000000..026262d51 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ResidentialFinanceCosts.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ResidentialFinanceCosts(adjustedTotalIncome: BigDecimal, + totalAllowableAmount: Option[BigDecimal], + relievableAmount: BigDecimal, + rate: BigDecimal, + totalResidentialFinanceCostsRelief: BigDecimal, + ukProperty: Option[UkProperty], + foreignProperty: Option[ForeignProperty], + allOtherIncomeReceivedWhilstAbroad: Option[AllOtherIncomeReceivedWhilstAbroad]) + +object ResidentialFinanceCosts { + implicit val format: OFormat[ResidentialFinanceCosts] = Json.format[ResidentialFinanceCosts] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/TopSlicingRelief.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/TopSlicingRelief.scala new file mode 100644 index 000000000..9a4e06ab4 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/TopSlicingRelief.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class TopSlicingRelief(amount: Option[BigDecimal]) + +object TopSlicingRelief { + implicit val format: OFormat[TopSlicingRelief] = Json.format[TopSlicingRelief] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/UkProperty.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/UkProperty.scala new file mode 100644 index 000000000..915ce0fef --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/UkProperty.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class UkProperty(amountClaimed: BigInt, allowableAmount: BigDecimal, carryForwardAmount: Option[BigDecimal]) + +object UkProperty { + implicit val format: OFormat[UkProperty] = Json.format[UkProperty] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/royaltyPayments/RoyaltyPayments.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/royaltyPayments/RoyaltyPayments.scala new file mode 100644 index 000000000..d68299e59 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/royaltyPayments/RoyaltyPayments.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.royaltyPayments + +import play.api.libs.json.{Json, OFormat} + +case class RoyaltyPayments(royaltyPaymentsAmount: BigInt, rate: BigDecimal, grossRoyaltyPayments: Option[BigInt]) + +object RoyaltyPayments { + implicit val format: OFormat[RoyaltyPayments] = Json.format[RoyaltyPayments] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncome.scala new file mode 100644 index 000000000..b4bebf91c --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncome.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType.`foreign-savings-and-gains` + +case class ForeignSavingsAndGainsIncome(incomeSourceType: IncomeSourceType, + countryCode: Option[String], + grossIncome: Option[BigDecimal], + netIncome: Option[BigDecimal], + taxDeducted: Option[BigDecimal], + foreignTaxCreditRelief: Option[Boolean]) + +object ForeignSavingsAndGainsIncome { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`foreign-savings-and-gains`) + implicit val format: Format[ForeignSavingsAndGainsIncome] = Json.format[ForeignSavingsAndGainsIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncome.scala new file mode 100644 index 000000000..7202c5d69 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncome.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{Format, Json} + +case class SavingsAndGainsIncome(totalChargeableSavingsAndGains: Option[BigInt], + totalUkSavingsAndGains: Option[BigInt], + ukSavingsAndGainsIncome: Option[Seq[UkSavingsAndGainsIncome]], + chargeableForeignSavingsAndGains: Option[BigInt], + foreignSavingsAndGainsIncome: Option[Seq[ForeignSavingsAndGainsIncome]]) + +object SavingsAndGainsIncome { + implicit val format: Format[SavingsAndGainsIncome] = Json.format[SavingsAndGainsIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncome.scala new file mode 100644 index 000000000..205a56822 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncome.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class UkSavingsAndGainsIncome(incomeSourceId: Option[String], + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + grossIncome: BigDecimal, + netIncome: Option[BigDecimal], + taxDeducted: Option[BigDecimal]) + +object UkSavingsAndGainsIncome { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`uk-savings-and-gains`, `uk-securities`) + implicit val format: Format[UkSavingsAndGainsIncome] = Json.format[UkSavingsAndGainsIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/seafarersDeductions/SeafarersDeductionDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/seafarersDeductions/SeafarersDeductionDetail.scala new file mode 100644 index 000000000..843d4fdcf --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/seafarersDeductions/SeafarersDeductionDetail.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.seafarersDeductions + +import play.api.libs.json.{Format, Json} + +case class SeafarersDeductionDetail(nameOfShip: String, amountDeducted: BigDecimal) + +object SeafarersDeductionDetail { + + implicit val format: Format[SeafarersDeductionDetail] = Json.format[SeafarersDeductionDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/seafarersDeductions/SeafarersDeductions.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/seafarersDeductions/SeafarersDeductions.scala new file mode 100644 index 000000000..57ff93e20 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/seafarersDeductions/SeafarersDeductions.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.seafarersDeductions + +import play.api.libs.json.{Format, Json} + +case class SeafarersDeductions(totalSeafarersDeduction: BigDecimal, seafarersDeductionDetail: Seq[SeafarersDeductionDetail]) + +object SeafarersDeductions { + + implicit val format: Format[SeafarersDeductions] = Json.format[SeafarersDeductions] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala new file mode 100644 index 000000000..28f7aa175 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.shareSchemesIncome + +import play.api.libs.json.{Json, OFormat} + +case class ShareSchemeDetail(`type`: String, employerName: Option[String], employerRef: Option[String], taxableAmount: BigDecimal) + +object ShareSchemeDetail { + implicit val format: OFormat[ShareSchemeDetail] = Json.format[ShareSchemeDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemesIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemesIncome.scala new file mode 100644 index 000000000..5382d4a94 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemesIncome.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.shareSchemesIncome + +import play.api.libs.json.{Json, OFormat} + +case class ShareSchemesIncome(totalIncome: BigDecimal, shareSchemeDetail: Option[Seq[ShareSchemeDetail]]) + +object ShareSchemesIncome { + implicit val format: OFormat[ShareSchemesIncome] = Json.format[ShareSchemesIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/CommonBenefit.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/CommonBenefit.scala new file mode 100644 index 000000000..ddcd9467c --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/CommonBenefit.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class CommonBenefit(incomeSourceId: String, amount: BigDecimal, source: Option[String]) + +object CommonBenefit { + implicit val format: OFormat[CommonBenefit] = Json.format[CommonBenefit] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/CommonBenefitWithTaxPaid.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/CommonBenefitWithTaxPaid.scala new file mode 100644 index 000000000..238ad2d29 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/CommonBenefitWithTaxPaid.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class CommonBenefitWithTaxPaid(incomeSourceId: String, amount: BigDecimal, taxPaid: Option[BigDecimal], source: Option[String]) + +object CommonBenefitWithTaxPaid { + implicit val format: OFormat[CommonBenefitWithTaxPaid] = Json.format[CommonBenefitWithTaxPaid] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StateBenefitsDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StateBenefitsDetail.scala new file mode 100644 index 000000000..4ecc442a7 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StateBenefitsDetail.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class StateBenefitsDetail(incapacityBenefit: Option[Seq[CommonBenefitWithTaxPaid]], + statePension: Option[Seq[CommonBenefit]], + statePensionLumpSum: Option[Seq[StatePensionLumpSum]], + employmentSupportAllowance: Option[Seq[CommonBenefitWithTaxPaid]], + jobSeekersAllowance: Option[Seq[CommonBenefitWithTaxPaid]], + bereavementAllowance: Option[Seq[CommonBenefit]], + otherStateBenefits: Option[Seq[CommonBenefit]]) + +object StateBenefitsDetail { + implicit val format: OFormat[StateBenefitsDetail] = Json.format[StateBenefitsDetail] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StateBenefitsIncome.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StateBenefitsIncome.scala new file mode 100644 index 000000000..42a9e37e3 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StateBenefitsIncome.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class StateBenefitsIncome(totalStateBenefitsIncome: Option[BigDecimal], + totalStateBenefitsTaxPaid: Option[BigDecimal], + stateBenefitsDetail: Option[StateBenefitsDetail], + totalStateBenefitsIncomeExcStatePensionLumpSum: Option[BigDecimal]) + +object StateBenefitsIncome { + implicit val format: OFormat[StateBenefitsIncome] = Json.format[StateBenefitsIncome] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StatePensionLumpSum.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StatePensionLumpSum.scala new file mode 100644 index 000000000..c27f71b8a --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/stateBenefitsIncome/StatePensionLumpSum.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class StatePensionLumpSum(incomeSourceId: String, amount: BigDecimal, taxPaid: Option[BigDecimal], rate: BigDecimal, source: Option[String]) + +object StatePensionLumpSum { + implicit val format: OFormat[StatePensionLumpSum] = Json.format[StatePensionLumpSum] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/studentLoans/StudentLoans.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/studentLoans/StudentLoans.scala new file mode 100644 index 000000000..ce1fe06e9 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/studentLoans/StudentLoans.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.studentLoans + +import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.StudentLoanPlanType + +case class StudentLoans(planType: StudentLoanPlanType, + studentLoanTotalIncomeAmount: BigDecimal, + studentLoanChargeableIncomeAmount: BigDecimal, + studentLoanRepaymentAmount: BigDecimal, + studentLoanDeductionsFromEmployment: Option[BigDecimal], + studentLoanRepaymentAmountNetOfDeductions: BigDecimal, + studentLoanApportionedIncomeThreshold: BigInt, + studentLoanRate: BigDecimal, + payeIncomeForStudentLoan: Option[BigDecimal], + nonPayeIncomeForStudentLoan: Option[BigDecimal]) + +object StudentLoans { + implicit val format: OFormat[StudentLoans] = Json.format[StudentLoans] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRel.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRel.scala new file mode 100644 index 000000000..da07d0baa --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRel.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class BusinessAssetsDisposalsAndInvestorsRel( + gainsIncome: Option[BigDecimal], + lossesBroughtForward: Option[BigDecimal], + lossesArisingThisYear: Option[BigDecimal], + gainsAfterLosses: Option[BigDecimal], + annualExemptionAmount: Option[BigDecimal], + taxableGains: Option[BigDecimal], + rate: Option[BigDecimal], + taxAmount: Option[BigDecimal] +) + +object BusinessAssetsDisposalsAndInvestorsRel { + implicit val format: Format[BusinessAssetsDisposalsAndInvestorsRel] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CapitalGainsTax.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CapitalGainsTax.scala new file mode 100644 index 000000000..3df789a18 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CapitalGainsTax.scala @@ -0,0 +1,40 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class CapitalGainsTax( + totalCapitalGainsIncome: BigDecimal, + annualExemptionAmount: BigDecimal, + totalTaxableGains: BigDecimal, + businessAssetsDisposalsAndInvestorsRel: Option[BusinessAssetsDisposalsAndInvestorsRel], + residentialPropertyAndCarriedInterest: Option[ResidentialPropertyAndCarriedInterest], + otherGains: Option[OtherGains], + capitalGainsTaxAmount: Option[BigDecimal], + adjustments: Option[BigDecimal], + adjustedCapitalGainsTax: Option[BigDecimal], + foreignTaxCreditRelief: Option[BigDecimal], + capitalGainsTaxAfterFTCR: Option[BigDecimal], + taxOnGainsAlreadyPaid: Option[BigDecimal], + capitalGainsTaxDue: BigDecimal, + capitalGainsOverpaid: Option[BigDecimal] +) + +object CapitalGainsTax { + implicit val format: Format[CapitalGainsTax] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBand.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBand.scala new file mode 100644 index 000000000..4aca544b0 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBand.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class CgtBand( + name: CgtBandName, + rate: BigDecimal, + income: BigDecimal, + taxAmount: BigDecimal +) + +object CgtBand { + implicit val format: Format[CgtBand] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandName.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandName.scala new file mode 100644 index 000000000..986f05915 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandName.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait CgtBandName + +object CgtBandName { + case object `lower-rate` extends CgtBandName + case object `higher-rate` extends CgtBandName + + implicit val writes: Writes[CgtBandName] = Enums.writes[CgtBandName] + + implicit val reads: Reads[CgtBandName] = Enums.readsUsing { + case "lowerRate" => `lower-rate` + case "higherRate" => `higher-rate` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class2Nics.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class2Nics.scala new file mode 100644 index 000000000..2ffa02861 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class2Nics.scala @@ -0,0 +1,36 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class Class2Nics( + amount: Option[BigDecimal], + weeklyRate: Option[BigDecimal], + weeks: Option[BigInt], + limit: Option[BigInt], + apportionedLimit: Option[BigInt], + underSmallProfitThreshold: Boolean, + underLowerProfitThreshold: Option[Boolean], + actualClass2Nic: Option[Boolean] +) { + def withoutUnderLowerProfitThreshold: Class2Nics = copy(underLowerProfitThreshold = None) +} + +object Class2Nics { + implicit val format: Format[Class2Nics] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class4Nics.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class4Nics.scala new file mode 100644 index 000000000..e3214a454 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class4Nics.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class Class4Nics( + totalIncomeLiableToClass4Charge: Option[BigInt], + totalClass4LossesAvailable: Option[BigInt], + totalClass4LossesUsed: Option[BigInt], + totalClass4LossesCarriedForward: Option[BigInt], + totalIncomeChargeableToClass4: Option[BigInt], + totalAmount: BigDecimal, + nic4Bands: Seq[Nic4Band] +) + +object Class4Nics { + implicit val format: Format[Class4Nics] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTax.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTax.scala new file mode 100644 index 000000000..adc1629d2 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTax.scala @@ -0,0 +1,48 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class IncomeTax( + totalIncomeReceivedFromAllSources: BigInt, + totalAllowancesAndDeductions: BigInt, + totalTaxableIncome: BigInt, + payPensionsProfit: Option[IncomeTaxItem], + savingsAndGains: Option[IncomeTaxItem], + dividends: Option[IncomeTaxItem], + lumpSums: Option[IncomeTaxItem], + gainsOnLifePolicies: Option[IncomeTaxItem], + incomeTaxCharged: BigDecimal, + totalReliefs: Option[BigDecimal], + incomeTaxDueAfterReliefs: Option[BigDecimal], + totalNotionalTax: Option[BigDecimal], + marriageAllowanceRelief: Option[BigDecimal], + incomeTaxDueAfterTaxReductions: Option[BigDecimal], + incomeTaxDueAfterGiftAid: Option[BigDecimal], + totalPensionSavingsTaxCharges: Option[BigDecimal], + statePensionLumpSumCharges: Option[BigDecimal], + payeUnderpaymentsCodedOut: Option[BigDecimal], + totalIncomeTaxDue: Option[BigDecimal], + giftAidTaxChargeWhereBasicRateDiffers: Option[BigDecimal] +) { + def withoutGiftAidTaxChargeWhereBasicRateDiffers: IncomeTax = copy(giftAidTaxChargeWhereBasicRateDiffers = None) +} + +object IncomeTax { + implicit val format: Format[IncomeTax] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBand.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBand.scala new file mode 100644 index 000000000..e7287ee46 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBand.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class IncomeTaxBand( + name: IncomeTaxBandName, + rate: BigDecimal, + bandLimit: BigInt, + apportionedBandLimit: BigInt, + income: BigInt, + taxAmount: BigDecimal +) + +object IncomeTaxBand { + implicit val format: Format[IncomeTaxBand] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandName.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandName.scala new file mode 100644 index 000000000..581e69d63 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandName.scala @@ -0,0 +1,57 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait IncomeTaxBandName + +object IncomeTaxBandName { + case object `savings-starter-rate` extends IncomeTaxBandName + + case object `allowance-awarded-at-basic-rate` extends IncomeTaxBandName + + case object `allowance-awarded-at-higher-rate` extends IncomeTaxBandName + + case object `allowance-awarded-at-additional-rate` extends IncomeTaxBandName + + case object `starter-rate` extends IncomeTaxBandName + + case object `basic-rate` extends IncomeTaxBandName + + case object `intermediate-rate` extends IncomeTaxBandName + + case object `higher-rate` extends IncomeTaxBandName + + case object `additional-rate` extends IncomeTaxBandName + + implicit val writes: Writes[IncomeTaxBandName] = Enums.writes[IncomeTaxBandName] + + implicit val reads: Reads[IncomeTaxBandName] = Enums.readsUsing { + case "SSR" => `savings-starter-rate` + case "ZRTBR" => `allowance-awarded-at-basic-rate` + case "ZRTHR" => `allowance-awarded-at-higher-rate` + case "ZRTAR" => `allowance-awarded-at-additional-rate` + case "SRT" => `starter-rate` + case "BRT" => `basic-rate` + case "IRT" => `intermediate-rate` + case "HRT" => `higher-rate` + case "ART" => `additional-rate` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxItem.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxItem.scala new file mode 100644 index 000000000..2760fe114 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxItem.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class IncomeTaxItem( + incomeReceived: BigInt, + allowancesAllocated: BigInt, + taxableIncome: BigInt, + incomeTaxAmount: BigDecimal, + taxBands: Option[Seq[IncomeTaxBand]] +) + +object IncomeTaxItem { + implicit val format: Format[IncomeTaxItem] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4Band.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4Band.scala new file mode 100644 index 000000000..7f696b0b5 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4Band.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class Nic4Band( + name: Nic4BandName, + rate: BigDecimal, + threshold: Option[BigInt], + apportionedThreshold: Option[BigInt], + income: BigInt, + amount: BigDecimal +) + +object Nic4Band { + implicit val format: Format[Nic4Band] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandName.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandName.scala new file mode 100644 index 000000000..f81743658 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandName.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait Nic4BandName + +object Nic4BandName { + case object `zero-rate` extends Nic4BandName + + case object `basic-rate` extends Nic4BandName + + case object `higher-rate` extends Nic4BandName + + implicit val writes: Writes[Nic4BandName] = Enums.writes[Nic4BandName] + + implicit val reads: Reads[Nic4BandName] = Enums.readsUsing { + case "ZRT" => `zero-rate` + case "BRT" => `basic-rate` + case "HRT" => `higher-rate` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nics.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nics.scala new file mode 100644 index 000000000..794ac5366 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nics.scala @@ -0,0 +1,44 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class Nics( + class2Nics: Option[Class2Nics], + class4Nics: Option[Class4Nics], + nic2NetOfDeductions: Option[BigDecimal], + nic4NetOfDeductions: Option[BigDecimal], + totalNic: Option[BigDecimal] +) { + + def isDefined: Boolean = !( + class2Nics.isEmpty && + class4Nics.isEmpty && + nic2NetOfDeductions.isEmpty && + nic4NetOfDeductions.isEmpty && + totalNic.isEmpty + ) + + def withoutUnderLowerProfitThreshold: Nics = + copy(class2Nics = class2Nics.map(_.withoutUnderLowerProfitThreshold)) + +} + +object Nics { + implicit val format: Format[Nics] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/OtherGains.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/OtherGains.scala new file mode 100644 index 000000000..657f33d0e --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/OtherGains.scala @@ -0,0 +1,36 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class OtherGains( + gainsIncome: Option[BigDecimal], + lossesBroughtForward: Option[BigDecimal], + lossesArisingThisYear: Option[BigDecimal], + gainsAfterLosses: Option[BigDecimal], + attributedGains: Option[BigDecimal], + netGains: Option[BigDecimal], + annualExemptionAmount: Option[BigDecimal], + taxableGains: Option[BigDecimal], + cgtTaxBands: Option[Seq[CgtBand]], + totalTaxAmount: Option[BigDecimal] +) + +object OtherGains { + implicit val format: Format[OtherGains] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterest.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterest.scala new file mode 100644 index 000000000..9d622e900 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterest.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class ResidentialPropertyAndCarriedInterest( + gainsIncome: Option[BigDecimal], + lossesBroughtForward: Option[BigDecimal], + lossesArisingThisYear: Option[BigDecimal], + gainsAfterLosses: Option[BigDecimal], + annualExemptionAmount: Option[BigDecimal], + taxableGains: Option[BigDecimal], + cgtTaxBands: Option[Seq[CgtBand]], + totalTaxAmount: Option[BigDecimal] +) + +object ResidentialPropertyAndCarriedInterest { + implicit val format: Format[ResidentialPropertyAndCarriedInterest] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculation.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculation.scala new file mode 100644 index 000000000..de1c3f727 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculation.scala @@ -0,0 +1,46 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class TaxCalculation( + incomeTax: Option[IncomeTax], + nics: Option[Nics], + totalTaxDeductedBeforeCodingOut: Option[BigDecimal], + saUnderpaymentsCodedOut: Option[BigDecimal], + totalIncomeTaxNicsCharged: Option[BigDecimal], + totalStudentLoansRepaymentAmount: Option[BigDecimal], + totalAnnuityPaymentsTaxCharged: Option[BigDecimal], + totalRoyaltyPaymentsTaxCharged: Option[BigDecimal], + totalTaxDeducted: Option[BigDecimal], + totalIncomeTaxAndNicsDue: Option[BigDecimal], + capitalGainsTax: Option[CapitalGainsTax], + totalIncomeTaxAndNicsAndCgt: Option[BigDecimal] +) { + + def withoutUnderLowerProfitThreshold: TaxCalculation = + copy(nics = nics.map(_.withoutUnderLowerProfitThreshold).filter(_.isDefined)) + + def withoutGiftAidTaxChargeWhereBasicRateDiffers: TaxCalculation = + copy(incomeTax = incomeTax.map(_.withoutGiftAidTaxChargeWhereBasicRateDiffers)) + +} + +object TaxCalculation { + implicit val format: Format[TaxCalculation] = Json.format +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/taxDeductedAtSource/TaxDeductedAtSource.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/taxDeductedAtSource/TaxDeductedAtSource.scala new file mode 100644 index 000000000..5d5094a6d --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/taxDeductedAtSource/TaxDeductedAtSource.scala @@ -0,0 +1,40 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxDeductedAtSource + +import play.api.libs.json.{Json, OFormat} + +case class TaxDeductedAtSource(bbsi: Option[BigDecimal], + ukLandAndProperty: Option[BigDecimal], + cis: Option[BigDecimal], + securities: Option[BigDecimal], + voidedIsa: Option[BigDecimal], + payeEmployments: Option[BigDecimal], + occupationalPensions: Option[BigDecimal], + stateBenefits: Option[BigDecimal], + specialWithholdingTaxOrUkTaxPaid: Option[BigDecimal], + inYearAdjustmentCodedInLaterTaxYear: Option[BigDecimal], + taxTakenOffTradingIncome: Option[BigDecimal]) { + + def withoutTaxTakenOffTradingIncome: TaxDeductedAtSource = + copy(taxTakenOffTradingIncome = None) + +} + +object TaxDeductedAtSource { + implicit val format: OFormat[TaxDeductedAtSource] = Json.format[TaxDeductedAtSource] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala new file mode 100644 index 000000000..b74f94a73 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class AllowancesReliefsAndDeductions(`type`: Option[String], + submittedTimestamp: Option[String], + startDate: Option[String], + endDate: Option[String], + source: Option[String]) + +object AllowancesReliefsAndDeductions { + implicit val format: OFormat[AllowancesReliefsAndDeductions] = Json.format[AllowancesReliefsAndDeductions] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/AnnualAdjustment.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/AnnualAdjustment.scala new file mode 100644 index 000000000..df3b29fa1 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/AnnualAdjustment.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.functional.syntax._ +import play.api.libs.json._ +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class AnnualAdjustment(incomeSourceId: String, + incomeSourceType: IncomeSourceType, + bsasId: String, + receivedDateTime: String, + applied: Boolean) + +object AnnualAdjustment { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `uk-property-fhl`, + `foreign-property-fhl-eea`, + `foreign-property` + ) + + implicit val reads: Reads[AnnualAdjustment] = ( + (JsPath \ "incomeSourceId").read[String] and + (JsPath \ "incomeSourceType").read[IncomeSourceType](incomeSourceTypeFormat) and + (JsPath \ "ascId").read[String] and + (JsPath \ "receivedDateTime").read[String] and + (JsPath \ "applied").read[Boolean] + )(AnnualAdjustment.apply _) + + implicit val writes: OWrites[AnnualAdjustment] = Json.writes +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/BusinessIncomeSource.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/BusinessIncomeSource.scala new file mode 100644 index 000000000..5292043d3 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/BusinessIncomeSource.scala @@ -0,0 +1,63 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class BusinessIncomeSource(incomeSourceId: String, + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + accountingPeriodStartDate: String, + accountingPeriodEndDate: String, + source: String, + commencementDate: Option[String], + cessationDate: Option[String], + latestPeriodEndDate: String, + latestReceivedDateTime: String, + finalised: Option[Boolean], + finalisationTimestamp: Option[String], + submissionPeriods: Option[Seq[SubmissionPeriod]]) { + + val isDefined: Boolean = + !(incomeSourceName.isEmpty && + commencementDate.isEmpty && + cessationDate.isEmpty && + finalised.isEmpty && + finalisationTimestamp.isEmpty && + finalisationTimestamp.isEmpty && + submissionPeriods.isEmpty) + + def withoutCessationDate: BusinessIncomeSource = copy(cessationDate = None) + + def withoutCommencementDate: BusinessIncomeSource = copy(commencementDate = None) +} + +case object BusinessIncomeSource { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `uk-property-fhl`, + `foreign-property-fhl-eea`, + `foreign-property` + ) + + implicit val format: OFormat[BusinessIncomeSource] = Json.format[BusinessIncomeSource] + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/Claim.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/Claim.scala new file mode 100644 index 000000000..d580846ce --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/Claim.scala @@ -0,0 +1,47 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.IncomeSourceType._ + +case class Claim(claimId: Option[String], + originatingClaimId: Option[String], + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + submissionTimestamp: Option[String], + taxYearClaimMade: TaxYear, + claimType: ClaimType, + sequence: Option[Int]) + +object Claim extends { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `uk-property-fhl`, + `foreign-property-fhl-eea`, + `foreign-property` + ) + + implicit val format: OFormat[Claim] = Json.format[Claim] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/ConstructionIndustryScheme.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/ConstructionIndustryScheme.scala new file mode 100644 index 000000000..d0b83d15a --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/ConstructionIndustryScheme.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class ConstructionIndustryScheme(employerRef: String, contractorName: Option[String], periodData: Seq[PeriodData]) + +object ConstructionIndustryScheme { + implicit val format: OFormat[ConstructionIndustryScheme] = Json.format[ConstructionIndustryScheme] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/IncomeSources.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/IncomeSources.scala new file mode 100644 index 000000000..8442d869c --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/IncomeSources.scala @@ -0,0 +1,51 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class IncomeSources(businessIncomeSources: Option[Seq[BusinessIncomeSource]], + nonBusinessIncomeSources: Option[Seq[NonBusinessIncomeSource]]) { + + val isDefined: Boolean = + !(businessIncomeSources.isEmpty && nonBusinessIncomeSources.isEmpty) + + def withoutCessationDate: IncomeSources = + businessIncomeSources match { + case Some(det) => + val details = (for (d <- det) yield d.withoutCessationDate).filter(_.isDefined) + if (details.nonEmpty) { copy(businessIncomeSources = Some(details)) } + else { copy(businessIncomeSources = None) } + case None => copy(businessIncomeSources = None) + } + + def withoutCommencementDate: IncomeSources = businessIncomeSources match { + case Some(det) => + val details = (for (d <- det) yield d.withoutCommencementDate).filter(_.isDefined) + if (details.nonEmpty) { + copy(businessIncomeSources = Some(details)) + } else { + copy(businessIncomeSources = None) + } + case None => copy(businessIncomeSources = None) + } + +} + +object IncomeSources { + implicit val format: OFormat[IncomeSources] = Json.format[IncomeSources] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/Inputs.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/Inputs.scala new file mode 100644 index 000000000..42fab48cd --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/Inputs.scala @@ -0,0 +1,53 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.functional.syntax._ +import play.api.libs.json.{JsPath, Json, OWrites, Reads} + +case class Inputs(personalInformation: PersonalInformation, + incomeSources: IncomeSources, + annualAdjustments: Option[Seq[AnnualAdjustment]], + lossesBroughtForward: Option[Seq[LossBroughtForward]], + claims: Option[Seq[Claim]], + constructionIndustryScheme: Option[Seq[ConstructionIndustryScheme]], // This field name has been changed from downstream. + allowancesReliefsAndDeductions: Option[Seq[AllowancesReliefsAndDeductions]], + pensionContributionAndCharges: Option[Seq[PensionContributionAndCharges]], + other: Option[Seq[Other]]) { + def withoutCessationDate: Inputs = copy(incomeSources = incomeSources.withoutCessationDate) + + def withoutCommencementDate: Inputs = copy(incomeSources = incomeSources.withoutCommencementDate) + + def withoutItsaStatus: Inputs = copy(personalInformation = personalInformation.withoutItsaStatus) +} + +object Inputs { + implicit val writes: OWrites[Inputs] = Json.writes[Inputs] + + implicit val reads: Reads[Inputs] = ( + (JsPath \ "personalInformation").read[PersonalInformation] and + (JsPath \ "incomeSources").read[IncomeSources] and + (JsPath \ "annualAdjustments").readNullable[Seq[AnnualAdjustment]] and + (JsPath \ "lossesBroughtForward").readNullable[Seq[LossBroughtForward]] and + (JsPath \ "claims").readNullable[Seq[Claim]] and + (JsPath \ "cis").readNullable[Seq[ConstructionIndustryScheme]] and + (JsPath \ "allowancesReliefsAndDeductions").readNullable[Seq[AllowancesReliefsAndDeductions]] and + (JsPath \ "pensionContributionAndCharges").readNullable[Seq[PensionContributionAndCharges]] and + (JsPath \ "other").readNullable[Seq[Other]] + )(Inputs.apply _) + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/LossBroughtForward.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/LossBroughtForward.scala new file mode 100644 index 000000000..58840c8c1 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/LossBroughtForward.scala @@ -0,0 +1,47 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class LossBroughtForward(lossId: Option[String], + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + submissionTimestamp: Option[String], + lossType: Option[String], + taxYearLossIncurred: TaxYear, + currentLossValue: BigInt, + mtdLoss: Option[Boolean]) + +object LossBroughtForward { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `uk-property-fhl`, + `foreign-property-fhl-eea`, + `foreign-property` + ) + + implicit val format: OFormat[LossBroughtForward] = Json.format[LossBroughtForward] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/NonBusinessIncomeSource.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/NonBusinessIncomeSource.scala new file mode 100644 index 000000000..d729c9100 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/NonBusinessIncomeSource.scala @@ -0,0 +1,52 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class NonBusinessIncomeSource(incomeSourceId: Option[String], + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + startDate: String, + endDate: Option[String], + source: String, + periodId: Option[String], + latestReceivedDateTime: Option[String]) + +case object NonBusinessIncomeSource { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `employments`, + `foreign-dividends`, + `uk-savings-and-gains`, + `uk-dividends`, + `state-benefits`, + `share-schemes`, + `foreign-savings-and-gains`, + `other-dividends`, + `uk-securities`, + `other-income`, + `foreign-pension`, + `non-paye-income`, + `capital-gains-tax`, + `charitable-giving` + ) + + implicit val format: OFormat[NonBusinessIncomeSource] = Json.format[NonBusinessIncomeSource] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala new file mode 100644 index 000000000..db4c42c59 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class Other(`type`: String, submittedOn: Option[String]) + +object Other { + implicit val format: OFormat[Other] = Json.format[Other] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala new file mode 100644 index 000000000..a4ef2fe29 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionAndCharges(`type`: String, + submissionTimestamp: Option[String], + startDate: Option[String], + endDate: Option[String], + source: Option[String]) + +object PensionContributionAndCharges { + implicit val format: OFormat[PensionContributionAndCharges] = Json.format[PensionContributionAndCharges] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/PeriodData.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/PeriodData.scala new file mode 100644 index 000000000..a4fb124a0 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/PeriodData.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class PeriodData(deductionFromDate: String, deductionToDate: String, submissionTimestamp: String, source: String, deductionAmount: BigDecimal) + +object PeriodData { + implicit val format: OFormat[PeriodData] = Json.format[PeriodData] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala new file mode 100644 index 000000000..1cbceba41 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class PersonalInformation(identifier: String, + dateOfBirth: Option[String], + taxRegime: String, + statePensionAgeDate: Option[String], + studentLoanPlan: Option[Seq[StudentLoanPlan]], + class2VoluntaryContributions: Option[Boolean], + marriageAllowance: Option[String], + uniqueTaxpayerReference: Option[String], + itsaStatus: Option[String]) { + def withoutItsaStatus: PersonalInformation = copy(itsaStatus = None) +} + +object PersonalInformation { + implicit val format: OFormat[PersonalInformation] = Json.format[PersonalInformation] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/StudentLoanPlan.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/StudentLoanPlan.scala new file mode 100644 index 000000000..1b13aebb5 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/StudentLoanPlan.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{JsPath, Json, OWrites, Reads} +import v7.common.model.response.StudentLoanPlanType + +case class StudentLoanPlan(planType: StudentLoanPlanType) + +object StudentLoanPlan { + implicit val writes: OWrites[StudentLoanPlan] = Json.writes[StudentLoanPlan] + implicit val reads: Reads[StudentLoanPlan] = (JsPath \ "planType").read[StudentLoanPlanType].map(StudentLoanPlan(_)) +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/SubmissionPeriod.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/SubmissionPeriod.scala new file mode 100644 index 000000000..f68aaf920 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/SubmissionPeriod.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class SubmissionPeriod(periodId: Option[String], startDate: String, endDate: String, receivedDateTime: String) + +object SubmissionPeriod { + implicit val format: OFormat[SubmissionPeriod] = Json.format[SubmissionPeriod] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/messages/Messages.scala b/app/v7/retrieveCalculation/def1/model/response/messages/Messages.scala new file mode 100644 index 000000000..cad42b1cd --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/messages/Messages.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.messages + +import play.api.libs.json.{Json, OFormat} + +case class Message(id: String, text: String) + +case class Messages(info: Option[Seq[Message]], warnings: Option[Seq[Message]], errors: Option[Seq[Message]]) + +object Messages { + implicit val messageFormat: OFormat[Message] = Json.format[Message] + implicit val messagesFormat: OFormat[Messages] = Json.format[Messages] +} diff --git a/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala b/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala new file mode 100644 index 000000000..4bc038290 --- /dev/null +++ b/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala @@ -0,0 +1,59 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.metadata + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.functional.syntax._ +import play.api.libs.json._ +import v7.common.model.response.CalculationType + +case class Metadata(calculationId: String, + taxYear: TaxYear, + requestedBy: String, + requestedTimestamp: Option[String], + calculationReason: String, + calculationTimestamp: Option[String], + calculationType: CalculationType, + intentToSubmitFinalDeclaration: Boolean, + finalDeclaration: Boolean, + finalDeclarationTimestamp: Option[String], + periodFrom: String, + periodTo: String) + +object Metadata { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val writes: OWrites[Metadata] = Json.writes[Metadata] + + implicit val reads: Reads[Metadata] = ( + (JsPath \ "calculationId").read[String] and + (JsPath \ "taxYear").read[TaxYear] and + (JsPath \ "requestedBy").read[String] and + (JsPath \ "requestedTimestamp").readNullable[String] and + (JsPath \ "calculationReason").read[String] and + (JsPath \ "calculationTimestamp").readNullable[String] and + (JsPath \ "calculationType").read[CalculationType] and + (JsPath \ "intentToCrystallise").readWithDefault[Boolean](false) and + (JsPath \ "crystallised").readWithDefault[Boolean](false) and + (JsPath \ "crystallisationTimestamp").readNullable[String] and + (JsPath \ "periodFrom").read[String] and + (JsPath \ "periodTo").read[String] + )(Metadata.apply _) + +} diff --git a/app/v7/retrieveCalculation/def2/Def2_RetrieveCalculationValidator.scala b/app/v7/retrieveCalculation/def2/Def2_RetrieveCalculationValidator.scala new file mode 100644 index 000000000..989510b18 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/Def2_RetrieveCalculationValidator.scala @@ -0,0 +1,42 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2 + +import shared.controllers.validators.Validator +import shared.controllers.validators.resolvers.{ResolveCalculationId, ResolveNino, ResolveTaxYearMinimum} +import shared.models.domain.TaxYear +import shared.models.errors.MtdError +import cats.data.Validated +import cats.implicits._ +import v7.retrieveCalculation.models.request.{Def2_RetrieveCalculationRequestData, RetrieveCalculationRequestData} + +object Def2_RetrieveCalculationValidator { + private val retrieveCalculationsMinimumTaxYear = TaxYear.fromMtd("2017-18") + private val resolveTaxYear = ResolveTaxYearMinimum(retrieveCalculationsMinimumTaxYear) +} + +class Def2_RetrieveCalculationValidator(nino: String, taxYear: String, calculationId: String) extends Validator[RetrieveCalculationRequestData] { + import Def2_RetrieveCalculationValidator._ + + def validate: Validated[Seq[MtdError], RetrieveCalculationRequestData] = + ( + ResolveNino(nino), + resolveTaxYear(taxYear), + ResolveCalculationId(calculationId) + ).mapN(Def2_RetrieveCalculationRequestData) + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/Calculation.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/Calculation.scala new file mode 100644 index 000000000..b0181e230 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/Calculation.scala @@ -0,0 +1,205 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation + +import play.api.libs.json._ +import v7.retrieveCalculation.def2.model.response.calculation.allowancesAndDeductions.AllowancesAndDeductions +import v7.retrieveCalculation.def2.model.response.calculation.businessProfitAndLoss.BusinessProfitAndLoss +import v7.retrieveCalculation.def2.model.response.calculation.chargeableEventGainsIncome.ChargeableEventGainsIncome +import v7.retrieveCalculation.def2.model.response.calculation.codedOutUnderpayments.CodedOutUnderpayments +import v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome.DividendsIncome +import v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome.EmploymentAndPensionsIncome +import v7.retrieveCalculation.def2.model.response.calculation.employmentExpenses.EmploymentExpenses +import v7.retrieveCalculation.def2.model.response.calculation.endOfYearEstimate.EndOfYearEstimate +import v7.retrieveCalculation.def2.model.response.calculation.foreignIncome.ForeignIncome +import v7.retrieveCalculation.def2.model.response.calculation.foreignPropertyIncome.ForeignPropertyIncome +import v7.retrieveCalculation.def2.model.response.calculation.foreignTaxForFtcrNotClaimed.ForeignTaxForFtcrNotClaimed +import v7.retrieveCalculation.def2.model.response.calculation.giftAid.GiftAid +import v7.retrieveCalculation.def2.model.response.calculation.incomeSummaryTotals.IncomeSummaryTotals +import v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims.LossesAndClaims +import v7.retrieveCalculation.def2.model.response.calculation.marriageAllowanceTransferredIn.MarriageAllowanceTransferredIn +import v7.retrieveCalculation.def2.model.response.calculation.notionalTax.NotionalTax +import v7.retrieveCalculation.def2.model.response.calculation.otherIncome.OtherIncome +import v7.retrieveCalculation.def2.model.response.calculation.pensionContributionReliefs.PensionContributionReliefs +import v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges.PensionSavingsTaxCharges +import v7.retrieveCalculation.def2.model.response.calculation.previousCalculation.PreviousCalculation +import v7.retrieveCalculation.def2.model.response.calculation.reliefs.Reliefs +import v7.retrieveCalculation.def2.model.response.calculation.royaltyPayments.RoyaltyPayments +import v7.retrieveCalculation.def2.model.response.calculation.savingsAndGainsIncome.SavingsAndGainsIncome +import v7.retrieveCalculation.def2.model.response.calculation.seafarersDeductions.SeafarersDeductions +import v7.retrieveCalculation.def2.model.response.calculation.shareSchemesIncome.ShareSchemesIncome +import v7.retrieveCalculation.def2.model.response.calculation.stateBenefitsIncome.StateBenefitsIncome +import v7.retrieveCalculation.def2.model.response.calculation.studentLoans.StudentLoans +import v7.retrieveCalculation.def2.model.response.calculation.taxCalculation.TaxCalculation +import v7.retrieveCalculation.def2.model.response.calculation.taxDeductedAtSource.TaxDeductedAtSource +import v7.retrieveCalculation.def2.model.response.calculation.transitionProfit.TransitionProfit + +case class Calculation( + allowancesAndDeductions: Option[AllowancesAndDeductions], + reliefs: Option[Reliefs], + taxDeductedAtSource: Option[TaxDeductedAtSource], + giftAid: Option[GiftAid], + royaltyPayments: Option[RoyaltyPayments], + notionalTax: Option[NotionalTax], + marriageAllowanceTransferredIn: Option[MarriageAllowanceTransferredIn], + pensionContributionReliefs: Option[PensionContributionReliefs], + pensionSavingsTaxCharges: Option[PensionSavingsTaxCharges], + studentLoans: Option[Seq[StudentLoans]], + codedOutUnderpayments: Option[CodedOutUnderpayments], + foreignPropertyIncome: Option[Seq[ForeignPropertyIncome]], + businessProfitAndLoss: Option[Seq[BusinessProfitAndLoss]], + employmentAndPensionsIncome: Option[EmploymentAndPensionsIncome], + employmentExpenses: Option[EmploymentExpenses], + seafarersDeductions: Option[SeafarersDeductions], + foreignTaxForFtcrNotClaimed: Option[ForeignTaxForFtcrNotClaimed], + stateBenefitsIncome: Option[StateBenefitsIncome], + shareSchemesIncome: Option[ShareSchemesIncome], + foreignIncome: Option[ForeignIncome], + chargeableEventGainsIncome: Option[ChargeableEventGainsIncome], + savingsAndGainsIncome: Option[SavingsAndGainsIncome], + otherIncome: Option[OtherIncome], + dividendsIncome: Option[DividendsIncome], + incomeSummaryTotals: Option[IncomeSummaryTotals], + taxCalculation: Option[TaxCalculation], + previousCalculation: Option[PreviousCalculation], + endOfYearEstimate: Option[EndOfYearEstimate], + lossesAndClaims: Option[LossesAndClaims], + transitionProfit: Option[TransitionProfit] +) + +object Calculation { + + implicit val reads: Reads[Calculation] = for { + allowancesAndDeductions <- (JsPath \ "allowancesAndDeductions").readNullable[AllowancesAndDeductions] + reliefs <- (JsPath \ "reliefs").readNullable[Reliefs] + taxDeductedAtSource <- (JsPath \ "taxDeductedAtSource").readNullable[TaxDeductedAtSource] + giftAid <- (JsPath \ "giftAid").readNullable[GiftAid] + royaltyPayments <- (JsPath \ "royaltyPayments").readNullable[RoyaltyPayments] + notionalTax <- (JsPath \ "notionalTax").readNullable[NotionalTax] + marriageAllowanceTransferredIn <- (JsPath \ "marriageAllowanceTransferredIn").readNullable[MarriageAllowanceTransferredIn] + pensionContributionReliefs <- (JsPath \ "pensionContributionReliefs").readNullable[PensionContributionReliefs] + pensionSavingsTaxCharges <- (JsPath \ "pensionSavingsTaxCharges").readNullable[PensionSavingsTaxCharges] + studentLoans <- (JsPath \ "studentLoans").readNullable[Seq[StudentLoans]] + codedOutUnderpayments <- (JsPath \ "codedOutUnderpayments").readNullable[CodedOutUnderpayments] + foreignPropertyIncome <- (JsPath \ "foreignPropertyIncome").readNullable[Seq[ForeignPropertyIncome]] + businessProfitAndLoss <- (JsPath \ "businessProfitAndLoss").readNullable[Seq[BusinessProfitAndLoss]] + employmentAndPensionsIncome <- (JsPath \ "employmentAndPensionsIncome").readNullable[EmploymentAndPensionsIncome] + employmentExpenses <- (JsPath \ "employmentExpenses").readNullable[EmploymentExpenses] + seafarersDeductions <- (JsPath \ "seafarersDeductions").readNullable[SeafarersDeductions] + foreignTaxForFtcrNotClaimed <- (JsPath \ "foreignTaxForFtcrNotClaimed").readNullable[ForeignTaxForFtcrNotClaimed] + stateBenefitsIncome <- (JsPath \ "stateBenefitsIncome").readNullable[StateBenefitsIncome] + shareSchemesIncome <- (JsPath \ "shareSchemesIncome").readNullable[ShareSchemesIncome] + foreignIncome <- (JsPath \ "foreignIncome").readNullable[ForeignIncome] + chargeableEventGainsIncome <- (JsPath \ "chargeableEventGainsIncome").readNullable[ChargeableEventGainsIncome] + savingsAndGainsIncome <- (JsPath \ "savingsAndGainsIncome").readNullable[SavingsAndGainsIncome] + otherIncome <- (JsPath \ "otherIncome").readNullable[OtherIncome] + dividendsIncome <- (JsPath \ "dividendsIncome").readNullable[DividendsIncome] + incomeSummaryTotals <- (JsPath \ "incomeSummaryTotals").readNullable[IncomeSummaryTotals] + taxCalculation <- (JsPath \ "taxCalculation").readNullable[TaxCalculation] + previousCalculation <- (JsPath \ "previousCalculation").readNullable[PreviousCalculation] + endOfYearEstimate <- (JsPath \ "endOfYearEstimate").readNullable[EndOfYearEstimate] + lossesAndClaims <- (JsPath \ "lossesAndClaims").readNullable[LossesAndClaims] + transitionProfit <- (JsPath \ "transitionProfit").readNullable[TransitionProfit] + } yield { + Calculation( + allowancesAndDeductions = allowancesAndDeductions, + reliefs = reliefs, + taxDeductedAtSource = taxDeductedAtSource, + giftAid = giftAid, + royaltyPayments = royaltyPayments, + notionalTax = notionalTax, + marriageAllowanceTransferredIn = marriageAllowanceTransferredIn, + pensionContributionReliefs = pensionContributionReliefs, + pensionSavingsTaxCharges = pensionSavingsTaxCharges, + studentLoans = studentLoans, + codedOutUnderpayments = codedOutUnderpayments, + foreignPropertyIncome = foreignPropertyIncome, + businessProfitAndLoss = businessProfitAndLoss, + employmentAndPensionsIncome = employmentAndPensionsIncome, + employmentExpenses = employmentExpenses, + seafarersDeductions = seafarersDeductions, + foreignTaxForFtcrNotClaimed = foreignTaxForFtcrNotClaimed, + stateBenefitsIncome = stateBenefitsIncome, + shareSchemesIncome = shareSchemesIncome, + foreignIncome = foreignIncome, + chargeableEventGainsIncome = chargeableEventGainsIncome, + savingsAndGainsIncome = savingsAndGainsIncome, + otherIncome = otherIncome, + dividendsIncome = dividendsIncome, + incomeSummaryTotals = incomeSummaryTotals, + taxCalculation = taxCalculation, + previousCalculation = previousCalculation, + endOfYearEstimate = endOfYearEstimate, + lossesAndClaims = lossesAndClaims, + transitionProfit = transitionProfit + ) + } + + implicit val writes: OWrites[Calculation] = (o: Calculation) => { + JsObject( + Map( + "allowancesAndDeductions" -> Json.toJson(o.allowancesAndDeductions), + "reliefs" -> Json.toJson(o.reliefs), + "taxDeductedAtSource" -> Json.toJson(o.taxDeductedAtSource), + "giftAid" -> Json.toJson(o.giftAid), + "royaltyPayments" -> Json.toJson(o.royaltyPayments), + "notionalTax" -> Json.toJson(o.notionalTax), + "marriageAllowanceTransferredIn" -> Json.toJson(o.marriageAllowanceTransferredIn), + "pensionContributionReliefs" -> Json.toJson(o.pensionContributionReliefs), + "pensionSavingsTaxCharges" -> Json.toJson(o.pensionSavingsTaxCharges), + "studentLoans" -> Json.toJson(o.studentLoans), + "codedOutUnderpayments" -> Json.toJson(o.codedOutUnderpayments), + "foreignPropertyIncome" -> Json.toJson(o.foreignPropertyIncome), + "businessProfitAndLoss" -> Json.toJson(o.businessProfitAndLoss), + "employmentAndPensionsIncome" -> Json.toJson(o.employmentAndPensionsIncome), + "employmentExpenses" -> Json.toJson(o.employmentExpenses), + "seafarersDeductions" -> Json.toJson(o.seafarersDeductions), + "foreignTaxForFtcrNotClaimed" -> Json.toJson(o.foreignTaxForFtcrNotClaimed), + "stateBenefitsIncome" -> Json.toJson(o.stateBenefitsIncome), + "shareSchemesIncome" -> Json.toJson(o.shareSchemesIncome), + "foreignIncome" -> Json.toJson(o.foreignIncome), + "chargeableEventGainsIncome" -> Json.toJson(o.chargeableEventGainsIncome), + "savingsAndGainsIncome" -> Json.toJson(o.savingsAndGainsIncome), + "otherIncome" -> Json.toJson(o.otherIncome), + "dividendsIncome" -> Json.toJson(o.dividendsIncome), + "incomeSummaryTotals" -> Json.toJson(o.incomeSummaryTotals), + "taxCalculation" -> Json.toJson(o.taxCalculation), + "previousCalculation" -> Json.toJson(o.previousCalculation), + "endOfYearEstimate" -> Json.toJson(o.endOfYearEstimate), + "lossesAndClaims" -> Json.toJson(o.lossesAndClaims), + "transitionProfit" -> Json.toJson(o.transitionProfit) + ).filterNot { case (_, value) => + value == JsNull + } + ) + } + + // format: off + val empty: Calculation = Calculation( + None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, None, None, None, None, None, None, None + ) + // format: on + + def withoutTransitionProfit(maybeCalculation: Option[Calculation]): Option[Calculation] = { + maybeCalculation.flatMap { calc => + val updated = calc.copy(transitionProfit = None) + if (updated == empty) None else Some(updated) + } + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductions.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductions.scala new file mode 100644 index 000000000..9de378052 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductions.scala @@ -0,0 +1,58 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.allowancesAndDeductions + +import play.api.libs.functional.syntax._ +import play.api.libs.json.{JsPath, Json, Reads, Writes} + +case class AllowancesAndDeductions(personalAllowance: Option[BigInt], + marriageAllowanceTransferOut: Option[MarriageAllowanceTransferOut], + reducedPersonalAllowance: Option[BigInt], + giftOfInvestmentsAndPropertyToCharity: Option[BigInt], + blindPersonsAllowance: Option[BigInt], + lossesAppliedToGeneralIncome: Option[BigInt], + cgtLossSetAgainstInYearGeneralIncome: Option[BigInt], + qualifyingLoanInterestFromInvestments: Option[BigDecimal], + postCessationTradeReceipts: Option[BigDecimal], + paymentsToTradeUnionsForDeathBenefits: Option[BigDecimal], + grossAnnuityPayments: Option[BigDecimal], + annuityPayments: Option[AnnuityPayments], + pensionContributions: Option[BigDecimal], + pensionContributionsDetail: Option[PensionContributionsDetail]) + +object AllowancesAndDeductions { + + implicit val reads: Reads[AllowancesAndDeductions] = ( + (JsPath \ "personalAllowance").readNullable[BigInt] and + (JsPath \ "marriageAllowanceTransferOut").readNullable[MarriageAllowanceTransferOut] and + (JsPath \ "reducedPersonalAllowance").readNullable[BigInt] and + (JsPath \ "giftOfInvestmentsAndPropertyToCharity").readNullable[BigInt] and + (JsPath \ "blindPersonsAllowance").readNullable[BigInt] and + (JsPath \ "lossesAppliedToGeneralIncome").readNullable[BigInt] and + (JsPath \ "cgtLossSetAgainstInYearGeneralIncome").readNullable[BigInt] and + (JsPath \ "qualifyingLoanInterestFromInvestments").readNullable[BigDecimal] and + (JsPath \ "post-cessationTradeReceipts").readNullable[BigDecimal] and + (JsPath \ "paymentsToTradeUnionsForDeathBenefits").readNullable[BigDecimal] and + (JsPath \ "grossAnnuityPayments").readNullable[BigDecimal] and + (JsPath \ "annuityPayments").readNullable[AnnuityPayments] and + (JsPath \ "pensionContributions").readNullable[BigDecimal] and + (JsPath \ "pensionContributionsDetail").readNullable[PensionContributionsDetail] + )(AllowancesAndDeductions.apply _) + + implicit val writes: Writes[AllowancesAndDeductions] = Json.writes[AllowancesAndDeductions] + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AnnuityPayments.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AnnuityPayments.scala new file mode 100644 index 000000000..9b7fa2f82 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AnnuityPayments.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.allowancesAndDeductions + +import play.api.libs.json.{Json, OFormat} + +case class AnnuityPayments(reliefClaimed: Option[BigDecimal], rate: Option[BigDecimal]) + +object AnnuityPayments { + implicit val format: OFormat[AnnuityPayments] = Json.format[AnnuityPayments] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/MarriageAllowanceTransferOut.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/MarriageAllowanceTransferOut.scala new file mode 100644 index 000000000..f045806fd --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/MarriageAllowanceTransferOut.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.allowancesAndDeductions + +import play.api.libs.json.{Json, OFormat} + +case class MarriageAllowanceTransferOut(personalAllowanceBeforeTransferOut: BigDecimal, transferredOutAmount: BigDecimal) + +object MarriageAllowanceTransferOut { + implicit val format: OFormat[MarriageAllowanceTransferOut] = Json.format[MarriageAllowanceTransferOut] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/PensionContributionsDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/PensionContributionsDetail.scala new file mode 100644 index 000000000..aeb84d2a8 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/PensionContributionsDetail.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.allowancesAndDeductions + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionsDetail(retirementAnnuityPayments: Option[BigDecimal], + paymentToEmployersSchemeNoTaxRelief: Option[BigDecimal], + overseasPensionSchemeContributions: Option[BigDecimal]) + +object PensionContributionsDetail { + implicit val format: OFormat[PensionContributionsDetail] = Json.format[PensionContributionsDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLoss.scala new file mode 100644 index 000000000..bcad996bf --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLoss.scala @@ -0,0 +1,146 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.businessProfitAndLoss + +import play.api.libs.json._ +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class BusinessProfitAndLoss(incomeSourceId: String, + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + totalIncome: Option[BigDecimal], + totalExpenses: Option[BigDecimal], + netProfit: Option[BigDecimal], + netLoss: Option[BigDecimal], + totalAdditions: Option[BigDecimal], + totalDeductions: Option[BigDecimal], + accountingAdjustments: Option[BigDecimal], + taxableProfit: Option[BigInt], + adjustedIncomeTaxLoss: Option[BigInt], + totalBroughtForwardIncomeTaxLosses: Option[BigInt], + lossForCSFHL: Option[BigInt], + broughtForwardIncomeTaxLossesUsed: Option[BigInt], + taxableProfitAfterIncomeTaxLossesDeduction: Option[BigInt], + carrySidewaysIncomeTaxLossesUsed: Option[BigInt], + broughtForwardCarrySidewaysIncomeTaxLossesUsed: Option[BigInt], + totalIncomeTaxLossesCarriedForward: Option[BigInt], + class4Loss: Option[BigInt], + totalBroughtForwardClass4Losses: Option[BigInt], + broughtForwardClass4LossesUsed: Option[BigInt], + carrySidewaysClass4LossesUsed: Option[BigInt], + totalClass4LossesCarriedForward: Option[BigInt]) + +object BusinessProfitAndLoss { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `foreign-property-fhl-eea`, + `uk-property-fhl`, + `foreign-property` + ) + + implicit val reads: Reads[BusinessProfitAndLoss] = for { + incomeSourceId <- (JsPath \ "incomeSourceId").read[String] + incomeSourceType <- (JsPath \ "incomeSourceType").read[IncomeSourceType] + incomeSourceName <- (JsPath \ "incomeSourceName").readNullable[String] + totalIncome <- (JsPath \ "totalIncome").readNullable[BigDecimal] + totalExpenses <- (JsPath \ "totalExpenses").readNullable[BigDecimal] + netProfit <- (JsPath \ "netProfit").readNullable[BigDecimal] + netLoss <- (JsPath \ "netLoss").readNullable[BigDecimal] + totalAdditions <- (JsPath \ "totalAdditions").readNullable[BigDecimal] + totalDeductions <- (JsPath \ "totalDeductions").readNullable[BigDecimal] + accountingAdjustments <- (JsPath \ "accountingAdjustments").readNullable[BigDecimal] + taxableProfit <- (JsPath \ "taxableProfit").readNullable[BigInt] + adjustedIncomeTaxLoss <- (JsPath \ "adjustedIncomeTaxLoss").readNullable[BigInt] + totalBroughtForwardIncomeTaxLosses <- (JsPath \ "totalBroughtForwardIncomeTaxLosses").readNullable[BigInt] + lossForCSFHL <- (JsPath \ "lossForCSFHL").readNullable[BigInt] + broughtForwardIncomeTaxLossesUsed <- (JsPath \ "broughtForwardIncomeTaxLossesUsed").readNullable[BigInt] + taxableProfitAfterIncomeTaxLossesDeduction <- (JsPath \ "taxableProfitAfterIncomeTaxLossesDeduction").readNullable[BigInt] + carrySidewaysIncomeTaxLossesUsed <- (JsPath \ "carrySidewaysIncomeTaxLossesUsed").readNullable[BigInt] + broughtForwardCarrySidewaysIncomeTaxLossesUsed <- (JsPath \ "broughtForwardCarrySidewaysIncomeTaxLossesUsed").readNullable[BigInt] + totalIncomeTaxLossesCarriedForward <- (JsPath \ "totalIncomeTaxLossesCarriedForward").readNullable[BigInt] + class4Loss <- (JsPath \ "class4Loss").readNullable[BigInt] + totalBroughtForwardClass4Losses <- (JsPath \ "totalBroughtForwardClass4Losses").readNullable[BigInt] + broughtForwardClass4LossesUsed <- (JsPath \ "broughtForwardClass4LossesUsed").readNullable[BigInt] + carrySidewaysClass4LossesUsed <- (JsPath \ "carrySidewaysClass4LossesUsed").readNullable[BigInt] + totalClass4LossesCarriedForward <- (JsPath \ "totalClass4LossesCarriedForward").readNullable[BigInt] + + } yield { + BusinessProfitAndLoss( + incomeSourceId = incomeSourceId, + incomeSourceType = incomeSourceType, + incomeSourceName = incomeSourceName, + totalIncome = totalIncome, + totalExpenses = totalExpenses, + netProfit = netProfit, + netLoss = netLoss, + totalAdditions = totalAdditions, + totalDeductions = totalDeductions, + accountingAdjustments = accountingAdjustments, + taxableProfit = taxableProfit, + adjustedIncomeTaxLoss = adjustedIncomeTaxLoss, + totalBroughtForwardIncomeTaxLosses = totalBroughtForwardIncomeTaxLosses, + lossForCSFHL = lossForCSFHL, + broughtForwardIncomeTaxLossesUsed = broughtForwardIncomeTaxLossesUsed, + taxableProfitAfterIncomeTaxLossesDeduction = taxableProfitAfterIncomeTaxLossesDeduction, + carrySidewaysIncomeTaxLossesUsed = carrySidewaysIncomeTaxLossesUsed, + broughtForwardCarrySidewaysIncomeTaxLossesUsed = broughtForwardCarrySidewaysIncomeTaxLossesUsed, + totalIncomeTaxLossesCarriedForward = totalIncomeTaxLossesCarriedForward, + class4Loss = class4Loss, + totalBroughtForwardClass4Losses = totalBroughtForwardClass4Losses, + broughtForwardClass4LossesUsed = broughtForwardClass4LossesUsed, + carrySidewaysClass4LossesUsed = carrySidewaysClass4LossesUsed, + totalClass4LossesCarriedForward = totalClass4LossesCarriedForward + ) + } + + implicit val writes: OWrites[BusinessProfitAndLoss] = (o: BusinessProfitAndLoss) => { + JsObject( + Map( + "incomeSourceId" -> Json.toJson(o.incomeSourceId), + "incomeSourceType" -> Json.toJson(o.incomeSourceType), + "incomeSourceName" -> Json.toJson(o.incomeSourceName), + "totalIncome" -> Json.toJson(o.totalIncome), + "totalExpenses" -> Json.toJson(o.totalExpenses), + "netProfit" -> Json.toJson(o.netProfit), + "netLoss" -> Json.toJson(o.netLoss), + "totalAdditions" -> Json.toJson(o.totalAdditions), + "totalDeductions" -> Json.toJson(o.totalDeductions), + "accountingAdjustments" -> Json.toJson(o.accountingAdjustments), + "taxableProfit" -> Json.toJson(o.taxableProfit), + "adjustedIncomeTaxLoss" -> Json.toJson(o.adjustedIncomeTaxLoss), + "totalBroughtForwardIncomeTaxLosses" -> Json.toJson(o.totalBroughtForwardIncomeTaxLosses), + "lossForCSFHL" -> Json.toJson(o.lossForCSFHL), + "broughtForwardIncomeTaxLossesUsed" -> Json.toJson(o.broughtForwardIncomeTaxLossesUsed), + "taxableProfitAfterIncomeTaxLossesDeduction" -> Json.toJson(o.taxableProfitAfterIncomeTaxLossesDeduction), + "carrySidewaysIncomeTaxLossesUsed" -> Json.toJson(o.carrySidewaysIncomeTaxLossesUsed), + "broughtForwardCarrySidewaysIncomeTaxLossesUsed" -> Json.toJson(o.broughtForwardCarrySidewaysIncomeTaxLossesUsed), + "totalIncomeTaxLossesCarriedForward" -> Json.toJson(o.totalIncomeTaxLossesCarriedForward), + "class4Loss" -> Json.toJson(o.class4Loss), + "totalBroughtForwardClass4Losses" -> Json.toJson(o.totalBroughtForwardClass4Losses), + "broughtForwardClass4LossesUsed" -> Json.toJson(o.broughtForwardClass4LossesUsed), + "carrySidewaysClass4LossesUsed" -> Json.toJson(o.carrySidewaysClass4LossesUsed), + "totalClass4LossesCarriedForward" -> Json.toJson(o.totalClass4LossesCarriedForward) + ).filterNot { case (_, value) => + value == JsNull + } + ) + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ChargeableEventGainsIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ChargeableEventGainsIncome.scala new file mode 100644 index 000000000..610b80370 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ChargeableEventGainsIncome.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class ChargeableEventGainsIncome(totalOfAllGains: BigInt, + totalGainsWithTaxPaid: Option[BigInt], + gainsWithTaxPaidDetail: Option[Seq[GainsWithTaxPaidDetail]], + totalGainsWithNoTaxPaidAndVoidedIsa: Option[BigInt], + gainsWithNoTaxPaidAndVoidedIsaDetail: Option[Seq[GainsWithNoTaxPaidAndVoidedIsaDetail]], + totalForeignGainsOnLifePoliciesTaxPaid: Option[BigInt], + foreignGainsOnLifePoliciesTaxPaidDetail: Option[Seq[ForeignGainsOnLifePoliciesTaxPaidDetail]], + totalForeignGainsOnLifePoliciesNoTaxPaid: Option[BigInt], + foreignGainsOnLifePoliciesNoTaxPaidDetail: Option[Seq[ForeignGainsOnLifePoliciesNoTaxPaidDetail]]) + +object ChargeableEventGainsIncome { + implicit val format: Format[ChargeableEventGainsIncome] = Json.format[ChargeableEventGainsIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesNoTaxPaidDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesNoTaxPaidDetail.scala new file mode 100644 index 000000000..49ba74fb9 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesNoTaxPaidDetail.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class ForeignGainsOnLifePoliciesNoTaxPaidDetail(customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt]) + +object ForeignGainsOnLifePoliciesNoTaxPaidDetail { + implicit val format: Format[ForeignGainsOnLifePoliciesNoTaxPaidDetail] = Json.format[ForeignGainsOnLifePoliciesNoTaxPaidDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesTaxPaidDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesTaxPaidDetail.scala new file mode 100644 index 000000000..7bc49d60a --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/ForeignGainsOnLifePoliciesTaxPaidDetail.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class ForeignGainsOnLifePoliciesTaxPaidDetail(customerReference: Option[String], + gainAmount: Option[BigDecimal], + taxPaidAmount: Option[BigDecimal], + yearsHeld: Option[BigInt]) + +object ForeignGainsOnLifePoliciesTaxPaidDetail { + implicit val format: Format[ForeignGainsOnLifePoliciesTaxPaidDetail] = Json.format[ForeignGainsOnLifePoliciesTaxPaidDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala new file mode 100644 index 000000000..d835bee23 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class GainsWithNoTaxPaidAndVoidedIsaDetail(`type`: String, + customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt], + yearsHeldSinceLastGain: Option[BigInt], + voidedIsaTaxPaid: Option[BigDecimal]) + +object GainsWithNoTaxPaidAndVoidedIsaDetail { + implicit val format: Format[GainsWithNoTaxPaidAndVoidedIsaDetail] = Json.format[GainsWithNoTaxPaidAndVoidedIsaDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala new file mode 100644 index 000000000..c273817d8 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.chargeableEventGainsIncome + +import play.api.libs.json.{Format, Json} + +case class GainsWithTaxPaidDetail(`type`: String, + customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt], + yearsHeldSinceLastGain: Option[BigInt]) + +object GainsWithTaxPaidDetail { + implicit val format: Format[GainsWithTaxPaidDetail] = Json.format[GainsWithTaxPaidDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/CodedOutUnderpayments.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/CodedOutUnderpayments.scala new file mode 100644 index 000000000..d6d38e33e --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/CodedOutUnderpayments.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.codedOutUnderpayments + +import play.api.libs.json.{Json, OFormat} + +case class CodedOutUnderpayments(totalPayeUnderpayments: Option[BigDecimal], + payeUnderpaymentsDetail: Option[Seq[PayeUnderpaymentsDetail]], + totalSelfAssessmentUnderpayments: Option[BigDecimal], + totalCollectedSelfAssessmentUnderpayments: Option[BigDecimal], + totalUncollectedSelfAssessmentUnderpayments: Option[BigDecimal], + selfAssessmentUnderpaymentsDetail: Option[Seq[SelfAssessmentUnderpaymentsDetail]]) + +object CodedOutUnderpayments { + implicit val format: OFormat[CodedOutUnderpayments] = Json.format[CodedOutUnderpayments] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/PayeUnderpaymentsDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/PayeUnderpaymentsDetail.scala new file mode 100644 index 000000000..0db390c5b --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/PayeUnderpaymentsDetail.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.codedOutUnderpayments + +import play.api.libs.json.{Json, OFormat} + +case class PayeUnderpaymentsDetail(amount: BigDecimal, relatedTaxYear: String, source: Option[String]) + +object PayeUnderpaymentsDetail { + implicit val format: OFormat[PayeUnderpaymentsDetail] = Json.format[PayeUnderpaymentsDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/SelfAssessmentUnderpaymentsDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/SelfAssessmentUnderpaymentsDetail.scala new file mode 100644 index 000000000..39e66f125 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/codedOutUnderpayments/SelfAssessmentUnderpaymentsDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.codedOutUnderpayments + +import play.api.libs.json.{Json, OFormat} + +case class SelfAssessmentUnderpaymentsDetail(amount: BigDecimal, + relatedTaxYear: String, + source: Option[String], + collectedAmount: Option[BigDecimal], + uncollectedAmount: Option[BigDecimal]) + +object SelfAssessmentUnderpaymentsDetail { + implicit val format: OFormat[SelfAssessmentUnderpaymentsDetail] = Json.format[SelfAssessmentUnderpaymentsDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/CommonForeignDividend.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/CommonForeignDividend.scala new file mode 100644 index 000000000..dd2c6754c --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/CommonForeignDividend.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType.`foreign-dividends` + +case class CommonForeignDividend(incomeSourceType: Option[IncomeSourceType], + countryCode: String, + grossIncome: Option[BigDecimal], + netIncome: Option[BigDecimal], + taxDeducted: Option[BigDecimal], + foreignTaxCreditRelief: Option[Boolean]) + +object CommonForeignDividend { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`foreign-dividends`) + implicit val format: Format[CommonForeignDividend] = Json.format[CommonForeignDividend] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncome.scala new file mode 100644 index 000000000..9faa0b769 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncome.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import play.api.libs.json.{Format, Json} + +case class DividendsIncome(totalChargeableDividends: Option[BigInt], + totalUkDividends: Option[BigInt], + ukDividends: Option[UkDividends], + otherDividends: Option[Seq[OtherDividends]], + chargeableForeignDividends: Option[BigInt], + foreignDividends: Option[Seq[CommonForeignDividend]], + dividendIncomeReceivedWhilstAbroad: Option[Seq[CommonForeignDividend]]) + +object DividendsIncome { + implicit val format: Format[DividendsIncome] = Json.format[DividendsIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala new file mode 100644 index 000000000..bdf33da22 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import play.api.libs.json.{Format, Json} + +case class OtherDividends(typeOfDividend: Option[String], customerReference: Option[String], grossAmount: Option[BigDecimal]) + +object OtherDividends { + implicit val format: Format[OtherDividends] = Json.format[OtherDividends] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/UkDividends.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/UkDividends.scala new file mode 100644 index 000000000..b9c00a63e --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/UkDividends.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType.`uk-dividends` + +case class UkDividends(incomeSourceId: Option[String], + incomeSourceType: Option[IncomeSourceType], + dividends: Option[BigInt], + otherUkDividends: Option[BigInt]) + +object UkDividends { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`uk-dividends`) + implicit val format: Format[UkDividends] = Json.format[UkDividends] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitFromEmployerFinancedRetirementScheme.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitFromEmployerFinancedRetirementScheme.scala new file mode 100644 index 000000000..72dce444e --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitFromEmployerFinancedRetirementScheme.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class BenefitFromEmployerFinancedRetirementScheme(amount: Option[BigDecimal], + exemptAmount: Option[BigDecimal], + taxPaid: Option[BigDecimal], + taxTakenOffInEmployment: Option[Boolean]) + +object BenefitFromEmployerFinancedRetirementScheme { + + implicit val format: Format[BenefitFromEmployerFinancedRetirementScheme] = Json.format[BenefitFromEmployerFinancedRetirementScheme] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKind.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKind.scala new file mode 100644 index 000000000..575d6bc79 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKind.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class BenefitsInKind(totalBenefitsInKindReceived: Option[BigDecimal], benefitsInKindDetail: Option[BenefitsInKindDetail]) + +object BenefitsInKind { + + implicit val format: Format[BenefitsInKind] = Json.format[BenefitsInKind] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetail.scala new file mode 100644 index 000000000..e9133fb7c --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetail.scala @@ -0,0 +1,152 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json._ + +case class BenefitsInKindDetail(apportionedAccommodation: Option[BigDecimal], + apportionedAssets: Option[BigDecimal], + apportionedAssetTransfer: Option[BigDecimal], + apportionedBeneficialLoan: Option[BigDecimal], + apportionedCar: Option[BigDecimal], + apportionedCarFuel: Option[BigDecimal], + apportionedEducationalServices: Option[BigDecimal], + apportionedEntertaining: Option[BigDecimal], + apportionedExpenses: Option[BigDecimal], + apportionedMedicalInsurance: Option[BigDecimal], + apportionedTelephone: Option[BigDecimal], + apportionedService: Option[BigDecimal], + apportionedTaxableExpenses: Option[BigDecimal], + apportionedVan: Option[BigDecimal], + apportionedVanFuel: Option[BigDecimal], + apportionedMileage: Option[BigDecimal], + apportionedNonQualifyingRelocationExpenses: Option[BigDecimal], + apportionedNurseryPlaces: Option[BigDecimal], + apportionedOtherItems: Option[BigDecimal], + apportionedPaymentsOnEmployeesBehalf: Option[BigDecimal], + apportionedPersonalIncidentalExpenses: Option[BigDecimal], + apportionedQualifyingRelocationExpenses: Option[BigDecimal], + apportionedEmployerProvidedProfessionalSubscriptions: Option[BigDecimal], + apportionedEmployerProvidedServices: Option[BigDecimal], + apportionedIncomeTaxPaidByDirector: Option[BigDecimal], + apportionedTravelAndSubsistence: Option[BigDecimal], + apportionedVouchersAndCreditCards: Option[BigDecimal], + apportionedNonCash: Option[BigDecimal]) + +object BenefitsInKindDetail { + + implicit val reads: Reads[BenefitsInKindDetail] = for { + apportionedAccommodation <- (JsPath \ "apportionedAccommodation").readNullable[BigDecimal] + apportionedAssets <- (JsPath \ "apportionedAssets").readNullable[BigDecimal] + apportionedAssetTransfer <- (JsPath \ "apportionedAssetTransfer").readNullable[BigDecimal] + apportionedBeneficialLoan <- (JsPath \ "apportionedBeneficialLoan").readNullable[BigDecimal] + apportionedCar <- (JsPath \ "apportionedCar").readNullable[BigDecimal] + apportionedCarFuel <- (JsPath \ "apportionedCarFuel").readNullable[BigDecimal] + apportionedEducationalServices <- (JsPath \ "apportionedEducationalServices").readNullable[BigDecimal] + apportionedEntertaining <- (JsPath \ "apportionedEntertaining").readNullable[BigDecimal] + apportionedExpenses <- (JsPath \ "apportionedExpenses").readNullable[BigDecimal] + apportionedMedicalInsurance <- (JsPath \ "apportionedMedicalInsurance").readNullable[BigDecimal] + apportionedTelephone <- (JsPath \ "apportionedTelephone").readNullable[BigDecimal] + apportionedTaxableExpenses <- (JsPath \ "apportionedTaxableExpenses").readNullable[BigDecimal] + apportionedService <- (JsPath \ "apportionedService").readNullable[BigDecimal] + apportionedVan <- (JsPath \ "apportionedVan").readNullable[BigDecimal] + apportionedVanFuel <- (JsPath \ "apportionedVanFuel").readNullable[BigDecimal] + apportionedMileage <- (JsPath \ "apportionedMileage").readNullable[BigDecimal] + apportionedNonQualifyingRelocationExpenses <- (JsPath \ "apportionedNonQualifyingRelocationExpenses").readNullable[BigDecimal] + apportionedNurseryPlaces <- (JsPath \ "apportionedNurseryPlaces").readNullable[BigDecimal] + apportionedOtherItems <- (JsPath \ "apportionedOtherItems").readNullable[BigDecimal] + apportionedPaymentsOnEmployeesBehalf <- (JsPath \ "apportionedPaymentsOnEmployeesBehalf").readNullable[BigDecimal] + apportionedPersonalIncidentalExpenses <- (JsPath \ "apportionedPersonalIncidentalExpenses").readNullable[BigDecimal] + apportionedQualifyingRelocationExpenses <- (JsPath \ "apportionedQualifyingRelocationExpenses").readNullable[BigDecimal] + apportionedEmployerProvidedProfessionalSubscriptions <- (JsPath \ "apportionedEmployerProvidedProfessionalSubscriptions").readNullable[BigDecimal] + apportionedEmployerProvidedServices <- (JsPath \ "apportionedEmployerProvidedServices").readNullable[BigDecimal] + apportionedIncomeTaxPaidByDirector <- (JsPath \ "apportionedIncomeTaxPaidByDirector").readNullable[BigDecimal] + apportionedTravelAndSubsistence <- (JsPath \ "apportionedTravelAndSubsistence").readNullable[BigDecimal] + apportionedVouchersAndCreditCards <- (JsPath \ "apportionedVouchersAndCreditCards").readNullable[BigDecimal] + apportionedNonCash <- (JsPath \ "apportionedNonCash").readNullable[BigDecimal] + + } yield { + BenefitsInKindDetail( + apportionedAccommodation = apportionedAccommodation, + apportionedAssets = apportionedAssets, + apportionedAssetTransfer = apportionedAssetTransfer, + apportionedBeneficialLoan = apportionedBeneficialLoan, + apportionedCar = apportionedCar, + apportionedCarFuel = apportionedCarFuel, + apportionedEducationalServices = apportionedEducationalServices, + apportionedEntertaining = apportionedEntertaining, + apportionedExpenses = apportionedExpenses, + apportionedMedicalInsurance = apportionedMedicalInsurance, + apportionedTelephone = apportionedTelephone, + apportionedService = apportionedService, + apportionedTaxableExpenses = apportionedTaxableExpenses, + apportionedVan = apportionedVan, + apportionedVanFuel = apportionedVanFuel, + apportionedMileage = apportionedMileage, + apportionedNonQualifyingRelocationExpenses = apportionedNonQualifyingRelocationExpenses, + apportionedNurseryPlaces = apportionedNurseryPlaces, + apportionedOtherItems = apportionedOtherItems, + apportionedPaymentsOnEmployeesBehalf = apportionedPaymentsOnEmployeesBehalf, + apportionedPersonalIncidentalExpenses = apportionedPersonalIncidentalExpenses, + apportionedQualifyingRelocationExpenses = apportionedQualifyingRelocationExpenses, + apportionedEmployerProvidedProfessionalSubscriptions = apportionedEmployerProvidedProfessionalSubscriptions, + apportionedEmployerProvidedServices = apportionedEmployerProvidedServices, + apportionedIncomeTaxPaidByDirector = apportionedIncomeTaxPaidByDirector, + apportionedTravelAndSubsistence = apportionedTravelAndSubsistence, + apportionedVouchersAndCreditCards = apportionedVouchersAndCreditCards, + apportionedNonCash = apportionedNonCash + ) + } + + implicit val writes: OWrites[BenefitsInKindDetail] = (o: BenefitsInKindDetail) => { + JsObject( + Map( + "apportionedAccommodation" -> Json.toJson(o.apportionedAccommodation), + "apportionedAssets" -> Json.toJson(o.apportionedAssets), + "apportionedAssetTransfer" -> Json.toJson(o.apportionedAssetTransfer), + "apportionedBeneficialLoan" -> Json.toJson(o.apportionedBeneficialLoan), + "apportionedCar" -> Json.toJson(o.apportionedCar), + "apportionedCarFuel" -> Json.toJson(o.apportionedCarFuel), + "apportionedEducationalServices" -> Json.toJson(o.apportionedEducationalServices), + "apportionedEntertaining" -> Json.toJson(o.apportionedEntertaining), + "apportionedExpenses" -> Json.toJson(o.apportionedExpenses), + "apportionedMedicalInsurance" -> Json.toJson(o.apportionedMedicalInsurance), + "apportionedTelephone" -> Json.toJson(o.apportionedTelephone), + "apportionedService" -> Json.toJson(o.apportionedService), + "apportionedTaxableExpenses" -> Json.toJson(o.apportionedTaxableExpenses), + "apportionedVan" -> Json.toJson(o.apportionedVan), + "apportionedVanFuel" -> Json.toJson(o.apportionedVanFuel), + "apportionedMileage" -> Json.toJson(o.apportionedMileage), + "apportionedNonQualifyingRelocationExpenses" -> Json.toJson(o.apportionedNonQualifyingRelocationExpenses), + "apportionedNurseryPlaces" -> Json.toJson(o.apportionedNurseryPlaces), + "apportionedOtherItems" -> Json.toJson(o.apportionedOtherItems), + "apportionedPaymentsOnEmployeesBehalf" -> Json.toJson(o.apportionedPaymentsOnEmployeesBehalf), + "apportionedPersonalIncidentalExpenses" -> Json.toJson(o.apportionedPersonalIncidentalExpenses), + "apportionedQualifyingRelocationExpenses" -> Json.toJson(o.apportionedQualifyingRelocationExpenses), + "apportionedEmployerProvidedProfessionalSubscriptions" -> Json.toJson(o.apportionedEmployerProvidedProfessionalSubscriptions), + "apportionedEmployerProvidedServices" -> Json.toJson(o.apportionedEmployerProvidedServices), + "apportionedIncomeTaxPaidByDirector" -> Json.toJson(o.apportionedIncomeTaxPaidByDirector), + "apportionedTravelAndSubsistence" -> Json.toJson(o.apportionedTravelAndSubsistence), + "apportionedVouchersAndCreditCards" -> Json.toJson(o.apportionedVouchersAndCreditCards), + "apportionedNonCash" -> Json.toJson(o.apportionedNonCash) + ).filterNot { case (_, value) => + value == JsNull + } + ) + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncome.scala new file mode 100644 index 000000000..109a14cd2 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncome.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class EmploymentAndPensionsIncome(totalPayeEmploymentAndLumpSumIncome: Option[BigDecimal], + totalOccupationalPensionIncome: Option[BigDecimal], + totalBenefitsInKind: Option[BigDecimal], + tipsIncome: Option[BigDecimal], + employmentAndPensionsIncomeDetail: Option[Seq[EmploymentAndPensionsIncomeDetail]]) + +object EmploymentAndPensionsIncome { + + implicit val format: Format[EmploymentAndPensionsIncome] = Json.format[EmploymentAndPensionsIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala new file mode 100644 index 000000000..d2bef4039 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala @@ -0,0 +1,41 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.Source + +case class EmploymentAndPensionsIncomeDetail(incomeSourceId: Option[String], + source: Option[Source], + occupationalPension: Option[Boolean], + employerRef: Option[String], + employerName: Option[String], + offPayrollWorker: Option[Boolean], + payrollId: Option[String], + startDate: Option[String], + dateEmploymentEnded: Option[String], + taxablePayToDate: Option[BigDecimal], + totalTaxToDate: Option[BigDecimal], + disguisedRemuneration: Option[Boolean], + lumpSums: Option[LumpSums], + studentLoans: Option[StudentLoans], + benefitsInKind: Option[BenefitsInKind]) + +object EmploymentAndPensionsIncomeDetail { + + implicit val format: Format[EmploymentAndPensionsIncomeDetail] = Json.format[EmploymentAndPensionsIncomeDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/LumpSums.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/LumpSums.scala new file mode 100644 index 000000000..af3be0897 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/LumpSums.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class LumpSums(totalLumpSum: BigDecimal, totalTaxPaid: Option[BigDecimal], lumpSumsDetail: LumpSumsDetail) + +object LumpSums { + + implicit val format: Format[LumpSums] = Json.format[LumpSums] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/LumpSumsDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/LumpSumsDetail.scala new file mode 100644 index 000000000..94a9ba09a --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/LumpSumsDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class LumpSumsDetail(taxableLumpSumsAndCertainIncome: Option[TaxableLumpSumsAndCertainIncome], + benefitFromEmployerFinancedRetirementScheme: Option[BenefitFromEmployerFinancedRetirementScheme], + redundancyCompensationPaymentsOverExemption: Option[RedundancyCompensationPaymentsOverExemption], + redundancyCompensationPaymentsUnderExemption: Option[RedundancyCompensationPaymentsUnderExemption]) + +object LumpSumsDetail { + + implicit val format: Format[LumpSumsDetail] = Json.format[LumpSumsDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsOverExemption.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsOverExemption.scala new file mode 100644 index 000000000..fc2ca61ff --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsOverExemption.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class RedundancyCompensationPaymentsOverExemption(amount: Option[BigDecimal], + taxPaid: Option[BigDecimal], + taxTakenOffInEmployment: Option[Boolean]) + +object RedundancyCompensationPaymentsOverExemption { + + implicit val format: Format[RedundancyCompensationPaymentsOverExemption] = Json.format[RedundancyCompensationPaymentsOverExemption] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsUnderExemption.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsUnderExemption.scala new file mode 100644 index 000000000..4c0e03a40 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/RedundancyCompensationPaymentsUnderExemption.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class RedundancyCompensationPaymentsUnderExemption(amount: Option[BigDecimal]) + +object RedundancyCompensationPaymentsUnderExemption { + + implicit val format: Format[RedundancyCompensationPaymentsUnderExemption] = Json.format[RedundancyCompensationPaymentsUnderExemption] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/StudentLoans.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/StudentLoans.scala new file mode 100644 index 000000000..20e365829 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/StudentLoans.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class StudentLoans(uglDeductionAmount: Option[BigDecimal], pglDeductionAmount: Option[BigDecimal]) + +object StudentLoans { + + implicit val format: Format[StudentLoans] = Json.format[StudentLoans] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/TaxableLumpSumsAndCertainIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/TaxableLumpSumsAndCertainIncome.scala new file mode 100644 index 000000000..037ffb5b9 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/TaxableLumpSumsAndCertainIncome.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{Format, Json} + +case class TaxableLumpSumsAndCertainIncome(amount: Option[BigDecimal], taxPaid: Option[BigDecimal], taxTakenOffInEmployment: Option[Boolean]) + +object TaxableLumpSumsAndCertainIncome { + + implicit val format: Format[TaxableLumpSumsAndCertainIncome] = Json.format[TaxableLumpSumsAndCertainIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentExpenses/EmploymentExpenses.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentExpenses/EmploymentExpenses.scala new file mode 100644 index 000000000..6f8eafdbf --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentExpenses/EmploymentExpenses.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentExpenses + +import play.api.libs.json.{Format, Json} + +case class EmploymentExpenses(totalEmploymentExpenses: Option[BigDecimal], employmentExpensesDetail: Option[EmploymentExpensesDetail]) + +object EmploymentExpenses { + + implicit val format: Format[EmploymentExpenses] = Json.format[EmploymentExpenses] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentExpenses/EmploymentExpensesDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentExpenses/EmploymentExpensesDetail.scala new file mode 100644 index 000000000..622475da3 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentExpenses/EmploymentExpensesDetail.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentExpenses + +import play.api.libs.json.{Format, Json} + +case class EmploymentExpensesDetail(businessTravelCosts: Option[BigDecimal], + jobExpenses: Option[BigDecimal], + flatRateJobExpenses: Option[BigDecimal], + professionalSubscriptions: Option[BigDecimal], + hotelAndMealExpenses: Option[BigDecimal], + otherAndCapitalAllowances: Option[BigDecimal], + vehicleExpenses: Option[BigDecimal], + mileageAllowanceRelief: Option[BigDecimal]) + +object EmploymentExpensesDetail { + + implicit val format: Format[EmploymentExpensesDetail] = Json.format[EmploymentExpensesDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/EndOfYearEstimate.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/EndOfYearEstimate.scala new file mode 100644 index 000000000..9c1e82c05 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/EndOfYearEstimate.scala @@ -0,0 +1,43 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.endOfYearEstimate + +import play.api.libs.json.{Json, OFormat} + +case class EndOfYearEstimate( + incomeSource: Option[Seq[IncomeSource]], + totalEstimatedIncome: Option[BigInt], + totalAllowancesAndDeductions: Option[BigInt], + totalTaxableIncome: Option[BigInt], + incomeTaxAmount: Option[BigDecimal], + nic2: Option[BigDecimal], + nic4: Option[BigDecimal], + totalTaxDeductedBeforeCodingOut: Option[BigDecimal], + saUnderpaymentsCodedOut: Option[BigDecimal], + totalNicAmount: Option[BigDecimal], + totalStudentLoansRepaymentAmount: Option[BigDecimal], + totalAnnuityPaymentsTaxCharged: Option[BigDecimal], + totalRoyaltyPaymentsTaxCharged: Option[BigDecimal], + totalTaxDeducted: Option[BigDecimal], + incomeTaxNicAmount: Option[BigDecimal], + cgtAmount: Option[BigDecimal], + incomeTaxNicAndCgtAmount: Option[BigDecimal] +) + +object EndOfYearEstimate { + implicit val format: OFormat[EndOfYearEstimate] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/IncomeSource.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/IncomeSource.scala new file mode 100644 index 000000000..cba191b9b --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/IncomeSource.scala @@ -0,0 +1,57 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.endOfYearEstimate + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType + +case class IncomeSource( + incomeSourceId: Option[String], + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + taxableIncome: BigInt, + finalised: Option[Boolean] +) + +object IncomeSource { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`employments`, + IncomeSourceType.`foreign-income`, + IncomeSourceType.`foreign-dividends`, + IncomeSourceType.`uk-savings-and-gains`, + IncomeSourceType.`uk-dividends`, + IncomeSourceType.`state-benefits`, + IncomeSourceType.`gains-on-life-policies`, + IncomeSourceType.`share-schemes`, + IncomeSourceType.`foreign-property`, + IncomeSourceType.`foreign-savings-and-gains`, + IncomeSourceType.`other-dividends`, + IncomeSourceType.`uk-securities`, + IncomeSourceType.`other-income`, + IncomeSourceType.`foreign-pension`, + IncomeSourceType.`non-paye-income`, + IncomeSourceType.`capital-gains-tax`, + IncomeSourceType.`charitable-giving` + ) + + implicit val format: OFormat[IncomeSource] = Json.format[IncomeSource] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/ChargeableForeignBenefitsAndGiftsDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/ChargeableForeignBenefitsAndGiftsDetail.scala new file mode 100644 index 000000000..99b11b775 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/ChargeableForeignBenefitsAndGiftsDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.foreignIncome + +import play.api.libs.json.{Json, OFormat} + +case class ChargeableForeignBenefitsAndGiftsDetail(transactionBenefit: Option[BigDecimal], + protectedForeignIncomeSourceBenefit: Option[BigDecimal], + protectedForeignIncomeOnwardGift: Option[BigDecimal], + benefitReceivedAsASettler: Option[BigDecimal], + onwardGiftReceivedAsASettler: Option[BigDecimal]) + +object ChargeableForeignBenefitsAndGiftsDetail { + implicit val format: OFormat[ChargeableForeignBenefitsAndGiftsDetail] = Json.format[ChargeableForeignBenefitsAndGiftsDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/CommonForeignIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/CommonForeignIncome.scala new file mode 100644 index 000000000..2aefc987f --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/CommonForeignIncome.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.foreignIncome + +import play.api.libs.json.{Json, OFormat} + +case class CommonForeignIncome(countryCode: String, + grossIncome: Option[BigDecimal], + netIncome: Option[BigDecimal], + taxDeducted: Option[BigDecimal], + foreignTaxCreditRelief: Option[Boolean]) + +object CommonForeignIncome { + implicit val format: OFormat[CommonForeignIncome] = Json.format[CommonForeignIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/ForeignIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/ForeignIncome.scala new file mode 100644 index 000000000..1321848d2 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/ForeignIncome.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.foreignIncome + +import play.api.libs.json.{Json, OFormat} + +case class ForeignIncome(chargeableOverseasPensionsStateBenefitsRoyalties: Option[BigDecimal], + overseasPensionsStateBenefitsRoyaltiesDetail: Option[Seq[CommonForeignIncome]], + chargeableAllOtherIncomeReceivedWhilstAbroad: Option[BigDecimal], + allOtherIncomeReceivedWhilstAbroadDetail: Option[Seq[CommonForeignIncome]], + overseasIncomeAndGains: Option[OverseasIncomeAndGains], + totalForeignBenefitsAndGifts: Option[BigDecimal], + chargeableForeignBenefitsAndGiftsDetail: Option[ChargeableForeignBenefitsAndGiftsDetail]) + +object ForeignIncome { + implicit val format: OFormat[ForeignIncome] = Json.format[ForeignIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/OverseasIncomeAndGains.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/OverseasIncomeAndGains.scala new file mode 100644 index 000000000..bb6e11035 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignIncome/OverseasIncomeAndGains.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.foreignIncome + +import play.api.libs.json.{Json, OFormat} + +case class OverseasIncomeAndGains(gainAmount: BigDecimal) + +object OverseasIncomeAndGains { + implicit val format: OFormat[OverseasIncomeAndGains] = Json.format[OverseasIncomeAndGains] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/foreignPropertyIncome/ForeignPropertyIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignPropertyIncome/ForeignPropertyIncome.scala new file mode 100644 index 000000000..309789342 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignPropertyIncome/ForeignPropertyIncome.scala @@ -0,0 +1,38 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.foreignPropertyIncome + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType.`foreign-property` + +case class ForeignPropertyIncome(incomeSourceId: String, + incomeSourceType: IncomeSourceType, + countryCode: String, + totalIncome: Option[BigDecimal], + totalExpenses: Option[BigDecimal], + netProfit: Option[BigDecimal], + netLoss: Option[BigDecimal], + totalAdditions: Option[BigDecimal], + totalDeductions: Option[BigDecimal], + taxableProfit: Option[BigDecimal], + adjustedIncomeTaxLoss: Option[BigDecimal]) + +object ForeignPropertyIncome { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`foreign-property`) + implicit val format: OFormat[ForeignPropertyIncome] = Json.format[ForeignPropertyIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/foreignTaxForFtcrNotClaimed/ForeignTaxForFtcrNotClaimed.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignTaxForFtcrNotClaimed/ForeignTaxForFtcrNotClaimed.scala new file mode 100644 index 000000000..f7f753899 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/foreignTaxForFtcrNotClaimed/ForeignTaxForFtcrNotClaimed.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.foreignTaxForFtcrNotClaimed + +import play.api.libs.json.{Json, OFormat} + +case class ForeignTaxForFtcrNotClaimed(foreignTaxOnForeignEmployment: BigDecimal) + +object ForeignTaxForFtcrNotClaimed { + implicit val format: OFormat[ForeignTaxForFtcrNotClaimed] = Json.format[ForeignTaxForFtcrNotClaimed] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/giftAid/GiftAid.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/giftAid/GiftAid.scala new file mode 100644 index 000000000..19a275c60 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/giftAid/GiftAid.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.giftAid + +import play.api.libs.json.{Json, OFormat} + +case class GiftAid(grossGiftAidPayments: BigInt, + rate: BigDecimal, + giftAidTax: BigDecimal, + giftAidTaxReductions: Option[BigDecimal], + incomeTaxChargedAfterGiftAidTaxReductions: Option[BigDecimal], + giftAidCharge: Option[BigDecimal]) + +object GiftAid { + implicit val format: OFormat[GiftAid] = Json.format[GiftAid] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/incomeSummaryTotals/IncomeSummaryTotals.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/incomeSummaryTotals/IncomeSummaryTotals.scala new file mode 100644 index 000000000..54fbdec9a --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/incomeSummaryTotals/IncomeSummaryTotals.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.incomeSummaryTotals + +import play.api.libs.json.{Format, Json} + +case class IncomeSummaryTotals(totalSelfEmploymentProfit: Option[BigInt], + totalPropertyProfit: Option[BigInt], + totalFHLPropertyProfit: Option[BigInt], + totalUKOtherPropertyProfit: Option[BigInt], + totalForeignPropertyProfit: Option[BigInt], + totalEeaFhlProfit: Option[BigInt], + totalEmploymentIncome: Option[BigInt]) + +object IncomeSummaryTotals { + implicit val format: Format[IncomeSummaryTotals] = Json.format[IncomeSummaryTotals] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala new file mode 100644 index 000000000..698531348 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.{ClaimType, IncomeSourceType} + +case class CarriedForwardLoss( + claimId: Option[String], + originatingClaimId: Option[String], + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + claimType: ClaimType, + taxYearClaimMade: Option[TaxYear], + taxYearLossIncurred: TaxYear, + currentLossValue: BigInt, + lossType: Option[String] +) + +object CarriedForwardLoss { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val format: OFormat[CarriedForwardLoss] = Json.format[CarriedForwardLoss] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ClaimNotApplied.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ClaimNotApplied.scala new file mode 100644 index 000000000..779336e7c --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ClaimNotApplied.scala @@ -0,0 +1,45 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.{ClaimType, IncomeSourceType} + +case class ClaimNotApplied( + claimId: String, + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + taxYearClaimMade: TaxYear, + claimType: ClaimType +) + +object ClaimNotApplied { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val format: OFormat[ClaimNotApplied] = Json.format[ClaimNotApplied] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLoss.scala new file mode 100644 index 000000000..4e08c4778 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLoss.scala @@ -0,0 +1,45 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType + +case class DefaultCarriedForwardLoss( + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + taxYearLossIncurred: TaxYear, + currentLossValue: BigInt +) + +object DefaultCarriedForwardLoss { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val format: OFormat[DefaultCarriedForwardLoss] = Json.format[DefaultCarriedForwardLoss] + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossesAndClaims.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossesAndClaims.scala new file mode 100644 index 000000000..fb2985c3c --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossesAndClaims.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{Json, OFormat} + +case class LossesAndClaims( + resultOfClaimsApplied: Option[Seq[ResultOfClaimsApplied]], + unclaimedLosses: Option[Seq[UnclaimedLoss]], + carriedForwardLosses: Option[Seq[CarriedForwardLoss]], + defaultCarriedForwardLosses: Option[Seq[DefaultCarriedForwardLoss]], + claimsNotApplied: Option[Seq[ClaimNotApplied]] +) + +object LossesAndClaims { + implicit val format: OFormat[LossesAndClaims] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala new file mode 100644 index 000000000..e9774c4b8 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala @@ -0,0 +1,51 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.{ClaimType, IncomeSourceType} + +case class ResultOfClaimsApplied( + claimId: Option[String], + originatingClaimId: Option[String], + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + taxYearClaimMade: TaxYear, + claimType: ClaimType, + mtdLoss: Option[Boolean], + taxYearLossIncurred: TaxYear, + lossAmountUsed: BigInt, + remainingLossValue: BigInt, + lossType: Option[String] +) + +object ResultOfClaimsApplied { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val format: OFormat[ResultOfClaimsApplied] = Json.format[ResultOfClaimsApplied] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala new file mode 100644 index 000000000..db3bc5ce0 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala @@ -0,0 +1,46 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType + +case class UnclaimedLoss( + incomeSourceId: Option[String], + incomeSourceType: IncomeSourceType, + taxYearLossIncurred: TaxYear, + currentLossValue: BigInt, + lossType: Option[String] +) + +object UnclaimedLoss { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + IncomeSourceType.`self-employment`, + IncomeSourceType.`uk-property-non-fhl`, + IncomeSourceType.`foreign-property-fhl-eea`, + IncomeSourceType.`uk-property-fhl`, + IncomeSourceType.`foreign-property` + ) + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val format: OFormat[UnclaimedLoss] = Json.format[UnclaimedLoss] + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/marriageAllowanceTransferredIn/MarriageAllowanceTransferredIn.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/marriageAllowanceTransferredIn/MarriageAllowanceTransferredIn.scala new file mode 100644 index 000000000..ba9d78d6a --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/marriageAllowanceTransferredIn/MarriageAllowanceTransferredIn.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.marriageAllowanceTransferredIn + +import play.api.libs.json.{Json, OFormat} + +case class MarriageAllowanceTransferredIn(amount: Option[BigDecimal], rate: Option[BigDecimal]) + +object MarriageAllowanceTransferredIn { + implicit val format: OFormat[MarriageAllowanceTransferredIn] = Json.format[MarriageAllowanceTransferredIn] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/notionalTax/NotionalTax.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/notionalTax/NotionalTax.scala new file mode 100644 index 000000000..0cd0a1219 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/notionalTax/NotionalTax.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.notionalTax + +import play.api.libs.json.{Json, OFormat} + +case class NotionalTax(chargeableGains: Option[BigDecimal]) + +object NotionalTax { + implicit val format: OFormat[NotionalTax] = Json.format[NotionalTax] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/OtherIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/OtherIncome.scala new file mode 100644 index 000000000..27a61501b --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/OtherIncome.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.otherIncome + +import play.api.libs.json.{Json, OFormat} + +case class OtherIncome(totalOtherIncome: BigDecimal, postCessationIncome: Option[PostCessationIncome]) + +object OtherIncome { + implicit val format: OFormat[OtherIncome] = Json.format[OtherIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/PostCessationIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/PostCessationIncome.scala new file mode 100644 index 000000000..51545ea0d --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/PostCessationIncome.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.otherIncome + +import play.api.libs.json.{Json, OFormat} + +case class PostCessationIncome( + totalPostCessationReceipts: BigDecimal, + postCessationReceipts: Seq[PostCessationReceipt] +) + +object PostCessationIncome { + implicit val format: OFormat[PostCessationIncome] = Json.format[PostCessationIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/PostCessationReceipt.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/PostCessationReceipt.scala new file mode 100644 index 000000000..1c231b313 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/otherIncome/PostCessationReceipt.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.otherIncome + +import play.api.libs.json.{Json, OFormat} + +case class PostCessationReceipt(amount: BigDecimal, taxYearIncomeToBeTaxed: String) + +object PostCessationReceipt { + implicit val format: OFormat[PostCessationReceipt] = Json.format[PostCessationReceipt] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionContributionReliefs/PensionContributionDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionContributionReliefs/PensionContributionDetail.scala new file mode 100644 index 000000000..ddc824d9e --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionContributionReliefs/PensionContributionDetail.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionContributionReliefs + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionDetail(regularPensionContributions: Option[BigDecimal], oneOffPensionContributionsPaid: Option[BigDecimal]) + +object PensionContributionDetail { + implicit val format: OFormat[PensionContributionDetail] = Json.format[PensionContributionDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionContributionReliefs/PensionContributionReliefs.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionContributionReliefs/PensionContributionReliefs.scala new file mode 100644 index 000000000..c5d1e160f --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionContributionReliefs/PensionContributionReliefs.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionContributionReliefs + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionReliefs(totalPensionContributionReliefs: BigDecimal, pensionContributionDetail: PensionContributionDetail) + +object PensionContributionReliefs { + implicit val format: OFormat[PensionContributionReliefs] = Json.format[PensionContributionReliefs] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/OverseasPensionContributions.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/OverseasPensionContributions.scala new file mode 100644 index 000000000..08b5b2bf4 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/OverseasPensionContributions.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class OverseasPensionContributions(totalShortServiceRefund: BigDecimal, + totalShortServiceRefundCharge: BigDecimal, + shortServiceRefundTaxPaid: Option[BigDecimal], + totalShortServiceRefundChargeDue: BigDecimal, + shortServiceRefundBands: Option[Seq[ShortServiceRefundBands]]) + +object OverseasPensionContributions { + implicit val format: OFormat[OverseasPensionContributions] = Json.format[OverseasPensionContributions] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionBand.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionBand.scala new file mode 100644 index 000000000..0040267b9 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionBand.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.PensionBandName + +case class PensionBand(name: PensionBandName, + rate: BigDecimal, + bandLimit: BigInt, + apportionedBandLimit: BigInt, + contributionAmount: BigDecimal, + pensionCharge: BigDecimal) + +object PensionBand { + implicit val format: OFormat[PensionBand] = Json.format[PensionBand] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionContributionsInExcessOfTheAnnualAllowance.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionContributionsInExcessOfTheAnnualAllowance.scala new file mode 100644 index 000000000..edd9e5db9 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionContributionsInExcessOfTheAnnualAllowance.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionsInExcessOfTheAnnualAllowance(totalContributions: BigDecimal, + totalPensionCharge: BigDecimal, + annualAllowanceTaxPaid: Option[BigDecimal], + totalPensionChargeDue: BigDecimal, + pensionBands: Option[Seq[PensionBand]]) + +object PensionContributionsInExcessOfTheAnnualAllowance { + + implicit val format: OFormat[PensionContributionsInExcessOfTheAnnualAllowance] = + Json.format[PensionContributionsInExcessOfTheAnnualAllowance] + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsDetailBreakdown.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsDetailBreakdown.scala new file mode 100644 index 000000000..fc31a0625 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsDetailBreakdown.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSavingsDetailBreakdown(amount: Option[BigDecimal], + taxPaid: Option[BigDecimal], + rate: Option[BigDecimal], + chargeableAmount: Option[BigDecimal]) + +object PensionSavingsDetailBreakdown { + implicit val format: OFormat[PensionSavingsDetailBreakdown] = Json.format[PensionSavingsDetailBreakdown] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxCharges.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxCharges.scala new file mode 100644 index 000000000..89b8f7991 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxCharges.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSavingsTaxCharges(totalPensionCharges: Option[BigDecimal], + totalTaxPaid: Option[BigDecimal], + totalPensionChargesDue: Option[BigDecimal], + pensionSavingsTaxChargesDetail: Option[PensionSavingsTaxChargesDetail]) + +object PensionSavingsTaxCharges { + implicit val format: OFormat[PensionSavingsTaxCharges] = Json.format[PensionSavingsTaxCharges] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxChargesDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxChargesDetail.scala new file mode 100644 index 000000000..a5c1c1bbc --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSavingsTaxChargesDetail.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSavingsTaxChargesDetail( + pensionSchemeUnauthorisedPayments: Option[PensionSchemeUnauthorisedPayments], + pensionSchemeOverseasTransfers: Option[PensionSchemeOverseasTransfers], + pensionContributionsInExcessOfTheAnnualAllowance: Option[PensionContributionsInExcessOfTheAnnualAllowance], + overseasPensionContributions: Option[OverseasPensionContributions]) + +object PensionSavingsTaxChargesDetail { + implicit val format: OFormat[PensionSavingsTaxChargesDetail] = Json.format[PensionSavingsTaxChargesDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeOverseasTransfers.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeOverseasTransfers.scala new file mode 100644 index 000000000..fea2b20bf --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeOverseasTransfers.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSchemeOverseasTransfers(transferCharge: Option[BigDecimal], + transferChargeTaxPaid: Option[BigDecimal], + rate: Option[BigDecimal], + chargeableAmount: Option[BigDecimal]) + +object PensionSchemeOverseasTransfers { + implicit val format: OFormat[PensionSchemeOverseasTransfers] = Json.format[PensionSchemeOverseasTransfers] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeUnauthorisedPayments.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeUnauthorisedPayments.scala new file mode 100644 index 000000000..ea26c13ce --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/PensionSchemeUnauthorisedPayments.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class PensionSchemeUnauthorisedPayments(totalChargeableAmount: Option[BigDecimal], + totalTaxPaid: Option[BigDecimal], + pensionSchemeUnauthorisedPaymentsSurcharge: Option[PensionSavingsDetailBreakdown], + pensionSchemeUnauthorisedPaymentsNonSurcharge: Option[PensionSavingsDetailBreakdown]) + +object PensionSchemeUnauthorisedPayments { + implicit val format: OFormat[PensionSchemeUnauthorisedPayments] = Json.format[PensionSchemeUnauthorisedPayments] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala new file mode 100644 index 000000000..de5552f76 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import play.api.libs.json.{Json, OFormat} + +case class ShortServiceRefundBands(name: String, + rate: BigDecimal, + bandLimit: BigInt, + apportionedBandLimit: BigInt, + shortServiceRefundAmount: BigDecimal, + shortServiceRefundCharge: BigDecimal) + +object ShortServiceRefundBands { + implicit val format: OFormat[ShortServiceRefundBands] = Json.format[ShortServiceRefundBands] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/previousCalculation/PreviousCalculation.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/previousCalculation/PreviousCalculation.scala new file mode 100644 index 000000000..436575b2e --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/previousCalculation/PreviousCalculation.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.previousCalculation + +import play.api.libs.json.{Json, OFormat} + +case class PreviousCalculation( + calculationTimestamp: Option[String], + calculationId: Option[String], + totalIncomeTaxAndNicsDue: Option[BigDecimal], + cgtTaxDue: Option[BigDecimal], + totalIncomeTaxAndNicsAndCgtDue: Option[BigDecimal], + incomeTaxNicDueThisPeriod: Option[BigDecimal], + cgtDueThisPeriod: Option[BigDecimal], + totalIncomeTaxAndNicsAndCgtDueThisPeriod: Option[BigDecimal] +) + +object PreviousCalculation { + implicit val format: OFormat[PreviousCalculation] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/AllOtherIncomeReceivedWhilstAbroad.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/AllOtherIncomeReceivedWhilstAbroad.scala new file mode 100644 index 000000000..9f7dc8811 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/AllOtherIncomeReceivedWhilstAbroad.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Format, Json} + +case class AllOtherIncomeReceivedWhilstAbroad(totalOtherIncomeAllowableAmount: BigDecimal, otherIncomeRfcDetail: Seq[OtherIncomeRfcDetail]) + +object AllOtherIncomeReceivedWhilstAbroad { + implicit val format: Format[AllOtherIncomeReceivedWhilstAbroad] = Json.format[AllOtherIncomeReceivedWhilstAbroad] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/BasicRateExtension.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/BasicRateExtension.scala new file mode 100644 index 000000000..e968cbcda --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/BasicRateExtension.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class BasicRateExtension(totalBasicRateExtension: Option[BigDecimal], + giftAidRelief: Option[BigInt], + pensionContributionReliefs: Option[BigDecimal]) + +object BasicRateExtension { + implicit val format: OFormat[BasicRateExtension] = Json.format[BasicRateExtension] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignProperty.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignProperty.scala new file mode 100644 index 000000000..31551d19b --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignProperty.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ForeignProperty(totalForeignPropertyAllowableAmount: BigDecimal, foreignPropertyRfcDetail: Seq[ForeignPropertyRfcDetail]) + +object ForeignProperty { + implicit val format: OFormat[ForeignProperty] = Json.format[ForeignProperty] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignPropertyRfcDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignPropertyRfcDetail.scala new file mode 100644 index 000000000..f55bbf87d --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignPropertyRfcDetail.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ForeignPropertyRfcDetail(countryCode: String, + amountClaimed: BigInt, + allowableAmount: BigDecimal, + carryForwardAmount: Option[BigDecimal]) + +object ForeignPropertyRfcDetail { + implicit val format: OFormat[ForeignPropertyRfcDetail] = Json.format[ForeignPropertyRfcDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignTaxCreditRelief.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignTaxCreditRelief.scala new file mode 100644 index 000000000..3e74ff683 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignTaxCreditRelief.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ForeignTaxCreditRelief(customerCalculatedRelief: Option[Boolean], + totalForeignTaxCreditRelief: BigDecimal, + foreignTaxCreditReliefOnProperty: Option[BigDecimal], + foreignTaxCreditReliefOnDividends: Option[BigDecimal], + foreignTaxCreditReliefOnSavings: Option[BigDecimal], + foreignTaxCreditReliefOnForeignIncome: Option[BigDecimal], + foreignTaxCreditReliefDetail: Option[Seq[ForeignTaxCreditReliefDetail]]) + +object ForeignTaxCreditRelief { + implicit val format: OFormat[ForeignTaxCreditRelief] = Json.format[ForeignTaxCreditRelief] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignTaxCreditReliefDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignTaxCreditReliefDetail.scala new file mode 100644 index 000000000..62252ad20 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ForeignTaxCreditReliefDetail.scala @@ -0,0 +1,46 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class ForeignTaxCreditReliefDetail(incomeSourceType: Option[IncomeSourceType], + incomeSourceId: Option[String], + countryCode: String, + foreignIncome: BigDecimal, + foreignTax: Option[BigDecimal], + dtaRate: Option[BigDecimal], + dtaAmount: Option[BigDecimal], + ukLiabilityOnIncome: Option[BigDecimal], + foreignTaxCredit: BigDecimal, + employmentLumpSum: Option[Boolean]) + +object ForeignTaxCreditReliefDetail { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = + IncomeSourceType.formatRestricted( + `foreign-dividends`, + `foreign-property`, + `foreign-savings-and-gains`, + `other-income`, + `foreign-pension` + ) + + implicit val format: OFormat[ForeignTaxCreditReliefDetail] = Json.format[ForeignTaxCreditReliefDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/GiftAidTaxReductionWhereBasicRateDiffers.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/GiftAidTaxReductionWhereBasicRateDiffers.scala new file mode 100644 index 000000000..0ef45e79c --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/GiftAidTaxReductionWhereBasicRateDiffers.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class GiftAidTaxReductionWhereBasicRateDiffers(amount: Option[BigDecimal]) + +object GiftAidTaxReductionWhereBasicRateDiffers { + implicit val format: OFormat[GiftAidTaxReductionWhereBasicRateDiffers] = Json.format[GiftAidTaxReductionWhereBasicRateDiffers] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/OtherIncomeRfcDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/OtherIncomeRfcDetail.scala new file mode 100644 index 000000000..ad822bb9a --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/OtherIncomeRfcDetail.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class OtherIncomeRfcDetail(countryCode: String, + residentialFinancialCostAmount: Option[BigDecimal], + broughtFwdResidentialFinancialCostAmount: Option[BigDecimal]) + +object OtherIncomeRfcDetail { + implicit val format: OFormat[OtherIncomeRfcDetail] = Json.format[OtherIncomeRfcDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/Reliefs.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/Reliefs.scala new file mode 100644 index 000000000..aec54de4b --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/Reliefs.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class Reliefs(residentialFinanceCosts: Option[ResidentialFinanceCosts], + reliefsClaimed: Option[Seq[ReliefsClaimed]], + foreignTaxCreditRelief: Option[ForeignTaxCreditRelief], + topSlicingRelief: Option[TopSlicingRelief], + basicRateExtension: Option[BasicRateExtension], + giftAidTaxReductionWhereBasicRateDiffers: Option[GiftAidTaxReductionWhereBasicRateDiffers]) + +object Reliefs extends { + + implicit val format: OFormat[Reliefs] = Json.format[Reliefs] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimed.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimed.scala new file mode 100644 index 000000000..11f9be4f3 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimed.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.ReliefsClaimedType + +case class ReliefsClaimed(`type`: ReliefsClaimedType, + amountClaimed: Option[BigDecimal], + allowableAmount: Option[BigDecimal], + amountUsed: Option[BigDecimal], + rate: Option[BigDecimal], + reliefsClaimedDetail: Option[Seq[ReliefsClaimedDetail]]) + +object ReliefsClaimed { + implicit val format: OFormat[ReliefsClaimed] = Json.format[ReliefsClaimed] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala new file mode 100644 index 000000000..2cb8b43ca --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ReliefsClaimedDetail(amountClaimed: Option[BigDecimal], + uniqueInvestmentRef: Option[String], + name: Option[String], + socialEnterpriseName: Option[String], + companyName: Option[String], + deficiencyReliefType: Option[String], + customerReference: Option[String]) + +object ReliefsClaimedDetail { + implicit val format: OFormat[ReliefsClaimedDetail] = Json.format[ReliefsClaimedDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ResidentialFinanceCosts.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ResidentialFinanceCosts.scala new file mode 100644 index 000000000..b2ec6c095 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ResidentialFinanceCosts.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class ResidentialFinanceCosts(adjustedTotalIncome: BigDecimal, + totalAllowableAmount: Option[BigDecimal], + relievableAmount: BigDecimal, + rate: BigDecimal, + totalResidentialFinanceCostsRelief: BigDecimal, + ukProperty: Option[UkProperty], + foreignProperty: Option[ForeignProperty], + allOtherIncomeReceivedWhilstAbroad: Option[AllOtherIncomeReceivedWhilstAbroad]) + +object ResidentialFinanceCosts { + implicit val format: OFormat[ResidentialFinanceCosts] = Json.format[ResidentialFinanceCosts] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/TopSlicingRelief.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/TopSlicingRelief.scala new file mode 100644 index 000000000..d637045ae --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/TopSlicingRelief.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class TopSlicingRelief(amount: Option[BigDecimal]) + +object TopSlicingRelief { + implicit val format: OFormat[TopSlicingRelief] = Json.format[TopSlicingRelief] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/UkProperty.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/UkProperty.scala new file mode 100644 index 000000000..ce55b0a17 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/UkProperty.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import play.api.libs.json.{Json, OFormat} + +case class UkProperty(amountClaimed: BigInt, allowableAmount: BigDecimal, carryForwardAmount: Option[BigDecimal]) + +object UkProperty { + implicit val format: OFormat[UkProperty] = Json.format[UkProperty] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/royaltyPayments/RoyaltyPayments.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/royaltyPayments/RoyaltyPayments.scala new file mode 100644 index 000000000..7d033dd7d --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/royaltyPayments/RoyaltyPayments.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.royaltyPayments + +import play.api.libs.json.{Json, OFormat} + +case class RoyaltyPayments(royaltyPaymentsAmount: BigInt, rate: BigDecimal, grossRoyaltyPayments: Option[BigInt]) + +object RoyaltyPayments { + implicit val format: OFormat[RoyaltyPayments] = Json.format[RoyaltyPayments] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncome.scala new file mode 100644 index 000000000..dcc6bce22 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncome.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType.`foreign-savings-and-gains` + +case class ForeignSavingsAndGainsIncome(incomeSourceType: IncomeSourceType, + countryCode: Option[String], + grossIncome: Option[BigDecimal], + netIncome: Option[BigDecimal], + taxDeducted: Option[BigDecimal], + foreignTaxCreditRelief: Option[Boolean]) + +object ForeignSavingsAndGainsIncome { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`foreign-savings-and-gains`) + implicit val format: Format[ForeignSavingsAndGainsIncome] = Json.format[ForeignSavingsAndGainsIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncome.scala new file mode 100644 index 000000000..96abb3408 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncome.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{Format, Json} + +case class SavingsAndGainsIncome(totalChargeableSavingsAndGains: Option[BigInt], + totalUkSavingsAndGains: Option[BigInt], + ukSavingsAndGainsIncome: Option[Seq[UkSavingsAndGainsIncome]], + chargeableForeignSavingsAndGains: Option[BigInt], + foreignSavingsAndGainsIncome: Option[Seq[ForeignSavingsAndGainsIncome]]) + +object SavingsAndGainsIncome { + implicit val format: Format[SavingsAndGainsIncome] = Json.format[SavingsAndGainsIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncome.scala new file mode 100644 index 000000000..c6d3809ec --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncome.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{Format, Json} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class UkSavingsAndGainsIncome(incomeSourceId: Option[String], + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + grossIncome: BigDecimal, + netIncome: Option[BigDecimal], + taxDeducted: Option[BigDecimal]) + +object UkSavingsAndGainsIncome { + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted(`uk-savings-and-gains`, `uk-securities`) + implicit val format: Format[UkSavingsAndGainsIncome] = Json.format[UkSavingsAndGainsIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/seafarersDeductions/SeafarersDeductionDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/seafarersDeductions/SeafarersDeductionDetail.scala new file mode 100644 index 000000000..dbf89f52f --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/seafarersDeductions/SeafarersDeductionDetail.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.seafarersDeductions + +import play.api.libs.json.{Format, Json} + +case class SeafarersDeductionDetail(nameOfShip: String, amountDeducted: BigDecimal) + +object SeafarersDeductionDetail { + + implicit val format: Format[SeafarersDeductionDetail] = Json.format[SeafarersDeductionDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/seafarersDeductions/SeafarersDeductions.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/seafarersDeductions/SeafarersDeductions.scala new file mode 100644 index 000000000..02afcc5a1 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/seafarersDeductions/SeafarersDeductions.scala @@ -0,0 +1,26 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.seafarersDeductions + +import play.api.libs.json.{Format, Json} + +case class SeafarersDeductions(totalSeafarersDeduction: BigDecimal, seafarersDeductionDetail: Seq[SeafarersDeductionDetail]) + +object SeafarersDeductions { + + implicit val format: Format[SeafarersDeductions] = Json.format[SeafarersDeductions] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala new file mode 100644 index 000000000..daed030d5 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.shareSchemesIncome + +import play.api.libs.json.{Json, OFormat} + +case class ShareSchemeDetail(`type`: String, employerName: Option[String], employerRef: Option[String], taxableAmount: BigDecimal) + +object ShareSchemeDetail { + implicit val format: OFormat[ShareSchemeDetail] = Json.format[ShareSchemeDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemesIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemesIncome.scala new file mode 100644 index 000000000..b76984c7d --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemesIncome.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.shareSchemesIncome + +import play.api.libs.json.{Json, OFormat} + +case class ShareSchemesIncome(totalIncome: BigDecimal, shareSchemeDetail: Option[Seq[ShareSchemeDetail]]) + +object ShareSchemesIncome { + implicit val format: OFormat[ShareSchemesIncome] = Json.format[ShareSchemesIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/CommonBenefit.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/CommonBenefit.scala new file mode 100644 index 000000000..f621ca9d2 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/CommonBenefit.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class CommonBenefit(incomeSourceId: String, amount: BigDecimal, source: Option[String]) + +object CommonBenefit { + implicit val format: OFormat[CommonBenefit] = Json.format[CommonBenefit] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/CommonBenefitWithTaxPaid.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/CommonBenefitWithTaxPaid.scala new file mode 100644 index 000000000..4219367f5 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/CommonBenefitWithTaxPaid.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class CommonBenefitWithTaxPaid(incomeSourceId: String, amount: BigDecimal, taxPaid: Option[BigDecimal], source: Option[String]) + +object CommonBenefitWithTaxPaid { + implicit val format: OFormat[CommonBenefitWithTaxPaid] = Json.format[CommonBenefitWithTaxPaid] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StateBenefitsDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StateBenefitsDetail.scala new file mode 100644 index 000000000..2c10e16f5 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StateBenefitsDetail.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class StateBenefitsDetail(incapacityBenefit: Option[Seq[CommonBenefitWithTaxPaid]], + statePension: Option[Seq[CommonBenefit]], + statePensionLumpSum: Option[Seq[StatePensionLumpSum]], + employmentSupportAllowance: Option[Seq[CommonBenefitWithTaxPaid]], + jobSeekersAllowance: Option[Seq[CommonBenefitWithTaxPaid]], + bereavementAllowance: Option[Seq[CommonBenefit]], + otherStateBenefits: Option[Seq[CommonBenefit]]) + +object StateBenefitsDetail { + implicit val format: OFormat[StateBenefitsDetail] = Json.format[StateBenefitsDetail] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StateBenefitsIncome.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StateBenefitsIncome.scala new file mode 100644 index 000000000..1a14e315c --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StateBenefitsIncome.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class StateBenefitsIncome(totalStateBenefitsIncome: Option[BigDecimal], + totalStateBenefitsTaxPaid: Option[BigDecimal], + stateBenefitsDetail: Option[StateBenefitsDetail], + totalStateBenefitsIncomeExcStatePensionLumpSum: Option[BigDecimal]) + +object StateBenefitsIncome { + implicit val format: OFormat[StateBenefitsIncome] = Json.format[StateBenefitsIncome] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StatePensionLumpSum.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StatePensionLumpSum.scala new file mode 100644 index 000000000..5acb819d9 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/stateBenefitsIncome/StatePensionLumpSum.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.stateBenefitsIncome + +import play.api.libs.json.{Json, OFormat} + +case class StatePensionLumpSum(incomeSourceId: String, amount: BigDecimal, taxPaid: Option[BigDecimal], rate: BigDecimal, source: Option[String]) + +object StatePensionLumpSum { + implicit val format: OFormat[StatePensionLumpSum] = Json.format[StatePensionLumpSum] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/studentLoans/StudentLoans.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/studentLoans/StudentLoans.scala new file mode 100644 index 000000000..9740e697e --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/studentLoans/StudentLoans.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.studentLoans + +import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.StudentLoanPlanType + +case class StudentLoans(planType: StudentLoanPlanType, + studentLoanTotalIncomeAmount: BigDecimal, + studentLoanChargeableIncomeAmount: BigDecimal, + studentLoanRepaymentAmount: BigDecimal, + studentLoanDeductionsFromEmployment: Option[BigDecimal], + studentLoanRepaymentAmountNetOfDeductions: BigDecimal, + studentLoanApportionedIncomeThreshold: BigInt, + studentLoanRate: BigDecimal, + payeIncomeForStudentLoan: Option[BigDecimal], + nonPayeIncomeForStudentLoan: Option[BigDecimal]) + +object StudentLoans { + implicit val format: OFormat[StudentLoans] = Json.format[StudentLoans] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRel.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRel.scala new file mode 100644 index 000000000..9456140ff --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRel.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class BusinessAssetsDisposalsAndInvestorsRel( + gainsIncome: Option[BigDecimal], + lossesBroughtForward: Option[BigDecimal], + lossesArisingThisYear: Option[BigDecimal], + gainsAfterLosses: Option[BigDecimal], + annualExemptionAmount: Option[BigDecimal], + taxableGains: Option[BigDecimal], + rate: Option[BigDecimal], + taxAmount: Option[BigDecimal] +) + +object BusinessAssetsDisposalsAndInvestorsRel { + implicit val format: Format[BusinessAssetsDisposalsAndInvestorsRel] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CapitalGainsTax.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CapitalGainsTax.scala new file mode 100644 index 000000000..ee457d2ee --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CapitalGainsTax.scala @@ -0,0 +1,40 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class CapitalGainsTax( + totalCapitalGainsIncome: BigDecimal, + annualExemptionAmount: BigDecimal, + totalTaxableGains: BigDecimal, + businessAssetsDisposalsAndInvestorsRel: Option[BusinessAssetsDisposalsAndInvestorsRel], + residentialPropertyAndCarriedInterest: Option[ResidentialPropertyAndCarriedInterest], + otherGains: Option[OtherGains], + capitalGainsTaxAmount: Option[BigDecimal], + adjustments: Option[BigDecimal], + adjustedCapitalGainsTax: Option[BigDecimal], + foreignTaxCreditRelief: Option[BigDecimal], + capitalGainsTaxAfterFTCR: Option[BigDecimal], + taxOnGainsAlreadyPaid: Option[BigDecimal], + capitalGainsTaxDue: BigDecimal, + capitalGainsOverpaid: Option[BigDecimal] +) + +object CapitalGainsTax { + implicit val format: Format[CapitalGainsTax] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBand.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBand.scala new file mode 100644 index 000000000..d9b0f07d5 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBand.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class CgtBand( + name: CgtBandName, + rate: BigDecimal, + income: BigDecimal, + taxAmount: BigDecimal +) + +object CgtBand { + implicit val format: Format[CgtBand] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandName.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandName.scala new file mode 100644 index 000000000..b77793e20 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandName.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait CgtBandName + +object CgtBandName { + case object `lower-rate` extends CgtBandName + case object `higher-rate` extends CgtBandName + + implicit val writes: Writes[CgtBandName] = Enums.writes[CgtBandName] + + implicit val reads: Reads[CgtBandName] = Enums.readsUsing { + case "lowerRate" => `lower-rate` + case "higherRate" => `higher-rate` + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class2Nics.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class2Nics.scala new file mode 100644 index 000000000..62cac3f19 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class2Nics.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class Class2Nics( + amount: Option[BigDecimal], + weeklyRate: Option[BigDecimal], + weeks: Option[BigInt], + limit: Option[BigInt], + apportionedLimit: Option[BigInt], + underSmallProfitThreshold: Boolean, + underLowerProfitThreshold: Option[Boolean], + actualClass2Nic: Option[Boolean] +) + +object Class2Nics { + implicit val format: Format[Class2Nics] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class4Nics.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class4Nics.scala new file mode 100644 index 000000000..9562585db --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class4Nics.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class Class4Nics( + totalIncomeLiableToClass4Charge: Option[BigInt], + totalClass4LossesAvailable: Option[BigInt], + totalClass4LossesUsed: Option[BigInt], + totalClass4LossesCarriedForward: Option[BigInt], + totalIncomeChargeableToClass4: Option[BigInt], + totalAmount: BigDecimal, + nic4Bands: Seq[Nic4Band] +) + +object Class4Nics { + implicit val format: Format[Class4Nics] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTax.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTax.scala new file mode 100644 index 000000000..5fb38f61d --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTax.scala @@ -0,0 +1,46 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class IncomeTax( + totalIncomeReceivedFromAllSources: BigInt, + totalAllowancesAndDeductions: BigInt, + totalTaxableIncome: BigInt, + payPensionsProfit: Option[IncomeTaxItem], + savingsAndGains: Option[IncomeTaxItem], + dividends: Option[IncomeTaxItem], + lumpSums: Option[IncomeTaxItem], + gainsOnLifePolicies: Option[IncomeTaxItem], + incomeTaxCharged: BigDecimal, + totalReliefs: Option[BigDecimal], + incomeTaxDueAfterReliefs: Option[BigDecimal], + totalNotionalTax: Option[BigDecimal], + marriageAllowanceRelief: Option[BigDecimal], + incomeTaxDueAfterTaxReductions: Option[BigDecimal], + incomeTaxDueAfterGiftAid: Option[BigDecimal], + totalPensionSavingsTaxCharges: Option[BigDecimal], + statePensionLumpSumCharges: Option[BigDecimal], + payeUnderpaymentsCodedOut: Option[BigDecimal], + totalIncomeTaxDue: Option[BigDecimal], + giftAidTaxChargeWhereBasicRateDiffers: Option[BigDecimal] +) + +object IncomeTax { + implicit val format: Format[IncomeTax] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBand.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBand.scala new file mode 100644 index 000000000..00b45b759 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBand.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class IncomeTaxBand( + name: IncomeTaxBandName, + rate: BigDecimal, + bandLimit: BigInt, + apportionedBandLimit: BigInt, + income: BigInt, + taxAmount: BigDecimal +) + +object IncomeTaxBand { + implicit val format: Format[IncomeTaxBand] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandName.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandName.scala new file mode 100644 index 000000000..f7f1b6545 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandName.scala @@ -0,0 +1,60 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait IncomeTaxBandName + +object IncomeTaxBandName { + case object `savings-starter-rate` extends IncomeTaxBandName + + case object `allowance-awarded-at-basic-rate` extends IncomeTaxBandName + + case object `allowance-awarded-at-higher-rate` extends IncomeTaxBandName + + case object `allowance-awarded-at-additional-rate` extends IncomeTaxBandName + + case object `starter-rate` extends IncomeTaxBandName + + case object `basic-rate` extends IncomeTaxBandName + + case object `intermediate-rate` extends IncomeTaxBandName + + case object `higher-rate` extends IncomeTaxBandName + + case object `additional-rate` extends IncomeTaxBandName + + case object `advanced-rate` extends IncomeTaxBandName + + implicit val writes: Writes[IncomeTaxBandName] = Enums.writes[IncomeTaxBandName] + + implicit val reads: Reads[IncomeTaxBandName] = Enums.readsUsing { + case "SSR" => `savings-starter-rate` + case "ZRTBR" => `allowance-awarded-at-basic-rate` + case "ZRTHR" => `allowance-awarded-at-higher-rate` + case "ZRTAR" => `allowance-awarded-at-additional-rate` + case "SRT" => `starter-rate` + case "BRT" => `basic-rate` + case "IRT" => `intermediate-rate` + case "HRT" => `higher-rate` + case "ART" => `additional-rate` + case "AVRT" => `advanced-rate` + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxItem.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxItem.scala new file mode 100644 index 000000000..500b011f8 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxItem.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class IncomeTaxItem( + incomeReceived: BigInt, + allowancesAllocated: BigInt, + taxableIncome: BigInt, + incomeTaxAmount: BigDecimal, + taxBands: Option[Seq[IncomeTaxBand]] +) + +object IncomeTaxItem { + implicit val format: Format[IncomeTaxItem] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4Band.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4Band.scala new file mode 100644 index 000000000..7bb764451 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4Band.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class Nic4Band( + name: Nic4BandName, + rate: BigDecimal, + threshold: Option[BigInt], + apportionedThreshold: Option[BigInt], + income: BigInt, + amount: BigDecimal +) + +object Nic4Band { + implicit val format: Format[Nic4Band] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandName.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandName.scala new file mode 100644 index 000000000..71ce5431c --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandName.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait Nic4BandName + +object Nic4BandName { + case object `zero-rate` extends Nic4BandName + + case object `basic-rate` extends Nic4BandName + + case object `higher-rate` extends Nic4BandName + + implicit val writes: Writes[Nic4BandName] = Enums.writes[Nic4BandName] + + implicit val reads: Reads[Nic4BandName] = Enums.readsUsing { + case "ZRT" => `zero-rate` + case "BRT" => `basic-rate` + case "HRT" => `higher-rate` + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nics.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nics.scala new file mode 100644 index 000000000..976a7c830 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nics.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class Nics( + class2Nics: Option[Class2Nics], + class4Nics: Option[Class4Nics], + nic2NetOfDeductions: Option[BigDecimal], + nic4NetOfDeductions: Option[BigDecimal], + totalNic: Option[BigDecimal] +) + +object Nics { + implicit val format: Format[Nics] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/OtherGains.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/OtherGains.scala new file mode 100644 index 000000000..8f7b23bdf --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/OtherGains.scala @@ -0,0 +1,36 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class OtherGains( + gainsIncome: Option[BigDecimal], + lossesBroughtForward: Option[BigDecimal], + lossesArisingThisYear: Option[BigDecimal], + gainsAfterLosses: Option[BigDecimal], + attributedGains: Option[BigDecimal], + netGains: Option[BigDecimal], + annualExemptionAmount: Option[BigDecimal], + taxableGains: Option[BigDecimal], + cgtTaxBands: Option[Seq[CgtBand]], + totalTaxAmount: Option[BigDecimal] +) + +object OtherGains { + implicit val format: Format[OtherGains] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterest.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterest.scala new file mode 100644 index 000000000..7a416ccb3 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterest.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class ResidentialPropertyAndCarriedInterest( + gainsIncome: Option[BigDecimal], + lossesBroughtForward: Option[BigDecimal], + lossesArisingThisYear: Option[BigDecimal], + gainsAfterLosses: Option[BigDecimal], + annualExemptionAmount: Option[BigDecimal], + taxableGains: Option[BigDecimal], + cgtTaxBands: Option[Seq[CgtBand]], + totalTaxAmount: Option[BigDecimal] +) + +object ResidentialPropertyAndCarriedInterest { + implicit val format: Format[ResidentialPropertyAndCarriedInterest] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculation.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculation.scala new file mode 100644 index 000000000..80b475a0e --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculation.scala @@ -0,0 +1,38 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{Format, Json} + +case class TaxCalculation( + incomeTax: Option[IncomeTax], + nics: Option[Nics], + totalTaxDeductedBeforeCodingOut: Option[BigDecimal], + saUnderpaymentsCodedOut: Option[BigDecimal], + totalIncomeTaxNicsCharged: Option[BigDecimal], + totalStudentLoansRepaymentAmount: Option[BigDecimal], + totalAnnuityPaymentsTaxCharged: Option[BigDecimal], + totalRoyaltyPaymentsTaxCharged: Option[BigDecimal], + totalTaxDeducted: Option[BigDecimal], + totalIncomeTaxAndNicsDue: Option[BigDecimal], + capitalGainsTax: Option[CapitalGainsTax], + totalIncomeTaxAndNicsAndCgt: Option[BigDecimal] +) + +object TaxCalculation { + implicit val format: Format[TaxCalculation] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/taxDeductedAtSource/TaxDeductedAtSource.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/taxDeductedAtSource/TaxDeductedAtSource.scala new file mode 100644 index 000000000..e1a2c88f5 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/taxDeductedAtSource/TaxDeductedAtSource.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxDeductedAtSource + +import play.api.libs.json.{Json, OFormat} + +case class TaxDeductedAtSource(bbsi: Option[BigDecimal], + ukLandAndProperty: Option[BigDecimal], + cis: Option[BigDecimal], + securities: Option[BigDecimal], + voidedIsa: Option[BigDecimal], + payeEmployments: Option[BigDecimal], + occupationalPensions: Option[BigDecimal], + stateBenefits: Option[BigDecimal], + specialWithholdingTaxOrUkTaxPaid: Option[BigDecimal], + inYearAdjustmentCodedInLaterTaxYear: Option[BigDecimal], + taxTakenOffTradingIncome: Option[BigDecimal]) + +object TaxDeductedAtSource { + implicit val format: OFormat[TaxDeductedAtSource] = Json.format[TaxDeductedAtSource] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/transitionProfit/TransitionProfit.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/transitionProfit/TransitionProfit.scala new file mode 100644 index 000000000..1e693e780 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/transitionProfit/TransitionProfit.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2024 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.transitionProfit + +import play.api.libs.json.{Format, Json} + +case class TransitionProfit( + totalTaxableTransitionProfit: Option[BigInt], + transitionProfitDetail: Option[Seq[TransitionProfitDetail]] +) + +object TransitionProfit { + implicit val format: Format[TransitionProfit] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/transitionProfit/TransitionProfitDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/transitionProfit/TransitionProfitDetail.scala new file mode 100644 index 000000000..2e70ad9aa --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/transitionProfit/TransitionProfitDetail.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2024 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.transitionProfit + +import play.api.libs.json.{Format, Json} + +case class TransitionProfitDetail( + incomeSourceId: String, + incomeSourceName: Option[String], + transitionProfitAmount: BigDecimal, + transitionProfitAccelerationAmount: Option[BigDecimal], + totalTransitionProfit: Option[BigInt], + remainingBroughtForwardIncomeTaxLosses: Option[BigInt], + broughtForwardIncomeTaxLossesUsed: Option[BigInt], + transitionProfitsAfterIncomeTaxLossDeductions: Option[BigInt] +) + +object TransitionProfitDetail { + implicit val format: Format[TransitionProfitDetail] = Json.format +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala new file mode 100644 index 000000000..bce04d4a6 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class AllowancesReliefsAndDeductions(`type`: Option[String], + submittedTimestamp: Option[String], + startDate: Option[String], + endDate: Option[String], + source: Option[String]) + +object AllowancesReliefsAndDeductions { + implicit val format: OFormat[AllowancesReliefsAndDeductions] = Json.format[AllowancesReliefsAndDeductions] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/AnnualAdjustment.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/AnnualAdjustment.scala new file mode 100644 index 000000000..a811599a5 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/AnnualAdjustment.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.functional.syntax._ +import play.api.libs.json._ +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class AnnualAdjustment(incomeSourceId: String, + incomeSourceType: IncomeSourceType, + bsasId: String, + receivedDateTime: String, + applied: Boolean) + +object AnnualAdjustment { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `uk-property-fhl`, + `foreign-property-fhl-eea`, + `foreign-property` + ) + + implicit val reads: Reads[AnnualAdjustment] = ( + (JsPath \ "incomeSourceId").read[String] and + (JsPath \ "incomeSourceType").read[IncomeSourceType](incomeSourceTypeFormat) and + (JsPath \ "ascId").read[String] and + (JsPath \ "receivedDateTime").read[String] and + (JsPath \ "applied").read[Boolean] + )(AnnualAdjustment.apply _) + + implicit val writes: OWrites[AnnualAdjustment] = Json.writes +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/BusinessIncomeSource.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/BusinessIncomeSource.scala new file mode 100644 index 000000000..1eca8df3a --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/BusinessIncomeSource.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class BusinessIncomeSource(incomeSourceId: String, + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + accountingPeriodStartDate: String, + accountingPeriodEndDate: String, + source: String, + commencementDate: Option[String], + cessationDate: Option[String], + latestPeriodEndDate: String, + latestReceivedDateTime: String, + finalised: Option[Boolean], + finalisationTimestamp: Option[String], + submissionPeriods: Option[Seq[SubmissionPeriod]]) + +case object BusinessIncomeSource { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `uk-property-fhl`, + `foreign-property-fhl-eea`, + `foreign-property` + ) + + implicit val format: OFormat[BusinessIncomeSource] = Json.format[BusinessIncomeSource] + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/Claim.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/Claim.scala new file mode 100644 index 000000000..0f0088f5d --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/Claim.scala @@ -0,0 +1,47 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.IncomeSourceType._ + +case class Claim(claimId: Option[String], + originatingClaimId: Option[String], + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + submissionTimestamp: Option[String], + taxYearClaimMade: TaxYear, + claimType: ClaimType, + sequence: Option[Int]) + +object Claim extends { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `uk-property-fhl`, + `foreign-property-fhl-eea`, + `foreign-property` + ) + + implicit val format: OFormat[Claim] = Json.format[Claim] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/ConstructionIndustryScheme.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/ConstructionIndustryScheme.scala new file mode 100644 index 000000000..263c1a3a4 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/ConstructionIndustryScheme.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class ConstructionIndustryScheme(employerRef: String, contractorName: Option[String], periodData: Seq[PeriodData]) + +object ConstructionIndustryScheme { + implicit val format: OFormat[ConstructionIndustryScheme] = Json.format[ConstructionIndustryScheme] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/IncomeSources.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/IncomeSources.scala new file mode 100644 index 000000000..3976dfbb9 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/IncomeSources.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class IncomeSources(businessIncomeSources: Option[Seq[BusinessIncomeSource]], nonBusinessIncomeSources: Option[Seq[NonBusinessIncomeSource]]) + +object IncomeSources { + implicit val format: OFormat[IncomeSources] = Json.format[IncomeSources] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/Inputs.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/Inputs.scala new file mode 100644 index 000000000..db23c0b49 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/Inputs.scala @@ -0,0 +1,47 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.functional.syntax._ +import play.api.libs.json.{JsPath, Json, OWrites, Reads} + +case class Inputs(personalInformation: PersonalInformation, + incomeSources: IncomeSources, + annualAdjustments: Option[Seq[AnnualAdjustment]], + lossesBroughtForward: Option[Seq[LossBroughtForward]], + claims: Option[Seq[Claim]], + constructionIndustryScheme: Option[Seq[ConstructionIndustryScheme]], // This field name has been changed from downstream. + allowancesReliefsAndDeductions: Option[Seq[AllowancesReliefsAndDeductions]], + pensionContributionAndCharges: Option[Seq[PensionContributionAndCharges]], + other: Option[Seq[Other]]) + +object Inputs { + implicit val writes: OWrites[Inputs] = Json.writes[Inputs] + + implicit val reads: Reads[Inputs] = ( + (JsPath \ "personalInformation").read[PersonalInformation] and + (JsPath \ "incomeSources").read[IncomeSources] and + (JsPath \ "annualAdjustments").readNullable[Seq[AnnualAdjustment]] and + (JsPath \ "lossesBroughtForward").readNullable[Seq[LossBroughtForward]] and + (JsPath \ "claims").readNullable[Seq[Claim]] and + (JsPath \ "cis").readNullable[Seq[ConstructionIndustryScheme]] and + (JsPath \ "allowancesReliefsAndDeductions").readNullable[Seq[AllowancesReliefsAndDeductions]] and + (JsPath \ "pensionContributionAndCharges").readNullable[Seq[PensionContributionAndCharges]] and + (JsPath \ "other").readNullable[Seq[Other]] + )(Inputs.apply _) + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/LossBroughtForward.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/LossBroughtForward.scala new file mode 100644 index 000000000..42aeffb29 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/LossBroughtForward.scala @@ -0,0 +1,47 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class LossBroughtForward(lossId: Option[String], + incomeSourceId: String, + incomeSourceType: IncomeSourceType, + submissionTimestamp: Option[String], + lossType: Option[String], + taxYearLossIncurred: TaxYear, + currentLossValue: BigInt, + mtdLoss: Option[Boolean]) + +object LossBroughtForward { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `self-employment`, + `uk-property-non-fhl`, + `uk-property-fhl`, + `foreign-property-fhl-eea`, + `foreign-property` + ) + + implicit val format: OFormat[LossBroughtForward] = Json.format[LossBroughtForward] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/NonBusinessIncomeSource.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/NonBusinessIncomeSource.scala new file mode 100644 index 000000000..eb6ca92f1 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/NonBusinessIncomeSource.scala @@ -0,0 +1,52 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Format, Json, OFormat} +import v7.common.model.response.IncomeSourceType +import IncomeSourceType._ + +case class NonBusinessIncomeSource(incomeSourceId: Option[String], + incomeSourceType: IncomeSourceType, + incomeSourceName: Option[String], + startDate: String, + endDate: Option[String], + source: String, + periodId: Option[String], + latestReceivedDateTime: Option[String]) + +case object NonBusinessIncomeSource { + + implicit val incomeSourceTypeFormat: Format[IncomeSourceType] = IncomeSourceType.formatRestricted( + `employments`, + `foreign-dividends`, + `uk-savings-and-gains`, + `uk-dividends`, + `state-benefits`, + `share-schemes`, + `foreign-savings-and-gains`, + `other-dividends`, + `uk-securities`, + `other-income`, + `foreign-pension`, + `non-paye-income`, + `capital-gains-tax`, + `charitable-giving` + ) + + implicit val format: OFormat[NonBusinessIncomeSource] = Json.format[NonBusinessIncomeSource] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala new file mode 100644 index 000000000..30edad968 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class Other(`type`: String, submittedOn: Option[String]) + +object Other { + implicit val format: OFormat[Other] = Json.format[Other] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala new file mode 100644 index 000000000..06d01c48d --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class PensionContributionAndCharges(`type`: String, + submissionTimestamp: Option[String], + startDate: Option[String], + endDate: Option[String], + source: Option[String]) + +object PensionContributionAndCharges { + implicit val format: OFormat[PensionContributionAndCharges] = Json.format[PensionContributionAndCharges] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/PeriodData.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/PeriodData.scala new file mode 100644 index 000000000..bc4e9948a --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/PeriodData.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class PeriodData(deductionFromDate: String, deductionToDate: String, submissionTimestamp: String, source: String, deductionAmount: BigDecimal) + +object PeriodData { + implicit val format: OFormat[PeriodData] = Json.format[PeriodData] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala new file mode 100644 index 000000000..132e841c5 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class PersonalInformation(identifier: String, + dateOfBirth: Option[String], + taxRegime: String, + statePensionAgeDate: Option[String], + studentLoanPlan: Option[Seq[StudentLoanPlan]], + class2VoluntaryContributions: Option[Boolean], + marriageAllowance: Option[String], + uniqueTaxpayerReference: Option[String], + itsaStatus: Option[String]) + +object PersonalInformation { + implicit val format: OFormat[PersonalInformation] = Json.format[PersonalInformation] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/StudentLoanPlan.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/StudentLoanPlan.scala new file mode 100644 index 000000000..55f483026 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/StudentLoanPlan.scala @@ -0,0 +1,27 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{JsPath, Json, OWrites, Reads} +import v7.common.model.response.StudentLoanPlanType + +case class StudentLoanPlan(planType: StudentLoanPlanType) + +object StudentLoanPlan { + implicit val writes: OWrites[StudentLoanPlan] = Json.writes[StudentLoanPlan] + implicit val reads: Reads[StudentLoanPlan] = (JsPath \ "planType").read[StudentLoanPlanType].map(StudentLoanPlan(_)) +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/SubmissionPeriod.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/SubmissionPeriod.scala new file mode 100644 index 000000000..1ac399e98 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/SubmissionPeriod.scala @@ -0,0 +1,25 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import play.api.libs.json.{Json, OFormat} + +case class SubmissionPeriod(periodId: Option[String], startDate: String, endDate: String, receivedDateTime: String) + +object SubmissionPeriod { + implicit val format: OFormat[SubmissionPeriod] = Json.format[SubmissionPeriod] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/messages/Messages.scala b/app/v7/retrieveCalculation/def2/model/response/messages/Messages.scala new file mode 100644 index 000000000..1415d76d1 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/messages/Messages.scala @@ -0,0 +1,28 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.messages + +import play.api.libs.json.{Json, OFormat} + +case class Message(id: String, text: String) + +case class Messages(info: Option[Seq[Message]], warnings: Option[Seq[Message]], errors: Option[Seq[Message]]) + +object Messages { + implicit val messageFormat: OFormat[Message] = Json.format[Message] + implicit val messagesFormat: OFormat[Messages] = Json.format[Messages] +} diff --git a/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala b/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala new file mode 100644 index 000000000..e399b3ce9 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala @@ -0,0 +1,59 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.metadata + +import common.TaxYearFormats +import shared.models.domain.TaxYear +import play.api.libs.functional.syntax._ +import play.api.libs.json._ +import v7.common.model.response.CalculationType + +case class Metadata(calculationId: String, + taxYear: TaxYear, + requestedBy: String, + requestedTimestamp: Option[String], + calculationReason: String, + calculationTimestamp: Option[String], + calculationType: CalculationType, + intentToSubmitFinalDeclaration: Boolean, + finalDeclaration: Boolean, + finalDeclarationTimestamp: Option[String], + periodFrom: String, + periodTo: String) + +object Metadata { + + implicit val taxYearFormat: Format[TaxYear] = TaxYearFormats.downstreamIntToMtdFormat + + implicit val writes: OWrites[Metadata] = Json.writes[Metadata] + + implicit val reads: Reads[Metadata] = ( + (JsPath \ "calculationId").read[String] and + (JsPath \ "taxYear").read[TaxYear] and + (JsPath \ "requestedBy").read[String] and + (JsPath \ "requestedTimestamp").readNullable[String] and + (JsPath \ "calculationReason").read[String] and + (JsPath \ "calculationTimestamp").readNullable[String] and + (JsPath \ "calculationType").read[CalculationType] and + (JsPath \ "intentToCrystallise").readWithDefault[Boolean](false) and + (JsPath \ "crystallised").readWithDefault[Boolean](false) and + (JsPath \ "crystallisationTimestamp").readNullable[String] and + (JsPath \ "periodFrom").read[String] and + (JsPath \ "periodTo").read[String] + )(Metadata.apply _) + +} diff --git a/app/v7/retrieveCalculation/models/request/RetrieveCalculationRequestData.scala b/app/v7/retrieveCalculation/models/request/RetrieveCalculationRequestData.scala new file mode 100644 index 000000000..f93083d81 --- /dev/null +++ b/app/v7/retrieveCalculation/models/request/RetrieveCalculationRequestData.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.models.request + +import shared.models.domain.{CalculationId, Nino, TaxYear} +import v7.retrieveCalculation.schema.RetrieveCalculationSchema + +sealed trait RetrieveCalculationRequestData { + val nino: Nino + val taxYear: TaxYear + val calculationId: CalculationId + val schema: RetrieveCalculationSchema +} + +case class Def1_RetrieveCalculationRequestData(nino: Nino, taxYear: TaxYear, calculationId: CalculationId) extends RetrieveCalculationRequestData{ + override val schema: RetrieveCalculationSchema = RetrieveCalculationSchema.Def1 +} + +case class Def2_RetrieveCalculationRequestData(nino: Nino, taxYear: TaxYear, calculationId: CalculationId) extends RetrieveCalculationRequestData{ + override val schema: RetrieveCalculationSchema = RetrieveCalculationSchema.Def2 +} \ No newline at end of file diff --git a/app/v7/retrieveCalculation/models/response/RetrieveCalculationResponse.scala b/app/v7/retrieveCalculation/models/response/RetrieveCalculationResponse.scala new file mode 100644 index 000000000..e1a097d37 --- /dev/null +++ b/app/v7/retrieveCalculation/models/response/RetrieveCalculationResponse.scala @@ -0,0 +1,192 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.models.response + +import shared.models.domain.TaxYear +import config.CalculationsFeatureSwitches +import play.api.libs.json.{Json, OWrites, Reads} +import v7.retrieveCalculation._ +import v7.retrieveCalculation.def2.model.response.calculation.Calculation + +import scala.math.Ordered.orderingToOrdered + +sealed trait RetrieveCalculationResponse { + def adjustFields(featureSwitches: CalculationsFeatureSwitches, taxYear: String): RetrieveCalculationResponse + + def intentToSubmitFinalDeclaration: Boolean + + def finalDeclaration: Boolean + + def hasErrors: Boolean +} + +object RetrieveCalculationResponse { + + implicit val writes: OWrites[RetrieveCalculationResponse] = { + case def1: Def1_RetrieveCalculationResponse => Json.toJsObject(def1) + case def2: Def2_RetrieveCalculationResponse => Json.toJsObject(def2) + } + +} + +case class Def1_RetrieveCalculationResponse( + metadata: def1.model.response.metadata.Metadata, + inputs: def1.model.response.inputs.Inputs, + calculation: Option[def1.model.response.calculation.Calculation], + messages: Option[def1.model.response.messages.Messages] +) extends RetrieveCalculationResponse { + + override def intentToSubmitFinalDeclaration: Boolean = metadata.intentToSubmitFinalDeclaration + + override def finalDeclaration: Boolean = metadata.finalDeclaration + + override def hasErrors: Boolean = { + for { + messages <- messages + errors <- messages.errors + } yield errors.nonEmpty + }.getOrElse(false) + + def adjustFields(featureSwitches: CalculationsFeatureSwitches, taxYear: String): Def1_RetrieveCalculationResponse = { + import featureSwitches._ + + def updateModelR8b(response: Def1_RetrieveCalculationResponse): Def1_RetrieveCalculationResponse = + if (isR8bSpecificApiEnabled) response else response.withoutR8bSpecificUpdates + + def updateModelAdditionalFields(response: Def1_RetrieveCalculationResponse): Def1_RetrieveCalculationResponse = + if (isRetrieveSAAdditionalFieldsEnabled) response else response.withoutAdditionalFieldsUpdates + + def updateModelCl290(response: Def1_RetrieveCalculationResponse): Def1_RetrieveCalculationResponse = + if (isCl290Enabled) response else response.withoutTaxTakenOffTradingIncome + + def updateModelBasicRateDivergence(taxYear: String, response: Def1_RetrieveCalculationResponse): Def1_RetrieveCalculationResponse = { + if (isBasicRateDivergenceEnabled && TaxYear.fromMtd(taxYear) >= TaxYear.fromMtd("2024-25")) response + else response.withoutBasicRateDivergenceUpdates + } + + val responseMaybeWithoutR8b = updateModelR8b(this) + val responseMaybeWithoutAdditionalFields = updateModelAdditionalFields(responseMaybeWithoutR8b) + val responseMaybeWithoutCl290 = updateModelCl290(responseMaybeWithoutAdditionalFields) + updateModelBasicRateDivergence(taxYear, responseMaybeWithoutCl290) + + } + + def withoutR8bSpecificUpdates: Def1_RetrieveCalculationResponse = + this.withoutBasicExtension.withoutOffPayrollWorker.withoutTotalAllowanceAndDeductions + + def withoutBasicExtension: Def1_RetrieveCalculationResponse = + Def1_RetrieveCalculationResponse(metadata, inputs, calculation.map(_.withoutBasicExtension), messages) + + def withoutOffPayrollWorker: Def1_RetrieveCalculationResponse = + Def1_RetrieveCalculationResponse(metadata, inputs, calculation.map(_.withoutOffPayrollWorker), messages) + + def withoutTotalAllowanceAndDeductions: Def1_RetrieveCalculationResponse = + Def1_RetrieveCalculationResponse(metadata, inputs, calculation.map(_.withoutTotalAllowanceAndDeductions), messages) + + // find where its used + def withoutUnderLowerProfitThreshold: Def1_RetrieveCalculationResponse = + Def1_RetrieveCalculationResponse(metadata, inputs, calculation.map(_.withoutUnderLowerProfitThreshold), messages) + + def withoutTaxTakenOffTradingIncome: Def1_RetrieveCalculationResponse = { + Def1_RetrieveCalculationResponse(metadata, inputs, calculation.map(_.withoutTaxTakenOffTradingIncome).filter(_.isDefined), messages) + } + + def withoutBasicRateDivergenceUpdates: Def1_RetrieveCalculationResponse = + this.withoutGiftAidTaxReductionWhereBasicRateDiffers.withoutGiftAidTaxChargeWhereBasicRateDiffers + + def withoutGiftAidTaxReductionWhereBasicRateDiffers: Def1_RetrieveCalculationResponse = + Def1_RetrieveCalculationResponse(metadata, inputs, calculation.map(_.withoutGiftAidTaxReductionWhereBasicRateDiffers), messages) + + def withoutGiftAidTaxChargeWhereBasicRateDiffers: Def1_RetrieveCalculationResponse = + Def1_RetrieveCalculationResponse(metadata, inputs, calculation.map(_.withoutGiftAidTaxChargeWhereBasicRateDiffers), messages) + + def withoutAdditionalFieldsUpdates: Def1_RetrieveCalculationResponse = + this.withoutCessationDate.withoutOtherIncome.withoutCommencementDate.withoutItsaStatus + + def withoutCessationDate: Def1_RetrieveCalculationResponse = { + Def1_RetrieveCalculationResponse(metadata, inputs.withoutCessationDate, calculation, messages) + } + + def withoutCommencementDate: Def1_RetrieveCalculationResponse = { + Def1_RetrieveCalculationResponse(metadata, inputs.withoutCommencementDate, calculation, messages) + } + + def withoutOtherIncome: Def1_RetrieveCalculationResponse = { + Def1_RetrieveCalculationResponse(metadata, inputs, calculation.map(_.withoutOtherIncome).filter(_.isDefined), messages) + } + + def withoutItsaStatus: Def1_RetrieveCalculationResponse = { + Def1_RetrieveCalculationResponse(metadata, inputs.withoutItsaStatus, calculation, messages) + } + +} + +object Def1_RetrieveCalculationResponse { + + def apply(metadata: def1.model.response.metadata.Metadata, + inputs: def1.model.response.inputs.Inputs, + calculation: Option[def1.model.response.calculation.Calculation], + messages: Option[def1.model.response.messages.Messages]): Def1_RetrieveCalculationResponse = { + new Def1_RetrieveCalculationResponse( + metadata, + inputs, + calculation = if (calculation.exists(_.isDefined)) calculation else None, + messages + ) + } + + implicit val reads: Reads[Def1_RetrieveCalculationResponse] = Json.reads[Def1_RetrieveCalculationResponse] + + implicit val writes: OWrites[Def1_RetrieveCalculationResponse] = Json.writes[Def1_RetrieveCalculationResponse] + +} + +case class Def2_RetrieveCalculationResponse( + metadata: def2.model.response.metadata.Metadata, + inputs: def2.model.response.inputs.Inputs, + calculation: Option[def2.model.response.calculation.Calculation], + messages: Option[def2.model.response.messages.Messages] +) extends RetrieveCalculationResponse { + + override def intentToSubmitFinalDeclaration: Boolean = metadata.intentToSubmitFinalDeclaration + + override def finalDeclaration: Boolean = metadata.finalDeclaration + + override def hasErrors: Boolean = { + for { + messages <- messages + errors <- messages.errors + } yield errors.nonEmpty + }.getOrElse(false) + + def adjustFields(featureSwitches: CalculationsFeatureSwitches, taxYear: String): Def2_RetrieveCalculationResponse = { + if (featureSwitches.isEnabled("retrieveTransitionProfit")) { + this + } else { + this.copy(calculation = Calculation.withoutTransitionProfit(calculation)) + } + } + +} + +object Def2_RetrieveCalculationResponse { + + implicit val reads: Reads[Def2_RetrieveCalculationResponse] = Json.reads[Def2_RetrieveCalculationResponse] + + implicit val writes: OWrites[Def2_RetrieveCalculationResponse] = Json.writes[Def2_RetrieveCalculationResponse] + +} diff --git a/app/v7/retrieveCalculation/schema/RetrieveCalculationSchema.scala b/app/v7/retrieveCalculation/schema/RetrieveCalculationSchema.scala new file mode 100644 index 000000000..e41a82753 --- /dev/null +++ b/app/v7/retrieveCalculation/schema/RetrieveCalculationSchema.scala @@ -0,0 +1,53 @@ +/* + * Copyright 2024 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.schema + +import shared.controllers.validators.resolvers.ResolveTaxYear +import shared.models.domain.TaxYear +import shared.schema.DownstreamReadable +import play.api.libs.json.Reads +import v7.retrieveCalculation.models.response.{Def1_RetrieveCalculationResponse, Def2_RetrieveCalculationResponse, RetrieveCalculationResponse} + +import scala.math.Ordered.orderingToOrdered + +sealed trait RetrieveCalculationSchema extends DownstreamReadable[RetrieveCalculationResponse] + +object RetrieveCalculationSchema { + + case object Def1 extends RetrieveCalculationSchema { + type DownstreamResp = Def1_RetrieveCalculationResponse + val connectorReads: Reads[DownstreamResp] = Def1_RetrieveCalculationResponse.reads + } + + case object Def2 extends RetrieveCalculationSchema { + type DownstreamResp = Def2_RetrieveCalculationResponse + val connectorReads: Reads[DownstreamResp] = Def2_RetrieveCalculationResponse.reads + } + + private val latestSchema = Def2 + + def schemaFor(taxYear: String): RetrieveCalculationSchema = + ResolveTaxYear(taxYear).toOption + .map(schemaFor) + .getOrElse(latestSchema) + + def schemaFor(taxYear: TaxYear): RetrieveCalculationSchema = + if (taxYear <= TaxYear.starting(2023)) Def1 + else if (taxYear == TaxYear.starting(2024)) Def2 + else latestSchema + +} diff --git a/conf/v7.routes b/conf/v7.routes index a639b1e25..1e03a9fe0 100644 --- a/conf/v7.routes +++ b/conf/v7.routes @@ -1,5 +1,5 @@ #V5 endpoints -GET /:nino/self-assessment/:taxYear/:calculationId v6.retrieveCalculation.RetrieveCalculationController.retrieveCalculation(nino: String, taxYear: String, calculationId: String) +GET /:nino/self-assessment/:taxYear/:calculationId v7.retrieveCalculation.RetrieveCalculationController.retrieveCalculation(nino: String, taxYear: String, calculationId: String) POST /:nino/self-assessment/:taxYear/:calculationId/final-declaration v5.submitFinalDeclaration.SubmitFinalDeclarationController.submitFinalDeclaration(nino: String, taxYear: String, calculationId: String) -GET /:nino/self-assessment v5.listCalculations.ListCalculationsController.list(nino: String, taxYear: Option[String]) +GET /:nino/self-assessment v7.listCalculations.ListCalculationsController.list(nino: String, taxYear: Option[String]) POST /:nino/self-assessment/:taxYear v5.triggerCalculation.TriggerCalculationController.triggerCalculation(nino: String, taxYear: String, finalDeclaration: Option[String]) diff --git a/it/v7/listCalculations/def1/ListCalculationsControllerISpec.scala b/it/v7/listCalculations/def1/ListCalculationsControllerISpec.scala new file mode 100644 index 000000000..350e65c53 --- /dev/null +++ b/it/v7/listCalculations/def1/ListCalculationsControllerISpec.scala @@ -0,0 +1,203 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.def1 + +import com.github.tomakehurst.wiremock.stubbing.StubMapping +import play.api.http.HeaderNames.ACCEPT +import play.api.http.Status._ +import play.api.libs.json.Json +import play.api.libs.ws.{WSRequest, WSResponse} +import play.api.test.Helpers.AUTHORIZATION +import shared.models.domain.TaxYear +import shared.models.errors._ +import shared.services.{AuditStub, AuthStub, DownstreamStub, MtdIdLookupStub} +import shared.support.IntegrationBaseSpec +import v7.listCalculations.def1.model.Def1_ListCalculationsFixture + +class ListCalculationsControllerISpec extends IntegrationBaseSpec with Def1_ListCalculationsFixture { + + private trait Test { + val nino: String = "ZG903729C" + + def taxYear: Option[String] + + private def uri: String = s"/$nino/self-assessment" + + def downstreamUri: String + + def setupStubs(): StubMapping + + def request: WSRequest = { + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + + def downstreamQueryParams: Seq[(String, String)] = + Seq("taxYear" -> taxYear) + .collect { case (k, Some(v)) => (k, v) } + + setupStubs() + buildRequest(uri) + .addQueryStringParameters(downstreamQueryParams: _*) + .withHttpHeaders( + (ACCEPT, "application/vnd.hmrc.5.0+json"), + (AUTHORIZATION, "Bearer 123") + ) + } + + def errorBody(code: String): String = + s""" + |{ + | "code": "$code", + | "message": "backend message" + |} + """.stripMargin + + } + + private trait NonTysTest extends Test { + def taxYear: Option[String] = Some("2018-19") + + override def downstreamUri: String = s"/income-tax/list-of-calculation-results/$nino" + } + + private trait TysIfsTest extends Test { + + val mtdTaxYear: String = TaxYear.now().asMtd + val downstreamTaxYear: String = TaxYear.now().asTysDownstream + def taxYear: Option[String] = Some(mtdTaxYear) + + override def downstreamUri: String = s"/income-tax/view/calculations/liability/$downstreamTaxYear/$nino" + + } + + "Calling the list calculations endpoint" should { + "return a 200 status code" when { + "valid request is made with a tax year" in new NonTysTest { + + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onSuccess(DownstreamStub.GET, downstreamUri, Map("taxYear" -> "2019"), OK, listCalculationsDownstreamJson) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe OK + response.header("Content-Type") shouldBe Some("application/json") + response.json shouldBe listCalculationsMtdJson + } + + "valid request is made without a tax year" in new TysIfsTest { + override def taxYear: Option[String] = None + + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onSuccess(DownstreamStub.GET, downstreamUri, OK, listCalculationsDownstreamJson) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe OK + response.header("Content-Type") shouldBe Some("application/json") + response.json shouldBe listCalculationsMtdJson + } + + "valid TYS request is made with a tax year" in new TysIfsTest { + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onSuccess(DownstreamStub.GET, downstreamUri, OK, listCalculationsDownstreamJson) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe OK + response.header("Content-Type") shouldBe Some("application/json") + response.json shouldBe listCalculationsMtdJson + } + } + + "return error according to spec" when { + "validation error" when { + def validationErrorTest(requestNino: String, requestTaxYear: String, expectedStatus: Int, expectedBody: MtdError): Unit = { + s"validation fails with ${expectedBody.code} error" in new NonTysTest { + override val nino: String = requestNino + override val taxYear: Option[String] = Some(requestTaxYear) + + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe expectedStatus + response.json shouldBe Json.toJson(expectedBody) + response.header("Content-Type") shouldBe Some("application/json") + } + } + + val input = Seq( + ("AA1123A", "2017-18", BAD_REQUEST, NinoFormatError), + ("ZG903729C", "20177", BAD_REQUEST, TaxYearFormatError), + ("ZG903729C", "2015-16", BAD_REQUEST, RuleTaxYearNotSupportedError), + ("ZG903729C", "2020-22", BAD_REQUEST, RuleTaxYearRangeInvalidError) + ) + + input.foreach(args => (validationErrorTest _).tupled(args)) + } + + "downstream returns a service error" when { + def serviceErrorTest(downstreamStatus: Int, downstreamCode: String, expectedStatus: Int, expectedBody: MtdError): Unit = { + s"backend returns an $downstreamStatus error and status $downstreamCode" in new NonTysTest { + + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onError(DownstreamStub.GET, downstreamUri, downstreamStatus, errorBody(downstreamCode)) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe expectedStatus + response.json shouldBe Json.toJson(expectedBody) + response.header("Content-Type") shouldBe Some("application/json") + } + } + + val errors = Seq( + (BAD_REQUEST, "INVALID_TAXABLE_ENTITY_ID", BAD_REQUEST, NinoFormatError), + (BAD_REQUEST, "INVALID_TAXYEAR", BAD_REQUEST, TaxYearFormatError), + (NOT_FOUND, "NOT_FOUND", NOT_FOUND, NotFoundError), + (INTERNAL_SERVER_ERROR, "SERVER_ERROR", INTERNAL_SERVER_ERROR, InternalError), + (SERVICE_UNAVAILABLE, "SERVICE_UNAVAILABLE", INTERNAL_SERVER_ERROR, InternalError), + (NOT_FOUND, "UNMATCHED_STUB_ERROR", BAD_REQUEST, RuleIncorrectGovTestScenarioError) + ) + + val extraTysErrors = Seq( + (BAD_REQUEST, "INVALID_TAX_YEAR", BAD_REQUEST, TaxYearFormatError), + (BAD_REQUEST, "INVALID_CORRELATION_ID", INTERNAL_SERVER_ERROR, InternalError), + (UNPROCESSABLE_ENTITY, "TAX_YEAR_NOT_SUPPORTED", BAD_REQUEST, RuleTaxYearNotSupportedError) + ) + + (errors ++ extraTysErrors).foreach(args => (serviceErrorTest _).tupled(args)) + } + } + } + +} diff --git a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala new file mode 100644 index 000000000..88cad8acf --- /dev/null +++ b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala @@ -0,0 +1,274 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1 + +import com.github.tomakehurst.wiremock.stubbing.StubMapping +import play.api.http.HeaderNames.ACCEPT +import play.api.http.Status._ +import play.api.libs.json.{JsValue, Json} +import play.api.libs.ws.{WSRequest, WSResponse} +import play.api.test.Helpers.AUTHORIZATION +import shared.models.errors._ +import shared.services.{AuditStub, AuthStub, DownstreamStub, MtdIdLookupStub} +import shared.support.IntegrationBaseSpec + +class Def1_RetrieveCalculationControllerISpec extends IntegrationBaseSpec { + + private trait Test { + val nino: String = "ZG903729C" + val calculationId: String = "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c" + def taxYear: String + def downstreamTaxYear: String + + def downstreamUri: String + + def setupStubs(): StubMapping + + def request: WSRequest = { + setupStubs() + buildRequest(uri) + .withHttpHeaders( + (ACCEPT, "application/vnd.hmrc.6.0+json"), + (AUTHORIZATION, "Bearer 123") + ) + } + + def uri: String = s"/$nino/self-assessment/$taxYear/$calculationId" + + def downstreamResponseBody(canBeFinalised: Boolean): JsValue = Json.parse( + s""" + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": 2017, + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | ${if (canBeFinalised) """"intentToCrystallise": true,""" else ""} + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | }, + | "calculation" : { + | "endOfYearEstimate": { + | "totalAllowancesAndDeductions": 100 + | }, + | "reliefs": { + | "basicRateExtension": { + | "totalBasicRateExtension": 2000.00 + | } + | } + | }, + | "messages" : {} + |} + """.stripMargin + ) + + def responseBody(canBeFinalised: Boolean): JsValue = Json.parse( + s""" + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": "2016-17", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": $canBeFinalised, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | }, + | "calculation" : { + | "endOfYearEstimate": { + | "totalAllowancesAndDeductions": 100 + | }, + | "reliefs": { + | "basicRateExtension": { + | "totalBasicRateExtension": 2000.00 + | } + | } + | }, + | "messages" : {} + |} + """.stripMargin + ) + + def errorBody(code: String): String = + s""" + |{ + | "code": "$code", + | "message": "backend message" + |} + """.stripMargin + + } + + private trait NonTysTest extends Test { + def taxYear: String = "2018-19" + def downstreamTaxYear: String = "2018-19" + override def downstreamUri: String = s"/income-tax/view/calculations/liability/$nino/$calculationId" + } + + private trait TysIfsTest extends Test { + def taxYear: String = "2023-24" + + override def downstreamUri: String = s"/income-tax/view/calculations/liability/$downstreamTaxYear/$nino/$calculationId" + + def downstreamTaxYear: String = "23-24" + } + + "Calling the retrieveCalculation endpoint" when { + "the response can be finalised" should { + "return a 200 status code" when { + "a valid request is made" in new NonTysTest { + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onSuccess(DownstreamStub.GET, downstreamUri, Map(), OK, downstreamResponseBody(canBeFinalised = false)) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe OK + response.header("Content-Type") shouldBe Some("application/json") + response.json shouldBe responseBody(canBeFinalised = false) + } + + "a valid request is made with a Tax Year Specific tax year" in new TysIfsTest { + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onSuccess(DownstreamStub.GET, downstreamUri, Map(), OK, downstreamResponseBody(canBeFinalised = false)) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe OK + response.header("Content-Type") shouldBe Some("application/json") + response.json shouldBe responseBody(canBeFinalised = false) + } + + "a valid request is made and the response can be finalised" in new NonTysTest { + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onSuccess(DownstreamStub.GET, downstreamUri, Map(), OK, downstreamResponseBody(canBeFinalised = true)) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe OK + response.header("Content-Type") shouldBe Some("application/json") + response.json shouldBe responseBody(canBeFinalised = true) + } + + "a valid request is made and the response can be finalised with a Tax Year Specific tax year" in new TysIfsTest { + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onSuccess(DownstreamStub.GET, downstreamUri, Map(), OK, downstreamResponseBody(canBeFinalised = true)) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe OK + response.header("Content-Type") shouldBe Some("application/json") + response.json shouldBe responseBody(canBeFinalised = true) + } + } + + "return the correct error code" when { + def validationErrorTest(requestNino: String, + requestTaxYear: String, + requestCalculationId: String, + expectedStatus: Int, + expectedBody: MtdError): Unit = { + s"validation fails with ${expectedBody.code} error" in new NonTysTest { + override val nino: String = requestNino + override val taxYear: String = requestTaxYear + override val calculationId: String = requestCalculationId + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(requestNino) + } + val response: WSResponse = await(request.get()) + response.status shouldBe expectedStatus + response.json shouldBe Json.toJson(expectedBody) + response.header("Content-Type") shouldBe Some("application/json") + } + } + val input = Seq( + ("AA1123A", "2018-19", "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", BAD_REQUEST, NinoFormatError), + ("ZG903729C", "20177", "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", BAD_REQUEST, TaxYearFormatError), + ("ZG903729C", "2016-17", "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", BAD_REQUEST, RuleTaxYearNotSupportedError), + ("ZG903729C", "2020-22", "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", BAD_REQUEST, RuleTaxYearRangeInvalidError), + ("ZG903729C", "2017-18", "bad id", BAD_REQUEST, CalculationIdFormatError) + ) + input.foreach(args => (validationErrorTest _).tupled(args)) + "downstream returns a service error" when { + def serviceErrorTest(downstreamStatus: Int, downstreamCode: String, expectedStatus: Int, expectedBody: MtdError): Unit = { + s"backend returns an $downstreamCode error and status $downstreamStatus" in new NonTysTest { + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onError(DownstreamStub.GET, downstreamUri, downstreamStatus, errorBody(downstreamCode)) + } + val response: WSResponse = await(request.get()) + response.status shouldBe expectedStatus + response.json shouldBe Json.toJson(expectedBody) + response.header("Content-Type") shouldBe Some("application/json") + } + } + val errors = Seq( + (BAD_REQUEST, "INVALID_TAXABLE_ENTITY_ID", BAD_REQUEST, NinoFormatError), + (BAD_REQUEST, "INVALID_CALCULATION_ID", BAD_REQUEST, CalculationIdFormatError), + (BAD_REQUEST, "INVALID_CORRELATIONID", INTERNAL_SERVER_ERROR, InternalError), + (BAD_REQUEST, "INVALID_CONSUMERID", INTERNAL_SERVER_ERROR, InternalError), + (NOT_FOUND, "NO_DATA_FOUND", NOT_FOUND, NotFoundError), + (INTERNAL_SERVER_ERROR, "SERVER_ERROR", INTERNAL_SERVER_ERROR, InternalError), + (SERVICE_UNAVAILABLE, "SERVICE_UNAVAILABLE", INTERNAL_SERVER_ERROR, InternalError), + (NOT_FOUND, "UNMATCHED_STUB_ERROR", BAD_REQUEST, RuleIncorrectGovTestScenarioError) + ) + val extraTysErrors = Seq( + (BAD_REQUEST, "INVALID_TAX_YEAR", BAD_REQUEST, TaxYearFormatError), + (BAD_REQUEST, "INVALID_CORRELATION_ID", INTERNAL_SERVER_ERROR, InternalError), + (BAD_REQUEST, "INVALID_CONSUMER_ID", INTERNAL_SERVER_ERROR, InternalError), + (NOT_FOUND, "NOT_FOUND", NOT_FOUND, NotFoundError), + (UNPROCESSABLE_ENTITY, "TAX_YEAR_NOT_SUPPORTED", BAD_REQUEST, RuleTaxYearNotSupportedError) + ) + (errors ++ extraTysErrors).foreach(args => (serviceErrorTest _).tupled(args)) + } + } + } + } + +} diff --git a/it/v7/retrieveCalculation/def2/Def2_RetrieveCalculationControllerISpec.scala b/it/v7/retrieveCalculation/def2/Def2_RetrieveCalculationControllerISpec.scala new file mode 100644 index 000000000..3d91e71e3 --- /dev/null +++ b/it/v7/retrieveCalculation/def2/Def2_RetrieveCalculationControllerISpec.scala @@ -0,0 +1,151 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2 + +import com.github.tomakehurst.wiremock.stubbing.StubMapping +import play.api.http.HeaderNames.ACCEPT +import play.api.http.Status._ +import play.api.libs.json.{JsObject, JsValue, Json} +import play.api.libs.ws.{WSRequest, WSResponse} +import play.api.test.Helpers.AUTHORIZATION +import shared.models.errors._ +import shared.services.{AuditStub, AuthStub, DownstreamStub, MtdIdLookupStub} +import shared.support.IntegrationBaseSpec +import v7.retrieveCalculation.def2.model.Def2_CalculationFixture + +class Def2_RetrieveCalculationControllerISpec extends IntegrationBaseSpec with Def2_CalculationFixture { + + private trait Test { + val nino: String = "ZG903729C" + val calculationId: String = "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c" + def taxYear: String = "2024-25" + def downstreamTaxYear: String = "24-25" + + def downstreamUri: String = s"/income-tax/view/calculations/liability/$downstreamTaxYear/$nino/$calculationId" + + def setupStubs(): StubMapping + + def request: WSRequest = { + setupStubs() + buildRequest(s"/$nino/self-assessment/$taxYear/$calculationId") + .withHttpHeaders( + (ACCEPT, "application/vnd.hmrc.6.0+json"), + (AUTHORIZATION, "Bearer 123") + ) + } + + val downstreamResponseBody: JsValue = calculationDownstreamJson + + val responseBody: JsValue = calculationMtdJson.as[JsObject] + + def errorBody(code: String): String = + s""" + |{ + | "code": "$code", + | "message": "backend message" + |} + """.stripMargin + + } + + "Calling the retrieveCalculation endpoint" when { + "successful" should { + "return a 200 status code" when { + "a valid request is made" in new Test { + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onSuccess(DownstreamStub.GET, downstreamUri, Map(), OK, downstreamResponseBody) + } + + val response: WSResponse = await(request.get()) + response.status shouldBe OK + response.header("Content-Type") shouldBe Some("application/json") + response.json shouldBe responseBody + } + + } + + "return the correct error code" when { + def validationErrorTest(requestNino: String, + requestTaxYear: String, + requestCalculationId: String, + expectedStatus: Int, + expectedBody: MtdError): Unit = { + s"validation fails with ${expectedBody.code} error" in new Test { + override val nino: String = requestNino + override val taxYear: String = requestTaxYear + override val calculationId: String = requestCalculationId + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(requestNino) + } + val response: WSResponse = await(request.get()) + response.status shouldBe expectedStatus + response.json shouldBe Json.toJson(expectedBody) + response.header("Content-Type") shouldBe Some("application/json") + } + } + val input = Seq( + ("AA1123A", "2018-19", "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", BAD_REQUEST, NinoFormatError), + ("ZG903729C", "20177", "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", BAD_REQUEST, TaxYearFormatError), + ("ZG903729C", "2016-17", "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", BAD_REQUEST, RuleTaxYearNotSupportedError), + ("ZG903729C", "2020-22", "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", BAD_REQUEST, RuleTaxYearRangeInvalidError), + ("ZG903729C", "2017-18", "bad id", BAD_REQUEST, CalculationIdFormatError) + ) + input.foreach(args => (validationErrorTest _).tupled(args)) + "downstream returns a service error" when { + def serviceErrorTest(downstreamStatus: Int, downstreamCode: String, expectedStatus: Int, expectedBody: MtdError): Unit = { + s"backend returns an $downstreamCode error and status $downstreamStatus" in new Test { + override def setupStubs(): StubMapping = { + AuditStub.audit() + AuthStub.authorised() + MtdIdLookupStub.ninoFound(nino) + DownstreamStub.onError(DownstreamStub.GET, downstreamUri, downstreamStatus, errorBody(downstreamCode)) + } + val response: WSResponse = await(request.get()) + response.status shouldBe expectedStatus + response.json shouldBe Json.toJson(expectedBody) + response.header("Content-Type") shouldBe Some("application/json") + } + } + val errors = Seq( + (BAD_REQUEST, "INVALID_TAXABLE_ENTITY_ID", BAD_REQUEST, NinoFormatError), + (BAD_REQUEST, "INVALID_CALCULATION_ID", BAD_REQUEST, CalculationIdFormatError), + (BAD_REQUEST, "INVALID_CORRELATIONID", INTERNAL_SERVER_ERROR, InternalError), + (BAD_REQUEST, "INVALID_CONSUMERID", INTERNAL_SERVER_ERROR, InternalError), + (NOT_FOUND, "NO_DATA_FOUND", NOT_FOUND, NotFoundError), + (INTERNAL_SERVER_ERROR, "SERVER_ERROR", INTERNAL_SERVER_ERROR, InternalError), + (SERVICE_UNAVAILABLE, "SERVICE_UNAVAILABLE", INTERNAL_SERVER_ERROR, InternalError), + (NOT_FOUND, "UNMATCHED_STUB_ERROR", BAD_REQUEST, RuleIncorrectGovTestScenarioError) + ) + val extraTysErrors = Seq( + (BAD_REQUEST, "INVALID_TAX_YEAR", BAD_REQUEST, TaxYearFormatError), + (BAD_REQUEST, "INVALID_CORRELATION_ID", INTERNAL_SERVER_ERROR, InternalError), + (BAD_REQUEST, "INVALID_CONSUMER_ID", INTERNAL_SERVER_ERROR, InternalError), + (NOT_FOUND, "NOT_FOUND", NOT_FOUND, NotFoundError), + (UNPROCESSABLE_ENTITY, "TAX_YEAR_NOT_SUPPORTED", BAD_REQUEST, RuleTaxYearNotSupportedError) + ) + (errors ++ extraTysErrors).foreach(args => (serviceErrorTest _).tupled(args)) + } + } + } + } + +} diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_downstream.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_downstream.json new file mode 100644 index 000000000..2358d1ef1 --- /dev/null +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_downstream.json @@ -0,0 +1,198 @@ +{ + "incomeTax": { + "totalIncomeReceivedFromAllSources": 12500, + "totalAllowancesAndDeductions": 12500, + "totalTaxableIncome": 12500, + "payPensionsProfit": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "savingsAndGains": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "dividends": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "lumpSums": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "gainsOnLifePolicies": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "incomeTaxCharged": 5000.99, + "totalReliefs": 5000.99, + "incomeTaxDueAfterReliefs": -99999999999.99, + "totalNotionalTax": 5000.99, + "marriageAllowanceRelief": 5000.99, + "incomeTaxDueAfterTaxReductions": 5000.99, + "incomeTaxDueAfterGiftAid": 5000.99, + "totalPensionSavingsTaxCharges": 5000.99, + "statePensionLumpSumCharges": 5000.99, + "payeUnderpaymentsCodedOut": 5000.99, + "totalIncomeTaxDue": 5000.99 + }, + "nics": { + "class2Nics": { + "amount": 5000.99, + "weeklyRate": 5000.99, + "weeks": 0, + "limit": 12500, + "apportionedLimit": 12500, + "underSmallProfitThreshold": true, + "actualClass2Nic": true + }, + "class4Nics": { + "totalIncomeLiableToClass4Charge": 12500, + "totalClass4LossesAvailable": 12500, + "totalClass4LossesUsed": 12500, + "totalClass4LossesCarriedForward": 12500, + "totalIncomeChargeableToClass4": 12500, + "totalAmount": 5000.99, + "nic4Bands": [ + { + "name": "ZRT", + "rate": 20, + "threshold": 12500, + "apportionedThreshold": 12500, + "income": 12500, + "amount": 5000.99 + } + ] + }, + "nic2NetOfDeductions": -99999999999.99, + "nic4NetOfDeductions": -99999999999.99, + "totalNic": -99999999999.99 + }, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalAnnuityPaymentsTaxCharged": 12500, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalIncomeTaxNicsCharged": -99999999999.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalTaxDeducted": -99999999999.99, + "totalIncomeTaxAndNicsDue": -99999999999.99, + "capitalGainsTax": { + "totalCapitalGainsIncome": 5000.99, + "annualExemptionAmount": 5000.99, + "totalTaxableGains": 5000.99, + "businessAssetsDisposalsAndInvestorsRel": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "rate": 20, + "taxAmount": 5000.99 + }, + "residentialPropertyAndCarriedInterest": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lowerRate", + "rate": 20, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "otherGains": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "attributedGains": 5000.99, + "netGains": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lowerRate", + "rate": 20, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "capitalGainsTaxAmount": 5000.99, + "adjustments": -99999999999.99, + "adjustedCapitalGainsTax": 5000.99, + "foreignTaxCreditRelief": 5000.99, + "capitalGainsTaxAfterFTCR": 5000.99, + "taxOnGainsAlreadyPaid": 5000.99, + "capitalGainsTaxDue": 5000.99, + "capitalGainsOverpaid": 5000.99 + }, + "totalIncomeTaxAndNicsAndCgt": 5000.99 +} \ No newline at end of file diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_mtd.json new file mode 100644 index 000000000..3b3ceb8b8 --- /dev/null +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_mtd.json @@ -0,0 +1,198 @@ +{ + "incomeTax": { + "totalIncomeReceivedFromAllSources": 12500, + "totalAllowancesAndDeductions": 12500, + "totalTaxableIncome": 12500, + "payPensionsProfit": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "savingsAndGains": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "dividends": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "lumpSums": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "gainsOnLifePolicies": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "incomeTaxCharged": 5000.99, + "totalReliefs": 5000.99, + "incomeTaxDueAfterReliefs": -99999999999.99, + "totalNotionalTax": 5000.99, + "marriageAllowanceRelief": 5000.99, + "incomeTaxDueAfterTaxReductions": 5000.99, + "incomeTaxDueAfterGiftAid": 5000.99, + "totalPensionSavingsTaxCharges": 5000.99, + "statePensionLumpSumCharges": 5000.99, + "payeUnderpaymentsCodedOut": 5000.99, + "totalIncomeTaxDue": 5000.99 + }, + "nics": { + "class2Nics": { + "amount": 5000.99, + "weeklyRate": 5000.99, + "weeks": 0, + "limit": 12500, + "apportionedLimit": 12500, + "underSmallProfitThreshold": true, + "actualClass2Nic": true + }, + "class4Nics": { + "totalIncomeLiableToClass4Charge": 12500, + "totalClass4LossesAvailable": 12500, + "totalClass4LossesUsed": 12500, + "totalClass4LossesCarriedForward": 12500, + "totalIncomeChargeableToClass4": 12500, + "totalAmount": 5000.99, + "nic4Bands": [ + { + "name": "zero-rate", + "rate": 20, + "threshold": 12500, + "apportionedThreshold": 12500, + "income": 12500, + "amount": 5000.99 + } + ] + }, + "nic2NetOfDeductions": -99999999999.99, + "nic4NetOfDeductions": -99999999999.99, + "totalNic": -99999999999.99 + }, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalAnnuityPaymentsTaxCharged": 12500, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalIncomeTaxNicsCharged": -99999999999.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalTaxDeducted": -99999999999.99, + "totalIncomeTaxAndNicsDue": -99999999999.99, + "capitalGainsTax": { + "totalCapitalGainsIncome": 5000.99, + "annualExemptionAmount": 5000.99, + "totalTaxableGains": 5000.99, + "businessAssetsDisposalsAndInvestorsRel": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "rate": 20, + "taxAmount": 5000.99 + }, + "residentialPropertyAndCarriedInterest": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lower-rate", + "rate": 20, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "otherGains": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "attributedGains": 5000.99, + "netGains": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lower-rate", + "rate": 20, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "capitalGainsTaxAmount": 5000.99, + "adjustments": -99999999999.99, + "adjustedCapitalGainsTax": 5000.99, + "foreignTaxCreditRelief": 5000.99, + "capitalGainsTaxAfterFTCR": 5000.99, + "taxOnGainsAlreadyPaid": 5000.99, + "capitalGainsTaxDue": 5000.99, + "capitalGainsOverpaid": 5000.99 + }, + "totalIncomeTaxAndNicsAndCgt": 5000.99 +} \ No newline at end of file diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json new file mode 100644 index 000000000..57b9f8fc5 --- /dev/null +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json @@ -0,0 +1,1094 @@ +{ + "metadata": { + "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", + "taxYear": 2018, + "requestedBy": "customer", + "requestedTimestamp": "2019-02-15T09:35:15.000Z", + "calculationReason": "customerRequest", + "calculationTimestamp": "2019-02-15T09:35:15.094Z", + "calculationType": "crystallisation", + "intentToCrystallise": true, + "crystallised": true, + "crystallisationTimestamp": "2019-02-15T09:35:15.094Z", + "periodFrom": "2018-04-06", + "periodTo": "2019-04-05" + }, + "inputs": { + "personalInformation": { + "identifier": "VO123456A", + "dateOfBirth": "2018-04-06", + "taxRegime": "UK", + "statePensionAgeDate": "2050-04-06", + "studentLoanPlan": [ + { + "planType": "01" + } + ], + "class2VoluntaryContributions": true, + "marriageAllowance": "transferor", + "uniqueTaxpayerReference": "1234567890" + }, + "incomeSources": { + "businessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "incomeSourceName": "string", + "accountingPeriodStartDate": "2018-04-06", + "accountingPeriodEndDate": "2019-04-05", + "source": "MTD-SA", + "latestPeriodEndDate": "2021-12-02", + "latestReceivedDateTime": "2021-12-02T15:25:48Z", + "finalised": true, + "finalisationTimestamp": "2019-02-15T09:35:15.094Z", + "submissionPeriods": [ + { + "periodId": "001", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "receivedDateTime": "2019-02-15T09:35:04.843Z" + } + ] + } + ], + "nonBusinessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "09", + "incomeSourceName": "Savings Account 1", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "source": "MTD-SA", + "periodId": "001", + "latestReceivedDateTime": "2019-08-01T13:02:09.775Z" + } + ] + }, + "annualAdjustments": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "ascId": "123a456b-789c-1d23-845e-678b9d1bd2ab", + "receivedDateTime": "2021-12-02T15:25:48Z", + "applied": true + } + ], + "lossesBroughtForward": [ + { + "lossId": "0yriP9QrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "lossType": "income", + "taxYearLossIncurred": 2018, + "currentLossValue": 12500, + "mtdLoss": false + } + ], + "claims": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "taxYearClaimMade": 2018, + "claimType": "CF", + "sequence": 0 + } + ], + "cis": [ + { + "employerRef": "123/AA12345", + "contractorName": "string", + "periodData": [ + { + "deductionFromDate": "2021-12-02", + "deductionToDate": "2021-12-02", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "source": "contractor", + "deductionAmount": 5000.99 + } + ] + } + ], + "allowancesReliefsAndDeductions": [ + { + "type": "investmentReliefs", + "submittedTimestamp": "2021-12-02T15:25:48Z", + "startDate": "2021-12-02", + "endDate": "2021-12-02", + "source": "MTD-SA" + } + ], + "pensionContributionAndCharges": [ + { + "type": "pensionReliefs", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "startDate": "2021-12-02", + "endDate": "2021-12-02", + "source": "customer" + } + ], + "other": [ + { + "type": "codingOut", + "submittedOn": "2021-12-02T15:25:48Z" + } + ] + }, + "calculation": { + "allowancesAndDeductions": { + "personalAllowance": 12500, + "marriageAllowanceTransferOut": { + "personalAllowanceBeforeTransferOut": 5000.99, + "transferredOutAmount": 5000.99 + }, + "reducedPersonalAllowance": 12501, + "giftOfInvestmentsAndPropertyToCharity": 12502, + "blindPersonsAllowance": 12503, + "lossesAppliedToGeneralIncome": 12504, + "cgtLossSetAgainstInYearGeneralIncome": 12505, + "qualifyingLoanInterestFromInvestments": 5001.99, + "post-cessationTradeReceipts": 5002.99, + "paymentsToTradeUnionsForDeathBenefits": 5003.99, + "grossAnnuityPayments": 5004.99, + "annuityPayments": { + "reliefClaimed": 5000.99, + "rate": 20.01 + }, + "pensionContributions": 5000.99, + "pensionContributionsDetail": { + "retirementAnnuityPayments": 5000.99, + "paymentToEmployersSchemeNoTaxRelief": 5000.99, + "overseasPensionSchemeContributions": 5000.99 + } + }, + "reliefs": { + "residentialFinanceCosts": { + "adjustedTotalIncome": 5000.99, + "totalAllowableAmount": 5000.99, + "relievableAmount": 5000.99, + "rate": 20.01, + "totalResidentialFinanceCostsRelief": 5000.99, + "ukProperty": { + "amountClaimed": 12500, + "allowableAmount": 5000.99, + "carryForwardAmount": 5000.99 + }, + "foreignProperty": { + "totalForeignPropertyAllowableAmount": 5000.99, + "foreignPropertyRfcDetail": [ + { + "countryCode": "FRA", + "amountClaimed": 12500, + "allowableAmount": 5000.99, + "carryForwardAmount": 5000.99 + } + ] + }, + "allOtherIncomeReceivedWhilstAbroad": { + "totalOtherIncomeAllowableAmount": 5000.99, + "otherIncomeRfcDetail": [ + { + "countryCode": "FRA", + "residentialFinancialCostAmount": 5000.99, + "broughtFwdResidentialFinancialCostAmount": 5000.99 + } + ] + } + }, + "reliefsClaimed": [ + { + "type": "vctSubscriptions", + "amountClaimed": 5000.99, + "allowableAmount": 5000.99, + "amountUsed": 5000.99, + "rate": 20.01, + "reliefsClaimedDetail": [ + { + "amountClaimed": 5000.99, + "uniqueInvestmentRef": "string", + "name": "string", + "socialEnterpriseName": "string", + "companyName": "string", + "deficiencyReliefType": "lifeInsurance", + "customerReference": "string" + } + ] + } + ], + "foreignTaxCreditRelief": { + "customerCalculatedRelief": true, + "totalForeignTaxCreditRelief": 5000.99, + "foreignTaxCreditReliefOnProperty": 5000.99, + "foreignTaxCreditReliefOnDividends": 5000.99, + "foreignTaxCreditReliefOnSavings": 5000.99, + "foreignTaxCreditReliefOnForeignIncome": 5000.99, + "foreignTaxCreditReliefDetail": [ + { + "incomeSourceType": "15", + "incomeSourceId": "000000000000210", + "countryCode": "FRA", + "foreignIncome": 5001.99, + "foreignTax": 5002.99, + "dtaRate": 20, + "dtaAmount": 5003.99, + "ukLiabilityOnIncome": 5004.99, + "foreignTaxCredit": 5005.99, + "employmentLumpSum": true + } + ] + }, + "topSlicingRelief": { + "amount": 5000.99 + } + }, + "taxDeductedAtSource": { + "bbsi": 5000.99, + "ukLandAndProperty": 5000.99, + "cis": 5000.99, + "securities": 5000.99, + "voidedIsa": 5000.99, + "payeEmployments": 5000.99, + "occupationalPensions": 5000.99, + "stateBenefits": -99999999999.99, + "specialWithholdingTaxOrUkTaxPaid": 5000.99, + "inYearAdjustmentCodedInLaterTaxYear": 5000.99 + }, + "giftAid": { + "grossGiftAidPayments": 12500, + "rate": 20.01, + "giftAidTax": 5000.99, + "giftAidTaxReductions": 5000.99, + "incomeTaxChargedAfterGiftAidTaxReductions": 5000.99, + "giftAidCharge": 5000.99 + }, + "royaltyPayments": { + "royaltyPaymentsAmount": 12500, + "rate": 20.01, + "grossRoyaltyPayments": 12500 + }, + "notionalTax": { + "chargeableGains": 5000.99 + }, + "marriageAllowanceTransferredIn": { + "amount": 5000.99, + "rate": 20.01 + }, + "pensionContributionReliefs": { + "totalPensionContributionReliefs": 5000.99, + "pensionContributionDetail": { + "regularPensionContributions": 5000.99, + "oneOffPensionContributionsPaid": 5000.99 + } + }, + "pensionSavingsTaxCharges": { + "totalPensionCharges": 5000.99, + "totalTaxPaid": 5000.99, + "totalPensionChargesDue": 5000.99, + "pensionSavingsTaxChargesDetail": { + "excessOfLifeTimeAllowance": { + "totalChargeableAmount": 5000.99, + "totalTaxPaid": 5000.99, + "lumpSumBenefitTakenInExcessOfLifetimeAllowance": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "benefitInExcessOfLifetimeAllowance": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + } + }, + "pensionSchemeUnauthorisedPayments": { + "totalChargeableAmount": 5000.99, + "totalTaxPaid": 5000.99, + "pensionSchemeUnauthorisedPaymentsSurcharge": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "pensionSchemeUnauthorisedPaymentsNonSurcharge": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + } + }, + "pensionSchemeOverseasTransfers": { + "transferCharge": 5000.99, + "transferChargeTaxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "pensionContributionsInExcessOfTheAnnualAllowance": { + "totalContributions": 5000.99, + "totalPensionCharge": 5000.99, + "annualAllowanceTaxPaid": 5000.99, + "totalPensionChargeDue": 5000.99, + "pensionBands": [ + { + "name": "BRT", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "contributionAmount": 5001.99, + "pensionCharge": 5002.99 + } + ] + }, + "overseasPensionContributions": { + "totalShortServiceRefund": 5000.99, + "totalShortServiceRefundCharge": 5000.99, + "shortServiceRefundTaxPaid": 5000.99, + "totalShortServiceRefundChargeDue": 5000.99, + "shortServiceRefundBands": [ + { + "name": "lowerBand", + "rate": 20.01, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "shortServiceRefundAmount": 5000.99, + "shortServiceRefundCharge": 5000.99 + } + ] + } + } + }, + "studentLoans": [ + { + "planType": "01", + "studentLoanTotalIncomeAmount": 5001.99, + "studentLoanChargeableIncomeAmount": 5002.99, + "studentLoanRepaymentAmount": 5003.99, + "studentLoanDeductionsFromEmployment": 5004.99, + "studentLoanRepaymentAmountNetOfDeductions": 5005.99, + "studentLoanApportionedIncomeThreshold": 12500, + "studentLoanRate": 20.01, + "payeIncomeForStudentLoan": 5006.99, + "nonPayeIncomeForStudentLoan": 5007.99 + } + ], + "codedOutUnderpayments": { + "totalPayeUnderpayments": 5000.99, + "payeUnderpaymentsDetail": [ + { + "amount": 5000.99, + "relatedTaxYear": "2017-18", + "source": "customer" + } + ], + "totalSelfAssessmentUnderpayments": 5000.99, + "totalCollectedSelfAssessmentUnderpayments": 5000.99, + "totalUncollectedSelfAssessmentUnderpayments": 5000.99, + "selfAssessmentUnderpaymentsDetail": [ + { + "amount": 5000.99, + "relatedTaxYear": "2017-18", + "saAccountingSystem": "ETMP", + "source": "customer", + "collectedAmount": 5001.99, + "uncollectedAmount": 5002.99 + } + ] + }, + "foreignPropertyIncome": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "15", + "countryCode": "FRA", + "totalIncome": 5001.99, + "totalExpenses": 5002.99, + "netProfit": 5003.99, + "netLoss": 5004.99, + "totalAdditions": 5005.99, + "totalDeductions": 5006.99, + "taxableProfit": 5007.99, + "adjustedIncomeTaxLoss": 5008.99 + } + ], + "businessProfitAndLoss": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "incomeSourceName": "string", + "totalIncome": 5001.99, + "totalExpenses": -5002.99, + "netProfit": 5003.99, + "netLoss": 5004.99, + "totalAdditions": -5005.99, + "totalDeductions": 5006.99, + "accountingAdjustments": -5007.99, + "taxableProfit": 12501, + "adjustedIncomeTaxLoss": 12502, + "totalBroughtForwardIncomeTaxLosses": 12503, + "lossForCSFHL": 12504, + "broughtForwardIncomeTaxLossesUsed": 12505, + "taxableProfitAfterIncomeTaxLossesDeduction": 12506, + "carrySidewaysIncomeTaxLossesUsed": 12507, + "broughtForwardCarrySidewaysIncomeTaxLossesUsed": 12508, + "totalIncomeTaxLossesCarriedForward": 12509, + "class4Loss": 12510, + "totalBroughtForwardClass4Losses": 12511, + "broughtForwardClass4LossesUsed": 12512, + "carrySidewaysClass4LossesUsed": 12513, + "totalClass4LossesCarriedForward": 12514 + } + ], + "employmentAndPensionsIncome": { + "totalPayeEmploymentAndLumpSumIncome": 5000.99, + "totalOccupationalPensionIncome": 5000.99, + "totalBenefitsInKind": 5000.99, + "tipsIncome": 5000.99, + "employmentAndPensionsIncomeDetail": [ + { + "incomeSourceId": "string", + "source": "customer", + "occupationalPension": true, + "employerRef": "123/AA12345", + "employerName": "string", + "payrollId": "string", + "startDate": "2021-12-02", + "dateEmploymentEnded": "2021-12-02", + "taxablePayToDate": 5000.99, + "totalTaxToDate": -99999999999.99, + "disguisedRemuneration": true, + "lumpSums": { + "totalLumpSum": 5000.99, + "totalTaxPaid": 5000.99, + "lumpSumsDetail": { + "taxableLumpSumsAndCertainIncome": { + "amount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "benefitFromEmployerFinancedRetirementScheme": { + "amount": 5000.99, + "exemptAmount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "redundancyCompensationPaymentsOverExemption": { + "amount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "redundancyCompensationPaymentsUnderExemption": { + "amount": 5000.99 + } + } + }, + "studentLoans": { + "uglDeductionAmount": 5000.99, + "pglDeductionAmount": 5000.99 + }, + "benefitsInKind": { + "totalBenefitsInKindReceived": 5000.99, + "benefitsInKindDetail": { + "apportionedAccommodation": 5000.99, + "apportionedAssets": 5000.99, + "apportionedAssetTransfer": 5000.99, + "apportionedBeneficialLoan": 5000.99, + "apportionedCar": 5000.99, + "apportionedCarFuel": 5000.99, + "apportionedEducationalServices": 5000.99, + "apportionedEntertaining": 5000.99, + "apportionedExpenses": 5000.99, + "apportionedMedicalInsurance": 5000.99, + "apportionedTelephone": 5000.99, + "apportionedService": 5000.99, + "apportionedTaxableExpenses": 5000.99, + "apportionedVan": 5000.99, + "apportionedVanFuel": 5000.99, + "apportionedMileage": 5000.99, + "apportionedNonQualifyingRelocationExpenses": 5000.99, + "apportionedNurseryPlaces": 5000.99, + "apportionedOtherItems": 5000.99, + "apportionedPaymentsOnEmployeesBehalf": 5000.99, + "apportionedPersonalIncidentalExpenses": 5000.99, + "apportionedQualifyingRelocationExpenses": 5000.99, + "apportionedEmployerProvidedProfessionalSubscriptions": 5000.99, + "apportionedEmployerProvidedServices": 5000.99, + "apportionedIncomeTaxPaidByDirector": 5000.99, + "apportionedTravelAndSubsistence": 5000.99, + "apportionedVouchersAndCreditCards": 5000.99, + "apportionedNonCash": 5000.99 + } + } + } + ] + }, + "employmentExpenses": { + "totalEmploymentExpenses": 5000.99, + "employmentExpensesDetail": { + "businessTravelCosts": 5000.99, + "jobExpenses": 5000.99, + "flatRateJobExpenses": 5000.99, + "professionalSubscriptions": 5000.99, + "hotelAndMealExpenses": 5000.99, + "otherAndCapitalAllowances": 5000.99, + "vehicleExpenses": 5000.99, + "mileageAllowanceRelief": 5000.99 + } + }, + "seafarersDeductions": { + "totalSeafarersDeduction": 5000.99, + "seafarersDeductionDetail": [ + { + "nameOfShip": "string", + "amountDeducted": 5000.99 + } + ] + }, + "foreignTaxForFtcrNotClaimed": { + "foreignTaxOnForeignEmployment": 5000.99 + }, + "stateBenefitsIncome": { + "totalStateBenefitsIncome": 5000.99, + "totalStateBenefitsTaxPaid": -99999999999.99, + "stateBenefitsDetail": { + "incapacityBenefit": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": 5000.99, + "source": "customer" + } + ], + "statePension": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ], + "statePensionLumpSum": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "source": "customer" + } + ], + "employmentSupportAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": -99999999999.99, + "source": "customer" + } + ], + "jobSeekersAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": -99999999999.99, + "source": "customer" + } + ], + "bereavementAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ], + "otherStateBenefits": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ] + }, + "totalStateBenefitsIncomeExcStatePensionLumpSum": 5000.01 + }, + "shareSchemesIncome": { + "totalIncome": 5000.99, + "shareSchemeDetail": [ + { + "type": "shareOption", + "employerName": "string", + "employerRef": "123/AA12345", + "taxableAmount": 5000.99 + } + ] + }, + "foreignIncome": { + "chargeableOverseasPensionsStateBenefitsRoyalties": 5000.99, + "overseasPensionsStateBenefitsRoyaltiesDetail": [ + { + "countryCode": "FRA", + "grossIncome": 5000.99, + "netIncome": 5000.99, + "taxDeducted": 5000.99, + "foreignTaxCreditRelief": true + } + ], + "chargeableAllOtherIncomeReceivedWhilstAbroad": 5000.99, + "allOtherIncomeReceivedWhilstAbroadDetail": [ + { + "countryCode": "FRA", + "grossIncome": 5000.99, + "netIncome": 5000.99, + "taxDeducted": 5000.99, + "foreignTaxCreditRelief": true + } + ], + "overseasIncomeAndGains": { + "gainAmount": 5000.99 + }, + "totalForeignBenefitsAndGifts": 5000.99, + "chargeableForeignBenefitsAndGiftsDetail": { + "transactionBenefit": 5000.99, + "protectedForeignIncomeSourceBenefit": 5000.99, + "protectedForeignIncomeOnwardGift": 5000.99, + "benefitReceivedAsASettler": 5000.99, + "onwardGiftReceivedAsASettler": 5000.99 + } + }, + "chargeableEventGainsIncome": { + "totalOfAllGains": 12500, + "totalGainsWithTaxPaid": 12500, + "gainsWithTaxPaidDetail": [ + { + "type": "lifeInsurance", + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0, + "yearsHeldSinceLastGain": 0 + } + ], + "totalGainsWithNoTaxPaidAndVoidedIsa": 12500, + "gainsWithNoTaxPaidAndVoidedIsaDetail": [ + { + "type": "lifeInsurance", + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0, + "yearsHeldSinceLastGain": 0, + "voidedIsaTaxPaid": 5000.99 + } + ], + "totalForeignGainsOnLifePoliciesTaxPaid": 12500, + "foreignGainsOnLifePoliciesTaxPaidDetail": [ + { + "customerReference": "string", + "gainAmount": 5000.99, + "taxPaidAmount": 5000.99, + "yearsHeld": 0 + } + ], + "totalForeignGainsOnLifePoliciesNoTaxPaid": 12500, + "foreignGainsOnLifePoliciesNoTaxPaidDetail": [ + { + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0 + } + ] + }, + "savingsAndGainsIncome": { + "totalChargeableSavingsAndGains": 12500, + "totalUkSavingsAndGains": 12500, + "ukSavingsAndGainsIncome": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "09", + "incomeSourceName": "My Savings Account 1", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99 + } + ], + "chargeableForeignSavingsAndGains": 12500, + "foreignSavingsAndGainsIncome": [ + { + "incomeSourceType": "16", + "countryCode": "GER", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ] + }, + "dividendsIncome": { + "totalChargeableDividends": 12500, + "totalUkDividends": 12500, + "ukDividends": { + "incomeSourceId": "000000000000210", + "incomeSourceType": "10", + "dividends": 12501, + "otherUkDividends": 12502 + }, + "otherDividends": [ + { + "typeOfDividend": "stockDividend", + "customerReference": "string", + "grossAmount": 5000.99 + } + ], + "chargeableForeignDividends": 12500, + "foreignDividends": [ + { + "incomeSourceType": "07", + "countryCode": "ZZZ", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ], + "dividendIncomeReceivedWhilstAbroad": [ + { + "incomeSourceType": "07", + "countryCode": "ZZZ", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ] + }, + "incomeSummaryTotals": { + "totalSelfEmploymentProfit": 12500, + "totalPropertyProfit": 12500, + "totalFHLPropertyProfit": 12500, + "totalUKOtherPropertyProfit": 12500, + "totalForeignPropertyProfit": 12500, + "totalEeaFhlProfit": 12500, + "totalEmploymentIncome": 12500 + }, + "taxCalculation": { + "incomeTax": { + "totalIncomeReceivedFromAllSources": 12500, + "totalAllowancesAndDeductions": 12500, + "totalTaxableIncome": 12500, + "payPensionsProfit": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "savingsAndGains": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "dividends": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "lumpSums": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "gainsOnLifePolicies": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "incomeTaxCharged": 5000.99, + "totalReliefs": 5000.99, + "incomeTaxDueAfterReliefs": -99999999999.99, + "totalNotionalTax": 5000.99, + "marriageAllowanceRelief": 5000.99, + "incomeTaxDueAfterTaxReductions": 5000.99, + "incomeTaxDueAfterGiftAid": 5000.99, + "totalPensionSavingsTaxCharges": 5000.99, + "statePensionLumpSumCharges": 5000.99, + "payeUnderpaymentsCodedOut": 5000.99, + "totalIncomeTaxDue": 5000.99 + }, + "nics": { + "class2Nics": { + "amount": 5000.99, + "weeklyRate": 5000.99, + "weeks": 0, + "limit": 12500, + "apportionedLimit": 12500, + "underSmallProfitThreshold": true, + "actualClass2Nic": true + }, + "class4Nics": { + "totalIncomeLiableToClass4Charge": 12500, + "totalClass4LossesAvailable": 12500, + "totalClass4LossesUsed": 12500, + "totalClass4LossesCarriedForward": 12500, + "totalIncomeChargeableToClass4": 12500, + "totalAmount": 5000.99, + "nic4Bands": [ + { + "name": "ZRT", + "rate": 20.01, + "threshold": 12501, + "apportionedThreshold": 12502, + "income": 12503, + "amount": 5000.99 + } + ] + }, + "nic2NetOfDeductions": -99999999999.99, + "nic4NetOfDeductions": -99999999999.99, + "totalNic": -99999999999.99 + }, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalAnnuityPaymentsTaxCharged": 12500, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalIncomeTaxNicsCharged": -99999999999.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalTaxDeducted": -99999999999.99, + "totalIncomeTaxAndNicsDue": -99999999999.99, + "capitalGainsTax": { + "totalCapitalGainsIncome": 5000.99, + "annualExemptionAmount": 5000.99, + "totalTaxableGains": 5000.99, + "businessAssetsDisposalsAndInvestorsRel": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "rate": 20.01, + "taxAmount": 5000.99 + }, + "residentialPropertyAndCarriedInterest": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lowerRate", + "rate": 20.01, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "otherGains": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "attributedGains": 5000.99, + "netGains": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lowerRate", + "rate": 20.01, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "capitalGainsTaxAmount": 5000.99, + "adjustments": -99999999999.99, + "adjustedCapitalGainsTax": 5000.99, + "foreignTaxCreditRelief": 5000.99, + "capitalGainsTaxAfterFTCR": 5000.99, + "taxOnGainsAlreadyPaid": 5000.99, + "capitalGainsTaxDue": 5000.99, + "capitalGainsOverpaid": 5000.99 + }, + "totalIncomeTaxAndNicsAndCgt": 5000.99 + }, + "previousCalculation": { + "calculationTimestamp": "2021-12-02T15:25:48Z", + "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", + "totalIncomeTaxAndNicsDue": -99999999999.99, + "cgtTaxDue": 5000.99, + "totalIncomeTaxAndNicsAndCgtDue": 5000.99, + "incomeTaxNicDueThisPeriod": -99999999999.99, + "cgtDueThisPeriod": -99999999999.99, + "totalIncomeTaxAndNicsAndCgtDueThisPeriod": 5000.99 + }, + "endOfYearEstimate": { + "incomeSource": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "incomeSourceName": "string", + "taxableIncome": 12500, + "finalised": true + } + ], + "totalEstimatedIncome": 12500, + "totalTaxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "nic2": 5000.99, + "nic4": 5000.99, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalNicAmount": 5000.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalAnnuityPaymentsTaxCharged": 5000.99, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalTaxDeducted": -99999999999.99, + "incomeTaxNicAmount": -99999999999.99, + "cgtAmount": 5000.99, + "incomeTaxNicAndCgtAmount": 5000.99 + }, + "lossesAndClaims": { + "resultOfClaimsApplied": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "taxYearClaimMade": 2017, + "claimType": "CF", + "mtdLoss": false, + "taxYearLossIncurred": 2018, + "lossAmountUsed": 12501, + "remainingLossValue": 12502, + "lossType": "income" + } + ], + "unclaimedLosses": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "taxYearLossIncurred": 2018, + "currentLossValue": 12500, + "lossType": "income" + } + ], + "carriedForwardLosses": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "claimType": "CF", + "taxYearClaimMade": 2017, + "taxYearLossIncurred": 2018, + "currentLossValue": 12500, + "lossType": "income" + } + ], + "defaultCarriedForwardLosses": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "taxYearLossIncurred": 2018, + "currentLossValue": 12500 + } + ], + "claimsNotApplied": [ + { + "claimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "taxYearClaimMade": 2018, + "claimType": "CF" + } + ] + } + }, + "messages": { + "info": [ + { + "id": "string", + "text": "string" + } + ], + "warnings": [ + { + "id": "string", + "text": "string" + } + ], + "errors": [ + { + "id": "string", + "text": "string" + } + ] + }, + "internal": { + "calculationDetails": { + "incomeTax": 5000.99, + "marriageAllowance": { + "creationTimestamp": "string" + }, + "employments": { + "employmentQuantity": 0 + }, + "selfEmployments": { + "selfEmploymentQuantity": 0 + } + } + } +} \ No newline at end of file diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json new file mode 100644 index 000000000..6e6d30b63 --- /dev/null +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -0,0 +1,1079 @@ +{ + "metadata": { + "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", + "taxYear": "2017-18", + "requestedBy": "customer", + "requestedTimestamp": "2019-02-15T09:35:15.000Z", + "calculationReason": "customerRequest", + "calculationTimestamp": "2019-02-15T09:35:15.094Z", + "calculationType": "finalDeclaration", + "intentToSubmitFinalDeclaration": true, + "finalDeclaration": true, + "finalDeclarationTimestamp": "2019-02-15T09:35:15.094Z", + "periodFrom": "2018-04-06", + "periodTo": "2019-04-05" + }, + "inputs": { + "personalInformation": { + "identifier": "VO123456A", + "dateOfBirth": "2018-04-06", + "taxRegime": "UK", + "statePensionAgeDate": "2050-04-06", + "studentLoanPlan": [ + { + "planType": "plan1" + } + ], + "class2VoluntaryContributions": true, + "marriageAllowance": "transferor", + "uniqueTaxpayerReference": "1234567890" + }, + "incomeSources": { + "businessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "incomeSourceName": "string", + "accountingPeriodStartDate": "2018-04-06", + "accountingPeriodEndDate": "2019-04-05", + "source": "MTD-SA", + "latestPeriodEndDate": "2021-12-02", + "latestReceivedDateTime": "2021-12-02T15:25:48Z", + "finalised": true, + "finalisationTimestamp": "2019-02-15T09:35:15.094Z", + "submissionPeriods": [ + { + "periodId": "001", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "receivedDateTime": "2019-02-15T09:35:04.843Z" + } + ] + } + ], + "nonBusinessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "uk-savings-and-gains", + "incomeSourceName": "Savings Account 1", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "source": "MTD-SA", + "periodId": "001", + "latestReceivedDateTime": "2019-08-01T13:02:09.775Z" + } + ] + }, + "annualAdjustments": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "bsasId": "123a456b-789c-1d23-845e-678b9d1bd2ab", + "receivedDateTime": "2021-12-02T15:25:48Z", + "applied": true + } + ], + "lossesBroughtForward": [ + { + "lossId": "0yriP9QrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "lossType": "income", + "taxYearLossIncurred": "2017-18", + "currentLossValue": 12500, + "mtdLoss": false + } + ], + "claims": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "taxYearClaimMade": "2017-18", + "claimType": "carry-forward", + "sequence": 0 + } + ], + "constructionIndustryScheme": [ + { + "employerRef": "123/AA12345", + "contractorName": "string", + "periodData": [ + { + "deductionFromDate": "2021-12-02", + "deductionToDate": "2021-12-02", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "source": "contractor", + "deductionAmount": 5000.99 + } + ] + } + ], + "allowancesReliefsAndDeductions": [ + { + "type": "investmentReliefs", + "submittedTimestamp": "2021-12-02T15:25:48Z", + "startDate": "2021-12-02", + "endDate": "2021-12-02", + "source": "MTD-SA" + } + ], + "pensionContributionAndCharges": [ + { + "type": "pensionReliefs", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "startDate": "2021-12-02", + "endDate": "2021-12-02", + "source": "customer" + } + ], + "other": [ + { + "type": "codingOut", + "submittedOn": "2021-12-02T15:25:48Z" + } + ] + }, + "calculation": { + "allowancesAndDeductions": { + "personalAllowance": 12500, + "marriageAllowanceTransferOut": { + "personalAllowanceBeforeTransferOut": 5000.99, + "transferredOutAmount": 5000.99 + }, + "reducedPersonalAllowance": 12501, + "giftOfInvestmentsAndPropertyToCharity": 12502, + "blindPersonsAllowance": 12503, + "lossesAppliedToGeneralIncome": 12504, + "cgtLossSetAgainstInYearGeneralIncome": 12505, + "qualifyingLoanInterestFromInvestments": 5001.99, + "postCessationTradeReceipts": 5002.99, + "paymentsToTradeUnionsForDeathBenefits": 5003.99, + "grossAnnuityPayments": 5004.99, + "annuityPayments": { + "reliefClaimed": 5000.99, + "rate": 20.01 + }, + "pensionContributions": 5000.99, + "pensionContributionsDetail": { + "retirementAnnuityPayments": 5000.99, + "paymentToEmployersSchemeNoTaxRelief": 5000.99, + "overseasPensionSchemeContributions": 5000.99 + } + }, + "reliefs": { + "residentialFinanceCosts": { + "adjustedTotalIncome": 5000.99, + "totalAllowableAmount": 5000.99, + "relievableAmount": 5000.99, + "rate": 20.01, + "totalResidentialFinanceCostsRelief": 5000.99, + "ukProperty": { + "amountClaimed": 12500, + "allowableAmount": 5000.99, + "carryForwardAmount": 5000.99 + }, + "foreignProperty": { + "totalForeignPropertyAllowableAmount": 5000.99, + "foreignPropertyRfcDetail": [ + { + "countryCode": "FRA", + "amountClaimed": 12500, + "allowableAmount": 5000.99, + "carryForwardAmount": 5000.99 + } + ] + }, + "allOtherIncomeReceivedWhilstAbroad": { + "totalOtherIncomeAllowableAmount": 5000.99, + "otherIncomeRfcDetail": [ + { + "countryCode": "FRA", + "residentialFinancialCostAmount": 5000.99, + "broughtFwdResidentialFinancialCostAmount": 5000.99 + } + ] + } + }, + "reliefsClaimed": [ + { + "type": "vctSubscriptions", + "amountClaimed": 5000.99, + "allowableAmount": 5000.99, + "amountUsed": 5000.99, + "rate": 20.01, + "reliefsClaimedDetail": [ + { + "amountClaimed": 5000.99, + "uniqueInvestmentRef": "string", + "name": "string", + "socialEnterpriseName": "string", + "companyName": "string", + "deficiencyReliefType": "lifeInsurance", + "customerReference": "string" + } + ] + } + ], + "foreignTaxCreditRelief": { + "customerCalculatedRelief": true, + "totalForeignTaxCreditRelief": 5000.99, + "foreignTaxCreditReliefOnProperty": 5000.99, + "foreignTaxCreditReliefOnDividends": 5000.99, + "foreignTaxCreditReliefOnSavings": 5000.99, + "foreignTaxCreditReliefOnForeignIncome": 5000.99, + "foreignTaxCreditReliefDetail": [ + { + "incomeSourceType": "foreign-property", + "incomeSourceId": "000000000000210", + "countryCode": "FRA", + "foreignIncome": 5001.99, + "foreignTax": 5002.99, + "dtaRate": 20, + "dtaAmount": 5003.99, + "ukLiabilityOnIncome": 5004.99, + "foreignTaxCredit": 5005.99, + "employmentLumpSum": true + } + ] + }, + "topSlicingRelief": { + "amount": 5000.99 + } + }, + "taxDeductedAtSource": { + "bbsi": 5000.99, + "ukLandAndProperty": 5000.99, + "cis": 5000.99, + "securities": 5000.99, + "voidedIsa": 5000.99, + "payeEmployments": 5000.99, + "occupationalPensions": 5000.99, + "stateBenefits": -99999999999.99, + "specialWithholdingTaxOrUkTaxPaid": 5000.99, + "inYearAdjustmentCodedInLaterTaxYear": 5000.99 + }, + "giftAid": { + "grossGiftAidPayments": 12500, + "rate": 20.01, + "giftAidTax": 5000.99, + "giftAidTaxReductions": 5000.99, + "incomeTaxChargedAfterGiftAidTaxReductions": 5000.99, + "giftAidCharge": 5000.99 + }, + "royaltyPayments": { + "royaltyPaymentsAmount": 12500, + "rate": 20.01, + "grossRoyaltyPayments": 12500 + }, + "notionalTax": { + "chargeableGains": 5000.99 + }, + "marriageAllowanceTransferredIn": { + "amount": 5000.99, + "rate": 20.01 + }, + "pensionContributionReliefs": { + "totalPensionContributionReliefs": 5000.99, + "pensionContributionDetail": { + "regularPensionContributions": 5000.99, + "oneOffPensionContributionsPaid": 5000.99 + } + }, + "pensionSavingsTaxCharges": { + "totalPensionCharges": 5000.99, + "totalTaxPaid": 5000.99, + "totalPensionChargesDue": 5000.99, + "pensionSavingsTaxChargesDetail": { + "excessOfLifeTimeAllowance": { + "totalChargeableAmount": 5000.99, + "totalTaxPaid": 5000.99, + "lumpSumBenefitTakenInExcessOfLifetimeAllowance": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "benefitInExcessOfLifetimeAllowance": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + } + }, + "pensionSchemeUnauthorisedPayments": { + "totalChargeableAmount": 5000.99, + "totalTaxPaid": 5000.99, + "pensionSchemeUnauthorisedPaymentsSurcharge": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "pensionSchemeUnauthorisedPaymentsNonSurcharge": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + } + }, + "pensionSchemeOverseasTransfers": { + "transferCharge": 5000.99, + "transferChargeTaxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "pensionContributionsInExcessOfTheAnnualAllowance": { + "totalContributions": 5000.99, + "totalPensionCharge": 5000.99, + "annualAllowanceTaxPaid": 5000.99, + "totalPensionChargeDue": 5000.99, + "pensionBands": [ + { + "name": "basic-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "contributionAmount": 5001.99, + "pensionCharge": 5002.99 + } + ] + }, + "overseasPensionContributions": { + "totalShortServiceRefund": 5000.99, + "totalShortServiceRefundCharge": 5000.99, + "shortServiceRefundTaxPaid": 5000.99, + "totalShortServiceRefundChargeDue": 5000.99, + "shortServiceRefundBands": [ + { + "name": "lowerBand", + "rate": 20.01, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "shortServiceRefundAmount": 5000.99, + "shortServiceRefundCharge": 5000.99 + } + ] + } + } + }, + "studentLoans": [ + { + "planType": "plan1", + "studentLoanTotalIncomeAmount": 5001.99, + "studentLoanChargeableIncomeAmount": 5002.99, + "studentLoanRepaymentAmount": 5003.99, + "studentLoanDeductionsFromEmployment": 5004.99, + "studentLoanRepaymentAmountNetOfDeductions": 5005.99, + "studentLoanApportionedIncomeThreshold": 12500, + "studentLoanRate": 20.01, + "payeIncomeForStudentLoan": 5006.99, + "nonPayeIncomeForStudentLoan": 5007.99 + } + ], + "codedOutUnderpayments": { + "totalPayeUnderpayments": 5000.99, + "payeUnderpaymentsDetail": [ + { + "amount": 5000.99, + "relatedTaxYear": "2017-18", + "source": "customer" + } + ], + "totalSelfAssessmentUnderpayments": 5000.99, + "totalCollectedSelfAssessmentUnderpayments": 5000.99, + "totalUncollectedSelfAssessmentUnderpayments": 5000.99, + "selfAssessmentUnderpaymentsDetail": [ + { + "amount": 5000.99, + "relatedTaxYear": "2017-18", + "source": "customer", + "collectedAmount": 5001.99, + "uncollectedAmount": 5002.99 + } + ] + }, + "foreignPropertyIncome": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "foreign-property", + "countryCode": "FRA", + "totalIncome": 5001.99, + "totalExpenses": 5002.99, + "netProfit": 5003.99, + "netLoss": 5004.99, + "totalAdditions": 5005.99, + "totalDeductions": 5006.99, + "taxableProfit": 5007.99, + "adjustedIncomeTaxLoss": 5008.99 + } + ], + "businessProfitAndLoss": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "incomeSourceName": "string", + "totalIncome": 5001.99, + "totalExpenses": -5002.99, + "netProfit": 5003.99, + "netLoss": 5004.99, + "totalAdditions": -5005.99, + "totalDeductions": 5006.99, + "accountingAdjustments": -5007.99, + "taxableProfit": 12501, + "adjustedIncomeTaxLoss": 12502, + "totalBroughtForwardIncomeTaxLosses": 12503, + "lossForCSFHL": 12504, + "broughtForwardIncomeTaxLossesUsed": 12505, + "taxableProfitAfterIncomeTaxLossesDeduction": 12506, + "carrySidewaysIncomeTaxLossesUsed": 12507, + "broughtForwardCarrySidewaysIncomeTaxLossesUsed": 12508, + "totalIncomeTaxLossesCarriedForward": 12509, + "class4Loss": 12510, + "totalBroughtForwardClass4Losses": 12511, + "broughtForwardClass4LossesUsed": 12512, + "carrySidewaysClass4LossesUsed": 12513, + "totalClass4LossesCarriedForward": 12514 + } + ], + "employmentAndPensionsIncome": { + "totalPayeEmploymentAndLumpSumIncome": 5000.99, + "totalOccupationalPensionIncome": 5000.99, + "totalBenefitsInKind": 5000.99, + "tipsIncome": 5000.99, + "employmentAndPensionsIncomeDetail": [ + { + "incomeSourceId": "string", + "source": "customer", + "occupationalPension": true, + "employerRef": "123/AA12345", + "employerName": "string", + "payrollId": "string", + "startDate": "2021-12-02", + "dateEmploymentEnded": "2021-12-02", + "taxablePayToDate": 5000.99, + "totalTaxToDate": -99999999999.99, + "disguisedRemuneration": true, + "lumpSums": { + "totalLumpSum": 5000.99, + "totalTaxPaid": 5000.99, + "lumpSumsDetail": { + "taxableLumpSumsAndCertainIncome": { + "amount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "benefitFromEmployerFinancedRetirementScheme": { + "amount": 5000.99, + "exemptAmount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "redundancyCompensationPaymentsOverExemption": { + "amount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "redundancyCompensationPaymentsUnderExemption": { + "amount": 5000.99 + } + } + }, + "studentLoans": { + "uglDeductionAmount": 5000.99, + "pglDeductionAmount": 5000.99 + }, + "benefitsInKind": { + "totalBenefitsInKindReceived": 5000.99, + "benefitsInKindDetail": { + "apportionedAccommodation": 5000.99, + "apportionedAssets": 5000.99, + "apportionedAssetTransfer": 5000.99, + "apportionedBeneficialLoan": 5000.99, + "apportionedCar": 5000.99, + "apportionedCarFuel": 5000.99, + "apportionedEducationalServices": 5000.99, + "apportionedEntertaining": 5000.99, + "apportionedExpenses": 5000.99, + "apportionedMedicalInsurance": 5000.99, + "apportionedTelephone": 5000.99, + "apportionedService": 5000.99, + "apportionedTaxableExpenses": 5000.99, + "apportionedVan": 5000.99, + "apportionedVanFuel": 5000.99, + "apportionedMileage": 5000.99, + "apportionedNonQualifyingRelocationExpenses": 5000.99, + "apportionedNurseryPlaces": 5000.99, + "apportionedOtherItems": 5000.99, + "apportionedPaymentsOnEmployeesBehalf": 5000.99, + "apportionedPersonalIncidentalExpenses": 5000.99, + "apportionedQualifyingRelocationExpenses": 5000.99, + "apportionedEmployerProvidedProfessionalSubscriptions": 5000.99, + "apportionedEmployerProvidedServices": 5000.99, + "apportionedIncomeTaxPaidByDirector": 5000.99, + "apportionedTravelAndSubsistence": 5000.99, + "apportionedVouchersAndCreditCards": 5000.99, + "apportionedNonCash": 5000.99 + } + } + } + ] + }, + "employmentExpenses": { + "totalEmploymentExpenses": 5000.99, + "employmentExpensesDetail": { + "businessTravelCosts": 5000.99, + "jobExpenses": 5000.99, + "flatRateJobExpenses": 5000.99, + "professionalSubscriptions": 5000.99, + "hotelAndMealExpenses": 5000.99, + "otherAndCapitalAllowances": 5000.99, + "vehicleExpenses": 5000.99, + "mileageAllowanceRelief": 5000.99 + } + }, + "seafarersDeductions": { + "totalSeafarersDeduction": 5000.99, + "seafarersDeductionDetail": [ + { + "nameOfShip": "string", + "amountDeducted": 5000.99 + } + ] + }, + "foreignTaxForFtcrNotClaimed": { + "foreignTaxOnForeignEmployment": 5000.99 + }, + "stateBenefitsIncome": { + "totalStateBenefitsIncome": 5000.99, + "totalStateBenefitsTaxPaid": -99999999999.99, + "stateBenefitsDetail": { + "incapacityBenefit": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": 5000.99, + "source": "customer" + } + ], + "statePension": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ], + "statePensionLumpSum": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "source": "customer" + } + ], + "employmentSupportAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": -99999999999.99, + "source": "customer" + } + ], + "jobSeekersAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": -99999999999.99, + "source": "customer" + } + ], + "bereavementAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ], + "otherStateBenefits": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ] + }, + "totalStateBenefitsIncomeExcStatePensionLumpSum": 5000.01 + }, + "shareSchemesIncome": { + "totalIncome": 5000.99, + "shareSchemeDetail": [ + { + "type": "shareOption", + "employerName": "string", + "employerRef": "123/AA12345", + "taxableAmount": 5000.99 + } + ] + }, + "foreignIncome": { + "chargeableOverseasPensionsStateBenefitsRoyalties": 5000.99, + "overseasPensionsStateBenefitsRoyaltiesDetail": [ + { + "countryCode": "FRA", + "grossIncome": 5000.99, + "netIncome": 5000.99, + "taxDeducted": 5000.99, + "foreignTaxCreditRelief": true + } + ], + "chargeableAllOtherIncomeReceivedWhilstAbroad": 5000.99, + "allOtherIncomeReceivedWhilstAbroadDetail": [ + { + "countryCode": "FRA", + "grossIncome": 5000.99, + "netIncome": 5000.99, + "taxDeducted": 5000.99, + "foreignTaxCreditRelief": true + } + ], + "overseasIncomeAndGains": { + "gainAmount": 5000.99 + }, + "totalForeignBenefitsAndGifts": 5000.99, + "chargeableForeignBenefitsAndGiftsDetail": { + "transactionBenefit": 5000.99, + "protectedForeignIncomeSourceBenefit": 5000.99, + "protectedForeignIncomeOnwardGift": 5000.99, + "benefitReceivedAsASettler": 5000.99, + "onwardGiftReceivedAsASettler": 5000.99 + } + }, + "chargeableEventGainsIncome": { + "totalOfAllGains": 12500, + "totalGainsWithTaxPaid": 12500, + "gainsWithTaxPaidDetail": [ + { + "type": "lifeInsurance", + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0, + "yearsHeldSinceLastGain": 0 + } + ], + "totalGainsWithNoTaxPaidAndVoidedIsa": 12500, + "gainsWithNoTaxPaidAndVoidedIsaDetail": [ + { + "type": "lifeInsurance", + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0, + "yearsHeldSinceLastGain": 0, + "voidedIsaTaxPaid": 5000.99 + } + ], + "totalForeignGainsOnLifePoliciesTaxPaid": 12500, + "foreignGainsOnLifePoliciesTaxPaidDetail": [ + { + "customerReference": "string", + "gainAmount": 5000.99, + "taxPaidAmount": 5000.99, + "yearsHeld": 0 + } + ], + "totalForeignGainsOnLifePoliciesNoTaxPaid": 12500, + "foreignGainsOnLifePoliciesNoTaxPaidDetail": [ + { + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0 + } + ] + }, + "savingsAndGainsIncome": { + "totalChargeableSavingsAndGains": 12500, + "totalUkSavingsAndGains": 12500, + "ukSavingsAndGainsIncome": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "uk-savings-and-gains", + "incomeSourceName": "My Savings Account 1", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99 + } + ], + "chargeableForeignSavingsAndGains": 12500, + "foreignSavingsAndGainsIncome": [ + { + "incomeSourceType": "foreign-savings-and-gains", + "countryCode": "GER", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ] + }, + "dividendsIncome": { + "totalChargeableDividends": 12500, + "totalUkDividends": 12500, + "ukDividends": { + "incomeSourceId": "000000000000210", + "incomeSourceType": "uk-dividends", + "dividends": 12501, + "otherUkDividends": 12502 + }, + "otherDividends": [ + { + "typeOfDividend": "stockDividend", + "customerReference": "string", + "grossAmount": 5000.99 + } + ], + "chargeableForeignDividends": 12500, + "foreignDividends": [ + { + "incomeSourceType": "foreign-dividends", + "countryCode": "ZZZ", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ], + "dividendIncomeReceivedWhilstAbroad": [ + { + "incomeSourceType": "foreign-dividends", + "countryCode": "ZZZ", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ] + }, + "incomeSummaryTotals": { + "totalSelfEmploymentProfit": 12500, + "totalPropertyProfit": 12500, + "totalFHLPropertyProfit": 12500, + "totalUKOtherPropertyProfit": 12500, + "totalForeignPropertyProfit": 12500, + "totalEeaFhlProfit": 12500, + "totalEmploymentIncome": 12500 + }, + "taxCalculation": { + "incomeTax": { + "totalIncomeReceivedFromAllSources": 12500, + "totalAllowancesAndDeductions": 12500, + "totalTaxableIncome": 12500, + "payPensionsProfit": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "savingsAndGains": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "dividends": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "lumpSums": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "gainsOnLifePolicies": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "incomeTaxCharged": 5000.99, + "totalReliefs": 5000.99, + "incomeTaxDueAfterReliefs": -99999999999.99, + "totalNotionalTax": 5000.99, + "marriageAllowanceRelief": 5000.99, + "incomeTaxDueAfterTaxReductions": 5000.99, + "incomeTaxDueAfterGiftAid": 5000.99, + "totalPensionSavingsTaxCharges": 5000.99, + "statePensionLumpSumCharges": 5000.99, + "payeUnderpaymentsCodedOut": 5000.99, + "totalIncomeTaxDue": 5000.99 + }, + "nics": { + "class2Nics": { + "amount": 5000.99, + "weeklyRate": 5000.99, + "weeks": 0, + "limit": 12500, + "apportionedLimit": 12500, + "underSmallProfitThreshold": true, + "actualClass2Nic": true + }, + "class4Nics": { + "totalIncomeLiableToClass4Charge": 12500, + "totalClass4LossesAvailable": 12500, + "totalClass4LossesUsed": 12500, + "totalClass4LossesCarriedForward": 12500, + "totalIncomeChargeableToClass4": 12500, + "totalAmount": 5000.99, + "nic4Bands": [ + { + "name": "zero-rate", + "rate": 20.01, + "threshold": 12501, + "apportionedThreshold": 12502, + "income": 12503, + "amount": 5000.99 + } + ] + }, + "nic2NetOfDeductions": -99999999999.99, + "nic4NetOfDeductions": -99999999999.99, + "totalNic": -99999999999.99 + }, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalAnnuityPaymentsTaxCharged": 12500, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalIncomeTaxNicsCharged": -99999999999.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalTaxDeducted": -99999999999.99, + "totalIncomeTaxAndNicsDue": -99999999999.99, + "capitalGainsTax": { + "totalCapitalGainsIncome": 5000.99, + "annualExemptionAmount": 5000.99, + "totalTaxableGains": 5000.99, + "businessAssetsDisposalsAndInvestorsRel": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "rate": 20.01, + "taxAmount": 5000.99 + }, + "residentialPropertyAndCarriedInterest": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lower-rate", + "rate": 20.01, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "otherGains": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "attributedGains": 5000.99, + "netGains": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lower-rate", + "rate": 20.01, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "capitalGainsTaxAmount": 5000.99, + "adjustments": -99999999999.99, + "adjustedCapitalGainsTax": 5000.99, + "foreignTaxCreditRelief": 5000.99, + "capitalGainsTaxAfterFTCR": 5000.99, + "taxOnGainsAlreadyPaid": 5000.99, + "capitalGainsTaxDue": 5000.99, + "capitalGainsOverpaid": 5000.99 + }, + "totalIncomeTaxAndNicsAndCgt": 5000.99 + }, + "previousCalculation": { + "calculationTimestamp": "2021-12-02T15:25:48Z", + "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", + "totalIncomeTaxAndNicsDue": -99999999999.99, + "cgtTaxDue": 5000.99, + "totalIncomeTaxAndNicsAndCgtDue": 5000.99, + "incomeTaxNicDueThisPeriod": -99999999999.99, + "cgtDueThisPeriod": -99999999999.99, + "totalIncomeTaxAndNicsAndCgtDueThisPeriod": 5000.99 + }, + "endOfYearEstimate": { + "incomeSource": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "incomeSourceName": "string", + "taxableIncome": 12500, + "finalised": true + } + ], + "totalEstimatedIncome": 12500, + "totalTaxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "nic2": 5000.99, + "nic4": 5000.99, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalNicAmount": 5000.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalAnnuityPaymentsTaxCharged": 5000.99, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalTaxDeducted": -99999999999.99, + "incomeTaxNicAmount": -99999999999.99, + "cgtAmount": 5000.99, + "incomeTaxNicAndCgtAmount": 5000.99 + }, + "lossesAndClaims": { + "resultOfClaimsApplied": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "taxYearClaimMade": "2016-17", + "claimType": "carry-forward", + "mtdLoss": false, + "taxYearLossIncurred": "2017-18", + "lossAmountUsed": 12501, + "remainingLossValue": 12502, + "lossType": "income" + } + ], + "unclaimedLosses": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "taxYearLossIncurred": "2017-18", + "currentLossValue": 12500, + "lossType": "income" + } + ], + "carriedForwardLosses": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "claimType": "carry-forward", + "taxYearClaimMade": "2016-17", + "taxYearLossIncurred": "2017-18", + "currentLossValue": 12500, + "lossType": "income" + } + ], + "defaultCarriedForwardLosses": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "taxYearLossIncurred": "2017-18", + "currentLossValue": 12500 + } + ], + "claimsNotApplied": [ + { + "claimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "taxYearClaimMade": "2017-18", + "claimType": "carry-forward" + } + ] + } + }, + "messages": { + "info": [ + { + "id": "string", + "text": "string" + } + ], + "warnings": [ + { + "id": "string", + "text": "string" + } + ], + "errors": [ + { + "id": "string", + "text": "string" + } + ] + } +} \ No newline at end of file diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_downstream.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_downstream.json new file mode 100644 index 000000000..2358d1ef1 --- /dev/null +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_downstream.json @@ -0,0 +1,198 @@ +{ + "incomeTax": { + "totalIncomeReceivedFromAllSources": 12500, + "totalAllowancesAndDeductions": 12500, + "totalTaxableIncome": 12500, + "payPensionsProfit": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "savingsAndGains": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "dividends": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "lumpSums": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "gainsOnLifePolicies": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "incomeTaxCharged": 5000.99, + "totalReliefs": 5000.99, + "incomeTaxDueAfterReliefs": -99999999999.99, + "totalNotionalTax": 5000.99, + "marriageAllowanceRelief": 5000.99, + "incomeTaxDueAfterTaxReductions": 5000.99, + "incomeTaxDueAfterGiftAid": 5000.99, + "totalPensionSavingsTaxCharges": 5000.99, + "statePensionLumpSumCharges": 5000.99, + "payeUnderpaymentsCodedOut": 5000.99, + "totalIncomeTaxDue": 5000.99 + }, + "nics": { + "class2Nics": { + "amount": 5000.99, + "weeklyRate": 5000.99, + "weeks": 0, + "limit": 12500, + "apportionedLimit": 12500, + "underSmallProfitThreshold": true, + "actualClass2Nic": true + }, + "class4Nics": { + "totalIncomeLiableToClass4Charge": 12500, + "totalClass4LossesAvailable": 12500, + "totalClass4LossesUsed": 12500, + "totalClass4LossesCarriedForward": 12500, + "totalIncomeChargeableToClass4": 12500, + "totalAmount": 5000.99, + "nic4Bands": [ + { + "name": "ZRT", + "rate": 20, + "threshold": 12500, + "apportionedThreshold": 12500, + "income": 12500, + "amount": 5000.99 + } + ] + }, + "nic2NetOfDeductions": -99999999999.99, + "nic4NetOfDeductions": -99999999999.99, + "totalNic": -99999999999.99 + }, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalAnnuityPaymentsTaxCharged": 12500, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalIncomeTaxNicsCharged": -99999999999.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalTaxDeducted": -99999999999.99, + "totalIncomeTaxAndNicsDue": -99999999999.99, + "capitalGainsTax": { + "totalCapitalGainsIncome": 5000.99, + "annualExemptionAmount": 5000.99, + "totalTaxableGains": 5000.99, + "businessAssetsDisposalsAndInvestorsRel": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "rate": 20, + "taxAmount": 5000.99 + }, + "residentialPropertyAndCarriedInterest": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lowerRate", + "rate": 20, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "otherGains": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "attributedGains": 5000.99, + "netGains": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lowerRate", + "rate": 20, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "capitalGainsTaxAmount": 5000.99, + "adjustments": -99999999999.99, + "adjustedCapitalGainsTax": 5000.99, + "foreignTaxCreditRelief": 5000.99, + "capitalGainsTaxAfterFTCR": 5000.99, + "taxOnGainsAlreadyPaid": 5000.99, + "capitalGainsTaxDue": 5000.99, + "capitalGainsOverpaid": 5000.99 + }, + "totalIncomeTaxAndNicsAndCgt": 5000.99 +} \ No newline at end of file diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_mtd.json new file mode 100644 index 000000000..3b3ceb8b8 --- /dev/null +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_mtd.json @@ -0,0 +1,198 @@ +{ + "incomeTax": { + "totalIncomeReceivedFromAllSources": 12500, + "totalAllowancesAndDeductions": 12500, + "totalTaxableIncome": 12500, + "payPensionsProfit": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "savingsAndGains": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "dividends": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "lumpSums": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "gainsOnLifePolicies": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "income": 12500, + "taxAmount": 5000.99 + } + ] + }, + "incomeTaxCharged": 5000.99, + "totalReliefs": 5000.99, + "incomeTaxDueAfterReliefs": -99999999999.99, + "totalNotionalTax": 5000.99, + "marriageAllowanceRelief": 5000.99, + "incomeTaxDueAfterTaxReductions": 5000.99, + "incomeTaxDueAfterGiftAid": 5000.99, + "totalPensionSavingsTaxCharges": 5000.99, + "statePensionLumpSumCharges": 5000.99, + "payeUnderpaymentsCodedOut": 5000.99, + "totalIncomeTaxDue": 5000.99 + }, + "nics": { + "class2Nics": { + "amount": 5000.99, + "weeklyRate": 5000.99, + "weeks": 0, + "limit": 12500, + "apportionedLimit": 12500, + "underSmallProfitThreshold": true, + "actualClass2Nic": true + }, + "class4Nics": { + "totalIncomeLiableToClass4Charge": 12500, + "totalClass4LossesAvailable": 12500, + "totalClass4LossesUsed": 12500, + "totalClass4LossesCarriedForward": 12500, + "totalIncomeChargeableToClass4": 12500, + "totalAmount": 5000.99, + "nic4Bands": [ + { + "name": "zero-rate", + "rate": 20, + "threshold": 12500, + "apportionedThreshold": 12500, + "income": 12500, + "amount": 5000.99 + } + ] + }, + "nic2NetOfDeductions": -99999999999.99, + "nic4NetOfDeductions": -99999999999.99, + "totalNic": -99999999999.99 + }, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalAnnuityPaymentsTaxCharged": 12500, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalIncomeTaxNicsCharged": -99999999999.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalTaxDeducted": -99999999999.99, + "totalIncomeTaxAndNicsDue": -99999999999.99, + "capitalGainsTax": { + "totalCapitalGainsIncome": 5000.99, + "annualExemptionAmount": 5000.99, + "totalTaxableGains": 5000.99, + "businessAssetsDisposalsAndInvestorsRel": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "rate": 20, + "taxAmount": 5000.99 + }, + "residentialPropertyAndCarriedInterest": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lower-rate", + "rate": 20, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "otherGains": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "attributedGains": 5000.99, + "netGains": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lower-rate", + "rate": 20, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "capitalGainsTaxAmount": 5000.99, + "adjustments": -99999999999.99, + "adjustedCapitalGainsTax": 5000.99, + "foreignTaxCreditRelief": 5000.99, + "capitalGainsTaxAfterFTCR": 5000.99, + "taxOnGainsAlreadyPaid": 5000.99, + "capitalGainsTaxDue": 5000.99, + "capitalGainsOverpaid": 5000.99 + }, + "totalIncomeTaxAndNicsAndCgt": 5000.99 +} \ No newline at end of file diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json new file mode 100644 index 000000000..b7f1d20ae --- /dev/null +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json @@ -0,0 +1,1093 @@ +{ + "metadata": { + "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", + "taxYear": 2018, + "requestedBy": "customer", + "requestedTimestamp": "2019-02-15T09:35:15.000Z", + "calculationReason": "customerRequest", + "calculationTimestamp": "2019-02-15T09:35:15.094Z", + "calculationType": "crystallisation", + "intentToCrystallise": true, + "crystallised": true, + "crystallisationTimestamp": "2019-02-15T09:35:15.094Z", + "periodFrom": "2018-04-06", + "periodTo": "2019-04-05" + }, + "inputs": { + "personalInformation": { + "identifier": "VO123456A", + "dateOfBirth": "2018-04-06", + "taxRegime": "UK", + "statePensionAgeDate": "2050-04-06", + "studentLoanPlan": [ + { + "planType": "01" + } + ], + "class2VoluntaryContributions": true, + "marriageAllowance": "transferor", + "uniqueTaxpayerReference": "1234567890" + }, + "incomeSources": { + "businessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "incomeSourceName": "string", + "accountingPeriodStartDate": "2018-04-06", + "accountingPeriodEndDate": "2019-04-05", + "source": "MTD-SA", + "latestPeriodEndDate": "2021-12-02", + "latestReceivedDateTime": "2021-12-02T15:25:48Z", + "finalised": true, + "finalisationTimestamp": "2019-02-15T09:35:15.094Z", + "submissionPeriods": [ + { + "periodId": "001", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "receivedDateTime": "2019-02-15T09:35:04.843Z" + } + ] + } + ], + "nonBusinessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "09", + "incomeSourceName": "Savings Account 1", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "source": "MTD-SA", + "periodId": "001", + "latestReceivedDateTime": "2019-08-01T13:02:09.775Z" + } + ] + }, + "annualAdjustments": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "ascId": "123a456b-789c-1d23-845e-678b9d1bd2ab", + "receivedDateTime": "2021-12-02T15:25:48Z", + "applied": true + } + ], + "lossesBroughtForward": [ + { + "lossId": "0yriP9QrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "lossType": "income", + "taxYearLossIncurred": 2018, + "currentLossValue": 12500, + "mtdLoss": false + } + ], + "claims": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "taxYearClaimMade": 2018, + "claimType": "CF", + "sequence": 0 + } + ], + "cis": [ + { + "employerRef": "123/AA12345", + "contractorName": "string", + "periodData": [ + { + "deductionFromDate": "2021-12-02", + "deductionToDate": "2021-12-02", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "source": "contractor", + "deductionAmount": 5000.99 + } + ] + } + ], + "allowancesReliefsAndDeductions": [ + { + "type": "investmentReliefs", + "submittedTimestamp": "2021-12-02T15:25:48Z", + "startDate": "2021-12-02", + "endDate": "2021-12-02", + "source": "MTD-SA" + } + ], + "pensionContributionAndCharges": [ + { + "type": "pensionReliefs", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "startDate": "2021-12-02", + "endDate": "2021-12-02", + "source": "customer" + } + ], + "other": [ + { + "type": "codingOut", + "submittedOn": "2021-12-02T15:25:48Z" + } + ] + }, + "calculation": { + "allowancesAndDeductions": { + "personalAllowance": 12500, + "marriageAllowanceTransferOut": { + "personalAllowanceBeforeTransferOut": 5000.99, + "transferredOutAmount": 5000.99 + }, + "reducedPersonalAllowance": 12501, + "giftOfInvestmentsAndPropertyToCharity": 12502, + "blindPersonsAllowance": 12503, + "lossesAppliedToGeneralIncome": 12504, + "cgtLossSetAgainstInYearGeneralIncome": 12505, + "qualifyingLoanInterestFromInvestments": 5001.99, + "post-cessationTradeReceipts": 5002.99, + "paymentsToTradeUnionsForDeathBenefits": 5003.99, + "grossAnnuityPayments": 5004.99, + "annuityPayments": { + "reliefClaimed": 5000.99, + "rate": 20.01 + }, + "pensionContributions": 5000.99, + "pensionContributionsDetail": { + "retirementAnnuityPayments": 5000.99, + "paymentToEmployersSchemeNoTaxRelief": 5000.99, + "overseasPensionSchemeContributions": 5000.99 + } + }, + "reliefs": { + "residentialFinanceCosts": { + "adjustedTotalIncome": 5000.99, + "totalAllowableAmount": 5000.99, + "relievableAmount": 5000.99, + "rate": 20.01, + "totalResidentialFinanceCostsRelief": 5000.99, + "ukProperty": { + "amountClaimed": 12500, + "allowableAmount": 5000.99, + "carryForwardAmount": 5000.99 + }, + "foreignProperty": { + "totalForeignPropertyAllowableAmount": 5000.99, + "foreignPropertyRfcDetail": [ + { + "countryCode": "FRA", + "amountClaimed": 12500, + "allowableAmount": 5000.99, + "carryForwardAmount": 5000.99 + } + ] + }, + "allOtherIncomeReceivedWhilstAbroad": { + "totalOtherIncomeAllowableAmount": 5000.99, + "otherIncomeRfcDetail": [ + { + "countryCode": "FRA", + "residentialFinancialCostAmount": 5000.99, + "broughtFwdResidentialFinancialCostAmount": 5000.99 + } + ] + } + }, + "reliefsClaimed": [ + { + "type": "vctSubscriptions", + "amountClaimed": 5000.99, + "allowableAmount": 5000.99, + "amountUsed": 5000.99, + "rate": 20.01, + "reliefsClaimedDetail": [ + { + "amountClaimed": 5000.99, + "uniqueInvestmentRef": "string", + "name": "string", + "socialEnterpriseName": "string", + "companyName": "string", + "deficiencyReliefType": "lifeInsurance", + "customerReference": "string" + } + ] + } + ], + "foreignTaxCreditRelief": { + "customerCalculatedRelief": true, + "totalForeignTaxCreditRelief": 5000.99, + "foreignTaxCreditReliefOnProperty": 5000.99, + "foreignTaxCreditReliefOnDividends": 5000.99, + "foreignTaxCreditReliefOnSavings": 5000.99, + "foreignTaxCreditReliefOnForeignIncome": 5000.99, + "foreignTaxCreditReliefDetail": [ + { + "incomeSourceType": "15", + "incomeSourceId": "000000000000210", + "countryCode": "FRA", + "foreignIncome": 5001.99, + "foreignTax": 5002.99, + "dtaRate": 20, + "dtaAmount": 5003.99, + "ukLiabilityOnIncome": 5004.99, + "foreignTaxCredit": 5005.99, + "employmentLumpSum": true + } + ] + }, + "topSlicingRelief": { + "amount": 5000.99 + } + }, + "taxDeductedAtSource": { + "bbsi": 5000.99, + "ukLandAndProperty": 5000.99, + "cis": 5000.99, + "securities": 5000.99, + "voidedIsa": 5000.99, + "payeEmployments": 5000.99, + "occupationalPensions": 5000.99, + "stateBenefits": -99999999999.99, + "specialWithholdingTaxOrUkTaxPaid": 5000.99, + "inYearAdjustmentCodedInLaterTaxYear": 5000.99 + }, + "giftAid": { + "grossGiftAidPayments": 12500, + "rate": 20.01, + "giftAidTax": 5000.99, + "giftAidTaxReductions": 5000.99, + "incomeTaxChargedAfterGiftAidTaxReductions": 5000.99, + "giftAidCharge": 5000.99 + }, + "royaltyPayments": { + "royaltyPaymentsAmount": 12500, + "rate": 20.01, + "grossRoyaltyPayments": 12500 + }, + "notionalTax": { + "chargeableGains": 5000.99 + }, + "marriageAllowanceTransferredIn": { + "amount": 5000.99, + "rate": 20.01 + }, + "pensionContributionReliefs": { + "totalPensionContributionReliefs": 5000.99, + "pensionContributionDetail": { + "regularPensionContributions": 5000.99, + "oneOffPensionContributionsPaid": 5000.99 + } + }, + "pensionSavingsTaxCharges": { + "totalPensionCharges": 5000.99, + "totalTaxPaid": 5000.99, + "totalPensionChargesDue": 5000.99, + "pensionSavingsTaxChargesDetail": { + "pensionSchemeUnauthorisedPayments": { + "totalChargeableAmount": 5000.99, + "totalTaxPaid": 5000.99, + "pensionSchemeUnauthorisedPaymentsSurcharge": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "pensionSchemeUnauthorisedPaymentsNonSurcharge": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + } + }, + "pensionSchemeOverseasTransfers": { + "transferCharge": 5000.99, + "transferChargeTaxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "pensionContributionsInExcessOfTheAnnualAllowance": { + "totalContributions": 5000.99, + "totalPensionCharge": 5000.99, + "annualAllowanceTaxPaid": 5000.99, + "totalPensionChargeDue": 5000.99, + "pensionBands": [ + { + "name": "BRT", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "contributionAmount": 5001.99, + "pensionCharge": 5002.99 + } + ] + }, + "overseasPensionContributions": { + "totalShortServiceRefund": 5000.99, + "totalShortServiceRefundCharge": 5000.99, + "shortServiceRefundTaxPaid": 5000.99, + "totalShortServiceRefundChargeDue": 5000.99, + "shortServiceRefundBands": [ + { + "name": "lowerBand", + "rate": 20.01, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "shortServiceRefundAmount": 5000.99, + "shortServiceRefundCharge": 5000.99 + } + ] + } + } + }, + "studentLoans": [ + { + "planType": "01", + "studentLoanTotalIncomeAmount": 5001.99, + "studentLoanChargeableIncomeAmount": 5002.99, + "studentLoanRepaymentAmount": 5003.99, + "studentLoanDeductionsFromEmployment": 5004.99, + "studentLoanRepaymentAmountNetOfDeductions": 5005.99, + "studentLoanApportionedIncomeThreshold": 12500, + "studentLoanRate": 20.01, + "payeIncomeForStudentLoan": 5006.99, + "nonPayeIncomeForStudentLoan": 5007.99 + } + ], + "codedOutUnderpayments": { + "totalPayeUnderpayments": 5000.99, + "payeUnderpaymentsDetail": [ + { + "amount": 5000.99, + "relatedTaxYear": "2017-18", + "source": "customer" + } + ], + "totalSelfAssessmentUnderpayments": 5000.99, + "totalCollectedSelfAssessmentUnderpayments": 5000.99, + "totalUncollectedSelfAssessmentUnderpayments": 5000.99, + "selfAssessmentUnderpaymentsDetail": [ + { + "amount": 5000.99, + "relatedTaxYear": "2017-18", + "saAccountingSystem": "ETMP", + "source": "customer", + "collectedAmount": 5001.99, + "uncollectedAmount": 5002.99 + } + ] + }, + "foreignPropertyIncome": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "15", + "countryCode": "FRA", + "totalIncome": 5001.99, + "totalExpenses": 5002.99, + "netProfit": 5003.99, + "netLoss": 5004.99, + "totalAdditions": 5005.99, + "totalDeductions": 5006.99, + "taxableProfit": 5007.99, + "adjustedIncomeTaxLoss": 5008.99 + } + ], + "businessProfitAndLoss": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "incomeSourceName": "string", + "totalIncome": 5001.99, + "totalExpenses": -5002.99, + "netProfit": 5003.99, + "netLoss": 5004.99, + "totalAdditions": -5005.99, + "totalDeductions": 5006.99, + "accountingAdjustments": -5007.99, + "taxableProfit": 12501, + "adjustedIncomeTaxLoss": 12502, + "totalBroughtForwardIncomeTaxLosses": 12503, + "lossForCSFHL": 12504, + "broughtForwardIncomeTaxLossesUsed": 12505, + "taxableProfitAfterIncomeTaxLossesDeduction": 12506, + "carrySidewaysIncomeTaxLossesUsed": 12507, + "broughtForwardCarrySidewaysIncomeTaxLossesUsed": 12508, + "totalIncomeTaxLossesCarriedForward": 12509, + "class4Loss": 12510, + "totalBroughtForwardClass4Losses": 12511, + "broughtForwardClass4LossesUsed": 12512, + "carrySidewaysClass4LossesUsed": 12513, + "totalClass4LossesCarriedForward": 12514 + } + ], + "employmentAndPensionsIncome": { + "totalPayeEmploymentAndLumpSumIncome": 5000.99, + "totalOccupationalPensionIncome": 5000.99, + "totalBenefitsInKind": 5000.99, + "tipsIncome": 5000.99, + "employmentAndPensionsIncomeDetail": [ + { + "incomeSourceId": "string", + "source": "customer", + "occupationalPension": true, + "employerRef": "123/AA12345", + "employerName": "string", + "payrollId": "string", + "startDate": "2021-12-02", + "dateEmploymentEnded": "2021-12-02", + "taxablePayToDate": 5000.99, + "totalTaxToDate": -99999999999.99, + "disguisedRemuneration": true, + "lumpSums": { + "totalLumpSum": 5000.99, + "totalTaxPaid": 5000.99, + "lumpSumsDetail": { + "taxableLumpSumsAndCertainIncome": { + "amount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "benefitFromEmployerFinancedRetirementScheme": { + "amount": 5000.99, + "exemptAmount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "redundancyCompensationPaymentsOverExemption": { + "amount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "redundancyCompensationPaymentsUnderExemption": { + "amount": 5000.99 + } + } + }, + "studentLoans": { + "uglDeductionAmount": 5000.99, + "pglDeductionAmount": 5000.99 + }, + "benefitsInKind": { + "totalBenefitsInKindReceived": 5000.99, + "benefitsInKindDetail": { + "apportionedAccommodation": 5000.99, + "apportionedAssets": 5000.99, + "apportionedAssetTransfer": 5000.99, + "apportionedBeneficialLoan": 5000.99, + "apportionedCar": 5000.99, + "apportionedCarFuel": 5000.99, + "apportionedEducationalServices": 5000.99, + "apportionedEntertaining": 5000.99, + "apportionedExpenses": 5000.99, + "apportionedMedicalInsurance": 5000.99, + "apportionedTelephone": 5000.99, + "apportionedService": 5000.99, + "apportionedTaxableExpenses": 5000.99, + "apportionedVan": 5000.99, + "apportionedVanFuel": 5000.99, + "apportionedMileage": 5000.99, + "apportionedNonQualifyingRelocationExpenses": 5000.99, + "apportionedNurseryPlaces": 5000.99, + "apportionedOtherItems": 5000.99, + "apportionedPaymentsOnEmployeesBehalf": 5000.99, + "apportionedPersonalIncidentalExpenses": 5000.99, + "apportionedQualifyingRelocationExpenses": 5000.99, + "apportionedEmployerProvidedProfessionalSubscriptions": 5000.99, + "apportionedEmployerProvidedServices": 5000.99, + "apportionedIncomeTaxPaidByDirector": 5000.99, + "apportionedTravelAndSubsistence": 5000.99, + "apportionedVouchersAndCreditCards": 5000.99, + "apportionedNonCash": 5000.99 + } + } + } + ] + }, + "employmentExpenses": { + "totalEmploymentExpenses": 5000.99, + "employmentExpensesDetail": { + "businessTravelCosts": 5000.99, + "jobExpenses": 5000.99, + "flatRateJobExpenses": 5000.99, + "professionalSubscriptions": 5000.99, + "hotelAndMealExpenses": 5000.99, + "otherAndCapitalAllowances": 5000.99, + "vehicleExpenses": 5000.99, + "mileageAllowanceRelief": 5000.99 + } + }, + "seafarersDeductions": { + "totalSeafarersDeduction": 5000.99, + "seafarersDeductionDetail": [ + { + "nameOfShip": "string", + "amountDeducted": 5000.99 + } + ] + }, + "foreignTaxForFtcrNotClaimed": { + "foreignTaxOnForeignEmployment": 5000.99 + }, + "stateBenefitsIncome": { + "totalStateBenefitsIncome": 5000.99, + "totalStateBenefitsTaxPaid": -99999999999.99, + "stateBenefitsDetail": { + "incapacityBenefit": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": 5000.99, + "source": "customer" + } + ], + "statePension": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ], + "statePensionLumpSum": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "source": "customer" + } + ], + "employmentSupportAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": -99999999999.99, + "source": "customer" + } + ], + "jobSeekersAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": -99999999999.99, + "source": "customer" + } + ], + "bereavementAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ], + "otherStateBenefits": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ] + }, + "totalStateBenefitsIncomeExcStatePensionLumpSum": 5000.01 + }, + "shareSchemesIncome": { + "totalIncome": 5000.99, + "shareSchemeDetail": [ + { + "type": "shareOption", + "employerName": "string", + "employerRef": "123/AA12345", + "taxableAmount": 5000.99 + } + ] + }, + "foreignIncome": { + "chargeableOverseasPensionsStateBenefitsRoyalties": 5000.99, + "overseasPensionsStateBenefitsRoyaltiesDetail": [ + { + "countryCode": "FRA", + "grossIncome": 5000.99, + "netIncome": 5000.99, + "taxDeducted": 5000.99, + "foreignTaxCreditRelief": true + } + ], + "chargeableAllOtherIncomeReceivedWhilstAbroad": 5000.99, + "allOtherIncomeReceivedWhilstAbroadDetail": [ + { + "countryCode": "FRA", + "grossIncome": 5000.99, + "netIncome": 5000.99, + "taxDeducted": 5000.99, + "foreignTaxCreditRelief": true + } + ], + "overseasIncomeAndGains": { + "gainAmount": 5000.99 + }, + "totalForeignBenefitsAndGifts": 5000.99, + "chargeableForeignBenefitsAndGiftsDetail": { + "transactionBenefit": 5000.99, + "protectedForeignIncomeSourceBenefit": 5000.99, + "protectedForeignIncomeOnwardGift": 5000.99, + "benefitReceivedAsASettler": 5000.99, + "onwardGiftReceivedAsASettler": 5000.99 + } + }, + "chargeableEventGainsIncome": { + "totalOfAllGains": 12500, + "totalGainsWithTaxPaid": 12500, + "gainsWithTaxPaidDetail": [ + { + "type": "lifeInsurance", + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0, + "yearsHeldSinceLastGain": 0 + } + ], + "totalGainsWithNoTaxPaidAndVoidedIsa": 12500, + "gainsWithNoTaxPaidAndVoidedIsaDetail": [ + { + "type": "lifeInsurance", + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0, + "yearsHeldSinceLastGain": 0, + "voidedIsaTaxPaid": 5000.99 + } + ], + "totalForeignGainsOnLifePoliciesTaxPaid": 12500, + "foreignGainsOnLifePoliciesTaxPaidDetail": [ + { + "customerReference": "string", + "gainAmount": 5000.99, + "taxPaidAmount": 5000.99, + "yearsHeld": 0 + } + ], + "totalForeignGainsOnLifePoliciesNoTaxPaid": 12500, + "foreignGainsOnLifePoliciesNoTaxPaidDetail": [ + { + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0 + } + ] + }, + "savingsAndGainsIncome": { + "totalChargeableSavingsAndGains": 12500, + "totalUkSavingsAndGains": 12500, + "ukSavingsAndGainsIncome": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "09", + "incomeSourceName": "My Savings Account 1", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99 + } + ], + "chargeableForeignSavingsAndGains": 12500, + "foreignSavingsAndGainsIncome": [ + { + "incomeSourceType": "16", + "countryCode": "GER", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ] + }, + "dividendsIncome": { + "totalChargeableDividends": 12500, + "totalUkDividends": 12500, + "ukDividends": { + "incomeSourceId": "000000000000210", + "incomeSourceType": "10", + "dividends": 12501, + "otherUkDividends": 12502 + }, + "otherDividends": [ + { + "typeOfDividend": "stockDividend", + "customerReference": "string", + "grossAmount": 5000.99 + } + ], + "chargeableForeignDividends": 12500, + "foreignDividends": [ + { + "incomeSourceType": "07", + "countryCode": "ZZZ", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ], + "dividendIncomeReceivedWhilstAbroad": [ + { + "incomeSourceType": "07", + "countryCode": "ZZZ", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ] + }, + "incomeSummaryTotals": { + "totalSelfEmploymentProfit": 12500, + "totalPropertyProfit": 12500, + "totalFHLPropertyProfit": 12500, + "totalUKOtherPropertyProfit": 12500, + "totalForeignPropertyProfit": 12500, + "totalEeaFhlProfit": 12500, + "totalEmploymentIncome": 12500 + }, + "taxCalculation": { + "incomeTax": { + "totalIncomeReceivedFromAllSources": 12500, + "totalAllowancesAndDeductions": 12500, + "totalTaxableIncome": 12500, + "payPensionsProfit": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "savingsAndGains": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "dividends": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "lumpSums": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "gainsOnLifePolicies": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "SSR", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "incomeTaxCharged": 5000.99, + "totalReliefs": 5000.99, + "incomeTaxDueAfterReliefs": -99999999999.99, + "totalNotionalTax": 5000.99, + "marriageAllowanceRelief": 5000.99, + "incomeTaxDueAfterTaxReductions": 5000.99, + "incomeTaxDueAfterGiftAid": 5000.99, + "totalPensionSavingsTaxCharges": 5000.99, + "statePensionLumpSumCharges": 5000.99, + "payeUnderpaymentsCodedOut": 5000.99, + "totalIncomeTaxDue": 5000.99 + }, + "nics": { + "class2Nics": { + "amount": 5000.99, + "weeklyRate": 5000.99, + "weeks": 0, + "limit": 12500, + "apportionedLimit": 12500, + "underSmallProfitThreshold": true, + "actualClass2Nic": true + }, + "class4Nics": { + "totalIncomeLiableToClass4Charge": 12500, + "totalClass4LossesAvailable": 12500, + "totalClass4LossesUsed": 12500, + "totalClass4LossesCarriedForward": 12500, + "totalIncomeChargeableToClass4": 12500, + "totalAmount": 5000.99, + "nic4Bands": [ + { + "name": "ZRT", + "rate": 20.01, + "threshold": 12501, + "apportionedThreshold": 12502, + "income": 12503, + "amount": 5000.99 + } + ] + }, + "nic2NetOfDeductions": -99999999999.99, + "nic4NetOfDeductions": -99999999999.99, + "totalNic": -99999999999.99 + }, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalAnnuityPaymentsTaxCharged": 12500, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalIncomeTaxNicsCharged": -99999999999.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalTaxDeducted": -99999999999.99, + "totalIncomeTaxAndNicsDue": -99999999999.99, + "capitalGainsTax": { + "totalCapitalGainsIncome": 5000.99, + "annualExemptionAmount": 5000.99, + "totalTaxableGains": 5000.99, + "businessAssetsDisposalsAndInvestorsRel": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "rate": 20.01, + "taxAmount": 5000.99 + }, + "residentialPropertyAndCarriedInterest": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lowerRate", + "rate": 20.01, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "otherGains": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "attributedGains": 5000.99, + "netGains": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lowerRate", + "rate": 20.01, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "capitalGainsTaxAmount": 5000.99, + "adjustments": -99999999999.99, + "adjustedCapitalGainsTax": 5000.99, + "foreignTaxCreditRelief": 5000.99, + "capitalGainsTaxAfterFTCR": 5000.99, + "taxOnGainsAlreadyPaid": 5000.99, + "capitalGainsTaxDue": 5000.99, + "capitalGainsOverpaid": 5000.99 + }, + "totalIncomeTaxAndNicsAndCgt": 5000.99 + }, + "previousCalculation": { + "calculationTimestamp": "2021-12-02T15:25:48Z", + "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", + "totalIncomeTaxAndNicsDue": -99999999999.99, + "cgtTaxDue": 5000.99, + "totalIncomeTaxAndNicsAndCgtDue": 5000.99, + "incomeTaxNicDueThisPeriod": -99999999999.99, + "cgtDueThisPeriod": -99999999999.99, + "totalIncomeTaxAndNicsAndCgtDueThisPeriod": 5000.99 + }, + "endOfYearEstimate": { + "incomeSource": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "incomeSourceName": "string", + "taxableIncome": 12500, + "finalised": true + } + ], + "totalEstimatedIncome": 12500, + "totalTaxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "nic2": 5000.99, + "nic4": 5000.99, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalNicAmount": 5000.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalAnnuityPaymentsTaxCharged": 5000.99, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalTaxDeducted": -99999999999.99, + "incomeTaxNicAmount": -99999999999.99, + "cgtAmount": 5000.99, + "incomeTaxNicAndCgtAmount": 5000.99 + }, + "lossesAndClaims": { + "resultOfClaimsApplied": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "taxYearClaimMade": 2017, + "claimType": "CF", + "mtdLoss": false, + "taxYearLossIncurred": 2018, + "lossAmountUsed": 12501, + "remainingLossValue": 12502, + "lossType": "income" + } + ], + "unclaimedLosses": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "taxYearLossIncurred": 2018, + "currentLossValue": 12500, + "lossType": "income" + } + ], + "carriedForwardLosses": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "claimType": "CF", + "taxYearClaimMade": 2017, + "taxYearLossIncurred": 2018, + "currentLossValue": 12500, + "lossType": "income" + } + ], + "defaultCarriedForwardLosses": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "taxYearLossIncurred": 2018, + "currentLossValue": 12500 + } + ], + "claimsNotApplied": [ + { + "claimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "01", + "taxYearClaimMade": 2018, + "claimType": "CF" + } + ] + }, + "transitionProfit": { + "totalTaxableTransitionProfit": 5000, + "transitionProfitDetail": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceName": "string", + "transitionProfitAmount": 5000.99, + "transitionProfitAccelerationAmount": 5000.99, + "totalTransitionProfit": 5000, + "remainingBroughtForwardIncomeTaxLosses": 5000, + "broughtForwardIncomeTaxLossesUsed": 5000, + "transitionProfitsAfterIncomeTaxLossDeductions": 5000 + } + ] + } + }, + "messages": { + "info": [ + { + "id": "string", + "text": "string" + } + ], + "warnings": [ + { + "id": "string", + "text": "string" + } + ], + "errors": [ + { + "id": "string", + "text": "string" + } + ] + }, + "internal": { + "calculationDetails": { + "incomeTax": 5000.99, + "marriageAllowance": { + "creationTimestamp": "string" + }, + "employments": { + "employmentQuantity": 0 + }, + "selfEmployments": { + "selfEmploymentQuantity": 0 + } + } + } +} \ No newline at end of file diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json new file mode 100644 index 000000000..573d372ff --- /dev/null +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -0,0 +1,1078 @@ +{ + "metadata": { + "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", + "taxYear": "2017-18", + "requestedBy": "customer", + "requestedTimestamp": "2019-02-15T09:35:15.000Z", + "calculationReason": "customerRequest", + "calculationTimestamp": "2019-02-15T09:35:15.094Z", + "calculationType": "finalDeclaration", + "intentToSubmitFinalDeclaration": true, + "finalDeclaration": true, + "finalDeclarationTimestamp": "2019-02-15T09:35:15.094Z", + "periodFrom": "2018-04-06", + "periodTo": "2019-04-05" + }, + "inputs": { + "personalInformation": { + "identifier": "VO123456A", + "dateOfBirth": "2018-04-06", + "taxRegime": "UK", + "statePensionAgeDate": "2050-04-06", + "studentLoanPlan": [ + { + "planType": "plan1" + } + ], + "class2VoluntaryContributions": true, + "marriageAllowance": "transferor", + "uniqueTaxpayerReference": "1234567890" + }, + "incomeSources": { + "businessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "incomeSourceName": "string", + "accountingPeriodStartDate": "2018-04-06", + "accountingPeriodEndDate": "2019-04-05", + "source": "MTD-SA", + "latestPeriodEndDate": "2021-12-02", + "latestReceivedDateTime": "2021-12-02T15:25:48Z", + "finalised": true, + "finalisationTimestamp": "2019-02-15T09:35:15.094Z", + "submissionPeriods": [ + { + "periodId": "001", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "receivedDateTime": "2019-02-15T09:35:04.843Z" + } + ] + } + ], + "nonBusinessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "uk-savings-and-gains", + "incomeSourceName": "Savings Account 1", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "source": "MTD-SA", + "periodId": "001", + "latestReceivedDateTime": "2019-08-01T13:02:09.775Z" + } + ] + }, + "annualAdjustments": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "bsasId": "123a456b-789c-1d23-845e-678b9d1bd2ab", + "receivedDateTime": "2021-12-02T15:25:48Z", + "applied": true + } + ], + "lossesBroughtForward": [ + { + "lossId": "0yriP9QrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "lossType": "income", + "taxYearLossIncurred": "2017-18", + "currentLossValue": 12500, + "mtdLoss": false + } + ], + "claims": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "taxYearClaimMade": "2017-18", + "claimType": "carry-forward", + "sequence": 0 + } + ], + "constructionIndustryScheme": [ + { + "employerRef": "123/AA12345", + "contractorName": "string", + "periodData": [ + { + "deductionFromDate": "2021-12-02", + "deductionToDate": "2021-12-02", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "source": "contractor", + "deductionAmount": 5000.99 + } + ] + } + ], + "allowancesReliefsAndDeductions": [ + { + "type": "investmentReliefs", + "submittedTimestamp": "2021-12-02T15:25:48Z", + "startDate": "2021-12-02", + "endDate": "2021-12-02", + "source": "MTD-SA" + } + ], + "pensionContributionAndCharges": [ + { + "type": "pensionReliefs", + "submissionTimestamp": "2021-12-02T15:25:48Z", + "startDate": "2021-12-02", + "endDate": "2021-12-02", + "source": "customer" + } + ], + "other": [ + { + "type": "codingOut", + "submittedOn": "2021-12-02T15:25:48Z" + } + ] + }, + "calculation": { + "allowancesAndDeductions": { + "personalAllowance": 12500, + "marriageAllowanceTransferOut": { + "personalAllowanceBeforeTransferOut": 5000.99, + "transferredOutAmount": 5000.99 + }, + "reducedPersonalAllowance": 12501, + "giftOfInvestmentsAndPropertyToCharity": 12502, + "blindPersonsAllowance": 12503, + "lossesAppliedToGeneralIncome": 12504, + "cgtLossSetAgainstInYearGeneralIncome": 12505, + "qualifyingLoanInterestFromInvestments": 5001.99, + "postCessationTradeReceipts": 5002.99, + "paymentsToTradeUnionsForDeathBenefits": 5003.99, + "grossAnnuityPayments": 5004.99, + "annuityPayments": { + "reliefClaimed": 5000.99, + "rate": 20.01 + }, + "pensionContributions": 5000.99, + "pensionContributionsDetail": { + "retirementAnnuityPayments": 5000.99, + "paymentToEmployersSchemeNoTaxRelief": 5000.99, + "overseasPensionSchemeContributions": 5000.99 + } + }, + "reliefs": { + "residentialFinanceCosts": { + "adjustedTotalIncome": 5000.99, + "totalAllowableAmount": 5000.99, + "relievableAmount": 5000.99, + "rate": 20.01, + "totalResidentialFinanceCostsRelief": 5000.99, + "ukProperty": { + "amountClaimed": 12500, + "allowableAmount": 5000.99, + "carryForwardAmount": 5000.99 + }, + "foreignProperty": { + "totalForeignPropertyAllowableAmount": 5000.99, + "foreignPropertyRfcDetail": [ + { + "countryCode": "FRA", + "amountClaimed": 12500, + "allowableAmount": 5000.99, + "carryForwardAmount": 5000.99 + } + ] + }, + "allOtherIncomeReceivedWhilstAbroad": { + "totalOtherIncomeAllowableAmount": 5000.99, + "otherIncomeRfcDetail": [ + { + "countryCode": "FRA", + "residentialFinancialCostAmount": 5000.99, + "broughtFwdResidentialFinancialCostAmount": 5000.99 + } + ] + } + }, + "reliefsClaimed": [ + { + "type": "vctSubscriptions", + "amountClaimed": 5000.99, + "allowableAmount": 5000.99, + "amountUsed": 5000.99, + "rate": 20.01, + "reliefsClaimedDetail": [ + { + "amountClaimed": 5000.99, + "uniqueInvestmentRef": "string", + "name": "string", + "socialEnterpriseName": "string", + "companyName": "string", + "deficiencyReliefType": "lifeInsurance", + "customerReference": "string" + } + ] + } + ], + "foreignTaxCreditRelief": { + "customerCalculatedRelief": true, + "totalForeignTaxCreditRelief": 5000.99, + "foreignTaxCreditReliefOnProperty": 5000.99, + "foreignTaxCreditReliefOnDividends": 5000.99, + "foreignTaxCreditReliefOnSavings": 5000.99, + "foreignTaxCreditReliefOnForeignIncome": 5000.99, + "foreignTaxCreditReliefDetail": [ + { + "incomeSourceType": "foreign-property", + "incomeSourceId": "000000000000210", + "countryCode": "FRA", + "foreignIncome": 5001.99, + "foreignTax": 5002.99, + "dtaRate": 20, + "dtaAmount": 5003.99, + "ukLiabilityOnIncome": 5004.99, + "foreignTaxCredit": 5005.99, + "employmentLumpSum": true + } + ] + }, + "topSlicingRelief": { + "amount": 5000.99 + } + }, + "taxDeductedAtSource": { + "bbsi": 5000.99, + "ukLandAndProperty": 5000.99, + "cis": 5000.99, + "securities": 5000.99, + "voidedIsa": 5000.99, + "payeEmployments": 5000.99, + "occupationalPensions": 5000.99, + "stateBenefits": -99999999999.99, + "specialWithholdingTaxOrUkTaxPaid": 5000.99, + "inYearAdjustmentCodedInLaterTaxYear": 5000.99 + }, + "giftAid": { + "grossGiftAidPayments": 12500, + "rate": 20.01, + "giftAidTax": 5000.99, + "giftAidTaxReductions": 5000.99, + "incomeTaxChargedAfterGiftAidTaxReductions": 5000.99, + "giftAidCharge": 5000.99 + }, + "royaltyPayments": { + "royaltyPaymentsAmount": 12500, + "rate": 20.01, + "grossRoyaltyPayments": 12500 + }, + "notionalTax": { + "chargeableGains": 5000.99 + }, + "marriageAllowanceTransferredIn": { + "amount": 5000.99, + "rate": 20.01 + }, + "pensionContributionReliefs": { + "totalPensionContributionReliefs": 5000.99, + "pensionContributionDetail": { + "regularPensionContributions": 5000.99, + "oneOffPensionContributionsPaid": 5000.99 + } + }, + "pensionSavingsTaxCharges": { + "totalPensionCharges": 5000.99, + "totalTaxPaid": 5000.99, + "totalPensionChargesDue": 5000.99, + "pensionSavingsTaxChargesDetail": { + "pensionSchemeUnauthorisedPayments": { + "totalChargeableAmount": 5000.99, + "totalTaxPaid": 5000.99, + "pensionSchemeUnauthorisedPaymentsSurcharge": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "pensionSchemeUnauthorisedPaymentsNonSurcharge": { + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + } + }, + "pensionSchemeOverseasTransfers": { + "transferCharge": 5000.99, + "transferChargeTaxPaid": 5000.99, + "rate": 20.01, + "chargeableAmount": 5000.99 + }, + "pensionContributionsInExcessOfTheAnnualAllowance": { + "totalContributions": 5000.99, + "totalPensionCharge": 5000.99, + "annualAllowanceTaxPaid": 5000.99, + "totalPensionChargeDue": 5000.99, + "pensionBands": [ + { + "name": "basic-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "contributionAmount": 5001.99, + "pensionCharge": 5002.99 + } + ] + }, + "overseasPensionContributions": { + "totalShortServiceRefund": 5000.99, + "totalShortServiceRefundCharge": 5000.99, + "shortServiceRefundTaxPaid": 5000.99, + "totalShortServiceRefundChargeDue": 5000.99, + "shortServiceRefundBands": [ + { + "name": "lowerBand", + "rate": 20.01, + "bandLimit": 12500, + "apportionedBandLimit": 12500, + "shortServiceRefundAmount": 5000.99, + "shortServiceRefundCharge": 5000.99 + } + ] + } + } + }, + "studentLoans": [ + { + "planType": "plan1", + "studentLoanTotalIncomeAmount": 5001.99, + "studentLoanChargeableIncomeAmount": 5002.99, + "studentLoanRepaymentAmount": 5003.99, + "studentLoanDeductionsFromEmployment": 5004.99, + "studentLoanRepaymentAmountNetOfDeductions": 5005.99, + "studentLoanApportionedIncomeThreshold": 12500, + "studentLoanRate": 20.01, + "payeIncomeForStudentLoan": 5006.99, + "nonPayeIncomeForStudentLoan": 5007.99 + } + ], + "codedOutUnderpayments": { + "totalPayeUnderpayments": 5000.99, + "payeUnderpaymentsDetail": [ + { + "amount": 5000.99, + "relatedTaxYear": "2017-18", + "source": "customer" + } + ], + "totalSelfAssessmentUnderpayments": 5000.99, + "totalCollectedSelfAssessmentUnderpayments": 5000.99, + "totalUncollectedSelfAssessmentUnderpayments": 5000.99, + "selfAssessmentUnderpaymentsDetail": [ + { + "amount": 5000.99, + "relatedTaxYear": "2017-18", + "source": "customer", + "collectedAmount": 5001.99, + "uncollectedAmount": 5002.99 + } + ] + }, + "foreignPropertyIncome": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "foreign-property", + "countryCode": "FRA", + "totalIncome": 5001.99, + "totalExpenses": 5002.99, + "netProfit": 5003.99, + "netLoss": 5004.99, + "totalAdditions": 5005.99, + "totalDeductions": 5006.99, + "taxableProfit": 5007.99, + "adjustedIncomeTaxLoss": 5008.99 + } + ], + "businessProfitAndLoss": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "incomeSourceName": "string", + "totalIncome": 5001.99, + "totalExpenses": -5002.99, + "netProfit": 5003.99, + "netLoss": 5004.99, + "totalAdditions": -5005.99, + "totalDeductions": 5006.99, + "accountingAdjustments": -5007.99, + "taxableProfit": 12501, + "adjustedIncomeTaxLoss": 12502, + "totalBroughtForwardIncomeTaxLosses": 12503, + "lossForCSFHL": 12504, + "broughtForwardIncomeTaxLossesUsed": 12505, + "taxableProfitAfterIncomeTaxLossesDeduction": 12506, + "carrySidewaysIncomeTaxLossesUsed": 12507, + "broughtForwardCarrySidewaysIncomeTaxLossesUsed": 12508, + "totalIncomeTaxLossesCarriedForward": 12509, + "class4Loss": 12510, + "totalBroughtForwardClass4Losses": 12511, + "broughtForwardClass4LossesUsed": 12512, + "carrySidewaysClass4LossesUsed": 12513, + "totalClass4LossesCarriedForward": 12514 + } + ], + "employmentAndPensionsIncome": { + "totalPayeEmploymentAndLumpSumIncome": 5000.99, + "totalOccupationalPensionIncome": 5000.99, + "totalBenefitsInKind": 5000.99, + "tipsIncome": 5000.99, + "employmentAndPensionsIncomeDetail": [ + { + "incomeSourceId": "string", + "source": "customer", + "occupationalPension": true, + "employerRef": "123/AA12345", + "employerName": "string", + "payrollId": "string", + "startDate": "2021-12-02", + "dateEmploymentEnded": "2021-12-02", + "taxablePayToDate": 5000.99, + "totalTaxToDate": -99999999999.99, + "disguisedRemuneration": true, + "lumpSums": { + "totalLumpSum": 5000.99, + "totalTaxPaid": 5000.99, + "lumpSumsDetail": { + "taxableLumpSumsAndCertainIncome": { + "amount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "benefitFromEmployerFinancedRetirementScheme": { + "amount": 5000.99, + "exemptAmount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "redundancyCompensationPaymentsOverExemption": { + "amount": 5000.99, + "taxPaid": 5000.99, + "taxTakenOffInEmployment": true + }, + "redundancyCompensationPaymentsUnderExemption": { + "amount": 5000.99 + } + } + }, + "studentLoans": { + "uglDeductionAmount": 5000.99, + "pglDeductionAmount": 5000.99 + }, + "benefitsInKind": { + "totalBenefitsInKindReceived": 5000.99, + "benefitsInKindDetail": { + "apportionedAccommodation": 5000.99, + "apportionedAssets": 5000.99, + "apportionedAssetTransfer": 5000.99, + "apportionedBeneficialLoan": 5000.99, + "apportionedCar": 5000.99, + "apportionedCarFuel": 5000.99, + "apportionedEducationalServices": 5000.99, + "apportionedEntertaining": 5000.99, + "apportionedExpenses": 5000.99, + "apportionedMedicalInsurance": 5000.99, + "apportionedTelephone": 5000.99, + "apportionedService": 5000.99, + "apportionedTaxableExpenses": 5000.99, + "apportionedVan": 5000.99, + "apportionedVanFuel": 5000.99, + "apportionedMileage": 5000.99, + "apportionedNonQualifyingRelocationExpenses": 5000.99, + "apportionedNurseryPlaces": 5000.99, + "apportionedOtherItems": 5000.99, + "apportionedPaymentsOnEmployeesBehalf": 5000.99, + "apportionedPersonalIncidentalExpenses": 5000.99, + "apportionedQualifyingRelocationExpenses": 5000.99, + "apportionedEmployerProvidedProfessionalSubscriptions": 5000.99, + "apportionedEmployerProvidedServices": 5000.99, + "apportionedIncomeTaxPaidByDirector": 5000.99, + "apportionedTravelAndSubsistence": 5000.99, + "apportionedVouchersAndCreditCards": 5000.99, + "apportionedNonCash": 5000.99 + } + } + } + ] + }, + "employmentExpenses": { + "totalEmploymentExpenses": 5000.99, + "employmentExpensesDetail": { + "businessTravelCosts": 5000.99, + "jobExpenses": 5000.99, + "flatRateJobExpenses": 5000.99, + "professionalSubscriptions": 5000.99, + "hotelAndMealExpenses": 5000.99, + "otherAndCapitalAllowances": 5000.99, + "vehicleExpenses": 5000.99, + "mileageAllowanceRelief": 5000.99 + } + }, + "seafarersDeductions": { + "totalSeafarersDeduction": 5000.99, + "seafarersDeductionDetail": [ + { + "nameOfShip": "string", + "amountDeducted": 5000.99 + } + ] + }, + "foreignTaxForFtcrNotClaimed": { + "foreignTaxOnForeignEmployment": 5000.99 + }, + "stateBenefitsIncome": { + "totalStateBenefitsIncome": 5000.99, + "totalStateBenefitsTaxPaid": -99999999999.99, + "stateBenefitsDetail": { + "incapacityBenefit": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": 5000.99, + "source": "customer" + } + ], + "statePension": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ], + "statePensionLumpSum": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": 5000.99, + "rate": 20.01, + "source": "customer" + } + ], + "employmentSupportAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": -99999999999.99, + "source": "customer" + } + ], + "jobSeekersAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "taxPaid": -99999999999.99, + "source": "customer" + } + ], + "bereavementAllowance": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ], + "otherStateBenefits": [ + { + "incomeSourceId": "string", + "amount": 5000.99, + "source": "customer" + } + ] + }, + "totalStateBenefitsIncomeExcStatePensionLumpSum": 5000.01 + }, + "shareSchemesIncome": { + "totalIncome": 5000.99, + "shareSchemeDetail": [ + { + "type": "shareOption", + "employerName": "string", + "employerRef": "123/AA12345", + "taxableAmount": 5000.99 + } + ] + }, + "foreignIncome": { + "chargeableOverseasPensionsStateBenefitsRoyalties": 5000.99, + "overseasPensionsStateBenefitsRoyaltiesDetail": [ + { + "countryCode": "FRA", + "grossIncome": 5000.99, + "netIncome": 5000.99, + "taxDeducted": 5000.99, + "foreignTaxCreditRelief": true + } + ], + "chargeableAllOtherIncomeReceivedWhilstAbroad": 5000.99, + "allOtherIncomeReceivedWhilstAbroadDetail": [ + { + "countryCode": "FRA", + "grossIncome": 5000.99, + "netIncome": 5000.99, + "taxDeducted": 5000.99, + "foreignTaxCreditRelief": true + } + ], + "overseasIncomeAndGains": { + "gainAmount": 5000.99 + }, + "totalForeignBenefitsAndGifts": 5000.99, + "chargeableForeignBenefitsAndGiftsDetail": { + "transactionBenefit": 5000.99, + "protectedForeignIncomeSourceBenefit": 5000.99, + "protectedForeignIncomeOnwardGift": 5000.99, + "benefitReceivedAsASettler": 5000.99, + "onwardGiftReceivedAsASettler": 5000.99 + } + }, + "chargeableEventGainsIncome": { + "totalOfAllGains": 12500, + "totalGainsWithTaxPaid": 12500, + "gainsWithTaxPaidDetail": [ + { + "type": "lifeInsurance", + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0, + "yearsHeldSinceLastGain": 0 + } + ], + "totalGainsWithNoTaxPaidAndVoidedIsa": 12500, + "gainsWithNoTaxPaidAndVoidedIsaDetail": [ + { + "type": "lifeInsurance", + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0, + "yearsHeldSinceLastGain": 0, + "voidedIsaTaxPaid": 5000.99 + } + ], + "totalForeignGainsOnLifePoliciesTaxPaid": 12500, + "foreignGainsOnLifePoliciesTaxPaidDetail": [ + { + "customerReference": "string", + "gainAmount": 5000.99, + "taxPaidAmount": 5000.99, + "yearsHeld": 0 + } + ], + "totalForeignGainsOnLifePoliciesNoTaxPaid": 12500, + "foreignGainsOnLifePoliciesNoTaxPaidDetail": [ + { + "customerReference": "string", + "gainAmount": 5000.99, + "yearsHeld": 0 + } + ] + }, + "savingsAndGainsIncome": { + "totalChargeableSavingsAndGains": 12500, + "totalUkSavingsAndGains": 12500, + "ukSavingsAndGainsIncome": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "uk-savings-and-gains", + "incomeSourceName": "My Savings Account 1", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99 + } + ], + "chargeableForeignSavingsAndGains": 12500, + "foreignSavingsAndGainsIncome": [ + { + "incomeSourceType": "foreign-savings-and-gains", + "countryCode": "GER", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ] + }, + "dividendsIncome": { + "totalChargeableDividends": 12500, + "totalUkDividends": 12500, + "ukDividends": { + "incomeSourceId": "000000000000210", + "incomeSourceType": "uk-dividends", + "dividends": 12501, + "otherUkDividends": 12502 + }, + "otherDividends": [ + { + "typeOfDividend": "stockDividend", + "customerReference": "string", + "grossAmount": 5000.99 + } + ], + "chargeableForeignDividends": 12500, + "foreignDividends": [ + { + "incomeSourceType": "foreign-dividends", + "countryCode": "ZZZ", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ], + "dividendIncomeReceivedWhilstAbroad": [ + { + "incomeSourceType": "foreign-dividends", + "countryCode": "ZZZ", + "grossIncome": 5001.99, + "netIncome": 5002.99, + "taxDeducted": 5003.99, + "foreignTaxCreditRelief": true + } + ] + }, + "incomeSummaryTotals": { + "totalSelfEmploymentProfit": 12500, + "totalPropertyProfit": 12500, + "totalFHLPropertyProfit": 12500, + "totalUKOtherPropertyProfit": 12500, + "totalForeignPropertyProfit": 12500, + "totalEeaFhlProfit": 12500, + "totalEmploymentIncome": 12500 + }, + "taxCalculation": { + "incomeTax": { + "totalIncomeReceivedFromAllSources": 12500, + "totalAllowancesAndDeductions": 12500, + "totalTaxableIncome": 12500, + "payPensionsProfit": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "savingsAndGains": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "dividends": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "lumpSums": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "gainsOnLifePolicies": { + "incomeReceived": 12500, + "allowancesAllocated": 12500, + "taxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "taxBands": [ + { + "name": "savings-starter-rate", + "rate": 20.01, + "bandLimit": 12501, + "apportionedBandLimit": 12502, + "income": 12503, + "taxAmount": 5000.99 + } + ] + }, + "incomeTaxCharged": 5000.99, + "totalReliefs": 5000.99, + "incomeTaxDueAfterReliefs": -99999999999.99, + "totalNotionalTax": 5000.99, + "marriageAllowanceRelief": 5000.99, + "incomeTaxDueAfterTaxReductions": 5000.99, + "incomeTaxDueAfterGiftAid": 5000.99, + "totalPensionSavingsTaxCharges": 5000.99, + "statePensionLumpSumCharges": 5000.99, + "payeUnderpaymentsCodedOut": 5000.99, + "totalIncomeTaxDue": 5000.99 + }, + "nics": { + "class2Nics": { + "amount": 5000.99, + "weeklyRate": 5000.99, + "weeks": 0, + "limit": 12500, + "apportionedLimit": 12500, + "underSmallProfitThreshold": true, + "actualClass2Nic": true + }, + "class4Nics": { + "totalIncomeLiableToClass4Charge": 12500, + "totalClass4LossesAvailable": 12500, + "totalClass4LossesUsed": 12500, + "totalClass4LossesCarriedForward": 12500, + "totalIncomeChargeableToClass4": 12500, + "totalAmount": 5000.99, + "nic4Bands": [ + { + "name": "zero-rate", + "rate": 20.01, + "threshold": 12501, + "apportionedThreshold": 12502, + "income": 12503, + "amount": 5000.99 + } + ] + }, + "nic2NetOfDeductions": -99999999999.99, + "nic4NetOfDeductions": -99999999999.99, + "totalNic": -99999999999.99 + }, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalAnnuityPaymentsTaxCharged": 12500, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalIncomeTaxNicsCharged": -99999999999.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalTaxDeducted": -99999999999.99, + "totalIncomeTaxAndNicsDue": -99999999999.99, + "capitalGainsTax": { + "totalCapitalGainsIncome": 5000.99, + "annualExemptionAmount": 5000.99, + "totalTaxableGains": 5000.99, + "businessAssetsDisposalsAndInvestorsRel": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "rate": 20.01, + "taxAmount": 5000.99 + }, + "residentialPropertyAndCarriedInterest": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lower-rate", + "rate": 20.01, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "otherGains": { + "gainsIncome": 5000.99, + "lossesBroughtForward": 5000.99, + "lossesArisingThisYear": 5000.99, + "gainsAfterLosses": 5000.99, + "attributedGains": 5000.99, + "netGains": 5000.99, + "annualExemptionAmount": 5000.99, + "taxableGains": 5000.99, + "cgtTaxBands": [ + { + "name": "lower-rate", + "rate": 20.01, + "income": 5000.99, + "taxAmount": 5000.99 + } + ], + "totalTaxAmount": 5000.99 + }, + "capitalGainsTaxAmount": 5000.99, + "adjustments": -99999999999.99, + "adjustedCapitalGainsTax": 5000.99, + "foreignTaxCreditRelief": 5000.99, + "capitalGainsTaxAfterFTCR": 5000.99, + "taxOnGainsAlreadyPaid": 5000.99, + "capitalGainsTaxDue": 5000.99, + "capitalGainsOverpaid": 5000.99 + }, + "totalIncomeTaxAndNicsAndCgt": 5000.99 + }, + "previousCalculation": { + "calculationTimestamp": "2021-12-02T15:25:48Z", + "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", + "totalIncomeTaxAndNicsDue": -99999999999.99, + "cgtTaxDue": 5000.99, + "totalIncomeTaxAndNicsAndCgtDue": 5000.99, + "incomeTaxNicDueThisPeriod": -99999999999.99, + "cgtDueThisPeriod": -99999999999.99, + "totalIncomeTaxAndNicsAndCgtDueThisPeriod": 5000.99 + }, + "endOfYearEstimate": { + "incomeSource": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "incomeSourceName": "string", + "taxableIncome": 12500, + "finalised": true + } + ], + "totalEstimatedIncome": 12500, + "totalTaxableIncome": 12500, + "incomeTaxAmount": 5000.99, + "nic2": 5000.99, + "nic4": 5000.99, + "totalTaxDeductedBeforeCodingOut": 5000.99, + "saUnderpaymentsCodedOut": 5000.99, + "totalNicAmount": 5000.99, + "totalStudentLoansRepaymentAmount": 5000.99, + "totalAnnuityPaymentsTaxCharged": 5000.99, + "totalRoyaltyPaymentsTaxCharged": 5000.99, + "totalTaxDeducted": -99999999999.99, + "incomeTaxNicAmount": -99999999999.99, + "cgtAmount": 5000.99, + "incomeTaxNicAndCgtAmount": 5000.99 + }, + "lossesAndClaims": { + "resultOfClaimsApplied": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "taxYearClaimMade": "2016-17", + "claimType": "carry-forward", + "mtdLoss": false, + "taxYearLossIncurred": "2017-18", + "lossAmountUsed": 12501, + "remainingLossValue": 12502, + "lossType": "income" + } + ], + "unclaimedLosses": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "taxYearLossIncurred": "2017-18", + "currentLossValue": 12500, + "lossType": "income" + } + ], + "carriedForwardLosses": [ + { + "claimId": "0vayS9JrW2jTa6n", + "originatingClaimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "claimType": "carry-forward", + "taxYearClaimMade": "2016-17", + "taxYearLossIncurred": "2017-18", + "currentLossValue": 12500, + "lossType": "income" + } + ], + "defaultCarriedForwardLosses": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "taxYearLossIncurred": "2017-18", + "currentLossValue": 12500 + } + ], + "claimsNotApplied": [ + { + "claimId": "0vayS9JrW2jTa6n", + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "taxYearClaimMade": "2017-18", + "claimType": "carry-forward" + } + ] + }, + "transitionProfit": { + "totalTaxableTransitionProfit": 5000, + "transitionProfitDetail": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceName": "string", + "transitionProfitAmount": 5000.99, + "transitionProfitAccelerationAmount": 5000.99, + "totalTransitionProfit": 5000, + "remainingBroughtForwardIncomeTaxLosses": 5000, + "broughtForwardIncomeTaxLossesUsed": 5000, + "transitionProfitsAfterIncomeTaxLossDeductions": 5000 + } + ] + } + }, + "messages": { + "info": [ + { + "id": "string", + "text": "string" + } + ], + "warnings": [ + { + "id": "string", + "text": "string" + } + ], + "errors": [ + { + "id": "string", + "text": "string" + } + ] + } +} \ No newline at end of file diff --git a/test/v7/common/model/response/CalculationTypeSpec.scala b/test/v7/common/model/response/CalculationTypeSpec.scala new file mode 100644 index 000000000..7e09a5aed --- /dev/null +++ b/test/v7/common/model/response/CalculationTypeSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2022 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.CalculationType._ + +class CalculationTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[CalculationType]( + "inYear" -> `inYear`, + "crystallisation" -> `finalDeclaration` + ) + + testWrites[CalculationType]( + `inYear` -> "inYear", + `finalDeclaration` -> "finalDeclaration" + ) + +} diff --git a/test/v7/common/model/response/ClaimTypeSpec.scala b/test/v7/common/model/response/ClaimTypeSpec.scala new file mode 100644 index 000000000..be921c9e3 --- /dev/null +++ b/test/v7/common/model/response/ClaimTypeSpec.scala @@ -0,0 +1,43 @@ +/* + * Copyright 2022 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.ClaimType._ + +class ClaimTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[ClaimType]( + "CF" -> `carry-forward`, + "CSGI" -> `carry-sideways`, + "CFCSGI" -> `carry-forward-to-carry-sideways`, + "CSFHL" -> `carry-sideways-fhl`, + "CB" -> `carry-backwards`, + "CBGI" -> `carry-backwards-general-income` + ) + + testWrites[ClaimType]( + `carry-forward` -> "carry-forward", + `carry-sideways` -> "carry-sideways", + `carry-forward-to-carry-sideways` -> "carry-forward-to-carry-sideways", + `carry-sideways-fhl` -> "carry-sideways-fhl", + `carry-backwards` -> "carry-backwards", + `carry-backwards-general-income` -> "carry-backwards-general-income" + ) + +} diff --git a/test/v7/common/model/response/IncomeSourceTypeSpec.scala b/test/v7/common/model/response/IncomeSourceTypeSpec.scala new file mode 100644 index 000000000..3b8118ee2 --- /dev/null +++ b/test/v7/common/model/response/IncomeSourceTypeSpec.scala @@ -0,0 +1,97 @@ +/* + * Copyright 2022 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import play.api.libs.json.{JsResultException, JsString, Json} +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.IncomeSourceType._ + +class IncomeSourceTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[IncomeSourceType]( + "01" -> `self-employment`, + "02" -> `uk-property-non-fhl`, + "03" -> `foreign-property-fhl-eea`, + "04" -> `uk-property-fhl`, + "05" -> `employments`, + "06" -> `foreign-income`, + "07" -> `foreign-dividends`, + "09" -> `uk-savings-and-gains`, + "10" -> `uk-dividends`, + "11" -> `state-benefits`, + "12" -> `gains-on-life-policies`, + "13" -> `share-schemes`, + "15" -> `foreign-property`, + "16" -> `foreign-savings-and-gains`, + "17" -> `other-dividends`, + "18" -> `uk-securities`, + "19" -> `other-income`, + "20" -> `foreign-pension`, + "21" -> `non-paye-income`, + "22" -> `capital-gains-tax`, + "98" -> `charitable-giving` + ) + + testWrites[IncomeSourceType]( + `self-employment` -> "self-employment", + `uk-property-non-fhl` -> "uk-property-non-fhl", + `foreign-property-fhl-eea` -> "foreign-property-fhl-eea", + `uk-property-fhl` -> "uk-property-fhl", + `employments` -> "employments", + `foreign-income` -> "foreign-income", + `foreign-dividends` -> "foreign-dividends", + `uk-savings-and-gains` -> "uk-savings-and-gains", + `uk-dividends` -> "uk-dividends", + `state-benefits` -> "state-benefits", + `gains-on-life-policies` -> "gains-on-life-policies", + `share-schemes` -> "share-schemes", + `foreign-property` -> "foreign-property", + `foreign-savings-and-gains` -> "foreign-savings-and-gains", + `other-dividends` -> "other-dividends", + `uk-securities` -> "uk-securities", + `other-income` -> "other-income", + `foreign-pension` -> "foreign-pension", + `non-paye-income` -> "non-paye-income", + `capital-gains-tax` -> "capital-gains-tax", + `charitable-giving` -> "charitable-giving" + ) + + "formatRestricted" when { + "reads" should { + "work when the provided IncomeSourceType is in the list" in { + JsString("01").as[IncomeSourceType](formatRestricted(`self-employment`)) shouldBe + IncomeSourceType.`self-employment` + } + + "fail when the provided IncomeSourceType is not in the list" in { + val exception = intercept[JsResultException] { + JsString("02").as[IncomeSourceType](formatRestricted(`self-employment`)) + } + exception.errors.head._2.head.message shouldBe "error.expected.IncomeSourceType" + } + } + + "writes" should { + "work" in { + Json + .toJson(`self-employment`: IncomeSourceType)(formatRestricted(`self-employment`)) shouldBe JsString("self-employment") + } + } + } + +} diff --git a/test/v7/common/model/response/PensionBandNameSpec.scala b/test/v7/common/model/response/PensionBandNameSpec.scala new file mode 100644 index 000000000..8f4690748 --- /dev/null +++ b/test/v7/common/model/response/PensionBandNameSpec.scala @@ -0,0 +1,41 @@ +/* + * Copyright 2022 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.PensionBandName._ + +class PensionBandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[PensionBandName]( + "BRT" -> `basic-rate`, + "IRT" -> `intermediate-rate`, + "HRT" -> `higher-rate`, + "ART" -> `additional-rate`, + "AVRT" -> `advanced-rate` + ) + + testWrites[PensionBandName]( + `basic-rate` -> "basic-rate", + `intermediate-rate` -> "intermediate-rate", + `higher-rate` -> "higher-rate", + `additional-rate` -> "additional-rate", + `advanced-rate` -> "advanced-rate" + ) + +} diff --git a/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala b/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala new file mode 100644 index 000000000..56c66c203 --- /dev/null +++ b/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2022 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.ReliefsClaimedType._ + +class ReliefsClaimedTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[ReliefsClaimedType]( + "vctSubscriptions" -> vctSubscriptions, + "eisSubscriptions" -> eisSubscriptions, + "communityInvestment" -> communityInvestment, + "seedEnterpriseInvestment" -> seedEnterpriseInvestment, + "socialEnterpriseInvestment" -> socialEnterpriseInvestment, + "maintenancePayments" -> maintenancePayments, + "deficiencyRelief" -> deficiencyRelief, + "nonDeductableLoanInterest" -> nonDeductibleLoanInterest, + "qualifyingDistributionRedemptionOfSharesAndSecurities" -> qualifyingDistributionRedemptionOfSharesAndSecurities + ) + + testWrites[ReliefsClaimedType]( + vctSubscriptions -> "vctSubscriptions", + eisSubscriptions -> "eisSubscriptions", + communityInvestment -> "communityInvestment", + seedEnterpriseInvestment -> "seedEnterpriseInvestment", + socialEnterpriseInvestment -> "socialEnterpriseInvestment", + maintenancePayments -> "maintenancePayments", + deficiencyRelief -> "deficiencyRelief", + nonDeductibleLoanInterest -> "nonDeductibleLoanInterest", + qualifyingDistributionRedemptionOfSharesAndSecurities -> "qualifyingDistributionRedemptionOfSharesAndSecurities" + ) + +} diff --git a/test/v7/common/model/response/StudentLoanPlanTypeSpec.scala b/test/v7/common/model/response/StudentLoanPlanTypeSpec.scala new file mode 100644 index 000000000..b83f6af33 --- /dev/null +++ b/test/v7/common/model/response/StudentLoanPlanTypeSpec.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2022 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.StudentLoanPlanType._ + +class StudentLoanPlanTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[StudentLoanPlanType]( + "01" -> `plan1`, + "02" -> `plan2`, + "03" -> `postgraduate`, + "04" -> `plan4` + ) + + testWrites[StudentLoanPlanType]( + `plan1` -> "plan1", + `plan2` -> "plan2", + `postgraduate` -> "postgraduate", + `plan4` -> "plan4" + ) + +} diff --git a/test/v7/listCalculations/ListCalculationsConnectorSpec.scala b/test/v7/listCalculations/ListCalculationsConnectorSpec.scala new file mode 100644 index 000000000..51a633e3b --- /dev/null +++ b/test/v7/listCalculations/ListCalculationsConnectorSpec.scala @@ -0,0 +1,88 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.connectors.{ConnectorSpec, DownstreamOutcome} +import shared.models.domain.{Nino, TaxYear} +import shared.models.errors.{DownstreamErrorCode, DownstreamErrors} +import shared.models.outcomes.ResponseWrapper +import v7.listCalculations.def1.model.Def1_ListCalculationsFixture +import v7.listCalculations.def1.model.response.Calculation +import v7.listCalculations.model.request.Def1_ListCalculationsRequestData +import v7.listCalculations.model.response.ListCalculationsResponse + +import scala.concurrent.Future + +class ListCalculationsConnectorSpec extends ConnectorSpec with Def1_ListCalculationsFixture { + + val nino: Nino = Nino("AA111111A") + val taxYear: TaxYear = TaxYear.fromMtd("2018-19") + val tysTaxYear: TaxYear = TaxYear.fromMtd("2023-24") + + val request: Def1_ListCalculationsRequestData = Def1_ListCalculationsRequestData(nino, taxYear) + val tysRequest: Def1_ListCalculationsRequestData = Def1_ListCalculationsRequestData(nino, tysTaxYear) + + trait Test { _: ConnectorTest => + + val connector: ListCalculationsConnector = new ListCalculationsConnector( + http = mockHttpClient, + appConfig = mockAppConfig + ) + + } + + "ListCalculationsConnector" should { + "return successful response" when { + "Non-TYS tax year query param is passed" in new DesTest with Test { + val outcome = Right(ResponseWrapper(correlationId, listCalculationsResponseModel)) + + willGet( + s"$baseUrl/income-tax/list-of-calculation-results/${nino.nino}?taxYear=2019" + ) + .returns(Future.successful(outcome)) + + await(connector.list(request)) shouldBe outcome + } + + "TYS tax year query param is passed" in new TysIfsTest with Test { + val outcome = Right(ResponseWrapper(correlationId, listCalculationsResponseModel)) + + willGet( + s"$baseUrl/income-tax/view/calculations/liability/${tysTaxYear.asTysDownstream}/${nino.nino}" + ) + .returns(Future.successful(outcome)) + + await(connector.list(tysRequest)) shouldBe outcome + } + } + + "an error is received" must { + "return the expected result" in new DesTest with Test { + val outcome = Left(ResponseWrapper(correlationId, DownstreamErrors.single(DownstreamErrorCode("ERROR_CODE")))) + + willGet( + s"$baseUrl/income-tax/list-of-calculation-results/${nino.nino}?taxYear=2019" + ) + .returns(Future.successful(outcome)) + + private val result: DownstreamOutcome[ListCalculationsResponse[Calculation]] = await(connector.list(request)) + result shouldBe outcome + } + } + } + +} diff --git a/test/v7/listCalculations/ListCalculationsControllerSpec.scala b/test/v7/listCalculations/ListCalculationsControllerSpec.scala new file mode 100644 index 000000000..878c60a1a --- /dev/null +++ b/test/v7/listCalculations/ListCalculationsControllerSpec.scala @@ -0,0 +1,105 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import play.api.Configuration +import play.api.mvc.Result +import shared.controllers.{ControllerBaseSpec, ControllerTestRunner} +import shared.models.audit.GenericAuditDetailFixture.nino +import shared.models.domain.{Nino, TaxYear} +import shared.models.errors.{ErrorWrapper, NinoFormatError, RuleTaxYearNotSupportedError} +import shared.models.outcomes.ResponseWrapper +import shared.services.{MockEnrolmentsAuthService, MockMtdIdLookupService} +import shared.utils.MockIdGenerator +import v7.listCalculations.def1.model.Def1_ListCalculationsFixture +import v7.listCalculations.model.request.{Def1_ListCalculationsRequestData, ListCalculationsRequestData} + +import scala.concurrent.ExecutionContext.Implicits.global +import scala.concurrent.Future + +class ListCalculationsControllerSpec + extends ControllerBaseSpec + with ControllerTestRunner + with MockEnrolmentsAuthService + with MockMtdIdLookupService + with MockListCalculationsValidatorFactory + with MockListCalculationsService + with MockIdGenerator + with Def1_ListCalculationsFixture { + + val taxYear: Option[String] = Some("2020-21") + + private val requestData: ListCalculationsRequestData = Def1_ListCalculationsRequestData( + nino = Nino(nino), + taxYear = taxYear.map(TaxYear.fromMtd).getOrElse(TaxYear.now()) + ) + + "ListCalculationsController" when { + "a valid request is supplied" should { + "return the expected result for a successful service response" in new Test { + willUseValidator(returningSuccess(requestData)) + + MockListCalculationsService + .list(requestData) + .returns( + Future.successful(Right(ResponseWrapper(correlationId, listCalculationsResponseModel))) + ) + + runOkTest(OK, Some(listCalculationsMtdJson)) + } + } + + "return the error as per spec" when { + "the parser validation fails" in new Test { + willUseValidator(returning(NinoFormatError)) + + runErrorTest(NinoFormatError) + } + + "the service returns an error" in new Test { + willUseValidator(returningSuccess(requestData)) + + MockListCalculationsService + .list(requestData) + .returns(Future.successful(Left(ErrorWrapper(correlationId, RuleTaxYearNotSupportedError)))) + + runErrorTest(RuleTaxYearNotSupportedError) + } + } + } + + private trait Test extends ControllerTest { + + val controller: ListCalculationsController = new ListCalculationsController( + mockEnrolmentsAuthService, + mockMtdIdLookupService, + mockListCalculationsFactory, + mockListCalculationsService, + cc, + mockIdGenerator + ) + + MockedAppConfig.featureSwitchConfig.anyNumberOfTimes() returns Configuration( + "supporting-agents-access-control.enabled" -> true + ) + + MockedAppConfig.endpointAllowsSupportingAgents(controller.endpointName).anyNumberOfTimes() returns false + + override protected def callController(): Future[Result] = controller.list(validNino, taxYear)(fakeRequest) + } + +} diff --git a/test/v7/listCalculations/ListCalculationsServiceSpec.scala b/test/v7/listCalculations/ListCalculationsServiceSpec.scala new file mode 100644 index 000000000..d2870defc --- /dev/null +++ b/test/v7/listCalculations/ListCalculationsServiceSpec.scala @@ -0,0 +1,86 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.models.domain.{Nino, TaxYear} +import shared.models.errors._ +import shared.models.outcomes.ResponseWrapper +import shared.services.ServiceSpec +import v7.listCalculations.def1.model.Def1_ListCalculationsFixture +import v7.listCalculations.model.request.{Def1_ListCalculationsRequestData, ListCalculationsRequestData} + +import scala.concurrent.Future + +class ListCalculationsServiceSpec extends ServiceSpec with Def1_ListCalculationsFixture { + + trait Test extends MockListCalculationsConnector { + val nino: Nino = Nino("AA111111A") + val taxYear: TaxYear = TaxYear.fromMtd("2018-19") + val request: ListCalculationsRequestData = Def1_ListCalculationsRequestData(nino, taxYear) + val service: ListCalculationsService = new ListCalculationsService(mockListCalculationsConnector) + } + + "ListCalculationsService" when { + "a successful response is returned" must { + "return a success" in new Test { + val outcome = Right(ResponseWrapper(correlationId, listCalculationsResponseModel)) + + MockListCalculationsConnector + .list(request) + .returns( + Future.successful(Right(ResponseWrapper(correlationId, listCalculationsResponseModel))) + ) + + await(service.list(request)) shouldBe outcome + } + } + + "an error response is returned" must { + def checkErrorMappings(downstreamErrorCode: String, mtdError: MtdError): Unit = new Test { + s"map appropriately for error code: '$downstreamErrorCode'" in { + val connectorOutcome = Left(ResponseWrapper(correlationId, DownstreamErrors.single(DownstreamErrorCode(downstreamErrorCode)))) + MockListCalculationsConnector.list(request).returns(Future.successful(connectorOutcome)) + await(service.list(request)) shouldBe Left(ErrorWrapper(correlationId, mtdError)) + } + } + + val errors = Seq( + "INVALID_TAXABLE_ENTITY_ID" -> NinoFormatError, + "INVALID_TAXYEAR" -> TaxYearFormatError, + "NOT_FOUND" -> NotFoundError, + "SERVER_ERROR" -> InternalError, + "SERVICE_UNAVAILABLE" -> InternalError, + "UNMATCHED_STUB_ERROR" -> RuleIncorrectGovTestScenarioError + ) + + val extraTysErrors = Seq( + "INVALID_TAX_YEAR" -> TaxYearFormatError, + "INVALID_CORRELATION_ID" -> InternalError, + "TAX_YEAR_NOT_SUPPORTED" -> RuleTaxYearNotSupportedError + ) + + (errors ++ extraTysErrors).foreach(args => (checkErrorMappings _).tupled(args)) + + "return an internal server error for an unexpected error code" in new Test { + val outcome = Left(ResponseWrapper(correlationId, DownstreamErrors.single(DownstreamErrorCode("NOT_MAPPED")))) + MockListCalculationsConnector.list(request).returns(Future.successful(outcome)) + await(service.list(request)) shouldBe Left(ErrorWrapper(correlationId, InternalError)) + } + } + } + +} diff --git a/test/v7/listCalculations/ListCalculationsValidatorFactorySpec.scala b/test/v7/listCalculations/ListCalculationsValidatorFactorySpec.scala new file mode 100644 index 000000000..b286ebdff --- /dev/null +++ b/test/v7/listCalculations/ListCalculationsValidatorFactorySpec.scala @@ -0,0 +1,48 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.controllers.validators.Validator +import shared.utils.UnitSpec +import v7.listCalculations.def1.Def1_ListCalculationsValidator +import v7.listCalculations.model.request.ListCalculationsRequestData +import v7.listCalculations.schema.ListCalculationsSchema + +import javax.inject.Singleton + +@Singleton +class ListCalculationsValidatorFactorySpec extends UnitSpec { + + private val validNino = "ZG903729C" + private val validTaxYear = "2017-18" + + private val validatorFactory = new ListCalculationsValidatorFactory + + "validator()" when { + + "given any request for schema definition 1" should { + "return the Validator for schema definition 1" in { + val result: Validator[ListCalculationsRequestData] = + validatorFactory.validator(validNino, taxYear = Some(validTaxYear), ListCalculationsSchema.Def1) + + result shouldBe a[Def1_ListCalculationsValidator] + } + } + + } + +} diff --git a/test/v7/listCalculations/MockListCalculationsConnector.scala b/test/v7/listCalculations/MockListCalculationsConnector.scala new file mode 100644 index 000000000..f9f324d34 --- /dev/null +++ b/test/v7/listCalculations/MockListCalculationsConnector.scala @@ -0,0 +1,42 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.connectors.DownstreamOutcome +import org.scalamock.handlers.CallHandler +import org.scalamock.scalatest.MockFactory +import uk.gov.hmrc.http.HeaderCarrier +import v7.listCalculations.def1.model.response.Calculation +import v7.listCalculations.model.request.ListCalculationsRequestData +import v7.listCalculations.model.response.ListCalculationsResponse + +import scala.concurrent.{ExecutionContext, Future} + +trait MockListCalculationsConnector extends MockFactory { + val mockListCalculationsConnector: ListCalculationsConnector = mock[ListCalculationsConnector] + + object MockListCalculationsConnector { + + def list[I](request: ListCalculationsRequestData): CallHandler[Future[DownstreamOutcome[ListCalculationsResponse[Calculation]]]] = { + (mockListCalculationsConnector + .list(_: ListCalculationsRequestData)(_: HeaderCarrier, _: ExecutionContext, _: String)) + .expects(request, *, *, *) + } + + } + +} diff --git a/test/v7/listCalculations/MockListCalculationsService.scala b/test/v7/listCalculations/MockListCalculationsService.scala new file mode 100644 index 000000000..a663040e3 --- /dev/null +++ b/test/v7/listCalculations/MockListCalculationsService.scala @@ -0,0 +1,43 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.controllers.RequestContext +import shared.models.errors.ErrorWrapper +import shared.models.outcomes.ResponseWrapper +import org.scalamock.handlers.CallHandler +import org.scalamock.scalatest.MockFactory +import v7.listCalculations.def1.model.response.Calculation +import v7.listCalculations.model.request.ListCalculationsRequestData +import v7.listCalculations.model.response.ListCalculationsResponse + +import scala.concurrent.{ExecutionContext, Future} + +trait MockListCalculationsService extends MockFactory { + val mockListCalculationsService: ListCalculationsService = mock[ListCalculationsService] + + object MockListCalculationsService { + + def list[I](requestData: ListCalculationsRequestData): CallHandler[Future[Either[ErrorWrapper, ResponseWrapper[ListCalculationsResponse[Calculation]]]]] = { + (mockListCalculationsService + .list(_: ListCalculationsRequestData)(_: RequestContext, _: ExecutionContext)) + .expects(requestData, *, *) + } + + } + +} diff --git a/test/v7/listCalculations/MockListCalculationsValidatorFactory.scala b/test/v7/listCalculations/MockListCalculationsValidatorFactory.scala new file mode 100644 index 000000000..1c023d58e --- /dev/null +++ b/test/v7/listCalculations/MockListCalculationsValidatorFactory.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations + +import shared.controllers.validators.{MockValidatorFactory, Validator} +import org.scalamock.handlers.CallHandler +import v7.listCalculations.model.request.ListCalculationsRequestData +import v7.listCalculations.schema.ListCalculationsSchema + +trait MockListCalculationsValidatorFactory extends MockValidatorFactory[ListCalculationsRequestData] { + + val mockListCalculationsFactory: ListCalculationsValidatorFactory = mock[ListCalculationsValidatorFactory] + + def validator(): CallHandler[Validator[ListCalculationsRequestData]] = + (mockListCalculationsFactory.validator(_: String, _: Option[String], _: ListCalculationsSchema)).expects(*, *, *) + +} diff --git a/test/v7/listCalculations/def1/Def1_ListCalculationsValidatorSpec.scala b/test/v7/listCalculations/def1/Def1_ListCalculationsValidatorSpec.scala new file mode 100644 index 000000000..b4131f2e8 --- /dev/null +++ b/test/v7/listCalculations/def1/Def1_ListCalculationsValidatorSpec.scala @@ -0,0 +1,101 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.def1 + +import shared.models.domain.{Nino, TaxYear} +import shared.models.errors._ +import shared.utils.UnitSpec +import v7.listCalculations.model.request.Def1_ListCalculationsRequestData + +class Def1_ListCalculationsValidatorSpec extends UnitSpec { + + private implicit val correlationId: String = "1234" + + private val validNino = "ZG903729C" + private val validTaxYear = "2017-18" + + private val parsedNino = Nino(validNino) + private val parsedTaxYear = TaxYear.fromMtd(validTaxYear) + + private def validator(nino: String, taxYear: Option[String]) = + new Def1_ListCalculationsValidator(nino, taxYear) + + "validator" should { + "return the parsed domain object" when { + "a valid request is supplied with a tax year" in { + val result = validator(validNino, Some(validTaxYear)).validateAndWrapResult() + result shouldBe Right(Def1_ListCalculationsRequestData(parsedNino, parsedTaxYear)) + } + + "a valid request is supplied without a tax year" in { + val result = validator(validNino, None).validateAndWrapResult() + result shouldBe Right(Def1_ListCalculationsRequestData(parsedNino, TaxYear.now())) + } + } + + "return NinoFormatError error" when { + "an invalid nino is supplied" in { + val result = validator("A12344A", Some(validTaxYear)).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, NinoFormatError) + ) + } + } + + "return TaxYearFormatError error" when { + "an invalid tax year is supplied" in { + val result = validator(validNino, Some("201718")).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, TaxYearFormatError) + ) + } + } + + "return RuleTaxYearNotSupportedError error" when { + "an out of range tax year is supplied" in { + val result = validator(validNino, Some("2016-17")).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, RuleTaxYearNotSupportedError) + ) + } + } + + "return RuleTaxYearRangeInvalidError error" when { + "an invalid tax year range is supplied" in { + val result = validator(validNino, Some("2017-19")).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, RuleTaxYearRangeInvalidError) + ) + } + } + + "return multiple errors" when { + "multiple invalid parameters are provided" in { + val result = validator("not-a-nino", Some("2017-19")).validateAndWrapResult() + + result shouldBe Left( + ErrorWrapper( + correlationId, + BadRequestError, + Some(List(NinoFormatError, RuleTaxYearRangeInvalidError)) + ) + ) + } + } + } + +} diff --git a/test/v7/listCalculations/def1/model/Def1_ListCalculationsFixture.scala b/test/v7/listCalculations/def1/model/Def1_ListCalculationsFixture.scala new file mode 100644 index 000000000..55d511f7d --- /dev/null +++ b/test/v7/listCalculations/def1/model/Def1_ListCalculationsFixture.scala @@ -0,0 +1,77 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.def1.model + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import v7.common.model.response.CalculationType +import v7.listCalculations.def1.model.response.{Calculation, Def1_Calculation} +import v7.listCalculations.model.response.{Def1_ListCalculationsResponse, ListCalculationsResponse} + +trait Def1_ListCalculationsFixture { + + val listCalculationsDownstreamJson: JsValue = Json.parse(""" + |[ + | { + | "calculationId":"c432a56d-e811-474c-a26a-76fc3bcaefe5", + | "calculationTimestamp":"2021-07-12T07:51:43.112Z", + | "calculationType":"crystallisation", + | "requestedBy":"customer", + | "year":2021, + | "fromDate":"2021-01-01", + | "toDate":"2021-12-31", + | "totalIncomeTaxAndNicsDue":10000.12, + | "intentToCrystallise":true, + | "crystallised":true, + | "crystallisationTimestamp":"2021-07-13T07:51:43.112Z" + | } + |] + """.stripMargin) + + val listCalculationsMtdJson: JsValue = Json.parse(""" + |{ + | "calculations": [ + | { + | "calculationId":"c432a56d-e811-474c-a26a-76fc3bcaefe5", + | "calculationTimestamp":"2021-07-12T07:51:43.112Z", + | "calculationType":"finalDeclaration", + | "requestedBy":"customer", + | "taxYear":"2020-21", + | "totalIncomeTaxAndNicsDue":10000.12, + | "intentToSubmitFinalDeclaration":true, + | "finalDeclaration":true, + | "finalDeclarationTimestamp":"2021-07-13T07:51:43.112Z" + | } + | ] + |} + """.stripMargin) + + val calculationModel: Def1_Calculation = Def1_Calculation( + calculationId = "c432a56d-e811-474c-a26a-76fc3bcaefe5", + calculationTimestamp = "2021-07-12T07:51:43.112Z", + calculationType = CalculationType.`finalDeclaration`, + requestedBy = Some("customer"), + taxYear = Some(TaxYear.fromDownstreamInt(2021)), + totalIncomeTaxAndNicsDue = Some(10000.12), + intentToSubmitFinalDeclaration = Some(true), + finalDeclaration = Some(true), + finalDeclarationTimestamp = Some("2021-07-13T07:51:43.112Z") + ) + + val listCalculationsResponseModel: ListCalculationsResponse[Calculation] = Def1_ListCalculationsResponse(Seq(calculationModel)) + +} diff --git a/test/v7/listCalculations/def1/model/response/Def1_ListCalculationsResponseSpec.scala b/test/v7/listCalculations/def1/model/response/Def1_ListCalculationsResponseSpec.scala new file mode 100644 index 000000000..29552d67a --- /dev/null +++ b/test/v7/listCalculations/def1/model/response/Def1_ListCalculationsResponseSpec.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.def1.model.response + +import play.api.libs.json.Json +import shared.utils.UnitSpec +import v7.listCalculations.def1.model.Def1_ListCalculationsFixture +import v7.listCalculations.model.response.Def1_ListCalculationsResponse + +class Def1_ListCalculationsResponseSpec extends UnitSpec with Def1_ListCalculationsFixture { + + "ListCalculationsResponse" when { + "read from downstream JSON" must { + "return the expected data model" in { + listCalculationsDownstreamJson.as[Def1_ListCalculationsResponse[Def1_Calculation]] shouldBe listCalculationsResponseModel + } + } + + "written to MTD JSON" must { + "produce the expected JSON body" in { + Json.toJson(listCalculationsResponseModel) shouldBe listCalculationsMtdJson + } + } + } +} diff --git a/test/v7/listCalculations/schema/ListCalculationsSchemaSpec.scala b/test/v7/listCalculations/schema/ListCalculationsSchemaSpec.scala new file mode 100644 index 000000000..9877b0e41 --- /dev/null +++ b/test/v7/listCalculations/schema/ListCalculationsSchemaSpec.scala @@ -0,0 +1,66 @@ +/* + * Copyright 2024 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.listCalculations.schema + +import shared.models.domain.{TaxYear, TaxYearPropertyCheckSupport} +import org.scalacheck.{Arbitrary, Gen} +import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks +import shared.utils.UnitSpec + +import java.time.{Clock, LocalDate, ZoneOffset} + +class ListCalculationsSchemaSpec extends UnitSpec with ScalaCheckDrivenPropertyChecks with TaxYearPropertyCheckSupport { + + "schema lookup" when { + "a tax year is present" must { + "use Def1 for tax years from 2023-24" in { + forTaxYearsFrom(TaxYear.fromMtd("2023-24")) { taxYear => + ListCalculationsSchema.schemaFor(Some(taxYear.asMtd)) shouldBe ListCalculationsSchema.Def1 + } + } + + "use Def1 for pre-TYS tax years" in { + forPreTysTaxYears { taxYear => + ListCalculationsSchema.schemaFor(Some(taxYear.asMtd)) shouldBe ListCalculationsSchema.Def1 + } + } + } + + "the tax year is present but not valid" must { + "use a default of Def1" in { + ListCalculationsSchema.schemaFor(Some("NotATaxYear")) shouldBe ListCalculationsSchema.Def1 + } + } + + "no tax year is present" must { + def clockForTimeInYear(year: Int) = + Clock.fixed(LocalDate.of(year, 6, 1).atStartOfDay().toInstant(ZoneOffset.UTC), ZoneOffset.UTC) + + "use the same schema as for the current tax year" in { + implicit val arbYear: Arbitrary[Int] = Arbitrary(Gen.choose(min = 2000, max = 2099)) + + forAll { year: Int => + implicit val clock: Clock = clockForTimeInYear(year) + + ListCalculationsSchema.schemaFor(None) shouldBe + ListCalculationsSchema.schemaFor(Some(TaxYear.currentTaxYear.asMtd)) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/MockRetrieveCalculationConnector.scala b/test/v7/retrieveCalculation/MockRetrieveCalculationConnector.scala new file mode 100644 index 000000000..cce55ae04 --- /dev/null +++ b/test/v7/retrieveCalculation/MockRetrieveCalculationConnector.scala @@ -0,0 +1,42 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import org.scalamock.handlers.CallHandler +import org.scalamock.scalatest.MockFactory +import shared.connectors.DownstreamOutcome +import uk.gov.hmrc.http.HeaderCarrier +import v7.retrieveCalculation.models.request.RetrieveCalculationRequestData +import v7.retrieveCalculation.models.response.RetrieveCalculationResponse + +import scala.concurrent.{ExecutionContext, Future} + +trait MockRetrieveCalculationConnector extends MockFactory { + + val mockConnector: RetrieveCalculationConnector = mock[RetrieveCalculationConnector] + + object MockRetrieveCalculationConnector { + + def retrieveCalculation(request: RetrieveCalculationRequestData): CallHandler[Future[DownstreamOutcome[RetrieveCalculationResponse]]] = { + (mockConnector + .retrieveCalculation(_: RetrieveCalculationRequestData)(_: HeaderCarrier, _: ExecutionContext, _: String)) + .expects(request, *, *, *) + } + + } + +} diff --git a/test/v7/retrieveCalculation/MockRetrieveCalculationService.scala b/test/v7/retrieveCalculation/MockRetrieveCalculationService.scala new file mode 100644 index 000000000..e0b3b264a --- /dev/null +++ b/test/v7/retrieveCalculation/MockRetrieveCalculationService.scala @@ -0,0 +1,44 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import org.scalamock.handlers.CallHandler +import org.scalamock.scalatest.MockFactory +import shared.controllers.RequestContext +import shared.models.errors.ErrorWrapper +import shared.models.outcomes.ResponseWrapper +import v7.retrieveCalculation.models.request.RetrieveCalculationRequestData +import v7.retrieveCalculation.models.response.RetrieveCalculationResponse + +import scala.concurrent.{ExecutionContext, Future} + +trait MockRetrieveCalculationService extends MockFactory { + + val mockRetrieveCalculationService: RetrieveCalculationService = mock[RetrieveCalculationService] + + object MockRetrieveCalculationService { + + def retrieveCalculation( + request: RetrieveCalculationRequestData): CallHandler[Future[Either[ErrorWrapper, ResponseWrapper[RetrieveCalculationResponse]]]] = { + (mockRetrieveCalculationService + .retrieveCalculation(_: RetrieveCalculationRequestData)(_: RequestContext, _: ExecutionContext)) + .expects(request, *, *) + } + + } + +} diff --git a/test/v7/retrieveCalculation/MockRetrieveCalculationValidatorFactory.scala b/test/v7/retrieveCalculation/MockRetrieveCalculationValidatorFactory.scala new file mode 100644 index 000000000..c5a7f1fc4 --- /dev/null +++ b/test/v7/retrieveCalculation/MockRetrieveCalculationValidatorFactory.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import org.scalamock.handlers.CallHandler +import shared.controllers.validators.{MockValidatorFactory, Validator} +import v7.retrieveCalculation.models.request.RetrieveCalculationRequestData +import v7.retrieveCalculation.schema.RetrieveCalculationSchema + +trait MockRetrieveCalculationValidatorFactory extends MockValidatorFactory[RetrieveCalculationRequestData] { + + val mockRetrieveCalculationValidatorFactory: RetrieveCalculationValidatorFactory = mock[RetrieveCalculationValidatorFactory] + + def validator(): CallHandler[Validator[RetrieveCalculationRequestData]] = + (mockRetrieveCalculationValidatorFactory.validator(_: String, _: String, _: String, _: RetrieveCalculationSchema)).expects(*, *, *, *) + +} diff --git a/test/v7/retrieveCalculation/RetrieveCalculationConnectorSpec.scala b/test/v7/retrieveCalculation/RetrieveCalculationConnectorSpec.scala new file mode 100644 index 000000000..46709055f --- /dev/null +++ b/test/v7/retrieveCalculation/RetrieveCalculationConnectorSpec.scala @@ -0,0 +1,114 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import org.scalamock.handlers.CallHandler +import shared.connectors.{ConnectorSpec, DownstreamOutcome} +import shared.models.domain.{CalculationId, Nino, TaxYear} +import shared.models.errors.{DownstreamErrorCode, DownstreamErrors} +import shared.models.outcomes.ResponseWrapper +import v7.retrieveCalculation.def1.model.Def1_CalculationFixture +import v7.retrieveCalculation.models.request.{Def1_RetrieveCalculationRequestData, RetrieveCalculationRequestData} +import v7.retrieveCalculation.models.response.RetrieveCalculationResponse + +import scala.concurrent.Future + +class RetrieveCalculationConnectorSpec extends ConnectorSpec with Def1_CalculationFixture { + + val nino: Nino = Nino("ZG903729C") + val calculationId: CalculationId = CalculationId("f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c") + + private val preTysTaxYear = TaxYear.fromMtd("2018-19") + private val tysTaxYear = TaxYear.fromMtd("2023-24") + + "retrieveCalculation" should { + "return a valid response" when { + "a valid request is supplied" in new IfsTest with Test { + def taxYear: TaxYear = preTysTaxYear + val outcome: Right[Nothing, ResponseWrapper[RetrieveCalculationResponse]] = + Right(ResponseWrapper(correlationId, minimalCalculationR8bResponse)) + + stubHttpResponse(outcome) + + await(connector.retrieveCalculation(request)) shouldBe outcome + } + + "a valid request with Tax Year Specific tax year is supplied" in new TysIfsTest with Test { + def taxYear: TaxYear = tysTaxYear + val outcome: Right[Nothing, ResponseWrapper[RetrieveCalculationResponse]] = + Right(ResponseWrapper(correlationId, minimalCalculationR8bResponse)) + + stubTysHttpResponse(outcome) + + await(connector.retrieveCalculation(request)) shouldBe outcome + } + + "response is an error" must { + val downstreamErrorResponse: DownstreamErrors = + DownstreamErrors.single(DownstreamErrorCode("SOME_ERROR")) + val outcome = Left(ResponseWrapper(correlationId, downstreamErrorResponse)) + + "return the error" in new IfsTest with Test { + def taxYear: TaxYear = preTysTaxYear + stubHttpResponse(outcome) + + val result: DownstreamOutcome[RetrieveCalculationResponse] = + await(connector.retrieveCalculation(request)) + result shouldBe outcome + } + + "return the error given a TYS tax year request" in new TysIfsTest with Test { + def taxYear: TaxYear = tysTaxYear + stubTysHttpResponse(outcome) + + val result: DownstreamOutcome[RetrieveCalculationResponse] = + await(connector.retrieveCalculation(request)) + result shouldBe outcome + } + } + } + } + + trait Test { _: ConnectorTest => + def taxYear: TaxYear + + val request: RetrieveCalculationRequestData = Def1_RetrieveCalculationRequestData(nino, taxYear, calculationId) + + val connector: RetrieveCalculationConnector = new RetrieveCalculationConnector( + http = mockHttpClient, + appConfig = mockAppConfig + ) + + protected def stubHttpResponse( + outcome: DownstreamOutcome[RetrieveCalculationResponse]): CallHandler[Future[DownstreamOutcome[RetrieveCalculationResponse]]]#Derived = { + willGet( + url = s"$baseUrl/income-tax/view/calculations/liability/${nino.nino}/$calculationId" + ) + .returns(Future.successful(outcome)) + } + + protected def stubTysHttpResponse( + outcome: DownstreamOutcome[RetrieveCalculationResponse]): CallHandler[Future[DownstreamOutcome[RetrieveCalculationResponse]]]#Derived = { + willGet( + url = s"$baseUrl/income-tax/view/calculations/liability/${taxYear.asTysDownstream}/${nino.nino}/$calculationId" + ) + .returns(Future.successful(outcome)) + } + + } + +} diff --git a/test/v7/retrieveCalculation/RetrieveCalculationControllerSpec.scala b/test/v7/retrieveCalculation/RetrieveCalculationControllerSpec.scala new file mode 100644 index 000000000..4fc959e28 --- /dev/null +++ b/test/v7/retrieveCalculation/RetrieveCalculationControllerSpec.scala @@ -0,0 +1,258 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import play.api.Configuration +import play.api.libs.json.{JsObject, JsValue} +import play.api.mvc.Result +import shared.config.MockAppConfig +import shared.controllers.{ControllerBaseSpec, ControllerTestRunner} +import shared.models.audit.{AuditEvent, AuditResponse, GenericAuditDetail} +import shared.models.domain.{CalculationId, Nino, TaxYear} +import shared.models.errors.{ErrorWrapper, NinoFormatError, RuleTaxYearNotSupportedError} +import shared.models.outcomes.ResponseWrapper +import shared.services.{MockAuditService, MockEnrolmentsAuthService, MockMtdIdLookupService} +import shared.utils.MockIdGenerator +import v7.retrieveCalculation.def1.model.Def1_CalculationFixture +import v7.retrieveCalculation.models.request.{Def1_RetrieveCalculationRequestData, RetrieveCalculationRequestData} + +import scala.concurrent.ExecutionContext.Implicits.global +import scala.concurrent.Future + +class RetrieveCalculationControllerSpec + extends ControllerBaseSpec + with ControllerTestRunner + with MockEnrolmentsAuthService + with MockMtdIdLookupService + with MockRetrieveCalculationValidatorFactory + with MockRetrieveCalculationService + with MockAuditService + with MockIdGenerator + with MockAppConfig + with Def1_CalculationFixture { + + private val calculationId = "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c" + private val responseWithR8b = minimalCalculationR8bResponse + private val responseWithAdditionalFields = minimalCalculationAdditionalFieldsResponse + private val responseWithCl290Enabled = minimalCalculationCl290EnabledResponse + private val responseWithBasicRateDivergenceEnabled = minimalCalculationBasicRateDivergenceEnabledResponse + private val mtdResponseWithR8BJson = minimumCalculationResponseR8BEnabledJson + private val mtdResponseWithAdditionalFieldsJson = responseAdditionalFieldsEnabledJson + private val mtdResponseWithCl290EnabledJson = minimumResponseCl290EnabledJson + private val mtdResponseWithBasicRateDivergenceEnabledJson = minimumCalculationResponseBasicRateDivergenceEnabledJson + + "handleRequest" should { + "return OK with the calculation" when { + "happy path with R8B feature switch enabled" in new NonTysTest { + willUseValidator(returningSuccess(requestData)) + + MockRetrieveCalculationService + .retrieveCalculation(requestData) + .returns(Future.successful(Right(ResponseWrapper(correlationId, responseWithR8b)))) + + MockedAppConfig.featureSwitchConfig + .returns( + Configuration( + "r8b-api.enabled" -> true, + "retrieveSAAdditionalFields.enabled" -> false, + "cl290.enabled" -> false, + "basicRateDivergence.enabled" -> false + )) + .anyNumberOfTimes() + + runOkTestWithAudit( + expectedStatus = OK, + maybeExpectedResponseBody = Some(mtdResponseWithR8BJson), + maybeAuditResponseBody = Some(mtdResponseWithR8BJson) + ) + } + + "happy path with Additional Fields feature switch enabled" in new NonTysTest { + willUseValidator(returningSuccess(requestData)) + + MockRetrieveCalculationService + .retrieveCalculation(requestData) + .returns(Future.successful(Right(ResponseWrapper(correlationId, responseWithAdditionalFields)))) + + MockedAppConfig.featureSwitchConfig + .returns( + Configuration( + "r8b-api.enabled" -> false, + "retrieveSAAdditionalFields.enabled" -> true, + "cl290.enabled" -> false, + "basicRateDivergence.enabled" -> false)) + .anyNumberOfTimes() + + runOkTestWithAudit( + expectedStatus = OK, + maybeExpectedResponseBody = Some(mtdResponseWithAdditionalFieldsJson), + maybeAuditResponseBody = Some(mtdResponseWithAdditionalFieldsJson) + ) + } + + "happy path with cl290 feature switch enabled" in new NonTysTest { + willUseValidator(returningSuccess(requestData)) + + MockRetrieveCalculationService + .retrieveCalculation(requestData) + .returns(Future.successful(Right(ResponseWrapper(correlationId, responseWithCl290Enabled)))) + + MockedAppConfig.featureSwitchConfig + .returns( + Configuration( + "r8b-api.enabled" -> false, + "retrieveSAAdditionalFields.enabled" -> false, + "cl290.enabled" -> true, + "basicRateDivergence.enabled" -> false)) + .anyNumberOfTimes() + + runOkTestWithAudit( + expectedStatus = OK, + maybeExpectedResponseBody = Some(mtdResponseWithCl290EnabledJson), + maybeAuditResponseBody = Some(mtdResponseWithCl290EnabledJson) + ) + } + + "happy path with BasicRateDivergence feature switch enabled and TYS (2025)" in new TysTest { + willUseValidator(returningSuccess(requestData)) + + MockRetrieveCalculationService + .retrieveCalculation(requestData) + .returns(Future.successful(Right(ResponseWrapper(correlationId, responseWithBasicRateDivergenceEnabled)))) + + MockedAppConfig.featureSwitchConfig + .returns( + Configuration( + "r8b-api.enabled" -> false, + "retrieveSAAdditionalFields.enabled" -> false, + "cl290.enabled" -> false, + "basicRateDivergence.enabled" -> true)) + .anyNumberOfTimes() + + runOkTestWithAudit( + expectedStatus = OK, + maybeExpectedResponseBody = Some(mtdResponseWithBasicRateDivergenceEnabledJson), + maybeAuditResponseBody = Some(mtdResponseWithBasicRateDivergenceEnabledJson) + ) + } + + "happy path with R8B; additional fields; cl290 and basicRateDivergence feature switches disabled" in new NonTysTest { + val updatedMtdResponse: JsObject = minimumCalculationResponseWithSwitchesDisabledJson + willUseValidator(returningSuccess(requestData)) + + MockRetrieveCalculationService + .retrieveCalculation(requestData) + .returns(Future.successful(Right(ResponseWrapper(correlationId, responseWithR8b)))) + + MockedAppConfig.featureSwitchConfig + .returns( + Configuration( + "r8b-api.enabled" -> false, + "retrieveSAAdditionalFields.enabled" -> false, + "cl290.enabled" -> false, + "basicRateDivergence.enabled" -> false)) + .anyNumberOfTimes() + + runOkTestWithAudit( + expectedStatus = OK, + maybeExpectedResponseBody = Some(updatedMtdResponse), + maybeAuditResponseBody = Some(updatedMtdResponse) + ) + } + + } + + "return the error as per spec" when { + "the parser validation fails" in new NonTysTest { + + willUseValidator(returning(NinoFormatError)) + + MockedAppConfig.featureSwitchConfig + .returns(Configuration("r8b-api.enabled" -> true)) + .anyNumberOfTimes() + + runErrorTest(NinoFormatError) + } + + "the service returns an error" in new NonTysTest { + + willUseValidator(returningSuccess(requestData)) + + MockedAppConfig.featureSwitchConfig + .returns(Configuration("r8b-api.enabled" -> true)) + .anyNumberOfTimes() + + MockRetrieveCalculationService + .retrieveCalculation(requestData) + .returns(Future.successful(Left(ErrorWrapper(correlationId, RuleTaxYearNotSupportedError)))) + + runErrorTest(RuleTaxYearNotSupportedError) + } + } + } + + trait Test extends ControllerTest with AuditEventChecking[GenericAuditDetail] { + def taxYear: String + + def requestData: RetrieveCalculationRequestData = + Def1_RetrieveCalculationRequestData(Nino(validNino), TaxYear.fromMtd(taxYear), CalculationId(calculationId)) + + lazy val controller = new RetrieveCalculationController( + authService = mockEnrolmentsAuthService, + lookupService = mockMtdIdLookupService, + validatorFactory = mockRetrieveCalculationValidatorFactory, + service = mockRetrieveCalculationService, + cc = cc, + idGenerator = mockIdGenerator, + auditService = mockAuditService + ) + + // MockedAppConfig.featureSwitchConfig.anyNumberOfTimes() returns Configuration( + // "supporting-agents-access-control.enabled" -> true + // ) + + MockedAppConfig.endpointAllowsSupportingAgents(controller.endpointName).anyNumberOfTimes() returns false + + protected def callController(): Future[Result] = + controller.retrieveCalculation(validNino, taxYear, calculationId)(fakeRequest) + + protected def event(auditResponse: AuditResponse, requestBody: Option[JsValue]): AuditEvent[GenericAuditDetail] = + AuditEvent( + auditType = "RetrieveATaxCalculation", + transactionName = "retrieve-a-tax-calculation", + detail = GenericAuditDetail( + versionNumber = apiVersion.name, + userType = "Individual", + agentReferenceNumber = None, + params = Map("nino" -> validNino, "calculationId" -> calculationId, "taxYear" -> taxYear), + requestBody = requestBody, + `X-CorrelationId` = correlationId, + auditResponse = auditResponse + ) + ) + + } + + trait NonTysTest extends Test { + def taxYear: String = "2017-18" + } + + trait TysTest extends Test { + def taxYear: String = "2024-25" + } + +} diff --git a/test/v7/retrieveCalculation/RetrieveCalculationServiceSpec.scala b/test/v7/retrieveCalculation/RetrieveCalculationServiceSpec.scala new file mode 100644 index 000000000..c03a5e14f --- /dev/null +++ b/test/v7/retrieveCalculation/RetrieveCalculationServiceSpec.scala @@ -0,0 +1,92 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import shared.models.domain.{CalculationId, Nino, TaxYear} +import shared.models.errors._ +import shared.models.outcomes.ResponseWrapper +import shared.services.ServiceSpec +import uk.gov.hmrc.http.HeaderCarrier +import v7.retrieveCalculation.def1.model.Def1_CalculationFixture +import v7.retrieveCalculation.models.request.{Def1_RetrieveCalculationRequestData, RetrieveCalculationRequestData} +import v7.retrieveCalculation.models.response.RetrieveCalculationResponse + +import scala.concurrent.Future + +class RetrieveCalculationServiceSpec extends ServiceSpec with Def1_CalculationFixture { + + private val nino: Nino = Nino("ZG903729C") + private val taxYear: TaxYear = TaxYear.fromMtd("2019-20") + private val calculationId: CalculationId = CalculationId("someCalcId") + + val request: RetrieveCalculationRequestData = Def1_RetrieveCalculationRequestData(nino, taxYear, calculationId) + val response: RetrieveCalculationResponse = minimalCalculationResponse + + trait Test extends MockRetrieveCalculationConnector { + implicit val hc: HeaderCarrier = HeaderCarrier() + + val service = new RetrieveCalculationService(mockConnector) + } + + "retrieveCalculation" should { + "return a valid response" when { + "a valid request is supplied" in new Test { + MockRetrieveCalculationConnector + .retrieveCalculation(request) + .returns(Future.successful(Right(ResponseWrapper(correlationId, response)))) + + await(service.retrieveCalculation(request)) shouldBe Right(ResponseWrapper(correlationId, response)) + } + } + + "return error response" when { + + def serviceError(downstreamErrorCode: String, error: MtdError): Unit = + s"a $downstreamErrorCode error is returned from the service" in new Test { + + MockRetrieveCalculationConnector + .retrieveCalculation(request) + .returns(Future.successful(Left(ResponseWrapper(correlationId, DownstreamErrors.single(DownstreamErrorCode(downstreamErrorCode)))))) + + await(service.retrieveCalculation(request)) shouldBe Left(ErrorWrapper(correlationId, error)) + } + + // TODO ensure errors match + val errors = Seq( + ("INVALID_TAXABLE_ENTITY_ID", NinoFormatError), + ("INVALID_CALCULATION_ID", CalculationIdFormatError), + ("INVALID_CORRELATIONID", InternalError), + ("INVALID_CONSUMERID", InternalError), + ("NO_DATA_FOUND", NotFoundError), + ("SERVER_ERROR", InternalError), + ("SERVICE_UNAVAILABLE", InternalError), + ("UNMATCHED_STUB_ERROR", RuleIncorrectGovTestScenarioError) + ) + + val extraTysErrors = Seq( + ("INVALID_TAX_YEAR", TaxYearFormatError), + ("INVALID_CORRELATION_ID", InternalError), + ("INVALID_CONSUMER_ID", InternalError), + ("NOT_FOUND", NotFoundError), + ("TAX_YEAR_NOT_SUPPORTED", RuleTaxYearNotSupportedError) + ) + + (errors ++ extraTysErrors).foreach(args => (serviceError _).tupled(args)) + } + } + +} diff --git a/test/v7/retrieveCalculation/RetrieveCalculationValidatorFactorySpec.scala b/test/v7/retrieveCalculation/RetrieveCalculationValidatorFactorySpec.scala new file mode 100644 index 000000000..b87bfab01 --- /dev/null +++ b/test/v7/retrieveCalculation/RetrieveCalculationValidatorFactorySpec.scala @@ -0,0 +1,50 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation + +import shared.utils.UnitSpec +import v7.retrieveCalculation.def1.Def1_RetrieveCalculationValidator +import v7.retrieveCalculation.def2.Def2_RetrieveCalculationValidator +import v7.retrieveCalculation.schema.RetrieveCalculationSchema + +class RetrieveCalculationValidatorFactorySpec extends UnitSpec { + + private val validNino = "ZG903729C" + private val validTaxYear = "2017-18" + private val validCalculationId = "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c" + + private val validatorFactory = new RetrieveCalculationValidatorFactory + + "validator factory" when { + + "given any request for schema 1" should { + "return the Validator for schema definition 1" in { + validatorFactory.validator(validNino, validTaxYear, validCalculationId, RetrieveCalculationSchema.Def1) shouldBe + a[Def1_RetrieveCalculationValidator] + } + } + + "given any request for schema 2" should { + "return the Validator for schema definition 2" in { + validatorFactory.validator(validNino, validTaxYear, validCalculationId, RetrieveCalculationSchema.Def2) shouldBe + a[Def2_RetrieveCalculationValidator] + } + } + + } + +} diff --git a/test/v7/retrieveCalculation/def1/Def1_RetrieveCalculationValidatorSpec.scala b/test/v7/retrieveCalculation/def1/Def1_RetrieveCalculationValidatorSpec.scala new file mode 100644 index 000000000..f6182e0b6 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/Def1_RetrieveCalculationValidatorSpec.scala @@ -0,0 +1,107 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1 + +import shared.models.domain.{CalculationId, Nino, TaxYear} +import shared.models.errors._ +import shared.utils.UnitSpec +import v7.retrieveCalculation.models.request.Def1_RetrieveCalculationRequestData + +class Def1_RetrieveCalculationValidatorSpec extends UnitSpec { + + private implicit val correlationId: String = "1234" + + private val validNino = "ZG903729C" + private val validTaxYear = "2017-18" + private val validCalculationId = "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c" + + private val parsedNino = Nino(validNino) + private val parsedTaxYear = TaxYear.fromMtd(validTaxYear) + private val parsedCalculationId = CalculationId(validCalculationId) + + private def validator(nino: String, taxYear: String, calculationId: String) = + new Def1_RetrieveCalculationValidator(nino, taxYear, calculationId) + + "validator" should { + "return the parsed domain object" when { + "a valid request is supplied" in { + val result = validator(validNino, validTaxYear, validCalculationId).validateAndWrapResult() + result shouldBe Right(Def1_RetrieveCalculationRequestData(parsedNino, parsedTaxYear, parsedCalculationId)) + } + } + + "return NinoFormatError error" when { + "an invalid nino is supplied" in { + val result = validator("A12344A", validTaxYear, validCalculationId).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, NinoFormatError) + ) + } + } + + "return TaxYearFormatError error" when { + "an invalid tax year is supplied" in { + val result = validator(validNino, "201718", validCalculationId).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, TaxYearFormatError) + ) + } + } + + "return RuleTaxYearNotSupportedError error" when { + "an out of range tax year is supplied" in { + val result = validator(validNino, "2016-17", validCalculationId).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, RuleTaxYearNotSupportedError) + ) + } + } + + "return RuleTaxYearRangeInvalidError error" when { + "an invalid tax year range is supplied" in { + val result = validator(validNino, "2017-19", validCalculationId).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, RuleTaxYearRangeInvalidError) + ) + } + } + + "return CalculationIdFormatError error" when { + "an invalid calculation id is supplied" in { + val result = validator(validNino, validTaxYear, "bad id").validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, CalculationIdFormatError) + ) + } + } + + "return multiple errors" when { + "multiple invalid parameters are provided" in { + val result = validator("not-a-nino", validTaxYear, "bad id").validateAndWrapResult() + + result shouldBe Left( + ErrorWrapper( + correlationId, + BadRequestError, + Some(List(CalculationIdFormatError, NinoFormatError)) + ) + ) + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala new file mode 100644 index 000000000..04031a51e --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala @@ -0,0 +1,873 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model + +import play.api.libs.json.{JsObject, JsValue, Json} +import shared.models.domain.TaxYear +import v7.common.model.response.CalculationType.`inYear` +import v7.common.model.response.IncomeSourceType +import v7.retrieveCalculation.def1.model.response.calculation.Calculation +import v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome.{EmploymentAndPensionsIncome, EmploymentAndPensionsIncomeDetail} +import v7.retrieveCalculation.def1.model.response.calculation.endOfYearEstimate.EndOfYearEstimate +import v7.retrieveCalculation.def1.model.response.calculation.otherIncome.{OtherIncome, PostCessationIncome, PostCessationReceipt} +import v7.retrieveCalculation.def1.model.response.calculation.reliefs.{BasicRateExtension, GiftAidTaxReductionWhereBasicRateDiffers, Reliefs} +import v7.retrieveCalculation.def1.model.response.calculation.taxCalculation.{Class2Nics, IncomeTax, Nics, TaxCalculation} +import v7.retrieveCalculation.def1.model.response.calculation.taxDeductedAtSource.TaxDeductedAtSource +import v7.retrieveCalculation.def1.model.response.inputs._ +import v7.retrieveCalculation.def1.model.response.metadata.Metadata +import v7.retrieveCalculation.models.response.Def1_RetrieveCalculationResponse + +trait Def1_CalculationFixture { + + val totalBasicRateExtension = 2000 + val totalAllowancesAndDeductions = 100 + val incomeTaxValue = 50 + + val calculationMtdJson: JsValue = + Json.parse(getClass.getResourceAsStream("/v7/retrieveCalculation/def1/model/response/calculation_mtd.json")) + + val calculationDownstreamJson: JsValue = + Json.parse(getClass.getResourceAsStream("/v7/retrieveCalculation/def1/model/response/calculation_downstream.json")) + + val reliefs: Reliefs = Reliefs( + basicRateExtension = + Some(BasicRateExtension(totalBasicRateExtension = Some(totalBasicRateExtension), giftAidRelief = None, pensionContributionReliefs = None)), + residentialFinanceCosts = None, + foreignTaxCreditRelief = None, + topSlicingRelief = None, + reliefsClaimed = None, + giftAidTaxReductionWhereBasicRateDiffers = None + ) + + val reliefsWithBasicRateDivergenceData: Reliefs = + reliefs.copy(basicRateExtension = None, giftAidTaxReductionWhereBasicRateDiffers = Some(GiftAidTaxReductionWhereBasicRateDiffers(Some(2000.25)))) + + val class2Nics: Class2Nics = Class2Nics( + amount = None, + weeklyRate = None, + weeks = None, + limit = None, + apportionedLimit = None, + underSmallProfitThreshold = true, + underLowerProfitThreshold = Some(true), + actualClass2Nic = None + ) + + val class2NicsWithoutUnderLowerProfitThreshold: Class2Nics = class2Nics.copy(underLowerProfitThreshold = None) + + val nics: Nics = Nics(class2Nics = Some(class2Nics), class4Nics = None, nic2NetOfDeductions = None, nic4NetOfDeductions = None, totalNic = None) + val nicsWithoutUnderLowerProfitThreshold: Nics = nics.copy(class2Nics = Some(class2NicsWithoutUnderLowerProfitThreshold)) + + val incomeTax: IncomeTax = IncomeTax( + totalIncomeReceivedFromAllSources = incomeTaxValue, + totalAllowancesAndDeductions = incomeTaxValue, + totalTaxableIncome = incomeTaxValue, + payPensionsProfit = None, + savingsAndGains = None, + dividends = None, + lumpSums = None, + gainsOnLifePolicies = None, + incomeTaxCharged = incomeTaxValue, + totalReliefs = None, + incomeTaxDueAfterReliefs = None, + totalNotionalTax = None, + marriageAllowanceRelief = None, + incomeTaxDueAfterTaxReductions = None, + incomeTaxDueAfterGiftAid = None, + totalPensionSavingsTaxCharges = None, + statePensionLumpSumCharges = None, + payeUnderpaymentsCodedOut = None, + totalIncomeTaxDue = None, + giftAidTaxChargeWhereBasicRateDiffers = None + ) + + val incomeTaxWithBasicRateDivergenceData: IncomeTax = incomeTax.copy(giftAidTaxChargeWhereBasicRateDiffers = Some(2000.25)) + + val taxCalculation: TaxCalculation = TaxCalculation( + incomeTax = Some(incomeTax), + nics = Some(nics), + totalTaxDeductedBeforeCodingOut = None, + saUnderpaymentsCodedOut = None, + totalIncomeTaxNicsCharged = None, + totalStudentLoansRepaymentAmount = None, + totalAnnuityPaymentsTaxCharged = None, + totalRoyaltyPaymentsTaxCharged = None, + totalTaxDeducted = None, + totalIncomeTaxAndNicsDue = Some(incomeTaxValue), + capitalGainsTax = None, + totalIncomeTaxAndNicsAndCgt = None + ) + + val taxCalculationWithBasicRateDivergenceData: TaxCalculation = taxCalculation.copy(incomeTax = Some(incomeTaxWithBasicRateDivergenceData)) + + val taxCalculationWithoutUnderLowerProfitThreshold: TaxCalculation = taxCalculation.copy(nics = Some(nicsWithoutUnderLowerProfitThreshold)) + + val employmentAndPensionsIncomeDetails: EmploymentAndPensionsIncomeDetail = EmploymentAndPensionsIncomeDetail( + incomeSourceId = None, + source = None, + occupationalPension = None, + employerRef = None, + employerName = None, + offPayrollWorker = Some(true), + payrollId = None, + startDate = None, + dateEmploymentEnded = None, + taxablePayToDate = None, + totalTaxToDate = None, + disguisedRemuneration = None, + lumpSums = None, + studentLoans = None, + benefitsInKind = None + ) + + val employmentAndPensionsIncome: EmploymentAndPensionsIncome = EmploymentAndPensionsIncome( + totalPayeEmploymentAndLumpSumIncome = None, + totalOccupationalPensionIncome = None, + totalBenefitsInKind = None, + tipsIncome = None, + employmentAndPensionsIncomeDetail = Some(Seq(employmentAndPensionsIncomeDetails)) + ) + + val eoyEstimates: EndOfYearEstimate = EndOfYearEstimate( + incomeSource = None, + totalEstimatedIncome = None, + totalAllowancesAndDeductions = Some(totalAllowancesAndDeductions), + totalTaxableIncome = None, + incomeTaxAmount = None, + nic2 = None, + nic4 = None, + totalTaxDeductedBeforeCodingOut = None, + saUnderpaymentsCodedOut = None, + totalNicAmount = None, + totalStudentLoansRepaymentAmount = None, + totalAnnuityPaymentsTaxCharged = None, + totalRoyaltyPaymentsTaxCharged = None, + totalTaxDeducted = None, + incomeTaxNicAmount = None, + cgtAmount = None, + incomeTaxNicAndCgtAmount = None + ) + // @formatter:on + + val calculationWithR8BData: Calculation = Calculation( + reliefs = Some(reliefs), + allowancesAndDeductions = None, + taxDeductedAtSource = None, + giftAid = None, + royaltyPayments = None, + notionalTax = None, + marriageAllowanceTransferredIn = None, + pensionContributionReliefs = None, + pensionSavingsTaxCharges = None, + studentLoans = None, + codedOutUnderpayments = None, + foreignPropertyIncome = None, + businessProfitAndLoss = None, + employmentAndPensionsIncome = Some(employmentAndPensionsIncome), + employmentExpenses = None, + seafarersDeductions = None, + foreignTaxForFtcrNotClaimed = None, + stateBenefitsIncome = None, + shareSchemesIncome = None, + foreignIncome = None, + chargeableEventGainsIncome = None, + savingsAndGainsIncome = None, + otherIncome = None, + dividendsIncome = None, + incomeSummaryTotals = None, + taxCalculation = Some(taxCalculation), + previousCalculation = None, + endOfYearEstimate = Some(eoyEstimates), + lossesAndClaims = None + ) + + val taxDeductedAtSource: TaxDeductedAtSource = + TaxDeductedAtSource(None, None, None, None, None, None, None, None, None, None, taxTakenOffTradingIncome = Some(2000.00)) + + val otherIncome: OtherIncome = + OtherIncome( + totalOtherIncome = 2000.00, + postCessationIncome = Some( + PostCessationIncome( + totalPostCessationReceipts = 2000.00, + postCessationReceipts = Seq(PostCessationReceipt(amount = 100.00, taxYearIncomeToBeTaxed = "2019-20")))) + ) + + val calculationWithAdditionalFields: Calculation = Calculation( + reliefs = None, + allowancesAndDeductions = None, + taxDeductedAtSource = None, + giftAid = None, + royaltyPayments = None, + notionalTax = None, + marriageAllowanceTransferredIn = None, + pensionContributionReliefs = None, + pensionSavingsTaxCharges = None, + studentLoans = None, + codedOutUnderpayments = None, + foreignPropertyIncome = None, + businessProfitAndLoss = None, + employmentAndPensionsIncome = None, + employmentExpenses = None, + seafarersDeductions = None, + foreignTaxForFtcrNotClaimed = None, + stateBenefitsIncome = None, + shareSchemesIncome = None, + foreignIncome = None, + chargeableEventGainsIncome = None, + savingsAndGainsIncome = None, + otherIncome = Some(otherIncome), + dividendsIncome = None, + incomeSummaryTotals = None, + taxCalculation = None, + previousCalculation = None, + endOfYearEstimate = None, + lossesAndClaims = None + ) + + val calculationWithCl290Enabled: Calculation = Calculation( + reliefs = None, + allowancesAndDeductions = None, + taxDeductedAtSource = Some(taxDeductedAtSource), + giftAid = None, + royaltyPayments = None, + notionalTax = None, + marriageAllowanceTransferredIn = None, + pensionContributionReliefs = None, + pensionSavingsTaxCharges = None, + studentLoans = None, + codedOutUnderpayments = None, + foreignPropertyIncome = None, + businessProfitAndLoss = None, + employmentAndPensionsIncome = None, + employmentExpenses = None, + seafarersDeductions = None, + foreignTaxForFtcrNotClaimed = None, + stateBenefitsIncome = None, + shareSchemesIncome = None, + foreignIncome = None, + chargeableEventGainsIncome = None, + savingsAndGainsIncome = None, + otherIncome = None, + dividendsIncome = None, + incomeSummaryTotals = None, + taxCalculation = None, + previousCalculation = None, + endOfYearEstimate = None, + lossesAndClaims = None + ) + + val calculationWithBasicRateDivergenceEnabled: Calculation = Calculation( + reliefs = Some(reliefsWithBasicRateDivergenceData), + allowancesAndDeductions = None, + taxDeductedAtSource = None, + giftAid = None, + royaltyPayments = None, + notionalTax = None, + marriageAllowanceTransferredIn = None, + pensionContributionReliefs = None, + pensionSavingsTaxCharges = None, + studentLoans = None, + codedOutUnderpayments = None, + foreignPropertyIncome = None, + businessProfitAndLoss = None, + employmentAndPensionsIncome = None, + employmentExpenses = None, + seafarersDeductions = None, + foreignTaxForFtcrNotClaimed = None, + stateBenefitsIncome = None, + shareSchemesIncome = None, + foreignIncome = None, + chargeableEventGainsIncome = None, + savingsAndGainsIncome = None, + otherIncome = None, + dividendsIncome = None, + incomeSummaryTotals = None, + taxCalculation = Some(taxCalculationWithBasicRateDivergenceData), + previousCalculation = None, + endOfYearEstimate = None, + lossesAndClaims = None + ) + + val calculationWithR8BDisabled: Calculation = + calculationWithR8BData.copy(employmentAndPensionsIncome = None, endOfYearEstimate = None, reliefs = None) + + val metadata: Metadata = Metadata( + calculationId = "", + taxYear = TaxYear.fromDownstream("2018"), + requestedBy = "", + requestedTimestamp = None, + calculationReason = "", + calculationTimestamp = None, + calculationType = `inYear`, + intentToSubmitFinalDeclaration = false, + finalDeclaration = false, + finalDeclarationTimestamp = None, + periodFrom = "", + periodTo = "" + ) + val metadataWithBasicRateDivergenceData: Metadata = metadata.copy(taxYear = TaxYear.fromDownstream("2025")) + + val inputs: Inputs = Inputs( + PersonalInformation("", None, "UK", None, None, None, None, None, None), + IncomeSources(None, None), + // @formatter:off + None, None, None, None, + None, None, None + ) + // @formatter:on + + val businessIncomeSourceWithAdditionalField: BusinessIncomeSource = BusinessIncomeSource( + incomeSourceId = "000000000000210", + incomeSourceType = IncomeSourceType.`self-employment`, + incomeSourceName = Some("string"), + accountingPeriodStartDate = "2018-04-06", + accountingPeriodEndDate = "2019-04-05", + source = "MTD-SA", + commencementDate = Some("2018-04-06"), + cessationDate = Some("2019-04-05"), + latestPeriodEndDate = "2021-12-02", + latestReceivedDateTime = "2021-12-02T15:25:48Z", + finalised = Some(true), + finalisationTimestamp = Some("2019-02-15T09:35:15.094Z"), + submissionPeriods = Some( + Seq( + SubmissionPeriod( + periodId = Some("001"), + startDate = "2018-04-06", + endDate = "2019-04-05", + receivedDateTime = "2019-02-15T09:35:04.843Z" + ))) + ) + + val inputsWithAdditionalFields: Inputs = Inputs( + PersonalInformation("", None, "UK", None, None, None, None, None, Some("No Status")), + IncomeSources(Some(Seq(businessIncomeSourceWithAdditionalField)), None), + // @formatter:off + None, None, None, None, + None, None, None + ) + // @formatter:on + + val minimalCalculationR8bResponse: Def1_RetrieveCalculationResponse = Def1_RetrieveCalculationResponse( + metadata = metadata, + inputs = inputs, + calculation = Some(calculationWithR8BData), + messages = None + ) + + val minimalCalculationAdditionalFieldsResponse: Def1_RetrieveCalculationResponse = Def1_RetrieveCalculationResponse( + metadata = metadata, + inputs = inputsWithAdditionalFields, + calculation = Some(calculationWithAdditionalFields), + messages = None + ) + + val minimalCalculationCl290EnabledResponse: Def1_RetrieveCalculationResponse = Def1_RetrieveCalculationResponse( + metadata = metadata, + inputs = inputs, + calculation = Some(calculationWithCl290Enabled), + messages = None + ) + + val minimalCalculationBasicRateDivergenceEnabledResponse: Def1_RetrieveCalculationResponse = Def1_RetrieveCalculationResponse( + metadata = metadataWithBasicRateDivergenceData, + inputs = inputs, + calculation = Some(calculationWithBasicRateDivergenceEnabled), + messages = None + ) + + // @formatter:off + val emptyCalculation: Calculation = Calculation( + None, None, None, None, None, None, + None, None, None, None, None, None, + None, None, None, None, None, None, + None, None, None, None, None, None, + None, None, None, None, None) + + val calcWithoutEndOfYearEstimate: Calculation = emptyCalculation.copy(reliefs= Some(reliefs),employmentAndPensionsIncome = Some(employmentAndPensionsIncome), taxCalculation = Some(taxCalculation)) + + + val calcWithoutBasicExtension: Calculation = emptyCalculation.copy(endOfYearEstimate = Some(eoyEstimates), employmentAndPensionsIncome = Some(employmentAndPensionsIncome), taxCalculation = Some(taxCalculation)) + + val calcWithoutOffPayrollWorker: Calculation = emptyCalculation.copy(reliefs= Some(reliefs),endOfYearEstimate = Some(eoyEstimates), taxCalculation = Some(taxCalculation)) + val calcWithoutUnderLowerProfitThreshold: Calculation = emptyCalculation.copy(taxCalculation=Some(taxCalculationWithoutUnderLowerProfitThreshold), reliefs= Some(reliefs),endOfYearEstimate = Some(eoyEstimates), employmentAndPensionsIncome = Some(employmentAndPensionsIncome)) + // @formatter:on + + val minimalCalculationResponse: Def1_RetrieveCalculationResponse = Def1_RetrieveCalculationResponse( + metadata = metadata, + inputs = inputs, + calculation = Some(calculationWithR8BData), + messages = None + ) + + val minimalCalculationResponseWithoutR8BData: Def1_RetrieveCalculationResponse = Def1_RetrieveCalculationResponse( + metadata = metadata, + inputs = inputs, + calculation = None, + messages = None + ) + + val minimumCalculationResponseMtdJson: JsObject = Json + .parse( + """ + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": "2017-18", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": false, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | }, + | "calculation": { + | "taxCalculation": { + | "incomeTax": { + | "totalIncomeReceivedFromAllSources": 50, + | "totalAllowancesAndDeductions": 50, + | "totalTaxableIncome": 50, + | "incomeTaxCharged": 50 + | }, + | "totalIncomeTaxAndNicsDue": 50, + | "nics": { + | "class2Nics": { + | "underSmallProfitThreshold": true, + | "underLowerProfitThreshold": true + | } + | } + | }, + | "employmentAndPensionsIncome": { + | "employmentAndPensionsIncomeDetail": [ + | { + | "offPayrollWorker": true + | } + | ] + | }, + | "reliefs": { + | "basicRateExtension": { + | "totalBasicRateExtension": 2000 + | } + | }, + | "endOfYearEstimate": { + | "totalAllowancesAndDeductions": 100 + | } + | } + |} + """.stripMargin + ) + .as[JsObject] + + val minimumCalculationResponseR8BEnabledJson: JsObject = Json + .parse( + """ + |{ + | "metadata": { + | "calculationId": "", + | "taxYear": "2017-18", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": false, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs": { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | }, + | "calculation": { + | "taxCalculation": { + | "incomeTax": { + | "totalIncomeReceivedFromAllSources": 50, + | "totalAllowancesAndDeductions": 50, + | "totalTaxableIncome": 50, + | "incomeTaxCharged": 50 + | }, + | "nics": { + | "class2Nics": { + | "underSmallProfitThreshold": true, + | "underLowerProfitThreshold": true + | } + | }, + | "totalIncomeTaxAndNicsDue": 50 + | }, + | "employmentAndPensionsIncome": { + | "employmentAndPensionsIncomeDetail": [ + | { + | "offPayrollWorker": true + | } + | ] + | }, + | "reliefs": { + | "basicRateExtension": { + | "totalBasicRateExtension": 2000 + | } + | }, + | "endOfYearEstimate": { + | "totalAllowancesAndDeductions": 100 + | } + | } + |} + """.stripMargin + ) + .as[JsObject] + + val responseAdditionalFieldsEnabledJson: JsObject = Json + .parse( + """ + { + "metadata": { + "calculationId": "", + "taxYear": "2017-18", + "requestedBy": "", + "calculationReason": "", + "calculationType": "inYear", + "intentToSubmitFinalDeclaration": false, + "finalDeclaration": false, + "periodFrom": "", + "periodTo": "" + }, + "inputs": { + "personalInformation": { + "identifier": "", + "taxRegime": "UK", + "itsaStatus": "No Status" + }, + "incomeSources": { + "businessIncomeSources": [ + { + "incomeSourceId": "000000000000210", + "incomeSourceType": "self-employment", + "incomeSourceName": "string", + "accountingPeriodStartDate": "2018-04-06", + "accountingPeriodEndDate": "2019-04-05", + "commencementDate": "2018-04-06", + "cessationDate": "2019-04-05", + "source": "MTD-SA", + "latestPeriodEndDate": "2021-12-02", + "latestReceivedDateTime": "2021-12-02T15:25:48Z", + "finalised": true, + "finalisationTimestamp": "2019-02-15T09:35:15.094Z", + "submissionPeriods": [ + { + "periodId": "001", + "startDate": "2018-04-06", + "endDate": "2019-04-05", + "receivedDateTime": "2019-02-15T09:35:04.843Z" + } + ] + } + ] + } + }, + "calculation": { + "otherIncome": { + "totalOtherIncome": 2000.00, + "postCessationIncome": { + "totalPostCessationReceipts": 2000.00, + "postCessationReceipts": [ + { + "amount": 100.00, + "taxYearIncomeToBeTaxed": "2019-20" + } + ] + } + } + } + } + """ + ) + .as[JsObject] + + val minimumResponseCl290EnabledJson: JsObject = Json + .parse( + """ + |{ + | "metadata":{ + | "calculationId":"", + | "taxYear":"2017-18", + | "requestedBy":"", + | "calculationReason":"", + | "calculationType":"inYear", + | "intentToSubmitFinalDeclaration":false, + | "finalDeclaration":false, + | "periodFrom":"", + | "periodTo":"" + | }, + | "inputs":{ + | "personalInformation":{ + | "identifier":"", + | "taxRegime":"UK" + | }, + | "incomeSources":{ + | + | } + | }, + | "calculation":{ + | "taxDeductedAtSource":{ + | "taxTakenOffTradingIncome":2000.00 + | } + | } + |} + """.stripMargin + ) + .as[JsObject] + + val minimumCalculationResponseBasicRateDivergenceEnabledJson: JsObject = Json + .parse( + """ + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": "2024-25", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": false, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | }, + | "calculation": { + | "taxCalculation": { + | "incomeTax": { + | "totalIncomeReceivedFromAllSources": 50, + | "totalAllowancesAndDeductions": 50, + | "totalTaxableIncome": 50, + | "incomeTaxCharged": 50, + | "giftAidTaxChargeWhereBasicRateDiffers":2000.25 + | }, + | "nics": { + | "class2Nics": { + | "underSmallProfitThreshold": true, + | "underLowerProfitThreshold": true + | } + | }, + | "totalIncomeTaxAndNicsDue": 50 + | }, + | "reliefs": { + | "giftAidTaxReductionWhereBasicRateDiffers": { + | "amount": 2000.25 + | } + | } + | } + |} +""".stripMargin + ) + .as[JsObject] + + val minimumCalculationResponseWithSwitchesDisabledJson: JsObject = Json + .parse( + """ + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": "2017-18", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": false, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | }, + | "calculation": { + | "taxCalculation":{ + | "incomeTax":{ + | "totalIncomeReceivedFromAllSources":50, + | "totalAllowancesAndDeductions":50, + | "totalTaxableIncome":50, + | "incomeTaxCharged":50 + | }, + | "nics":{ + | "class2Nics":{ + | "underSmallProfitThreshold":true, + | "underLowerProfitThreshold":true + | } + | }, + | "totalIncomeTaxAndNicsDue":50 + | } + | } + |} + """.stripMargin + ) + .as[JsObject] + + val emptyCalculationResponse: Def1_RetrieveCalculationResponse = Def1_RetrieveCalculationResponse( + metadata = metadata, + inputs = inputs, + calculation = Some(emptyCalculation), + messages = None + ) + + val minimumCalculationResponseJson: JsObject = Json + .parse( + """ + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": "2017-18", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": false, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | } + |} + """.stripMargin + ) + .as[JsObject] + + val emptyCalculationResponseMtdJson: JsObject = Json + .parse( + """ + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": "2017-18", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": false, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | }, + | "calculation" : { + | "endOfYearEstimate": { + | } + | } + |} + """.stripMargin + ) + .as[JsObject] + + val noEOYCalculationResponseMtdJson: JsObject = Json + .parse( + """ + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": "2017-18", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": false, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | } + |} + """.stripMargin + ) + .as[JsObject] + + val noUnderLowerProfitThresholdCalculationResponseMtdJson: JsObject = Json + .parse( + """ + |{ + | "metadata" : { + | "calculationId": "", + | "taxYear": "2017-18", + | "requestedBy": "", + | "calculationReason": "", + | "calculationType": "inYear", + | "intentToSubmitFinalDeclaration": false, + | "finalDeclaration": false, + | "periodFrom": "", + | "periodTo": "" + | }, + | "inputs" : { + | "personalInformation": { + | "identifier": "", + | "taxRegime": "UK" + | }, + | "incomeSources": {} + | }, + | "calculation": { + | "taxCalculation":{ + | "incomeTax":{ + | "totalIncomeReceivedFromAllSources":50, + | "totalAllowancesAndDeductions":50, + | "totalTaxableIncome":50, + | "incomeTaxCharged":50 + | }, + | "nics":{ + | "class2Nics":{ + | "underSmallProfitThreshold":true + | } + | }, + | "totalIncomeTaxAndNicsDue":50 + | } + | } + |} + """.stripMargin + ) + .as[JsObject] + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/Def1_RetrieveCalculationResponseSpec.scala b/test/v7/retrieveCalculation/def1/model/response/Def1_RetrieveCalculationResponseSpec.scala new file mode 100644 index 000000000..06f0543a8 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/Def1_RetrieveCalculationResponseSpec.scala @@ -0,0 +1,45 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response + +import play.api.libs.json.Json +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.retrieveCalculation.def1.model.Def1_CalculationFixture +import v7.retrieveCalculation.models.response.Def1_RetrieveCalculationResponse + +class Def1_RetrieveCalculationResponseSpec extends UnitSpec with Def1_CalculationFixture with JsonErrorValidators { + + "RetrieveCalculationResponse" must { + "allow conversion from downstream JSON to MTD JSON" when { + "JSON contains every field" in { + val model = calculationDownstreamJson.as[Def1_RetrieveCalculationResponse] + Json.toJson(model) shouldBe calculationMtdJson + } + } + + "have the correct fields optional" when { + testAllOptionalJsonFieldsExcept[Def1_RetrieveCalculationResponse](calculationDownstreamJson)("metadata", "inputs") + } + + "return the correct TaxDeductedAtSource" in { + taxDeductedAtSource.withoutTaxTakenOffTradingIncome shouldBe taxDeductedAtSource.copy(taxTakenOffTradingIncome = None) + } + + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/RetrieveCalculationResponseWithoutSpec.scala b/test/v7/retrieveCalculation/def1/model/response/RetrieveCalculationResponseWithoutSpec.scala new file mode 100644 index 000000000..937695850 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/RetrieveCalculationResponseWithoutSpec.scala @@ -0,0 +1,96 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response + +import shared.utils.UnitSpec +import v7.retrieveCalculation.def1.model.Def1_CalculationFixture + +class RetrieveCalculationResponseWithoutSpec extends UnitSpec with Def1_CalculationFixture { + + "withoutTotalAllowanceAndDeductions" when { + "calculation.isDefined returns true" should { + "return the response with the calculation" in { + val calculation = calcWithoutEndOfYearEstimate + val result = minimalCalculationR8bResponse.withoutTotalAllowanceAndDeductions + result shouldBe minimalCalculationR8bResponse.copy(calculation = Some(calculation)) + } + } + + "calculation.isDefined returns false" should { + "return the response with no calculation" in { + val response = minimalCalculationR8bResponse.copy(calculation = Some(emptyCalculation)) + val result = response.withoutTotalAllowanceAndDeductions + result shouldBe minimalCalculationR8bResponse.copy(calculation = None) + } + } + } + + "withoutBasicExtension" when { + "calculation.isDefined returns true" should { + "return the response with the calculation" in { + val calculation = calcWithoutBasicExtension + val result = minimalCalculationR8bResponse.withoutBasicExtension + result shouldBe minimalCalculationR8bResponse.copy(calculation = Some(calculation)) + } + } + + "calculation.isDefined returns false" should { + "return the response with no calculation" in { + val response = minimalCalculationR8bResponse.copy(calculation = Some(emptyCalculation)) + val result = response.withoutBasicExtension + result shouldBe minimalCalculationR8bResponse.copy(calculation = None) + } + } + } + + "withoutOffPayrollWorker" when { + "calculation.isDefined returns true" should { + "return the response with the calculation" in { + val calculation = calcWithoutOffPayrollWorker + val result = minimalCalculationR8bResponse.withoutOffPayrollWorker + result shouldBe minimalCalculationR8bResponse.copy(calculation = Some(calculation)) + } + } + + "calculation.isDefined returns false" should { + "return the response with no calculation" in { + val response = minimalCalculationR8bResponse.copy(calculation = Some(emptyCalculation)) + val result = response.withoutOffPayrollWorker + result shouldBe minimalCalculationR8bResponse.copy(calculation = None) + } + } + } + + "withoutUnderLowerProfitThreshold" when { + "calculation.isDefined returns true" should { + "return the response with the calculation" in { + val calculation = calcWithoutUnderLowerProfitThreshold + val result = minimalCalculationR8bResponse.withoutUnderLowerProfitThreshold + result shouldBe minimalCalculationR8bResponse.copy(calculation = Some(calculation)) + } + } + + "calculation.isDefined returns false" should { + "return the response with no calculation" in { + val response = minimalCalculationR8bResponse.copy(calculation = Some(emptyCalculation)) + val result = response.withoutOffPayrollWorker + result shouldBe minimalCalculationR8bResponse.copy(calculation = None) + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductionsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductionsSpec.scala new file mode 100644 index 000000000..aa5525f1f --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductionsSpec.scala @@ -0,0 +1,130 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.allowancesAndDeductions + +import play.api.libs.json.{JsValue, Json} +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport + +class AllowancesAndDeductionsSpec extends UnitSpec with EnumJsonSpecSupport { + + val model: AllowancesAndDeductions = + AllowancesAndDeductions( + Some(12500), + Some( + MarriageAllowanceTransferOut( + 1001.99, + 1001.99 + )), + Some(12500), + Some(12500), + Some(12500), + Some(12500), + Some(12500), + Some(1001.99), + Some(1001.99), + Some(1001.99), + Some(1001.99), + Some( + AnnuityPayments( + Some(1001.99), + Some(1001.99) + )), + Some(1001.99), + Some( + PensionContributionsDetail( + Some(1001.99), + Some(1001.99), + Some(1001.99) + )) + ) + + val mtdJson: JsValue = Json.parse(""" + |{ + | "personalAllowance": 12500, + | "marriageAllowanceTransferOut": { + | "personalAllowanceBeforeTransferOut": 1001.99, + | "transferredOutAmount": 1001.99 + | }, + | "reducedPersonalAllowance": 12500, + | "giftOfInvestmentsAndPropertyToCharity": 12500, + | "blindPersonsAllowance": 12500, + | "lossesAppliedToGeneralIncome": 12500, + | "cgtLossSetAgainstInYearGeneralIncome": 12500, + | "qualifyingLoanInterestFromInvestments": 1001.99, + | "postCessationTradeReceipts": 1001.99, + | "paymentsToTradeUnionsForDeathBenefits": 1001.99, + | "grossAnnuityPayments": 1001.99, + | "annuityPayments": { + | "reliefClaimed": 1001.99, + | "rate": 1001.99 + | }, + | "pensionContributions": 1001.99, + | "pensionContributionsDetail": { + | "retirementAnnuityPayments": 1001.99, + | "paymentToEmployersSchemeNoTaxRelief": 1001.99, + | "overseasPensionSchemeContributions": 1001.99 + | } + |} + |""".stripMargin) + + val ifsJson: JsValue = Json.parse(""" + |{ + | "personalAllowance": 12500, + | "marriageAllowanceTransferOut": { + | "personalAllowanceBeforeTransferOut": 1001.99, + | "transferredOutAmount": 1001.99 + | }, + | "reducedPersonalAllowance": 12500, + | "giftOfInvestmentsAndPropertyToCharity": 12500, + | "blindPersonsAllowance": 12500, + | "lossesAppliedToGeneralIncome": 12500, + | "cgtLossSetAgainstInYearGeneralIncome": 12500, + | "qualifyingLoanInterestFromInvestments": 1001.99, + | "post-cessationTradeReceipts": 1001.99, + | "paymentsToTradeUnionsForDeathBenefits": 1001.99, + | "grossAnnuityPayments": 1001.99, + | "annuityPayments": { + | "reliefClaimed": 1001.99, + | "rate": 1001.99 + | }, + | "pensionContributions": 1001.99, + | "pensionContributionsDetail": { + | "retirementAnnuityPayments": 1001.99, + | "paymentToEmployersSchemeNoTaxRelief": 1001.99, + | "overseasPensionSchemeContributions": 1001.99 + | } + |} + |""".stripMargin) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + model shouldBe ifsJson.as[AllowancesAndDeductions] + } + } + } + + "writes" when { + "passed valid model" should { + "return valid json" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLossSpec.scala new file mode 100644 index 000000000..7561b6337 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLossSpec.scala @@ -0,0 +1,145 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.businessProfitAndLoss + +import play.api.libs.json.{JsValue, Json} +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class BusinessProfitAndLossSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "incomeSourceName": "Dave's Bar", + | "totalIncome": 456.00, + | "totalExpenses": 456.00, + | "netProfit": 456.00, + | "netLoss": 456.00, + | "totalAdditions": 456.00, + | "totalDeductions": 456.00, + | "accountingAdjustments": 456.00, + | "taxableProfit": 456, + | "adjustedIncomeTaxLoss": 456, + | "totalBroughtForwardIncomeTaxLosses": 456, + | "lossForCSFHL": 456, + | "broughtForwardIncomeTaxLossesUsed": 456, + | "taxableProfitAfterIncomeTaxLossesDeduction": 456, + | "carrySidewaysIncomeTaxLossesUsed": 456, + | "broughtForwardCarrySidewaysIncomeTaxLossesUsed": 456, + | "totalIncomeTaxLossesCarriedForward": 456, + | "class4Loss": 456, + | "totalBroughtForwardClass4Losses": 456, + | "broughtForwardClass4LossesUsed": 456, + | "carrySidewaysClass4LossesUsed": 456, + | "totalClass4LossesCarriedForward": 456 + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType): BusinessProfitAndLoss = + BusinessProfitAndLoss( + incomeSourceId = "123456789012345", + incomeSourceType = incomeSourceType, + incomeSourceName = Some("Dave's Bar"), + totalIncome = Some(BigDecimal(456.00)), + totalExpenses = Some(BigDecimal(456.00)), + netProfit = Some(BigDecimal(456.00)), + netLoss = Some(BigDecimal(456.00)), + totalAdditions = Some(BigDecimal(456.00)), + totalDeductions = Some(BigDecimal(456.00)), + accountingAdjustments = Some(BigDecimal(456.00)), + taxableProfit = Some(BigInt(456)), + adjustedIncomeTaxLoss = Some(BigInt(456)), + totalBroughtForwardIncomeTaxLosses = Some(BigInt(456)), + lossForCSFHL = Some(BigInt(456)), + broughtForwardIncomeTaxLossesUsed = Some(BigInt(456)), + taxableProfitAfterIncomeTaxLossesDeduction = Some(BigInt(456)), + carrySidewaysIncomeTaxLossesUsed = Some(BigInt(456)), + broughtForwardCarrySidewaysIncomeTaxLossesUsed = Some(BigInt(456)), + totalIncomeTaxLossesCarriedForward = Some(BigInt(456)), + class4Loss = Some(BigInt(456)), + totalBroughtForwardClass4Losses = Some(BigInt(456)), + broughtForwardClass4LossesUsed = Some(BigInt(456)), + carrySidewaysClass4LossesUsed = Some(BigInt(456)), + totalClass4LossesCarriedForward = Some(BigInt(456)) + ) + + def mtdJson(incomeSourceType: IncomeSourceType): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "incomeSourceName": "Dave's Bar", + | "totalIncome": 456.00, + | "totalExpenses": 456.00, + | "netProfit": 456.00, + | "netLoss": 456.00, + | "totalAdditions": 456.00, + | "totalDeductions": 456.00, + | "accountingAdjustments": 456.00, + | "taxableProfit": 456, + | "adjustedIncomeTaxLoss": 456, + | "totalBroughtForwardIncomeTaxLosses": 456, + | "lossForCSFHL": 456, + | "broughtForwardIncomeTaxLossesUsed": 456, + | "taxableProfitAfterIncomeTaxLossesDeduction": 456, + | "carrySidewaysIncomeTaxLossesUsed": 456, + | "broughtForwardCarrySidewaysIncomeTaxLossesUsed": 456, + | "totalIncomeTaxLossesCarriedForward": 456, + | "class4Loss": 456, + | "totalBroughtForwardClass4Losses": 456, + | "broughtForwardClass4LossesUsed": 456, + | "carrySidewaysClass4LossesUsed": 456, + | "totalClass4LossesCarriedForward": 456 + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`), + Test("02", IncomeSourceType.`uk-property-non-fhl`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`), + Test("04", IncomeSourceType.`uk-property-fhl`), + Test("15", IncomeSourceType.`foreign-property`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType) => + s"provided downstream income source type $downstreamIncomeSourceType" in { + downstreamJson(downstreamIncomeSourceType).as[BusinessProfitAndLoss] shouldBe + model(incomeSourceType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType) => + s"provided income source type $incomeSourceType" in { + Json.toJson(model(incomeSourceType)) shouldBe + mtdJson(incomeSourceType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/CommonForeignDividendSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/CommonForeignDividendSpec.scala new file mode 100644 index 000000000..672d5c10a --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/CommonForeignDividendSpec.scala @@ -0,0 +1,77 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class CommonForeignDividendSpec extends UnitSpec with JsonErrorValidators { + + val model: CommonForeignDividend = CommonForeignDividend( + Some(IncomeSourceType.`foreign-dividends`), + "GER", + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(true) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceType": "07", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceType": "foreign-dividends", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[CommonForeignDividend] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala new file mode 100644 index 000000000..3dd937082 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -0,0 +1,160 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { + + val ukModel: UkDividends = UkDividends( + Some("000000000000210"), + Some(IncomeSourceType.`uk-dividends`), + Some(12500), + Some(12500) + ) + + val otherModel: OtherDividends = OtherDividends( + Some("stockDividend"), + Some("string"), + Some(5000.99) + ) + + val foreignModel: CommonForeignDividend = CommonForeignDividend( + Some(IncomeSourceType.`foreign-dividends`), + "GER", + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(true) + ) + + val model: DividendsIncome = DividendsIncome( + Some(12500), + Some(12500), + Some(ukModel), + Some(Seq(otherModel)), + Some(12500), + Some(Seq(foreignModel)), + Some(Seq(foreignModel)) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "totalChargeableDividends":12500, + | "totalUkDividends":12500, + | "ukDividends":{ + | "incomeSourceId":"000000000000210", + | "incomeSourceType":"10", + | "dividends":12500, + | "otherUkDividends":12500 + | }, + | "otherDividends":[ + | { + | "typeOfDividend":"stockDividend", + | "customerReference":"string", + | "grossAmount":5000.99 + | } + | ], + | "chargeableForeignDividends":12500, + | "foreignDividends":[ + | { + | "incomeSourceType":"07", + | "countryCode":"GER", + | "grossIncome":5000.99, + | "netIncome":5000.99, + | "taxDeducted":5000.99, + | "foreignTaxCreditRelief":true + | } + | ], + | "dividendIncomeReceivedWhilstAbroad":[ + | { + | "incomeSourceType":"07", + | "countryCode":"GER", + | "grossIncome":5000.99, + | "netIncome":5000.99, + | "taxDeducted":5000.99, + | "foreignTaxCreditRelief":true + | } + | ] + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "totalChargeableDividends":12500, + | "totalUkDividends":12500, + | "ukDividends":{ + | "incomeSourceId":"000000000000210", + | "incomeSourceType":"uk-dividends", + | "dividends":12500, + | "otherUkDividends":12500 + | }, + | "otherDividends":[ + | { + | "typeOfDividend":"stockDividend", + | "customerReference":"string", + | "grossAmount":5000.99 + | } + | ], + | "chargeableForeignDividends":12500, + | "foreignDividends":[ + | { + | "incomeSourceType":"foreign-dividends", + | "countryCode":"GER", + | "grossIncome":5000.99, + | "netIncome":5000.99, + | "taxDeducted":5000.99, + | "foreignTaxCreditRelief":true + | } + | ], + | "dividendIncomeReceivedWhilstAbroad":[ + | { + | "incomeSourceType":"foreign-dividends", + | "countryCode":"GER", + | "grossIncome":5000.99, + | "netIncome":5000.99, + | "taxDeducted":5000.99, + | "foreignTaxCreditRelief":true + | } + | ] + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[DividendsIncome] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/UkDividendsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/UkDividendsSpec.scala new file mode 100644 index 000000000..b572988c3 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/UkDividendsSpec.scala @@ -0,0 +1,71 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class UkDividendsSpec extends UnitSpec with JsonErrorValidators { + + val model: UkDividends = UkDividends( + Some("000000000000210"), + Some(IncomeSourceType.`uk-dividends`), + Some(5000), + Some(5000) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceId": "000000000000210", + | "incomeSourceType": "10", + | "dividends": 5000, + | "otherUkDividends": 5000 + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceId": "000000000000210", + | "incomeSourceType": "uk-dividends", + | "dividends": 5000, + | "otherUkDividends": 5000 + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[UkDividends] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetailSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetailSpec.scala new file mode 100644 index 000000000..1abd38c18 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetailSpec.scala @@ -0,0 +1,142 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class BenefitsInKindDetailSpec extends UnitSpec with JsonErrorValidators { + + val model: BenefitsInKindDetail = BenefitsInKindDetail( + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "apportionedAccommodation": 5000.99, + | "apportionedAssets": 5000.99, + | "apportionedAssetTransfer": 5000.99, + | "apportionedBeneficialLoan": 5000.99, + | "apportionedCar": 5000.99, + | "apportionedCarFuel": 5000.99, + | "apportionedEducationalServices": 5000.99, + | "apportionedEntertaining": 5000.99, + | "apportionedExpenses": 5000.99, + | "apportionedMedicalInsurance": 5000.99, + | "apportionedTelephone": 5000.99, + | "apportionedService": 5000.99, + | "apportionedTaxableExpenses": 5000.99, + | "apportionedVan": 5000.99, + | "apportionedVanFuel": 5000.99, + | "apportionedMileage": 5000.99, + | "apportionedNonQualifyingRelocationExpenses": 5000.99, + | "apportionedNurseryPlaces": 5000.99, + | "apportionedOtherItems": 5000.99, + | "apportionedPaymentsOnEmployeesBehalf": 5000.99, + | "apportionedPersonalIncidentalExpenses": 5000.99, + | "apportionedQualifyingRelocationExpenses": 5000.99, + | "apportionedEmployerProvidedProfessionalSubscriptions": 5000.99, + | "apportionedEmployerProvidedServices": 5000.99, + | "apportionedIncomeTaxPaidByDirector": 5000.99, + | "apportionedTravelAndSubsistence": 5000.99, + | "apportionedVouchersAndCreditCards": 5000.99, + | "apportionedNonCash": 5000.99 + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "apportionedAccommodation": 5000.99, + | "apportionedAssets": 5000.99, + | "apportionedAssetTransfer": 5000.99, + | "apportionedBeneficialLoan": 5000.99, + | "apportionedCar": 5000.99, + | "apportionedCarFuel": 5000.99, + | "apportionedEducationalServices": 5000.99, + | "apportionedEntertaining": 5000.99, + | "apportionedExpenses": 5000.99, + | "apportionedMedicalInsurance": 5000.99, + | "apportionedTelephone": 5000.99, + | "apportionedService": 5000.99, + | "apportionedTaxableExpenses": 5000.99, + | "apportionedVan": 5000.99, + | "apportionedVanFuel": 5000.99, + | "apportionedMileage": 5000.99, + | "apportionedNonQualifyingRelocationExpenses": 5000.99, + | "apportionedNurseryPlaces": 5000.99, + | "apportionedOtherItems": 5000.99, + | "apportionedPaymentsOnEmployeesBehalf": 5000.99, + | "apportionedPersonalIncidentalExpenses": 5000.99, + | "apportionedQualifyingRelocationExpenses": 5000.99, + | "apportionedEmployerProvidedProfessionalSubscriptions": 5000.99, + | "apportionedEmployerProvidedServices": 5000.99, + | "apportionedIncomeTaxPaidByDirector": 5000.99, + | "apportionedTravelAndSubsistence": 5000.99, + | "apportionedVouchersAndCreditCards": 5000.99, + | "apportionedNonCash": 5000.99 + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[BenefitsInKindDetail] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeSpec.scala new file mode 100644 index 000000000..7535dc732 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeSpec.scala @@ -0,0 +1,72 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import shared.utils.UnitSpec + +class EmploymentAndPensionsIncomeSpec extends UnitSpec { + + val detail: EmploymentAndPensionsIncomeDetail = EmploymentAndPensionsIncomeDetail( + incomeSourceId = None, + source = None, + occupationalPension = None, + employerRef = None, + employerName = None, + offPayrollWorker = Some(true), + payrollId = None, + startDate = None, + dateEmploymentEnded = None, + taxablePayToDate = None, + totalTaxToDate = None, + disguisedRemuneration = None, + lumpSums = None, + studentLoans = None, + benefitsInKind = None + ) + + val detailWithIncomeSource: EmploymentAndPensionsIncomeDetail = detail.copy(incomeSourceId = Some("incomeSourceId")) + val updatedDetailWithIncomeSource: EmploymentAndPensionsIncomeDetail = detailWithIncomeSource.copy(offPayrollWorker = None) + val model: EmploymentAndPensionsIncome = EmploymentAndPensionsIncome(None, None, None, None, Some(Seq(detail))) + val updatedModel: EmploymentAndPensionsIncome = model.copy(employmentAndPensionsIncomeDetail = None) + + "withoutOffPayrollWorker" when { + "employmentAndPensionIncome is defined, returns true" should { + "employmentAndPensionDetail should be Some(_)" in { + val employmentAndPensionsIncome: EmploymentAndPensionsIncome = + model.copy(employmentAndPensionsIncomeDetail = Some(Seq(detailWithIncomeSource))) + val result: EmploymentAndPensionsIncome = employmentAndPensionsIncome.withoutOffPayrollWorker + result.employmentAndPensionsIncomeDetail shouldBe Some(Seq(updatedDetailWithIncomeSource)) + } + } + "employmentAndPensionIncome is defined, returns false" should { + "employmentAndPensionDetail should be None" in { + val employmentAndPensionsIncome: EmploymentAndPensionsIncome = model + val result = employmentAndPensionsIncome.withoutOffPayrollWorker + result.employmentAndPensionsIncomeDetail shouldBe None + } + } + + "employmentAndPensionIncome is not defined, returns false" should { + "employmentAndPensionDetail should be None" in { + val employmentAndPensionsIncome: EmploymentAndPensionsIncome = updatedModel + val result = employmentAndPensionsIncome.withoutOffPayrollWorker + result.employmentAndPensionsIncomeDetail shouldBe None + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/IncomeSourceSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/IncomeSourceSpec.scala new file mode 100644 index 000000000..6acfa27c8 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/endOfYearEstimate/IncomeSourceSpec.scala @@ -0,0 +1,74 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.endOfYearEstimate + +import play.api.libs.json.Json +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType._ + +class IncomeSourceSpec extends UnitSpec { + + "reads" should { + "successfully read in a model" when { + Seq( + ("01", `self-employment`), + ("02", `uk-property-non-fhl`), + ("03", `foreign-property-fhl-eea`), + ("04", `uk-property-fhl`), + ("05", `employments`), + ("06", `foreign-income`), + ("07", `foreign-dividends`), + ("09", `uk-savings-and-gains`), + ("10", `uk-dividends`), + ("11", `state-benefits`), + ("12", `gains-on-life-policies`), + ("13", `share-schemes`), + ("15", `foreign-property`), + ("16", `foreign-savings-and-gains`), + ("17", `other-dividends`), + ("18", `uk-securities`), + ("19", `other-income`), + ("20", `foreign-pension`), + ("21", `non-paye-income`), + ("22", `capital-gains-tax`), + ("98", `charitable-giving`) + ).foreach { case (downstreamIncomeSourceType, mtdIncomeSourceType) => + s"provided downstream IncomeSourceType of $downstreamIncomeSourceType" in { + val json = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$downstreamIncomeSourceType", + | "incomeSourceName": "My name", + | "taxableIncome": 3, + | "finalised": true + |} + |""".stripMargin) + + val model = IncomeSource( + incomeSourceId = Some("123456789012345"), + incomeSourceType = mtdIncomeSourceType, + incomeSourceName = Some("My name"), + taxableIncome = 3, + finalised = Some(true)) + + json.as[IncomeSource] shouldBe model + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala new file mode 100644 index 000000000..a0aa6a783 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala @@ -0,0 +1,102 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.{ClaimType, IncomeSourceType} + +class CarriedForwardLossSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "originatingClaimId": "123456789012346", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "claimType": "$claimType", + | "taxYearClaimMade": 2020, + | "taxYearLossIncurred": 2019, + | "currentLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): CarriedForwardLoss = + CarriedForwardLoss( + claimId = Some("123456789012345"), + originatingClaimId = Some("123456789012346"), + incomeSourceId = "123456789012347", + incomeSourceType = incomeSourceType, + claimType = claimType, + taxYearClaimMade = Some(TaxYear.fromDownstream("2020")), + taxYearLossIncurred = TaxYear.fromDownstream("2019"), + currentLossValue = BigInt(456), + lossType = Some("income") + ) + + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "originatingClaimId": "123456789012346", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "claimType": "$claimType", + | "taxYearClaimMade": "2019-20", + | "taxYearLossIncurred": "2018-19", + | "currentLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + s"provided downstream type of claim $downstreamClaimType" in { + downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[CarriedForwardLoss] shouldBe + model(incomeSourceType, claimType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType, _, claimType) => + s"provided type of claim $claimType" in { + Json.toJson(model(incomeSourceType, claimType)) shouldBe + mtdJson(incomeSourceType, claimType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ClaimNotAppliedSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ClaimNotAppliedSpec.scala new file mode 100644 index 000000000..36c91e9c6 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ClaimNotAppliedSpec.scala @@ -0,0 +1,90 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.{ClaimType, IncomeSourceType} + +class ClaimNotAppliedSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "taxYearClaimMade": 2020, + | "claimType": "$claimType" + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): ClaimNotApplied = + ClaimNotApplied( + claimId = "123456789012345", + incomeSourceId = "123456789012347", + incomeSourceType = incomeSourceType, + taxYearClaimMade = TaxYear.fromDownstream("2020"), + claimType = claimType + ) + + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "taxYearClaimMade": "2019-20", + | "claimType": "$claimType" + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + s"provided downstream type of claim $downstreamClaimType" in { + downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[ClaimNotApplied] shouldBe + model(incomeSourceType, claimType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType, _, claimType) => + s"provided type of claim $claimType" in { + Json.toJson(model(incomeSourceType, claimType)) shouldBe + mtdJson(incomeSourceType, claimType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLossSpec.scala new file mode 100644 index 000000000..acb91563d --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLossSpec.scala @@ -0,0 +1,86 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class DefaultCarriedForwardLossSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "taxYearLossIncurred": 2019, + | "currentLossValue": 456 + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType): DefaultCarriedForwardLoss = + DefaultCarriedForwardLoss( + incomeSourceId = "123456789012345", + incomeSourceType = incomeSourceType, + taxYearLossIncurred = TaxYear.fromDownstream("2019"), + currentLossValue = BigInt(456) + ) + + def mtdJson(incomeSourceType: IncomeSourceType): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "taxYearLossIncurred": "2018-19", + | "currentLossValue": 456 + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`), + Test("02", IncomeSourceType.`uk-property-non-fhl`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`), + Test("04", IncomeSourceType.`uk-property-fhl`), + Test("15", IncomeSourceType.`foreign-property`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType) => + s"provided downstream income source type $downstreamIncomeSourceType" in { + downstreamJson(downstreamIncomeSourceType).as[DefaultCarriedForwardLoss] shouldBe + model(incomeSourceType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType) => + s"provided income source type $incomeSourceType" in { + Json.toJson(model(incomeSourceType)) shouldBe + mtdJson(incomeSourceType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala new file mode 100644 index 000000000..eb09fbc14 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala @@ -0,0 +1,108 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.{ClaimType, IncomeSourceType} + +class ResultOfClaimsAppliedSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "originatingClaimId": "123456789012346", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "taxYearClaimMade": 2020, + | "claimType": "$claimType", + | "mtdLoss": false, + | "taxYearLossIncurred": 2019, + | "lossAmountUsed": 123, + | "remainingLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): ResultOfClaimsApplied = + ResultOfClaimsApplied( + claimId = Some("123456789012345"), + originatingClaimId = Some("123456789012346"), + incomeSourceId = "123456789012347", + incomeSourceType = incomeSourceType, + taxYearClaimMade = TaxYear.fromDownstream("2020"), + claimType = claimType, + mtdLoss = Some(false), + taxYearLossIncurred = TaxYear.fromDownstream("2019"), + lossAmountUsed = BigInt(123), + remainingLossValue = BigInt(456), + lossType = Some("income") + ) + + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "originatingClaimId": "123456789012346", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "taxYearClaimMade": "2019-20", + | "claimType": "$claimType", + | "mtdLoss": false, + | "taxYearLossIncurred": "2018-19", + | "lossAmountUsed": 123, + | "remainingLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + s"provided downstream type of claim $downstreamClaimType" in { + downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[ResultOfClaimsApplied] shouldBe + model(incomeSourceType, claimType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType, _, claimType) => + s"provided type of claim $claimType" in { + Json.toJson(model(incomeSourceType, claimType)) shouldBe + mtdJson(incomeSourceType, claimType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala new file mode 100644 index 000000000..e05098dc1 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala @@ -0,0 +1,89 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class UnclaimedLossSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "taxYearLossIncurred": 2020, + | "currentLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType): UnclaimedLoss = + UnclaimedLoss( + incomeSourceId = Some("123456789012345"), + incomeSourceType = incomeSourceType, + taxYearLossIncurred = TaxYear.fromDownstream("2020"), + currentLossValue = BigInt(456), + lossType = Some("income") + ) + + def mtdJson(incomeSourceType: IncomeSourceType): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "taxYearLossIncurred": "2019-20", + | "currentLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`), + Test("02", IncomeSourceType.`uk-property-non-fhl`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`), + Test("04", IncomeSourceType.`uk-property-fhl`), + Test("15", IncomeSourceType.`foreign-property`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType) => + s"provided downstream income source type $downstreamIncomeSourceType" in { + downstreamJson(downstreamIncomeSourceType).as[UnclaimedLoss] shouldBe + model(incomeSourceType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType) => + s"provided income source type $incomeSourceType" in { + Json.toJson(model(incomeSourceType)) shouldBe + mtdJson(incomeSourceType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncomeSpec.scala new file mode 100644 index 000000000..d1cd0944c --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncomeSpec.scala @@ -0,0 +1,77 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType.`foreign-savings-and-gains` + +class ForeignSavingsAndGainsIncomeSpec extends UnitSpec with JsonErrorValidators { + + val model: ForeignSavingsAndGainsIncome = ForeignSavingsAndGainsIncome( + `foreign-savings-and-gains`, + Some("GER"), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(true) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceType": "16", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceType": "foreign-savings-and-gains", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[ForeignSavingsAndGainsIncome] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncomeSpec.scala new file mode 100644 index 000000000..2035e5f0d --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncomeSpec.scala @@ -0,0 +1,128 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class SavingsAndGainsIncomeSpec extends UnitSpec with JsonErrorValidators { + + val ukModel: UkSavingsAndGainsIncome = UkSavingsAndGainsIncome( + Some("000000000000210"), + IncomeSourceType.`uk-savings-and-gains`, + Some("My Savings Account 1"), + 5000.99, + Some(5000.99), + Some(5000.99) + ) + + val foreignModel: ForeignSavingsAndGainsIncome = ForeignSavingsAndGainsIncome( + IncomeSourceType.`foreign-savings-and-gains`, + Some("GER"), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(true) + ) + + val model: SavingsAndGainsIncome = SavingsAndGainsIncome( + Some(100), + Some(100), + Some(Seq(ukModel)), + Some(100), + Some(Seq(foreignModel)) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "totalChargeableSavingsAndGains": 100, + | "totalUkSavingsAndGains": 100, + | "ukSavingsAndGainsIncome": [ + | { + | "incomeSourceId": "000000000000210", + | "incomeSourceType": "09", + | "incomeSourceName": "My Savings Account 1", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99 + | } + | ], + | "chargeableForeignSavingsAndGains": 100, + | "foreignSavingsAndGainsIncome": [ + | { + | "incomeSourceType": "16", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + | } + | ] + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "totalChargeableSavingsAndGains": 100, + | "totalUkSavingsAndGains": 100, + | "ukSavingsAndGainsIncome": [ + | { + | "incomeSourceId": "000000000000210", + | "incomeSourceType": "uk-savings-and-gains", + | "incomeSourceName": "My Savings Account 1", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99 + | } + | ], + | "chargeableForeignSavingsAndGains": 100, + | "foreignSavingsAndGainsIncome": [ + | { + | "incomeSourceType": "foreign-savings-and-gains", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + | } + | ] + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[SavingsAndGainsIncome] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncomeSpec.scala new file mode 100644 index 000000000..775344a17 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncomeSpec.scala @@ -0,0 +1,77 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class UkSavingsAndGainsIncomeSpec extends UnitSpec with JsonErrorValidators { + + val model: UkSavingsAndGainsIncome = UkSavingsAndGainsIncome( + Some("000000000000210"), + IncomeSourceType.`uk-savings-and-gains`, + Some("My Savings Account 1"), + 99.99, + Some(99.99), + Some(99.99) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceId":"000000000000210", + | "incomeSourceType":"09", + | "incomeSourceName":"My Savings Account 1", + | "grossIncome":99.99, + | "netIncome":99.99, + | "taxDeducted":99.99 + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceId":"000000000000210", + | "incomeSourceType":"uk-savings-and-gains", + | "incomeSourceName":"My Savings Account 1", + | "grossIncome":99.99, + | "netIncome":99.99, + | "taxDeducted":99.99 + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[UkSavingsAndGainsIncome] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRelSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRelSpec.scala new file mode 100644 index 000000000..25c1be264 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRelSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class BusinessAssetsDisposalsAndInvestorsRelSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax" \ "businessAssetsDisposalsAndInvestorsRel").as[JsValue] + + testOptionalJsonFields[BusinessAssetsDisposalsAndInvestorsRel](json) + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CapitalGainsTaxSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CapitalGainsTaxSpec.scala new file mode 100644 index 000000000..fc34c7ffb --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CapitalGainsTaxSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class CapitalGainsTaxSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax").as[JsValue] + + testAllOptionalJsonFieldsExcept[CapitalGainsTax](json)( + "totalCapitalGainsIncome", + "annualExemptionAmount", + "totalTaxableGains", + "capitalGainsTaxDue") + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandNameSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandNameSpec.scala new file mode 100644 index 000000000..77fe1316d --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandNameSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def1.model.response.calculation.taxCalculation.CgtBandName._ + +class CgtBandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[CgtBandName]( + "lowerRate" -> `lower-rate`, + "higherRate" -> `higher-rate` + ) + + testWrites[CgtBandName]( + `lower-rate` -> "lower-rate", + `higher-rate` -> "higher-rate" + ) + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandSpec.scala new file mode 100644 index 000000000..2379f42e1 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/CgtBandSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsObject +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class CgtBandSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax" \ "otherGains" \ "cgtTaxBands").head.as[JsObject] + + testMandatoryJsonFields[CgtBand](json) + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class2NicsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class2NicsSpec.scala new file mode 100644 index 000000000..ed50acfb3 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class2NicsSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class Class2NicsSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "nics" \ "class2Nics").as[JsValue] + + testAllOptionalJsonFieldsExcept[Class2Nics](json)("underSmallProfitThreshold") + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class4NicsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class4NicsSpec.scala new file mode 100644 index 000000000..2fd843a15 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Class4NicsSpec.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class Class4NicsSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "nics" \ "class4Nics").get + + testAllOptionalJsonFieldsExcept[Class4Nics](json)("totalAmount", "nic4Bands") + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala new file mode 100644 index 000000000..f0e79afe5 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def1.model.response.calculation.taxCalculation.IncomeTaxBandName._ + +class IncomeTaxBandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[IncomeTaxBandName]( + "SSR" -> `savings-starter-rate`, + "ZRTBR" -> `allowance-awarded-at-basic-rate`, + "ZRTHR" -> `allowance-awarded-at-higher-rate`, + "ZRTAR" -> `allowance-awarded-at-additional-rate`, + "SRT" -> `starter-rate`, + "BRT" -> `basic-rate`, + "IRT" -> `intermediate-rate`, + "HRT" -> `higher-rate`, + "ART" -> `additional-rate` + ) + + testWrites[IncomeTaxBandName]( + `savings-starter-rate` -> "savings-starter-rate", + `allowance-awarded-at-basic-rate` -> "allowance-awarded-at-basic-rate", + `allowance-awarded-at-higher-rate` -> "allowance-awarded-at-higher-rate", + `allowance-awarded-at-additional-rate` -> "allowance-awarded-at-additional-rate", + `starter-rate` -> "starter-rate", + `basic-rate` -> "basic-rate", + `intermediate-rate` -> "intermediate-rate", + `higher-rate` -> "higher-rate", + `additional-rate` -> "additional-rate" + ) + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandSpec.scala new file mode 100644 index 000000000..5078de86a --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxBandSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsObject +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class IncomeTaxBandSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "incomeTax" \ "payPensionsProfit" \ "taxBands").head.as[JsObject] + + testMandatoryJsonFields[IncomeTaxBand](json) + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxItemSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxItemSpec.scala new file mode 100644 index 000000000..901be7e22 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxItemSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class IncomeTaxItemSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "incomeTax" \ "payPensionsProfit").as[JsValue] + + testAllMandatoryJsonFieldsExcept[IncomeTaxItem](json)("taxBands") + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxSpec.scala new file mode 100644 index 000000000..71b5af169 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/IncomeTaxSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class IncomeTaxSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "incomeTax").as[JsValue] + + testAllOptionalJsonFieldsExcept[IncomeTax](json)( + "totalIncomeReceivedFromAllSources", + "totalAllowancesAndDeductions", + "totalTaxableIncome", + "incomeTaxCharged") + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandNameSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandNameSpec.scala new file mode 100644 index 000000000..f53c712db --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandNameSpec.scala @@ -0,0 +1,37 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def1.model.response.calculation.taxCalculation.Nic4BandName._ + +class Nic4BandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[Nic4BandName]( + "ZRT" -> `zero-rate`, + "BRT" -> `basic-rate`, + "HRT" -> `higher-rate` + ) + + testWrites[Nic4BandName]( + `zero-rate` -> "zero-rate", + `basic-rate` -> "basic-rate", + `higher-rate` -> "higher-rate" + ) + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandSpec.scala new file mode 100644 index 000000000..4e587c20c --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/Nic4BandSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsObject +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class Nic4BandSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "nics" \ "class4Nics" \ "nic4Bands").head.as[JsObject] + + testAllMandatoryJsonFieldsExcept[Nic4Band](json)("threshold", "apportionedThreshold") + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/NicsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/NicsSpec.scala new file mode 100644 index 000000000..b1d36d659 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/NicsSpec.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class NicsSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "nics").get + + testOptionalJsonFields[Nics](json) + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/OtherGainsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/OtherGainsSpec.scala new file mode 100644 index 000000000..91e2d7827 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/OtherGainsSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class OtherGainsSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax" \ "otherGains").as[JsValue] + + testOptionalJsonFields[OtherGains](json) + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterestSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterestSpec.scala new file mode 100644 index 000000000..50df97276 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterestSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class ResidentialPropertyAndCarriedInterestSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax" \ "residentialPropertyAndCarriedInterest").as[JsValue] + + testOptionalJsonFields[ResidentialPropertyAndCarriedInterest](json) + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculationFixture.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculationFixture.scala new file mode 100644 index 000000000..37da388bb --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculationFixture.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.{JsValue, Json} + +trait TaxCalculationFixture { + + val taxCalculationMtdJson: JsValue = + Json.parse(getClass.getResourceAsStream("/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_mtd.json")) + + val taxCalculationDownstreamJson: JsValue = + Json.parse(getClass.getResourceAsStream("/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/taxCalculation_downstream.json")) + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculationSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculationSpec.scala new file mode 100644 index 000000000..416516e7f --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/taxCalculation/TaxCalculationSpec.scala @@ -0,0 +1,38 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.taxCalculation + +import play.api.libs.json.Json +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class TaxCalculationSpec extends UnitSpec with TaxCalculationFixture with JsonErrorValidators { + + "TaxCalculation" must { + "allow conversion from downstream JSON to MTD JSON" when { + "JSON contains every field" in { + val model = taxCalculationDownstreamJson.as[TaxCalculation] + Json.toJson(model) shouldBe taxCalculationMtdJson + } + } + + "have the correct fields optional" when { + testOptionalJsonFields[TaxCalculation](taxCalculationDownstreamJson) + } + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala b/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala new file mode 100644 index 000000000..109d9a55d --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala @@ -0,0 +1,132 @@ +/* + * Copyright 2024 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.metadata + +import play.api.libs.json.Json +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.CalculationType + +class MetadataSpec extends UnitSpec { + + "reads" when { + "passed valid JSON with all fields populated" should { + "return the correct model" in { + Json + .parse( + """{ + | "calculationId": "calcId", + | "taxYear": 2018, + | "requestedBy": "customer", + | "requestedTimestamp": "requested timestamp", + | "calculationReason": "reason", + | "calculationTimestamp": "calc timestamp", + | "calculationType": "crystallisation", + | "intentToCrystallise": true, + | "crystallised": true, + | "crystallisationTimestamp": "decl timestamp", + | "periodFrom": "from", + | "periodTo": "to" + | } + |""".stripMargin) + .as[Metadata] shouldBe + Metadata( + calculationId = "calcId", + taxYear = TaxYear.fromDownstream("2018"), + requestedBy = "customer", + requestedTimestamp = Some("requested timestamp"), + calculationReason = "reason", + calculationTimestamp = Some("calc timestamp"), + calculationType = CalculationType.`finalDeclaration`, + intentToSubmitFinalDeclaration = true, + finalDeclaration = true, + finalDeclarationTimestamp = Some("decl timestamp"), + periodFrom = "from", + periodTo = "to" + ) + } + } + + "only mandatory fields populated" should { + "default the final declaration fields to false" in { + Json + .parse( + """{ + | "calculationId": "calcId", + | "taxYear": 2018, + | "requestedBy": "customer", + | "calculationReason": "reason", + | "calculationType": "crystallisation", + | "periodFrom": "from", + | "periodTo": "to" + | } + |""".stripMargin) + .as[Metadata] shouldBe + Metadata( + calculationId = "calcId", + taxYear = TaxYear.fromDownstream("2018"), + requestedBy = "customer", + requestedTimestamp = None, + calculationReason = "reason", + calculationTimestamp = None, + calculationType = CalculationType.`finalDeclaration`, + intentToSubmitFinalDeclaration = false, + finalDeclaration = false, + finalDeclarationTimestamp = None, + periodFrom = "from", + periodTo = "to" + ) + } + } + } + + "writes" should { + "work" in { + Json.toJson( + Metadata( + calculationId = "calcId", + taxYear = TaxYear.fromDownstream("2018"), + requestedBy = "customer", + requestedTimestamp = Some("requested timestamp"), + calculationReason = "reason", + calculationTimestamp = Some("calc timestamp"), + calculationType = CalculationType.`finalDeclaration`, + intentToSubmitFinalDeclaration = true, + finalDeclaration = true, + finalDeclarationTimestamp = Some("decl timestamp"), + periodFrom = "from", + periodTo = "to" + )) shouldBe Json.parse( + """{ + | "calculationId": "calcId", + | "taxYear": "2017-18", + | "requestedBy": "customer", + | "requestedTimestamp": "requested timestamp", + | "calculationReason": "reason", + | "calculationTimestamp": "calc timestamp", + | "calculationType": "finalDeclaration", + | "intentToSubmitFinalDeclaration": true, + | "finalDeclaration": true, + | "finalDeclarationTimestamp": "decl timestamp", + | "periodFrom": "from", + | "periodTo": "to" + | } + |""".stripMargin) + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/Def2_RetrieveCalculationValidatorSpec.scala b/test/v7/retrieveCalculation/def2/Def2_RetrieveCalculationValidatorSpec.scala new file mode 100644 index 000000000..a3c7cdadb --- /dev/null +++ b/test/v7/retrieveCalculation/def2/Def2_RetrieveCalculationValidatorSpec.scala @@ -0,0 +1,107 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2 + +import shared.models.domain.{CalculationId, Nino, TaxYear} +import shared.models.errors._ +import shared.utils.UnitSpec +import v7.retrieveCalculation.models.request.Def2_RetrieveCalculationRequestData + +class Def2_RetrieveCalculationValidatorSpec extends UnitSpec { + + private implicit val correlationId: String = "1234" + + private val validNino = "ZG903729C" + private val validTaxYear = "2017-18" + private val validCalculationId = "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c" + + private val parsedNino = Nino(validNino) + private val parsedTaxYear = TaxYear.fromMtd(validTaxYear) + private val parsedCalculationId = CalculationId(validCalculationId) + + private def validator(nino: String, taxYear: String, calculationId: String) = + new Def2_RetrieveCalculationValidator(nino, taxYear, calculationId) + + "validator" should { + "return the parsed domain object" when { + "a valid request is supplied" in { + val result = validator(validNino, validTaxYear, validCalculationId).validateAndWrapResult() + result shouldBe Right(Def2_RetrieveCalculationRequestData(parsedNino, parsedTaxYear, parsedCalculationId)) + } + } + + "return NinoFormatError error" when { + "an invalid nino is supplied" in { + val result = validator("A12344A", validTaxYear, validCalculationId).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, NinoFormatError) + ) + } + } + + "return TaxYearFormatError error" when { + "an invalid tax year is supplied" in { + val result = validator(validNino, "201718", validCalculationId).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, TaxYearFormatError) + ) + } + } + + "return RuleTaxYearNotSupportedError error" when { + "an out of range tax year is supplied" in { + val result = validator(validNino, "2016-17", validCalculationId).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, RuleTaxYearNotSupportedError) + ) + } + } + + "return RuleTaxYearRangeInvalidError error" when { + "an invalid tax year range is supplied" in { + val result = validator(validNino, "2017-19", validCalculationId).validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, RuleTaxYearRangeInvalidError) + ) + } + } + + "return CalculationIdFormatError error" when { + "an invalid calculation id is supplied" in { + val result = validator(validNino, validTaxYear, "bad id").validateAndWrapResult() + result shouldBe Left( + ErrorWrapper(correlationId, CalculationIdFormatError) + ) + } + } + + "return multiple errors" when { + "multiple invalid parameters are provided" in { + val result = validator("not-a-nino", validTaxYear, "bad id").validateAndWrapResult() + + result shouldBe Left( + ErrorWrapper( + correlationId, + BadRequestError, + Some(List(CalculationIdFormatError, NinoFormatError)) + ) + ) + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/Def2_CalculationFixture.scala b/test/v7/retrieveCalculation/def2/model/Def2_CalculationFixture.scala new file mode 100644 index 000000000..5db3178a9 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/Def2_CalculationFixture.scala @@ -0,0 +1,29 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model + +import play.api.libs.json.{JsObject, Json} + +trait Def2_CalculationFixture { + + val calculationMtdJson: JsObject = + Json.parse(getClass.getResourceAsStream("/v7/retrieveCalculation/def2/model/response/calculation_mtd.json")).as[JsObject] + + val calculationDownstreamJson: JsObject = + Json.parse(getClass.getResourceAsStream("/v7/retrieveCalculation/def2/model/response/calculation_downstream.json")).as[JsObject] + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/Def2_RetrieveCalculationResponseSpec.scala b/test/v7/retrieveCalculation/def2/model/response/Def2_RetrieveCalculationResponseSpec.scala new file mode 100644 index 000000000..534351e4d --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/Def2_RetrieveCalculationResponseSpec.scala @@ -0,0 +1,90 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response + +import config.CalculationsFeatureSwitches +import org.scalatest.Inside +import play.api.Configuration +import play.api.libs.json.Json +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.retrieveCalculation.def2.model.Def2_CalculationFixture +import v7.retrieveCalculation.def2.model.response.calculation.Calculation +import v7.retrieveCalculation.def2.model.response.calculation.transitionProfit.TransitionProfit +import v7.retrieveCalculation.models.response.Def2_RetrieveCalculationResponse + +class Def2_RetrieveCalculationResponseSpec extends UnitSpec with Def2_CalculationFixture with JsonErrorValidators with Inside { + + "Def2_RetrieveCalculationResponse" must { + "allow conversion from downstream JSON to MTD JSON" when { + "JSON contains every field" in { + val model = calculationDownstreamJson.as[Def2_RetrieveCalculationResponse] + Json.toJson(model) shouldBe calculationMtdJson + } + } + + "have the correct fields optional" when { + testAllOptionalJsonFieldsExcept[Def2_RetrieveCalculationResponse](calculationDownstreamJson)("metadata", "inputs") + } + } + + "Def2_RetrieveCalculationResponse adjustFields" when { + val fullResponse = calculationDownstreamJson.as[Def2_RetrieveCalculationResponse] + + val ignoredTaxYear = "ignoredTaxYear" + + def featureSwitchesWith(enabled: Boolean) = + CalculationsFeatureSwitches(Configuration("retrieveTransitionProfit.enabled" -> enabled)) + + "the retrieveTransitionProfit featureSwitchWith is on" must { + val featureSwitches = featureSwitchesWith(enabled = true) + + "leave the transitionProfit field" in { + + fullResponse.adjustFields(featureSwitches, ignoredTaxYear) shouldBe fullResponse + } + } + + "the retrieveTransitionProfit featureSwitchWith is off" must { + val featureSwitches = featureSwitchesWith(enabled = false) + + "remove transitionProfit" in { + val calculation = inside(fullResponse.calculation) { case Some(calculation) => calculation } + + val calculationWithoutTransitionProfit = calculation.copy(transitionProfit = None) + + fullResponse.adjustFields(featureSwitches, ignoredTaxYear) shouldBe + fullResponse.copy(calculation = Some(calculationWithoutTransitionProfit)) + } + + "also remove calculation if no other fields are defined in it" in { + // format: off + val onlyTransitionProfitCalculation = Calculation( + None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, None, None, None, None, None, None, None, + transitionProfit = Some(TransitionProfit(totalTaxableTransitionProfit = Some(123), transitionProfitDetail = None)) + ) + // format: on + + val response = fullResponse.copy(calculation = Some(onlyTransitionProfitCalculation)) + + response.adjustFields(featureSwitches, ignoredTaxYear) shouldBe response.copy(calculation = None) + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductionsSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductionsSpec.scala new file mode 100644 index 000000000..5e38efd70 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/allowancesAndDeductions/AllowancesAndDeductionsSpec.scala @@ -0,0 +1,130 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.allowancesAndDeductions + +import play.api.libs.json.{JsValue, Json} +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport + +class AllowancesAndDeductionsSpec extends UnitSpec with EnumJsonSpecSupport { + + val model: AllowancesAndDeductions = + AllowancesAndDeductions( + Some(12500), + Some( + MarriageAllowanceTransferOut( + 1001.99, + 1001.99 + )), + Some(12500), + Some(12500), + Some(12500), + Some(12500), + Some(12500), + Some(1001.99), + Some(1001.99), + Some(1001.99), + Some(1001.99), + Some( + AnnuityPayments( + Some(1001.99), + Some(1001.99) + )), + Some(1001.99), + Some( + PensionContributionsDetail( + Some(1001.99), + Some(1001.99), + Some(1001.99) + )) + ) + + val mtdJson: JsValue = Json.parse(""" + |{ + | "personalAllowance": 12500, + | "marriageAllowanceTransferOut": { + | "personalAllowanceBeforeTransferOut": 1001.99, + | "transferredOutAmount": 1001.99 + | }, + | "reducedPersonalAllowance": 12500, + | "giftOfInvestmentsAndPropertyToCharity": 12500, + | "blindPersonsAllowance": 12500, + | "lossesAppliedToGeneralIncome": 12500, + | "cgtLossSetAgainstInYearGeneralIncome": 12500, + | "qualifyingLoanInterestFromInvestments": 1001.99, + | "postCessationTradeReceipts": 1001.99, + | "paymentsToTradeUnionsForDeathBenefits": 1001.99, + | "grossAnnuityPayments": 1001.99, + | "annuityPayments": { + | "reliefClaimed": 1001.99, + | "rate": 1001.99 + | }, + | "pensionContributions": 1001.99, + | "pensionContributionsDetail": { + | "retirementAnnuityPayments": 1001.99, + | "paymentToEmployersSchemeNoTaxRelief": 1001.99, + | "overseasPensionSchemeContributions": 1001.99 + | } + |} + |""".stripMargin) + + val ifsJson: JsValue = Json.parse(""" + |{ + | "personalAllowance": 12500, + | "marriageAllowanceTransferOut": { + | "personalAllowanceBeforeTransferOut": 1001.99, + | "transferredOutAmount": 1001.99 + | }, + | "reducedPersonalAllowance": 12500, + | "giftOfInvestmentsAndPropertyToCharity": 12500, + | "blindPersonsAllowance": 12500, + | "lossesAppliedToGeneralIncome": 12500, + | "cgtLossSetAgainstInYearGeneralIncome": 12500, + | "qualifyingLoanInterestFromInvestments": 1001.99, + | "post-cessationTradeReceipts": 1001.99, + | "paymentsToTradeUnionsForDeathBenefits": 1001.99, + | "grossAnnuityPayments": 1001.99, + | "annuityPayments": { + | "reliefClaimed": 1001.99, + | "rate": 1001.99 + | }, + | "pensionContributions": 1001.99, + | "pensionContributionsDetail": { + | "retirementAnnuityPayments": 1001.99, + | "paymentToEmployersSchemeNoTaxRelief": 1001.99, + | "overseasPensionSchemeContributions": 1001.99 + | } + |} + |""".stripMargin) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + model shouldBe ifsJson.as[AllowancesAndDeductions] + } + } + } + + "writes" when { + "passed valid model" should { + "return valid json" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLossSpec.scala new file mode 100644 index 000000000..4617bfc1c --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/businessProfitAndLoss/BusinessProfitAndLossSpec.scala @@ -0,0 +1,145 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.businessProfitAndLoss + +import play.api.libs.json.{JsValue, Json} +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class BusinessProfitAndLossSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "incomeSourceName": "Dave's Bar", + | "totalIncome": 456.00, + | "totalExpenses": 456.00, + | "netProfit": 456.00, + | "netLoss": 456.00, + | "totalAdditions": 456.00, + | "totalDeductions": 456.00, + | "accountingAdjustments": 456.00, + | "taxableProfit": 456, + | "adjustedIncomeTaxLoss": 456, + | "totalBroughtForwardIncomeTaxLosses": 456, + | "lossForCSFHL": 456, + | "broughtForwardIncomeTaxLossesUsed": 456, + | "taxableProfitAfterIncomeTaxLossesDeduction": 456, + | "carrySidewaysIncomeTaxLossesUsed": 456, + | "broughtForwardCarrySidewaysIncomeTaxLossesUsed": 456, + | "totalIncomeTaxLossesCarriedForward": 456, + | "class4Loss": 456, + | "totalBroughtForwardClass4Losses": 456, + | "broughtForwardClass4LossesUsed": 456, + | "carrySidewaysClass4LossesUsed": 456, + | "totalClass4LossesCarriedForward": 456 + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType): BusinessProfitAndLoss = + BusinessProfitAndLoss( + incomeSourceId = "123456789012345", + incomeSourceType = incomeSourceType, + incomeSourceName = Some("Dave's Bar"), + totalIncome = Some(BigDecimal(456.00)), + totalExpenses = Some(BigDecimal(456.00)), + netProfit = Some(BigDecimal(456.00)), + netLoss = Some(BigDecimal(456.00)), + totalAdditions = Some(BigDecimal(456.00)), + totalDeductions = Some(BigDecimal(456.00)), + accountingAdjustments = Some(BigDecimal(456.00)), + taxableProfit = Some(BigInt(456)), + adjustedIncomeTaxLoss = Some(BigInt(456)), + totalBroughtForwardIncomeTaxLosses = Some(BigInt(456)), + lossForCSFHL = Some(BigInt(456)), + broughtForwardIncomeTaxLossesUsed = Some(BigInt(456)), + taxableProfitAfterIncomeTaxLossesDeduction = Some(BigInt(456)), + carrySidewaysIncomeTaxLossesUsed = Some(BigInt(456)), + broughtForwardCarrySidewaysIncomeTaxLossesUsed = Some(BigInt(456)), + totalIncomeTaxLossesCarriedForward = Some(BigInt(456)), + class4Loss = Some(BigInt(456)), + totalBroughtForwardClass4Losses = Some(BigInt(456)), + broughtForwardClass4LossesUsed = Some(BigInt(456)), + carrySidewaysClass4LossesUsed = Some(BigInt(456)), + totalClass4LossesCarriedForward = Some(BigInt(456)) + ) + + def mtdJson(incomeSourceType: IncomeSourceType): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "incomeSourceName": "Dave's Bar", + | "totalIncome": 456.00, + | "totalExpenses": 456.00, + | "netProfit": 456.00, + | "netLoss": 456.00, + | "totalAdditions": 456.00, + | "totalDeductions": 456.00, + | "accountingAdjustments": 456.00, + | "taxableProfit": 456, + | "adjustedIncomeTaxLoss": 456, + | "totalBroughtForwardIncomeTaxLosses": 456, + | "lossForCSFHL": 456, + | "broughtForwardIncomeTaxLossesUsed": 456, + | "taxableProfitAfterIncomeTaxLossesDeduction": 456, + | "carrySidewaysIncomeTaxLossesUsed": 456, + | "broughtForwardCarrySidewaysIncomeTaxLossesUsed": 456, + | "totalIncomeTaxLossesCarriedForward": 456, + | "class4Loss": 456, + | "totalBroughtForwardClass4Losses": 456, + | "broughtForwardClass4LossesUsed": 456, + | "carrySidewaysClass4LossesUsed": 456, + | "totalClass4LossesCarriedForward": 456 + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`), + Test("02", IncomeSourceType.`uk-property-non-fhl`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`), + Test("04", IncomeSourceType.`uk-property-fhl`), + Test("15", IncomeSourceType.`foreign-property`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType) => + s"provided downstream income source type $downstreamIncomeSourceType" in { + downstreamJson(downstreamIncomeSourceType).as[BusinessProfitAndLoss] shouldBe + model(incomeSourceType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType) => + s"provided income source type $incomeSourceType" in { + Json.toJson(model(incomeSourceType)) shouldBe + mtdJson(incomeSourceType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/CommonForeignDividendSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/CommonForeignDividendSpec.scala new file mode 100644 index 000000000..0c8811d66 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/CommonForeignDividendSpec.scala @@ -0,0 +1,77 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class CommonForeignDividendSpec extends UnitSpec with JsonErrorValidators { + + val model: CommonForeignDividend = CommonForeignDividend( + Some(IncomeSourceType.`foreign-dividends`), + "GER", + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(true) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceType": "07", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceType": "foreign-dividends", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[CommonForeignDividend] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala new file mode 100644 index 000000000..9fb45f887 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -0,0 +1,160 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { + + val ukModel: UkDividends = UkDividends( + Some("000000000000210"), + Some(IncomeSourceType.`uk-dividends`), + Some(12500), + Some(12500) + ) + + val otherModel: OtherDividends = OtherDividends( + Some("stockDividend"), + Some("string"), + Some(5000.99) + ) + + val foreignModel: CommonForeignDividend = CommonForeignDividend( + Some(IncomeSourceType.`foreign-dividends`), + "GER", + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(true) + ) + + val model: DividendsIncome = DividendsIncome( + Some(12500), + Some(12500), + Some(ukModel), + Some(Seq(otherModel)), + Some(12500), + Some(Seq(foreignModel)), + Some(Seq(foreignModel)) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "totalChargeableDividends":12500, + | "totalUkDividends":12500, + | "ukDividends":{ + | "incomeSourceId":"000000000000210", + | "incomeSourceType":"10", + | "dividends":12500, + | "otherUkDividends":12500 + | }, + | "otherDividends":[ + | { + | "typeOfDividend":"stockDividend", + | "customerReference":"string", + | "grossAmount":5000.99 + | } + | ], + | "chargeableForeignDividends":12500, + | "foreignDividends":[ + | { + | "incomeSourceType":"07", + | "countryCode":"GER", + | "grossIncome":5000.99, + | "netIncome":5000.99, + | "taxDeducted":5000.99, + | "foreignTaxCreditRelief":true + | } + | ], + | "dividendIncomeReceivedWhilstAbroad":[ + | { + | "incomeSourceType":"07", + | "countryCode":"GER", + | "grossIncome":5000.99, + | "netIncome":5000.99, + | "taxDeducted":5000.99, + | "foreignTaxCreditRelief":true + | } + | ] + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "totalChargeableDividends":12500, + | "totalUkDividends":12500, + | "ukDividends":{ + | "incomeSourceId":"000000000000210", + | "incomeSourceType":"uk-dividends", + | "dividends":12500, + | "otherUkDividends":12500 + | }, + | "otherDividends":[ + | { + | "typeOfDividend":"stockDividend", + | "customerReference":"string", + | "grossAmount":5000.99 + | } + | ], + | "chargeableForeignDividends":12500, + | "foreignDividends":[ + | { + | "incomeSourceType":"foreign-dividends", + | "countryCode":"GER", + | "grossIncome":5000.99, + | "netIncome":5000.99, + | "taxDeducted":5000.99, + | "foreignTaxCreditRelief":true + | } + | ], + | "dividendIncomeReceivedWhilstAbroad":[ + | { + | "incomeSourceType":"foreign-dividends", + | "countryCode":"GER", + | "grossIncome":5000.99, + | "netIncome":5000.99, + | "taxDeducted":5000.99, + | "foreignTaxCreditRelief":true + | } + | ] + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[DividendsIncome] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/UkDividendsSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/UkDividendsSpec.scala new file mode 100644 index 000000000..77df39505 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/UkDividendsSpec.scala @@ -0,0 +1,71 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class UkDividendsSpec extends UnitSpec with JsonErrorValidators { + + val model: UkDividends = UkDividends( + Some("000000000000210"), + Some(IncomeSourceType.`uk-dividends`), + Some(5000), + Some(5000) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceId": "000000000000210", + | "incomeSourceType": "10", + | "dividends": 5000, + | "otherUkDividends": 5000 + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceId": "000000000000210", + | "incomeSourceType": "uk-dividends", + | "dividends": 5000, + | "otherUkDividends": 5000 + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[UkDividends] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetailSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetailSpec.scala new file mode 100644 index 000000000..f7a60d206 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/BenefitsInKindDetailSpec.scala @@ -0,0 +1,142 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class BenefitsInKindDetailSpec extends UnitSpec with JsonErrorValidators { + + val model: BenefitsInKindDetail = BenefitsInKindDetail( + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(5000.99) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "apportionedAccommodation": 5000.99, + | "apportionedAssets": 5000.99, + | "apportionedAssetTransfer": 5000.99, + | "apportionedBeneficialLoan": 5000.99, + | "apportionedCar": 5000.99, + | "apportionedCarFuel": 5000.99, + | "apportionedEducationalServices": 5000.99, + | "apportionedEntertaining": 5000.99, + | "apportionedExpenses": 5000.99, + | "apportionedMedicalInsurance": 5000.99, + | "apportionedTelephone": 5000.99, + | "apportionedService": 5000.99, + | "apportionedTaxableExpenses": 5000.99, + | "apportionedVan": 5000.99, + | "apportionedVanFuel": 5000.99, + | "apportionedMileage": 5000.99, + | "apportionedNonQualifyingRelocationExpenses": 5000.99, + | "apportionedNurseryPlaces": 5000.99, + | "apportionedOtherItems": 5000.99, + | "apportionedPaymentsOnEmployeesBehalf": 5000.99, + | "apportionedPersonalIncidentalExpenses": 5000.99, + | "apportionedQualifyingRelocationExpenses": 5000.99, + | "apportionedEmployerProvidedProfessionalSubscriptions": 5000.99, + | "apportionedEmployerProvidedServices": 5000.99, + | "apportionedIncomeTaxPaidByDirector": 5000.99, + | "apportionedTravelAndSubsistence": 5000.99, + | "apportionedVouchersAndCreditCards": 5000.99, + | "apportionedNonCash": 5000.99 + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "apportionedAccommodation": 5000.99, + | "apportionedAssets": 5000.99, + | "apportionedAssetTransfer": 5000.99, + | "apportionedBeneficialLoan": 5000.99, + | "apportionedCar": 5000.99, + | "apportionedCarFuel": 5000.99, + | "apportionedEducationalServices": 5000.99, + | "apportionedEntertaining": 5000.99, + | "apportionedExpenses": 5000.99, + | "apportionedMedicalInsurance": 5000.99, + | "apportionedTelephone": 5000.99, + | "apportionedService": 5000.99, + | "apportionedTaxableExpenses": 5000.99, + | "apportionedVan": 5000.99, + | "apportionedVanFuel": 5000.99, + | "apportionedMileage": 5000.99, + | "apportionedNonQualifyingRelocationExpenses": 5000.99, + | "apportionedNurseryPlaces": 5000.99, + | "apportionedOtherItems": 5000.99, + | "apportionedPaymentsOnEmployeesBehalf": 5000.99, + | "apportionedPersonalIncidentalExpenses": 5000.99, + | "apportionedQualifyingRelocationExpenses": 5000.99, + | "apportionedEmployerProvidedProfessionalSubscriptions": 5000.99, + | "apportionedEmployerProvidedServices": 5000.99, + | "apportionedIncomeTaxPaidByDirector": 5000.99, + | "apportionedTravelAndSubsistence": 5000.99, + | "apportionedVouchersAndCreditCards": 5000.99, + | "apportionedNonCash": 5000.99 + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[BenefitsInKindDetail] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/IncomeSourceSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/IncomeSourceSpec.scala new file mode 100644 index 000000000..a0a31d876 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/endOfYearEstimate/IncomeSourceSpec.scala @@ -0,0 +1,74 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.endOfYearEstimate + +import play.api.libs.json.Json +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType._ + +class IncomeSourceSpec extends UnitSpec { + + "reads" should { + "successfully read in a model" when { + Seq( + ("01", `self-employment`), + ("02", `uk-property-non-fhl`), + ("03", `foreign-property-fhl-eea`), + ("04", `uk-property-fhl`), + ("05", `employments`), + ("06", `foreign-income`), + ("07", `foreign-dividends`), + ("09", `uk-savings-and-gains`), + ("10", `uk-dividends`), + ("11", `state-benefits`), + ("12", `gains-on-life-policies`), + ("13", `share-schemes`), + ("15", `foreign-property`), + ("16", `foreign-savings-and-gains`), + ("17", `other-dividends`), + ("18", `uk-securities`), + ("19", `other-income`), + ("20", `foreign-pension`), + ("21", `non-paye-income`), + ("22", `capital-gains-tax`), + ("98", `charitable-giving`) + ).foreach { case (downstreamIncomeSourceType, mtdIncomeSourceType) => + s"provided downstream IncomeSourceType of $downstreamIncomeSourceType" in { + val json = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$downstreamIncomeSourceType", + | "incomeSourceName": "My name", + | "taxableIncome": 3, + | "finalised": true + |} + |""".stripMargin) + + val model = IncomeSource( + incomeSourceId = Some("123456789012345"), + incomeSourceType = mtdIncomeSourceType, + incomeSourceName = Some("My name"), + taxableIncome = 3, + finalised = Some(true)) + + json.as[IncomeSource] shouldBe model + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala new file mode 100644 index 000000000..7baeea681 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala @@ -0,0 +1,102 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.{ClaimType, IncomeSourceType} + +class CarriedForwardLossSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "originatingClaimId": "123456789012346", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "claimType": "$claimType", + | "taxYearClaimMade": 2020, + | "taxYearLossIncurred": 2019, + | "currentLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): CarriedForwardLoss = + CarriedForwardLoss( + claimId = Some("123456789012345"), + originatingClaimId = Some("123456789012346"), + incomeSourceId = "123456789012347", + incomeSourceType = incomeSourceType, + claimType = claimType, + taxYearClaimMade = Some(TaxYear.fromDownstream("2020")), + taxYearLossIncurred = TaxYear.fromDownstream("2019"), + currentLossValue = BigInt(456), + lossType = Some("income") + ) + + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "originatingClaimId": "123456789012346", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "claimType": "$claimType", + | "taxYearClaimMade": "2019-20", + | "taxYearLossIncurred": "2018-19", + | "currentLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + s"provided downstream type of claim $downstreamClaimType" in { + downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[CarriedForwardLoss] shouldBe + model(incomeSourceType, claimType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType, _, claimType) => + s"provided type of claim $claimType" in { + Json.toJson(model(incomeSourceType, claimType)) shouldBe + mtdJson(incomeSourceType, claimType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ClaimNotAppliedSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ClaimNotAppliedSpec.scala new file mode 100644 index 000000000..ba5745dd6 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ClaimNotAppliedSpec.scala @@ -0,0 +1,90 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.{ClaimType, IncomeSourceType} + +class ClaimNotAppliedSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "taxYearClaimMade": 2020, + | "claimType": "$claimType" + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): ClaimNotApplied = + ClaimNotApplied( + claimId = "123456789012345", + incomeSourceId = "123456789012347", + incomeSourceType = incomeSourceType, + taxYearClaimMade = TaxYear.fromDownstream("2020"), + claimType = claimType + ) + + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "taxYearClaimMade": "2019-20", + | "claimType": "$claimType" + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + s"provided downstream type of claim $downstreamClaimType" in { + downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[ClaimNotApplied] shouldBe + model(incomeSourceType, claimType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType, _, claimType) => + s"provided type of claim $claimType" in { + Json.toJson(model(incomeSourceType, claimType)) shouldBe + mtdJson(incomeSourceType, claimType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLossSpec.scala new file mode 100644 index 000000000..93ae7d457 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/DefaultCarriedForwardLossSpec.scala @@ -0,0 +1,86 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class DefaultCarriedForwardLossSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "taxYearLossIncurred": 2019, + | "currentLossValue": 456 + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType): DefaultCarriedForwardLoss = + DefaultCarriedForwardLoss( + incomeSourceId = "123456789012345", + incomeSourceType = incomeSourceType, + taxYearLossIncurred = TaxYear.fromDownstream("2019"), + currentLossValue = BigInt(456) + ) + + def mtdJson(incomeSourceType: IncomeSourceType): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "taxYearLossIncurred": "2018-19", + | "currentLossValue": 456 + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`), + Test("02", IncomeSourceType.`uk-property-non-fhl`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`), + Test("04", IncomeSourceType.`uk-property-fhl`), + Test("15", IncomeSourceType.`foreign-property`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType) => + s"provided downstream income source type $downstreamIncomeSourceType" in { + downstreamJson(downstreamIncomeSourceType).as[DefaultCarriedForwardLoss] shouldBe + model(incomeSourceType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType) => + s"provided income source type $incomeSourceType" in { + Json.toJson(model(incomeSourceType)) shouldBe + mtdJson(incomeSourceType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala new file mode 100644 index 000000000..1f9173ce7 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala @@ -0,0 +1,108 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.{ClaimType, IncomeSourceType} + +class ResultOfClaimsAppliedSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "originatingClaimId": "123456789012346", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "taxYearClaimMade": 2020, + | "claimType": "$claimType", + | "mtdLoss": false, + | "taxYearLossIncurred": 2019, + | "lossAmountUsed": 123, + | "remainingLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): ResultOfClaimsApplied = + ResultOfClaimsApplied( + claimId = Some("123456789012345"), + originatingClaimId = Some("123456789012346"), + incomeSourceId = "123456789012347", + incomeSourceType = incomeSourceType, + taxYearClaimMade = TaxYear.fromDownstream("2020"), + claimType = claimType, + mtdLoss = Some(false), + taxYearLossIncurred = TaxYear.fromDownstream("2019"), + lossAmountUsed = BigInt(123), + remainingLossValue = BigInt(456), + lossType = Some("income") + ) + + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + |{ + | "claimId": "123456789012345", + | "originatingClaimId": "123456789012346", + | "incomeSourceId": "123456789012347", + | "incomeSourceType": "$incomeSourceType", + | "taxYearClaimMade": "2019-20", + | "claimType": "$claimType", + | "mtdLoss": false, + | "taxYearLossIncurred": "2018-19", + | "lossAmountUsed": 123, + | "remainingLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + s"provided downstream type of claim $downstreamClaimType" in { + downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[ResultOfClaimsApplied] shouldBe + model(incomeSourceType, claimType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType, _, claimType) => + s"provided type of claim $claimType" in { + Json.toJson(model(incomeSourceType, claimType)) shouldBe + mtdJson(incomeSourceType, claimType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala new file mode 100644 index 000000000..08af2cf6c --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala @@ -0,0 +1,89 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import play.api.libs.json.{JsValue, Json} +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class UnclaimedLossSpec extends UnitSpec { + + def downstreamJson(incomeSourceType: String): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "taxYearLossIncurred": 2020, + | "currentLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + def model(incomeSourceType: IncomeSourceType): UnclaimedLoss = + UnclaimedLoss( + incomeSourceId = Some("123456789012345"), + incomeSourceType = incomeSourceType, + taxYearLossIncurred = TaxYear.fromDownstream("2020"), + currentLossValue = BigInt(456), + lossType = Some("income") + ) + + def mtdJson(incomeSourceType: IncomeSourceType): JsValue = Json.parse(s""" + |{ + | "incomeSourceId": "123456789012345", + | "incomeSourceType": "$incomeSourceType", + | "taxYearLossIncurred": "2019-20", + | "currentLossValue": 456, + | "lossType": "income" + |} + |""".stripMargin) + + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType) + + val testData: Seq[Test] = Seq[Test]( + Test("01", IncomeSourceType.`self-employment`), + Test("02", IncomeSourceType.`uk-property-non-fhl`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`), + Test("04", IncomeSourceType.`uk-property-fhl`), + Test("15", IncomeSourceType.`foreign-property`) + ) + + "reads" should { + "successfully read in a model" when { + + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType) => + s"provided downstream income source type $downstreamIncomeSourceType" in { + downstreamJson(downstreamIncomeSourceType).as[UnclaimedLoss] shouldBe + model(incomeSourceType) + } + } + } + } + + "writes" should { + "successfully write a model to json" when { + + testData.foreach { case Test(_, incomeSourceType) => + s"provided income source type $incomeSourceType" in { + Json.toJson(model(incomeSourceType)) shouldBe + mtdJson(incomeSourceType) + } + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncomeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncomeSpec.scala new file mode 100644 index 000000000..df1b14a9a --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/ForeignSavingsAndGainsIncomeSpec.scala @@ -0,0 +1,77 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType.`foreign-savings-and-gains` + +class ForeignSavingsAndGainsIncomeSpec extends UnitSpec with JsonErrorValidators { + + val model: ForeignSavingsAndGainsIncome = ForeignSavingsAndGainsIncome( + `foreign-savings-and-gains`, + Some("GER"), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(true) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceType": "16", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceType": "foreign-savings-and-gains", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[ForeignSavingsAndGainsIncome] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncomeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncomeSpec.scala new file mode 100644 index 000000000..d8467dfd0 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/SavingsAndGainsIncomeSpec.scala @@ -0,0 +1,128 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class SavingsAndGainsIncomeSpec extends UnitSpec with JsonErrorValidators { + + val ukModel: UkSavingsAndGainsIncome = UkSavingsAndGainsIncome( + Some("000000000000210"), + IncomeSourceType.`uk-savings-and-gains`, + Some("My Savings Account 1"), + 5000.99, + Some(5000.99), + Some(5000.99) + ) + + val foreignModel: ForeignSavingsAndGainsIncome = ForeignSavingsAndGainsIncome( + IncomeSourceType.`foreign-savings-and-gains`, + Some("GER"), + Some(5000.99), + Some(5000.99), + Some(5000.99), + Some(true) + ) + + val model: SavingsAndGainsIncome = SavingsAndGainsIncome( + Some(100), + Some(100), + Some(Seq(ukModel)), + Some(100), + Some(Seq(foreignModel)) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "totalChargeableSavingsAndGains": 100, + | "totalUkSavingsAndGains": 100, + | "ukSavingsAndGainsIncome": [ + | { + | "incomeSourceId": "000000000000210", + | "incomeSourceType": "09", + | "incomeSourceName": "My Savings Account 1", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99 + | } + | ], + | "chargeableForeignSavingsAndGains": 100, + | "foreignSavingsAndGainsIncome": [ + | { + | "incomeSourceType": "16", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + | } + | ] + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "totalChargeableSavingsAndGains": 100, + | "totalUkSavingsAndGains": 100, + | "ukSavingsAndGainsIncome": [ + | { + | "incomeSourceId": "000000000000210", + | "incomeSourceType": "uk-savings-and-gains", + | "incomeSourceName": "My Savings Account 1", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99 + | } + | ], + | "chargeableForeignSavingsAndGains": 100, + | "foreignSavingsAndGainsIncome": [ + | { + | "incomeSourceType": "foreign-savings-and-gains", + | "countryCode": "GER", + | "grossIncome": 5000.99, + | "netIncome": 5000.99, + | "taxDeducted": 5000.99, + | "foreignTaxCreditRelief": true + | } + | ] + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[SavingsAndGainsIncome] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncomeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncomeSpec.scala new file mode 100644 index 000000000..b6db1e68f --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/savingsAndGainsIncome/UkSavingsAndGainsIncomeSpec.scala @@ -0,0 +1,77 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.savingsAndGainsIncome + +import play.api.libs.json.{JsValue, Json} +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec +import v7.common.model.response.IncomeSourceType + +class UkSavingsAndGainsIncomeSpec extends UnitSpec with JsonErrorValidators { + + val model: UkSavingsAndGainsIncome = UkSavingsAndGainsIncome( + Some("000000000000210"), + IncomeSourceType.`uk-savings-and-gains`, + Some("My Savings Account 1"), + 99.99, + Some(99.99), + Some(99.99) + ) + + val downstreamJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceId":"000000000000210", + | "incomeSourceType":"09", + | "incomeSourceName":"My Savings Account 1", + | "grossIncome":99.99, + | "netIncome":99.99, + | "taxDeducted":99.99 + |} + |""".stripMargin + ) + + val mtdJson: JsValue = Json.parse( + """ + |{ + | "incomeSourceId":"000000000000210", + | "incomeSourceType":"uk-savings-and-gains", + | "incomeSourceName":"My Savings Account 1", + | "grossIncome":99.99, + | "netIncome":99.99, + | "taxDeducted":99.99 + |} + |""".stripMargin + ) + + "reads" when { + "passed valid JSON" should { + "return a valid model" in { + downstreamJson.as[UkSavingsAndGainsIncome] shouldBe model + } + } + } + + "writes" when { + "passed valid model" should { + "return valid JSON" in { + Json.toJson(model) shouldBe mtdJson + } + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRelSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRelSpec.scala new file mode 100644 index 000000000..9aea5137b --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/BusinessAssetsDisposalsAndInvestorsRelSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class BusinessAssetsDisposalsAndInvestorsRelSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax" \ "businessAssetsDisposalsAndInvestorsRel").as[JsValue] + + testOptionalJsonFields[BusinessAssetsDisposalsAndInvestorsRel](json) + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CapitalGainsTaxSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CapitalGainsTaxSpec.scala new file mode 100644 index 000000000..dbeac33b8 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CapitalGainsTaxSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class CapitalGainsTaxSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax").as[JsValue] + + testAllOptionalJsonFieldsExcept[CapitalGainsTax](json)( + "totalCapitalGainsIncome", + "annualExemptionAmount", + "totalTaxableGains", + "capitalGainsTaxDue") + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandNameSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandNameSpec.scala new file mode 100644 index 000000000..821e33f57 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandNameSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.taxCalculation.CgtBandName._ + +class CgtBandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[CgtBandName]( + "lowerRate" -> `lower-rate`, + "higherRate" -> `higher-rate` + ) + + testWrites[CgtBandName]( + `lower-rate` -> "lower-rate", + `higher-rate` -> "higher-rate" + ) + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandSpec.scala new file mode 100644 index 000000000..bbdb76793 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/CgtBandSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsObject +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class CgtBandSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax" \ "otherGains" \ "cgtTaxBands").head.as[JsObject] + + testMandatoryJsonFields[CgtBand](json) + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class2NicsSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class2NicsSpec.scala new file mode 100644 index 000000000..c60615308 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class2NicsSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class Class2NicsSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "nics" \ "class2Nics").as[JsValue] + + testAllOptionalJsonFieldsExcept[Class2Nics](json)("underSmallProfitThreshold") + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class4NicsSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class4NicsSpec.scala new file mode 100644 index 000000000..1ba00c19c --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Class4NicsSpec.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class Class4NicsSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "nics" \ "class4Nics").get + + testAllOptionalJsonFieldsExcept[Class4Nics](json)("totalAmount", "nic4Bands") + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala new file mode 100644 index 000000000..eccb38cfe --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandNameSpec.scala @@ -0,0 +1,51 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.taxCalculation.IncomeTaxBandName._ + +class IncomeTaxBandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[IncomeTaxBandName]( + "SSR" -> `savings-starter-rate`, + "ZRTBR" -> `allowance-awarded-at-basic-rate`, + "ZRTHR" -> `allowance-awarded-at-higher-rate`, + "ZRTAR" -> `allowance-awarded-at-additional-rate`, + "SRT" -> `starter-rate`, + "BRT" -> `basic-rate`, + "IRT" -> `intermediate-rate`, + "HRT" -> `higher-rate`, + "ART" -> `additional-rate`, + "AVRT" -> `advanced-rate` + ) + + testWrites[IncomeTaxBandName]( + `savings-starter-rate` -> "savings-starter-rate", + `allowance-awarded-at-basic-rate` -> "allowance-awarded-at-basic-rate", + `allowance-awarded-at-higher-rate` -> "allowance-awarded-at-higher-rate", + `allowance-awarded-at-additional-rate` -> "allowance-awarded-at-additional-rate", + `starter-rate` -> "starter-rate", + `basic-rate` -> "basic-rate", + `intermediate-rate` -> "intermediate-rate", + `higher-rate` -> "higher-rate", + `additional-rate` -> "additional-rate", + `advanced-rate` -> "advanced-rate" + ) + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandSpec.scala new file mode 100644 index 000000000..4358fbac8 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxBandSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsObject +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class IncomeTaxBandSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "incomeTax" \ "payPensionsProfit" \ "taxBands").head.as[JsObject] + + testMandatoryJsonFields[IncomeTaxBand](json) + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxItemSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxItemSpec.scala new file mode 100644 index 000000000..fcc6e28d2 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxItemSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class IncomeTaxItemSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "incomeTax" \ "payPensionsProfit").as[JsValue] + + testAllMandatoryJsonFieldsExcept[IncomeTaxItem](json)("taxBands") + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxSpec.scala new file mode 100644 index 000000000..bb3c9c496 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/IncomeTaxSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class IncomeTaxSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "incomeTax").as[JsValue] + + testAllOptionalJsonFieldsExcept[IncomeTax](json)( + "totalIncomeReceivedFromAllSources", + "totalAllowancesAndDeductions", + "totalTaxableIncome", + "incomeTaxCharged") + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandNameSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandNameSpec.scala new file mode 100644 index 000000000..c691ebc70 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandNameSpec.scala @@ -0,0 +1,37 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.taxCalculation.Nic4BandName._ + +class Nic4BandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[Nic4BandName]( + "ZRT" -> `zero-rate`, + "BRT" -> `basic-rate`, + "HRT" -> `higher-rate` + ) + + testWrites[Nic4BandName]( + `zero-rate` -> "zero-rate", + `basic-rate` -> "basic-rate", + `higher-rate` -> "higher-rate" + ) + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandSpec.scala new file mode 100644 index 000000000..0c37b5dfa --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/Nic4BandSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsObject +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class Nic4BandSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "nics" \ "class4Nics" \ "nic4Bands").head.as[JsObject] + + testAllMandatoryJsonFieldsExcept[Nic4Band](json)("threshold", "apportionedThreshold") + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/NicsSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/NicsSpec.scala new file mode 100644 index 000000000..1a57cc49f --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/NicsSpec.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class NicsSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "nics").get + + testOptionalJsonFields[Nics](json) + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/OtherGainsSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/OtherGainsSpec.scala new file mode 100644 index 000000000..0e73bfc3d --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/OtherGainsSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class OtherGainsSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax" \ "otherGains").as[JsValue] + + testOptionalJsonFields[OtherGains](json) + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterestSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterestSpec.scala new file mode 100644 index 000000000..fc548d2e5 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/ResidentialPropertyAndCarriedInterestSpec.scala @@ -0,0 +1,31 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.JsValue +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class ResidentialPropertyAndCarriedInterestSpec extends UnitSpec with JsonErrorValidators with TaxCalculationFixture { + + "have the correct fields optional" when { + val json = (taxCalculationDownstreamJson \ "capitalGainsTax" \ "residentialPropertyAndCarriedInterest").as[JsValue] + + testOptionalJsonFields[ResidentialPropertyAndCarriedInterest](json) + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculationFixture.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculationFixture.scala new file mode 100644 index 000000000..00c886850 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculationFixture.scala @@ -0,0 +1,30 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.{JsValue, Json} + +trait TaxCalculationFixture { + + val taxCalculationMtdJson: JsValue = + Json.parse(getClass.getResourceAsStream("/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_mtd.json")) + + val taxCalculationDownstreamJson: JsValue = + Json.parse(getClass.getResourceAsStream("/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/taxCalculation_downstream.json")) + + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculationSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculationSpec.scala new file mode 100644 index 000000000..0b8e8814c --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/taxCalculation/TaxCalculationSpec.scala @@ -0,0 +1,38 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.taxCalculation + +import play.api.libs.json.Json +import shared.models.utils.JsonErrorValidators +import shared.utils.UnitSpec + +class TaxCalculationSpec extends UnitSpec with TaxCalculationFixture with JsonErrorValidators { + + "TaxCalculation" must { + "allow conversion from downstream JSON to MTD JSON" when { + "JSON contains every field" in { + val model = taxCalculationDownstreamJson.as[TaxCalculation] + Json.toJson(model) shouldBe taxCalculationMtdJson + } + } + + "have the correct fields optional" when { + testOptionalJsonFields[TaxCalculation](taxCalculationDownstreamJson) + } + } + +} diff --git a/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala b/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala new file mode 100644 index 000000000..ca7e6b2f4 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala @@ -0,0 +1,129 @@ +/* + * Copyright 2024 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.metadata + +import play.api.libs.json.Json +import shared.models.domain.TaxYear +import shared.utils.UnitSpec +import v7.common.model.response.CalculationType + +class MetadataSpec extends UnitSpec { + + "reads" when { + "passed valid JSON with all fields populated" should { + "return the correct model" in { + Json + .parse("""{ + | "calculationId": "calcId", + | "taxYear": 2018, + | "requestedBy": "customer", + | "requestedTimestamp": "requested timestamp", + | "calculationReason": "reason", + | "calculationTimestamp": "calc timestamp", + | "calculationType": "crystallisation", + | "intentToCrystallise": true, + | "crystallised": true, + | "crystallisationTimestamp": "decl timestamp", + | "periodFrom": "from", + | "periodTo": "to" + | } + |""".stripMargin) + .as[Metadata] shouldBe + Metadata( + calculationId = "calcId", + taxYear = TaxYear.fromDownstream("2018"), + requestedBy = "customer", + requestedTimestamp = Some("requested timestamp"), + calculationReason = "reason", + calculationTimestamp = Some("calc timestamp"), + calculationType = CalculationType.`finalDeclaration`, + intentToSubmitFinalDeclaration = true, + finalDeclaration = true, + finalDeclarationTimestamp = Some("decl timestamp"), + periodFrom = "from", + periodTo = "to" + ) + } + } + + "only mandatory fields populated" should { + "default the final declaration fields to false" in { + Json + .parse("""{ + | "calculationId": "calcId", + | "taxYear": 2018, + | "requestedBy": "customer", + | "calculationReason": "reason", + | "calculationType": "crystallisation", + | "periodFrom": "from", + | "periodTo": "to" + | } + |""".stripMargin) + .as[Metadata] shouldBe + Metadata( + calculationId = "calcId", + taxYear = TaxYear.fromDownstream("2018"), + requestedBy = "customer", + requestedTimestamp = None, + calculationReason = "reason", + calculationTimestamp = None, + calculationType = CalculationType.`finalDeclaration`, + intentToSubmitFinalDeclaration = false, + finalDeclaration = false, + finalDeclarationTimestamp = None, + periodFrom = "from", + periodTo = "to" + ) + } + } + } + + "writes" should { + "work" in { + Json.toJson( + Metadata( + calculationId = "calcId", + taxYear = TaxYear.fromDownstream("2018"), + requestedBy = "customer", + requestedTimestamp = Some("requested timestamp"), + calculationReason = "reason", + calculationTimestamp = Some("calc timestamp"), + calculationType = CalculationType.`finalDeclaration`, + intentToSubmitFinalDeclaration = true, + finalDeclaration = true, + finalDeclarationTimestamp = Some("decl timestamp"), + periodFrom = "from", + periodTo = "to" + )) shouldBe Json.parse("""{ + | "calculationId": "calcId", + | "taxYear": "2017-18", + | "requestedBy": "customer", + | "requestedTimestamp": "requested timestamp", + | "calculationReason": "reason", + | "calculationTimestamp": "calc timestamp", + | "calculationType": "finalDeclaration", + | "intentToSubmitFinalDeclaration": true, + | "finalDeclaration": true, + | "finalDeclarationTimestamp": "decl timestamp", + | "periodFrom": "from", + | "periodTo": "to" + | } + |""".stripMargin) + } + } + +} diff --git a/test/v7/retrieveCalculation/schema/RetrieveCalculationSchemaSpec.scala b/test/v7/retrieveCalculation/schema/RetrieveCalculationSchemaSpec.scala new file mode 100644 index 000000000..d9e281b7d --- /dev/null +++ b/test/v7/retrieveCalculation/schema/RetrieveCalculationSchemaSpec.scala @@ -0,0 +1,52 @@ +/* + * Copyright 2024 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.schema + +import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks +import shared.models.domain.{TaxYear, TaxYearPropertyCheckSupport} +import shared.utils.UnitSpec + +class RetrieveCalculationSchemaSpec extends UnitSpec with ScalaCheckDrivenPropertyChecks with TaxYearPropertyCheckSupport { + + "Getting a schema" when { + "a tax year is valid" must { + "use Def1 for tax year 2023-24" in { + val taxYear = TaxYear.fromMtd("2023-24") + RetrieveCalculationSchema.schemaFor(taxYear.asMtd) shouldBe RetrieveCalculationSchema.Def1 + } + + "use Def2 for tax years from 2024-25" in { + forTaxYearsFrom(TaxYear.fromMtd("2024-25")) { taxYear => + RetrieveCalculationSchema.schemaFor(taxYear.asMtd) shouldBe RetrieveCalculationSchema.Def2 + } + } + + "use Def1 for pre-TYS tax years" in { + forPreTysTaxYears { taxYear => + RetrieveCalculationSchema.schemaFor(taxYear.asMtd) shouldBe RetrieveCalculationSchema.Def1 + } + } + } + + "the tax year is not valid" must { + "use a default of Def2 (where tax year validation will fail)" in { + RetrieveCalculationSchema.schemaFor("NotATaxYear") shouldBe RetrieveCalculationSchema.Def2 + } + } + } + +} From 3f61172f6bfb4e6d42974eede8445aad711d8d68 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:50:49 +0100 Subject: [PATCH 04/32] [MTDSA-26589] Update first 2 enum values --- .../model/response/CalculationType.scala | 8 +++---- .../ListCalculationsControllerISpec.scala | 2 +- ...1_RetrieveCalculationControllerISpec.scala | 6 ++--- ...2_RetrieveCalculationControllerISpec.scala | 2 +- .../conf/7.0/examples/list/list_response.json | 2 +- .../conf/7.0/schemas/list/list_response.json | 2 +- .../7.0/schemas/retrieve/def1/metadata.json | 2 +- .../7.0/schemas/retrieve/def2/metadata.json | 2 +- .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- .../model/response/CalculationTypeSpec.scala | 8 +++---- .../model/Def1_ListCalculationsFixture.scala | 4 ++-- .../def1/model/Def1_CalculationFixture.scala | 24 +++++++++---------- .../response/metadata/MetadataSpec.scala | 8 +++---- .../response/metadata/MetadataSpec.scala | 8 +++---- 15 files changed, 41 insertions(+), 41 deletions(-) diff --git a/app/v7/common/model/response/CalculationType.scala b/app/v7/common/model/response/CalculationType.scala index e83c18d1c..2e4b06e3e 100644 --- a/app/v7/common/model/response/CalculationType.scala +++ b/app/v7/common/model/response/CalculationType.scala @@ -23,14 +23,14 @@ sealed trait CalculationType object CalculationType { - case object `inYear` extends CalculationType - case object `finalDeclaration` extends CalculationType + case object `in-year` extends CalculationType + case object `final-declaration` extends CalculationType implicit val writes: Writes[CalculationType] = Enums.writes[CalculationType] implicit val reads: Reads[CalculationType] = Enums.readsUsing[CalculationType] { - case "inYear" => `inYear` - case "crystallisation" => `finalDeclaration` + case "in-year" => `in-year` + case "crystallisation" => `final-declaration` } } diff --git a/it/v7/listCalculations/def1/ListCalculationsControllerISpec.scala b/it/v7/listCalculations/def1/ListCalculationsControllerISpec.scala index 350e65c53..6fa0f23c7 100644 --- a/it/v7/listCalculations/def1/ListCalculationsControllerISpec.scala +++ b/it/v7/listCalculations/def1/ListCalculationsControllerISpec.scala @@ -53,7 +53,7 @@ class ListCalculationsControllerISpec extends IntegrationBaseSpec with Def1_List buildRequest(uri) .addQueryStringParameters(downstreamQueryParams: _*) .withHttpHeaders( - (ACCEPT, "application/vnd.hmrc.5.0+json"), + (ACCEPT, "application/vnd.hmrc.7.0+json"), (AUTHORIZATION, "Bearer 123") ) } diff --git a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala index 88cad8acf..0dd9cb449 100644 --- a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala +++ b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala @@ -42,7 +42,7 @@ class Def1_RetrieveCalculationControllerISpec extends IntegrationBaseSpec { setupStubs() buildRequest(uri) .withHttpHeaders( - (ACCEPT, "application/vnd.hmrc.6.0+json"), + (ACCEPT, "application/vnd.hmrc.7.0+json"), (AUTHORIZATION, "Bearer 123") ) } @@ -57,7 +57,7 @@ class Def1_RetrieveCalculationControllerISpec extends IntegrationBaseSpec { | "taxYear": 2017, | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | ${if (canBeFinalised) """"intentToCrystallise": true,""" else ""} | "periodFrom": "", | "periodTo": "" @@ -92,7 +92,7 @@ class Def1_RetrieveCalculationControllerISpec extends IntegrationBaseSpec { | "taxYear": "2016-17", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": $canBeFinalised, | "finalDeclaration": false, | "periodFrom": "", diff --git a/it/v7/retrieveCalculation/def2/Def2_RetrieveCalculationControllerISpec.scala b/it/v7/retrieveCalculation/def2/Def2_RetrieveCalculationControllerISpec.scala index 3d91e71e3..7f06931e0 100644 --- a/it/v7/retrieveCalculation/def2/Def2_RetrieveCalculationControllerISpec.scala +++ b/it/v7/retrieveCalculation/def2/Def2_RetrieveCalculationControllerISpec.scala @@ -43,7 +43,7 @@ class Def2_RetrieveCalculationControllerISpec extends IntegrationBaseSpec with D setupStubs() buildRequest(s"/$nino/self-assessment/$taxYear/$calculationId") .withHttpHeaders( - (ACCEPT, "application/vnd.hmrc.6.0+json"), + (ACCEPT, "application/vnd.hmrc.7.0+json"), (AUTHORIZATION, "Bearer 123") ) } diff --git a/resources/public/api/conf/7.0/examples/list/list_response.json b/resources/public/api/conf/7.0/examples/list/list_response.json index 820a7aeef..ab0dc6e99 100644 --- a/resources/public/api/conf/7.0/examples/list/list_response.json +++ b/resources/public/api/conf/7.0/examples/list/list_response.json @@ -14,7 +14,7 @@ { "calculationId": "f2fb30e5-4ab6-4a29-b3c1-c7264259ff1c", "calculationTimestamp": "2021-06-22T08:53:44.122Z", - "calculationType": "inYear", + "calculationType": "in-year", "requestedBy": "customer", "taxYear": "2021-22", "totalIncomeTaxAndNicsDue": 10000.12, diff --git a/resources/public/api/conf/7.0/schemas/list/list_response.json b/resources/public/api/conf/7.0/schemas/list/list_response.json index 6fa4be449..5d91e513b 100644 --- a/resources/public/api/conf/7.0/schemas/list/list_response.json +++ b/resources/public/api/conf/7.0/schemas/list/list_response.json @@ -25,7 +25,7 @@ "description": "The type of calculation performed.", "type": "string", "enum": [ - "inYear", + "in-year", "finalDeclaration" ] }, diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json index 68cdce52f..d26ed7272 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json @@ -98,7 +98,7 @@ "description": "The type of calculation performed.", "type": "string", "oneOf": [ - {"enum": ["inYear"], "description": "Cannot be used for a final declaration."}, + {"enum": ["in-year"], "description": "Cannot be used for a final declaration."}, {"enum": ["finalDeclaration"], "description": "Can be used when submitting a final declaration."} ] }, diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json index 68cdce52f..d26ed7272 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json @@ -98,7 +98,7 @@ "description": "The type of calculation performed.", "type": "string", "oneOf": [ - {"enum": ["inYear"], "description": "Cannot be used for a final declaration."}, + {"enum": ["in-year"], "description": "Cannot be used for a final declaration."}, {"enum": ["finalDeclaration"], "description": "Can be used when submitting a final declaration."} ] }, diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index 6e6d30b63..15a33cb8f 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -6,7 +6,7 @@ "requestedTimestamp": "2019-02-15T09:35:15.000Z", "calculationReason": "customerRequest", "calculationTimestamp": "2019-02-15T09:35:15.094Z", - "calculationType": "finalDeclaration", + "calculationType": "final-declaration", "intentToSubmitFinalDeclaration": true, "finalDeclaration": true, "finalDeclarationTimestamp": "2019-02-15T09:35:15.094Z", diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index 573d372ff..d15f4ac38 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -6,7 +6,7 @@ "requestedTimestamp": "2019-02-15T09:35:15.000Z", "calculationReason": "customerRequest", "calculationTimestamp": "2019-02-15T09:35:15.094Z", - "calculationType": "finalDeclaration", + "calculationType": "final-declaration", "intentToSubmitFinalDeclaration": true, "finalDeclaration": true, "finalDeclarationTimestamp": "2019-02-15T09:35:15.094Z", diff --git a/test/v7/common/model/response/CalculationTypeSpec.scala b/test/v7/common/model/response/CalculationTypeSpec.scala index 7e09a5aed..31f6ef9cc 100644 --- a/test/v7/common/model/response/CalculationTypeSpec.scala +++ b/test/v7/common/model/response/CalculationTypeSpec.scala @@ -23,13 +23,13 @@ import v7.common.model.response.CalculationType._ class CalculationTypeSpec extends UnitSpec with EnumJsonSpecSupport { testReads[CalculationType]( - "inYear" -> `inYear`, - "crystallisation" -> `finalDeclaration` + "in-year" -> `in-year`, + "crystallisation" -> `final-declaration` ) testWrites[CalculationType]( - `inYear` -> "inYear", - `finalDeclaration` -> "finalDeclaration" + `in-year` -> "in-year", + `final-declaration` -> "final-declaration" ) } diff --git a/test/v7/listCalculations/def1/model/Def1_ListCalculationsFixture.scala b/test/v7/listCalculations/def1/model/Def1_ListCalculationsFixture.scala index 55d511f7d..001b70bec 100644 --- a/test/v7/listCalculations/def1/model/Def1_ListCalculationsFixture.scala +++ b/test/v7/listCalculations/def1/model/Def1_ListCalculationsFixture.scala @@ -48,7 +48,7 @@ trait Def1_ListCalculationsFixture { | { | "calculationId":"c432a56d-e811-474c-a26a-76fc3bcaefe5", | "calculationTimestamp":"2021-07-12T07:51:43.112Z", - | "calculationType":"finalDeclaration", + | "calculationType":"final-declaration", | "requestedBy":"customer", | "taxYear":"2020-21", | "totalIncomeTaxAndNicsDue":10000.12, @@ -63,7 +63,7 @@ trait Def1_ListCalculationsFixture { val calculationModel: Def1_Calculation = Def1_Calculation( calculationId = "c432a56d-e811-474c-a26a-76fc3bcaefe5", calculationTimestamp = "2021-07-12T07:51:43.112Z", - calculationType = CalculationType.`finalDeclaration`, + calculationType = CalculationType.`final-declaration`, requestedBy = Some("customer"), taxYear = Some(TaxYear.fromDownstreamInt(2021)), totalIncomeTaxAndNicsDue = Some(10000.12), diff --git a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala index 04031a51e..04fcca447 100644 --- a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala +++ b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala @@ -18,7 +18,7 @@ package v7.retrieveCalculation.def1.model import play.api.libs.json.{JsObject, JsValue, Json} import shared.models.domain.TaxYear -import v7.common.model.response.CalculationType.`inYear` +import v7.common.model.response.CalculationType.`in-year` import v7.common.model.response.IncomeSourceType import v7.retrieveCalculation.def1.model.response.calculation.Calculation import v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome.{EmploymentAndPensionsIncome, EmploymentAndPensionsIncomeDetail} @@ -313,7 +313,7 @@ trait Def1_CalculationFixture { requestedTimestamp = None, calculationReason = "", calculationTimestamp = None, - calculationType = `inYear`, + calculationType = `in-year`, intentToSubmitFinalDeclaration = false, finalDeclaration = false, finalDeclarationTimestamp = None, @@ -431,7 +431,7 @@ trait Def1_CalculationFixture { | "taxYear": "2017-18", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, | "periodFrom": "", @@ -490,7 +490,7 @@ trait Def1_CalculationFixture { | "taxYear": "2017-18", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, | "periodFrom": "", @@ -549,7 +549,7 @@ trait Def1_CalculationFixture { "taxYear": "2017-18", "requestedBy": "", "calculationReason": "", - "calculationType": "inYear", + "calculationType": "in-year", "intentToSubmitFinalDeclaration": false, "finalDeclaration": false, "periodFrom": "", @@ -616,7 +616,7 @@ trait Def1_CalculationFixture { | "taxYear":"2017-18", | "requestedBy":"", | "calculationReason":"", - | "calculationType":"inYear", + | "calculationType":"in-year", | "intentToSubmitFinalDeclaration":false, | "finalDeclaration":false, | "periodFrom":"", @@ -650,7 +650,7 @@ trait Def1_CalculationFixture { | "taxYear": "2024-25", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, | "periodFrom": "", @@ -700,7 +700,7 @@ trait Def1_CalculationFixture { | "taxYear": "2017-18", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, | "periodFrom": "", @@ -751,7 +751,7 @@ trait Def1_CalculationFixture { | "taxYear": "2017-18", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, | "periodFrom": "", @@ -778,7 +778,7 @@ trait Def1_CalculationFixture { | "taxYear": "2017-18", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, | "periodFrom": "", @@ -809,7 +809,7 @@ trait Def1_CalculationFixture { | "taxYear": "2017-18", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, | "periodFrom": "", @@ -836,7 +836,7 @@ trait Def1_CalculationFixture { | "taxYear": "2017-18", | "requestedBy": "", | "calculationReason": "", - | "calculationType": "inYear", + | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, | "periodFrom": "", diff --git a/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala b/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala index 109d9a55d..e7bbf31f7 100644 --- a/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala @@ -51,7 +51,7 @@ class MetadataSpec extends UnitSpec { requestedTimestamp = Some("requested timestamp"), calculationReason = "reason", calculationTimestamp = Some("calc timestamp"), - calculationType = CalculationType.`finalDeclaration`, + calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = true, finalDeclaration = true, finalDeclarationTimestamp = Some("decl timestamp"), @@ -83,7 +83,7 @@ class MetadataSpec extends UnitSpec { requestedTimestamp = None, calculationReason = "reason", calculationTimestamp = None, - calculationType = CalculationType.`finalDeclaration`, + calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = false, finalDeclaration = false, finalDeclarationTimestamp = None, @@ -104,7 +104,7 @@ class MetadataSpec extends UnitSpec { requestedTimestamp = Some("requested timestamp"), calculationReason = "reason", calculationTimestamp = Some("calc timestamp"), - calculationType = CalculationType.`finalDeclaration`, + calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = true, finalDeclaration = true, finalDeclarationTimestamp = Some("decl timestamp"), @@ -118,7 +118,7 @@ class MetadataSpec extends UnitSpec { | "requestedTimestamp": "requested timestamp", | "calculationReason": "reason", | "calculationTimestamp": "calc timestamp", - | "calculationType": "finalDeclaration", + | "calculationType": "final-declaration", | "intentToSubmitFinalDeclaration": true, | "finalDeclaration": true, | "finalDeclarationTimestamp": "decl timestamp", diff --git a/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala b/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala index ca7e6b2f4..bdfa6dace 100644 --- a/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala @@ -50,7 +50,7 @@ class MetadataSpec extends UnitSpec { requestedTimestamp = Some("requested timestamp"), calculationReason = "reason", calculationTimestamp = Some("calc timestamp"), - calculationType = CalculationType.`finalDeclaration`, + calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = true, finalDeclaration = true, finalDeclarationTimestamp = Some("decl timestamp"), @@ -81,7 +81,7 @@ class MetadataSpec extends UnitSpec { requestedTimestamp = None, calculationReason = "reason", calculationTimestamp = None, - calculationType = CalculationType.`finalDeclaration`, + calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = false, finalDeclaration = false, finalDeclarationTimestamp = None, @@ -102,7 +102,7 @@ class MetadataSpec extends UnitSpec { requestedTimestamp = Some("requested timestamp"), calculationReason = "reason", calculationTimestamp = Some("calc timestamp"), - calculationType = CalculationType.`finalDeclaration`, + calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = true, finalDeclaration = true, finalDeclarationTimestamp = Some("decl timestamp"), @@ -115,7 +115,7 @@ class MetadataSpec extends UnitSpec { | "requestedTimestamp": "requested timestamp", | "calculationReason": "reason", | "calculationTimestamp": "calc timestamp", - | "calculationType": "finalDeclaration", + | "calculationType": "final-declaration", | "intentToSubmitFinalDeclaration": true, | "finalDeclaration": true, | "finalDeclarationTimestamp": "decl timestamp", From f23842053dc60b7b126f8b2c81c10c2ae8bb1367 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:09:16 +0100 Subject: [PATCH 05/32] Update OAS --- app/v7/common/model/response/CalculationType.scala | 2 +- .../Def1_RetrieveCalculationControllerISpec.scala | 2 +- .../api/conf/7.0/examples/list/list_response.json | 2 +- .../examples/retrieve/def1/retrieve_response.json | 2 +- .../examples/retrieve/def2/retrieve_response.json | 2 +- .../api/conf/7.0/schemas/list/list_response.json | 2 +- .../conf/7.0/schemas/retrieve/def1/common_defs.json | 2 +- .../api/conf/7.0/schemas/retrieve/def1/metadata.json | 12 ++++++------ .../conf/7.0/schemas/retrieve/def2/common_defs.json | 2 +- .../api/conf/7.0/schemas/retrieve/def2/metadata.json | 12 ++++++------ .../common/model/response/CalculationTypeSpec.scala | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/v7/common/model/response/CalculationType.scala b/app/v7/common/model/response/CalculationType.scala index 2e4b06e3e..bb84dc161 100644 --- a/app/v7/common/model/response/CalculationType.scala +++ b/app/v7/common/model/response/CalculationType.scala @@ -29,7 +29,7 @@ object CalculationType { implicit val writes: Writes[CalculationType] = Enums.writes[CalculationType] implicit val reads: Reads[CalculationType] = Enums.readsUsing[CalculationType] { - case "in-year" => `in-year` + case "inYear" => `in-year` case "crystallisation" => `final-declaration` } diff --git a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala index 0dd9cb449..963b28a5b 100644 --- a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala +++ b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala @@ -57,7 +57,7 @@ class Def1_RetrieveCalculationControllerISpec extends IntegrationBaseSpec { | "taxYear": 2017, | "requestedBy": "", | "calculationReason": "", - | "calculationType": "in-year", + | "calculationType": "inYear", | ${if (canBeFinalised) """"intentToCrystallise": true,""" else ""} | "periodFrom": "", | "periodTo": "" diff --git a/resources/public/api/conf/7.0/examples/list/list_response.json b/resources/public/api/conf/7.0/examples/list/list_response.json index ab0dc6e99..3111a8ec5 100644 --- a/resources/public/api/conf/7.0/examples/list/list_response.json +++ b/resources/public/api/conf/7.0/examples/list/list_response.json @@ -3,7 +3,7 @@ { "calculationId": "c432a56d-e811-474c-a26a-76fc3bcaefe5", "calculationTimestamp": "2021-07-12T07:51:43.112Z", - "calculationType": "finalDeclaration", + "calculationType": "final-declaration", "requestedBy": "customer", "taxYear": "2021-22", "totalIncomeTaxAndNicsDue": 10000.12, diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index 3aea70476..4200cd5c4 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -6,7 +6,7 @@ "requestedTimestamp": "2021-02-15T09:35:15.094Z", "calculationReason": "customerRequest", "calculationTimestamp": "2021-08-15T09:35:15.094Z", - "calculationType": "finalDeclaration", + "calculationType": "final-declaration", "intentToSubmitFinalDeclaration": true, "finalDeclaration": true, "finalDeclarationTimestamp": "2021-02-15T09:35:15.094Z", diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index 9bb6e454c..6d0b3ad8f 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -6,7 +6,7 @@ "requestedTimestamp": "2021-02-15T09:35:15.094Z", "calculationReason": "customerRequest", "calculationTimestamp": "2021-08-15T09:35:15.094Z", - "calculationType": "finalDeclaration", + "calculationType": "final-declaration", "intentToSubmitFinalDeclaration": true, "finalDeclaration": true, "finalDeclarationTimestamp": "2021-02-15T09:35:15.094Z", diff --git a/resources/public/api/conf/7.0/schemas/list/list_response.json b/resources/public/api/conf/7.0/schemas/list/list_response.json index 5d91e513b..af3ac57fe 100644 --- a/resources/public/api/conf/7.0/schemas/list/list_response.json +++ b/resources/public/api/conf/7.0/schemas/list/list_response.json @@ -26,7 +26,7 @@ "type": "string", "enum": [ "in-year", - "finalDeclaration" + "final-declaration" ] }, "requestedBy": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/common_defs.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/common_defs.json index 7327b4168..94fc9f914 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/common_defs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/common_defs.json @@ -37,7 +37,7 @@ "type": "string", "enum": [ "income", - "class4nics" + "class4-nics" ] }, "studentLoanPlanType": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json index d26ed7272..6b06d196c 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json @@ -43,31 +43,31 @@ "enum": [ "class2NICEvent" ], - "description": "The calculation was triggered internally by HMRC once the actual Class 2 NIC amount became available. This event is only applicable for an in-year \"finalDeclaration\" calculation type." + "description": "The calculation was triggered internally by HMRC once the actual Class 2 NIC amount became available. This event is only applicable for an in-year \"final-declaration\" calculation type." }, { "enum": [ "newLossEvent" ], - "description": "The calculation was triggered by HMRC on receipt of a new pre-MTD brought forward loss made by the customer. This event is only applicable for a \"finalDeclaration\" calculation type. This event is not currently supported and will be supported in the future." + "description": "The calculation was triggered by HMRC on receipt of a new pre-MTD brought forward loss made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ "newClaimEvent" ], - "description": "The calculation was triggered by HMRC on receipt of a new loss claim made by the customer. This event is only applicable for a \"finalDeclaration\" calculation type. This event is not currently supported and will be supported in the future." + "description": "The calculation was triggered by HMRC on receipt of a new loss claim made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ "updatedClaimEvent" ], - "description": "The calculation was triggered internally by HMRC on receipt of an updated loss claim made by the customer. This event is only applicable for a \"finalDeclaration\" calculation type. This event is not currently supported and will be supported in the future." + "description": "The calculation was triggered internally by HMRC on receipt of an updated loss claim made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ "updatedLossEvent" ], - "description": "The calculation was triggered internally by HMRC on receipt of an updated pre-MTD brought forward loss made by the customer. This event is only applicable for a \"finalDeclaration\" calculation type. This event is not currently supported and will be supported in the future." + "description": "The calculation was triggered internally by HMRC on receipt of an updated pre-MTD brought forward loss made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ @@ -99,7 +99,7 @@ "type": "string", "oneOf": [ {"enum": ["in-year"], "description": "Cannot be used for a final declaration."}, - {"enum": ["finalDeclaration"], "description": "Can be used when submitting a final declaration."} + {"enum": ["final-declaration"], "description": "Can be used when submitting a final declaration."} ] }, "intentToSubmitFinalDeclaration": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/common_defs.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/common_defs.json index 7327b4168..94fc9f914 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/common_defs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/common_defs.json @@ -37,7 +37,7 @@ "type": "string", "enum": [ "income", - "class4nics" + "class4-nics" ] }, "studentLoanPlanType": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json index d26ed7272..6b06d196c 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json @@ -43,31 +43,31 @@ "enum": [ "class2NICEvent" ], - "description": "The calculation was triggered internally by HMRC once the actual Class 2 NIC amount became available. This event is only applicable for an in-year \"finalDeclaration\" calculation type." + "description": "The calculation was triggered internally by HMRC once the actual Class 2 NIC amount became available. This event is only applicable for an in-year \"final-declaration\" calculation type." }, { "enum": [ "newLossEvent" ], - "description": "The calculation was triggered by HMRC on receipt of a new pre-MTD brought forward loss made by the customer. This event is only applicable for a \"finalDeclaration\" calculation type. This event is not currently supported and will be supported in the future." + "description": "The calculation was triggered by HMRC on receipt of a new pre-MTD brought forward loss made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ "newClaimEvent" ], - "description": "The calculation was triggered by HMRC on receipt of a new loss claim made by the customer. This event is only applicable for a \"finalDeclaration\" calculation type. This event is not currently supported and will be supported in the future." + "description": "The calculation was triggered by HMRC on receipt of a new loss claim made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ "updatedClaimEvent" ], - "description": "The calculation was triggered internally by HMRC on receipt of an updated loss claim made by the customer. This event is only applicable for a \"finalDeclaration\" calculation type. This event is not currently supported and will be supported in the future." + "description": "The calculation was triggered internally by HMRC on receipt of an updated loss claim made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ "updatedLossEvent" ], - "description": "The calculation was triggered internally by HMRC on receipt of an updated pre-MTD brought forward loss made by the customer. This event is only applicable for a \"finalDeclaration\" calculation type. This event is not currently supported and will be supported in the future." + "description": "The calculation was triggered internally by HMRC on receipt of an updated pre-MTD brought forward loss made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ @@ -99,7 +99,7 @@ "type": "string", "oneOf": [ {"enum": ["in-year"], "description": "Cannot be used for a final declaration."}, - {"enum": ["finalDeclaration"], "description": "Can be used when submitting a final declaration."} + {"enum": ["final-declaration"], "description": "Can be used when submitting a final declaration."} ] }, "intentToSubmitFinalDeclaration": { diff --git a/test/v7/common/model/response/CalculationTypeSpec.scala b/test/v7/common/model/response/CalculationTypeSpec.scala index 31f6ef9cc..32f6aca0b 100644 --- a/test/v7/common/model/response/CalculationTypeSpec.scala +++ b/test/v7/common/model/response/CalculationTypeSpec.scala @@ -23,7 +23,7 @@ import v7.common.model.response.CalculationType._ class CalculationTypeSpec extends UnitSpec with EnumJsonSpecSupport { testReads[CalculationType]( - "in-year" -> `in-year`, + "inYear" -> `in-year`, "crystallisation" -> `final-declaration` ) From 4d422707216b1b5f36bf74c2478cc4a8a5177a35 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 24 Sep 2024 17:22:26 +0100 Subject: [PATCH 06/32] Update typeOfDividend enums --- .../7.0/examples/retrieve/def1/retrieve_response.json | 2 +- .../7.0/examples/retrieve/def2/retrieve_response.json | 2 +- .../retrieve/def1/calculation/dividendsIncome.json | 8 ++++---- .../retrieve/def2/calculation/dividendsIncome.json | 8 ++++---- .../def1/model/response/calculation_downstream.json | 2 +- .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_downstream.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- .../calculation/dividendsIncome/DividendsIncomeSpec.scala | 6 +++--- .../calculation/dividendsIncome/DividendsIncomeSpec.scala | 6 +++--- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index 4200cd5c4..39dbd0ec8 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -763,7 +763,7 @@ }, "otherDividends": [ { - "typeOfDividend": "stockDividend", + "typeOfDividend": "stock-dividend", "customerReference": "ODPDLY235A", "grossAmount": 5000.99 } diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index 6d0b3ad8f..b11c0ba8a 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -737,7 +737,7 @@ }, "otherDividends": [ { - "typeOfDividend": "stockDividend", + "typeOfDividend": "stock-dividend", "customerReference": "ODPDLY235A", "grossAmount": 5000.99 } diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/dividendsIncome.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/dividendsIncome.json index 916fc6854..813a38bdb 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/dividendsIncome.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/dividendsIncome.json @@ -53,10 +53,10 @@ "description": "Type of dividend.", "type": "string", "enum": [ - "stockDividend", - "redeemableShares", - "bonusIssuesOfSecurities", - "closeCompanyLoansWrittenOff" + "stock-dividend", + "redeemable-shares", + "bonus-issues-of-securities", + "close-company-loans-written-off" ] }, "customerReference": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/dividendsIncome.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/dividendsIncome.json index 916fc6854..813a38bdb 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/dividendsIncome.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/dividendsIncome.json @@ -53,10 +53,10 @@ "description": "Type of dividend.", "type": "string", "enum": [ - "stockDividend", - "redeemableShares", - "bonusIssuesOfSecurities", - "closeCompanyLoansWrittenOff" + "stock-dividend", + "redeemable-shares", + "bonus-issues-of-securities", + "close-company-loans-written-off" ] }, "customerReference": { diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json index 57b9f8fc5..2c0d6e342 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json @@ -730,7 +730,7 @@ }, "otherDividends": [ { - "typeOfDividend": "stockDividend", + "typeOfDividend": "stock-dividend", "customerReference": "string", "grossAmount": 5000.99 } diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index 15a33cb8f..c5b1d509b 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -729,7 +729,7 @@ }, "otherDividends": [ { - "typeOfDividend": "stockDividend", + "typeOfDividend": "stock-dividend", "customerReference": "string", "grossAmount": 5000.99 } diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json index b7f1d20ae..831cf9bd0 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json @@ -714,7 +714,7 @@ }, "otherDividends": [ { - "typeOfDividend": "stockDividend", + "typeOfDividend": "stock-dividend", "customerReference": "string", "grossAmount": 5000.99 } diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index d15f4ac38..9fdf872a5 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -713,7 +713,7 @@ }, "otherDividends": [ { - "typeOfDividend": "stockDividend", + "typeOfDividend": "stock-dividend", "customerReference": "string", "grossAmount": 5000.99 } diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala index 3dd937082..6a94e0d94 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -31,7 +31,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { ) val otherModel: OtherDividends = OtherDividends( - Some("stockDividend"), + Some("stock-dividend"), Some("string"), Some(5000.99) ) @@ -68,7 +68,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { | }, | "otherDividends":[ | { - | "typeOfDividend":"stockDividend", + | "typeOfDividend":"stock-dividend", | "customerReference":"string", | "grossAmount":5000.99 | } @@ -111,7 +111,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { | }, | "otherDividends":[ | { - | "typeOfDividend":"stockDividend", + | "typeOfDividend":"stock-dividend", | "customerReference":"string", | "grossAmount":5000.99 | } diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala index 9fb45f887..17d9e1699 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -31,7 +31,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { ) val otherModel: OtherDividends = OtherDividends( - Some("stockDividend"), + Some("stock-dividend"), Some("string"), Some(5000.99) ) @@ -68,7 +68,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { | }, | "otherDividends":[ | { - | "typeOfDividend":"stockDividend", + | "typeOfDividend":"stock-dividend", | "customerReference":"string", | "grossAmount":5000.99 | } @@ -111,7 +111,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { | }, | "otherDividends":[ | { - | "typeOfDividend":"stockDividend", + | "typeOfDividend":"stock-dividend", | "customerReference":"string", | "grossAmount":5000.99 | } From 57fb1013c731bee0dbb6fc3c05b86ae993e65158 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:12:13 +0100 Subject: [PATCH 07/32] [MTDSA-23287] Update enums for consistency --- .../model/response/ReliefsClaimedType.scala | 36 +++++++++---------- .../ShortServiceRefundBandsName.scala | 35 ++++++++++++++++++ app/v7/common/model/response/Source.scala | 12 +++++-- .../ShortServiceRefundBands.scala | 13 +++---- .../ShortServiceRefundBands.scala | 13 +++---- .../retrieve/def1/retrieve_response.json | 8 ++--- .../retrieve/def2/retrieve_response.json | 8 ++--- .../chargeableEventGainsIncome.json | 8 ++--- .../calculation/pensionSavingsTaxCharges.json | 4 +-- .../retrieve/def1/calculation/reliefs.json | 4 +-- .../schemas/retrieve/def1/common_defs.json | 2 +- .../chargeableEventGainsIncome.json | 8 ++--- .../calculation/pensionSavingsTaxCharges.json | 4 +-- .../retrieve/def2/calculation/reliefs.json | 4 +-- .../schemas/retrieve/def2/common_defs.json | 2 +- .../def1/model/response/calculation_mtd.json | 4 +-- .../def2/model/response/calculation_mtd.json | 4 +-- .../response/ReliefsClaimedTypeSpec.scala | 36 +++++++++---------- 18 files changed, 124 insertions(+), 81 deletions(-) create mode 100644 app/v7/common/model/response/ShortServiceRefundBandsName.scala diff --git a/app/v7/common/model/response/ReliefsClaimedType.scala b/app/v7/common/model/response/ReliefsClaimedType.scala index 7472f8913..b8369deaa 100644 --- a/app/v7/common/model/response/ReliefsClaimedType.scala +++ b/app/v7/common/model/response/ReliefsClaimedType.scala @@ -22,28 +22,28 @@ import play.api.libs.json.{Reads, Writes} sealed trait ReliefsClaimedType object ReliefsClaimedType { - case object vctSubscriptions extends ReliefsClaimedType - case object eisSubscriptions extends ReliefsClaimedType - case object communityInvestment extends ReliefsClaimedType - case object seedEnterpriseInvestment extends ReliefsClaimedType - case object socialEnterpriseInvestment extends ReliefsClaimedType - case object maintenancePayments extends ReliefsClaimedType - case object deficiencyRelief extends ReliefsClaimedType - case object nonDeductibleLoanInterest extends ReliefsClaimedType - case object qualifyingDistributionRedemptionOfSharesAndSecurities extends ReliefsClaimedType + case object `vct-subscriptions` extends ReliefsClaimedType + case object `eis-subscriptions` extends ReliefsClaimedType + case object `community-investment` extends ReliefsClaimedType + case object `seed-enterprise-investment` extends ReliefsClaimedType + case object `social-enterprise-investment` extends ReliefsClaimedType + case object `maintenance-payments` extends ReliefsClaimedType + case object `deficiency-relief` extends ReliefsClaimedType + case object `non-deductible-loan-interest` extends ReliefsClaimedType + case object `qualifying-distribution-redemption-of-shares-and-securities` extends ReliefsClaimedType implicit val writes: Writes[ReliefsClaimedType] = Enums.writes[ReliefsClaimedType] implicit val reads: Reads[ReliefsClaimedType] = Enums.readsUsing { - case "vctSubscriptions" => vctSubscriptions - case "eisSubscriptions" => eisSubscriptions - case "communityInvestment" => communityInvestment - case "seedEnterpriseInvestment" => seedEnterpriseInvestment - case "socialEnterpriseInvestment" => socialEnterpriseInvestment - case "maintenancePayments" => maintenancePayments - case "deficiencyRelief" => deficiencyRelief - case "nonDeductableLoanInterest" => nonDeductibleLoanInterest - case "qualifyingDistributionRedemptionOfSharesAndSecurities" => qualifyingDistributionRedemptionOfSharesAndSecurities + case "vctSubscriptions" => `vct-subscriptions` + case "eisSubscriptions" => `eis-subscriptions` + case "communityInvestment" => `community-investment` + case "seedEnterpriseInvestment" => `seed-enterprise-investment` + case "socialEnterpriseInvestment" => `social-enterprise-investment` + case "maintenancePayments" => `maintenance-payments` + case "deficiencyRelief" => `deficiency-relief` + case "nonDeductableLoanInterest" => `non-deductible-loan-interest` + case "qualifyingDistributionRedemptionOfSharesAndSecurities" => `qualifying-distribution-redemption-of-shares-and-securities` } } diff --git a/app/v7/common/model/response/ShortServiceRefundBandsName.scala b/app/v7/common/model/response/ShortServiceRefundBandsName.scala new file mode 100644 index 000000000..792c830e6 --- /dev/null +++ b/app/v7/common/model/response/ShortServiceRefundBandsName.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait ShortServiceRefundBandsName + +object ShortServiceRefundBandsName { + case object `lower-band` extends ShortServiceRefundBandsName + case object `upper-band` extends ShortServiceRefundBandsName + + implicit val writes: Writes[ShortServiceRefundBandsName] = Enums.writes[ShortServiceRefundBandsName] + + implicit val reads: Reads[ShortServiceRefundBandsName] = Enums.readsUsing { + case "lowerBand" => `lower-band` + case "upperBand" => `upper-band` + } + +} diff --git a/app/v7/common/model/response/Source.scala b/app/v7/common/model/response/Source.scala index dd6750299..5cb3496d6 100644 --- a/app/v7/common/model/response/Source.scala +++ b/app/v7/common/model/response/Source.scala @@ -17,14 +17,20 @@ package v7.common.model.response import common.utils.enums.Enums -import play.api.libs.json.Format +import play.api.libs.json.{Reads, Writes} sealed trait Source object Source { case object `customer` extends Source - case object `HMRC HELD` extends Source + case object `hmrc-held` extends Source + + implicit val writes: Writes[Source] = Enums.writes[Source] + + implicit val reads: Reads[Source] = Enums.readsUsing[Source] { + case "customer" => `customer` + case "HMRC HELD" => `hmrc-held` + } - implicit val format: Format[Source] = Enums.format[Source] } diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala index 84f05068a..ae4a66d0a 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala @@ -17,13 +17,14 @@ package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.ShortServiceRefundBandsName -case class ShortServiceRefundBands(name: String, - rate: BigDecimal, - bandLimit: BigInt, - apportionedBandLimit: BigInt, - shortServiceRefundAmount: BigDecimal, - shortServiceRefundCharge: BigDecimal) +case class ShortServiceRefundBands(name: ShortServiceRefundBandsName, + rate: BigDecimal, + bandLimit: BigInt, + apportionedBandLimit: BigInt, + shortServiceRefundAmount: BigDecimal, + shortServiceRefundCharge: BigDecimal) object ShortServiceRefundBands { implicit val format: OFormat[ShortServiceRefundBands] = Json.format[ShortServiceRefundBands] diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala index de5552f76..9590a1ef1 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala @@ -17,13 +17,14 @@ package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.ShortServiceRefundBandsName -case class ShortServiceRefundBands(name: String, - rate: BigDecimal, - bandLimit: BigInt, - apportionedBandLimit: BigInt, - shortServiceRefundAmount: BigDecimal, - shortServiceRefundCharge: BigDecimal) +case class ShortServiceRefundBands(name: ShortServiceRefundBandsName, + rate: BigDecimal, + bandLimit: BigInt, + apportionedBandLimit: BigInt, + shortServiceRefundAmount: BigDecimal, + shortServiceRefundCharge: BigDecimal) object ShortServiceRefundBands { implicit val format: OFormat[ShortServiceRefundBands] = Json.format[ShortServiceRefundBands] diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index 39dbd0ec8..2a51b03c9 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -219,7 +219,7 @@ "name": "VCT fund", "socialEnterpriseName": "SE Inc", "companyName": "Company Ltd.", - "deficiencyReliefType": "lifeInsurance", + "deficiencyReliefType": "life-insurance", "customerReference": "INPOLY123A" } ] @@ -369,7 +369,7 @@ "totalShortServiceRefundChargeDue": 5000.99, "shortServiceRefundBands": [ { - "name": "lowerBand", + "name": "lower-band", "rate": 20.99, "bandLimit": 12500, "apportionedBandLimit": 12500, @@ -677,7 +677,7 @@ "totalGainsWithTaxPaid": 12500, "gainsWithTaxPaidDetail": [ { - "type": "lifeInsurance", + "type": "life-insurance", "customerReference": "string", "gainAmount": 5000.99, "yearsHeld": 0, @@ -687,7 +687,7 @@ "totalGainsWithNoTaxPaidAndVoidedIsa": 12500, "gainsWithNoTaxPaidAndVoidedIsaDetail": [ { - "type": "lifeInsurance", + "type": "life-insurance", "customerReference": "INPOLY123B", "gainAmount": 5000.99, "yearsHeld": 0, diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index b11c0ba8a..9d66f1e43 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -215,7 +215,7 @@ "name": "VCT fund", "socialEnterpriseName": "SE Inc", "companyName": "Company Ltd.", - "deficiencyReliefType": "lifeInsurance", + "deficiencyReliefType": "life-insurance", "customerReference": "INPOLY123A" } ] @@ -345,7 +345,7 @@ "totalShortServiceRefundChargeDue": 5000.99, "shortServiceRefundBands": [ { - "name": "lowerBand", + "name": "lower-band", "rate": 20.99, "bandLimit": 12500, "apportionedBandLimit": 12500, @@ -653,7 +653,7 @@ "totalGainsWithTaxPaid": 12500, "gainsWithTaxPaidDetail": [ { - "type": "lifeInsurance", + "type": "life-insurance", "customerReference": "string", "gainAmount": 5000.99, "yearsHeld": 0, @@ -663,7 +663,7 @@ "totalGainsWithNoTaxPaidAndVoidedIsa": 12500, "gainsWithNoTaxPaidAndVoidedIsaDetail": [ { - "type": "lifeInsurance", + "type": "life-insurance", "customerReference": "INPOLY123B", "gainAmount": 5000.99, "yearsHeld": 0, diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/chargeableEventGainsIncome.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/chargeableEventGainsIncome.json index 8b53daf7e..ec9c18e35 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/chargeableEventGainsIncome.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/chargeableEventGainsIncome.json @@ -23,8 +23,8 @@ "description": "The type of gains with tax paid.", "type": "string", "enum": [ - "lifeInsurance", - "capitalRedemption", + "life-insurance", + "capital-redemption", "lifeAnnuity" ] }, @@ -71,8 +71,8 @@ "description": "The type of gains with no tax paid and voided ISA.", "type": "string", "enum": [ - "lifeInsurance", - "capitalRedemption", + "life-insurance", + "capital-redemption", "lifeAnnuity", "voidedIsa" ] diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/pensionSavingsTaxCharges.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/pensionSavingsTaxCharges.json index 976e2f811..3e29fb85e 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/pensionSavingsTaxCharges.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/pensionSavingsTaxCharges.json @@ -440,8 +440,8 @@ "description": "The name of the tax band.", "type": "string", "enum": [ - "lowerBand", - "upperBand" + "lower-band", + "upper-band" ] }, "rate": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/reliefs.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/reliefs.json index 70763ea97..f1614df7e 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/reliefs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/reliefs.json @@ -239,9 +239,9 @@ "description": "The type of relief. Populated only for deficiency relief.", "type": "string", "enum": [ - "lifeInsurance", + "life-insurance", "lifeAnnuity", - "capitalRedemption" + "capital-redemption" ] }, "customerReference": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/common_defs.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/common_defs.json index 94fc9f914..622a204c3 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/common_defs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/common_defs.json @@ -6,7 +6,7 @@ "type": "string", "enum": [ "customer", - "HMRC HELD" + "hmrc-held" ] }, "businessIncomeSourceType": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/chargeableEventGainsIncome.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/chargeableEventGainsIncome.json index 8b53daf7e..ec9c18e35 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/chargeableEventGainsIncome.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/chargeableEventGainsIncome.json @@ -23,8 +23,8 @@ "description": "The type of gains with tax paid.", "type": "string", "enum": [ - "lifeInsurance", - "capitalRedemption", + "life-insurance", + "capital-redemption", "lifeAnnuity" ] }, @@ -71,8 +71,8 @@ "description": "The type of gains with no tax paid and voided ISA.", "type": "string", "enum": [ - "lifeInsurance", - "capitalRedemption", + "life-insurance", + "capital-redemption", "lifeAnnuity", "voidedIsa" ] diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/pensionSavingsTaxCharges.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/pensionSavingsTaxCharges.json index 777aeff45..96b151df3 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/pensionSavingsTaxCharges.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/pensionSavingsTaxCharges.json @@ -341,8 +341,8 @@ "description": "The name of the tax band.", "type": "string", "enum": [ - "lowerBand", - "upperBand" + "lower-band", + "upper-band" ] }, "rate": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/reliefs.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/reliefs.json index dabbf2e71..32f555564 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/reliefs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/reliefs.json @@ -239,9 +239,9 @@ "description": "The type of relief. Populated only for deficiency relief.", "type": "string", "enum": [ - "lifeInsurance", + "life-insurance", "lifeAnnuity", - "capitalRedemption" + "capital-redemption" ] }, "customerReference": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/common_defs.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/common_defs.json index 94fc9f914..622a204c3 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/common_defs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/common_defs.json @@ -6,7 +6,7 @@ "type": "string", "enum": [ "customer", - "HMRC HELD" + "hmrc-held" ] }, "businessIncomeSourceType": { diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index c5b1d509b..4c2955d67 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -200,7 +200,7 @@ }, "reliefsClaimed": [ { - "type": "vctSubscriptions", + "type": "vct-subscriptions", "amountClaimed": 5000.99, "allowableAmount": 5000.99, "amountUsed": 5000.99, @@ -349,7 +349,7 @@ "totalShortServiceRefundChargeDue": 5000.99, "shortServiceRefundBands": [ { - "name": "lowerBand", + "name": "lower-band", "rate": 20.01, "bandLimit": 12500, "apportionedBandLimit": 12500, diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index 9fdf872a5..f03d5dbb1 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -200,7 +200,7 @@ }, "reliefsClaimed": [ { - "type": "vctSubscriptions", + "type": "vct-subscriptions", "amountClaimed": 5000.99, "allowableAmount": 5000.99, "amountUsed": 5000.99, @@ -333,7 +333,7 @@ "totalShortServiceRefundChargeDue": 5000.99, "shortServiceRefundBands": [ { - "name": "lowerBand", + "name": "lower-band", "rate": 20.01, "bandLimit": 12500, "apportionedBandLimit": 12500, diff --git a/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala b/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala index 56c66c203..386cb0ffd 100644 --- a/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala +++ b/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala @@ -23,27 +23,27 @@ import v7.common.model.response.ReliefsClaimedType._ class ReliefsClaimedTypeSpec extends UnitSpec with EnumJsonSpecSupport { testReads[ReliefsClaimedType]( - "vctSubscriptions" -> vctSubscriptions, - "eisSubscriptions" -> eisSubscriptions, - "communityInvestment" -> communityInvestment, - "seedEnterpriseInvestment" -> seedEnterpriseInvestment, - "socialEnterpriseInvestment" -> socialEnterpriseInvestment, - "maintenancePayments" -> maintenancePayments, - "deficiencyRelief" -> deficiencyRelief, - "nonDeductableLoanInterest" -> nonDeductibleLoanInterest, - "qualifyingDistributionRedemptionOfSharesAndSecurities" -> qualifyingDistributionRedemptionOfSharesAndSecurities + "vctSubscriptions" -> `vct-subscriptions`, + "eisSubscriptions" -> `eis-subscriptions`, + "communityInvestment" -> `community-investment`, + "seedEnterpriseInvestment" -> `seed-enterprise-investment`, + "socialEnterpriseInvestment" -> `social-enterprise-investment`, + "maintenancePayments" -> `maintenance-payments`, + "deficiencyRelief" -> `deficiency-relief`, + "nonDeductableLoanInterest" -> `non-deductible-loan-interest`, + "qualifyingDistributionRedemptionOfSharesAndSecurities" -> `qualifying-distribution-redemption-of-shares-and-securities` ) testWrites[ReliefsClaimedType]( - vctSubscriptions -> "vctSubscriptions", - eisSubscriptions -> "eisSubscriptions", - communityInvestment -> "communityInvestment", - seedEnterpriseInvestment -> "seedEnterpriseInvestment", - socialEnterpriseInvestment -> "socialEnterpriseInvestment", - maintenancePayments -> "maintenancePayments", - deficiencyRelief -> "deficiencyRelief", - nonDeductibleLoanInterest -> "nonDeductibleLoanInterest", - qualifyingDistributionRedemptionOfSharesAndSecurities -> "qualifyingDistributionRedemptionOfSharesAndSecurities" + `vct-subscriptions` -> "vct-subscriptions", + `eis-subscriptions` -> "eis-subscriptions", + `community-investment` -> "community-investment", + `seed-enterprise-investment` -> "seed-enterprise-investment", + `social-enterprise-investment` -> "social-enterprise-investment", + `maintenance-payments` -> "maintenance-payments", + `deficiency-relief` -> "deficiency-relief", + `non-deductible-loan-interest` -> "non-deductible-loan-interest", + `qualifying-distribution-redemption-of-shares-and-securities` -> "qualifying-distribution-redemption-of-shares-and-securities" ) } From d85157441282fa2374b455f2a9765d338fe79450 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:52:40 +0100 Subject: [PATCH 08/32] [MTDSA-23287] Update lossType enums for consistency --- app/v7/common/model/response/LossType.scala | 35 ++++++++++++++++ .../lossesAndClaims/CarriedForwardLoss.scala | 4 +- .../ResultOfClaimsApplied.scala | 4 +- .../lossesAndClaims/UnclaimedLoss.scala | 4 +- .../lossesAndClaims/CarriedForwardLoss.scala | 4 +- .../ResultOfClaimsApplied.scala | 4 +- .../lossesAndClaims/UnclaimedLoss.scala | 4 +- .../CarriedForwardLossSpec.scala | 40 +++++++++---------- .../ResultOfClaimsAppliedSpec.scala | 40 +++++++++---------- .../lossesAndClaims/UnclaimedLossSpec.scala | 38 +++++++++--------- .../CarriedForwardLossSpec.scala | 40 +++++++++---------- .../ResultOfClaimsAppliedSpec.scala | 40 +++++++++---------- .../lossesAndClaims/UnclaimedLossSpec.scala | 38 +++++++++--------- 13 files changed, 165 insertions(+), 130 deletions(-) create mode 100644 app/v7/common/model/response/LossType.scala diff --git a/app/v7/common/model/response/LossType.scala b/app/v7/common/model/response/LossType.scala new file mode 100644 index 000000000..07ba5b01a --- /dev/null +++ b/app/v7/common/model/response/LossType.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait LossType + +object LossType { + case object `income` extends LossType + case object `class4-nics` extends LossType + + implicit val writes: Writes[LossType] = Enums.writes[LossType] + + implicit val reads: Reads[LossType] = Enums.readsUsing { + case "income" => `income` + case "class4nics" => `class4-nics` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala index 37ff13838..3efbbb541 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} case class CarriedForwardLoss( claimId: Option[String], @@ -30,7 +30,7 @@ case class CarriedForwardLoss( taxYearClaimMade: Option[TaxYear], taxYearLossIncurred: TaxYear, currentLossValue: BigInt, - lossType: Option[String] + lossType: LossType ) object CarriedForwardLoss { diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala index dc1f33777..ba73a191f 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} case class ResultOfClaimsApplied( claimId: Option[String], @@ -32,7 +32,7 @@ case class ResultOfClaimsApplied( taxYearLossIncurred: TaxYear, lossAmountUsed: BigInt, remainingLossValue: BigInt, - lossType: Option[String] + lossType: LossType ) object ResultOfClaimsApplied { diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala index 5e2decc15..612409247 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala @@ -19,14 +19,14 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.IncomeSourceType +import v7.common.model.response.{IncomeSourceType, LossType} case class UnclaimedLoss( incomeSourceId: Option[String], incomeSourceType: IncomeSourceType, taxYearLossIncurred: TaxYear, currentLossValue: BigInt, - lossType: Option[String] + lossType: LossType ) object UnclaimedLoss { diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala index 698531348..362ea2d3f 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} case class CarriedForwardLoss( claimId: Option[String], @@ -30,7 +30,7 @@ case class CarriedForwardLoss( taxYearClaimMade: Option[TaxYear], taxYearLossIncurred: TaxYear, currentLossValue: BigInt, - lossType: Option[String] + lossType: LossType ) object CarriedForwardLoss { diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala index e9774c4b8..bcd57e2f5 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} case class ResultOfClaimsApplied( claimId: Option[String], @@ -32,7 +32,7 @@ case class ResultOfClaimsApplied( taxYearLossIncurred: TaxYear, lossAmountUsed: BigInt, remainingLossValue: BigInt, - lossType: Option[String] + lossType: LossType ) object ResultOfClaimsApplied { diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala index db3bc5ce0..b1fafa9ca 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala @@ -19,14 +19,14 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.IncomeSourceType +import v7.common.model.response.{IncomeSourceType, LossType} case class UnclaimedLoss( incomeSourceId: Option[String], incomeSourceType: IncomeSourceType, taxYearLossIncurred: TaxYear, currentLossValue: BigInt, - lossType: Option[String] + lossType: LossType ) object UnclaimedLoss { diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala index a0aa6a783..106788c6b 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala @@ -19,11 +19,11 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} class CarriedForwardLossSpec extends UnitSpec { - def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + def downstreamJson(incomeSourceType: String, claimType: String, lossType: String): JsValue = Json.parse(s""" |{ | "claimId": "123456789012345", | "originatingClaimId": "123456789012346", @@ -33,11 +33,11 @@ class CarriedForwardLossSpec extends UnitSpec { | "taxYearClaimMade": 2020, | "taxYearLossIncurred": 2019, | "currentLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): CarriedForwardLoss = + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): CarriedForwardLoss = CarriedForwardLoss( claimId = Some("123456789012345"), originatingClaimId = Some("123456789012346"), @@ -47,10 +47,10 @@ class CarriedForwardLossSpec extends UnitSpec { taxYearClaimMade = Some(TaxYear.fromDownstream("2020")), taxYearLossIncurred = TaxYear.fromDownstream("2019"), currentLossValue = BigInt(456), - lossType = Some("income") + lossType = lossType ) - def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): JsValue = Json.parse(s""" |{ | "claimId": "123456789012345", | "originatingClaimId": "123456789012346", @@ -60,28 +60,28 @@ class CarriedForwardLossSpec extends UnitSpec { | "taxYearClaimMade": "2019-20", | "taxYearLossIncurred": "2018-19", | "currentLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType, lossType: LossType) val testData: Seq[Test] = Seq[Test]( - Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), - Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), - Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), - Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), - Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), - Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`, LossType.`class4-nics`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`, LossType.`class4-nics`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`, LossType.`class4-nics`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`, LossType.`class4-nics`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`, LossType.`class4-nics`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`, LossType.`class4-nics`) ) "reads" should { "successfully read in a model" when { - testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType, lossType) => s"provided downstream type of claim $downstreamClaimType" in { - downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[CarriedForwardLoss] shouldBe - model(incomeSourceType, claimType) + downstreamJson(downstreamIncomeSourceType, downstreamClaimType, lossType = "class4nics").as[CarriedForwardLoss] shouldBe + model(incomeSourceType, claimType, lossType) } } } @@ -90,10 +90,10 @@ class CarriedForwardLossSpec extends UnitSpec { "writes" should { "successfully write a model to json" when { - testData.foreach { case Test(_, incomeSourceType, _, claimType) => + testData.foreach { case Test(_, incomeSourceType, _, claimType, lossType) => s"provided type of claim $claimType" in { - Json.toJson(model(incomeSourceType, claimType)) shouldBe - mtdJson(incomeSourceType, claimType) + Json.toJson(model(incomeSourceType, claimType, lossType)) shouldBe + mtdJson(incomeSourceType, claimType, lossType) } } } diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala index eb09fbc14..2e68b198a 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala @@ -19,11 +19,11 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} class ResultOfClaimsAppliedSpec extends UnitSpec { - def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + def downstreamJson(incomeSourceType: String, claimType: String, lossType: String): JsValue = Json.parse(s""" |{ | "claimId": "123456789012345", | "originatingClaimId": "123456789012346", @@ -35,11 +35,11 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { | "taxYearLossIncurred": 2019, | "lossAmountUsed": 123, | "remainingLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): ResultOfClaimsApplied = + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): ResultOfClaimsApplied = ResultOfClaimsApplied( claimId = Some("123456789012345"), originatingClaimId = Some("123456789012346"), @@ -51,10 +51,10 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { taxYearLossIncurred = TaxYear.fromDownstream("2019"), lossAmountUsed = BigInt(123), remainingLossValue = BigInt(456), - lossType = Some("income") + lossType = lossType ) - def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): JsValue = Json.parse(s""" |{ | "claimId": "123456789012345", | "originatingClaimId": "123456789012346", @@ -66,28 +66,28 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { | "taxYearLossIncurred": "2018-19", | "lossAmountUsed": 123, | "remainingLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType, lossType: LossType) val testData: Seq[Test] = Seq[Test]( - Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), - Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), - Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), - Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), - Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), - Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`, LossType.`class4-nics`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`, LossType.`class4-nics`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`, LossType.`class4-nics`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`, LossType.`class4-nics`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`, LossType.`class4-nics`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`, LossType.`class4-nics`) ) "reads" should { "successfully read in a model" when { - testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType, lossType) => s"provided downstream type of claim $downstreamClaimType" in { - downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[ResultOfClaimsApplied] shouldBe - model(incomeSourceType, claimType) + downstreamJson(downstreamIncomeSourceType, downstreamClaimType, lossType = "class4nics").as[ResultOfClaimsApplied] shouldBe + model(incomeSourceType, claimType, lossType) } } } @@ -96,10 +96,10 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { "writes" should { "successfully write a model to json" when { - testData.foreach { case Test(_, incomeSourceType, _, claimType) => + testData.foreach { case Test(_, incomeSourceType, _, claimType, lossType) => s"provided type of claim $claimType" in { - Json.toJson(model(incomeSourceType, claimType)) shouldBe - mtdJson(incomeSourceType, claimType) + Json.toJson(model(incomeSourceType, claimType, lossType)) shouldBe + mtdJson(incomeSourceType, claimType, lossType) } } } diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala index e05098dc1..4762e9b48 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala @@ -19,56 +19,56 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.IncomeSourceType +import v7.common.model.response.{IncomeSourceType, LossType} class UnclaimedLossSpec extends UnitSpec { - def downstreamJson(incomeSourceType: String): JsValue = Json.parse(s""" + def downstreamJson(incomeSourceType: String, lossType: String): JsValue = Json.parse(s""" |{ | "incomeSourceId": "123456789012345", | "incomeSourceType": "$incomeSourceType", | "taxYearLossIncurred": 2020, | "currentLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - def model(incomeSourceType: IncomeSourceType): UnclaimedLoss = + def model(incomeSourceType: IncomeSourceType, lossType: LossType): UnclaimedLoss = UnclaimedLoss( incomeSourceId = Some("123456789012345"), incomeSourceType = incomeSourceType, taxYearLossIncurred = TaxYear.fromDownstream("2020"), currentLossValue = BigInt(456), - lossType = Some("income") + lossType = lossType ) - def mtdJson(incomeSourceType: IncomeSourceType): JsValue = Json.parse(s""" + def mtdJson(incomeSourceType: IncomeSourceType, lossType: LossType): JsValue = Json.parse(s""" |{ | "incomeSourceId": "123456789012345", | "incomeSourceType": "$incomeSourceType", | "taxYearLossIncurred": "2019-20", | "currentLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType) + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, lossType: LossType) val testData: Seq[Test] = Seq[Test]( - Test("01", IncomeSourceType.`self-employment`), - Test("02", IncomeSourceType.`uk-property-non-fhl`), - Test("03", IncomeSourceType.`foreign-property-fhl-eea`), - Test("04", IncomeSourceType.`uk-property-fhl`), - Test("15", IncomeSourceType.`foreign-property`) + Test("01", IncomeSourceType.`self-employment`, LossType.`class4-nics`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, LossType.`class4-nics`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, LossType.`class4-nics`), + Test("04", IncomeSourceType.`uk-property-fhl`, LossType.`class4-nics`), + Test("15", IncomeSourceType.`foreign-property`, LossType.`class4-nics`) ) "reads" should { "successfully read in a model" when { - testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType) => + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, lossType) => s"provided downstream income source type $downstreamIncomeSourceType" in { - downstreamJson(downstreamIncomeSourceType).as[UnclaimedLoss] shouldBe - model(incomeSourceType) + downstreamJson(downstreamIncomeSourceType, lossType = "class4nics").as[UnclaimedLoss] shouldBe + model(incomeSourceType, lossType) } } } @@ -77,10 +77,10 @@ class UnclaimedLossSpec extends UnitSpec { "writes" should { "successfully write a model to json" when { - testData.foreach { case Test(_, incomeSourceType) => + testData.foreach { case Test(_, incomeSourceType, lossType) => s"provided income source type $incomeSourceType" in { - Json.toJson(model(incomeSourceType)) shouldBe - mtdJson(incomeSourceType) + Json.toJson(model(incomeSourceType, lossType)) shouldBe + mtdJson(incomeSourceType, lossType) } } } diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala index 7baeea681..1c19798b7 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala @@ -19,11 +19,11 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} class CarriedForwardLossSpec extends UnitSpec { - def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + def downstreamJson(incomeSourceType: String, claimType: String, lossType: String): JsValue = Json.parse(s""" |{ | "claimId": "123456789012345", | "originatingClaimId": "123456789012346", @@ -33,11 +33,11 @@ class CarriedForwardLossSpec extends UnitSpec { | "taxYearClaimMade": 2020, | "taxYearLossIncurred": 2019, | "currentLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): CarriedForwardLoss = + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): CarriedForwardLoss = CarriedForwardLoss( claimId = Some("123456789012345"), originatingClaimId = Some("123456789012346"), @@ -47,10 +47,10 @@ class CarriedForwardLossSpec extends UnitSpec { taxYearClaimMade = Some(TaxYear.fromDownstream("2020")), taxYearLossIncurred = TaxYear.fromDownstream("2019"), currentLossValue = BigInt(456), - lossType = Some("income") + lossType = lossType ) - def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): JsValue = Json.parse(s""" |{ | "claimId": "123456789012345", | "originatingClaimId": "123456789012346", @@ -60,28 +60,28 @@ class CarriedForwardLossSpec extends UnitSpec { | "taxYearClaimMade": "2019-20", | "taxYearLossIncurred": "2018-19", | "currentLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType, lossType: LossType) val testData: Seq[Test] = Seq[Test]( - Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), - Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), - Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), - Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), - Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), - Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`, LossType.`class4-nics`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`, LossType.`class4-nics`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`, LossType.`class4-nics`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`, LossType.`class4-nics`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`, LossType.`class4-nics`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`, LossType.`class4-nics`) ) "reads" should { "successfully read in a model" when { - testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType, lossType) => s"provided downstream type of claim $downstreamClaimType" in { - downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[CarriedForwardLoss] shouldBe - model(incomeSourceType, claimType) + downstreamJson(downstreamIncomeSourceType, downstreamClaimType, lossType = "class4nics").as[CarriedForwardLoss] shouldBe + model(incomeSourceType, claimType, lossType) } } } @@ -90,10 +90,10 @@ class CarriedForwardLossSpec extends UnitSpec { "writes" should { "successfully write a model to json" when { - testData.foreach { case Test(_, incomeSourceType, _, claimType) => + testData.foreach { case Test(_, incomeSourceType, _, claimType, lossType) => s"provided type of claim $claimType" in { - Json.toJson(model(incomeSourceType, claimType)) shouldBe - mtdJson(incomeSourceType, claimType) + Json.toJson(model(incomeSourceType, claimType, lossType)) shouldBe + mtdJson(incomeSourceType, claimType, lossType) } } } diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala index 1f9173ce7..6c9d6465f 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala @@ -19,11 +19,11 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{ClaimType, IncomeSourceType} +import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} class ResultOfClaimsAppliedSpec extends UnitSpec { - def downstreamJson(incomeSourceType: String, claimType: String): JsValue = Json.parse(s""" + def downstreamJson(incomeSourceType: String, claimType: String, lossType: String): JsValue = Json.parse(s""" |{ | "claimId": "123456789012345", | "originatingClaimId": "123456789012346", @@ -35,11 +35,11 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { | "taxYearLossIncurred": 2019, | "lossAmountUsed": 123, | "remainingLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - def model(incomeSourceType: IncomeSourceType, claimType: ClaimType): ResultOfClaimsApplied = + def model(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): ResultOfClaimsApplied = ResultOfClaimsApplied( claimId = Some("123456789012345"), originatingClaimId = Some("123456789012346"), @@ -51,10 +51,10 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { taxYearLossIncurred = TaxYear.fromDownstream("2019"), lossAmountUsed = BigInt(123), remainingLossValue = BigInt(456), - lossType = Some("income") + lossType = lossType ) - def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType): JsValue = Json.parse(s""" + def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): JsValue = Json.parse(s""" |{ | "claimId": "123456789012345", | "originatingClaimId": "123456789012346", @@ -66,28 +66,28 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { | "taxYearLossIncurred": "2018-19", | "lossAmountUsed": 123, | "remainingLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType) + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, downstreamClaimType: String, claimType: ClaimType, lossType: LossType) val testData: Seq[Test] = Seq[Test]( - Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`), - Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`), - Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`), - Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`), - Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`), - Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`) + Test("01", IncomeSourceType.`self-employment`, "CF", ClaimType.`carry-forward`, LossType.`class4-nics`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, "CSGI", ClaimType.`carry-sideways`, LossType.`class4-nics`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, "CFCSGI", ClaimType.`carry-forward-to-carry-sideways`, LossType.`class4-nics`), + Test("04", IncomeSourceType.`uk-property-fhl`, "CSFHL", ClaimType.`carry-sideways-fhl`, LossType.`class4-nics`), + Test("15", IncomeSourceType.`foreign-property`, "CB", ClaimType.`carry-backwards`, LossType.`class4-nics`), + Test("01", IncomeSourceType.`self-employment`, "CBGI", ClaimType.`carry-backwards-general-income`, LossType.`class4-nics`) ) "reads" should { "successfully read in a model" when { - testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType) => + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, downstreamClaimType, claimType, lossType) => s"provided downstream type of claim $downstreamClaimType" in { - downstreamJson(downstreamIncomeSourceType, downstreamClaimType).as[ResultOfClaimsApplied] shouldBe - model(incomeSourceType, claimType) + downstreamJson(downstreamIncomeSourceType, downstreamClaimType, lossType = "class4nics").as[ResultOfClaimsApplied] shouldBe + model(incomeSourceType, claimType, lossType) } } } @@ -96,10 +96,10 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { "writes" should { "successfully write a model to json" when { - testData.foreach { case Test(_, incomeSourceType, _, claimType) => + testData.foreach { case Test(_, incomeSourceType, _, claimType, lossType) => s"provided type of claim $claimType" in { - Json.toJson(model(incomeSourceType, claimType)) shouldBe - mtdJson(incomeSourceType, claimType) + Json.toJson(model(incomeSourceType, claimType, lossType)) shouldBe + mtdJson(incomeSourceType, claimType, lossType) } } } diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala index 08af2cf6c..72847a340 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala @@ -19,56 +19,56 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.IncomeSourceType +import v7.common.model.response.{IncomeSourceType, LossType} class UnclaimedLossSpec extends UnitSpec { - def downstreamJson(incomeSourceType: String): JsValue = Json.parse(s""" + def downstreamJson(incomeSourceType: String, lossType: String): JsValue = Json.parse(s""" |{ | "incomeSourceId": "123456789012345", | "incomeSourceType": "$incomeSourceType", | "taxYearLossIncurred": 2020, | "currentLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - def model(incomeSourceType: IncomeSourceType): UnclaimedLoss = + def model(incomeSourceType: IncomeSourceType, lossType: LossType): UnclaimedLoss = UnclaimedLoss( incomeSourceId = Some("123456789012345"), incomeSourceType = incomeSourceType, taxYearLossIncurred = TaxYear.fromDownstream("2020"), currentLossValue = BigInt(456), - lossType = Some("income") + lossType = lossType ) - def mtdJson(incomeSourceType: IncomeSourceType): JsValue = Json.parse(s""" + def mtdJson(incomeSourceType: IncomeSourceType, lossType: LossType): JsValue = Json.parse(s""" |{ | "incomeSourceId": "123456789012345", | "incomeSourceType": "$incomeSourceType", | "taxYearLossIncurred": "2019-20", | "currentLossValue": 456, - | "lossType": "income" + | "lossType": "$lossType" |} |""".stripMargin) - case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType) + case class Test(downstreamIncomeSourceType: String, incomeSourceType: IncomeSourceType, lossType: LossType) val testData: Seq[Test] = Seq[Test]( - Test("01", IncomeSourceType.`self-employment`), - Test("02", IncomeSourceType.`uk-property-non-fhl`), - Test("03", IncomeSourceType.`foreign-property-fhl-eea`), - Test("04", IncomeSourceType.`uk-property-fhl`), - Test("15", IncomeSourceType.`foreign-property`) + Test("01", IncomeSourceType.`self-employment`, LossType.`class4-nics`), + Test("02", IncomeSourceType.`uk-property-non-fhl`, LossType.`class4-nics`), + Test("03", IncomeSourceType.`foreign-property-fhl-eea`, LossType.`class4-nics`), + Test("04", IncomeSourceType.`uk-property-fhl`, LossType.`class4-nics`), + Test("15", IncomeSourceType.`foreign-property`, LossType.`class4-nics`) ) "reads" should { "successfully read in a model" when { - testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType) => + testData.foreach { case Test(downstreamIncomeSourceType, incomeSourceType, lossType) => s"provided downstream income source type $downstreamIncomeSourceType" in { - downstreamJson(downstreamIncomeSourceType).as[UnclaimedLoss] shouldBe - model(incomeSourceType) + downstreamJson(downstreamIncomeSourceType, lossType = "class4nics").as[UnclaimedLoss] shouldBe + model(incomeSourceType, lossType) } } } @@ -77,10 +77,10 @@ class UnclaimedLossSpec extends UnitSpec { "writes" should { "successfully write a model to json" when { - testData.foreach { case Test(_, incomeSourceType) => + testData.foreach { case Test(_, incomeSourceType, lossType) => s"provided income source type $incomeSourceType" in { - Json.toJson(model(incomeSourceType)) shouldBe - mtdJson(incomeSourceType) + Json.toJson(model(incomeSourceType, lossType)) shouldBe + mtdJson(incomeSourceType, lossType) } } } From cacf091b91559e54ca53488c0c3fb04ebdcb03e6 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:21:59 +0100 Subject: [PATCH 09/32] [MTDSA-23287] Update TypeOfDividend enums for consistency --- app/v7/common/model/response/LossType.scala | 6 +-- .../model/response/TypeOfDividend.scala | 39 +++++++++++++++++++ .../dividendsIncome/OtherDividends.scala | 5 ++- .../dividendsIncome/OtherDividends.scala | 5 ++- .../response/calculation_downstream.json | 2 +- .../response/calculation_downstream.json | 2 +- .../dividendsIncome/DividendsIncomeSpec.scala | 6 +-- .../dividendsIncome/DividendsIncomeSpec.scala | 6 +-- 8 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 app/v7/common/model/response/TypeOfDividend.scala diff --git a/app/v7/common/model/response/LossType.scala b/app/v7/common/model/response/LossType.scala index 07ba5b01a..feb57ddd8 100644 --- a/app/v7/common/model/response/LossType.scala +++ b/app/v7/common/model/response/LossType.scala @@ -22,14 +22,14 @@ import play.api.libs.json.{Reads, Writes} sealed trait LossType object LossType { - case object `income` extends LossType + case object `income` extends LossType case object `class4-nics` extends LossType implicit val writes: Writes[LossType] = Enums.writes[LossType] implicit val reads: Reads[LossType] = Enums.readsUsing { - case "income" => `income` - case "class4nics" => `class4-nics` + case "income" => `income` + case "class4nics" => `class4-nics` } } diff --git a/app/v7/common/model/response/TypeOfDividend.scala b/app/v7/common/model/response/TypeOfDividend.scala new file mode 100644 index 000000000..ac51fc4c7 --- /dev/null +++ b/app/v7/common/model/response/TypeOfDividend.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait TypeOfDividend + +object TypeOfDividend { + case object `stock-dividend` extends TypeOfDividend + case object `redeemable-shares` extends TypeOfDividend + case object `bonus-issues-of-securities` extends TypeOfDividend + case object `close-company-loans-written-off` extends TypeOfDividend + + implicit val writes: Writes[TypeOfDividend] = Enums.writes[TypeOfDividend] + + implicit val reads: Reads[TypeOfDividend] = Enums.readsUsing { + case "stockDividend" => `stock-dividend` + case "redeemableShares" => `redeemable-shares` + case "bonusIssuesOfSecurities" => `bonus-issues-of-securities` + case "closeCompanyLoansWrittenOff" => `close-company-loans-written-off` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala index afba74200..57d991341 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala @@ -17,8 +17,11 @@ package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome import play.api.libs.json.{Format, Json} +import v7.common.model.response.TypeOfDividend -case class OtherDividends(typeOfDividend: Option[String], customerReference: Option[String], grossAmount: Option[BigDecimal]) +case class OtherDividends(typeOfDividend: TypeOfDividend, + customerReference: Option[String], + grossAmount: Option[BigDecimal]) object OtherDividends { implicit val format: Format[OtherDividends] = Json.format[OtherDividends] diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala index bdf33da22..89c118c74 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala @@ -17,8 +17,11 @@ package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome import play.api.libs.json.{Format, Json} +import v7.common.model.response.TypeOfDividend -case class OtherDividends(typeOfDividend: Option[String], customerReference: Option[String], grossAmount: Option[BigDecimal]) +case class OtherDividends(typeOfDividend: TypeOfDividend, + customerReference: Option[String], + grossAmount: Option[BigDecimal]) object OtherDividends { implicit val format: Format[OtherDividends] = Json.format[OtherDividends] diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json index 2c0d6e342..57b9f8fc5 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_downstream.json @@ -730,7 +730,7 @@ }, "otherDividends": [ { - "typeOfDividend": "stock-dividend", + "typeOfDividend": "stockDividend", "customerReference": "string", "grossAmount": 5000.99 } diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json index 831cf9bd0..b7f1d20ae 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_downstream.json @@ -714,7 +714,7 @@ }, "otherDividends": [ { - "typeOfDividend": "stock-dividend", + "typeOfDividend": "stockDividend", "customerReference": "string", "grossAmount": 5000.99 } diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala index 6a94e0d94..2dd676b9b 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome import play.api.libs.json.{JsValue, Json} import shared.models.utils.JsonErrorValidators import shared.utils.UnitSpec -import v7.common.model.response.IncomeSourceType +import v7.common.model.response.{IncomeSourceType, TypeOfDividend} class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { @@ -31,7 +31,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { ) val otherModel: OtherDividends = OtherDividends( - Some("stock-dividend"), + TypeOfDividend.`stock-dividend`, Some("string"), Some(5000.99) ) @@ -68,7 +68,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { | }, | "otherDividends":[ | { - | "typeOfDividend":"stock-dividend", + | "typeOfDividend":"stockDividend", | "customerReference":"string", | "grossAmount":5000.99 | } diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala index 17d9e1699..d6d55c937 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome import play.api.libs.json.{JsValue, Json} import shared.models.utils.JsonErrorValidators import shared.utils.UnitSpec -import v7.common.model.response.IncomeSourceType +import v7.common.model.response.{IncomeSourceType, TypeOfDividend} class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { @@ -31,7 +31,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { ) val otherModel: OtherDividends = OtherDividends( - Some("stock-dividend"), + TypeOfDividend.`stock-dividend`, Some("string"), Some(5000.99) ) @@ -68,7 +68,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { | }, | "otherDividends":[ | { - | "typeOfDividend":"stock-dividend", + | "typeOfDividend":"stockDividend", | "customerReference":"string", | "grossAmount":5000.99 | } From 72cbba246b65e5b55d50ca2d41db72829f38a919 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Wed, 25 Sep 2024 17:53:52 +0100 Subject: [PATCH 10/32] [MTDSA-23287] Update chargeableEventGainsIncome enums --- .../ChargeableEventGainsIncomeType.scala | 39 +++++++++++++++++++ ...GainsWithNoTaxPaidAndVoidedIsaDetail.scala | 13 ++++--- .../GainsWithTaxPaidDetail.scala | 11 +++--- ...GainsWithNoTaxPaidAndVoidedIsaDetail.scala | 13 ++++--- .../GainsWithTaxPaidDetail.scala | 11 +++--- .../def1/model/response/calculation_mtd.json | 4 +- .../def2/model/response/calculation_mtd.json | 4 +- 7 files changed, 69 insertions(+), 26 deletions(-) create mode 100644 app/v7/common/model/response/ChargeableEventGainsIncomeType.scala diff --git a/app/v7/common/model/response/ChargeableEventGainsIncomeType.scala b/app/v7/common/model/response/ChargeableEventGainsIncomeType.scala new file mode 100644 index 000000000..2fd945717 --- /dev/null +++ b/app/v7/common/model/response/ChargeableEventGainsIncomeType.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait ChargeableEventGainsIncomeType + +object ChargeableEventGainsIncomeType { + case object `life-insurance` extends ChargeableEventGainsIncomeType + case object `capital-redemption` extends ChargeableEventGainsIncomeType + case object `life-annuity` extends ChargeableEventGainsIncomeType + case object `voided-isa` extends ChargeableEventGainsIncomeType + + implicit val writes: Writes[ChargeableEventGainsIncomeType] = Enums.writes[ChargeableEventGainsIncomeType] + + implicit val reads: Reads[ChargeableEventGainsIncomeType] = Enums.readsUsing { + case "lifeInsurance" => `life-insurance` + case "capitalRedemption" => `capital-redemption` + case "lifeAnnuity" => `life-annuity` + case "voidedIsa" => `voided-isa` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala index 79270fbed..8c4b712f9 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala @@ -17,13 +17,14 @@ package v7.retrieveCalculation.def1.model.response.calculation.chargeableEventGainsIncome import play.api.libs.json.{Format, Json} +import v7.common.model.response.ChargeableEventGainsIncomeType -case class GainsWithNoTaxPaidAndVoidedIsaDetail(`type`: String, - customerReference: Option[String], - gainAmount: Option[BigDecimal], - yearsHeld: Option[BigInt], - yearsHeldSinceLastGain: Option[BigInt], - voidedIsaTaxPaid: Option[BigDecimal]) +case class GainsWithNoTaxPaidAndVoidedIsaDetail(`type`: ChargeableEventGainsIncomeType, + customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt], + yearsHeldSinceLastGain: Option[BigInt], + voidedIsaTaxPaid: Option[BigDecimal]) object GainsWithNoTaxPaidAndVoidedIsaDetail { implicit val format: Format[GainsWithNoTaxPaidAndVoidedIsaDetail] = Json.format[GainsWithNoTaxPaidAndVoidedIsaDetail] diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala index 1b623a150..31dbed552 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala @@ -17,12 +17,13 @@ package v7.retrieveCalculation.def1.model.response.calculation.chargeableEventGainsIncome import play.api.libs.json.{Format, Json} +import v7.common.model.response.ChargeableEventGainsIncomeType -case class GainsWithTaxPaidDetail(`type`: String, - customerReference: Option[String], - gainAmount: Option[BigDecimal], - yearsHeld: Option[BigInt], - yearsHeldSinceLastGain: Option[BigInt]) +case class GainsWithTaxPaidDetail(`type`: ChargeableEventGainsIncomeType, + customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt], + yearsHeldSinceLastGain: Option[BigInt]) object GainsWithTaxPaidDetail { implicit val format: Format[GainsWithTaxPaidDetail] = Json.format[GainsWithTaxPaidDetail] diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala index d835bee23..97164dfbc 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithNoTaxPaidAndVoidedIsaDetail.scala @@ -17,13 +17,14 @@ package v7.retrieveCalculation.def2.model.response.calculation.chargeableEventGainsIncome import play.api.libs.json.{Format, Json} +import v7.common.model.response.ChargeableEventGainsIncomeType -case class GainsWithNoTaxPaidAndVoidedIsaDetail(`type`: String, - customerReference: Option[String], - gainAmount: Option[BigDecimal], - yearsHeld: Option[BigInt], - yearsHeldSinceLastGain: Option[BigInt], - voidedIsaTaxPaid: Option[BigDecimal]) +case class GainsWithNoTaxPaidAndVoidedIsaDetail(`type`: ChargeableEventGainsIncomeType, + customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt], + yearsHeldSinceLastGain: Option[BigInt], + voidedIsaTaxPaid: Option[BigDecimal]) object GainsWithNoTaxPaidAndVoidedIsaDetail { implicit val format: Format[GainsWithNoTaxPaidAndVoidedIsaDetail] = Json.format[GainsWithNoTaxPaidAndVoidedIsaDetail] diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala index c273817d8..4ee17aa18 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/chargeableEventGainsIncome/GainsWithTaxPaidDetail.scala @@ -17,12 +17,13 @@ package v7.retrieveCalculation.def2.model.response.calculation.chargeableEventGainsIncome import play.api.libs.json.{Format, Json} +import v7.common.model.response.ChargeableEventGainsIncomeType -case class GainsWithTaxPaidDetail(`type`: String, - customerReference: Option[String], - gainAmount: Option[BigDecimal], - yearsHeld: Option[BigInt], - yearsHeldSinceLastGain: Option[BigInt]) +case class GainsWithTaxPaidDetail(`type`: ChargeableEventGainsIncomeType, + customerReference: Option[String], + gainAmount: Option[BigDecimal], + yearsHeld: Option[BigInt], + yearsHeldSinceLastGain: Option[BigInt]) object GainsWithTaxPaidDetail { implicit val format: Format[GainsWithTaxPaidDetail] = Json.format[GainsWithTaxPaidDetail] diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index 4c2955d67..5d67b40eb 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -657,7 +657,7 @@ "totalGainsWithTaxPaid": 12500, "gainsWithTaxPaidDetail": [ { - "type": "lifeInsurance", + "type": "life-insurance", "customerReference": "string", "gainAmount": 5000.99, "yearsHeld": 0, @@ -667,7 +667,7 @@ "totalGainsWithNoTaxPaidAndVoidedIsa": 12500, "gainsWithNoTaxPaidAndVoidedIsaDetail": [ { - "type": "lifeInsurance", + "type": "life-insurance", "customerReference": "string", "gainAmount": 5000.99, "yearsHeld": 0, diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index f03d5dbb1..ceeabe929 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -641,7 +641,7 @@ "totalGainsWithTaxPaid": 12500, "gainsWithTaxPaidDetail": [ { - "type": "lifeInsurance", + "type": "life-insurance", "customerReference": "string", "gainAmount": 5000.99, "yearsHeld": 0, @@ -651,7 +651,7 @@ "totalGainsWithNoTaxPaidAndVoidedIsa": 12500, "gainsWithNoTaxPaidAndVoidedIsaDetail": [ { - "type": "lifeInsurance", + "type": "life-insurance", "customerReference": "string", "gainAmount": 5000.99, "yearsHeld": 0, From add7253fc4f4c5f1ae93c9e1cc1896519ef7b67f Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:06:06 +0100 Subject: [PATCH 11/32] [MTDSA-23287] Update deficiencyReliefType enums --- .../calculation/reliefs/ReliefsClaimedDetail.scala | 13 +++++++------ .../calculation/reliefs/ReliefsClaimedDetail.scala | 13 +++++++------ .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala index 6d7017737..26a8b607f 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala @@ -17,14 +17,15 @@ package v7.retrieveCalculation.def1.model.response.calculation.reliefs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.ChargeableEventGainsIncomeType case class ReliefsClaimedDetail(amountClaimed: Option[BigDecimal], - uniqueInvestmentRef: Option[String], - name: Option[String], - socialEnterpriseName: Option[String], - companyName: Option[String], - deficiencyReliefType: Option[String], - customerReference: Option[String]) + uniqueInvestmentRef: Option[String], + name: Option[String], + socialEnterpriseName: Option[String], + companyName: Option[String], + deficiencyReliefType: ChargeableEventGainsIncomeType, + customerReference: Option[String]) object ReliefsClaimedDetail { implicit val format: OFormat[ReliefsClaimedDetail] = Json.format[ReliefsClaimedDetail] diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala index 2cb8b43ca..89856961f 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala @@ -17,14 +17,15 @@ package v7.retrieveCalculation.def2.model.response.calculation.reliefs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.ChargeableEventGainsIncomeType case class ReliefsClaimedDetail(amountClaimed: Option[BigDecimal], - uniqueInvestmentRef: Option[String], - name: Option[String], - socialEnterpriseName: Option[String], - companyName: Option[String], - deficiencyReliefType: Option[String], - customerReference: Option[String]) + uniqueInvestmentRef: Option[String], + name: Option[String], + socialEnterpriseName: Option[String], + companyName: Option[String], + deficiencyReliefType: ChargeableEventGainsIncomeType, + customerReference: Option[String]) object ReliefsClaimedDetail { implicit val format: OFormat[ReliefsClaimedDetail] = Json.format[ReliefsClaimedDetail] diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index 5d67b40eb..ff9a6cfa1 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -212,7 +212,7 @@ "name": "string", "socialEnterpriseName": "string", "companyName": "string", - "deficiencyReliefType": "lifeInsurance", + "deficiencyReliefType": "life-insurance", "customerReference": "string" } ] diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index ceeabe929..2698441a3 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -212,7 +212,7 @@ "name": "string", "socialEnterpriseName": "string", "companyName": "string", - "deficiencyReliefType": "lifeInsurance", + "deficiencyReliefType": "life-insurance", "customerReference": "string" } ] From ccc81cf7b0ed929de1dab9747753c949560ceb17 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:42:31 +0100 Subject: [PATCH 12/32] [MTDSA-23287] Update ShareSchemeDetail enums --- .../response/ShareSchemeDetailType.scala | 35 +++++++++++++++++++ .../ShareSchemeDetail.scala | 6 +++- .../ShareSchemeDetail.scala | 6 +++- .../retrieve/def1/retrieve_response.json | 2 +- .../retrieve/def2/retrieve_response.json | 2 +- .../def1/calculation/shareSchemesIncome.json | 4 +-- .../def2/calculation/shareSchemesIncome.json | 4 +-- .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- 9 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 app/v7/common/model/response/ShareSchemeDetailType.scala diff --git a/app/v7/common/model/response/ShareSchemeDetailType.scala b/app/v7/common/model/response/ShareSchemeDetailType.scala new file mode 100644 index 000000000..f2521e921 --- /dev/null +++ b/app/v7/common/model/response/ShareSchemeDetailType.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait ShareSchemeDetailType + +object ShareSchemeDetailType { + case object `share-option` extends ShareSchemeDetailType + case object `shares-awarded-or-received` extends ShareSchemeDetailType + + implicit val writes: Writes[ShareSchemeDetailType] = Enums.writes[ShareSchemeDetailType] + + implicit val reads: Reads[ShareSchemeDetailType] = Enums.readsUsing { + case "shareOption" => `share-option` + case "sharesAwardedOrReceived" => `shares-awarded-or-received` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala index 28f7aa175..8aa29b08e 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala @@ -17,8 +17,12 @@ package v7.retrieveCalculation.def1.model.response.calculation.shareSchemesIncome import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.ShareSchemeDetailType -case class ShareSchemeDetail(`type`: String, employerName: Option[String], employerRef: Option[String], taxableAmount: BigDecimal) +case class ShareSchemeDetail(`type`: ShareSchemeDetailType, + employerName: Option[String], + employerRef: Option[String], + taxableAmount: BigDecimal) object ShareSchemeDetail { implicit val format: OFormat[ShareSchemeDetail] = Json.format[ShareSchemeDetail] diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala index daed030d5..8f8c35c3f 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala @@ -17,8 +17,12 @@ package v7.retrieveCalculation.def2.model.response.calculation.shareSchemesIncome import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.ShareSchemeDetailType -case class ShareSchemeDetail(`type`: String, employerName: Option[String], employerRef: Option[String], taxableAmount: BigDecimal) +case class ShareSchemeDetail(`type`: ShareSchemeDetailType, + employerName: Option[String], + employerRef: Option[String], + taxableAmount: BigDecimal) object ShareSchemeDetail { implicit val format: OFormat[ShareSchemeDetail] = Json.format[ShareSchemeDetail] diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index 2a51b03c9..39b6bcca5 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -632,7 +632,7 @@ "totalIncome": 5000.99, "shareSchemeDetail": [ { - "type": "shareOption", + "type": "share-option", "employerName": "ABC-123 Ltd.", "employerRef": "123/AB56797", "taxableAmount": 5000.99 diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index 9d66f1e43..9bc93bbdb 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -608,7 +608,7 @@ "totalIncome": 5000.99, "shareSchemeDetail": [ { - "type": "shareOption", + "type": "share-option", "employerName": "ABC-123 Ltd.", "employerRef": "123/AB56797", "taxableAmount": 5000.99 diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/shareSchemesIncome.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/shareSchemesIncome.json index ea5dda791..3f56efadc 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/shareSchemesIncome.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/shareSchemesIncome.json @@ -21,8 +21,8 @@ "description": "The type of share scheme.", "type": "string", "enum": [ - "shareOption", - "sharesAwardedOrReceived" + "share-option", + "shares-awarded-or-received" ] }, "employerName": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/shareSchemesIncome.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/shareSchemesIncome.json index ea5dda791..3f56efadc 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/shareSchemesIncome.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/shareSchemesIncome.json @@ -21,8 +21,8 @@ "description": "The type of share scheme.", "type": "string", "enum": [ - "shareOption", - "sharesAwardedOrReceived" + "share-option", + "shares-awarded-or-received" ] }, "employerName": { diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index ff9a6cfa1..dda7748c5 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -612,7 +612,7 @@ "totalIncome": 5000.99, "shareSchemeDetail": [ { - "type": "shareOption", + "type": "share-option", "employerName": "string", "employerRef": "123/AA12345", "taxableAmount": 5000.99 diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index 2698441a3..3a15dbb65 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -596,7 +596,7 @@ "totalIncome": 5000.99, "shareSchemeDetail": [ { - "type": "shareOption", + "type": "share-option", "employerName": "string", "employerRef": "123/AA12345", "taxableAmount": 5000.99 From 6c6fb22f342e2085c72ab574b6e107dfa2a56b70 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:00:12 +0100 Subject: [PATCH 13/32] [MTDSA-23287] Update TaxRegime enums --- app/v7/common/model/response/TaxRegime.scala | 37 +++++++++++++++++++ .../response/inputs/PersonalInformation.scala | 17 +++++---- .../response/inputs/PersonalInformation.scala | 3 +- ...1_RetrieveCalculationControllerISpec.scala | 2 +- .../retrieve/def1/retrieve_response.json | 2 +- .../retrieve/def2/retrieve_response.json | 2 +- .../7.0/schemas/retrieve/def1/inputs.json | 6 +-- .../7.0/schemas/retrieve/def2/inputs.json | 6 +-- .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- .../def1/model/Def1_CalculationFixture.scala | 25 +++++++------ 11 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 app/v7/common/model/response/TaxRegime.scala diff --git a/app/v7/common/model/response/TaxRegime.scala b/app/v7/common/model/response/TaxRegime.scala new file mode 100644 index 000000000..97799dae4 --- /dev/null +++ b/app/v7/common/model/response/TaxRegime.scala @@ -0,0 +1,37 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait TaxRegime + +object TaxRegime { + case object `uk` extends TaxRegime + case object `scotland` extends TaxRegime + case object `wales` extends TaxRegime + + implicit val writes: Writes[TaxRegime] = Enums.writes[TaxRegime] + + implicit val reads: Reads[TaxRegime] = Enums.readsUsing { + case "UK" => `uk` + case "Scotland" => `scotland` + case "Wales" => `wales` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala index 1cbceba41..9cf6ac087 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala @@ -17,16 +17,17 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.TaxRegime case class PersonalInformation(identifier: String, - dateOfBirth: Option[String], - taxRegime: String, - statePensionAgeDate: Option[String], - studentLoanPlan: Option[Seq[StudentLoanPlan]], - class2VoluntaryContributions: Option[Boolean], - marriageAllowance: Option[String], - uniqueTaxpayerReference: Option[String], - itsaStatus: Option[String]) { + dateOfBirth: Option[String], + taxRegime: TaxRegime, + statePensionAgeDate: Option[String], + studentLoanPlan: Option[Seq[StudentLoanPlan]], + class2VoluntaryContributions: Option[Boolean], + marriageAllowance: Option[String], + uniqueTaxpayerReference: Option[String], + itsaStatus: Option[String]) { def withoutItsaStatus: PersonalInformation = copy(itsaStatus = None) } diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala index 132e841c5..44342eccc 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala @@ -17,10 +17,11 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.TaxRegime case class PersonalInformation(identifier: String, dateOfBirth: Option[String], - taxRegime: String, + taxRegime: TaxRegime, statePensionAgeDate: Option[String], studentLoanPlan: Option[Seq[StudentLoanPlan]], class2VoluntaryContributions: Option[Boolean], diff --git a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala index 963b28a5b..247d9cd82 100644 --- a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala +++ b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala @@ -101,7 +101,7 @@ class Def1_RetrieveCalculationControllerISpec extends IntegrationBaseSpec { | "inputs" : { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | }, diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index 39b6bcca5..2fae89e9d 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -17,7 +17,7 @@ "personalInformation": { "identifier": "VO123456A", "dateOfBirth": "1988-08-27", - "taxRegime": "UK", + "taxRegime": "uk", "statePensionAgeDate": "2050-04-06", "studentLoanPlan": [ { diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index 9bc93bbdb..caba49fbd 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -17,7 +17,7 @@ "personalInformation": { "identifier": "VO123456A", "dateOfBirth": "1988-08-27", - "taxRegime": "UK", + "taxRegime": "uk", "statePensionAgeDate": "2050-04-06", "studentLoanPlan": [ { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json index 5cc1fbd7f..12a94dd3c 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json @@ -62,9 +62,9 @@ "description": "The tax regime which applies to this calculation.", "type": "string", "enum": [ - "UK", - "Scotland", - "Wales" + "uk", + "scotland", + "wales" ] }, "statePensionAgeDate": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json index af7173822..d5617ed6f 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json @@ -62,9 +62,9 @@ "description": "The tax regime which applies to this calculation.", "type": "string", "enum": [ - "UK", - "Scotland", - "Wales" + "uk", + "scotland", + "wales" ] }, "statePensionAgeDate": { diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index dda7748c5..64eff943e 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -17,7 +17,7 @@ "personalInformation": { "identifier": "VO123456A", "dateOfBirth": "2018-04-06", - "taxRegime": "UK", + "taxRegime": "uk", "statePensionAgeDate": "2050-04-06", "studentLoanPlan": [ { diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index 3a15dbb65..ffd4f19d1 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -17,7 +17,7 @@ "personalInformation": { "identifier": "VO123456A", "dateOfBirth": "2018-04-06", - "taxRegime": "UK", + "taxRegime": "uk", "statePensionAgeDate": "2050-04-06", "studentLoanPlan": [ { diff --git a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala index 04fcca447..a699b6218 100644 --- a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala +++ b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala @@ -20,6 +20,7 @@ import play.api.libs.json.{JsObject, JsValue, Json} import shared.models.domain.TaxYear import v7.common.model.response.CalculationType.`in-year` import v7.common.model.response.IncomeSourceType +import v7.common.model.response.TaxRegime import v7.retrieveCalculation.def1.model.response.calculation.Calculation import v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome.{EmploymentAndPensionsIncome, EmploymentAndPensionsIncomeDetail} import v7.retrieveCalculation.def1.model.response.calculation.endOfYearEstimate.EndOfYearEstimate @@ -323,7 +324,7 @@ trait Def1_CalculationFixture { val metadataWithBasicRateDivergenceData: Metadata = metadata.copy(taxYear = TaxYear.fromDownstream("2025")) val inputs: Inputs = Inputs( - PersonalInformation("", None, "UK", None, None, None, None, None, None), + PersonalInformation("", None, TaxRegime.`uk`, None, None, None, None, None, None), IncomeSources(None, None), // @formatter:off None, None, None, None, @@ -355,7 +356,7 @@ trait Def1_CalculationFixture { ) val inputsWithAdditionalFields: Inputs = Inputs( - PersonalInformation("", None, "UK", None, None, None, None, None, Some("No Status")), + PersonalInformation("", None, TaxRegime.`uk`, None, None, None, None, None, Some("No Status")), IncomeSources(Some(Seq(businessIncomeSourceWithAdditionalField)), None), // @formatter:off None, None, None, None, @@ -440,7 +441,7 @@ trait Def1_CalculationFixture { | "inputs" : { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | }, @@ -499,7 +500,7 @@ trait Def1_CalculationFixture { | "inputs": { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | }, @@ -558,7 +559,7 @@ trait Def1_CalculationFixture { "inputs": { "personalInformation": { "identifier": "", - "taxRegime": "UK", + "taxRegime": "uk", "itsaStatus": "No Status" }, "incomeSources": { @@ -625,7 +626,7 @@ trait Def1_CalculationFixture { | "inputs":{ | "personalInformation":{ | "identifier":"", - | "taxRegime":"UK" + | "taxRegime":"uk" | }, | "incomeSources":{ | @@ -659,7 +660,7 @@ trait Def1_CalculationFixture { | "inputs" : { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | }, @@ -709,7 +710,7 @@ trait Def1_CalculationFixture { | "inputs" : { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | }, @@ -760,7 +761,7 @@ trait Def1_CalculationFixture { | "inputs" : { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | } @@ -787,7 +788,7 @@ trait Def1_CalculationFixture { | "inputs" : { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | }, @@ -818,7 +819,7 @@ trait Def1_CalculationFixture { | "inputs" : { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | } @@ -845,7 +846,7 @@ trait Def1_CalculationFixture { | "inputs" : { | "personalInformation": { | "identifier": "", - | "taxRegime": "UK" + | "taxRegime": "uk" | }, | "incomeSources": {} | }, From d2d220f2a99ea9fa60cf0f644e4c66d100ac0099 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:14:48 +0100 Subject: [PATCH 14/32] [MTDSA-23287] Update AllowancesReliefsAndDeductionsType enums --- .../AllowancesReliefsAndDeductionsType.scala | 41 +++++++++++++++++++ .../AllowancesReliefsAndDeductions.scala | 11 ++--- .../AllowancesReliefsAndDeductions.scala | 11 ++--- .../retrieve/def1/retrieve_response.json | 2 +- .../retrieve/def2/retrieve_response.json | 2 +- .../7.0/schemas/retrieve/def1/inputs.json | 10 ++--- .../7.0/schemas/retrieve/def2/inputs.json | 10 ++--- .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- 9 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 app/v7/common/model/response/AllowancesReliefsAndDeductionsType.scala diff --git a/app/v7/common/model/response/AllowancesReliefsAndDeductionsType.scala b/app/v7/common/model/response/AllowancesReliefsAndDeductionsType.scala new file mode 100644 index 000000000..b6e494915 --- /dev/null +++ b/app/v7/common/model/response/AllowancesReliefsAndDeductionsType.scala @@ -0,0 +1,41 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait AllowancesReliefsAndDeductionsType + +object AllowancesReliefsAndDeductionsType { + case object `investment-reliefs` extends AllowancesReliefsAndDeductionsType + case object `other-reliefs` extends AllowancesReliefsAndDeductionsType + case object `other-expenses` extends AllowancesReliefsAndDeductionsType + case object `other-deductions` extends AllowancesReliefsAndDeductionsType + case object `foreign-reliefs` extends AllowancesReliefsAndDeductionsType + + implicit val writes: Writes[AllowancesReliefsAndDeductionsType] = Enums.writes[AllowancesReliefsAndDeductionsType] + + implicit val reads: Reads[AllowancesReliefsAndDeductionsType] = Enums.readsUsing { + case "investmentReliefs" => `investment-reliefs` + case "otherReliefs" => `other-reliefs` + case "otherExpenses" => `other-expenses` + case "otherDeductions" => `other-deductions` + case "foreignReliefs" => `foreign-reliefs` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala index b74f94a73..38985531c 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala @@ -17,12 +17,13 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.AllowancesReliefsAndDeductionsType -case class AllowancesReliefsAndDeductions(`type`: Option[String], - submittedTimestamp: Option[String], - startDate: Option[String], - endDate: Option[String], - source: Option[String]) +case class AllowancesReliefsAndDeductions(`type`: AllowancesReliefsAndDeductionsType, + submittedTimestamp: Option[String], + startDate: Option[String], + endDate: Option[String], + source: Option[String]) object AllowancesReliefsAndDeductions { implicit val format: OFormat[AllowancesReliefsAndDeductions] = Json.format[AllowancesReliefsAndDeductions] diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala index bce04d4a6..37c82baab 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala @@ -17,12 +17,13 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.AllowancesReliefsAndDeductionsType -case class AllowancesReliefsAndDeductions(`type`: Option[String], - submittedTimestamp: Option[String], - startDate: Option[String], - endDate: Option[String], - source: Option[String]) +case class AllowancesReliefsAndDeductions(`type`: AllowancesReliefsAndDeductionsType, + submittedTimestamp: Option[String], + startDate: Option[String], + endDate: Option[String], + source: Option[String]) object AllowancesReliefsAndDeductions { implicit val format: OFormat[AllowancesReliefsAndDeductions] = Json.format[AllowancesReliefsAndDeductions] diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index 2fae89e9d..aa0b963f3 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -121,7 +121,7 @@ ], "allowancesReliefsAndDeductions": [ { - "type": "investmentReliefs", + "type": "investment-reliefs", "submittedTimestamp": "2021-12-10T15:25:48.475Z", "startDate": "2021-11-02", "endDate": "2021-12-02", diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index caba49fbd..26a2fb86a 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -117,7 +117,7 @@ ], "allowancesReliefsAndDeductions": [ { - "type": "investmentReliefs", + "type": "investment-reliefs", "submittedTimestamp": "2021-12-10T15:25:48.475Z", "startDate": "2021-11-02", "endDate": "2021-12-02", diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json index 12a94dd3c..5ee3ed221 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json @@ -447,11 +447,11 @@ "description": "The type of allowance, deduction or relief claimed.", "type": "string", "enum": [ - "investmentReliefs", - "otherReliefs", - "otherExpenses", - "otherDeductions", - "foreignReliefs" + "investment-reliefs", + "other-reliefs", + "other-expenses", + "other-deductions", + "foreign-reliefs" ] }, "submittedTimestamp": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json index d5617ed6f..42d46272e 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json @@ -445,11 +445,11 @@ "description": "The type of allowance, deduction or relief claimed.", "type": "string", "enum": [ - "investmentReliefs", - "otherReliefs", - "otherExpenses", - "otherDeductions", - "foreignReliefs" + "investment-reliefs", + "other-reliefs", + "other-expenses", + "other-deductions", + "foreign-reliefs" ] }, "submittedTimestamp": { diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index 64eff943e..e6e6df99b 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -114,7 +114,7 @@ ], "allowancesReliefsAndDeductions": [ { - "type": "investmentReliefs", + "type": "investment-reliefs", "submittedTimestamp": "2021-12-02T15:25:48Z", "startDate": "2021-12-02", "endDate": "2021-12-02", diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index ffd4f19d1..7e6f5e03b 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -114,7 +114,7 @@ ], "allowancesReliefsAndDeductions": [ { - "type": "investmentReliefs", + "type": "investment-reliefs", "submittedTimestamp": "2021-12-02T15:25:48Z", "startDate": "2021-12-02", "endDate": "2021-12-02", From 2b1e8306d12bb24fc7f94c0da710ee1b65f47319 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:23:10 +0100 Subject: [PATCH 15/32] [MTDSA-23287] Update PensionContributionAndChargesType enums --- .../PensionContributionAndChargesType.scala | 35 +++++++++++++++++++ .../PensionContributionAndCharges.scala | 11 +++--- .../PensionContributionAndCharges.scala | 11 +++--- .../retrieve/def1/retrieve_response.json | 2 +- .../retrieve/def2/retrieve_response.json | 2 +- .../7.0/schemas/retrieve/def1/inputs.json | 4 +-- .../7.0/schemas/retrieve/def2/inputs.json | 4 +-- .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- 9 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 app/v7/common/model/response/PensionContributionAndChargesType.scala diff --git a/app/v7/common/model/response/PensionContributionAndChargesType.scala b/app/v7/common/model/response/PensionContributionAndChargesType.scala new file mode 100644 index 000000000..9a2bd881d --- /dev/null +++ b/app/v7/common/model/response/PensionContributionAndChargesType.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait PensionContributionAndChargesType + +object PensionContributionAndChargesType { + case object `pension-reliefs` extends PensionContributionAndChargesType + case object `pension-charges` extends PensionContributionAndChargesType + + implicit val writes: Writes[PensionContributionAndChargesType] = Enums.writes[PensionContributionAndChargesType] + + implicit val reads: Reads[PensionContributionAndChargesType] = Enums.readsUsing { + case "pensionReliefs" => `pension-reliefs` + case "pensionCharges" => `pension-charges` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala index a4ef2fe29..ab6c88cf1 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala @@ -17,12 +17,13 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.PensionContributionAndChargesType -case class PensionContributionAndCharges(`type`: String, - submissionTimestamp: Option[String], - startDate: Option[String], - endDate: Option[String], - source: Option[String]) +case class PensionContributionAndCharges(`type`: PensionContributionAndChargesType, + submissionTimestamp: Option[String], + startDate: Option[String], + endDate: Option[String], + source: Option[String]) object PensionContributionAndCharges { implicit val format: OFormat[PensionContributionAndCharges] = Json.format[PensionContributionAndCharges] diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala index 06d01c48d..f6c43c40b 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala @@ -17,12 +17,13 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.PensionContributionAndChargesType -case class PensionContributionAndCharges(`type`: String, - submissionTimestamp: Option[String], - startDate: Option[String], - endDate: Option[String], - source: Option[String]) +case class PensionContributionAndCharges(`type`: PensionContributionAndChargesType, + submissionTimestamp: Option[String], + startDate: Option[String], + endDate: Option[String], + source: Option[String]) object PensionContributionAndCharges { implicit val format: OFormat[PensionContributionAndCharges] = Json.format[PensionContributionAndCharges] diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index aa0b963f3..99de403ad 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -130,7 +130,7 @@ ], "pensionContributionAndCharges": [ { - "type": "pensionReliefs", + "type": "pension-reliefs", "submissionTimestamp": "2021-12-10T15:25:48.475Z", "startDate": "2021-11-02", "endDate": "2021-12-02", diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index 26a2fb86a..b01d459e0 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -126,7 +126,7 @@ ], "pensionContributionAndCharges": [ { - "type": "pensionReliefs", + "type": "pension-reliefs", "submissionTimestamp": "2021-12-10T15:25:48.475Z", "startDate": "2021-11-02", "endDate": "2021-12-02", diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json index 5ee3ed221..796750e55 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json @@ -500,8 +500,8 @@ "description": "The type of pension contribution.", "type": "string", "enum": [ - "pensionReliefs", - "pensionCharges" + "pension-reliefs", + "pension-charges" ] }, "submissionTimestamp": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json index 42d46272e..6f058b7cc 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json @@ -498,8 +498,8 @@ "description": "The type of pension contribution.", "type": "string", "enum": [ - "pensionReliefs", - "pensionCharges" + "pension-reliefs", + "pension-charges" ] }, "submissionTimestamp": { diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index e6e6df99b..9c4d1a2d0 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -123,7 +123,7 @@ ], "pensionContributionAndCharges": [ { - "type": "pensionReliefs", + "type": "pension-reliefs", "submissionTimestamp": "2021-12-02T15:25:48Z", "startDate": "2021-12-02", "endDate": "2021-12-02", diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index 7e6f5e03b..cfbdc78d6 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -123,7 +123,7 @@ ], "pensionContributionAndCharges": [ { - "type": "pensionReliefs", + "type": "pension-reliefs", "submissionTimestamp": "2021-12-02T15:25:48Z", "startDate": "2021-12-02", "endDate": "2021-12-02", From 63dccab61f09106bcd771d3f2b6caa580e72a748 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:34:53 +0100 Subject: [PATCH 16/32] [MTDSA-23287] Update InputsOtherType enums --- .../model/response/InputsOtherType.scala | 33 +++++++++++++++++++ .../def1/model/response/inputs/Other.scala | 3 +- .../def2/model/response/inputs/Other.scala | 3 +- .../retrieve/def1/retrieve_response.json | 2 +- .../retrieve/def2/retrieve_response.json | 2 +- .../7.0/schemas/retrieve/def1/inputs.json | 2 +- .../7.0/schemas/retrieve/def2/inputs.json | 2 +- .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- 9 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 app/v7/common/model/response/InputsOtherType.scala diff --git a/app/v7/common/model/response/InputsOtherType.scala b/app/v7/common/model/response/InputsOtherType.scala new file mode 100644 index 000000000..8366d9faa --- /dev/null +++ b/app/v7/common/model/response/InputsOtherType.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait InputsOtherType + +object InputsOtherType { + case object `coding-out` extends InputsOtherType + + implicit val writes: Writes[InputsOtherType] = Enums.writes[InputsOtherType] + + implicit val reads: Reads[InputsOtherType] = Enums.readsUsing { + case "codingOut" => `coding-out` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala index db4c42c59..dfd1f3ab7 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala @@ -17,8 +17,9 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.InputsOtherType -case class Other(`type`: String, submittedOn: Option[String]) +case class Other(`type`: InputsOtherType, submittedOn: Option[String]) object Other { implicit val format: OFormat[Other] = Json.format[Other] diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala index 30edad968..089e73482 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala @@ -17,8 +17,9 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} +import v7.common.model.response.InputsOtherType -case class Other(`type`: String, submittedOn: Option[String]) +case class Other(`type`: InputsOtherType, submittedOn: Option[String]) object Other { implicit val format: OFormat[Other] = Json.format[Other] diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index 99de403ad..3912a3393 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -139,7 +139,7 @@ ], "other": [ { - "type": "codingOut", + "type": "coding-out", "submittedOn": "2021-12-04T15:25:48.475Z" } ] diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index b01d459e0..a463c53aa 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -135,7 +135,7 @@ ], "other": [ { - "type": "codingOut", + "type": "coding-out", "submittedOn": "2021-12-04T15:25:48.475Z" } ] diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json index 796750e55..d5202e5e5 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/inputs.json @@ -553,7 +553,7 @@ "description": "An array of other inputs that have been pulled into this calculation.", "type": "string", "enum": [ - "codingOut" + "coding-out" ] }, "submittedOn": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json index 6f058b7cc..98599112d 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/inputs.json @@ -551,7 +551,7 @@ "description": "An array of other inputs that have been pulled into this calculation.", "type": "string", "enum": [ - "codingOut" + "coding-out" ] }, "submittedOn": { diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index 9c4d1a2d0..92e0eba9b 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -132,7 +132,7 @@ ], "other": [ { - "type": "codingOut", + "type": "coding-out", "submittedOn": "2021-12-02T15:25:48Z" } ] diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index cfbdc78d6..5ad7861c7 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -132,7 +132,7 @@ ], "other": [ { - "type": "codingOut", + "type": "coding-out", "submittedOn": "2021-12-02T15:25:48Z" } ] From 3fb6373018d6189ef08d2592751ccc65b38f9b23 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Thu, 26 Sep 2024 19:29:33 +0100 Subject: [PATCH 17/32] [MTDSA-23287] Update calculationReason enums --- .../model/response/CalculationReason.scala | 49 +++++++++++++++++++ .../model/response/metadata/Metadata.scala | 6 +-- .../model/response/metadata/Metadata.scala | 6 +-- ...1_RetrieveCalculationControllerISpec.scala | 4 +- .../retrieve/def1/retrieve_response.json | 2 +- .../retrieve/def2/retrieve_response.json | 2 +- .../7.0/schemas/retrieve/def1/metadata.json | 18 +++---- .../7.0/schemas/retrieve/def2/metadata.json | 18 +++---- .../def1/model/response/calculation_mtd.json | 2 +- .../def2/model/response/calculation_mtd.json | 2 +- .../def1/model/Def1_CalculationFixture.scala | 23 ++++----- .../response/metadata/MetadataSpec.scala | 14 +++--- .../response/metadata/MetadataSpec.scala | 14 +++--- 13 files changed, 105 insertions(+), 55 deletions(-) create mode 100644 app/v7/common/model/response/CalculationReason.scala diff --git a/app/v7/common/model/response/CalculationReason.scala b/app/v7/common/model/response/CalculationReason.scala new file mode 100644 index 000000000..b53c70ee1 --- /dev/null +++ b/app/v7/common/model/response/CalculationReason.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.common.model.response + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait CalculationReason + +object CalculationReason { + case object `customer-request` extends CalculationReason + case object `class2-nic-event` extends CalculationReason + case object `new-loss-event` extends CalculationReason + case object `updated-loss-event` extends CalculationReason + case object `new-claim-event` extends CalculationReason + case object `updated-claim-event` extends CalculationReason + case object `new-annual-adjustment-event` extends CalculationReason + case object `updated-annual-adjustment-event` extends CalculationReason + case object `unattended-calculation` extends CalculationReason + + implicit val writes: Writes[CalculationReason] = Enums.writes[CalculationReason] + + implicit val reads: Reads[CalculationReason] = Enums.readsUsing { + case "customerRequest" => `customer-request` + case "class2NICEvent" => `class2-nic-event` + case "newLossEvent" => `new-loss-event` + case "updatedLossEvent" => `updated-loss-event` + case "newClaimEvent" => `new-claim-event` + case "updatedClaimEvent" => `updated-claim-event` + case "newAnnualAdjustmentEvent" => `new-annual-adjustment-event` + case "updatedAnnualAdjustmentEvent" => `updated-annual-adjustment-event` + case "unattendedCalculation" => `unattended-calculation` + } + +} diff --git a/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala b/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala index 4bc038290..ebed256ad 100644 --- a/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala +++ b/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala @@ -20,13 +20,13 @@ import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.functional.syntax._ import play.api.libs.json._ -import v7.common.model.response.CalculationType +import v7.common.model.response.{CalculationType, CalculationReason} case class Metadata(calculationId: String, taxYear: TaxYear, requestedBy: String, requestedTimestamp: Option[String], - calculationReason: String, + calculationReason: CalculationReason, calculationTimestamp: Option[String], calculationType: CalculationType, intentToSubmitFinalDeclaration: Boolean, @@ -46,7 +46,7 @@ object Metadata { (JsPath \ "taxYear").read[TaxYear] and (JsPath \ "requestedBy").read[String] and (JsPath \ "requestedTimestamp").readNullable[String] and - (JsPath \ "calculationReason").read[String] and + (JsPath \ "calculationReason").read[CalculationReason] and (JsPath \ "calculationTimestamp").readNullable[String] and (JsPath \ "calculationType").read[CalculationType] and (JsPath \ "intentToCrystallise").readWithDefault[Boolean](false) and diff --git a/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala b/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala index e399b3ce9..bf2e8d85b 100644 --- a/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala +++ b/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala @@ -20,13 +20,13 @@ import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.functional.syntax._ import play.api.libs.json._ -import v7.common.model.response.CalculationType +import v7.common.model.response.{CalculationType, CalculationReason} case class Metadata(calculationId: String, taxYear: TaxYear, requestedBy: String, requestedTimestamp: Option[String], - calculationReason: String, + calculationReason: CalculationReason, calculationTimestamp: Option[String], calculationType: CalculationType, intentToSubmitFinalDeclaration: Boolean, @@ -46,7 +46,7 @@ object Metadata { (JsPath \ "taxYear").read[TaxYear] and (JsPath \ "requestedBy").read[String] and (JsPath \ "requestedTimestamp").readNullable[String] and - (JsPath \ "calculationReason").read[String] and + (JsPath \ "calculationReason").read[CalculationReason] and (JsPath \ "calculationTimestamp").readNullable[String] and (JsPath \ "calculationType").read[CalculationType] and (JsPath \ "intentToCrystallise").readWithDefault[Boolean](false) and diff --git a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala index 247d9cd82..7de82b52e 100644 --- a/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala +++ b/it/v7/retrieveCalculation/def1/Def1_RetrieveCalculationControllerISpec.scala @@ -56,7 +56,7 @@ class Def1_RetrieveCalculationControllerISpec extends IntegrationBaseSpec { | "calculationId": "", | "taxYear": 2017, | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customerRequest", | "calculationType": "inYear", | ${if (canBeFinalised) """"intentToCrystallise": true,""" else ""} | "periodFrom": "", @@ -91,7 +91,7 @@ class Def1_RetrieveCalculationControllerISpec extends IntegrationBaseSpec { | "calculationId": "", | "taxYear": "2016-17", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": $canBeFinalised, | "finalDeclaration": false, diff --git a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json index 3912a3393..a39a53305 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def1/retrieve_response.json @@ -4,7 +4,7 @@ "taxYear": "2021-22", "requestedBy": "customer", "requestedTimestamp": "2021-02-15T09:35:15.094Z", - "calculationReason": "customerRequest", + "calculationReason": "customer-request", "calculationTimestamp": "2021-08-15T09:35:15.094Z", "calculationType": "final-declaration", "intentToSubmitFinalDeclaration": true, diff --git a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json index a463c53aa..834d84aac 100644 --- a/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json +++ b/resources/public/api/conf/7.0/examples/retrieve/def2/retrieve_response.json @@ -4,7 +4,7 @@ "taxYear": "2021-22", "requestedBy": "customer", "requestedTimestamp": "2021-02-15T09:35:15.094Z", - "calculationReason": "customerRequest", + "calculationReason": "customer-request", "calculationTimestamp": "2021-08-15T09:35:15.094Z", "calculationType": "final-declaration", "intentToSubmitFinalDeclaration": true, diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json index 6b06d196c..c812b32c2 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/metadata.json @@ -35,55 +35,55 @@ "oneOf": [ { "enum": [ - "customerRequest" + "customer-request" ], "description": "The calculation was triggered by the customer via software." }, { "enum": [ - "class2NICEvent" + "class2-nic-event" ], "description": "The calculation was triggered internally by HMRC once the actual Class 2 NIC amount became available. This event is only applicable for an in-year \"final-declaration\" calculation type." }, { "enum": [ - "newLossEvent" + "new-loss-event" ], "description": "The calculation was triggered by HMRC on receipt of a new pre-MTD brought forward loss made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ - "newClaimEvent" + "new-claim-event" ], "description": "The calculation was triggered by HMRC on receipt of a new loss claim made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ - "updatedClaimEvent" + "updated-claim-event" ], "description": "The calculation was triggered internally by HMRC on receipt of an updated loss claim made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ - "updatedLossEvent" + "updated-loss-event" ], "description": "The calculation was triggered internally by HMRC on receipt of an updated pre-MTD brought forward loss made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ - "newAnnualAdjustmentEvent" + "new-annual-adjustment-event" ], "description": "The calculation was triggered internally by HMRC on receipt of a request for a new adjustable summary calculation by the customer. This event is not currently supported." }, { "enum": [ - "updatedAnnualAdjustmentEvent" + "updated-annual-adjustment-event" ], "description": "The calculation was triggered internally by HMRC on receipt of an adjustment to an adjustable summary calculation made by the customer. This event is not currently supported." }, { "enum": [ - "unattendedCalculation" + "unattended-calculation" ], "description": "HMRC has updated the calculation for you. You can see more details in your record-keeping software." } diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json index 6b06d196c..c812b32c2 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/metadata.json @@ -35,55 +35,55 @@ "oneOf": [ { "enum": [ - "customerRequest" + "customer-request" ], "description": "The calculation was triggered by the customer via software." }, { "enum": [ - "class2NICEvent" + "class2-nic-event" ], "description": "The calculation was triggered internally by HMRC once the actual Class 2 NIC amount became available. This event is only applicable for an in-year \"final-declaration\" calculation type." }, { "enum": [ - "newLossEvent" + "new-loss-event" ], "description": "The calculation was triggered by HMRC on receipt of a new pre-MTD brought forward loss made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ - "newClaimEvent" + "new-claim-event" ], "description": "The calculation was triggered by HMRC on receipt of a new loss claim made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ - "updatedClaimEvent" + "updated-claim-event" ], "description": "The calculation was triggered internally by HMRC on receipt of an updated loss claim made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ - "updatedLossEvent" + "updated-loss-event" ], "description": "The calculation was triggered internally by HMRC on receipt of an updated pre-MTD brought forward loss made by the customer. This event is only applicable for a \"final-declaration\" calculation type. This event is not currently supported and will be supported in the future." }, { "enum": [ - "newAnnualAdjustmentEvent" + "new-annual-adjustment-event" ], "description": "The calculation was triggered internally by HMRC on receipt of a request for a new adjustable summary calculation by the customer. This event is not currently supported." }, { "enum": [ - "updatedAnnualAdjustmentEvent" + "updated-annual-adjustment-event" ], "description": "The calculation was triggered internally by HMRC on receipt of an adjustment to an adjustable summary calculation made by the customer. This event is not currently supported." }, { "enum": [ - "unattendedCalculation" + "unattended-calculation" ], "description": "HMRC has updated the calculation for you. You can see more details in your record-keeping software." } diff --git a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json index 92e0eba9b..6b4c51e19 100644 --- a/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def1/model/response/calculation_mtd.json @@ -4,7 +4,7 @@ "taxYear": "2017-18", "requestedBy": "customer", "requestedTimestamp": "2019-02-15T09:35:15.000Z", - "calculationReason": "customerRequest", + "calculationReason": "customer-request", "calculationTimestamp": "2019-02-15T09:35:15.094Z", "calculationType": "final-declaration", "intentToSubmitFinalDeclaration": true, diff --git a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json index 5ad7861c7..c97b4bf56 100644 --- a/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json +++ b/test/resources/v7/retrieveCalculation/def2/model/response/calculation_mtd.json @@ -4,7 +4,7 @@ "taxYear": "2017-18", "requestedBy": "customer", "requestedTimestamp": "2019-02-15T09:35:15.000Z", - "calculationReason": "customerRequest", + "calculationReason": "customer-request", "calculationTimestamp": "2019-02-15T09:35:15.094Z", "calculationType": "final-declaration", "intentToSubmitFinalDeclaration": true, diff --git a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala index a699b6218..c6b15fef8 100644 --- a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala +++ b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala @@ -19,6 +19,7 @@ package v7.retrieveCalculation.def1.model import play.api.libs.json.{JsObject, JsValue, Json} import shared.models.domain.TaxYear import v7.common.model.response.CalculationType.`in-year` +import v7.common.model.response.CalculationReason.`customer-request` import v7.common.model.response.IncomeSourceType import v7.common.model.response.TaxRegime import v7.retrieveCalculation.def1.model.response.calculation.Calculation @@ -312,7 +313,7 @@ trait Def1_CalculationFixture { taxYear = TaxYear.fromDownstream("2018"), requestedBy = "", requestedTimestamp = None, - calculationReason = "", + calculationReason = `customer-request`, calculationTimestamp = None, calculationType = `in-year`, intentToSubmitFinalDeclaration = false, @@ -431,7 +432,7 @@ trait Def1_CalculationFixture { | "calculationId": "", | "taxYear": "2017-18", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, @@ -490,7 +491,7 @@ trait Def1_CalculationFixture { | "calculationId": "", | "taxYear": "2017-18", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, @@ -549,7 +550,7 @@ trait Def1_CalculationFixture { "calculationId": "", "taxYear": "2017-18", "requestedBy": "", - "calculationReason": "", + "calculationReason": "customer-request", "calculationType": "in-year", "intentToSubmitFinalDeclaration": false, "finalDeclaration": false, @@ -616,7 +617,7 @@ trait Def1_CalculationFixture { | "calculationId":"", | "taxYear":"2017-18", | "requestedBy":"", - | "calculationReason":"", + | "calculationReason":"customer-request", | "calculationType":"in-year", | "intentToSubmitFinalDeclaration":false, | "finalDeclaration":false, @@ -650,7 +651,7 @@ trait Def1_CalculationFixture { | "calculationId": "", | "taxYear": "2024-25", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, @@ -700,7 +701,7 @@ trait Def1_CalculationFixture { | "calculationId": "", | "taxYear": "2017-18", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, @@ -751,7 +752,7 @@ trait Def1_CalculationFixture { | "calculationId": "", | "taxYear": "2017-18", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, @@ -778,7 +779,7 @@ trait Def1_CalculationFixture { | "calculationId": "", | "taxYear": "2017-18", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, @@ -809,7 +810,7 @@ trait Def1_CalculationFixture { | "calculationId": "", | "taxYear": "2017-18", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, @@ -836,7 +837,7 @@ trait Def1_CalculationFixture { | "calculationId": "", | "taxYear": "2017-18", | "requestedBy": "", - | "calculationReason": "", + | "calculationReason": "customer-request", | "calculationType": "in-year", | "intentToSubmitFinalDeclaration": false, | "finalDeclaration": false, diff --git a/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala b/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala index e7bbf31f7..3c9ac66f7 100644 --- a/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.metadata import play.api.libs.json.Json import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.CalculationType +import v7.common.model.response.{CalculationType, CalculationReason} class MetadataSpec extends UnitSpec { @@ -33,7 +33,7 @@ class MetadataSpec extends UnitSpec { | "taxYear": 2018, | "requestedBy": "customer", | "requestedTimestamp": "requested timestamp", - | "calculationReason": "reason", + | "calculationReason": "customerRequest", | "calculationTimestamp": "calc timestamp", | "calculationType": "crystallisation", | "intentToCrystallise": true, @@ -49,7 +49,7 @@ class MetadataSpec extends UnitSpec { taxYear = TaxYear.fromDownstream("2018"), requestedBy = "customer", requestedTimestamp = Some("requested timestamp"), - calculationReason = "reason", + calculationReason = CalculationReason.`customer-request`, calculationTimestamp = Some("calc timestamp"), calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = true, @@ -69,7 +69,7 @@ class MetadataSpec extends UnitSpec { | "calculationId": "calcId", | "taxYear": 2018, | "requestedBy": "customer", - | "calculationReason": "reason", + | "calculationReason": "customerRequest", | "calculationType": "crystallisation", | "periodFrom": "from", | "periodTo": "to" @@ -81,7 +81,7 @@ class MetadataSpec extends UnitSpec { taxYear = TaxYear.fromDownstream("2018"), requestedBy = "customer", requestedTimestamp = None, - calculationReason = "reason", + calculationReason = CalculationReason.`customer-request`, calculationTimestamp = None, calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = false, @@ -102,7 +102,7 @@ class MetadataSpec extends UnitSpec { taxYear = TaxYear.fromDownstream("2018"), requestedBy = "customer", requestedTimestamp = Some("requested timestamp"), - calculationReason = "reason", + calculationReason = CalculationReason.`customer-request`, calculationTimestamp = Some("calc timestamp"), calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = true, @@ -116,7 +116,7 @@ class MetadataSpec extends UnitSpec { | "taxYear": "2017-18", | "requestedBy": "customer", | "requestedTimestamp": "requested timestamp", - | "calculationReason": "reason", + | "calculationReason": "customer-request", | "calculationTimestamp": "calc timestamp", | "calculationType": "final-declaration", | "intentToSubmitFinalDeclaration": true, diff --git a/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala b/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala index bdfa6dace..e1cb4fb11 100644 --- a/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.metadata import play.api.libs.json.Json import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.CalculationType +import v7.common.model.response.{CalculationType, CalculationReason} class MetadataSpec extends UnitSpec { @@ -32,7 +32,7 @@ class MetadataSpec extends UnitSpec { | "taxYear": 2018, | "requestedBy": "customer", | "requestedTimestamp": "requested timestamp", - | "calculationReason": "reason", + | "calculationReason": "customerRequest", | "calculationTimestamp": "calc timestamp", | "calculationType": "crystallisation", | "intentToCrystallise": true, @@ -48,7 +48,7 @@ class MetadataSpec extends UnitSpec { taxYear = TaxYear.fromDownstream("2018"), requestedBy = "customer", requestedTimestamp = Some("requested timestamp"), - calculationReason = "reason", + calculationReason = CalculationReason.`customer-request`, calculationTimestamp = Some("calc timestamp"), calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = true, @@ -67,7 +67,7 @@ class MetadataSpec extends UnitSpec { | "calculationId": "calcId", | "taxYear": 2018, | "requestedBy": "customer", - | "calculationReason": "reason", + | "calculationReason": "customerRequest", | "calculationType": "crystallisation", | "periodFrom": "from", | "periodTo": "to" @@ -79,7 +79,7 @@ class MetadataSpec extends UnitSpec { taxYear = TaxYear.fromDownstream("2018"), requestedBy = "customer", requestedTimestamp = None, - calculationReason = "reason", + calculationReason = CalculationReason.`customer-request`, calculationTimestamp = None, calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = false, @@ -100,7 +100,7 @@ class MetadataSpec extends UnitSpec { taxYear = TaxYear.fromDownstream("2018"), requestedBy = "customer", requestedTimestamp = Some("requested timestamp"), - calculationReason = "reason", + calculationReason = CalculationReason.`customer-request`, calculationTimestamp = Some("calc timestamp"), calculationType = CalculationType.`final-declaration`, intentToSubmitFinalDeclaration = true, @@ -113,7 +113,7 @@ class MetadataSpec extends UnitSpec { | "taxYear": "2017-18", | "requestedBy": "customer", | "requestedTimestamp": "requested timestamp", - | "calculationReason": "reason", + | "calculationReason": "customer-request", | "calculationTimestamp": "calc timestamp", | "calculationType": "final-declaration", | "intentToSubmitFinalDeclaration": true, From 9c880489c6bfc7cbf5b101fc8bdcf5d1f2cc6cdc Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 12:18:24 +0100 Subject: [PATCH 18/32] Implement PR Comments --- ...dsName.scala => ShortServiceRefundBandName.scala} | 12 ++++++------ .../calculation/dividendsIncome/OtherDividends.scala | 2 +- .../lossesAndClaims/CarriedForwardLoss.scala | 2 +- .../lossesAndClaims/ResultOfClaimsApplied.scala | 2 +- .../calculation/lossesAndClaims/UnclaimedLoss.scala | 2 +- .../ShortServiceRefundBands.scala | 4 ++-- .../calculation/reliefs/ReliefsClaimedDetail.scala | 2 +- .../inputs/AllowancesReliefsAndDeductions.scala | 2 +- .../calculation/dividendsIncome/OtherDividends.scala | 2 +- .../lossesAndClaims/CarriedForwardLoss.scala | 2 +- .../lossesAndClaims/ResultOfClaimsApplied.scala | 2 +- .../calculation/lossesAndClaims/UnclaimedLoss.scala | 2 +- .../ShortServiceRefundBands.scala | 4 ++-- .../calculation/reliefs/ReliefsClaimedDetail.scala | 2 +- .../inputs/AllowancesReliefsAndDeductions.scala | 2 +- .../def1/calculation/chargeableEventGainsIncome.json | 6 +++--- .../schemas/retrieve/def1/calculation/reliefs.json | 2 +- .../def2/calculation/chargeableEventGainsIncome.json | 6 +++--- .../schemas/retrieve/def2/calculation/reliefs.json | 2 +- .../dividendsIncome/DividendsIncomeSpec.scala | 2 +- .../lossesAndClaims/CarriedForwardLossSpec.scala | 2 +- .../lossesAndClaims/ResultOfClaimsAppliedSpec.scala | 2 +- .../lossesAndClaims/UnclaimedLossSpec.scala | 2 +- .../dividendsIncome/DividendsIncomeSpec.scala | 2 +- .../lossesAndClaims/CarriedForwardLossSpec.scala | 2 +- .../lossesAndClaims/ResultOfClaimsAppliedSpec.scala | 2 +- .../lossesAndClaims/UnclaimedLossSpec.scala | 2 +- 27 files changed, 38 insertions(+), 38 deletions(-) rename app/v7/common/model/response/{ShortServiceRefundBandsName.scala => ShortServiceRefundBandName.scala} (67%) diff --git a/app/v7/common/model/response/ShortServiceRefundBandsName.scala b/app/v7/common/model/response/ShortServiceRefundBandName.scala similarity index 67% rename from app/v7/common/model/response/ShortServiceRefundBandsName.scala rename to app/v7/common/model/response/ShortServiceRefundBandName.scala index 792c830e6..a48b500db 100644 --- a/app/v7/common/model/response/ShortServiceRefundBandsName.scala +++ b/app/v7/common/model/response/ShortServiceRefundBandName.scala @@ -19,15 +19,15 @@ package v7.common.model.response import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} -sealed trait ShortServiceRefundBandsName +sealed trait ShortServiceRefundBandName -object ShortServiceRefundBandsName { - case object `lower-band` extends ShortServiceRefundBandsName - case object `upper-band` extends ShortServiceRefundBandsName +object ShortServiceRefundBandName { + case object `lower-band` extends ShortServiceRefundBandName + case object `upper-band` extends ShortServiceRefundBandName - implicit val writes: Writes[ShortServiceRefundBandsName] = Enums.writes[ShortServiceRefundBandsName] + implicit val writes: Writes[ShortServiceRefundBandName] = Enums.writes[ShortServiceRefundBandName] - implicit val reads: Reads[ShortServiceRefundBandsName] = Enums.readsUsing { + implicit val reads: Reads[ShortServiceRefundBandName] = Enums.readsUsing { case "lowerBand" => `lower-band` case "upperBand" => `upper-band` } diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala index 57d991341..37e0bfccf 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome import play.api.libs.json.{Format, Json} import v7.common.model.response.TypeOfDividend -case class OtherDividends(typeOfDividend: TypeOfDividend, +case class OtherDividends(typeOfDividend: Option[TypeOfDividend], customerReference: Option[String], grossAmount: Option[BigDecimal]) diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala index 3efbbb541..223621cb8 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala @@ -30,7 +30,7 @@ case class CarriedForwardLoss( taxYearClaimMade: Option[TaxYear], taxYearLossIncurred: TaxYear, currentLossValue: BigInt, - lossType: LossType + lossType: Option[LossType] ) object CarriedForwardLoss { diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala index ba73a191f..39a28033d 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala @@ -32,7 +32,7 @@ case class ResultOfClaimsApplied( taxYearLossIncurred: TaxYear, lossAmountUsed: BigInt, remainingLossValue: BigInt, - lossType: LossType + lossType: Option[LossType] ) object ResultOfClaimsApplied { diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala index 612409247..f54e9373c 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala @@ -26,7 +26,7 @@ case class UnclaimedLoss( incomeSourceType: IncomeSourceType, taxYearLossIncurred: TaxYear, currentLossValue: BigInt, - lossType: LossType + lossType: Option[LossType] ) object UnclaimedLoss { diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala index ae4a66d0a..6eadeb5c5 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala @@ -17,9 +17,9 @@ package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.ShortServiceRefundBandsName +import v7.common.model.response.ShortServiceRefundBandName -case class ShortServiceRefundBands(name: ShortServiceRefundBandsName, +case class ShortServiceRefundBands(name: ShortServiceRefundBandName, rate: BigDecimal, bandLimit: BigInt, apportionedBandLimit: BigInt, diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala index 26a8b607f..b257c6aaf 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedDetail.scala @@ -24,7 +24,7 @@ case class ReliefsClaimedDetail(amountClaimed: Option[BigDecimal], name: Option[String], socialEnterpriseName: Option[String], companyName: Option[String], - deficiencyReliefType: ChargeableEventGainsIncomeType, + deficiencyReliefType: Option[ChargeableEventGainsIncomeType], customerReference: Option[String]) object ReliefsClaimedDetail { diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala index 38985531c..5c7b02b9c 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} import v7.common.model.response.AllowancesReliefsAndDeductionsType -case class AllowancesReliefsAndDeductions(`type`: AllowancesReliefsAndDeductionsType, +case class AllowancesReliefsAndDeductions(`type`: Option[AllowancesReliefsAndDeductionsType], submittedTimestamp: Option[String], startDate: Option[String], endDate: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala index 89c118c74..4918e5aa5 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome import play.api.libs.json.{Format, Json} import v7.common.model.response.TypeOfDividend -case class OtherDividends(typeOfDividend: TypeOfDividend, +case class OtherDividends(typeOfDividend: Option[TypeOfDividend], customerReference: Option[String], grossAmount: Option[BigDecimal]) diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala index 362ea2d3f..84a6a3ec6 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala @@ -30,7 +30,7 @@ case class CarriedForwardLoss( taxYearClaimMade: Option[TaxYear], taxYearLossIncurred: TaxYear, currentLossValue: BigInt, - lossType: LossType + lossType: Option[LossType] ) object CarriedForwardLoss { diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala index bcd57e2f5..7056f1659 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala @@ -32,7 +32,7 @@ case class ResultOfClaimsApplied( taxYearLossIncurred: TaxYear, lossAmountUsed: BigInt, remainingLossValue: BigInt, - lossType: LossType + lossType: Option[LossType] ) object ResultOfClaimsApplied { diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala index b1fafa9ca..5edc9aacb 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala @@ -26,7 +26,7 @@ case class UnclaimedLoss( incomeSourceType: IncomeSourceType, taxYearLossIncurred: TaxYear, currentLossValue: BigInt, - lossType: LossType + lossType: Option[LossType] ) object UnclaimedLoss { diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala index 9590a1ef1..e3fd91dd5 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala @@ -17,9 +17,9 @@ package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.ShortServiceRefundBandsName +import v7.common.model.response.ShortServiceRefundBandName -case class ShortServiceRefundBands(name: ShortServiceRefundBandsName, +case class ShortServiceRefundBands(name: ShortServiceRefundBandName, rate: BigDecimal, bandLimit: BigInt, apportionedBandLimit: BigInt, diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala index 89856961f..8ac5291e5 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedDetail.scala @@ -24,7 +24,7 @@ case class ReliefsClaimedDetail(amountClaimed: Option[BigDecimal], name: Option[String], socialEnterpriseName: Option[String], companyName: Option[String], - deficiencyReliefType: ChargeableEventGainsIncomeType, + deficiencyReliefType: Option[ChargeableEventGainsIncomeType], customerReference: Option[String]) object ReliefsClaimedDetail { diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala index 37c82baab..983b49a87 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} import v7.common.model.response.AllowancesReliefsAndDeductionsType -case class AllowancesReliefsAndDeductions(`type`: AllowancesReliefsAndDeductionsType, +case class AllowancesReliefsAndDeductions(`type`: Option[AllowancesReliefsAndDeductionsType], submittedTimestamp: Option[String], startDate: Option[String], endDate: Option[String], diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/chargeableEventGainsIncome.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/chargeableEventGainsIncome.json index ec9c18e35..3459ce399 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/chargeableEventGainsIncome.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/chargeableEventGainsIncome.json @@ -25,7 +25,7 @@ "enum": [ "life-insurance", "capital-redemption", - "lifeAnnuity" + "life-annuity" ] }, "customerReference": { @@ -73,8 +73,8 @@ "enum": [ "life-insurance", "capital-redemption", - "lifeAnnuity", - "voidedIsa" + "life-annuity", + "voided-isa" ] }, "customerReference": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/reliefs.json b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/reliefs.json index f1614df7e..55d779c2a 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/reliefs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def1/calculation/reliefs.json @@ -240,7 +240,7 @@ "type": "string", "enum": [ "life-insurance", - "lifeAnnuity", + "life-annuity", "capital-redemption" ] }, diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/chargeableEventGainsIncome.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/chargeableEventGainsIncome.json index ec9c18e35..3459ce399 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/chargeableEventGainsIncome.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/chargeableEventGainsIncome.json @@ -25,7 +25,7 @@ "enum": [ "life-insurance", "capital-redemption", - "lifeAnnuity" + "life-annuity" ] }, "customerReference": { @@ -73,8 +73,8 @@ "enum": [ "life-insurance", "capital-redemption", - "lifeAnnuity", - "voidedIsa" + "life-annuity", + "voided-isa" ] }, "customerReference": { diff --git a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/reliefs.json b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/reliefs.json index 32f555564..11db6d0f8 100644 --- a/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/reliefs.json +++ b/resources/public/api/conf/7.0/schemas/retrieve/def2/calculation/reliefs.json @@ -240,7 +240,7 @@ "type": "string", "enum": [ "life-insurance", - "lifeAnnuity", + "life-annuity", "capital-redemption" ] }, diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala index 2dd676b9b..ec45826cb 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -31,7 +31,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { ) val otherModel: OtherDividends = OtherDividends( - TypeOfDividend.`stock-dividend`, + Some(TypeOfDividend.`stock-dividend`), Some("string"), Some(5000.99) ) diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala index 106788c6b..40648b8ea 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala @@ -47,7 +47,7 @@ class CarriedForwardLossSpec extends UnitSpec { taxYearClaimMade = Some(TaxYear.fromDownstream("2020")), taxYearLossIncurred = TaxYear.fromDownstream("2019"), currentLossValue = BigInt(456), - lossType = lossType + lossType = Some(LossType.`class4-nics`) ) def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): JsValue = Json.parse(s""" diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala index 2e68b198a..9b8d5e1e4 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala @@ -51,7 +51,7 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { taxYearLossIncurred = TaxYear.fromDownstream("2019"), lossAmountUsed = BigInt(123), remainingLossValue = BigInt(456), - lossType = lossType + lossType = Some(LossType.`class4-nics`) ) def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): JsValue = Json.parse(s""" diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala index 4762e9b48..6072decbe 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala @@ -39,7 +39,7 @@ class UnclaimedLossSpec extends UnitSpec { incomeSourceType = incomeSourceType, taxYearLossIncurred = TaxYear.fromDownstream("2020"), currentLossValue = BigInt(456), - lossType = lossType + lossType = Some(LossType.`class4-nics`) ) def mtdJson(incomeSourceType: IncomeSourceType, lossType: LossType): JsValue = Json.parse(s""" diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala index d6d55c937..8db163087 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -31,7 +31,7 @@ class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { ) val otherModel: OtherDividends = OtherDividends( - TypeOfDividend.`stock-dividend`, + Some(TypeOfDividend.`stock-dividend`), Some("string"), Some(5000.99) ) diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala index 1c19798b7..c57a9ff36 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala @@ -47,7 +47,7 @@ class CarriedForwardLossSpec extends UnitSpec { taxYearClaimMade = Some(TaxYear.fromDownstream("2020")), taxYearLossIncurred = TaxYear.fromDownstream("2019"), currentLossValue = BigInt(456), - lossType = lossType + lossType = Some(LossType.`class4-nics`) ) def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): JsValue = Json.parse(s""" diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala index 6c9d6465f..247bb7a34 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala @@ -51,7 +51,7 @@ class ResultOfClaimsAppliedSpec extends UnitSpec { taxYearLossIncurred = TaxYear.fromDownstream("2019"), lossAmountUsed = BigInt(123), remainingLossValue = BigInt(456), - lossType = lossType + lossType = Some(LossType.`class4-nics`) ) def mtdJson(incomeSourceType: IncomeSourceType, claimType: ClaimType, lossType: LossType): JsValue = Json.parse(s""" diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala index 72847a340..c85da3283 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala @@ -39,7 +39,7 @@ class UnclaimedLossSpec extends UnitSpec { incomeSourceType = incomeSourceType, taxYearLossIncurred = TaxYear.fromDownstream("2020"), currentLossValue = BigInt(456), - lossType = lossType + lossType = Some(LossType.`class4-nics`) ) def mtdJson(incomeSourceType: IncomeSourceType, lossType: LossType): JsValue = Json.parse(s""" From 9627f036562bd824dcc4ced55ec4013b916fe182 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 12:52:47 +0100 Subject: [PATCH 19/32] Create AllowancesReliefsAndDeductionsType rename test --- .../AllowancesReliefsAndDeductionsSpec.scala | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala diff --git a/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala new file mode 100644 index 000000000..69c52b485 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala @@ -0,0 +1,41 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.AllowancesReliefsAndDeductionsType +import v7.common.model.response.AllowancesReliefsAndDeductionsType._ + +class AllowancesReliefsAndDeductionsTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[AllowancesReliefsAndDeductionsType]( + "investmentReliefs" -> `investment-reliefs`, + "otherReliefs" -> `other-reliefs`, + "otherExpenses" -> `other-expenses`, + "otherDeductions" -> `other-deductions`, + "foreignReliefs" -> `foreign-reliefs` + ) + + testWrites[AllowancesReliefsAndDeductionsType]( + `investment-reliefs` -> "investment-reliefs", + `other-reliefs` -> "other-reliefs", + `other-expenses` -> "other-expenses", + `other-deductions` -> "other-deductions", + `foreign-reliefs` -> "foreign-reliefs" + ) +} From bcc192b3342d17e99806ea48320e43e32ef751c5 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 12:55:12 +0100 Subject: [PATCH 20/32] Tidy code alignment --- .../AllowancesReliefsAndDeductionsSpec.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala index 69c52b485..2d7e907a0 100644 --- a/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala @@ -25,17 +25,17 @@ class AllowancesReliefsAndDeductionsTypeSpec extends UnitSpec with EnumJsonSpecS testReads[AllowancesReliefsAndDeductionsType]( "investmentReliefs" -> `investment-reliefs`, - "otherReliefs" -> `other-reliefs`, - "otherExpenses" -> `other-expenses`, - "otherDeductions" -> `other-deductions`, - "foreignReliefs" -> `foreign-reliefs` + "otherReliefs" -> `other-reliefs`, + "otherExpenses" -> `other-expenses`, + "otherDeductions" -> `other-deductions`, + "foreignReliefs" -> `foreign-reliefs` ) testWrites[AllowancesReliefsAndDeductionsType]( `investment-reliefs` -> "investment-reliefs", - `other-reliefs` -> "other-reliefs", - `other-expenses` -> "other-expenses", - `other-deductions` -> "other-deductions", - `foreign-reliefs` -> "foreign-reliefs" + `other-reliefs` -> "other-reliefs", + `other-expenses` -> "other-expenses", + `other-deductions` -> "other-deductions", + `foreign-reliefs` -> "foreign-reliefs" ) } From 7e42f9d2ff779b3db98ed37ab51697d5c6b93216 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:10:21 +0100 Subject: [PATCH 21/32] Create Tests for new enum renames --- .../dividendsIncome/TypeOfDividendSpec.scala | 39 +++++++++++++++ .../SourceSpec.scala | 35 +++++++++++++ .../lossesAndClaims/LossTypeSpec.scala | 35 +++++++++++++ .../ShortServiceRefundBandNameSpec.scala | 35 +++++++++++++ .../response/inputs/InputsOtherTypeSpec.scala | 33 +++++++++++++ .../model/response/inputs/TaxRegimeSpec.scala | 37 ++++++++++++++ .../metadata/CalculationReasonSpec.scala | 49 +++++++++++++++++++ 7 files changed, 263 insertions(+) create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossTypeSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherTypeSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/inputs/TaxRegimeSpec.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/metadata/CalculationReasonSpec.scala diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala new file mode 100644 index 000000000..48e625b51 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.TypeOfDividend +import v7.common.model.response.TypeOfDividend._ + +class TypeOfDividendSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[TypeOfDividend]( + "stockDividend" -> `stock-dividend`, + "redeemableShares" -> `redeemable-shares`, + "bonusIssuesOfSecurities" -> `bonus-issues-of-securities`, + "closeCompanyLoansWrittenOff" -> `close-company-loans-written-off` + ) + + testWrites[TypeOfDividend]( + `stock-dividend` -> "stock-dividend", + `redeemable-shares` -> "redeemable-shares", + `bonus-issues-of-securities` -> "bonus-issues-of-securities", + `close-company-loans-written-off` -> "close-company-loans-written-off" + ) +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala new file mode 100644 index 000000000..5ae4a5d32 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.Source +import v7.common.model.response.Source._ + +class SourceSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[Source]( + "customer" -> `customer`, + "HMRC HELD" -> `hmrc-held` + ) + + testWrites[Source]( + `customer` -> "customer", + `hmrc-held` -> "hmrc-held" + ) +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossTypeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossTypeSpec.scala new file mode 100644 index 000000000..95a1e3002 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossTypeSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.LossType +import v7.common.model.response.LossType._ + +class LossTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[LossType]( + "income" -> `income`, + "class4nics" -> `class4-nics` + ) + + testWrites[LossType]( + `income` -> "income", + `class4-nics` -> "class4-nics" + ) +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala new file mode 100644 index 000000000..5d2b6a98f --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.ShortServiceRefundBandName +import v7.common.model.response.ShortServiceRefundBandName._ + +class ShortServiceRefundBandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[ShortServiceRefundBandName]( + "lowerBand" -> `lower-band`, + "upperBand" -> `upper-band` + ) + + testWrites[ShortServiceRefundBandName]( + `lower-band` -> "lower-band", + `upper-band` -> "upper-band" + ) +} diff --git a/test/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherTypeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherTypeSpec.scala new file mode 100644 index 000000000..29c976576 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherTypeSpec.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.InputsOtherType +import v7.common.model.response.InputsOtherType._ + +class InputsOtherTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[InputsOtherType]( + "codingOut" -> `coding-out` + ) + + testWrites[InputsOtherType]( + `coding-out` -> "coding-out" + ) +} diff --git a/test/v7/retrieveCalculation/def1/model/response/inputs/TaxRegimeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/inputs/TaxRegimeSpec.scala new file mode 100644 index 000000000..0b6d31101 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/inputs/TaxRegimeSpec.scala @@ -0,0 +1,37 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.TaxRegime +import v7.common.model.response.TaxRegime._ + +class TaxRegimeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[TaxRegime]( + "UK" -> `uk`, + "Scotland" -> `scotland`, + "Wales" -> `wales` + ) + + testWrites[TaxRegime]( + `uk` -> "uk", + `scotland` -> "scotland", + `wales` -> "wales" + ) +} diff --git a/test/v7/retrieveCalculation/def1/model/response/metadata/CalculationReasonSpec.scala b/test/v7/retrieveCalculation/def1/model/response/metadata/CalculationReasonSpec.scala new file mode 100644 index 000000000..2675f7b88 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/metadata/CalculationReasonSpec.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.metadata + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.common.model.response.CalculationReason +import v7.common.model.response.CalculationReason._ + +class CalculationReasonSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[CalculationReason]( + "customerRequest" -> `customer-request`, + "class2NICEvent" -> `class2-nic-event`, + "newLossEvent" -> `new-loss-event`, + "updatedLossEvent" -> `updated-loss-event`, + "newClaimEvent" -> `new-claim-event`, + "updatedClaimEvent" -> `updated-claim-event`, + "newAnnualAdjustmentEvent" -> `new-annual-adjustment-event`, + "updatedAnnualAdjustmentEvent" -> `updated-annual-adjustment-event`, + "unattendedCalculation" -> `unattended-calculation` + ) + + testWrites[CalculationReason]( + `customer-request` -> "customer-request", + `class2-nic-event` -> "class2-nic-event", + `new-loss-event` -> "new-loss-event", + `updated-loss-event` -> "updated-loss-event", + `new-claim-event` -> "new-claim-event", + `updated-claim-event` -> "updated-claim-event", + `new-annual-adjustment-event` -> "new-annual-adjustment-event", + `updated-annual-adjustment-event` -> "updated-annual-adjustment-event", + `unattended-calculation` -> "unattended-calculation", + ) +} From 2c0fcc17cb71b9d00e3a9c953df839745a443cdf Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:25:12 +0100 Subject: [PATCH 22/32] Reorganise TypeOfDividend Stucture --- .../dividendsIncome/OtherDividends.scala | 1 - .../dividendsIncome}/TypeOfDividend.scala | 2 +- .../dividendsIncome/OtherDividends.scala | 1 - .../dividendsIncome/TypeOfDividend.scala | 39 +++++++++++++++++++ .../dividendsIncome/DividendsIncomeSpec.scala | 2 +- .../dividendsIncome/TypeOfDividendSpec.scala | 3 +- .../dividendsIncome/DividendsIncomeSpec.scala | 2 +- .../dividendsIncome/TypeOfDividendSpec.scala | 38 ++++++++++++++++++ 8 files changed, 81 insertions(+), 7 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/calculation/dividendsIncome}/TypeOfDividend.scala (94%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/TypeOfDividend.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala index 37e0bfccf..41a06a0bb 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/OtherDividends.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome import play.api.libs.json.{Format, Json} -import v7.common.model.response.TypeOfDividend case class OtherDividends(typeOfDividend: Option[TypeOfDividend], customerReference: Option[String], diff --git a/app/v7/common/model/response/TypeOfDividend.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividend.scala similarity index 94% rename from app/v7/common/model/response/TypeOfDividend.scala rename to app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividend.scala index ac51fc4c7..27780182a 100644 --- a/app/v7/common/model/response/TypeOfDividend.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividend.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala index 4918e5aa5..21601e446 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/OtherDividends.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome import play.api.libs.json.{Format, Json} -import v7.common.model.response.TypeOfDividend case class OtherDividends(typeOfDividend: Option[TypeOfDividend], customerReference: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/TypeOfDividend.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/TypeOfDividend.scala new file mode 100644 index 000000000..13e3fe316 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/TypeOfDividend.scala @@ -0,0 +1,39 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait TypeOfDividend + +object TypeOfDividend { + case object `stock-dividend` extends TypeOfDividend + case object `redeemable-shares` extends TypeOfDividend + case object `bonus-issues-of-securities` extends TypeOfDividend + case object `close-company-loans-written-off` extends TypeOfDividend + + implicit val writes: Writes[TypeOfDividend] = Enums.writes[TypeOfDividend] + + implicit val reads: Reads[TypeOfDividend] = Enums.readsUsing { + case "stockDividend" => `stock-dividend` + case "redeemableShares" => `redeemable-shares` + case "bonusIssuesOfSecurities" => `bonus-issues-of-securities` + case "closeCompanyLoansWrittenOff" => `close-company-loans-written-off` + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala index ec45826cb..7f025656f 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome import play.api.libs.json.{JsValue, Json} import shared.models.utils.JsonErrorValidators import shared.utils.UnitSpec -import v7.common.model.response.{IncomeSourceType, TypeOfDividend} +import v7.common.model.response.IncomeSourceType class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala index 48e625b51..f62646b9d 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala @@ -18,8 +18,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.TypeOfDividend -import v7.common.model.response.TypeOfDividend._ +import v7.retrieveCalculation.def1.model.response.calculation.dividendsIncome.TypeOfDividend._ class TypeOfDividendSpec extends UnitSpec with EnumJsonSpecSupport { diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala index 8db163087..a3fc2fe5a 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/DividendsIncomeSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome import play.api.libs.json.{JsValue, Json} import shared.models.utils.JsonErrorValidators import shared.utils.UnitSpec -import v7.common.model.response.{IncomeSourceType, TypeOfDividend} +import v7.common.model.response.IncomeSourceType class DividendsIncomeSpec extends UnitSpec with JsonErrorValidators { diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala new file mode 100644 index 000000000..e38e66684 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/dividendsIncome/TypeOfDividendSpec.scala @@ -0,0 +1,38 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.dividendsIncome.TypeOfDividend._ + +class TypeOfDividendSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[TypeOfDividend]( + "stockDividend" -> `stock-dividend`, + "redeemableShares" -> `redeemable-shares`, + "bonusIssuesOfSecurities" -> `bonus-issues-of-securities`, + "closeCompanyLoansWrittenOff" -> `close-company-loans-written-off` + ) + + testWrites[TypeOfDividend]( + `stock-dividend` -> "stock-dividend", + `redeemable-shares` -> "redeemable-shares", + `bonus-issues-of-securities` -> "bonus-issues-of-securities", + `close-company-loans-written-off` -> "close-company-loans-written-off" + ) +} From b71662a55a3594c3d69e9fce58acb55cc3892821 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:34:12 +0100 Subject: [PATCH 23/32] Reorganise TaxRegime Stucture --- .../response/inputs/PersonalInformation.scala | 1 - .../model/response/inputs}/TaxRegime.scala | 2 +- .../response/inputs/PersonalInformation.scala | 1 - .../model/response/inputs/TaxRegime.scala | 37 +++++++++++++++++++ .../def1/model/Def1_CalculationFixture.scala | 1 - .../model/response/inputs/TaxRegimeSpec.scala | 4 +- .../model/response/inputs/TaxRegimeSpec.scala | 37 +++++++++++++++++++ 7 files changed, 77 insertions(+), 6 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/inputs}/TaxRegime.scala (94%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/TaxRegime.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/inputs/TaxRegimeSpec.scala diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala index 9cf6ac087..a57c48d8c 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/PersonalInformation.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.TaxRegime case class PersonalInformation(identifier: String, dateOfBirth: Option[String], diff --git a/app/v7/common/model/response/TaxRegime.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/TaxRegime.scala similarity index 94% rename from app/v7/common/model/response/TaxRegime.scala rename to app/v7/retrieveCalculation/def1/model/response/inputs/TaxRegime.scala index 97799dae4..9985847e2 100644 --- a/app/v7/common/model/response/TaxRegime.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/TaxRegime.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.inputs import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala index 44342eccc..25b1c3bbe 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/PersonalInformation.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.TaxRegime case class PersonalInformation(identifier: String, dateOfBirth: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/TaxRegime.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/TaxRegime.scala new file mode 100644 index 000000000..ec885691c --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/TaxRegime.scala @@ -0,0 +1,37 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait TaxRegime + +object TaxRegime { + case object `uk` extends TaxRegime + case object `scotland` extends TaxRegime + case object `wales` extends TaxRegime + + implicit val writes: Writes[TaxRegime] = Enums.writes[TaxRegime] + + implicit val reads: Reads[TaxRegime] = Enums.readsUsing { + case "UK" => `uk` + case "Scotland" => `scotland` + case "Wales" => `wales` + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala index c6b15fef8..8227890d3 100644 --- a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala +++ b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala @@ -21,7 +21,6 @@ import shared.models.domain.TaxYear import v7.common.model.response.CalculationType.`in-year` import v7.common.model.response.CalculationReason.`customer-request` import v7.common.model.response.IncomeSourceType -import v7.common.model.response.TaxRegime import v7.retrieveCalculation.def1.model.response.calculation.Calculation import v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome.{EmploymentAndPensionsIncome, EmploymentAndPensionsIncomeDetail} import v7.retrieveCalculation.def1.model.response.calculation.endOfYearEstimate.EndOfYearEstimate diff --git a/test/v7/retrieveCalculation/def1/model/response/inputs/TaxRegimeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/inputs/TaxRegimeSpec.scala index 0b6d31101..7537fcff3 100644 --- a/test/v7/retrieveCalculation/def1/model/response/inputs/TaxRegimeSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/inputs/TaxRegimeSpec.scala @@ -18,8 +18,8 @@ package v7.retrieveCalculation.def1.model.response.inputs import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.TaxRegime -import v7.common.model.response.TaxRegime._ +import v7.retrieveCalculation.def1.model.response.inputs.TaxRegime._ + class TaxRegimeSpec extends UnitSpec with EnumJsonSpecSupport { diff --git a/test/v7/retrieveCalculation/def2/model/response/inputs/TaxRegimeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/inputs/TaxRegimeSpec.scala new file mode 100644 index 000000000..95980ac0d --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/inputs/TaxRegimeSpec.scala @@ -0,0 +1,37 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.inputs.TaxRegime._ + + +class TaxRegimeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[TaxRegime]( + "UK" -> `uk`, + "Scotland" -> `scotland`, + "Wales" -> `wales` + ) + + testWrites[TaxRegime]( + `uk` -> "uk", + `scotland` -> "scotland", + `wales` -> "wales" + ) +} From c1c8aafb7d7f0408b0f0d79c3e89852599f0b7f6 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:39:18 +0100 Subject: [PATCH 24/32] Reorganise Source Stucture --- .../EmploymentAndPensionsIncomeDetail.scala | 1 - .../employmentAndPensionsIncome}/Source.scala | 2 +- .../EmploymentAndPensionsIncomeDetail.scala | 1 - .../employmentAndPensionsIncome/Source.scala | 36 +++++++++++++++++++ .../SourceSpec.scala | 3 +- .../SourceSpec.scala | 34 ++++++++++++++++++ 6 files changed, 72 insertions(+), 5 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome}/Source.scala (91%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/Source.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala index f4b0e2a49..b8c11df30 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome import play.api.libs.json.{Format, Json} -import v7.common.model.response.Source case class EmploymentAndPensionsIncomeDetail(incomeSourceId: Option[String], source: Option[Source], diff --git a/app/v7/common/model/response/Source.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/Source.scala similarity index 91% rename from app/v7/common/model/response/Source.scala rename to app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/Source.scala index 5cb3496d6..2afd42109 100644 --- a/app/v7/common/model/response/Source.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/Source.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala index d2bef4039..eeeaebfa4 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/EmploymentAndPensionsIncomeDetail.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome import play.api.libs.json.{Format, Json} -import v7.common.model.response.Source case class EmploymentAndPensionsIncomeDetail(incomeSourceId: Option[String], source: Option[Source], diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/Source.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/Source.scala new file mode 100644 index 000000000..6655a772f --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/Source.scala @@ -0,0 +1,36 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait Source + +object Source { + + case object `customer` extends Source + case object `hmrc-held` extends Source + + implicit val writes: Writes[Source] = Enums.writes[Source] + + implicit val reads: Reads[Source] = Enums.readsUsing[Source] { + case "customer" => `customer` + case "HMRC HELD" => `hmrc-held` + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala index 5ae4a5d32..a60b0775d 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala @@ -18,8 +18,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.employmentAndPens import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.Source -import v7.common.model.response.Source._ +import v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome.Source._ class SourceSpec extends UnitSpec with EnumJsonSpecSupport { diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala new file mode 100644 index 000000000..170d181e1 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/employmentAndPensionsIncome/SourceSpec.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.employmentAndPensionsIncome.Source._ + +class SourceSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[Source]( + "customer" -> `customer`, + "HMRC HELD" -> `hmrc-held` + ) + + testWrites[Source]( + `customer` -> "customer", + `hmrc-held` -> "hmrc-held" + ) +} From f342297d858c3e6d525c3eb4332bc50dfd3f5d6a Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:52:45 +0100 Subject: [PATCH 25/32] Reorganise ShortServiceRefundBandName Stucture --- .../ShortServiceRefundBandName.scala | 2 +- .../ShortServiceRefundBands.scala | 1 - .../ShortServiceRefundBandName.scala | 35 +++++++++++++++++++ .../ShortServiceRefundBands.scala | 1 - .../ShortServiceRefundBandNameSpec.scala | 3 +- .../ShortServiceRefundBandNameSpec.scala | 34 ++++++++++++++++++ 6 files changed, 71 insertions(+), 5 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges}/ShortServiceRefundBandName.scala (92%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandName.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala diff --git a/app/v7/common/model/response/ShortServiceRefundBandName.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandName.scala similarity index 92% rename from app/v7/common/model/response/ShortServiceRefundBandName.scala rename to app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandName.scala index a48b500db..cb885ca40 100644 --- a/app/v7/common/model/response/ShortServiceRefundBandName.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandName.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala index 6eadeb5c5..65a2bb44d 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.ShortServiceRefundBandName case class ShortServiceRefundBands(name: ShortServiceRefundBandName, rate: BigDecimal, diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandName.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandName.scala new file mode 100644 index 000000000..7633af266 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandName.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait ShortServiceRefundBandName + +object ShortServiceRefundBandName { + case object `lower-band` extends ShortServiceRefundBandName + case object `upper-band` extends ShortServiceRefundBandName + + implicit val writes: Writes[ShortServiceRefundBandName] = Enums.writes[ShortServiceRefundBandName] + + implicit val reads: Reads[ShortServiceRefundBandName] = Enums.readsUsing { + case "lowerBand" => `lower-band` + case "upperBand" => `upper-band` + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala index e3fd91dd5..a63cd2969 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBands.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.ShortServiceRefundBandName case class ShortServiceRefundBands(name: ShortServiceRefundBandName, rate: BigDecimal, diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala index 5d2b6a98f..776c2d552 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala @@ -18,8 +18,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTax import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.ShortServiceRefundBandName -import v7.common.model.response.ShortServiceRefundBandName._ +import v7.retrieveCalculation.def1.model.response.calculation.pensionSavingsTaxCharges.ShortServiceRefundBandName._ class ShortServiceRefundBandNameSpec extends UnitSpec with EnumJsonSpecSupport { diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala new file mode 100644 index 000000000..1bf5a44f9 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/pensionSavingsTaxCharges/ShortServiceRefundBandNameSpec.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.pensionSavingsTaxCharges.ShortServiceRefundBandName._ + +class ShortServiceRefundBandNameSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[ShortServiceRefundBandName]( + "lowerBand" -> `lower-band`, + "upperBand" -> `upper-band` + ) + + testWrites[ShortServiceRefundBandName]( + `lower-band` -> "lower-band", + `upper-band` -> "upper-band" + ) +} From 307eb0bdfec38896283c8c77a1cd7ca475ba4ea9 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:01:16 +0100 Subject: [PATCH 26/32] Reorganise LossType Stucture --- .../lossesAndClaims/CarriedForwardLoss.scala | 2 +- .../lossesAndClaims}/LossType.scala | 2 +- .../ResultOfClaimsApplied.scala | 2 +- .../lossesAndClaims/UnclaimedLoss.scala | 2 +- .../lossesAndClaims/CarriedForwardLoss.scala | 2 +- .../lossesAndClaims/LossType.scala | 35 +++++++++++++++++++ .../ResultOfClaimsApplied.scala | 2 +- .../lossesAndClaims/UnclaimedLoss.scala | 2 +- .../CarriedForwardLossSpec.scala | 2 +- .../lossesAndClaims/LossTypeSpec.scala | 3 +- .../ResultOfClaimsAppliedSpec.scala | 2 +- .../lossesAndClaims/UnclaimedLossSpec.scala | 2 +- .../CarriedForwardLossSpec.scala | 2 +- .../lossesAndClaims/LossTypeSpec.scala | 34 ++++++++++++++++++ .../ResultOfClaimsAppliedSpec.scala | 2 +- .../lossesAndClaims/UnclaimedLossSpec.scala | 2 +- 16 files changed, 83 insertions(+), 15 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/calculation/lossesAndClaims}/LossType.scala (92%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossType.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossTypeSpec.scala diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala index 223621cb8..54b0dc317 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} +import v7.common.model.response.{ClaimType, IncomeSourceType} case class CarriedForwardLoss( claimId: Option[String], diff --git a/app/v7/common/model/response/LossType.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossType.scala similarity index 92% rename from app/v7/common/model/response/LossType.scala rename to app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossType.scala index feb57ddd8..88c99ace7 100644 --- a/app/v7/common/model/response/LossType.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossType.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala index 39a28033d..6334e9156 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} +import v7.common.model.response.{ClaimType, IncomeSourceType} case class ResultOfClaimsApplied( claimId: Option[String], diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala index f54e9373c..190082926 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{IncomeSourceType, LossType} +import v7.common.model.response.IncomeSourceType case class UnclaimedLoss( incomeSourceId: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala index 84a6a3ec6..87ac3c34b 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLoss.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} +import v7.common.model.response.{ClaimType, IncomeSourceType} case class CarriedForwardLoss( claimId: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossType.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossType.scala new file mode 100644 index 000000000..4cb4628d2 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossType.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait LossType + +object LossType { + case object `income` extends LossType + case object `class4-nics` extends LossType + + implicit val writes: Writes[LossType] = Enums.writes[LossType] + + implicit val reads: Reads[LossType] = Enums.readsUsing { + case "income" => `income` + case "class4nics" => `class4-nics` + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala index 7056f1659..d0810fe22 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsApplied.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} +import v7.common.model.response.{ClaimType, IncomeSourceType} case class ResultOfClaimsApplied( claimId: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala index 5edc9aacb..c16ec2565 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLoss.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.json.{Format, Json, OFormat} -import v7.common.model.response.{IncomeSourceType, LossType} +import v7.common.model.response.IncomeSourceType case class UnclaimedLoss( incomeSourceId: Option[String], diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala index 40648b8ea..b9011fcc3 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} +import v7.common.model.response.{ClaimType, IncomeSourceType} class CarriedForwardLossSpec extends UnitSpec { diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossTypeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossTypeSpec.scala index 95a1e3002..2538657bc 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossTypeSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/LossTypeSpec.scala @@ -18,8 +18,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.LossType -import v7.common.model.response.LossType._ +import v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims.LossType._ class LossTypeSpec extends UnitSpec with EnumJsonSpecSupport { diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala index 9b8d5e1e4..f67d2bb37 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} +import v7.common.model.response.{ClaimType, IncomeSourceType} class ResultOfClaimsAppliedSpec extends UnitSpec { diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala index 6072decbe..14502f764 100644 --- a/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{IncomeSourceType, LossType} +import v7.common.model.response.IncomeSourceType class UnclaimedLossSpec extends UnitSpec { diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala index c57a9ff36..df82fc4cb 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/CarriedForwardLossSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} +import v7.common.model.response.{ClaimType, IncomeSourceType} class CarriedForwardLossSpec extends UnitSpec { diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossTypeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossTypeSpec.scala new file mode 100644 index 000000000..582cf2bf1 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/LossTypeSpec.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims.LossType._ + +class LossTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[LossType]( + "income" -> `income`, + "class4nics" -> `class4-nics` + ) + + testWrites[LossType]( + `income` -> "income", + `class4-nics` -> "class4-nics" + ) +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala index 247bb7a34..759a8ac14 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/ResultOfClaimsAppliedSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{ClaimType, IncomeSourceType, LossType} +import v7.common.model.response.{ClaimType, IncomeSourceType} class ResultOfClaimsAppliedSpec extends UnitSpec { diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala index c85da3283..5678f4bdb 100644 --- a/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/lossesAndClaims/UnclaimedLossSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.calculation.lossesAndClaims import play.api.libs.json.{JsValue, Json} import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{IncomeSourceType, LossType} +import v7.common.model.response.IncomeSourceType class UnclaimedLossSpec extends UnitSpec { From b5fe17dba9f639aea6c026b5b5bb7e02e94e1b5d Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:06:05 +0100 Subject: [PATCH 27/32] Reorganise InputsOtherType Stucture --- .../response/inputs}/InputsOtherType.scala | 2 +- .../def1/model/response/inputs/Other.scala | 1 - .../response/inputs/InputsOtherType.scala | 33 +++++++++++++++++++ .../def2/model/response/inputs/Other.scala | 1 - .../response/inputs/InputsOtherTypeSpec.scala | 3 +- .../response/inputs/InputsOtherTypeSpec.scala | 32 ++++++++++++++++++ 6 files changed, 67 insertions(+), 5 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/inputs}/InputsOtherType.scala (94%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/InputsOtherType.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/inputs/InputsOtherTypeSpec.scala diff --git a/app/v7/common/model/response/InputsOtherType.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherType.scala similarity index 94% rename from app/v7/common/model/response/InputsOtherType.scala rename to app/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherType.scala index 8366d9faa..c7cfb2aff 100644 --- a/app/v7/common/model/response/InputsOtherType.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherType.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.inputs import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala index dfd1f3ab7..db33766e5 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/Other.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.InputsOtherType case class Other(`type`: InputsOtherType, submittedOn: Option[String]) diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/InputsOtherType.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/InputsOtherType.scala new file mode 100644 index 000000000..c74fb7cba --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/InputsOtherType.scala @@ -0,0 +1,33 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait InputsOtherType + +object InputsOtherType { + case object `coding-out` extends InputsOtherType + + implicit val writes: Writes[InputsOtherType] = Enums.writes[InputsOtherType] + + implicit val reads: Reads[InputsOtherType] = Enums.readsUsing { + case "codingOut" => `coding-out` + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala index 089e73482..b63713a1c 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/Other.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.InputsOtherType case class Other(`type`: InputsOtherType, submittedOn: Option[String]) diff --git a/test/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherTypeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherTypeSpec.scala index 29c976576..c749fd7e6 100644 --- a/test/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherTypeSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/inputs/InputsOtherTypeSpec.scala @@ -18,8 +18,7 @@ package v7.retrieveCalculation.def1.model.response.inputs import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.InputsOtherType -import v7.common.model.response.InputsOtherType._ +import v7.retrieveCalculation.def1.model.response.inputs.InputsOtherType._ class InputsOtherTypeSpec extends UnitSpec with EnumJsonSpecSupport { diff --git a/test/v7/retrieveCalculation/def2/model/response/inputs/InputsOtherTypeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/inputs/InputsOtherTypeSpec.scala new file mode 100644 index 000000000..3be4793fa --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/inputs/InputsOtherTypeSpec.scala @@ -0,0 +1,32 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.inputs.InputsOtherType._ + +class InputsOtherTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[InputsOtherType]( + "codingOut" -> `coding-out` + ) + + testWrites[InputsOtherType]( + `coding-out` -> "coding-out" + ) +} From 1aa611ab12eb39703b3555d4eb89d4b29f7eb2bf Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:17:55 +0100 Subject: [PATCH 28/32] Reorganise CalculationReason Stucture --- .../metadata}/CalculationReason.scala | 2 +- .../model/response/metadata/Metadata.scala | 2 +- .../response/metadata/CalculationReason.scala | 49 +++++++++++++++++++ .../model/response/metadata/Metadata.scala | 2 +- .../def1/model/Def1_CalculationFixture.scala | 2 +- .../metadata/CalculationReasonSpec.scala | 3 +- .../response/metadata/MetadataSpec.scala | 2 +- .../metadata/CalculationReasonSpec.scala | 48 ++++++++++++++++++ .../response/metadata/MetadataSpec.scala | 2 +- 9 files changed, 104 insertions(+), 8 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/metadata}/CalculationReason.scala (97%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/metadata/CalculationReason.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/metadata/CalculationReasonSpec.scala diff --git a/app/v7/common/model/response/CalculationReason.scala b/app/v7/retrieveCalculation/def1/model/response/metadata/CalculationReason.scala similarity index 97% rename from app/v7/common/model/response/CalculationReason.scala rename to app/v7/retrieveCalculation/def1/model/response/metadata/CalculationReason.scala index b53c70ee1..191f9beb1 100644 --- a/app/v7/common/model/response/CalculationReason.scala +++ b/app/v7/retrieveCalculation/def1/model/response/metadata/CalculationReason.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.metadata import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala b/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala index ebed256ad..570bf96d0 100644 --- a/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala +++ b/app/v7/retrieveCalculation/def1/model/response/metadata/Metadata.scala @@ -20,7 +20,7 @@ import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.functional.syntax._ import play.api.libs.json._ -import v7.common.model.response.{CalculationType, CalculationReason} +import v7.common.model.response.CalculationType case class Metadata(calculationId: String, taxYear: TaxYear, diff --git a/app/v7/retrieveCalculation/def2/model/response/metadata/CalculationReason.scala b/app/v7/retrieveCalculation/def2/model/response/metadata/CalculationReason.scala new file mode 100644 index 000000000..a2a348fb8 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/metadata/CalculationReason.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.metadata + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait CalculationReason + +object CalculationReason { + case object `customer-request` extends CalculationReason + case object `class2-nic-event` extends CalculationReason + case object `new-loss-event` extends CalculationReason + case object `updated-loss-event` extends CalculationReason + case object `new-claim-event` extends CalculationReason + case object `updated-claim-event` extends CalculationReason + case object `new-annual-adjustment-event` extends CalculationReason + case object `updated-annual-adjustment-event` extends CalculationReason + case object `unattended-calculation` extends CalculationReason + + implicit val writes: Writes[CalculationReason] = Enums.writes[CalculationReason] + + implicit val reads: Reads[CalculationReason] = Enums.readsUsing { + case "customerRequest" => `customer-request` + case "class2NICEvent" => `class2-nic-event` + case "newLossEvent" => `new-loss-event` + case "updatedLossEvent" => `updated-loss-event` + case "newClaimEvent" => `new-claim-event` + case "updatedClaimEvent" => `updated-claim-event` + case "newAnnualAdjustmentEvent" => `new-annual-adjustment-event` + case "updatedAnnualAdjustmentEvent" => `updated-annual-adjustment-event` + case "unattendedCalculation" => `unattended-calculation` + } + +} diff --git a/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala b/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala index bf2e8d85b..31043854b 100644 --- a/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala +++ b/app/v7/retrieveCalculation/def2/model/response/metadata/Metadata.scala @@ -20,7 +20,7 @@ import common.TaxYearFormats import shared.models.domain.TaxYear import play.api.libs.functional.syntax._ import play.api.libs.json._ -import v7.common.model.response.{CalculationType, CalculationReason} +import v7.common.model.response.CalculationType case class Metadata(calculationId: String, taxYear: TaxYear, diff --git a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala index 8227890d3..d414b9854 100644 --- a/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala +++ b/test/v7/retrieveCalculation/def1/model/Def1_CalculationFixture.scala @@ -19,7 +19,6 @@ package v7.retrieveCalculation.def1.model import play.api.libs.json.{JsObject, JsValue, Json} import shared.models.domain.TaxYear import v7.common.model.response.CalculationType.`in-year` -import v7.common.model.response.CalculationReason.`customer-request` import v7.common.model.response.IncomeSourceType import v7.retrieveCalculation.def1.model.response.calculation.Calculation import v7.retrieveCalculation.def1.model.response.calculation.employmentAndPensionsIncome.{EmploymentAndPensionsIncome, EmploymentAndPensionsIncomeDetail} @@ -29,6 +28,7 @@ import v7.retrieveCalculation.def1.model.response.calculation.reliefs.{BasicRate import v7.retrieveCalculation.def1.model.response.calculation.taxCalculation.{Class2Nics, IncomeTax, Nics, TaxCalculation} import v7.retrieveCalculation.def1.model.response.calculation.taxDeductedAtSource.TaxDeductedAtSource import v7.retrieveCalculation.def1.model.response.inputs._ +import v7.retrieveCalculation.def1.model.response.metadata.CalculationReason.`customer-request` import v7.retrieveCalculation.def1.model.response.metadata.Metadata import v7.retrieveCalculation.models.response.Def1_RetrieveCalculationResponse diff --git a/test/v7/retrieveCalculation/def1/model/response/metadata/CalculationReasonSpec.scala b/test/v7/retrieveCalculation/def1/model/response/metadata/CalculationReasonSpec.scala index 2675f7b88..57164e587 100644 --- a/test/v7/retrieveCalculation/def1/model/response/metadata/CalculationReasonSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/metadata/CalculationReasonSpec.scala @@ -18,8 +18,7 @@ package v7.retrieveCalculation.def1.model.response.metadata import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.CalculationReason -import v7.common.model.response.CalculationReason._ +import v7.retrieveCalculation.def1.model.response.metadata.CalculationReason._ class CalculationReasonSpec extends UnitSpec with EnumJsonSpecSupport { diff --git a/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala b/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala index 3c9ac66f7..2fb9f341a 100644 --- a/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/metadata/MetadataSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def1.model.response.metadata import play.api.libs.json.Json import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{CalculationType, CalculationReason} +import v7.common.model.response.CalculationType class MetadataSpec extends UnitSpec { diff --git a/test/v7/retrieveCalculation/def2/model/response/metadata/CalculationReasonSpec.scala b/test/v7/retrieveCalculation/def2/model/response/metadata/CalculationReasonSpec.scala new file mode 100644 index 000000000..1420c9281 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/metadata/CalculationReasonSpec.scala @@ -0,0 +1,48 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.metadata + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.metadata.CalculationReason._ + +class CalculationReasonSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[CalculationReason]( + "customerRequest" -> `customer-request`, + "class2NICEvent" -> `class2-nic-event`, + "newLossEvent" -> `new-loss-event`, + "updatedLossEvent" -> `updated-loss-event`, + "newClaimEvent" -> `new-claim-event`, + "updatedClaimEvent" -> `updated-claim-event`, + "newAnnualAdjustmentEvent" -> `new-annual-adjustment-event`, + "updatedAnnualAdjustmentEvent" -> `updated-annual-adjustment-event`, + "unattendedCalculation" -> `unattended-calculation` + ) + + testWrites[CalculationReason]( + `customer-request` -> "customer-request", + `class2-nic-event` -> "class2-nic-event", + `new-loss-event` -> "new-loss-event", + `updated-loss-event` -> "updated-loss-event", + `new-claim-event` -> "new-claim-event", + `updated-claim-event` -> "updated-claim-event", + `new-annual-adjustment-event` -> "new-annual-adjustment-event", + `updated-annual-adjustment-event` -> "updated-annual-adjustment-event", + `unattended-calculation` -> "unattended-calculation", + ) +} diff --git a/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala b/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala index e1cb4fb11..813932ec0 100644 --- a/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala +++ b/test/v7/retrieveCalculation/def2/model/response/metadata/MetadataSpec.scala @@ -19,7 +19,7 @@ package v7.retrieveCalculation.def2.model.response.metadata import play.api.libs.json.Json import shared.models.domain.TaxYear import shared.utils.UnitSpec -import v7.common.model.response.{CalculationType, CalculationReason} +import v7.common.model.response.CalculationType class MetadataSpec extends UnitSpec { From 69e480662e5eb1476c4badb5c8122ea66e8bfb99 Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:24:02 +0100 Subject: [PATCH 29/32] Reorganise AllowancesReliefsAndDeductionsType Stucture --- .../AllowancesReliefsAndDeductions.scala | 1 - .../AllowancesReliefsAndDeductionsType.scala | 2 +- .../AllowancesReliefsAndDeductions.scala | 1 - .../AllowancesReliefsAndDeductionsType.scala | 41 +++++++++++++++++++ .../AllowancesReliefsAndDeductionsSpec.scala | 3 +- ...lowancesReliefsAndDeductionsTypeSpec.scala | 40 ++++++++++++++++++ 6 files changed, 83 insertions(+), 5 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/inputs}/AllowancesReliefsAndDeductionsType.scala (96%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductionsType.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductionsTypeSpec.scala diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala index 5c7b02b9c..658871434 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductions.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.AllowancesReliefsAndDeductionsType case class AllowancesReliefsAndDeductions(`type`: Option[AllowancesReliefsAndDeductionsType], submittedTimestamp: Option[String], diff --git a/app/v7/common/model/response/AllowancesReliefsAndDeductionsType.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsType.scala similarity index 96% rename from app/v7/common/model/response/AllowancesReliefsAndDeductionsType.scala rename to app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsType.scala index b6e494915..99ed3ea57 100644 --- a/app/v7/common/model/response/AllowancesReliefsAndDeductionsType.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsType.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.inputs import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala index 983b49a87..2a5fa1b7b 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductions.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.AllowancesReliefsAndDeductionsType case class AllowancesReliefsAndDeductions(`type`: Option[AllowancesReliefsAndDeductionsType], submittedTimestamp: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductionsType.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductionsType.scala new file mode 100644 index 000000000..f408a838f --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductionsType.scala @@ -0,0 +1,41 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait AllowancesReliefsAndDeductionsType + +object AllowancesReliefsAndDeductionsType { + case object `investment-reliefs` extends AllowancesReliefsAndDeductionsType + case object `other-reliefs` extends AllowancesReliefsAndDeductionsType + case object `other-expenses` extends AllowancesReliefsAndDeductionsType + case object `other-deductions` extends AllowancesReliefsAndDeductionsType + case object `foreign-reliefs` extends AllowancesReliefsAndDeductionsType + + implicit val writes: Writes[AllowancesReliefsAndDeductionsType] = Enums.writes[AllowancesReliefsAndDeductionsType] + + implicit val reads: Reads[AllowancesReliefsAndDeductionsType] = Enums.readsUsing { + case "investmentReliefs" => `investment-reliefs` + case "otherReliefs" => `other-reliefs` + case "otherExpenses" => `other-expenses` + case "otherDeductions" => `other-deductions` + case "foreignReliefs" => `foreign-reliefs` + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala b/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala index 2d7e907a0..719528c5c 100644 --- a/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/inputs/AllowancesReliefsAndDeductionsSpec.scala @@ -18,8 +18,7 @@ package v7.retrieveCalculation.def1.model.response.inputs import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.AllowancesReliefsAndDeductionsType -import v7.common.model.response.AllowancesReliefsAndDeductionsType._ +import v7.retrieveCalculation.def1.model.response.inputs.AllowancesReliefsAndDeductionsType._ class AllowancesReliefsAndDeductionsTypeSpec extends UnitSpec with EnumJsonSpecSupport { diff --git a/test/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductionsTypeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductionsTypeSpec.scala new file mode 100644 index 000000000..f432fe7c7 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/inputs/AllowancesReliefsAndDeductionsTypeSpec.scala @@ -0,0 +1,40 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.inputs.AllowancesReliefsAndDeductionsType._ + +class AllowancesReliefsAndDeductionsTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[AllowancesReliefsAndDeductionsType]( + "investmentReliefs" -> `investment-reliefs`, + "otherReliefs" -> `other-reliefs`, + "otherExpenses" -> `other-expenses`, + "otherDeductions" -> `other-deductions`, + "foreignReliefs" -> `foreign-reliefs` + ) + + testWrites[AllowancesReliefsAndDeductionsType]( + `investment-reliefs` -> "investment-reliefs", + `other-reliefs` -> "other-reliefs", + `other-expenses` -> "other-expenses", + `other-deductions` -> "other-deductions", + `foreign-reliefs` -> "foreign-reliefs" + ) +} From 08c9b534bdf8592edfa80e03246618cbca66068d Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:48:50 +0100 Subject: [PATCH 30/32] Reorganise PensionContributionAndChargesType Stucture --- .../PensionContributionAndCharges.scala | 1 - .../PensionContributionAndChargesType.scala | 2 +- .../PensionContributionAndCharges.scala | 1 - .../PensionContributionAndChargesType.scala | 35 +++++++++++++++++++ .../PensionContributionAndChargesSpec.scala | 35 +++++++++++++++++++ .../PensionContributionAndChargesSpec.scala | 35 +++++++++++++++++++ 6 files changed, 106 insertions(+), 3 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/inputs}/PensionContributionAndChargesType.scala (95%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndChargesType.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndChargesSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndChargesSpec.scala diff --git a/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala index ab6c88cf1..83e4bdd77 100644 --- a/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndCharges.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def1.model.response.inputs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.PensionContributionAndChargesType case class PensionContributionAndCharges(`type`: PensionContributionAndChargesType, submissionTimestamp: Option[String], diff --git a/app/v7/common/model/response/PensionContributionAndChargesType.scala b/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndChargesType.scala similarity index 95% rename from app/v7/common/model/response/PensionContributionAndChargesType.scala rename to app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndChargesType.scala index 9a2bd881d..4555d7a7d 100644 --- a/app/v7/common/model/response/PensionContributionAndChargesType.scala +++ b/app/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndChargesType.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.inputs import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala index f6c43c40b..42749fd25 100644 --- a/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndCharges.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def2.model.response.inputs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.PensionContributionAndChargesType case class PensionContributionAndCharges(`type`: PensionContributionAndChargesType, submissionTimestamp: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndChargesType.scala b/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndChargesType.scala new file mode 100644 index 000000000..381697497 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndChargesType.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait PensionContributionAndChargesType + +object PensionContributionAndChargesType { + case object `pension-reliefs` extends PensionContributionAndChargesType + case object `pension-charges` extends PensionContributionAndChargesType + + implicit val writes: Writes[PensionContributionAndChargesType] = Enums.writes[PensionContributionAndChargesType] + + implicit val reads: Reads[PensionContributionAndChargesType] = Enums.readsUsing { + case "pensionReliefs" => `pension-reliefs` + case "pensionCharges" => `pension-charges` + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndChargesSpec.scala b/test/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndChargesSpec.scala new file mode 100644 index 000000000..268e46055 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/inputs/PensionContributionAndChargesSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.inputs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def1.model.response.inputs.PensionContributionAndChargesType._ + + +class PensionContributionAndChargesSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[PensionContributionAndChargesType]( + "pensionReliefs" -> `pension-reliefs`, + "pensionCharges" -> `pension-charges` + ) + + testWrites[PensionContributionAndChargesType]( + `pension-reliefs` -> "pension-reliefs", + `pension-charges` -> "pension-charges" + ) +} diff --git a/test/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndChargesSpec.scala b/test/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndChargesSpec.scala new file mode 100644 index 000000000..d9062775e --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/inputs/PensionContributionAndChargesSpec.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.inputs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.inputs.PensionContributionAndChargesType._ + + +class PensionContributionAndChargesSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[PensionContributionAndChargesType]( + "pensionReliefs" -> `pension-reliefs`, + "pensionCharges" -> `pension-charges` + ) + + testWrites[PensionContributionAndChargesType]( + `pension-reliefs` -> "pension-reliefs", + `pension-charges` -> "pension-charges" + ) +} From d40baa7f5b624c7e9805febc82c758da29fdcc3f Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:59:42 +0100 Subject: [PATCH 31/32] Reorganise ShareSchemeDetailType Stucture --- .../ShareSchemeDetail.scala | 1 - .../ShareSchemeDetailType.scala | 2 +- .../ShareSchemeDetail.scala | 1 - .../ShareSchemeDetailType.scala | 35 +++++++++++++++++++ .../ShareSchemeDetailTypeSpec.scala | 34 ++++++++++++++++++ .../ShareSchemeDetailTypeSpec.scala | 34 ++++++++++++++++++ 6 files changed, 104 insertions(+), 3 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/calculation/shareSchemesIncome}/ShareSchemeDetailType.scala (93%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetailType.scala create mode 100644 test/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetailTypeSpec.scala create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetailTypeSpec.scala diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala index 8aa29b08e..acb2d513a 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def1.model.response.calculation.shareSchemesIncome import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.ShareSchemeDetailType case class ShareSchemeDetail(`type`: ShareSchemeDetailType, employerName: Option[String], diff --git a/app/v7/common/model/response/ShareSchemeDetailType.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetailType.scala similarity index 93% rename from app/v7/common/model/response/ShareSchemeDetailType.scala rename to app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetailType.scala index f2521e921..1e11f48fe 100644 --- a/app/v7/common/model/response/ShareSchemeDetailType.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetailType.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.calculation.shareSchemesIncome import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala index 8f8c35c3f..7c80c235b 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetail.scala @@ -17,7 +17,6 @@ package v7.retrieveCalculation.def2.model.response.calculation.shareSchemesIncome import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.ShareSchemeDetailType case class ShareSchemeDetail(`type`: ShareSchemeDetailType, employerName: Option[String], diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetailType.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetailType.scala new file mode 100644 index 000000000..87e261e70 --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetailType.scala @@ -0,0 +1,35 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.shareSchemesIncome + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait ShareSchemeDetailType + +object ShareSchemeDetailType { + case object `share-option` extends ShareSchemeDetailType + case object `shares-awarded-or-received` extends ShareSchemeDetailType + + implicit val writes: Writes[ShareSchemeDetailType] = Enums.writes[ShareSchemeDetailType] + + implicit val reads: Reads[ShareSchemeDetailType] = Enums.readsUsing { + case "shareOption" => `share-option` + case "sharesAwardedOrReceived" => `shares-awarded-or-received` + } + +} diff --git a/test/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetailTypeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetailTypeSpec.scala new file mode 100644 index 000000000..0ed937a25 --- /dev/null +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/shareSchemesIncome/ShareSchemeDetailTypeSpec.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def1.model.response.calculation.shareSchemesIncome + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def1.model.response.calculation.shareSchemesIncome.ShareSchemeDetailType._ + +class ShareSchemeDetailTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[ShareSchemeDetailType]( + "shareOption" -> `share-option`, + "sharesAwardedOrReceived" -> `shares-awarded-or-received` + ) + + testWrites[ShareSchemeDetailType]( + `share-option` -> "share-option", + `shares-awarded-or-received` -> "shares-awarded-or-received" + ) +} diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetailTypeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetailTypeSpec.scala new file mode 100644 index 000000000..2aae9932c --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/shareSchemesIncome/ShareSchemeDetailTypeSpec.scala @@ -0,0 +1,34 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.shareSchemesIncome + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.shareSchemesIncome.ShareSchemeDetailType._ + +class ShareSchemeDetailTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[ShareSchemeDetailType]( + "shareOption" -> `share-option`, + "sharesAwardedOrReceived" -> `shares-awarded-or-received` + ) + + testWrites[ShareSchemeDetailType]( + `share-option` -> "share-option", + `shares-awarded-or-received` -> "shares-awarded-or-received" + ) +} From 75eb054df883cfd3124675dd4baef853962ff85f Mon Sep 17 00:00:00 2001 From: MadStu <737342+MadStu@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:16:00 +0100 Subject: [PATCH 32/32] Reorganise ReliefsClaimedType Stucture --- .../calculation/reliefs/ReliefsClaimed.scala | 11 ++--- .../reliefs}/ReliefsClaimedType.scala | 2 +- .../calculation/reliefs/ReliefsClaimed.scala | 11 ++--- .../reliefs/ReliefsClaimedType.scala | 49 +++++++++++++++++++ .../reliefs}/ReliefsClaimedTypeSpec.scala | 8 +-- .../reliefs/ReliefsClaimedTypeSpec.scala | 49 +++++++++++++++++++ 6 files changed, 113 insertions(+), 17 deletions(-) rename app/v7/{common/model/response => retrieveCalculation/def1/model/response/calculation/reliefs}/ReliefsClaimedType.scala (97%) create mode 100644 app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedType.scala rename test/v7/{common/model/response => retrieveCalculation/def1/model/response/calculation/reliefs}/ReliefsClaimedTypeSpec.scala (92%) create mode 100644 test/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedTypeSpec.scala diff --git a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimed.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimed.scala index ceb32f5b1..9796b363f 100644 --- a/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimed.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimed.scala @@ -17,14 +17,13 @@ package v7.retrieveCalculation.def1.model.response.calculation.reliefs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.ReliefsClaimedType case class ReliefsClaimed(`type`: ReliefsClaimedType, - amountClaimed: Option[BigDecimal], - allowableAmount: Option[BigDecimal], - amountUsed: Option[BigDecimal], - rate: Option[BigDecimal], - reliefsClaimedDetail: Option[Seq[ReliefsClaimedDetail]]) + amountClaimed: Option[BigDecimal], + allowableAmount: Option[BigDecimal], + amountUsed: Option[BigDecimal], + rate: Option[BigDecimal], + reliefsClaimedDetail: Option[Seq[ReliefsClaimedDetail]]) object ReliefsClaimed { implicit val format: OFormat[ReliefsClaimed] = Json.format[ReliefsClaimed] diff --git a/app/v7/common/model/response/ReliefsClaimedType.scala b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedType.scala similarity index 97% rename from app/v7/common/model/response/ReliefsClaimedType.scala rename to app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedType.scala index b8369deaa..6d6b3641a 100644 --- a/app/v7/common/model/response/ReliefsClaimedType.scala +++ b/app/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedType.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.calculation.reliefs import common.utils.enums.Enums import play.api.libs.json.{Reads, Writes} diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimed.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimed.scala index 11f9be4f3..8be80f97b 100644 --- a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimed.scala +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimed.scala @@ -17,14 +17,13 @@ package v7.retrieveCalculation.def2.model.response.calculation.reliefs import play.api.libs.json.{Json, OFormat} -import v7.common.model.response.ReliefsClaimedType case class ReliefsClaimed(`type`: ReliefsClaimedType, - amountClaimed: Option[BigDecimal], - allowableAmount: Option[BigDecimal], - amountUsed: Option[BigDecimal], - rate: Option[BigDecimal], - reliefsClaimedDetail: Option[Seq[ReliefsClaimedDetail]]) + amountClaimed: Option[BigDecimal], + allowableAmount: Option[BigDecimal], + amountUsed: Option[BigDecimal], + rate: Option[BigDecimal], + reliefsClaimedDetail: Option[Seq[ReliefsClaimedDetail]]) object ReliefsClaimed { implicit val format: OFormat[ReliefsClaimed] = Json.format[ReliefsClaimed] diff --git a/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedType.scala b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedType.scala new file mode 100644 index 000000000..73f5d031a --- /dev/null +++ b/app/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedType.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import common.utils.enums.Enums +import play.api.libs.json.{Reads, Writes} + +sealed trait ReliefsClaimedType + +object ReliefsClaimedType { + case object `vct-subscriptions` extends ReliefsClaimedType + case object `eis-subscriptions` extends ReliefsClaimedType + case object `community-investment` extends ReliefsClaimedType + case object `seed-enterprise-investment` extends ReliefsClaimedType + case object `social-enterprise-investment` extends ReliefsClaimedType + case object `maintenance-payments` extends ReliefsClaimedType + case object `deficiency-relief` extends ReliefsClaimedType + case object `non-deductible-loan-interest` extends ReliefsClaimedType + case object `qualifying-distribution-redemption-of-shares-and-securities` extends ReliefsClaimedType + + implicit val writes: Writes[ReliefsClaimedType] = Enums.writes[ReliefsClaimedType] + + implicit val reads: Reads[ReliefsClaimedType] = Enums.readsUsing { + case "vctSubscriptions" => `vct-subscriptions` + case "eisSubscriptions" => `eis-subscriptions` + case "communityInvestment" => `community-investment` + case "seedEnterpriseInvestment" => `seed-enterprise-investment` + case "socialEnterpriseInvestment" => `social-enterprise-investment` + case "maintenancePayments" => `maintenance-payments` + case "deficiencyRelief" => `deficiency-relief` + case "nonDeductableLoanInterest" => `non-deductible-loan-interest` + case "qualifyingDistributionRedemptionOfSharesAndSecurities" => `qualifying-distribution-redemption-of-shares-and-securities` + } + +} diff --git a/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala b/test/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedTypeSpec.scala similarity index 92% rename from test/v7/common/model/response/ReliefsClaimedTypeSpec.scala rename to test/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedTypeSpec.scala index 386cb0ffd..174589f33 100644 --- a/test/v7/common/model/response/ReliefsClaimedTypeSpec.scala +++ b/test/v7/retrieveCalculation/def1/model/response/calculation/reliefs/ReliefsClaimedTypeSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2022 HM Revenue & Customs + * Copyright 2023 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,12 @@ * limitations under the License. */ -package v7.common.model.response +package v7.retrieveCalculation.def1.model.response.calculation.reliefs import shared.utils.UnitSpec import utils.enums.EnumJsonSpecSupport -import v7.common.model.response.ReliefsClaimedType._ +import v7.retrieveCalculation.def1.model.response.calculation.reliefs.ReliefsClaimedType._ + class ReliefsClaimedTypeSpec extends UnitSpec with EnumJsonSpecSupport { @@ -45,5 +46,4 @@ class ReliefsClaimedTypeSpec extends UnitSpec with EnumJsonSpecSupport { `non-deductible-loan-interest` -> "non-deductible-loan-interest", `qualifying-distribution-redemption-of-shares-and-securities` -> "qualifying-distribution-redemption-of-shares-and-securities" ) - } diff --git a/test/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedTypeSpec.scala b/test/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedTypeSpec.scala new file mode 100644 index 000000000..a2dc5ac57 --- /dev/null +++ b/test/v7/retrieveCalculation/def2/model/response/calculation/reliefs/ReliefsClaimedTypeSpec.scala @@ -0,0 +1,49 @@ +/* + * Copyright 2023 HM Revenue & Customs + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v7.retrieveCalculation.def2.model.response.calculation.reliefs + +import shared.utils.UnitSpec +import utils.enums.EnumJsonSpecSupport +import v7.retrieveCalculation.def2.model.response.calculation.reliefs.ReliefsClaimedType._ + + +class ReliefsClaimedTypeSpec extends UnitSpec with EnumJsonSpecSupport { + + testReads[ReliefsClaimedType]( + "vctSubscriptions" -> `vct-subscriptions`, + "eisSubscriptions" -> `eis-subscriptions`, + "communityInvestment" -> `community-investment`, + "seedEnterpriseInvestment" -> `seed-enterprise-investment`, + "socialEnterpriseInvestment" -> `social-enterprise-investment`, + "maintenancePayments" -> `maintenance-payments`, + "deficiencyRelief" -> `deficiency-relief`, + "nonDeductableLoanInterest" -> `non-deductible-loan-interest`, + "qualifyingDistributionRedemptionOfSharesAndSecurities" -> `qualifying-distribution-redemption-of-shares-and-securities` + ) + + testWrites[ReliefsClaimedType]( + `vct-subscriptions` -> "vct-subscriptions", + `eis-subscriptions` -> "eis-subscriptions", + `community-investment` -> "community-investment", + `seed-enterprise-investment` -> "seed-enterprise-investment", + `social-enterprise-investment` -> "social-enterprise-investment", + `maintenance-payments` -> "maintenance-payments", + `deficiency-relief` -> "deficiency-relief", + `non-deductible-loan-interest` -> "non-deductible-loan-interest", + `qualifying-distribution-redemption-of-shares-and-securities` -> "qualifying-distribution-redemption-of-shares-and-securities" + ) +}