Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

PSR-1567 Made pre-populated other asset fields optional #135

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import java.time.LocalDate

case class EtmpOtherAssets(
recordVersion: Option[String],
otherAssetsWereHeld: String,
otherAssetsWereDisposed: String,
otherAssetsWereHeld: Option[String],
otherAssetsWereDisposed: Option[String],
noOfTransactions: Option[Int],
otherAssetTransactions: Option[Seq[EtmpOtherAssetTransaction]]
)
Expand All @@ -38,8 +38,8 @@ case class EtmpOtherAssetTransaction(
acquiredFromType: Option[EtmpIdentityType],
connectedStatus: Option[String],
supportedByIndepValuation: Option[String],
movableSchedule29A: String,
totalIncomeOrReceipts: Double,
movableSchedule29A: Option[String],
totalIncomeOrReceipts: Option[Double],
assetsDisposed: Option[Seq[EtmpAssetsDisposed]]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import java.time.LocalDate

case class OtherAssets(
recordVersion: Option[String],
otherAssetsWereHeld: Boolean,
otherAssetsWereDisposed: Boolean,
optOtherAssetsWereHeld: Option[Boolean],
optOtherAssetsWereDisposed: Option[Boolean],
otherAssetTransactions: Seq[OtherAssetTransaction]
)

Expand All @@ -37,8 +37,8 @@ case class OtherAssetTransaction(
optPropertyAcquiredFrom: Option[PropertyAcquiredFrom],
optConnectedStatus: Option[Boolean],
optIndepValuationSupport: Option[Boolean],
movableSchedule29A: Boolean,
totalIncomeOrReceipts: Double,
optMovableSchedule29A: Option[Boolean],
optTotalIncomeOrReceipts: Option[Double],
optOtherAssetDisposed: Option[Seq[OtherAssetDisposed]]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ class AssetsFromEtmp @Inject() extends Transformer {
optOtherAssets = assets.otherAssets.map(otherAssets =>
OtherAssets(
recordVersion = otherAssets.recordVersion,
otherAssetsWereHeld = fromYesNo(otherAssets.otherAssetsWereHeld),
otherAssetsWereDisposed = fromYesNo(otherAssets.otherAssetsWereDisposed),
optOtherAssetsWereHeld = otherAssets.otherAssetsWereHeld.map(fromYesNo),
optOtherAssetsWereDisposed = otherAssets.otherAssetsWereDisposed.map(fromYesNo),
otherAssetTransactions = otherAssets.otherAssetTransactions
.getOrElse(Seq.empty)
.map(oa =>
Expand All @@ -198,8 +198,8 @@ class AssetsFromEtmp @Inject() extends Transformer {
},
optConnectedStatus = oa.connectedStatus.map(_ == Connected),
optIndepValuationSupport = oa.supportedByIndepValuation.map(fromYesNo),
movableSchedule29A = fromYesNo(oa.movableSchedule29A),
totalIncomeOrReceipts = oa.totalIncomeOrReceipts,
optMovableSchedule29A = oa.movableSchedule29A.map(fromYesNo),
optTotalIncomeOrReceipts = oa.totalIncomeOrReceipts,
optOtherAssetDisposed = oa.assetsDisposed.map(
_.map(oad =>
OtherAssetDisposed(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,14 @@ class AssetsToEtmp @Inject() extends Transformer {
otherAssets = assets.optOtherAssets.map(otherAssets =>
EtmpOtherAssets(
recordVersion = otherAssets.recordVersion,
otherAssetsWereHeld = toYesNo(otherAssets.otherAssetsWereHeld),
otherAssetsWereDisposed = toYesNo(otherAssets.otherAssetsWereDisposed),
noOfTransactions = Option.when(otherAssets.otherAssetsWereHeld)(otherAssets.otherAssetTransactions.size),
otherAssetTransactions = Option.when(otherAssets.otherAssetsWereHeld)(
otherAssetsWereHeld = otherAssets.optOtherAssetsWereHeld.map(toYesNo),
otherAssetsWereDisposed = otherAssets.optOtherAssetsWereDisposed.map(toYesNo),
noOfTransactions =
Option.when(otherAssets.optOtherAssetsWereHeld.getOrElse(false))(otherAssets.otherAssetTransactions.size),
otherAssetTransactions = Option.when(
otherAssets.otherAssetTransactions.nonEmpty ||
(otherAssets.optOtherAssetsWereHeld.nonEmpty && otherAssets.optOtherAssetsWereHeld.get)
)(
otherAssets.otherAssetTransactions.map(otherAssetTransaction =>
EtmpOtherAssetTransaction(
assetDescription = otherAssetTransaction.assetDescription,
Expand All @@ -213,8 +217,8 @@ class AssetsToEtmp @Inject() extends Transformer {
),
connectedStatus = otherAssetTransaction.optConnectedStatus.map(transformToEtmpConnectedPartyStatus),
supportedByIndepValuation = otherAssetTransaction.optIndepValuationSupport.map(toYesNo),
movableSchedule29A = toYesNo(otherAssetTransaction.movableSchedule29A),
totalIncomeOrReceipts = otherAssetTransaction.totalIncomeOrReceipts,
movableSchedule29A = otherAssetTransaction.optMovableSchedule29A.map(toYesNo),
totalIncomeOrReceipts = otherAssetTransaction.optTotalIncomeOrReceipts,
assetsDisposed = otherAssetTransaction.optOtherAssetDisposed
.map(
_.map(otherAssetDisposed =>
Expand Down
20 changes: 10 additions & 10 deletions test-utils/utils/TestValues.scala
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ trait TestValues {
optOtherAssets = Some(
OtherAssets(
recordVersion = Some("001"),
otherAssetsWereHeld = true,
otherAssetsWereDisposed = true,
optOtherAssetsWereHeld = Some(true),
optOtherAssetsWereDisposed = Some(true),
otherAssetTransactions = Seq(
OtherAssetTransaction(
assetDescription = "assetDescription",
Expand All @@ -272,8 +272,8 @@ trait TestValues {
optPropertyAcquiredFrom = None,
optConnectedStatus = None,
optIndepValuationSupport = None,
movableSchedule29A = true,
totalIncomeOrReceipts = Double.MaxValue,
optMovableSchedule29A = Some(true),
optTotalIncomeOrReceipts = Some(Double.MaxValue),
optOtherAssetDisposed = Some(
Seq(
OtherAssetDisposed(
Expand Down Expand Up @@ -637,8 +637,8 @@ trait TestValues {
otherAssets = Some(
EtmpOtherAssets(
recordVersion = None,
otherAssetsWereHeld = "otherAssetsWereHeld",
otherAssetsWereDisposed = "otherAssetsWereDisposed",
otherAssetsWereHeld = Some("otherAssetsWereHeld"),
otherAssetsWereDisposed = Some("otherAssetsWereDisposed"),
noOfTransactions = None,
otherAssetTransactions = None
)
Expand Down Expand Up @@ -1045,8 +1045,8 @@ trait TestValues {
otherAssets = Some(
EtmpOtherAssets(
recordVersion = Some("002"),
otherAssetsWereHeld = "Yes",
otherAssetsWereDisposed = "No",
otherAssetsWereHeld = Some("Yes"),
otherAssetsWereDisposed = Some("No"),
noOfTransactions = Some(1),
otherAssetTransactions = Some(
Seq(
Expand All @@ -1066,8 +1066,8 @@ trait TestValues {
),
connectedStatus = Some("01"),
supportedByIndepValuation = Some("No"),
movableSchedule29A = "No",
totalIncomeOrReceipts = Double.MaxValue,
movableSchedule29A = Some("No"),
totalIncomeOrReceipts = Some(Double.MaxValue),
assetsDisposed = Some(
Seq(
EtmpAssetsDisposed(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ body:json {
]
},
"optOtherAssets": {
"otherAssetsWereHeld": true,
"otherAssetsWereDisposed": false,
"optOtherAssetsWereHeld": true,
"optOtherAssetsWereDisposed": false,
"otherAssetTransactions": [
{
"assetDescription": "Test asset",
Expand All @@ -308,8 +308,8 @@ body:json {
},
"optConnectedStatus": false,
"optIndepValuationSupport": false,
"movableSchedule29A": false,
"totalIncomeOrReceipts": 34.56,
"optMovableSchedule29A": false,
"optTotalIncomeOrReceipts": 34.56,
"optOtherAssetDisposed": [
{
"methodOfDisposal": "Sold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ body:json {
},
"optOtherAssets": {
"recordVersion": "001",
"otherAssetsWereHeld": true,
"otherAssetsWereDisposed": false,
"optOtherAssetsWereHeld": true,
"optOtherAssetsWereDisposed": false,
"otherAssetTransactions": [
{
"assetDescription": "Test asset",
Expand All @@ -314,8 +314,8 @@ body:json {
},
"optConnectedStatus": false,
"optIndepValuationSupport": false,
"movableSchedule29A": false,
"totalIncomeOrReceipts": 34.56,
"optMovableSchedule29A": false,
"optTotalIncomeOrReceipts": 34.56,
"optOtherAssetDisposed": [
{
"methodOfDisposal": "Sold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ body:json {
"checkReturnDates": true,
"assets": {
"optOtherAssets": {
"otherAssetsWereHeld": true,
"otherAssetsWereDisposed": false,
"optOtherAssetsWereHeld": true,
"optOtherAssetsWereDisposed": false,
"otherAssetTransactions": [
{
"assetDescription": "Test asset",
Expand All @@ -62,8 +62,8 @@ body:json {
},
"optConnectedStatus": false,
"optIndepValuationSupport": false,
"movableSchedule29A": false,
"totalIncomeOrReceipts": 34.56,
"optMovableSchedule29A": false,
"optTotalIncomeOrReceipts": 34.56,
"optOtherAssetDisposed": [
{
"methodOfDisposal": "Sold",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ body:json {
]
},
"optOtherAssets": {
"otherAssetsWereHeld": true,
"otherAssetsWereDisposed": false,
"otherAssetTransactions": [
{
"assetDescription": "Test asset",
Expand All @@ -192,9 +190,7 @@ body:json {
"otherDescription": "gfhfghfghf"
},
"optConnectedStatus": false,
"optIndepValuationSupport": false,
"movableSchedule29A": false,
"totalIncomeOrReceipts": 34.56
"optIndepValuationSupport": false
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"reportDetails": {
"psrStatus": "Compiled",
"periodStart": "2022-04-06",
"periodEnd": "2023-04-05"
},
"accountingPeriodDetails": {
"recordVersion": "002",
"accountingPeriods": [
{
"accPeriodStart": "2022-04-06",
"accPeriodEnd": "2022-12-31"
},
{
"accPeriodStart": "2023-01-01",
"accPeriodEnd": "2023-04-05"
}
]
},
"schemeDesignatory": {
"recordVersion": "002",
"openBankAccount": "Yes",
"noOfActiveMembers": 5,
"noOfDeferredMembers": 2,
"noOfPensionerMembers": 10,
"totalAssetValueStart": 10000000,
"totalAssetValueEnd": 11000000,
"totalCashStart": 2500000,
"totalCashEnd": 2800000,
"totalPayments": 2000000
},
"assets": {
"otherAssets": {
"recordVersion": "002",
"noOfTransactions": 2,
"otherAssetTransactions": [
{
"assetDescription": "Box of matches",
"methodOfHolding": "02",
"dateOfAcqOrContrib": "2022-09-30",
"costOfAsset": 100000,
"acquiredFromName": "Dodgy Den Match Co.",
"acquiredFromType": {
"indivOrOrgType": "04",
"idNumber": "TS315528"
},
"connectedStatus": "01",
"supportedByIndepValuation": "No"
},
{
"assetDescription": "10kg Gold bars",
"methodOfHolding": "03",
"dateOfAcqOrContrib": "2023-04-30",
"costOfAsset": 2400000,
"acquiredFromName": "GoldBullion.co.uk",
"acquiredFromType": {
"indivOrOrgType": "02",
"idNumber": "SC123456"
},
"connectedStatus": "02",
"supportedByIndepValuation": "No"
}
]
}
}
}
25 changes: 2 additions & 23 deletions test/resources/api-1999-valid-example-optional-fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,6 @@
},
"otherAssets": {
"recordVersion": "002",
"otherAssetsWereHeld": "Yes",
"otherAssetsWereDisposed": "No",
"noOfTransactions": 2,
"otherAssetTransactions": [
{
Expand All @@ -476,24 +474,7 @@
"idNumber": "TS315528"
},
"connectedStatus": "01",
"supportedByIndepValuation": "No",
"movableSchedule29A": "No",
"totalIncomeOrReceipts": 0,
"assetsDisposed": [
{
"methodOfDisposal": "01",
"dateSold": "2022-12-30",
"purchaserName": "Acme Express Ltd.",
"purchaserType": {
"indivOrOrgType": "04",
"otherDescription": "Foreign purchaser"
},
"totalAmountReceived": 150000,
"connectedStatus": "02",
"supportedByIndepValuation": "Yes",
"fullyDisposedOf": "Yes"
}
]
"supportedByIndepValuation": "No"
},
{
"assetDescription": "10kg Gold bars",
Expand All @@ -506,9 +487,7 @@
"idNumber": "SC123456"
},
"connectedStatus": "02",
"supportedByIndepValuation": "No",
"movableSchedule29A": "No",
"totalIncomeOrReceipts": 0
"supportedByIndepValuation": "No"
}
]
}
Expand Down
Loading