Skip to content

Commit 83d86dc

Browse files
authored
fix/wsfe_without_error_observation auto commit (#24)
1 parent aa996f1 commit 83d86dc

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Change Log
22

3+
## [2.0.2] - 30-07-20
4+
5+
### Added
6+
- AfipUnhandledException. Used for uncontrolled errors. You never send this data final user, it's only for debugging purposes.
7+
8+
### Fixed
9+
- Error when WSFE return an error without Observations
10+
311
## [v2.0.0 (2019-08-08)](https://github.com/multinexo/php-afip-ws/releases/tag/2.0.0)
412

513
### Added
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Copyright (C) 1997-2020 Reyesoft <[email protected]>.
4+
*
5+
* This file is part of php-afip-ws. php-afip-ws can not be copied and/or
6+
* distributed without the express permission of Reyesoft
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace Multinexo\Exceptions;
12+
13+
class AfipUnhandledException extends \Exception
14+
{
15+
}

src/WSFE/Wsfe.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Multinexo\WSFE;
1212

13+
use Multinexo\Exceptions\AfipUnhandledException;
1314
use Multinexo\Exceptions\ManejadorResultados;
1415
use Multinexo\Exceptions\WsException;
1516
use Multinexo\Models\AfipConfig;
@@ -112,7 +113,11 @@ public function FECAESolicitar($data)
112113
$this->resultado->procesar($resultado);
113114

114115
if (reset($resultado)->FeDetResp->FECAEDetResponse->Resultado === 'R') {
115-
$observaciones = reset($resultado)->FeDetResp->FECAEDetResponse->Observaciones->Obs->Msg;
116+
$observaciones = reset($resultado)->FeDetResp->FECAEDetResponse->Observaciones->Obs->Msg ?? '';
117+
118+
if (empty($observaciones)) {
119+
throw new AfipUnhandledException(print_r('FECAEDetResponse: ' . reset($resultado)->FeDetResp->FECAEDetResponse, true));
120+
}
116121

117122
throw new WsException($observaciones);
118123
}
@@ -477,6 +482,11 @@ public function FEParamGetPtosVenta()
477482
* Desc string(250) Descripción
478483
* FchDesde string(8) Fecha de vigencia desde
479484
* FchHasta string(8) Fecha de vigencia hasta
485+
*
486+
* @throws AfipUnhandledException
487+
* @throws WsException
488+
*
489+
* @return mixed
480490
*/
481491
public function FEParamGetTiposCbte()
482492
{
@@ -486,6 +496,10 @@ public function FEParamGetTiposCbte()
486496

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

499+
if (!isset($resultado->FEParamGetTiposCbteResult->ResultGet)) {
500+
throw new AfipUnhandledException('ResultGet not defined: ' . print_r($resultado, true));
501+
}
502+
489503
return $resultado->FEParamGetTiposCbteResult->ResultGet;
490504
}
491505

0 commit comments

Comments
 (0)