Skip to content

Commit

Permalink
exclude null information (Retention, Perception)
Browse files Browse the repository at this point in the history
  • Loading branch information
giansalex committed Feb 2, 2018
1 parent 4e73e5b commit 96fc01b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/Greenter/Parser/PerceptionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ private function getDetails()
->setNumDoc($temp->nodeValue)
->setFechaEmision(new \DateTime($xml->getValue('cbc:IssueDate', $node)))
->setImpTotal(floatval($mount->nodeValue))
->setMoneda($mount->getAttribute('currencyID'));
->setMoneda($mount->getAttribute('currencyID'))
->setCobros(iterator_to_array($this->getPayments($node)));

$temp = $xml->getNode('sac:SUNATPerceptionInformation', $node);
if (empty($temp)) {
$det->setImpPercibido(0)
->setImpCobrar(0)
->setFechaPercepcion(new \DateTime());

yield $det;
}

$det
->setCobros(iterator_to_array($this->getPayments($node)))
->setImpPercibido(floatval($xml->getValue('sac:SUNATPerceptionAmount', $temp)))
->setFechaPercepcion(new \DateTime($xml->getValue('sac:SUNATPerceptionDate', $temp)))
->setImpCobrar(floatval($xml->getValue('sac:SUNATNetTotalCashed', $temp)));
Expand Down
12 changes: 10 additions & 2 deletions src/Greenter/Parser/RetentionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,19 @@ private function getDetails()
->setNumDoc($temp->nodeValue)
->setFechaEmision(new \DateTime($xml->getValue('cbc:IssueDate', $node)))
->setImpTotal(floatval($mount->nodeValue))
->setMoneda($mount->getAttribute('currencyID'));
->setMoneda($mount->getAttribute('currencyID'))
->setPagos(iterator_to_array($this->getPayments($node)));

$temp = $xml->getNode('sac:SUNATRetentionInformation', $node);
if (empty($temp)) {
$det->setImpRetenido(0)
->setImpPagar(0)
->setFechaRetencion(new \DateTime());

yield $det;
}

$det
->setPagos(iterator_to_array($this->getPayments($node)))
->setImpRetenido(floatval($xml->getValue('sac:SUNATRetentionAmount', $temp)))
->setFechaRetencion(new \DateTime($xml->getValue('sac:SUNATRetentionDate', $temp)))
->setImpPagar(floatval($xml->getValue('sac:SUNATNetTotalPaid', $temp)));
Expand Down

0 comments on commit 96fc01b

Please sign in to comment.