Controle sofinummer bankrekeningnummer

3
I want to check ´sofinummer´en ´bankrekening´ number of an employee. Has anyone build this already? In java or a microflow? I found some javascipt (see below), can i use that? Sofinummer check: <script language="javascript"> function checksofi(){ sofinr=document.sofi.nummer.value.toString(); checksum=0; if(isNaN(sofinr) || sofinr.length!=9){ alert("Uw sofinummer is niet correct. Indien het eerste cijfer een 0 is van uw sofinummer, moet u deze ook invullen!"); } else{ for(i=0;i<8;i++){ checksum += (sofinr.charAt(i)*(9-i)); } checksum -= sofinr.charAt(8); if(checksum%11!=0){ alert("Uw sofinummer is niet correct. Indien het eerste cijfer een 0 is van uw sofinummer, moet u deze ook invullen!"); } } } </script> Bankrekeningnummer check: <script language="javascript"> function elf_proef(bankrekeningnummer) { // verwijder alle tekens die geen cijfers zijn bankrekeningnummer=bankrekeningnummer.replace(/\D/, ""); aantal_tekens=bankrekeningnummer.length; var som=0; // loop door de 9 cijfers met de 11 proef formule for (i=1; i<10; i++) { getal=bankrekeningnummer.charAt(i-1); som+=getal*(10-i); } // geef resultaat van check terug if (som % 11==0 && aantal_tekens==9) { return true } else { return false } } </script>
asked
4 answers
3

Something like this?

Create a javaaction for checking the BSN. add the input parameter 'bsnnr'. copy and paste the folowing code between the "//user code" tags

// BEGIN USER CODE
        int checksum = 0; 

        double bsnnrDouble = 0;

        try 
        {
            bsnnrDouble = Double.parseDouble(bsnnr);
        }
        catch (Exception e)
        {
            return false;
        }

        if(bsnnr.length() != 9)
        { 
            return false; 
        } 
        else
        { 
            for(int i = 0; i < 8; i++)
            { 
                checksum += ( Integer.parseInt(Character.toString(bsnnr.charAt(i))) *(9-i));
            } 
            checksum -= Integer.parseInt(Character.toString(bsnnr.charAt(8)));

            if(checksum % 11 != 0)
            {
                return false;
            }
        }

        return true;
// END USER CODE

Create a javaaction for checking the bankaccount. add the input parameter 'bankaccountnr'. copy and paste the folowing code between the "//user code" tags.

// BEGIN USER CODE

        bankaccountnr = bankaccountnr.replaceAll( "[^\\d]", "" );
        int aantal_tekens = bankaccountnr.length(); 
        int som = 0; 

        for (int i = 1; i < 10; i++) 
        {
            int getal = Integer.parseInt(Character.toString(bankaccountnr.charAt(i-1)));
            som+=getal*(10-i); 
        } 

        if (som % 11 == 0 && aantal_tekens == 9) 
        { 
            return true;
        } 
        else 
        { 
            return false;
        } 

    // END USER CODE
answered
1

To me this sounds like something you´d want to do through validation rules with a proper Regular expression

answered
1

You can check this using a simple java action in the before commit which optionally shows a datavalidation message.The code would be almost the same in java.

answered
0

It doesn't seem so difficult to build in a microflow either. Just make a loop.

answered