Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Impresión (https://www.clubdelphi.com/foros/forumdisplay.php?f=4)
-   -   Dígito verificador Interleaved 2 of 5 (https://www.clubdelphi.com/foros/showthread.php?t=93848)

santiago14 04-04-2019 13:38:42

Dígito verificador Interleaved 2 of 5
 
Buenas, ¿alguien tendría el algoritmo del dígito verificador de Interleaved 2 of 5?
Es para poner en las facturas de Argentina que exigen las barras.

Gracias.

lucho6007 04-04-2019 14:21:35

Calculo
 
Hola! te dejo la función que calcula el hash.
La entrada a la función va:

CUIT (char 11) + Tipo Comprobante (char 2) + Punto de venta (char 4) + CAE + VenceCAE (char 8, yyyymmdd)


Código Delphi [-]
function CalculaCAEBarCode(AStr: String): String;
var
  I, DummyInt, SumaPar, SumaImpar: Integer;
begin
  if Length(AStr) = 39 then begin
    SumaPar:= 0;
    SumaImpar:= 0;
    for I:= 1 to Length(AStr) do begin
      DummyInt:= StrToInt(AStr[i]);
      if Odd(I) then begin
        SumaImpar:= SumaImpar + DummyInt;
      end
      else begin
        SumaPar:= SumaPar + DummyInt;
      end;
    end;
    SumaPar:= SumaPar + (SumaImpar * 3);

    Result:= AStr + IntToStr(10 - (SumaPar - ((SumaPar div 10) * 10)));
  end
  else begin
    Result:= '';
  end;
end;


La franja horaria es GMT +2. Ahora son las 17:54:12.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi