Cálculo Digito Verificador
30/09/2004
0
Alguem tem a rotina para validar o número de inscrição do INSS ? Preciso implantar essa rotina no meu sistema de folha de pagamento ..
Obrigado pela atenção.
[]´s
Obrigado pela atenção.
[]´s
Seu-madruga
Curtir tópico
+ 0
Responder
Posts
30/09/2004
Pehdepano
O dígito é calculado através de Mod11 ou Mod10??
Se for...
[b:5a108bd276]function Modulo10(N: string): string[/b:5a108bd276];
var
Somatorio, m, k, i: Integer;
begin
Somatorio := 0;
if Odd(Length(N))
then m := 2
else m := 1;
for i := 1 to Length(N) do
begin
k := StrToInt(N[i]) * m;
if k > 9 then k := (k - 9);
Somatorio := Somatorio + k;
if m = 1 then m := 2 else m := 1;
end;
m := 1000 - Somatorio;
Result := Copy(IntToStr(m), Length(IntToStr(m)), 1);
end;
[b:5a108bd276]function Modulo11(N: string): string;[/b:5a108bd276]
var
Somatorio, multipl, i, r: Integer;
begin
multipl := 2;
Somatorio := 0;
for i := Length(N) downto 1 do
begin
Somatorio := Somatorio + (StrToInt(N[i]) * multipl);
inc(multipl);
if multipl = 10 then multipl := 2;
end;
r := Somatorio mod 11;
multipl := 11 - r;
if multipl > 9 then multipl := 1;
if multipl = 0 then multipl := 1;
Result := IntToStr(multipl);
end;
Se for...
[b:5a108bd276]function Modulo10(N: string): string[/b:5a108bd276];
var
Somatorio, m, k, i: Integer;
begin
Somatorio := 0;
if Odd(Length(N))
then m := 2
else m := 1;
for i := 1 to Length(N) do
begin
k := StrToInt(N[i]) * m;
if k > 9 then k := (k - 9);
Somatorio := Somatorio + k;
if m = 1 then m := 2 else m := 1;
end;
m := 1000 - Somatorio;
Result := Copy(IntToStr(m), Length(IntToStr(m)), 1);
end;
[b:5a108bd276]function Modulo11(N: string): string;[/b:5a108bd276]
var
Somatorio, multipl, i, r: Integer;
begin
multipl := 2;
Somatorio := 0;
for i := Length(N) downto 1 do
begin
Somatorio := Somatorio + (StrToInt(N[i]) * multipl);
inc(multipl);
if multipl = 10 then multipl := 2;
end;
r := Somatorio mod 11;
multipl := 11 - r;
if multipl > 9 then multipl := 1;
if multipl = 0 then multipl := 1;
Result := IntToStr(multipl);
end;
Responder
Clique aqui para fazer login e interagir na Comunidade :)