Align tests with new workflow
This commit is contained in:
parent
c3b5a972a1
commit
9b98d45d3b
|
|
@ -18038,16 +18038,16 @@
|
|||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v3.85.1",
|
||||
"version": "v3.86.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
|
||||
"reference": "2fb6d7f6c3398dca5786a1635b27405d73a417ba"
|
||||
"reference": "4a952bd19dc97879b0620f495552ef09b55f7d36"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2fb6d7f6c3398dca5786a1635b27405d73a417ba",
|
||||
"reference": "2fb6d7f6c3398dca5786a1635b27405d73a417ba",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/4a952bd19dc97879b0620f495552ef09b55f7d36",
|
||||
"reference": "4a952bd19dc97879b0620f495552ef09b55f7d36",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -18131,7 +18131,7 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.85.1"
|
||||
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.86.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
|
@ -18139,7 +18139,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-07-29T22:22:50+00:00"
|
||||
"time": "2025-08-13T22:36:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "hamcrest/hamcrest-php",
|
||||
|
|
|
|||
|
|
@ -714,452 +714,6 @@ $this->assertCount(0, $errors);
|
|||
$this->assertEquals('S', $deserialized->getEncadenamiento()->getPrimerRegistro());
|
||||
}
|
||||
|
||||
public function testCreateAndSerializeInvoiceWithThirdPartyIssuer(): void
|
||||
{
|
||||
$invoice = new Invoice();
|
||||
$invoice
|
||||
->setIdVersion('1.0')
|
||||
->setIdFactura((new \App\Services\EDocument\Standards\Verifactu\Models\IDFactura())
|
||||
->setIdEmisorFactura('B12345678')
|
||||
->setNumSerieFactura('FAC-2023-009')
|
||||
->setFechaExpedicionFactura('01-01-2023'))
|
||||
->setNombreRazonEmisor('Empresa Ejemplo SL')
|
||||
->setTipoFactura('F1')
|
||||
->setDescripcionOperacion('Factura emitida por tercero')
|
||||
->setEmitidaPorTerceroODestinatario('T')
|
||||
->setCuotaTotal(21.00)
|
||||
->setImporteTotal(100.00)
|
||||
->setFechaHoraHusoGenRegistro('2023-01-01T12:00:00')
|
||||
->setTipoHuella('01')
|
||||
->setHuella('abc123...');
|
||||
|
||||
// Set up the third party issuer
|
||||
$tercero = new PersonaFisicaJuridica();
|
||||
$tercero
|
||||
->setNif('B98765432')
|
||||
->setRazonSocial('Tercero Emisor SL');
|
||||
$invoice->setTercero($tercero);
|
||||
|
||||
// Add desglose
|
||||
$desglose = new Desglose();
|
||||
$desglose->setDesgloseIVA([
|
||||
'Impuesto' => '01',
|
||||
'ClaveRegimen' => '02',
|
||||
'CalificacionOperacion' => 'S2',
|
||||
'BaseImponible' => 100.00,
|
||||
'TipoImpositivo' => 21,
|
||||
'Cuota' => 21.00
|
||||
]);
|
||||
$invoice->setDesglose($desglose);
|
||||
|
||||
// Add encadenamiento (required)
|
||||
$encadenamiento = new Encadenamiento();
|
||||
$encadenamiento->setPrimerRegistro('S');
|
||||
$invoice->setEncadenamiento($encadenamiento);
|
||||
|
||||
// Add sistema informatico with all required fields
|
||||
$sistema = new SistemaInformatico();
|
||||
$sistema
|
||||
->setNombreRazon('Sistema de Facturación')
|
||||
->setNif('B12345678')
|
||||
->setNombreSistemaInformatico('SistemaFacturacion')
|
||||
->setIdSistemaInformatico('01')
|
||||
->setVersion('1.0')
|
||||
->setNumeroInstalacion('INST-001')
|
||||
->setTipoUsoPosibleSoloVerifactu('S')
|
||||
->setTipoUsoPosibleMultiOT('S')
|
||||
->setIndicadorMultiplesOT('S');
|
||||
$invoice->setSistemaInformatico($sistema);
|
||||
|
||||
// Generate XML string
|
||||
$xml = $invoice->toXmlString();
|
||||
|
||||
// Debug output
|
||||
// echo "\nGenerated XML:\n";
|
||||
// echo $xml;
|
||||
// echo "\n\n";
|
||||
|
||||
|
||||
$xslt = new VerifactuDocumentValidator($xml);
|
||||
$xslt->validate();
|
||||
$errors = $xslt->getVerifactuErrors();
|
||||
|
||||
if(count($errors) > 0) {
|
||||
nlog($xml);
|
||||
nlog($errors);
|
||||
}
|
||||
|
||||
$this->assertCount(0, $errors);
|
||||
|
||||
|
||||
// Test deserialization
|
||||
$deserialized = Invoice::fromXml($xml);
|
||||
$this->assertEquals('T', $deserialized->getEmitidaPorTerceroODestinatario());
|
||||
$this->assertEquals('B98765432', $deserialized->getTercero()->getNif());
|
||||
$this->assertEquals('Tercero Emisor SL', $deserialized->getTercero()->getRazonSocial());
|
||||
}
|
||||
|
||||
public function testCreateAndSerializeInvoiceWithMacroData(): void
|
||||
{
|
||||
$invoice = new Invoice();
|
||||
$invoice
|
||||
->setIdVersion('1.0')
|
||||
->setIdFactura((new \App\Services\EDocument\Standards\Verifactu\Models\IDFactura())
|
||||
->setIdEmisorFactura('B12345678')
|
||||
->setNumSerieFactura('FAC-2023-010')
|
||||
->setFechaExpedicionFactura('01-01-2023'))
|
||||
->setNombreRazonEmisor('Empresa Ejemplo SL')
|
||||
->setTipoFactura('F1')
|
||||
->setMacrodato('S')
|
||||
->setDescripcionOperacion('Factura con macrodato')
|
||||
->setCuotaTotal(21.00)
|
||||
->setImporteTotal(100.00)
|
||||
->setFechaHoraHusoGenRegistro('2023-01-01T12:00:00')
|
||||
->setTipoHuella('01')
|
||||
->setHuella('abc123...');
|
||||
|
||||
// Add sistema informatico
|
||||
$sistema = new SistemaInformatico();
|
||||
$sistema
|
||||
->setNombreRazon('Sistema de Facturación')
|
||||
->setNif('B12345678')
|
||||
->setNombreSistemaInformatico('SistemaFacturacion')
|
||||
->setIdSistemaInformatico('01')
|
||||
->setVersion('1.0')
|
||||
->setNumeroInstalacion('INST-001')
|
||||
->setTipoUsoPosibleSoloVerifactu('S')
|
||||
->setTipoUsoPosibleMultiOT('S')
|
||||
->setIndicadorMultiplesOT('S');
|
||||
$invoice->setSistemaInformatico($sistema);
|
||||
|
||||
// Add Desglose
|
||||
$desglose = new Desglose();
|
||||
$desglose->setDesgloseIVA([
|
||||
'Impuesto' => '01',
|
||||
'ClaveRegimen' => '01',
|
||||
'CalificacionOperacion' => 'S1',
|
||||
'BaseImponible' => 100.00,
|
||||
'TipoImpositivo' => 21.00,
|
||||
'Cuota' => 21.00
|
||||
]);
|
||||
$invoice->setDesglose($desglose);
|
||||
|
||||
// Add Encadenamiento
|
||||
$encadenamiento = new Encadenamiento();
|
||||
$encadenamiento->setPrimerRegistro('S');
|
||||
$invoice->setEncadenamiento($encadenamiento);
|
||||
|
||||
// Generate XML string
|
||||
$xml = $invoice->toXmlString();
|
||||
|
||||
// Debug output
|
||||
// echo "\nGenerated XML:\n";
|
||||
// echo $xml;
|
||||
// echo "\n\n";
|
||||
|
||||
|
||||
$xslt = new VerifactuDocumentValidator($xml);
|
||||
$xslt->validate();
|
||||
$errors = $xslt->getVerifactuErrors();
|
||||
|
||||
if(count($errors) > 0) {
|
||||
nlog($xml);
|
||||
nlog($errors);
|
||||
}
|
||||
|
||||
$this->assertCount(0, $errors);
|
||||
|
||||
|
||||
// Test deserialization
|
||||
$deserialized = Invoice::fromXml($xml);
|
||||
$this->assertEquals('S', $deserialized->getMacrodato());
|
||||
}
|
||||
|
||||
public function testCreateAndSerializeInvoiceWithAgreementData(): void
|
||||
{
|
||||
$invoice = new Invoice();
|
||||
$invoice->setIdVersion('1.0')
|
||||
->setIdFactura((new \App\Services\EDocument\Standards\Verifactu\Models\IDFactura())
|
||||
->setIdEmisorFactura('B12345678')
|
||||
->setNumSerieFactura('FAC-2023-012')
|
||||
->setFechaExpedicionFactura('01-01-2023'))
|
||||
->setNombreRazonEmisor('Empresa Ejemplo SL')
|
||||
->setTipoFactura('F1')
|
||||
->setDescripcionOperacion('Factura con datos de acuerdo')
|
||||
->setCuotaTotal(21)
|
||||
->setImporteTotal(100)
|
||||
->setFechaHoraHusoGenRegistro('2023-01-01T12:00:00')
|
||||
->setTipoHuella('01')
|
||||
->setHuella('abc123...')
|
||||
->setNumRegistroAcuerdoFacturacion('REG-001')
|
||||
->setIdAcuerdoSistemaInformatico('AGR-001');
|
||||
|
||||
// Set up Desglose
|
||||
$desglose = new Desglose();
|
||||
$desglose->setDesgloseIVA([
|
||||
'Impuesto' => '01',
|
||||
'ClaveRegimen' => '02',
|
||||
'CalificacionOperacion' => 'S2',
|
||||
'BaseImponible' => 100.00,
|
||||
'TipoImpositivo' => 21.00,
|
||||
'Cuota' => 21.00
|
||||
]);
|
||||
$invoice->setDesglose($desglose);
|
||||
|
||||
// Set up Encadenamiento
|
||||
$encadenamiento = new Encadenamiento();
|
||||
$encadenamiento->setPrimerRegistro('S');
|
||||
$invoice->setEncadenamiento($encadenamiento);
|
||||
|
||||
// Set up SistemaInformatico
|
||||
$sistema = new SistemaInformatico();
|
||||
$sistema->setNombreRazon('Sistema de Facturación')
|
||||
->setNIF('B12345678')
|
||||
->setNombreSistemaInformatico('SistemaFacturacion')
|
||||
->setIdSistemaInformatico('01')
|
||||
->setVersion('1.0')
|
||||
->setNumeroInstalacion('INST-001')
|
||||
->setTipoUsoPosibleSoloVerifactu('S')
|
||||
->setTipoUsoPosibleMultiOT('S')
|
||||
->setIndicadorMultiplesOT('S');
|
||||
$invoice->setSistemaInformatico($sistema);
|
||||
|
||||
$xml = $invoice->toXmlString();
|
||||
|
||||
$xslt = new VerifactuDocumentValidator($xml);
|
||||
$xslt->validate();
|
||||
$errors = $xslt->getVerifactuErrors();
|
||||
|
||||
if(count($errors) > 0) {
|
||||
nlog($xml);
|
||||
nlog($errors);
|
||||
}
|
||||
|
||||
$this->assertCount(0, $errors);
|
||||
|
||||
|
||||
// Deserialize and verify
|
||||
$deserializedInvoice = Invoice::fromXml($xml);
|
||||
$this->assertEquals('REG-001', $deserializedInvoice->getNumRegistroAcuerdoFacturacion());
|
||||
$this->assertEquals('AGR-001', $deserializedInvoice->getIdAcuerdoSistemaInformatico());
|
||||
}
|
||||
|
||||
public function testCreateAndSerializeInvoiceWithRejectionAndCorrection()
|
||||
{
|
||||
$invoice = new Invoice();
|
||||
$invoice->setIdVersion('1.0')
|
||||
->setIdFactura((new \App\Services\EDocument\Standards\Verifactu\Models\IDFactura())
|
||||
->setIdEmisorFactura('B12345678')
|
||||
->setNumSerieFactura('FAC-2023-013')
|
||||
->setFechaExpedicionFactura('01-01-2023'))
|
||||
->setNombreRazonEmisor('Empresa Ejemplo SL')
|
||||
->setSubsanacion('S')
|
||||
->setRechazoPrevio('S')
|
||||
->setTipoFactura('F1')
|
||||
->setDescripcionOperacion('Factura con rechazo y subsanación')
|
||||
->setCuotaTotal(21)
|
||||
->setImporteTotal(100)
|
||||
->setFechaHoraHusoGenRegistro('2023-01-01T12:00:00')
|
||||
->setTipoHuella('01')
|
||||
->setHuella('abc123...');
|
||||
|
||||
// Add proper Desglose
|
||||
$desglose = new Desglose();
|
||||
$desglose->setDesgloseFactura([
|
||||
'Impuesto' => '01',
|
||||
'ClaveRegimen' => '02',
|
||||
'CalificacionOperacion' => 'S2',
|
||||
'TipoImpositivo' => 21.00,
|
||||
'BaseImponible' => 100.00,
|
||||
'Cuota' => 21.00
|
||||
]);
|
||||
$invoice->setDesglose($desglose);
|
||||
|
||||
// Add proper Encadenamiento
|
||||
$encadenamiento = new Encadenamiento();
|
||||
$encadenamiento->setPrimerRegistro('S');
|
||||
$invoice->setEncadenamiento($encadenamiento);
|
||||
|
||||
// Add SistemaInformatico
|
||||
$sistemaInformatico = new SistemaInformatico();
|
||||
$sistemaInformatico->setNombreRazon('Sistema de Facturación')
|
||||
->setNif('B12345678')
|
||||
->setNombreSistemaInformatico('SistemaFacturacion')
|
||||
->setIdSistemaInformatico('01')
|
||||
->setVersion('1.0')
|
||||
->setNumeroInstalacion('INST-001')
|
||||
->setTipoUsoPosibleSoloVerifactu('S')
|
||||
->setTipoUsoPosibleMultiOT('S')
|
||||
->setIndicadorMultiplesOT('S');
|
||||
$invoice->setSistemaInformatico($sistemaInformatico);
|
||||
|
||||
$xml = $invoice->toXmlString();
|
||||
$this->assertNotEmpty($xml);
|
||||
|
||||
$xslt = new VerifactuDocumentValidator($xml);
|
||||
$xslt->validate();
|
||||
$errors = $xslt->getVerifactuErrors();
|
||||
|
||||
if(count($errors) > 0) {
|
||||
nlog($xml);
|
||||
nlog($errors);
|
||||
}
|
||||
|
||||
$this->assertCount(0, $errors);
|
||||
|
||||
|
||||
// Test deserialization
|
||||
$deserializedInvoice = Invoice::fromXml($xml);
|
||||
$this->assertEquals('S', $deserializedInvoice->getSubsanacion());
|
||||
$this->assertEquals('S', $deserializedInvoice->getRechazoPrevio());
|
||||
}
|
||||
|
||||
public function testCreateAndSerializeInvoiceWithOperationDate(): void
|
||||
{
|
||||
$invoice = new Invoice();
|
||||
$invoice
|
||||
->setIdVersion('1.0')
|
||||
->setIdFactura((new \App\Services\EDocument\Standards\Verifactu\Models\IDFactura())
|
||||
->setIdEmisorFactura('B12345678')
|
||||
->setNumSerieFactura('FAC-2023-014')
|
||||
->setFechaExpedicionFactura('01-01-2023'))
|
||||
->setNombreRazonEmisor('Empresa Ejemplo SL')
|
||||
->setTipoFactura('F1')
|
||||
->setDescripcionOperacion('Factura con fecha de operación')
|
||||
->setFechaOperacion('2023-01-01')
|
||||
->setCuotaTotal(21.00)
|
||||
->setImporteTotal(100.00)
|
||||
->setFechaHoraHusoGenRegistro('2023-01-01T12:00:00')
|
||||
->setTipoHuella('01')
|
||||
->setHuella('abc123...');
|
||||
|
||||
// Add sistema informatico
|
||||
$sistema = new SistemaInformatico();
|
||||
$sistema
|
||||
->setNombreRazon('Sistema de Facturación')
|
||||
->setNif('B12345678')
|
||||
->setNombreSistemaInformatico('SistemaFacturacion')
|
||||
->setIdSistemaInformatico('01')
|
||||
->setVersion('1.0')
|
||||
->setNumeroInstalacion('INST-001');
|
||||
$invoice->setSistemaInformatico($sistema);
|
||||
|
||||
// Add Desglose
|
||||
$desglose = new Desglose();
|
||||
$desglose->setDesgloseFactura([
|
||||
'Impuesto' => '01',
|
||||
'ClaveRegimen' => '02',
|
||||
'CalificacionOperacion' => 'S2',
|
||||
'TipoImpositivo' => '21.00',
|
||||
'BaseImponibleOimporteNoSujeto' => '100.00',
|
||||
'CuotaRepercutida' => '21.00'
|
||||
]);
|
||||
$invoice->setDesglose($desglose);
|
||||
|
||||
// Add Encadenamiento
|
||||
$encadenamiento = new Encadenamiento();
|
||||
$encadenamiento->setPrimerRegistro('S');
|
||||
$invoice->setEncadenamiento($encadenamiento);
|
||||
|
||||
// Generate XML string
|
||||
$xml = $invoice->toXmlString();
|
||||
|
||||
// // Debug output
|
||||
// echo "\nGenerated XML:\n";
|
||||
// echo $xml;
|
||||
// echo "\n\n";
|
||||
|
||||
|
||||
$xslt = new VerifactuDocumentValidator($xml);
|
||||
$xslt->validate();
|
||||
$errors = $xslt->getVerifactuErrors();
|
||||
|
||||
if(count($errors) > 0) {
|
||||
nlog($xml);
|
||||
nlog($errors);
|
||||
}
|
||||
|
||||
$this->assertCount(0, $errors);
|
||||
|
||||
|
||||
// Test deserialization
|
||||
$deserialized = Invoice::fromXml($xml);
|
||||
$this->assertEquals('01-01-2023', $deserialized->getFechaOperacion());
|
||||
}
|
||||
|
||||
public function testCreateAndSerializeInvoiceWithCoupon(): void
|
||||
{
|
||||
$invoice = new Invoice();
|
||||
$invoice
|
||||
->setIdVersion('1.0')
|
||||
->setIdFactura((new \App\Services\EDocument\Standards\Verifactu\Models\IDFactura())
|
||||
->setIdEmisorFactura('B12345678')
|
||||
->setNumSerieFactura('FAC-2023-015')
|
||||
->setFechaExpedicionFactura('01-01-2023'))
|
||||
->setNombreRazonEmisor('Empresa Ejemplo SL')
|
||||
->setTipoFactura('F1')
|
||||
->setDescripcionOperacion('Factura con cupón')
|
||||
->setCupon('S') // Set cupon to 'S' to indicate it has a coupon
|
||||
->setCuotaTotal(21.00)
|
||||
->setImporteTotal(100.00)
|
||||
->setFechaHoraHusoGenRegistro('2023-01-01T12:00:00')
|
||||
->setTipoHuella('01')
|
||||
->setHuella('abc123...');
|
||||
|
||||
// Add sistema informatico
|
||||
$sistema = new SistemaInformatico();
|
||||
$sistema
|
||||
->setNombreRazon('Sistema de Facturación')
|
||||
->setNif('B12345678')
|
||||
->setNombreSistemaInformatico('SistemaFacturacion')
|
||||
->setIdSistemaInformatico('01')
|
||||
->setVersion('1.0')
|
||||
->setNumeroInstalacion('INST-001');
|
||||
$invoice->setSistemaInformatico($sistema);
|
||||
|
||||
// Add Desglose
|
||||
$desglose = new Desglose();
|
||||
$desglose->setDesgloseFactura([
|
||||
'Impuesto' => '01',
|
||||
'ClaveRegimen' => '01',
|
||||
'CalificacionOperacion' => 'S1',
|
||||
'TipoImpositivo' => '21.00',
|
||||
'BaseImponibleOimporteNoSujeto' => '100.00',
|
||||
'CuotaRepercutida' => '21.00'
|
||||
]);
|
||||
$invoice->setDesglose($desglose);
|
||||
|
||||
// Add Encadenamiento
|
||||
$encadenamiento = new Encadenamiento();
|
||||
$encadenamiento->setPrimerRegistro('S');
|
||||
$invoice->setEncadenamiento($encadenamiento);
|
||||
|
||||
// Generate XML string
|
||||
$xml = $invoice->toXmlString();
|
||||
|
||||
// Debug output
|
||||
// echo "\nGenerated XML:\n";
|
||||
// echo $xml;
|
||||
// echo "\n\n";
|
||||
|
||||
|
||||
$xslt = new VerifactuDocumentValidator($xml);
|
||||
$xslt->validate();
|
||||
$errors = $xslt->getVerifactuErrors();
|
||||
|
||||
if(count($errors) > 0) {
|
||||
nlog($xml);
|
||||
nlog($errors);
|
||||
}
|
||||
|
||||
$this->assertCount(0, $errors);
|
||||
|
||||
|
||||
// Test deserialization
|
||||
$deserialized = Invoice::fromXml($xml);
|
||||
$this->assertNotNull($deserialized->getCupon());
|
||||
$this->assertEquals('S', $deserialized->getCupon());
|
||||
}
|
||||
|
||||
public function testInvalidTipoFacturaThrowsException(): void
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue