If you as I have come this far. Here’s how I solved my problem.
The general checker digit corresponds to the 5th position of the barcode. The digit 0 (zero) in the 5th position will indicate that the barcode has no checker digit;
assign the corresponding weights (from 2 to 9) for each of the 43 digits (except the DV itself) of the Barcode, starting from right to left;
Multiply each digit by its corresponding weight. the first digit from right to left by 2, the second by 3, and so on until it reaches weight 9, when it starts again with weight 2;
Accumulate the result of each multiplication;
Divide the sum result by 11 (eleven);
identify the rest of the division;
My problem lies precisely in this last line of algorithm:
//Agora que tenho a soma vamos pegar o resto da divisão por 11
mod = 11-(soma % 11);
//Se o resultado da subtração for 0 (zero), 1 (um) ou maior que 9 (nove), o dígito verificador será 1 (um). Senão o DV é o próprio resultado da subtração.
if (mod == 0 || mod == 1 || mod > 9)
{
dv = 1;
}
DvGeral = dv;
The check digit will be the result of the subtraction: 11 - rest of the division. If the result of the subtraction is 0 (zero), 1 (one) or greater than 9 (nine), the check digit shall be 1 (one). Otherwise the DV is the result of subtraction itself.
But helping someone was worth it
You have already entered the steps to verify the digit. What is your question?
– André Ribeiro
What is the doubt? You have everything you need.
– Jéf Bueno
@Jéfersontavares André Ribeiro the expected DV would be 1 and not the number 5.
– Fabrício Mendes
Dude, show me the code you already have.
– Jéf Bueno
@Jéfersontas the error is not in the code works blz, it assigns the weight, makes the sum, and finds the rest of the division. The problem is in the assembly itself. I am using this manual https://www.sicredi.com.br/html/para-sua-empresa/received/cobranca/arquivos/25420_manual_beneficiario_cobranca_cnab_400.pdf
– Fabrício Mendes
If you are not getting the right result, the error is in the code. @Fabríciosimonealanamendes
– Jéf Bueno
@Fabríciosimonealanamendes In the assembly of what? Without seeing your code no one will be able to help you.
– André Ribeiro
@You don’t fit the code here
– Fabrício Mendes
Anyway, try to be more specific in your question. The way you are nobody will be able to help.
– Jéf Bueno
My problem is in calculating the Barcode Checker Digit. On the first line I have the code data, on the second line I have the weight, on the third line I have the remaining multiplication... I don’t know if I can be more explicit than that.
– Fabrício Mendes
Your code may be too much for a comment but you can edit your question and include it there.
– ramaral
@OK Jéfersontavares is there in the code
– Fabrício Mendes
Someone has the form to calculate the barcode code DV of the Sicredi billet
– Fabrício Mendes