From 0741dd3e736dc68199152c3aa0a594db065d49c4 Mon Sep 17 00:00:00 2001 From: Esteban De La Fuente Rubio Date: Mon, 13 Jan 2025 17:08:49 -0300 Subject: [PATCH] Se agrega toString() a las entidades para que resuelvan correctamente en el TemplateDataHandler. --- composer.lock | 20 +++--- .../Document/Abstract/AbstractDocument.php | 2 +- .../DocumentBagManagerWorkerInterface.php | 13 ++-- .../Contract/TipoDocumentoInterface.php | 7 ++ .../Document/Entity/AduanaClausulaVenta.php | 7 ++ .../Document/Entity/AduanaFormaPago.php | 7 ++ .../Document/Entity/AduanaModalidadVenta.php | 7 ++ .../Document/Entity/AduanaMoneda.php | 8 +++ .../Component/Document/Entity/AduanaPais.php | 7 ++ .../Document/Entity/AduanaPuerto.php | 7 ++ .../Document/Entity/AduanaTipoBulto.php | 7 ++ .../Document/Entity/AduanaTransporte.php | 7 ++ .../Document/Entity/AduanaUnidad.php | 7 ++ .../Component/Document/Entity/Comuna.php | 8 +++ .../Component/Document/Entity/FormaPago.php | 7 ++ .../Document/Entity/FormaPagoExportacion.php | 7 ++ .../Entity/ImpuestoAdicionalRetencion.php | 8 +++ .../Component/Document/Entity/MedioPago.php | 7 ++ .../Component/Document/Entity/Moneda.php | 72 +++++++++++++++++++ .../Component/Document/Entity/TagXml.php | 24 +++++++ .../Document/Entity/TipoDocumento.php | 17 +++++ .../Component/Document/Entity/Traslado.php | 7 ++ .../Document/Service/TemplateDataHandler.php | 16 +++-- .../Worker/DocumentBagManagerWorker.php | 9 +-- .../Contract/EmisorInterface.php | 14 ++++ .../TradingParties/Entity/Emisor.php | 25 +++++++ 26 files changed, 303 insertions(+), 24 deletions(-) diff --git a/composer.lock b/composer.lock index b8d54ca..8e05321 100644 --- a/composer.lock +++ b/composer.lock @@ -157,12 +157,12 @@ "source": { "type": "git", "url": "https://github.com/derafu/derafu-lib-core.git", - "reference": "db8c155b4a6434f0dfd38e0ed2d09741a14fd7d3" + "reference": "5e368029d958ac98fa86855f79675fcecbc62d20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/derafu/derafu-lib-core/zipball/db8c155b4a6434f0dfd38e0ed2d09741a14fd7d3", - "reference": "db8c155b4a6434f0dfd38e0ed2d09741a14fd7d3", + "url": "https://api.github.com/repos/derafu/derafu-lib-core/zipball/5e368029d958ac98fa86855f79675fcecbc62d20", + "reference": "5e368029d958ac98fa86855f79675fcecbc62d20", "shasum": "" }, "require": { @@ -222,7 +222,7 @@ "issues": "https://github.com/derafu/derafu-lib-core/issues", "source": "https://github.com/derafu/derafu-lib-core" }, - "time": "2025-01-13T11:56:08+00:00" + "time": "2025-01-13T19:51:45+00:00" }, { "name": "dflydev/dot-access-data", @@ -5778,16 +5778,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.67.1", + "version": "v3.68.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "db533e9aeb19c33033b6a1b734c8de4f4ebaa7dc" + "reference": "73f78d8b2b34a0dd65fedb434a602ee4c2c8ad4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/db533e9aeb19c33033b6a1b734c8de4f4ebaa7dc", - "reference": "db533e9aeb19c33033b6a1b734c8de4f4ebaa7dc", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/73f78d8b2b34a0dd65fedb434a602ee4c2c8ad4c", + "reference": "73f78d8b2b34a0dd65fedb434a602ee4c2c8ad4c", "shasum": "" }, "require": { @@ -5869,7 +5869,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.67.1" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.68.0" }, "funding": [ { @@ -5877,7 +5877,7 @@ "type": "github" } ], - "time": "2025-01-12T12:20:47+00:00" + "time": "2025-01-13T17:01:01+00:00" }, { "name": "nikic/php-parser", diff --git a/src/Package/Billing/Component/Document/Abstract/AbstractDocument.php b/src/Package/Billing/Component/Document/Abstract/AbstractDocument.php index ae049e4..42090a6 100644 --- a/src/Package/Billing/Component/Document/Abstract/AbstractDocument.php +++ b/src/Package/Billing/Component/Document/Abstract/AbstractDocument.php @@ -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'] diff --git a/src/Package/Billing/Component/Document/Contract/DocumentBagManagerWorkerInterface.php b/src/Package/Billing/Component/Document/Contract/DocumentBagManagerWorkerInterface.php index 8c30bce..ac4afb8 100644 --- a/src/Package/Billing/Component/Document/Contract/DocumentBagManagerWorkerInterface.php +++ b/src/Package/Billing/Component/Document/Contract/DocumentBagManagerWorkerInterface.php @@ -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 diff --git a/src/Package/Billing/Component/Document/Contract/TipoDocumentoInterface.php b/src/Package/Billing/Component/Document/Contract/TipoDocumentoInterface.php index 5fdb9ce..87c0be2 100644 --- a/src/Package/Billing/Component/Document/Contract/TipoDocumentoInterface.php +++ b/src/Package/Billing/Component/Document/Contract/TipoDocumentoInterface.php @@ -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. * diff --git a/src/Package/Billing/Component/Document/Entity/AduanaClausulaVenta.php b/src/Package/Billing/Component/Document/Entity/AduanaClausulaVenta.php index 7557be5..9f21ffb 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaClausulaVenta.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaClausulaVenta.php @@ -31,4 +31,11 @@ */ class AduanaClausulaVenta extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/AduanaFormaPago.php b/src/Package/Billing/Component/Document/Entity/AduanaFormaPago.php index c6391db..5bd4865 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaFormaPago.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaFormaPago.php @@ -31,4 +31,11 @@ */ class AduanaFormaPago extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/AduanaModalidadVenta.php b/src/Package/Billing/Component/Document/Entity/AduanaModalidadVenta.php index a8403d3..06bd773 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaModalidadVenta.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaModalidadVenta.php @@ -31,4 +31,11 @@ */ class AduanaModalidadVenta extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/AduanaMoneda.php b/src/Package/Billing/Component/Document/Entity/AduanaMoneda.php index e5ff74c..51048aa 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaMoneda.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaMoneda.php @@ -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. * diff --git a/src/Package/Billing/Component/Document/Entity/AduanaPais.php b/src/Package/Billing/Component/Document/Entity/AduanaPais.php index 8b48b97..e10c490 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaPais.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaPais.php @@ -31,4 +31,11 @@ */ class AduanaPais extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/AduanaPuerto.php b/src/Package/Billing/Component/Document/Entity/AduanaPuerto.php index 26633f5..bbb86fa 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaPuerto.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaPuerto.php @@ -31,4 +31,11 @@ */ class AduanaPuerto extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/AduanaTipoBulto.php b/src/Package/Billing/Component/Document/Entity/AduanaTipoBulto.php index d14fb44..68e6e43 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaTipoBulto.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaTipoBulto.php @@ -31,4 +31,11 @@ */ class AduanaTipoBulto extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/AduanaTransporte.php b/src/Package/Billing/Component/Document/Entity/AduanaTransporte.php index 50b1c4a..9ab46a6 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaTransporte.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaTransporte.php @@ -31,4 +31,11 @@ */ class AduanaTransporte extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/AduanaUnidad.php b/src/Package/Billing/Component/Document/Entity/AduanaUnidad.php index c5d65e9..540ae5a 100644 --- a/src/Package/Billing/Component/Document/Entity/AduanaUnidad.php +++ b/src/Package/Billing/Component/Document/Entity/AduanaUnidad.php @@ -31,4 +31,11 @@ */ class AduanaUnidad extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/Comuna.php b/src/Package/Billing/Component/Document/Entity/Comuna.php index 8f6022b..10ad052 100644 --- a/src/Package/Billing/Component/Document/Entity/Comuna.php +++ b/src/Package/Billing/Component/Document/Entity/Comuna.php @@ -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. * diff --git a/src/Package/Billing/Component/Document/Entity/FormaPago.php b/src/Package/Billing/Component/Document/Entity/FormaPago.php index 11f04f9..c57c6dc 100644 --- a/src/Package/Billing/Component/Document/Entity/FormaPago.php +++ b/src/Package/Billing/Component/Document/Entity/FormaPago.php @@ -31,4 +31,11 @@ */ class FormaPago extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/FormaPagoExportacion.php b/src/Package/Billing/Component/Document/Entity/FormaPagoExportacion.php index 63c6924..8337cf5 100644 --- a/src/Package/Billing/Component/Document/Entity/FormaPagoExportacion.php +++ b/src/Package/Billing/Component/Document/Entity/FormaPagoExportacion.php @@ -31,4 +31,11 @@ */ class FormaPagoExportacion extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/ImpuestoAdicionalRetencion.php b/src/Package/Billing/Component/Document/Entity/ImpuestoAdicionalRetencion.php index 97fe15e..b6d9f84 100644 --- a/src/Package/Billing/Component/Document/Entity/ImpuestoAdicionalRetencion.php +++ b/src/Package/Billing/Component/Document/Entity/ImpuestoAdicionalRetencion.php @@ -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. * diff --git a/src/Package/Billing/Component/Document/Entity/MedioPago.php b/src/Package/Billing/Component/Document/Entity/MedioPago.php index b21770f..b18c32d 100644 --- a/src/Package/Billing/Component/Document/Entity/MedioPago.php +++ b/src/Package/Billing/Component/Document/Entity/MedioPago.php @@ -31,4 +31,11 @@ */ class MedioPago extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/Moneda.php b/src/Package/Billing/Component/Document/Entity/Moneda.php index 23ef920..7427c92 100644 --- a/src/Package/Billing/Component/Document/Entity/Moneda.php +++ b/src/Package/Billing/Component/Document/Entity/Moneda.php @@ -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 => 'zł', + self::CZK->value => 'Kč', + 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. * @@ -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]; + } } diff --git a/src/Package/Billing/Component/Document/Entity/TagXml.php b/src/Package/Billing/Component/Document/Entity/TagXml.php index 992024c..0a0d7d2 100644 --- a/src/Package/Billing/Component/Document/Entity/TagXml.php +++ b/src/Package/Billing/Component/Document/Entity/TagXml.php @@ -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'); + } } diff --git a/src/Package/Billing/Component/Document/Entity/TipoDocumento.php b/src/Package/Billing/Component/Document/Entity/TipoDocumento.php index 39e4b82..bbc555f 100644 --- a/src/Package/Billing/Component/Document/Entity/TipoDocumento.php +++ b/src/Package/Billing/Component/Document/Entity/TipoDocumento.php @@ -322,6 +322,14 @@ public function getTipoSobre(): ?TipoSobre |-------------------------------------------------------------------------- */ + /** + * {@inheritdoc} + */ + public function esGuiaDespacho(): bool + { + return (int) $this->codigo === 52; + } + /** * {@inheritdoc} */ @@ -352,6 +360,15 @@ public function esExento(): bool |-------------------------------------------------------------------------- */ + /** + * {@inheritdoc} + */ + public function requiereAcuseRecibo(): bool + { + // Boletas, notas de crédito y notas de débito no usan acuse de recibo. + return !in_array($this->codigo, [39, 41, 56, 61, 110, 111, 112]); + } + /** * {@inheritdoc} */ diff --git a/src/Package/Billing/Component/Document/Entity/Traslado.php b/src/Package/Billing/Component/Document/Entity/Traslado.php index d54b1c7..74bb9ba 100644 --- a/src/Package/Billing/Component/Document/Entity/Traslado.php +++ b/src/Package/Billing/Component/Document/Entity/Traslado.php @@ -31,4 +31,11 @@ */ class Traslado extends Entity { + /** + * {@inheritDoc} + */ + public function __toString(): string + { + return $this->getAttribute('glosa'); + } } diff --git a/src/Package/Billing/Component/Document/Service/TemplateDataHandler.php b/src/Package/Billing/Component/Document/Service/TemplateDataHandler.php index 4df4604..c58c4ac 100644 --- a/src/Package/Billing/Component/Document/Service/TemplateDataHandler.php +++ b/src/Package/Billing/Component/Document/Service/TemplateDataHandler.php @@ -25,6 +25,7 @@ namespace libredte\lib\Core\Package\Billing\Component\Document\Service; use Closure; +use Derafu\Lib\Core\Helper\Date; use Derafu\Lib\Core\Helper\Rut; use Derafu\Lib\Core\Package\Prime\Component\Entity\Contract\EntityComponentInterface; use Derafu\Lib\Core\Package\Prime\Component\Template\Contract\DataHandlerInterface; @@ -36,6 +37,8 @@ use libredte\lib\Core\Package\Billing\Component\Document\Entity\AduanaTransporte; use libredte\lib\Core\Package\Billing\Component\Document\Entity\Comuna; use libredte\lib\Core\Package\Billing\Component\Document\Entity\FormaPago; +use libredte\lib\Core\Package\Billing\Component\Document\Entity\ImpuestoAdicionalRetencion; +use libredte\lib\Core\Package\Billing\Component\Document\Entity\MedioPago; use libredte\lib\Core\Package\Billing\Component\Document\Entity\Moneda; use libredte\lib\Core\Package\Billing\Component\Document\Entity\TagXml; use libredte\lib\Core\Package\Billing\Component\Document\Entity\Traslado; @@ -163,10 +166,7 @@ private function createHandlers(): array , 'CiudadRecep' => 'alias:CiudadOrigen', // Fechas largas. - 'FchEmis' => function (string $fecha) { - $timestamp = strtotime($fecha); - return date('d/m/Y', $timestamp); // TODO: Formato largo. - }, + 'FchEmis' => fn (string $fecha) => Date::formatSpanish($fecha), 'FchRef' => 'alias:FchEmis', 'FchVenc' => 'alias:FchEmis', // Fechas cortas. @@ -175,6 +175,7 @@ private function createHandlers(): array return date('d/m/Y', $timestamp); }, 'PeriodoHasta' => 'alias:PeriodoDesde', + 'FchPago' => 'alias:PeriodoDesde', // Solo año de una fecha. 'FchResol' => fn (string $fecha) => explode('-', $fecha, 2)[0], // Datos de Aduana. @@ -197,8 +198,15 @@ private function createHandlers(): array } return ''; }, + 'TotItems' => 'alias:Number', // Otros datos que se mapean de un código a su glosa usando un // repositorio. + 'TipoImp' => $this->entityComponent->getRepository( + ImpuestoAdicionalRetencion::class + ), + 'MedioPago' => $this->entityComponent->getRepository( + MedioPago::class + ), 'FmaPago' => $this->entityComponent->getRepository( FormaPago::class ), diff --git a/src/Package/Billing/Component/Document/Worker/DocumentBagManagerWorker.php b/src/Package/Billing/Component/Document/Worker/DocumentBagManagerWorker.php index 00df5bf..9e8df79 100644 --- a/src/Package/Billing/Component/Document/Worker/DocumentBagManagerWorker.php +++ b/src/Package/Billing/Component/Document/Worker/DocumentBagManagerWorker.php @@ -74,6 +74,7 @@ public function create( $bag = new $class(); // Si los datos vienen como string se deben parsear para asignar. + // Además se normalizarán. if (is_string($source)) { $aux = explode(':', $source, 1); $parserStrategy = str_replace('parser.strategy.', '', $aux[0]); @@ -85,20 +86,20 @@ public function create( $parser->parse($bag); } - // Si los datos vienen como arreglo son los datos parseados. + // Si los datos vienen como arreglo son los datos normalizados. if (is_array($source)) { - $bag->setParsedData($source); + $bag->setNormalizedData($source); } // Si los datos vienen como documento XML es un XML cargado desde un - // string XML (carga realizada por LoaderWorker). + // string XML (carga realizada por LoaderWorker). Ya viene normalizado. if ($source instanceof XmlInterface) { $bag->setXmlDocument($source); } // Si los datos vienen como documento tributario entonces es un // documento que ya está creado. Puede estar o no timbrado y firmado, - // eso no se determina ni valida acá. + // eso no se determina ni valida acá. Si debe estará normalizado. if ($source instanceof DocumentInterface) { $bag->setDocument($source); } diff --git a/src/Package/Billing/Component/TradingParties/Contract/EmisorInterface.php b/src/Package/Billing/Component/TradingParties/Contract/EmisorInterface.php index 2a469a3..13d95b5 100644 --- a/src/Package/Billing/Component/TradingParties/Contract/EmisorInterface.php +++ b/src/Package/Billing/Component/TradingParties/Contract/EmisorInterface.php @@ -29,4 +29,18 @@ */ interface EmisorInterface extends ContribuyenteInterface, AutorizacionDteInfoInterface, CorreoIntercambioDteInfoInterface { + /** + * Asigna los datos del logo del emisor. + * + * @param string $logo + * @return static + */ + public function setLogo(string $logo): static; + + /** + * Obtiene los datos del logo del emisor. + * + * @return string|null + */ + public function getLogo(): ?string; } diff --git a/src/Package/Billing/Component/TradingParties/Entity/Emisor.php b/src/Package/Billing/Component/TradingParties/Entity/Emisor.php index f371450..483faea 100644 --- a/src/Package/Billing/Component/TradingParties/Entity/Emisor.php +++ b/src/Package/Billing/Component/TradingParties/Entity/Emisor.php @@ -46,6 +46,13 @@ class Emisor extends Contribuyente implements EmisorInterface */ private ?AutorizacionDteInterface $autorizacionDte = null; + /** + * Logo del emisor. + * + * @var string|null + */ + private ?string $logo = null; + /** * {@inheritdoc} */ @@ -63,4 +70,22 @@ public function getAutorizacionDte(): ?AutorizacionDteInterface { return $this->autorizacionDte; } + + /** + * {@inheritdoc} + */ + public function setLogo(string $logo): static + { + $this->logo = $logo; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getLogo(): ?string + { + return $this->logo; + } }