Skip to content

Commit

Permalink
Revisión código de parser form.estandar. Se ajustó test con asignació…
Browse files Browse the repository at this point in the history
…n de folio. Se crearon proveedores para los datos del emisor y del receptor. Se agregaron las fixtures para el test de form.estandar.
  • Loading branch information
estebandelaf committed Jan 21, 2025
1 parent 5bd0ed5 commit 9eafeff
Show file tree
Hide file tree
Showing 89 changed files with 4,763 additions and 537 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
/tests/fixtures/caf/*.xml
/tests/fixtures/emision_masiva/*.xml
/tests/fixtures/emision_masiva/*.pdf
/tests/fixtures/parsers/*/*/*.json.xml
/tests/fixtures/parsers/*/*/*.xml.xml
/tests/fixtures/parsers/*/*/*.yaml.xml
/tests/fixtures/parsers/*/*/*.pdf
/tests/fixtures/xml/upload/*.xml
/tests/fixtures/yaml/documentos_ok/*/*.xml
/tests/fixtures/yaml/documentos_ok/*/*.html
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

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

6 changes: 6 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ services:
class: libredte\lib\Core\Package\Billing\Component\Identifier\Worker\CafLoaderWorker
arguments:
$emisorFactory: '@libredte\lib\Core\Package\Billing\Component\TradingParties\Contract\EmisorFactoryInterface'
libredte\lib\Core\Package\Billing\Component\Identifier\Contract\CafProviderWorkerInterface:
class: libredte\lib\Core\Package\Billing\Component\Identifier\Worker\CafProviderWorker
libredte\lib\Core\Package\Billing\Component\Identifier\Contract\CafValidatorWorkerInterface:
class: libredte\lib\Core\Package\Billing\Component\Identifier\Worker\CafValidatorWorker

Expand Down Expand Up @@ -98,6 +100,10 @@ services:
class: libredte\lib\Core\Package\Billing\Component\TradingParties\Factory\ReceptorFactory
libredte\lib\Core\Package\Billing\Component\TradingParties\Contract\MandatarioFactoryInterface:
class: libredte\lib\Core\Package\Billing\Component\TradingParties\Factory\MandatarioFactory
libredte\lib\Core\Package\Billing\Component\TradingParties\Contract\EmisorProviderInterface:
class: libredte\lib\Core\Package\Billing\Component\TradingParties\Service\FakeEmisorProvider
libredte\lib\Core\Package\Billing\Component\TradingParties\Contract\ReceptorProviderInterface:
class: libredte\lib\Core\Package\Billing\Component\TradingParties\Service\FakeReceptorProvider

# Servicios del componente "billing.document".
libredte\lib\Core\Package\Billing\Component\Document\Contract\TipoDocumentoFactoryInterface:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function create(XmlInterface $xmlDocument): DocumentInterface
{
Expand All @@ -72,7 +72,7 @@ public function create(XmlInterface $xmlDocument): DocumentInterface
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function build(DocumentBagInterface $bag): DocumentInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getXml(): string
public function getId(): string
{
return sprintf(
'%sT%03dF%09d',
'%s_T%03dF%09d',
$this->getRutEmisor(),
$this->getCodigo(),
$this->getFolio()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class AbstractNormalizerStrategy extends AbstractStrategy implements No
protected NormalizeDataPostDocumentNormalizationJob $normalizeDataPostDocumentNormalizationJob;

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function normalize(DocumentBagInterface $bag): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
abstract class AbstractValidatorStrategy extends AbstractStrategy implements ValidatorStrategyInterface
{
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function validate(DocumentBagInterface $bag): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public function getDefaultTasaIVA(): float|false
{
$TasaIVA = 19;

return !in_array($this->codigo, [41, 110, 111, 112]) ? $TasaIVA : false;
return !in_array($this->codigo, [34, 41, 110, 111, 112]) ? $TasaIVA : false;
}

/**
Expand Down
19 changes: 12 additions & 7 deletions src/Package/Billing/Component/Document/Support/DocumentBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -656,21 +656,26 @@ public function setFolio(int $folio): static
);
}

$data = $this->getNormalizedData() ?? $this->getParsedData();
$parsedData = $this->getParsedData();
$normalizedData = $this->getNormalizedData();

if ($data === null) {
if ($parsedData === null && $normalizedData === null) {
throw new LogicException(
'No es posible asignar el folio si no existen datos normalizados o parseados.'
'No es posible asignar el folio si no existen datos parseados o normalizados.'
);
}

$data['Encabezado']['IdDoc']['Folio'] = $folio;
if ($parsedData !== null) {
$parsedData['Encabezado']['IdDoc']['Folio'] = $folio;
$this->setParsedData($parsedData);
}

if ($this->getNormalizedData()) {
return $this->setNormalizedData($data);
if ($normalizedData !== null) {
$normalizedData['Encabezado']['IdDoc']['Folio'] = $folio;
$this->setNormalizedData($normalizedData);
}

return $this->setParsedData($data);
return $this;
}

/**
Expand Down
Loading

0 comments on commit 9eafeff

Please sign in to comment.