Skip to content

Commit 9ba0328

Browse files
committed
TAfipQuery.ObtenerConstancia can now raise an EConstanciaNotFound exception
1 parent 3d65677 commit 9ba0328

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

AFIP/Afip.PublicAPI.Types.pas

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ EPersonNotFound = class(EAfipException)
7979
public
8080
constructor Create(const ARawJson: string); override;
8181
end;
82+
83+
/// <summary>
84+
/// Esta excepcion se va a elevar cuando no se encuentra una constancia de
85+
/// CUIT. Desciende de Exception porque no hay informacion JSON para
86+
/// mostrar
87+
/// </summary>
88+
EConstanciaNotFound = class(Exception)
89+
public
90+
constructor Create; reintroduce;
91+
end;
8292
{$ENDREGION}
8393

8494
{$REGION 'TDomicilioFiscal'}
@@ -567,7 +577,13 @@ procedure TDomicilioFiscal.SetRawJson(const Value: string);
567577

568578
function TDomicilioFiscal.ToString: string;
569579
begin
570-
Result := Direccion + ', ' + Localidad + ', ' + CodPostal;
580+
Result := Direccion;
581+
582+
if Localidad <> EmptyStr then
583+
Result := Result + ', ' + Localidad;
584+
585+
if CodPostal <> EmptyStr then
586+
Result := Result + ', ' + CodPostal;
571587
end;
572588

573589
{$ENDREGION}
@@ -647,4 +663,11 @@ constructor EPersonNotFound.Create(const ARawJson: string);
647663
end;
648664
{$ENDREGION}
649665

666+
{ EConstanciaNotFound }
667+
668+
constructor EConstanciaNotFound.Create;
669+
begin
670+
inherited Create('No se encontraron resultados');
671+
end;
672+
650673
end.

AFIP/Afip.PublicAPI.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ function TAfipQuery.ObtenerConstancia(const Cuit: string): TStream;
123123
begin
124124
Result := TMemoryStream.Create;
125125
AResponse := FHttpClient.Get(FServicesUrl[stConstancia] + Cuit, Result);
126+
if Result.Size = 0 then
127+
raise EConstanciaNotFound.Create;
126128
end;
127129
{$ENDREGION}
128130

0 commit comments

Comments
 (0)