3namespace Noalyss\XMLDocument;
55 parent::__construct($domDocument);
66 $dm = new \DOMDocument();
67 if ($dm->loadXML(
$string) !=
false)
72 throw new \Exception(
"XR55: not a valid XML",55);
83 if (!file_exists($filename))
85 throw new \Exception(
"XR62: file not found $filename", 62);
87 $dm = new \DOMDocument();
88 if ($dm->load($filename) !=
false)
93 throw new \Exception(
"XR55: not a valid XML", 55);
102 $node = $this->get_node(
"//cac:InvoiceLine");
107 throw new \Exception (
"XR143 unknow document",143);
109 for (
$e = 0;
$e < $node->length;
$e++)
112 $row [
'quantity'] = $this->get_node_value(
"//cbc:InvoicedQuantity",
$e);
113 $row [
'amount'] = $this->get_node_value(
"//cbc:LineExtensionAmount",
$e);
114 $row [
'description'] = $this->get_node_value(
"//cac:Item/cbc:Description",
$e);
115 $row [
'name'] = $this->get_node_value(
"//cac:InvoiceLine/cac:Item/cbc:Name",
$e);
116 $row [
'unit_price'] = $this->get_node_value(
"//cac:InvoiceLine/cac:Price/cbc:PriceAmount",
$e);
117 $row [
'tva_id'] = $this->get_node_value(
"//cac:InvoiceLine/cac:Item/cac:ClassifiedTaxCategory/cbc:ID",
$e);
118 $row [
'tva_percent'] = $this->get_node_value(
"//cac:InvoiceLine/cac:Item/cac:ClassifiedTaxCategory/cbc:Percent",
$e);
130 return "invoice ".$this->get_node_value(
'cbc:InvoiceTypeCode');
141 "cac"=>
'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2'
142 ,
"cbc"=>
'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2'
143 ,
"ns4"=>
'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'
155 $node = $this->get_node(
"//cac:TaxTotal/cac:TaxSubtotal");
157 for (
$e = 0;
$e < $node->length;
$e++)
160 $xml = simplexml_import_dom($node->item(
$e));
162 $this->registerNS(
$xml);
164 $row [
'taxable_amount'] =
$xml->xpath(
"//cbc:TaxableAmount")[
$e] .
"";
165 $row [
'tax'] =
$xml->xpath(
"//cbc:TaxAmount")[
$e] .
"";
166 $row [
'tax_id'] =
$xml->xpath(
"//cac:TaxCategory/cbc:ID")[
$e] .
"";
167 $row [
'tax_percent'] =
$xml->xpath(
"//cac:TaxCategory/cbc:Percent")[
$e] .
"";
168 if (isset(
$xml->xpath(
"//cac:InvoiceLine/cac:Item/cbc:Name")[
$e]))
170 $row [
'name'] =
$xml->xpath(
"//cac:InvoiceLine/cac:Item/cbc:Name")[
$e].
"";
174 if ( isset (
$xml->xpath(
"//cbc:TaxExemptionReasonCode")[
$e]))
176 $row[
'vatex']=
$xml->xpath(
"//cbc:TaxExemptionReasonCode")[
$e];
Get information from an XML Exception code :
get_invoiceLine()
retrieve InvoiceLines
get_document_type_code()
return the code of the document
static build_from_string($string)
Build an XMLInvoice_Reader object from an XML string.
static build_from_file($filename)
Build an XMLInvoice_Reader object from an XML file.
get_taxes()
get the Taxes info from XML
__construct(\DOMDocument $domDocument)
get_namespace()
before executing xpath->query the namespace must be registered the NS are different for each type of ...