Skip to content

Commit

Permalink
Elementos de CartaPorte (#73)
Browse files Browse the repository at this point in the history
Se agregan los elementos de Carta Porte 1.0, Gracias @AndreyPootMay
Closes #70
  • Loading branch information
AndreyPootMay authored Nov 9, 2021
1 parent 988a9d8 commit 40e0421
Show file tree
Hide file tree
Showing 52 changed files with 2,205 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/Arrendatario.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class Arrendatario extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:Arrendatario';
}

public function getDomicilio(): Domicilio
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->helperGetOrAdd(new Domicilio());
}

public function addDomicilio(array $attributes = []): Domicilio
{
$domicilio = $this->getDomicilio();
$domicilio->addAttributes($attributes);

return $domicilio;
}
}
41 changes: 41 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/AutotransporteFederal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class AutotransporteFederal extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:AutotransporteFederal';
}

public function addIdentificacionVehicular(array $attributes = []): IdentificacionVehicular
{
$identificacionVehicular = new IdentificacionVehicular($attributes);
$this->addChild($identificacionVehicular);

return $identificacionVehicular;
}

public function getIdentificacionVehicular(): IdentificacionVehicular
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->helperGetOrAdd(new IdentificacionVehicular());
}

public function addRemolques(array $attributes = []): Remolques
{
$remolques = new Remolques($attributes);
$this->addChild($remolques);

return $remolques;
}

public function getRemolques(): Remolques
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->helperGetOrAdd(new Remolques());
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/CantidadTransporta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class CantidadTransporta extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:CantidadTransporta';
}
}
29 changes: 29 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/Carro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class Carro extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:Carro';
}

public function addContenedor(array $attributes = []): Contenedor
{
$contenedor = new Contenedor($attributes);
$this->addChild($contenedor);

return $contenedor;
}

public function multiContenedor(array ...$elementAttributes): self
{
foreach ($elementAttributes as $attributes) {
$this->addContenedor($attributes);
}
return $this;
}
}
74 changes: 74 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/CartaPorte.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class CartaPorte extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:CartaPorte';
}

public function getChildrenOrder(): array
{
return [
'cartaporte:Ubicaciones',
'cartaporte:Mercancias',
'cartaporte:FiguraTransporte',
];
}

public function getFixedAttributes(): array
{
return [
'xmlns:cartaporte' => 'http://www.sat.gob.mx/cartaporte',
'xsi:schemaLocation' => 'http://www.sat.gob.mx/cartaporte'
. ' http://www.sat.gob.mx/sitio_internet/cfd/CartaPorte/CartaPorte.xsd',
'Version' => '1.0',
];
}

public function getUbicaciones(): Ubicaciones
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->helperGetOrAdd(new Ubicaciones());
}

public function addUbicaciones(array $attributes = []): Ubicaciones
{
$ubicaciones = $this->getUbicaciones();
$ubicaciones->addAttributes($attributes);

return $ubicaciones;
}

public function getMercancias(): Mercancias
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->helperGetOrAdd(new Mercancias());
}

public function addMercancias(array $attributes = []): Mercancias
{
$mercancias = $this->getMercancias();
$mercancias->addAttributes($attributes);

return $mercancias;
}

public function getFiguraTransporte(): FiguraTransporte
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->helperGetOrAdd(new FiguraTransporte());
}

public function addFiguraTransporte(array $attributes = []): FiguraTransporte
{
$figuraTransporte = $this->getFiguraTransporte();
$figuraTransporte->addAttributes($attributes);

return $figuraTransporte;
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/Contenedor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class Contenedor extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:Contenedor';
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/DerechosDePaso.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class DerechosDePaso extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:DerechosDePaso';
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/Destino.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class Destino extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:Destino';
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/DetalleMercancia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class DetalleMercancia extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:DetalleMercancia';
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/Domicilio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class Domicilio extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:Domicilio';
}
}
77 changes: 77 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/FiguraTransporte.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class FiguraTransporte extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:FiguraTransporte';
}

public function addOperadores(array $attributes = []): Operadores
{
$operadores = new Operadores($attributes);
$this->addChild($operadores);

return $operadores;
}

public function multiOperadores(array ...$elementAttributes): self
{
foreach ($elementAttributes as $attributes) {
$this->addOperadores($attributes);
}
return $this;
}

public function addPropietario(array $attributes = []): Propietario
{
$propietario = new Propietario($attributes);
$this->addChild($propietario);

return $propietario;
}

public function multiPropietario(array ...$elementAttributes): self
{
foreach ($elementAttributes as $attributes) {
$this->addPropietario($attributes);
}
return $this;
}

public function addArrendatario(array $attributes = []): Arrendatario
{
$arrendatario = new Arrendatario($attributes);
$this->addChild($arrendatario);

return $arrendatario;
}

public function multiArrendatario(array ...$elementAttributes): self
{
foreach ($elementAttributes as $attributes) {
$this->addArrendatario($attributes);
}
return $this;
}

public function addNotificado(array $attributes = []): Notificado
{
$arrendatario = new Notificado($attributes);
$this->addChild($arrendatario);

return $arrendatario;
}

public function multiNotificado(array ...$elementAttributes): self
{
foreach ($elementAttributes as $attributes) {
$this->addNotificado($attributes);
}
return $this;
}
}
13 changes: 13 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/IdentificacionVehicular.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class IdentificacionVehicular extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:IdentificacionVehicular';
}
}
43 changes: 43 additions & 0 deletions src/CfdiUtils/Elements/CartaPorte10/Mercancia.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace CfdiUtils\Elements\CartaPorte10;

use CfdiUtils\Elements\Common\AbstractElement;

class Mercancia extends AbstractElement
{
public function getElementName(): string
{
return 'cartaporte:Mercancia';
}

public function addCantidadTransporta(array $attributes = []): CantidadTransporta
{
$cantidadTransporta = new CantidadTransporta($attributes);
$this->addChild($cantidadTransporta);

return $cantidadTransporta;
}

public function multiCantidadTransporta(array ...$elementAttributes): self
{
foreach ($elementAttributes as $attributes) {
$this->addCantidadTransporta($attributes);
}
return $this;
}

public function addDetalleMercancia(array $attributes = []): DetalleMercancia
{
$detalleMercancia = new DetalleMercancia($attributes);
$this->addChild($detalleMercancia);

return $detalleMercancia;
}

public function getDetalleMercancia(): DetalleMercancia
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return $this->helperGetOrAdd(new DetalleMercancia());
}
}
Loading

3 comments on commit 40e0421

@ramelp
Copy link

@ramelp ramelp commented on 40e0421 Nov 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndreyPootMay
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eclipxe13
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hola @ramelp !

La Carta Porte 2.0 se debe usar a partir de 2021-12-01, aún no debería utilizarse.

El inicio de vigencia del complemento Carta Porte versión 2.0, será a partir del 1 de diciembre de 2021

Las diferencias entre Carta Porte 2.0 y 1.0 no son muchas pero sí son sustaciales.
Lo mejor sería abrir un issue independiente para crear también los Elementos (code helpers) de este estándar.
Ambas versiones pueden convivir en la librería porque tienen espacios de nombres diferentes.

Please sign in to comment.