-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #116 from eclipxe13/version-2.26.0
Add CCE 2.0 & add move SAT definitions to Retenciones (version 2.26.0)
Showing
20 changed files
with
460 additions
and
13 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
development/ElementsMaker/specifications/ComercioExterior20.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"php-namespace": "CfdiUtils\\Elements\\Cce20", | ||
"prefix": "cce20", | ||
"xml-namespace": "http://www.sat.gob.mx/ComercioExterior20", | ||
"xml-schemalocation": "http://www.sat.gob.mx/sitio_internet/cfd/ComercioExterior20/ComercioExterior20.xsd", | ||
"version-attribute": "Version", | ||
"version-value": "2.0", | ||
"root-element": "ComercioExterior", | ||
"structure": { | ||
"Emisor": { | ||
"Domicilio": {} | ||
}, | ||
"Propietario": { | ||
"multiple": true | ||
}, | ||
"Receptor": { | ||
"Domicilio": {} | ||
}, | ||
"Destinatario": { | ||
"multiple": true, | ||
"Domicilio": { | ||
"multiple": true | ||
} | ||
}, | ||
"Mercancias": { | ||
"Mercancia": { | ||
"multiple": true, | ||
"DescripcionesEspecificas": { | ||
"multiple": true | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class ComercioExterior extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:ComercioExterior'; | ||
} | ||
|
||
public function getChildrenOrder(): array | ||
{ | ||
return [ | ||
'cce20:Emisor', | ||
'cce20:Propietario', | ||
'cce20:Receptor', | ||
'cce20:Destinatario', | ||
'cce20:Mercancias', | ||
]; | ||
} | ||
|
||
public function getFixedAttributes(): array | ||
{ | ||
return [ | ||
'xmlns:cce20' => 'http://www.sat.gob.mx/ComercioExterior20', | ||
'xsi:schemaLocation' => 'http://www.sat.gob.mx/ComercioExterior20' | ||
. ' http://www.sat.gob.mx/sitio_internet/cfd/ComercioExterior20/ComercioExterior20.xsd', | ||
'Version' => '2.0', | ||
]; | ||
} | ||
|
||
public function getEmisor(): Emisor | ||
{ | ||
return $this->helperGetOrAdd(new Emisor()); | ||
} | ||
|
||
public function addEmisor(array $attributes = []): Emisor | ||
{ | ||
$subject = $this->getEmisor(); | ||
$subject->addAttributes($attributes); | ||
return $subject; | ||
} | ||
|
||
public function addPropietario(array $attributes = []): Propietario | ||
{ | ||
$subject = new Propietario($attributes); | ||
$this->addChild($subject); | ||
return $subject; | ||
} | ||
|
||
public function multiPropietario(array ...$elementAttributes): self | ||
{ | ||
foreach ($elementAttributes as $attributes) { | ||
$this->addPropietario($attributes); | ||
} | ||
return $this; | ||
} | ||
|
||
public function getReceptor(): Receptor | ||
{ | ||
return $this->helperGetOrAdd(new Receptor()); | ||
} | ||
|
||
public function addReceptor(array $attributes = []): Receptor | ||
{ | ||
$subject = $this->getReceptor(); | ||
$subject->addAttributes($attributes); | ||
return $subject; | ||
} | ||
|
||
public function addDestinatario(array $attributes = []): Destinatario | ||
{ | ||
$subject = new Destinatario($attributes); | ||
$this->addChild($subject); | ||
return $subject; | ||
} | ||
|
||
public function multiDestinatario(array ...$elementAttributes): self | ||
{ | ||
foreach ($elementAttributes as $attributes) { | ||
$this->addDestinatario($attributes); | ||
} | ||
return $this; | ||
} | ||
|
||
public function getMercancias(): Mercancias | ||
{ | ||
return $this->helperGetOrAdd(new Mercancias()); | ||
} | ||
|
||
public function addMercancias(array $attributes = []): Mercancias | ||
{ | ||
$subject = $this->getMercancias(); | ||
$subject->addAttributes($attributes); | ||
return $subject; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class DescripcionesEspecificas extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:DescripcionesEspecificas'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class Destinatario extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:Destinatario'; | ||
} | ||
|
||
public function addDomicilio(array $attributes = []): Domicilio | ||
{ | ||
$subject = new Domicilio($attributes); | ||
$this->addChild($subject); | ||
return $subject; | ||
} | ||
|
||
public function multiDomicilio(array ...$elementAttributes): self | ||
{ | ||
foreach ($elementAttributes as $attributes) { | ||
$this->addDomicilio($attributes); | ||
} | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class Domicilio extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:Domicilio'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class Emisor extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:Emisor'; | ||
} | ||
|
||
public function getDomicilio(): Domicilio | ||
{ | ||
return $this->helperGetOrAdd(new Domicilio()); | ||
} | ||
|
||
public function addDomicilio(array $attributes = []): Domicilio | ||
{ | ||
$subject = $this->getDomicilio(); | ||
$subject->addAttributes($attributes); | ||
return $subject; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class Mercancia extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:Mercancia'; | ||
} | ||
|
||
public function addDescripcionesEspecificas(array $attributes = []): DescripcionesEspecificas | ||
{ | ||
$subject = new DescripcionesEspecificas($attributes); | ||
$this->addChild($subject); | ||
return $subject; | ||
} | ||
|
||
public function multiDescripcionesEspecificas(array ...$elementAttributes): self | ||
{ | ||
foreach ($elementAttributes as $attributes) { | ||
$this->addDescripcionesEspecificas($attributes); | ||
} | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class Mercancias extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:Mercancias'; | ||
} | ||
|
||
public function addMercancia(array $attributes = []): Mercancia | ||
{ | ||
$subject = new Mercancia($attributes); | ||
$this->addChild($subject); | ||
return $subject; | ||
} | ||
|
||
public function multiMercancia(array ...$elementAttributes): self | ||
{ | ||
foreach ($elementAttributes as $attributes) { | ||
$this->addMercancia($attributes); | ||
} | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class Propietario extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:Propietario'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Common\AbstractElement; | ||
|
||
class Receptor extends AbstractElement | ||
{ | ||
public function getElementName(): string | ||
{ | ||
return 'cce20:Receptor'; | ||
} | ||
|
||
public function getDomicilio(): Domicilio | ||
{ | ||
return $this->helperGetOrAdd(new Domicilio()); | ||
} | ||
|
||
public function addDomicilio(array $attributes = []): Domicilio | ||
{ | ||
$subject = $this->getDomicilio(); | ||
$subject->addAttributes($attributes); | ||
return $subject; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace CfdiUtils\Utils; | ||
|
||
use CfdiUtils\Nodes\NodeInterface; | ||
use CfdiUtils\Nodes\NodeNsDefinitionsMover; | ||
|
||
final class SatNsDefinitionsMover | ||
{ | ||
public function move(NodeInterface $root): void | ||
{ | ||
$nodeNsDefinitionsMover = new NodeNsDefinitionsMover(); | ||
$nodeNsDefinitionsMover->setNamespaceFilter( | ||
function (string $namespaceUri): bool { | ||
return ('http://www.sat.gob.mx/' === (substr($namespaceUri, 0, 22) ?: '')); | ||
} | ||
); | ||
$nodeNsDefinitionsMover->process($root); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
tests/CfdiUtilsTests/Elements/Cce20/ComercioExteriorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace CfdiUtilsTests\Elements\Cce20; | ||
|
||
use CfdiUtils\Elements\Cce20\ComercioExterior; | ||
use CfdiUtils\Elements\Cce20\DescripcionesEspecificas; | ||
use CfdiUtils\Elements\Cce20\Destinatario; | ||
use CfdiUtils\Elements\Cce20\Domicilio; | ||
use CfdiUtils\Elements\Cce20\Emisor; | ||
use CfdiUtils\Elements\Cce20\Mercancia; | ||
use CfdiUtils\Elements\Cce20\Mercancias; | ||
use CfdiUtils\Elements\Cce20\Propietario; | ||
use CfdiUtils\Elements\Cce20\Receptor; | ||
use CfdiUtilsTests\Elements\ElementTestCase; | ||
|
||
final class ComercioExteriorTest extends ElementTestCase | ||
{ | ||
public function testComercioExterior(): void | ||
{ | ||
$element = new ComercioExterior(); | ||
$this->assertElementHasName($element, 'cce20:ComercioExterior'); | ||
$this->assertElementHasOrder($element, [ | ||
'cce20:Emisor', | ||
'cce20:Propietario', | ||
'cce20:Receptor', | ||
'cce20:Destinatario', | ||
'cce20:Mercancias', | ||
]); | ||
$this->assertElementHasFixedAttributes($element, [ | ||
'xmlns:cce20' => 'http://www.sat.gob.mx/ComercioExterior20', | ||
'xsi:schemaLocation' => 'http://www.sat.gob.mx/ComercioExterior20' | ||
. ' http://www.sat.gob.mx/sitio_internet/cfd/ComercioExterior20/ComercioExterior20.xsd', | ||
'Version' => '2.0', | ||
]); | ||
$this->assertElementHasChildSingle($element, Emisor::class); | ||
$this->assertElementHasChildMultiple($element, Propietario::class); | ||
$this->assertElementHasChildSingle($element, Receptor::class); | ||
$this->assertElementHasChildMultiple($element, Destinatario::class); | ||
$this->assertElementHasChildSingle($element, Mercancias::class); | ||
} | ||
|
||
public function testEmisor(): void | ||
{ | ||
$element = new Emisor(); | ||
$this->assertElementHasName($element, 'cce20:Emisor'); | ||
$this->assertElementHasChildSingle($element, Domicilio::class); | ||
} | ||
|
||
public function testDomicilio(): void | ||
{ | ||
$element = new Domicilio(); | ||
$this->assertElementHasName($element, 'cce20:Domicilio'); | ||
} | ||
|
||
public function testPropietario(): void | ||
{ | ||
$element = new Propietario(); | ||
$this->assertElementHasName($element, 'cce20:Propietario'); | ||
} | ||
|
||
public function testReceptor(): void | ||
{ | ||
$element = new Receptor(); | ||
$this->assertElementHasName($element, 'cce20:Receptor'); | ||
$this->assertElementHasChildSingle($element, Domicilio::class); | ||
} | ||
|
||
public function testDestinatario(): void | ||
{ | ||
$element = new Destinatario(); | ||
$this->assertElementHasName($element, 'cce20:Destinatario'); | ||
$this->assertElementHasChildMultiple($element, Domicilio::class); | ||
} | ||
|
||
public function testMercancias(): void | ||
{ | ||
$element = new Mercancias(); | ||
$this->assertElementHasName($element, 'cce20:Mercancias'); | ||
$this->assertElementHasChildMultiple($element, Mercancia::class); | ||
} | ||
|
||
public function testMercancia(): void | ||
{ | ||
$element = new Mercancia(); | ||
$this->assertElementHasName($element, 'cce20:Mercancia'); | ||
$this->assertElementHasChildMultiple($element, DescripcionesEspecificas::class); | ||
} | ||
|
||
public function testDescripcionesEspecificas(): void | ||
{ | ||
$element = new DescripcionesEspecificas(); | ||
$this->assertElementHasName($element, 'cce20:DescripcionesEspecificas'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters