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: alternative address is an alternative to another address #123

Closed kathryn-ods closed 3 months ago

kathryn-ods commented 3 months ago

Check: If an address in the addresses array is of type "alternative" then there is also another address in the array with a different type

On fail:

Error message: An alternative address has been provided with no primary address. Info message: Address: [address VALUE]

kathryn-ods commented 3 months ago

Original spec "If an address in the addresses array is of type "alternative" then there is also another address in the array"

2 possible edge cases here.

@kd-ods thoughts?

kathryn-ods commented 3 months ago

Valid

[
  {
    "statementId": "1dc0e987-5c57-4a1c-b3ad-61353b66a9b7",
    "declarationSubject": "c359f58d2977",
    "statementDate": "2020-03-04",
    "recordId": "c359f58d2977",
    "recordType": "entity",
    "recordDetails": {
      "isComponent": false,
      "entityType": {
        "type": "registeredEntity",
        "addresses": [
          {
            "type": "business", 
            "address": "123"
          },
          {
            "type": "alternative",
            "address": "123"
          }
        ]
      }
    }
  },
  {
    "statementId": "019a93f1-e470-42e9-957b-03559861b2e2",
    "declarationSubject": "c359f58d2977",
    "statementDate": "2020-03-04",
    "recordId": "10478c6cf6de",
    "recordType": "person",
    "recordDetails": {
      "isComponent": false,
      "personType": "knownPerson",
      "addresses": [
        {
          "type": "residence",
          "postCode": "123"
        },
        {
          "type": "alternative",
          "country": {
            "name": "United Kingdom" 
          }
        }
      ]
    }
  }
]

Invalid 1

[
  {
    "statementId": "1dc0e987-5c57-4a1c-b3ad-61353b66a9b7",
    "declarationSubject": "c359f58d2977",
    "statementDate": "2020-03-04",
    "recordId": "c359f58d2977",
    "recordType": "entity",
    "recordDetails": {
      "isComponent": false,
      "entityType": {
        "type": "registeredEntity",
        "addresses": [
          {
            "type": "alternative",
            "address": "123"
          }
        ]
      }
    }
  }
]

Invalid 2

[
  {
    "statementId": "019a93f1-e470-42e9-957b-03559861b2e2",
    "declarationSubject": "c359f58d2977",
    "statementDate": "2020-03-04",
    "recordId": "10478c6cf6de",
    "recordType": "person",
    "recordDetails": {
      "isComponent": false,
      "personType": "knownPerson",
      "addresses": [
        {
          "type": "alternative",
          "postCode": "123"
        }
      ]
    }
  }
]

Edge case 1 - alternative address & address with no type

[
  {
    "statementId": "1dc0e987-5c57-4a1c-b3ad-61353b66a9b7",
    "declarationSubject": "c359f58d2977",
    "statementDate": "2020-03-04",
    "recordId": "c359f58d2977",
    "recordType": "entity",
    "recordDetails": {
      "isComponent": false,
      "entityType": {
        "type": "registeredEntity",
        "addresses": [
          {
            "type": "alternative",
            "address": "123"
          },
          {
            "address": "1234"
          }
        ]
      }
    }
  }
]

Edge case 2 - 2 alternative addresses

[
  {
    "statementId": "019a93f1-e470-42e9-957b-03559861b2e2",
    "declarationSubject": "c359f58d2977",
    "statementDate": "2020-03-04",
    "recordId": "10478c6cf6de",
    "recordType": "person",
    "recordDetails": {
      "isComponent": false,
      "personType": "knownPerson",
      "addresses": [
        {
          "type": "alternative",
          "postCode": "123"
        },
        {
          "type": "alternative",
          "country": {
            "name": "United Kingdom" 
          }
        }
      ]
    }
  }
]
kd-ods commented 3 months ago

@kathryn-ods

Is it sensible to be applying these kind of constraints at all when type isn't a required field??

Good point. tbh, it's made me think that 'alternative' is just an unhelpful code. We should probably turn it into 'other', make the field required and reduce constraints. I can't see that loosening constraints would open up any particular loophole wrt BO verification. (For example, I don't imagine that red-flagging would depend on categorisation of addresses: if a BODS statement from one source categorised an entity's address as 'business' but the same entity's address in another source was categorised as 'other' that would not be of great interest. The address itself is the target of interest.)

Depending on what you think about the above, Kathryn, we may want to NOT work on this check during this round of work, pending a review of address type codes in the data standard.

kathryn-ods commented 3 months ago

We should probably turn it into 'other', make the field required and reduce constraints.

Yes I think this is sensible. I'm happy to leave this check out for now.

Do we already have an appropriate ticket to document this suggestion against?

kathryn-ods commented 3 months ago

I have added a new ticket here https://github.com/openownership/data-standard/issues/725