Skip to content

Commit

Permalink
Merge pull request #176 from josemmo/develop
Browse files Browse the repository at this point in the history
v1.8.2
  • Loading branch information
josemmo authored Nov 23, 2024
2 parents c7f01f5 + 5412dd0 commit edb213c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
include:
- php-version: '8.3'
- php-version: '8.4'
test-ws: true
send-coverage: true
- php-version: '8.4'
- php-version: '8.5'
experimental: true
steps:
# Download code from repository
Expand Down
21 changes: 21 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* This file is an extremely simple autoloader for environments where Composer is not available.
*/

spl_autoload_register(static function ($class) {
// Verify we're importing a class from this library
if (mb_strpos($class, 'josemmo\\Facturae\\') !== 0) {
return false;
}

// Find file
$path = __DIR__ . "/src/" . str_replace('\\', '/', mb_substr($class, 17)) . ".php";
if (!file_exists($path)) {
return false;
}

// Import file
require $path;
return true;
});
4 changes: 2 additions & 2 deletions doc/anexos/validacion.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ permalink: /anexos/validacion.html
Todas las facturas generadas y firmadas con Facturae-PHP son probadas con las siguientes herramientas online para garantizar el cumplimiento del estándar:

- [https://viewer.facturadirecta.com/](https://viewer.facturadirecta.com/) (no soporta 3.2.2)
- [http://plataforma.firma-e.com/VisualizadorFacturae/](http://plataforma.firma-e.com/VisualizadorFacturae/) (no soporta 3.2.2)
- [http://sedeaplicaciones2.minetur.gob.es/FacturaE/index.jsp](http://sedeaplicaciones2.minetur.gob.es/FacturaE/index.jsp)
- [https://plataforma.firma-e.com/VisualizadorFacturae/](https://plataforma.firma-e.com/VisualizadorFacturae/)
- [https://face.gob.es/es/facturas/validar-visualizar-facturas](https://face.gob.es/es/facturas/validar-visualizar-facturas)
- [https://sedeaplicaciones2.minetur.gob.es/FacturaE/index.jsp](https://sedeaplicaciones2.minetur.gob.es/FacturaE/index.jsp) (ya no existe)
14 changes: 3 additions & 11 deletions doc/ejemplos/sin-composer.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,10 @@ permalink: /ejemplos/sin-composer.html
# Uso sin Composer
Este ejemplo muestra cómo usar `Facturae-PHP` sin tener configurado un entorno de Composer, solo descargando el código fuente de la librería.

Para ello, se incluye el script "autoload.php" en el directorio raíz, que permite auto-cargar las clases de la librería.

```php
require_once 'ruta/hacia/Facturae-PHP/src/Common/FacturaeSigner.php';
require_once 'ruta/hacia/Facturae-PHP/src/Common/KeyPairReaderTrait.php';
require_once 'ruta/hacia/Facturae-PHP/src/Common/XmlTools.php';
require_once 'ruta/hacia/Facturae-PHP/src/FacturaeTraits/PropertiesTrait.php';
require_once 'ruta/hacia/Facturae-PHP/src/FacturaeTraits/UtilsTrait.php';
require_once 'ruta/hacia/Facturae-PHP/src/FacturaeTraits/SignableTrait.php';
require_once 'ruta/hacia/Facturae-PHP/src/FacturaeTraits/ExportableTrait.php';
require_once 'ruta/hacia/Facturae-PHP/src/Facturae.php';
require_once 'ruta/hacia/Facturae-PHP/src/FacturaeCentre.php';
require_once 'ruta/hacia/Facturae-PHP/src/FacturaeItem.php';
require_once 'ruta/hacia/Facturae-PHP/src/FacturaeParty.php';
require_once 'ruta/hacia/Facturae-PHP/autoload.php'; // <-- Autoloader incluido con la librería

use josemmo\Facturae\Facturae;
use josemmo\Facturae\FacturaeParty;
Expand Down
1 change: 1 addition & 0 deletions doc/entidades/compradores-y-vendedores.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $empresa = new FacturaeParty([
"isLegalEntity" => true, // Se asume true si se omite
"taxNumber" => "A00000000",
"name" => "Perico el de los Palotes S.A.",
"tradeName" => "Peri Co.", // Nombre comercial
"address" => "C/ Falsa, 123",
"postCode" => "12345",
"town" => "Madrid",
Expand Down
2 changes: 1 addition & 1 deletion src/Facturae.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Class for creating electronic invoices that comply with the Spanish FacturaE format.
*/
class Facturae {
const VERSION = "1.8.1";
const VERSION = "1.8.2";
const USER_AGENT = "FacturaePHP/" . self::VERSION;

const SCHEMA_3_2 = "3.2";
Expand Down
11 changes: 7 additions & 4 deletions src/FacturaeParty.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class FacturaeParty {
public $taxNumber = null;
/** @var string|null */
public $name = null;
/** @var string|null */
public $tradeName = null;

/**
* Libro (only for legal entities)
Expand Down Expand Up @@ -182,14 +184,15 @@ public function getXML($includeAdministrativeCentres) {
// Add data exclusive to `LegalEntity`
if ($this->isLegalEntity) {
$xml .= '<CorporateName>' . XmlTools::escape($this->name) . '</CorporateName>';
$fields = array("book", "registerOfCompaniesLocation", "sheet", "folio",
"section", "volume");
if (!empty($this->tradeName)) {
$xml .= '<TradeName>' . XmlTools::escape($this->tradeName) . '</TradeName>';
}

$nonEmptyFields = array();
$fields = ["book", "registerOfCompaniesLocation", "sheet", "folio", "section", "volume"];
$nonEmptyFields = [];
foreach ($fields as $fieldName) {
if (!empty($this->{$fieldName})) $nonEmptyFields[] = $fieldName;
}

if (count($nonEmptyFields) > 0) {
$xml .= '<RegistrationData>';
foreach ($nonEmptyFields as $fieldName) {
Expand Down
1 change: 1 addition & 0 deletions tests/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function testCreateInvoice($schemaVersion, $isPfx) {
$fac->setSeller(new FacturaeParty([
"taxNumber" => "A00000000",
"name" => "Perico el de los Palotes S.A.",
"tradeName" => "Peri Co.",
"address" => "C/ Falsa, 123",
"postCode" => "23456",
"town" => "Madrid",
Expand Down

0 comments on commit edb213c

Please sign in to comment.