openownership / lib-cove-bods

Check that your data complies with the Beneficial Ownership Data Standard (BODS) using our install our data review library to analyse files via your command line interface
https://datareview.openownership.org/
Other
1 stars 0 forks source link

Additional check: isComponent and person statements #132

Closed kathryn-ods closed 2 months ago

kathryn-ods commented 3 months ago

I think it will make sense to combine these into one check as they're interlinked

Check:

Where isComponent is 'true': (1) the recordId of this person MUST be an element in the componentRecords array of that primary Relationship Statement,

and

Where isComponent is 'true': (2) this Person Statement MUST come before that primary Relationship Statement in a BODS package or stream

On fail: Error message - Statement is set as component of primary relationship statement. The record identifier of this Statement must be in the Component Statements array of the primary statement. Component Statements must be before the primary Relationship Statement in the statement series. Info message - Statement identifier [value]

kathryn-ods commented 3 months ago

isComponent is unlikely to ever be true for a personStatement so this is redundant

kathryn-ods commented 3 months ago

Ok functionally this test probably won't ever be applied but we already have tests statement_is_component_but_not_used_in_component_statement_ids and statement_is_component_but_is_after_use_in_component_statement_id so I will make some passable test data but it won't be practically meaningful. We probably need to consider the us of isComponent more widely. I will check whether there is already a ticket for this

kathryn-ods commented 3 months ago

Valid (but nonsensical) data

[
  {
    "statementId": "8729fec1-eb01-4866-ba40-dd5525d43db8",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "ad3f6c2fcc9e",
    "recordStatus": "new",
    "recordType": "entity",
    "recordDetails": {
      "isComponent": false,
      "entityType": {
        "type": "registeredEntity"
      }
    }
  },
  {
    "statementId": "6b9cfb52-505a-49cb-ab02-cc856a4e5c66",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "c25d4d612c2c",
    "recordStatus": "new",
    "recordType": "person",
    "recordDetails": {
      "isComponent": true,
      "personType": "knownPerson"
    }
  },
  {
    "statementId": "cdb6acc7-426e-4a7a-9410-895d556fd329",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "d8d75ccf40e4",
    "recordStatus": "new",
    "recordType": "relationship",
    "recordDetails": {
      "isComponent": false,
      "subject": "ad3f6c2fcc9e",
      "interestedParty": "c25d4d612c2c",
      "componentRecords": [
        "c25d4d612c2c"
      ]
    }
  }
]

Invalid data - primary record before component record

[
  {
    "statementId": "8729fec1-eb01-4866-ba40-dd5525d43db8",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "ad3f6c2fcc9e",
    "recordStatus": "new",
    "recordType": "entity",
    "recordDetails": {
      "isComponent": false,
      "entityType": {
        "type": "registeredEntity"
      }
    }
  },
  {
    "statementId": "cdb6acc7-426e-4a7a-9410-895d556fd329",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "d8d75ccf40e4",
    "recordStatus": "new",
    "recordType": "relationship",
    "recordDetails": {
      "isComponent": false,
      "subject": "ad3f6c2fcc9e",
      "interestedParty": "c25d4d612c2c",
      "componentRecords": [
        "ad3f6c2fcc9e"
      ]
    }
  },
  {
    "statementId": "6b9cfb52-505a-49cb-ab02-cc856a4e5c66",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "c25d4d612c2c",
    "recordStatus": "new",
    "recordType": "person",
    "recordDetails": {
      "isComponent": true,
      "personType": "knownPerson"
    }
  }
]

Invalid data 2 - component record id not in componentRecords

[
  {
    "statementId": "8729fec1-eb01-4866-ba40-dd5525d43db8",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "ad3f6c2fcc9e",
    "recordStatus": "new",
    "recordType": "entity",
    "recordDetails": {
      "isComponent": false,
      "entityType": {
        "type": "registeredEntity"
      }
    }
  },
  {
    "statementId": "6b9cfb52-505a-49cb-ab02-cc856a4e5c66",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "c25d4d612c2c",
    "recordStatus": "new",
    "recordType": "person",
    "recordDetails": {
      "isComponent": true,
      "personType": "knownPerson"
    }
  },
  {
    "statementId": "cdb6acc7-426e-4a7a-9410-895d556fd329",
    "declarationSubject": "ad3f6c2fcc9e",
    "statementDate": "2018-12-17",
    "recordId": "d8d75ccf40e4",
    "recordStatus": "new",
    "recordType": "relationship",
    "recordDetails": {
      "isComponent": false,
      "subject": "ad3f6c2fcc9e",
      "interestedParty": "c25d4d612c2c",
      "componentRecords": [
      ]
    }
  }
]
radix0000 commented 2 months ago

@kathryn-ods @kd-ods Is the valid data actually wrong ("c25d4d612c2c" isn't in "componentRecords")?

kathryn-ods commented 2 months ago

@radix0000 yes apologies! I have updated now