In my application a double registration of a relation as well as an invoice has to be prevented.
I’ve tried this by using the combination of postcode with house number as relation number.
for invoices it wil be the combination of relation number and invoice number to create an unique registration.
This seems possible but it generates two new problems:
- only one office of a group of “small” organisations, who are situated in one and the same building, can be registered.
- sometimes a “normal” house can be divided in more appartments and have a number of different additions which make a double registration still possible.
How can these problems be addressed in Alan?
root {
'Relaties': collection ['RelatieNr'] {
'HuisNr': text @description: "bijvoorbeeld: 123, 123A..Z of 123-1H"
'Postcode': text @validate: "^(\\d){4}([A-Z]{2})$" @description: "1234AB"
'RelatieNr': text @description: "Postcode + HuisNr: 1234AB123"
}
'Nieuwe Relatie': action {
'HuisNr': text @description: "bijvoorbeeld: 123, 123A..Z of 123-1H"
'Postcode': text @validate: "^(\\d){4}([A-Z]{2})$" @description: "1234AB"
'RelatieNr': text @description: "Postcode + HuisNr, zonder spaties"
} => update .'Relaties' = create (
'HuisNr'= @ .'HuisNr'
'Postcode'= @ .'Postcode'
'RelatieNr'= concat ( @ .'Postcode', @ .'HuisNr' ) // 'RelatieNr'
)
}