From a3e84e40671e6ca0d6d15b5a566ffe0ca413000b Mon Sep 17 00:00:00 2001 From: David Obando Date: Wed, 23 Jul 2025 18:39:01 -0400 Subject: [PATCH] fix: copilot suggestions --- .gitignore | 5 +++-- api/contrib/clave/clave.php | 10 +++++----- api/contrib/genXML/genXML.php | 7 +------ www/settings.php | 23 ++++++++++++++--------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 3ec45d7b..6868f7e4 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ build/* validation_data.json # content of settings.php is autogenerated -www/settings.php +# www/settings.php # Mysql Volume /mysql-data/* @@ -46,4 +46,5 @@ Desktop.ini !*.secret random_seed junit-report.html -junit-report.xml \ No newline at end of file +junit-report.xml +.env \ No newline at end of file diff --git a/api/contrib/clave/clave.php b/api/contrib/clave/clave.php index 255bb01f..c9b34802 100644 --- a/api/contrib/clave/clave.php +++ b/api/contrib/clave/clave.php @@ -85,7 +85,7 @@ function getClave($tipoDocumento = "", $tipoCedula = "", $cedula = "", $situacio } if (!ctype_digit($consecutivo)) { - return "El parametro sucursal no es numeral"; + return "El parametro consecutivo no es numeral"; } else if (strlen($consecutivo) < 10) { $consecutivo = str_pad($consecutivo, 10, "0", STR_PAD_LEFT); } else if (strlen($consecutivo) > 10) { @@ -93,7 +93,7 @@ function getClave($tipoDocumento = "", $tipoCedula = "", $cedula = "", $situacio } if (!ctype_digit($codigoSeguridad)) { - return "El parametro sucursal no es numeral"; + return "El parametro codigoSeguridad no es numeral"; } else if (strlen($codigoSeguridad) < 8) { $codigoSeguridad = str_pad($codigoSeguridad, 8, "0", STR_PAD_LEFT); } else if (strlen($codigoSeguridad) > 8) { @@ -180,14 +180,14 @@ function getClave($tipoDocumento = "", $tipoCedula = "", $cedula = "", $situacio "sininternet" => 3 ); - $situacion = $situaciones[strtolower($situacion)] ?? null; + $codSituacion = $situaciones[strtolower($situacion)] ?? null; - if ($situacion === null) { + if ($codSituacion === null) { return "No se encuentra el tipo de situacion [$situacion]"; } // Crea la clave - $clave = $codigoPais . $dia . $mes . $ano . $identificacion . $consecutivoFinal . $situacion . $codigoSeguridad; + $clave = $codigoPais . $dia . $mes . $ano . $identificacion . $consecutivoFinal . $codSituacion . $codigoSeguridad; $arrayResp = array( "clave" => "$clave", "consecutivo" => "$consecutivoFinal", diff --git a/api/contrib/genXML/genXML.php b/api/contrib/genXML/genXML.php index 51ef3858..b197e2c0 100644 --- a/api/contrib/genXML/genXML.php +++ b/api/contrib/genXML/genXML.php @@ -434,7 +434,7 @@ function genXMLFe() $l = 1; foreach ($detalles as $d) { - + foreach (["codigoCABYS","subTotal","impuestoAsumidoEmisorFabrica","impuestoNeto"] as $requiredField) { if (!isset($d->{$requiredField}) || $d->{$requiredField} === '') { tools_reply("Se requiere el campo $requiredField en el detalle #$l", true); @@ -445,11 +445,6 @@ function genXMLFe() ' . $l . ''; - if(!isset($d->codigoCABYS) || $d->codigoCABYS == "") { - error_log("codigoCABYS is required in LineaDetalle"); - tools_reply("Se requiere el codigoCABYS en el detalle #$l", true); - continue; // Skip this line if codigoCABYS is not set - } $xmlString .= ' ' . $d->codigoCABYS . ''; diff --git a/www/settings.php b/www/settings.php index 2074204b..406d6383 100644 --- a/www/settings.php +++ b/www/settings.php @@ -20,13 +20,18 @@ global $config; # Cargar config del .env -$env = file_get_contents(__DIR__."/../.env"); -$lines = explode("\n",$env); - -foreach($lines as $line){ - preg_match("/([^#]+)\=(.*)/",$line,$matches); - if(isset($matches[2])){ putenv(trim($line)); } -} +$envFilePath = __DIR__ . "/../.env"; +if (file_exists($envFilePath)) { + $env = file_get_contents($envFilePath); + $lines = explode("\n", $env); + + foreach ($lines as $line) { + preg_match("/^\s*([^#][^=]*)=(.*)$/", $line, $matches); + if (isset($matches[2])) { + putenv(trim($line)); + } + } +} ##################################################################################### # @@ -111,11 +116,11 @@ /******************************************************************************* * You should not need to touch anything beyond this point */ - + # List of core modules -$config['modules']['core'] = array('cala','db', 'users', 'files', 'geoloc', 'wirez', 'crypto'); +$config['modules']['core'] = array('cala', 'db', 'users', 'files', 'geoloc', 'wirez', 'crypto'); # List of core modules to load always, you can overide this list $config['modules']['coreLoad'] = array('cala', 'db', 'users', 'crypto');