HAALCENTRAAL English translation
BRP API / Bewoning / Features / stap-definities

Step definitions

#language: en

@stap-documentatie
Feature: Step definitions

  In order to be able to write scenarios for the BRP APIs, this feature describes which SQL statements are generated and executed for a Given step.
  These SQL statements are in the table of the 'Dan zijn de gegenereerde SQL statements' step. Each row in the table indicates
  - which Given step the SQL statement belongs to (the stap column indicates the step within the scenario: 1 = 1st step, 2 = 2nd step, etc.)
  - which BRP category the SQL statement belongs to (the categorie column)
  - what the SQL statement is (the text column)
  - which values are passed when the SQL statement is executed (the values column)

  Background:
    Given the 1st 'SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres' statement has the result '4999'
    And the 2nd 'SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres' statement has the result '5000'
    And the 3rd 'SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres' statement has the result '5001'
    And the 1st 'SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl' statement has the result '9999'
    And the 2nd 'SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl' statement has the result '10000'
    And the 3rd 'SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl' statement has the result '10001'

Rule: Given the person with citizen service number '<bsn>' has the following '<categorie>' data

  Scenario: The person has 'inschrijving' data
    Given the person with citizen service number '000000012' has the following 'inschrijving' data
    | indicatie geheim (70.10) | aanduiding uitgesloten kiesrecht (38.10) |
    | 7                        | A                                        |
    Then the generated SQL statements are
    | stap | categorie    | text                                                                                                                                                                            | values               |
    | 1    | inschrijving | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind,kiesrecht_uitgesl_aand) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1,$2) RETURNING * | 7,A                  |
    |      | persoon      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                                                | 9999,0,0,P,000000012 |

  Scenario: The person has 'kiesrecht' data
    kiesrecht is not an existing BRP category
    kiesrecht data is recorded under the category inschrijving; kiesrecht is used as an alias for the category inschrijving for the sake of clarity

    Given the person with citizen service number '000000012' has the following 'kiesrecht' data
    | aanduiding uitgesloten kiesrecht (38.10) |
    | A                                        |
    Then the generated SQL statements are
    | stap | categorie    | text                                                                                                                                                                            | values               |
    | 1    | inschrijving | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind,kiesrecht_uitgesl_aand) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1,$2) RETURNING * | 0,A                  |
    |      | persoon      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                                                | 9999,0,0,P,000000012 |

  Scenario: The person has 'gezagsverhouding' data
    Given the person with citizen service number '000000012' has the following 'gezagsverhouding' data
    | indicatie gezag minderjarige (32.10) |
    | 12                                   |
    Then the generated SQL statements are
    | stap | categorie        | text                                                                                                                                                  | values               |
    | 1    | inschrijving     | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                    |
    |      | persoon          | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012 |
    |      | gezagsverhouding | INSERT INTO public.lo3_pl_gezagsverhouding(pl_id,volg_nr,minderjarig_gezag_ind) VALUES($1,$2,$3)                                                      | 9999,0,12            |

  Scenario: The person has 'inschrijving' and 'gezagsverhouding' data
    Given the person with citizen service number '000000012' has the following 'inschrijving' data
    | indicatie geheim (70.10) | aanduiding uitgesloten kiesrecht (38.10) |
    | 7                        | A                                        |
    And the person has the following 'gezagsverhouding' data
    | indicatie gezag minderjarige (32.10) |
    | 12                                   |
    Then the generated SQL statements are
    | stap | categorie        | text                                                                                                                                                                            | values               |
    | 1    | inschrijving     | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind,kiesrecht_uitgesl_aand) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1,$2) RETURNING * | 7,A                  |
    |      | persoon          | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                                                | 9999,0,0,P,000000012 |
    |      | gezagsverhouding | INSERT INTO public.lo3_pl_gezagsverhouding(pl_id,volg_nr,minderjarig_gezag_ind) VALUES($1,$2,$3)                                                                                | 9999,0,12            |

  Scenario: an address
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    Then the generated SQL statements are
    | stap | categorie | text                                                                                                                                  | values    |
    | 1    | adres-A1  | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING * | Boterdiep |

  Scenario: several addresses
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And address 'A2' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    Then the generated SQL statements are
    | stap | categorie | text                                                                                                                                                 | values           |
    | 1    | adres-A1  | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                | Boterdiep        |
    |      | adres-A2  | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING * | 0800010011067001 |

  Scenario: a registration at an address
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                 |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep              |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                      |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012   |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,W,20230102 |

  Scenario: several registrations at an address
    Given address 'A1' has the following data
    | naam               | waarde    |
    | straatnaam (11.10) | Boterdiep |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    And the person with citizen service number '000000013' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230203                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                  |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep               |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                       |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012    |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,W,20230102  |
    | 3    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                       |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 10000,0,0,P,000000013   |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 10000,4999,0,W,20230203 |

  Scenario: a move
    Given address 'A1' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    And address 'A2' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067002                         |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    And the person was subsequently registered at address 'A2' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230601                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                 |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *  | 0800010011067001       |
    |      | adres-A2       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *  | 0800010011067002       |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                      |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012   |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,1,W,20230102 |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,5000,0,W,20230601 |

  Scenario: many registrations at an address
    Given address 'A1' has the following data
    | naam               | waarde    |
    | straatnaam (11.10) | Boterdiep |
    And 3 persons are registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                  |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep               |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                       |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000001    |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,W,20230102  |
    | 3    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                       |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 10000,0,0,P,000000002   |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 10000,4999,0,W,20230102 |
    | 4    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                       |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 10001,0,0,P,000000003   |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 10001,4999,0,W,20230102 |

  Scenario: an address is updated
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And address 'A1' was updated on '2023-02-03' with the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    Then the generated SQL statements are
    | stap | categorie | text                                                                                                                                                                | values                     |
    | 1    | adres-A1  | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                               | Boterdiep                  |
    |      | adres-2   | INSERT INTO public.lo3_adres(adres_id,straat_naam,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING * | Boterdiep,0800010011067001 |

  Scenario: a registration at an address with an identification that is updated
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20220102                           |
    And address 'A1' was updated on '2023-02-03' with the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                                | values                     |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                               | Boterdiep                  |
    |      | adres-2        | INSERT INTO public.lo3_adres(adres_id,straat_naam,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING * | Boterdiep,0800010011067001 |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING *               | 0                          |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                                    | 9999,0,0,P,000000012       |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                                      | 9999,4999,1,W,20220102     |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum,aangifte_adreshouding_oms) VALUES($1,$2,$3,$4,$5,$6)         | 9999,5000,0,W,20230203,T   |

  Scenario: a registration at an address with an identification that is merged
    Given address 'A1' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20220102                           |
    And address 'A1' was merged on '2023-02-03' into address 'A2' with the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067002                         |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                        | values                   |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *        | 0800010011067001         |
    |      | adres-A2       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *        | 0800010011067002         |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING *       | 0                        |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                            | 9999,0,0,P,000000012     |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                              | 9999,4999,1,W,20220102   |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum,aangifte_adreshouding_oms) VALUES($1,$2,$3,$4,$5,$6) | 9999,5000,0,W,20230203,W |

  Scenario: a registration at several addresses with identifications that are merged
    Given address 'A1' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20220102                           |
    Given address 'A2' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067002                         |
    And the person with citizen service number '000000024' is registered at address 'A2' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20211201                           |
    And the addresses 'A1, A2' were merged on '2023-02-03' into address 'A3' with the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067003                         |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                        | values                    |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *        | 0800010011067001          |
    |      | adres-A2       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *        | 0800010011067002          |
    |      | adres-A3       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *        | 0800010011067003          |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING *       | 0                         |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                            | 9999,0,0,P,000000012      |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                              | 9999,4999,1,W,20220102    |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum,aangifte_adreshouding_oms) VALUES($1,$2,$3,$4,$5,$6) | 9999,5001,0,W,20230203,W  |
    | 3    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING *       | 0                         |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                            | 10000,0,0,P,000000024     |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                              | 10000,5000,1,W,20211201   |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum,aangifte_adreshouding_oms) VALUES($1,$2,$3,$4,$5,$6) | 10000,5001,0,W,20230203,W |

  Scenario: an address with an identification is split
    Given address 'A1' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    And address 'A1' has been split into addresses with the following data
    | adres | identificatiecode verblijfplaats (11.80) |
    | A2    | 0800010011067002                         |
    | A3    | 0800010011067003                         |
    Then the generated SQL statements are
    | stap | categorie | text                                                                                                                                                 | values           |
    | 1    | adres-A1  | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING * | 0800010011067001 |
    |      | adres-A2  | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING * | 0800010011067002 |
    |      | adres-A3  | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING * | 0800010011067003 |

  Scenario: an emigration
    Given address 'A1' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20220102                           |
    And the 'verblijfplaats' has been changed to the following data
    | land (13.10) | datum aanvang adres buitenland (13.20) |
    | 5010         | 20230526                               |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                 |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *  | 0800010011067001       |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                      |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012   |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,1,W,20220102 |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,volg_nr,vertrek_land_code,vertrek_datum) VALUES($1,$2,$3,$4)                                           | 9999,0,5010,20230526   |

  Scenario: a municipality
    Given municipality 'G1' has the following data
    | gemeentecode (92.10) | gemeentenaam (92.11) |
    | 9999                 | Ons Dorp             |
    Then the generated SQL statements are
    | stap | categorie   | text                                                                       | values        |
    | 1    | gemeente-G1 | INSERT INTO public.lo3_gemeente(gemeente_code,gemeente_naam) VALUES($1,$2) | 9999,Ons Dorp |

  Scenario: a municipality that has been merged
    Given municipality 'G1' has the following data
    | gemeentecode (92.10) | gemeentenaam (92.11) |
    | 9999                 | Ons Dorp             |
    And municipality 'G1' has been merged with the following data
    | nieuwe gemeentecode (92.12) | datum beëindiging (99.99) |
    | 0800                        | 20230526                  |
    Then the generated SQL statements are
    | stap | categorie   | text                                                                                                                         | values                      |
    | 1    | gemeente-G1 | INSERT INTO public.lo3_gemeente(gemeente_code,gemeente_naam,nieuwe_gemeente_code,tabel_regel_eind_datum) VALUES($1,$2,$3,$4) | 9999,Ons Dorp,0800,20230526 |

  Scenario: a municipality with an address that has been merged
    Given municipality 'G1' has the following data
    | gemeentecode (92.10) | gemeentenaam (92.11) |
    | 9999                 | Ons Dorp             |
    And address 'A1' has the following data
    | gemeentecode (92.10) | identificatiecode verblijfplaats (11.80) |
    | 9999                 | 9999010000000003                         |
    And municipality 'G1' has been merged with the following data
    | nieuwe gemeentecode (92.12) | datum beëindiging (99.99) |
    | 0800                        | 20230526                  |
    Then the generated SQL statements are
    | stap | categorie   | text                                                                                                                                                                  | values                      |
    | 1    | gemeente-G1 | INSERT INTO public.lo3_gemeente(gemeente_code,gemeente_naam,nieuwe_gemeente_code,tabel_regel_eind_datum) VALUES($1,$2,$3,$4)                                          | 9999,Ons Dorp,0800,20230526 |
    | 2    | adres-A1    | INSERT INTO public.lo3_adres(adres_id,gemeente_code,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING * | 9999,9999010000000003       |
    |      | adres-2     | INSERT INTO public.lo3_adres(adres_id,gemeente_code,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING * | 0800,9999010000000003       |

  Scenario: a municipality with a verblijfplaats that has been merged
    Given municipality 'G1' has the following data
    | gemeentecode (92.10) | gemeentenaam (92.11) |
    | 9000                 | Ons Dorp             |
    And address 'A1' has the following data
    | gemeentecode (92.10) | identificatiecode verblijfplaats (11.80) |
    | 9000                 | 9999010000000003                         |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | gemeente van inschrijving (09.10) | datum aanvang adreshouding (10.30) |
    | 9000                              | 20220102                           |
    And municipality 'G1' has been merged with the following data
    | nieuwe gemeentecode (92.12) | datum beëindiging (99.99) |
    | 0800                        | 20230526                  |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                                                      | values                        |
    | 1    | gemeente-G1    | INSERT INTO public.lo3_gemeente(gemeente_code,gemeente_naam,nieuwe_gemeente_code,tabel_regel_eind_datum) VALUES($1,$2,$3,$4)                                                              | 9000,Ons Dorp,0800,20230526   |
    | 2    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,gemeente_code,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING *                     | 9000,9999010000000003         |
    |      | adres-2        | INSERT INTO public.lo3_adres(adres_id,gemeente_code,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING *                     | 0800,9999010000000003         |
    | 3    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING *                                     | 0                             |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                                                          | 9999,0,0,P,000000012          |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,inschrijving_gemeente_code,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5,$6)                              | 9999,4999,1,W,9000,20220102   |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,inschrijving_gemeente_code,adreshouding_start_datum,aangifte_adreshouding_oms) VALUES($1,$2,$3,$4,$5,$6,$7) | 9999,5000,0,W,0800,20230526,W |

  Scenario: a registration at an address with an identification that is changed infrastructurally
    Given address 'A1' has the following data
    | gemeentecode (92.10) | identificatiecode verblijfplaats (11.80) |
    | 0800                 | 0800010000000003                         |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | gemeente van inschrijving (09.10) | datum aanvang adreshouding (10.30) |
    | 0800                              | 20220102                           |
    And address 'A1' was changed infrastructurally on '2023-02-03' with the following data
    | gemeentecode (92.10) |
    | 0530                 |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                                                      | values                        |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,gemeente_code,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING *                     | 0800,0800010000000003         |
    |      | adres-2        | INSERT INTO public.lo3_adres(adres_id,gemeente_code,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING *                     | 0530,0800010000000003         |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING *                                     | 0                             |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                                                          | 9999,0,0,P,000000012          |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,inschrijving_gemeente_code,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5,$6)                              | 9999,4999,1,W,0800,20220102   |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,inschrijving_gemeente_code,adreshouding_start_datum,aangifte_adreshouding_oms) VALUES($1,$2,$3,$4,$5,$6,$7) | 9999,5000,0,W,0530,20230203,W |

  Scenario: a registration at an address with an identification that is changed infrastructurally into an address with an identification
    Given address 'A1' has the following data
    | gemeentecode (92.10) | identificatiecode verblijfplaats (11.80) |
    | 0800                 | 0800010000000003                         |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | gemeente van inschrijving (09.10) | datum aanvang adreshouding (10.30) |
    | 0800                              | 20220102                           |
    And address 'A1' was changed infrastructurally on '2023-02-03' to address 'A2' with the following data
    | gemeentecode (92.10) |
    | 0530                 |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                                                      | values                        |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,gemeente_code,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING *                     | 0800,0800010000000003         |
    |      | adres-A2       | INSERT INTO public.lo3_adres(adres_id,gemeente_code,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1,$2) RETURNING *                     | 0530,0800010000000003         |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING *                                     | 0                             |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                                                          | 9999,0,0,P,000000012          |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,inschrijving_gemeente_code,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5,$6)                              | 9999,4999,1,W,0800,20220102   |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,inschrijving_gemeente_code,adreshouding_start_datum,aangifte_adreshouding_oms) VALUES($1,$2,$3,$4,$5,$6,$7) | 9999,5000,0,W,0530,20230203,W |

  Scenario: a correction of a registration at an address with an identification
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And address 'A2' has the following data
    | identificatiecode verblijfplaats (11.80) |
    | 0800010011067001                         |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    And the registration was subsequently corrected as a registration at address 'A2' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230800                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                   |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep                |
    |      | adres-A2       | INSERT INTO public.lo3_adres(adres_id,verblijf_plaats_ident_code) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *  | 0800010011067001         |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                        |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012     |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum,onjuist_ind) VALUES($1,$2,$3,$4,$5,$6)         | 9999,4999,1,W,20230102,O |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,5000,0,W,20230800   |

  Scenario: the person has a child
    Given the person with citizen service number '000000012' has a 'kind' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    Then the generated SQL statements are
    | stap | categorie    | text                                                                                                                                                  | values               |
    | 1    | inschrijving | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                    |
    |      | persoon      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012 |
    |      | kind-1       | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,K,Jansen    |

  Scenario: the person has a child and a registration at an address with an identification
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' has a 'kind' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    And the person is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                 |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep              |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                      |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012   |
    |      | kind-1         | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,K,Jansen      |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,W,20230102 |

  Scenario Outline: the person has a parent
    Given the person with citizen service number '000000012' has a parent '<ouder-type>' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    Then the generated SQL statements are
    | stap | categorie          | text                                                                                                                                                  | values                       |
    | 1    | inschrijving       | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                            |
    |      | persoon            | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012         |
    |      | ouder-<ouder-type> | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,<ouder-type>,Jansen |

    Examples:
    | ouder-type |
    | 1          |
    | 2          |

  Scenario: a person with 2 parents
    Given the person with citizen service number '000000012' has a parent '1' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    And the person has a parent '2' with the following data
    | naam                  | waarde    |
    | geslachtsnaam (02.40) | Pietersen |
    Then the generated SQL statements are
    | stap | categorie    | text                                                                                                                                                  | values               |
    | 1    | inschrijving | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                    |
    |      | persoon      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012 |
    |      | ouder-1      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,1,Jansen    |
    |      | ouder-2      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,2,Pietersen |

  Scenario Outline: the person has a parent and a registration at an address with an identification
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' has a parent '<ouder-type>' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    And the person is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie          | text                                                                                                                                                  | values                       |
    | 1    | adres-A1           | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep                    |
    | 2    | inschrijving       | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                            |
    |      | persoon            | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012         |
    |      | ouder-<ouder-type> | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,<ouder-type>,Jansen |
    |      | verblijfplaats     | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,W,20230102       |

    Examples:
    | ouder-type |
    | 1          |
    | 2          |

  Scenario: the person has a partner
    Given the person with citizen service number '000000012' has a 'partner' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    Then the generated SQL statements are
    | stap | categorie    | text                                                                                                                                                  | values               |
    | 1    | inschrijving | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                    |
    |      | persoon      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012 |
    |      | partner-1    | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,R,Jansen    |

  Scenario: the person has a partner and a registration at an address with an identification
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' has a 'partner' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    And the person is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                 |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep              |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                      |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012   |
    |      | partner-1      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,R,Jansen      |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,W,20230102 |

  Scenario: the person has a parent, partner, child and a registration at an address with an identification
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' has a parent '1' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    And the person has a 'partner' with the following data
    | naam                  | waarde    |
    | geslachtsnaam (02.40) | Pietersen |
    And the person has a 'kind' with the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    And the person is registered at address 'A1' with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                 |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep              |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                      |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012   |
    |      | ouder-1        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,1,Jansen      |
    |      | partner-1      | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,R,Pietersen   |
    |      | kind-1         | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,geslachts_naam) VALUES($1,$2,$3,$4,$5)                                         | 9999,0,0,K,Jansen      |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,W,20230102 |

  Scenario: giving an address as a correspondence address
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' has given address 'A1' as a correspondence address with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                 |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep              |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                      |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                      | 9999,0,0,P,000000012   |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,B,20230102 |

  Scenario: given the person has given an address as a correspondence address with the following data
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' has the following data
    | naam                  | waarde |
    | geslachtsnaam (02.40) | Jansen |
    And the person has given address 'A1' as a correspondence address with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                  | values                      |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                 | Boterdiep                   |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING * | 0                           |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr,geslachts_naam) VALUES($1,$2,$3,$4,$5,$6)                    | 9999,0,0,P,000000012,Jansen |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                        | 9999,4999,0,B,20230102      |

  Scenario: given the person has subsequently given an address as a correspondence address with the following data
    Given address 'A1' has the following data
    | straatnaam (11.10) |
    | Boterdiep          |
    And the person with citizen service number '000000012' is registered at address 'A1' with the following data
    | gemeente van inschrijving (09.10) | datum aanvang adreshouding (10.30) |
    | 0800                              | 20220102                           |
    And the person has subsequently given address 'A1' as a correspondence address with the following data
    | datum aanvang adreshouding (10.30) |
    | 20230102                           |
    Then the generated SQL statements are
    | stap | categorie      | text                                                                                                                                                         | values                      |
    | 1    | adres-A1       | INSERT INTO public.lo3_adres(adres_id,straat_naam) VALUES((SELECT COALESCE(MAX(adres_id), 0)+1 FROM public.lo3_adres),$1) RETURNING *                        | Boterdiep                   |
    | 2    | inschrijving   | INSERT INTO public.lo3_pl(pl_id,mutatie_dt,geheim_ind) VALUES((SELECT COALESCE(MAX(pl_id), 0)+1 FROM public.lo3_pl),current_timestamp,$1) RETURNING *        | 0                           |
    |      | persoon        | INSERT INTO public.lo3_pl_persoon(pl_id,stapel_nr,volg_nr,persoon_type,burger_service_nr) VALUES($1,$2,$3,$4,$5)                                             | 9999,0,0,P,000000012        |
    |      | verblijfplaats | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,inschrijving_gemeente_code,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5,$6) | 9999,4999,1,W,0800,20220102 |
    |      |                | INSERT INTO public.lo3_pl_verblijfplaats(pl_id,adres_id,volg_nr,adres_functie,adreshouding_start_datum) VALUES($1,$2,$3,$4,$5)                               | 9999,4999,0,B,20230102      |