Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [2.0.2] - 30-07-20

### Added
- AfipUnhandledException. Used for uncontrolled errors. You never send this data final user, it's only for debugging purposes.

### Fixed
- Error when WSFE return an error without Observations

## [v2.0.0 (2019-08-08)](https://github.com/multinexo/php-afip-ws/releases/tag/2.0.0)

### Added
Expand Down
15 changes: 15 additions & 0 deletions src/Exceptions/AfipUnhandledException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Copyright (C) 1997-2020 Reyesoft <info@reyesoft.com>.
*
* This file is part of php-afip-ws. php-afip-ws can not be copied and/or
* distributed without the express permission of Reyesoft
*/

declare(strict_types=1);

namespace Multinexo\Exceptions;

class AfipUnhandledException extends \Exception
{
}
16 changes: 15 additions & 1 deletion src/WSFE/Wsfe.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace Multinexo\WSFE;

use Multinexo\Exceptions\AfipUnhandledException;
use Multinexo\Exceptions\ManejadorResultados;
use Multinexo\Exceptions\WsException;
use Multinexo\Models\AfipConfig;
Expand Down Expand Up @@ -112,7 +113,11 @@ public function FECAESolicitar($data)
$this->resultado->procesar($resultado);

if (reset($resultado)->FeDetResp->FECAEDetResponse->Resultado === 'R') {
$observaciones = reset($resultado)->FeDetResp->FECAEDetResponse->Observaciones->Obs->Msg;
$observaciones = reset($resultado)->FeDetResp->FECAEDetResponse->Observaciones->Obs->Msg ?? '';

if (empty($observaciones)) {
throw new AfipUnhandledException(print_r('FECAEDetResponse: ' . reset($resultado)->FeDetResp->FECAEDetResponse, true));
}

throw new WsException($observaciones);
}
Expand Down Expand Up @@ -477,6 +482,11 @@ public function FEParamGetPtosVenta()
* Desc string(250) Descripción
* FchDesde string(8) Fecha de vigencia desde
* FchHasta string(8) Fecha de vigencia hasta
*
* @throws AfipUnhandledException
* @throws WsException
*
* @return mixed
*/
public function FEParamGetTiposCbte()
{
Expand All @@ -486,6 +496,10 @@ public function FEParamGetTiposCbte()

$this->resultado->procesar($resultado);

if (!isset($resultado->FEParamGetTiposCbteResult->ResultGet)) {
throw new AfipUnhandledException('ResultGet not defined: ' . print_r($resultado, true));
}

return $resultado->FEParamGetTiposCbteResult->ResultGet;
}

Expand Down