Skip to content

Commit

Permalink
Fix/issue 45 (#47)
Browse files Browse the repository at this point in the history
solves #45
  • Loading branch information
pablorsk authored Aug 12, 2022
1 parent 6b41fac commit d2535ae
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.8] - 2022-08-12
### Fixed
- ValidacionDeToken: No validaron las fechas del token GenTime, ExpTime, NowUTC [#45](https://github.com/multinexo/php-afip-ws/issues/45)

## [2.0.5] - 2021-07-31
### Changed
- CHANGELOG based on Keep aChangelog
Expand Down
2 changes: 1 addition & 1 deletion src/WSAA/Wsaa.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function checkTARenovation(stdClass $service): bool

$expirationTime = self::getXmlAttribute($path, ['header', 'expirationTime']);

if (strtotime((string) $expirationTime) < strtotime(date('Y-m-d h:m:i'))) {
if (strtotime((string) $expirationTime) <= strtotime(gmdate('Y-m-d h:m:i'))) {
self::authenticate($service);

return true;
Expand Down
47 changes: 25 additions & 22 deletions src/WSFE/Wsfe.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Multinexo\Exceptions\WsException;
use Multinexo\Models\AfipConfig;
use Multinexo\Models\InvoiceWebService;
use Multinexo\Models\Log;
use Multinexo\Models\Validaciones;
use Multinexo\Objects\AssociatedDocumentObject;
use Multinexo\Objects\InvoiceObject;
Expand Down Expand Up @@ -489,6 +488,12 @@ public function FEParamGetPtosVenta(): stdClass
* FchDesde string(8) Fecha de vigencia desde
* FchHasta string(8) Fecha de vigencia hasta
*/

/**
* @throws AfipUnavailableServiceException
* @throws AfipUnhandledException
* @throws WsException
*/
public function FEParamGetTiposCbte(): stdClass
{
$resultado = $this->service->client->FEParamGetTiposCbte([
Expand All @@ -497,28 +502,28 @@ public function FEParamGetTiposCbte(): stdClass

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

$error_code = $resultado->FEParamGetTiposCbteResult->Errors->Code ?? null;
if ($error_code > 0) {
switch ($error_code) {
case 600:
// ValidacionDeToken: No validaron las fechas del token GenTime, ExpTime, NowUTC:...
throw new AfipUnavailableServiceException(
$resultado->FEParamGetTiposCbteResult->Errors->Msg ?? '',
$error_code
);
default:
throw new WsException(
$resultado->FEParamGetTiposCbteResult->Errors->Msg ?? print_r($resultado, true),
$error_code
);
}
if (isset($resultado->FEParamGetTiposCbteResult->ResultGet)) {
return $resultado->FEParamGetTiposCbteResult->ResultGet;
}

if (!isset($resultado->FEParamGetTiposCbteResult->ResultGet)) {
throw new AfipUnhandledException('ResultGet not defined: ' . print_r($resultado, true));
$err = $resultado->FEParamGetTiposCbteResult->Errors->Err
?? $resultado->FEParamGetTiposCbteResult->Errors
?? null;
switch ($err->Code ?? null) {
case 600:
// ValidacionDeToken: No validaron las fechas del token GenTime, ExpTime, NowUTC:...
throw new AfipUnavailableServiceException(
$resultado->FEParamGetTiposCbteResult->Errors->Msg ?? '',
$err->Code
);
case null:
throw new AfipUnhandledException('ResultGet not defined: ' . print_r($resultado, true));
default:
throw new WsException(
$resultado->FEParamGetTiposCbteResult->Errors->Msg ?? print_r($resultado, true),
$err->Code
);
}

return $resultado->FEParamGetTiposCbteResult->ResultGet;
}

/*
Expand Down Expand Up @@ -672,8 +677,6 @@ public function getAvailablePosNumbers(): array

$fetched_pos_array = $result->ResultGet->PtoVenta ?? [];
if (!is_array($fetched_pos_array)) {
// testing dont work like production
Log::debug('Fix testing env: ' . print_r($result->ResultGet, true));
$fetched_pos_array = $result->ResultGet ?? [];
}
foreach ($fetched_pos_array as $fetched_pos) {
Expand Down

0 comments on commit d2535ae

Please sign in to comment.