Skip to content

Commit

Permalink
Se agrega toString() a las entidades para que resuelvan correctamente…
Browse files Browse the repository at this point in the history
… en el TemplateDataHandler.
  • Loading branch information
estebandelaf committed Jan 13, 2025
1 parent a5e9ad1 commit 0741dd3
Show file tree
Hide file tree
Showing 26 changed files with 303 additions and 24 deletions.
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function getDatos(): array
// Si los datos del DTE no están determinados se crean de una manera
// estandarizada compatible con los datos de entrada normalizados.
if (!isset($this->datos)) {
$array = $this->xmlDocument->query('/');
$array = $this->xmlDocument->toArray();

$array = $array['DTE']['Documento']
?? $array['DTE']['Exportaciones']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ interface DocumentBagManagerWorkerInterface extends WorkerInterface
*
* Se pueden pasar diferentes tipos de datos de origen:
*
* - `string`: Datos de entrada para ser parseados. Debe empezar con el
* prefijo `parser.strategy.xyz:` para que los datos sean parseados.
* - `array`: Datos parseados desde los datos de entrada.
* - `XmlInterface`: Una instancia del documento XML.
* - `DocumentInterface`: Una instancia del documento tributario.
* - `string`: Datos de entrada para ser parseados y normalizados. Debe
* empezar con el prefijo `parser.strategy.xyz:` para que los datos sean
* parseados.
* - `array`: Datos ya normalizados.
* - `XmlInterface`: Una instancia del documento XML con sus datos
* normalizado.
* - `DocumentInterface`: Una instancia del documento tributario con sus
* datos normalizados.
*
* @param string|array|XmlInterface|DocumentInterface $source Datos de origen.
* @param bool $normalizeAll Indica si se deben normalizar todos los datos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ public function getTipoSobre(): ?TipoSobre;
|--------------------------------------------------------------------------
*/

/**
* Indica si el documento es de tipo guía de despacho.
*
* @return boolean
*/
public function esGuiaDespacho(): bool;

/**
* Indica si el documento es de tipo boleta.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class AduanaClausulaVenta extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class AduanaFormaPago extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class AduanaModalidadVenta extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
*/
class AduanaMoneda extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}

/**
* Entrega el código ISO 4217 asociado a la moneda.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Package/Billing/Component/Document/Entity/AduanaPais.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class AduanaPais extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class AduanaPuerto extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class AduanaTipoBulto extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class AduanaTransporte extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class AduanaUnidad extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
8 changes: 8 additions & 0 deletions src/Package/Billing/Component/Document/Entity/Comuna.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
#[DEM\Entity(repositoryClass: ComunaRepository::class)]
class Comuna extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('nombre');
}

/**
* Obtiene el código de la comuna.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Package/Billing/Component/Document/Entity/FormaPago.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class FormaPago extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class FormaPagoExportacion extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
#[DEM\Entity(repositoryClass: ImpuestoAdicionalRetencionRepository::class)]
class ImpuestoAdicionalRetencion extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}

/**
* Obtiene el código del impuesto o retención.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Package/Billing/Component/Document/Entity/MedioPago.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,11 @@
*/
class MedioPago extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}
}
72 changes: 72 additions & 0 deletions src/Package/Billing/Component/Document/Entity/Moneda.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,68 @@ enum Moneda: string
self::XXX->value => 2,
];

/**
* Símbolos de las monedas reconocidas.
*
* @var array
*/
private const SIMBOLOS = [
self::CLP->value => '$',
self::CLF->value => 'UF',
self::UTM->value => 'UTM',
self::UTA->value => 'UTA',
self::USD->value => '$',
self::EUR->value => '',
self::BTC->value => '',
self::ARS->value => '$',
self::GBP->value => '£',
self::SEK->value => 'kr',
self::HKD->value => 'HK$',
self::ZAR->value => 'R',
self::COP->value => '$',
self::MXN->value => '$',
self::VES->value => 'Bs.',
self::SGD->value => 'S$',
self::INR->value => '',
self::TWD->value => 'NT$',
self::AED->value => 'د.إ',
self::KRW->value => '',
self::PLN->value => '',
self::CZK->value => '',
self::HUF->value => 'Ft',
self::THB->value => '฿',
self::TRY->value => '',
self::MYR->value => 'RM',
self::RUB->value => '',
self::IDR->value => 'Rp',
self::UAH->value => '',
self::ILS->value => '',
self::PHP->value => '',
self::SAR->value => '',
self::PKR->value => '',
self::VND->value => '',
self::EGP->value => '£',
self::RON->value => 'lei',
self::ISK->value => 'kr',
self::IRR->value => '',
self::CRC->value => '',
self::PAB->value => 'B/.',
self::PYG->value => '',
self::PEN->value => 'S/',
self::UYU->value => '$U',
self::AUD->value => 'A$',
self::BOB->value => 'Bs.',
self::CNY->value => '¥',
self::BRL->value => 'R$',
self::DKK->value => 'kr',
self::CAD->value => 'C$',
self::JPY->value => '¥',
self::CHF->value => 'CHF',
self::NOK->value => 'kr',
self::NZD->value => 'NZ$',
self::XXX->value => '',
];

/**
* Entrega la cantidad de decimales de la moneda.
*
Expand All @@ -372,4 +434,14 @@ public function getDecimales(): int
{
return self::DECIMALES[$this->value];
}

/**
* Entrega el símbolo de la moneda.
*
* @return string
*/
public function getSimbolo(): string
{
return self::SIMBOLOS[$this->value];
}
}
24 changes: 24 additions & 0 deletions src/Package/Billing/Component/Document/Entity/TagXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,28 @@
*/
class TagXml extends Entity
{
/**
* {@inheritDoc}
*/
public function __toString(): string
{
return $this->getAttribute('glosa');
}

/**
* Entrega la entidad asociada al tag XML si existe una.
*
* La entidad estará disponible cuando exista un repositorio asociado que
* maneje el tag XML (sus glosas).
*
* @return string|null
*/
public function getEntity(): ?string
{
if (!$this->hasAttribute('entity')) {
return null;
}

return $this->getAttribute('entity');
}
}
Loading

0 comments on commit 0741dd3

Please sign in to comment.